lido-standalone 0.0.0-beta-19-dev → 0.0.0-beta-20-dev
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/dist/cjs/{index-52f24ddb.js → index-9a2514de.js} +3 -1
- package/dist/cjs/index-9a2514de.js.map +1 -0
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/lido-standalone.cjs.entry.js +114 -65
- package/dist/cjs/lido-standalone.cjs.entry.js.map +1 -1
- package/dist/cjs/lido-standalone.cjs.js +2 -2
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/collection/components/lido-standalone/lido-standalone.js +148 -63
- package/dist/collection/components/lido-standalone/lido-standalone.js.map +1 -1
- package/dist/components/lido-standalone.js +117 -65
- package/dist/components/lido-standalone.js.map +1 -1
- package/dist/esm/{index-5da3b4be.js → index-32cd7d72.js} +3 -2
- package/dist/esm/index-32cd7d72.js.map +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/lido-standalone.entry.js +114 -65
- package/dist/esm/lido-standalone.entry.js.map +1 -1
- package/dist/esm/lido-standalone.js +3 -3
- package/dist/esm/loader.js +3 -3
- package/dist/lido-standalone/index.esm.js +1 -1
- package/dist/lido-standalone/lido-standalone.esm.js +1 -1
- package/dist/lido-standalone/lido-standalone.esm.js.map +1 -1
- package/dist/lido-standalone/p-1469ddb8.js +3 -0
- package/dist/lido-standalone/p-1469ddb8.js.map +1 -0
- package/dist/lido-standalone/p-862a6695.entry.js +2 -0
- package/dist/lido-standalone/p-862a6695.entry.js.map +1 -0
- package/dist/types/components/lido-standalone/lido-standalone.d.ts +13 -3
- package/dist/types/components.d.ts +16 -0
- package/package.json +1 -1
- package/src/components/lido-standalone/lido-standalone.tsx +142 -77
- package/src/components/lido-standalone/readme.md +2 -0
- package/src/components.d.ts +16 -0
- package/dist/cjs/index-52f24ddb.js.map +0 -1
- package/dist/esm/index-5da3b4be.js.map +0 -1
- package/dist/lido-standalone/p-1bb50e6d.entry.js +0 -2
- package/dist/lido-standalone/p-1bb50e6d.entry.js.map +0 -1
- package/dist/lido-standalone/p-3a3323c8.js +0 -3
- package/dist/lido-standalone/p-3a3323c8.js.map +0 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const index = require('./index-
|
|
5
|
+
const index = require('./index-9a2514de.js');
|
|
6
6
|
|
|
7
7
|
const lidoStandaloneCss = "";
|
|
8
8
|
const LidoStandaloneStyle0 = lidoStandaloneCss;
|
|
@@ -15,7 +15,9 @@ const LidoStandalone = class {
|
|
|
15
15
|
this.initialIndex = 0;
|
|
16
16
|
this.canplay = false;
|
|
17
17
|
this.height = '75vh';
|
|
18
|
+
this.language = undefined;
|
|
18
19
|
this.xmlData = undefined;
|
|
20
|
+
this.zipUrl = undefined;
|
|
19
21
|
this.codeFolderPath = undefined;
|
|
20
22
|
this.commonAudioPath = undefined;
|
|
21
23
|
this.scriptsInjected = false;
|
|
@@ -30,6 +32,10 @@ const LidoStandalone = class {
|
|
|
30
32
|
onXmlPathChange() {
|
|
31
33
|
this.fetchXmlData();
|
|
32
34
|
}
|
|
35
|
+
// Re-apply inline XML whenever the host prop changes.
|
|
36
|
+
onXmlDataChange() {
|
|
37
|
+
this.fetchXmlData();
|
|
38
|
+
}
|
|
33
39
|
componentWillLoad() {
|
|
34
40
|
// 1) Attempt to inject the Lido scripts from baseUrl
|
|
35
41
|
this.injectLidoScripts();
|
|
@@ -51,7 +57,11 @@ const LidoStandalone = class {
|
|
|
51
57
|
const cleanBase = this.baseUrl.replace(/\/+$/, '');
|
|
52
58
|
const scriptCheckUrl = `${cleanBase}/code/lido-player.esm.js`;
|
|
53
59
|
const fileExists = this.doesFileExistSync(scriptCheckUrl);
|
|
60
|
+
// --------------- CASE: NO codeFolderPath PROVIDED ---------------
|
|
61
|
+
// Try loading version from default /code_versions folder
|
|
62
|
+
// --------------- SINGLE CASE: codeFolderPath PROVIDED ---------------
|
|
54
63
|
if (fileExists) {
|
|
64
|
+
console.log("Using code from zip....");
|
|
55
65
|
// If it exists, inject them
|
|
56
66
|
const scriptEsm = document.createElement('script');
|
|
57
67
|
scriptEsm.type = 'module';
|
|
@@ -64,79 +74,117 @@ const LidoStandalone = class {
|
|
|
64
74
|
document.head.appendChild(scriptNoModule);
|
|
65
75
|
this.scriptsInjected = true;
|
|
66
76
|
console.debug('Lido scripts injected from:', this.baseUrl);
|
|
77
|
+
return;
|
|
67
78
|
}
|
|
68
|
-
|
|
79
|
+
if (this.codeFolderPath) {
|
|
69
80
|
const cleanBase = this.baseUrl.replace(/\/+$/, "");
|
|
70
|
-
const cfgUrl = `${cleanBase}/config.json`;
|
|
71
81
|
try {
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
// --- Version exists: try to load versioned folder ---
|
|
86
|
-
const codePath = this.codeFolderPath.replace(/\/+$/, "");
|
|
87
|
-
const versionFolder = `${codePath}/${version}`;
|
|
88
|
-
const esmUrl = `${versionFolder}/lido-player.esm.js`;
|
|
89
|
-
const noModuleUrl = `${versionFolder}/lido-player.js`;
|
|
90
|
-
// Check if versioned ESM exists
|
|
91
|
-
const headCheck = await fetch(esmUrl, { method: "HEAD" });
|
|
92
|
-
if (!headCheck.ok) {
|
|
93
|
-
console.warn(`Version folder found but lido-player.esm.js missing: ${esmUrl}`);
|
|
82
|
+
const lessonCfgUrl = `${cleanBase}/config.json`;
|
|
83
|
+
try {
|
|
84
|
+
// 1️⃣ Load lesson config.json safely
|
|
85
|
+
let lessonCfg = {};
|
|
86
|
+
let lessonVersion = null;
|
|
87
|
+
try {
|
|
88
|
+
const lessonResp = await fetch(lessonCfgUrl);
|
|
89
|
+
if (!lessonResp.ok)
|
|
90
|
+
throw new Error("Lesson config.json missing");
|
|
91
|
+
// Check for empty file (0 bytes)
|
|
92
|
+
const text = await lessonResp.text();
|
|
93
|
+
if (text.trim().length > 0) {
|
|
94
|
+
lessonCfg = JSON.parse(text);
|
|
94
95
|
}
|
|
95
96
|
else {
|
|
96
|
-
|
|
97
|
-
const scriptEsm = document.createElement("script");
|
|
98
|
-
scriptEsm.type = "module";
|
|
99
|
-
scriptEsm.src = esmUrl;
|
|
100
|
-
document.head.appendChild(scriptEsm);
|
|
101
|
-
const scriptNoModule = document.createElement("script");
|
|
102
|
-
scriptNoModule.setAttribute("nomodule", "");
|
|
103
|
-
scriptNoModule.src = noModuleUrl;
|
|
104
|
-
document.head.appendChild(scriptNoModule);
|
|
105
|
-
this.scriptsInjected = true;
|
|
106
|
-
console.debug("Loaded version from config.json:", versionFolder);
|
|
107
|
-
return; // return when version successfully loaded
|
|
97
|
+
console.warn("Lesson config.json is EMPTY → falling back to latest version");
|
|
108
98
|
}
|
|
99
|
+
lessonVersion = lessonCfg.code_version;
|
|
100
|
+
console.log(`%c USING THE VERSION FOLDER--> ${lessonVersion} `, "color: #3bffe8ff; background:#d32f2f; font-size: 15px; font-weight: bold; padding: 6px 10px; border-radius: 4px;");
|
|
101
|
+
}
|
|
102
|
+
catch (parseErr) {
|
|
103
|
+
console.warn("Lesson config.json invalid or unreadable → fallback to latest version");
|
|
104
|
+
lessonVersion = null;
|
|
109
105
|
}
|
|
106
|
+
// Normalize invalid versions
|
|
107
|
+
if (!lessonVersion || typeof lessonVersion !== "string" || lessonVersion.trim() === "") {
|
|
108
|
+
console.warn("Lesson has NO valid codeVersion → using latest version in code-folder-path");
|
|
109
|
+
lessonVersion = null;
|
|
110
|
+
}
|
|
111
|
+
// 2️⃣ Load version list from code-folder-path/config.json
|
|
112
|
+
const codeCfgUrl = `${this.codeFolderPath.replace(/\/+$/, '')}/config.json`;
|
|
113
|
+
const codeResp = await fetch(codeCfgUrl);
|
|
114
|
+
if (!codeResp.ok)
|
|
115
|
+
throw new Error("Code-folder config.json missing");
|
|
116
|
+
const codeCfg = await codeResp.json();
|
|
117
|
+
const availableVersions = codeCfg.versions || [];
|
|
118
|
+
if (!availableVersions.length) {
|
|
119
|
+
throw new Error("No versions listed in code-folder config.json");
|
|
120
|
+
}
|
|
121
|
+
// 3️⃣ Compute selected version
|
|
122
|
+
let selectedVersion = null;
|
|
123
|
+
if (lessonVersion) {
|
|
124
|
+
selectedVersion = availableVersions.find(v => v.includes(lessonVersion));
|
|
125
|
+
}
|
|
126
|
+
// Fallback: use latest version
|
|
127
|
+
if (!selectedVersion) {
|
|
128
|
+
selectedVersion = availableVersions[availableVersions.length - 1];
|
|
129
|
+
console.log(`%c USING THE LATEST VERSION FOLDER-> ${selectedVersion} `, "color: #3bffe8ff; background:#d32f2f; font-size: 15px; font-weight: bold; padding: 6px 10px; border-radius: 4px;");
|
|
130
|
+
}
|
|
131
|
+
// 4️⃣ Inject scripts
|
|
132
|
+
const versionDir = `${this.codeFolderPath}/${selectedVersion}`;
|
|
133
|
+
const esmUrl = `${versionDir}/lido-player.esm.js`;
|
|
134
|
+
const noModuleUrl = `${versionDir}/lido-player.js`;
|
|
135
|
+
// Check if version folder exists
|
|
136
|
+
const headCheck = await fetch(esmUrl, { method: "HEAD" });
|
|
137
|
+
if (!headCheck.ok)
|
|
138
|
+
throw new Error(`Versioned script missing: ${esmUrl}`);
|
|
139
|
+
// Inject main module file
|
|
140
|
+
const scriptEsm = document.createElement("script");
|
|
141
|
+
scriptEsm.type = "module";
|
|
142
|
+
scriptEsm.src = esmUrl;
|
|
143
|
+
document.head.appendChild(scriptEsm);
|
|
144
|
+
// Inject fallback nomodule script
|
|
145
|
+
const scriptNoModule = document.createElement("script");
|
|
146
|
+
scriptNoModule.setAttribute("nomodule", "");
|
|
147
|
+
scriptNoModule.src = noModuleUrl;
|
|
148
|
+
document.head.appendChild(scriptNoModule);
|
|
149
|
+
this.scriptsInjected = true;
|
|
150
|
+
console.debug("Loaded Lido version from:", versionDir);
|
|
151
|
+
}
|
|
152
|
+
catch (err) {
|
|
153
|
+
console.warn("Failed to load versioned scripts, falling back to npm:", err);
|
|
154
|
+
this.fallbackNpmImport();
|
|
110
155
|
}
|
|
111
156
|
}
|
|
112
|
-
catch (
|
|
113
|
-
console.
|
|
157
|
+
catch (err) {
|
|
158
|
+
console.warn("Failed loading scripts → fallback to npm:", err);
|
|
114
159
|
this.fallbackNpmImport();
|
|
115
160
|
}
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
else {
|
|
119
|
-
// Otherwise, fallback to the npm package
|
|
120
|
-
console.warn(`Could not find remote scripts at "${scriptCheckUrl}". Falling back to npm package "lido-player"...`);
|
|
121
|
-
this.fallbackNpmImport();
|
|
161
|
+
return;
|
|
122
162
|
}
|
|
163
|
+
this.fallbackNpmImport();
|
|
123
164
|
}
|
|
124
165
|
/**
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
166
|
+
* Checks if a file truly exists (not a dev-server fallback).
|
|
167
|
+
* Ensures:
|
|
168
|
+
* - HTTP HEAD returns 2xx
|
|
169
|
+
* - responseURL matches the requested URL
|
|
170
|
+
*/
|
|
128
171
|
doesFileExistSync(url) {
|
|
129
|
-
let exists = false;
|
|
130
172
|
try {
|
|
131
173
|
const xhr = new XMLHttpRequest();
|
|
132
|
-
xhr.open(
|
|
133
|
-
xhr.send(
|
|
134
|
-
|
|
174
|
+
xhr.open("HEAD", url, false); // synchronous
|
|
175
|
+
xhr.send();
|
|
176
|
+
const statusOk = xhr.status >= 200 && xhr.status < 300;
|
|
177
|
+
if (!statusOk)
|
|
178
|
+
return false;
|
|
179
|
+
// Detect fallback HTML responses (common when folder/file is missing)
|
|
180
|
+
const contentType = xhr.getResponseHeader("Content-Type") || "";
|
|
181
|
+
const isHtmlFallback = contentType.includes("text/html");
|
|
182
|
+
return !isHtmlFallback;
|
|
135
183
|
}
|
|
136
184
|
catch (err) {
|
|
137
|
-
console.warn(
|
|
185
|
+
console.warn("File existence check failed for:", url, err);
|
|
186
|
+
return false;
|
|
138
187
|
}
|
|
139
|
-
return exists;
|
|
140
188
|
}
|
|
141
189
|
/**
|
|
142
190
|
* Fallback approach: dynamically import the "lido-player/loader" module,
|
|
@@ -163,15 +211,13 @@ const LidoStandalone = class {
|
|
|
163
211
|
return;
|
|
164
212
|
}
|
|
165
213
|
// If xmlPath is not explicitly provided, default to `index.xml` in baseUrl
|
|
166
|
-
if (
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
214
|
+
if (this.baseUrl) {
|
|
215
|
+
const cleanBase = this.baseUrl.replace(/\/+$/, '');
|
|
216
|
+
this.xmlPath = `${cleanBase}/index.xml`;
|
|
217
|
+
this.xmlBaseUrl = this.baseUrl;
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
return;
|
|
175
221
|
}
|
|
176
222
|
try {
|
|
177
223
|
const xhr = new XMLHttpRequest();
|
|
@@ -199,11 +245,14 @@ const LidoStandalone = class {
|
|
|
199
245
|
*
|
|
200
246
|
* This ensures the custom elements are defined before usage.
|
|
201
247
|
*/
|
|
202
|
-
|
|
248
|
+
const lang = this.language || 'en';
|
|
249
|
+
return index.h("lido-home", { key: '52fd8d3879919dbba73d4c687f2d540f0e4e601f', "common-audio-path": this.commonAudioPath, "initial-index": this.initialIndex, canplay: this.canplay, height: this.height, lang: lang, "xml-data": this.localXmlData, "base-url": this.xmlBaseUrl, "code-folder-path": this.codeFolderPath, "zip-url": this.zipUrl });
|
|
203
250
|
}
|
|
251
|
+
get hostElement() { return index.getElement(this); }
|
|
204
252
|
static get watchers() { return {
|
|
205
253
|
"baseUrl": ["onBaseUrlChange"],
|
|
206
|
-
"xmlPath": ["onXmlPathChange"]
|
|
254
|
+
"xmlPath": ["onXmlPathChange"],
|
|
255
|
+
"xmlData": ["onXmlDataChange"]
|
|
207
256
|
}; }
|
|
208
257
|
};
|
|
209
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I,cAAc,EAAE,CAAC;YACjC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;YACrC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAEf,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,MAAM,GAAG,GAAG,EAAE;gBACzC,IAAI,CAAC,YAAY,GAAG,GAAG,CAAC,YAAY,CAAC;aACtC;iBAAM;gBACL,OAAO,CAAC,IAAI,CAAC,4BAA4B,IAAI,CAAC,OAAO,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;aACvE;SACF;QAAC,OAAO,GAAG,EAAE;YACZ,OAAO,CAAC,IAAI,CAAC,2BAA2B,IAAI,CAAC,OAAO,GAAG,EAAE,GAAG,CAAC,CAAC;SAC/D;KACF;IAED,MAAM;;;;;;;;;;;QAYJ,OAAOA,6FAA+B,IAAI,CAAC,eAAe,mBAAiB,IAAI,CAAC,YAAY,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,cAAY,IAAI,CAAC,YAAY,cAAY,IAAI,CAAC,UAAU,sBAAoB,IAAI,CAAC,cAAc,GAAc,CAAC;KACvP;;;;;;;;;;","names":["h"],"sources":["src/components/lido-standalone/lido-standalone.css?tag=lido-standalone","src/components/lido-standalone/lido-standalone.tsx"],"sourcesContent":["","import { Component, Prop, State, Watch, h } from '@stencil/core';\n\n/**\n * <lido-standalone> usage example:\n *\n * <lido-standalone\n * base-url=\"https://example.com/path/to/folder/lido-game\"\n * xml-path=\"https://example.com/path/to/folder/lido-game/assets/xmlData.xml\"\n * initial-index=\"2\"\n * canplay=\"true\"\n * height=\"75vh\"\n * ></lido-standalone>\n *\n * This attempts to load the external Lido scripts at runtime (from `baseUrl`).\n * If they aren't found, it falls back to loading the Lido npm package\n * and calls defineCustomElements(...) to register <lido-home>.\n */\n@Component({\n tag: 'lido-standalone',\n styleUrl: 'lido-standalone.css',\n shadow: false,\n})\nexport class LidoStandalone {\n /**\n * The public URL where the unzipped Lido code is hosted, e.g.\n * \"https://example.com/path/to/lido-game\".\n *\n * Inside that folder, we expect:\n * - code/lido-player.esm.js\n * - code/lido-player.js\n * - assets/ (optional)\n */\n @Prop() baseUrl: string = '';\n\n /**\n * If provided, we'll fetch this XML path once and pass the loaded string\n * to <lido-home>'s `xml-data` attribute.\n */\n @Prop() xmlPath?: string;\n\n /** The initial index to pass down to <lido-home>. Defaults to 0. */\n @Prop() initialIndex: number = 0;\n\n /** Whether the <lido-home> can play. Defaults to false. */\n @Prop() canplay: boolean = false;\n\n /** The height prop to pass to <lido-home>. Defaults to \"75vh\". */\n @Prop() height: string = '75vh';\n\n /**\n * Optional prop for directly providing XML data instead of fetching.\n */\n @Prop() xmlData?: string;\n\n /**\n * If provided(in index.html) → tries versioned script loading from config.json.\n * If no version is found → automatically falls back to default player loading.\n * If not provided → version management is skipped entirely and falls back to default player loading.\n */\n @Prop() codeFolderPath?: string;\n\n @Prop() commonAudioPath?: string;\n\n /** Whether scripts are already injected (remote or fallback). */\n @State() scriptsInjected: boolean = false;\n\n /** Stores the fetched or provided XML data. */\n @State() localXmlData?: string;\n\n /** This might be used by <lido-home> if referencing assets. */\n @State() xmlBaseUrl?: string;\n\n // Re-inject scripts if the baseUrl changes\n @Watch('baseUrl')\n onBaseUrlChange() {\n this.injectLidoScripts();\n }\n\n // Re-fetch XML if the xmlPath changes\n @Watch('xmlPath')\n onXmlPathChange() {\n this.fetchXmlData();\n }\n\n componentWillLoad() {\n // 1) Attempt to inject the Lido scripts from baseUrl\n this.injectLidoScripts();\n // 2) Fetch the XML (or use the xmlData if provided)\n this.fetchXmlData();\n }\n\n private async injectLidoScripts() {\n console.log('injectLidoScripts() called. baseUrl=', this.baseUrl);\n\n // If no baseUrl is provided OR we already injected scripts, just go to fallback\n if (!this.baseUrl) {\n console.warn('lido-standalone: No baseUrl provided. Using npm fallback...');\n this.fallbackNpmImport();\n return;\n }\n if (this.scriptsInjected) {\n return;\n }\n\n // Synchronously check if remote ESM script exists at baseUrl/code/lido-player.esm.js\n const cleanBase = this.baseUrl.replace(/\\/+$/, '');\n const scriptCheckUrl = `${cleanBase}/code/lido-player.esm.js`;\n const fileExists = this.doesFileExistSync(scriptCheckUrl);\n\n if (fileExists) {\n // If it exists, inject them\n const scriptEsm = document.createElement('script');\n scriptEsm.type = 'module';\n scriptEsm.src = scriptCheckUrl;\n document.head.appendChild(scriptEsm);\n\n // (Optional) NoModule script for older browsers\n const scriptNoModule = document.createElement('script');\n scriptNoModule.setAttribute('nomodule', '');\n scriptNoModule.src = `${cleanBase}/code/lido-player.js`;\n document.head.appendChild(scriptNoModule);\n\n this.scriptsInjected = true;\n console.debug('Lido scripts injected from:', this.baseUrl);\n }\n\n else if (this.codeFolderPath) {\n const cleanBase = this.baseUrl.replace(/\\/+$/, \"\");\n const cfgUrl = `${cleanBase}/config.json`;\n\n try {\n const res = await fetch(cfgUrl);\n\n if (!res.ok) {\n console.warn(\"config.json not found. Skipping versioning and continuing...\");\n throw new Error(\"config.json fetch failed\");\n } \n else {\n const cfg = await res.json();\n const version = cfg.codeVersion;\n\n if (!version) {\n console.warn(\"config.json missing codeVersion. Skipping versioning. Falling back to npm package lido-player...\");\n throw new Error(\"codeVersion missing in config.json\");\n } else {\n // --- Version exists: try to load versioned folder ---\n const codePath = this.codeFolderPath.replace(/\\/+$/, \"\");\n const versionFolder = `${codePath}/${version}`;\n\n const esmUrl = `${versionFolder}/lido-player.esm.js`;\n const noModuleUrl = `${versionFolder}/lido-player.js`;\n\n // Check if versioned ESM exists\n const headCheck = await fetch(esmUrl, { method: \"HEAD\" });\n\n if (!headCheck.ok) {\n console.warn(`Version folder found but lido-player.esm.js missing: ${esmUrl}`);\n } else {\n // --- Load versioned scripts (SUCCESS CASE) ---\n const scriptEsm = document.createElement(\"script\");\n scriptEsm.type = \"module\";\n scriptEsm.src = esmUrl;\n document.head.appendChild(scriptEsm);\n\n const scriptNoModule = document.createElement(\"script\");\n scriptNoModule.setAttribute(\"nomodule\", \"\");\n scriptNoModule.src = noModuleUrl;\n document.head.appendChild(scriptNoModule);\n\n this.scriptsInjected = true;\n console.debug(\"Loaded version from config.json:\", versionFolder);\n return; // return when version successfully loaded\n }\n }\n }\n } catch (e) {\n console.error(\"Failed to read config.json. Skipping versioning...\", e);\n this.fallbackNpmImport();\n }\n // If we reach this point, version loading FAILED → continue to final else\n }\n\n else {\n // Otherwise, fallback to the npm package\n console.warn(`Could not find remote scripts at \"${scriptCheckUrl}\". Falling back to npm package \"lido-player\"...`);\n this.fallbackNpmImport();\n }\n }\n\n /**\n * Synchronously checks if a file exists via HTTP HEAD request.\n * Returns true if status is 2xx, false otherwise.\n */\n private doesFileExistSync(url: string): boolean {\n let exists = false;\n try {\n const xhr = new XMLHttpRequest();\n xhr.open('HEAD', url, false); // false = synchronous\n xhr.send(null);\n exists = xhr.status >= 200 && xhr.status < 300;\n } catch (err) {\n console.warn('Synchronous HEAD request failed for:', url, err);\n }\n return exists;\n }\n\n /**\n * Fallback approach: dynamically import the \"lido-player/loader\" module,\n * then call defineCustomElements(window) to register the <lido-home> component.\n * This is asynchronous by nature.\n */\n private fallbackNpmImport() {\n import('lido-player/loader')\n .then(({ defineCustomElements }) => {\n // Register custom elements on 'window'\n defineCustomElements(window);\n // Mark scripts as loaded so we can proceed\n this.scriptsInjected = true;\n console.debug('Lido scripts loaded via npm fallback (defineCustomElements).');\n })\n .catch(err => {\n console.error('Failed to load from npm package \"lido-player\":', err);\n });\n }\n\n private fetchXmlData() {\n // If the user provided raw XML data, just store it\n if (this.xmlData) {\n this.localXmlData = this.xmlData;\n return;\n }\n\n // If xmlPath is not explicitly provided, default to `index.xml` in baseUrl\n if (!this.xmlPath) {\n if (this.baseUrl) {\n const cleanBase = this.baseUrl.replace(/\\/+$/, '');\n this.xmlPath = `${cleanBase}/index.xml`;\n this.xmlBaseUrl = this.baseUrl;\n } else {\n return;\n }\n }\n\n try {\n const xhr = new XMLHttpRequest();\n xhr.open('GET', this.xmlPath, false); // false = synchronous\n xhr.send(null);\n\n if (xhr.status >= 200 && xhr.status < 300) {\n this.localXmlData = xhr.responseText;\n } else {\n console.warn(`Failed to fetch XML from ${this.xmlPath}:`, xhr.status);\n }\n } catch (err) {\n console.warn(`Error fetching XML from ${this.xmlPath}:`, err);\n }\n }\n\n render() {\n /**\n * If you want to hide <lido-home> until the fallback is fully loaded,\n * you could do something like:\n *\n * if (!this.scriptsInjected) {\n * return <div>Loading Lido...</div>;\n * }\n *\n * This ensures the custom elements are defined before usage.\n */\n\n return <lido-home common-audio-path={this.commonAudioPath} initial-index={this.initialIndex} canplay={this.canplay} height={this.height} xml-data={this.localXmlData} base-url={this.xmlBaseUrl} code-folder-path={this.codeFolderPath}></lido-home>;\n }\n\n \n}\n\n\n"],"version":3}
|
|
1
|
+
{"file":"lido-standalone.entry.cjs.js","mappings":";;;;;;AAAA,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAC7B,6BAAe,iBAAiB;;MCqBnB,cAAc;;;uBAYC,EAAE;;4BASG,CAAC;uBAGL,KAAK;sBAGP,MAAM;;;;;;+BAyBK,KAAK;;;;;IAUzC,eAAe;QACb,IAAI,CAAC,iBAAiB,EAAE,CAAC;KAC1B;;IAID,eAAe;QACb,IAAI,CAAC,YAAY,EAAE,CAAC;KACrB;;IAID,eAAe;QACb,IAAI,CAAC,YAAY,EAAE,CAAC;KACrB;IAED,iBAAiB;;QAEf,IAAI,CAAC,iBAAiB,EAAE,CAAC;;QAEzB,IAAI,CAAC,YAAY,EAAE,CAAC;KACrB;IAEO,MAAM,iBAAiB;QAC7B,OAAO,CAAC,GAAG,CAAC,sCAAsC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;;QAGlE,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACjB,OAAO,CAAC,IAAI,CAAC,6DAA6D,CAAC,CAAC;YAC5E,IAAI,CAAC,iBAAiB,EA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F;QAAC,OAAO,GAAG,EAAE;YACZ,OAAO,CAAC,IAAI,CAAC,2BAA2B,IAAI,CAAC,OAAO,GAAG,EAAE,GAAG,CAAC,CAAC;SAC/D;KACF;IAED,MAAM;;;;;;;;;;;QAYJ,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC;QACnC,OAAOA,6FAA+B,IAAI,CAAC,eAAe,mBAAiB,IAAI,CAAC,YAAY,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,cAAY,IAAI,CAAC,YAAY,cAAY,IAAI,CAAC,UAAU,sBAAoB,IAAI,CAAC,cAAc,aAAW,IAAI,CAAC,MAAM,GAAc,CAAC;KACzR;;;;;;;;;;;;","names":["h"],"sources":["src/components/lido-standalone/lido-standalone.css?tag=lido-standalone","src/components/lido-standalone/lido-standalone.tsx"],"sourcesContent":["","import { Component, Element, Prop, State, Watch, h } from '@stencil/core';\n\n/**\n * <lido-standalone> usage example:\n *\n * <lido-standalone\n * base-url=\"https://example.com/path/to/folder/lido-game\"\n * xml-path=\"https://example.com/path/to/folder/lido-game/assets/xmlData.xml\"\n * initial-index=\"2\"\n * canplay=\"true\"\n * height=\"75vh\"\n * ></lido-standalone>\n *\n * This attempts to load the external Lido scripts at runtime (from `baseUrl`).\n * If they aren't found, it falls back to loading the Lido npm package\n * and calls defineCustomElements(...) to register <lido-home>.\n */\n@Component({\n tag: 'lido-standalone',\n styleUrl: 'lido-standalone.css',\n shadow: false,\n})\nexport class LidoStandalone {\n @Element() hostElement!: HTMLElement;\n\n /**\n * The public URL where the unzipped Lido code is hosted, e.g.\n * \"https://example.com/path/to/lido-game\".\n *\n * Inside that folder, we expect:\n * - code/lido-player.esm.js\n * - code/lido-player.js\n * - assets/ (optional)\n */\n @Prop() baseUrl: string = '';\n\n /**\n * If provided, we'll fetch this XML path once and pass the loaded string\n * to <lido-home>'s `xml-data` attribute.\n */\n @Prop() xmlPath?: string;\n\n /** The initial index to pass down to <lido-home>. Defaults to 0. */\n @Prop() initialIndex: number = 0;\n\n /** Whether the <lido-home> can play. Defaults to false. */\n @Prop() canplay: boolean = false;\n\n /** The height prop to pass to <lido-home>. Defaults to \"75vh\". */\n @Prop() height: string = '75vh';\n\n /** The language prop to pass to <lido-home>. */\n @Prop() language?: string;\n\n /**\n * Optional prop for directly providing XML data instead of fetching.\n */\n @Prop() xmlData?: string;\n\n /**\n * To pass zip file directly to <lido-home> as its attribute.\n */\n @Prop() zipUrl?: string;\n\n /**\n * If provided(in index.html) → tries versioned script loading from config.json.\n * If no version is found → automatically falls back to default player loading.\n * If not provided → version management is skipped entirely and falls back to default player loading.\n */\n @Prop() codeFolderPath?: string;\n\n @Prop() commonAudioPath?: string;\n\n /** Whether scripts are already injected (remote or fallback). */\n @State() scriptsInjected: boolean = false;\n\n /** Stores the fetched or provided XML data. */\n @State() localXmlData?: string;\n\n /** This might be used by <lido-home> if referencing assets. */\n @State() xmlBaseUrl?: string;\n\n // Re-inject scripts if the baseUrl changes\n @Watch('baseUrl')\n onBaseUrlChange() {\n this.injectLidoScripts();\n }\n\n // Re-fetch XML if the xmlPath changes\n @Watch('xmlPath')\n onXmlPathChange() {\n this.fetchXmlData();\n }\n\n // Re-apply inline XML whenever the host prop changes.\n @Watch('xmlData')\n onXmlDataChange() {\n this.fetchXmlData();\n }\n\n componentWillLoad() {\n // 1) Attempt to inject the Lido scripts from baseUrl\n this.injectLidoScripts();\n // 2) Fetch the XML (or use the xmlData if provided)\n this.fetchXmlData();\n }\n\n private async injectLidoScripts() {\n console.log('injectLidoScripts() called. baseUrl=', this.baseUrl);\n\n // If no baseUrl is provided OR we already injected scripts, just go to fallback\n if (!this.baseUrl) {\n console.warn('lido-standalone: No baseUrl provided. Using npm fallback...');\n this.fallbackNpmImport();\n return;\n }\n if (this.scriptsInjected) {\n return;\n }\n\n // Synchronously check if remote ESM script exists at baseUrl/code/lido-player.esm.js\n const cleanBase = this.baseUrl.replace(/\\/+$/, '');\n const scriptCheckUrl = `${cleanBase}/code/lido-player.esm.js`;\n const fileExists = this.doesFileExistSync(scriptCheckUrl);\n\n // --------------- CASE: NO codeFolderPath PROVIDED ---------------\n // Try loading version from default /code_versions folder\n // --------------- SINGLE CASE: codeFolderPath PROVIDED ---------------\n\n if (fileExists) {\n console.log(\"Using code from zip....\")\n // If it exists, inject them\n const scriptEsm = document.createElement('script');\n scriptEsm.type = 'module';\n scriptEsm.src = scriptCheckUrl;\n document.head.appendChild(scriptEsm);\n // (Optional) NoModule script for older browsers\n const scriptNoModule = document.createElement('script');\n scriptNoModule.setAttribute('nomodule', '');\n scriptNoModule.src = `${cleanBase}/code/lido-player.js`;\n document.head.appendChild(scriptNoModule);\n this.scriptsInjected = true;\n console.debug('Lido scripts injected from:', this.baseUrl);\n return;\n }\n \n if (this.codeFolderPath) {\n const cleanBase = this.baseUrl.replace(/\\/+$/, \"\");\n try {\n const lessonCfgUrl = `${cleanBase}/config.json`;\n try {\n // 1️⃣ Load lesson config.json safely\n let lessonCfg: any = {};\n let lessonVersion: string | null = null;\n\n try {\n const lessonResp = await fetch(lessonCfgUrl);\n if (!lessonResp.ok) throw new Error(\"Lesson config.json missing\");\n\n // Check for empty file (0 bytes)\n const text = await lessonResp.text();\n if (text.trim().length > 0) {\n lessonCfg = JSON.parse(text);\n } else {\n console.warn(\"Lesson config.json is EMPTY → falling back to latest version\");\n }\n\n lessonVersion = lessonCfg.code_version;\n console.log(`%c USING THE VERSION FOLDER--> ${lessonVersion} `,\"color: #3bffe8ff; background:#d32f2f; font-size: 15px; font-weight: bold; padding: 6px 10px; border-radius: 4px;\");\n\n } catch (parseErr) {\n console.warn(\"Lesson config.json invalid or unreadable → fallback to latest version\");\n lessonVersion = null;\n }\n\n // Normalize invalid versions\n if (!lessonVersion || typeof lessonVersion !== \"string\" || lessonVersion.trim() === \"\") {\n console.warn(\"Lesson has NO valid codeVersion → using latest version in code-folder-path\");\n lessonVersion = null;\n }\n\n // 2️⃣ Load version list from code-folder-path/config.json\n const codeCfgUrl = `${this.codeFolderPath.replace(/\\/+$/, '')}/config.json`;\n const codeResp = await fetch(codeCfgUrl);\n if (!codeResp.ok) throw new Error(\"Code-folder config.json missing\");\n\n const codeCfg = await codeResp.json();\n const availableVersions: string[] = codeCfg.versions || [];\n\n if (!availableVersions.length) {\n throw new Error(\"No versions listed in code-folder config.json\");\n }\n\n // 3️⃣ Compute selected version\n let selectedVersion: string | undefined = null;\n\n if (lessonVersion) {\n selectedVersion = availableVersions.find(v => v.includes(lessonVersion));\n }\n\n // Fallback: use latest version\n if (!selectedVersion) {\n selectedVersion = availableVersions[availableVersions.length - 1];\n console.log(`%c USING THE LATEST VERSION FOLDER-> ${selectedVersion} `,\"color: #3bffe8ff; background:#d32f2f; font-size: 15px; font-weight: bold; padding: 6px 10px; border-radius: 4px;\");\n }\n\n // 4️⃣ Inject scripts\n const versionDir = `${this.codeFolderPath}/${selectedVersion}`;\n const esmUrl = `${versionDir}/lido-player.esm.js`;\n const noModuleUrl = `${versionDir}/lido-player.js`;\n\n // Check if version folder exists\n const headCheck = await fetch(esmUrl, { method: \"HEAD\" });\n if (!headCheck.ok) throw new Error(`Versioned script missing: ${esmUrl}`);\n\n // Inject main module file\n const scriptEsm = document.createElement(\"script\");\n scriptEsm.type = \"module\";\n scriptEsm.src = esmUrl;\n document.head.appendChild(scriptEsm);\n\n // Inject fallback nomodule script\n const scriptNoModule = document.createElement(\"script\");\n scriptNoModule.setAttribute(\"nomodule\", \"\");\n scriptNoModule.src = noModuleUrl;\n document.head.appendChild(scriptNoModule);\n\n this.scriptsInjected = true;\n console.debug(\"Loaded Lido version from:\", versionDir);\n\n }catch (err) {\n console.warn(\"Failed to load versioned scripts, falling back to npm:\", err);\n this.fallbackNpmImport();\n } \n } catch (err) {\n console.warn(\"Failed loading scripts → fallback to npm:\", err);\n this.fallbackNpmImport();\n }\n return;\n }\n this.fallbackNpmImport();\n }\n\n /**\n * Checks if a file truly exists (not a dev-server fallback).\n * Ensures:\n * - HTTP HEAD returns 2xx\n * - responseURL matches the requested URL\n */\nprivate doesFileExistSync(url: string): boolean {\n try {\n const xhr = new XMLHttpRequest();\n xhr.open(\"HEAD\", url, false); // synchronous\n xhr.send();\n\n const statusOk = xhr.status >= 200 && xhr.status < 300;\n\n if (!statusOk) return false;\n\n // Detect fallback HTML responses (common when folder/file is missing)\n const contentType = xhr.getResponseHeader(\"Content-Type\") || \"\";\n\n const isHtmlFallback = contentType.includes(\"text/html\");\n\n return !isHtmlFallback;\n } catch (err) {\n console.warn(\"File existence check failed for:\", url, err);\n return false;\n }\n}\n\n\n /**\n * Fallback approach: dynamically import the \"lido-player/loader\" module,\n * then call defineCustomElements(window) to register the <lido-home> component.\n * This is asynchronous by nature.\n */\n private fallbackNpmImport() {\n import('lido-player/loader')\n .then(({ defineCustomElements }) => {\n // Register custom elements on 'window'\n defineCustomElements(window);\n // Mark scripts as loaded so we can proceed\n this.scriptsInjected = true;\n console.debug('Lido scripts loaded via npm fallback (defineCustomElements).');\n })\n .catch(err => {\n console.error('Failed to load from npm package \"lido-player\":', err);\n });\n }\n\n private fetchXmlData() {\n // If the user provided raw XML data, just store it\n if (this.xmlData) {\n this.localXmlData = this.xmlData;\n return;\n }\n\n // If xmlPath is not explicitly provided, default to `index.xml` in baseUrl\n if (this.baseUrl) {\n const cleanBase = this.baseUrl.replace(/\\/+$/, '');\n this.xmlPath = `${cleanBase}/index.xml`;\n this.xmlBaseUrl = this.baseUrl;\n } else {\n return;\n }\n\n try {\n const xhr = new XMLHttpRequest();\n xhr.open('GET', this.xmlPath, false); // false = synchronous\n xhr.send(null);\n\n if (xhr.status >= 200 && xhr.status < 300) {\n this.localXmlData = xhr.responseText;\n } else {\n console.warn(`Failed to fetch XML from ${this.xmlPath}:`, xhr.status);\n }\n } catch (err) {\n console.warn(`Error fetching XML from ${this.xmlPath}:`, err);\n }\n }\n\n render() {\n /**\n * If you want to hide <lido-home> until the fallback is fully loaded,\n * you could do something like:\n *\n * if (!this.scriptsInjected) {\n * return <div>Loading Lido...</div>;\n * }\n *\n * This ensures the custom elements are defined before usage.\n */\n\n const lang = this.language || 'en';\n return <lido-home common-audio-path={this.commonAudioPath} initial-index={this.initialIndex} canplay={this.canplay} height={this.height} lang={lang} xml-data={this.localXmlData} base-url={this.xmlBaseUrl} code-folder-path={this.codeFolderPath} zip-url={this.zipUrl}></lido-home>;\n }\n\n \n}\n\n\n"],"version":3}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const index = require('./index-
|
|
5
|
+
const index = require('./index-9a2514de.js');
|
|
6
6
|
const appGlobals = require('./app-globals-3a1e7e63.js');
|
|
7
7
|
|
|
8
8
|
/*
|
|
@@ -19,7 +19,7 @@ var patchBrowser = () => {
|
|
|
19
19
|
|
|
20
20
|
patchBrowser().then(async (options) => {
|
|
21
21
|
await appGlobals.globalScripts();
|
|
22
|
-
return index.bootstrapLazy([["lido-standalone.cjs",[[0,"lido-standalone",{"baseUrl":[1,"base-url"],"xmlPath":[1,"xml-path"],"initialIndex":[2,"initial-index"],"canplay":[4],"height":[1],"xmlData":[1,"xml-data"],"codeFolderPath":[1,"code-folder-path"],"commonAudioPath":[1,"common-audio-path"],"scriptsInjected":[32],"localXmlData":[32],"xmlBaseUrl":[32]},null,{"baseUrl":["onBaseUrlChange"],"xmlPath":["onXmlPathChange"]}]]]], options);
|
|
22
|
+
return index.bootstrapLazy([["lido-standalone.cjs",[[0,"lido-standalone",{"baseUrl":[1,"base-url"],"xmlPath":[1,"xml-path"],"initialIndex":[2,"initial-index"],"canplay":[4],"height":[1],"language":[1],"xmlData":[1,"xml-data"],"zipUrl":[1,"zip-url"],"codeFolderPath":[1,"code-folder-path"],"commonAudioPath":[1,"common-audio-path"],"scriptsInjected":[32],"localXmlData":[32],"xmlBaseUrl":[32]},null,{"baseUrl":["onBaseUrlChange"],"xmlPath":["onXmlPathChange"],"xmlData":["onXmlDataChange"]}]]]], options);
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
exports.setNonce = index.setNonce;
|
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const index = require('./index-
|
|
5
|
+
const index = require('./index-9a2514de.js');
|
|
6
6
|
const appGlobals = require('./app-globals-3a1e7e63.js');
|
|
7
7
|
|
|
8
8
|
const defineCustomElements = async (win, options) => {
|
|
9
9
|
if (typeof window === 'undefined') return undefined;
|
|
10
10
|
await appGlobals.globalScripts();
|
|
11
|
-
return index.bootstrapLazy([["lido-standalone.cjs",[[0,"lido-standalone",{"baseUrl":[1,"base-url"],"xmlPath":[1,"xml-path"],"initialIndex":[2,"initial-index"],"canplay":[4],"height":[1],"xmlData":[1,"xml-data"],"codeFolderPath":[1,"code-folder-path"],"commonAudioPath":[1,"common-audio-path"],"scriptsInjected":[32],"localXmlData":[32],"xmlBaseUrl":[32]},null,{"baseUrl":["onBaseUrlChange"],"xmlPath":["onXmlPathChange"]}]]]], options);
|
|
11
|
+
return index.bootstrapLazy([["lido-standalone.cjs",[[0,"lido-standalone",{"baseUrl":[1,"base-url"],"xmlPath":[1,"xml-path"],"initialIndex":[2,"initial-index"],"canplay":[4],"height":[1],"language":[1],"xmlData":[1,"xml-data"],"zipUrl":[1,"zip-url"],"codeFolderPath":[1,"code-folder-path"],"commonAudioPath":[1,"common-audio-path"],"scriptsInjected":[32],"localXmlData":[32],"xmlBaseUrl":[32]},null,{"baseUrl":["onBaseUrlChange"],"xmlPath":["onXmlPathChange"],"xmlData":["onXmlDataChange"]}]]]], options);
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
exports.setNonce = index.setNonce;
|