poly: remove completely

polynt
CanadaHonk 2 years ago
parent 7a04cb57df
commit 4305ead341

@ -6,7 +6,6 @@ on:
paths:
- 'src/**'
- 'scripts/**'
- 'poly/**'
- '.github/workflows/**'
jobs:
@ -25,7 +24,6 @@ jobs:
- name: Pack base asar
run: |
npm i -g asar
bash scripts/injectPolyfills.sh
sed -i -e "s/nightly/nightly-$(git rev-parse HEAD | cut -c 1-7)/" src/index.js
node scripts/strip.js
npx asar pack src app.asar

@ -22,7 +22,7 @@ OpenAsar optimizes Chromium (the web engine / browser Discord uses) to help incr
The main speed increase (default options) is mostly accidental / coincidental (not intended) as it is mostly a side effect of rewriting it.
### How is this so small?
Compared to Discord's original, OpenAsar is <2% of the size. This is because when rewriting we remove NPM dependencies with our own custom code for more performance and efficiency. These are replaced with custom polyfills (compatible replacements).
Compared to Discord's original, OpenAsar is <2% of the size. This is because when rewriting we remove NPM dependencies with our own custom code for more performance and efficiency.
### What is Quickstart?
Quickstart "skips" a few Discord features like the splash screen and waiting for updates in favour of speed. It is currently experimental and not fully recommended for normal use.

@ -1,2 +0,0 @@
// Stub
exports.lookup = (file) => 'text/plain';

@ -1,84 +0,0 @@
const https = require('https');
// Generic polyfill for "request" npm package, wrapper for https
const nodeReq = ({ method, url, headers, qs, timeout, body }) => new Promise((resolve) => {
let req;
try {
req = https.request(url + (qs != null ? `?${(new URLSearchParams(qs)).toString()}` : ''), { method, headers, timeout }, async (res) => {
const loc = res.headers.location;
if (loc) return resolve(await nodeReq({ url: loc, method, headers, timeout, body }));
resolve(res);
});
} catch (e) {
return resolve(e);
}
req.on('error', resolve);
if (body) req.write(body); // Write POST body if included
req.end();
});
const request = (...args) => {
let options, callback;
switch (args.length) {
case 3: // request(url, options, callback)
options = {
url: args[0],
...args[1]
};
callback = args[2];
break;
default: // request(url, callback) / request(options, callback)
options = args[0];
callback = args[1];
}
if (typeof options === 'string') {
options = {
url: options
};
}
const listeners = {};
nodeReq(options).then(async (res) => {
if (!res.statusCode) {
listeners['error']?.(res);
return callback?.(res, null, null);
}
listeners['response']?.(res);
let data = [];
res.on('data', (chunk) => {
data.push(chunk);
listeners['data']?.(chunk);
});
await new Promise((resolve) => res.on('end', resolve)); // Wait to read full body
const buf = Buffer.concat(data);
callback?.(undefined, res, options.encoding !== null ? buf.toString() : buf);
});
const ret = {
on: (type, handler) => {
listeners[type] = handler;
return ret; // Return self
}
};
return ret;
};
for (const m of [ 'get', 'post', 'put', 'patch', 'delete', 'head', 'options' ]) {
request[m] = (url, callback) => request({ url, method: m }, callback);
}
request.del = request.delete; // Special case
module.exports = request;

@ -1,3 +0,0 @@
rm -rf src/node_modules
mkdir src/node_modules
cp -rf poly/* src/node_modules

@ -1,7 +1,6 @@
#!/bin/sh
echo "Packing asar..."
./scripts/injectPolyfills.sh
asar pack src app.asar # Package asar
# asar list app.asar # List asar for debugging / testing

Loading…
Cancel
Save