sygnal 7.0.0 → 7.2.0-preview.0
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/CHANGELOG.md +632 -0
- package/dist/agent-ui.cjs.js +592 -0
- package/dist/agent-ui.cjs.js.map +1 -0
- package/dist/agent-ui.esm.js +582 -0
- package/dist/agent-ui.esm.js.map +1 -0
- package/dist/api.cjs.js +63 -0
- package/dist/api.cjs.js.map +1 -0
- package/dist/api.esm.js +2 -0
- package/dist/api.esm.js.map +1 -0
- package/dist/astro/index.cjs.js +968 -4
- package/dist/astro/index.cjs.js.map +1 -1
- package/dist/astro/index.mjs +968 -4
- package/dist/astro/index.mjs.map +1 -1
- package/dist/astro/server.cjs.js +73 -45
- package/dist/astro/server.cjs.js.map +1 -1
- package/dist/astro/server.mjs +73 -45
- package/dist/astro/server.mjs.map +1 -1
- package/dist/canvas.cjs.js +2919 -0
- package/dist/canvas.cjs.js.map +1 -0
- package/dist/canvas.esm.js +2866 -0
- package/dist/canvas.esm.js.map +1 -0
- package/dist/devtools.cjs.js +38 -6
- package/dist/devtools.cjs.js.map +1 -1
- package/dist/devtools.esm.js +38 -6
- package/dist/devtools.esm.js.map +1 -1
- package/dist/diagnostics.cjs.js +224 -20
- package/dist/diagnostics.cjs.js.map +1 -1
- package/dist/diagnostics.esm.js +224 -20
- package/dist/diagnostics.esm.js.map +1 -1
- package/dist/guide/accessibility.md +1 -1
- package/dist/guide/ai-compose.md +150 -0
- package/dist/guide/behaviors.md +2 -1
- package/dist/guide/collaborative-state.md +265 -0
- package/dist/guide/element-commands.md +36 -2
- package/dist/guide/forms-reference.md +5 -5
- package/dist/guide/forms.md +3 -2
- package/dist/guide/http.md +28 -1
- package/dist/guide/islands.md +240 -0
- package/dist/guide/recipes/code-editor.md +1 -1
- package/dist/guide/renderers/agent-ui.md +138 -0
- package/dist/guide/renderers/custom-targets.md +126 -0
- package/dist/guide/renderers/overview.md +120 -0
- package/dist/guide/renderers/react-native.md +128 -0
- package/dist/guide/renderers/terminal.md +306 -0
- package/dist/guide/renderers/three.md +332 -0
- package/dist/guide/renderers/write-once.md +137 -0
- package/dist/guide/resources.md +2 -0
- package/dist/guide/sandboxed-components.md +223 -0
- package/dist/guide/timers.md +32 -5
- package/dist/guide/typed-apis.md +442 -0
- package/dist/guide/ui/accordion.md +11 -0
- package/dist/guide/ui/combobox.md +112 -8
- package/dist/guide/ui/dialog.md +96 -20
- package/dist/guide/ui/menu.md +57 -5
- package/dist/guide/ui/overview.md +8 -4
- package/dist/guide/ui/popover.md +69 -9
- package/dist/guide/ui/select.md +54 -4
- package/dist/guide/ui/tabs.md +1 -1
- package/dist/guide/ui/tooltip.md +7 -5
- package/dist/guide/virtual-collections.md +3 -0
- package/dist/guide/widgets.md +90 -1
- package/dist/host.cjs.js +2181 -0
- package/dist/host.cjs.js.map +1 -0
- package/dist/host.esm.js +2146 -0
- package/dist/host.esm.js.map +1 -0
- package/dist/index.cjs.js +3948 -586
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +584 -44
- package/dist/index.esm.js +3918 -586
- package/dist/index.esm.js.map +1 -1
- package/dist/primitives.cjs.js +143 -0
- package/dist/primitives.cjs.js.map +1 -0
- package/dist/primitives.esm.js +133 -0
- package/dist/primitives.esm.js.map +1 -0
- package/dist/react-native.cjs.js +248 -0
- package/dist/react-native.cjs.js.map +1 -0
- package/dist/react-native.esm.js +244 -0
- package/dist/react-native.esm.js.map +1 -0
- package/dist/replay.cjs.js +39 -0
- package/dist/replay.cjs.js.map +1 -0
- package/dist/replay.esm.js +2 -0
- package/dist/replay.esm.js.map +1 -0
- package/dist/sandbox-build.cjs.js +140 -0
- package/dist/sandbox-build.cjs.js.map +1 -0
- package/dist/sandbox-build.esm.js +137 -0
- package/dist/sandbox-build.esm.js.map +1 -0
- package/dist/sandbox-kernel.esm.js +212 -0
- package/dist/sandbox-kernel.esm.js.map +1 -0
- package/dist/sandbox-worker.cjs.js +857 -0
- package/dist/sandbox-worker.cjs.js.map +1 -0
- package/dist/sandbox-worker.esm.js +854 -0
- package/dist/sandbox-worker.esm.js.map +1 -0
- package/dist/sandbox.cjs.js +1425 -0
- package/dist/sandbox.cjs.js.map +1 -0
- package/dist/sandbox.esm.js +1406 -0
- package/dist/sandbox.esm.js.map +1 -0
- package/dist/sygnal.min.js +1 -1
- package/dist/sygnal.min.js.map +1 -1
- package/dist/terminal.cjs.js +1314 -0
- package/dist/terminal.cjs.js.map +1 -0
- package/dist/terminal.esm.js +1304 -0
- package/dist/terminal.esm.js.map +1 -0
- package/dist/three.cjs.js +1111 -0
- package/dist/three.cjs.js.map +1 -0
- package/dist/three.esm.js +1079 -0
- package/dist/three.esm.js.map +1 -0
- package/dist/ui-combobox.cjs.js +256 -18
- package/dist/ui-combobox.cjs.js.map +1 -1
- package/dist/ui-combobox.esm.js +256 -18
- package/dist/ui-combobox.esm.js.map +1 -1
- package/dist/ui-menu.cjs.js +150 -16
- package/dist/ui-menu.cjs.js.map +1 -1
- package/dist/ui-menu.esm.js +151 -17
- package/dist/ui-menu.esm.js.map +1 -1
- package/dist/ui-select.cjs.js +95 -9
- package/dist/ui-select.cjs.js.map +1 -1
- package/dist/ui-select.esm.js +95 -9
- package/dist/ui-select.esm.js.map +1 -1
- package/dist/ui.cjs.js +679 -173
- package/dist/ui.cjs.js.map +1 -1
- package/dist/ui.esm.js +679 -175
- package/dist/ui.esm.js.map +1 -1
- package/dist/vike/config/package.json +1 -1
- package/dist/vite/plugin.cjs.js +968 -4
- package/dist/vite/plugin.cjs.js.map +1 -1
- package/dist/vite/plugin.mjs +968 -4
- package/dist/vite/plugin.mjs.map +1 -1
- package/dist/worker-page.cjs.js +669 -0
- package/dist/worker-page.cjs.js.map +1 -0
- package/dist/worker-page.esm.js +665 -0
- package/dist/worker-page.esm.js.map +1 -0
- package/dist/worker.cjs.js +377 -0
- package/dist/worker.cjs.js.map +1 -0
- package/dist/worker.esm.js +374 -0
- package/dist/worker.esm.js.map +1 -0
- package/dist/yjs-testing.cjs.js +98 -0
- package/dist/yjs-testing.cjs.js.map +1 -0
- package/dist/yjs-testing.esm.js +77 -0
- package/dist/yjs-testing.esm.js.map +1 -0
- package/dist/yjs.cjs.js +923 -0
- package/dist/yjs.cjs.js.map +1 -0
- package/dist/yjs.esm.js +900 -0
- package/dist/yjs.esm.js.map +1 -0
- package/dist/zag.cjs.js +11 -1
- package/dist/zag.cjs.js.map +1 -1
- package/dist/zag.esm.js +11 -1
- package/dist/zag.esm.js.map +1 -1
- package/llms/ai.md +65 -0
- package/llms/collaboration.md +5 -0
- package/llms/graphics.md +10 -0
- package/llms/renderers.md +7 -0
- package/llms/replay.md +5 -0
- package/llms/sandbox.md +5 -0
- package/llms/typed-apis.md +5 -0
- package/llms/ui.md +10 -0
- package/llms-full.txt +444 -0
- package/llms.txt +37 -35
- package/package.json +139 -3
- package/src/agent-ui/mcp.ts +152 -0
- package/src/agent-ui/snapshot.ts +212 -0
- package/src/agent-ui.d.ts +106 -0
- package/src/agent-ui.ts +249 -0
- package/src/ai.d.ts +95 -2
- package/src/api.d.ts +303 -0
- package/src/api.ts +9 -0
- package/src/canvas/Canvas.ts +585 -0
- package/src/canvas/backend.ts +627 -0
- package/src/canvas/geometry.ts +187 -0
- package/src/canvas/gesture.ts +23 -0
- package/src/canvas/image.ts +197 -0
- package/src/canvas/kit.ts +130 -0
- package/src/canvas/paint.ts +260 -0
- package/src/canvas/pointer.ts +25 -0
- package/src/canvas/snap.ts +68 -0
- package/src/canvas/svg.ts +99 -0
- package/src/canvas.d.ts +373 -0
- package/src/canvas.ts +46 -0
- package/src/core/actions.ts +14 -3
- package/src/core/cell.ts +12 -4
- package/src/core/debug.ts +8 -3
- package/src/core/hooks.ts +16 -2
- package/src/core/hosts/collection.ts +1 -1
- package/src/core/hosts/switchable.ts +26 -8
- package/src/core/instance.ts +98 -45
- package/src/core/markers/portal.ts +4 -0
- package/src/core/registry.ts +4 -0
- package/src/core/runtime.ts +34 -25
- package/src/core/statics.ts +5 -5
- package/src/cycle/dom/EventDelegator.ts +37 -33
- package/src/cycle/dom/MainDOMSource.ts +16 -14
- package/src/cycle/dom/enrichEventStream.ts +13 -9
- package/src/cycle/dom/fromEvent.ts +6 -10
- package/src/cycle/dom/index.ts +11 -7
- package/src/cycle/dom/isolate.ts +13 -6
- package/src/cycle/dom/makeDOMDriver.ts +6 -2
- package/src/cycle/dom/utils.ts +9 -2
- package/src/cycle/run/adapt.ts +4 -12
- package/src/devtools.d.ts +9 -0
- package/src/devtools.ts +2 -1
- package/src/extra/ai/compose/catalog.ts +2 -1
- package/src/extra/ai/compose/decisions.ts +1 -2
- package/src/extra/ai/compose/generated.ts +234 -0
- package/src/extra/ai/compose/index.ts +6 -2
- package/src/extra/ai/compose/layout.ts +3 -1
- package/src/extra/ai/compose/llm.ts +7 -3
- package/src/extra/ai/compose/types.ts +2 -2
- package/src/extra/ai/transports/shared.ts +3 -1
- package/src/extra/api/contract.ts +485 -0
- package/src/extra/api/index.ts +26 -0
- package/src/extra/behaviors.ts +3 -3
- package/src/extra/controlled.ts +44 -0
- package/src/extra/copyAsTest.ts +22 -0
- package/src/extra/devtools.ts +5 -3
- package/src/extra/devtoolsActions.ts +8 -0
- package/src/extra/devtoolsNext.ts +1 -1
- package/src/extra/diagnostics/checks/actionLog.ts +8 -3
- package/src/extra/diagnostics/checks/behaviors.ts +25 -0
- package/src/extra/diagnostics/checks/elementCommands.ts +17 -5
- package/src/extra/diagnostics/checks/index.ts +1 -1
- package/src/extra/diagnostics/checks/next.ts +78 -4
- package/src/extra/diagnostics/checks/props.ts +6 -1
- package/src/extra/diagnostics/checks/replies.ts +11 -7
- package/src/extra/diagnostics/checks/timers.ts +8 -2
- package/src/extra/diagnostics/checks/virtual.ts +11 -0
- package/src/extra/diagnostics/codes.ts +51 -1
- package/src/extra/elementCommands.ts +20 -4
- package/src/extra/fetchDriver.ts +4 -1
- package/src/extra/fetchEventSource.ts +6 -2
- package/src/extra/field.ts +29 -0
- package/src/extra/form.ts +42 -16
- package/src/extra/frame.ts +54 -0
- package/src/extra/keymap.ts +41 -0
- package/src/extra/pager.ts +2 -0
- package/src/extra/persist.ts +2 -1
- package/src/extra/pointer.ts +262 -0
- package/src/extra/processForm.ts +34 -1
- package/src/extra/replay/address.ts +49 -0
- package/src/extra/replay/entropy.ts +99 -0
- package/src/extra/replay/format.ts +263 -0
- package/src/extra/replay/index.ts +8 -0
- package/src/extra/replay/inert.ts +22 -0
- package/src/extra/replay/recorder.ts +247 -0
- package/src/extra/replay/replayer.ts +234 -0
- package/src/extra/replay/report.ts +126 -0
- package/src/extra/replay/schema.ts +52 -0
- package/src/extra/replay/version.ts +3 -0
- package/src/extra/router.ts +7 -3
- package/src/extra/selection.ts +2 -0
- package/src/extra/socketDriver.ts +51 -6
- package/src/extra/ssr.ts +128 -42
- package/src/extra/testing.ts +295 -39
- package/src/extra/timers.ts +96 -7
- package/src/extra/undo.ts +2 -0
- package/src/extra/virtual.ts +25 -2
- package/src/extra/widget.ts +106 -17
- package/src/host/actions.ts +383 -0
- package/src/host/delegation.ts +101 -0
- package/src/host/dom.ts +553 -0
- package/src/host/driver.ts +185 -0
- package/src/host/selector.ts +119 -0
- package/src/host/style.ts +51 -0
- package/src/host.d.ts +298 -0
- package/src/host.ts +46 -0
- package/src/index.d.ts +302 -38
- package/src/index.ts +15 -3
- package/src/pragma/blocks.ts +211 -0
- package/src/pragma/index.ts +44 -10
- package/src/primitives.d.ts +54 -0
- package/src/primitives.ts +136 -0
- package/src/react-native.d.ts +57 -0
- package/src/react-native.ts +285 -0
- package/src/react-peers.d.ts +21 -3
- package/src/replay.d.ts +185 -0
- package/src/replay.ts +6 -0
- package/src/sandbox/build.ts +119 -0
- package/src/sandbox/create.ts +187 -0
- package/src/sandbox/engine.ts +267 -0
- package/src/sandbox/generated.ts +195 -0
- package/src/sandbox/kernel.ts +180 -0
- package/src/sandbox/mirror.ts +269 -0
- package/src/sandbox/protocol.ts +128 -0
- package/src/sandbox/quickjs.ts +74 -0
- package/src/sandbox/ssr.ts +41 -0
- package/src/sandbox/widget.ts +60 -0
- package/src/sandbox/worker-entry.ts +59 -0
- package/src/sandbox/worker.ts +137 -0
- package/src/sandbox-build.d.ts +12 -0
- package/src/sandbox-build.ts +6 -0
- package/src/sandbox.d.ts +299 -0
- package/src/sandbox.ts +25 -0
- package/src/shared.ts +12 -0
- package/src/terminal/paint.ts +712 -0
- package/src/terminal.d.ts +167 -0
- package/src/terminal.ts +530 -0
- package/src/three/assets.ts +170 -0
- package/src/three/host.ts +36 -0
- package/src/three/scene.ts +217 -0
- package/src/three/target.ts +252 -0
- package/src/three.d.ts +221 -0
- package/src/three.ts +30 -0
- package/src/ui/accordion.ts +21 -7
- package/src/ui/dialog.ts +192 -90
- package/src/ui/disclosure.ts +2 -0
- package/src/ui/dom.ts +30 -0
- package/src/ui/layers.ts +132 -0
- package/src/ui/popover.ts +120 -21
- package/src/ui/shared.ts +98 -12
- package/src/ui/stack.ts +18 -0
- package/src/ui/tabs.ts +2 -0
- package/src/ui/toaster.ts +16 -15
- package/src/ui/tooltip.ts +24 -8
- package/src/ui/tooltips.ts +26 -14
- package/src/ui/zag/combobox.ts +180 -13
- package/src/ui/zag/menu.ts +97 -17
- package/src/ui/zag/select.ts +15 -4
- package/src/ui/zag/shared.ts +60 -8
- package/src/ui-combobox.d.ts +16 -1
- package/src/ui-menu.d.ts +22 -7
- package/src/ui-zag-types.d.ts +13 -5
- package/src/ui.d.ts +62 -7
- package/src/ui.ts +2 -2
- package/src/vite/api.ts +186 -0
- package/src/vite/compile.ts +280 -0
- package/src/vite/plugin.d.ts +34 -0
- package/src/vite/plugin.ts +78 -4
- package/src/vite/sandbox.ts +16 -0
- package/src/worker/page.ts +396 -0
- package/src/worker/protocol.ts +48 -0
- package/src/worker/target.ts +282 -0
- package/src/worker-page.d.ts +42 -0
- package/src/worker-page.ts +12 -0
- package/src/worker.d.ts +65 -0
- package/src/worker.ts +16 -0
- package/src/yjs/driver.ts +253 -0
- package/src/yjs/mapping.ts +389 -0
- package/src/yjs/shared.ts +138 -0
- package/src/yjs/testing.ts +91 -0
- package/src/yjs-testing.d.ts +34 -0
- package/src/yjs-testing.ts +7 -0
- package/src/yjs.d.ts +109 -0
- package/src/yjs.ts +18 -0
- package/src/zag.d.ts +2 -0
- package/src/zag.ts +8 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-native.cjs.js","sources":["../src/react-native.ts"],"sourcesContent":["/*\n * 'sygnal/react-native': a Sygnal app on React Native. The app renders into a sygnal/host tree\n * (the kit the terminal and agent UI targets use); this bridge renders that tree as React Native\n * components, and turns native callbacks into the DOM events intents already listen for (D-AR-3):\n * onPress → click, onChangeText → input, onValueChange → click + input + change, onScroll → scroll.\n *\n * import { SygnalView } from 'sygnal/react-native'\n * export default () => <SygnalView app={App} styles={[['.done', { opacity: 0.5 }]]} />\n *\n * - Incremental: each host element is a memoized React component keyed by its host node and\n * revision (the host's change tracking: a mutation moves the revision of the node and its\n * ancestors), so a change re-renders the changed path only (`incremental: false`: every element,\n * for comparison; `onNodeRender` counts).\n * - What maps to what: the 'sygnal/primitives' (by their data-primitive marker), the common HTML\n * tags (a web view runs as is: div → View, span/p/h1 → Text, button → Pressable, input →\n * TextInput or Switch, img → Image, select → a Pressable that steps through the options), and a\n * target's own field tags (registerFieldTags: text → TextInput, checkbox → Switch). `components`\n * replaces any of them.\n * - Controlled fields: a field's value is read from the host element when React renders it, never\n * captured earlier, so React Native's own TextInput protocol (the native event count) keeps\n * typing ahead of a render that hasn't seen it yet; the app's value wins whenever it differs.\n * - Styles: the `styles` rules ([selector, style], after defaultNativeStyles) compile to a\n * StyleSheet; an element's style is its matching rules, then its inline style (`px` strings\n * from the primitives' web form read back as numbers). Text keys (color, fontSize, …) of a\n * View-like element style the Text that wraps its direct text (React Native has no inheritance\n * from a View).\n * - Lists: a `List` primitive renders as a FlatList over its children (native views windowed; the\n * Sygnal items stay mounted). VirtualCollection measures the DOM and is web-only.\n *\n * Separate entry: './index' and './host' become the external 'sygnal' and 'sygnal/host'; react\n * and react-native are optional peer dependencies (D209).\n */\nimport {createElement as h, memo, useState, useReducer, useEffect} from 'react'\nimport {View, Text, Pressable, TextInput, Switch, Image, ScrollView, FlatList, StyleSheet} from 'react-native'\nimport {run} from './index'\nimport {HostDocument, makeHostDriver, nodeId, matches, activate, pressKey, chooseOption, optionValue, isTextField, isCheckable, HostEvent} from './host'\nimport type {HostElement, HostNode} from './host'\n\nexport type NativeStyle = Record<string, any>\nexport type NativeStyleRule = [selector: string, style: NativeStyle]\n\n/** HTML defaults for native (a web view's headings, links, buttons and fields look like themselves) */\nexport const defaultNativeStyles: NativeStyleRule[] = [\n ['h1', {fontSize: 32, fontWeight: '700', marginVertical: 8}],\n ['h2', {fontSize: 24, fontWeight: '700', marginVertical: 6}],\n ['h3', {fontSize: 20, fontWeight: '600', marginVertical: 4}],\n ['h4, h5, h6', {fontSize: 17, fontWeight: '600'}],\n ['strong, b, th', {fontWeight: '700'}],\n ['em, i', {fontStyle: 'italic'}],\n ['a', {color: '#2f6fed', textDecorationLine: 'underline'}],\n // HTML elements only: a primitive (data-primitive) is styled by the app, as in React Native\n ['button:not([data-primitive])', {paddingHorizontal: 14, paddingVertical: 8, borderRadius: 8, backgroundColor: '#2f6fed', color: '#ffffff', fontWeight: '600', fontSize: 17, alignItems: 'center', justifyContent: 'center'}],\n ['button[disabled]', {opacity: 0.5}],\n ['input:not([data-primitive]):not([type=\"checkbox\"]):not([type=\"radio\"]), textarea:not([data-primitive])', {borderWidth: 1, borderColor: '#bbbbbb', borderRadius: 8, paddingHorizontal: 10, paddingVertical: 8, fontSize: 17, minWidth: 160}],\n ['p, li', {fontSize: 17}],\n ['hr', {height: 1, backgroundColor: '#cccccc', marginVertical: 8}],\n]\n\n/** the text keys React Native applies to Text only */\nconst TEXT_KEYS = /^(color|font\\w*|textAlign|textDecoration\\w*|textTransform|letterSpacing|lineHeight|includeFontPadding|textShadow\\w*|writingDirection|userSelect)$/\nconst PX = /^(-?\\d*\\.?\\d+)px$/\n/** a style value as React Native takes it: `12px` → 12 (the primitives' web form) */\nconst nativeValue = (v: any) => (typeof v == 'string' && PX.test(v) ? parseFloat(v) : v)\n// web-only style the primitives add for the browser (a plain button look, line clamping): not React Native's\nconst WEB_ONLY = /^(background|font|cursor|boxSizing|outline\\w*|transition\\w*|Webkit\\w*|whiteSpace|textOverflow|overflow)$/\nconst ownStyle = (el: HostElement) => {\n let out: NativeStyle | undefined\n for (const k in el.style) {\n const v = el.style[k]\n if (v == null || v === '' || v === 'inherit' || WEB_ONLY.test(k) || (k == 'display' && v != 'none' && v != 'flex')) continue\n ;(out ||= {})[k] = nativeValue(v)\n }\n return out\n}\n\n/** a component of the table: the element, its children as React nodes, its style (view part, text part) */\nexport type NativeComponent = (el: HostElement, children: any[], style: {view: NativeStyle, text: NativeStyle, all: NativeStyle}, ctx: NativeContext) => any\nexport interface NativeContext {\n /** fire a DOM-shaped event on a host element */\n fire(el: HostElement, type: string, init?: Record<string, any>): boolean\n /** a click and its default action (sygnal/host activate) */\n press(el: HostElement): void\n /** render a host child (a memoized element) */\n child(node: HostNode): any\n}\n\nexport interface NativeHostOptions {\n /** the app's native stylesheet (after defaultNativeStyles) */\n styles?: readonly NativeStyleRule[]\n /** false: no defaultNativeStyles */\n defaultStyles?: boolean\n /** replace or add components, by primitive name ('View', 'List', …) or tag ('button', 'my-chart') */\n components?: Record<string, NativeComponent>\n /** a link's default action (an <a href> pressed): a router driver's go */\n onNavigate?: (href: string, el: HostElement) => void\n /** false: re-render every element on every change (for measuring) */\n incremental?: boolean\n /** called each time an element's React component renders (measuring, tests) */\n onNodeRender?: (el: HostElement) => void\n /** the root View's style (default { flex: 1 }) */\n style?: NativeStyle\n}\n\nconst TEXTUAL = /^(span|p|label|strong|b|em|i|small|code|h[1-6]|a|li|th|td|dt|dd|figcaption|summary|legend|caption)$/\nconst INLINE = /^(span|strong|b|em|i|small|code|a|label|img|button|input|select|textarea|br)$/\nconst fireOn = (el: HostElement, type: string, init?: Record<string, any>) => el.dispatchEvent(new HostEvent(type, init))\nconst prim = (el: HostElement) => el.dataset.primitive as string | undefined\n\nfunction split(all: NativeStyle) {\n const view: NativeStyle = {}, text: NativeStyle = {}\n for (const k in all) (TEXT_KEYS.test(k) ? text : view)[k] = all[k]\n return {view, text, all}\n}\nconst has = (o: object) => { for (const _ in o) return true; return false }\n\n/** the built-in table */\nfunction defaultComponents(): Record<string, NativeComponent> {\n // direct strings become Text with the element's text style; element children render as they are\n const kids = (children: any[], text: NativeStyle) => children.map((c, i) => typeof c == 'string' ? h(Text, {key: 't' + i, style: has(text) ? text : undefined}, c) : c)\n // an HTML container of inline content (a <li> with a checkbox, a label and a button) flows in a row,\n // as the browser lays it out; a View primitive is a column unless its style says otherwise\n const view: NativeComponent = (el, c, s) => {\n const row = !prim(el) && s.view.flexDirection == null && el.children.length > 0 && el.childNodes.every(n => n.nodeType === 3 || INLINE.test((n as HostElement).localName) && !prim(n as HostElement) || prim(n as HostElement) == 'Text' || prim(n as HostElement) == 'Pressable' || prim(n as HostElement) == 'Switch')\n return h(View, {style: row ? [{flexDirection: 'row', flexWrap: 'wrap', alignItems: 'center', gap: 8}, s.view] : s.view}, ...kids(c, s.text))\n }\n const text: NativeComponent = (el, c, s, ctx) => h(Text, {style: s.all, onPress: listensClick(el) ? () => ctx.press(el) : undefined, accessibilityRole: el.localName == 'a' ? 'link' : /^h\\d$/.test(el.localName) ? 'header' : undefined}, ...c)\n const pressable: NativeComponent = (el, c, s, ctx) => h(Pressable, {\n onPress: () => ctx.press(el), disabled: el.disabled, accessibilityRole: 'button', accessibilityLabel: el.getAttribute('aria-label') || undefined,\n accessibilityState: {disabled: el.disabled},\n style: ({pressed}: {pressed: boolean}) => (pressed ? [s.view, {opacity: 0.6}] : s.view),\n }, ...kids(c, s.text))\n const textInput: NativeComponent = (el, _c, s, ctx) => h(TextInput, {\n // read now, at render: never a value captured before the latest native change was applied\n value: el.value,\n placeholder: el.getAttribute('placeholder') || undefined,\n secureTextEntry: el.type == 'password',\n multiline: el.localName == 'textarea',\n editable: !el.readOnly && !el.disabled,\n keyboardType: el.type == 'email' ? 'email-address' : el.getAttribute('inputmode') == 'numeric' || (el as any).inputMode == 'numeric' ? 'numeric' : undefined,\n accessibilityLabel: el.getAttribute('aria-label') || undefined,\n onChangeText: (v: string) => { el.value = v; ctx.fire(el, 'input', {inputType: 'insertText', data: v}) },\n onSubmitEditing: () => pressKey(el, 'Enter'),\n onFocus: () => el.focus(),\n onBlur: () => { if (el.ownerDocument.activeElement === el) { el.blur(); ctx.fire(el, 'change') } },\n style: s.all,\n })\n const switchC: NativeComponent = (el, _c, s, ctx) => h(Switch, {\n value: el.checked, disabled: el.disabled, accessibilityLabel: el.getAttribute('aria-label') || undefined,\n // a checkbox's click: it toggles, then input + change (undone when an intent prevents it)\n onValueChange: () => ctx.press(el),\n style: s.view,\n })\n const image: NativeComponent = (el, _c, s) => h(Image, {source: {uri: el.getAttribute('src') || (el as any).src}, accessibilityLabel: el.getAttribute('alt') || undefined, style: s.view, resizeMode: s.all.objectFit == 'contain' ? 'contain' : s.all.objectFit == 'fill' ? 'stretch' : 'cover'})\n const LAYOUT = /^(flexDirection|flexWrap|alignItems|justifyContent|alignContent|gap|rowGap|columnGap|padding\\w*)$/\n const scroll = (el: HostElement, s: {view: NativeStyle}) => {\n const outer: NativeStyle = {}, inner: NativeStyle = {}\n for (const k in s.view) (LAYOUT.test(k) ? inner : outer)[k] = s.view[k]\n delete outer.overflow\n delete outer.display\n return {outer, inner, horizontal: inner.flexDirection == 'row', onScroll: (e: any) => {\n const {contentOffset: o = {}, contentSize: z = {}, layoutMeasurement: m = {}} = e?.nativeEvent || {}\n fireOn(el, 'scroll', {bubbles: false, detail: {x: o.x || 0, y: o.y || 0, end: (o.y || 0) + (m.height || 0) >= (z.height || 0) - 1}})\n }}\n }\n const scrollView: NativeComponent = (el, c, s) => {\n const {outer, inner, horizontal, onScroll} = scroll(el, s)\n return h(ScrollView, {style: outer, contentContainerStyle: inner, horizontal, onScroll, scrollEventThrottle: 50}, ...kids(c, s.text))\n }\n const list: NativeComponent = (el, _c, s, ctx) => {\n const {outer, inner, horizontal, onScroll} = scroll(el, s)\n return h(FlatList, {\n // each item is the memoized element of a host child; FlatList windows the native views\n data: el.children, keyExtractor: (n: HostElement) => String(nodeId(n)), renderItem: ({item}: {item: HostElement}) => ctx.child(item),\n extraData: el.revision, horizontal, style: outer, contentContainerStyle: inner, onScroll, scrollEventThrottle: 50,\n })\n }\n const select: NativeComponent = (el, _c, s, ctx) => {\n // no picker in React Native's core: a button that steps to the next option (input + change)\n const opts = el.options, i = Math.max(0, opts.findIndex(o => optionValue(o) == el.value))\n return h(Pressable, {accessibilityRole: 'button', accessibilityLabel: el.getAttribute('aria-label') || undefined, style: s.view,\n onPress: () => { const next = opts[(i + 1) % opts.length]; if (next) chooseOption(el, optionValue(next)) }},\n h(Text, {style: s.text}, (opts[i]?.textContent || '').trim() + ' ▾'))\n void ctx\n }\n return {\n View: view, Text: text, Pressable: pressable, TextInput: textInput, Switch: switchC, Image: image, ScrollView: scrollView, List: list,\n button: pressable, img: image, select,\n hr: (_el, _c, s) => h(View, {style: s.view}),\n br: () => h(Text, null, '\\n'),\n }\n}\nconst listensClick = (el: HostElement) => el.ownerDocument.listenedTypes(el).some(t => t == 'click')\n\n/** the component for a host element: its primitive, its tag, its field kind, else View or Text */\nfunction pick(el: HostElement, table: Record<string, NativeComponent>): NativeComponent {\n const p = prim(el)\n if (p && table[p]) return table[p]\n if (table[el.localName]) return table[el.localName]\n if (isCheckable(el)) return table.Switch\n if (isTextField(el)) return table.TextInput\n // a textual tag holding only text and inline text elements is Text; holding a field or a button,\n // it is a row of Views (a <label> around a checkbox)\n if (TEXTUAL.test(el.localName) && el.children.every(c => TEXTUAL.test(c.localName) && !prim(c) || c.localName == 'br')) return table.Text\n return table.View\n}\n\nexport interface NativeHost {\n readonly doc: HostDocument\n /** the DOM driver: run(App, { DOM: host.driver }) */\n readonly driver: ReturnType<typeof makeHostDriver>\n /** the React component that shows the host tree */\n Root: () => any\n /** stop rendering (before the app's dispose empties the tree) */\n stop(): void\n}\n\n/** a host document, its driver, and the React component that renders it */\nexport function createNativeHost(options: NativeHostOptions = {}): NativeHost {\n const doc = new HostDocument()\n const table = {...defaultComponents(), ...options.components}\n const rules = [...(options.defaultStyles === false ? [] : defaultNativeStyles), ...(options.styles || [])]\n // each rule's style compiled once (StyleSheet validates it in development)\n const sheet: any = StyleSheet.create(Object.fromEntries(rules.map(([, st], i) => [i, Object.fromEntries(Object.entries(st).map(([k, v]) => [k, nativeValue(v)]))])))\n // a descendant / child selector (not a list's comma): an ancestor's class change can restyle below it\n const combinators = rules.some(([sel]) => sel.split(',').some(part => /[\\s>]/.test(part.trim())))\n const incremental = options.incremental !== false\n const listeners = new Set<() => void>()\n let live = true\n doc.onChange = () => { if (live) for (const l of [...listeners]) l() }\n\n const ctx: NativeContext = {\n fire: fireOn,\n press: (el) => { activate(el, {onNavigate: options.onNavigate}) },\n child: (n) => (n.nodeType === 3 ? (n as any).data : h(Node, {key: nodeId(n), node: n, rev: n.revision, inh: 0})),\n }\n const styleOf = (el: HostElement) => {\n const parts: any[] = []\n for (let i = 0; i < rules.length; i++) if (matches(el, rules[i][0])) parts.push(sheet[i])\n const own = ownStyle(el)\n if (own) parts.push(own)\n const all: NativeStyle = parts.length ? {...StyleSheet.flatten(parts)} : {}\n if (el.hidden) all.display = 'none'\n delete all.overflow\n return split(all)\n }\n const render = (el: HostElement, inh: number): any => {\n options.onNodeRender?.(el)\n const c = pick(el, table)\n const childInh = combinators ? (inh * 31 + el.attrRevision + 1) | 0 : 0\n const children = el.childNodes.map((n) => n.nodeType === 3 ? (n as any).data\n : h(Node, {key: nodeId(n), node: n, rev: n.revision, inh: childInh}))\n // (inside Text, element children render as nested Text: an inline run)\n return c(el, children, styleOf(el), ctx)\n }\n const same = (a: any, b: any) => a.node === b.node && a.rev === b.rev && a.inh === b.inh\n const Node: any = incremental ? memo(({node, inh}: any) => render(node, inh), same) : ({node, inh}: any) => render(node, inh)\n\n function Root() {\n const [, force] = useReducer((x: number) => x + 1, 0)\n useEffect(() => { listeners.add(force); return () => { listeners.delete(force) } }, [])\n const body = doc.body\n return h(View, {style: options.style || {flex: 1}}, ...body.childNodes.map((n) =>\n n.nodeType === 3 ? h(Text, {key: nodeId(n)}, (n as any).data) : h(Node, {key: nodeId(n), node: n, rev: n.revision, inh: 0})))\n }\n return {doc, driver: makeHostDriver(doc), Root, stop: () => { live = false }}\n}\n\nexport interface SygnalViewProps extends NativeHostOptions {\n /** the root component */\n app: any\n /** the app's other drivers (DOM is the bridge's) */\n drivers?: Record<string, any>\n /** run() options (onError, …) */\n runOptions?: Record<string, any>\n}\n\n/** a Sygnal app as a React Native component: runs it on mount, disposes it on unmount */\nexport function SygnalView(props: SygnalViewProps): any {\n const [host] = useState(() => createNativeHost(props))\n useEffect(() => {\n const app = run(props.app, {...props.drivers, DOM: host.driver}, props.runOptions)\n return () => { host.stop(); app.dispose() }\n }, [])\n return h(host.Root)\n}\n"],"names":["HostEvent","h","Text","View","Pressable","TextInput","pressKey","Switch","Image","ScrollView","FlatList","nodeId","optionValue","chooseOption","isCheckable","isTextField","HostDocument","StyleSheet","activate","matches","memo","useReducer","useEffect","makeHostDriver","useState","run"],"mappings":";;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BG;AAUH;AACa,MAAA,mBAAmB,GAAsB;AACpD,IAAA,CAAC,IAAI,EAAE,EAAC,QAAQ,EAAE,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC,EAAC,CAAC;AAC5D,IAAA,CAAC,IAAI,EAAE,EAAC,QAAQ,EAAE,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC,EAAC,CAAC;AAC5D,IAAA,CAAC,IAAI,EAAE,EAAC,QAAQ,EAAE,EAAE,EAAE,UAAU,EAAE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ressable, TextInput, Switch, Image, ScrollView, FlatList } from 'react-native';
|
|
3
|
+
import { run } from 'sygnal';
|
|
4
|
+
import { HostDocument, makeHostDriver, nodeId, pressKey, optionValue, chooseOption, isCheckable, isTextField, activate, matches, HostEvent } from 'sygnal/host';
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
* 'sygnal/react-native': a Sygnal app on React Native. The app renders into a sygnal/host tree
|
|
8
|
+
* (the kit the terminal and agent UI targets use); this bridge renders that tree as React Native
|
|
9
|
+
* components, and turns native callbacks into the DOM events intents already listen for (D-AR-3):
|
|
10
|
+
* onPress → click, onChangeText → input, onValueChange → click + input + change, onScroll → scroll.
|
|
11
|
+
*
|
|
12
|
+
* import { SygnalView } from 'sygnal/react-native'
|
|
13
|
+
* export default () => <SygnalView app={App} styles={[['.done', { opacity: 0.5 }]]} />
|
|
14
|
+
*
|
|
15
|
+
* - Incremental: each host element is a memoized React component keyed by its host node and
|
|
16
|
+
* revision (the host's change tracking: a mutation moves the revision of the node and its
|
|
17
|
+
* ancestors), so a change re-renders the changed path only (`incremental: false`: every element,
|
|
18
|
+
* for comparison; `onNodeRender` counts).
|
|
19
|
+
* - What maps to what: the 'sygnal/primitives' (by their data-primitive marker), the common HTML
|
|
20
|
+
* tags (a web view runs as is: div → View, span/p/h1 → Text, button → Pressable, input →
|
|
21
|
+
* TextInput or Switch, img → Image, select → a Pressable that steps through the options), and a
|
|
22
|
+
* target's own field tags (registerFieldTags: text → TextInput, checkbox → Switch). `components`
|
|
23
|
+
* replaces any of them.
|
|
24
|
+
* - Controlled fields: a field's value is read from the host element when React renders it, never
|
|
25
|
+
* captured earlier, so React Native's own TextInput protocol (the native event count) keeps
|
|
26
|
+
* typing ahead of a render that hasn't seen it yet; the app's value wins whenever it differs.
|
|
27
|
+
* - Styles: the `styles` rules ([selector, style], after defaultNativeStyles) compile to a
|
|
28
|
+
* StyleSheet; an element's style is its matching rules, then its inline style (`px` strings
|
|
29
|
+
* from the primitives' web form read back as numbers). Text keys (color, fontSize, …) of a
|
|
30
|
+
* View-like element style the Text that wraps its direct text (React Native has no inheritance
|
|
31
|
+
* from a View).
|
|
32
|
+
* - Lists: a `List` primitive renders as a FlatList over its children (native views windowed; the
|
|
33
|
+
* Sygnal items stay mounted). VirtualCollection measures the DOM and is web-only.
|
|
34
|
+
*
|
|
35
|
+
* Separate entry: './index' and './host' become the external 'sygnal' and 'sygnal/host'; react
|
|
36
|
+
* and react-native are optional peer dependencies (D209).
|
|
37
|
+
*/
|
|
38
|
+
/** HTML defaults for native (a web view's headings, links, buttons and fields look like themselves) */
|
|
39
|
+
const defaultNativeStyles = [
|
|
40
|
+
['h1', { fontSize: 32, fontWeight: '700', marginVertical: 8 }],
|
|
41
|
+
['h2', { fontSize: 24, fontWeight: '700', marginVertical: 6 }],
|
|
42
|
+
['h3', { fontSize: 20, fontWeight: '600', marginVertical: 4 }],
|
|
43
|
+
['h4, h5, h6', { fontSize: 17, fontWeight: '600' }],
|
|
44
|
+
['strong, b, th', { fontWeight: '700' }],
|
|
45
|
+
['em, i', { fontStyle: 'italic' }],
|
|
46
|
+
['a', { color: '#2f6fed', textDecorationLine: 'underline' }],
|
|
47
|
+
// HTML elements only: a primitive (data-primitive) is styled by the app, as in React Native
|
|
48
|
+
['button:not([data-primitive])', { paddingHorizontal: 14, paddingVertical: 8, borderRadius: 8, backgroundColor: '#2f6fed', color: '#ffffff', fontWeight: '600', fontSize: 17, alignItems: 'center', justifyContent: 'center' }],
|
|
49
|
+
['button[disabled]', { opacity: 0.5 }],
|
|
50
|
+
['input:not([data-primitive]):not([type="checkbox"]):not([type="radio"]), textarea:not([data-primitive])', { borderWidth: 1, borderColor: '#bbbbbb', borderRadius: 8, paddingHorizontal: 10, paddingVertical: 8, fontSize: 17, minWidth: 160 }],
|
|
51
|
+
['p, li', { fontSize: 17 }],
|
|
52
|
+
['hr', { height: 1, backgroundColor: '#cccccc', marginVertical: 8 }],
|
|
53
|
+
];
|
|
54
|
+
/** the text keys React Native applies to Text only */
|
|
55
|
+
const TEXT_KEYS = /^(color|font\w*|textAlign|textDecoration\w*|textTransform|letterSpacing|lineHeight|includeFontPadding|textShadow\w*|writingDirection|userSelect)$/;
|
|
56
|
+
const PX = /^(-?\d*\.?\d+)px$/;
|
|
57
|
+
/** a style value as React Native takes it: `12px` → 12 (the primitives' web form) */
|
|
58
|
+
const nativeValue = (v) => (typeof v == 'string' && PX.test(v) ? parseFloat(v) : v);
|
|
59
|
+
// web-only style the primitives add for the browser (a plain button look, line clamping): not React Native's
|
|
60
|
+
const WEB_ONLY = /^(background|font|cursor|boxSizing|outline\w*|transition\w*|Webkit\w*|whiteSpace|textOverflow|overflow)$/;
|
|
61
|
+
const ownStyle = (el) => {
|
|
62
|
+
let out;
|
|
63
|
+
for (const k in el.style) {
|
|
64
|
+
const v = el.style[k];
|
|
65
|
+
if (v == null || v === '' || v === 'inherit' || WEB_ONLY.test(k) || (k == 'display' && v != 'none' && v != 'flex'))
|
|
66
|
+
continue;
|
|
67
|
+
(out || (out = {}))[k] = nativeValue(v);
|
|
68
|
+
}
|
|
69
|
+
return out;
|
|
70
|
+
};
|
|
71
|
+
const TEXTUAL = /^(span|p|label|strong|b|em|i|small|code|h[1-6]|a|li|th|td|dt|dd|figcaption|summary|legend|caption)$/;
|
|
72
|
+
const INLINE = /^(span|strong|b|em|i|small|code|a|label|img|button|input|select|textarea|br)$/;
|
|
73
|
+
const fireOn = (el, type, init) => el.dispatchEvent(new HostEvent(type, init));
|
|
74
|
+
const prim = (el) => el.dataset.primitive;
|
|
75
|
+
function split(all) {
|
|
76
|
+
const view = {}, text = {};
|
|
77
|
+
for (const k in all)
|
|
78
|
+
(TEXT_KEYS.test(k) ? text : view)[k] = all[k];
|
|
79
|
+
return { view, text, all };
|
|
80
|
+
}
|
|
81
|
+
const has = (o) => { for (const _ in o)
|
|
82
|
+
return true; return false; };
|
|
83
|
+
/** the built-in table */
|
|
84
|
+
function defaultComponents() {
|
|
85
|
+
// direct strings become Text with the element's text style; element children render as they are
|
|
86
|
+
const kids = (children, text) => children.map((c, i) => typeof c == 'string' ? createElement(Text, { key: 't' + i, style: has(text) ? text : undefined }, c) : c);
|
|
87
|
+
// an HTML container of inline content (a <li> with a checkbox, a label and a button) flows in a row,
|
|
88
|
+
// as the browser lays it out; a View primitive is a column unless its style says otherwise
|
|
89
|
+
const view = (el, c, s) => {
|
|
90
|
+
const row = !prim(el) && s.view.flexDirection == null && el.children.length > 0 && el.childNodes.every(n => n.nodeType === 3 || INLINE.test(n.localName) && !prim(n) || prim(n) == 'Text' || prim(n) == 'Pressable' || prim(n) == 'Switch');
|
|
91
|
+
return createElement(View, { style: row ? [{ flexDirection: 'row', flexWrap: 'wrap', alignItems: 'center', gap: 8 }, s.view] : s.view }, ...kids(c, s.text));
|
|
92
|
+
};
|
|
93
|
+
const text = (el, c, s, ctx) => createElement(Text, { style: s.all, onPress: listensClick(el) ? () => ctx.press(el) : undefined, accessibilityRole: el.localName == 'a' ? 'link' : /^h\d$/.test(el.localName) ? 'header' : undefined }, ...c);
|
|
94
|
+
const pressable = (el, c, s, ctx) => createElement(Pressable, {
|
|
95
|
+
onPress: () => ctx.press(el), disabled: el.disabled, accessibilityRole: 'button', accessibilityLabel: el.getAttribute('aria-label') || undefined,
|
|
96
|
+
accessibilityState: { disabled: el.disabled },
|
|
97
|
+
style: ({ pressed }) => (pressed ? [s.view, { opacity: 0.6 }] : s.view),
|
|
98
|
+
}, ...kids(c, s.text));
|
|
99
|
+
const textInput = (el, _c, s, ctx) => createElement(TextInput, {
|
|
100
|
+
// read now, at render: never a value captured before the latest native change was applied
|
|
101
|
+
value: el.value,
|
|
102
|
+
placeholder: el.getAttribute('placeholder') || undefined,
|
|
103
|
+
secureTextEntry: el.type == 'password',
|
|
104
|
+
multiline: el.localName == 'textarea',
|
|
105
|
+
editable: !el.readOnly && !el.disabled,
|
|
106
|
+
keyboardType: el.type == 'email' ? 'email-address' : el.getAttribute('inputmode') == 'numeric' || el.inputMode == 'numeric' ? 'numeric' : undefined,
|
|
107
|
+
accessibilityLabel: el.getAttribute('aria-label') || undefined,
|
|
108
|
+
onChangeText: (v) => { el.value = v; ctx.fire(el, 'input', { inputType: 'insertText', data: v }); },
|
|
109
|
+
onSubmitEditing: () => pressKey(el, 'Enter'),
|
|
110
|
+
onFocus: () => el.focus(),
|
|
111
|
+
onBlur: () => { if (el.ownerDocument.activeElement === el) {
|
|
112
|
+
el.blur();
|
|
113
|
+
ctx.fire(el, 'change');
|
|
114
|
+
} },
|
|
115
|
+
style: s.all,
|
|
116
|
+
});
|
|
117
|
+
const switchC = (el, _c, s, ctx) => createElement(Switch, {
|
|
118
|
+
value: el.checked, disabled: el.disabled, accessibilityLabel: el.getAttribute('aria-label') || undefined,
|
|
119
|
+
// a checkbox's click: it toggles, then input + change (undone when an intent prevents it)
|
|
120
|
+
onValueChange: () => ctx.press(el),
|
|
121
|
+
style: s.view,
|
|
122
|
+
});
|
|
123
|
+
const image = (el, _c, s) => createElement(Image, { source: { uri: el.getAttribute('src') || el.src }, accessibilityLabel: el.getAttribute('alt') || undefined, style: s.view, resizeMode: s.all.objectFit == 'contain' ? 'contain' : s.all.objectFit == 'fill' ? 'stretch' : 'cover' });
|
|
124
|
+
const LAYOUT = /^(flexDirection|flexWrap|alignItems|justifyContent|alignContent|gap|rowGap|columnGap|padding\w*)$/;
|
|
125
|
+
const scroll = (el, s) => {
|
|
126
|
+
const outer = {}, inner = {};
|
|
127
|
+
for (const k in s.view)
|
|
128
|
+
(LAYOUT.test(k) ? inner : outer)[k] = s.view[k];
|
|
129
|
+
delete outer.overflow;
|
|
130
|
+
delete outer.display;
|
|
131
|
+
return { outer, inner, horizontal: inner.flexDirection == 'row', onScroll: (e) => {
|
|
132
|
+
const { contentOffset: o = {}, contentSize: z = {}, layoutMeasurement: m = {} } = e?.nativeEvent || {};
|
|
133
|
+
fireOn(el, 'scroll', { bubbles: false, detail: { x: o.x || 0, y: o.y || 0, end: (o.y || 0) + (m.height || 0) >= (z.height || 0) - 1 } });
|
|
134
|
+
} };
|
|
135
|
+
};
|
|
136
|
+
const scrollView = (el, c, s) => {
|
|
137
|
+
const { outer, inner, horizontal, onScroll } = scroll(el, s);
|
|
138
|
+
return createElement(ScrollView, { style: outer, contentContainerStyle: inner, horizontal, onScroll, scrollEventThrottle: 50 }, ...kids(c, s.text));
|
|
139
|
+
};
|
|
140
|
+
const list = (el, _c, s, ctx) => {
|
|
141
|
+
const { outer, inner, horizontal, onScroll } = scroll(el, s);
|
|
142
|
+
return createElement(FlatList, {
|
|
143
|
+
// each item is the memoized element of a host child; FlatList windows the native views
|
|
144
|
+
data: el.children, keyExtractor: (n) => String(nodeId(n)), renderItem: ({ item }) => ctx.child(item),
|
|
145
|
+
extraData: el.revision, horizontal, style: outer, contentContainerStyle: inner, onScroll, scrollEventThrottle: 50,
|
|
146
|
+
});
|
|
147
|
+
};
|
|
148
|
+
const select = (el, _c, s, ctx) => {
|
|
149
|
+
// no picker in React Native's core: a button that steps to the next option (input + change)
|
|
150
|
+
const opts = el.options, i = Math.max(0, opts.findIndex(o => optionValue(o) == el.value));
|
|
151
|
+
return createElement(Pressable, { accessibilityRole: 'button', accessibilityLabel: el.getAttribute('aria-label') || undefined, style: s.view,
|
|
152
|
+
onPress: () => { const next = opts[(i + 1) % opts.length]; if (next)
|
|
153
|
+
chooseOption(el, optionValue(next)); } }, createElement(Text, { style: s.text }, (opts[i]?.textContent || '').trim() + ' ▾'));
|
|
154
|
+
};
|
|
155
|
+
return {
|
|
156
|
+
View: view, Text: text, Pressable: pressable, TextInput: textInput, Switch: switchC, Image: image, ScrollView: scrollView, List: list,
|
|
157
|
+
button: pressable, img: image, select,
|
|
158
|
+
hr: (_el, _c, s) => createElement(View, { style: s.view }),
|
|
159
|
+
br: () => createElement(Text, null, '\n'),
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
const listensClick = (el) => el.ownerDocument.listenedTypes(el).some(t => t == 'click');
|
|
163
|
+
/** the component for a host element: its primitive, its tag, its field kind, else View or Text */
|
|
164
|
+
function pick(el, table) {
|
|
165
|
+
const p = prim(el);
|
|
166
|
+
if (p && table[p])
|
|
167
|
+
return table[p];
|
|
168
|
+
if (table[el.localName])
|
|
169
|
+
return table[el.localName];
|
|
170
|
+
if (isCheckable(el))
|
|
171
|
+
return table.Switch;
|
|
172
|
+
if (isTextField(el))
|
|
173
|
+
return table.TextInput;
|
|
174
|
+
// a textual tag holding only text and inline text elements is Text; holding a field or a button,
|
|
175
|
+
// it is a row of Views (a <label> around a checkbox)
|
|
176
|
+
if (TEXTUAL.test(el.localName) && el.children.every(c => TEXTUAL.test(c.localName) && !prim(c) || c.localName == 'br'))
|
|
177
|
+
return table.Text;
|
|
178
|
+
return table.View;
|
|
179
|
+
}
|
|
180
|
+
/** a host document, its driver, and the React component that renders it */
|
|
181
|
+
function createNativeHost(options = {}) {
|
|
182
|
+
const doc = new HostDocument();
|
|
183
|
+
const table = { ...defaultComponents(), ...options.components };
|
|
184
|
+
const rules = [...(options.defaultStyles === false ? [] : defaultNativeStyles), ...(options.styles || [])];
|
|
185
|
+
// each rule's style compiled once (StyleSheet validates it in development)
|
|
186
|
+
const sheet = StyleSheet.create(Object.fromEntries(rules.map(([, st], i) => [i, Object.fromEntries(Object.entries(st).map(([k, v]) => [k, nativeValue(v)]))])));
|
|
187
|
+
// a descendant / child selector (not a list's comma): an ancestor's class change can restyle below it
|
|
188
|
+
const combinators = rules.some(([sel]) => sel.split(',').some(part => /[\s>]/.test(part.trim())));
|
|
189
|
+
const incremental = options.incremental !== false;
|
|
190
|
+
const listeners = new Set();
|
|
191
|
+
let live = true;
|
|
192
|
+
doc.onChange = () => { if (live)
|
|
193
|
+
for (const l of [...listeners])
|
|
194
|
+
l(); };
|
|
195
|
+
const ctx = {
|
|
196
|
+
fire: fireOn,
|
|
197
|
+
press: (el) => { activate(el, { onNavigate: options.onNavigate }); },
|
|
198
|
+
child: (n) => (n.nodeType === 3 ? n.data : createElement(Node, { key: nodeId(n), node: n, rev: n.revision, inh: 0 })),
|
|
199
|
+
};
|
|
200
|
+
const styleOf = (el) => {
|
|
201
|
+
const parts = [];
|
|
202
|
+
for (let i = 0; i < rules.length; i++)
|
|
203
|
+
if (matches(el, rules[i][0]))
|
|
204
|
+
parts.push(sheet[i]);
|
|
205
|
+
const own = ownStyle(el);
|
|
206
|
+
if (own)
|
|
207
|
+
parts.push(own);
|
|
208
|
+
const all = parts.length ? { ...StyleSheet.flatten(parts) } : {};
|
|
209
|
+
if (el.hidden)
|
|
210
|
+
all.display = 'none';
|
|
211
|
+
delete all.overflow;
|
|
212
|
+
return split(all);
|
|
213
|
+
};
|
|
214
|
+
const render = (el, inh) => {
|
|
215
|
+
options.onNodeRender?.(el);
|
|
216
|
+
const c = pick(el, table);
|
|
217
|
+
const childInh = combinators ? (inh * 31 + el.attrRevision + 1) | 0 : 0;
|
|
218
|
+
const children = el.childNodes.map((n) => n.nodeType === 3 ? n.data
|
|
219
|
+
: createElement(Node, { key: nodeId(n), node: n, rev: n.revision, inh: childInh }));
|
|
220
|
+
// (inside Text, element children render as nested Text: an inline run)
|
|
221
|
+
return c(el, children, styleOf(el), ctx);
|
|
222
|
+
};
|
|
223
|
+
const same = (a, b) => a.node === b.node && a.rev === b.rev && a.inh === b.inh;
|
|
224
|
+
const Node = incremental ? memo(({ node, inh }) => render(node, inh), same) : ({ node, inh }) => render(node, inh);
|
|
225
|
+
function Root() {
|
|
226
|
+
const [, force] = useReducer((x) => x + 1, 0);
|
|
227
|
+
useEffect(() => { listeners.add(force); return () => { listeners.delete(force); }; }, []);
|
|
228
|
+
const body = doc.body;
|
|
229
|
+
return createElement(View, { style: options.style || { flex: 1 } }, ...body.childNodes.map((n) => n.nodeType === 3 ? createElement(Text, { key: nodeId(n) }, n.data) : createElement(Node, { key: nodeId(n), node: n, rev: n.revision, inh: 0 })));
|
|
230
|
+
}
|
|
231
|
+
return { doc, driver: makeHostDriver(doc), Root, stop: () => { live = false; } };
|
|
232
|
+
}
|
|
233
|
+
/** a Sygnal app as a React Native component: runs it on mount, disposes it on unmount */
|
|
234
|
+
function SygnalView(props) {
|
|
235
|
+
const [host] = useState(() => createNativeHost(props));
|
|
236
|
+
useEffect(() => {
|
|
237
|
+
const app = run(props.app, { ...props.drivers, DOM: host.driver }, props.runOptions);
|
|
238
|
+
return () => { host.stop(); app.dispose(); };
|
|
239
|
+
}, []);
|
|
240
|
+
return createElement(host.Root);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export { SygnalView, createNativeHost, defaultNativeStyles };
|
|
244
|
+
//# sourceMappingURL=react-native.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-native.esm.js","sources":["../src/react-native.ts"],"sourcesContent":["/*\n * 'sygnal/react-native': a Sygnal app on React Native. The app renders into a sygnal/host tree\n * (the kit the terminal and agent UI targets use); this bridge renders that tree as React Native\n * components, and turns native callbacks into the DOM events intents already listen for (D-AR-3):\n * onPress → click, onChangeText → input, onValueChange → click + input + change, onScroll → scroll.\n *\n * import { SygnalView } from 'sygnal/react-native'\n * export default () => <SygnalView app={App} styles={[['.done', { opacity: 0.5 }]]} />\n *\n * - Incremental: each host element is a memoized React component keyed by its host node and\n * revision (the host's change tracking: a mutation moves the revision of the node and its\n * ancestors), so a change re-renders the changed path only (`incremental: false`: every element,\n * for comparison; `onNodeRender` counts).\n * - What maps to what: the 'sygnal/primitives' (by their data-primitive marker), the common HTML\n * tags (a web view runs as is: div → View, span/p/h1 → Text, button → Pressable, input →\n * TextInput or Switch, img → Image, select → a Pressable that steps through the options), and a\n * target's own field tags (registerFieldTags: text → TextInput, checkbox → Switch). `components`\n * replaces any of them.\n * - Controlled fields: a field's value is read from the host element when React renders it, never\n * captured earlier, so React Native's own TextInput protocol (the native event count) keeps\n * typing ahead of a render that hasn't seen it yet; the app's value wins whenever it differs.\n * - Styles: the `styles` rules ([selector, style], after defaultNativeStyles) compile to a\n * StyleSheet; an element's style is its matching rules, then its inline style (`px` strings\n * from the primitives' web form read back as numbers). Text keys (color, fontSize, …) of a\n * View-like element style the Text that wraps its direct text (React Native has no inheritance\n * from a View).\n * - Lists: a `List` primitive renders as a FlatList over its children (native views windowed; the\n * Sygnal items stay mounted). VirtualCollection measures the DOM and is web-only.\n *\n * Separate entry: './index' and './host' become the external 'sygnal' and 'sygnal/host'; react\n * and react-native are optional peer dependencies (D209).\n */\nimport {createElement as h, memo, useState, useReducer, useEffect} from 'react'\nimport {View, Text, Pressable, TextInput, Switch, Image, ScrollView, FlatList, StyleSheet} from 'react-native'\nimport {run} from './index'\nimport {HostDocument, makeHostDriver, nodeId, matches, activate, pressKey, chooseOption, optionValue, isTextField, isCheckable, HostEvent} from './host'\nimport type {HostElement, HostNode} from './host'\n\nexport type NativeStyle = Record<string, any>\nexport type NativeStyleRule = [selector: string, style: NativeStyle]\n\n/** HTML defaults for native (a web view's headings, links, buttons and fields look like themselves) */\nexport const defaultNativeStyles: NativeStyleRule[] = [\n ['h1', {fontSize: 32, fontWeight: '700', marginVertical: 8}],\n ['h2', {fontSize: 24, fontWeight: '700', marginVertical: 6}],\n ['h3', {fontSize: 20, fontWeight: '600', marginVertical: 4}],\n ['h4, h5, h6', {fontSize: 17, fontWeight: '600'}],\n ['strong, b, th', {fontWeight: '700'}],\n ['em, i', {fontStyle: 'italic'}],\n ['a', {color: '#2f6fed', textDecorationLine: 'underline'}],\n // HTML elements only: a primitive (data-primitive) is styled by the app, as in React Native\n ['button:not([data-primitive])', {paddingHorizontal: 14, paddingVertical: 8, borderRadius: 8, backgroundColor: '#2f6fed', color: '#ffffff', fontWeight: '600', fontSize: 17, alignItems: 'center', justifyContent: 'center'}],\n ['button[disabled]', {opacity: 0.5}],\n ['input:not([data-primitive]):not([type=\"checkbox\"]):not([type=\"radio\"]), textarea:not([data-primitive])', {borderWidth: 1, borderColor: '#bbbbbb', borderRadius: 8, paddingHorizontal: 10, paddingVertical: 8, fontSize: 17, minWidth: 160}],\n ['p, li', {fontSize: 17}],\n ['hr', {height: 1, backgroundColor: '#cccccc', marginVertical: 8}],\n]\n\n/** the text keys React Native applies to Text only */\nconst TEXT_KEYS = /^(color|font\\w*|textAlign|textDecoration\\w*|textTransform|letterSpacing|lineHeight|includeFontPadding|textShadow\\w*|writingDirection|userSelect)$/\nconst PX = /^(-?\\d*\\.?\\d+)px$/\n/** a style value as React Native takes it: `12px` → 12 (the primitives' web form) */\nconst nativeValue = (v: any) => (typeof v == 'string' && PX.test(v) ? parseFloat(v) : v)\n// web-only style the primitives add for the browser (a plain button look, line clamping): not React Native's\nconst WEB_ONLY = /^(background|font|cursor|boxSizing|outline\\w*|transition\\w*|Webkit\\w*|whiteSpace|textOverflow|overflow)$/\nconst ownStyle = (el: HostElement) => {\n let out: NativeStyle | undefined\n for (const k in el.style) {\n const v = el.style[k]\n if (v == null || v === '' || v === 'inherit' || WEB_ONLY.test(k) || (k == 'display' && v != 'none' && v != 'flex')) continue\n ;(out ||= {})[k] = nativeValue(v)\n }\n return out\n}\n\n/** a component of the table: the element, its children as React nodes, its style (view part, text part) */\nexport type NativeComponent = (el: HostElement, children: any[], style: {view: NativeStyle, text: NativeStyle, all: NativeStyle}, ctx: NativeContext) => any\nexport interface NativeContext {\n /** fire a DOM-shaped event on a host element */\n fire(el: HostElement, type: string, init?: Record<string, any>): boolean\n /** a click and its default action (sygnal/host activate) */\n press(el: HostElement): void\n /** render a host child (a memoized element) */\n child(node: HostNode): any\n}\n\nexport interface NativeHostOptions {\n /** the app's native stylesheet (after defaultNativeStyles) */\n styles?: readonly NativeStyleRule[]\n /** false: no defaultNativeStyles */\n defaultStyles?: boolean\n /** replace or add components, by primitive name ('View', 'List', …) or tag ('button', 'my-chart') */\n components?: Record<string, NativeComponent>\n /** a link's default action (an <a href> pressed): a router driver's go */\n onNavigate?: (href: string, el: HostElement) => void\n /** false: re-render every element on every change (for measuring) */\n incremental?: boolean\n /** called each time an element's React component renders (measuring, tests) */\n onNodeRender?: (el: HostElement) => void\n /** the root View's style (default { flex: 1 }) */\n style?: NativeStyle\n}\n\nconst TEXTUAL = /^(span|p|label|strong|b|em|i|small|code|h[1-6]|a|li|th|td|dt|dd|figcaption|summary|legend|caption)$/\nconst INLINE = /^(span|strong|b|em|i|small|code|a|label|img|button|input|select|textarea|br)$/\nconst fireOn = (el: HostElement, type: string, init?: Record<string, any>) => el.dispatchEvent(new HostEvent(type, init))\nconst prim = (el: HostElement) => el.dataset.primitive as string | undefined\n\nfunction split(all: NativeStyle) {\n const view: NativeStyle = {}, text: NativeStyle = {}\n for (const k in all) (TEXT_KEYS.test(k) ? text : view)[k] = all[k]\n return {view, text, all}\n}\nconst has = (o: object) => { for (const _ in o) return true; return false }\n\n/** the built-in table */\nfunction defaultComponents(): Record<string, NativeComponent> {\n // direct strings become Text with the element's text style; element children render as they are\n const kids = (children: any[], text: NativeStyle) => children.map((c, i) => typeof c == 'string' ? h(Text, {key: 't' + i, style: has(text) ? text : undefined}, c) : c)\n // an HTML container of inline content (a <li> with a checkbox, a label and a button) flows in a row,\n // as the browser lays it out; a View primitive is a column unless its style says otherwise\n const view: NativeComponent = (el, c, s) => {\n const row = !prim(el) && s.view.flexDirection == null && el.children.length > 0 && el.childNodes.every(n => n.nodeType === 3 || INLINE.test((n as HostElement).localName) && !prim(n as HostElement) || prim(n as HostElement) == 'Text' || prim(n as HostElement) == 'Pressable' || prim(n as HostElement) == 'Switch')\n return h(View, {style: row ? [{flexDirection: 'row', flexWrap: 'wrap', alignItems: 'center', gap: 8}, s.view] : s.view}, ...kids(c, s.text))\n }\n const text: NativeComponent = (el, c, s, ctx) => h(Text, {style: s.all, onPress: listensClick(el) ? () => ctx.press(el) : undefined, accessibilityRole: el.localName == 'a' ? 'link' : /^h\\d$/.test(el.localName) ? 'header' : undefined}, ...c)\n const pressable: NativeComponent = (el, c, s, ctx) => h(Pressable, {\n onPress: () => ctx.press(el), disabled: el.disabled, accessibilityRole: 'button', accessibilityLabel: el.getAttribute('aria-label') || undefined,\n accessibilityState: {disabled: el.disabled},\n style: ({pressed}: {pressed: boolean}) => (pressed ? [s.view, {opacity: 0.6}] : s.view),\n }, ...kids(c, s.text))\n const textInput: NativeComponent = (el, _c, s, ctx) => h(TextInput, {\n // read now, at render: never a value captured before the latest native change was applied\n value: el.value,\n placeholder: el.getAttribute('placeholder') || undefined,\n secureTextEntry: el.type == 'password',\n multiline: el.localName == 'textarea',\n editable: !el.readOnly && !el.disabled,\n keyboardType: el.type == 'email' ? 'email-address' : el.getAttribute('inputmode') == 'numeric' || (el as any).inputMode == 'numeric' ? 'numeric' : undefined,\n accessibilityLabel: el.getAttribute('aria-label') || undefined,\n onChangeText: (v: string) => { el.value = v; ctx.fire(el, 'input', {inputType: 'insertText', data: v}) },\n onSubmitEditing: () => pressKey(el, 'Enter'),\n onFocus: () => el.focus(),\n onBlur: () => { if (el.ownerDocument.activeElement === el) { el.blur(); ctx.fire(el, 'change') } },\n style: s.all,\n })\n const switchC: NativeComponent = (el, _c, s, ctx) => h(Switch, {\n value: el.checked, disabled: el.disabled, accessibilityLabel: el.getAttribute('aria-label') || undefined,\n // a checkbox's click: it toggles, then input + change (undone when an intent prevents it)\n onValueChange: () => ctx.press(el),\n style: s.view,\n })\n const image: NativeComponent = (el, _c, s) => h(Image, {source: {uri: el.getAttribute('src') || (el as any).src}, accessibilityLabel: el.getAttribute('alt') || undefined, style: s.view, resizeMode: s.all.objectFit == 'contain' ? 'contain' : s.all.objectFit == 'fill' ? 'stretch' : 'cover'})\n const LAYOUT = /^(flexDirection|flexWrap|alignItems|justifyContent|alignContent|gap|rowGap|columnGap|padding\\w*)$/\n const scroll = (el: HostElement, s: {view: NativeStyle}) => {\n const outer: NativeStyle = {}, inner: NativeStyle = {}\n for (const k in s.view) (LAYOUT.test(k) ? inner : outer)[k] = s.view[k]\n delete outer.overflow\n delete outer.display\n return {outer, inner, horizontal: inner.flexDirection == 'row', onScroll: (e: any) => {\n const {contentOffset: o = {}, contentSize: z = {}, layoutMeasurement: m = {}} = e?.nativeEvent || {}\n fireOn(el, 'scroll', {bubbles: false, detail: {x: o.x || 0, y: o.y || 0, end: (o.y || 0) + (m.height || 0) >= (z.height || 0) - 1}})\n }}\n }\n const scrollView: NativeComponent = (el, c, s) => {\n const {outer, inner, horizontal, onScroll} = scroll(el, s)\n return h(ScrollView, {style: outer, contentContainerStyle: inner, horizontal, onScroll, scrollEventThrottle: 50}, ...kids(c, s.text))\n }\n const list: NativeComponent = (el, _c, s, ctx) => {\n const {outer, inner, horizontal, onScroll} = scroll(el, s)\n return h(FlatList, {\n // each item is the memoized element of a host child; FlatList windows the native views\n data: el.children, keyExtractor: (n: HostElement) => String(nodeId(n)), renderItem: ({item}: {item: HostElement}) => ctx.child(item),\n extraData: el.revision, horizontal, style: outer, contentContainerStyle: inner, onScroll, scrollEventThrottle: 50,\n })\n }\n const select: NativeComponent = (el, _c, s, ctx) => {\n // no picker in React Native's core: a button that steps to the next option (input + change)\n const opts = el.options, i = Math.max(0, opts.findIndex(o => optionValue(o) == el.value))\n return h(Pressable, {accessibilityRole: 'button', accessibilityLabel: el.getAttribute('aria-label') || undefined, style: s.view,\n onPress: () => { const next = opts[(i + 1) % opts.length]; if (next) chooseOption(el, optionValue(next)) }},\n h(Text, {style: s.text}, (opts[i]?.textContent || '').trim() + ' ▾'))\n void ctx\n }\n return {\n View: view, Text: text, Pressable: pressable, TextInput: textInput, Switch: switchC, Image: image, ScrollView: scrollView, List: list,\n button: pressable, img: image, select,\n hr: (_el, _c, s) => h(View, {style: s.view}),\n br: () => h(Text, null, '\\n'),\n }\n}\nconst listensClick = (el: HostElement) => el.ownerDocument.listenedTypes(el).some(t => t == 'click')\n\n/** the component for a host element: its primitive, its tag, its field kind, else View or Text */\nfunction pick(el: HostElement, table: Record<string, NativeComponent>): NativeComponent {\n const p = prim(el)\n if (p && table[p]) return table[p]\n if (table[el.localName]) return table[el.localName]\n if (isCheckable(el)) return table.Switch\n if (isTextField(el)) return table.TextInput\n // a textual tag holding only text and inline text elements is Text; holding a field or a button,\n // it is a row of Views (a <label> around a checkbox)\n if (TEXTUAL.test(el.localName) && el.children.every(c => TEXTUAL.test(c.localName) && !prim(c) || c.localName == 'br')) return table.Text\n return table.View\n}\n\nexport interface NativeHost {\n readonly doc: HostDocument\n /** the DOM driver: run(App, { DOM: host.driver }) */\n readonly driver: ReturnType<typeof makeHostDriver>\n /** the React component that shows the host tree */\n Root: () => any\n /** stop rendering (before the app's dispose empties the tree) */\n stop(): void\n}\n\n/** a host document, its driver, and the React component that renders it */\nexport function createNativeHost(options: NativeHostOptions = {}): NativeHost {\n const doc = new HostDocument()\n const table = {...defaultComponents(), ...options.components}\n const rules = [...(options.defaultStyles === false ? [] : defaultNativeStyles), ...(options.styles || [])]\n // each rule's style compiled once (StyleSheet validates it in development)\n const sheet: any = StyleSheet.create(Object.fromEntries(rules.map(([, st], i) => [i, Object.fromEntries(Object.entries(st).map(([k, v]) => [k, nativeValue(v)]))])))\n // a descendant / child selector (not a list's comma): an ancestor's class change can restyle below it\n const combinators = rules.some(([sel]) => sel.split(',').some(part => /[\\s>]/.test(part.trim())))\n const incremental = options.incremental !== false\n const listeners = new Set<() => void>()\n let live = true\n doc.onChange = () => { if (live) for (const l of [...listeners]) l() }\n\n const ctx: NativeContext = {\n fire: fireOn,\n press: (el) => { activate(el, {onNavigate: options.onNavigate}) },\n child: (n) => (n.nodeType === 3 ? (n as any).data : h(Node, {key: nodeId(n), node: n, rev: n.revision, inh: 0})),\n }\n const styleOf = (el: HostElement) => {\n const parts: any[] = []\n for (let i = 0; i < rules.length; i++) if (matches(el, rules[i][0])) parts.push(sheet[i])\n const own = ownStyle(el)\n if (own) parts.push(own)\n const all: NativeStyle = parts.length ? {...StyleSheet.flatten(parts)} : {}\n if (el.hidden) all.display = 'none'\n delete all.overflow\n return split(all)\n }\n const render = (el: HostElement, inh: number): any => {\n options.onNodeRender?.(el)\n const c = pick(el, table)\n const childInh = combinators ? (inh * 31 + el.attrRevision + 1) | 0 : 0\n const children = el.childNodes.map((n) => n.nodeType === 3 ? (n as any).data\n : h(Node, {key: nodeId(n), node: n, rev: n.revision, inh: childInh}))\n // (inside Text, element children render as nested Text: an inline run)\n return c(el, children, styleOf(el), ctx)\n }\n const same = (a: any, b: any) => a.node === b.node && a.rev === b.rev && a.inh === b.inh\n const Node: any = incremental ? memo(({node, inh}: any) => render(node, inh), same) : ({node, inh}: any) => render(node, inh)\n\n function Root() {\n const [, force] = useReducer((x: number) => x + 1, 0)\n useEffect(() => { listeners.add(force); return () => { listeners.delete(force) } }, [])\n const body = doc.body\n return h(View, {style: options.style || {flex: 1}}, ...body.childNodes.map((n) =>\n n.nodeType === 3 ? h(Text, {key: nodeId(n)}, (n as any).data) : h(Node, {key: nodeId(n), node: n, rev: n.revision, inh: 0})))\n }\n return {doc, driver: makeHostDriver(doc), Root, stop: () => { live = false }}\n}\n\nexport interface SygnalViewProps extends NativeHostOptions {\n /** the root component */\n app: any\n /** the app's other drivers (DOM is the bridge's) */\n drivers?: Record<string, any>\n /** run() options (onError, …) */\n runOptions?: Record<string, any>\n}\n\n/** a Sygnal app as a React Native component: runs it on mount, disposes it on unmount */\nexport function SygnalView(props: SygnalViewProps): any {\n const [host] = useState(() => createNativeHost(props))\n useEffect(() => {\n const app = run(props.app, {...props.drivers, DOM: host.driver}, props.runOptions)\n return () => { host.stop(); app.dispose() }\n }, [])\n return h(host.Root)\n}\n"],"names":["h"],"mappings":";;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BG;AAUH;AACa,MAAA,mBAAmB,GAAsB;AACpD,IAAA,CAAC,IAAI,EAAE,EAAC,QAAQ,EAAE,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC,EAAC,CAAC;AAC5D,IAAA,CAAC,IAAI,EAAE,EAAC,QAAQ,EAAE,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC,EAAC,CAAC;AAC5D,IAAA,CAAC,IAAI,EAAE,EAAC,QAAQ,EAAE,EAAE,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
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return sygnal.RECORDING_SCHEMA; }
|
|
10
|
+
});
|
|
11
|
+
Object.defineProperty(exports, 'bugReport', {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return sygnal.bugReport; }
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(exports, 'finalState', {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return sygnal.finalState; }
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, 'inertDriver', {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return sygnal.inertDriver; }
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports, 'replay', {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () { return sygnal.replay; }
|
|
26
|
+
});
|
|
27
|
+
Object.defineProperty(exports, 'replayTest', {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get: function () { return sygnal.replayTest; }
|
|
30
|
+
});
|
|
31
|
+
Object.defineProperty(exports, 'startRecording', {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function () { return sygnal.startRecording; }
|
|
34
|
+
});
|
|
35
|
+
Object.defineProperty(exports, 'timeline', {
|
|
36
|
+
enumerable: true,
|
|
37
|
+
get: function () { return sygnal.timeline; }
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=replay.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replay.cjs.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replay.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
4
|
+
/*
|
|
5
|
+
* The QuickJS WASM module: `quickjs-emscripten-core` + `@jitl/quickjs-wasmfile-release-sync`,
|
|
6
|
+
* optional peer dependencies (D209), loaded on first use. Stock packages only (README §9 Q6):
|
|
7
|
+
* a quickjs-ng variant can be passed as `variant`.
|
|
8
|
+
*/
|
|
9
|
+
// Node built-ins by a name bundlers don't follow (a browser bundle never loads them)
|
|
10
|
+
const nodeImport = (name) => import(/* @vite-ignore */ /* webpackIgnore: true */ name);
|
|
11
|
+
|
|
12
|
+
/*
|
|
13
|
+
* The guest kernel, built from the app's installed packages (README §7 option (a), §9 Q1; D209:
|
|
14
|
+
* Sygnal's npm package never ships xstream or snabbdom prebuilt into it). sygnal/vite resolves
|
|
15
|
+
* `sygnal/sandbox/kernel?raw` to this function's output (the project's own Vite), and
|
|
16
|
+
* `buildSandboxKernel()` (sygnal/sandbox/build) does it for other toolchains (Vite, esbuild or
|
|
17
|
+
* Rollup, whichever the project has).
|
|
18
|
+
*
|
|
19
|
+
* The output is one script: the platform prelude (timers, console, microtasks on `__host`,
|
|
20
|
+
* which the core's modules read when they load), then dist/sandbox-kernel.esm.js bundled as an
|
|
21
|
+
* IIFE with the installed sygnal (dist/index.esm.js and dist/host.esm.js of the same package: one
|
|
22
|
+
* core), xstream and snabbdom. `process.env.NODE_ENV` is 'production'; xstream's `globalthis`
|
|
23
|
+
* dependency is Sygnal's shim (as sygnal/vite does, G-099).
|
|
24
|
+
*/
|
|
25
|
+
// The platform a bare QuickJS context lacks. A plain script, so it runs before the bundle's modules.
|
|
26
|
+
const PLATFORM = `var global = globalThis;
|
|
27
|
+
(function () {
|
|
28
|
+
var H = globalThis.__host, G = globalThis, timers = new Map(), intervals = new Map(), seq = 0;
|
|
29
|
+
G.__sandboxTimers = timers;
|
|
30
|
+
G.queueMicrotask = G.queueMicrotask || function (f) { Promise.resolve().then(f) };
|
|
31
|
+
G.setTimeout = function (f, ms) { var id = ++seq; timers.set(id, f); H.timer(id, +ms || 0); return id };
|
|
32
|
+
G.clearTimeout = function (id) { if (timers.delete(id)) H.clearTimer(id) };
|
|
33
|
+
// the core's macrotask hop (runtime.ts macro()): its own channel, so a component's timers can't starve it
|
|
34
|
+
G.setImmediate = function (f) { var id = ++seq; timers.set(id, f); H.timer(id, -1); return id };
|
|
35
|
+
G.clearImmediate = G.clearTimeout;
|
|
36
|
+
G.setInterval = function (f, ms) { var box = {}; var tick = function () { box.id = G.setTimeout(tick, ms); f() }; box.id = G.setTimeout(tick, ms); var id = ++seq; intervals.set(id, box); return id };
|
|
37
|
+
G.clearInterval = function (id) { var b = intervals.get(id); if (b) { intervals.delete(id); G.clearTimeout(b.id) } };
|
|
38
|
+
G.requestAnimationFrame = function (f) { return G.setTimeout(function () { f(Date.now()) }, 16) };
|
|
39
|
+
G.cancelAnimationFrame = G.clearTimeout;
|
|
40
|
+
var fmt = function (a) { return a.map(function (x) { if (typeof x == 'string') return x; if (x instanceof Error) return x.name + ': ' + x.message; try { return JSON.stringify(x) } catch (e) { return String(x) } }).join(' ') };
|
|
41
|
+
G.console = {
|
|
42
|
+
log: function () { H.log('log', fmt([].slice.call(arguments))) }, info: function () { H.log('log', fmt([].slice.call(arguments))) },
|
|
43
|
+
warn: function () { H.log('warn', fmt([].slice.call(arguments))) }, error: function () { H.log('error', fmt([].slice.call(arguments))) },
|
|
44
|
+
debug: function () {},
|
|
45
|
+
};
|
|
46
|
+
})();
|
|
47
|
+
`;
|
|
48
|
+
/** The guest kernel script for createSandbox / <Sandboxed> (`kernel`), built from the installed packages */
|
|
49
|
+
async function buildSandboxKernel(opts = {}) {
|
|
50
|
+
const [path, { createRequire }, { pathToFileURL }, fs] = await Promise.all([nodeImport('node:path'), nodeImport('node:module'), nodeImport('node:url'), nodeImport('node:fs')]);
|
|
51
|
+
const root = path.resolve(opts.root || globalThis.process.cwd());
|
|
52
|
+
const fromRoot = createRequire(path.join(root, 'package.json'));
|
|
53
|
+
// the app's sygnal (else this one): its dist/ holds the kernel entry, the core and the kit
|
|
54
|
+
let main;
|
|
55
|
+
try {
|
|
56
|
+
main = fromRoot.resolve('sygnal');
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
main = createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('sandbox-build.cjs.js', document.baseURI).href))).resolve('sygnal');
|
|
60
|
+
}
|
|
61
|
+
const dist = path.dirname(main);
|
|
62
|
+
const entry = path.join(dist, 'sandbox-kernel.esm.js');
|
|
63
|
+
const files = {
|
|
64
|
+
sygnal: path.join(dist, 'index.esm.js'),
|
|
65
|
+
'sygnal/host': path.join(dist, 'host.esm.js'),
|
|
66
|
+
globalthis: path.join(dist, 'shims/globalthis.cjs'),
|
|
67
|
+
};
|
|
68
|
+
for (const f of [entry, ...Object.values(files)])
|
|
69
|
+
if (!fs.existsSync(f))
|
|
70
|
+
throw new Error(`buildSandboxKernel: ${f} is missing (an incomplete sygnal install?)`);
|
|
71
|
+
const minify = opts.minify !== false;
|
|
72
|
+
const define = { 'process.env.NODE_ENV': '"production"' };
|
|
73
|
+
const has = (name) => { try {
|
|
74
|
+
fromRoot.resolve(name);
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
return false;
|
|
79
|
+
} };
|
|
80
|
+
const want = opts.bundler || 'auto';
|
|
81
|
+
const bundler = want !== 'auto' ? want : has('vite') ? 'vite' : has('esbuild') ? 'esbuild' : has('rollup') ? 'rollup' : null;
|
|
82
|
+
if (!bundler)
|
|
83
|
+
throw new Error('buildSandboxKernel: needs vite, esbuild or rollup installed in ' + root);
|
|
84
|
+
const load = (name) => import(/* @vite-ignore */ pathToFileURL(resolveEsm(fromRoot, fs, path, name)).href);
|
|
85
|
+
let code;
|
|
86
|
+
if (bundler === 'esbuild') {
|
|
87
|
+
const esbuild = await load('esbuild');
|
|
88
|
+
const r = await (esbuild.build || esbuild.default.build)({
|
|
89
|
+
entryPoints: [entry], bundle: true, write: false, format: 'iife', platform: 'browser', target: 'es2020',
|
|
90
|
+
minify, define, alias: files, logLevel: 'silent', legalComments: 'none',
|
|
91
|
+
});
|
|
92
|
+
code = r.outputFiles[0].text;
|
|
93
|
+
}
|
|
94
|
+
else if (bundler === 'rollup') {
|
|
95
|
+
const { rollup } = await load('rollup');
|
|
96
|
+
const plugins = [{
|
|
97
|
+
name: 'sygnal-kernel', resolveId: (id) => files[id] || null,
|
|
98
|
+
transform: (c) => (c.includes('process.env.NODE_ENV') ? c.split('process.env.NODE_ENV').join(define['process.env.NODE_ENV']) : null),
|
|
99
|
+
}];
|
|
100
|
+
const req = async (n) => { const m = await load(n); return m.default || m; };
|
|
101
|
+
if (has('@rollup/plugin-node-resolve'))
|
|
102
|
+
plugins.push((await load('@rollup/plugin-node-resolve')).nodeResolve({ browser: true }));
|
|
103
|
+
if (has('@rollup/plugin-commonjs'))
|
|
104
|
+
plugins.push((await req('@rollup/plugin-commonjs'))());
|
|
105
|
+
if (minify && has('@rollup/plugin-terser'))
|
|
106
|
+
plugins.push((await req('@rollup/plugin-terser'))({ ecma: 2020 }));
|
|
107
|
+
const b = await rollup({ input: entry, plugins, onwarn: () => { } });
|
|
108
|
+
code = (await b.generate({ format: 'iife', name: '__sygnalKernel' })).output[0].code;
|
|
109
|
+
await b.close();
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
const vite = await load('vite');
|
|
113
|
+
const out = await vite.build({
|
|
114
|
+
configFile: false, root, logLevel: 'silent', mode: 'production', define,
|
|
115
|
+
resolve: { alias: Object.entries(files).map(([find, replacement]) => ({ find: new RegExp(`^${find.replace('/', '\\/')}$`), replacement })) },
|
|
116
|
+
build: { write: false, minify, target: 'es2020', lib: { entry, formats: ['iife'], name: '__sygnalKernel', fileName: () => 'kernel.js' }, rollupOptions: { output: { inlineDynamicImports: true } } },
|
|
117
|
+
});
|
|
118
|
+
const o = (Array.isArray(out) ? out[0] : out).output;
|
|
119
|
+
code = o.find((c) => c.type === 'chunk').code;
|
|
120
|
+
}
|
|
121
|
+
return PLATFORM + code;
|
|
122
|
+
}
|
|
123
|
+
// a package's ESM entry, as resolved from the app (import() needs a file URL, not a bare name, to resolve from there)
|
|
124
|
+
function resolveEsm(req, fs, path, name) {
|
|
125
|
+
try {
|
|
126
|
+
const pj = req.resolve(`${name}/package.json`);
|
|
127
|
+
const pkg = JSON.parse(fs.readFileSync(pj, 'utf8'));
|
|
128
|
+
const dot = typeof pkg.exports == 'string' ? pkg.exports : pkg.exports?.['.'];
|
|
129
|
+
let e = typeof dot == 'string' ? dot : dot?.import ?? pkg.module ?? pkg.main ?? 'index.js';
|
|
130
|
+
if (e && typeof e == 'object')
|
|
131
|
+
e = e.default;
|
|
132
|
+
return path.join(path.dirname(pj), e);
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
return req.resolve(name);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
exports.buildSandboxKernel = buildSandboxKernel;
|
|
140
|
+
//# sourceMappingURL=sandbox-build.cjs.js.map
|