@hortonstudio/main 1.1.4 → 1.1.6

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 (2) hide show
  1. package/index.js +17 -39
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,5 +1,4 @@
1
1
  // Configuration: Change this variable to rename the API
2
- console.log('🚀 SCRIPT FILE LOADED');
3
2
  const API_NAME = 'hsmain';
4
3
 
5
4
  window[API_NAME] = window[API_NAME] || {};
@@ -25,47 +24,19 @@ const autoInitModules = {
25
24
  // Store callbacks to run after Webflow.ready()
26
25
  const postWebflowCallbacks = [];
27
26
 
28
- // Get the base URL from the current script's location
29
- const getBaseUrl = () => {
30
- const currentScript = document.querySelector('script[data-hs-main]');
31
- console.log('🔍 Script tag found:', currentScript);
32
- console.log('🔍 Script src:', currentScript?.src);
33
-
34
- if (currentScript && currentScript.src) {
35
- const result = currentScript.src.substring(0, currentScript.src.lastIndexOf('/') + 1);
36
- console.log('🔍 Base URL from script:', result);
37
- return result;
38
- }
39
-
40
- const fallback = new URL('./', import.meta.url).href;
41
- console.log('🔍 Base URL from import.meta:', fallback);
42
- return fallback;
43
- };
44
-
45
27
  const loadModule = (moduleName) => {
46
28
  // Check manual modules first
47
29
  let modulePath = animationModules[moduleName] || utilityModules[moduleName];
48
-
30
+
49
31
  // Then check auto-init modules
50
32
  if (!modulePath) {
51
33
  modulePath = autoInitModules[moduleName];
52
34
  }
53
-
35
+
54
36
  if (!modulePath) {
55
37
  throw new Error(`HortonStudio module "${moduleName}" is not supported.`);
56
38
  }
57
-
58
- // Convert relative path to absolute URL
59
- const baseUrl = getBaseUrl();
60
- const absoluteUrl = new URL(modulePath, baseUrl).href;
61
-
62
- // DEBUG: Log what URLs we're creating
63
- console.log('🔍 Debug info for module:', moduleName);
64
- console.log(' - Base URL:', baseUrl);
65
- console.log(' - Module path:', modulePath);
66
- console.log(' - Final URL:', absoluteUrl);
67
-
68
- return import(absoluteUrl);
39
+ return import(modulePath);
69
40
  };
70
41
 
71
42
  const findCurrentScriptTag = () => {
@@ -75,32 +46,40 @@ const findCurrentScriptTag = () => {
75
46
 
76
47
  const processModules = async (scriptTag) => {
77
48
  const modulePromises = [];
78
-
49
+
79
50
  // Load manual modules based on attributes
80
51
  for (const moduleName of Object.keys({ ...animationModules, ...utilityModules })) {
81
52
  if (scriptTag && scriptTag.hasAttribute(moduleName)) {
82
53
  modulePromises.push(loadHsModule(moduleName));
83
54
  }
84
55
  }
85
-
56
+
86
57
  // Load auto-init modules
87
58
  for (const moduleName of Object.keys(autoInitModules)) {
88
59
  modulePromises.push(loadHsModule(moduleName));
89
60
  }
90
-
61
+
62
+ // Hide .transition elements if transition module is not loaded
63
+ if (!scriptTag || !scriptTag.hasAttribute('data-hs-anim-transition')) {
64
+ const transitionElements = document.querySelectorAll('.transition');
65
+ transitionElements.forEach(element => {
66
+ element.style.display = 'none';
67
+ });
68
+ }
69
+
91
70
  // Wait for ALL modules to finish loading
92
71
  await Promise.all(modulePromises);
93
-
72
+
94
73
  // Always refresh Webflow after all modules are loaded
95
74
  refreshWebflow();
96
75
  };
97
76
 
98
77
  const refreshWebflow = () => {
99
-
78
+
100
79
  setTimeout(() => {
101
80
  if (window.Webflow && window.Webflow.ready) {
102
81
  window.Webflow.ready();
103
-
82
+
104
83
  // Run all registered post-Webflow callbacks
105
84
  setTimeout(() => {
106
85
  postWebflowCallbacks.forEach(callback => {
@@ -157,7 +136,6 @@ const loadHsModule = async (moduleName) => {
157
136
  };
158
137
 
159
138
  const initializeAPI = () => {
160
- console.log('🔍 Initializing HortonStudio API...');
161
139
  const apiInstance = window[API_NAME];
162
140
 
163
141
  const existingRequests = Array.isArray(apiInstance) ? apiInstance : [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hortonstudio/main",
3
- "version": "1.1.4",
3
+ "version": "1.1.6",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "scripts": {