@stacksjs/stx 0.2.265 → 0.2.267

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 (170) hide show
  1. package/dist/app-shell.js +5 -24
  2. package/dist/caching.js +2 -0
  3. package/dist/{chunk-25de1sj7.js → chunk-0athjw48.js} +2 -2
  4. package/dist/{chunk-38ykv2gd.js → chunk-135mme4g.js} +1 -1
  5. package/dist/{chunk-4xr8099h.js → chunk-13ftt3qc.js} +1 -1
  6. package/dist/{chunk-w5b2bwxp.js → chunk-18nxwzv3.js} +109 -109
  7. package/dist/{chunk-gpt6ggxj.js → chunk-1hhxj2r5.js} +1 -1
  8. package/dist/{chunk-f0rjjfk0.js → chunk-1j77d7fw.js} +1 -1
  9. package/dist/{chunk-sr49fd8p.js → chunk-1m4sa11y.js} +1 -1
  10. package/dist/{chunk-nteg247p.js → chunk-278yw67q.js} +1 -1
  11. package/dist/{chunk-0mk858ne.js → chunk-2ed60g20.js} +2 -2
  12. package/dist/{chunk-qpsj28s2.js → chunk-2qsa4h1t.js} +2 -2
  13. package/dist/{chunk-3rnc94mp.js → chunk-2x9s5z8x.js} +1 -1
  14. package/dist/{chunk-va2wwrpf.js → chunk-455pgdzh.js} +1 -1
  15. package/dist/{chunk-k6st4606.js → chunk-4ay1ymgp.js} +1 -1
  16. package/dist/{chunk-x7pp10qb.js → chunk-4cr21p7m.js} +1 -1
  17. package/dist/chunk-4mvpapjz.js +2 -0
  18. package/dist/{chunk-7exqxjx5.js → chunk-4mw2kfqd.js} +1 -1
  19. package/dist/chunk-4wnnet1k.js +12 -0
  20. package/dist/{chunk-jt8as8j8.js → chunk-52wr95ps.js} +1 -1
  21. package/dist/{chunk-pbsfbgx7.js → chunk-5d4csjhx.js} +1 -1
  22. package/dist/chunk-5htqgzbb.js +2 -0
  23. package/dist/{chunk-z0aygs4h.js → chunk-5k0j7bjy.js} +1 -1
  24. package/dist/{chunk-aw651z2y.js → chunk-5wkwhjjn.js} +54 -20
  25. package/dist/{chunk-xr1758xj.js → chunk-6746wmsf.js} +1 -1
  26. package/dist/{chunk-new80es4.js → chunk-6g7m08rv.js} +1 -1
  27. package/dist/{chunk-bjj27mf3.js → chunk-6kcz7bg6.js} +2 -2
  28. package/dist/{chunk-p1rswnys.js → chunk-73yr54sg.js} +1 -1
  29. package/dist/{chunk-2pavh1yg.js → chunk-78bm61kd.js} +1 -1
  30. package/dist/chunk-7cts329z.js +2 -0
  31. package/dist/chunk-7kkc13rc.js +2 -0
  32. package/dist/chunk-8evws5cc.js +11 -0
  33. package/dist/{chunk-zr4emtxf.js → chunk-8jvmjzmr.js} +1 -1
  34. package/dist/{chunk-pfm1325e.js → chunk-8vewrjzp.js} +2 -2
  35. package/dist/{chunk-zr6m5k3t.js → chunk-987kjtg8.js} +1 -1
  36. package/dist/{chunk-3fa6t4fw.js → chunk-9gzmcxzg.js} +1 -1
  37. package/dist/{chunk-b3f5dwzz.js → chunk-9rdg7x9h.js} +1 -1
  38. package/dist/chunk-9rkcrzj4.js +2 -0
  39. package/dist/{chunk-8pvymy12.js → chunk-9y175wxc.js} +1 -1
  40. package/dist/chunk-b41qf397.js +2 -0
  41. package/dist/{chunk-dnhckx52.js → chunk-bby4emay.js} +1 -1
  42. package/dist/chunk-c1r9q5pk.js +15 -0
  43. package/dist/chunk-cd4v7xyr.js +2 -0
  44. package/dist/{chunk-ecyac25w.js → chunk-cksz4k5v.js} +2 -2
  45. package/dist/chunk-d3v3p15c.js +2 -0
  46. package/dist/{chunk-jq375v8t.js → chunk-dhe8sp1a.js} +1 -1
  47. package/dist/chunk-dpgp6rzq.js +2 -0
  48. package/dist/{chunk-0j9hrzjj.js → chunk-e6tvnnnz.js} +1 -1
  49. package/dist/chunk-e6vdk4v0.js +2 -0
  50. package/dist/{chunk-g8tce9rr.js → chunk-f1jd5qjb.js} +1 -1
  51. package/dist/{chunk-4qq5wj04.js → chunk-f3m0q482.js} +1 -1
  52. package/dist/{chunk-wb7dfcnc.js → chunk-f8g0zbm3.js} +1 -1
  53. package/dist/{chunk-0y6f4037.js → chunk-f8wjdg40.js} +1 -1
  54. package/dist/chunk-fcv00xs9.js +2 -0
  55. package/dist/{chunk-sne7938g.js → chunk-fn9yw31x.js} +1 -1
  56. package/dist/chunk-g4z7gah7.js +2 -0
  57. package/dist/{chunk-ph5f8eev.js → chunk-gej3rmfy.js} +1 -1
  58. package/dist/{chunk-1qnyvw5w.js → chunk-hhyf0s7s.js} +1 -1
  59. package/dist/chunk-j135b7xt.js +2 -0
  60. package/dist/{chunk-x84g0m0p.js → chunk-j24k071e.js} +1 -1
  61. package/dist/chunk-jb7h4qgh.js +22 -0
  62. package/dist/{chunk-ym3r8ktq.js → chunk-jcped0kt.js} +1 -1
  63. package/dist/{chunk-a8mnhryz.js → chunk-jnbhyzkv.js} +2 -2
  64. package/dist/{chunk-1n16xphq.js → chunk-jq4104he.js} +2 -2
  65. package/dist/chunk-k5c19t7e.js +2 -0
  66. package/dist/{chunk-6vqb54c8.js → chunk-k7n88ess.js} +1 -1
  67. package/dist/{chunk-3txrk37v.js → chunk-khfszwjy.js} +1 -1
  68. package/dist/{chunk-wj2trgsn.js → chunk-krgth3gf.js} +1 -1
  69. package/dist/{chunk-nqy2v6vh.js → chunk-m0aetx9j.js} +2 -2
  70. package/dist/chunk-mb0kqnwf.js +2 -0
  71. package/dist/{chunk-r7dd7c7y.js → chunk-mbvkvac6.js} +332 -343
  72. package/dist/{chunk-4w3gg4g7.js → chunk-mcn9mwzv.js} +1 -1
  73. package/dist/chunk-mzpb11dp.js +2 -0
  74. package/dist/{chunk-rp0m678g.js → chunk-n2r83qwt.js} +1 -1
  75. package/dist/chunk-ng1wyd2v.js +2 -0
  76. package/dist/{chunk-s2wm8qwg.js → chunk-q4n8a7sf.js} +1 -1
  77. package/dist/chunk-q5et8k2d.js +2 -0
  78. package/dist/chunk-qf5grrg1.js +2 -0
  79. package/dist/{chunk-k1e72asa.js → chunk-qh6223a0.js} +1 -1
  80. package/dist/{chunk-gg2en16q.js → chunk-qkbrbys7.js} +1 -1
  81. package/dist/{chunk-yjk7vyd8.js → chunk-r4nkpr60.js} +1 -1
  82. package/dist/chunk-r8qvm7a3.js +30 -0
  83. package/dist/{chunk-c17txgm7.js → chunk-r9z71gj0.js} +1 -1
  84. package/dist/{chunk-c59rkxwf.js → chunk-rc4zrsw3.js} +1 -1
  85. package/dist/chunk-rgh4njyv.js +2 -0
  86. package/dist/{chunk-10tcqry1.js → chunk-rwb4nztb.js} +1 -1
  87. package/dist/chunk-scdxk8nn.js +2 -0
  88. package/dist/{chunk-5h5ydexj.js → chunk-sde45gh3.js} +1 -1
  89. package/dist/{chunk-chsfdfqm.js → chunk-shtemwbq.js} +1 -1
  90. package/dist/chunk-sz51py35.js +2 -0
  91. package/dist/chunk-tc01rmwh.js +2 -0
  92. package/dist/{chunk-wx73fmky.js → chunk-tv6ds16a.js} +1 -1
  93. package/dist/chunk-v9xkrwxt.js +2 -0
  94. package/dist/{chunk-a90d3xne.js → chunk-vnrhn6b0.js} +1 -1
  95. package/dist/{chunk-95mj2e8x.js → chunk-vrskjx64.js} +1 -1
  96. package/dist/{chunk-4svmpj7y.js → chunk-w7gpyx2k.js} +1 -1
  97. package/dist/{chunk-gyga6sjp.js → chunk-wacr03x4.js} +1 -1
  98. package/dist/{chunk-j6e4vwv5.js → chunk-wrg838f0.js} +1 -1
  99. package/dist/chunk-xkb16kmv.js +2 -0
  100. package/dist/chunk-xpsxwbw0.js +2 -0
  101. package/dist/chunk-xv2mr8vq.js +2 -0
  102. package/dist/{chunk-rkrnb0ec.js → chunk-y9tv04zh.js} +2 -2
  103. package/dist/{chunk-yb3nrbqz.js → chunk-yhtq662h.js} +1 -1
  104. package/dist/chunk-ykxs16y7.js +2 -0
  105. package/dist/chunk-yxp7wv61.js +3 -0
  106. package/dist/{chunk-4zkv1vqh.js → chunk-z86pq9pd.js} +2 -2
  107. package/dist/{chunk-j59pkkzn.js → chunk-zr2rkgag.js} +2 -2
  108. package/dist/cli.js +14 -14
  109. package/dist/client-script-bundler.d.ts +14 -0
  110. package/dist/client-script-bundler.js +37 -21
  111. package/dist/client-script.d.ts +1 -0
  112. package/dist/client-script.js +4 -2
  113. package/dist/color-mode-boot.js +6 -3
  114. package/dist/component-client-factories.d.ts +29 -0
  115. package/dist/component-client-factories.js +24 -0
  116. package/dist/craft-entry.js +1 -1
  117. package/dist/craft.js +1 -1
  118. package/dist/database.js +1 -1
  119. package/dist/dev-server/crosswind.d.ts +0 -3
  120. package/dist/dev-server/crosswind.js +13 -0
  121. package/dist/fragment-container.js +15 -1
  122. package/dist/framework-composables.js +12 -2
  123. package/dist/performance-utils.d.ts +22 -1
  124. package/dist/performance-utils.js +30 -5
  125. package/dist/pwa.js +2 -2
  126. package/dist/render-memo.d.ts +40 -0
  127. package/dist/render-memo.js +33 -0
  128. package/dist/script-validation.js +25 -11
  129. package/dist/ssg.js +2 -2
  130. package/dist/store-loader.js +10 -1
  131. package/dist/style-scoping.js +18 -7
  132. package/dist/utils.js +108 -58
  133. package/dist/variable-extractor.js +14 -8
  134. package/dist/visual-testing.js +1 -1
  135. package/package.json +5 -5
  136. package/dist/chunk-0ha9e1wt.js +0 -5
  137. package/dist/chunk-0x022m9m.js +0 -2
  138. package/dist/chunk-14cps421.js +0 -2
  139. package/dist/chunk-1r8c2wws.js +0 -2
  140. package/dist/chunk-2p4v6ed7.js +0 -2
  141. package/dist/chunk-2qbde7w2.js +0 -2
  142. package/dist/chunk-3wwnx5d4.js +0 -2
  143. package/dist/chunk-4s2p4hry.js +0 -2
  144. package/dist/chunk-6gc8phhe.js +0 -2
  145. package/dist/chunk-7qgnd7z8.js +0 -2
  146. package/dist/chunk-85wgtm01.js +0 -2
  147. package/dist/chunk-8raem8ng.js +0 -2
  148. package/dist/chunk-9v8be077.js +0 -2
  149. package/dist/chunk-a5sn113x.js +0 -12
  150. package/dist/chunk-b3zes539.js +0 -11
  151. package/dist/chunk-c2mvr9z1.js +0 -2
  152. package/dist/chunk-fenb3cqw.js +0 -2
  153. package/dist/chunk-g4t9zc0a.js +0 -2
  154. package/dist/chunk-gayjne01.js +0 -2
  155. package/dist/chunk-gd9gfw08.js +0 -2
  156. package/dist/chunk-h44qqffw.js +0 -2
  157. package/dist/chunk-jftmdf4j.js +0 -2
  158. package/dist/chunk-k6wnmjhf.js +0 -3
  159. package/dist/chunk-m116b3d9.js +0 -2
  160. package/dist/chunk-m8hggrdc.js +0 -2
  161. package/dist/chunk-mjbsb088.js +0 -2
  162. package/dist/chunk-ptcpaeem.js +0 -11
  163. package/dist/chunk-qqfsm20p.js +0 -30
  164. package/dist/chunk-rs5w6cm5.js +0 -2
  165. package/dist/chunk-tn2kwwy4.js +0 -13
  166. package/dist/chunk-venjrj7g.js +0 -2
  167. package/dist/chunk-x0t0ndxd.js +0 -2
  168. package/dist/chunk-xezfdh27.js +0 -2
  169. package/dist/chunk-xmrwskw2.js +0 -2
  170. package/dist/chunk-zcz486dz.js +0 -2
