@stacksjs/stx 0.2.534 → 0.2.536

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 (85) hide show
  1. package/dist/{chunk-843y0pfg.js → chunk-0yveptr0.js} +2 -2
  2. package/dist/{chunk-01343ehq.js → chunk-1es2y1jz.js} +1 -1
  3. package/dist/{chunk-13zbt9py.js → chunk-22ztsen0.js} +1 -1
  4. package/dist/{chunk-7zgtdap7.js → chunk-2kf4z3e6.js} +1 -1
  5. package/dist/{chunk-9p6bt089.js → chunk-33vbh6g3.js} +1 -1
  6. package/dist/{chunk-qqr4rn9p.js → chunk-5zp9wt6m.js} +2 -2
  7. package/dist/{chunk-pz1mjgsp.js → chunk-672nmsmm.js} +1 -1
  8. package/dist/{chunk-nmy4x6dx.js → chunk-7g90r41h.js} +1 -1
  9. package/dist/{chunk-f3q84h7b.js → chunk-8bt1mxny.js} +1 -1
  10. package/dist/{chunk-d1jxmhph.js → chunk-9e1hftmd.js} +1 -1
  11. package/dist/{chunk-7v2j9bmc.js → chunk-bgvqcjrg.js} +1 -1
  12. package/dist/{chunk-8chxczpj.js → chunk-bk5g7qez.js} +1 -1
  13. package/dist/{chunk-wxy9re1a.js → chunk-c0prbbpe.js} +1 -1
  14. package/dist/{chunk-kcs7hyep.js → chunk-dr0394tm.js} +1 -1
  15. package/dist/{chunk-tgc645pa.js → chunk-e6mmvwy9.js} +5 -5
  16. package/dist/{chunk-bxsehntq.js → chunk-f1cc1z85.js} +1 -1
  17. package/dist/{chunk-9674w2gm.js → chunk-g9byv420.js} +1 -1
  18. package/dist/{chunk-4a7v51vh.js → chunk-gx3cs15y.js} +1 -1
  19. package/dist/{chunk-sqb6gkzf.js → chunk-h51g1ydb.js} +1 -1
  20. package/dist/{chunk-gsc5t942.js → chunk-hen8zqnp.js} +1 -1
  21. package/dist/{chunk-tr9bjtqx.js → chunk-hpkrscgk.js} +1 -1
  22. package/dist/{chunk-z9r3tqyr.js → chunk-jn9e5a4t.js} +1 -1
  23. package/dist/{chunk-90kzf313.js → chunk-jq3j35a6.js} +1 -1
  24. package/dist/{chunk-xwrbrg1q.js → chunk-jsa2apk6.js} +1 -1
  25. package/dist/{chunk-94rg5s6c.js → chunk-jskc4rr7.js} +1 -1
  26. package/dist/{chunk-jv3jj612.js → chunk-knxqe213.js} +1 -1
  27. package/dist/chunk-kvn3xsfq.js +2 -0
  28. package/dist/{chunk-k3v13vfr.js → chunk-mx3rh8zj.js} +1 -1
  29. package/dist/chunk-n9k24wmf.js +57 -0
  30. package/dist/{chunk-d871008z.js → chunk-nn66ek7z.js} +1 -1
  31. package/dist/{chunk-ngma9vzc.js → chunk-pd460250.js} +1 -1
  32. package/dist/{chunk-v4r8nzf3.js → chunk-pekfkzh7.js} +1 -1
  33. package/dist/{chunk-gnx0fzne.js → chunk-pwdvc964.js} +19 -19
  34. package/dist/{chunk-3zs8yxy0.js → chunk-qmd2kvb2.js} +1 -1
  35. package/dist/{chunk-kvp0at16.js → chunk-s9htq6ef.js} +1 -1
  36. package/dist/{chunk-2n4je46m.js → chunk-sh8ec2e0.js} +1 -1
  37. package/dist/chunk-sve2646p.js +2 -0
  38. package/dist/{chunk-5g498pdp.js → chunk-sye2bjyq.js} +1 -1
  39. package/dist/{chunk-6rcxtdh3.js → chunk-tr49ckr5.js} +1 -1
  40. package/dist/{chunk-qk3ptn6h.js → chunk-va61kyky.js} +1 -1
  41. package/dist/{chunk-93n6yv5x.js → chunk-ve6tn04z.js} +1 -1
  42. package/dist/{chunk-0e5nasyf.js → chunk-vmq2dd3k.js} +1 -1
  43. package/dist/{chunk-fqfqyn48.js → chunk-xq7f1yc2.js} +1 -1
  44. package/dist/chunk-xvjtj1kt.js +2 -0
  45. package/dist/{chunk-vfnerp7h.js → chunk-xy5sx2z1.js} +1 -1
  46. package/dist/{chunk-2h4f37kx.js → chunk-xz7dk3yc.js} +1 -1
  47. package/dist/{chunk-zeve89kw.js → chunk-y5acfh13.js} +1 -1
  48. package/dist/{chunk-4pxc3r1p.js → chunk-z0h3we7z.js} +2 -2
  49. package/dist/{chunk-jvqas8y2.js → chunk-zaj09h72.js} +1 -1
  50. package/dist/{chunk-wjt46tdp.js → chunk-zs5p8jcn.js} +1 -1
  51. package/dist/cli.js +8 -8
  52. package/dist/client/signals-loop-conditional-runtime.d.ts +1 -1
  53. package/dist/client/signals-loop-conditional-runtime.js +1 -1
  54. package/dist/craft-entry.js +1 -1
  55. package/dist/craft.js +1 -1
  56. package/dist/native/bridge/protocol.d.ts +3 -1
  57. package/dist/native/compiler/browser.d.ts +10 -0
  58. package/dist/native/compiler/browser.js +31 -0
  59. package/dist/native/compiler/bundle.d.ts +3 -0
  60. package/dist/native/compiler/bundle.js +27 -10
  61. package/dist/native/compiler/html-to-ir.d.ts +2 -0
  62. package/dist/native/compiler/html-to-ir.js +8 -3
  63. package/dist/native/compiler/icons.d.ts +2 -0
  64. package/dist/native/compiler/icons.js +2 -0
  65. package/dist/native/compiler/render-screen.d.ts +1 -0
  66. package/dist/native/compiler/render-screen.js +2 -2
  67. package/dist/native/index.d.ts +1 -0
  68. package/dist/native/index.js +1 -0
  69. package/dist/native/runtime/browser-renderer.d.ts +16 -0
  70. package/dist/native/runtime/browser-renderer.js +537 -0
  71. package/dist/native/runtime/browser-screen.d.ts +26 -0
  72. package/dist/native/runtime/browser-screen.js +254 -0
  73. package/dist/native/runtime/craft-bridge.js +10 -6
  74. package/dist/native/runtime/craft.d.ts +1 -0
  75. package/dist/native/runtime/jsc-globals.js +1 -1
  76. package/dist/native/runtime/native-host.js +9 -4
  77. package/dist/pwa.js +1 -1
  78. package/dist/signals-loop-conditional-runtime.d.ts +1 -1
  79. package/dist/ssg.js +2 -2
  80. package/dist/variable-extractor.js +5 -1
  81. package/package.json +5 -5
  82. package/dist/chunk-40hbpz2b.js +0 -45
  83. package/dist/chunk-5wx323bm.js +0 -2
  84. package/dist/chunk-epa1c4q4.js +0 -2
  85. package/dist/chunk-ydtnskdv.js +0 -2
