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.
Files changed (37) hide show
  1. package/dist/cjs/{index-52f24ddb.js → index-9a2514de.js} +3 -1
  2. package/dist/cjs/index-9a2514de.js.map +1 -0
  3. package/dist/cjs/index.cjs.js +1 -1
  4. package/dist/cjs/lido-standalone.cjs.entry.js +114 -65
  5. package/dist/cjs/lido-standalone.cjs.entry.js.map +1 -1
  6. package/dist/cjs/lido-standalone.cjs.js +2 -2
  7. package/dist/cjs/loader.cjs.js +2 -2
  8. package/dist/collection/components/lido-standalone/lido-standalone.js +148 -63
  9. package/dist/collection/components/lido-standalone/lido-standalone.js.map +1 -1
  10. package/dist/components/lido-standalone.js +117 -65
  11. package/dist/components/lido-standalone.js.map +1 -1
  12. package/dist/esm/{index-5da3b4be.js → index-32cd7d72.js} +3 -2
  13. package/dist/esm/index-32cd7d72.js.map +1 -0
  14. package/dist/esm/index.js +1 -1
  15. package/dist/esm/lido-standalone.entry.js +114 -65
  16. package/dist/esm/lido-standalone.entry.js.map +1 -1
  17. package/dist/esm/lido-standalone.js +3 -3
  18. package/dist/esm/loader.js +3 -3
  19. package/dist/lido-standalone/index.esm.js +1 -1
  20. package/dist/lido-standalone/lido-standalone.esm.js +1 -1
  21. package/dist/lido-standalone/lido-standalone.esm.js.map +1 -1
  22. package/dist/lido-standalone/p-1469ddb8.js +3 -0
  23. package/dist/lido-standalone/p-1469ddb8.js.map +1 -0
  24. package/dist/lido-standalone/p-862a6695.entry.js +2 -0
  25. package/dist/lido-standalone/p-862a6695.entry.js.map +1 -0
  26. package/dist/types/components/lido-standalone/lido-standalone.d.ts +13 -3
  27. package/dist/types/components.d.ts +16 -0
  28. package/package.json +1 -1
  29. package/src/components/lido-standalone/lido-standalone.tsx +142 -77
  30. package/src/components/lido-standalone/readme.md +2 -0
  31. package/src/components.d.ts +16 -0
  32. package/dist/cjs/index-52f24ddb.js.map +0 -1
  33. package/dist/esm/index-5da3b4be.js.map +0 -1
  34. package/dist/lido-standalone/p-1bb50e6d.entry.js +0 -2
  35. package/dist/lido-standalone/p-1bb50e6d.entry.js.map +0 -1
  36. package/dist/lido-standalone/p-3a3323c8.js +0 -3
  37. package/dist/lido-standalone/p-3a3323c8.js.map +0 -1