@@ -1,6 +1,16 @@
1
1
  import { maskAtElementPosition, matchScriptElement, matchStyleElement } from "./html-masking.js";
2
2
  import { generateComponentId, scopeCss } from "./web-components/css-scoping.js";
3
- const SCOPED_STYLE_ATTR = String.raw`(?<![\w-])scoped(?![\w-])`, SCOPED_STYLE_PROBE = new RegExp(`<style\\s+[^>]*${SCOPED_STYLE_ATTR}`, "i");
3
+ const SCOPED_STYLE_ATTR = String.raw`(?<![\w-])scoped(?![\w-])`, STYLE_OPEN_TAG = /<style\s+([^>]*)>/gi, STYLE_TAG_WITH_ATTRS = /<style\s+([^>]*)>([\s\S]*?)<\/style>/gi, SCOPED_ATTR_IN_TAG = new RegExp(SCOPED_STYLE_ATTR, "i"), SCOPED_ATTR_EVERYWHERE = new RegExp(SCOPED_STYLE_ATTR, "gi");
4
+ function hasScopedStyleTag(template) {
5
+ STYLE_OPEN_TAG.lastIndex = 0;
6
+ let tag = STYLE_OPEN_TAG.exec(template);
7
+ while (tag !== null) {
8
+ if (SCOPED_ATTR_IN_TAG.test(tag[1]))
9
+ return !0;
10
+ tag = STYLE_OPEN_TAG.exec(template);
11
+ }
12
+ return !1;
13
+ }
4
14
  export function dedupeScopedStyles(html) {
5
15
  const seen = new Set;
6
16
  return html.replace(/<style\b[^>]*\bdata-stx-scoped(?:=(?:"[^"]*"|'[^']*'|[^\s>]+))?[^>]*>[\s\S]*?<\/style>\s*/gi, (styleBlock) => {
@@ -12,15 +22,16 @@ export function dedupeScopedStyles(html) {
12
22
  });
13
23
  }
14
24
  export function processScopedStyles(template, filePath) {
15
- if (!SCOPED_STYLE_PROBE.test(template))
25
+ if (!hasScopedStyleTag(template))
16
26
  return { html: template, hasScoped: !1 };
17
27
  const componentId = generateComponentId(filePath), scopeAttr = `data-v-${componentId}`;
18
- let output = template;
19
- const scopedStyleRegex = new RegExp(`<style\\s+([^>]*${SCOPED_STYLE_ATTR}[^>]*)>([\\s\\S]*?)</style>`, "gi");
20
- let hasScoped = !1;
21
- output = output.replace(scopedStyleRegex, (_match, attrs, cssContent) => {
28
+ let output = template, hasScoped = !1;
29
+ STYLE_TAG_WITH_ATTRS.lastIndex = 0;
30
+ output = output.replace(STYLE_TAG_WITH_ATTRS, (match, attrs, cssContent) => {
31
+ if (!SCOPED_ATTR_IN_TAG.test(attrs))
32
+ return match;
22
33
  hasScoped = !0;
23
- const scopedCss = scopeCssWithAttribute(cssContent, scopeAttr), cleanAttrs = attrs.replace(new RegExp(SCOPED_STYLE_ATTR, "gi"), "").trim(), attrStr = cleanAttrs ? ` ${cleanAttrs}` : "";
34
+ const scopedCss = scopeCssWithAttribute(cssContent, scopeAttr), cleanAttrs = attrs.replace(SCOPED_ATTR_EVERYWHERE, "").trim(), attrStr = cleanAttrs ? ` ${cleanAttrs}` : "";
24
35
  return `<style data-stx-scoped="${componentId}"${attrStr}>${scopedCss}</style>`;
25
36
  });
26
37
  if (!hasScoped)
package/dist/utils.js CHANGED
@@ -1,9 +1,16 @@
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
+ import {
5
+ COMPONENT_CLIENT_FACTORIES_CONTEXT_KEY,
6
+ componentClientFactoriesRegisteredSince,
7
+ registerComponentClientFactory,
8
+ replayComponentClientFactories,
9
+ snapshotComponentClientFactoryCounts
10
+ } from "./component-client-factories.js";
5
11
  import { interpolateScriptExpressions, processExpressions, usesSignalsInScript } from "./expressions.js";
6
12
  import { COMPONENT_SCOPE_LOCAL_GLOBALS, buildRuntimeGlobalsDestructure } from "./runtime-globals.js";
13
+ import { contentKey, depsUnchanged, renderMemo, snapshotDeps } from "./render-memo.js";
7
14
  import { transformStoreImports } from "./store-imports.js";
8
15
  import { LRUCache } from "./performance-utils.js";
9
16
  import { processDirectives } from "./process.js";
@@ -25,7 +32,10 @@ export {
25
32
  extractVariables,
26
33
  hasVariables
27
34
  } from "./variable-extractor.js";
28
- const componentsCache = new LRUCache(500), componentResolutionCache = new LRUCache(1000), componentRenderCache = new LRUCache(2000);
35
+ const componentsCache = new LRUCache(500), componentResolutionCache = new LRUCache(1000), COMPONENT_RENDER_CACHE_BYTES = 33554432, componentRenderCache = new LRUCache(2000, {
36
+ maxBytes: COMPONENT_RENDER_CACHE_BYTES,
37
+ sizeOf: (entry) => entry.output.length
38
+ });
29
39
  let scopeIdCounter = 0;
30
40
  function serializeComponentRenderInput(value) {
31
41
  const seen = new WeakSet;
@@ -604,8 +614,12 @@ ${triedPaths.map((p) => ` - ${p}`).join(`
604
614
  $slots.default = parsedSlotContent.defaultSlot;
605
615
  for (const [slotName, slotDef] of parsedSlotContent.namedSlots)
606
616
  $slots[slotName] = slotDef.content;
607
- const componentContext = {
617
+ const scopeSeq = parentContext.__stx_scope_seq ??= {
618
+ n: 0,
619
+ key: Bun.hash(String(parentContext.__filename ?? parentFilePath)).toString(36).slice(0, 6)
620
+ }, componentUid = `stx_${baseName.replace(/[^a-zA-Z0-9]/g, "_")}_${++scopeSeq.n}_${scopeSeq.key}`, componentContext = {
608
621
  ...filteredParentContext,
622
+ $uid: componentUid,
609
623
  ...props,
610
624
  props,
611
625
  slot: componentSlotContent,
@@ -619,24 +633,36 @@ ${triedPaths.map((p) => ` - ${p}`).join(`
619
633
  const templateBlock = findSfcTemplateBlock(workingContent);
620
634
  if (templateBlock)
621
635
  workingContent = templateBlock.content.trim();
622
- const scriptRegex = /<script\b([^>]*)>([\s\S]*?)<\/script>/gi, scriptMatches = [...componentContent.matchAll(scriptRegex)], clientScripts = [], cacheableServerComponent = scriptMatches.some((match) => /\bserver\b/.test(match[1] || "") && /\bcache\b/.test(match[1] || "")) && scriptMatches.every((match) => /\bserver\b/.test(match[1] || ""));
623
- let componentRenderCacheKey = null, dependencyBaseline = null;
636
+ const scriptRegex = /<script\b([^>]*)>([\s\S]*?)<\/script>/gi, scriptMatches = [...componentContent.matchAll(scriptRegex)], clientScripts = [], cacheableServerComponent = scriptMatches.some((match) => /\bserver\b/.test(match[1] || "") && /\bcache\b/.test(match[1] || ""));
637
+ let componentRenderCacheKey = null, dependencyBaseline = null, clientFactoryBaseline = null, uidBaseline = 0, preservedExpressionBaseline = null;
624
638
  if (cacheableServerComponent) {
625
639
  const serializedInput = serializeComponentRenderInput({
626
640
  props,
627
641
  slot: slotContent,
628
642
  buildMode: options.buildMode ?? "",
629
- skipEventDirectives: options.skipEventDirectives === !0
643
+ skipEventDirectives: options.skipEventDirectives === !0,
644
+ uid: componentUid
630
645
  });
631
646
  if (serializedInput !== null) {
632
- componentRenderCacheKey = `${componentFilePath}\x00${serializedInput}`;
647
+ componentRenderCacheKey = `${componentFilePath}\x00${contentKey(componentContent)}\x00${serializedInput}`;
633
648
  const cachedRender = componentRenderCache.get(componentRenderCacheKey);
634
649
  if (cachedRender) {
635
650
  for (const dependency of cachedRender.dependencies)
636
651
  dependencies.add(dependency);
652
+ replayComponentClientFactories(parentContext, cachedRender.clientFactories);
653
+ scopeSeq.n += cachedRender.uidsConsumed;
654
+ if (cachedRender.preservedClientExpressions.length > 0) {
655
+ const preserved = new Set(Array.isArray(parentContext.__stx_preserved_client_expressions) ? parentContext.__stx_preserved_client_expressions : []);
656
+ for (const expression of cachedRender.preservedClientExpressions)
657
+ preserved.add(expression);
658
+ parentContext.__stx_preserved_client_expressions = [...preserved];
659
+ }
637
660
  return cachedRender.output;
638
661
  }
639
662
  dependencyBaseline = new Set(dependencies);
663
+ clientFactoryBaseline = snapshotComponentClientFactoryCounts(parentContext);
664
+ uidBaseline = scopeSeq.n;
665
+ preservedExpressionBaseline = new Set(Array.isArray(parentContext.__stx_preserved_client_expressions) ? parentContext.__stx_preserved_client_expressions : []);
640
666
  }
641
667
  }
642
668
  for (const match of scriptMatches) {
@@ -701,10 +727,7 @@ ${triedPaths.map((p) => ` - ${p}`).join(`
701
727
  preservedExpressions.add(match[1].trim());
702
728
  if (preservedExpressions.size > 0)
703
729
  parentContext.__stx_preserved_client_expressions = [...preservedExpressions];
704
- const scopeSeq = parentContext.__stx_scope_seq ??= {
705
- n: 0,
706
- key: Bun.hash(String(parentContext.__filename ?? parentFilePath)).toString(36).slice(0, 6)
707
- }, scopeId = `stx_${baseName.replace(/[^a-zA-Z0-9]/g, "_")}_${++scopeSeq.n}_${scopeSeq.key}`;
730
+ const scopeId = componentUid;
708
731
  let output = result;
709
732
  if (hasSignalScripts) {
710
733
  let propsJson = "";
@@ -718,51 +741,7 @@ ${triedPaths.map((p) => ` - ${p}`).join(`
718
741
  const scriptMatch = script.match(/<script([^>]*)>([\s\S]*)<\/script>/i);
719
742
  if (!scriptMatch)
720
743
  return script;
721
- const [, attrs, rawContent] = scriptMatch, cssExtraction = extractAndStripCssImports(rawContent, {
722
- filePath: componentFilePath,
723
- projectRoot: process.cwd()
724
- });
725
- let bundledContent = cssExtraction.code;
726
- const vendorStyleTags = renderVendorStyleTags(cssExtraction.styles);
727
- bundledContent = injectBrowserCoreAutoImports(bundledContent).code;
728
- const { hasUserImports, bundleClientScript } = await importOnce("stx/client-script-bundler", () => import("./client-script-bundler.js"));
729
- if (hasUserImports(bundledContent))
730
- bundledContent = await bundleClientScript(bundledContent, componentFilePath, {
731
- projectRoot: process.cwd(),
732
- minify: options.buildMode === "compile"
733
- });
734
- const { stripStxRuntimeImports } = await importOnce("stx/signal-processing", () => import("./signal-processing.js"));
735
- bundledContent = stripStxRuntimeImports(bundledContent);
736
- const content = transformStoreImports(bundledContent), componentLocalNames = extractVariableNames(content), factoryBody = `function(__scopeId) {
737
- ${buildRuntimeGlobalsDestructure("const", [...COMPONENT_SCOPE_LOCAL_GLOBALS, ...componentLocalNames], content)}
738
- const __scope = window.stx._scopes = window.stx._scopes || {};
739
- const __scopeVars = __scope[__scopeId] = __scope[__scopeId] || {};
740
- __scopeVars.$refs = __scopeVars.$refs || {};
741
- const __previousCurrentElement = window.__STX_CURRENT_ELEMENT__;
742
- window.__STX_CURRENT_ELEMENT__ = document.querySelector('[data-stx-scope="' + __scopeId + '"]');
743
-
744
- // Scope-specific lifecycle callbacks
745
- __scopeVars.__mountCallbacks = __scopeVars.__mountCallbacks || [];
746
- __scopeVars.__destroyCallbacks = __scopeVars.__destroyCallbacks || [];
747
- const onMount = (fn) => __scopeVars.__mountCallbacks.push(fn);
748
- const onDestroy = (fn) => __scopeVars.__destroyCallbacks.push(fn);
749
-
750
- try {
751
- ${content}
752
-
753
- // Register all defined signals and functions in this scope
754
- const __localVars = {};
755
- try {
756
- ${componentLocalNames.map((v) => `if (typeof ${v} !== 'undefined') __localVars['${v}'] = ${v};`).join(`
757
- `)}
758
- }
759
- catch (e) {}
760
- Object.assign(__scopeVars, __localVars);
761
- }
762
- finally {
763
- window.__STX_CURRENT_ELEMENT__ = __previousCurrentElement;
764
- }
765
- }`, factoryId = hydrateTrigger ? null : registerComponentClientFactory(parentContext, factoryBody), wrappedContent = factoryId ? `window.__stxComponentFactories[${JSON.stringify(factoryId)}](${JSON.stringify(scopeId)});` : `(${factoryBody})(${JSON.stringify(scopeId)});`;
744
+ const [, attrs, rawContent] = scriptMatch, { vendorStyleTags, factoryBody } = await buildComponentIsland(rawContent, componentFilePath, options.buildMode === "compile"), factoryId = hydrateTrigger ? null : registerComponentClientFactory(parentContext, factoryBody), wrappedContent = factoryId ? `window.__stxComponentFactories[${JSON.stringify(factoryId)}](${JSON.stringify(scopeId)});` : `(${factoryBody})(${JSON.stringify(scopeId)});`;
766
745
  if (hydrateTrigger)
767
746
  return `${vendorStyleTags}<script type="stx/island" data-stx-island="${scopeId}" data-stx-scoped${attrs}>${wrappedContent}</script>`;
768
747
  return `${vendorStyleTags}<script data-stx-scoped data-stx-run="always"${attrs}>${wrappedContent}</script>`;
@@ -795,11 +774,16 @@ finally {
795
774
  if (scopedStyleResult.hasScoped)
796
775
  output = scopedStyleResult.html;
797
776
  }
798
- if (componentRenderCacheKey && dependencyBaseline)
777
+ if (componentRenderCacheKey && dependencyBaseline) {
778
+ const preservedNow = Array.isArray(parentContext.__stx_preserved_client_expressions) ? parentContext.__stx_preserved_client_expressions : [];
799
779
  componentRenderCache.set(componentRenderCacheKey, {
800
780
  output,
801
- dependencies: [...dependencies].filter((dependency) => !dependencyBaseline.has(dependency))
781
+ dependencies: [...dependencies].filter((dependency) => !dependencyBaseline.has(dependency)),
782
+ clientFactories: clientFactoryBaseline ? componentClientFactoriesRegisteredSince(parentContext, clientFactoryBaseline) : [],
783
+ uidsConsumed: scopeSeq.n - uidBaseline,
784
+ preservedClientExpressions: preservedExpressionBaseline ? preservedNow.filter((expression) => !preservedExpressionBaseline.has(expression)) : []
802
785
  });
786
+ }
803
787
  return callerClientScripts.length > 0 ? `${output}
804
788
  ${callerClientScripts.join(`
805
789
  `)}` : output;
@@ -1091,3 +1075,69 @@ export function getComponentCacheStats() {
1091
1075
  maxSize: 500
1092
1076
  };
1093
1077
  }
1078
+ const componentIslands = renderMemo(128);
1079
+ async function buildComponentIsland(rawContent, componentFilePath, minify) {
1080
+ const key = contentKey(rawContent, componentFilePath, minify), remembered = componentIslands.get(key);
1081
+ if (remembered) {
1082
+ if (depsUnchanged(remembered.deps))
1083
+ return remembered;
1084
+ componentIslands.delete(key);
1085
+ }
1086
+ const cssExtraction = extractAndStripCssImports(rawContent, {
1087
+ filePath: componentFilePath,
1088
+ projectRoot: process.cwd()
1089
+ });
1090
+ let bundledContent = cssExtraction.code;
1091
+ const vendorStyleTags = renderVendorStyleTags(cssExtraction.styles);
1092
+ bundledContent = injectBrowserCoreAutoImports(bundledContent).code;
1093
+ const { hasUserImports, bundleClientScript } = await importOnce("stx/client-script-bundler", () => import("./client-script-bundler.js")), bundleInputs = [];
1094
+ let bundleFellBack = !1;
1095
+ if (hasUserImports(bundledContent)) {
1096
+ const unbundled = bundledContent;
1097
+ bundledContent = await bundleClientScript(unbundled, componentFilePath, {
1098
+ projectRoot: process.cwd(),
1099
+ minify,
1100
+ collectInputs: bundleInputs
1101
+ });
1102
+ bundleFellBack = bundledContent === unbundled;
1103
+ }
1104
+ const { stripStxRuntimeImports } = await importOnce("stx/signal-processing", () => import("./signal-processing.js"));
1105
+ bundledContent = stripStxRuntimeImports(bundledContent);
1106
+ const content = transformStoreImports(bundledContent), componentLocalNames = extractVariableNames(content), factoryBody = `function(__scopeId) {
1107
+ ${buildRuntimeGlobalsDestructure("const", [...COMPONENT_SCOPE_LOCAL_GLOBALS, ...componentLocalNames], content)}
1108
+ const __scope = window.stx._scopes = window.stx._scopes || {};
1109
+ const __scopeVars = __scope[__scopeId] = __scope[__scopeId] || {};
1110
+ __scopeVars.$refs = __scopeVars.$refs || {};
1111
+ const __previousCurrentElement = window.__STX_CURRENT_ELEMENT__;
1112
+ window.__STX_CURRENT_ELEMENT__ = document.querySelector('[data-stx-scope="' + __scopeId + '"]');
1113
+
1114
+ // Scope-specific lifecycle callbacks
1115
+ __scopeVars.__mountCallbacks = __scopeVars.__mountCallbacks || [];
1116
+ __scopeVars.__destroyCallbacks = __scopeVars.__destroyCallbacks || [];
1117
+ const onMount = (fn) => __scopeVars.__mountCallbacks.push(fn);
1118
+ const onDestroy = (fn) => __scopeVars.__destroyCallbacks.push(fn);
1119
+
1120
+ try {
1121
+ ${content}
1122
+
1123
+ // Register all defined signals and functions in this scope
1124
+ const __localVars = {};
1125
+ try {
1126
+ ${componentLocalNames.map((v) => `if (typeof ${v} !== 'undefined') __localVars['${v}'] = ${v};`).join(`
1127
+ `)}
1128
+ }
1129
+ catch (e) {}
1130
+ Object.assign(__scopeVars, __localVars);
1131
+ }
1132
+ finally {
1133
+ window.__STX_CURRENT_ELEMENT__ = __previousCurrentElement;
1134
+ }
1135
+ }`, island = {
1136
+ vendorStyleTags,
1137
+ factoryBody,
1138
+ deps: snapshotDeps([...bundleInputs, ...cssExtraction.styles.map((style) => style.resolvedPath)])
1139
+ };
1140
+ if (!bundleFellBack && cssExtraction.unresolved.length === 0)
1141
+ componentIslands.set(key, island);
1142
+ return island;
1143
+ }
@@ -58,6 +58,8 @@ import { mergeHeadConfigs, seoMetaToHeadConfig } from "./head.js";
58
58
  import { getPublicEnvDefine } from "./public-env.js";
59
59
  import { safeEvaluate } from "./safe-evaluator.js";
60
60
  import { responseBindings } from "./page-response.js";
61
+ import { contentKey, renderMemo } from "./render-memo.js";
62
+ const transpiledServerScripts = renderMemo(128);
61
63
  function extractDeclaredVariableNames(script) {
62
64
  const names = [];
63
65
  let depth = 0;
@@ -275,14 +277,18 @@ export function isMissingBindingFailure(message) {
275
277
  export async function extractVariables(scriptContent, context, filePath, options = {}) {
276
278
  if (!scriptContent.trim())
277
279
  return;
278
- let jsContent;
279
- try {
280
- const transpiler = getSharedTranspiler({ loader: "ts", target: "browser", define: getPublicEnvDefine() });
281
- let processedCode = scriptContent.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm, "");
282
- processedCode = processedCode.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm, "");
283
- jsContent = transpiler.transformSync(processedCode);
284
- } catch {
285
- jsContent = stripTypeScript(scriptContent);
280
+ const define = getPublicEnvDefine(), transpileKey = contentKey(scriptContent, JSON.stringify(define));
281
+ let jsContent = transpiledServerScripts.get(transpileKey);
282
+ if (jsContent === void 0) {
283
+ try {
284
+ const transpiler = getSharedTranspiler({ loader: "ts", target: "browser", define });
285
+ let processedCode = scriptContent.replace(/^\s*import\s+\w+\s+from\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm, "");
286
+ processedCode = processedCode.replace(/^\s*import\s+['"][^'"]*\.stx['"]\s*;?\s*$/gm, "");
287
+ jsContent = transpiler.transformSync(processedCode);
288
+ } catch {
289
+ jsContent = stripTypeScript(scriptContent);
290
+ }
291
+ transpiledServerScripts.set(transpileKey, jsContent);
286
292
  }
287
293
  const module = { exports: {} }, exports = module.exports, projectRoot = process.cwd(), preloaded = {}, serverRequires = [...jsContent.matchAll(/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g) || []].map((m) => m[1]).filter((id) => !id.startsWith("node:") && !["fs", "path", "os", "child_process", "crypto", "http", "https", "url", "util", "stream", "events", "buffer", "net", "querystring", "zlib", "tls"].includes(id)), unresolvable = new Map;
288
294
  for (const id of serverRequires)
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import"./chunk-0y6f4037.js";import B from"fs";import $ from"path";import k from"crypto";var V=[{name:"mobile",width:375,height:667,isMobile:!0,hasTouch:!0},{name:"tablet",width:768,height:1024,isMobile:!0,hasTouch:!0},{name:"desktop",width:1280,height:800,isMobile:!1,hasTouch:!1},{name:"wide",width:1920,height:1080,isMobile:!1,hasTouch:!1}];function J(N={}){let Y={snapshotDir:N.snapshotDir||"__snapshots__",screenshotDir:N.screenshotDir||"__screenshots__",updateSnapshots:N.updateSnapshots||process.env.UPDATE_SNAPSHOTS==="true",threshold:N.threshold??0.01,viewports:N.viewports||V,generateDiff:N.generateDiff??!0,diffDir:N.diffDir||"__diffs__",compare:N.compare||b,ci:N.ci??process.env.CI==="true",retries:N.retries??(N.ci?3:1)};return{async snapshot(M,X){let q=$.join(Y.snapshotDir,`${X}.html`),G=C(M),Q=K(G);if(await Bun.file(q).exists()){let W=await Bun.file(q).text(),Z=K(C(W));if(Q===Z)return{passed:!0,snapshotPath:q,message:"Snapshot matches"};if(Y.updateSnapshots)return await B.promises.mkdir($.dirname(q),{recursive:!0}),await Bun.write(q,G),{passed:!0,snapshotPath:q,message:"Snapshot updated"};let F=$.join(Y.diffDir,`${X}.actual.html`),U=$.join(Y.diffDir,`${X}.diff.html`);return await B.promises.mkdir(Y.diffDir,{recursive:!0}),await Bun.write(F,G),await Bun.write(U,I(W,G)),{passed:!1,snapshotPath:q,actualPath:F,diffPath:U,message:"Snapshot does not match"}}return await B.promises.mkdir($.dirname(q),{recursive:!0}),await Bun.write(q,G),{passed:!0,snapshotPath:q,message:"New snapshot created"}},async snapshotJson(M,X){let q=$.join(Y.snapshotDir,`${X}.json`),G=JSON.stringify(M,null,2);if(await Bun.file(q).exists()){let Q=await Bun.file(q).text();if(G===Q)return{passed:!0,snapshotPath:q};if(Y.updateSnapshots)return await Bun.write(q,G),{passed:!0,snapshotPath:q,message:"Snapshot updated"};return{passed:!1,snapshotPath:q,message:`JSON snapshot mismatch:
2
+ import"./chunk-f8wjdg40.js";import B from"fs";import $ from"path";import k from"crypto";var V=[{name:"mobile",width:375,height:667,isMobile:!0,hasTouch:!0},{name:"tablet",width:768,height:1024,isMobile:!0,hasTouch:!0},{name:"desktop",width:1280,height:800,isMobile:!1,hasTouch:!1},{name:"wide",width:1920,height:1080,isMobile:!1,hasTouch:!1}];function J(N={}){let Y={snapshotDir:N.snapshotDir||"__snapshots__",screenshotDir:N.screenshotDir||"__screenshots__",updateSnapshots:N.updateSnapshots||process.env.UPDATE_SNAPSHOTS==="true",threshold:N.threshold??0.01,viewports:N.viewports||V,generateDiff:N.generateDiff??!0,diffDir:N.diffDir||"__diffs__",compare:N.compare||b,ci:N.ci??process.env.CI==="true",retries:N.retries??(N.ci?3:1)};return{async snapshot(M,X){let q=$.join(Y.snapshotDir,`${X}.html`),G=C(M),Q=K(G);if(await Bun.file(q).exists()){let W=await Bun.file(q).text(),Z=K(C(W));if(Q===Z)return{passed:!0,snapshotPath:q,message:"Snapshot matches"};if(Y.updateSnapshots)return await B.promises.mkdir($.dirname(q),{recursive:!0}),await Bun.write(q,G),{passed:!0,snapshotPath:q,message:"Snapshot updated"};let F=$.join(Y.diffDir,`${X}.actual.html`),U=$.join(Y.diffDir,`${X}.diff.html`);return await B.promises.mkdir(Y.diffDir,{recursive:!0}),await Bun.write(F,G),await Bun.write(U,I(W,G)),{passed:!1,snapshotPath:q,actualPath:F,diffPath:U,message:"Snapshot does not match"}}return await B.promises.mkdir($.dirname(q),{recursive:!0}),await Bun.write(q,G),{passed:!0,snapshotPath:q,message:"New snapshot created"}},async snapshotJson(M,X){let q=$.join(Y.snapshotDir,`${X}.json`),G=JSON.stringify(M,null,2);if(await Bun.file(q).exists()){let Q=await Bun.file(q).text();if(G===Q)return{passed:!0,snapshotPath:q};if(Y.updateSnapshots)return await Bun.write(q,G),{passed:!0,snapshotPath:q,message:"Snapshot updated"};return{passed:!1,snapshotPath:q,message:`JSON snapshot mismatch:
3
3
  ${z(Q,G)}`}}return await B.promises.mkdir($.dirname(q),{recursive:!0}),await Bun.write(q,G),{passed:!0,snapshotPath:q,message:"New snapshot created"}},matchInlineSnapshot(M,X){let q=C(M);if(X===void 0)return{passed:!0,expected:q};let G=C(X);return{passed:q===G,expected:q}},getConfig(){return Y}}}function D(N={}){let Y=J(N),M=Y.getConfig();return{async compareScreenshots(X,q,G="desktop"){let Q=$.join(M.screenshotDir,G,`${X}.png`),W=$.join(M.diffDir,G,`${X}.actual.png`),Z=$.join(M.diffDir,G,`${X}.diff.png`);if(await Bun.file(Q).exists()){let F=await Bun.file(Q).arrayBuffer(),U=Buffer.from(F),_=await M.compare(q,U);if(_.match||_.diffPercentage<=M.threshold)return{viewport:G,passed:!0,baselinePath:Q};if(M.updateSnapshots)return await B.promises.mkdir($.dirname(Q),{recursive:!0}),await Bun.write(Q,q),{viewport:G,passed:!0,baselinePath:Q};if(await B.promises.mkdir($.dirname(W),{recursive:!0}),await Bun.write(W,q),_.diffImage&&M.generateDiff)await Bun.write(Z,_.diffImage);return{viewport:G,passed:!1,baselinePath:Q,actualPath:W,diffPath:M.generateDiff?Z:void 0,diffPercentage:_.diffPercentage}}return await B.promises.mkdir($.dirname(Q),{recursive:!0}),await Bun.write(Q,q),{viewport:G,passed:!0,baselinePath:Q}},async testViewports(X,q,G=M.viewports){let Q=[];for(let W of G){let Z=null;for(let F=0;F<M.retries;F++)try{let U=await q(W),_=await this.compareScreenshots(X,U,W.name);Q.push(_),Z=null;break}catch(U){if(Z=U,F<M.retries-1)await new Promise((_)=>setTimeout(_,100*(F+1)))}if(Z)Q.push({viewport:W.name,passed:!1,baselinePath:"",diffPercentage:100})}return Q},getSnapshotTester(){return Y}}}function L(N={}){let M=D(N).getSnapshotTester(),X=new Map;return{addStory(q){X.set(`${q.component}/${q.name}`,q)},addStories(q){for(let G of q)this.addStory(G)},getStories(){return Array.from(X.values())},getStoriesForComponent(q){return Array.from(X.values()).filter((G)=>G.component===q)},async testStory(q){let G=X.get(q);if(!G)return{name:q,passed:!1,duration:0,snapshots:[],screenshots:[],errors:[Error(`Story not found: ${q}`)]};let Q=Date.now(),W={name:q,passed:!0,duration:0,snapshots:[],screenshots:[],errors:[]};try{let Z=await G.render(),F=await M.snapshot(Z,q.replace(/\//g,"-"));if(W.snapshots.push(F),!F.passed)W.passed=!1}catch(Z){W.passed=!1,W.errors.push(Z)}return W.duration=Date.now()-Q,W},async testAllStories(){let q=[];for(let G of X.keys()){let Q=await this.testStory(G);q.push(Q)}return q},async generateStoryIndex(){let q={};for(let G of X.values()){if(!q[G.component])q[G.component]=[];q[G.component].push({name:G.name,args:G.args})}return JSON.stringify(q,null,2)}}}async function S(N,Y={}){let M={outputDir:Y.outputDir||"visual-test-report",format:Y.format||"html",title:Y.title||"Visual Test Report",includeScreenshots:Y.includeScreenshots??!0};await B.promises.mkdir(M.outputDir,{recursive:!0});let X=N.length,q=N.filter((F)=>F.passed).length,G=X-q,Q=N.reduce((F,U)=>F+U.duration,0);if(M.format==="json"){let F={title:M.title,summary:{total:X,passed:q,failed:G,duration:Q},results:N,generatedAt:new Date().toISOString()},U=$.join(M.outputDir,"report.json");return await Bun.write(U,JSON.stringify(F,null,2)),U}if(M.format==="markdown"){let F=`# ${M.title}
4
4
 
5
5
  `;F+=`## Summary
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/stx",
3
3
  "type": "module",
4
- "version": "0.2.265",
4
+ "version": "0.2.267",
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.19",
119
119
  "@stacksjs/clapp": "^0.2.14",
120
- "@stacksjs/desktop": "0.2.265",
121
- "@stacksjs/sanitizer": "0.2.265",
120
+ "@stacksjs/desktop": "0.2.267",
121
+ "@stacksjs/sanitizer": "0.2.267",
122
122
  "@stacksjs/ts-i18n": "^0.1.11",
123
- "bun-plugin-stx": "0.2.265",
123
+ "bun-plugin-stx": "0.2.267",
124
124
  "bunfig": "^0.15.17",
125
- "stx-router": "0.2.265",
125
+ "stx-router": "0.2.267",
126
126
  "ts-broadcasting": "^0.0.9",
127
127
  "ts-images": "^0.2.11",
128
128
  "ts-syntax-highlighter": "^0.2.1"
@@ -1,5 +0,0 @@
1
- // @bun
2
- function G(q){if(!q||typeof q!=="object")return!1;let z=q;return typeof z.message==="string"&&(z.name==="BuildMessage"||z.name==="ResolveMessage"||("position"in z))}function H(q){if(q&&typeof q==="object"&&Array.isArray(q.errors))return q.errors;return[q]}function I(q,z){let j=[];for(let A of H(q)){if(G(A)){let D=A.position||void 0;j.push({file:z||D?.file,line:D?.line,column:D?.column,message:A.message??"",lineText:D?.lineText});continue}j.push({file:z,message:A instanceof Error?A.message:String(A)})}return j}function J(q,z){return I(q,z).map((j)=>{let A=j.file?`${j.file}${j.line?`:${j.line}${j.column?`:${j.column}`:""}`:""}`:"",D=j.lineText?`
3
- ${j.lineText.trim()}`:"";return A?`${A}: ${j.message}${D}`:`${j.message}${D}`}).join(`
4
- `)}
5
- export{I as il,J as jl};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Am as m,Bm as n,Cm as o,om as a,pm as b,qm as c,rm as d,sm as e,tm as f,um as g,vm as h,wm as i,xm as j,ym as k,zm as l}from"./chunk-r7dd7c7y.js";import"./chunk-25de1sj7.js";import"./chunk-38ykv2gd.js";import"./chunk-4qq5wj04.js";import"./chunk-g8tce9rr.js";import"./chunk-ptcpaeem.js";import"./chunk-a8mnhryz.js";import"./chunk-dnhckx52.js";import"./chunk-jt8as8j8.js";import"./chunk-x84g0m0p.js";import"./chunk-5h5ydexj.js";import"./chunk-aw651z2y.js";import"./chunk-wj2trgsn.js";import"./chunk-0y6f4037.js";export{h as usesSignalsInScript,o as unescapeHtml,c as registerFilters,b as registerFilter,l as processExpressions,k as interpolateScriptsInTemplate,i as interpolateScriptExpressions,j as interpolateScriptAttributes,d as getAllFilters,n as evaluateExpression,g as escapeHtmlValue,f as escapeHtml,a as defaultFilters,e as clearCustomFilters,m as applyFilters};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Dh as a}from"./chunk-w3ycm4na.js";import"./chunk-0y6f4037.js";export{a as rewriteImagesWithSiblings};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{$l as k,Rl as c,Ul as d,Vl as e,Wl as f,Xl as g,Yl as h,Zl as i,_l as j,am as l,bm as m}from"./chunk-r7dd7c7y.js";import"./chunk-25de1sj7.js";import"./chunk-38ykv2gd.js";import"./chunk-4qq5wj04.js";import{Ls as a,Ms as b}from"./chunk-g8tce9rr.js";import"./chunk-ptcpaeem.js";import"./chunk-a8mnhryz.js";import"./chunk-dnhckx52.js";import"./chunk-jt8as8j8.js";import"./chunk-x84g0m0p.js";import"./chunk-5h5ydexj.js";import"./chunk-aw651z2y.js";import"./chunk-wj2trgsn.js";import"./chunk-0y6f4037.js";export{h as transformAutoImports,b as stripCommentsAndLiterals,e as renderVendorStyleTags,m as processClientScript,g as injectBrowserCoreAutoImports,l as generateServerDataBridge,j as generateBrowserAutoImportDestructuring,i as generateAutoImportDestructuring,a as findInterpolationEnd,k as extractBridgeData,d as extractAndStripCssImports,f as STX_AUTO_IMPORTS,c as BROWSER_CORE_IMPORTS};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Dp as a,Ep as b,Fp as c,Gp as d,Hp as e,Ip as f}from"./chunk-r7dd7c7y.js";import"./chunk-25de1sj7.js";import"./chunk-38ykv2gd.js";import"./chunk-4qq5wj04.js";import"./chunk-g8tce9rr.js";import"./chunk-ptcpaeem.js";import"./chunk-a8mnhryz.js";import"./chunk-dnhckx52.js";import"./chunk-jt8as8j8.js";import"./chunk-x84g0m0p.js";import"./chunk-5h5ydexj.js";import"./chunk-aw651z2y.js";import"./chunk-wj2trgsn.js";import"./chunk-0y6f4037.js";export{f as processStackReplacements,e as processStackPushDirectives,d as processIncludes,a as partialsCache,b as onceStore,c as clearOnceStore};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{it as a,jt as b,kt as c,lt as d,mt as e,nt as f}from"./chunk-dnhckx52.js";import"./chunk-0y6f4037.js";export{d as stateDirName,e as stateDir,c as setStateDir,f as rebaseOntoStateDir,b as STATE_DIR_ENV_VAR,a as DEFAULT_STATE_DIR};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Vk as a,Wk as b,Xk as c,Yk as d,Zk as e}from"./chunk-4svmpj7y.js";import"./chunk-0y6f4037.js";export{b as injectPwaTags,e as generateThemeColorMeta,c as generateSwRegistrationScript,a as generatePwaTags,d as generateManifestLink};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Mf as a}from"./chunk-rkrnb0ec.js";import"./chunk-4zkv1vqh.js";import"./chunk-qqfsm20p.js";import"./chunk-ph5f8eev.js";import"./chunk-w95sp0k9.js";import"./chunk-58f0mthg.js";import"./chunk-r7dd7c7y.js";import"./chunk-25de1sj7.js";import"./chunk-38ykv2gd.js";import"./chunk-4qq5wj04.js";import"./chunk-g8tce9rr.js";import"./chunk-ptcpaeem.js";import"./chunk-a8mnhryz.js";import"./chunk-dnhckx52.js";import"./chunk-jt8as8j8.js";import"./chunk-x84g0m0p.js";import"./chunk-5h5ydexj.js";import"./chunk-aw651z2y.js";import"./chunk-wj2trgsn.js";import"./chunk-0y6f4037.js";export{a as buildForProduction};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Af as e,Bf as f,Cf as g,Df as h,yf as c,zf as d}from"./chunk-nqy2v6vh.js";import{Nf as a,Qf as b}from"./chunk-4zkv1vqh.js";import"./chunk-new80es4.js";import"./chunk-9n0gvfrg.js";import"./chunk-r7dd7c7y.js";import"./chunk-25de1sj7.js";import"./chunk-38ykv2gd.js";import"./chunk-4qq5wj04.js";import"./chunk-g8tce9rr.js";import"./chunk-ptcpaeem.js";import"./chunk-a8mnhryz.js";import"./chunk-dnhckx52.js";import"./chunk-jt8as8j8.js";import"./chunk-x84g0m0p.js";import"./chunk-5h5ydexj.js";import"./chunk-aw651z2y.js";import"./chunk-wj2trgsn.js";import"./chunk-0y6f4037.js";export{d as virtualPathFor,g as typecheckStxFiles,e as sourcePathFor,h as formatTypecheckDiagnostics,f as findRuntimeTypeDeclarations,b as extractTemplateExpressions,a as extractScriptBlocks,c as buildVirtualSource};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Eq as b,Fq as c,Gq as d,Hq as e,ep as a}from"./chunk-r7dd7c7y.js";import"./chunk-25de1sj7.js";import"./chunk-38ykv2gd.js";import"./chunk-4qq5wj04.js";import"./chunk-g8tce9rr.js";import"./chunk-ptcpaeem.js";import"./chunk-a8mnhryz.js";import"./chunk-dnhckx52.js";import"./chunk-jt8as8j8.js";import"./chunk-x84g0m0p.js";import"./chunk-5h5ydexj.js";import"./chunk-aw651z2y.js";import"./chunk-wj2trgsn.js";import"./chunk-0y6f4037.js";export{d as validateClientScript,c as processOnceDirective,b as processJsonDirective,e as processDirectives,a as injectRouterScript};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Et as a,Ft as b}from"./chunk-x84g0m0p.js";import"./chunk-0y6f4037.js";export{b as warnUnbalancedTags,a as findUnbalancedTags};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{fp as a,gp as b,hp as c,ip as d,jp as e,kp as f,lp as g,mp as h,np as i,op as j,pp as k,qp as l}from"./chunk-r7dd7c7y.js";import"./chunk-25de1sj7.js";import"./chunk-38ykv2gd.js";import"./chunk-4qq5wj04.js";import"./chunk-g8tce9rr.js";import"./chunk-ptcpaeem.js";import"./chunk-a8mnhryz.js";import"./chunk-dnhckx52.js";import"./chunk-jt8as8j8.js";import"./chunk-x84g0m0p.js";import"./chunk-5h5ydexj.js";import"./chunk-aw651z2y.js";import"./chunk-wj2trgsn.js";import"./chunk-0y6f4037.js";export{l as stripStxRuntimeImports,a as scanScriptTags,k as rewriteStxImportSpecifiers,i as processSignals,g as processScriptSetup,e as preEvalLiteralReactiveIfs,b as parseLoopExpression,c as hasSignalsSyntax,j as findMarkupIndexOutsideScripts,h as extractExports,f as convertSignalLoopsToAttributes,d as convertSignalDirectivesToAttributes};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{wg as a}from"./chunk-ecyac25w.js";import"./chunk-qqfsm20p.js";import"./chunk-r7dd7c7y.js";import"./chunk-25de1sj7.js";import"./chunk-38ykv2gd.js";import"./chunk-4qq5wj04.js";import"./chunk-g8tce9rr.js";import"./chunk-ptcpaeem.js";import"./chunk-a8mnhryz.js";import"./chunk-dnhckx52.js";import"./chunk-jt8as8j8.js";import"./chunk-x84g0m0p.js";import"./chunk-5h5ydexj.js";import"./chunk-aw651z2y.js";import"./chunk-wj2trgsn.js";import"./chunk-0y6f4037.js";export{a as startProductionServer};
@@ -1,12 +0,0 @@
1
- // @bun
2
- import{Pq as x,Sl as Y}from"./chunk-r7dd7c7y.js";import"./chunk-25de1sj7.js";import"./chunk-38ykv2gd.js";import"./chunk-4qq5wj04.js";import"./chunk-g8tce9rr.js";import"./chunk-ptcpaeem.js";import"./chunk-a8mnhryz.js";import"./chunk-dnhckx52.js";import"./chunk-jt8as8j8.js";import"./chunk-x84g0m0p.js";import"./chunk-5h5ydexj.js";import"./chunk-aw651z2y.js";import"./chunk-wj2trgsn.js";import"./chunk-0y6f4037.js";import A from"path";var C=["broadcast","calculateDistance","canNotify","clearCookies","clearFetchCache","clearStorage","copyToClipboard","createShareableFile","defineForm","getBatteryLevel","getCookie","getCurrentPosition","getStorageKeys","getStorageSize","getVoices","hasBattery","hasCameraPermission","hasGeolocationPermission","hasMicrophonePermission","hasNotificationPermission","hasResizeObserver","hexToHsl","hexToRgb","isBroadcastChannelSupported","isCharging","isDeviceMotionSupported","isDeviceOrientationSupported","isEventSourceSupported","isEyeDropperSupported","isInFullscreen","isMutationObserverSupported","isPermissionGranted","isSpeechRecognitionSupported","isSpeechSynthesisSupported","isWakeLockSupported","isWebSocketSupported","notify","parseCookies","pickColor","prefetch","removeCookie","requestMediaPermissions","requestMotionPermission","requestNotificationPermission","requestOrientationPermission","setCookie","share","shareCurrentPage","shareFiles","shareText","shareURL","shareWithFallback","speak","stopSpeaking","toggleFullscreen","useAsyncData","useAttributeObserver","useAutoLogout","useAutoWakeLock","useBattery","useBreakpoint","useBroadcastChannel","useChannel","useChildListObserver","useClipboard","useColorHistory","useConditionalWakeLock","useCookies","useCopySelection","useDeviceMotion","useDeviceOrientation","useElementSize","useElementTextSelection","useElementVisibility","useEventSource","useEyeDropper","useFavicon","useForm","useFullscreen","useGeolocation","useGeolocationWatch","useHotkey","useIdle","useIdleState","useInfiniteScroll","useIntersectionObserver","useIntersectionObserverMultiple","useIsDesktop","useIsMobile","useIsTablet","useKeyPressed","useKeySequence","useKeyboard","useLastActive","useLazyLoad","useMeta","useMouse","useMouseInElement","useMutationObserver","useNetwork","useNotification","useOnline","useParallax","usePermission","usePermissions","usePointer","usePost","useResizeObserver","useResizeObserverMultiple","useSSE","useScroll","useSelectionPopup","useShare","useSpeechRecognition","useSpeechSynthesis","useStorage","useTextObserver","useTextSelection","useTitle","useVisibility","useWakeLock","useWindowSize"],y=new Set(C);var Z=new Map,I=new Set,P=new Set(C);function R(){Z.clear()}function D(G){let H=new Map;for(let z of G){let K=A.basename(z);if(K.endsWith(".d.ts"))continue;let J=K.replace(/\.[jt]s$/,"");if(J==="index")continue;if(J===K)continue;let X=H.get(J);if(X&&!X.endsWith(".js"))continue;H.set(J,z)}return[...H.values()].sort()}function L(G,H){let z=H.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");return new RegExp(`(?:^|[^\\w$.])(?:const|let|var|function|class)\\s+${z}\\b`).test(G)}function k(G){if(!G)return[];let H=G.replace(/<script\b[^>]*\bdata-stx-runtime\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-framework-composables\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-stores\b[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<script\b[^>]*\bdata-stx-composables\b[^>]*>[\s\S]*?<\/script>/gi,""),z=[];for(let K of P){if(I.has(K))continue;let J=K.replace(/[$()*+.?[\\\]^{|}-]/g,"\\$&");if(new RegExp(`(^|[^\\w$.])${J}\\s*\\(`).test(H))z.push(K)}return z.sort()}async function _(G,H){let z=k(G);if(z.length===0)return null;let K=H??A.join(import.meta.dir,"composables"),J=`${K}\x00${z.join(",")}`,X=Z.get(J);if(X!==void 0)return X||null;let T=x({loader:"ts",target:"browser",define:Y()}),B=new Set(z),F=[],w=new Set,$=[];try{let q=new Bun.Glob("*.{ts,js}");for await(let j of q.scan({cwd:K,absolute:!0}))$.push(j)}catch{return Z.set(J,""),null}$=D($);for(let q of $){let j;try{j=await Bun.file(q).text()}catch{continue}let W=[];try{W=T.scan(j).exports.filter((Q)=>Q!=="default")}catch{continue}if(!W.some((Q)=>B.has(Q)))continue;try{j=j.replace(/^import\s+.*from\s+['"][^'"]+['"]\s*;?\s*$/gm,""),j=j.replace(/^import\s+type\s+.*$/gm,""),j=j.replace(/^export\s+\*\s+(?:as\s+\w+\s+)?from\s*['"][^'"]+['"]\s*;?\s*$/gm,""),j=j.replace(/^export\s+(?:type\s+)?\{[\s\S]*?\}\s*(?:from\s*['"][^'"]+['"]\s*)?;?\s*$/gm,""),j=j.replace(/^export\s+default\s+/gm,""),j=j.replace(/^export\s+(?=(?:declare\s+)?(?:abstract\s+)?(?:async\s+)?(?:function|class|const|let|var|type|interface|enum)\b)/gm,""),F.push(`// ${A.basename(q).replace(/\.[jt]s$/,"")}
3
- ${T.transformSync(j).trim()}`);for(let Q of W)w.add(Q)}catch(Q){console.warn(`[stx] framework composable ${A.basename(q)} could not be bundled:`,Q)}}let U=z.filter((q)=>!w.has(q)&&!L(G,q));if(U.length>0)console.warn(`[stx] could not bundle ${U.join(", ")} from @stacksjs/stx/composables \u2014 `+"calls to them will throw ReferenceError in the browser. Import them explicitly so the bundler inlines them, or use a runtime equivalent from window.stx.");if(F.length===0)return Z.set(J,""),null;let M=[...w].map((q)=>` try { if (!(${JSON.stringify(q)} in __s)) { __s[${JSON.stringify(q)}] = ${q}; if (!(${JSON.stringify(q)} in window)) window[${JSON.stringify(q)}] = ${q}; } } catch (e) {}`).join(`
4
- `),V=`<script data-stx-framework-composables>
5
- ;(function(){
6
- var __s = window.stx = window.stx || {};
7
- ${F.join(`
8
-
9
- `)}
10
- ${M}
11
- })();
12
- </script>`;return Z.set(J,V),V}function v(G){I.clear();for(let H of G)I.add(H)}export{D as selectComposableFiles,k as referencedFrameworkComposables,_ as getFrameworkComposableScript,R as clearFrameworkComposableCache,v as __setRuntimeOwnedForTest};
@@ -1,11 +0,0 @@
1
- // @bun
2
- import{$i as E,_i as j,aj as Z}from"./chunk-9n0gvfrg.js";import{Pl as R,Pq as L,Ql as U,Sl as X,es as M}from"./chunk-r7dd7c7y.js";import{Ht as P}from"./chunk-5h5ydexj.js";import $ from"path";var V=new Map;function w(Q,z){for(let J of Q.matchAll(/\b(?:const|let|var|function|class)\s+([A-Z_a-z$][\w$]*)/g))if(J[1])z.add(J[1]);for(let J of Q.matchAll(/\b(?:const|let|var)\s*\{([^{}]*)\}\s*=/g))for(let H of(J[1]??"").split(",")){let Y=((H.includes(":")?H.split(":").pop():H)??"").replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(Y))z.add(Y)}for(let J of Q.matchAll(/\b(?:const|let|var)\s*\[([^\]]*)\]\s*=/g))for(let H of(J[1]??"").split(",")){let K=H.replace(/=.*$/s,"").replace(/^\s*\.\.\./,"").trim();if(/^[A-Z_a-z$][\w$]*$/.test(K))z.add(K)}}async function u(Q){let z;if(Q)z=$.resolve(Q);else{let q=await M();z=$.resolve(q.root||process.cwd(),q.storesDir||"stores")}let J=new Bun.Glob("*.ts"),H=[];try{for await(let q of J.scan({cwd:z,absolute:!0})){let y=$.basename(q,".ts");if(["index","types"].includes(y))continue;if(q.includes(".d.ts"))continue;H.push(q)}}catch{return Z(V,z,"",""),null}let K=j(H),Y=E(V,z,K);if(Y!==void 0)return Y||null;if(H.length===0)return Z(V,z,K,""),null;let x=[];for(let q of H){let y=await Bun.file(q).text();x.push({file:q,hasUseStore:/useStore\s*\(/.test(y)})}x.sort((q,y)=>{if(q.hasUseStore===y.hasUseStore)return 0;return q.hasUseStore?1:-1});let I=x.map((q)=>q.file),A=[],B=new Set,T=L({loader:"ts",target:"browser",define:X()});for(let q of I)try{let y=await Bun.file(q).text(),W=$.basename(q,".ts");w(y,B),y=R(y),y=U(y),y=y.replace(/^export\s+(default\s+)?/gm,""),y=T.transformSync(y),A.push(`// Store: ${W}
3
- ${y.trim()}`)}catch(y){console.warn(`[stx] Failed to load store ${q}:`,y)}if(A.length===0)return Z(V,z,K,""),null;let G=A.join(`
4
-
5
- `),O=`;(function(){
6
- var __stx = window.stx || {};
7
- ${P.filter((q)=>!B.has(q)&&new RegExp(`\\b${q}\\b`).test(G)).map((q)=>`var ${q} = __stx[${JSON.stringify(q)}];`).join(`
8
- `)}
9
- ${G}
10
- })();`;return Z(V,z,K,O),O}function g(){V.clear()}
11
- export{u as Vi,g as Wi};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{ig as a,jg as b}from"./chunk-j59pkkzn.js";import"./chunk-k6st4606.js";import"./chunk-0y6f4037.js";export{a as handleImageRequest,b as createImageHandler};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Ap as j,rp as a,sp as b,tp as c,up as d,vp as e,wp as f,xp as g,yp as h,zp as i}from"./chunk-r7dd7c7y.js";import"./chunk-25de1sj7.js";import"./chunk-38ykv2gd.js";import"./chunk-4qq5wj04.js";import"./chunk-g8tce9rr.js";import"./chunk-ptcpaeem.js";import"./chunk-a8mnhryz.js";import"./chunk-dnhckx52.js";import"./chunk-jt8as8j8.js";import"./chunk-x84g0m0p.js";import"./chunk-5h5ydexj.js";import"./chunk-aw651z2y.js";import"./chunk-wj2trgsn.js";import"./chunk-0y6f4037.js";export{b as stripTypeScript,h as splitDeclaration,c as isModuleResolutionFailure,d as isMissingBindingFailure,f as isCompleteImport,j as hasVariables,e as extractVariables,i as extractScriptFromTemplate,g as convertToCommonJS,a as STX_ENGINE_BINDING_NAMES};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{$k as b,_k as a,al as c,bl as d,cl as e,dl as f,el as g,fl as h,gl as i,hl as j}from"./chunk-tn2kwwy4.js";import"./chunk-0ha9e1wt.js";import"./chunk-r7dd7c7y.js";import"./chunk-25de1sj7.js";import"./chunk-38ykv2gd.js";import"./chunk-4qq5wj04.js";import"./chunk-g8tce9rr.js";import"./chunk-ptcpaeem.js";import"./chunk-a8mnhryz.js";import"./chunk-dnhckx52.js";import"./chunk-jt8as8j8.js";import"./chunk-x84g0m0p.js";import"./chunk-5h5ydexj.js";import"./chunk-aw651z2y.js";import"./chunk-wj2trgsn.js";import"./chunk-0y6f4037.js";export{b as shouldLogBundlerDiagnostics,f as setBundlerFallbackMode,g as resolveBundlerFallback,c as recordBundleFailure,i as queueClientBundleBuild,h as hasUserImports,d as getBundleFailures,a as clientBundleDependencies,e as clearBundleFailures,j as bundleClientScript};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{ik as a,jk as b,kk as c,lk as d}from"./chunk-c17txgm7.js";import"./chunk-qpsj28s2.js";import"./chunk-r7dd7c7y.js";import"./chunk-25de1sj7.js";import"./chunk-38ykv2gd.js";import"./chunk-4qq5wj04.js";import"./chunk-g8tce9rr.js";import"./chunk-ptcpaeem.js";import"./chunk-a8mnhryz.js";import"./chunk-dnhckx52.js";import"./chunk-jt8as8j8.js";import"./chunk-x84g0m0p.js";import"./chunk-5h5ydexj.js";import"./chunk-aw651z2y.js";import"./chunk-wj2trgsn.js";import"./chunk-0y6f4037.js";export{b as getAvailableTargets,c as getAvailableFormats,d as default,a as buildNative};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Bp as a,Cp as b}from"./chunk-r7dd7c7y.js";import"./chunk-25de1sj7.js";import"./chunk-38ykv2gd.js";import"./chunk-4qq5wj04.js";import"./chunk-g8tce9rr.js";import"./chunk-ptcpaeem.js";import"./chunk-a8mnhryz.js";import"./chunk-dnhckx52.js";import"./chunk-jt8as8j8.js";import"./chunk-x84g0m0p.js";import"./chunk-5h5ydexj.js";import"./chunk-aw651z2y.js";import"./chunk-wj2trgsn.js";import"./chunk-0y6f4037.js";export{b as processLoops,a as parseLoopBinding};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{$o as b,ap as c,em as a}from"./chunk-r7dd7c7y.js";import"./chunk-25de1sj7.js";import"./chunk-38ykv2gd.js";import"./chunk-4qq5wj04.js";import"./chunk-g8tce9rr.js";import"./chunk-ptcpaeem.js";import"./chunk-a8mnhryz.js";import"./chunk-dnhckx52.js";import"./chunk-jt8as8j8.js";import"./chunk-x84g0m0p.js";import"./chunk-5h5ydexj.js";import"./chunk-aw651z2y.js";import"./chunk-wj2trgsn.js";import"./chunk-0y6f4037.js";export{b as processESImports,c as processComponents,a as freeIdentifiers};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{kg as a}from"./chunk-pfm1325e.js";import"./chunk-r7dd7c7y.js";import"./chunk-25de1sj7.js";import"./chunk-38ykv2gd.js";import"./chunk-4qq5wj04.js";import"./chunk-g8tce9rr.js";import"./chunk-ptcpaeem.js";import"./chunk-a8mnhryz.js";import"./chunk-dnhckx52.js";import"./chunk-jt8as8j8.js";import"./chunk-x84g0m0p.js";import"./chunk-5h5ydexj.js";import"./chunk-aw651z2y.js";import"./chunk-wj2trgsn.js";import"./chunk-0y6f4037.js";export{a as buildApp};
@@ -1,3 +0,0 @@
1
- // @bun
2
- import{Wq as q,_q as y}from"./chunk-r7dd7c7y.js";import{Su as L}from"./chunk-0y6f4037.js";import M from"fs";import X from"path";var T=new Map,Q=new Map;async function A(j){let z;for(let K=0;K<3;K++)try{let V=(await M.promises.stat(j)).mtime.getTime(),J=Q.get(j);if(J&&J.mtime===V)return J.content;let W=await Bun.file(j).text(),U=(await M.promises.stat(j)).mtime.getTime();if(U!==V)continue;return Q.set(j,{content:W,mtime:U}),W}catch(I){z=I;break}throw Q.delete(j),Error(`File not found: ${j}${z?` (${z.message})`:""}`)}function H(j){Q.delete(j)}function v(j){for(let B of Q.keys())if(B.startsWith(j))Q.delete(B)}var Z=null,b=null,N=null;function E(j){N=j}async function F(j=!1){let B=N??await import("./chunk-x7pp10qb.js");if(j)return B.generateSignalsRuntimeDev();if(Z===null)Z=B.generateSignalsRuntime();return Z}var $=null;async function R(){if($===null){let{getRouterScript:j}=await import("./chunk-10tcqry1.js");$=j()}return $}function S(){Q.clear(),y(),Z=null,b=null,$=null}function k(j){let B={debug:j.debug===!0,middleware:(j.middleware??[]).map((z)=>({name:z.name,timing:z.timing,handler:String(z.handler)})),customDirectives:(j.customDirectives??[]).map((z)=>({name:z.name,hasEndTag:z.hasEndTag===!0,handler:String(z.handler)}))};return new Bun.CryptoHasher("sha1").update(JSON.stringify(B)).digest("hex")}async function _(j,B){try{if(!B.cachePath)return null;let z=X.resolve(B.cachePath),K=X.join(z,`${D(j)}.html`),I=X.join(z,`${D(j)}.meta.json`);if(!await q(K)||!await q(I))return null;let V=await Bun.file(I).text(),J=JSON.parse(V);if(J.cacheVersion!==B.cacheVersion)return null;if(J.optionsSignature!==k(B))return null;if((await M.promises.stat(j)).mtime.getTime()>J.mtime)return null;for(let Y of J.dependencies)if(await q(Y)){if((await M.promises.stat(Y)).mtime.getTime()>J.mtime)return null}else return null;return await Bun.file(K).text()}catch(z){return console.warn(`Cache error for ${j}:`,z),null}}async function g(j,B,z,K){try{if(!K.cachePath)return;let I=X.resolve(K.cachePath);await M.promises.mkdir(I,{recursive:!0});let V=X.join(I,`${D(j)}.html`),J=X.join(I,`${D(j)}.meta.json`),W=await M.promises.stat(j);await Bun.write(V,B);let Y={sourcePath:j,mtime:W.mtime.getTime(),dependencies:Array.from(z),cacheVersion:K.cacheVersion,optionsSignature:k(K),generatedAt:Date.now()};await Bun.write(J,JSON.stringify(Y,null,2)),T.set(j,{output:B,mtime:W.mtime.getTime(),dependencies:z})}catch(I){console.warn(`Failed to cache template ${j}:`,I)}}var G=16;function D(j){return new Bun.CryptoHasher("sha1").update(j).digest("hex").substring(0,G)}
3
- export{T as Oj,A as Pj,H as Qj,v as Rj,E as Sj,F as Tj,R as Uj,S as Vj,_ as Wj,g as Xj,D as Yj};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{cs as a,ds as b,es as c,fs as d,gs as e,hs as f}from"./chunk-r7dd7c7y.js";import"./chunk-25de1sj7.js";import"./chunk-38ykv2gd.js";import"./chunk-4qq5wj04.js";import"./chunk-g8tce9rr.js";import"./chunk-ptcpaeem.js";import"./chunk-a8mnhryz.js";import"./chunk-dnhckx52.js";import"./chunk-jt8as8j8.js";import"./chunk-x84g0m0p.js";import"./chunk-5h5ydexj.js";import"./chunk-aw651z2y.js";import"./chunk-wj2trgsn.js";import"./chunk-0y6f4037.js";export{f as validateConfig,b as resolveStxDirectories,c as loadStxConfig,e as defineStxConfig,a as defaultConfig,d as config};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{bj as a}from"./chunk-7q9mwh4v.js";import"./chunk-0y6f4037.js";export{a as processDeferDirectives};
@@ -1,2 +0,0 @@
1
- // @bun
2
- import{Xi as a,Yi as b,Zi as c}from"./chunk-new80es4.js";import"./chunk-9n0gvfrg.js";import"./chunk-r7dd7c7y.js";import"./chunk-25de1sj7.js";import"./chunk-38ykv2gd.js";import"./chunk-4qq5wj04.js";import"./chunk-g8tce9rr.js";import"./chunk-ptcpaeem.js";import"./chunk-a8mnhryz.js";import"./chunk-dnhckx52.js";import"./chunk-jt8as8j8.js";import"./chunk-x84g0m0p.js";import"./chunk-5h5ydexj.js";import"./chunk-aw651z2y.js";import"./chunk-wj2trgsn.js";import"./chunk-0y6f4037.js";export{a as listComposableModules,b as getComposableScript,c as clearComposableCache};
@@ -1,11 +0,0 @@
1
- // @bun
2
- import{mt as Jq}from"./chunk-dnhckx52.js";import{Su as Gq}from"./chunk-0y6f4037.js";import $ from"path";import{hasLocalConfig as Uq}from"bunfig";var a={fg:{light:"gray-900",dark:"gray-100",description:"Primary text"},"fg-strong":{light:"gray-700",dark:"gray-300",description:"Labels, secondary headings"},"fg-muted":{light:"gray-600",dark:"gray-400",description:"Supporting text"},"fg-soft":{light:"gray-500",dark:"gray-400",description:"De-emphasised text"},"fg-subtle":{light:"gray-400",dark:"gray-500",description:"Placeholders, disabled text"},surface:{light:"gray-50",dark:"gray-800",description:"Page and panel background"},"surface-raised":{light:"gray-100",dark:"gray-700",description:"Cards, popovers"},"surface-sunken":{light:"gray-200",dark:"gray-700",description:"Wells, track backgrounds"},line:{light:"gray-200",dark:"gray-700",description:"Default border, divider"},"line-strong":{light:"gray-300",dark:"gray-600",description:"Input border, focus ring track"},accent:{light:"indigo-600",dark:"indigo-400",description:"Primary action, selected state"},info:{light:"blue-600",dark:"blue-400",description:"Informational emphasis, links"},danger:{light:"red-600",dark:"red-400",description:"Errors, destructive actions"},success:{light:"green-600",dark:"green-400",description:"Confirmation"},warning:{light:"yellow-500",dark:"yellow-400",description:"Caution"},"accent-solid":{light:"indigo-600",dark:"indigo-500",description:"Primary button fill"},"info-solid":{light:"blue-600",dark:"blue-500",description:"Informational fill"},"danger-solid":{light:"red-600",dark:"red-500",description:"Destructive button fill"},"success-solid":{light:"green-600",dark:"green-500",description:"Confirmation fill"}};function m(G){return`--stx-${G}`}function p(G,q){let Q=q.lastIndexOf("-");if(Q===-1)return typeof G[q]==="string"?G[q]:void 0;let J=G[q.slice(0,Q)];if(!J||typeof J!=="object")return;let Y=J[q.slice(Q+1)];return typeof Y==="string"?Y:void 0}function o(G){let q={};for(let[Q,J]of Object.entries(a)){let Y=p(G,J.light);if(Y===void 0)continue;q[Q]=`var(${m(Q)}, ${Y})`}return q}function t(G){let q=[],Q=[];for(let[J,Y]of Object.entries(a)){let Z=p(G,Y.light),U=p(G,Y.dark);if(Z===void 0)continue;if(q.push(` ${m(J)}: ${Z};`),U!==void 0)Q.push(` ${m(J)}: ${U};`)}if(q.length===0)return"";return["/* stx role tokens \u2014 override any of these to re-theme by meaning. */",":root {",...q,"}",".dark {",...Q,"}",""].join(`
3
- `)}function s(G){return typeof G==="object"&&G!==null&&!Array.isArray(G)}function g(G,q){let Q={...G};for(let[J,Y]of Object.entries(q))Q[J]=s(Y)&&s(Q[J])?g(Q[J],Y):Y;return Q}function e(G={},q={}){let Q=G.theme||{},J=q.theme||{},{extend:Y,...Z}=J,{extend:U,...z}=Q,X=z.colors||{};z.colors={...X,...o(X)};let A=g(z,Z),L=g(U||{},Y||{});if(Object.keys(L).length>0)A.extend=L;let H=[...G.safelist||[],...q.safelist||[]],E={...G.shortcuts||{},...q.shortcuts||{}},P=[...G.preflights||[],...q.preflights||[]];return{config:{...G,...q,theme:A,safelist:H,shortcuts:E,...P.length>0?{preflights:P}:{},content:[],output:""},safelist:H,shortcuts:E,includePreflight:q.preflight!==!1,minify:q.minify===!0,tokenCSS:t(X)}}var W={reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",underscore:"\x1B[4m",blink:"\x1B[5m",reverse:"\x1B[7m",hidden:"\x1B[8m",black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m",gray:"\x1B[90m",bgBlack:"\x1B[40m",bgRed:"\x1B[41m",bgGreen:"\x1B[42m",bgYellow:"\x1B[43m",bgBlue:"\x1B[44m",bgMagenta:"\x1B[45m",bgCyan:"\x1B[46m",bgWhite:"\x1B[47m",bgGray:"\x1B[100m"};var F=null,C=!1,_=null,b="",K=!1,Qq=256,V=new Map,O=new Map,j=null,d=null;function S(G){return Bun.hash(G).toString(16).padStart(16,"0").slice(0,16)}function u(G,q){if(V.has(G))V.delete(G);else if(V.size>=Qq)V.delete(V.keys().next().value);V.set(G,q)}function Wq(G){let q=S(G);if(O.has(q))O.delete(q);else if(O.size>=Qq)O.delete(O.keys().next().value);return O.set(q,G),q}function Dq(G){let q=O.get(G);if(q===void 0)return;return O.delete(G),O.set(G,q),q}async function Xq(G){if(!j)return null;try{let q=Bun.file($.join(j,`cw-${S(G)}.css`));if(!await q.exists())return null;return await q.text()}catch{return null}}async function zq(G,q){if(!j)return;try{if(!fs.existsSync(j))fs.mkdirSync(j,{recursive:!0});await Bun.write($.join(j,`cw-${S(G)}.css`),q)}catch{}}async function qq(G){try{let q=await import(G);if(q&&q.CSSGenerator)return{CSSGenerator:q.CSSGenerator,config:q.config,build:q.build,defaultConfig:q.defaultConfig,extractClasses:q.extractClasses}}catch{}return null}function Iq(){let G=[],q=process.cwd();while(q!==$.dirname(q))G.push($.join(q,"node_modules","@cwcss","crosswind","dist","index.js")),G.push($.join(q,"node_modules","@cwcss","crosswind","src","index.ts")),G.push($.join(q,"pantry","@cwcss","crosswind","dist","index.js")),G.push($.join(q,"pantry","@cwcss","crosswind","src","index.ts")),G.push($.join(q,"node_modules","@stacksjs","crosswind","dist","index.js")),G.push($.join(q,"pantry","@stacksjs","crosswind","dist","index.js")),q=$.dirname(q);return G}function Oq(){let G=[],q=process.env.HOME||process.env.USERPROFILE||"";if(q){let Q=[$.join(q,"Code","Tools","crosswind","packages","crosswind","dist","index.js"),$.join(q,"Code","Tools","crosswind","packages","crosswind","src","index.ts"),$.join(q,"repos","stacks-org","crosswind","packages","crosswind","dist","index.js"),$.join(q,"repos","stacks-org","crosswind","packages","crosswind","src","index.ts"),$.join(q,"Code","Tools","stx","packages","stx","node_modules","@cwcss","crosswind","dist","index.js"),$.join(q,"Code","Tools","stx","packages","stx","node_modules","@stacksjs","crosswind","dist","index.js")];G.push(...Q)}return G.push($.join(process.cwd(),"..","crosswind","packages","crosswind","dist","index.js")),G.push($.join(process.cwd(),"..","crosswind","packages","crosswind","src","index.ts")),G}async function Yq(){if(C)return F;C=!0;try{let G=async(Y)=>{for(let Z of Y){if(!await Bun.file(Z).exists())continue;let U=await qq(Z);if(U){if(!process.env.STACKS_DEV_QUIET)console.log(`${W.green}[Crosswind]${W.reset} CSS engine loaded from ${$.dirname($.dirname(Z))}`);return U}}return null};if(process.env.CROSSWIND_SRC){let Y=$.resolve(process.env.CROSSWIND_SRC),Z=await G([Y]);if(!Z)throw Error(`CROSSWIND_SRC did not resolve to a Crosswind module: ${Y}`);return F=Z,F}let q=await G(Iq());if(q)return F=q,F;let Q=["@cwcss/crosswind","@cwcss/crosswind/dist/index.js","@stacksjs/crosswind","@stacksjs/crosswind/dist/index.js"];for(let Y of Q){let Z=await qq(Y);if(Z){if(F=Z,!process.env.STACKS_DEV_QUIET)console.log(`${W.green}[Crosswind]${W.reset} CSS engine loaded`);return F}}let J=await G(Oq());if(J)return F=J,F;throw Error("Crosswind CSSGenerator not found in any location")}catch{return console.warn(`${W.yellow}[Crosswind] CSS engine not available, Tailwind styles will not be generated${W.reset}`),console.warn(`${W.yellow}Run 'bun add @stacksjs/crosswind' to enable CSS generation${W.reset}`),null}}function Sq(){V.clear(),O.clear()}function xq(){F=null,C=!1,_=null,b="",V.clear(),O.clear(),d=null}async function Zq(G){try{if(!Uq({name:"crosswind",cwd:G}))return null;let{loadConfigWithResult:q}=await import("bunfig"),Q=await q({name:"crosswind",cwd:G,defaultConfig:{},checkEnv:!1,verbose:!1});if(!Q?.path||!Q.config||Object.keys(Q.config).length===0)return null;let J=$.relative(G,Q.path);if(!process.env.STACKS_DEV_QUIET)console.log(`${W.green}[Crosswind]${W.reset} Loaded config from ${J||Q.path}`);return Q.config}catch(q){if(q instanceof Error&&q.name==="ConfigNotFoundError")return null;return console.warn(`${W.yellow}[Crosswind]${W.reset} Failed to load crosswind config:`,q instanceof Error?q.message:q),null}}async function _q(G){let q=null;try{let{loadStxConfig:Q}=await import("./chunk-m116b3d9.js"),J=await Q(G);if(J.css)if(typeof J.css==="string"){let Y=$.isAbsolute(J.css)?J.css:$.resolve(G,J.css);if(await Bun.file(Y).exists()){let Z=await import(Y);q=Z.default||Z,console.log(`${W.green}[Crosswind]${W.reset} Loaded config from stx.config.ts \u2192 ${J.css}`)}}else{if(q={...J.css,content:J.css.content||[],preflight:J.css.preflight??!0,minify:J.css.minify??!1},J.css.config){let Y=$.isAbsolute(J.css.config)?J.css.config:$.resolve(G,J.css.config);if(await Bun.file(Y).exists()){let Z=await import(Y);q={...Z.default||Z,...q}}}console.log(`${W.green}[Crosswind]${W.reset} Using inline CSS config from stx.config.ts`)}}catch{}return q||await Zq(G)}function Fq(G){try{let q=new WeakSet;return S(JSON.stringify(G??{},(Q,J)=>{if(typeof J==="function")return`[fn]${String(J)}`;if(typeof J==="object"&&J!==null){if(q.has(J))return"[circular]";q.add(J)}return J})??"")}catch{return"unhashable"}}async function Nq(G){if(K)return b;K=!0;try{let q=await Yq();if(!q||!q.build)return K=!1,"";if(!_)_=await Zq(G);if(!_)return K=!1,"";let Q=q.defaultConfig?.theme||{},J=_.theme||{},Y={...q.defaultConfig,..._,theme:{...Q,...J,extend:{...Q.extend||{},...J.extend||{}}}},Z=performance.now(),U=await q.build(Y),z=performance.now()-Z;if(b=U.css,console.log(`${W.cyan}[Crosswind]${W.reset} Built ${U.classes.size} classes in ${z.toFixed(1)}ms`),Y.output){let X=$.isAbsolute(Y.output)?Y.output:$.join(G,Y.output),A=$.dirname(X);if(!fs.existsSync(A))fs.mkdirSync(A,{recursive:!0});await Bun.write(X,U.css)}return K=!1,U.css}catch(q){return console.error(`${W.red}[Crosswind]${W.reset} Build error:`,q),K=!1,b}}async function kq(G){_=null,await Nq(G)}function wq(){return b}function Vq(G){let q=new Set,Q=/class\s*=\s*["']([^"']+)["']/gi,J=Q.exec(G);while(J!==null){for(let U of J[1].split(/\s+/))if(U.trim())q.add(U.trim());J=Q.exec(G)}let Y=/(?:x-class|:class)\s*=\s*"([^"]+)"/gi,Z=Y.exec(G);while(Z!==null){let U=Z[1].match(/'([^']+)'/g);if(U){for(let z of U)for(let X of z.slice(1,-1).split(/\s+/))if(X.trim())q.add(X.trim())}Z=Y.exec(G)}return q}async function jq(G,q){try{let Q=await Yq();if(!Q)return"";let J=typeof Q.extractClasses==="function"?Q.extractClasses(G):Vq(G);if(J.size===0)return"";let Y=q?$.resolve(q):process.cwd();if(!j)j=Jq(Y,"cache");let Z=[...J].sort().join(" "),U=`${d||"default"}::${Z}`,z=V.get(U);if(z!==void 0)return u(U,z),z;let X=await Xq(U);if(X!==null)return u(U,X),X;if(!_)_=await _q(Y),d=Fq(_);let A=Q.defaultConfig||Q.config,L=_||{},H=e(A,L),{safelist:E,includePreflight:P,minify:x,tokenCSS:$q}=H,h=H.config,R=new Q.CSSGenerator(h);for(let I of E)R.generate(I);for(let I of J)R.generate(I);let N=R.toCSS(P,x),i=h.shortcuts||L.shortcuts||{};for(let[I,k]of Object.entries(i)){if(!J.has(I)&&!E.includes(I))continue;let w=k.split(/\s+/).filter(Boolean);for(let T of w)R.generate(T)}N=R.toCSS(P,x);let B=N.split(`
4
- `);for(let[I,k]of Object.entries(i)){if(!J.has(I)&&!E.includes(I))continue;let w=k.split(/\s+/).filter(Boolean),T=[],y=[];for(let v of w){let c=v.startsWith("dark:"),n=`.${(c?v.slice(5):v).replace(/\//g,"\\/").replace(/:/g,"\\:").replace(/\./g,"\\.").replace(/\[/g,"\\[").replace(/\]/g,"\\]").replace(/%/g,"\\%")}`;for(let M=0;M<B.length;M++){let l=B[M].trim();if(l===`${n} {`||l.startsWith(`${n} {`)){let D=M,r="";while(D<B.length){if(r+=B[D],B[D].includes("}"))break;D++}let f=r.match(/\{([^}]+)\}/);if(f)if(c)y.push(f[1].trim());else T.push(f[1].trim());break}}}if(T.length)N+=`
5
- .${I} { ${T.join(" ")} }`;if(y.length)N+=`
6
- @media (prefers-color-scheme: dark) { .dark .${I} { ${y.join(" ")} } }`}return N=$q+N,u(U,N),zq(U,N),N}catch(Q){return console.warn("Failed to generate Crosswind CSS:",Q),""}}async function yq(G,q,Q=!1){let J=await jq(G,q);if(!J)return G;let Y=Q?`<link data-crosswind="generated" rel="stylesheet" href="/_stx/crosswind.${Wq(J)}.css">`:`<style data-crosswind="generated">
7
- ${J}
8
- </style>`,Z=/(?:<style\b[^>]*\bdata-crosswind=(?:"generated"|'generated')[^>]*>[\s\S]*?<\/style>|<link\b[^>]*\bdata-crosswind=(?:"generated"|'generated')[^>]*>)/g;if(Z.test(G)){let U=!1;return G.replace(Z,()=>{if(U)return"";return U=!0,Y})}if(G.includes("</head>"))return G.replace("</head>",`${Y}
9
- </head>`);if(G.includes("<body"))return G.replace(/<body([^>]*)>/,`<body$1>
10
- ${Y}`);return Y+G}
11
- export{g as Ns,e as Os,W as Ps,Dq as Qs,Yq as Rs,Sq as Ss,xq as Ts,Zq as Us,_q as Vs,Fq as Ws,Nq as Xs,kq as Ys,wq as Zs,Vq as _s,jq as $s,yq as at};