@@ -13,13 +13,18 @@ function nativeRuntimeModule(name) {
13
13
  throw Error(`Native runtime module ${name} is missing`);
14
14
  return resolved;
15
15
  }
16
- async function build(entry, plugins, minify) {
17
- const result = await Bun.build({
16
+ async function build(entry, plugins, minify, dependencies) {
17
+ const track = { name: "stx-screen-inputs", setup(builder) {
18
+ builder.onLoad({ filter: /.*/, namespace: "file" }, ({ path: file }) => {
19
+ dependencies.add(file);
20
+ return;
21
+ });
22
+ } }, result = await Bun.build({
18
23
  entrypoints: [entry],
19
24
  target: "browser",
20
25
  format: "iife",
21
26
  minify,
22
- plugins,
27
+ plugins: [track, ...plugins],
23
28
  define: { "process.env.NODE_ENV": JSON.stringify(minify ? "production" : "development") }
24
29
  });
25
30
  if (!result.success) {
@@ -51,7 +56,7 @@ export async function compileNativeBundle(options) {
51
56
  throw Error("An app script needs a routed bundle");
52
57
  if (appFile && options.screens[NATIVE_APP_ROUTE])
53
58
  throw Error(`${NATIVE_APP_ROUTE} is the app script's route, not a screen name`);
54
- const route = routed ? `var routeName = g.__stxNativeRoute || ${JSON.stringify(initialScreen)};
59
+ const browser = options.browser, route = routed ? `var routeName = g.__stxNativeRoute || ${JSON.stringify(initialScreen)};
55
60
  var isApp = ${appFile ? `routeName === ${JSON.stringify(NATIVE_APP_ROUTE)}` : "false"};
56
61
  if (!isApp && routeNames.indexOf(routeName) === -1) throw new Error(['Unknown native screen:', routeName].join(' '));` : `var routeName = 'main';
57
62
  var isApp = false;`, selections = compiledScreens.map(({ name, compiled }, index) => `${index === 0 ? "if" : "else if"} (routeName === ${JSON.stringify(routed ? name : "main")}) {
@@ -61,13 +66,19 @@ var isApp = false;`, selections = compiledScreens.map(({ name, compiled }, index
61
66
  `), setups = compiledScreens.map(({ name, compiled }, index) => `${index === 0 ? "if" : "else if"} (routeName === ${JSON.stringify(routed ? name : "main")}) {
62
67
  ${compiled.setup?.code ?? "g.__stx_latestSetup = null;"}
63
68
  }`).join(`
64
- `), contents = `
69
+ `), browserRuntime = browser ? nativeRuntimeModule("browser-screen") : null, platformModule = browser ? Bun.resolveSync(browser.platformModule, root) : null, contents = `
65
70
  import { installJSCGlobals } from ${JSON.stringify(runtimeGlobals)};
66
71
  import { prepareNativeApp, prepareSharedNativeScreen } from ${JSON.stringify(sharedScreen)};
72
+ ${browser ? `import { createBrowserScreenBridge } from ${JSON.stringify(browserRuntime)};
73
+ import { createBrowserPlatform } from ${JSON.stringify(platformModule)};` : ""}
67
74
  ${appFile ? `import * as nativeAppModule from ${JSON.stringify(appFile)};` : "var nativeAppModule = null;"}
75
+ ${browser ? "(async function() {" : ""}
68
76
  var g = globalThis;
69
77
  installJSCGlobals(g);
70
- var bridge = g.__stxNativeBridge;
78
+ ${browser ? `var browserPlatform = await createBrowserPlatform(${JSON.stringify(browser.platformOptions ?? {})});
79
+ var browserBridge = createBrowserScreenBridge(browserPlatform, ${JSON.stringify(browser)});
80
+ var bridge = browserBridge;
81
+ g.__stxNativeRoute = ${JSON.stringify(initialScreen)};` : "var bridge = g.__stxNativeBridge;"}
71
82
  if (!bridge) throw new Error('Missing __stxNativeBridge');
72
83
  var routeNames = ${JSON.stringify(routed ? names : ["main"])};
73
84
  ${route}
@@ -90,22 +101,28 @@ ${generateSignalsRuntime()}
90
101
  ${setups}
91
102
  if (isApp) app.start(nativeAppModule);
92
103
  else screen.mount(g.stx, g.__stx_latestSetup || null);
93
- `, code = await build("stx:native-shared-screens", [{
104
+ ${browser ? `var stopApp = nativeAppModule && typeof nativeAppModule.default === 'function' ? nativeAppModule.default(g.craft) : null;
105
+ var unmount = g.__stxNativeUnmount;
106
+ var ended = false;
107
+ g.__stxNativeUnmount = function() { if (ended) return; ended = true; if (typeof stopApp === 'function') stopApp(); unmount(); browserBridge.dispose(); };
108
+ g.addEventListener('pagehide', function(event) { if (!event.persisted) g.__stxNativeUnmount(); });
109
+ })().catch(function(error) { console.error('[stx browser screen]', error); var node = document.querySelector(${JSON.stringify(browser.container)}); if (node) { node.textContent = 'This screen could not start. Reload to try again.'; node.setAttribute('role', 'alert'); } });` : ""}
110
+ `, plugin = {
94
111
  name: "stx-native-shared-screens",
95
112
  setup(builder) {
96
113
  builder.onResolve({ filter: /^stx:native-shared-screens$/ }, () => ({ path: "entry", namespace: "stx-native-shared-screens" }));
97
114
  builder.onLoad({ filter: /.*/, namespace: "stx-native-shared-screens" }, () => ({ contents, loader: "js" }));
98
115
  }
99
- }], options.minify ?? !1), diagnostics = compiledScreens.flatMap(({ compiled }) => compiled.diagnostics).map((diagnostic) => ({
116
+ }, dependencies = new Set(compiledScreens.flatMap(({ compiled }) => compiled.dependencies)), code = await build("stx:native-shared-screens", [plugin], options.minify ?? !1, dependencies), diagnostics = compiledScreens.flatMap(({ compiled }) => compiled.diagnostics).map((diagnostic) => ({
100
117
  level: "warning",
101
118
  message: [diagnostic.kind, diagnostic.tag, diagnostic.name].filter(Boolean).join(": ")
102
119
  }));
103
120
  if (!options.outFile)
104
- return { code, diagnostics };
121
+ return { code, diagnostics, dependencies: [...dependencies] };
105
122
  const outFile = path.resolve(root, options.outFile);
106
123
  mkdirSync(path.dirname(outFile), { recursive: !0 });
107
124
  await Bun.write(outFile, code);
108
- return { code, outFile, diagnostics };
125
+ return { code, outFile, diagnostics, dependencies: [...dependencies] };
109
126
  }
110
127
  export async function compileSharedScreenBundle(file, options = {}) {
111
128
  return compileNativeBundle({ ...options, screens: { main: file }, routed: !1 });
@@ -37,6 +37,8 @@ export type TranslationDiagnosticKind = | 'unmapped-tag'
37
37
  | 'unread-event'
38
38
  /** An inline CSS property the IR has no field for. */
39
39
  | 'unknown-style'
40
+ /** A static utility class has no native style translation. */
41
+ | 'unknown-class'
40
42
  /** A value the IR's field cannot hold, so emitting it would brick the screen. */
41
43
  | 'non-numeric-style'
42
44
  /** A legacy virtual-list prop has no meaning in the shared-runtime tree. */
@@ -361,7 +361,10 @@ function readAttributes(tag, attributes, diagnostics) {
361
361
  props[prop] = decoded;
362
362
  }
363
363
  }
364
- const style = { ...classes ? compileClassStyles(classes).style : {}, ...inline };
364
+ const compiledClasses = classes ? compileClassStyles(classes) : void 0;
365
+ for (const name of new Set(compiledClasses?.unknown ?? []))
366
+ diagnostics.push({ kind: "unknown-class", tag, name });
367
+ const style = { ...compiledClasses?.style, ...inline };
365
368
  return { props, style, events, bindings, classes, inline };
366
369
  }
367
370
  function structuredStyle(property, value) {
@@ -528,8 +531,10 @@ export async function translateHtmlToIR(html, options = {}) {
528
531
  delete props.src;
529
532
  }
530
533
  if (type === "Icon") {
531
- const icon = compileClassStyles(classes).icon;
532
- props.symbol = resolveIconName(String(props.symbol || props.name || icon || ""), Boolean(props.symbol)).symbol;
534
+ const icon = compileClassStyles(classes).icon, resolved = resolveIconName(String(props.symbol || props.name || icon || ""), Boolean(props.symbol));
535
+ props.symbol = resolved.symbol;
536
+ if (resolved.iconify)
537
+ props.iconify = resolved.iconify;
533
538
  }
534
539
  if (type === "FlatList" || type === "SectionList") {
535
540
  const names = new Set([...Object.keys(props), ...Object.keys(bindings)].map((name) => name.toLowerCase()));
@@ -89,6 +89,8 @@ export declare const LUCIDE_TO_SF: {
89
89
  'chevron-up': 'chevron.up';
90
90
  'circle': 'circle';
91
91
  'circle-alert': 'exclamationmark.circle';
92
+ 'circle-arrow-out-up-left': 'arrow.uturn.backward.circle';
93
+ 'circle-minus': 'minus.circle';
92
94
  'circle-arrow-down': 'arrow.down.circle';
93
95
  'circle-check': 'checkmark.circle';
94
96
  'circle-check-big': 'checkmark.circle';
@@ -63,6 +63,8 @@ export const FALLBACK_SYMBOL = "circle", LUCIDE_TO_SF = {
63
63
  "chevron-up": "chevron.up",
64
64
  circle: "circle",
65
65
  "circle-alert": "exclamationmark.circle",
66
+ "circle-arrow-out-up-left": "arrow.uturn.backward.circle",
67
+ "circle-minus": "minus.circle",
66
68
  "circle-arrow-down": "arrow.down.circle",
67
69
  "circle-check": "checkmark.circle",
68
70
  "circle-check-big": "checkmark.circle",
@@ -22,6 +22,7 @@ export declare interface CompileScreenOptions {
22
22
  context?: Record<string, unknown>
23
23
  }
24
24
  export declare interface CompiledScreen {
25
+ dependencies: string[]
25
26
  document: STXDocument
26
27
  manifest: BindingManifest
27
28
  setup: GeneratedSetupScript | null
@@ -25,7 +25,7 @@ export async function compileScreenSource(source, filePath, options = {}) {
25
25
  cache: !1,
26
26
  _targetComponentDirs: [nativePrimitivesDir()],
27
27
  _pluginComponentDirs: loaded._pluginComponentDirs ?? []
28
- }, context = { ...options.context ?? {}, __stx_inject_css: !1 }, renderedHtml = await processDirectives(source, context, filePath, config, new Set), { html, manifest } = extractBindingManifest(renderedHtml), { document, diagnostics } = await translateHtmlToDocument(html, {
28
+ }, context = { ...options.context ?? {}, __stx_inject_css: !1 }, dependencies = new Set([filePath]), renderedHtml = await processDirectives(source, context, filePath, config, dependencies), { html, manifest } = extractBindingManifest(renderedHtml), { document, diagnostics } = await translateHtmlToDocument(html, {
29
29
  source: filePath,
30
30
  script: extractClientScript(source)
31
31
  });
@@ -34,7 +34,7 @@ export async function compileScreenSource(source, filePath, options = {}) {
34
34
  const forced = await processScriptSetup(source, filePath, options.context, { forceClientSetup: !0 });
35
35
  setup = extractGeneratedSetupScript(forced.setupCode ?? "") ?? setup;
36
36
  }
37
- return { document, manifest, setup, diagnostics, html };
37
+ return { document, manifest, setup, diagnostics, html, dependencies: [...dependencies] };
38
38
  }
39
39
  export async function compileScreenFile(filePath, options = {}) {
40
40
  return compileScreenSource(await Bun.file(filePath).text(), filePath, options);
@@ -59,6 +59,7 @@ export * from './compiler/html-to-ir';
59
59
  export * from './compiler/client-script';
60
60
  export * from './compiler/render-screen';
61
61
  export * from './compiler/bundle';
62
+ export * from './compiler/browser';
62
63
  export * from './compiler/icons';
63
64
  export * from './cli';
64
65
  export * from './runtime/shared-screen';
@@ -4,6 +4,7 @@ export * from "./compiler/html-to-ir.js";
4
4
  export * from "./compiler/client-script.js";
5
5
  export * from "./compiler/render-screen.js";
6
6
  export * from "./compiler/bundle.js";
7
+ export * from "./compiler/browser.js";
7
8
  export * from "./compiler/icons.js";
8
9
  export * from "./cli.js";
9
10
  export * from "./runtime/shared-screen.js";
@@ -0,0 +1,16 @@
1
+ import type { NativeMutationPayload } from '../bridge/protocol';
2
+ import type { STXNode } from '../compiler/ir';
3
+ export declare interface BrowserRendererOptions {
4
+ icons?: Record<string, { body: string, width?: number, height?: number }>
5
+ event: (handlerId: string, payload: Record<string, unknown>) => void
6
+ resolveMedia?: (url: string) => Promise<string>
7
+ }
8
+ /** Real browser controls for the same view descriptors and mutations as Craft. */
9
+ export declare class BrowserScreenRenderer {
10
+ readonly nodes: unknown;
11
+ readonly container: HTMLElement;
12
+ constructor(container: HTMLElement, options: BrowserRendererOptions);
13
+ render(tree: STXNode): void;
14
+ mutate(batch: NativeMutationPayload): void;
15
+ dispose(): void;
16
+ }