@stlite/desktop 0.16.0 → 0.17.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 +30 -14
- package/build/electron/main.js +20 -1
- package/build/electron/main.js.map +1 -1
- package/build/index.html +1 -1
- package/package.json +3 -3
package/bin/dump_artifacts.js
CHANGED
|
@@ -90,22 +90,37 @@ async function createSitePackagesSnapshot(options) {
|
|
|
90
90
|
async function copyStreamlitAppDirectory(options) {
|
|
91
91
|
console.info("Copy the Streamlit app directory...");
|
|
92
92
|
console.log(`Copy ${options.sourceDir} to ${options.copyTo}`);
|
|
93
|
-
|
|
93
|
+
await promises_1.default.rm(options.copyTo, { recursive: true, force: true });
|
|
94
|
+
await fs_extra_1.default.copy(options.sourceDir, options.copyTo);
|
|
94
95
|
}
|
|
96
|
+
// Original: packages/sharing-editor/bin/gen-sample-app-manifests-json.ts
|
|
97
|
+
// TODO: Be DRY
|
|
95
98
|
async function readRequirements(requirementsTxtPath) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
99
|
+
const requirementsTxtData = await promises_1.default.readFile(requirementsTxtPath, {
|
|
100
|
+
encoding: "utf-8",
|
|
101
|
+
});
|
|
102
|
+
return requirementsTxtData
|
|
103
|
+
.split("\n")
|
|
104
|
+
.map((r) => r.trim())
|
|
105
|
+
.filter((r) => r !== "");
|
|
106
|
+
}
|
|
107
|
+
// Original: kernel/src/requirements.ts
|
|
108
|
+
// TODO: Be DRY
|
|
109
|
+
function verifyRequirements(requirements) {
|
|
110
|
+
requirements.forEach((req) => {
|
|
111
|
+
let url;
|
|
112
|
+
try {
|
|
113
|
+
url = new URL(req);
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
// `req` is not a URL -> OK
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
// Ref: The scheme checker in the micropip implementation is https://github.com/pyodide/micropip/blob/v0.1.0/micropip/_compat_in_pyodide.py#L23-L26
|
|
120
|
+
if (url.protocol === "emfs:" || url.protocol === "file:") {
|
|
121
|
+
throw new Error(`"emfs:" and "file:" protocols are not allowed for the requirement (${req})`);
|
|
122
|
+
}
|
|
123
|
+
});
|
|
109
124
|
}
|
|
110
125
|
(0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
|
|
111
126
|
.command("* <appHomeDirSource> [packages..]", "Put the user code and data and the snapshot of the required packages into the build artifact.", () => { }, (argv) => {
|
|
@@ -153,6 +168,7 @@ async function readRequirements(requirementsTxtPath) {
|
|
|
153
168
|
for (const requirementTxtFilePath of args.requirement) {
|
|
154
169
|
requirements = requirements.concat(await readRequirements(requirementTxtFilePath));
|
|
155
170
|
}
|
|
171
|
+
verifyRequirements(requirements);
|
|
156
172
|
await copyBuildDirectory({ copyTo: destDir, override: args.force });
|
|
157
173
|
await createSitePackagesSnapshot({
|
|
158
174
|
useLocalKernelWheels: args.localKernelWheels,
|
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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AAM,cAAc,GAAG,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IACrD,mBAAQ,CAAC,qBAAqB,CAAC,MAAM,EAAE,UAAU,GAAG,EAAE,QAAQ;QAC5D,MAAM,gBAAgB,GAAG,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,uBAAuB;QAClE,IAAI,IAAI,CAAC,UAAU,CAAC,gBAAgB,CAAC,EAAE;YACrC,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC;YACrE,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC,CAAC;SAC5C;aAAM;YACL,QAAQ,CAAC,gBAAgB,CAAC,CAAC;SAC5B;IACH,CAAC,CAAC,CAAC;IAEH,YAAY,EAAE,CAAC;IAEf,cAAG,CAAC,EAAE,CAAC,UAAU,EAAE,GAAG,EAAE;QACtB,iEAAiE;QACjE,4DAA4D;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.17.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
|
-
"homepage": "
|
|
5
|
+
"homepage": "/",
|
|
6
6
|
"main": "./build/electron/main.js",
|
|
7
7
|
"files": [
|
|
8
8
|
"build",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@craco/craco": "^6.1.2",
|
|
52
|
-
"@stlite/kernel": "^0.
|
|
52
|
+
"@stlite/kernel": "^0.17.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",
|