@stlite/desktop 0.35.1 → 0.37.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/README.md +16 -1
- package/bin/dump_artifacts.js +5 -5
- package/build/asset-manifest.json +8 -8
- package/build/electron/main.js +24 -7
- package/build/index.html +1 -1
- package/build/static/js/{3580.e292972c.chunk.js → 3580.06d6525d.chunk.js} +1 -1
- package/build/static/js/{4320.8fa60786.chunk.js → 4320.4daf4ee0.chunk.js} +2 -2
- package/build/static/js/{787.30ab7f34.chunk.js → 787.6799b9ba.chunk.js} +1 -1
- package/build/static/js/{792.45efff32.chunk.js → 792.2e8015a9.chunk.js} +1 -1
- package/build/static/js/{9615.82cf4bfb.chunk.js → 9615.b2a2aa6f.chunk.js} +1 -1
- package/build/static/js/main.798bbf8c.js +28 -0
- package/package.json +4 -4
- package/build/static/js/main.259af25f.js +0 -28
- /package/build/static/js/{4320.8fa60786.chunk.js.LICENSE.txt → 4320.4daf4ee0.chunk.js.LICENSE.txt} +0 -0
- /package/build/static/js/{main.259af25f.js.LICENSE.txt → main.798bbf8c.js.LICENSE.txt} +0 -0
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ Convert your [Streamlit](https://streamlit.io/) application into a desktop app w
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@stlite/desktop": "0.
|
|
27
|
+
"@stlite/desktop": "0.36.0",
|
|
28
28
|
"cross-env": "^7.0.3",
|
|
29
29
|
"electron": "^25.2.0",
|
|
30
30
|
"electron-builder": "^24.4.0"
|
|
@@ -56,6 +56,21 @@ Convert your [Streamlit](https://streamlit.io/) application into a desktop app w
|
|
|
56
56
|
To make your app secure, be sure to use the latest version of Electron.
|
|
57
57
|
This is [announced](https://www.electronjs.org/docs/latest/tutorial/security#16-use-a-current-version-of-electron) as one of the security best practices in the Electron document too.
|
|
58
58
|
|
|
59
|
+
## Hide the toolbar, hamburger menu, and the footer
|
|
60
|
+
|
|
61
|
+
If you want to hide the toolbar, hamburger menu, and the footer, add the following to your `package.json` file and run the `dump` command again. By adding the `stlite.desktop.embed` field, the dumped Streamlit app will work in the [embed mode](https://docs.streamlit.io/streamlit-community-cloud/get-started/embed-your-app#embedding-with-iframes) which hides the toolbar, hamburger menu, and the footer.
|
|
62
|
+
|
|
63
|
+
```json
|
|
64
|
+
{
|
|
65
|
+
// ...other fields...
|
|
66
|
+
"stlite": {
|
|
67
|
+
"desktop": {
|
|
68
|
+
"embed": true
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
59
74
|
## Limitations
|
|
60
75
|
|
|
61
76
|
- Navigation to external resources like `st.markdown("[link](https://streamlit.io/)")` does not work for security. See https://github.com/whitphx/stlite/pull/445 and let us know if you have use cases where you have to use such external links.
|
package/bin/dump_artifacts.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var j=Object.create;var w=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var x=Object.getPrototypeOf,K=Object.prototype.hasOwnProperty;var k=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var W=(e,t,i,
|
|
3
|
-
`).filter(t=>!t.startsWith("#")).map(t=>t.trim()).filter(t=>t!=="")}f.parseRequirementsTxt=I});var P=k(d=>{"use strict";var
|
|
2
|
+
var j=Object.create;var w=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var x=Object.getPrototypeOf,K=Object.prototype.hasOwnProperty;var k=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var W=(e,t,i,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of F(t))!K.call(e,a)&&a!==i&&w(e,a,{get:()=>t[a],enumerable:!(o=S(t,a))||o.enumerable});return e};var p=(e,t,i)=>(i=e!=null?j(x(e)):{},W(t||!e||!e.__esModule?w(i,"default",{value:e,enumerable:!0}):i,e));var v=k(f=>{"use strict";Object.defineProperty(f,"__esModule",{value:!0});f.parseRequirementsTxt=void 0;function I(e){return e.split(`
|
|
3
|
+
`).filter(t=>!t.startsWith("#")).map(t=>t.trim()).filter(t=>t!=="")}f.parseRequirementsTxt=I});var P=k(d=>{"use strict";var M=d&&d.__createBinding||(Object.create?function(e,t,i,o){o===void 0&&(o=i);var a=Object.getOwnPropertyDescriptor(t,i);(!a||("get"in a?!t.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return t[i]}}),Object.defineProperty(e,o,a)}:function(e,t,i,o){o===void 0&&(o=i),e[o]=t[i]}),R=d&&d.__exportStar||function(e,t){for(var i in e)i!=="default"&&!Object.prototype.hasOwnProperty.call(t,i)&&M(t,e,i)};Object.defineProperty(d,"__esModule",{value:!0});R(v(),d)});var b=p(require("yargs")),_=require("yargs/helpers"),s=p(require("path")),n=p(require("fs/promises")),y=p(require("fs-extra")),u=p(require("node-fetch")),m=require("pyodide"),q=p(P());global.fetch=u.default;function $(e){return`https://cdn.jsdelivr.net/pyodide/v${m.version}/full/${e}`}async function C(e){console.info("Copy the build directory (the bare built app files) to this directory...");let t=s.default.resolve(__dirname,"../build");if(!(await n.default.stat(t)).isDirectory())throw new Error(`The source ${t} does not exist.`);if(t===e.copyTo){console.warn(`sourceDir == destDir (${t}). Are you in the development environment? Skip copying the directory.`);return}if(e.keepOld)try{await n.default.access(e.copyTo),console.info(`${e.copyTo} already exists. Use it and skip copying.`);return}catch{throw new Error(`${e.copyTo} does not exist even though the \`keepOld\` option is specified`)}console.log(`Copy ${t} to ${e.copyTo}`),await n.default.rm(e.copyTo,{recursive:!0,force:!0}),await y.default.copy(t,e.copyTo)}async function E(e){if(e.requirements.length===0)return[];let t=await(0,m.loadPyodide)();await t.loadPackage("micropip");let i=t.pyimport("micropip");return i.add_mock_package("streamlit","1.24.0"),await i.install(e.requirements),Object.entries(t.loadedPackages).filter(([,o])=>o==="default channel").map(([o])=>o)}async function T(){let e=$("repodata.json");return console.log(`Load the Pyodide repodata.json from ${e}`),(await(await(0,u.default)(e)).json()).packages}async function D(e,t){console.log(`Install the local wheel ${t}`);let i=await n.default.readFile(t),o="/tmp/"+s.default.basename(t);e.FS.writeFile(o,i);let a=e.pyimport("micropip"),c=`emfs:${o}`;console.log(`Install ${c}`),await a.install.callKwargs(c,{keep_going:!0})}async function J(e){console.info("Create the site-packages snapshot file...");let t=await(0,m.loadPyodide)();if(await t.loadPackage(["micropip"]),e.useLocalKernelWheels){let l=s.default.dirname(require.resolve("@stlite/kernel")),r=s.default.resolve(l,"../py");await D(t,s.default.join(r,"stlite-server/dist/stlite_server-0.1.0-py3-none-any.whl")),await D(t,s.default.join(r,"streamlit/lib/dist/streamlit-1.24.0-py2.py3-none-any.whl"))}else{let r=require(s.default.resolve(__dirname,"../package.json")).version,O=`https://data.jsdelivr.com/v1/package/npm/@stlite/kernel@${r}/flat`,h=(await(await(0,u.default)(O)).json()).files.filter(g=>g.name.endsWith(".whl")).map(g=>`https://cdn.jsdelivr.net/npm/@stlite/kernel@${r}${g.name}`),B=t.pyimport("micropip");console.log("Install",h),await B.install.callKwargs(h,{keep_going:!0})}let i=t.pyimport("micropip"),o=await T();e.usedBuiltinPackages.length>0&&(console.log("Mocking builtin packages so that they will not be included in the site-packages snapshot because these will be installed from the vendored wheel files at runtime..."),e.usedBuiltinPackages.forEach(l=>{let r=o[l];if(r==null)throw new Error(`Package ${l} is not found in the lock file.`);console.log(`Mock ${r.name} ${r.version}`),i.add_mock_package(r.name,r.version)})),console.log(`Install the requirements ${JSON.stringify(e.requirements)}`),await i.install.callKwargs(e.requirements,{keep_going:!0}),console.log("Archive the site-packages director(y|ies)");let a="/tmp/site-packages-snapshot.tar.gz";await t.runPythonAsync(`
|
|
4
4
|
import tarfile
|
|
5
5
|
import site
|
|
6
6
|
|
|
7
7
|
site_packages_dirs = site.getsitepackages()
|
|
8
8
|
|
|
9
|
-
tar_file_name = '${
|
|
9
|
+
tar_file_name = '${a}'
|
|
10
10
|
with tarfile.open(tar_file_name, mode='w:gz') as gzf:
|
|
11
11
|
for site_packages in site_packages_dirs:
|
|
12
12
|
gzf.add(site_packages)
|
|
13
|
-
`),console.log("Extract the archive file from EMFS");let
|
|
14
|
-
`);await n.default.writeFile(e,i,{encoding:"utf-8"})}function
|
|
13
|
+
`),console.log("Extract the archive file from EMFS");let c=t.FS.readFile(a);console.log(`Save the archive file (${e.saveTo})`),await n.default.writeFile(e.saveTo,c)}async function L(e){console.info("Copy the Streamlit app directory..."),console.log(`Copy ${e.sourceDir} to ${e.copyTo}`),await n.default.rm(e.copyTo,{recursive:!0,force:!0}),await y.default.copy(e.sourceDir,e.copyTo)}async function H(e){let t=await n.default.readFile(e,{encoding:"utf-8"});return(0,q.parseRequirementsTxt)(t)}async function U(e,t){let i=t.join(`
|
|
14
|
+
`);await n.default.writeFile(e,i,{encoding:"utf-8"})}function A(e){e.forEach(t=>{let i;try{i=new URL(t)}catch{return}if(i.protocol==="emfs:"||i.protocol==="file:")throw new Error(`"emfs:" and "file:" protocols are not allowed for the requirement (${t})`)})}async function z(e){let t=await T(),o=e.packages.map(a=>t[a]).map(a=>$(a.file_name));console.log("Downloading the used built-in packages..."),await Promise.all(o.map(async a=>{let c=s.default.resolve(e.destDir,"./pyodide",s.default.basename(a));console.log(`Download ${a} to ${c}`);let l=await(0,u.default)(a);if(!l.ok)throw new Error(`Failed to download ${a}: ${l.status} ${l.statusText}`);let r=await l.arrayBuffer();await n.default.writeFile(c,Buffer.from(r))}))}async function N(){let i={embed:(require(s.default.resolve(__dirname,"../package.json")).stlite?.desktop||{}).embed||!1},o=s.default.resolve(__dirname,"../build/stlite-manifest.json"),a=JSON.stringify(i,null,2);console.log(`Dump the manifest file -> ${o}`),console.log(a),await n.default.writeFile(o,a,{encoding:"utf-8"})}(0,b.default)((0,_.hideBin)(process.argv)).command("* <appHomeDirSource> [packages..]","Put the user code and data and the snapshot of the required packages into the build artifact.",()=>{},e=>{console.info(e)}).positional("appHomeDirSource",{describe:"The source directory of the user code and data that will be mounted in the Pyodide file system at app runtime",type:"string",demandOption:!0}).positional("packages",{describe:"Package names to install.",type:"string",array:!0}).options("requirement",{describe:"Install from the given requirements file. This option can be used multiple times.",array:!0,type:"string",alias:"r",default:[]}).options("localKernelWheels",{describe:"Use the locally installed kernel wheels",type:"boolean",alias:"l",default:!1}).options("keepOldBuild",{type:"boolean",default:!1,alias:"k",describe:"Keep the existing build directory contents except appHomeDir."}).parseAsync().then(async e=>{let t=s.default.resolve(process.cwd(),"./build");try{await n.default.access(e.appHomeDirSource)}catch{throw new Error(`${e.appHomeDirSource} does not exist.`)}let i=e.packages;for(let a of e.requirement)i=i.concat(await H(a));A(i);let o=await E({requirements:i,useLocalKernelWheels:e.localKernelWheels});console.log("The built-in packages loaded for the given requirements:"),console.log(o),await C({copyTo:t,keepOld:e.keepOldBuild}),await J({useLocalKernelWheels:e.localKernelWheels,requirements:i,usedBuiltinPackages:o,saveTo:s.default.resolve(t,"./site-packages-snapshot.tar.gz")}),await U(s.default.resolve(t,"./requirements.txt"),i),await L({sourceDir:e.appHomeDirSource,copyTo:s.default.resolve(t,"./streamlit_app")}),await z({packages:o,destDir:t}),await N()});
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"files": {
|
|
3
3
|
"main.css": "/static/css/main.b43a24ba.css",
|
|
4
|
-
"main.js": "/static/js/main.
|
|
4
|
+
"main.js": "/static/js/main.798bbf8c.js",
|
|
5
5
|
"static/js/7073.d0bf438f.chunk.js": "/static/js/7073.d0bf438f.chunk.js",
|
|
6
6
|
"static/js/4994.551c87ac.chunk.js": "/static/js/4994.551c87ac.chunk.js",
|
|
7
|
-
"static/js/792.
|
|
7
|
+
"static/js/792.2e8015a9.chunk.js": "/static/js/792.2e8015a9.chunk.js",
|
|
8
8
|
"static/js/4141.a101e33c.chunk.js": "/static/js/4141.a101e33c.chunk.js",
|
|
9
9
|
"static/js/6913.094a45e2.chunk.js": "/static/js/6913.094a45e2.chunk.js",
|
|
10
10
|
"static/css/5099.60b7ada4.chunk.css": "/static/css/5099.60b7ada4.chunk.css",
|
|
@@ -15,12 +15,12 @@
|
|
|
15
15
|
"static/js/8418.aed275df.chunk.js": "/static/js/8418.aed275df.chunk.js",
|
|
16
16
|
"static/js/8295.c3cd87de.chunk.js": "/static/js/8295.c3cd87de.chunk.js",
|
|
17
17
|
"static/js/8486.e56533d6.chunk.js": "/static/js/8486.e56533d6.chunk.js",
|
|
18
|
-
"static/js/9615.
|
|
18
|
+
"static/js/9615.b2a2aa6f.chunk.js": "/static/js/9615.b2a2aa6f.chunk.js",
|
|
19
19
|
"static/js/6557.fd2f35c8.chunk.js": "/static/js/6557.fd2f35c8.chunk.js",
|
|
20
20
|
"static/js/9382.c417d448.chunk.js": "/static/js/9382.c417d448.chunk.js",
|
|
21
|
-
"static/js/3580.
|
|
21
|
+
"static/js/3580.06d6525d.chunk.js": "/static/js/3580.06d6525d.chunk.js",
|
|
22
22
|
"static/js/2327.b8572a38.chunk.js": "/static/js/2327.b8572a38.chunk.js",
|
|
23
|
-
"static/js/787.
|
|
23
|
+
"static/js/787.6799b9ba.chunk.js": "/static/js/787.6799b9ba.chunk.js",
|
|
24
24
|
"static/js/5241.0326c97c.chunk.js": "/static/js/5241.0326c97c.chunk.js",
|
|
25
25
|
"static/js/172.599dcb6e.chunk.js": "/static/js/172.599dcb6e.chunk.js",
|
|
26
26
|
"static/js/4140.edb6c36a.chunk.js": "/static/js/4140.edb6c36a.chunk.js",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"static/js/5177.3eb35171.chunk.js": "/static/js/5177.3eb35171.chunk.js",
|
|
46
46
|
"static/js/1839.410079bf.chunk.js": "/static/js/1839.410079bf.chunk.js",
|
|
47
47
|
"static/css/4320.1edfa457.chunk.css": "/static/css/4320.1edfa457.chunk.css",
|
|
48
|
-
"static/js/4320.
|
|
48
|
+
"static/js/4320.4daf4ee0.chunk.js": "/static/js/4320.4daf4ee0.chunk.js",
|
|
49
49
|
"static/js/1579.10c95eae.chunk.js": "/static/js/1579.10c95eae.chunk.js",
|
|
50
50
|
"static/js/3744.93bd4bad.chunk.js": "/static/js/3744.93bd4bad.chunk.js",
|
|
51
51
|
"static/js/9733.0d6a1712.chunk.js": "/static/js/9733.0d6a1712.chunk.js",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"static/js/9166.1a468fb9.chunk.js": "/static/js/9166.1a468fb9.chunk.js",
|
|
56
56
|
"static/js/6865.b0803b6b.chunk.js": "/static/js/6865.b0803b6b.chunk.js",
|
|
57
57
|
"static/js/6679.859559e9.chunk.js": "/static/js/6679.859559e9.chunk.js",
|
|
58
|
-
"pypi/streamlit-1.24.0-
|
|
58
|
+
"pypi/streamlit-1.24.0-cp311-none-any.whl": "/pypi/streamlit-1.24.0-cp311-none-any.whl",
|
|
59
59
|
"static/media/SourceSansPro-Regular.ttf": "/static/media/SourceSansPro-Regular.efa76f8326aa5cee3bdd.ttf",
|
|
60
60
|
"static/media/SourceSansPro-SemiBold.ttf": "/static/media/SourceSansPro-SemiBold.43cc81b496222dc9ce3c.ttf",
|
|
61
61
|
"static/media/SourceSansPro-Bold.ttf": "/static/media/SourceSansPro-Bold.12e6acd2589d00c9d0aa.ttf",
|
|
@@ -154,6 +154,6 @@
|
|
|
154
154
|
},
|
|
155
155
|
"entrypoints": [
|
|
156
156
|
"static/css/main.b43a24ba.css",
|
|
157
|
-
"static/js/main.
|
|
157
|
+
"static/js/main.798bbf8c.js"
|
|
158
158
|
]
|
|
159
159
|
}
|
package/build/electron/main.js
CHANGED
|
@@ -12,7 +12,18 @@ if (process.env.NODE_ENV === "development") {
|
|
|
12
12
|
: "../../node_modules/.bin/electron"),
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
|
-
|
|
15
|
+
async function readManifest() {
|
|
16
|
+
const manifestPath = path.resolve(__dirname, "../stlite-manifest.json");
|
|
17
|
+
const manifestText = await fsPromises.readFile(manifestPath, {
|
|
18
|
+
encoding: "utf-8",
|
|
19
|
+
});
|
|
20
|
+
const maybeManifestData = JSON.parse(manifestText);
|
|
21
|
+
return {
|
|
22
|
+
embed: maybeManifestData.embed ?? false,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
const createWindow = async () => {
|
|
26
|
+
const manifest = await readManifest();
|
|
16
27
|
const mainWindow = new electron_1.BrowserWindow({
|
|
17
28
|
width: 1280,
|
|
18
29
|
height: 720,
|
|
@@ -21,9 +32,15 @@ const createWindow = () => {
|
|
|
21
32
|
sandbox: true, // https://www.electronjs.org/docs/latest/tutorial/security#4-enable-process-sandboxing
|
|
22
33
|
},
|
|
23
34
|
});
|
|
24
|
-
const
|
|
35
|
+
const indexUrlObj = new URL(electron_1.app.isPackaged || process.env.NODE_ENV === "production"
|
|
25
36
|
? "file:///index.html"
|
|
26
|
-
: "http://localhost:3000/";
|
|
37
|
+
: "http://localhost:3000/");
|
|
38
|
+
const indexUrlParams = new URLSearchParams();
|
|
39
|
+
if (manifest.embed) {
|
|
40
|
+
indexUrlParams.set("embed", "true");
|
|
41
|
+
}
|
|
42
|
+
indexUrlObj.search = indexUrlParams.toString();
|
|
43
|
+
const indexUrl = indexUrlObj.toString();
|
|
27
44
|
// Check the IPC sender in every callback below,
|
|
28
45
|
// following the security best practice, "17. Validate the sender of all IPC messages."
|
|
29
46
|
// https://www.electronjs.org/docs/latest/tutorial/security#17-validate-the-sender-of-all-ipc-messages
|
|
@@ -88,13 +105,13 @@ electron_1.app.whenReady().then(() => {
|
|
|
88
105
|
// Ref: https://github.com/electron/electron/issues/4612#issuecomment-189116655
|
|
89
106
|
const bundleBasePath = path.resolve(__dirname, "..");
|
|
90
107
|
electron_1.protocol.interceptFileProtocol("file", function (req, callback) {
|
|
91
|
-
const
|
|
92
|
-
if (path.isAbsolute(
|
|
93
|
-
const resolvedFilePath = path.join(bundleBasePath,
|
|
108
|
+
const filePath = new URL(req.url).pathname; // `file://<absolute_path>?<query>#<hash>` -> `<absolute_path>`
|
|
109
|
+
if (path.isAbsolute(filePath)) {
|
|
110
|
+
const resolvedFilePath = path.join(bundleBasePath, filePath);
|
|
94
111
|
callback(path.normalize(resolvedFilePath));
|
|
95
112
|
}
|
|
96
113
|
else {
|
|
97
|
-
callback(
|
|
114
|
+
callback(filePath);
|
|
98
115
|
}
|
|
99
116
|
});
|
|
100
117
|
createWindow();
|
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 'wasm-unsafe-eval' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; worker-src 'self' blob:; script-src-elem 'self' 'unsafe-inline' https:; style-src-elem 'self' 'unsafe-inline' https:; font-src 'self' data: https:; connect-src https://data.streamlit.io/ https://*.mapbox.com/ 'self' https:; img-src https: blob: data: file:; media-src https: blob:; frame-src https:"><script defer="defer" src="/static/js/main.
|
|
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' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; worker-src 'self' blob:; script-src-elem 'self' 'unsafe-inline' https:; style-src-elem 'self' 'unsafe-inline' https:; font-src 'self' data: https:; connect-src https://data.streamlit.io/ https://*.mapbox.com/ 'self' https:; img-src https: blob: data: file:; media-src https: blob:; frame-src https:"><script defer="defer" src="/static/js/main.798bbf8c.js"></script><link href="/static/css/main.b43a24ba.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(globalThis.webpackChunk_stlite_desktop=globalThis.webpackChunk_stlite_desktop||[]).push([[3580],{83580:(e,t,r)=>{r.r(t),r.d(t,{default:()=>d});var s=r(5057),a=r(98927),n=r(
|
|
1
|
+
"use strict";(globalThis.webpackChunk_stlite_desktop=globalThis.webpackChunk_stlite_desktop||[]).push([[3580],{83580:(e,t,r)=>{r.r(t),r.d(t,{default:()=>d});var s=r(5057),a=r(98927),n=r(99811),i=r(96266);const l=528;function d({element:e,width:t,endpoints:r}){const d=(0,s.useRef)(null),{type:o,url:c}=e,u=(0,n.O0)(c);(0,s.useEffect)((()=>{const t=d.current,r=()=>{t&&(t.currentTime=e.startTime)};return t&&t.addEventListener("loadedmetadata",r),()=>{t&&t.removeEventListener("loadedmetadata",r)}}),[e]);const h=t=>{const{startTime:r}=e;return r?`${t}?start=${r}`:t};if(o===a.nk.Type.YOUTUBE_IFRAME){const e=0!==t?.75*t:l;return(0,i.jsx)("iframe",{title:u,src:h(u),width:t,height:e,frameBorder:"0",allow:"autoplay; encrypted-media",allowFullScreen:!0})}return(0,i.jsx)("video",{ref:d,controls:!0,src:r.buildMediaURL(u),className:"stVideo",style:{width:t,height:0===t?l:void 0}})}}}]);
|