sygnal 5.3.7 → 6.0.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 +646 -0
- package/README.md +77 -47
- package/dist/astro/client.cjs.js +33 -8114
- package/dist/astro/client.cjs.js.map +1 -0
- package/dist/astro/client.mjs +33 -8114
- package/dist/astro/client.mjs.map +1 -0
- package/dist/astro/index.cjs.js +1039 -9
- package/dist/astro/index.cjs.js.map +1 -0
- package/dist/astro/index.mjs +1038 -9
- package/dist/astro/index.mjs.map +1 -0
- package/dist/astro/server.cjs.js +3400 -166
- package/dist/astro/server.cjs.js.map +1 -0
- package/dist/astro/server.mjs +3400 -166
- package/dist/astro/server.mjs.map +1 -0
- package/dist/devtools.cjs.js +1431 -0
- package/dist/devtools.cjs.js.map +1 -0
- package/dist/devtools.esm.js +1419 -0
- package/dist/devtools.esm.js.map +1 -0
- package/dist/diagnostics.cjs.js +4033 -0
- package/dist/diagnostics.cjs.js.map +1 -0
- package/dist/diagnostics.esm.js +4003 -0
- package/dist/diagnostics.esm.js.map +1 -0
- package/dist/element.cjs.js +230 -0
- package/dist/element.cjs.js.map +1 -0
- package/dist/element.esm.js +228 -0
- package/dist/element.esm.js.map +1 -0
- package/dist/guide/accessibility.md +257 -0
- package/dist/guide/adapters.md +221 -0
- package/dist/guide/behaviors.md +312 -0
- package/dist/guide/browser-sources.md +203 -0
- package/dist/guide/drag-and-drop.md +342 -0
- package/dist/guide/element-commands.md +306 -0
- package/dist/guide/error-boundaries.md +169 -0
- package/dist/guide/forms-reference.md +381 -0
- package/dist/guide/forms.md +250 -0
- package/dist/guide/http.md +299 -0
- package/dist/guide/inputs.md +173 -0
- package/dist/guide/persistence.md +245 -0
- package/dist/guide/recipes/carousel.md +155 -0
- package/dist/guide/recipes/charts.md +177 -0
- package/dist/guide/recipes/code-editor.md +135 -0
- package/dist/guide/recipes/data-grid.md +155 -0
- package/dist/guide/recipes/data-table.md +196 -0
- package/dist/guide/recipes/i18n.md +222 -0
- package/dist/guide/recipes/icons.md +115 -0
- package/dist/guide/recipes/overview.md +33 -0
- package/dist/guide/recipes/rich-text.md +154 -0
- package/dist/guide/resources.md +471 -0
- package/dist/guide/ssr.md +255 -0
- package/dist/guide/timers.md +178 -0
- package/dist/guide/ui/accordion.md +93 -0
- package/dist/guide/ui/combobox.md +144 -0
- package/dist/guide/ui/dialog.md +124 -0
- package/dist/guide/ui/disclosure.md +60 -0
- package/dist/guide/ui/menu.md +125 -0
- package/dist/guide/ui/overview.md +166 -0
- package/dist/guide/ui/popover.md +101 -0
- package/dist/guide/ui/select.md +114 -0
- package/dist/guide/ui/tabs.md +161 -0
- package/dist/guide/ui/toaster.md +152 -0
- package/dist/guide/ui/tooltip.md +103 -0
- package/dist/guide/undo.md +178 -0
- package/dist/guide/virtual-collections.md +183 -0
- package/dist/guide/web-components.md +179 -0
- package/dist/guide/widgets.md +217 -0
- package/dist/index.cjs.js +15283 -6279
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +3739 -370
- package/dist/index.esm.js +15230 -6274
- package/dist/index.esm.js.map +1 -0
- package/dist/jsx-dev-runtime.cjs.js +27 -329
- package/dist/jsx-dev-runtime.cjs.js.map +1 -0
- package/dist/jsx-dev-runtime.esm.js +20 -322
- package/dist/jsx-dev-runtime.esm.js.map +1 -0
- package/dist/jsx-runtime.cjs.js +27 -329
- package/dist/jsx-runtime.cjs.js.map +1 -0
- package/dist/jsx-runtime.esm.js +20 -322
- package/dist/jsx-runtime.esm.js.map +1 -0
- package/dist/jsx.cjs.js +11 -309
- package/dist/jsx.cjs.js.map +1 -0
- package/dist/jsx.esm.js +9 -310
- package/dist/jsx.esm.js.map +1 -0
- package/dist/react.cjs.js +117 -0
- package/dist/react.cjs.js.map +1 -0
- package/dist/react.esm.js +115 -0
- package/dist/react.esm.js.map +1 -0
- package/dist/shims/globalthis.cjs +20 -0
- package/dist/sygnal.min.js +2 -1
- package/dist/sygnal.min.js.map +1 -0
- package/dist/ui-combobox.cjs.js +169 -0
- package/dist/ui-combobox.cjs.js.map +1 -0
- package/dist/ui-combobox.esm.js +148 -0
- package/dist/ui-combobox.esm.js.map +1 -0
- package/dist/ui-menu.cjs.js +87 -0
- package/dist/ui-menu.cjs.js.map +1 -0
- package/dist/ui-menu.esm.js +66 -0
- package/dist/ui-menu.esm.js.map +1 -0
- package/dist/ui-select.cjs.js +104 -0
- package/dist/ui-select.cjs.js.map +1 -0
- package/dist/ui-select.esm.js +83 -0
- package/dist/ui-select.esm.js.map +1 -0
- package/dist/ui.cjs.js +738 -0
- package/dist/ui.cjs.js.map +1 -0
- package/dist/ui.esm.js +727 -0
- package/dist/ui.esm.js.map +1 -0
- package/dist/vike/ClientOnly.cjs.js +5 -14
- package/dist/vike/ClientOnly.cjs.js.map +1 -0
- package/dist/vike/ClientOnly.mjs +5 -14
- package/dist/vike/ClientOnly.mjs.map +1 -0
- package/dist/vike/{+config.js → config/+config.js} +10 -1
- package/dist/vike/config/+config.js.map +1 -0
- package/dist/vike/config/package.json +6 -0
- package/dist/vike/onRenderClient.cjs.js +166 -95
- package/dist/vike/onRenderClient.cjs.js.map +1 -0
- package/dist/vike/onRenderClient.mjs +166 -95
- package/dist/vike/onRenderClient.mjs.map +1 -0
- package/dist/vike/onRenderHtml.cjs.js +60 -24
- package/dist/vike/onRenderHtml.cjs.js.map +1 -0
- package/dist/vike/onRenderHtml.mjs +61 -25
- package/dist/vike/onRenderHtml.mjs.map +1 -0
- package/dist/vite/plugin.cjs.js +926 -65
- package/dist/vite/plugin.cjs.js.map +1 -0
- package/dist/vite/plugin.mjs +925 -65
- package/dist/vite/plugin.mjs.map +1 -0
- package/dist/zag.cjs.js +408 -0
- package/dist/zag.cjs.js.map +1 -0
- package/dist/zag.esm.js +405 -0
- package/dist/zag.esm.js.map +1 -0
- package/llms.txt +313 -0
- package/package.json +109 -16
- package/src/astro/client.ts +40 -18
- package/src/astro/index.d.ts +48 -1
- package/src/astro/index.ts +106 -9
- package/src/astro/server.ts +11 -3
- package/src/collection.ts +6 -90
- package/src/core/actions.ts +134 -0
- package/src/core/cell.ts +202 -0
- package/src/core/debug.ts +23 -0
- package/src/core/define.ts +242 -0
- package/src/core/hooks.ts +314 -0
- package/src/core/hosts/collection.ts +325 -0
- package/src/core/hosts/switchable.ts +146 -0
- package/src/core/instance.ts +592 -0
- package/src/core/markers/clientonly.ts +13 -0
- package/src/core/markers/lazy.ts +40 -0
- package/src/core/markers/portal.ts +96 -0
- package/src/core/markers/suspense.ts +41 -0
- package/src/core/markers/transition.ts +70 -0
- package/src/core/registry.ts +25 -0
- package/src/core/runtime.ts +573 -0
- package/src/core/statics.ts +104 -0
- package/src/core/teardown.ts +60 -0
- package/src/core/view.ts +37 -0
- package/src/cycle/dom/DocumentDOMSource.ts +13 -8
- package/src/cycle/dom/ElementFinder.ts +7 -9
- package/src/cycle/dom/EventDelegator.ts +174 -223
- package/src/cycle/dom/IsolateModule.ts +65 -35
- package/src/cycle/dom/MainDOMSource.ts +13 -2
- package/src/cycle/dom/PriorityQueue.ts +4 -2
- package/src/cycle/dom/SymbolTree.ts +18 -47
- package/src/cycle/dom/classNameModule.ts +76 -0
- package/src/cycle/dom/controlledInputModule.ts +50 -0
- package/src/cycle/dom/enrichEventStream.ts +29 -45
- package/src/cycle/dom/fragment.ts +7 -0
- package/src/cycle/dom/isolate.ts +30 -27
- package/src/cycle/dom/makeDOMDriver.ts +115 -57
- package/src/cycle/dom/mockDOMSource.ts +83 -9
- package/src/cycle/dom/modules.ts +21 -4
- package/src/cycle/dom/propsModule.ts +65 -0
- package/src/cycle/dom/selectModule.ts +22 -17
- package/src/cycle/dom/snabbdom.ts +1 -6
- package/src/cycle/dom/thunk.ts +3 -0
- package/src/cycle/dom/utils.ts +98 -0
- package/src/cycle/dom/viewTransition.ts +43 -0
- package/src/cycle/state/StateSource.ts +20 -4
- package/src/cycle/state/objIsEqual.ts +50 -0
- package/src/cycle/state/types.ts +0 -10
- package/src/defineComponent.ts +34 -0
- package/src/devtools.d.ts +151 -0
- package/src/devtools.ts +34 -0
- package/src/element.d.ts +59 -0
- package/src/element.ts +235 -0
- package/src/extra/backoff.ts +9 -0
- package/src/extra/behaviors.ts +169 -0
- package/src/extra/browserSignals.ts +23 -0
- package/src/extra/browserSources.ts +326 -0
- package/src/extra/command.ts +3 -3
- package/src/extra/controls.ts +47 -0
- package/src/extra/copyAsTest.ts +286 -0
- package/src/extra/devtools.ts +109 -31
- package/src/extra/devtoolsActions.ts +379 -0
- package/src/extra/devtoolsHook.ts +9 -0
- package/src/extra/devtoolsNext.ts +83 -0
- package/src/extra/diagnostics/checks/actionLog.ts +108 -0
- package/src/extra/diagnostics/checks/behaviors.ts +49 -0
- package/src/extra/diagnostics/checks/browserSources.ts +96 -0
- package/src/extra/diagnostics/checks/collections.ts +67 -0
- package/src/extra/diagnostics/checks/controls.ts +148 -0
- package/src/extra/diagnostics/checks/dataset.ts +57 -0
- package/src/extra/diagnostics/checks/dom.ts +250 -0
- package/src/extra/diagnostics/checks/elementCommands.ts +175 -0
- package/src/extra/diagnostics/checks/events.ts +83 -0
- package/src/extra/diagnostics/checks/fetch.ts +135 -0
- package/src/extra/diagnostics/checks/forms.ts +163 -0
- package/src/extra/diagnostics/checks/index.ts +202 -0
- package/src/extra/diagnostics/checks/inspect.ts +427 -0
- package/src/extra/diagnostics/checks/next.ts +417 -0
- package/src/extra/diagnostics/checks/persist.ts +54 -0
- package/src/extra/diagnostics/checks/props.ts +56 -0
- package/src/extra/diagnostics/checks/public.d.ts +302 -0
- package/src/extra/diagnostics/checks/replies.ts +128 -0
- package/src/extra/diagnostics/checks/router.ts +100 -0
- package/src/extra/diagnostics/checks/rxjsHints.ts +88 -0
- package/src/extra/diagnostics/checks/shared.ts +203 -0
- package/src/extra/diagnostics/checks/shorthand.ts +115 -0
- package/src/extra/diagnostics/checks/sortable.ts +129 -0
- package/src/extra/diagnostics/checks/state.ts +148 -0
- package/src/extra/diagnostics/checks/statics.ts +48 -0
- package/src/extra/diagnostics/checks/strict.ts +55 -0
- package/src/extra/diagnostics/checks/timers.ts +80 -0
- package/src/extra/diagnostics/checks/viewTransitions.ts +47 -0
- package/src/extra/diagnostics/checks/virtual.ts +73 -0
- package/src/extra/diagnostics/checks/widgets.ts +109 -0
- package/src/extra/diagnostics/checks/wiring.ts +121 -0
- package/src/extra/diagnostics/codes.ts +477 -0
- package/src/extra/diagnostics/index.ts +353 -0
- package/src/extra/diagnostics/legacy.ts +76 -0
- package/src/extra/driverFactories.ts +172 -60
- package/src/extra/elementCommands.ts +53 -0
- package/src/extra/eventDriver.ts +4 -0
- package/src/extra/fetchDriver.ts +519 -0
- package/src/extra/flatten.ts +75 -0
- package/src/extra/focusWithin.ts +27 -0
- package/src/extra/form.ts +268 -0
- package/src/extra/formHelpers.ts +139 -0
- package/src/extra/head.ts +106 -0
- package/src/extra/hmr.ts +2 -3
- package/src/extra/owned.ts +24 -0
- package/src/extra/pager.ts +50 -0
- package/src/extra/persist.ts +133 -0
- package/src/extra/pwa.ts +1 -1
- package/src/extra/queryCache.ts +107 -0
- package/src/extra/reducers.ts +13 -6
- package/src/extra/reduxDevtools.ts +92 -0
- package/src/extra/replies.ts +54 -0
- package/src/extra/router.ts +323 -0
- package/src/extra/run.ts +94 -210
- package/src/extra/selection.ts +76 -0
- package/src/extra/socketDriver.ts +265 -0
- package/src/extra/sortable.ts +377 -0
- package/src/extra/ssr.ts +427 -160
- package/src/extra/standardSchema.ts +27 -0
- package/src/extra/testing.ts +3158 -190
- package/src/extra/timers.ts +95 -0
- package/src/extra/undo.ts +261 -0
- package/src/extra/viewTransitions.ts +38 -0
- package/src/extra/virtual.ts +513 -0
- package/src/extra/widget.ts +201 -0
- package/src/extra/xstreamExtras.ts +269 -0
- package/src/index.d.ts +3012 -87
- package/src/index.ts +32 -10
- package/src/jsx-runtime.ts +15 -1
- package/src/jsx.ts +2 -1
- package/src/lazy.ts +50 -7
- package/src/portal.ts +3 -1
- package/src/pragma/index.ts +262 -134
- package/src/react-peers.d.ts +5 -0
- package/src/react.d.ts +43 -0
- package/src/react.ts +110 -0
- package/src/shared.ts +48 -0
- package/src/slot.ts +1 -1
- package/src/suspense.ts +3 -1
- package/src/switchable.ts +6 -119
- package/src/transition.ts +3 -1
- package/src/ui/accordion.ts +64 -0
- package/src/ui/dialog.ts +129 -0
- package/src/ui/disclosure.ts +35 -0
- package/src/ui/popover.ts +45 -0
- package/src/ui/shared.ts +94 -0
- package/src/ui/tabs.ts +82 -0
- package/src/ui/toaster.ts +198 -0
- package/src/ui/tooltip.ts +70 -0
- package/src/ui/zag/combobox.ts +115 -0
- package/src/ui/zag/menu.ts +40 -0
- package/src/ui/zag/select.ts +54 -0
- package/src/ui/zag/shared.ts +43 -0
- package/src/ui-combobox.d.ts +20 -0
- package/src/ui-combobox.ts +6 -0
- package/src/ui-menu.d.ts +30 -0
- package/src/ui-menu.ts +6 -0
- package/src/ui-select.d.ts +17 -0
- package/src/ui-select.ts +6 -0
- package/src/ui-zag-types.d.ts +42 -0
- package/src/ui.d.ts +208 -0
- package/src/ui.ts +15 -0
- package/src/vike/+config.ts +9 -1
- package/src/vike/ClientOnly.ts +1 -1
- package/src/vike/onRenderClient.ts +144 -96
- package/src/vike/onRenderHtml.ts +69 -26
- package/src/vike/types.ts +27 -4
- package/src/vite/globalthis-shim.ts +18 -0
- package/src/vite/globalthis.ts +56 -0
- package/src/vite/plugin.d.ts +114 -2
- package/src/vite/plugin.ts +920 -56
- package/src/zag.d.ts +64 -0
- package/src/zag.ts +238 -0
- package/dist/astro/astro/client.d.ts +0 -5
- package/dist/astro/astro/index.d.ts +0 -16
- package/dist/astro/astro/server.d.ts +0 -12
- package/dist/astro/client.d.ts +0 -5
- package/dist/astro/client.esm.js +0 -4665
- package/dist/astro/collection.d.ts +0 -12
- package/dist/astro/component.d.ts +0 -22
- package/dist/astro/cycle/dom/BodyDOMSource.d.ts +0 -10
- package/dist/astro/cycle/dom/DOMSource.d.ts +0 -11
- package/dist/astro/cycle/dom/DocumentDOMSource.d.ts +0 -12
- package/dist/astro/cycle/dom/ElementFinder.d.ts +0 -8
- package/dist/astro/cycle/dom/EventDelegator.d.ts +0 -34
- package/dist/astro/cycle/dom/IsolateModule.d.ts +0 -23
- package/dist/astro/cycle/dom/MainDOMSource.d.ts +0 -32
- package/dist/astro/cycle/dom/PriorityQueue.d.ts +0 -7
- package/dist/astro/cycle/dom/ScopeChecker.d.ts +0 -9
- package/dist/astro/cycle/dom/SymbolTree.d.ts +0 -9
- package/dist/astro/cycle/dom/VNodeWrapper.d.ts +0 -8
- package/dist/astro/cycle/dom/enrichEventStream.d.ts +0 -24
- package/dist/astro/cycle/dom/fromEvent.d.ts +0 -6
- package/dist/astro/cycle/dom/index.d.ts +0 -8
- package/dist/astro/cycle/dom/isolate.d.ts +0 -9
- package/dist/astro/cycle/dom/makeDOMDriver.d.ts +0 -11
- package/dist/astro/cycle/dom/mockDOMSource.d.ts +0 -17
- package/dist/astro/cycle/dom/modules.d.ts +0 -5
- package/dist/astro/cycle/dom/snabbdom.d.ts +0 -22
- package/dist/astro/cycle/dom/styleModule.d.ts +0 -13
- package/dist/astro/cycle/dom/thunk.d.ts +0 -11
- package/dist/astro/cycle/dom/utils.d.ts +0 -8
- package/dist/astro/cycle/isolate/index.d.ts +0 -42
- package/dist/astro/cycle/run/adapt.d.ts +0 -6
- package/dist/astro/cycle/run/index.d.ts +0 -36
- package/dist/astro/cycle/run/internals.d.ts +0 -8
- package/dist/astro/cycle/run/types.d.ts +0 -49
- package/dist/astro/cycle/state/Collection.d.ts +0 -29
- package/dist/astro/cycle/state/StateSource.d.ts +0 -20
- package/dist/astro/cycle/state/index.d.ts +0 -5
- package/dist/astro/cycle/state/pickCombine.d.ts +0 -3
- package/dist/astro/cycle/state/pickMerge.d.ts +0 -3
- package/dist/astro/cycle/state/types.d.ts +0 -18
- package/dist/astro/cycle/state/withState.d.ts +0 -17
- package/dist/astro/extra/classes.d.ts +0 -7
- package/dist/astro/extra/devtools.d.ts +0 -78
- package/dist/astro/extra/dragDriver.d.ts +0 -20
- package/dist/astro/extra/driverFactories.d.ts +0 -12
- package/dist/astro/extra/eventDriver.d.ts +0 -9
- package/dist/astro/extra/exactState.d.ts +0 -1
- package/dist/astro/extra/hmr.d.ts +0 -17
- package/dist/astro/extra/logDriver.d.ts +0 -2
- package/dist/astro/extra/processDrag.d.ts +0 -19
- package/dist/astro/extra/processForm.d.ts +0 -15
- package/dist/astro/extra/run.d.ts +0 -13
- package/dist/astro/extra/xstreamCompat.d.ts +0 -5
- package/dist/astro/index.d.ts +0 -19
- package/dist/astro/index.esm.js +0 -27
- package/dist/astro/jsx-dev-runtime.d.ts +0 -1
- package/dist/astro/jsx-runtime.d.ts +0 -4
- package/dist/astro/jsx.d.ts +0 -2
- package/dist/astro/pragma/fn.d.ts +0 -7
- package/dist/astro/pragma/index.d.ts +0 -7
- package/dist/astro/pragma/is.d.ts +0 -10
- package/dist/astro/server.d.ts +0 -12
- package/dist/astro/server.esm.js +0 -25
- package/dist/astro/switchable.d.ts +0 -7
- package/dist/collection.d.ts +0 -12
- package/dist/component.d.ts +0 -22
- package/dist/cycle/dom/BodyDOMSource.d.ts +0 -10
- package/dist/cycle/dom/DOMSource.d.ts +0 -11
- package/dist/cycle/dom/DocumentDOMSource.d.ts +0 -12
- package/dist/cycle/dom/ElementFinder.d.ts +0 -8
- package/dist/cycle/dom/EventDelegator.d.ts +0 -34
- package/dist/cycle/dom/IsolateModule.d.ts +0 -23
- package/dist/cycle/dom/MainDOMSource.d.ts +0 -32
- package/dist/cycle/dom/PriorityQueue.d.ts +0 -7
- package/dist/cycle/dom/ScopeChecker.d.ts +0 -9
- package/dist/cycle/dom/SymbolTree.d.ts +0 -9
- package/dist/cycle/dom/VNodeWrapper.d.ts +0 -8
- package/dist/cycle/dom/enrichEventStream.d.ts +0 -24
- package/dist/cycle/dom/fromEvent.d.ts +0 -6
- package/dist/cycle/dom/index.d.ts +0 -8
- package/dist/cycle/dom/isolate.d.ts +0 -9
- package/dist/cycle/dom/makeDOMDriver.d.ts +0 -11
- package/dist/cycle/dom/mockDOMSource.d.ts +0 -17
- package/dist/cycle/dom/modules.d.ts +0 -5
- package/dist/cycle/dom/snabbdom.d.ts +0 -22
- package/dist/cycle/dom/styleModule.d.ts +0 -13
- package/dist/cycle/dom/thunk.d.ts +0 -11
- package/dist/cycle/dom/utils.d.ts +0 -8
- package/dist/cycle/isolate/index.d.ts +0 -42
- package/dist/cycle/run/adapt.d.ts +0 -6
- package/dist/cycle/run/index.d.ts +0 -36
- package/dist/cycle/run/internals.d.ts +0 -8
- package/dist/cycle/run/types.d.ts +0 -49
- package/dist/cycle/state/Collection.d.ts +0 -29
- package/dist/cycle/state/StateSource.d.ts +0 -20
- package/dist/cycle/state/index.d.ts +0 -5
- package/dist/cycle/state/pickCombine.d.ts +0 -3
- package/dist/cycle/state/pickMerge.d.ts +0 -3
- package/dist/cycle/state/types.d.ts +0 -18
- package/dist/cycle/state/withState.d.ts +0 -17
- package/dist/extra/classes.d.ts +0 -7
- package/dist/extra/devtools.d.ts +0 -78
- package/dist/extra/dragDriver.d.ts +0 -20
- package/dist/extra/driverFactories.d.ts +0 -12
- package/dist/extra/eventDriver.d.ts +0 -9
- package/dist/extra/exactState.d.ts +0 -1
- package/dist/extra/hmr.d.ts +0 -17
- package/dist/extra/logDriver.d.ts +0 -2
- package/dist/extra/processDrag.d.ts +0 -19
- package/dist/extra/processForm.d.ts +0 -15
- package/dist/extra/run.d.ts +0 -13
- package/dist/extra/xstreamCompat.d.ts +0 -5
- package/dist/jsx-dev-runtime.d.ts +0 -1
- package/dist/jsx-dev-runtime.js +0 -224
- package/dist/jsx-runtime.d.ts +0 -4
- package/dist/jsx-runtime.js +0 -224
- package/dist/jsx.d.ts +0 -2
- package/dist/pragma/fn.d.ts +0 -7
- package/dist/pragma/index.d.ts +0 -7
- package/dist/pragma/is.d.ts +0 -10
- package/dist/switchable.d.ts +0 -7
- package/dist/vike/+config.cjs.js +0 -65
- package/src/component.ts +0 -2256
- package/src/cycle/isolate/index.ts +0 -196
- package/src/cycle/run/index.ts +0 -151
- package/src/cycle/run/internals.ts +0 -143
- package/src/cycle/state/Collection.ts +0 -174
- package/src/cycle/state/index.ts +0 -5
- package/src/cycle/state/pickCombine.ts +0 -167
- package/src/cycle/state/pickMerge.ts +0 -122
- package/src/cycle/state/withState.ts +0 -47
- package/src/pragma/fn.ts +0 -55
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var sygnal = require('sygnal');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* PLAN-4.5 G-275: marks an initial state that a wrapper built from its caller's values (an
|
|
7
|
+
* element's host props, Vike's pageContext.data or hydrated state, renderComponent's
|
|
8
|
+
* initialState option). The dev statics freeze (D152, checks/statics.ts) leaves a marked object
|
|
9
|
+
* and everything in it alone: the caller may still change those values. A non-enumerable symbol
|
|
10
|
+
* key: spreads, JSON and Object.keys don't see it.
|
|
11
|
+
*/
|
|
12
|
+
const OWNED = Symbol.for('sygnal.owned');
|
|
13
|
+
const owned = (v) => {
|
|
14
|
+
// G-289: an object that refuses the key (a Proxy) is returned as is
|
|
15
|
+
try {
|
|
16
|
+
if (v && typeof v == 'object' && Object.isExtensible(v))
|
|
17
|
+
Object.defineProperty(v, OWNED, { value: 1 });
|
|
18
|
+
}
|
|
19
|
+
catch { }
|
|
20
|
+
return v;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// 'sygnal/element' (PLAN-4 GS-13, D127): publish a Sygnal component as a custom element.
|
|
24
|
+
//
|
|
25
|
+
// defineElement('task-board', TaskBoard, {
|
|
26
|
+
// props: { title: String, tasks: Array, readonly: Boolean }, // or ['a', 'b'] (all String)
|
|
27
|
+
// events: { PARENT: 'task-picked' }, // sink name → CustomEvent name
|
|
28
|
+
// shadow: true, // true | 'open' | 'closed'
|
|
29
|
+
// styles: '.title { color: green }', // string | CSSStyleSheet | array
|
|
30
|
+
// })
|
|
31
|
+
//
|
|
32
|
+
// Each connected element is its own app: run(Component) mounted on a div inside the element
|
|
33
|
+
// (or its shadow root). Props are in state from the first render (the component's
|
|
34
|
+
// initialState, overlaid with the props); later property/attribute changes are merged into
|
|
35
|
+
// state. Sinks listed in `events` are dispatched as CustomEvents (bubbles + composed; the
|
|
36
|
+
// PARENT wrapper is unwrapped to its value). Removing the element disposes the app; a move
|
|
37
|
+
// (disconnect + connect in the same task) keeps it running. Calling defineElement again for
|
|
38
|
+
// the same tag (HMR) swaps the component in every live element, keeping each one's state.
|
|
39
|
+
//
|
|
40
|
+
// Separate entry: rollup rewrites './index' to the external 'sygnal' (0 B in the core bundle).
|
|
41
|
+
// Sinks that are the app's own drivers, never events
|
|
42
|
+
const RESERVED_SINKS = ['DOM', 'STATE', 'EVENTS'];
|
|
43
|
+
// Hot-swap functions of the tags this module defined
|
|
44
|
+
const swaps = new WeakMap();
|
|
45
|
+
const kebab = (name) => name.replace(/[A-Z]/g, (c) => '-' + c.toLowerCase());
|
|
46
|
+
function parseAttribute(type, value) {
|
|
47
|
+
if (type === Boolean)
|
|
48
|
+
return value !== null;
|
|
49
|
+
if (value === null)
|
|
50
|
+
return undefined;
|
|
51
|
+
if (type === Number)
|
|
52
|
+
return Number(value);
|
|
53
|
+
if (type === String)
|
|
54
|
+
return value;
|
|
55
|
+
return JSON.parse(value); // Object, Array (throws on bad JSON)
|
|
56
|
+
}
|
|
57
|
+
function toSheet(style) {
|
|
58
|
+
if (typeof style !== 'string')
|
|
59
|
+
return style;
|
|
60
|
+
const sheet = new CSSStyleSheet();
|
|
61
|
+
sheet.replaceSync(style);
|
|
62
|
+
return sheet;
|
|
63
|
+
}
|
|
64
|
+
const devMode = () => globalThis.__SYGNAL_DEV__ === true;
|
|
65
|
+
function defineElement(tag, Component, options = {}) {
|
|
66
|
+
const prior = customElements.get(tag);
|
|
67
|
+
const swap = prior && swaps.get(prior);
|
|
68
|
+
if (swap) {
|
|
69
|
+
swap(Component); // HMR: the defining module ran again
|
|
70
|
+
return prior;
|
|
71
|
+
}
|
|
72
|
+
if (typeof Component !== 'function') {
|
|
73
|
+
throw new TypeError(`defineElement('${tag}'): pass a function component`);
|
|
74
|
+
}
|
|
75
|
+
const types = Array.isArray(options.props)
|
|
76
|
+
? Object.fromEntries(options.props.map((name) => [name, String]))
|
|
77
|
+
: { ...options.props };
|
|
78
|
+
const propOfAttribute = Object.fromEntries(Object.keys(types).map((name) => [kebab(name), name]));
|
|
79
|
+
const events = { ...options.events };
|
|
80
|
+
for (const sink of RESERVED_SINKS) {
|
|
81
|
+
if (sink in events)
|
|
82
|
+
throw new TypeError(`defineElement('${tag}'): '${sink}' is a driver of the element's app, not an event sink`);
|
|
83
|
+
}
|
|
84
|
+
const shadowMode = options.shadow ? (options.shadow === 'closed' ? 'closed' : 'open') : undefined;
|
|
85
|
+
const sheets = shadowMode ? [].concat(options.styles || []).map(toSheet) : [];
|
|
86
|
+
// Props that hide a member of HTMLElement (e.g. title, hidden): SYG644 once per tag (D131)
|
|
87
|
+
const shadowedMembers = Object.keys(types).filter((name) => name in HTMLElement.prototype);
|
|
88
|
+
let warned = false;
|
|
89
|
+
const live = new Set();
|
|
90
|
+
let instances = 0;
|
|
91
|
+
class SygnalElement extends HTMLElement {
|
|
92
|
+
static observedAttributes = Object.keys(propOfAttribute);
|
|
93
|
+
#props = {};
|
|
94
|
+
#app = undefined;
|
|
95
|
+
#root = this;
|
|
96
|
+
#uid = `${tag}-${++instances}`;
|
|
97
|
+
static {
|
|
98
|
+
for (const name of Object.keys(types)) {
|
|
99
|
+
Object.defineProperty(this.prototype, name, {
|
|
100
|
+
configurable: true,
|
|
101
|
+
enumerable: true,
|
|
102
|
+
get() {
|
|
103
|
+
return this.#props[name];
|
|
104
|
+
},
|
|
105
|
+
set(value) {
|
|
106
|
+
this.#setProp(name, value);
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
swaps.set(this, (Next) => {
|
|
111
|
+
Component = Next;
|
|
112
|
+
live.forEach((element) => element.#swap());
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
constructor() {
|
|
116
|
+
super();
|
|
117
|
+
if (shadowMode) {
|
|
118
|
+
const root = this.attachShadow({ mode: shadowMode });
|
|
119
|
+
root.adoptedStyleSheets = sheets;
|
|
120
|
+
this.#root = root;
|
|
121
|
+
}
|
|
122
|
+
// Properties set before the tag was defined are own properties that hide the
|
|
123
|
+
// accessors: move them onto the accessors
|
|
124
|
+
for (const name of Object.keys(types)) {
|
|
125
|
+
if (Object.prototype.hasOwnProperty.call(this, name)) {
|
|
126
|
+
const value = this[name];
|
|
127
|
+
delete this[name];
|
|
128
|
+
this.#setProp(name, value);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
attributeChangedCallback(attribute, _old, value) {
|
|
133
|
+
const name = propOfAttribute[attribute];
|
|
134
|
+
try {
|
|
135
|
+
this.#setProp(name, parseAttribute(types[name], value));
|
|
136
|
+
}
|
|
137
|
+
catch (_) {
|
|
138
|
+
// bad JSON in an Object/Array attribute: keep the previous value
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
connectedCallback() {
|
|
142
|
+
if (this.#app)
|
|
143
|
+
return; // moved, not removed: keep running
|
|
144
|
+
// (G-216: a hot swap elsewhere on the page is that app's own, so no need to wait it out)
|
|
145
|
+
if (shadowedMembers.length && !warned) {
|
|
146
|
+
// D131: SYG644 through the diagnostics core when diagnostics are on; else a console
|
|
147
|
+
// warning in dev
|
|
148
|
+
const message = `props hide the HTMLElement members of the same name (${shadowedMembers.join(', ')})`;
|
|
149
|
+
const fix = 'Rename them to keep the native behaviour';
|
|
150
|
+
let reported;
|
|
151
|
+
try {
|
|
152
|
+
reported = globalThis.__SYGNAL_DIAGNOSTICS__?.report('SYG644', {
|
|
153
|
+
severity: 'warn', component: `<${tag}>`, message, fix, data: { tag, members: shadowedMembers },
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
catch (e) {
|
|
157
|
+
reported = true; // mode 'error': thrown after the element starts
|
|
158
|
+
queueMicrotask(() => { throw e; });
|
|
159
|
+
}
|
|
160
|
+
if (reported || devMode())
|
|
161
|
+
warned = true;
|
|
162
|
+
if (!reported && devMode())
|
|
163
|
+
console.warn(`[sygnal/element] <${tag}>: ${message}. ${fix}.`);
|
|
164
|
+
}
|
|
165
|
+
const mount = document.createElement('div');
|
|
166
|
+
this.#root.appendChild(mount);
|
|
167
|
+
this.#app = sygnal.run(this.#component(), this.#eventDrivers(), { mountPoint: mount, uid: this.#uid });
|
|
168
|
+
this.#releaseDevtools();
|
|
169
|
+
live.add(this);
|
|
170
|
+
}
|
|
171
|
+
disconnectedCallback() {
|
|
172
|
+
// Deferred: a move is a disconnect + connect in the same task
|
|
173
|
+
queueMicrotask(() => {
|
|
174
|
+
if (this.isConnected || !this.#app)
|
|
175
|
+
return;
|
|
176
|
+
this.#app.dispose();
|
|
177
|
+
this.#app = undefined;
|
|
178
|
+
live.delete(this);
|
|
179
|
+
this.#root.replaceChildren();
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
// Hot swap (defineElement again for this tag): the new component, this element's state
|
|
183
|
+
#swap() {
|
|
184
|
+
if (!this.#app)
|
|
185
|
+
return;
|
|
186
|
+
// (the state through the runtime API, 04 §3.9)
|
|
187
|
+
this.#app.hmr(this.#component(), this.#app.__runtime.getState());
|
|
188
|
+
this.#releaseDevtools();
|
|
189
|
+
}
|
|
190
|
+
#setProp(name, value) {
|
|
191
|
+
this.#props[name] = value;
|
|
192
|
+
const set = (state) => ({ ...state, [name]: value });
|
|
193
|
+
this.#app?.__runtime?.setState('root', set);
|
|
194
|
+
}
|
|
195
|
+
// A per-instance copy of the component whose initialState includes the current props
|
|
196
|
+
// (owned: the dev statics freeze leaves the host's values alone, G-275)
|
|
197
|
+
#component() {
|
|
198
|
+
const wrapped = Object.assign((...args) => Component(...args), Component, {
|
|
199
|
+
initialState: owned({ ...Component.initialState, ...this.#props }),
|
|
200
|
+
});
|
|
201
|
+
return Object.defineProperty(wrapped, 'name', { value: Component.name || tag });
|
|
202
|
+
}
|
|
203
|
+
#eventDrivers() {
|
|
204
|
+
return Object.fromEntries(Object.entries(events).map(([sink, eventName]) => [
|
|
205
|
+
sink,
|
|
206
|
+
(sink$) => {
|
|
207
|
+
sink$.addListener({
|
|
208
|
+
next: (value) => {
|
|
209
|
+
// PARENT values arrive wrapped as { name, component, value }
|
|
210
|
+
const detail = sink === 'PARENT' ? value?.value : value;
|
|
211
|
+
this.dispatchEvent(new CustomEvent(eventName, { detail, bubbles: true, composed: true }));
|
|
212
|
+
},
|
|
213
|
+
});
|
|
214
|
+
},
|
|
215
|
+
]));
|
|
216
|
+
}
|
|
217
|
+
// run() registers the first live app for DevTools time travel (G-212). An element gives
|
|
218
|
+
// the slot back, so a host app that starts later gets it
|
|
219
|
+
#releaseDevtools() {
|
|
220
|
+
const w = window;
|
|
221
|
+
if (w.__SYGNAL_DEVTOOLS_APP__ === this.#app || w.__SYGNAL_DEVTOOLS_APP__?.sinks === this.#app.sinks)
|
|
222
|
+
w.__SYGNAL_DEVTOOLS_APP__ = undefined;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
customElements.define(tag, SygnalElement);
|
|
226
|
+
return SygnalElement;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
exports.defineElement = defineElement;
|
|
230
|
+
//# sourceMappingURL=element.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element.cjs.js","sources":["../src/extra/owned.ts","../src/element.ts"],"sourcesContent":["/**\n * PLAN-4.5 G-275: marks an initial state that a wrapper built from its caller's values (an\n * element's host props, Vike's pageContext.data or hydrated state, renderComponent's\n * initialState option). The dev statics freeze (D152, checks/statics.ts) leaves a marked object\n * and everything in it alone: the caller may still change those values. A non-enumerable symbol\n * key: spreads, JSON and Object.keys don't see it.\n */\nexport const OWNED = Symbol.for('sygnal.owned')\n\nexport const owned = <T>(v: T): T => {\n // G-289: an object that refuses the key (a Proxy) is returned as is\n try { if (v && typeof v == 'object' && Object.isExtensible(v)) Object.defineProperty(v, OWNED, {value: 1}) } catch {}\n return v\n}\n\n/**\n * G-289: owned() of a shallow copy of a plain object or array (the caller's own object stays\n * unmarked: it may be a component's static, which the freeze must still cover, or sealed, which\n * can't be marked); anything else as owned()\n */\nexport const ownedCopy = <T>(v: T): T => {\n const p = v && typeof v == 'object' ? Object.getPrototypeOf(v) : 0\n return owned(Array.isArray(v) ? [...v] as any : p == Object.prototype || p === null ? {...v} : v)\n}\n","// 'sygnal/element' (PLAN-4 GS-13, D127): publish a Sygnal component as a custom element.\n//\n// defineElement('task-board', TaskBoard, {\n// props: { title: String, tasks: Array, readonly: Boolean }, // or ['a', 'b'] (all String)\n// events: { PARENT: 'task-picked' }, // sink name → CustomEvent name\n// shadow: true, // true | 'open' | 'closed'\n// styles: '.title { color: green }', // string | CSSStyleSheet | array\n// })\n//\n// Each connected element is its own app: run(Component) mounted on a div inside the element\n// (or its shadow root). Props are in state from the first render (the component's\n// initialState, overlaid with the props); later property/attribute changes are merged into\n// state. Sinks listed in `events` are dispatched as CustomEvents (bubbles + composed; the\n// PARENT wrapper is unwrapped to its value). Removing the element disposes the app; a move\n// (disconnect + connect in the same task) keeps it running. Calling defineElement again for\n// the same tag (HMR) swaps the component in every live element, keeping each one's state.\n//\n// Separate entry: rollup rewrites './index' to the external 'sygnal' (0 B in the core bundle).\nimport {run} from './index';\nimport {owned} from './extra/owned';\n\nexport type ElementPropType =\n | StringConstructor\n | NumberConstructor\n | BooleanConstructor\n | ObjectConstructor\n | ArrayConstructor;\n\nexport interface ElementOptions {\n /** Properties fed into state (camelCase; the attribute is kebab-case). An array means all String. */\n props?: readonly string[] | Record<string, ElementPropType>;\n /** Sink name → CustomEvent name, e.g. { PARENT: 'task-picked' } */\n events?: Record<string, string>;\n /** Render into a shadow root (true = 'open') */\n shadow?: boolean | 'open' | 'closed';\n /** Adopted into the shadow root, shared by every instance (ignored without shadow) */\n styles?: string | CSSStyleSheet | Array<string | CSSStyleSheet>;\n}\n\n// Sinks that are the app's own drivers, never events\nconst RESERVED_SINKS = ['DOM', 'STATE', 'EVENTS'];\n\n// Hot-swap functions of the tags this module defined\nconst swaps = new WeakMap<CustomElementConstructor, (Component: any) => void>();\n\nconst kebab = (name: string) => name.replace(/[A-Z]/g, (c) => '-' + c.toLowerCase());\n\nfunction parseAttribute(type: ElementPropType, value: string | null): any {\n if (type === Boolean) return value !== null;\n if (value === null) return undefined;\n if (type === Number) return Number(value);\n if (type === String) return value;\n return JSON.parse(value); // Object, Array (throws on bad JSON)\n}\n\nfunction toSheet(style: string | CSSStyleSheet): CSSStyleSheet {\n if (typeof style !== 'string') return style;\n const sheet = new CSSStyleSheet();\n sheet.replaceSync(style);\n return sheet;\n}\n\nconst devMode = () => (globalThis as any).__SYGNAL_DEV__ === true;\n\nexport function defineElement(tag: string, Component: any, options: ElementOptions = {}): CustomElementConstructor {\n const prior = customElements.get(tag);\n const swap = prior && swaps.get(prior);\n if (swap) {\n swap(Component); // HMR: the defining module ran again\n return prior!;\n }\n if (typeof Component !== 'function') {\n throw new TypeError(`defineElement('${tag}'): pass a function component`);\n }\n\n const types: Record<string, ElementPropType> = Array.isArray(options.props)\n ? Object.fromEntries(options.props.map((name: string) => [name, String]))\n : {...(options.props as Record<string, ElementPropType> | undefined)};\n const propOfAttribute: Record<string, string> = Object.fromEntries(Object.keys(types).map((name) => [kebab(name), name]));\n const events = {...options.events};\n for (const sink of RESERVED_SINKS) {\n if (sink in events) throw new TypeError(`defineElement('${tag}'): '${sink}' is a driver of the element's app, not an event sink`);\n }\n const shadowMode = options.shadow ? (options.shadow === 'closed' ? 'closed' : 'open') : undefined;\n const sheets = shadowMode ? ([] as Array<string | CSSStyleSheet>).concat(options.styles || []).map(toSheet) : [];\n // Props that hide a member of HTMLElement (e.g. title, hidden): SYG644 once per tag (D131)\n const shadowedMembers = Object.keys(types).filter((name) => name in HTMLElement.prototype);\n let warned = false;\n\n const live = new Set<SygnalElement>();\n let instances = 0;\n\n class SygnalElement extends HTMLElement {\n static observedAttributes = Object.keys(propOfAttribute);\n\n #props: Record<string, any> = {};\n #app: any = undefined;\n #root: HTMLElement | ShadowRoot = this;\n #uid = `${tag}-${++instances}`;\n\n static {\n for (const name of Object.keys(types)) {\n Object.defineProperty(this.prototype, name, {\n configurable: true,\n enumerable: true,\n get(this: SygnalElement) {\n return this.#props[name];\n },\n set(this: SygnalElement, value: any) {\n this.#setProp(name, value);\n },\n });\n }\n swaps.set(this, (Next: any) => {\n Component = Next;\n live.forEach((element) => element.#swap());\n });\n }\n\n constructor() {\n super();\n if (shadowMode) {\n const root = this.attachShadow({mode: shadowMode});\n root.adoptedStyleSheets = sheets;\n this.#root = root;\n }\n // Properties set before the tag was defined are own properties that hide the\n // accessors: move them onto the accessors\n for (const name of Object.keys(types)) {\n if (Object.prototype.hasOwnProperty.call(this, name)) {\n const value = (this as any)[name];\n delete (this as any)[name];\n this.#setProp(name, value);\n }\n }\n }\n\n attributeChangedCallback(attribute: string, _old: string | null, value: string | null) {\n const name = propOfAttribute[attribute];\n try {\n this.#setProp(name, parseAttribute(types[name], value));\n } catch (_) {\n // bad JSON in an Object/Array attribute: keep the previous value\n }\n }\n\n connectedCallback() {\n if (this.#app) return; // moved, not removed: keep running\n // (G-216: a hot swap elsewhere on the page is that app's own, so no need to wait it out)\n if (shadowedMembers.length && !warned) {\n // D131: SYG644 through the diagnostics core when diagnostics are on; else a console\n // warning in dev\n const message = `props hide the HTMLElement members of the same name (${shadowedMembers.join(', ')})`;\n const fix = 'Rename them to keep the native behaviour';\n let reported: any;\n try {\n reported = (globalThis as any).__SYGNAL_DIAGNOSTICS__?.report('SYG644', {\n severity: 'warn', component: `<${tag}>`, message, fix, data: {tag, members: shadowedMembers},\n });\n } catch (e) {\n reported = true; // mode 'error': thrown after the element starts\n queueMicrotask(() => { throw e; });\n }\n if (reported || devMode()) warned = true;\n if (!reported && devMode()) console.warn(`[sygnal/element] <${tag}>: ${message}. ${fix}.`);\n }\n const mount = document.createElement('div');\n this.#root.appendChild(mount);\n this.#app = run(this.#component(), this.#eventDrivers(), {mountPoint: mount as any, uid: this.#uid});\n this.#releaseDevtools();\n live.add(this);\n }\n\n disconnectedCallback() {\n // Deferred: a move is a disconnect + connect in the same task\n queueMicrotask(() => {\n if (this.isConnected || !this.#app) return;\n this.#app.dispose();\n this.#app = undefined;\n live.delete(this);\n this.#root.replaceChildren();\n });\n }\n\n // Hot swap (defineElement again for this tag): the new component, this element's state\n #swap() {\n if (!this.#app) return;\n // (the state through the runtime API, 04 §3.9)\n this.#app.hmr(this.#component(), (this.#app as any).__runtime.getState());\n this.#releaseDevtools();\n }\n\n #setProp(name: string, value: any) {\n this.#props[name] = value;\n const set = (state: any) => ({...state, [name]: value});\n (this.#app as any)?.__runtime?.setState('root', set);\n }\n\n // A per-instance copy of the component whose initialState includes the current props\n // (owned: the dev statics freeze leaves the host's values alone, G-275)\n #component() {\n const wrapped = Object.assign((...args: any[]) => Component(...args), Component, {\n initialState: owned({...Component.initialState, ...this.#props}),\n });\n return Object.defineProperty(wrapped, 'name', {value: Component.name || tag});\n }\n\n #eventDrivers() {\n return Object.fromEntries(\n Object.entries(events).map(([sink, eventName]) => [\n sink,\n (sink$: any) => {\n sink$.addListener({\n next: (value: any) => {\n // PARENT values arrive wrapped as { name, component, value }\n const detail = sink === 'PARENT' ? value?.value : value;\n this.dispatchEvent(new CustomEvent(eventName, {detail, bubbles: true, composed: true}));\n },\n });\n },\n ])\n );\n }\n\n // run() registers the first live app for DevTools time travel (G-212). An element gives\n // the slot back, so a host app that starts later gets it\n #releaseDevtools() {\n const w = window as any;\n if (w.__SYGNAL_DEVTOOLS_APP__ === this.#app || w.__SYGNAL_DEVTOOLS_APP__?.sinks === this.#app.sinks) w.__SYGNAL_DEVTOOLS_APP__ = undefined;\n }\n }\n\n customElements.define(tag, SygnalElement);\n return SygnalElement;\n}\n"],"names":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AAAE,gBAAA,CAAC,CAAC,uBAAuB,GAAG,SAAS,CAAC;SAC5I;;AAGH,IAAA,cAAc,CAAC,MAAM,CAAC,GAAG,EAAE,aAAa,CAAC,CAAC;AAC1C,IAAA,OAAO,aAAa,CAAC;AACvB;;;;"}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { run } from 'sygnal';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* PLAN-4.5 G-275: marks an initial state that a wrapper built from its caller's values (an
|
|
5
|
+
* element's host props, Vike's pageContext.data or hydrated state, renderComponent's
|
|
6
|
+
* initialState option). The dev statics freeze (D152, checks/statics.ts) leaves a marked object
|
|
7
|
+
* and everything in it alone: the caller may still change those values. A non-enumerable symbol
|
|
8
|
+
* key: spreads, JSON and Object.keys don't see it.
|
|
9
|
+
*/
|
|
10
|
+
const OWNED = Symbol.for('sygnal.owned');
|
|
11
|
+
const owned = (v) => {
|
|
12
|
+
// G-289: an object that refuses the key (a Proxy) is returned as is
|
|
13
|
+
try {
|
|
14
|
+
if (v && typeof v == 'object' && Object.isExtensible(v))
|
|
15
|
+
Object.defineProperty(v, OWNED, { value: 1 });
|
|
16
|
+
}
|
|
17
|
+
catch { }
|
|
18
|
+
return v;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// 'sygnal/element' (PLAN-4 GS-13, D127): publish a Sygnal component as a custom element.
|
|
22
|
+
//
|
|
23
|
+
// defineElement('task-board', TaskBoard, {
|
|
24
|
+
// props: { title: String, tasks: Array, readonly: Boolean }, // or ['a', 'b'] (all String)
|
|
25
|
+
// events: { PARENT: 'task-picked' }, // sink name → CustomEvent name
|
|
26
|
+
// shadow: true, // true | 'open' | 'closed'
|
|
27
|
+
// styles: '.title { color: green }', // string | CSSStyleSheet | array
|
|
28
|
+
// })
|
|
29
|
+
//
|
|
30
|
+
// Each connected element is its own app: run(Component) mounted on a div inside the element
|
|
31
|
+
// (or its shadow root). Props are in state from the first render (the component's
|
|
32
|
+
// initialState, overlaid with the props); later property/attribute changes are merged into
|
|
33
|
+
// state. Sinks listed in `events` are dispatched as CustomEvents (bubbles + composed; the
|
|
34
|
+
// PARENT wrapper is unwrapped to its value). Removing the element disposes the app; a move
|
|
35
|
+
// (disconnect + connect in the same task) keeps it running. Calling defineElement again for
|
|
36
|
+
// the same tag (HMR) swaps the component in every live element, keeping each one's state.
|
|
37
|
+
//
|
|
38
|
+
// Separate entry: rollup rewrites './index' to the external 'sygnal' (0 B in the core bundle).
|
|
39
|
+
// Sinks that are the app's own drivers, never events
|
|
40
|
+
const RESERVED_SINKS = ['DOM', 'STATE', 'EVENTS'];
|
|
41
|
+
// Hot-swap functions of the tags this module defined
|
|
42
|
+
const swaps = new WeakMap();
|
|
43
|
+
const kebab = (name) => name.replace(/[A-Z]/g, (c) => '-' + c.toLowerCase());
|
|
44
|
+
function parseAttribute(type, value) {
|
|
45
|
+
if (type === Boolean)
|
|
46
|
+
return value !== null;
|
|
47
|
+
if (value === null)
|
|
48
|
+
return undefined;
|
|
49
|
+
if (type === Number)
|
|
50
|
+
return Number(value);
|
|
51
|
+
if (type === String)
|
|
52
|
+
return value;
|
|
53
|
+
return JSON.parse(value); // Object, Array (throws on bad JSON)
|
|
54
|
+
}
|
|
55
|
+
function toSheet(style) {
|
|
56
|
+
if (typeof style !== 'string')
|
|
57
|
+
return style;
|
|
58
|
+
const sheet = new CSSStyleSheet();
|
|
59
|
+
sheet.replaceSync(style);
|
|
60
|
+
return sheet;
|
|
61
|
+
}
|
|
62
|
+
const devMode = () => globalThis.__SYGNAL_DEV__ === true;
|
|
63
|
+
function defineElement(tag, Component, options = {}) {
|
|
64
|
+
const prior = customElements.get(tag);
|
|
65
|
+
const swap = prior && swaps.get(prior);
|
|
66
|
+
if (swap) {
|
|
67
|
+
swap(Component); // HMR: the defining module ran again
|
|
68
|
+
return prior;
|
|
69
|
+
}
|
|
70
|
+
if (typeof Component !== 'function') {
|
|
71
|
+
throw new TypeError(`defineElement('${tag}'): pass a function component`);
|
|
72
|
+
}
|
|
73
|
+
const types = Array.isArray(options.props)
|
|
74
|
+
? Object.fromEntries(options.props.map((name) => [name, String]))
|
|
75
|
+
: { ...options.props };
|
|
76
|
+
const propOfAttribute = Object.fromEntries(Object.keys(types).map((name) => [kebab(name), name]));
|
|
77
|
+
const events = { ...options.events };
|
|
78
|
+
for (const sink of RESERVED_SINKS) {
|
|
79
|
+
if (sink in events)
|
|
80
|
+
throw new TypeError(`defineElement('${tag}'): '${sink}' is a driver of the element's app, not an event sink`);
|
|
81
|
+
}
|
|
82
|
+
const shadowMode = options.shadow ? (options.shadow === 'closed' ? 'closed' : 'open') : undefined;
|
|
83
|
+
const sheets = shadowMode ? [].concat(options.styles || []).map(toSheet) : [];
|
|
84
|
+
// Props that hide a member of HTMLElement (e.g. title, hidden): SYG644 once per tag (D131)
|
|
85
|
+
const shadowedMembers = Object.keys(types).filter((name) => name in HTMLElement.prototype);
|
|
86
|
+
let warned = false;
|
|
87
|
+
const live = new Set();
|
|
88
|
+
let instances = 0;
|
|
89
|
+
class SygnalElement extends HTMLElement {
|
|
90
|
+
static observedAttributes = Object.keys(propOfAttribute);
|
|
91
|
+
#props = {};
|
|
92
|
+
#app = undefined;
|
|
93
|
+
#root = this;
|
|
94
|
+
#uid = `${tag}-${++instances}`;
|
|
95
|
+
static {
|
|
96
|
+
for (const name of Object.keys(types)) {
|
|
97
|
+
Object.defineProperty(this.prototype, name, {
|
|
98
|
+
configurable: true,
|
|
99
|
+
enumerable: true,
|
|
100
|
+
get() {
|
|
101
|
+
return this.#props[name];
|
|
102
|
+
},
|
|
103
|
+
set(value) {
|
|
104
|
+
this.#setProp(name, value);
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
swaps.set(this, (Next) => {
|
|
109
|
+
Component = Next;
|
|
110
|
+
live.forEach((element) => element.#swap());
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
constructor() {
|
|
114
|
+
super();
|
|
115
|
+
if (shadowMode) {
|
|
116
|
+
const root = this.attachShadow({ mode: shadowMode });
|
|
117
|
+
root.adoptedStyleSheets = sheets;
|
|
118
|
+
this.#root = root;
|
|
119
|
+
}
|
|
120
|
+
// Properties set before the tag was defined are own properties that hide the
|
|
121
|
+
// accessors: move them onto the accessors
|
|
122
|
+
for (const name of Object.keys(types)) {
|
|
123
|
+
if (Object.prototype.hasOwnProperty.call(this, name)) {
|
|
124
|
+
const value = this[name];
|
|
125
|
+
delete this[name];
|
|
126
|
+
this.#setProp(name, value);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
attributeChangedCallback(attribute, _old, value) {
|
|
131
|
+
const name = propOfAttribute[attribute];
|
|
132
|
+
try {
|
|
133
|
+
this.#setProp(name, parseAttribute(types[name], value));
|
|
134
|
+
}
|
|
135
|
+
catch (_) {
|
|
136
|
+
// bad JSON in an Object/Array attribute: keep the previous value
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
connectedCallback() {
|
|
140
|
+
if (this.#app)
|
|
141
|
+
return; // moved, not removed: keep running
|
|
142
|
+
// (G-216: a hot swap elsewhere on the page is that app's own, so no need to wait it out)
|
|
143
|
+
if (shadowedMembers.length && !warned) {
|
|
144
|
+
// D131: SYG644 through the diagnostics core when diagnostics are on; else a console
|
|
145
|
+
// warning in dev
|
|
146
|
+
const message = `props hide the HTMLElement members of the same name (${shadowedMembers.join(', ')})`;
|
|
147
|
+
const fix = 'Rename them to keep the native behaviour';
|
|
148
|
+
let reported;
|
|
149
|
+
try {
|
|
150
|
+
reported = globalThis.__SYGNAL_DIAGNOSTICS__?.report('SYG644', {
|
|
151
|
+
severity: 'warn', component: `<${tag}>`, message, fix, data: { tag, members: shadowedMembers },
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
catch (e) {
|
|
155
|
+
reported = true; // mode 'error': thrown after the element starts
|
|
156
|
+
queueMicrotask(() => { throw e; });
|
|
157
|
+
}
|
|
158
|
+
if (reported || devMode())
|
|
159
|
+
warned = true;
|
|
160
|
+
if (!reported && devMode())
|
|
161
|
+
console.warn(`[sygnal/element] <${tag}>: ${message}. ${fix}.`);
|
|
162
|
+
}
|
|
163
|
+
const mount = document.createElement('div');
|
|
164
|
+
this.#root.appendChild(mount);
|
|
165
|
+
this.#app = run(this.#component(), this.#eventDrivers(), { mountPoint: mount, uid: this.#uid });
|
|
166
|
+
this.#releaseDevtools();
|
|
167
|
+
live.add(this);
|
|
168
|
+
}
|
|
169
|
+
disconnectedCallback() {
|
|
170
|
+
// Deferred: a move is a disconnect + connect in the same task
|
|
171
|
+
queueMicrotask(() => {
|
|
172
|
+
if (this.isConnected || !this.#app)
|
|
173
|
+
return;
|
|
174
|
+
this.#app.dispose();
|
|
175
|
+
this.#app = undefined;
|
|
176
|
+
live.delete(this);
|
|
177
|
+
this.#root.replaceChildren();
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
// Hot swap (defineElement again for this tag): the new component, this element's state
|
|
181
|
+
#swap() {
|
|
182
|
+
if (!this.#app)
|
|
183
|
+
return;
|
|
184
|
+
// (the state through the runtime API, 04 §3.9)
|
|
185
|
+
this.#app.hmr(this.#component(), this.#app.__runtime.getState());
|
|
186
|
+
this.#releaseDevtools();
|
|
187
|
+
}
|
|
188
|
+
#setProp(name, value) {
|
|
189
|
+
this.#props[name] = value;
|
|
190
|
+
const set = (state) => ({ ...state, [name]: value });
|
|
191
|
+
this.#app?.__runtime?.setState('root', set);
|
|
192
|
+
}
|
|
193
|
+
// A per-instance copy of the component whose initialState includes the current props
|
|
194
|
+
// (owned: the dev statics freeze leaves the host's values alone, G-275)
|
|
195
|
+
#component() {
|
|
196
|
+
const wrapped = Object.assign((...args) => Component(...args), Component, {
|
|
197
|
+
initialState: owned({ ...Component.initialState, ...this.#props }),
|
|
198
|
+
});
|
|
199
|
+
return Object.defineProperty(wrapped, 'name', { value: Component.name || tag });
|
|
200
|
+
}
|
|
201
|
+
#eventDrivers() {
|
|
202
|
+
return Object.fromEntries(Object.entries(events).map(([sink, eventName]) => [
|
|
203
|
+
sink,
|
|
204
|
+
(sink$) => {
|
|
205
|
+
sink$.addListener({
|
|
206
|
+
next: (value) => {
|
|
207
|
+
// PARENT values arrive wrapped as { name, component, value }
|
|
208
|
+
const detail = sink === 'PARENT' ? value?.value : value;
|
|
209
|
+
this.dispatchEvent(new CustomEvent(eventName, { detail, bubbles: true, composed: true }));
|
|
210
|
+
},
|
|
211
|
+
});
|
|
212
|
+
},
|
|
213
|
+
]));
|
|
214
|
+
}
|
|
215
|
+
// run() registers the first live app for DevTools time travel (G-212). An element gives
|
|
216
|
+
// the slot back, so a host app that starts later gets it
|
|
217
|
+
#releaseDevtools() {
|
|
218
|
+
const w = window;
|
|
219
|
+
if (w.__SYGNAL_DEVTOOLS_APP__ === this.#app || w.__SYGNAL_DEVTOOLS_APP__?.sinks === this.#app.sinks)
|
|
220
|
+
w.__SYGNAL_DEVTOOLS_APP__ = undefined;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
customElements.define(tag, SygnalElement);
|
|
224
|
+
return SygnalElement;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export { defineElement };
|
|
228
|
+
//# sourceMappingURL=element.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element.esm.js","sources":["../src/extra/owned.ts","../src/element.ts"],"sourcesContent":["/**\n * PLAN-4.5 G-275: marks an initial state that a wrapper built from its caller's values (an\n * element's host props, Vike's pageContext.data or hydrated state, renderComponent's\n * initialState option). The dev statics freeze (D152, checks/statics.ts) leaves a marked object\n * and everything in it alone: the caller may still change those values. A non-enumerable symbol\n * key: spreads, JSON and Object.keys don't see it.\n */\nexport const OWNED = Symbol.for('sygnal.owned')\n\nexport const owned = <T>(v: T): T => {\n // G-289: an object that refuses the key (a Proxy) is returned as is\n try { if (v && typeof v == 'object' && Object.isExtensible(v)) Object.defineProperty(v, OWNED, {value: 1}) } catch {}\n return v\n}\n\n/**\n * G-289: owned() of a shallow copy of a plain object or array (the caller's own object stays\n * unmarked: it may be a component's static, which the freeze must still cover, or sealed, which\n * can't be marked); anything else as owned()\n */\nexport const ownedCopy = <T>(v: T): T => {\n const p = v && typeof v == 'object' ? Object.getPrototypeOf(v) : 0\n return owned(Array.isArray(v) ? [...v] as any : p == Object.prototype || p === null ? {...v} : v)\n}\n","// 'sygnal/element' (PLAN-4 GS-13, D127): publish a Sygnal component as a custom element.\n//\n// defineElement('task-board', TaskBoard, {\n// props: { title: String, tasks: Array, readonly: Boolean }, // or ['a', 'b'] (all String)\n// events: { PARENT: 'task-picked' }, // sink name → CustomEvent name\n// shadow: true, // true | 'open' | 'closed'\n// styles: '.title { color: green }', // string | CSSStyleSheet | array\n// })\n//\n// Each connected element is its own app: run(Component) mounted on a div inside the element\n// (or its shadow root). Props are in state from the first render (the component's\n// initialState, overlaid with the props); later property/attribute changes are merged into\n// state. Sinks listed in `events` are dispatched as CustomEvents (bubbles + composed; the\n// PARENT wrapper is unwrapped to its value). Removing the element disposes the app; a move\n// (disconnect + connect in the same task) keeps it running. Calling defineElement again for\n// the same tag (HMR) swaps the component in every live element, keeping each one's state.\n//\n// Separate entry: rollup rewrites './index' to the external 'sygnal' (0 B in the core bundle).\nimport {run} from './index';\nimport {owned} from './extra/owned';\n\nexport type ElementPropType =\n | StringConstructor\n | NumberConstructor\n | BooleanConstructor\n | ObjectConstructor\n | ArrayConstructor;\n\nexport interface ElementOptions {\n /** Properties fed into state (camelCase; the attribute is kebab-case). An array means all String. */\n props?: readonly string[] | Record<string, ElementPropType>;\n /** Sink name → CustomEvent name, e.g. { PARENT: 'task-picked' } */\n events?: Record<string, string>;\n /** Render into a shadow root (true = 'open') */\n shadow?: boolean | 'open' | 'closed';\n /** Adopted into the shadow root, shared by every instance (ignored without shadow) */\n styles?: string | CSSStyleSheet | Array<string | CSSStyleSheet>;\n}\n\n// Sinks that are the app's own drivers, never events\nconst RESERVED_SINKS = ['DOM', 'STATE', 'EVENTS'];\n\n// Hot-swap functions of the tags this module defined\nconst swaps = new WeakMap<CustomElementConstructor, (Component: any) => void>();\n\nconst kebab = (name: string) => name.replace(/[A-Z]/g, (c) => '-' + c.toLowerCase());\n\nfunction parseAttribute(type: ElementPropType, value: string | null): any {\n if (type === Boolean) return value !== null;\n if (value === null) return undefined;\n if (type === Number) return Number(value);\n if (type === String) return value;\n return JSON.parse(value); // Object, Array (throws on bad JSON)\n}\n\nfunction toSheet(style: string | CSSStyleSheet): CSSStyleSheet {\n if (typeof style !== 'string') return style;\n const sheet = new CSSStyleSheet();\n sheet.replaceSync(style);\n return sheet;\n}\n\nconst devMode = () => (globalThis as any).__SYGNAL_DEV__ === true;\n\nexport function defineElement(tag: string, Component: any, options: ElementOptions = {}): CustomElementConstructor {\n const prior = customElements.get(tag);\n const swap = prior && swaps.get(prior);\n if (swap) {\n swap(Component); // HMR: the defining module ran again\n return prior!;\n }\n if (typeof Component !== 'function') {\n throw new TypeError(`defineElement('${tag}'): pass a function component`);\n }\n\n const types: Record<string, ElementPropType> = Array.isArray(options.props)\n ? Object.fromEntries(options.props.map((name: string) => [name, String]))\n : {...(options.props as Record<string, ElementPropType> | undefined)};\n const propOfAttribute: Record<string, string> = Object.fromEntries(Object.keys(types).map((name) => [kebab(name), name]));\n const events = {...options.events};\n for (const sink of RESERVED_SINKS) {\n if (sink in events) throw new TypeError(`defineElement('${tag}'): '${sink}' is a driver of the element's app, not an event sink`);\n }\n const shadowMode = options.shadow ? (options.shadow === 'closed' ? 'closed' : 'open') : undefined;\n const sheets = shadowMode ? ([] as Array<string | CSSStyleSheet>).concat(options.styles || []).map(toSheet) : [];\n // Props that hide a member of HTMLElement (e.g. title, hidden): SYG644 once per tag (D131)\n const shadowedMembers = Object.keys(types).filter((name) => name in HTMLElement.prototype);\n let warned = false;\n\n const live = new Set<SygnalElement>();\n let instances = 0;\n\n class SygnalElement extends HTMLElement {\n static observedAttributes = Object.keys(propOfAttribute);\n\n #props: Record<string, any> = {};\n #app: any = undefined;\n #root: HTMLElement | ShadowRoot = this;\n #uid = `${tag}-${++instances}`;\n\n static {\n for (const name of Object.keys(types)) {\n Object.defineProperty(this.prototype, name, {\n configurable: true,\n enumerable: true,\n get(this: SygnalElement) {\n return this.#props[name];\n },\n set(this: SygnalElement, value: any) {\n this.#setProp(name, value);\n },\n });\n }\n swaps.set(this, (Next: any) => {\n Component = Next;\n live.forEach((element) => element.#swap());\n });\n }\n\n constructor() {\n super();\n if (shadowMode) {\n const root = this.attachShadow({mode: shadowMode});\n root.adoptedStyleSheets = sheets;\n this.#root = root;\n }\n // Properties set before the tag was defined are own properties that hide the\n // accessors: move them onto the accessors\n for (const name of Object.keys(types)) {\n if (Object.prototype.hasOwnProperty.call(this, name)) {\n const value = (this as any)[name];\n delete (this as any)[name];\n this.#setProp(name, value);\n }\n }\n }\n\n attributeChangedCallback(attribute: string, _old: string | null, value: string | null) {\n const name = propOfAttribute[attribute];\n try {\n this.#setProp(name, parseAttribute(types[name], value));\n } catch (_) {\n // bad JSON in an Object/Array attribute: keep the previous value\n }\n }\n\n connectedCallback() {\n if (this.#app) return; // moved, not removed: keep running\n // (G-216: a hot swap elsewhere on the page is that app's own, so no need to wait it out)\n if (shadowedMembers.length && !warned) {\n // D131: SYG644 through the diagnostics core when diagnostics are on; else a console\n // warning in dev\n const message = `props hide the HTMLElement members of the same name (${shadowedMembers.join(', ')})`;\n const fix = 'Rename them to keep the native behaviour';\n let reported: any;\n try {\n reported = (globalThis as any).__SYGNAL_DIAGNOSTICS__?.report('SYG644', {\n severity: 'warn', component: `<${tag}>`, message, fix, data: {tag, members: shadowedMembers},\n });\n } catch (e) {\n reported = true; // mode 'error': thrown after the element starts\n queueMicrotask(() => { throw e; });\n }\n if (reported || devMode()) warned = true;\n if (!reported && devMode()) console.warn(`[sygnal/element] <${tag}>: ${message}. ${fix}.`);\n }\n const mount = document.createElement('div');\n this.#root.appendChild(mount);\n this.#app = run(this.#component(), this.#eventDrivers(), {mountPoint: mount as any, uid: this.#uid});\n this.#releaseDevtools();\n live.add(this);\n }\n\n disconnectedCallback() {\n // Deferred: a move is a disconnect + connect in the same task\n queueMicrotask(() => {\n if (this.isConnected || !this.#app) return;\n this.#app.dispose();\n this.#app = undefined;\n live.delete(this);\n this.#root.replaceChildren();\n });\n }\n\n // Hot swap (defineElement again for this tag): the new component, this element's state\n #swap() {\n if (!this.#app) return;\n // (the state through the runtime API, 04 §3.9)\n this.#app.hmr(this.#component(), (this.#app as any).__runtime.getState());\n this.#releaseDevtools();\n }\n\n #setProp(name: string, value: any) {\n this.#props[name] = value;\n const set = (state: any) => ({...state, [name]: value});\n (this.#app as any)?.__runtime?.setState('root', set);\n }\n\n // A per-instance copy of the component whose initialState includes the current props\n // (owned: the dev statics freeze leaves the host's values alone, G-275)\n #component() {\n const wrapped = Object.assign((...args: any[]) => Component(...args), Component, {\n initialState: owned({...Component.initialState, ...this.#props}),\n });\n return Object.defineProperty(wrapped, 'name', {value: Component.name || tag});\n }\n\n #eventDrivers() {\n return Object.fromEntries(\n Object.entries(events).map(([sink, eventName]) => [\n sink,\n (sink$: any) => {\n sink$.addListener({\n next: (value: any) => {\n // PARENT values arrive wrapped as { name, component, value }\n const detail = sink === 'PARENT' ? value?.value : value;\n this.dispatchEvent(new CustomEvent(eventName, {detail, bubbles: true, composed: true}));\n },\n });\n },\n ])\n );\n }\n\n // run() registers the first live app for DevTools time travel (G-212). An element gives\n // the slot back, so a host app that starts later gets it\n #releaseDevtools() {\n const w = window as any;\n if (w.__SYGNAL_DEVTOOLS_APP__ === this.#app || w.__SYGNAL_DEVTOOLS_APP__?.sinks === this.#app.sinks) w.__SYGNAL_DEVTOOLS_APP__ = undefined;\n }\n }\n\n customElements.define(tag, SygnalElement);\n return SygnalElement;\n}\n"],"names":[],"mappings":";;AAAA;;;;;;AAMG;AACI,MAAM,KAAK,GAAG,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA;AAExC,MAAM,KAAK,GAAG,CAAI,CAAI,KAAO;;AAEl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