@hortonstudio/main 1.1.0 → 1.1.1

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,17 @@ 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
+ if (currentScript && currentScript.src) {
31
+ // Extract directory path from script URL
32
+ return currentScript.src.substring(0, currentScript.src.lastIndexOf('/') + 1);
33
+ }
34
+ // Fallback to current origin + path for relative imports
35
+ return new URL('./', import.meta.url).href;
36
+ };
37
+
27
38
  const loadModule = (moduleName) => {
28
39
  // Check manual modules first
29
40
  let modulePath = animationModules[moduleName] || utilityModules[moduleName];
@@ -36,7 +47,12 @@ const loadModule = (moduleName) => {
36
47
  if (!modulePath) {
37
48
  throw new Error(`HortonStudio module "${moduleName}" is not supported.`);
38
49
  }
39
- return import(modulePath);
50
+
51
+ // Convert relative path to absolute URL
52
+ const baseUrl = getBaseUrl();
53
+ const absoluteUrl = new URL(modulePath, baseUrl).href;
54
+
55
+ return import(absoluteUrl);
40
56
  };
41
57
 
42
58
  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.1",
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>