@@ -12,7 +12,9 @@ const LidoStandalone$1 = /*@__PURE__*/ proxyCustomElement(class LidoStandalone e
12
12
  this.initialIndex = 0;
13
13
  this.canplay = false;
14
14
  this.height = '75vh';
15
+ this.language = undefined;
15
16
  this.xmlData = undefined;
17
+ this.zipUrl = undefined;
16
18
  this.codeFolderPath = undefined;
17
19
  this.commonAudioPath = undefined;
18
20
  this.scriptsInjected = false;
@@ -27,6 +29,10 @@ const LidoStandalone$1 = /*@__PURE__*/ proxyCustomElement(class LidoStandalone e
27
29
  onXmlPathChange() {
28
30
  this.fetchXmlData();
29
31
  }
32
+ // Re-apply inline XML whenever the host prop changes.
33
+ onXmlDataChange() {
34
+ this.fetchXmlData();
35
+ }
30
36
  componentWillLoad() {
31
37
  // 1) Attempt to inject the Lido scripts from baseUrl
32
38
  this.injectLidoScripts();
@@ -48,7 +54,11 @@ const LidoStandalone$1 = /*@__PURE__*/ proxyCustomElement(class LidoStandalone e
48
54
  const cleanBase = this.baseUrl.replace(/\/+$/, '');
49
55
  const scriptCheckUrl = `${cleanBase}/code/lido-player.esm.js`;
50
56
  const fileExists = this.doesFileExistSync(scriptCheckUrl);
57
+ // --------------- CASE: NO codeFolderPath PROVIDED ---------------
58
+ // Try loading version from default /code_versions folder
59
+ // --------------- SINGLE CASE: codeFolderPath PROVIDED ---------------
51
60
  if (fileExists) {
61
+ console.log("Using code from zip....");
52
62
  // If it exists, inject them
53
63
  const scriptEsm = document.createElement('script');
54
64
  scriptEsm.type = 'module';
@@ -61,79 +71,117 @@ const LidoStandalone$1 = /*@__PURE__*/ proxyCustomElement(class LidoStandalone e
61
71
  document.head.appendChild(scriptNoModule);
62
72
  this.scriptsInjected = true;
63
73
  console.debug('Lido scripts injected from:', this.baseUrl);
74
+ return;
64
75
  }
65
- else if (this.codeFolderPath) {
76
+ if (this.codeFolderPath) {
66
77
  const cleanBase = this.baseUrl.replace(/\/+$/, "");
67
- const cfgUrl = `${cleanBase}/config.json`;
68
78
  try {
69
- const res = await fetch(cfgUrl);
70
- if (!res.ok) {
71
- console.warn("config.json not found. Skipping versioning and continuing...");
72
- throw new Error("config.json fetch failed");
73
- }
74
- else {
75
- const cfg = await res.json();
76
- const version = cfg.codeVersion;
77
- if (!version) {
78
- console.warn("config.json missing codeVersion. Skipping versioning. Falling back to npm package lido-player...");
79
- throw new Error("codeVersion missing in config.json");
80
- }
81
- else {
82
- // --- Version exists: try to load versioned folder ---
83
- const codePath = this.codeFolderPath.replace(/\/+$/, "");
84
- const versionFolder = `${codePath}/${version}`;
85
- const esmUrl = `${versionFolder}/lido-player.esm.js`;
86
- const noModuleUrl = `${versionFolder}/lido-player.js`;
87
- // Check if versioned ESM exists
88
- const headCheck = await fetch(esmUrl, { method: "HEAD" });
89
- if (!headCheck.ok) {
90
- console.warn(`Version folder found but lido-player.esm.js missing: ${esmUrl}`);
79
+ const lessonCfgUrl = `${cleanBase}/config.json`;
80
+ try {
81
+ // 1️⃣ Load lesson config.json safely
82
+ let lessonCfg = {};
83
+ let lessonVersion = null;
84
+ try {
85
+ const lessonResp = await fetch(lessonCfgUrl);
86
+ if (!lessonResp.ok)
87
+ throw new Error("Lesson config.json missing");
88
+ // Check for empty file (0 bytes)
89
+ const text = await lessonResp.text();
90
+ if (text.trim().length > 0) {
91
+ lessonCfg = JSON.parse(text);
91
92
  }
92
93
  else {
93
- // --- Load versioned scripts (SUCCESS CASE) ---
94
- const scriptEsm = document.createElement("script");
95
- scriptEsm.type = "module";
96
- scriptEsm.src = esmUrl;
97
- document.head.appendChild(scriptEsm);
98
- const scriptNoModule = document.createElement("script");
99
- scriptNoModule.setAttribute("nomodule", "");
100
- scriptNoModule.src = noModuleUrl;
101
- document.head.appendChild(scriptNoModule);
102
- this.scriptsInjected = true;
103
- console.debug("Loaded version from config.json:", versionFolder);
104
- return; // return when version successfully loaded
94
+ console.warn("Lesson config.json is EMPTY → falling back to latest version");
105
95
  }
96
+ lessonVersion = lessonCfg.code_version;
97
+ console.log(`%c USING THE VERSION FOLDER--> ${lessonVersion} `, "color: #3bffe8ff; background:#d32f2f; font-size: 15px; font-weight: bold; padding: 6px 10px; border-radius: 4px;");
98
+ }
99
+ catch (parseErr) {
100
+ console.warn("Lesson config.json invalid or unreadable → fallback to latest version");
101
+ lessonVersion = null;
106
102
  }
103
+ // Normalize invalid versions
104
+ if (!lessonVersion || typeof lessonVersion !== "string" || lessonVersion.trim() === "") {
105
+ console.warn("Lesson has NO valid codeVersion → using latest version in code-folder-path");
106
+ lessonVersion = null;
107
+ }
108
+ // 2️⃣ Load version list from code-folder-path/config.json
109
+ const codeCfgUrl = `${this.codeFolderPath.replace(/\/+$/, '')}/config.json`;
110
+ const codeResp = await fetch(codeCfgUrl);
111
+ if (!codeResp.ok)
112
+ throw new Error("Code-folder config.json missing");
113
+ const codeCfg = await codeResp.json();
114
+ const availableVersions = codeCfg.versions || [];
115
+ if (!availableVersions.length) {
116
+ throw new Error("No versions listed in code-folder config.json");
117
+ }
118
+ // 3️⃣ Compute selected version
119
+ let selectedVersion = null;
120
+ if (lessonVersion) {
121
+ selectedVersion = availableVersions.find(v => v.includes(lessonVersion));
122
+ }
123
+ // Fallback: use latest version
124
+ if (!selectedVersion) {
125
+ selectedVersion = availableVersions[availableVersions.length - 1];
126
+ 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;");
127
+ }
128
+ // 4️⃣ Inject scripts
129
+ const versionDir = `${this.codeFolderPath}/${selectedVersion}`;
130
+ const esmUrl = `${versionDir}/lido-player.esm.js`;
131
+ const noModuleUrl = `${versionDir}/lido-player.js`;
132
+ // Check if version folder exists
133
+ const headCheck = await fetch(esmUrl, { method: "HEAD" });
134
+ if (!headCheck.ok)
135
+ throw new Error(`Versioned script missing: ${esmUrl}`);
136
+ // Inject main module file
137
+ const scriptEsm = document.createElement("script");
138
+ scriptEsm.type = "module";
139
+ scriptEsm.src = esmUrl;
140
+ document.head.appendChild(scriptEsm);
141
+ // Inject fallback nomodule script
142
+ const scriptNoModule = document.createElement("script");
143
+ scriptNoModule.setAttribute("nomodule", "");
144
+ scriptNoModule.src = noModuleUrl;
145
+ document.head.appendChild(scriptNoModule);
146
+ this.scriptsInjected = true;
147
+ console.debug("Loaded Lido version from:", versionDir);
148
+ }
149
+ catch (err) {
150
+ console.warn("Failed to load versioned scripts, falling back to npm:", err);
151
+ this.fallbackNpmImport();
107
152
  }
108
153
  }
109
- catch (e) {
110
- console.error("Failed to read config.json. Skipping versioning...", e);
154
+ catch (err) {
155
+ console.warn("Failed loading scripts → fallback to npm:", err);
111
156
  this.fallbackNpmImport();
112
157
  }
113
- // If we reach this point, version loading FAILED → continue to final else
114
- }
115
- else {
116
- // Otherwise, fallback to the npm package
117
- console.warn(`Could not find remote scripts at "${scriptCheckUrl}". Falling back to npm package "lido-player"...`);
118
- this.fallbackNpmImport();
158
+ return;
119
159
  }
160
+ this.fallbackNpmImport();
120
161
  }
121
162
  /**
122
- * Synchronously checks if a file exists via HTTP HEAD request.
123
- * Returns true if status is 2xx, false otherwise.
124
- */
163
+ * Checks if a file truly exists (not a dev-server fallback).
164
+ * Ensures:
165
+ * - HTTP HEAD returns 2xx
166
+ * - responseURL matches the requested URL
167
+ */
125
168
  doesFileExistSync(url) {
126
- let exists = false;
127
169
  try {
128
170
  const xhr = new XMLHttpRequest();
129
- xhr.open('HEAD', url, false); // false = synchronous
130
- xhr.send(null);
131
- exists = xhr.status >= 200 && xhr.status < 300;
171
+ xhr.open("HEAD", url, false); // synchronous
172
+ xhr.send();
173
+ const statusOk = xhr.status >= 200 && xhr.status < 300;
174
+ if (!statusOk)
175
+ return false;
176
+ // Detect fallback HTML responses (common when folder/file is missing)
177
+ const contentType = xhr.getResponseHeader("Content-Type") || "";
178
+ const isHtmlFallback = contentType.includes("text/html");
179
+ return !isHtmlFallback;
132
180
  }
133
181
  catch (err) {
134
- console.warn('Synchronous HEAD request failed for:', url, err);
182
+ console.warn("File existence check failed for:", url, err);
183
+ return false;
135
184
  }
136
- return exists;
137
185
  }
138
186
  /**
139
187
  * Fallback approach: dynamically import the "lido-player/loader" module,
@@ -160,15 +208,13 @@ const LidoStandalone$1 = /*@__PURE__*/ proxyCustomElement(class LidoStandalone e
160
208
  return;
161
209
  }
162
210
  // If xmlPath is not explicitly provided, default to `index.xml` in baseUrl
163
- if (!this.xmlPath) {
164
- if (this.baseUrl) {
165
- const cleanBase = this.baseUrl.replace(/\/+$/, '');
166
- this.xmlPath = `${cleanBase}/index.xml`;
167
- this.xmlBaseUrl = this.baseUrl;
168
- }
169
- else {
170
- return;
171
- }
211
+ if (this.baseUrl) {
212
+ const cleanBase = this.baseUrl.replace(/\/+$/, '');
213
+ this.xmlPath = `${cleanBase}/index.xml`;
214
+ this.xmlBaseUrl = this.baseUrl;
215
+ }
216
+ else {
217
+ return;
172
218
  }
173
219
  try {
174
220
  const xhr = new XMLHttpRequest();
@@ -196,11 +242,14 @@ const LidoStandalone$1 = /*@__PURE__*/ proxyCustomElement(class LidoStandalone e
196
242
  *
197
243
  * This ensures the custom elements are defined before usage.
198
244
  */
199
- return h("lido-home", { key: '4e0aae8e3dae8ebc2b78fbbe97b9cbd3e08b6ff1', "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 });
245
+ const lang = this.language || 'en';
246
+ return 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 });
200
247
  }
248
+ get hostElement() { return this; }
201
249
  static get watchers() { return {
202
250
  "baseUrl": ["onBaseUrlChange"],
203
- "xmlPath": ["onXmlPathChange"]
251
+ "xmlPath": ["onXmlPathChange"],
252
+ "xmlData": ["onXmlDataChange"]
204
253
  }; }
205
254
  static get style() { return LidoStandaloneStyle0; }
206
255
  }, [0, "lido-standalone", {
@@ -209,7 +258,9 @@ const LidoStandalone$1 = /*@__PURE__*/ proxyCustomElement(class LidoStandalone e
209
258
  "initialIndex": [2, "initial-index"],
210
259
  "canplay": [4],
211
260
  "height": [1],
261
+ "language": [1],
212
262
  "xmlData": [1, "xml-data"],
263
+ "zipUrl": [1, "zip-url"],
213
264
  "codeFolderPath": [1, "code-folder-path"],
214
265
  "commonAudioPath": [1, "common-audio-path"],
215
266
  "scriptsInjected": [32],
@@ -217,7 +268,8 @@ const LidoStandalone$1 = /*@__PURE__*/ proxyCustomElement(class LidoStandalone e
217
268
  "xmlBaseUrl": [32]
218
269
  }, undefined, {
219
270
  "baseUrl": ["onBaseUrlChange"],
220
- "xmlPath": ["onXmlPathChange"]
271
+ "xmlPath": ["onXmlPathChange"],
272
+ "xmlData": ["onXmlDataChange"]
221
273
  }]);
222
274
  function defineCustomElement$1() {
223
275
  if (typeof customElements === "undefined") {
@@ -1 +1 @@
1
- {"file":"lido-standalone.js","mappings":";;AAAA,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAC7B,6BAAe,iBAAiB;;MCqBnBA,gBAAc;;;;uBAUC,EAAE;;4BASG,CAAC;uBAGL,KAAK;sBAGP,MAAM;;;;+BAiBK,KAAK;;;;;IAUzC,eAAe;QACb,IAAI,CAAC,iBAAiB,EAAE,CAAC;KAC1B;;IAID,eAAe;QACb,IAAI,CAAC,YAAY,EAAE,CAAC;KACrB;IAED,iBAAiB;;QAEf,IAAI,CAAC,iBAAi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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,OAAO,uFAA+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":["LidoStandalone"],"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.js","mappings":";;AAAA,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAC7B,6BAAe,iBAAiB;;MCqBnBA,gBAAc;;;;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,EAAE,CAAC;YACzB,OAAO;SACR;QACD,IAAI,IAAI,CAAC,eAAe,EAAE;YACxB,OAAO;SACR;;QAGD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QACnD,MAAM,cAAc,GAAG,GAAG,SAAS,0BAA0B,CAAC;QAC9D,MAAM,UAAU,GAAG,IAAI,CAAC,iBAAiB,CAAC,cAAc,CAAC,CAAC;;;;QAM1D,IAAI,UAAU,EAAE;YACd,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAA;;YAEtC,MAAM,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CAAC,YAAY,cAAY,IAAI,CAAC,UAAU,sBAAoB,IAAI,CAAC,cAAc,aAAW,IAAI,CAAC,MAAM,GAAc,CAAC;KACzR;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["LidoStandalone"],"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}
@@ -281,6 +281,7 @@ var parsePropertyValue = (propValue, propType) => {
281
281
  }
282
282
  return propValue;
283
283
  };
284
+ var getElement = (ref) => getHostRef(ref).$hostElement$ ;
284
285
  var emitEvent = (elm, name, opts) => {
285
286
  const ev = plt.ce(name, opts);
286
287
  elm.dispatchEvent(ev);
@@ -1121,6 +1122,6 @@ var bootstrapLazy = (lazyBundles, options = {}) => {
1121
1122
  // src/runtime/nonce.ts
1122
1123
  var setNonce = (nonce) => plt.$nonce$ = nonce;
1123
1124
 
1124
- export { bootstrapLazy as b, forceUpdate as f, getRenderingRef as g, h, promiseResolve as p, registerInstance as r, setNonce as s };
1125
+ export { getElement as a, bootstrapLazy as b, forceUpdate as f, getRenderingRef as g, h, promiseResolve as p, registerInstance as r, setNonce as s };
1125
1126
 
1126
- //# sourceMappingURL=index-5da3b4be.js.map
1127
+ //# sourceMappingURL=index-32cd7d72.js.map