@hortonstudio/main 1.2.8 → 1.2.9

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 +5 -42
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,16 +1,11 @@
1
- // ver 1.2.6
1
+ // ver 1.2.9
2
2
 
3
3
  const API_NAME = 'hsmain';
4
4
 
5
- console.log(`🟢 ${API_NAME} v1.2.6 initializing...`);
6
- console.log('🔍 DOM state:', document.readyState);
7
- console.log('🔍 Script URL:', import.meta.url);
8
-
9
5
  // Main initialization function
10
6
  const initializeHsMain = () => {
11
7
  // Handle existing API
12
8
  if (window[API_NAME] && !Array.isArray(window[API_NAME]) && window[API_NAME].loaded) {
13
- console.log('⚠️ API already loaded, skipping initialization');
14
9
  return;
15
10
  }
16
11
 
@@ -39,8 +34,6 @@ const initializeHsMain = () => {
39
34
 
40
35
  // Dynamic module loader (like Finsweet)
41
36
  const loadModule = async (moduleName) => {
42
- console.log(`📦 Loading module: ${moduleName}`);
43
-
44
37
  switch (moduleName) {
45
38
  case "data-hs-anim-text":
46
39
  return import(new URL('./animations/text.js', import.meta.url).href);
@@ -57,7 +50,6 @@ const initializeHsMain = () => {
57
50
  case "smooth-scroll":
58
51
  return import(new URL('./autoInit/smooth-scroll.js', import.meta.url).href);
59
52
  default:
60
- console.error(`❌ Unsupported module: ${moduleName}`);
61
53
  throw new Error(`${API_NAME} module "${moduleName}" is not supported.`);
62
54
  }
63
55
  };
@@ -83,22 +75,17 @@ const initializeHsMain = () => {
83
75
 
84
76
  // Find script tags (Finsweet approach)
85
77
  const scripts = [...document.querySelectorAll(`script[type="module"][src="${import.meta.url}"]`)];
86
- console.log(`📄 Found ${scripts.length} matching script tags`);
87
78
 
88
79
  // Module loading function
89
80
  const loadHsModule = async (moduleName) => {
90
- console.log(`🔄 loadHsModule called for: ${moduleName}`);
91
-
92
81
  const apiInstance = window[API_NAME];
93
82
 
94
83
  // Check if already processing
95
84
  if (apiInstance.process.has(moduleName)) {
96
- console.log(`⚠️ Module ${moduleName} already processing`);
97
85
  return apiInstance.modules[moduleName]?.loading;
98
86
  }
99
87
 
100
88
  // Add to processing set
101
- console.log(`➕ Adding ${moduleName} to process set`);
102
89
  apiInstance.process.add(moduleName);
103
90
 
104
91
  // Create module object
@@ -112,14 +99,9 @@ const initializeHsMain = () => {
112
99
  });
113
100
 
114
101
  try {
115
- console.log(`📦 Importing ${moduleName}...`);
116
102
  const { init, version } = await loadModule(moduleName);
117
- console.log(`✅ ${moduleName} imported, version: ${version}`);
118
-
119
- console.log(`🔧 Initializing ${moduleName}...`);
120
103
  const initResult = await init();
121
104
  const { result, destroy } = initResult || {};
122
- console.log(`✅ ${moduleName} initialized:`, result);
123
105
 
124
106
  moduleObj.version = version;
125
107
 
@@ -141,7 +123,6 @@ const initializeHsMain = () => {
141
123
  return result;
142
124
 
143
125
  } catch (error) {
144
- console.error(`❌ Failed to load ${moduleName}:`, error);
145
126
  moduleObj.reject?.(error);
146
127
  apiInstance.process.delete(moduleName);
147
128
  throw error;
@@ -219,19 +200,13 @@ const initializeHsMain = () => {
219
200
 
220
201
  // Process modules from script tags
221
202
  const processScriptModules = () => {
222
- console.log(`⚙️ Processing ${scripts.length} script tags`);
223
-
224
203
  for (const script of scripts) {
225
- console.log(`🏷️ Processing script:`, script.src);
226
-
227
204
  // Check for auto mode
228
205
  const autoMode = script.getAttribute('data-hs-auto') === 'true';
229
- console.log(`🔍 Auto mode: ${autoMode}`);
230
206
 
231
207
  // Load modules based on script attributes
232
208
  for (const moduleName of Object.keys(allModules)) {
233
209
  if (script.hasAttribute(moduleName)) {
234
- console.log(`✅ Found attribute for: ${moduleName}`);
235
210
  loadHsModule(moduleName);
236
211
  }
237
212
  }
@@ -239,7 +214,6 @@ const initializeHsMain = () => {
239
214
  // Auto-discovery mode
240
215
  if (autoMode) {
241
216
  waitDOMReady().then(() => {
242
- console.log(`🔍 Starting auto-discovery...`);
243
217
  const foundModules = new Set();
244
218
  const allElements = document.querySelectorAll('*');
245
219
 
@@ -253,7 +227,6 @@ const initializeHsMain = () => {
253
227
  }
254
228
  }
255
229
 
256
- console.log(`🔍 Auto-discovered modules:`, [...foundModules]);
257
230
  for (const moduleName of foundModules) {
258
231
  loadHsModule(moduleName);
259
232
  }
@@ -262,7 +235,6 @@ const initializeHsMain = () => {
262
235
  }
263
236
 
264
237
  // Always load auto-init modules
265
- console.log(`🔄 Loading auto-init modules:`, Object.keys(autoInitModules));
266
238
  for (const moduleName of Object.keys(autoInitModules)) {
267
239
  loadHsModule(moduleName);
268
240
  }
@@ -288,40 +260,31 @@ const initializeHsMain = () => {
288
260
 
289
261
  // Main initialization
290
262
  const initializeMain = async () => {
291
- console.log(`🚀 Starting main initialization...`);
292
-
293
263
  // Process script modules
294
264
  processScriptModules();
295
265
 
296
266
  // Wait for Webflow
297
- console.log(`⏳ Waiting for Webflow...`);
298
267
  await waitWebflowReady();
299
- console.log(`✅ Webflow ready`);
300
268
 
301
269
  // Mark as loaded
302
270
  window[API_NAME].loaded = true;
303
271
 
304
272
  // Run all registered post-Webflow callbacks
305
- console.log(`🔄 Running ${postWebflowCallbacks.length} post-Webflow callbacks`);
306
- postWebflowCallbacks.forEach((callback, index) => {
273
+ postWebflowCallbacks.forEach((callback) => {
307
274
  try {
308
- console.log(`📞 Executing callback ${index + 1}/${postWebflowCallbacks.length}`);
309
275
  callback();
310
276
  } catch (error) {
311
- console.error(`❌ Callback ${index + 1} failed:`, error);
277
+ // Silent fail for callbacks
312
278
  }
313
279
  });
314
-
315
- console.log(`🎉 ${API_NAME} fully loaded and ready!`);
316
280
  };
317
281
 
318
282
  // Process any early requests
319
- console.log(`📝 Processing ${existingRequests.length} early requests`);
320
283
  window[API_NAME].push(...existingRequests);
321
284
 
322
285
  // Start initialization
323
- initializeMain().catch(error => {
324
- console.error(`❌ Failed to initialize ${API_NAME}:`, error);
286
+ initializeMain().catch(() => {
287
+ // Silent fail for initialization
325
288
  });
326
289
  };
327
290
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hortonstudio/main",
3
- "version": "1.2.8",
3
+ "version": "1.2.9",
4
4
  "main": "index.js",
5
5
  "type": "module",
6
6
  "scripts": {