@ecopages/radiant 0.3.0-alpha.0 → 0.3.0-alpha.10
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/README.md +72 -57
- package/dist/LICENSE +21 -0
- package/dist/client/app-bootstrap.d.ts +19 -0
- package/dist/client/app-bootstrap.js +3 -0
- package/dist/client/app-bootstrap.js.map +10 -0
- package/dist/client/hydrator.d.ts +19 -0
- package/dist/client/hydrator.js +3 -0
- package/dist/client/hydrator.js.map +11 -0
- package/dist/client/install-hydrator.d.ts +1 -0
- package/dist/client/install-hydrator.js +3 -0
- package/dist/client/install-hydrator.js.map +12 -0
- package/dist/context/context-consumer-bootstrap.d.ts +7 -6
- package/dist/context/context-consumer-bootstrap.js +2 -2
- package/dist/context/context-consumer-bootstrap.js.map +8 -3
- package/dist/context/context-consumer-runtime.d.ts +21 -8
- package/dist/context/context-consumer-runtime.js +2 -2
- package/dist/context/context-consumer-runtime.js.map +6 -3
- package/dist/context/context-host.d.ts +25 -0
- package/dist/context/context-host.js +3 -0
- package/dist/context/context-host.js.map +10 -0
- package/dist/context/context-provider.d.ts +10 -6
- package/dist/context/context-provider.js +2 -2
- package/dist/context/context-provider.js.map +9 -3
- package/dist/context/context-ssr-bridge.js +2 -2
- package/dist/context/context-ssr-bridge.js.map +4 -3
- package/dist/context/create-context.js +2 -2
- package/dist/context/create-context.js.map +4 -3
- package/dist/context/decorators/consume-context.d.ts +5 -2
- package/dist/context/decorators/consume-context.js +2 -2
- package/dist/context/decorators/consume-context.js.map +13 -3
- package/dist/context/decorators/context-selection-delivery.d.ts +1 -1
- package/dist/context/decorators/context-selection-delivery.js +2 -2
- package/dist/context/decorators/context-selection-delivery.js.map +5 -3
- package/dist/context/decorators/context-selector.d.ts +6 -11
- package/dist/context/decorators/context-selector.js +2 -2
- package/dist/context/decorators/context-selector.js.map +15 -3
- package/dist/context/decorators/legacy/consume-context.d.ts +2 -2
- package/dist/context/decorators/legacy/consume-context.js +2 -2
- package/dist/context/decorators/legacy/consume-context.js.map +10 -3
- package/dist/context/decorators/legacy/context-selector-field.d.ts +2 -2
- package/dist/context/decorators/legacy/context-selector-field.js +2 -2
- package/dist/context/decorators/legacy/context-selector-field.js.map +11 -3
- package/dist/context/decorators/legacy/context-selector.d.ts +2 -2
- package/dist/context/decorators/legacy/context-selector.js +2 -2
- package/dist/context/decorators/legacy/context-selector.js.map +11 -3
- package/dist/context/decorators/legacy/provide-context.d.ts +2 -2
- package/dist/context/decorators/legacy/provide-context.js +2 -2
- package/dist/context/decorators/legacy/provide-context.js.map +11 -3
- package/dist/context/decorators/on-context-update.d.ts +5 -5
- package/dist/context/decorators/on-context-update.js +2 -2
- package/dist/context/decorators/on-context-update.js.map +14 -3
- package/dist/context/decorators/provide-context.d.ts +5 -2
- package/dist/context/decorators/provide-context.js +2 -2
- package/dist/context/decorators/provide-context.js.map +14 -3
- package/dist/context/decorators/standard/consume-context.d.ts +2 -2
- package/dist/context/decorators/standard/consume-context.js +2 -2
- package/dist/context/decorators/standard/consume-context.js.map +9 -3
- package/dist/context/decorators/standard/context-selector-field.d.ts +2 -2
- package/dist/context/decorators/standard/context-selector-field.js +2 -2
- package/dist/context/decorators/standard/context-selector-field.js.map +10 -3
- package/dist/context/decorators/standard/context-selector.d.ts +2 -3
- package/dist/context/decorators/standard/context-selector.js +2 -2
- package/dist/context/decorators/standard/context-selector.js.map +10 -3
- package/dist/context/decorators/standard/provide-context.d.ts +2 -2
- package/dist/context/decorators/standard/provide-context.js +2 -2
- package/dist/context/decorators/standard/provide-context.js.map +10 -3
- package/dist/context/events.d.ts +18 -11
- package/dist/context/events.js +2 -2
- package/dist/context/events.js.map +4 -3
- package/dist/context/hydration-script.d.ts +0 -4
- package/dist/context/hydration-script.js +2 -2
- package/dist/context/hydration-script.js.map +6 -3
- package/dist/context/index.d.ts +8 -0
- package/dist/context/index.js +3 -0
- package/dist/context/index.js.map +35 -0
- package/dist/controller-registry.d.ts +38 -0
- package/dist/controller-registry.js +3 -0
- package/dist/controller-registry.js.map +11 -0
- package/dist/core/controller-metadata.d.ts +3 -0
- package/dist/core/controller-metadata.js +3 -0
- package/dist/core/controller-metadata.js.map +10 -0
- package/dist/core/custom-element-metadata.d.ts +11 -0
- package/dist/core/custom-element-metadata.js +2 -2
- package/dist/core/custom-element-metadata.js.map +4 -3
- package/dist/core/hydration-codec.d.ts +8 -1
- package/dist/core/hydration-codec.js +2 -2
- package/dist/core/hydration-codec.js.map +5 -3
- package/dist/core/radiant-component-ssr-registry.d.ts +54 -0
- package/dist/core/radiant-component-ssr-registry.js +3 -0
- package/dist/core/radiant-component-ssr-registry.js.map +10 -0
- package/dist/core/radiant-component-ssr.d.ts +3 -3
- package/dist/core/radiant-component-ssr.js +2 -2
- package/dist/core/radiant-component-ssr.js.map +8 -3
- package/dist/core/radiant-controller.d.ts +128 -0
- package/dist/core/radiant-controller.js +3 -0
- package/dist/core/radiant-controller.js.map +13 -0
- package/dist/core/radiant-element.d.ts +80 -41
- package/dist/core/radiant-element.js +2 -2
- package/dist/core/radiant-element.js.map +13 -3
- package/dist/core/radiant-hydrator-state.d.ts +20 -0
- package/dist/core/radiant-hydrator-state.js +3 -0
- package/dist/core/radiant-hydrator-state.js.map +10 -0
- package/dist/core/reactive-host.d.ts +137 -0
- package/dist/core/reactive-host.js +3 -0
- package/dist/core/reactive-host.js.map +10 -0
- package/dist/core/reactive-jsx-value.js +2 -2
- package/dist/core/reactive-jsx-value.js.map +4 -3
- package/dist/core/reactive-prop-metadata.js +2 -2
- package/dist/core/reactive-prop-metadata.js.map +4 -3
- package/dist/core/{slot-projection.d.ts → slot-projection-runtime.d.ts} +0 -20
- package/dist/core/slot-projection-runtime.js +3 -0
- package/dist/core/slot-projection-runtime.js.map +12 -0
- package/dist/core/ssr-preparation.js +2 -2
- package/dist/core/ssr-preparation.js.map +4 -3
- package/dist/decorators/attr.d.ts +6 -0
- package/dist/decorators/attr.js +3 -0
- package/dist/decorators/attr.js.map +16 -0
- package/dist/decorators/bound.d.ts +4 -2
- package/dist/decorators/bound.js +2 -2
- package/dist/decorators/bound.js.map +7 -3
- package/dist/decorators/bridge.d.ts +11 -7
- package/dist/decorators/bridge.js +2 -2
- package/dist/decorators/bridge.js.map +4 -3
- package/dist/decorators/controller.d.ts +2 -0
- package/dist/decorators/controller.js +3 -0
- package/dist/decorators/controller.js.map +12 -0
- package/dist/decorators/custom-element.d.ts +4 -2
- package/dist/decorators/custom-element.js +2 -2
- package/dist/decorators/custom-element.js.map +7 -3
- package/dist/decorators/debounce.d.ts +5 -2
- package/dist/decorators/debounce.js +2 -2
- package/dist/decorators/debounce.js.map +8 -3
- package/dist/decorators/event.d.ts +5 -2
- package/dist/decorators/event.js +2 -2
- package/dist/decorators/event.js.map +10 -3
- package/dist/decorators/legacy/attr.d.ts +2 -0
- package/dist/decorators/legacy/attr.js +3 -0
- package/dist/decorators/legacy/attr.js.map +13 -0
- package/dist/decorators/legacy/bound.js +2 -2
- package/dist/decorators/legacy/bound.js.map +4 -3
- package/dist/decorators/legacy/custom-element.js +2 -2
- package/dist/decorators/legacy/custom-element.js.map +5 -3
- package/dist/decorators/legacy/debounce.js +2 -2
- package/dist/decorators/legacy/debounce.js.map +5 -3
- package/dist/decorators/legacy/event.js +2 -2
- package/dist/decorators/legacy/event.js.map +7 -3
- package/dist/decorators/legacy/instance-initializers.d.ts +3 -4
- package/dist/decorators/legacy/instance-initializers.js +2 -2
- package/dist/decorators/legacy/instance-initializers.js.map +4 -3
- package/dist/decorators/legacy/on-event.d.ts +2 -2
- package/dist/decorators/legacy/on-event.js +2 -2
- package/dist/decorators/legacy/on-event.js.map +7 -3
- package/dist/decorators/legacy/on-updated.d.ts +7 -2
- package/dist/decorators/legacy/on-updated.js +2 -2
- package/dist/decorators/legacy/on-updated.js.map +5 -3
- package/dist/decorators/legacy/query-slot.d.ts +1 -1
- package/dist/decorators/legacy/query-slot.js +2 -2
- package/dist/decorators/legacy/query-slot.js.map +7 -3
- package/dist/decorators/legacy/query.d.ts +7 -2
- package/dist/decorators/legacy/query.js +2 -2
- package/dist/decorators/legacy/query.js.map +6 -3
- package/dist/decorators/legacy/reactive-field.d.ts +2 -2
- package/dist/decorators/legacy/reactive-field.js +2 -2
- package/dist/decorators/legacy/reactive-field.js.map +5 -3
- package/dist/decorators/legacy/reactive-prop.d.ts +10 -16
- package/dist/decorators/legacy/reactive-prop.js +2 -2
- package/dist/decorators/legacy/reactive-prop.js.map +7 -3
- package/dist/decorators/legacy/signal.d.ts +4 -3
- package/dist/decorators/legacy/signal.js +2 -2
- package/dist/decorators/legacy/signal.js.map +9 -3
- package/dist/decorators/on-event.d.ts +6 -3
- package/dist/decorators/on-event.js +2 -2
- package/dist/decorators/on-event.js.map +10 -3
- package/dist/decorators/on-updated.d.ts +12 -2
- package/dist/decorators/on-updated.js +2 -2
- package/dist/decorators/on-updated.js.map +8 -3
- package/dist/decorators/prop.d.ts +19 -7
- package/dist/decorators/prop.js +2 -2
- package/dist/decorators/prop.js.map +10 -3
- package/dist/decorators/query-slot.d.ts +7 -3
- package/dist/decorators/query-slot.js +2 -2
- package/dist/decorators/query-slot.js.map +10 -3
- package/dist/decorators/query.d.ts +9 -2
- package/dist/decorators/query.js +2 -2
- package/dist/decorators/query.js.map +9 -3
- package/dist/decorators/shared/reactive-attr.d.ts +25 -0
- package/dist/decorators/shared/reactive-attr.js +3 -0
- package/dist/decorators/shared/reactive-attr.js.map +11 -0
- package/dist/decorators/signal.d.ts +10 -4
- package/dist/decorators/signal.js +2 -2
- package/dist/decorators/signal.js.map +11 -3
- package/dist/decorators/standard/attr.d.ts +2 -0
- package/dist/decorators/standard/attr.js +3 -0
- package/dist/decorators/standard/attr.js.map +12 -0
- package/dist/decorators/standard/bound.js +2 -2
- package/dist/decorators/standard/bound.js.map +4 -3
- package/dist/decorators/standard/custom-element.js +2 -2
- package/dist/decorators/standard/custom-element.js.map +5 -3
- package/dist/decorators/standard/debounce.js +2 -2
- package/dist/decorators/standard/debounce.js.map +5 -3
- package/dist/decorators/standard/event.js +2 -2
- package/dist/decorators/standard/event.js.map +6 -3
- package/dist/decorators/standard/on-event.d.ts +2 -1
- package/dist/decorators/standard/on-event.js +2 -2
- package/dist/decorators/standard/on-event.js.map +6 -3
- package/dist/decorators/standard/on-updated.d.ts +5 -1
- package/dist/decorators/standard/on-updated.js +2 -2
- package/dist/decorators/standard/on-updated.js.map +4 -3
- package/dist/decorators/standard/query-slot.d.ts +1 -1
- package/dist/decorators/standard/query-slot.js +2 -2
- package/dist/decorators/standard/query-slot.js.map +5 -3
- package/dist/decorators/standard/query.d.ts +2 -1
- package/dist/decorators/standard/query.js +2 -2
- package/dist/decorators/standard/query.js.map +5 -3
- package/dist/decorators/standard/reactive-field.d.ts +2 -2
- package/dist/decorators/standard/reactive-field.js +2 -2
- package/dist/decorators/standard/reactive-field.js.map +4 -3
- package/dist/decorators/standard/reactive-prop.d.ts +13 -2
- package/dist/decorators/standard/reactive-prop.js +2 -2
- package/dist/decorators/standard/reactive-prop.js.map +6 -3
- package/dist/decorators/standard/signal.d.ts +4 -3
- package/dist/decorators/standard/signal.js +2 -2
- package/dist/decorators/standard/signal.js.map +8 -3
- package/dist/decorators/state.d.ts +6 -5
- package/dist/decorators/state.js +2 -2
- package/dist/decorators/state.js.map +8 -3
- package/dist/helpers/create-event-listener.d.ts +11 -2
- package/dist/helpers/create-event-listener.js +2 -2
- package/dist/helpers/create-event-listener.js.map +5 -3
- package/dist/helpers/create-event.js +2 -2
- package/dist/helpers/create-event.js.map +5 -3
- package/dist/helpers/create-query-slot.d.ts +2 -2
- package/dist/helpers/create-query-slot.js +2 -2
- package/dist/helpers/create-query-slot.js.map +4 -3
- package/dist/helpers/create-query.d.ts +14 -3
- package/dist/helpers/create-query.js +2 -2
- package/dist/helpers/create-query.js.map +4 -3
- package/dist/helpers/debounce.js +2 -2
- package/dist/helpers/debounce.js.map +4 -3
- package/dist/helpers/index.js +2 -2
- package/dist/helpers/index.js.map +10 -3
- package/dist/index.d.ts +4 -12
- package/dist/index.js +2 -2
- package/dist/index.js.map +66 -3
- package/dist/server/context-ssr.js +2 -2
- package/dist/server/context-ssr.js.map +5 -3
- package/dist/server/html-parser.d.ts +21 -0
- package/dist/server/html-parser.js +3 -0
- package/dist/server/html-parser.js.map +10 -0
- package/dist/server/install-light-dom-shim.js +2 -2
- package/dist/server/install-light-dom-shim.js.map +5 -3
- package/dist/server/light-dom-shim.d.ts +9 -0
- package/dist/server/light-dom-shim.js +2 -2
- package/dist/server/light-dom-shim.js.map +5 -3
- package/dist/server/project-root.js +2 -2
- package/dist/server/project-root.js.map +2 -2
- package/dist/server/radiant-component-ssr-runtime.d.ts +9 -0
- package/dist/server/radiant-component-ssr-runtime.js +3 -0
- package/dist/server/radiant-component-ssr-runtime.js.map +17 -0
- package/dist/server/render-component.d.ts +7 -17
- package/dist/server/render-component.js +2 -2
- package/dist/server/render-component.js.map +14 -4
- package/dist/server/render-controller.d.ts +57 -0
- package/dist/server/render-controller.js +3 -0
- package/dist/server/render-controller.js.map +23 -0
- package/dist/server/slot-projection-html.d.ts +3 -0
- package/dist/server/slot-projection-html.js +3 -0
- package/dist/server/slot-projection-html.js.map +14 -0
- package/dist/signals/host-resource.js +2 -2
- package/dist/signals/host-resource.js.map +2 -2
- package/dist/signals/host-signal.d.ts +4 -2
- package/dist/signals/host-signal.js +2 -2
- package/dist/signals/host-signal.js.map +7 -3
- package/dist/signals/hydration-script.d.ts +0 -4
- package/dist/signals/hydration-script.js +2 -2
- package/dist/signals/hydration-script.js.map +6 -3
- package/dist/tools/escape-css-identifier.d.ts +1 -0
- package/dist/tools/escape-css-identifier.js +3 -0
- package/dist/tools/escape-css-identifier.js.map +10 -0
- package/dist/tools/escape-script-json.js +2 -2
- package/dist/tools/escape-script-json.js.map +4 -3
- package/dist/tools/event-emitter.js +2 -2
- package/dist/tools/event-emitter.js.map +4 -3
- package/dist/tools/index.d.ts +1 -1
- package/dist/tools/index.js +2 -2
- package/dist/tools/index.js.map +7 -3
- package/dist/tools/render-jsx-template.js +2 -2
- package/dist/tools/render-jsx-template.js.map +4 -3
- package/dist/types.d.ts +0 -21
- package/dist/types.js +2 -2
- package/dist/types.js.map +3 -3
- package/dist/utils/attribute-utils.js +2 -2
- package/dist/utils/attribute-utils.js.map +4 -3
- package/dist/utils/index.js +2 -2
- package/dist/utils/index.js.map +4 -3
- package/package.json +41 -8
- package/size-budget.json +12 -9
- package/dist/chunk-0y78f8hj.js +0 -4
- package/dist/chunk-0y78f8hj.js.map +0 -10
- package/dist/chunk-0zq7e1ne.js +0 -4
- package/dist/chunk-0zq7e1ne.js.map +0 -10
- package/dist/chunk-13ydx769.js +0 -4
- package/dist/chunk-13ydx769.js.map +0 -10
- package/dist/chunk-147yvtsn.js +0 -4
- package/dist/chunk-147yvtsn.js.map +0 -10
- package/dist/chunk-17earqbr.js +0 -4
- package/dist/chunk-17earqbr.js.map +0 -10
- package/dist/chunk-1w1dm68j.js +0 -4
- package/dist/chunk-1w1dm68j.js.map +0 -10
- package/dist/chunk-2tgrfv09.js +0 -4
- package/dist/chunk-2tgrfv09.js.map +0 -10
- package/dist/chunk-3b033cgq.js +0 -4
- package/dist/chunk-3b033cgq.js.map +0 -10
- package/dist/chunk-42tyhfvh.js +0 -4
- package/dist/chunk-42tyhfvh.js.map +0 -10
- package/dist/chunk-4cc2syf5.js +0 -4
- package/dist/chunk-4cc2syf5.js.map +0 -10
- package/dist/chunk-4fqkmpra.js +0 -4
- package/dist/chunk-4fqkmpra.js.map +0 -10
- package/dist/chunk-4srpf0y5.js +0 -4
- package/dist/chunk-4srpf0y5.js.map +0 -10
- package/dist/chunk-57w3vmme.js +0 -4
- package/dist/chunk-57w3vmme.js.map +0 -10
- package/dist/chunk-5a2xez36.js +0 -4
- package/dist/chunk-5a2xez36.js.map +0 -10
- package/dist/chunk-5bym7y1d.js +0 -4
- package/dist/chunk-5bym7y1d.js.map +0 -10
- package/dist/chunk-5td6v9k3.js +0 -4
- package/dist/chunk-5td6v9k3.js.map +0 -10
- package/dist/chunk-60015zxq.js +0 -4
- package/dist/chunk-60015zxq.js.map +0 -10
- package/dist/chunk-60q4y3k5.js +0 -4
- package/dist/chunk-60q4y3k5.js.map +0 -10
- package/dist/chunk-6kdxrppw.js +0 -4
- package/dist/chunk-6kdxrppw.js.map +0 -10
- package/dist/chunk-6z34stya.js +0 -4
- package/dist/chunk-6z34stya.js.map +0 -10
- package/dist/chunk-73x7jpdd.js +0 -4
- package/dist/chunk-73x7jpdd.js.map +0 -10
- package/dist/chunk-84fc8cz9.js +0 -4
- package/dist/chunk-84fc8cz9.js.map +0 -10
- package/dist/chunk-8dexhy6c.js +0 -4
- package/dist/chunk-8dexhy6c.js.map +0 -10
- package/dist/chunk-8n2dhx28.js +0 -4
- package/dist/chunk-8n2dhx28.js.map +0 -10
- package/dist/chunk-8tvt04cm.js +0 -4
- package/dist/chunk-8tvt04cm.js.map +0 -10
- package/dist/chunk-8vak8w5w.js +0 -4
- package/dist/chunk-8vak8w5w.js.map +0 -10
- package/dist/chunk-8xy18qmz.js +0 -4
- package/dist/chunk-8xy18qmz.js.map +0 -9
- package/dist/chunk-9554n9t4.js +0 -4
- package/dist/chunk-9554n9t4.js.map +0 -10
- package/dist/chunk-9ascmjk3.js +0 -4
- package/dist/chunk-9ascmjk3.js.map +0 -10
- package/dist/chunk-9gjmqxp2.js +0 -4
- package/dist/chunk-9gjmqxp2.js.map +0 -10
- package/dist/chunk-a7hzs37s.js +0 -4
- package/dist/chunk-a7hzs37s.js.map +0 -10
- package/dist/chunk-aajhkdmn.js +0 -4
- package/dist/chunk-aajhkdmn.js.map +0 -10
- package/dist/chunk-agjb2a3r.js +0 -4
- package/dist/chunk-agjb2a3r.js.map +0 -10
- package/dist/chunk-ak97hp4w.js +0 -4
- package/dist/chunk-ak97hp4w.js.map +0 -10
- package/dist/chunk-bmhn4nbp.js +0 -4
- package/dist/chunk-bmhn4nbp.js.map +0 -10
- package/dist/chunk-c8vqg7r1.js +0 -4
- package/dist/chunk-c8vqg7r1.js.map +0 -10
- package/dist/chunk-cbvd18v1.js +0 -4
- package/dist/chunk-cbvd18v1.js.map +0 -10
- package/dist/chunk-chyn72n9.js +0 -4
- package/dist/chunk-chyn72n9.js.map +0 -10
- package/dist/chunk-cvz9mrxa.js +0 -4
- package/dist/chunk-cvz9mrxa.js.map +0 -10
- package/dist/chunk-d0n7njdy.js +0 -4
- package/dist/chunk-d0n7njdy.js.map +0 -10
- package/dist/chunk-d4v5qpxa.js +0 -4
- package/dist/chunk-d4v5qpxa.js.map +0 -10
- package/dist/chunk-d7hh3ze6.js +0 -4
- package/dist/chunk-d7hh3ze6.js.map +0 -10
- package/dist/chunk-d98q3myg.js +0 -4
- package/dist/chunk-d98q3myg.js.map +0 -10
- package/dist/chunk-dscj0sk9.js +0 -4
- package/dist/chunk-dscj0sk9.js.map +0 -10
- package/dist/chunk-dx1wqc00.js +0 -4
- package/dist/chunk-dx1wqc00.js.map +0 -10
- package/dist/chunk-g0gz7ypq.js +0 -4
- package/dist/chunk-g0gz7ypq.js.map +0 -10
- package/dist/chunk-hkmm3dj9.js +0 -4
- package/dist/chunk-hkmm3dj9.js.map +0 -10
- package/dist/chunk-hn4j8rt5.js +0 -4
- package/dist/chunk-hn4j8rt5.js.map +0 -10
- package/dist/chunk-jce9gqqw.js +0 -4
- package/dist/chunk-jce9gqqw.js.map +0 -10
- package/dist/chunk-jg20mzg8.js +0 -4
- package/dist/chunk-jg20mzg8.js.map +0 -10
- package/dist/chunk-jkb2y7c8.js +0 -4
- package/dist/chunk-jkb2y7c8.js.map +0 -10
- package/dist/chunk-k5hr781q.js +0 -4
- package/dist/chunk-k5hr781q.js.map +0 -10
- package/dist/chunk-ksv01cey.js +0 -4
- package/dist/chunk-ksv01cey.js.map +0 -10
- package/dist/chunk-mpjnqmbq.js +0 -4
- package/dist/chunk-mpjnqmbq.js.map +0 -10
- package/dist/chunk-mqxmfvyp.js +0 -4
- package/dist/chunk-mqxmfvyp.js.map +0 -10
- package/dist/chunk-ms6a9zdt.js +0 -4
- package/dist/chunk-ms6a9zdt.js.map +0 -10
- package/dist/chunk-nerd6fmg.js +0 -4
- package/dist/chunk-nerd6fmg.js.map +0 -10
- package/dist/chunk-nw171z6m.js +0 -4
- package/dist/chunk-nw171z6m.js.map +0 -10
- package/dist/chunk-p6pxdvkk.js +0 -4
- package/dist/chunk-p6pxdvkk.js.map +0 -10
- package/dist/chunk-paehjz94.js +0 -4
- package/dist/chunk-paehjz94.js.map +0 -10
- package/dist/chunk-par0t822.js +0 -4
- package/dist/chunk-par0t822.js.map +0 -10
- package/dist/chunk-qaagk55a.js +0 -4
- package/dist/chunk-qaagk55a.js.map +0 -10
- package/dist/chunk-qbnedp0y.js +0 -4
- package/dist/chunk-qbnedp0y.js.map +0 -10
- package/dist/chunk-qd28hvdx.js +0 -4
- package/dist/chunk-qd28hvdx.js.map +0 -10
- package/dist/chunk-qdj6r8jn.js +0 -4
- package/dist/chunk-qdj6r8jn.js.map +0 -10
- package/dist/chunk-qe6sjr27.js +0 -4
- package/dist/chunk-qe6sjr27.js.map +0 -10
- package/dist/chunk-r1cvaz1t.js +0 -4
- package/dist/chunk-r1cvaz1t.js.map +0 -10
- package/dist/chunk-r75y7ydb.js +0 -4
- package/dist/chunk-r75y7ydb.js.map +0 -10
- package/dist/chunk-s4qgct1z.js +0 -4
- package/dist/chunk-s4qgct1z.js.map +0 -10
- package/dist/chunk-scfk041e.js +0 -4
- package/dist/chunk-scfk041e.js.map +0 -10
- package/dist/chunk-t6x9e177.js +0 -4
- package/dist/chunk-t6x9e177.js.map +0 -10
- package/dist/chunk-t7a1bbxq.js +0 -4
- package/dist/chunk-t7a1bbxq.js.map +0 -10
- package/dist/chunk-tyysm4gk.js +0 -4
- package/dist/chunk-tyysm4gk.js.map +0 -10
- package/dist/chunk-vpfm9yw8.js +0 -4
- package/dist/chunk-vpfm9yw8.js.map +0 -10
- package/dist/chunk-w50v38rv.js +0 -4
- package/dist/chunk-w50v38rv.js.map +0 -10
- package/dist/chunk-x0522ksh.js +0 -4
- package/dist/chunk-x0522ksh.js.map +0 -10
- package/dist/chunk-xd1xn3vy.js +0 -4
- package/dist/chunk-xd1xn3vy.js.map +0 -10
- package/dist/chunk-zb7wh7w4.js +0 -4
- package/dist/chunk-zb7wh7w4.js.map +0 -10
- package/dist/chunk-zj9ez73m.js +0 -4
- package/dist/chunk-zj9ez73m.js.map +0 -10
- package/dist/core/radiant-component.d.ts +0 -106
- package/dist/core/radiant-component.js +0 -3
- package/dist/core/radiant-component.js.map +0 -9
- package/dist/core/slot-projection.js +0 -3
- package/dist/core/slot-projection.js.map +0 -9
- package/dist/tools/stringify-typed.d.ts +0 -16
- package/dist/tools/stringify-typed.js +0 -3
- package/dist/tools/stringify-typed.js.map +0 -9
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": [],
|
|
3
|
+
"sources": ["../src/utils/attribute-utils.ts", "../src/core/custom-element-metadata.ts", "../src/context/context-ssr-bridge.ts", "../src/server/context-ssr.ts", "../src/core/radiant-component-ssr.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
+
"import type { RadiantElement } from '../core/radiant-element';\n\nexport type AttributeTypeConstant = typeof Array | typeof Boolean | typeof Number | typeof Object | typeof String;\n\nexport type AttributeTypeDefault = Array<unknown> | boolean | number | Record<string, unknown> | string;\n\n/**\n * Parses the given attribute type constant and returns its corresponding string representation.\n *\n * @param constant - The attribute type constant to parse.\n * @returns The string representation of the attribute type constant.\n */\nexport function parseAttributeTypeConstant(constant?: AttributeTypeConstant) {\n\tswitch (constant) {\n\t\tcase Array:\n\t\t\treturn 'array';\n\t\tcase Boolean:\n\t\t\treturn 'boolean';\n\t\tcase Number:\n\t\t\treturn 'number';\n\t\tcase Object:\n\t\t\treturn 'object';\n\t\tcase String:\n\t\t\treturn 'string';\n\t}\n}\n\n/**\n * Parses the attribute type default value and returns its type as a string.\n *\n * @param defaultValue - The default value of the attribute type.\n * @returns The type of the default value as a string.\n */\nexport function parseAttributeTypeDefault(defaultValue?: AttributeTypeDefault) {\n\tswitch (typeof defaultValue) {\n\t\tcase 'boolean':\n\t\t\treturn 'boolean';\n\t\tcase 'number':\n\t\t\treturn 'number';\n\t\tcase 'string':\n\t\t\treturn 'string';\n\t}\n\n\tif (Array.isArray(defaultValue)) return 'array';\n\tif (Object.prototype.toString.call(defaultValue) === '[object Object]') return 'object';\n}\n\n/**\n * Returns the default value for a given attribute type.\n *\n * @param type - The attribute type constant.\n * @returns The default value for the specified attribute type.\n */\nexport function defaultValueForType(type: AttributeTypeConstant): unknown {\n\tswitch (type) {\n\t\tcase Number:\n\t\t\treturn 0;\n\t\tcase String:\n\t\t\treturn '';\n\t\tcase Boolean:\n\t\t\treturn false;\n\t\tdefault:\n\t\t\treturn null;\n\t}\n}\n\ntype Reader = (value: string) => number | string | boolean | object | unknown[];\n\n/**\n * Utility function to parse a JSON string safely\n */\nfunction parseJSON<T>(value: string): T {\n\ttry {\n\t\treturn JSON.parse(value);\n\t} catch {\n\t\tthrow new TypeError('Invalid JSON string');\n\t}\n}\n\n/**\n * Object that maps attribute types to reader functions.\n * @type {Object.<string, Reader>}\n */\nconst readers: { [type: string]: Reader } = {\n\tarray(value: string): unknown[] {\n\t\tconst array = parseJSON<unknown[]>(value);\n\t\tif (!Array.isArray(array)) {\n\t\t\tthrow new TypeError(`Expected an array but got a value of type \"${typeof array}\"`);\n\t\t}\n\t\treturn array;\n\t},\n\n\tboolean(value: string): boolean {\n\t\treturn !(value === '0' || String(value).toLowerCase() === 'false');\n\t},\n\n\tnumber(value: string): number {\n\t\tconst number = Number(value.replace(/_/g, ''));\n\t\treturn number;\n\t},\n\n\tobject(value: string): object {\n\t\tconst object = JSON.parse(value);\n\t\tif (object === null || typeof object !== 'object' || Array.isArray(object)) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`expected value of type \"object\" but instead got value \"${value}\" of type \"${parseAttributeTypeDefault(\n\t\t\t\t\tobject,\n\t\t\t\t)}\"`,\n\t\t\t);\n\t\t}\n\t\treturn object;\n\t},\n\n\tstring(value: string): string {\n\t\treturn value;\n\t},\n};\n\ntype Writer = (value: unknown) => string;\n\n/**\n * Object that maps attribute types to writer functions.\n * @type {Object.<string, Writer>}\n */\nconst writers: { [type: string]: Writer } = {\n\tdefault: writeString,\n\tarray: writeJSON,\n\tobject: writeJSON,\n};\n\nfunction writeJSON(value: unknown) {\n\treturn JSON.stringify(value);\n}\n\nfunction writeString(value: unknown) {\n\treturn `${value}`;\n}\n\n/**\n * Reads the attribute value based on the provided type.\n * @param value - The attribute value to be read.\n * @param type - The type of the attribute.\n * @returns The parsed attribute value.\n * @throws {TypeError} If the provided type is unknown.\n */\nexport function readAttributeValue(value: string, type: AttributeTypeConstant) {\n\tconst readerType = parseAttributeTypeConstant(type);\n\tif (!readerType) throw new TypeError(`[radiant-element] Unknown type \"${type}\"`);\n\treturn readers[readerType]!(value);\n}\n\nexport type ReadAttributeValueReturnType = ReturnType<typeof readAttributeValue>;\n\n/**\n * Writes the attribute value based on the provided type.\n *\n * @param value - The value to be written.\n * @param type - The type of the attribute.\n * @returns The written attribute value.\n * @throws {TypeError} If the provided type is unknown.\n */\nexport function writeAttributeValue(value: unknown, type: AttributeTypeConstant) {\n\tconst writerType = parseAttributeTypeConstant(type);\n\tif (!writerType) throw new TypeError(`[radiant-element] Unknown type \"${type}\"`);\n\tconst writer: Writer = writers[writerType] ?? writers.default ?? writeString;\n\treturn writer(value);\n}\n\nexport type WriteAttributeValueReturnType = ReturnType<typeof writeAttributeValue>;\n\n/*\n * Type guard functions for each type in AttributeTypeConstant\n */\nfunction isBoolean(value: unknown): value is boolean {\n\treturn typeof value === 'boolean';\n}\n\nfunction isNumber(value: unknown): value is number {\n\treturn typeof value === 'number';\n}\n\nfunction isString(value: unknown): value is string {\n\treturn typeof value === 'string';\n}\n\nfunction isArray(value: unknown): value is Array<unknown> {\n\treturn Array.isArray(value);\n}\n\nfunction isObject(value: unknown): value is object {\n\treturn typeof value === 'object' && !Array.isArray(value) && value !== null;\n}\n\n/*\n * Check function to ensure defaultValue matches the type\n */\nexport function isValueOfType(type: AttributeTypeConstant, defaultValue: unknown): boolean {\n\tswitch (type) {\n\t\tcase Boolean:\n\t\t\treturn isBoolean(defaultValue);\n\t\tcase Number:\n\t\t\treturn isNumber(defaultValue);\n\t\tcase String:\n\t\t\treturn isString(defaultValue);\n\t\tcase Array:\n\t\t\treturn isArray(defaultValue);\n\t\tcase Object:\n\t\t\treturn isObject(defaultValue);\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\nexport const getInitialValue = (\n\ttarget: RadiantElement,\n\ttype: AttributeTypeConstant,\n\tattributeKey: string,\n\tdefaultValue: unknown,\n) => {\n\tif (type === Boolean) {\n\t\tconst attributeValue = target.getAttribute(attributeKey);\n\t\tif (attributeValue === null) {\n\t\t\treturn defaultValue;\n\t\t}\n\n\t\treturn attributeValue === '' ? true : readAttributeValue(attributeValue, type);\n\t}\n\n\tconst attributeValue = target.getAttribute(attributeKey);\n\treturn attributeValue !== null\n\t\t? readAttributeValue(attributeValue, type)\n\t\t: (defaultValue ?? (defaultValueForType(type) as typeof defaultValue));\n};\n",
|
|
6
|
+
"export const CUSTOM_ELEMENT_TAG_NAME = Symbol.for('@ecopages/radiant.customElementTagName');\n\ntype CustomElementConstructorWithMetadata = CustomElementConstructor & {\n\t[CUSTOM_ELEMENT_TAG_NAME]?: string;\n};\n\n/**\n * Sets the custom element tag name for a given constructor.\n * This is used internally to associate a class with its custom element tag, which is necessary for features like hydration and SSR support.\n * @param target The constructor of the custom element.\n * @param tagName The tag name to associate with the custom element.\n */\nexport function setCustomElementTagName(target: CustomElementConstructor, tagName: string): void {\n\t(target as CustomElementConstructorWithMetadata)[CUSTOM_ELEMENT_TAG_NAME] = tagName;\n}\n\n/**\n * Retrieves the custom element tag name associated with a given constructor.\n * @param target The constructor of the custom element.\n * @returns The tag name associated with the custom element, or `undefined` if not set.\n */\nexport function getCustomElementTagName(target: CustomElementConstructor): string | undefined {\n\treturn (target as CustomElementConstructorWithMetadata)[CUSTOM_ELEMENT_TAG_NAME];\n}\n",
|
|
7
|
+
"import type { SsrSerializableContextProvider } from './context-provider';\nimport type { UnknownContext } from './types';\n\ntype SsrContextProviderResolver = (context: UnknownContext) => SsrSerializableContextProvider | undefined;\n\nconst SSR_CONTEXT_PROVIDER_RESOLVER_SYMBOL = Symbol.for('@ecopages/radiant.ssr-context-provider-resolver');\n\ntype GlobalResolverScope = typeof globalThis & {\n\t[SSR_CONTEXT_PROVIDER_RESOLVER_SYMBOL]?: SsrContextProviderResolver;\n};\n\nfunction getGlobalResolverScope(): GlobalResolverScope {\n\treturn globalThis as GlobalResolverScope;\n}\n\n/**\n * Installs the ambient SSR provider resolver used by shared context runtime helpers.\n *\n * Server-side rendering infrastructure owns the actual provider stack storage and\n * publishes a lookup function here so client/runtime code does not need to import\n * server-oriented modules.\n */\nexport function installSsrContextProviderResolver(resolver: SsrContextProviderResolver): void {\n\tgetGlobalResolverScope()[SSR_CONTEXT_PROVIDER_RESOLVER_SYMBOL] = resolver;\n}\n\n/**\n * Resolves an ambient SSR provider when a server render has published one.\n */\nexport function resolveAmbientSsrContextProvider(context: UnknownContext): SsrSerializableContextProvider | undefined {\n\treturn getGlobalResolverScope()[SSR_CONTEXT_PROVIDER_RESOLVER_SYMBOL]?.(context);\n}\n",
|
|
8
|
+
"import type { AsyncLocalStorage } from 'node:async_hooks';\nimport type { SsrSerializableContextProvider } from '../context/context-provider';\nimport { installSsrContextProviderResolver } from '../context/context-ssr-bridge';\nimport type { ContextType, UnknownContext } from '../context/types';\n\ntype ProviderFrame = Map<UnknownContext, SsrSerializableContextProvider>;\ntype ProviderStack = ProviderFrame[];\n\nlet resolvedAsyncLocalStorage: AsyncLocalStorage<ProviderStack> | null | undefined;\n\n/**\n * Lazily resolves `AsyncLocalStorage` from `node:async_hooks`.\n *\n * The dynamic `require` is necessary because browser-based SSR tests import\n * this server-oriented module directly. A top-level static import would break\n * those browser bundles even though normal application SSR runs on the server.\n *\n * On the server (Node.js, Bun, Cloudflare Workers) the import always succeeds.\n * In browser test environments where SSR rendering is exercised without a real\n * server, the fallback global stack is used instead.\n */\nfunction getAsyncLocalStorage(): AsyncLocalStorage<ProviderStack> | null {\n\tif (resolvedAsyncLocalStorage !== undefined) {\n\t\treturn resolvedAsyncLocalStorage;\n\t}\n\n\ttry {\n\t\tconst { AsyncLocalStorage: ALS } = require('node:async_hooks') as typeof import('node:async_hooks');\n\t\tresolvedAsyncLocalStorage = new ALS<ProviderStack>();\n\t\treturn resolvedAsyncLocalStorage;\n\t} catch {\n\t\tresolvedAsyncLocalStorage = null;\n\t\treturn null;\n\t}\n}\n\nconst SSR_CONTEXT_FALLBACK_STACK_SYMBOL = Symbol.for('@ecopages/radiant.ssr-context-fallback-stack');\n\nfunction getFallbackStack(): ProviderStack {\n\tconst g = globalThis as typeof globalThis & { [SSR_CONTEXT_FALLBACK_STACK_SYMBOL]?: ProviderStack };\n\tg[SSR_CONTEXT_FALLBACK_STACK_SYMBOL] ??= [];\n\treturn g[SSR_CONTEXT_FALLBACK_STACK_SYMBOL];\n}\n\n/**\n * Pushes a temporary provider frame onto the SSR context stack.\n *\n * On the server, each call creates an isolated `AsyncLocalStorage` context so\n * concurrent renders cannot corrupt each other.\n *\n * In browser test environments where `AsyncLocalStorage` is unavailable, a\n * synchronous global stack is used as a fallback.\n */\nexport function withSsrContextProviders(providers: readonly SsrSerializableContextProvider[]): () => void {\n\tif (providers.length === 0) {\n\t\treturn () => undefined;\n\t}\n\n\tconst frame = new Map<UnknownContext, SsrSerializableContextProvider>();\n\n\tfor (const provider of providers) {\n\t\tframe.set(provider.getContextKey(), provider);\n\t}\n\n\tconst als = getAsyncLocalStorage();\n\n\tif (als) {\n\t\tconst parentStack = als.getStore() ?? [];\n\t\tconst childStack = [...parentStack, frame];\n\t\tals.enterWith(childStack);\n\n\t\treturn () => {\n\t\t\tals.enterWith(parentStack);\n\t\t};\n\t}\n\n\tconst stack = getFallbackStack();\n\tstack.push(frame);\n\n\treturn () => {\n\t\tconst index = stack.lastIndexOf(frame);\n\t\tif (index >= 0) stack.splice(index, 1);\n\t};\n}\n\n/**\n * Resolves the nearest SSR-visible provider for a given context token.\n *\n * Lookup walks the provider frames from innermost to outermost so nested host\n * serialization behaves the same way as runtime context resolution in the DOM.\n */\nexport function resolveSsrContextProvider<T extends UnknownContext>(\n\tcontext: T,\n): SsrSerializableContextProvider | undefined {\n\tconst store = getAsyncLocalStorage()?.getStore() ?? getFallbackStack();\n\n\tfor (let index = store.length - 1; index >= 0; index -= 1) {\n\t\tconst provider = store[index]?.get(context);\n\n\t\tif (provider) {\n\t\t\treturn provider;\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Resolves the current SSR-visible value for a given context token.\n *\n * This is the ergonomic helper consumed by SSR-aware decorators and component\n * render paths when they only need the context payload instead of the full\n * provider instance.\n */\nexport function resolveSsrContextValue<T extends UnknownContext>(context: T): ContextType<T> | undefined {\n\tconst provider = resolveSsrContextProvider(context);\n\n\tif (!provider) {\n\t\treturn undefined;\n\t}\n\n\treturn provider.getContext() as ContextType<T>;\n}\n\ninstallSsrContextProviderResolver((context) => resolveSsrContextProvider(context));\n",
|
|
9
|
+
"import type { JsxRenderable } from '@ecopages/jsx';\nimport type { RenderToStringOptions } from '@ecopages/jsx/server';\nimport type { SsrSerializableContextProvider } from '../context/context-provider';\nimport { withSsrContextProviders } from '../server/context-ssr';\nimport { getCustomElementTagName } from './custom-element-metadata';\nimport type { ReactiveProperty } from './radiant-element';\nimport type { ReactivePropDefinition } from './reactive-prop-metadata';\nimport type { SsrSerializableHydrationBinding } from './ssr-hydration-binding';\nimport { writeAttributeValue } from '../utils/attribute-utils';\n\ntype RadiantElementSsrHost = {\n\tconstructor: CustomElementConstructor;\n\tgetAuthoredHydrationScriptMarkup?: () => string | undefined;\n\tgetContextProviders: () => SsrSerializableContextProvider[];\n\tgetHydrationBindings: () => SsrSerializableHydrationBinding[];\n\tgetSlotProjectionScriptTag?: () => string | undefined;\n\trenderToString: (options?: RenderToStringOptions) => string;\n\tgetReactiveProperties: () => ReactiveProperty[];\n\tgetReactivePropDefinitions: () => ReactivePropDefinition[];\n\tgetPropertyValue: (name: string) => unknown;\n\tlistAttributeNames: () => string[];\n\tgetAttributeValue: (name: string) => string | null;\n};\n\nexport class RadiantElementSsrService {\n\tconstructor(private readonly host: RadiantElementSsrHost) {}\n\n\tpublic renderHost(): JsxRenderable {\n\t\treturn {\n\t\t\tnodeType: 1,\n\t\t\touterHTML: this.renderHostToString({ mode: 'hydrate' }),\n\t\t};\n\t}\n\n\tpublic renderHostToString(options: RenderToStringOptions = {}, attributes = this.getHostAttributes()): string {\n\t\tconst tagName = this.getTagName();\n\t\tconst restoreSsrContexts = withSsrContextProviders(this.host.getContextProviders());\n\n\t\ttry {\n\t\t\treturn `<${tagName}${serializeHostAttributes(attributes)}>${this.renderHostContent(options)}</${tagName}>`;\n\t\t} finally {\n\t\t\trestoreSsrContexts();\n\t\t}\n\t}\n\n\tprivate renderHostContent(options: RenderToStringOptions): string {\n\t\tconst hostContent = this.host.renderToString(options);\n\t\tconst authoredHydrationMarkup = this.host.getAuthoredHydrationScriptMarkup?.() ?? '';\n\t\tconst slotProjectionScript = this.host.getSlotProjectionScriptTag?.() ?? '';\n\t\tconst hydrate = options.mode === 'hydrate' || (options.mode === undefined && options.hydrate === true);\n\n\t\tif (!hydrate) {\n\t\t\treturn `${hostContent}${authoredHydrationMarkup}${slotProjectionScript}`;\n\t\t}\n\n\t\tconst hydrationScripts = this.host\n\t\t\t.getHydrationBindings()\n\t\t\t.map((binding) => binding.renderHydrationScriptTag())\n\t\t\t.filter((markup): markup is string => typeof markup === 'string')\n\t\t\t.join('');\n\n\t\treturn `${hostContent}${slotProjectionScript}${hydrationScripts}`;\n\t}\n\n\tpublic getHostAttributes(): Record<string, string> {\n\t\tconst attributes: Record<string, string> = {};\n\t\tconst seenAttributes = new Set<string>();\n\n\t\tfor (const property of this.host.getReactiveProperties()) {\n\t\t\tconst currentValue = this.host.getPropertyValue(property.name);\n\t\t\tif (currentValue === undefined || currentValue === null || currentValue === false) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tattributes[property.attribute] = String(property.converter.toAttribute(currentValue));\n\t\t\tseenAttributes.add(property.attribute);\n\t\t}\n\n\t\tfor (const definition of this.host.getReactivePropDefinitions()) {\n\t\t\tconst attributeName = definition.options.attribute ?? definition.name;\n\n\t\t\tif (seenAttributes.has(attributeName)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst currentValue = this.host.getPropertyValue(definition.name);\n\n\t\t\tif (currentValue === undefined || currentValue === null || currentValue === false) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tattributes[attributeName] = String(writeAttributeValue(currentValue, definition.options.type));\n\t\t\tseenAttributes.add(attributeName);\n\t\t}\n\n\t\tfor (const attributeName of this.host.listAttributeNames()) {\n\t\t\tconst attributeValue = this.host.getAttributeValue(attributeName);\n\t\t\tif (attributeValue !== null) {\n\t\t\t\tattributes[attributeName] = attributeValue;\n\t\t\t}\n\t\t}\n\n\t\treturn attributes;\n\t}\n\n\tprivate getTagName(): string {\n\t\tconst tagName = getCustomElementTagName(this.host.constructor);\n\n\t\tif (!tagName) {\n\t\t\tthrow new Error(`${this.host.constructor.name} is missing @customElement metadata.`);\n\t\t}\n\n\t\treturn tagName;\n\t}\n}\n\nfunction serializeHostAttributes(attributes: Record<string, string>): string {\n\treturn Object.entries(attributes)\n\t\t.map(([name, value]) => ` ${name}=\"${escapeAttribute(value)}\"`)\n\t\t.join('');\n}\n\nfunction escapeAttribute(value: string): string {\n\treturn value.replace(/&/g, '&').replace(/\"/g, '"').replace(/</g, '<').replace(/>/g, '>');\n}\n"
|
|
5
10
|
],
|
|
6
|
-
"mappings": "",
|
|
7
|
-
"debugId": "
|
|
11
|
+
"mappings": "2PAYO,SAAS,CAA0B,CAAC,EAAkC,CAC5E,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1,128 @@
|
|
|
1
|
+
import { type JsxRenderable, type SubscribableJsxValue } from '@ecopages/jsx';
|
|
2
|
+
import type { UnknownContext } from '../context/types';
|
|
3
|
+
import { type ReactiveHostLike } from './reactive-host';
|
|
4
|
+
import type { ReactivePropertyOptions, ReactiveBindingValue, ReactiveBindings, ReactiveFieldOptions } from './radiant-element';
|
|
5
|
+
import type { ReactiveBindingOption } from './radiant-element';
|
|
6
|
+
import type { SsrSerializableHydrationBinding } from './ssr-hydration-binding';
|
|
7
|
+
type StringPropertyKey<Value> = Extract<keyof Value, string>;
|
|
8
|
+
/**
|
|
9
|
+
* Attaches Radiant reactivity to an existing DOM element without defining a
|
|
10
|
+
* custom element.
|
|
11
|
+
*
|
|
12
|
+
* `RadiantController` is the controller-host counterpart to `RadiantElement`.
|
|
13
|
+
* It can enhance authored DOM, or it can take over the host's inner DOM by
|
|
14
|
+
* overriding `render()`.
|
|
15
|
+
*
|
|
16
|
+
* When used with the controller registry, the attached host is typically an
|
|
17
|
+
* element carrying `data-controller="..."`.
|
|
18
|
+
*
|
|
19
|
+
* @typeParam Bindings - Explicit internal bindable shape. Include only the
|
|
20
|
+
* reactive keys that JSX bindings should accept.
|
|
21
|
+
*/
|
|
22
|
+
export declare class RadiantController<Bindings extends object = {}> implements ReactiveHostLike<Bindings> {
|
|
23
|
+
readonly host: Element;
|
|
24
|
+
readonly element: Element;
|
|
25
|
+
readonly bindings: ReactiveBindings<Bindings>;
|
|
26
|
+
readonly $: ReactiveBindings<Bindings>;
|
|
27
|
+
private readonly reactiveHost;
|
|
28
|
+
private connected;
|
|
29
|
+
private isRendering;
|
|
30
|
+
private isRenderScheduled;
|
|
31
|
+
private isSsrLifecycle;
|
|
32
|
+
private needsRender;
|
|
33
|
+
private renderSignal?;
|
|
34
|
+
private readonly renderWatcher;
|
|
35
|
+
constructor(host: Element);
|
|
36
|
+
/**
|
|
37
|
+
* Connects the controller to its host and starts reactive subscriptions.
|
|
38
|
+
*
|
|
39
|
+
* If the controller owns a render lifecycle by overriding `render()`, the
|
|
40
|
+
* first update runs immediately after connection.
|
|
41
|
+
*/
|
|
42
|
+
connect(): void;
|
|
43
|
+
/**
|
|
44
|
+
* Connects the controller for server-side rendering without running the
|
|
45
|
+
* browser render/update lifecycle.
|
|
46
|
+
*/
|
|
47
|
+
connectForSsrRender(): void;
|
|
48
|
+
/**
|
|
49
|
+
* Disconnects the controller from its host and tears down reactive work.
|
|
50
|
+
*/
|
|
51
|
+
disconnect(): void;
|
|
52
|
+
/**
|
|
53
|
+
* Disconnects a controller that was attached through the SSR-only lifecycle.
|
|
54
|
+
*/
|
|
55
|
+
disconnectForSsrRender(): void;
|
|
56
|
+
get isConnected(): boolean;
|
|
57
|
+
/**
|
|
58
|
+
* Returns the JSX tree rendered into the attached host.
|
|
59
|
+
*
|
|
60
|
+
* The base implementation renders nothing. Override this method when the
|
|
61
|
+
* controller should own the host's inner DOM instead of only enhancing
|
|
62
|
+
* authored markup.
|
|
63
|
+
*/
|
|
64
|
+
render(): JsxRenderable;
|
|
65
|
+
/**
|
|
66
|
+
* Schedules a render pass for render-owning controllers.
|
|
67
|
+
*
|
|
68
|
+
* Multiple calls in the same microtask are coalesced into a single update.
|
|
69
|
+
*/
|
|
70
|
+
requestUpdate(): void;
|
|
71
|
+
/**
|
|
72
|
+
* Flushes the current render output into the attached host element.
|
|
73
|
+
*
|
|
74
|
+
* This is a no-op unless the controller overrides `render()`.
|
|
75
|
+
*/
|
|
76
|
+
update(): void;
|
|
77
|
+
/**
|
|
78
|
+
* Returns a subscribable JSX binding for a selected reactive member.
|
|
79
|
+
*/
|
|
80
|
+
bind<Property extends StringPropertyKey<Bindings>>(property: Property): SubscribableJsxValue<ReactiveBindingValue<Bindings, Property>>;
|
|
81
|
+
/**
|
|
82
|
+
* Returns the cached binding object for a selected reactive member.
|
|
83
|
+
*/
|
|
84
|
+
getReactiveBinding<Property extends StringPropertyKey<Bindings>>(property: Property): SubscribableJsxValue<ReactiveBindingValue<Bindings, Property>>;
|
|
85
|
+
/**
|
|
86
|
+
* Defines a reactive field directly on the controller instance.
|
|
87
|
+
*/
|
|
88
|
+
createReactiveField<T>(propertyName: string, initialValue: T, options?: ReactiveFieldOptions): void;
|
|
89
|
+
/**
|
|
90
|
+
* Defines a controller prop backed by the attached host element's property
|
|
91
|
+
* channel instead of attribute serialization.
|
|
92
|
+
*
|
|
93
|
+
* This gives controller-based integrations the same reactive field surface as
|
|
94
|
+
* `@prop(...)` on `RadiantElement`, while allowing external code to assign
|
|
95
|
+
* structured values such as arrays or objects directly on `controller.host`.
|
|
96
|
+
*/
|
|
97
|
+
createReactiveProp<T = unknown>(propertyName: string, options: ReactivePropertyOptions<T>): void;
|
|
98
|
+
/**
|
|
99
|
+
* Defines a JSX binding companion such as `$count` for a reactive member.
|
|
100
|
+
*/
|
|
101
|
+
defineReactiveBinding(property: string, bind?: ReactiveBindingOption): void;
|
|
102
|
+
notifyUpdate(changedProperty: string, oldValue: unknown, value: unknown): void;
|
|
103
|
+
registerUpdateCallback(property: string, update: (...rest: any[]) => any): () => void;
|
|
104
|
+
connectedContextCallback(_contextName: UnknownContext): void;
|
|
105
|
+
registerContextProvider(_name: string, _provider: unknown): void;
|
|
106
|
+
registerHydrationBinding(_name: string, _binding: SsrSerializableHydrationBinding): void;
|
|
107
|
+
registerCleanupCallback(callback: () => void): void;
|
|
108
|
+
registerConnectedCallback(callback: () => void): void;
|
|
109
|
+
registerReactiveDependencyReader(property: string, read: () => unknown): void;
|
|
110
|
+
trackReactiveRead(property: string): void;
|
|
111
|
+
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
112
|
+
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
|
113
|
+
dispatchEvent(event: Event): boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Finds one or more elements inside the attached host by `data-ref`.
|
|
116
|
+
*
|
|
117
|
+
* Prefer `@query(...)` for stable, decorator-backed refs and use `getRef(...)`
|
|
118
|
+
* for one-off lookups.
|
|
119
|
+
*/
|
|
120
|
+
getRef<T extends Element = Element>(ref: string, all: true): T[];
|
|
121
|
+
getRef<T extends Element = Element>(ref: string, all?: false): T | null;
|
|
122
|
+
protected shouldAutoBindReactiveMembers(): boolean;
|
|
123
|
+
protected shouldRunRenderLifecycle(): boolean;
|
|
124
|
+
private getRenderTarget;
|
|
125
|
+
private disconnectRenderWatcher;
|
|
126
|
+
private resolveTrackedRenderOutput;
|
|
127
|
+
}
|
|
128
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var m=((q)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(q,{get:(M,Q)=>(typeof require<"u"?require:M)[Q]}):q)(function(q){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+q+'" is not supported')});var Y=Symbol.for("@ecopages/radiant.legacy-instance-initializers");function N(q,M){let U=q[Y];if(Array.isArray(U)){U.push(M);return}Object.defineProperty(q,Y,{value:[M],configurable:!0})}function F(q){let M=[],Q=Object.getPrototypeOf(q);while(Q&&Q!==Object.prototype)M.push(Q),Q=Object.getPrototypeOf(Q);for(let U=M.length-1;U>=0;U-=1){let W=M[U][Y];if(!Array.isArray(W))continue;for(let $ of W)$(q)}}import{createSubscribableJsxValue as D}from"@ecopages/jsx";import{trackDependency as K}from"@ecopages/signals";class O{read;subscribers=new Set;watcherListeners=new Set;version=0;constructor(q){this.read=q}get(){return K(this),this.read()}subscribe(q){return this.subscribers.add(q),()=>{this.subscribers.delete(q)}}addWatcher(q){return this.watcherListeners.add(q),()=>{this.watcherListeners.delete(q)}}getVersion(){return this.version}notify(q){this.version+=1;let M;try{this.notifyWatchers()}catch(Q){M=Q}if(this.publish(q),M)throw M}publish(q){for(let M of this.subscribers)M(q)}notifyWatchers(){let q=[];for(let M of this.watcherListeners)try{M()}catch(Q){q.push(Q)}if(q.length===1)throw q[0];if(q.length>1)throw AggregateError(q,"Multiple reactive dependency notifications failed.")}}function P(q){return typeof q==="object"&&q!==null&&typeof q.get==="function"}class Z{host;access;shouldAutoBind;bindings;$;reactiveFields=new Map;reactiveDependencies=new Map;reactiveDependencyReaders=new Map;reactiveBindings=new Map;updateCallbacks=new Map;onConnectedCallbacks=[];onDisconnectedCallback=[];constructor(q,M,Q){this.host=q;this.access=M;this.shouldAutoBind=Q;let U=this.createReactiveBindingNamespace();this.bindings=U,this.$=U}connectHost(){for(let q of this.onConnectedCallbacks)q()}disconnectHost(){for(let q of this.onDisconnectedCallback)q()}notifyUpdate(q,M,Q){if(M===Q)return;this.reactiveDependencies.get(q)?.notify(Q);let U=this.updateCallbacks.get(q);if(U)for(let W of U)W()}registerCleanupCallback(q){this.onDisconnectedCallback.push(q)}registerConnectedCallback(q){this.onConnectedCallbacks.push(q)}registerHydrationBinding(q,M){}registerReactiveDependencyReader(q,M){this.reactiveDependencyReaders.set(q,M)}registerUpdateCallback(q,M){if(!this.updateCallbacks.has(q))this.updateCallbacks.set(q,new Set);let Q=this.updateCallbacks.get(q);return Q.add(M),()=>{if(Q.delete(M),Q.size===0)this.updateCallbacks.delete(q)}}getReactiveBinding(q){let M=this.reactiveBindings.get(q);if(M)return M;let Q=D({getValue:()=>this.readReactiveBindingValue(q),subscribe:(U)=>this.registerUpdateCallback(q,()=>{U(this.readReactiveBindingValue(q))})});return this.reactiveBindings.set(q,Q),Q}bind(q){return this.getReactiveBinding(q)}defineReactiveBinding(q,M=!0){let Q=typeof M==="string"?M:M?`$${q}`:void 0,U=this.access.getBindingTarget?.(this.host)??this.host;if(!Q||this.access.hasProperty(this.host,Q))return;this.access.defineProperty(U,Q,{get:()=>this.getReactiveBinding(q),enumerable:!1,configurable:!0})}trackReactiveRead(q){K(this.getReactiveDependency(q))}defineReactiveAccessor(q,M){let Q=M.bind??this.shouldAutoBind();if(this.defineReactiveBinding(q,Q),this.registerReactiveDependencyReader(q,M.getValue),this.access.defineProperty(this.host,q,{get:()=>{return this.trackReactiveRead(q),M.getValue()},set:(U)=>{let W=M.getValue();if(W===U)return;M.setValue(U),this.notifyUpdate(q,W,U)},enumerable:!0,configurable:!0}),M.notifyInitialValue!==void 0)this.notifyUpdate(q,void 0,M.notifyInitialValue)}createReactiveField(q,M,Q={}){let U={name:q,value:M,initialValue:M};this.reactiveFields.set(q,U),this.defineReactiveAccessor(q,{bind:Q.bind,getValue:()=>this.reactiveFields.get(q)?.value,setValue:(W)=>{this.reactiveFields.set(q,{...U,value:W})},notifyInitialValue:M})}createReactiveBindingNamespace(){return new Proxy(Object.create(null),{get:(q,M)=>{if(typeof M!=="string")return;return this.getReactiveBinding(M)}})}getReactiveDependency(q){let M=this.reactiveDependencies.get(q);if(M)return M;let Q=new O(()=>this.readReactiveDependencyValue(q));return this.reactiveDependencies.set(q,Q),Q}readReactiveDependencyValue(q){let M=this.reactiveDependencyReaders.get(q);if(M)return M();return this.readReactiveBindingValue(q)}readReactiveBindingValue(q){let M=this.access.readProperty(this.host,q);if(P(M))return M.get();return M}}function L(q){switch(q){case Array:return"array";case Boolean:return"boolean";case Number:return"number";case Object:return"object";case String:return"string"}}function x(q){switch(typeof q){case"boolean":return"boolean";case"number":return"number";case"string":return"string"}if(Array.isArray(q))return"array";if(Object.prototype.toString.call(q)==="[object Object]")return"object"}function B(q){switch(q){case Number:return 0;case String:return"";case Boolean:return!1;default:return null}}function A(q){try{return JSON.parse(q)}catch{throw TypeError("Invalid JSON string")}}var k={array(q){let M=A(q);if(!Array.isArray(M))throw TypeError(`Expected an array but got a value of type "${typeof M}"`);return M},boolean(q){return!(q==="0"||String(q).toLowerCase()==="false")},number(q){return Number(q.replace(/_/g,""))},object(q){let M=JSON.parse(q);if(M===null||typeof M!=="object"||Array.isArray(M))throw TypeError(`expected value of type "object" but instead got value "${q}" of type "${x(M)}"`);return M},string(q){return q}},J={default:C,array:_,object:_};function _(q){return JSON.stringify(q)}function C(q){return`${q}`}function j(q,M){let Q=L(M);if(!Q)throw TypeError(`[radiant-element] Unknown type "${M}"`);return k[Q](q)}function y(q,M){let Q=L(M);if(!Q)throw TypeError(`[radiant-element] Unknown type "${M}"`);return(J[Q]??J.default??C)(q)}function R(q){return typeof q==="boolean"}function S(q){return typeof q==="number"}function T(q){return typeof q==="string"}function I(q){return Array.isArray(q)}function h(q){return typeof q==="object"&&!Array.isArray(q)&&q!==null}function E(q,M){switch(q){case Boolean:return R(M);case Number:return S(M);case String:return T(M);case Array:return I(M);case Object:return h(M);default:return!1}}var u=(q,M,Q,U)=>{if(M===Boolean){let $=q.getAttribute(Q);if($===null)return U;return $===""?!0:j($,M)}let W=q.getAttribute(Q);return W!==null?j(W,M):U??B(M)};import{render as w}from"@ecopages/jsx";import{Computed as g,subtle as f}from"@ecopages/signals";class z{host;element;bindings;$;reactiveHost;connected=!1;isRendering=!1;isRenderScheduled=!1;isSsrLifecycle=!1;needsRender=!1;renderSignal;renderWatcher=new f.Watcher(()=>{this.requestUpdate()});constructor(q){this.host=q,this.element=q,this.reactiveHost=new Z(this,{defineProperty:(M,Q,U)=>Object.defineProperty(M,Q,U),hasProperty:(M,Q)=>(Q in M),readProperty:(M,Q)=>M[Q]},()=>this.shouldAutoBindReactiveMembers()),this.bindings=this.reactiveHost.bindings,this.$=this.reactiveHost.$,F(this)}connect(){if(this.connected=!0,this.reactiveHost.connectHost(),this.shouldRunRenderLifecycle())this.update()}connectForSsrRender(){this.isSsrLifecycle=!0;try{this.connect()}finally{this.isSsrLifecycle=!1}}disconnect(){this.connected=!1,this.disconnectRenderWatcher(),this.reactiveHost.disconnectHost()}disconnectForSsrRender(){this.disconnect()}get isConnected(){return this.connected}render(){return null}requestUpdate(){if(!this.shouldRunRenderLifecycle())return;if(this.needsRender=!0,this.isRenderScheduled)return;this.isRenderScheduled=!0,queueMicrotask(()=>{if(this.isRenderScheduled=!1,!this.needsRender)return;this.update()})}update(){if(!this.shouldRunRenderLifecycle())return;let q=this.getRenderTarget();if(!q)return;if(this.needsRender=!0,!this.connected||this.isRendering)return;while(this.needsRender){this.needsRender=!1,this.isRendering=!0;try{w(this.resolveTrackedRenderOutput(),q)}finally{this.isRendering=!1}}}bind(q){return this.reactiveHost.bind(q)}getReactiveBinding(q){return this.reactiveHost.getReactiveBinding(q)}createReactiveField(q,M,Q={}){this.reactiveHost.createReactiveField(q,M,Q)}createReactiveProp(q,M){let{type:Q,defaultValue:U,bind:W}=M;if(U!==void 0&&!E(Q,U))throw Error(`defaultValue does not match the expected type for ${Q.name}`);let $=Object.getOwnPropertyDescriptor(this.host,q),G=this.host,H=G[q]??U??B(Q);this.reactiveHost.defineReactiveAccessor(q,{bind:W,getValue:()=>H,setValue:(X)=>{H=X},notifyInitialValue:H}),Object.defineProperty(this.host,q,{get:()=>this[q],set:(X)=>{this[q]=X},enumerable:$?.enumerable??!0,configurable:!0}),this.registerCleanupCallback(()=>{let X=this[q];if($){if(Object.defineProperty(this.host,q,$),"value"in $&&$.writable)G[q]=X;return}delete G[q];try{G[q]=X}catch{Object.defineProperty(this.host,q,{value:X,writable:!0,enumerable:!0,configurable:!0})}})}defineReactiveBinding(q,M=!0){this.reactiveHost.defineReactiveBinding(q,M)}notifyUpdate(q,M,Q){this.reactiveHost.notifyUpdate(q,M,Q)}registerUpdateCallback(q,M){return this.reactiveHost.registerUpdateCallback(q,M)}connectedContextCallback(q){}registerContextProvider(q,M){}registerHydrationBinding(q,M){}registerCleanupCallback(q){this.reactiveHost.registerCleanupCallback(q)}registerConnectedCallback(q){this.reactiveHost.registerConnectedCallback(q)}registerReactiveDependencyReader(q,M){this.reactiveHost.registerReactiveDependencyReader(q,M)}trackReactiveRead(q){this.reactiveHost.trackReactiveRead(q)}addEventListener(q,M,Q){this.host.addEventListener(q,M,Q)}removeEventListener(q,M,Q){this.host.removeEventListener(q,M,Q)}dispatchEvent(q){return this.host.dispatchEvent(q)}getRef(q,M=!1){let Q=`[data-ref="${q}"]`;if(M)return Array.from(this.host.querySelectorAll(Q));return this.host.querySelector(Q)??null}shouldAutoBindReactiveMembers(){return!0}shouldRunRenderLifecycle(){return!this.isSsrLifecycle&&this.render!==z.prototype.render}getRenderTarget(){return this.host instanceof HTMLElement?this.host:null}disconnectRenderWatcher(){if(!this.renderSignal)return;this.renderWatcher.unwatch(this.renderSignal),this.renderSignal=void 0}resolveTrackedRenderOutput(){let q=new g(()=>this.render()),M=q.get();if(!this.connected)return M;if(this.renderSignal)this.renderWatcher.unwatch(this.renderSignal);return this.renderSignal=q,this.renderWatcher.watch(q),M}}export{z as RadiantController};
|
|
2
|
+
|
|
3
|
+
//# debugId=3254076C7E6FE49F64756E2164756E21
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/decorators/legacy/instance-initializers.ts", "../src/core/reactive-host.ts", "../src/utils/attribute-utils.ts", "../src/core/radiant-controller.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"type LegacyInstanceInitializer<T extends object = object> = (instance: T) => void;\n\nconst LEGACY_INSTANCE_INITIALIZERS = Symbol.for('@ecopages/radiant.legacy-instance-initializers');\n\n/**\n * Registers per-instance initialization work for a legacy decorator.\n *\n * Legacy decorators execute against the prototype, so any initialization that\n * needs the concrete element instance must be deferred until construction time.\n */\nexport function registerLegacyInstanceInitializer<T extends object>(\n\tproto: T,\n\tinitializer: LegacyInstanceInitializer<T>,\n): void {\n\tconst target = proto as Record<PropertyKey, unknown>;\n\tconst ownInitializers = target[LEGACY_INSTANCE_INITIALIZERS];\n\n\tif (Array.isArray(ownInitializers)) {\n\t\townInitializers.push(initializer);\n\t\treturn;\n\t}\n\n\tObject.defineProperty(proto, LEGACY_INSTANCE_INITIALIZERS, {\n\t\tvalue: [initializer],\n\t\tconfigurable: true,\n\t});\n}\n\n/**\n * Runs all legacy decorator initializers for a newly constructed element.\n *\n * Initializers are collected from the prototype chain and executed from base to\n * derived class so inherited setup remains stable.\n */\nexport function runLegacyInstanceInitializers<T extends object>(instance: T): void {\n\tconst prototypes: object[] = [];\n\tlet currentPrototype = Object.getPrototypeOf(instance);\n\n\twhile (currentPrototype && currentPrototype !== Object.prototype) {\n\t\tprototypes.push(currentPrototype);\n\t\tcurrentPrototype = Object.getPrototypeOf(currentPrototype);\n\t}\n\n\tfor (let index = prototypes.length - 1; index >= 0; index -= 1) {\n\t\tconst initializers = (prototypes[index] as Record<PropertyKey, unknown>)[LEGACY_INSTANCE_INITIALIZERS] as\n\t\t\t| LegacyInstanceInitializer<T>[]\n\t\t\t| undefined;\n\n\t\tif (!Array.isArray(initializers)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tfor (const initializer of initializers) {\n\t\t\tinitializer(instance);\n\t\t}\n\t}\n}\n",
|
|
6
|
+
"import { createSubscribableJsxValue, type SubscribableJsxValue } from '@ecopages/jsx';\nimport { trackDependency, type DependencyNode, type SignalSubscriber } from '@ecopages/signals';\nimport type {\n\tReactiveBindingOption,\n\tReactiveBindingValue,\n\tReactiveBindings,\n\tReactiveFieldOptions,\n} from './radiant-element';\nimport type { SsrSerializableHydrationBinding } from './ssr-hydration-binding';\n\ntype StringPropertyKey<Value> = Extract<keyof Value, string>;\ntype ReactiveDependencyReader = () => unknown;\n\ntype ReactiveHostAccess<Host extends object> = {\n\tdefineProperty(target: object, property: string, descriptor: PropertyDescriptor): void;\n\tgetBindingTarget?(host: Host): object;\n\thasProperty(host: Host, property: string): boolean;\n\treadProperty(host: Host, property: string): unknown;\n};\n\ntype ReactiveField<T = unknown> = {\n\tname: string;\n\tvalue: T;\n\tinitialValue: T;\n};\n\ntype ReactiveAccessorOptions<T> = {\n\tbind?: ReactiveBindingOption;\n\tgetValue: () => T | undefined;\n\tsetValue: (value: T) => void;\n\tnotifyInitialValue?: T;\n};\n\n/**\n * Shared reactive-host contract consumed by decorators and host adapters.\n *\n * `RadiantElement` and `RadiantController` both implement this surface so the\n * decorator layer can define fields, bindings, context reactions, and tracked\n * reads without depending on a specific host class.\n */\nexport interface ReactiveHostLike<Bindings extends object = {}> {\n\treadonly bindings: ReactiveBindings<Bindings>;\n\treadonly $: ReactiveBindings<Bindings>;\n\tbind<Property extends StringPropertyKey<Bindings>>(\n\t\tproperty: Property,\n\t): SubscribableJsxValue<ReactiveBindingValue<Bindings, Property>>;\n\tgetReactiveBinding<Property extends StringPropertyKey<Bindings>>(\n\t\tproperty: Property,\n\t): SubscribableJsxValue<ReactiveBindingValue<Bindings, Property>>;\n\tcreateReactiveField<T>(propertyName: string, initialValue: T, options?: ReactiveFieldOptions): void;\n\tdefineReactiveBinding(property: string, bind?: ReactiveBindingOption): void;\n\tnotifyUpdate(changedProperty: string, oldValue: unknown, value: unknown): void;\n\tregisterCleanupCallback(callback: () => void): void;\n\tregisterConnectedCallback(callback: () => void): void;\n\tregisterHydrationBinding(name: string, binding: SsrSerializableHydrationBinding): void;\n\tregisterReactiveDependencyReader(property: string, read: () => unknown): void;\n\ttrackReactiveRead(property: string): void;\n}\n\n/**\n * Internal dependency node that bridges Radiant host members into the signals\n * tracking graph.\n */\nclass ReactiveHostDependency implements DependencyNode {\n\tprivate readonly subscribers = new Set<SignalSubscriber<unknown>>();\n\tprivate readonly watcherListeners = new Set<() => void>();\n\tprivate version = 0;\n\n\tconstructor(private readonly read: ReactiveDependencyReader) {}\n\n\tpublic get(): unknown {\n\t\ttrackDependency(this);\n\t\treturn this.read();\n\t}\n\n\tpublic subscribe(notify: SignalSubscriber<unknown>): () => void {\n\t\tthis.subscribers.add(notify);\n\n\t\treturn () => {\n\t\t\tthis.subscribers.delete(notify);\n\t\t};\n\t}\n\n\tpublic addWatcher(notify: () => void): () => void {\n\t\tthis.watcherListeners.add(notify);\n\n\t\treturn () => {\n\t\t\tthis.watcherListeners.delete(notify);\n\t\t};\n\t}\n\n\tpublic getVersion(): number {\n\t\treturn this.version;\n\t}\n\n\tpublic notify(nextValue: unknown): void {\n\t\tthis.version += 1;\n\t\tlet watcherError: unknown;\n\n\t\ttry {\n\t\t\tthis.notifyWatchers();\n\t\t} catch (error) {\n\t\t\twatcherError = error;\n\t\t}\n\n\t\tthis.publish(nextValue);\n\n\t\tif (watcherError) {\n\t\t\tthrow watcherError;\n\t\t}\n\t}\n\n\tprivate publish(nextValue: unknown): void {\n\t\tfor (const subscriber of this.subscribers) {\n\t\t\tsubscriber(nextValue);\n\t\t}\n\t}\n\n\tprivate notifyWatchers(): void {\n\t\tconst errors: unknown[] = [];\n\n\t\tfor (const listener of this.watcherListeners) {\n\t\t\ttry {\n\t\t\t\tlistener();\n\t\t\t} catch (error) {\n\t\t\t\terrors.push(error);\n\t\t\t}\n\t\t}\n\n\t\tif (errors.length === 1) {\n\t\t\tthrow errors[0];\n\t\t}\n\n\t\tif (errors.length > 1) {\n\t\t\tthrow new AggregateError(errors, 'Multiple reactive dependency notifications failed.');\n\t\t}\n\t}\n}\n\nfunction isSignalLikeBindingValue(value: unknown): value is { get(): unknown } {\n\treturn typeof value === 'object' && value !== null && typeof (value as { get?: unknown }).get === 'function';\n}\n\n/**\n * Shared reactivity engine used by both `RadiantElement` and\n * `RadiantController`.\n *\n * This class owns three pieces of shared behavior:\n *\n * - defining reactive accessors on the host object\n * - exposing cached JSX bindings such as `bindings.count` and `$count`\n * - publishing tracked updates into the signals graph and update callbacks\n *\n * Host-specific concerns such as attribute reflection, render lifecycles, and\n * custom-element APIs stay in the outer host classes.\n */\nexport class ReactiveHost<Host extends object, Bindings extends object = {}> implements ReactiveHostLike<Bindings> {\n\tpublic readonly bindings: ReactiveBindings<Bindings>;\n\tpublic readonly $: ReactiveBindings<Bindings>;\n\n\tprivate reactiveFields = new Map<string, ReactiveField>();\n\tprivate reactiveDependencies = new Map<string, ReactiveHostDependency>();\n\tprivate reactiveDependencyReaders = new Map<string, ReactiveDependencyReader>();\n\tprivate reactiveBindings = new Map<string, SubscribableJsxValue>();\n\tprivate updateCallbacks = new Map<string, Set<(...rest: any[]) => any>>();\n\tprivate onConnectedCallbacks: (() => void)[] = [];\n\tprivate onDisconnectedCallback: (() => void)[] = [];\n\n\tconstructor(\n\t\tprivate readonly host: Host,\n\t\tprivate readonly access: ReactiveHostAccess<Host>,\n\t\tprivate readonly shouldAutoBind: () => boolean,\n\t) {\n\t\tconst bindingNamespace = this.createReactiveBindingNamespace();\n\t\tthis.bindings = bindingNamespace;\n\t\tthis.$ = bindingNamespace;\n\t}\n\n\t/**\n\t * Runs all connection callbacks registered by decorators or host adapters.\n\t */\n\tpublic connectHost(): void {\n\t\tfor (const callback of this.onConnectedCallbacks) {\n\t\t\tcallback();\n\t\t}\n\t}\n\n\t/**\n\t * Runs all cleanup callbacks registered for host disconnect.\n\t */\n\tpublic disconnectHost(): void {\n\t\tfor (const cleanup of this.onDisconnectedCallback) {\n\t\t\tcleanup();\n\t\t}\n\t}\n\n\t/**\n\t * Publishes a reactive member change to tracked dependencies and explicit\n\t * update callbacks.\n\t */\n\tpublic notifyUpdate(changedProperty: string, oldValue: unknown, value: unknown): void {\n\t\tif (oldValue === value) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.reactiveDependencies.get(changedProperty)?.notify(value);\n\t\tconst updates = this.updateCallbacks.get(changedProperty);\n\n\t\tif (updates) {\n\t\t\tfor (const update of updates) {\n\t\t\t\tupdate();\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Registers a callback that should run when the outer host disconnects.\n\t */\n\tpublic registerCleanupCallback(callback: () => void): void {\n\t\tthis.onDisconnectedCallback.push(callback);\n\t}\n\n\t/**\n\t * Registers a callback that should run whenever the outer host connects.\n\t */\n\tpublic registerConnectedCallback(callback: () => void): void {\n\t\tthis.onConnectedCallbacks.push(callback);\n\t}\n\n\t/**\n\t * Placeholder hydration hook so shared decorators can target both host types.\n\t *\n\t * `ReactiveHost` itself does not persist hydration bindings; concrete hosts\n\t * such as `RadiantElement` can override this behavior at the outer layer.\n\t */\n\tpublic registerHydrationBinding(_name: string, _binding: SsrSerializableHydrationBinding): void {}\n\n\t/**\n\t * Registers a raw reader for a reactive member so tracked dependency reads do\n\t * not need to go back through the public accessor.\n\t */\n\tpublic registerReactiveDependencyReader(property: string, read: ReactiveDependencyReader): void {\n\t\tthis.reactiveDependencyReaders.set(property, read);\n\t}\n\n\t/**\n\t * Registers a callback that runs whenever a named reactive member changes.\n\t *\n\t * Returns a disposer that removes the callback.\n\t */\n\tpublic registerUpdateCallback(property: string, update: (...rest: any[]) => any): () => void {\n\t\tif (!this.updateCallbacks.has(property)) {\n\t\t\tthis.updateCallbacks.set(property, new Set());\n\t\t}\n\n\t\tconst callbacks = this.updateCallbacks.get(property)!;\n\t\tcallbacks.add(update);\n\n\t\treturn () => {\n\t\t\tcallbacks.delete(update);\n\n\t\t\tif (callbacks.size === 0) {\n\t\t\t\tthis.updateCallbacks.delete(property);\n\t\t\t}\n\t\t};\n\t}\n\n\t/**\n\t * Returns the cached JSX binding object for a named reactive member.\n\t */\n\tpublic getReactiveBinding<Property extends StringPropertyKey<Bindings>>(\n\t\tproperty: Property,\n\t): SubscribableJsxValue<ReactiveBindingValue<Bindings, Property>> {\n\t\tconst cachedBinding = this.reactiveBindings.get(property);\n\n\t\tif (cachedBinding) {\n\t\t\treturn cachedBinding as SubscribableJsxValue<ReactiveBindingValue<Bindings, Property>>;\n\t\t}\n\n\t\tconst binding = createSubscribableJsxValue<ReactiveBindingValue<Bindings, Property>>({\n\t\t\tgetValue: () => this.readReactiveBindingValue(property) as ReactiveBindingValue<Bindings, Property>,\n\t\t\tsubscribe: (notify) =>\n\t\t\t\tthis.registerUpdateCallback(property, () => {\n\t\t\t\t\tnotify(this.readReactiveBindingValue(property) as ReactiveBindingValue<Bindings, Property>);\n\t\t\t\t}),\n\t\t});\n\n\t\tthis.reactiveBindings.set(property, binding);\n\t\treturn binding;\n\t}\n\n\t/**\n\t * Short alias for `getReactiveBinding(...)`.\n\t */\n\tpublic bind<Property extends StringPropertyKey<Bindings>>(\n\t\tproperty: Property,\n\t): SubscribableJsxValue<ReactiveBindingValue<Bindings, Property>> {\n\t\treturn this.getReactiveBinding(property) as SubscribableJsxValue<ReactiveBindingValue<Bindings, Property>>;\n\t}\n\n\t/**\n\t * Defines a stable binding companion property such as `$count` on the host or\n\t * its chosen binding target.\n\t */\n\tpublic defineReactiveBinding(property: string, bind: ReactiveBindingOption = true): void {\n\t\tconst bindingPropertyName = typeof bind === 'string' ? bind : bind ? `$${property}` : undefined;\n\t\tconst bindingTarget = this.access.getBindingTarget?.(this.host) ?? this.host;\n\n\t\tif (!bindingPropertyName || this.access.hasProperty(this.host, bindingPropertyName)) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.access.defineProperty(bindingTarget, bindingPropertyName, {\n\t\t\tget: () => this.getReactiveBinding(property as StringPropertyKey<Bindings>),\n\t\t\tenumerable: false,\n\t\t\tconfigurable: true,\n\t\t});\n\t}\n\n\t/**\n\t * Records a dependency read for the named reactive member.\n\t */\n\tpublic trackReactiveRead(property: string): void {\n\t\ttrackDependency(this.getReactiveDependency(property));\n\t}\n\n\t/**\n\t * Defines a reactive getter/setter pair on the host and wires it into\n\t * bindings, dependency tracking, and update notifications.\n\t */\n\tpublic defineReactiveAccessor<T>(propertyName: string, options: ReactiveAccessorOptions<T>): void {\n\t\tconst bind = options.bind ?? this.shouldAutoBind();\n\n\t\tthis.defineReactiveBinding(propertyName, bind);\n\t\tthis.registerReactiveDependencyReader(propertyName, options.getValue);\n\n\t\tthis.access.defineProperty(this.host, propertyName, {\n\t\t\tget: () => {\n\t\t\t\tthis.trackReactiveRead(propertyName);\n\t\t\t\treturn options.getValue();\n\t\t\t},\n\t\t\tset: (newValue: T) => {\n\t\t\t\tconst oldValue = options.getValue();\n\n\t\t\t\tif (oldValue === newValue) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\toptions.setValue(newValue);\n\t\t\t\tthis.notifyUpdate(propertyName, oldValue, newValue);\n\t\t\t},\n\t\t\tenumerable: true,\n\t\t\tconfigurable: true,\n\t\t});\n\n\t\tif (options.notifyInitialValue !== undefined) {\n\t\t\tthis.notifyUpdate(propertyName, undefined, options.notifyInitialValue);\n\t\t}\n\t}\n\n\t/**\n\t * Defines a controller- or element-local reactive field with optional JSX\n\t * binding exposure.\n\t */\n\tpublic createReactiveField<T>(propertyName: string, initialValue: T, options: ReactiveFieldOptions = {}): void {\n\t\tconst reactiveField: ReactiveField<T> = {\n\t\t\tname: propertyName,\n\t\t\tvalue: initialValue,\n\t\t\tinitialValue,\n\t\t};\n\n\t\tthis.reactiveFields.set(propertyName, reactiveField);\n\n\t\tthis.defineReactiveAccessor(propertyName, {\n\t\t\tbind: options.bind,\n\t\t\tgetValue: () => this.reactiveFields.get(propertyName)?.value as T | undefined,\n\t\t\tsetValue: (newValue: T) => {\n\t\t\t\tthis.reactiveFields.set(propertyName, { ...reactiveField, value: newValue });\n\t\t\t},\n\t\t\tnotifyInitialValue: initialValue,\n\t\t});\n\t}\n\n\tprivate createReactiveBindingNamespace(): ReactiveBindings<Bindings> {\n\t\treturn new Proxy(Object.create(null) as ReactiveBindings<Bindings>, {\n\t\t\tget: (_target, property) => {\n\t\t\t\tif (typeof property !== 'string') {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\treturn this.getReactiveBinding(property as StringPropertyKey<Bindings>);\n\t\t\t},\n\t\t}) as ReactiveBindings<Bindings>;\n\t}\n\n\tprivate getReactiveDependency(property: string): ReactiveHostDependency {\n\t\tconst cachedDependency = this.reactiveDependencies.get(property);\n\n\t\tif (cachedDependency) {\n\t\t\treturn cachedDependency;\n\t\t}\n\n\t\tconst dependency = new ReactiveHostDependency(() => this.readReactiveDependencyValue(property));\n\t\tthis.reactiveDependencies.set(property, dependency);\n\t\treturn dependency;\n\t}\n\n\tprivate readReactiveDependencyValue(property: string): unknown {\n\t\tconst reader = this.reactiveDependencyReaders.get(property);\n\n\t\tif (reader) {\n\t\t\treturn reader();\n\t\t}\n\n\t\treturn this.readReactiveBindingValue(property as StringPropertyKey<Bindings>);\n\t}\n\n\tprivate readReactiveBindingValue<Property extends StringPropertyKey<Bindings>>(property: Property): unknown {\n\t\tconst value = this.access.readProperty(this.host, property);\n\n\t\tif (isSignalLikeBindingValue(value)) {\n\t\t\treturn value.get();\n\t\t}\n\n\t\treturn value;\n\t}\n}\n",
|
|
7
|
+
"import type { RadiantElement } from '../core/radiant-element';\n\nexport type AttributeTypeConstant = typeof Array | typeof Boolean | typeof Number | typeof Object | typeof String;\n\nexport type AttributeTypeDefault = Array<unknown> | boolean | number | Record<string, unknown> | string;\n\n/**\n * Parses the given attribute type constant and returns its corresponding string representation.\n *\n * @param constant - The attribute type constant to parse.\n * @returns The string representation of the attribute type constant.\n */\nexport function parseAttributeTypeConstant(constant?: AttributeTypeConstant) {\n\tswitch (constant) {\n\t\tcase Array:\n\t\t\treturn 'array';\n\t\tcase Boolean:\n\t\t\treturn 'boolean';\n\t\tcase Number:\n\t\t\treturn 'number';\n\t\tcase Object:\n\t\t\treturn 'object';\n\t\tcase String:\n\t\t\treturn 'string';\n\t}\n}\n\n/**\n * Parses the attribute type default value and returns its type as a string.\n *\n * @param defaultValue - The default value of the attribute type.\n * @returns The type of the default value as a string.\n */\nexport function parseAttributeTypeDefault(defaultValue?: AttributeTypeDefault) {\n\tswitch (typeof defaultValue) {\n\t\tcase 'boolean':\n\t\t\treturn 'boolean';\n\t\tcase 'number':\n\t\t\treturn 'number';\n\t\tcase 'string':\n\t\t\treturn 'string';\n\t}\n\n\tif (Array.isArray(defaultValue)) return 'array';\n\tif (Object.prototype.toString.call(defaultValue) === '[object Object]') return 'object';\n}\n\n/**\n * Returns the default value for a given attribute type.\n *\n * @param type - The attribute type constant.\n * @returns The default value for the specified attribute type.\n */\nexport function defaultValueForType(type: AttributeTypeConstant): unknown {\n\tswitch (type) {\n\t\tcase Number:\n\t\t\treturn 0;\n\t\tcase String:\n\t\t\treturn '';\n\t\tcase Boolean:\n\t\t\treturn false;\n\t\tdefault:\n\t\t\treturn null;\n\t}\n}\n\ntype Reader = (value: string) => number | string | boolean | object | unknown[];\n\n/**\n * Utility function to parse a JSON string safely\n */\nfunction parseJSON<T>(value: string): T {\n\ttry {\n\t\treturn JSON.parse(value);\n\t} catch {\n\t\tthrow new TypeError('Invalid JSON string');\n\t}\n}\n\n/**\n * Object that maps attribute types to reader functions.\n * @type {Object.<string, Reader>}\n */\nconst readers: { [type: string]: Reader } = {\n\tarray(value: string): unknown[] {\n\t\tconst array = parseJSON<unknown[]>(value);\n\t\tif (!Array.isArray(array)) {\n\t\t\tthrow new TypeError(`Expected an array but got a value of type \"${typeof array}\"`);\n\t\t}\n\t\treturn array;\n\t},\n\n\tboolean(value: string): boolean {\n\t\treturn !(value === '0' || String(value).toLowerCase() === 'false');\n\t},\n\n\tnumber(value: string): number {\n\t\tconst number = Number(value.replace(/_/g, ''));\n\t\treturn number;\n\t},\n\n\tobject(value: string): object {\n\t\tconst object = JSON.parse(value);\n\t\tif (object === null || typeof object !== 'object' || Array.isArray(object)) {\n\t\t\tthrow new TypeError(\n\t\t\t\t`expected value of type \"object\" but instead got value \"${value}\" of type \"${parseAttributeTypeDefault(\n\t\t\t\t\tobject,\n\t\t\t\t)}\"`,\n\t\t\t);\n\t\t}\n\t\treturn object;\n\t},\n\n\tstring(value: string): string {\n\t\treturn value;\n\t},\n};\n\ntype Writer = (value: unknown) => string;\n\n/**\n * Object that maps attribute types to writer functions.\n * @type {Object.<string, Writer>}\n */\nconst writers: { [type: string]: Writer } = {\n\tdefault: writeString,\n\tarray: writeJSON,\n\tobject: writeJSON,\n};\n\nfunction writeJSON(value: unknown) {\n\treturn JSON.stringify(value);\n}\n\nfunction writeString(value: unknown) {\n\treturn `${value}`;\n}\n\n/**\n * Reads the attribute value based on the provided type.\n * @param value - The attribute value to be read.\n * @param type - The type of the attribute.\n * @returns The parsed attribute value.\n * @throws {TypeError} If the provided type is unknown.\n */\nexport function readAttributeValue(value: string, type: AttributeTypeConstant) {\n\tconst readerType = parseAttributeTypeConstant(type);\n\tif (!readerType) throw new TypeError(`[radiant-element] Unknown type \"${type}\"`);\n\treturn readers[readerType]!(value);\n}\n\nexport type ReadAttributeValueReturnType = ReturnType<typeof readAttributeValue>;\n\n/**\n * Writes the attribute value based on the provided type.\n *\n * @param value - The value to be written.\n * @param type - The type of the attribute.\n * @returns The written attribute value.\n * @throws {TypeError} If the provided type is unknown.\n */\nexport function writeAttributeValue(value: unknown, type: AttributeTypeConstant) {\n\tconst writerType = parseAttributeTypeConstant(type);\n\tif (!writerType) throw new TypeError(`[radiant-element] Unknown type \"${type}\"`);\n\tconst writer: Writer = writers[writerType] ?? writers.default ?? writeString;\n\treturn writer(value);\n}\n\nexport type WriteAttributeValueReturnType = ReturnType<typeof writeAttributeValue>;\n\n/*\n * Type guard functions for each type in AttributeTypeConstant\n */\nfunction isBoolean(value: unknown): value is boolean {\n\treturn typeof value === 'boolean';\n}\n\nfunction isNumber(value: unknown): value is number {\n\treturn typeof value === 'number';\n}\n\nfunction isString(value: unknown): value is string {\n\treturn typeof value === 'string';\n}\n\nfunction isArray(value: unknown): value is Array<unknown> {\n\treturn Array.isArray(value);\n}\n\nfunction isObject(value: unknown): value is object {\n\treturn typeof value === 'object' && !Array.isArray(value) && value !== null;\n}\n\n/*\n * Check function to ensure defaultValue matches the type\n */\nexport function isValueOfType(type: AttributeTypeConstant, defaultValue: unknown): boolean {\n\tswitch (type) {\n\t\tcase Boolean:\n\t\t\treturn isBoolean(defaultValue);\n\t\tcase Number:\n\t\t\treturn isNumber(defaultValue);\n\t\tcase String:\n\t\t\treturn isString(defaultValue);\n\t\tcase Array:\n\t\t\treturn isArray(defaultValue);\n\t\tcase Object:\n\t\t\treturn isObject(defaultValue);\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\nexport const getInitialValue = (\n\ttarget: RadiantElement,\n\ttype: AttributeTypeConstant,\n\tattributeKey: string,\n\tdefaultValue: unknown,\n) => {\n\tif (type === Boolean) {\n\t\tconst attributeValue = target.getAttribute(attributeKey);\n\t\tif (attributeValue === null) {\n\t\t\treturn defaultValue;\n\t\t}\n\n\t\treturn attributeValue === '' ? true : readAttributeValue(attributeValue, type);\n\t}\n\n\tconst attributeValue = target.getAttribute(attributeKey);\n\treturn attributeValue !== null\n\t\t? readAttributeValue(attributeValue, type)\n\t\t: (defaultValue ?? (defaultValueForType(type) as typeof defaultValue));\n};\n",
|
|
8
|
+
"import { render as renderJsx, type JsxRenderable, type SubscribableJsxValue } from '@ecopages/jsx';\nimport { Computed, subtle } from '@ecopages/signals';\nimport type { UnknownContext } from '../context/types';\nimport { runLegacyInstanceInitializers } from '../decorators/legacy/instance-initializers';\nimport { ReactiveHost, type ReactiveHostLike } from './reactive-host';\nimport type {\n\tReactivePropertyOptions,\n\tReactiveBindingValue,\n\tReactiveBindings,\n\tReactiveFieldOptions,\n} from './radiant-element';\nimport type { ReactiveBindingOption } from './radiant-element';\nimport type { SsrSerializableHydrationBinding } from './ssr-hydration-binding';\nimport { defaultValueForType, isValueOfType } from '../utils/attribute-utils';\n\ntype StringPropertyKey<Value> = Extract<keyof Value, string>;\n\n/**\n * Attaches Radiant reactivity to an existing DOM element without defining a\n * custom element.\n *\n * `RadiantController` is the controller-host counterpart to `RadiantElement`.\n * It can enhance authored DOM, or it can take over the host's inner DOM by\n * overriding `render()`.\n *\n * When used with the controller registry, the attached host is typically an\n * element carrying `data-controller=\"...\"`.\n *\n * @typeParam Bindings - Explicit internal bindable shape. Include only the\n * reactive keys that JSX bindings should accept.\n */\nexport class RadiantController<Bindings extends object = {}> implements ReactiveHostLike<Bindings> {\n\tpublic readonly host: Element;\n\tpublic readonly element: Element;\n\tpublic readonly bindings: ReactiveBindings<Bindings>;\n\tpublic readonly $: ReactiveBindings<Bindings>;\n\n\tprivate readonly reactiveHost: ReactiveHost<this, Bindings>;\n\tprivate connected = false;\n\tprivate isRendering = false;\n\tprivate isRenderScheduled = false;\n\tprivate isSsrLifecycle = false;\n\tprivate needsRender = false;\n\tprivate renderSignal?: Computed<JsxRenderable>;\n\tprivate readonly renderWatcher = new subtle.Watcher(() => {\n\t\tthis.requestUpdate();\n\t});\n\n\tconstructor(host: Element) {\n\t\tthis.host = host;\n\t\tthis.element = host;\n\t\tthis.reactiveHost = new ReactiveHost<this, Bindings>(\n\t\t\tthis,\n\t\t\t{\n\t\t\t\tdefineProperty: (target, property, descriptor) => Object.defineProperty(target, property, descriptor),\n\t\t\t\thasProperty: (target, property) => property in target,\n\t\t\t\treadProperty: (target, property) => (target as Record<string, unknown>)[property],\n\t\t\t},\n\t\t\t() => this.shouldAutoBindReactiveMembers(),\n\t\t);\n\t\tthis.bindings = this.reactiveHost.bindings;\n\t\tthis.$ = this.reactiveHost.$;\n\t\trunLegacyInstanceInitializers(this);\n\t}\n\n\t/**\n\t * Connects the controller to its host and starts reactive subscriptions.\n\t *\n\t * If the controller owns a render lifecycle by overriding `render()`, the\n\t * first update runs immediately after connection.\n\t */\n\tpublic connect(): void {\n\t\tthis.connected = true;\n\t\tthis.reactiveHost.connectHost();\n\n\t\tif (this.shouldRunRenderLifecycle()) {\n\t\t\tthis.update();\n\t\t}\n\t}\n\n\t/**\n\t * Connects the controller for server-side rendering without running the\n\t * browser render/update lifecycle.\n\t */\n\tpublic connectForSsrRender(): void {\n\t\tthis.isSsrLifecycle = true;\n\n\t\ttry {\n\t\t\tthis.connect();\n\t\t} finally {\n\t\t\tthis.isSsrLifecycle = false;\n\t\t}\n\t}\n\n\t/**\n\t * Disconnects the controller from its host and tears down reactive work.\n\t */\n\tpublic disconnect(): void {\n\t\tthis.connected = false;\n\t\tthis.disconnectRenderWatcher();\n\t\tthis.reactiveHost.disconnectHost();\n\t}\n\n\t/**\n\t * Disconnects a controller that was attached through the SSR-only lifecycle.\n\t */\n\tpublic disconnectForSsrRender(): void {\n\t\tthis.disconnect();\n\t}\n\n\tpublic get isConnected(): boolean {\n\t\treturn this.connected;\n\t}\n\n\t/**\n\t * Returns the JSX tree rendered into the attached host.\n\t *\n\t * The base implementation renders nothing. Override this method when the\n\t * controller should own the host's inner DOM instead of only enhancing\n\t * authored markup.\n\t */\n\tpublic render(): JsxRenderable {\n\t\treturn null;\n\t}\n\n\t/**\n\t * Schedules a render pass for render-owning controllers.\n\t *\n\t * Multiple calls in the same microtask are coalesced into a single update.\n\t */\n\tpublic requestUpdate(): void {\n\t\tif (!this.shouldRunRenderLifecycle()) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.needsRender = true;\n\n\t\tif (this.isRenderScheduled) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.isRenderScheduled = true;\n\n\t\tqueueMicrotask(() => {\n\t\t\tthis.isRenderScheduled = false;\n\n\t\t\tif (!this.needsRender) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.update();\n\t\t});\n\t}\n\n\t/**\n\t * Flushes the current render output into the attached host element.\n\t *\n\t * This is a no-op unless the controller overrides `render()`.\n\t */\n\tpublic update(): void {\n\t\tif (!this.shouldRunRenderLifecycle()) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst renderTarget = this.getRenderTarget();\n\n\t\tif (!renderTarget) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.needsRender = true;\n\n\t\tif (!this.connected || this.isRendering) {\n\t\t\treturn;\n\t\t}\n\n\t\twhile (this.needsRender) {\n\t\t\tthis.needsRender = false;\n\t\t\tthis.isRendering = true;\n\n\t\t\ttry {\n\t\t\t\trenderJsx(this.resolveTrackedRenderOutput(), renderTarget);\n\t\t\t} finally {\n\t\t\t\tthis.isRendering = false;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Returns a subscribable JSX binding for a selected reactive member.\n\t */\n\tpublic bind<Property extends StringPropertyKey<Bindings>>(\n\t\tproperty: Property,\n\t): SubscribableJsxValue<ReactiveBindingValue<Bindings, Property>> {\n\t\treturn this.reactiveHost.bind(property);\n\t}\n\n\t/**\n\t * Returns the cached binding object for a selected reactive member.\n\t */\n\tpublic getReactiveBinding<Property extends StringPropertyKey<Bindings>>(\n\t\tproperty: Property,\n\t): SubscribableJsxValue<ReactiveBindingValue<Bindings, Property>> {\n\t\treturn this.reactiveHost.getReactiveBinding(property);\n\t}\n\n\t/**\n\t * Defines a reactive field directly on the controller instance.\n\t */\n\tpublic createReactiveField<T>(propertyName: string, initialValue: T, options: ReactiveFieldOptions = {}): void {\n\t\tthis.reactiveHost.createReactiveField(propertyName, initialValue, options);\n\t}\n\n\t/**\n\t * Defines a controller prop backed by the attached host element's property\n\t * channel instead of attribute serialization.\n\t *\n\t * This gives controller-based integrations the same reactive field surface as\n\t * `@prop(...)` on `RadiantElement`, while allowing external code to assign\n\t * structured values such as arrays or objects directly on `controller.host`.\n\t */\n\tpublic createReactiveProp<T = unknown>(propertyName: string, options: ReactivePropertyOptions<T>): void {\n\t\tconst { type, defaultValue, bind } = options;\n\n\t\tif (defaultValue !== undefined && !isValueOfType(type, defaultValue)) {\n\t\t\tthrow new Error(`defaultValue does not match the expected type for ${type.name}`);\n\t\t}\n\n\t\tconst ownDescriptor = Object.getOwnPropertyDescriptor(this.host, propertyName);\n\t\tconst hostRecord = this.host as unknown as Record<PropertyKey, unknown>;\n\t\tconst initialHostValue = hostRecord[propertyName] as T | undefined;\n\t\tlet currentValue = (initialHostValue ?? defaultValue ?? defaultValueForType(type)) as T;\n\n\t\tthis.reactiveHost.defineReactiveAccessor(propertyName, {\n\t\t\tbind,\n\t\t\tgetValue: () => currentValue,\n\t\t\tsetValue: (newValue: T) => {\n\t\t\t\tcurrentValue = newValue;\n\t\t\t},\n\t\t\tnotifyInitialValue: currentValue,\n\t\t});\n\n\t\tObject.defineProperty(this.host, propertyName, {\n\t\t\tget: () => (this as Record<PropertyKey, unknown>)[propertyName],\n\t\t\tset: (newValue: T) => {\n\t\t\t\t(this as Record<PropertyKey, unknown>)[propertyName] = newValue;\n\t\t\t},\n\t\t\tenumerable: ownDescriptor?.enumerable ?? true,\n\t\t\tconfigurable: true,\n\t\t});\n\n\t\tthis.registerCleanupCallback(() => {\n\t\t\tconst finalValue = (this as Record<PropertyKey, unknown>)[propertyName];\n\n\t\t\tif (ownDescriptor) {\n\t\t\t\tObject.defineProperty(this.host, propertyName, ownDescriptor);\n\n\t\t\t\tif ('value' in ownDescriptor && ownDescriptor.writable) {\n\t\t\t\t\thostRecord[propertyName] = finalValue;\n\t\t\t\t}\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tdelete hostRecord[propertyName];\n\n\t\t\ttry {\n\t\t\t\thostRecord[propertyName] = finalValue;\n\t\t\t} catch {\n\t\t\t\tObject.defineProperty(this.host, propertyName, {\n\t\t\t\t\tvalue: finalValue,\n\t\t\t\t\twritable: true,\n\t\t\t\t\tenumerable: true,\n\t\t\t\t\tconfigurable: true,\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t}\n\n\t/**\n\t * Defines a JSX binding companion such as `$count` for a reactive member.\n\t */\n\tpublic defineReactiveBinding(property: string, bind: ReactiveBindingOption = true): void {\n\t\tthis.reactiveHost.defineReactiveBinding(property, bind);\n\t}\n\n\tpublic notifyUpdate(changedProperty: string, oldValue: unknown, value: unknown): void {\n\t\tthis.reactiveHost.notifyUpdate(changedProperty, oldValue, value);\n\t}\n\n\tpublic registerUpdateCallback(property: string, update: (...rest: any[]) => any): () => void {\n\t\treturn this.reactiveHost.registerUpdateCallback(property, update);\n\t}\n\n\tpublic connectedContextCallback(_contextName: UnknownContext): void {}\n\n\tpublic registerContextProvider(_name: string, _provider: unknown): void {\n\t\t// Controller context support is currently client-only.\n\t}\n\n\tpublic registerHydrationBinding(_name: string, _binding: SsrSerializableHydrationBinding): void {}\n\n\tpublic registerCleanupCallback(callback: () => void): void {\n\t\tthis.reactiveHost.registerCleanupCallback(callback);\n\t}\n\n\tpublic registerConnectedCallback(callback: () => void): void {\n\t\tthis.reactiveHost.registerConnectedCallback(callback);\n\t}\n\n\tpublic registerReactiveDependencyReader(property: string, read: () => unknown): void {\n\t\tthis.reactiveHost.registerReactiveDependencyReader(property, read);\n\t}\n\n\tpublic trackReactiveRead(property: string): void {\n\t\tthis.reactiveHost.trackReactiveRead(property);\n\t}\n\n\tpublic addEventListener(\n\t\ttype: string,\n\t\tlistener: EventListenerOrEventListenerObject,\n\t\toptions?: boolean | AddEventListenerOptions,\n\t): void {\n\t\tthis.host.addEventListener(type, listener, options);\n\t}\n\n\tpublic removeEventListener(\n\t\ttype: string,\n\t\tlistener: EventListenerOrEventListenerObject,\n\t\toptions?: boolean | EventListenerOptions,\n\t): void {\n\t\tthis.host.removeEventListener(type, listener, options);\n\t}\n\n\tpublic dispatchEvent(event: Event): boolean {\n\t\treturn this.host.dispatchEvent(event);\n\t}\n\n\t/**\n\t * Finds one or more elements inside the attached host by `data-ref`.\n\t *\n\t * Prefer `@query(...)` for stable, decorator-backed refs and use `getRef(...)`\n\t * for one-off lookups.\n\t */\n\tpublic getRef<T extends Element = Element>(ref: string, all: true): T[];\n\tpublic getRef<T extends Element = Element>(ref: string, all?: false): T | null;\n\tpublic getRef<T extends Element = Element>(ref: string, all = false): T | T[] | null {\n\t\tconst selector = `[data-ref=\"${ref}\"]`;\n\n\t\tif (all) {\n\t\t\treturn Array.from(this.host.querySelectorAll(selector)) as T[];\n\t\t}\n\n\t\treturn (this.host.querySelector(selector) as T) ?? null;\n\t}\n\n\tprotected shouldAutoBindReactiveMembers(): boolean {\n\t\treturn true;\n\t}\n\n\tprotected shouldRunRenderLifecycle(): boolean {\n\t\treturn !this.isSsrLifecycle && this.render !== RadiantController.prototype.render;\n\t}\n\n\tprivate getRenderTarget(): HTMLElement | null {\n\t\treturn this.host instanceof HTMLElement ? this.host : null;\n\t}\n\n\tprivate disconnectRenderWatcher(): void {\n\t\tif (!this.renderSignal) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.renderWatcher.unwatch(this.renderSignal);\n\t\tthis.renderSignal = undefined;\n\t}\n\n\tprivate resolveTrackedRenderOutput(): JsxRenderable {\n\t\tconst nextRenderSignal = new Computed(() => this.render());\n\t\tconst output = nextRenderSignal.get();\n\n\t\tif (!this.connected) {\n\t\t\treturn output;\n\t\t}\n\n\t\tif (this.renderSignal) {\n\t\t\tthis.renderWatcher.unwatch(this.renderSignal);\n\t\t}\n\n\t\tthis.renderS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K,oBAAoB,EAAM,EAAU,CAAO,EAG/C,aAAa,CAAC,EAAuB,CAC3C,OAAO,KAAK,KAAK,cAAc,CAAK,EAW9B,MAAmC,CAAC,EAAa,EAAM,GAAuB,CACpF,IAAM,EAAW,cAAc,MAE/B,GAAI,EACH,OAAO,MAAM,KAAK,KAAK,KAAK,iBAAiB,CAAQ,CAAC,EAGvD,OAAQ,KAAK,KAAK,cAAc,CAAQ,GAAW,KAG1C,6BAA6B,EAAY,CAClD,MAAO,GAGE,wBAAwB,EAAY,CAC7C,MAAO,CAAC,KAAK,gBAAkB,KAAK,SAAW,EAAkB,UAAU,OAGpE,eAAe,EAAuB,CAC7C,OAAO,KAAK,gBAAgB,YAAc,KAAK,KAAO,KAG/C,uBAAuB,EAAS,CACvC,GAAI,CAAC,KAAK,aACT,OAGD,KAAK,cAAc,QAAQ,KAAK,YAAY,EAC5C,KAAK,aAAe,OAGb,0BAA0B,EAAkB,CACnD,IAAM,EAAmB,IAAI,EAAS,IAAM,KAAK,OAAO,CAAC,EACnD,EAAS,EAAiB,IAAI,EAEpC,GAAI,CAAC,KAAK,UACT,OAAO,EAGR,GAAI,KAAK,aACR,KAAK,cAAc,QAAQ,KAAK,YAAY,EAK7C,OAFA,KAAK,aAAe,EACpB,KAAK,cAAc,MAAM,CAAgB,EAClC,EAET",
|
|
11
|
+
"debugId": "3254076C7E6FE49F64756E2164756E21",
|
|
12
|
+
"names": []
|
|
13
|
+
}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import type { EventEmitter } from '../tools';
|
|
2
2
|
import { type JsxRenderable, type SubscribableJsxValue } from '@ecopages/jsx';
|
|
3
|
+
import type { RenderToStringOptions } from '@ecopages/jsx/server';
|
|
3
4
|
import type { SsrSerializableContextProvider } from '../context/context-provider';
|
|
4
5
|
import type { UnknownContext } from '../context/types';
|
|
5
6
|
import type { SsrSerializableHydrationBinding } from './ssr-hydration-binding';
|
|
7
|
+
import { type RadiantElementRenderBridge } from './radiant-component-ssr-registry';
|
|
6
8
|
import { type AttributeTypeConstant, type ReadAttributeValueReturnType, type WriteAttributeValueReturnType } from '../utils/attribute-utils';
|
|
7
9
|
declare const RadiantElementBase: {
|
|
8
10
|
new (): HTMLElement;
|
|
9
11
|
prototype: HTMLElement;
|
|
10
12
|
};
|
|
11
|
-
type
|
|
13
|
+
type RadiantRenderTarget = HTMLElement | ShadowRoot;
|
|
12
14
|
/**
|
|
13
15
|
* Possible positions to insert a rendered template.
|
|
14
16
|
*/
|
|
@@ -225,30 +227,21 @@ export interface IRadiantElement<Bindings extends object = {}> {
|
|
|
225
227
|
* @implements IRadiantElement<Bindings>
|
|
226
228
|
*/
|
|
227
229
|
export declare class RadiantElement<Bindings extends object = {}> extends RadiantElementBase implements IRadiantElement<Bindings> {
|
|
230
|
+
/**
|
|
231
|
+
* Controls where the JSX render lifecycle mounts the component view.
|
|
232
|
+
*
|
|
233
|
+
* Subclasses can override this with `'shadow'` to force an internal open
|
|
234
|
+
* shadow root for client-side rendering. Host SSR helpers remain light-DOM
|
|
235
|
+
* only and throw when shadow render mode is enabled.
|
|
236
|
+
*/
|
|
237
|
+
protected readonly renderRootMode: 'light' | 'shadow';
|
|
228
238
|
readonly bindings: ReactiveBindings<Bindings>;
|
|
229
239
|
readonly $: ReactiveBindings<Bindings>;
|
|
240
|
+
private readonly reactiveHost;
|
|
230
241
|
/**
|
|
231
242
|
* A map of property metadata objects, it contains useful information about the properties configured via decorators.
|
|
232
243
|
*/
|
|
233
244
|
private reactiveProperties;
|
|
234
|
-
/**
|
|
235
|
-
* A map of reactive fields, it contains the reactive fields configured via decorators.
|
|
236
|
-
*/
|
|
237
|
-
private reactiveFields;
|
|
238
|
-
/**
|
|
239
|
-
* Stable dependency nodes used when plain reactive member reads participate
|
|
240
|
-
* in tracked component renders.
|
|
241
|
-
*/
|
|
242
|
-
private reactiveDependencies;
|
|
243
|
-
/**
|
|
244
|
-
* Raw value readers for reactive members whose public getter should also
|
|
245
|
-
* register tracked render dependencies.
|
|
246
|
-
*/
|
|
247
|
-
private reactiveDependencyReaders;
|
|
248
|
-
/**
|
|
249
|
-
* Stable subscribable JSX bindings keyed by reactive property name.
|
|
250
|
-
*/
|
|
251
|
-
private reactiveBindings;
|
|
252
245
|
/**
|
|
253
246
|
* Registered context providers keyed by decorated property name.
|
|
254
247
|
*/
|
|
@@ -257,10 +250,6 @@ export declare class RadiantElement<Bindings extends object = {}> extends Radian
|
|
|
257
250
|
* Registered keyed hydration payload producers appended to SSR host output.
|
|
258
251
|
*/
|
|
259
252
|
private hydrationBindings;
|
|
260
|
-
/**
|
|
261
|
-
* A map of property update callbacks. These callbacks are called when a property is updated.
|
|
262
|
-
*/
|
|
263
|
-
private updateCallbacks;
|
|
264
253
|
/**
|
|
265
254
|
* A map of event subscriptions used to manage event listeners on the Radiant element.
|
|
266
255
|
*/
|
|
@@ -269,20 +258,36 @@ export declare class RadiantElement<Bindings extends object = {}> extends Radian
|
|
|
269
258
|
* A map for event emitters
|
|
270
259
|
*/
|
|
271
260
|
private eventEmitters;
|
|
272
|
-
/**
|
|
273
|
-
* Callbacks executed whenever the Radiant element is connected to the DOM.
|
|
274
|
-
*/
|
|
275
|
-
private onConnectedCallbacks;
|
|
276
|
-
/**
|
|
277
|
-
* An array of cleanup callbacks to be executed when the Radiant element is disconnected from the DOM.
|
|
278
|
-
*/
|
|
279
|
-
private onDisconnectedCallback;
|
|
280
261
|
/**
|
|
281
262
|
* A flag indicating whether the element has been connected to the DOM.
|
|
282
263
|
*/
|
|
283
264
|
private elementReady;
|
|
265
|
+
private isRendering;
|
|
266
|
+
private isFirstConnectPending;
|
|
267
|
+
private isRenderScheduled;
|
|
268
|
+
private needsRender;
|
|
269
|
+
/**
|
|
270
|
+
* Snapshot of own-property values that existed before Radiant installs the
|
|
271
|
+
* reactive accessors for declared props.
|
|
272
|
+
*
|
|
273
|
+
* "Pre-upgrade" refers to the custom-element upgrade window where user code,
|
|
274
|
+
* SSR boot code, or another framework assigns `element.someProp = value`
|
|
275
|
+
* before the browser has finished constructing the final custom-element class
|
|
276
|
+
* instance with its accessors in place.
|
|
277
|
+
*
|
|
278
|
+
* Those early assignments land as plain own properties on the element. If we
|
|
279
|
+
* define a reactive accessor later without first capturing them, the accessor
|
|
280
|
+
* would either miss the assigned value or remain shadowed by the own property.
|
|
281
|
+
* `createReactiveProp()` consumes this snapshot so the early value becomes the
|
|
282
|
+
* prop's initial reactive state.
|
|
283
|
+
*/
|
|
284
|
+
private readonly preUpgradePropertyValues;
|
|
285
|
+
private projectedSlotContent;
|
|
286
|
+
private renderSignal?;
|
|
287
|
+
private readonly renderWatcher;
|
|
288
|
+
private slotProjectionObserver?;
|
|
289
|
+
private slotProjectionVersion;
|
|
284
290
|
constructor();
|
|
285
|
-
private createReactiveBindingNamespace;
|
|
286
291
|
connectedCallback(): void;
|
|
287
292
|
connectedContextCallback(_contextName: UnknownContext): void;
|
|
288
293
|
disconnectedCallback(): void;
|
|
@@ -303,10 +308,16 @@ export declare class RadiantElement<Bindings extends object = {}> extends Radian
|
|
|
303
308
|
insert?: RenderInsertPosition;
|
|
304
309
|
sanitize?: (html: string) => string;
|
|
305
310
|
}): void;
|
|
311
|
+
render(): JsxRenderable;
|
|
312
|
+
renderToString(options?: RenderToStringOptions): string;
|
|
313
|
+
renderHost(): JsxRenderable;
|
|
314
|
+
renderHostToString(options?: RenderToStringOptions): string;
|
|
315
|
+
hydrate(): void;
|
|
316
|
+
requestUpdate(): void;
|
|
317
|
+
update(): void;
|
|
306
318
|
registerReactiveProperty(config: ReactiveProperty): void;
|
|
307
319
|
protected getReactiveProperties(): ReactiveProperty[];
|
|
308
|
-
|
|
309
|
-
registerReactiveDependencyReader(property: string, read: ReactiveDependencyReader): void;
|
|
320
|
+
registerReactiveDependencyReader(property: string, read: () => unknown): void;
|
|
310
321
|
registerContextProvider(name: string, provider: SsrSerializableContextProvider): void;
|
|
311
322
|
registerHydrationBinding(name: string, binding: SsrSerializableHydrationBinding): void;
|
|
312
323
|
protected getContextProviders(): SsrSerializableContextProvider[];
|
|
@@ -322,20 +333,24 @@ export declare class RadiantElement<Bindings extends object = {}> extends Radian
|
|
|
322
333
|
/**
|
|
323
334
|
* Returns the default JSX binding policy for reactive members on this host.
|
|
324
335
|
*
|
|
325
|
-
*
|
|
326
|
-
*
|
|
327
|
-
*
|
|
328
|
-
*
|
|
336
|
+
* `RadiantElement` hosts default to automatic bindings for reactive members
|
|
337
|
+
* when no explicit `bind` option is supplied.
|
|
338
|
+
*
|
|
339
|
+
* Lower-level hosts can override this hook to opt out when they want binding
|
|
340
|
+
* creation to stay fully explicit across `@prop`, `@state`, and direct
|
|
341
|
+
* `createReactiveProp`/`createReactiveField` calls.
|
|
329
342
|
*/
|
|
330
343
|
protected shouldAutoBindReactiveMembers(): boolean;
|
|
344
|
+
protected shouldRunRenderLifecycle(): boolean;
|
|
345
|
+
/** Returns the DOM root used by client-side render and hydrate work. */
|
|
346
|
+
protected getRenderTarget(): RadiantRenderTarget;
|
|
347
|
+
protected getHostSsrAttributes(): Record<string, string>;
|
|
348
|
+
protected resolveSsrRenderBridge(): RadiantElementRenderBridge;
|
|
331
349
|
registerUpdateCallback(property: string, update: (...rest: any[]) => any): () => void;
|
|
332
350
|
getReactiveBinding<Property extends StringPropertyKey<Bindings>>(property: Property): SubscribableJsxValue<ReactiveBindingValue<Bindings, Property>>;
|
|
333
351
|
bind<Property extends StringPropertyKey<Bindings>>(property: Property): SubscribableJsxValue<ReactiveBindingValue<Bindings, Property>>;
|
|
334
352
|
defineReactiveBinding(property: string, bind?: ReactiveBindingOption): void;
|
|
335
|
-
private getReactiveDependency;
|
|
336
353
|
trackReactiveRead(property: string): void;
|
|
337
|
-
private readReactiveDependencyValue;
|
|
338
|
-
private readReactiveBindingValue;
|
|
339
354
|
subscribeEvents(events: RadiantElementEventListener[]): Array<() => void>;
|
|
340
355
|
subscribeEvent(eventConfig: RadiantElementEventListener): () => void;
|
|
341
356
|
private unsubscribeEvent;
|
|
@@ -355,7 +370,31 @@ export declare class RadiantElement<Bindings extends object = {}> extends Radian
|
|
|
355
370
|
registerEventEmitter(name: string, emitter: EventEmitter): void;
|
|
356
371
|
getRef<T extends Element = Element>(ref: string, all: true): T[];
|
|
357
372
|
getRef<T extends Element = Element>(ref: string, all?: false): T | null;
|
|
373
|
+
getSlotElement<T extends Element = Element>(name?: string): T | null;
|
|
374
|
+
getSlotElements<T extends Element = Element>(name?: string): T[];
|
|
358
375
|
createReactiveField<T>(propertyName: string, initialValue: T, options?: ReactiveFieldOptions): void;
|
|
376
|
+
/**
|
|
377
|
+
* Defines a reactive custom-element property backed by a Radiant accessor.
|
|
378
|
+
*
|
|
379
|
+
* When the host was assigned a value before upgrade, that pre-upgrade value is
|
|
380
|
+
* preferred over attribute parsing and `defaultValue` so early `.prop = value`
|
|
381
|
+
* writes survive into the reactive lifecycle.
|
|
382
|
+
*/
|
|
359
383
|
createReactiveProp<T = unknown>(propertyName: string, options: ReactivePropertyOptions<T>): void;
|
|
384
|
+
private ensureSlotProjectionState;
|
|
385
|
+
private getHostChildNodeCount;
|
|
386
|
+
private getSlotProjectionScriptTag;
|
|
387
|
+
private getAuthoredHydrationScriptMarkup;
|
|
388
|
+
private handleSlotProjectionMutations;
|
|
389
|
+
private addProjectedSlotNode;
|
|
390
|
+
private removeProjectedSlotNode;
|
|
391
|
+
private observeSlotProjection;
|
|
392
|
+
private disconnectSlotProjectionObserver;
|
|
393
|
+
private disconnectRenderWatcher;
|
|
394
|
+
private resolveTrackedRenderOutput;
|
|
395
|
+
private resolveRenderOutput;
|
|
396
|
+
private getEventSubscriptionTarget;
|
|
397
|
+
private getQueryRoot;
|
|
398
|
+
private assertSupportsHostSsrRendering;
|
|
360
399
|
}
|
|
361
400
|
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{H as a}from"../chunk-84fc8cz9.js";import"../chunk-9gjmqxp2.js";import"../chunk-8tvt04cm.js";import"../chunk-73x7jpdd.js";import"../chunk-8xy18qmz.js";export{a as RadiantElement};
|
|
1
|
+
var h0=((Q)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(Q,{get:($,W)=>(typeof require<"u"?require:$)[W]}):Q)(function(Q){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+Q+'" is not supported')});var D=Symbol.for("@ecopages/radiant.legacy-instance-initializers");function f0(Q,$){let X=Q[D];if(Array.isArray(X)){X.push($);return}Object.defineProperty(Q,D,{value:[$],configurable:!0})}function _(Q){let $=[],W=Object.getPrototypeOf(Q);while(W&&W!==Object.prototype)$.push(W),W=Object.getPrototypeOf(W);for(let X=$.length-1;X>=0;X-=1){let Z=$[X][D];if(!Array.isArray(Z))continue;for(let q of Z)q(Q)}}import{createSubscribableJsxValue as W0}from"@ecopages/jsx";import{trackDependency as C}from"@ecopages/signals";class I{read;subscribers=new Set;watcherListeners=new Set;version=0;constructor(Q){this.read=Q}get(){return C(this),this.read()}subscribe(Q){return this.subscribers.add(Q),()=>{this.subscribers.delete(Q)}}addWatcher(Q){return this.watcherListeners.add(Q),()=>{this.watcherListeners.delete(Q)}}getVersion(){return this.version}notify(Q){this.version+=1;let $;try{this.notifyWatchers()}catch(W){$=W}if(this.publish(Q),$)throw $}publish(Q){for(let $ of this.subscribers)$(Q)}notifyWatchers(){let Q=[];for(let $ of this.watcherListeners)try{$()}catch(W){Q.push(W)}if(Q.length===1)throw Q[0];if(Q.length>1)throw AggregateError(Q,"Multiple reactive dependency notifications failed.")}}function X0(Q){return typeof Q==="object"&&Q!==null&&typeof Q.get==="function"}class w{host;access;shouldAutoBind;bindings;$;reactiveFields=new Map;reactiveDependencies=new Map;reactiveDependencyReaders=new Map;reactiveBindings=new Map;updateCallbacks=new Map;onConnectedCallbacks=[];onDisconnectedCallback=[];constructor(Q,$,W){this.host=Q;this.access=$;this.shouldAutoBind=W;let X=this.createReactiveBindingNamespace();this.bindings=X,this.$=X}connectHost(){for(let Q of this.onConnectedCallbacks)Q()}disconnectHost(){for(let Q of this.onDisconnectedCallback)Q()}notifyUpdate(Q,$,W){if($===W)return;this.reactiveDependencies.get(Q)?.notify(W);let X=this.updateCallbacks.get(Q);if(X)for(let Z of X)Z()}registerCleanupCallback(Q){this.onDisconnectedCallback.push(Q)}registerConnectedCallback(Q){this.onConnectedCallbacks.push(Q)}registerHydrationBinding(Q,$){}registerReactiveDependencyReader(Q,$){this.reactiveDependencyReaders.set(Q,$)}registerUpdateCallback(Q,$){if(!this.updateCallbacks.has(Q))this.updateCallbacks.set(Q,new Set);let W=this.updateCallbacks.get(Q);return W.add($),()=>{if(W.delete($),W.size===0)this.updateCallbacks.delete(Q)}}getReactiveBinding(Q){let $=this.reactiveBindings.get(Q);if($)return $;let W=W0({getValue:()=>this.readReactiveBindingValue(Q),subscribe:(X)=>this.registerUpdateCallback(Q,()=>{X(this.readReactiveBindingValue(Q))})});return this.reactiveBindings.set(Q,W),W}bind(Q){return this.getReactiveBinding(Q)}defineReactiveBinding(Q,$=!0){let W=typeof $==="string"?$:$?`$${Q}`:void 0,X=this.access.getBindingTarget?.(this.host)??this.host;if(!W||this.access.hasProperty(this.host,W))return;this.access.defineProperty(X,W,{get:()=>this.getReactiveBinding(Q),enumerable:!1,configurable:!0})}trackReactiveRead(Q){C(this.getReactiveDependency(Q))}defineReactiveAccessor(Q,$){let W=$.bind??this.shouldAutoBind();if(this.defineReactiveBinding(Q,W),this.registerReactiveDependencyReader(Q,$.getValue),this.access.defineProperty(this.host,Q,{get:()=>{return this.trackReactiveRead(Q),$.getValue()},set:(X)=>{let Z=$.getValue();if(Z===X)return;$.setValue(X),this.notifyUpdate(Q,Z,X)},enumerable:!0,configurable:!0}),$.notifyInitialValue!==void 0)this.notifyUpdate(Q,void 0,$.notifyInitialValue)}createReactiveField(Q,$,W={}){let X={name:Q,value:$,initialValue:$};this.reactiveFields.set(Q,X),this.defineReactiveAccessor(Q,{bind:W.bind,getValue:()=>this.reactiveFields.get(Q)?.value,setValue:(Z)=>{this.reactiveFields.set(Q,{...X,value:Z})},notifyInitialValue:$})}createReactiveBindingNamespace(){return new Proxy(Object.create(null),{get:(Q,$)=>{if(typeof $!=="string")return;return this.getReactiveBinding($)}})}getReactiveDependency(Q){let $=this.reactiveDependencies.get(Q);if($)return $;let W=new I(()=>this.readReactiveDependencyValue(Q));return this.reactiveDependencies.set(Q,W),W}readReactiveDependencyValue(Q){let $=this.reactiveDependencyReaders.get(Q);if($)return $();return this.readReactiveBindingValue(Q)}readReactiveBindingValue(Q){let $=this.access.readProperty(this.host,Q);if(X0($))return $.get();return $}}var L=Symbol.for("@ecopages/radiant.ssr-preparation-callbacks"),A=Symbol.for("@ecopages/radiant.ssr-preparation-running");function v0(Q,$){let X=Q[L];if(Array.isArray(X)){X.push($);return}Object.defineProperty(Q,L,{value:[$],configurable:!0})}function S(Q){let $=Q,W=$[L];if(!Array.isArray(W))return;$[A]=!0;try{for(let X of W)X()}finally{delete $[A]}}function R(Q){return Q.replace(/&/g,"\\u0026").replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}var F="data-hydration",T="data-hydration-type",O="data-hydration-key";function s0(Q){let $=Q.hydrationKey?` ${O}="${Z0(Q.hydrationKey)}"`:"";return`<script type="application/json" ${F} ${T}="${Q.type}"${$}>${Q.serializedValue}</script>`}function u0(Q){return R(Q)}function d0(Q,$){let W=Q.textContent;if(!W)return $;try{return JSON.parse(W)}catch{if(typeof console<"u")console.warn(`[@ecopages/radiant] Failed to parse hydration payload from <script ${F}>:`,W.slice(0,120));return $}}function i0(Q,$,W){let X=Q.children;if(!X||X.length===0){let Z=Q.childNodes;if(!Z||Z.length===0)return null;for(let q=0;q<Z.length;q+=1){let G=Z[q];if(G.nodeType!==1)continue;let M=G;if(h(M,$,W))return M}return null}for(let Z=0;Z<X.length;Z+=1)if(h(X[Z],$,W))return X[Z];return null}function h(Q,$,W){if(Q.tagName!=="SCRIPT"||!Q.hasAttribute(F)||Q.getAttribute(T)!==$)return!1;if(W!==void 0)return Q.getAttribute(O)===W;return!Q.hasAttribute(O)}function Z0(Q){return Q.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}import{createMarkupNodeLike as q0,isKeyedJsxValue as f,isSlotJsxValue as G0}from"@ecopages/jsx";var z="",H="data-radiant-slot-projection";function N(Q){let $=new Map;for(let W of Array.from(Q.childNodes)){if(z0(W))continue;J0($,M0(W),W)}return $}function V(Q){let $;try{$=JSON.parse(Q)}catch{if(typeof console<"u")console.warn("[@ecopages/radiant] Failed to parse slot projection payload:",Q.slice(0,120));return new Map}let W=new Map;for(let[X,Z]of Object.entries($)){if(!Array.isArray(Z)||Z.length===0)continue;W.set(P(X),Z.map((q)=>q0(q)))}return W}function g(Q){let $=Array.from(Q.childNodes).filter((W)=>s(W)).map((W)=>B(W)??"").filter((W)=>W!=="");return $.length>0?$.join(""):void 0}function m(Q){let $={};for(let[W,X]of Q.entries()){let Z=X.map((q)=>B(q)).filter((q)=>q!==void 0&&q!=="");if(Z.length>0)$[W]=Z}return Object.keys($).length>0?JSON.stringify($):void 0}function v(Q,$){let W=!1,X=(q)=>{if(G0(q))return W=!0,B0(q,$,X);if(f(q))return F0(q,X(q.value));if(U0(q))return{_$rType$:1,rootLocalName:q.rootLocalName,strings:q.strings,values:q.values.map((G)=>X(G))};if(c(q))return Array.from(q,(G)=>X(G));return q},Z=X(Q);return{containsSlots:W,value:Z}}function b(Q){for(let $ of Array.from(Q.childNodes)){if(!y($))continue;let W=$.textContent??void 0;return $.parentNode?.removeChild($),W}return}function J0(Q,$,W){let X=Q.get($);if(X){X.push(W);return}Q.set($,[W])}function F0(Q,$){return{...Q,value:$}}function M0(Q){if(Q instanceof Element)return P(Q.getAttribute("slot"));return z}function c(Q){return typeof Q!=="string"&&typeof Q==="object"&&Q!==null&&Symbol.iterator in Q}function y(Q){return Q instanceof HTMLScriptElement&&Q.hasAttribute(H)}function s(Q){return Q instanceof HTMLScriptElement&&Q.hasAttribute(F)}function z0(Q){return y(Q)||s(Q)}function U0(Q){return typeof Q==="object"&&Q!==null&&Q._$rType$===1&&Array.isArray(Q.strings)&&Array.isArray(Q.values)}function P(Q){return Q??z}function B(Q){if(Q===void 0||Q===null||Q===!1||Q===!0)return;if(typeof Node<"u"&&Q instanceof Node){if(Q.nodeType===Node.TEXT_NODE)return Q.textContent??"";return Q.outerHTML??Q.textContent??void 0}if(f(Q))return B(Q.value);if(typeof Q==="string"||typeof Q==="number"||typeof Q==="bigint")return String(Q);if(typeof Q==="object"&&Q!==null&&"outerHTML"in Q)return typeof Q.outerHTML==="string"?Q.outerHTML:Q.textContent??void 0;if(c(Q))return Array.from(Q,($)=>B($)??"").join("");return}function B0(Q,$,W){let X=$.get(P(Q.name));if(X&&X.length>0)return X.length===1?X[0]:X;if(Q.fallback===void 0)return"";return W(Q.fallback)}var E=Symbol.for("@ecopages/radiant.hydrator-installed");function a0(){globalThis[E]=!0}function r0(){delete globalThis[E]}function u(){return globalThis[E]===!0}var d=Symbol.for("@ecopages/radiant.component-ssr-runtime");function i(){return globalThis[d]}function e0(Q){globalThis[d]=Q}function o(Q){switch(Q){case Array:return"array";case Boolean:return"boolean";case Number:return"number";case Object:return"object";case String:return"string"}}function H0(Q){switch(typeof Q){case"boolean":return"boolean";case"number":return"number";case"string":return"string"}if(Array.isArray(Q))return"array";if(Object.prototype.toString.call(Q)==="[object Object]")return"object"}function Y0(Q){switch(Q){case Number:return 0;case String:return"";case Boolean:return!1;default:return null}}function K0(Q){try{return JSON.parse(Q)}catch{throw TypeError("Invalid JSON string")}}var j0={array(Q){let $=K0(Q);if(!Array.isArray($))throw TypeError(`Expected an array but got a value of type "${typeof $}"`);return $},boolean(Q){return!(Q==="0"||String(Q).toLowerCase()==="false")},number(Q){return Number(Q.replace(/_/g,""))},object(Q){let $=JSON.parse(Q);if($===null||typeof $!=="object"||Array.isArray($))throw TypeError(`expected value of type "object" but instead got value "${Q}" of type "${H0($)}"`);return $},string(Q){return Q}},p={default:n,array:l,object:l};function l(Q){return JSON.stringify(Q)}function n(Q){return`${Q}`}function Y(Q,$){let W=o($);if(!W)throw TypeError(`[radiant-element] Unknown type "${$}"`);return j0[W](Q)}function a(Q,$){let W=o($);if(!W)throw TypeError(`[radiant-element] Unknown type "${$}"`);return(p[W]??p.default??n)(Q)}function x0(Q){return typeof Q==="boolean"}function D0(Q){return typeof Q==="number"}function w0(Q){return typeof Q==="string"}function L0(Q){return Array.isArray(Q)}function O0(Q){return typeof Q==="object"&&!Array.isArray(Q)&&Q!==null}function r(Q,$){switch(Q){case Boolean:return x0($);case Number:return D0($);case String:return w0($);case Array:return L0($);case Object:return O0($);default:return!1}}var t=(Q,$,W,X)=>{if($===Boolean){let q=Q.getAttribute(W);if(q===null)return X;return q===""?!0:Y(q,$)}let Z=Q.getAttribute(W);return Z!==null?Y(Z,$):X??Y0($)};import{hasHydrationMarkers as P0,hydrate as E0,jsx as k0,render as _0}from"@ecopages/jsx";import{Computed as C0,subtle as I0}from"@ecopages/signals";var A0=S0();function S0(){if(typeof HTMLElement<"u")return HTMLElement;throw Error("RadiantElement requires HTMLElement. Install '@ecopages/radiant/server/light-dom-shim' before importing Radiant components in SSR.")}class j extends A0{renderRootMode="light";bindings;$;reactiveHost;reactiveProperties=new Map;contextProviders=new Map;hydrationBindings=new Map;eventSubscriptions=new Map;eventEmitters=new Map;elementReady=!1;isRendering=!1;isFirstConnectPending=!1;isRenderScheduled=!1;needsRender=!1;preUpgradePropertyValues=new Map;projectedSlotContent=new Map;renderSignal;renderWatcher=new I0.Watcher(()=>{this.requestUpdate()});slotProjectionObserver;slotProjectionVersion=0;constructor(){super();for(let Q of Object.getOwnPropertyNames(this))this.preUpgradePropertyValues.set(Q,this[Q]);this.reactiveHost=new w(this,{defineProperty:(Q,$,W)=>Object.defineProperty(Q,$,W),getBindingTarget:(Q)=>Object.getPrototypeOf(Q)??Q,hasProperty:(Q,$)=>($ in Q),readProperty:(Q,$)=>Q[$]},()=>this.shouldAutoBindReactiveMembers()),this.bindings=this.reactiveHost.bindings,this.$=this.reactiveHost.$,_(this)}connectedCallback(){let Q=this.isFirstConnectPending;if(this.elementReady=!0,this.reactiveHost.connectHost(),Q)return;this.isFirstConnectPending=!0,queueMicrotask(()=>{if(this.isFirstConnectPending=!1,!this.isConnected)return;if(!this.shouldRunRenderLifecycle())return;if(this.ensureSlotProjectionState(),this.observeSlotProjection(),e(this)){if(this.needsRender=!1,this.hydrate(),this.needsRender)this.update();return}this.update()})}connectedContextCallback(Q){}disconnectedCallback(){this.disconnectSlotProjectionObserver(),this.disconnectRenderWatcher(),this.removeAllSubscribedEvents(),this.reactiveHost.disconnectHost()}notifyUpdate(Q,$,W){this.reactiveHost.notifyUpdate(Q,$,W)}transformAttributeValue(Q,$){return Q!==null?$?.converter.fromAttribute(Q):Q}attributeChangedCallback(Q,$,W){if($===W||!this.elementReady)return;if(this.reactiveProperties.has(Q)){let X=this.reactiveProperties.get(Q),Z=this.transformAttributeValue(W,X),q=this.transformAttributeValue($,X),G=X?X.attribute:Q;this[G]=Z,this.notifyUpdate(Q,q,Z)}}renderTemplate({target:Q=this,template:$,insert:W="replace",sanitize:X}){let Z=X?X($):$;switch(W){case"replace":Q.innerHTML=Z;break;case"beforeend":Q.insertAdjacentHTML("beforeend",Z);break;case"afterbegin":Q.insertAdjacentHTML("afterbegin",Z);break;case"beforebegin":Q.insertAdjacentHTML("beforebegin",Z);break;case"afterend":Q.insertAdjacentHTML("afterend",Z);break}}render(){return k0("slot",{})}renderToString(Q={}){if(!this.shouldRunRenderLifecycle())return this.innerHTML;return this.prepareForSsr(),K().renderView(this,Q)}renderHost(){return this.assertSupportsHostSsrRendering(),K().renderHost(this)}renderHostToString(Q={}){return this.assertSupportsHostSsrRendering(),K().renderHostToString(this,Q)}hydrate(){if(!this.shouldRunRenderLifecycle()||!this.isConnected||this.isRendering)return;let Q=this.getRenderTarget();this.isRendering=!0,this.disconnectSlotProjectionObserver();try{E0(this.resolveTrackedRenderOutput().value,Q)}finally{this.isRendering=!1,this.observeSlotProjection()}}requestUpdate(){if(!this.shouldRunRenderLifecycle())return;if(this.needsRender=!0,this.isRenderScheduled)return;this.isRenderScheduled=!0,queueMicrotask(()=>{if(this.isRenderScheduled=!1,!this.needsRender)return;this.update()})}update(){if(!this.shouldRunRenderLifecycle())return;let Q=this.getRenderTarget();if(this.needsRender=!0,!this.isConnected||this.isRendering)return;if(this.isFirstConnectPending&&e(this))return;while(this.needsRender&&this.isConnected){this.needsRender=!1,this.isRendering=!0,this.disconnectSlotProjectionObserver();try{_0(this.resolveTrackedRenderOutput().value,Q)}finally{this.isRendering=!1,this.observeSlotProjection()}}}registerReactiveProperty(Q){this.reactiveProperties.set(Q.name,Q)}getReactiveProperties(){return Array.from(this.reactiveProperties.values())}registerReactiveDependencyReader(Q,$){this.reactiveHost.registerReactiveDependencyReader(Q,$)}registerContextProvider(Q,$){this.contextProviders.set(Q,$),this.registerHydrationBinding(Q,$)}registerHydrationBinding(Q,$){this.hydrationBindings.set(Q,$)}getContextProviders(){return Array.from(this.contextProviders.values())}getHydrationBindings(){return Array.from(this.hydrationBindings.values())}prepareForSsr(){S(this)}shouldAutoBindReactiveMembers(){return!0}shouldRunRenderLifecycle(){return this.render!==j.prototype.render}getRenderTarget(){if(this.renderRootMode!=="shadow")return this;if(this.shadowRoot)return this.shadowRoot;if(typeof this.attachShadow!=="function")throw Error("RadiantElement shadow render mode requires attachShadow().");return this.attachShadow({mode:"open"})}getHostSsrAttributes(){return K().getHostAttributes(this)}resolveSsrRenderBridge(){let Q={};if(this.renderHostToString===j.prototype.renderHostToString)Q.renderHostToString=($)=>this.renderHostToString($);if(this.renderHost===j.prototype.renderHost)Q.renderHost=()=>this.renderHost();return Q}registerUpdateCallback(Q,$){return this.reactiveHost.registerUpdateCallback(Q,$)}getReactiveBinding(Q){return this.reactiveHost.getReactiveBinding(Q)}bind(Q){return this.reactiveHost.bind(Q)}defineReactiveBinding(Q,$=!0){this.reactiveHost.defineReactiveBinding(Q,$)}trackReactiveRead(Q){this.reactiveHost.trackReactiveRead(Q)}subscribeEvents(Q){let $=[];for(let W of Q)$.push(this.subscribeEvent(W));return $}subscribeEvent(Q){let $=this.getEventSubscriptionTarget(),W=(Z)=>{if(Z.target&&Z.target.matches(Q.selector))Q.listener.call(this,Z)},X=`${Q.type}:${Q.selector}`;return $.addEventListener(Q.type,W,Q.options),this.eventSubscriptions.set(X,{...Q,listener:W,target:$}),this.unsubscribeEvent.bind(this,X)}unsubscribeEvent(Q){let $=this.eventSubscriptions.get(Q);if($)$.target.removeEventListener($.type,$.listener,$.options),this.eventSubscriptions.delete(Q)}removeAllSubscribedEvents(){for(let Q of this.eventSubscriptions.values())Q.target.removeEventListener(Q.type,Q.listener,Q.options);this.eventSubscriptions.clear()}registerCleanupCallback(Q){this.reactiveHost.registerCleanupCallback(Q)}registerConnectedCallback(Q){this.reactiveHost.registerConnectedCallback(Q)}registerEventEmitter(Q,$){this.eventEmitters.set(Q,$)}getRef(Q,$=!1){let W=`[data-ref="${Q}"]`,X=this.getQueryRoot();if($)return Array.from(X.querySelectorAll(W));return X.querySelector(W)??null}getSlotElement(Q){return this.getSlotElements(Q)[0]??null}getSlotElements(Q){return this.ensureSlotProjectionState(),(this.projectedSlotContent.get(Q??z)??[]).filter(($)=>typeof Node<"u"&&$ instanceof Element)}createReactiveField(Q,$,W={}){this.reactiveHost.createReactiveField(Q,$,W)}createReactiveProp(Q,$){let{type:W,attribute:X,reflect:Z,defaultValue:q}=$,G=X??Q,M=this.preUpgradePropertyValues.has(Q),Q0=M?this.preUpgradePropertyValues.get(Q):void 0;if(q!==void 0&&!r(W,q))throw Error(`defaultValue does not match the expected type for ${W.name}`);let U=M?Q0:t(this,W,G,q);if(this.hasAttribute(G)&&(!Z||U==null||U===""))this.removeAttribute(G);if(M&&Object.prototype.hasOwnProperty.call(this,Q))Reflect.deleteProperty(this,Q);let x={type:W,name:Q,value:U,initialValue:U,attribute:G,converter:{fromAttribute:(J)=>Y(J,W),toAttribute:(J)=>a(J,W)}};this.registerReactiveProperty(x);let k=(J)=>{if(Z)if(J==null||J===""||J===!1)this.removeAttribute(G);else{let $0=x.converter.toAttribute(J);this.setAttribute(G,$0)}};if(this.reactiveHost.defineReactiveAccessor(Q,{bind:$.bind,getValue:()=>this.reactiveProperties.get(Q)?.value,setValue:(J)=>{this.reactiveProperties.set(Q,{...x,value:J}),k(J)}}),U!==void 0)queueMicrotask(()=>{let J=this.reactiveProperties.get(Q)?.value;if(J===void 0)return;k(J),this.notifyUpdate(Q,void 0,J)})}ensureSlotProjectionState(){if(this.projectedSlotContent.size>0)return;let Q=this.isConnected?b(this):void 0;if(typeof Q==="string"&&Q!==""){this.projectedSlotContent=V(Q),this.slotProjectionVersion+=1;return}if(this.getHostChildNodeCount()>0)this.projectedSlotContent=N(this),this.slotProjectionVersion+=1}getHostChildNodeCount(){return"childNodes"in this&&this.childNodes?this.childNodes.length:0}getSlotProjectionScriptTag(){this.ensureSlotProjectionState();let Q=m(this.projectedSlotContent);if(!Q)return;return`<script type="application/json" ${H}>${R0(Q)}</script>`}getAuthoredHydrationScriptMarkup(){let Q=g(this);if(Q)return Q;return}handleSlotProjectionMutations(Q){let $=!1;for(let W of Q){for(let X of Array.from(W.removedNodes))if(this.removeProjectedSlotNode(X))$=!0;for(let X of Array.from(W.addedNodes)){if(X.parentNode!==this)continue;if(this.addProjectedSlotNode(X))$=!0}}if($)this.slotProjectionVersion+=1,this.update()}addProjectedSlotNode(Q){if(Q instanceof HTMLScriptElement&&(Q.hasAttribute(H)||Q.hasAttribute(F)))return!1;let $=Q instanceof Element?Q.getAttribute("slot")??z:z,W=this.projectedSlotContent.get($);if(W){if(W.includes(Q))return!1;return W.push(Q),!0}return this.projectedSlotContent.set($,[Q]),!0}removeProjectedSlotNode(Q){for(let[$,W]of this.projectedSlotContent.entries()){let X=W.indexOf(Q);if(X===-1)continue;if(W.splice(X,1),W.length===0)this.projectedSlotContent.delete($);return!0}return!1}observeSlotProjection(){if(typeof MutationObserver>"u"||this.slotProjectionObserver||!this.isConnected)return;this.slotProjectionObserver=new MutationObserver((Q)=>this.handleSlotProjectionMutations(Q)),this.slotProjectionObserver.observe(this,{childList:!0})}disconnectSlotProjectionObserver(){this.slotProjectionObserver?.disconnect(),this.slotProjectionObserver=void 0}disconnectRenderWatcher(){if(!this.renderSignal)return;this.renderWatcher.unwatch(this.renderSignal),this.renderSignal=void 0}resolveTrackedRenderOutput(){let Q=new C0(()=>this.resolveRenderOutput()),$=Q.get();if(!this.isConnected)return $;if(this.renderSignal)this.renderWatcher.unwatch(this.renderSignal);return this.renderSignal=Q,this.renderWatcher.watch(Q),$}resolveRenderOutput(){return this.ensureSlotProjectionState(),v(this.render(),this.projectedSlotContent)}getEventSubscriptionTarget(){let Q=this.getRenderTarget();return Q instanceof ShadowRoot?Q:this}getQueryRoot(){let Q=this.getRenderTarget();return Q instanceof ShadowRoot?Q:this}assertSupportsHostSsrRendering(){if(this.renderRootMode==="shadow")throw Error("RadiantElement shadow render mode does not support renderHost() or renderHostToString().")}}function K(){let Q=i();if(!Q)throw Error("Radiant SSR runtime is unavailable. Import `@ecopages/radiant/server/render-component` before using instance SSR methods.");return Q}function e(Q){return u()&&P0(Q)}function R0(Q){return Q.replace(/</g,"\\u003c")}export{j as RadiantElement};
|
|
2
2
|
|
|
3
|
-
//# debugId=
|
|
3
|
+
//# debugId=00E7CEE7F33A213F64756E2164756E21
|