@hortonstudio/main 1.1.0 → 1.1.2

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.
@@ -11,7 +11,8 @@
11
11
  "mcp__webflow__add_inline_site_script",
12
12
  "Bash(mv:*)",
13
13
  "WebFetch(domain:www.compassfacilities.com)",
14
- "mcp__webflow__pages_list"
14
+ "mcp__webflow__pages_list",
15
+ "Bash(npm publish:*)"
15
16
  ],
16
17
  "deny": []
17
18
  }
package/index.js CHANGED
@@ -24,6 +24,23 @@ const autoInitModules = {
24
24
  // Store callbacks to run after Webflow.ready()
25
25
  const postWebflowCallbacks = [];
26
26
 
27
+ // Get the base URL from the current script's location
28
+ const getBaseUrl = () => {
29
+ const currentScript = document.querySelector('script[data-hs-main]');
30
+ console.log('🔍 Script tag found:', currentScript);
31
+ console.log('🔍 Script src:', currentScript?.src);
32
+
33
+ if (currentScript && currentScript.src) {
34
+ const result = currentScript.src.substring(0, currentScript.src.lastIndexOf('/') + 1);
35
+ console.log('🔍 Base URL from script:', result);
36
+ return result;
37
+ }
38
+
39
+ const fallback = new URL('./', import.meta.url).href;
40
+ console.log('🔍 Base URL from import.meta:', fallback);
41
+ return fallback;
42
+ };
43
+
27
44
  const loadModule = (moduleName) => {
28
45
  // Check manual modules first
29
46
  let modulePath = animationModules[moduleName] || utilityModules[moduleName];
@@ -36,7 +53,18 @@ const loadModule = (moduleName) => {
36
53
  if (!modulePath) {
37
54
  throw new Error(`HortonStudio module "${moduleName}" is not supported.`);
38
55
  }
39
- return import(modulePath);
56
+
57
+ // Convert relative path to absolute URL
58
+ const baseUrl = getBaseUrl();
59
+ const absoluteUrl = new URL(modulePath, baseUrl).href;
60
+
61
+ // DEBUG: Log what URLs we're creating
62
+ console.log('🔍 Debug info for module:', moduleName);
63
+ console.log(' - Base URL:', baseUrl);
64
+ console.log(' - Module path:', modulePath);
65
+ console.log(' - Final URL:', absoluteUrl);
66
+
67
+ return import(absoluteUrl);
40
68
  };
41
69
 
42
70
  const findCurrentScriptTag = () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hortonstudio/main",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "scripts": {
package/test-cdn.html ADDED
@@ -0,0 +1,29 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>CDN Import Test</title>
5
+ </head>
6
+ <body>
7
+ <h1>Testing CDN Module Loading</h1>
8
+ <div data-hs-hero="heading">Hero Test Element</div>
9
+
10
+ <script>
11
+ // Test both local and CDN scenarios
12
+ console.log('Testing module loading...');
13
+
14
+ // Monitor console for debug messages
15
+ window.addEventListener('load', () => {
16
+ setTimeout(() => {
17
+ if (window.hsmain) {
18
+ console.log('API Status:', window.hsmain.status());
19
+ } else {
20
+ console.error('hsmain API not loaded');
21
+ }
22
+ }, 2000);
23
+ });
24
+ </script>
25
+
26
+ <!-- Test with local file -->
27
+ <script type="module" src="./index.js" data-hs-main data-hs-anim-hero></script>
28
+ </body>
29
+ </html>