@stacksjs/stx 0.2.136 → 0.2.138

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/utils.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { extractAndStripCssImports, extractBridgeData, injectBrowserCoreAutoImports, processClientScript, renderVendorStyleTags } from "./client-script.js";
4
+ import { COMPONENT_CLIENT_FACTORIES_CONTEXT_KEY, registerComponentClientFactory } from "./component-client-factories.js";
4
5
  import { interpolateScriptExpressions, processExpressions, unescapeHtml } from "./expressions.js";
5
6
  import { COMPONENT_SCOPE_LOCAL_GLOBALS, buildRuntimeGlobalsDestructure } from "./runtime-globals.js";
6
7
  import { transformStoreImports } from "./store-imports.js";
@@ -553,7 +554,11 @@ ${triedPaths.map((p) => ` - ${p}`).join(`
553
554
  } catch (error) {
554
555
  return `[Error loading component: ${error instanceof Error ? error.message : String(error)}]`;
555
556
  }
556
- const internalKeysToPreserve = new Set(["__originalFilePath", "__importedComponents"]), filteredParentContext = {};
557
+ const internalKeysToPreserve = new Set([
558
+ "__originalFilePath",
559
+ "__importedComponents",
560
+ COMPONENT_CLIENT_FACTORIES_CONTEXT_KEY
561
+ ]), filteredParentContext = {};
557
562
  for (const [key, val] of Object.entries(parentContext))
558
563
  if (!key.startsWith("__") || internalKeysToPreserve.has(key))
559
564
  filteredParentContext[key] = val;
@@ -695,13 +700,12 @@ ${triedPaths.map((p) => ` - ${p}`).join(`
695
700
  });
696
701
  const { rewriteStxImportSpecifiers } = await import("./signal-processing.js");
697
702
  bundledContent = bundledContent.replace(/^\s*import\s+(?:type\s+)?\{([^}]*)\}\s+from\s+['"](?:stx|@stacksjs\/stx|@stacksjs\/browser)['"]\s*;?\s*$/gm, (_match, specifiers) => rewriteStxImportSpecifiers(specifiers));
698
- const content = transformStoreImports(bundledContent), componentLocalNames = extractVariableNames(content), wrappedContent = `
699
- (function() {
703
+ const content = transformStoreImports(bundledContent), componentLocalNames = extractVariableNames(content), factoryBody = `function(__scopeId) {
700
704
  ${buildRuntimeGlobalsDestructure("const", [...COMPONENT_SCOPE_LOCAL_GLOBALS, ...componentLocalNames], content)}
701
705
  const __scope = window.stx._scopes = window.stx._scopes || {};
702
- const __scopeVars = __scope['${scopeId}'] = __scope['${scopeId}'] || {};
706
+ const __scopeVars = __scope[__scopeId] = __scope[__scopeId] || {};
703
707
  const __previousCurrentElement = window.__STX_CURRENT_ELEMENT__;
704
- window.__STX_CURRENT_ELEMENT__ = document.querySelector('[data-stx-scope="${scopeId}"]');
708
+ window.__STX_CURRENT_ELEMENT__ = document.querySelector('[data-stx-scope="' + __scopeId + '"]');
705
709
 
706
710
  // Scope-specific lifecycle callbacks
707
711
  __scopeVars.__mountCallbacks = __scopeVars.__mountCallbacks || [];
@@ -724,7 +728,7 @@ catch (e) {}
724
728
  finally {
725
729
  window.__STX_CURRENT_ELEMENT__ = __previousCurrentElement;
726
730
  }
727
- })();`;
731
+ }`, factoryId = hydrateTrigger ? null : registerComponentClientFactory(parentContext, factoryBody), wrappedContent = factoryId ? `window.__stxComponentFactories[${JSON.stringify(factoryId)}](${JSON.stringify(scopeId)});` : `(${factoryBody})(${JSON.stringify(scopeId)});`;
728
732
  if (hydrateTrigger)
729
733
  return `${vendorStyleTags}<script type="stx/island" data-stx-island="${scopeId}" data-stx-scoped${attrs}>${wrappedContent}</script>`;
730
734
  return `${vendorStyleTags}<script data-stx-scoped${attrs}>${wrappedContent}</script>`;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/stx",
3
3
  "type": "module",
4
- "version": "0.2.136",
4
+ "version": "0.2.138",
5
5
  "description": "A performant UI Framework. Powered by Bun.",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",
7
7
  "license": "MIT",
@@ -117,12 +117,12 @@
117
117
  "dependencies": {
118
118
  "@cwcss/crosswind": "^0.2.12",
119
119
  "@stacksjs/clapp": "^0.2.0",
120
- "@stacksjs/desktop": "0.2.136",
121
- "@stacksjs/sanitizer": "0.2.136",
120
+ "@stacksjs/desktop": "0.2.138",
121
+ "@stacksjs/sanitizer": "0.2.138",
122
122
  "@stacksjs/ts-i18n": "^0.1.11",
123
- "bun-plugin-stx": "0.2.136",
123
+ "bun-plugin-stx": "0.2.138",
124
124
  "bunfig": "^0.15.15",
125
- "stx-router": "0.2.136",
125
+ "stx-router": "0.2.138",
126
126
  "ts-broadcasting": "^0.0.9",
127
127
  "ts-images": "^0.1.9",
128
128
  "ts-syntax-highlighter": "^0.2.1"