[Polyfills] Rewrite

main
Oj 2 years ago
parent 9ce5e8c443
commit 6cfa808f7f

@ -21,18 +21,12 @@ jobs:
- name: NPM Install
run: cd src; npm i; cd ..
- name: Install Asar
run: npm i -g asar
- name: Pack Asar
run: npx asar pack src openasar.asar
- name: Make Deps Asar
- name: Pack
run: |
cd src
npm install request
cd ..
npx asar pack src openasar-with-deps.asar
npm i -g asar
node injectPolyfills.js
rm -rf src/package-lock.json src/node_modules/.package-lock.json src/splash/splashScreen.js.self
npx asar pack src openasar.asar
- name: GitHub Release
uses: ncipollo/release-action@v1
@ -40,7 +34,7 @@ jobs:
tag: "nightly"
allowUpdates: true
prerelease: true
artifacts: "openasar.asar,openasar-with-deps.asar"
artifacts: "openasar.asar"
name: "Nightly"

@ -0,0 +1,16 @@
const { readdirSync, mkdirSync, copyFileSync } = require('fs');
const { join } = require('path');
const polyfillsDir = join(__dirname, 'polyfills');
for (const file of readdirSync(polyfillsDir)) {
const [ name ] = file.split('.');
const jsPath = join(polyfillsDir, file);
const moduleDir = join(__dirname, 'src', 'node_modules', name);
try {
mkdirSync(moduleDir);
} catch (e) {}
copyFileSync(jsPath, join(moduleDir, 'index.js'));
}

@ -8,7 +8,7 @@ const nodeReq = ({ method, url, headers, qs, timeout, body, stream }) => {
const req = https.request(fullUrl, {
method,
headers,
timeout: timeout != null ? timeout : DEFAULT_REQUEST_TIMEOUT
timeout
}, async (res) => {
if (res.statusCode === 301 || res.statusCode === 302) { // Redirect, recall function
return resolve(await nodeReq({
@ -38,13 +38,13 @@ module.exports = (options, callback) => {
};
}
log('Polyfill > Request', options.method, options.url);
// log('Polyfill > Request', options.method, options.url);
const listener = {};
nodeReq(options).then((res) => { // No error handling because yes
if (callback) callback(undefined, res, res.body);
listener['response'](res);
if (listener['response']) listener['response'](res);
});
return {

@ -4,13 +4,6 @@ global.oaVersion = '0.2';
log('Init', 'OpenAsar v' + oaVersion);
const NodeModule = require('module');
const { join } = require('path');
NodeModule.globalPaths.push(join(__dirname, 'polyfills'));
log('Polyfills', 'Set up polyfills usage');
const appSettings = require('./appSettings');
global.oaConfig = appSettings.getSettings().get('openasar', {});

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

Loading…
Cancel
Save