@stacksjs/stx 0.2.139 → 0.2.141
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/dist/cli.js +712 -695
- package/dist/client-script-bundler.d.ts +2 -1
- package/dist/client-script-bundler.js +18 -8
- package/dist/client-script.js +2 -2
- package/dist/craft.js +340 -323
- package/dist/js-ts.js +4 -1
- package/dist/lazy-module.d.ts +1 -0
- package/dist/lazy-module.js +18 -0
- package/dist/process.js +24 -23
- package/dist/pwa.js +316 -299
- package/dist/signal-processing.js +3 -4
- package/dist/signals.js +25 -8
- package/dist/ssg.js +393 -376
- package/dist/utils.js +6 -5
- package/package.json +6 -6
|
@@ -5,6 +5,7 @@ import { transformStoreImports } from "./store-imports.js";
|
|
|
5
5
|
import { shouldTranspileTypeScript, transpileTypeScript } from "./utils.js";
|
|
6
6
|
import { injectSignalsRuntime, injectBrowserRuntime } from "./runtime-injection.js";
|
|
7
7
|
import { matchScriptElement, scanAtElementPosition } from "./html-masking.js";
|
|
8
|
+
import { importOnce } from "./lazy-module.js";
|
|
8
9
|
let signalSetupCounter = 0;
|
|
9
10
|
const TAG_ATTR_RUN = `(?:"[^"]*"|'[^']*'|[^>"'])*`, SINGLE_ELEMENT_RE = /^<([a-zA-Z][a-zA-Z0-9-]*)\b((?:\s+[^=\s>]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]*))?)*\s*)>([\s\S]*)<\/\1>$/s;
|
|
10
11
|
export function scanScriptTags(html, opts = {}) {
|
|
@@ -668,16 +669,14 @@ export async function processScriptSetup(template, filePath, serverData) {
|
|
|
668
669
|
}
|
|
669
670
|
if (signalScripts.length === 0)
|
|
670
671
|
return { output: template, setupCode: null };
|
|
671
|
-
const setupFnName = `__stx_setup_${Date.now()}_${signalSetupCounter++}`, { hasUserImports, bundleClientScript } = await import("./client-script-bundler.js"), resolvedParts = [];
|
|
672
|
+
const setupFnName = `__stx_setup_${Date.now()}_${signalSetupCounter++}`, { hasUserImports, bundleClientScript } = await importOnce("stx/client-script-bundler", () => import("./client-script-bundler.js")), resolvedParts = [];
|
|
672
673
|
for (let i = 0;i < signalScripts.length; i++) {
|
|
673
674
|
let scriptContent = signalScripts[i].content;
|
|
674
675
|
scriptContent = injectBrowserCoreAutoImports(scriptContent).code;
|
|
675
|
-
if (hasUserImports(scriptContent))
|
|
676
|
-
console.log("[stx:bundler] bundling signal script imports");
|
|
676
|
+
if (hasUserImports(scriptContent))
|
|
677
677
|
scriptContent = await bundleClientScript(scriptContent, filePath || "", {
|
|
678
678
|
projectRoot: process.cwd()
|
|
679
679
|
});
|
|
680
|
-
}
|
|
681
680
|
scriptContent = scriptContent.replace(/^\s*import\s+(?:type\s+)?\{([^}]*)\}\s+from\s+['"](?:stx|@stacksjs\/stx|@stacksjs\/browser)['"]\s*;?\s*$/gm, (_match, specifiers) => rewriteStxImportSpecifiers(specifiers));
|
|
682
681
|
const resolved = transformStoreImports(scriptContent);
|
|
683
682
|
resolvedParts.push(`// \u2500\u2500 merged signal script #${i + 1} \u2500\u2500
|
package/dist/signals.js
CHANGED
|
@@ -63,9 +63,13 @@ console.log('[stx] entering IIFE');
|
|
|
63
63
|
|
|
64
64
|
// Inject x-cloak CSS to prevent FOUC (Flash of Unstyled Content)
|
|
65
65
|
// Elements with x-cloak are hidden until the runtime removes the attribute after mount
|
|
66
|
-
var cloakStyle = document.
|
|
67
|
-
cloakStyle
|
|
68
|
-
|
|
66
|
+
var cloakStyle = document.getElementById ? document.getElementById('stx-cloak-style') : null;
|
|
67
|
+
if (!cloakStyle) {
|
|
68
|
+
cloakStyle = document.createElement('style');
|
|
69
|
+
cloakStyle.id = 'stx-cloak-style';
|
|
70
|
+
cloakStyle.textContent = '[x-cloak] { display: none !important; }';
|
|
71
|
+
document.head.appendChild(cloakStyle);
|
|
72
|
+
}
|
|
69
73
|
|
|
70
74
|
// ==========================================================================
|
|
71
75
|
// Reactive Core
|
|
@@ -6003,8 +6007,13 @@ else {
|
|
|
6003
6007
|
// Auto-initialization
|
|
6004
6008
|
// ==========================================================================
|
|
6005
6009
|
|
|
6006
|
-
|
|
6007
|
-
|
|
6010
|
+
// A dev runtime may be evaluated again by HMR, an embed, or a test harness.
|
|
6011
|
+
// Replace the previous listener so only the latest runtime closure can own
|
|
6012
|
+
// componentScope and reactive subscriptions.
|
|
6013
|
+
if (window.__stxDomReadyHandler) {
|
|
6014
|
+
document.removeEventListener('DOMContentLoaded', window.__stxDomReadyHandler);
|
|
6015
|
+
}
|
|
6016
|
+
const stxDomReadyHandler = () => {
|
|
6008
6017
|
console.log('[stx] DOMContentLoaded fired \u2014 processing scopes');
|
|
6009
6018
|
// Track which scoped elements have been processed
|
|
6010
6019
|
const processedScopes = new Set();
|
|
@@ -6225,7 +6234,10 @@ catch (e) {
|
|
|
6225
6234
|
}
|
|
6226
6235
|
}
|
|
6227
6236
|
});
|
|
6228
|
-
}
|
|
6237
|
+
};
|
|
6238
|
+
window.__stxDomReadyHandler = stxDomReadyHandler;
|
|
6239
|
+
console.log('[stx] registering DOMContentLoaded handler');
|
|
6240
|
+
document.addEventListener('DOMContentLoaded', stxDomReadyHandler);
|
|
6229
6241
|
|
|
6230
6242
|
// ==========================================================================
|
|
6231
6243
|
// Scope Disposal
|
|
@@ -6390,10 +6402,15 @@ catch (e) { console.warn('[stx] destroy hook error:', e); }
|
|
|
6390
6402
|
// Re-initialize components after SPA content swap.
|
|
6391
6403
|
// Debounce to handle rapid re-fires (HMR triggers navigate which triggers stx:load again).
|
|
6392
6404
|
var _stxLoadTimer = null;
|
|
6393
|
-
window.
|
|
6405
|
+
if (window.__stxLoadHandler) {
|
|
6406
|
+
window.removeEventListener('stx:load', window.__stxLoadHandler);
|
|
6407
|
+
}
|
|
6408
|
+
function stxLoadHandler() {
|
|
6394
6409
|
if (_stxLoadTimer) { clearTimeout(_stxLoadTimer); }
|
|
6395
6410
|
_stxLoadTimer = setTimeout(_handleStxLoad, 5);
|
|
6396
|
-
}
|
|
6411
|
+
}
|
|
6412
|
+
window.__stxLoadHandler = stxLoadHandler;
|
|
6413
|
+
window.addEventListener('stx:load', stxLoadHandler);
|
|
6397
6414
|
function _handleStxLoad() {
|
|
6398
6415
|
_stxLoadTimer = null;
|
|
6399
6416
|
console.log('[stx:load] START. mountQueue:', mountQueue.length, '_latestSetup:', !!window.stx._latestSetup);
|