beep boop
This commit is contained in:
6
.gitignore
vendored
6
.gitignore
vendored
@@ -1,7 +1,9 @@
|
|||||||
node_modules
|
node_modules
|
||||||
dist
|
dist
|
||||||
entry-asar/*.js*
|
entry-asar/cjs/*.?js*
|
||||||
entry-asar/*.ts
|
entry-asar/cjs/*.d.?ts
|
||||||
|
entry-asar/esm/*.?js*
|
||||||
|
entry-asar/esm/*.d.?ts
|
||||||
*.app
|
*.app
|
||||||
test/fixtures/apps
|
test/fixtures/apps
|
||||||
coverage
|
coverage
|
||||||
11
entry-asar/cjs/tsconfig.json
Normal file
11
entry-asar/cjs/tsconfig.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"extends": "../../tsconfig.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"outDir": ".",
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
".",
|
||||||
|
"../ambient.d.ts"
|
||||||
|
],
|
||||||
|
"exclude": []
|
||||||
|
}
|
||||||
28
entry-asar/esm/has-asar.mts
Normal file
28
entry-asar/esm/has-asar.mts
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
import { app } from 'electron';
|
||||||
|
import { createRequire } from 'node:module';
|
||||||
|
import path from 'node:path';
|
||||||
|
|
||||||
|
if (process.arch === 'arm64') {
|
||||||
|
await setPaths('arm64');
|
||||||
|
} else {
|
||||||
|
await setPaths('x64');
|
||||||
|
}
|
||||||
|
|
||||||
|
async function setPaths(platform: string) {
|
||||||
|
// This should return the full path, ending in something like
|
||||||
|
// Notion.app/Contents/Resources/app.asar
|
||||||
|
const appPath = app.getAppPath();
|
||||||
|
const asarFile = `app-${platform}.asar`;
|
||||||
|
|
||||||
|
// Maybe we'll handle this in Electron one day
|
||||||
|
if (path.basename(appPath) === 'app.asar') {
|
||||||
|
const platformAppPath = path.join(path.dirname(appPath), asarFile);
|
||||||
|
|
||||||
|
// This is an undocumented API. It exists.
|
||||||
|
app.setAppPath(platformAppPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
const require = createRequire(import.meta.url);
|
||||||
|
process._archPath = require.resolve(`../${asarFile}`);
|
||||||
|
await import(process._archPath);
|
||||||
|
}
|
||||||
13
entry-asar/esm/tsconfig.json
Normal file
13
entry-asar/esm/tsconfig.json
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"extends": "../../tsconfig.esm.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"module": "ESNext",
|
||||||
|
"target":"ESNext",
|
||||||
|
"outDir": ".",
|
||||||
|
},
|
||||||
|
"include": [
|
||||||
|
".",
|
||||||
|
"../ambient.d.ts"
|
||||||
|
],
|
||||||
|
"exclude": []
|
||||||
|
}
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
],
|
],
|
||||||
"author": "Samuel Attard",
|
"author": "Samuel Attard",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json && tsc -p tsconfig.entry-asar.json",
|
"build": "tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json && tsc -p tsconfig.entry-asar.json && tsc -p tsconfig.entry-asar.esm.json",
|
||||||
"lint": "prettier --check \"{src,entry-asar,test}/**/*.ts\" \"*.ts\"",
|
"lint": "prettier --check \"{src,entry-asar,test}/**/*.ts\" \"*.ts\"",
|
||||||
"prettier:write": "prettier --write \"{src,entry-asar,test}/**/*.ts\" \"*.ts\"",
|
"prettier:write": "prettier --write \"{src,entry-asar,test}/**/*.ts\" \"*.ts\"",
|
||||||
"prepublishOnly": "npm run build",
|
"prepublishOnly": "npm run build",
|
||||||
|
|||||||
20
src/index.ts
20
src/index.ts
@@ -290,10 +290,6 @@ export const makeUniversalApp = async (opts: MakeUniversalOpts): Promise<void> =
|
|||||||
|
|
||||||
const entryAsar = path.resolve(tmpDir, 'entry-asar');
|
const entryAsar = path.resolve(tmpDir, 'entry-asar');
|
||||||
await fs.mkdir(entryAsar);
|
await fs.mkdir(entryAsar);
|
||||||
await fs.copy(
|
|
||||||
path.resolve(__dirname, '..', '..', 'entry-asar', 'has-asar.js'),
|
|
||||||
path.resolve(entryAsar, 'index.js'),
|
|
||||||
);
|
|
||||||
let pj = JSON.parse(
|
let pj = JSON.parse(
|
||||||
(
|
(
|
||||||
await asar.extractFile(
|
await asar.extractFile(
|
||||||
@@ -302,7 +298,23 @@ export const makeUniversalApp = async (opts: MakeUniversalOpts): Promise<void> =
|
|||||||
)
|
)
|
||||||
).toString('utf8'),
|
).toString('utf8'),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (pj.type === 'module') {
|
||||||
|
d('ERICK TEST!!!!');
|
||||||
|
await fs.copy(
|
||||||
|
path.resolve(__dirname, '..', '..', 'entry-asar', 'esm', 'has-asar.mjs'),
|
||||||
|
path.resolve(entryAsar, 'index.mjs'),
|
||||||
|
);
|
||||||
|
pj.main = 'index.mjs';
|
||||||
|
} else {
|
||||||
|
await fs.copy(
|
||||||
|
path.resolve(__dirname, '..', '..', 'entry-asar', 'has-asar.js'),
|
||||||
|
path.resolve(entryAsar, 'index.js'),
|
||||||
|
);
|
||||||
pj.main = 'index.js';
|
pj.main = 'index.js';
|
||||||
|
}
|
||||||
|
d(JSON.stringify(pj, null, 2));
|
||||||
|
|
||||||
await fs.writeJson(path.resolve(entryAsar, 'package.json'), pj);
|
await fs.writeJson(path.resolve(entryAsar, 'package.json'), pj);
|
||||||
const asarPath = path.resolve(tmpApp, 'Contents', 'Resources', 'app.asar');
|
const asarPath = path.resolve(tmpApp, 'Contents', 'Resources', 'app.asar');
|
||||||
await asar.createPackage(entryAsar, asarPath);
|
await asar.createPackage(entryAsar, asarPath);
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": "./tsconfig.json",
|
|
||||||
"compilerOptions": {
|
|
||||||
"outDir": "entry-asar",
|
|
||||||
},
|
|
||||||
"include": [
|
|
||||||
"entry-asar"
|
|
||||||
],
|
|
||||||
"exclude": []
|
|
||||||
}
|
|
||||||
@@ -17,7 +17,6 @@
|
|||||||
"declaration": true
|
"declaration": true
|
||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"src",
|
"src"
|
||||||
"entry-asar"
|
],
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user