@hortonstudio/main 1.2.11 → 1.2.12
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/attributes-master/package.json +1 -1
- package/debug-version.html +37 -0
- package/index.js +16 -3
- package/package.json +1 -1
@@ -0,0 +1,37 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>CDN Version Debug Test</title>
|
5
|
+
</head>
|
6
|
+
<body>
|
7
|
+
<h1>CDN Version Debug Test</h1>
|
8
|
+
<div id="results"></div>
|
9
|
+
|
10
|
+
<!-- Test with major version @1 -->
|
11
|
+
<script type="module" src="https://cdn.jsdelivr.net/npm/@hortonstudio/main@1/index.js" data-hs-main data-hs-anim-hero></script>
|
12
|
+
|
13
|
+
<script>
|
14
|
+
setTimeout(() => {
|
15
|
+
const results = document.getElementById('results');
|
16
|
+
|
17
|
+
// Check what scripts are found
|
18
|
+
const scripts = [...document.querySelectorAll('script[type="module"]')];
|
19
|
+
results.innerHTML += `<h2>Found Scripts:</h2>`;
|
20
|
+
scripts.forEach((script, i) => {
|
21
|
+
results.innerHTML += `<p>Script ${i}: ${script.src}</p>`;
|
22
|
+
});
|
23
|
+
|
24
|
+
// Check if hsmain loaded and what scripts it found
|
25
|
+
if (window.hsmain) {
|
26
|
+
results.innerHTML += `<h2>HSMAIN Scripts Found:</h2>`;
|
27
|
+
results.innerHTML += `<p>Found ${window.hsmain.scripts.length} matching scripts</p>`;
|
28
|
+
window.hsmain.scripts.forEach((script, i) => {
|
29
|
+
results.innerHTML += `<p>HSMAIN Script ${i}: ${script.src}</p>`;
|
30
|
+
});
|
31
|
+
} else {
|
32
|
+
results.innerHTML += `<p>HSMAIN not loaded</p>`;
|
33
|
+
}
|
34
|
+
}, 2000);
|
35
|
+
</script>
|
36
|
+
</body>
|
37
|
+
</html>
|
package/index.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
// ver 1.2.
|
1
|
+
// ver 1.2.12
|
2
2
|
|
3
3
|
const API_NAME = 'hsmain';
|
4
4
|
|
@@ -73,8 +73,21 @@ const initializeHsMain = () => {
|
|
73
73
|
});
|
74
74
|
};
|
75
75
|
|
76
|
-
// Find script tags (
|
77
|
-
|
76
|
+
// Find script tags (with CDN version redirect support)
|
77
|
+
let scripts = [...document.querySelectorAll(`script[type="module"][src="${import.meta.url}"]`)];
|
78
|
+
|
79
|
+
// Handle CDN version redirects (e.g., @1 -> @1.2.11)
|
80
|
+
if (scripts.length === 0) {
|
81
|
+
const allScripts = [...document.querySelectorAll('script[type="module"][src*="@hortonstudio/main"]')];
|
82
|
+
scripts = allScripts.filter(script => {
|
83
|
+
const src = script.src;
|
84
|
+
const metaUrl = import.meta.url;
|
85
|
+
// Extract package name and check if they match (ignoring version differences)
|
86
|
+
const srcPackage = src.match(/@hortonstudio\/main(@[\d.]+)?/)?.[0];
|
87
|
+
const metaPackage = metaUrl.match(/@hortonstudio\/main(@[\d.]+)?/)?.[0];
|
88
|
+
return srcPackage && metaPackage && srcPackage.split('@')[0] === metaPackage.split('@')[0];
|
89
|
+
});
|
90
|
+
}
|
78
91
|
|
79
92
|
// Module loading function
|
80
93
|
const loadHsModule = async (moduleName) => {
|