@stlite/desktop 0.16.1 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/dump_artifacts.js +21 -22
- package/build/electron/main.js +20 -1
- package/build/electron/main.js.map +1 -1
- package/build/index.html +1 -1
- package/package.json +4 -4
package/bin/dump_artifacts.js
CHANGED
|
@@ -24,16 +24,20 @@ async function copyBuildDirectory(options) {
|
|
|
24
24
|
console.warn(`sourceDir == destDir (${sourceDir}). Are you in the development environment? Skip copying the directory.`);
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
|
-
if (
|
|
27
|
+
if (options.keepOld) {
|
|
28
28
|
try {
|
|
29
29
|
await promises_1.default.access(options.copyTo);
|
|
30
|
-
console.info(`${options.copyTo} already exists.
|
|
30
|
+
console.info(`${options.copyTo} already exists. Use it and skip copying.`);
|
|
31
31
|
return;
|
|
32
32
|
}
|
|
33
|
-
catch {
|
|
33
|
+
catch {
|
|
34
|
+
// If the destination directory does not exist
|
|
35
|
+
throw new Error(`${options.copyTo} does not exist even though the \`keepOld\` option is specified`);
|
|
36
|
+
}
|
|
34
37
|
}
|
|
35
38
|
console.log(`Copy ${sourceDir} to ${options.copyTo}`);
|
|
36
|
-
|
|
39
|
+
await promises_1.default.rm(options.copyTo, { recursive: true, force: true });
|
|
40
|
+
await fs_extra_1.default.copy(sourceDir, options.copyTo);
|
|
37
41
|
}
|
|
38
42
|
async function installLocalWheel(pyodide, localPath) {
|
|
39
43
|
console.log(`Install the local wheel ${localPath}`);
|
|
@@ -90,24 +94,19 @@ async function createSitePackagesSnapshot(options) {
|
|
|
90
94
|
async function copyStreamlitAppDirectory(options) {
|
|
91
95
|
console.info("Copy the Streamlit app directory...");
|
|
92
96
|
console.log(`Copy ${options.sourceDir} to ${options.copyTo}`);
|
|
93
|
-
|
|
97
|
+
await promises_1.default.rm(options.copyTo, { recursive: true, force: true });
|
|
98
|
+
await fs_extra_1.default.copy(options.sourceDir, options.copyTo);
|
|
94
99
|
}
|
|
95
100
|
// Original: packages/sharing-editor/bin/gen-sample-app-manifests-json.ts
|
|
96
101
|
// TODO: Be DRY
|
|
97
102
|
async function readRequirements(requirementsTxtPath) {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
.filter((r) => r !== "");
|
|
106
|
-
}
|
|
107
|
-
catch {
|
|
108
|
-
console.log(`Failed to read ${requirementsTxtPath}. Use [] as the requirements.`);
|
|
109
|
-
return [];
|
|
110
|
-
}
|
|
103
|
+
const requirementsTxtData = await promises_1.default.readFile(requirementsTxtPath, {
|
|
104
|
+
encoding: "utf-8",
|
|
105
|
+
});
|
|
106
|
+
return requirementsTxtData
|
|
107
|
+
.split("\n")
|
|
108
|
+
.map((r) => r.trim())
|
|
109
|
+
.filter((r) => r !== "");
|
|
111
110
|
}
|
|
112
111
|
// Original: kernel/src/requirements.ts
|
|
113
112
|
// TODO: Be DRY
|
|
@@ -154,11 +153,11 @@ function verifyRequirements(requirements) {
|
|
|
154
153
|
alias: "l",
|
|
155
154
|
default: false,
|
|
156
155
|
})
|
|
157
|
-
.options("
|
|
156
|
+
.options("keepOldBuild", {
|
|
158
157
|
type: "boolean",
|
|
159
158
|
default: false,
|
|
160
|
-
alias: "
|
|
161
|
-
describe: "
|
|
159
|
+
alias: "k",
|
|
160
|
+
describe: "Keep the existing build directory contents except appHomeDir.",
|
|
162
161
|
})
|
|
163
162
|
.parseAsync()
|
|
164
163
|
.then(async (args) => {
|
|
@@ -174,7 +173,7 @@ function verifyRequirements(requirements) {
|
|
|
174
173
|
requirements = requirements.concat(await readRequirements(requirementTxtFilePath));
|
|
175
174
|
}
|
|
176
175
|
verifyRequirements(requirements);
|
|
177
|
-
await copyBuildDirectory({ copyTo: destDir,
|
|
176
|
+
await copyBuildDirectory({ copyTo: destDir, keepOld: args.keepOldBuild });
|
|
178
177
|
await createSitePackagesSnapshot({
|
|
179
178
|
useLocalKernelWheels: args.localKernelWheels,
|
|
180
179
|
requirements: requirements,
|
package/build/electron/main.js
CHANGED
|
@@ -30,7 +30,11 @@ const createWindow = () => {
|
|
|
30
30
|
return (0, file_1.walkRead)(streamlitAppDir);
|
|
31
31
|
});
|
|
32
32
|
if (electron_1.app.isPackaged || process.env.NODE_ENV === "production") {
|
|
33
|
-
|
|
33
|
+
// Use .loadURL() with an absolute URL based on "/" instead of .loadFile()
|
|
34
|
+
// because absolute URLs with the file:// scheme will be resolved
|
|
35
|
+
// to absolute file paths based on the special handler
|
|
36
|
+
// registered through `interceptFileProtocol` below.
|
|
37
|
+
mainWindow.loadURL("file:///index.html");
|
|
34
38
|
}
|
|
35
39
|
else {
|
|
36
40
|
mainWindow.loadURL("http://localhost:3000");
|
|
@@ -43,6 +47,21 @@ const createWindow = () => {
|
|
|
43
47
|
// initialization and is ready to create browser windows.
|
|
44
48
|
// Some APIs can only be used after this event occurs.
|
|
45
49
|
electron_1.app.whenReady().then(() => {
|
|
50
|
+
// Resolve absolute paths based on the bundled directory.
|
|
51
|
+
// It is assumed that the resource paths are absolute paths starting with "/",
|
|
52
|
+
// which is configured at `package.json` with the `"homepage"` field.
|
|
53
|
+
// Ref: https://github.com/electron/electron/issues/4612#issuecomment-189116655
|
|
54
|
+
const bundleBasePath = path.resolve(__dirname, "..");
|
|
55
|
+
electron_1.protocol.interceptFileProtocol("file", function (req, callback) {
|
|
56
|
+
const urlWithoutScheme = req.url.slice(7); // 7 = "file://".length
|
|
57
|
+
if (path.isAbsolute(urlWithoutScheme)) {
|
|
58
|
+
const resolvedFilePath = path.join(bundleBasePath, urlWithoutScheme);
|
|
59
|
+
callback(path.normalize(resolvedFilePath));
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
callback(urlWithoutScheme);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
46
65
|
createWindow();
|
|
47
66
|
electron_1.app.on("activate", () => {
|
|
48
67
|
// On macOS it's common to re-create a window in the app when the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../electron/main.ts"],"names":[],"mappings":";;AAAA,
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../electron/main.ts"],"names":[],"mappings":";;AAAA,uCAAiE;AACjE,6BAA6B;AAC7B,0CAA0C;AAC1C,iCAAkC;AAElC,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,EAAE;IAC1C,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;IAC9C,OAAO,CAAC,iBAAiB,CAAC,CAAC,SAAS,EAAE;QACpC,QAAQ,EAAE,IAAI,CAAC,OAAO,CACpB,SAAS,EACT,OAAO,CAAC,QAAQ,KAAK,OAAO;YAC1B,CAAC,CAAC,+CAA+C;YACjD,CAAC,CAAC,kCAAkC,CACvC;KACF,CAAC,CAAC;CACJ;AAED,MAAM,YAAY,GAAG,GAAG,EAAE;IACxB,MAAM,UAAU,GAAG,IAAI,wBAAa,CAAC;QACnC,KAAK,EAAE,IAAI;QACX,MAAM,EAAE,GAAG;QACX,cAAc,EAAE;YACd,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC;SAC5C;KACF,CAAC,CAAC;IAEH,kBAAO,CAAC,MAAM,CAAC,0BAA0B,EAAE,CAAC,EAAE,EAAE,EAAE;QAChD,gEAAgE;QAChE,MAAM,eAAe,GAAG,IAAI,CAAC,OAAO,CAClC,SAAS,EACT,kCAAkC,CACnC,CAAC;QACF,OAAO,UAAU,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;IACH,kBAAO,CAAC,MAAM,CACZ,2BAA2B,EAC3B,KAAK,EAAE,EAAE,EAAmC,EAAE;QAC5C,MAAM,eAAe,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,kBAAkB,CAAC,CAAC;QACpE,OAAO,IAAA,eAAQ,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;QAC5D,IAAI,wBAAa,CAAC,aAAa,EAAE,CAAC,MAAM,KAAK,CAAC;YAAE,YAAY,EAAE,CAAC;IACjE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,wEAAwE;AACxE,0EAA0E;AAC1E,2BAA2B;AAC3B,cAAG,CAAC,EAAE,CAAC,mBAAmB,EAAE,GAAG,EAAE;IAC/B,IAAI,OAAO,CAAC,QAAQ,KAAK,QAAQ;QAAE,cAAG,CAAC,IAAI,EAAE,CAAC;AAChD,CAAC,CAAC,CAAC"}
|
package/build/index.html
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><title>stlite</title><meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src '
|
|
1
|
+
<!doctype html><html lang="en"><head><meta charset="utf-8"/><meta name="viewport" content="width=device-width,initial-scale=1"/><title>stlite</title><meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'wasm-unsafe-eval'; style-src 'self' 'unsafe-inline'; worker-src blob:; script-src-elem 'self' 'unsafe-inline' *; style-src-elem 'self' 'unsafe-inline' *; font-src 'self' data:; connect-src https://data.streamlit.io/ https://*.mapbox.com/ 'self' *; img-src * blob: data:; media-src * blob:; frame-src *"><link href="./static/css/6.bcb29708.chunk.css" rel="stylesheet"><link href="./static/css/main.978bf258.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script src="./static/js/runtime-main.42b31020.js"></script><script src="./static/js/6.ac18380a.chunk.js"></script><script src="./static/js/main.d0a5f08f.chunk.js"></script></body></html>
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stlite/desktop",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
|
-
"homepage": "
|
|
5
|
+
"homepage": "/",
|
|
6
6
|
"main": "./build/electron/main.js",
|
|
7
7
|
"files": [
|
|
8
8
|
"build",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"start": "concurrently \"cross-env BROWSER=none yarn start:web\" \"wait-on http://localhost:3000 && yarn start:electron\" \"wait-on http://localhost:3000 && tsc -p electron && cross-env NODE_ENV=\"development\" electron .\"",
|
|
26
26
|
"build:app": "yarn build:web && yarn build:electron && yarn build:pyodide",
|
|
27
27
|
"build": "yarn build:app && yarn build:bin",
|
|
28
|
-
"serve": "NODE_ENV
|
|
28
|
+
"serve": "cross-env NODE_ENV=production electron .",
|
|
29
29
|
"pack": "electron-builder --dir",
|
|
30
30
|
"dist": "electron-builder",
|
|
31
31
|
"fix:eslint": "eslint --fix '{src,electron,bin}/**/*.{ts,tsx}'",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@craco/craco": "^6.1.2",
|
|
52
|
-
"@stlite/kernel": "^0.
|
|
52
|
+
"@stlite/kernel": "^0.18.0",
|
|
53
53
|
"@testing-library/react": "^11.2.7",
|
|
54
54
|
"@testing-library/user-event": "^13.1.9",
|
|
55
55
|
"@types/jest": "^26.0.19",
|