@ecopages/radiant 0.3.0-alpha.3 → 0.3.0-alpha.5
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 +66 -56
- package/dist/LICENSE +21 -0
- package/dist/client/hydrator.d.ts +1 -1
- package/dist/client/hydrator.js +2 -2
- package/dist/client/hydrator.js.map +5 -3
- package/dist/client/install-hydrator.js +2 -2
- package/dist/client/install-hydrator.js.map +5 -3
- 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 -6
- 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.js +2 -2
- package/dist/context/hydration-script.js.map +6 -3
- package/dist/controller-registry.d.ts +28 -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 +13 -13
- package/dist/core/radiant-component-ssr-registry.js +2 -2
- package/dist/core/radiant-component-ssr-registry.js.map +4 -3
- 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 +127 -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 +43 -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 +1 -1
- package/dist/core/radiant-hydrator-state.js +2 -2
- package/dist/core/radiant-hydrator-state.js.map +4 -3
- 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-runtime.js +2 -2
- package/dist/core/slot-projection-runtime.js.map +6 -3
- 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 +6 -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.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 +9 -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 +11 -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 +5 -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 +4 -3
- package/dist/helpers/create-event.js +2 -2
- package/dist/helpers/create-event.js.map +5 -3
- 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 +9 -3
- package/dist/index.d.ts +11 -12
- package/dist/index.js +2 -2
- package/dist/index.js.map +87 -3
- package/dist/server/context-ssr.js +2 -2
- package/dist/server/context-ssr.js.map +5 -3
- package/dist/server/html-parser.js +2 -2
- package/dist/server/html-parser.js.map +4 -3
- 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.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 +2 -2
- package/dist/server/radiant-component-ssr-runtime.js +2 -2
- package/dist/server/radiant-component-ssr-runtime.js.map +11 -3
- package/dist/server/render-component.d.ts +3 -13
- 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.js +2 -2
- package/dist/server/slot-projection-html.js.map +7 -3
- 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.js +2 -2
- package/dist/signals/hydration-script.js.map +6 -3
- 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.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/tools/stringify-typed.js +2 -2
- package/dist/tools/stringify-typed.js.map +4 -3
- package/dist/types.js +2 -2
- package/dist/types.js.map +2 -2
- 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 +22 -5
- package/size-budget.json +11 -2
- package/dist/chunk-0bswvy25.js +0 -4
- package/dist/chunk-0bswvy25.js.map +0 -10
- package/dist/chunk-0btkzzyc.js +0 -4
- package/dist/chunk-0btkzzyc.js.map +0 -10
- package/dist/chunk-0g0j9re6.js +0 -4
- package/dist/chunk-0g0j9re6.js.map +0 -10
- package/dist/chunk-1x26p09c.js +0 -4
- package/dist/chunk-1x26p09c.js.map +0 -10
- package/dist/chunk-21a7jask.js +0 -4
- package/dist/chunk-21a7jask.js.map +0 -10
- package/dist/chunk-25zjh0kg.js +0 -4
- package/dist/chunk-25zjh0kg.js.map +0 -10
- package/dist/chunk-30x4hggg.js +0 -4
- package/dist/chunk-30x4hggg.js.map +0 -10
- package/dist/chunk-3xxvmd5c.js +0 -4
- package/dist/chunk-3xxvmd5c.js.map +0 -10
- package/dist/chunk-3ynk7e1e.js +0 -4
- package/dist/chunk-3ynk7e1e.js.map +0 -10
- package/dist/chunk-5b1en9vz.js +0 -4
- package/dist/chunk-5b1en9vz.js.map +0 -10
- package/dist/chunk-5bkat72n.js +0 -4
- package/dist/chunk-5bkat72n.js.map +0 -10
- package/dist/chunk-5qeaq3tj.js +0 -4
- package/dist/chunk-5qeaq3tj.js.map +0 -10
- package/dist/chunk-66e6s792.js +0 -4
- package/dist/chunk-66e6s792.js.map +0 -10
- package/dist/chunk-79jg8q67.js +0 -4
- package/dist/chunk-79jg8q67.js.map +0 -10
- package/dist/chunk-8d5ddvvf.js +0 -4
- package/dist/chunk-8d5ddvvf.js.map +0 -10
- package/dist/chunk-8e9fgtbn.js +0 -4
- package/dist/chunk-8e9fgtbn.js.map +0 -10
- package/dist/chunk-9mqtp3js.js +0 -4
- package/dist/chunk-9mqtp3js.js.map +0 -10
- package/dist/chunk-9rj2rwes.js +0 -4
- package/dist/chunk-9rj2rwes.js.map +0 -10
- package/dist/chunk-atms6yrh.js +0 -4
- package/dist/chunk-atms6yrh.js.map +0 -10
- package/dist/chunk-bk2nbmcd.js +0 -4
- package/dist/chunk-bk2nbmcd.js.map +0 -10
- package/dist/chunk-bk6qkvfp.js +0 -4
- package/dist/chunk-bk6qkvfp.js.map +0 -10
- package/dist/chunk-c0qyz98c.js +0 -4
- package/dist/chunk-c0qyz98c.js.map +0 -10
- package/dist/chunk-c52qhh0j.js +0 -4
- package/dist/chunk-c52qhh0j.js.map +0 -10
- package/dist/chunk-cnyxrh9r.js +0 -4
- package/dist/chunk-cnyxrh9r.js.map +0 -10
- package/dist/chunk-cvz9mrxa.js +0 -4
- package/dist/chunk-cvz9mrxa.js.map +0 -10
- package/dist/chunk-dabagjk6.js +0 -4
- package/dist/chunk-dabagjk6.js.map +0 -10
- package/dist/chunk-e0r6ca2g.js +0 -4
- package/dist/chunk-e0r6ca2g.js.map +0 -10
- package/dist/chunk-eevw1j2q.js +0 -4
- package/dist/chunk-eevw1j2q.js.map +0 -10
- package/dist/chunk-ek664x1c.js +0 -4
- package/dist/chunk-ek664x1c.js.map +0 -10
- package/dist/chunk-eyw14d6y.js +0 -4
- package/dist/chunk-eyw14d6y.js.map +0 -10
- package/dist/chunk-fs4j94bk.js +0 -4
- package/dist/chunk-fs4j94bk.js.map +0 -10
- package/dist/chunk-g2z3mm6b.js +0 -4
- package/dist/chunk-g2z3mm6b.js.map +0 -10
- package/dist/chunk-g5n3m11h.js +0 -4
- package/dist/chunk-g5n3m11h.js.map +0 -10
- package/dist/chunk-gdkte2vd.js +0 -4
- package/dist/chunk-gdkte2vd.js.map +0 -10
- package/dist/chunk-gg74gdpv.js +0 -4
- package/dist/chunk-gg74gdpv.js.map +0 -10
- package/dist/chunk-gpv1n74a.js +0 -4
- package/dist/chunk-gpv1n74a.js.map +0 -10
- package/dist/chunk-h9k7crjc.js +0 -4
- package/dist/chunk-h9k7crjc.js.map +0 -10
- package/dist/chunk-hpzgnxgq.js +0 -4
- package/dist/chunk-hpzgnxgq.js.map +0 -10
- package/dist/chunk-hrjc8b1y.js +0 -4
- package/dist/chunk-hrjc8b1y.js.map +0 -10
- package/dist/chunk-hvy4zvcc.js +0 -4
- package/dist/chunk-hvy4zvcc.js.map +0 -10
- package/dist/chunk-hztr86b4.js +0 -4
- package/dist/chunk-hztr86b4.js.map +0 -10
- package/dist/chunk-j3v7rca5.js +0 -4
- package/dist/chunk-j3v7rca5.js.map +0 -10
- package/dist/chunk-j864sv4w.js +0 -4
- package/dist/chunk-j864sv4w.js.map +0 -10
- package/dist/chunk-jkb2y7c8.js +0 -4
- package/dist/chunk-jkb2y7c8.js.map +0 -10
- package/dist/chunk-kakpjgzf.js +0 -4
- package/dist/chunk-kakpjgzf.js.map +0 -10
- package/dist/chunk-kmebacvv.js +0 -4
- package/dist/chunk-kmebacvv.js.map +0 -10
- package/dist/chunk-knqsm6v3.js +0 -4
- package/dist/chunk-knqsm6v3.js.map +0 -10
- package/dist/chunk-mp2vtrkg.js +0 -4
- package/dist/chunk-mp2vtrkg.js.map +0 -10
- package/dist/chunk-mpsj3cjs.js +0 -4
- package/dist/chunk-mpsj3cjs.js.map +0 -10
- package/dist/chunk-n4p2542b.js +0 -4
- package/dist/chunk-n4p2542b.js.map +0 -10
- package/dist/chunk-nctznxyz.js +0 -4
- package/dist/chunk-nctznxyz.js.map +0 -10
- package/dist/chunk-ndw3hc3v.js +0 -4
- package/dist/chunk-ndw3hc3v.js.map +0 -10
- package/dist/chunk-nnnb6pac.js +0 -4
- package/dist/chunk-nnnb6pac.js.map +0 -10
- package/dist/chunk-nssj2x13.js +0 -4
- package/dist/chunk-nssj2x13.js.map +0 -10
- package/dist/chunk-nvr37vma.js +0 -4
- package/dist/chunk-nvr37vma.js.map +0 -10
- package/dist/chunk-p8k4g99a.js +0 -4
- package/dist/chunk-p8k4g99a.js.map +0 -10
- package/dist/chunk-pkszgjqf.js +0 -4
- package/dist/chunk-pkszgjqf.js.map +0 -10
- package/dist/chunk-q9z6tnzw.js +0 -4
- package/dist/chunk-q9z6tnzw.js.map +0 -10
- package/dist/chunk-qdz5sncz.js +0 -4
- package/dist/chunk-qdz5sncz.js.map +0 -10
- package/dist/chunk-qe0eww1n.js +0 -4
- package/dist/chunk-qe0eww1n.js.map +0 -10
- package/dist/chunk-r33zvvda.js +0 -4
- package/dist/chunk-r33zvvda.js.map +0 -10
- package/dist/chunk-rkh1vkb9.js +0 -4
- package/dist/chunk-rkh1vkb9.js.map +0 -10
- package/dist/chunk-rrg759ht.js +0 -4
- package/dist/chunk-rrg759ht.js.map +0 -10
- package/dist/chunk-s09s5ayx.js +0 -4
- package/dist/chunk-s09s5ayx.js.map +0 -10
- package/dist/chunk-s5p5z3z4.js +0 -4
- package/dist/chunk-s5p5z3z4.js.map +0 -10
- package/dist/chunk-sf4a2gy5.js +0 -4
- package/dist/chunk-sf4a2gy5.js.map +0 -10
- package/dist/chunk-ssnnxzrj.js +0 -4
- package/dist/chunk-ssnnxzrj.js.map +0 -10
- package/dist/chunk-t8xtvgyg.js +0 -4
- package/dist/chunk-t8xtvgyg.js.map +0 -10
- package/dist/chunk-v3ta7hnv.js +0 -4
- package/dist/chunk-v3ta7hnv.js.map +0 -10
- package/dist/chunk-v92hp9g0.js +0 -4
- package/dist/chunk-v92hp9g0.js.map +0 -10
- package/dist/chunk-vgtggzb6.js +0 -4
- package/dist/chunk-vgtggzb6.js.map +0 -9
- package/dist/chunk-vk48hgm4.js +0 -4
- package/dist/chunk-vk48hgm4.js.map +0 -10
- package/dist/chunk-w8s5fnsq.js +0 -4
- package/dist/chunk-w8s5fnsq.js.map +0 -10
- package/dist/chunk-wd23rn4q.js +0 -4
- package/dist/chunk-wd23rn4q.js.map +0 -10
- package/dist/chunk-wds4href.js +0 -4
- package/dist/chunk-wds4href.js.map +0 -10
- package/dist/chunk-wvd1ffe4.js +0 -4
- package/dist/chunk-wvd1ffe4.js.map +0 -10
- package/dist/chunk-wwbjz9k4.js +0 -4
- package/dist/chunk-wwbjz9k4.js.map +0 -10
- package/dist/chunk-x2k0ngpz.js +0 -4
- package/dist/chunk-x2k0ngpz.js.map +0 -10
- package/dist/chunk-x457d0ap.js +0 -4
- package/dist/chunk-x457d0ap.js.map +0 -10
- package/dist/chunk-xbhtzkre.js +0 -4
- package/dist/chunk-xbhtzkre.js.map +0 -10
- package/dist/chunk-y139ycfm.js +0 -4
- package/dist/chunk-y139ycfm.js.map +0 -10
- package/dist/chunk-z9kxfckm.js +0 -4
- package/dist/chunk-z9kxfckm.js.map +0 -10
- package/dist/chunk-zx5txex8.js +0 -4
- package/dist/chunk-zx5txex8.js.map +0 -10
- package/dist/chunk-zygdebw8.js +0 -4
- package/dist/chunk-zygdebw8.js.map +0 -10
- package/dist/core/radiant-component.d.ts +0 -113
- package/dist/core/radiant-component.js +0 -3
- package/dist/core/radiant-component.js.map +0 -9
package/dist/index.js.map
CHANGED
|
@@ -1,9 +1,93 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": [],
|
|
3
|
+
"sources": ["../src/decorators/legacy/instance-initializers.ts", "../src/core/reactive-host.ts", "../src/core/ssr-preparation.ts", "../src/tools/escape-script-json.ts", "../src/core/hydration-codec.ts", "../src/core/slot-projection-runtime.ts", "../src/core/radiant-hydrator-state.ts", "../src/core/radiant-component-ssr-registry.ts", "../src/utils/attribute-utils.ts", "../src/core/radiant-element.ts", "../src/core/radiant-controller.ts", "../src/core/reactive-jsx-value.ts", "../src/core/controller-metadata.ts", "../src/controller-registry.ts", "../src/context/events.ts", "../src/context/hydration-script.ts", "../src/context/context-host.ts", "../src/context/context-provider.ts", "../src/context/create-context.ts", "../src/context/context-ssr-bridge.ts", "../src/context/context-consumer-runtime.ts", "../src/context/context-consumer-bootstrap.ts", "../src/context/decorators/legacy/consume-context.ts", "../src/context/decorators/standard/consume-context.ts", "../src/decorators/bridge.ts", "../src/context/decorators/consume-context.ts", "../src/context/decorators/context-selection-delivery.ts", "../src/context/decorators/legacy/context-selector.ts", "../src/context/decorators/standard/context-selector.ts", "../src/context/decorators/legacy/context-selector-field.ts", "../src/context/decorators/standard/context-selector-field.ts", "../src/context/decorators/context-selector.ts", "../src/context/decorators/on-context-update.ts", "../src/context/decorators/legacy/provide-context.ts", "../src/context/decorators/standard/provide-context.ts", "../src/context/decorators/provide-context.ts", "../src/decorators/shared/reactive-attr.ts", "../src/decorators/legacy/attr.ts", "../src/decorators/standard/attr.ts", "../src/decorators/attr.ts", "../src/decorators/legacy/bound.ts", "../src/decorators/standard/bound.ts", "../src/decorators/bound.ts", "../src/decorators/controller.ts", "../src/core/custom-element-metadata.ts", "../src/decorators/legacy/custom-element.ts", "../src/decorators/standard/custom-element.ts", "../src/decorators/custom-element.ts", "../src/helpers/debounce.ts", "../src/decorators/legacy/debounce.ts", "../src/decorators/standard/debounce.ts", "../src/decorators/debounce.ts", "../src/tools/event-emitter.ts", "../src/helpers/create-event.ts", "../src/decorators/legacy/event.ts", "../src/decorators/standard/event.ts", "../src/decorators/event.ts", "../src/helpers/create-event-listener.ts", "../src/decorators/legacy/on-event.ts", "../src/decorators/standard/on-event.ts", "../src/decorators/on-event.ts", "../src/decorators/legacy/on-updated.ts", "../src/decorators/standard/on-updated.ts", "../src/decorators/on-updated.ts", "../src/core/reactive-prop-metadata.ts", "../src/decorators/legacy/reactive-prop.ts", "../src/decorators/standard/reactive-prop.ts", "../src/decorators/prop.ts", "../src/helpers/create-query.ts", "../src/decorators/legacy/query.ts", "../src/decorators/standard/query.ts", "../src/decorators/query.ts", "../src/helpers/create-query-slot.ts", "../src/decorators/legacy/query-slot.ts", "../src/decorators/standard/query-slot.ts", "../src/decorators/query-slot.ts", "../src/signals/hydration-script.ts", "../src/signals/host-signal.ts", "../src/decorators/legacy/signal.ts", "../src/decorators/standard/signal.ts", "../src/decorators/signal.ts", "../src/decorators/legacy/reactive-field.ts", "../src/decorators/standard/reactive-field.ts", "../src/decorators/state.ts"],
|
|
4
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
|
+
"type SsrPreparationCallback = () => void;\n\nconst SSR_PREPARATION_CALLBACKS = Symbol();\nexport const SSR_PREPARATION_RUNNING = Symbol();\n\n/**\n * Registers instance-local SSR preparation work that should run immediately\n * before a Radiant host serializes its first server render.\n *\n * Decorators use this to defer SSR-only setup until after class fields,\n * reactive props, and authored host content have all been applied.\n */\nexport function registerSsrPreparationCallback(host: object, callback: SsrPreparationCallback): void {\n\tconst target = host as Record<PropertyKey, unknown>;\n\tconst existingCallbacks = target[SSR_PREPARATION_CALLBACKS];\n\n\tif (Array.isArray(existingCallbacks)) {\n\t\texistingCallbacks.push(callback);\n\t\treturn;\n\t}\n\n\tObject.defineProperty(host, SSR_PREPARATION_CALLBACKS, {\n\t\tvalue: [callback],\n\t\tconfigurable: true,\n\t});\n}\n\n/**\n * Runs all registered SSR preparation callbacks for the provided host.\n *\n * The callbacks are intentionally retained so repeated SSR serializations stay\n * deterministic after later host mutations.\n */\nexport function runSsrPreparationCallbacks(host: object): void {\n\tconst target = host as Record<PropertyKey, unknown>;\n\tconst callbacks = target[SSR_PREPARATION_CALLBACKS];\n\n\tif (!Array.isArray(callbacks)) {\n\t\treturn;\n\t}\n\n\ttarget[SSR_PREPARATION_RUNNING] = true;\n\n\ttry {\n\t\tfor (const callback of callbacks as SsrPreparationCallback[]) {\n\t\t\tcallback();\n\t\t}\n\t} finally {\n\t\tdelete target[SSR_PREPARATION_RUNNING];\n\t}\n}\n",
|
|
8
|
+
"/**\n * Escapes serialized JSON so it remains safe when embedded inside an HTML\n * `<script>` tag.\n */\nexport function escapeScriptJson(value: string): string {\n\treturn value\n\t\t.replace(/&/g, '\\\\u0026')\n\t\t.replace(/</g, '\\\\u003c')\n\t\t.replace(/>/g, '\\\\u003e')\n\t\t.replace(/\\u2028/g, '\\\\u2028')\n\t\t.replace(/\\u2029/g, '\\\\u2029');\n}\n",
|
|
9
|
+
"import { escapeScriptJson } from '../tools/escape-script-json';\n\n/** Attribute marker used to identify hydration payloads inside a host. */\nexport const HYDRATION_ATTRIBUTE = 'data-hydration';\n/** Discriminator that scopes a hydration payload to a specific feature. */\nexport const HYDRATION_TYPE_ATTRIBUTE = 'data-hydration-type';\n/** Optional key that scopes a hydration payload to a specific decorated field. */\nexport const HYDRATION_KEY_ATTRIBUTE = 'data-hydration-key';\n\nexport type HydrationPayloadType = 'signal' | 'context';\n\ntype HydrationScriptHost = {\n\tchildren?: ArrayLike<Element> | undefined;\n\tchildNodes?: ArrayLike<{ nodeType: number }> | undefined;\n};\n\n/** Creates a `<script type=\"application/json\">` tag for a hydration payload. */\nexport function createHydrationScriptTag(options: {\n\ttype: HydrationPayloadType;\n\thydrationKey?: string;\n\tserializedValue: string;\n}): string {\n\tconst keyAttribute = options.hydrationKey\n\t\t? ` ${HYDRATION_KEY_ATTRIBUTE}=\"${escapeHtmlAttribute(options.hydrationKey)}\"`\n\t\t: '';\n\n\treturn `<script type=\"application/json\" ${HYDRATION_ATTRIBUTE} ${HYDRATION_TYPE_ATTRIBUTE}=\"${options.type}\"${keyAttribute}>${options.serializedValue}</script>`;\n}\n\n/** Escapes serialized JSON so it remains safe inside an HTML script tag. */\nexport function escapeHydrationJson(value: string): string {\n\treturn escapeScriptJson(value);\n}\n\n/** Parses JSON from a hydration script element, returning the fallback on failure. */\nexport function parseHydrationPayload<T>(element: Element, fallback: T): T {\n\tconst textContent = element.textContent;\n\n\tif (!textContent) {\n\t\treturn fallback;\n\t}\n\n\ttry {\n\t\treturn JSON.parse(textContent) as T;\n\t} catch {\n\t\tif (typeof console !== 'undefined') {\n\t\t\tconsole.warn(\n\t\t\t\t`[@ecopages/radiant] Failed to parse hydration payload from <script ${HYDRATION_ATTRIBUTE}>:`,\n\t\t\t\ttextContent.slice(0, 120),\n\t\t\t);\n\t\t}\n\t\treturn fallback;\n\t}\n}\n\n/**\n * Finds a hydration script element inside a host by type and optional key.\n *\n * When a key is provided, looks for an exact `data-hydration-key` match.\n * Otherwise, returns the first unkeyed script matching the type.\n */\nexport function findHydrationScript(\n\thost: HydrationScriptHost,\n\ttype: HydrationPayloadType,\n\thydrationKey?: string,\n): Element | null {\n\tconst children = host.children;\n\n\tif (!children || children.length === 0) {\n\t\tconst childNodes = (host as Partial<{ childNodes: ArrayLike<{ nodeType: number }> }>).childNodes;\n\n\t\tif (!childNodes || childNodes.length === 0) {\n\t\t\treturn null;\n\t\t}\n\n\t\tfor (let i = 0; i < childNodes.length; i += 1) {\n\t\t\tconst node = childNodes[i]!;\n\n\t\t\tif (node.nodeType !== 1) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tconst element = node as unknown as Element;\n\n\t\t\tif (matchesHydrationScript(element, type, hydrationKey)) {\n\t\t\t\treturn element;\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tfor (let i = 0; i < children.length; i += 1) {\n\t\tif (matchesHydrationScript(children[i]!, type, hydrationKey)) {\n\t\t\treturn children[i]!;\n\t\t}\n\t}\n\n\treturn null;\n}\n\nfunction matchesHydrationScript(element: Element, type: HydrationPayloadType, hydrationKey?: string): boolean {\n\tif (\n\t\telement.tagName !== 'SCRIPT' ||\n\t\t!element.hasAttribute(HYDRATION_ATTRIBUTE) ||\n\t\telement.getAttribute(HYDRATION_TYPE_ATTRIBUTE) !== type\n\t) {\n\t\treturn false;\n\t}\n\n\tif (hydrationKey !== undefined) {\n\t\treturn element.getAttribute(HYDRATION_KEY_ATTRIBUTE) === hydrationKey;\n\t}\n\n\treturn !element.hasAttribute(HYDRATION_KEY_ATTRIBUTE);\n}\n\nfunction escapeHtmlAttribute(value: string): string {\n\treturn value.replace(/&/g, '&').replace(/\"/g, '"').replace(/</g, '<').replace(/>/g, '>');\n}\n",
|
|
10
|
+
"import {\n\tcreateMarkupNodeLike,\n\tisKeyedJsxValue,\n\tisSlotJsxValue,\n\ttype JsxRenderable,\n\ttype KeyedJsxValue,\n\ttype SlotJsxValue,\n\ttype TemplateResultLike,\n} from '@ecopages/jsx';\n\nimport { HYDRATION_ATTRIBUTE } from './hydration-codec';\n\nexport const DEFAULT_SLOT_NAME = '';\nexport const SLOT_PROJECTION_SCRIPT_ATTRIBUTE = 'data-radiant-slot-projection';\n\ntype ResolvedSlotProjection = {\n\tcontainsSlots: boolean;\n\tvalue: JsxRenderable;\n};\n\nexport function captureProjectedSlotRenderables(host: HTMLElement): Map<string, JsxRenderable[]> {\n\tconst projectedContent = new Map<string, JsxRenderable[]>();\n\n\tfor (const node of Array.from(host.childNodes)) {\n\t\tif (isIgnoredProjectedNode(node)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tappendProjectedRenderable(projectedContent, getNodeSlotName(node), node);\n\t}\n\n\treturn projectedContent;\n}\n\nexport function deserializeProjectedSlotRenderables(payload: string): Map<string, JsxRenderable[]> {\n\tlet parsedPayload: Record<string, string[]>;\n\n\ttry {\n\t\tparsedPayload = JSON.parse(payload) as Record<string, string[]>;\n\t} catch {\n\t\tif (typeof console !== 'undefined') {\n\t\t\tconsole.warn('[@ecopages/radiant] Failed to parse slot projection payload:', payload.slice(0, 120));\n\t\t}\n\t\treturn new Map();\n\t}\n\n\tconst projectedContent = new Map<string, JsxRenderable[]>();\n\n\tfor (const [slotName, fragments] of Object.entries(parsedPayload)) {\n\t\tif (!Array.isArray(fragments) || fragments.length === 0) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tprojectedContent.set(\n\t\t\tnormalizeSlotName(slotName),\n\t\t\tfragments.map((fragment) => createMarkupNodeLike(fragment)),\n\t\t);\n\t}\n\n\treturn projectedContent;\n}\n\nexport function collectAuthoredHydrationScriptMarkup(host: HTMLElement): string | undefined {\n\tconst fragments = Array.from(host.childNodes)\n\t\t.filter((node): node is HTMLScriptElement => isHydrationScriptNode(node))\n\t\t.map((node) => renderableToHtmlFragment(node) ?? '')\n\t\t.filter((fragment) => fragment !== '');\n\n\treturn fragments.length > 0 ? fragments.join('') : undefined;\n}\n\nexport function serializeProjectedSlotRenderables(\n\tprojectedContent: ReadonlyMap<string, readonly JsxRenderable[]>,\n): string | undefined {\n\tconst payload: Record<string, string[]> = {};\n\n\tfor (const [slotName, renderables] of projectedContent.entries()) {\n\t\tconst fragments = renderables\n\t\t\t.map((renderable) => renderableToHtmlFragment(renderable))\n\t\t\t.filter((fragment): fragment is string => fragment !== undefined && fragment !== '');\n\n\t\tif (fragments.length > 0) {\n\t\t\tpayload[slotName] = fragments;\n\t\t}\n\t}\n\n\treturn Object.keys(payload).length > 0 ? JSON.stringify(payload) : undefined;\n}\n\nexport function resolveSlotProjection(\n\tvalue: JsxRenderable,\n\tprojectedContent: ReadonlyMap<string, readonly JsxRenderable[]>,\n): ResolvedSlotProjection {\n\tlet containsSlots = false;\n\n\tconst resolveValue = (currentValue: JsxRenderable): JsxRenderable => {\n\t\tif (isSlotJsxValue(currentValue)) {\n\t\t\tcontainsSlots = true;\n\t\t\treturn resolveSlotValue(currentValue, projectedContent, resolveValue);\n\t\t}\n\n\t\tif (isKeyedJsxValue(currentValue)) {\n\t\t\treturn cloneKeyedJsxValue(currentValue, resolveValue(currentValue.value));\n\t\t}\n\n\t\tif (isTemplateResultLike(currentValue)) {\n\t\t\treturn {\n\t\t\t\t_$rType$: 1,\n\t\t\t\trootLocalName: currentValue.rootLocalName,\n\t\t\t\tstrings: currentValue.strings,\n\t\t\t\tvalues: currentValue.values.map((entry) => resolveValue(entry as JsxRenderable)),\n\t\t\t} satisfies TemplateResultLike;\n\t\t}\n\n\t\tif (isIterableRenderable(currentValue)) {\n\t\t\treturn Array.from(currentValue, (entry) => resolveValue(entry as JsxRenderable));\n\t\t}\n\n\t\treturn currentValue;\n\t};\n\n\tconst resolvedValue = resolveValue(value);\n\n\treturn {\n\t\tcontainsSlots,\n\t\tvalue: resolvedValue,\n\t};\n}\n\nexport function takeSlotProjectionScriptPayload(host: HTMLElement): string | undefined {\n\tfor (const node of Array.from(host.childNodes)) {\n\t\tif (!isSlotProjectionScriptNode(node)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst payload = node.textContent ?? undefined;\n\t\tnode.parentNode?.removeChild(node);\n\t\treturn payload;\n\t}\n\n\treturn undefined;\n}\n\nfunction appendProjectedRenderable(\n\tprojectedContent: Map<string, JsxRenderable[]>,\n\tslotName: string,\n\trenderable: JsxRenderable,\n): void {\n\tconst existingRenderables = projectedContent.get(slotName);\n\n\tif (existingRenderables) {\n\t\texistingRenderables.push(renderable);\n\t\treturn;\n\t}\n\n\tprojectedContent.set(slotName, [renderable]);\n}\n\nfunction cloneKeyedJsxValue(value: KeyedJsxValue, nextValue: JsxRenderable): KeyedJsxValue {\n\treturn {\n\t\t...value,\n\t\tvalue: nextValue,\n\t};\n}\n\nfunction getNodeSlotName(node: Node): string {\n\tif (node instanceof Element) {\n\t\treturn normalizeSlotName(node.getAttribute('slot'));\n\t}\n\n\treturn DEFAULT_SLOT_NAME;\n}\n\nfunction isIterableRenderable(value: JsxRenderable): value is Iterable<JsxRenderable> {\n\treturn typeof value !== 'string' && typeof value === 'object' && value !== null && Symbol.iterator in value;\n}\n\nfunction isSlotProjectionScriptNode(node: Node): node is HTMLScriptElement {\n\treturn node instanceof HTMLScriptElement && node.hasAttribute(SLOT_PROJECTION_SCRIPT_ATTRIBUTE);\n}\n\nfunction isHydrationScriptNode(node: Node): node is HTMLScriptElement {\n\treturn node instanceof HTMLScriptElement && node.hasAttribute(HYDRATION_ATTRIBUTE);\n}\n\nfunction isIgnoredProjectedNode(node: Node): boolean {\n\treturn isSlotProjectionScriptNode(node) || isHydrationScriptNode(node);\n}\n\nfunction isTemplateResultLike(value: JsxRenderable): value is TemplateResultLike {\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\t(value as Partial<TemplateResultLike>)['_$rType$'] === 1 &&\n\t\tArray.isArray((value as Partial<TemplateResultLike>).strings) &&\n\t\tArray.isArray((value as Partial<TemplateResultLike>).values)\n\t);\n}\n\nfunction normalizeSlotName(name: string | undefined | null): string {\n\treturn name ?? DEFAULT_SLOT_NAME;\n}\n\nfunction renderableToHtmlFragment(renderable: JsxRenderable): string | undefined {\n\tif (renderable === undefined || renderable === null || renderable === false || renderable === true) {\n\t\treturn undefined;\n\t}\n\n\tif (typeof Node !== 'undefined' && renderable instanceof Node) {\n\t\tif (renderable.nodeType === Node.TEXT_NODE) {\n\t\t\treturn renderable.textContent ?? '';\n\t\t}\n\n\t\treturn (renderable as Element).outerHTML ?? renderable.textContent ?? undefined;\n\t}\n\n\tif (isKeyedJsxValue(renderable)) {\n\t\treturn renderableToHtmlFragment(renderable.value);\n\t}\n\n\tif (typeof renderable === 'string' || typeof renderable === 'number' || typeof renderable === 'bigint') {\n\t\treturn String(renderable);\n\t}\n\n\tif (typeof renderable === 'object' && renderable !== null && 'outerHTML' in renderable) {\n\t\treturn typeof renderable.outerHTML === 'string' ? renderable.outerHTML : (renderable.textContent ?? undefined);\n\t}\n\n\tif (isIterableRenderable(renderable)) {\n\t\treturn Array.from(renderable, (entry) => renderableToHtmlFragment(entry as JsxRenderable) ?? '').join('');\n\t}\n\n\treturn undefined;\n}\n\nfunction resolveSlotValue(\n\tvalue: SlotJsxValue,\n\tprojectedContent: ReadonlyMap<string, readonly JsxRenderable[]>,\n\tresolveValue: (value: JsxRenderable) => JsxRenderable,\n): JsxRenderable {\n\tconst assignedContent = projectedContent.get(normalizeSlotName(value.name));\n\n\tif (assignedContent && assignedContent.length > 0) {\n\t\treturn assignedContent.length === 1 ? assignedContent[0] : (assignedContent as JsxRenderable);\n\t}\n\n\tif (value.fallback === undefined) {\n\t\treturn '';\n\t}\n\n\treturn resolveValue(value.fallback);\n}\n",
|
|
11
|
+
"const RADIANT_HYDRATOR_INSTALLED_SYMBOL = Symbol.for('@ecopages/radiant.hydrator-installed');\n\ntype GlobalHydratorState = typeof globalThis & Record<PropertyKey, unknown>;\n\n/**\n * Marks the current JavaScript environment as hydration-enabled for first\n * custom-element connect.\n *\n * `RadiantElement` reads this flag before deciding whether SSR markup should\n * hydrate in place or be replaced by a fresh client render.\n */\nexport function installRadiantHydratorState(): void {\n\t(globalThis as GlobalHydratorState)[RADIANT_HYDRATOR_INSTALLED_SYMBOL] = true;\n}\n\n/**\n * Clears the explicit hydration-enabled flag from `globalThis`.\n *\n * This is mainly used by tests so they can assert both hydrated and non-\n * hydrated first-connect behavior deterministically.\n */\nexport function uninstallRadiantHydratorState(): void {\n\tdelete (globalThis as GlobalHydratorState)[RADIANT_HYDRATOR_INSTALLED_SYMBOL];\n}\n\n/**\n * Returns whether first-connect hydration is currently enabled for this\n * JavaScript environment.\n */\nexport function isRadiantHydratorInstalled(): boolean {\n\treturn (globalThis as GlobalHydratorState)[RADIANT_HYDRATOR_INSTALLED_SYMBOL] === true;\n}\n",
|
|
12
|
+
"import type { JsxRenderable } from '@ecopages/jsx';\nimport type { RenderToStringOptions } from '@ecopages/jsx/server';\n\n/**\n * Optional SSR hooks exposed by `RadiantElement` instances to the shared\n * server runtime.\n *\n * The bridge lets the runtime detect whether a component is still using the\n * inherited host SSR implementation or has taken ownership of host rendering\n * through explicit overrides.\n */\nexport type RadiantElementRenderBridge = {\n\trenderHost?: () => JsxRenderable;\n\trenderHostToString?: (options?: RenderToStringOptions) => string;\n};\n\n/**\n * Runtime shape required by the shared Radiant SSR helpers.\n *\n * This is intentionally narrower than `RadiantElement` itself so the server\n * runtime can stay decoupled from the full client base-class implementation.\n */\nexport type RadiantElementSsrCapable = HTMLElement & {\n\tresolveSsrRenderBridge?: () => RadiantElementRenderBridge;\n\tgetHostSsrAttributes?: () => Record<string, string>;\n\trenderToString(options?: RenderToStringOptions): string;\n\trenderHost?(): JsxRenderable;\n\trenderHostToString(options?: RenderToStringOptions): string;\n};\n\n/**\n * Shared SSR runtime contract registered on `globalThis`.\n *\n * Server entrypoints install one implementation that both direct component SSR\n * and nested JSX custom-element SSR can reuse without importing client-only\n * internals into every call site.\n */\nexport type RadiantElementSsrRuntime = {\n\tgetHostAttributes(component: RadiantElementSsrCapable): Record<string, string>;\n\trenderHost(component: RadiantElementSsrCapable): JsxRenderable;\n\trenderHostToString(component: RadiantElementSsrCapable, options?: RenderToStringOptions): string;\n\tresolveRenderBridge(component: RadiantElementSsrCapable): RadiantElementRenderBridge | undefined;\n\trenderView(component: RadiantElementSsrCapable, options?: RenderToStringOptions): string;\n};\n\nconst RADIANT_COMPONENT_SSR_RUNTIME_SYMBOL = Symbol.for('@ecopages/radiant.component-ssr-runtime');\n\ntype GlobalSsrRuntimeState = typeof globalThis & {\n\t[RADIANT_COMPONENT_SSR_RUNTIME_SYMBOL]?: RadiantElementSsrRuntime;\n};\n\n/**\n * Reads the currently registered Radiant SSR runtime from `globalThis`.\n *\n * Returns `undefined` when no server entrypoint has installed the runtime yet.\n */\nexport function getRadiantElementSsrRuntime(): RadiantElementSsrRuntime | undefined {\n\treturn (globalThis as GlobalSsrRuntimeState)[RADIANT_COMPONENT_SSR_RUNTIME_SYMBOL];\n}\n\n/**\n * Registers the shared Radiant SSR runtime on `globalThis`.\n *\n * The latest registration wins, which keeps server adapters free to install\n * the runtime eagerly from their own explicit entrypoint.\n */\nexport function registerRadiantElementSsrRuntime(runtime: RadiantElementSsrRuntime): void {\n\t(globalThis as GlobalSsrRuntimeState)[RADIANT_COMPONENT_SSR_RUNTIME_SYMBOL] = runtime;\n}\n",
|
|
13
|
+
"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",
|
|
14
|
+
"import type { EventEmitter } from '../tools';\nimport {\n\thasHydrationMarkers,\n\thydrate as hydrateJsx,\n\tjsx,\n\trender as renderJsx,\n\ttype JsxRenderable,\n\ttype SubscribableJsxValue,\n} from '@ecopages/jsx';\nimport type { RenderToStringOptions } from '@ecopages/jsx/server';\nimport { Computed, subtle } from '@ecopages/signals';\nimport type { SsrSerializableContextProvider } from '../context/context-provider';\nimport type { UnknownContext } from '../context/types';\nimport { runLegacyInstanceInitializers } from '../decorators/legacy/instance-initializers';\nimport type { SsrSerializableHydrationBinding } from './ssr-hydration-binding';\nimport { ReactiveHost } from './reactive-host';\nimport { runSsrPreparationCallbacks } from './ssr-preparation';\nimport {\n\tDEFAULT_SLOT_NAME,\n\tSLOT_PROJECTION_SCRIPT_ATTRIBUTE,\n\tcollectAuthoredHydrationScriptMarkup,\n\tcaptureProjectedSlotRenderables,\n\tdeserializeProjectedSlotRenderables,\n\tresolveSlotProjection,\n\tserializeProjectedSlotRenderables,\n\ttakeSlotProjectionScriptPayload,\n} from './slot-projection-runtime';\nimport { HYDRATION_ATTRIBUTE } from './hydration-codec';\nimport { isRadiantHydratorInstalled } from './radiant-hydrator-state';\nimport {\n\tgetRadiantElementSsrRuntime,\n\ttype RadiantElementRenderBridge,\n\ttype RadiantElementSsrCapable,\n} from './radiant-component-ssr-registry';\nimport {\n\ttype AttributeTypeConstant,\n\ttype ReadAttributeValueReturnType,\n\ttype WriteAttributeValueReturnType,\n\tgetInitialValue,\n\tisValueOfType,\n\treadAttributeValue,\n\twriteAttributeValue,\n} from '../utils/attribute-utils';\n\nconst RadiantElementBase = resolveRadiantElementBase();\n\nfunction resolveRadiantElementBase(): typeof HTMLElement {\n\tif (typeof HTMLElement !== 'undefined') {\n\t\treturn HTMLElement;\n\t}\n\n\tthrow new Error(\n\t\t\"RadiantElement requires HTMLElement. Install '@ecopages/radiant/server/light-dom-shim' before importing Radiant components in SSR.\",\n\t);\n}\n\n/**\n * Possible positions to insert a rendered template.\n */\nexport type RenderInsertPosition = 'replace' | 'beforebegin' | 'afterbegin' | 'beforeend' | 'afterend';\n\n/**\n * Represents a Radiant element event listener.\n */\nexport type RadiantElementEventListener = {\n\tselector: string;\n\ttype: string;\n\tlistener: EventListener;\n\toptions?: AddEventListenerOptions;\n};\n\n/**\n * Represents a property metadata object.\n */\nexport interface ReactiveProperty<T = unknown> {\n\ttype: AttributeTypeConstant;\n\tvalue?: T;\n\tinitialValue?: T;\n\tname: string;\n\tattribute: string;\n\tconverter: {\n\t\tfromAttribute: (value: string) => ReadAttributeValueReturnType;\n\t\ttoAttribute: (value: any) => WriteAttributeValueReturnType;\n\t};\n}\n\n/**\n * Represents the options for a reactive property.\n */\nexport type ReactivePropertyOptions<T> = {\n\ttype: AttributeTypeConstant;\n\treflect?: boolean;\n\tattribute?: string;\n\tdefaultValue?: T;\n\t/**\n\t * Exposes a JSX binding companion for the reactive property.\n\t *\n\t * - `true` creates a `$propertyName` accessor.\n\t * - a string creates a custom accessor with that name.\n\t * - `undefined` defers to the host default.\n\t *\n\t * The generated accessor returns a subscribable JSX child value so JSX can\n\t * patch only the affected child part when the property changes.\n\t */\n\tbind?: boolean | string;\n};\n\nexport type ReactiveBindingOption = boolean | string;\n\nexport type ReactiveFieldOptions = {\n\t/**\n\t * Exposes a JSX binding companion for the reactive field.\n\t *\n\t * - `true` creates a `$fieldName` accessor.\n\t * - a string creates a custom accessor with that name.\n\t * - `undefined` defers to the host default.\n\t */\n\tbind?: ReactiveBindingOption;\n};\n\nexport type ReactiveField<T = unknown> = {\n\tname: string;\n\tvalue: T;\n\tinitialValue: T;\n};\n\ntype StringPropertyKey<Value> = Extract<keyof Value, string>;\n\n/**\n * Value type produced by a JSX binding for a selected reactive member.\n *\n * Bindings preserve the original property type when it is already renderable by\n * the Ecopages JSX runtime. For non-renderable values, the binding falls back\n * to the broader `JsxRenderable` contract consumed by the renderer.\n */\nexport type ReactiveBindingValue<\n\tHost extends object,\n\tProperty extends StringPropertyKey<Host>,\n> = Host[Property] extends JsxRenderable ? Host[Property] : JsxRenderable;\n\n/**\n * Namespace of cached JSX bindings keyed by the explicit bindable shape.\n *\n * Radiant exposes this namespace twice on every host:\n *\n * - `host.bindings.key` for the explicit form\n * - `host.$.key` for the short form\n *\n * Both aliases resolve through the same cached binding objects as\n * `host.bind('key')`.\n */\nexport type ReactiveBindings<Bindings extends object> = {\n\treadonly [Property in StringPropertyKey<Bindings>]: SubscribableJsxValue<ReactiveBindingValue<Bindings, Property>>;\n};\n\n/**\n * Represents an interface for a Radiant element.\n * @typeParam Bindings - Explicit internal bindable shape used to type `bind()` and `getReactiveBinding()`.\n *\n * This shape describes which reactive members are exposed through `bindings`,\n * `$`, and `bind(...)`. It does not automatically define the public JSX\n * attribute contract for the custom element.\n */\nexport interface IRadiantElement<Bindings extends object = {}> {\n\t/**\n\t * Namespace of cached JSX bindings keyed by the explicit bindable shape.\n\t */\n\treadonly bindings: ReactiveBindings<Bindings>;\n\n\t/**\n\t * Short alias for {@link bindings}.\n\t */\n\treadonly $: ReactiveBindings<Bindings>;\n\n\t/**\n\t * Called when a property of the element is updated.\n\t * @param changedProperty - The name of the changed property.\n\t * @param oldValue - The old value of the property.\n\t * @param newValue - The new value of the property.\n\t */\n\tnotifyUpdate(changedProperty: string, oldValue: unknown, newValue: unknown): void;\n\n\t/**\n\t * Subscribes to a Radiant element event.\n\t * @param event - The event listener to subscribe to.\n\t */\n\tsubscribeEvent(event: RadiantElementEventListener): void;\n\n\t/**\n\t * Registers a callback to be invoked when a reactive property or field changes.\n\t *\n\t * @returns A cleanup function that unregisters the callback.\n\t */\n\tregisterUpdateCallback(property: string, update: (...rest: any[]) => any): () => void;\n\n\t/**\n\t * Returns a subscribable JSX child binding for a reactive property or field.\n\t *\n\t * Prefer `this.bindings.key` or `this.$.key` in JSX render code when you want\n\t * property access syntax without string literals.\n\t */\n\tbind<Property extends StringPropertyKey<Bindings>>(\n\t\tproperty: Property,\n\t): SubscribableJsxValue<ReactiveBindingValue<Bindings, Property>>;\n\n\t/**\n\t * Returns a subscribable JSX child binding for a reactive property or field.\n\t *\n\t * This is the primitive lookup used by `bind()`, `bindings.key`, and `$.key`.\n\t */\n\tgetReactiveBinding<Property extends StringPropertyKey<Bindings>>(\n\t\tproperty: Property,\n\t): SubscribableJsxValue<ReactiveBindingValue<Bindings, Property>>;\n\n\t/**\n\t * Defines a stable JSX binding companion accessor for a reactive member.\n\t *\n\t * Companion bindings create properties such as `$count` directly on the host.\n\t * Prefer the `bindings` or `$` namespace for new code when you want typed,\n\t * explicit access to the configured bindable shape.\n\t */\n\tdefineReactiveBinding(property: string, bind?: ReactiveBindingOption): void;\n\n\t/**\n\t * Subscribes to multiple Radiant element events.\n\t * @param events - The array of event listeners to subscribe to.\n\t */\n\tsubscribeEvents(events: RadiantElementEventListener[]): void;\n\n\t/**\n\t * It adds a callback to be executed when the Radiant element is disconnected from the DOM.\n\t */\n\tregisterCleanupCallback(callback: () => void): void;\n\n\t/**\n\t * Registers a callback to run on each future host connection.\n\t *\n\t * The callback is only invoked from `connectedCallback()`. Registering it\n\t * after the host is already connected does not invoke it immediately.\n\t */\n\tregisterConnectedCallback(callback: () => void): void;\n\n\t/**\n\t * Registers a raw value reader for a reactive member so that tracked render\n\t * dependencies can read the underlying value without triggering the public\n\t * getter's dependency tracking.\n\t */\n\tregisterReactiveDependencyReader(property: string, read: () => unknown): void;\n\n\t/**\n\t * Records a tracked read of a reactive member during a component render,\n\t * allowing the signals runtime to re-render only the affected parts.\n\t */\n\ttrackReactiveRead(property: string): void;\n\n\t/**\n\t * Renders a trusted HTML template string into the specified target element.\n\t *\n\t * **Security:** The `template` string is written to the DOM via `innerHTML`\n\t * or `insertAdjacentHTML` without built-in sanitization. Callers are\n\t * responsible for ensuring the input is trusted. Supply a `sanitize`\n\t * function to transform the template before insertion.\n\t *\n\t * @param options - The rendering options.\n\t * @param options.target - The target element to render the template into.\n\t * @param options.template - The template string to render.\n\t * @param options.insert - The position to insert the rendered template. (optional)\n\t * @param options.sanitize - An optional function that transforms the template string before insertion.\n\t */\n\trenderTemplate(options: {\n\t\ttarget: HTMLElement;\n\t\ttemplate: string;\n\t\tinsert?: RenderInsertPosition;\n\t\tsanitize?: (html: string) => string;\n\t}): void;\n\n\t/**\n\t * Called when the Radiant element is connected to a context.\n\t * @param context - The connected context.\n\t */\n\tconnectedContextCallback(context: UnknownContext): void;\n\n\t/**\n\t * Gets a reference to a child element by its data-ref attribute.\n\t * @param ref - The data-ref attribute value of the element to get.\n\t * @param all - Whether to get all elements with the specified data-ref attribute value.\n\t * @returns The element with the specified data-ref attribute value, an array of elements or null if no element was found.\n\t */\n\tgetRef<T extends Element = Element>(ref: string, all: true): T[];\n\tgetRef<T extends Element = Element>(ref: string, all?: false): T | null;\n}\n\n/**\n * A base class for creating custom elements with reactive properties and event subscriptions.\n * @typeParam Bindings - Explicit internal bindable shape. Include only the\n * prop/state keys that JSX bindings should accept.\n *\n * Prefer a separate public props type for custom-element JSX declarations when\n * the external attribute contract differs from the component's internal\n * reactive state. Reuse the same type only when the public props and bindable\n * members are intentionally identical.\n * @extends HTMLElement\n * @implements IRadiantElement<Bindings>\n */\nexport class RadiantElement<Bindings extends object = {}>\n\textends RadiantElementBase\n\timplements IRadiantElement<Bindings>\n{\n\tpublic readonly bindings: ReactiveBindings<Bindings>;\n\tpublic readonly $: ReactiveBindings<Bindings>;\n\tprivate readonly reactiveHost: ReactiveHost<this, Bindings>;\n\n\t/**\n\t * A map of property metadata objects, it contains useful information about the properties configured via decorators.\n\t */\n\tprivate reactiveProperties = new Map<string, ReactiveProperty>();\n\n\t/**\n\t * Registered context providers keyed by decorated property name.\n\t */\n\tprivate contextProviders = new Map<string, SsrSerializableContextProvider>();\n\n\t/**\n\t * Registered keyed hydration payload producers appended to SSR host output.\n\t */\n\tprivate hydrationBindings = new Map<string, SsrSerializableHydrationBinding>();\n\n\t/**\n\t * A map of event subscriptions used to manage event listeners on the Radiant element.\n\t */\n\tprivate eventSubscriptions = new Map<string, RadiantElementEventListener>();\n\n\t/**\n\t * A map for event emitters\n\t */\n\tprivate eventEmitters = new Map<string, EventEmitter>();\n\n\t/**\n\t * A flag indicating whether the element has been connected to the DOM.\n\t */\n\tprivate elementReady = false;\n\tprivate isRendering = false;\n\tprivate isFirstConnectPending = false;\n\tprivate isRenderScheduled = false;\n\tprivate needsRender = false;\n\tprivate projectedSlotContent = new Map<string, JsxRenderable[]>();\n\tprivate renderSignal?: Computed<{ containsSlots: boolean; value: JsxRenderable }>;\n\tprivate readonly renderWatcher = new subtle.Watcher(() => {\n\t\tthis.requestUpdate();\n\t});\n\tprivate slotProjectionObserver?: MutationObserver;\n\tprivate slotProjectionVersion = 0;\n\n\tconstructor() {\n\t\tsuper();\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\tgetBindingTarget: (target) => Object.getPrototypeOf(target) ?? target,\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\tconnectedCallback() {\n\t\tconst isReconnectDuringPendingFirstConnect = this.isFirstConnectPending;\n\n\t\tthis.elementReady = true;\n\n\t\tthis.reactiveHost.connectHost();\n\n\t\tif (isReconnectDuringPendingFirstConnect) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.isFirstConnectPending = true;\n\n\t\tqueueMicrotask(() => {\n\t\t\tthis.isFirstConnectPending = false;\n\n\t\t\tif (!this.isConnected) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!this.shouldRunRenderLifecycle()) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.ensureSlotProjectionState();\n\t\t\tthis.observeSlotProjection();\n\n\t\t\tif (shouldHydrateOnConnect(this)) {\n\t\t\t\tthis.needsRender = false;\n\t\t\t\tthis.hydrate();\n\n\t\t\t\tif (this.needsRender) {\n\t\t\t\t\tthis.update();\n\t\t\t\t}\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.update();\n\t\t});\n\t}\n\n\tconnectedContextCallback(_contextName: UnknownContext): void {}\n\n\tdisconnectedCallback() {\n\t\tthis.disconnectSlotProjectionObserver();\n\t\tthis.disconnectRenderWatcher();\n\t\tthis.removeAllSubscribedEvents();\n\t\tthis.reactiveHost.disconnectHost();\n\t}\n\n\tpublic notifyUpdate(changedProperty: string, oldValue: unknown, value: unknown) {\n\t\tthis.reactiveHost.notifyUpdate(changedProperty, oldValue, value);\n\t}\n\n\tprivate transformAttributeValue(value: string | null, config: any): unknown {\n\t\treturn value !== null ? config?.converter.fromAttribute(value) : value;\n\t}\n\n\tattributeChangedCallback(name: string, oldValue: string | null, newValue: string | null) {\n\t\tif (oldValue === newValue || !this.elementReady) return;\n\n\t\tif (this.reactiveProperties.has(name)) {\n\t\t\tconst config = this.reactiveProperties.get(name);\n\n\t\t\tconst transformedValue = this.transformAttributeValue(newValue, config);\n\t\t\tconst transformedOldValue = this.transformAttributeValue(oldValue, config);\n\n\t\t\tconst key = config ? config.attribute : name;\n\t\t\t(this as any)[key] = transformedValue;\n\t\t\tthis.notifyUpdate(name, transformedOldValue, transformedValue);\n\t\t}\n\t}\n\n\t/**\n\t * Renders a trusted HTML template string into the specified target element.\n\t *\n\t * **Security:** The `template` string is written to the DOM via `innerHTML`\n\t * or `insertAdjacentHTML` without built-in sanitization. Callers are\n\t * responsible for ensuring the input is trusted. Supply a `sanitize`\n\t * function to transform the template before insertion.\n\t */\n\tpublic renderTemplate({\n\t\ttarget = this,\n\t\ttemplate,\n\t\tinsert = 'replace',\n\t\tsanitize,\n\t}: {\n\t\ttarget: HTMLElement;\n\t\ttemplate: string;\n\t\tinsert?: RenderInsertPosition;\n\t\tsanitize?: (html: string) => string;\n\t}) {\n\t\tconst html = sanitize ? sanitize(template) : template;\n\t\tswitch (insert) {\n\t\t\tcase 'replace':\n\t\t\t\ttarget.innerHTML = html;\n\t\t\t\tbreak;\n\t\t\tcase 'beforeend':\n\t\t\t\ttarget.insertAdjacentHTML('beforeend', html);\n\t\t\t\tbreak;\n\t\t\tcase 'afterbegin':\n\t\t\t\ttarget.insertAdjacentHTML('afterbegin', html);\n\t\t\t\tbreak;\n\t\t\tcase 'beforebegin':\n\t\t\t\ttarget.insertAdjacentHTML('beforebegin', html);\n\t\t\t\tbreak;\n\t\t\tcase 'afterend':\n\t\t\t\ttarget.insertAdjacentHTML('afterend', html);\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\tpublic render(): JsxRenderable {\n\t\treturn jsx('slot', {});\n\t}\n\n\tpublic renderToString(options: RenderToStringOptions = {}): string {\n\t\tif (!this.shouldRunRenderLifecycle()) {\n\t\t\treturn this.innerHTML;\n\t\t}\n\n\t\tthis.prepareForSsr();\n\n\t\treturn requireRadiantElementSsrRuntime().renderView(this as unknown as RadiantElementSsrCapable, options);\n\t}\n\n\tpublic renderHost(): JsxRenderable {\n\t\treturn requireRadiantElementSsrRuntime().renderHost(this as unknown as RadiantElementSsrCapable);\n\t}\n\n\tpublic renderHostToString(options: RenderToStringOptions = {}): string {\n\t\treturn requireRadiantElementSsrRuntime().renderHostToString(\n\t\t\tthis as unknown as RadiantElementSsrCapable,\n\t\t\toptions,\n\t\t);\n\t}\n\n\tpublic hydrate(): void {\n\t\tif (!this.shouldRunRenderLifecycle() || !this.isConnected || this.isRendering) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.isRendering = true;\n\t\tthis.disconnectSlotProjectionObserver();\n\n\t\ttry {\n\t\t\thydrateJsx(this.resolveTrackedRenderOutput().value, this);\n\t\t} finally {\n\t\t\tthis.isRendering = false;\n\t\t\tthis.observeSlotProjection();\n\t\t}\n\t}\n\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\tpublic update(): void {\n\t\tif (!this.shouldRunRenderLifecycle()) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.needsRender = true;\n\n\t\tif (!this.isConnected || this.isRendering) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.isFirstConnectPending && shouldHydrateOnConnect(this)) {\n\t\t\treturn;\n\t\t}\n\n\t\twhile (this.needsRender && this.isConnected) {\n\t\t\tthis.needsRender = false;\n\t\t\tthis.isRendering = true;\n\t\t\tthis.disconnectSlotProjectionObserver();\n\n\t\t\ttry {\n\t\t\t\trenderJsx(this.resolveTrackedRenderOutput().value, this);\n\t\t\t} finally {\n\t\t\t\tthis.isRendering = false;\n\t\t\t\tthis.observeSlotProjection();\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic registerReactiveProperty(config: ReactiveProperty) {\n\t\tthis.reactiveProperties.set(config.name, config);\n\t}\n\n\tprotected getReactiveProperties(): ReactiveProperty[] {\n\t\treturn Array.from(this.reactiveProperties.values());\n\t}\n\n\tpublic registerReactiveDependencyReader(property: string, read: () => unknown): void {\n\t\tthis.reactiveHost.registerReactiveDependencyReader(property, read);\n\t}\n\n\tpublic registerContextProvider(name: string, provider: SsrSerializableContextProvider): void {\n\t\tthis.contextProviders.set(name, provider);\n\t\tthis.registerHydrationBinding(name, provider);\n\t}\n\n\tpublic registerHydrationBinding(name: string, binding: SsrSerializableHydrationBinding): void {\n\t\tthis.hydrationBindings.set(name, binding);\n\t}\n\n\tprotected getContextProviders(): SsrSerializableContextProvider[] {\n\t\treturn Array.from(this.contextProviders.values());\n\t}\n\n\tprotected getHydrationBindings(): SsrSerializableHydrationBinding[] {\n\t\treturn Array.from(this.hydrationBindings.values());\n\t}\n\n\t/**\n\t * Flushes any deferred SSR-only preparation work before the host is\n\t * serialized.\n\t *\n\t * Radiant uses this to reapply SSR consumer state after construction so the\n\t * first server render sees finalized fields, props, and authored content.\n\t */\n\tprotected prepareForSsr(): void {\n\t\trunSsrPreparationCallbacks(this);\n\t}\n\n\t/**\n\t * Returns the default JSX binding policy for reactive members on this host.\n\t *\n\t * `RadiantElement` hosts default to automatic bindings for reactive members\n\t * when no explicit `bind` option is supplied.\n\t *\n\t * Lower-level hosts can override this hook to opt out when they want binding\n\t * creation to stay fully explicit across `@prop`, `@state`, and direct\n\t * `createReactiveProp`/`createReactiveField` calls.\n\t */\n\tprotected shouldAutoBindReactiveMembers(): boolean {\n\t\treturn true;\n\t}\n\n\tprotected shouldRunRenderLifecycle(): boolean {\n\t\treturn this.render !== RadiantElement.prototype.render;\n\t}\n\n\tprotected getHostSsrAttributes(): Record<string, string> {\n\t\treturn requireRadiantElementSsrRuntime().getHostAttributes(this as unknown as RadiantElementSsrCapable);\n\t}\n\n\tprotected resolveSsrRenderBridge(): RadiantElementRenderBridge {\n\t\tconst bridge: RadiantElementRenderBridge = {};\n\n\t\tif (this.renderHostToString === RadiantElement.prototype.renderHostToString) {\n\t\t\tbridge.renderHostToString = (options: RenderToStringOptions | undefined) =>\n\t\t\t\tthis.renderHostToString(options);\n\t\t}\n\n\t\tif (this.renderHost === RadiantElement.prototype.renderHost) {\n\t\t\tbridge.renderHost = () => this.renderHost();\n\t\t}\n\n\t\treturn bridge;\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 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\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\tpublic defineReactiveBinding(property: string, bind: ReactiveBindingOption = true): void {\n\t\tthis.reactiveHost.defineReactiveBinding(property, bind);\n\t}\n\n\tpublic trackReactiveRead(property: string): void {\n\t\tthis.reactiveHost.trackReactiveRead(property);\n\t}\n\n\tpublic subscribeEvents(events: RadiantElementEventListener[]): Array<() => void> {\n\t\tconst unsubscribers: Array<() => void> = [];\n\t\tfor (const event of events) {\n\t\t\tunsubscribers.push(this.subscribeEvent(event));\n\t\t}\n\t\treturn unsubscribers;\n\t}\n\n\tpublic subscribeEvent(eventConfig: RadiantElementEventListener): () => void {\n\t\tconst delegatedListener = (delegatedEvent: Event) => {\n\t\t\tif (delegatedEvent.target && (delegatedEvent.target as Element).matches(eventConfig.selector)) {\n\t\t\t\teventConfig.listener.call(this, delegatedEvent);\n\t\t\t}\n\t\t};\n\t\tconst subscriptionId = `${eventConfig.type}:${eventConfig.selector}`;\n\t\tthis.addEventListener(eventConfig.type, delegatedListener, eventConfig.options);\n\t\tthis.eventSubscriptions.set(subscriptionId, {\n\t\t\t...eventConfig,\n\t\t\tlistener: delegatedListener,\n\t\t});\n\n\t\treturn this.unsubscribeEvent.bind(this, subscriptionId);\n\t}\n\n\tprivate unsubscribeEvent(id: string): void {\n\t\tconst eventSubscription = this.eventSubscriptions.get(id);\n\t\tif (eventSubscription) {\n\t\t\tthis.removeEventListener(eventSubscription.type, eventSubscription.listener, eventSubscription.options);\n\t\t\tthis.eventSubscriptions.delete(id);\n\t\t}\n\t}\n\n\tprivate removeAllSubscribedEvents(): void {\n\t\tfor (const eventSubscription of this.eventSubscriptions.values()) {\n\t\t\tthis.removeEventListener(eventSubscription.type, eventSubscription.listener, eventSubscription.options);\n\t\t}\n\t\tthis.eventSubscriptions.clear();\n\t}\n\n\t/**\n\t * Registers a callback that runs on every future disconnect.\n\t */\n\tpublic registerCleanupCallback(callback: () => void): void {\n\t\tthis.reactiveHost.registerCleanupCallback(callback);\n\t}\n\n\t/**\n\t * Registers a callback that runs from `connectedCallback()` on future host\n\t * connections.\n\t *\n\t * Registering after the host is already connected does not invoke the\n\t * callback immediately.\n\t */\n\tpublic registerConnectedCallback(callback: () => void): void {\n\t\tthis.reactiveHost.registerConnectedCallback(callback);\n\t}\n\n\tpublic registerEventEmitter(name: string, emitter: EventEmitter) {\n\t\tthis.eventEmitters.set(name, emitter);\n\t}\n\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\t\tif (all) {\n\t\t\treturn Array.from(this.querySelectorAll(selector)) as T[];\n\t\t}\n\t\treturn (this.querySelector(selector) as T) ?? null;\n\t}\n\n\tpublic getSlotElement<T extends Element = Element>(name?: string): T | null {\n\t\treturn (this.getSlotElements<T>(name)[0] ?? null) as T | null;\n\t}\n\n\tpublic getSlotElements<T extends Element = Element>(name?: string): T[] {\n\t\tthis.ensureSlotProjectionState();\n\n\t\treturn (this.projectedSlotContent.get(name ?? DEFAULT_SLOT_NAME) ?? []).filter(\n\t\t\t(renderable): renderable is T => typeof Node !== 'undefined' && renderable instanceof Element,\n\t\t);\n\t}\n\n\tpublic createReactiveField<T>(propertyName: string, initialValue: T, options: ReactiveFieldOptions = {}): void {\n\t\tthis.reactiveHost.createReactiveField(propertyName, initialValue, options);\n\t}\n\n\tpublic createReactiveProp<T = unknown>(propertyName: string, options: ReactivePropertyOptions<T>): void {\n\t\tconst { type, attribute, reflect, defaultValue } = options;\n\t\tconst attributeKey = attribute ?? propertyName;\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 initialValue: T | undefined = getInitialValue(this, type, attributeKey, defaultValue) as T;\n\n\t\tif (this.hasAttribute(attributeKey) && (!reflect || initialValue == null || initialValue === '')) {\n\t\t\tthis.removeAttribute(attributeKey);\n\t\t}\n\n\t\tconst propertyMapping: ReactiveProperty<T> = {\n\t\t\ttype,\n\t\t\tname: propertyName,\n\t\t\tvalue: initialValue,\n\t\t\tinitialValue,\n\t\t\tattribute: attributeKey,\n\t\t\tconverter: {\n\t\t\t\tfromAttribute: (value) => readAttributeValue(value, type),\n\t\t\t\ttoAttribute: (value) => writeAttributeValue(value, type),\n\t\t\t},\n\t\t};\n\n\t\tthis.registerReactiveProperty(propertyMapping);\n\n\t\tconst handleReflectRequest = (value: T) => {\n\t\t\tif (reflect) {\n\t\t\t\tif (value == null || value === '' || value === false) {\n\t\t\t\t\tthis.removeAttribute(attributeKey);\n\t\t\t\t} else {\n\t\t\t\t\tconst attributeValue = propertyMapping.converter.toAttribute(value);\n\t\t\t\t\tthis.setAttribute(attributeKey, attributeValue);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tthis.reactiveHost.defineReactiveAccessor(propertyName, {\n\t\t\tbind: options.bind,\n\t\t\tgetValue: () => this.reactiveProperties.get(propertyName)?.value as T | undefined,\n\t\t\tsetValue: (newValue: T) => {\n\t\t\t\tthis.reactiveProperties.set(propertyName, { ...propertyMapping, value: newValue });\n\t\t\t\thandleReflectRequest(newValue);\n\t\t\t},\n\t\t});\n\n\t\tif (initialValue !== undefined) {\n\t\t\tqueueMicrotask(() => {\n\t\t\t\tconst currentValue = this.reactiveProperties.get(propertyName)?.value as T | undefined;\n\t\t\t\tif (currentValue === undefined) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\thandleReflectRequest(currentValue);\n\t\t\t\tthis.notifyUpdate(propertyName, undefined, currentValue);\n\t\t\t});\n\t\t}\n\t}\n\n\tprivate ensureSlotProjectionState(): void {\n\t\tif (this.projectedSlotContent.size > 0) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst scriptPayload = this.isConnected ? takeSlotProjectionScriptPayload(this) : undefined;\n\n\t\tif (typeof scriptPayload === 'string' && scriptPayload !== '') {\n\t\t\tthis.projectedSlotContent = deserializeProjectedSlotRenderables(scriptPayload);\n\t\t\tthis.slotProjectionVersion += 1;\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.getHostChildNodeCount() > 0) {\n\t\t\tthis.projectedSlotContent = captureProjectedSlotRenderables(this);\n\t\t\tthis.slotProjectionVersion += 1;\n\t\t}\n\t}\n\n\tprivate getHostChildNodeCount(): number {\n\t\treturn 'childNodes' in this && this.childNodes ? this.childNodes.length : 0;\n\t}\n\n\tprivate getSlotProjectionScriptTag(): string | undefined {\n\t\tthis.ensureSlotProjectionState();\n\t\tconst payload = serializeProjectedSlotRenderables(this.projectedSlotContent);\n\n\t\tif (!payload) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn `<script type=\"application/json\" ${SLOT_PROJECTION_SCRIPT_ATTRIBUTE}>${escapeScriptText(payload)}</script>`;\n\t}\n\n\tprivate getAuthoredHydrationScriptMarkup(): string | undefined {\n\t\tconst authoredHydrationMarkup = collectAuthoredHydrationScriptMarkup(this);\n\n\t\tif (authoredHydrationMarkup) {\n\t\t\treturn authoredHydrationMarkup;\n\t\t}\n\n\t\treturn undefined;\n\t}\n\n\tprivate handleSlotProjectionMutations(records: MutationRecord[]): void {\n\t\tlet hasProjectionChanges = false;\n\n\t\tfor (const record of records) {\n\t\t\tfor (const removedNode of Array.from(record.removedNodes)) {\n\t\t\t\tif (this.removeProjectedSlotNode(removedNode)) {\n\t\t\t\t\thasProjectionChanges = true;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tfor (const addedNode of Array.from(record.addedNodes)) {\n\t\t\t\tif (addedNode.parentNode !== this) {\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tif (this.addProjectedSlotNode(addedNode)) {\n\t\t\t\t\thasProjectionChanges = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (hasProjectionChanges) {\n\t\t\tthis.slotProjectionVersion += 1;\n\t\t\tthis.update();\n\t\t}\n\t}\n\n\tprivate addProjectedSlotNode(node: Node): boolean {\n\t\tif (\n\t\t\tnode instanceof HTMLScriptElement &&\n\t\t\t(node.hasAttribute(SLOT_PROJECTION_SCRIPT_ATTRIBUTE) || node.hasAttribute(HYDRATION_ATTRIBUTE))\n\t\t) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst slotName = node instanceof Element ? (node.getAttribute('slot') ?? DEFAULT_SLOT_NAME) : DEFAULT_SLOT_NAME;\n\t\tconst bucket = this.projectedSlotContent.get(slotName);\n\n\t\tif (bucket) {\n\t\t\tif (bucket.includes(node)) {\n\t\t\t\treturn false;\n\t\t\t}\n\n\t\t\tbucket.push(node);\n\t\t\treturn true;\n\t\t}\n\n\t\tthis.projectedSlotContent.set(slotName, [node]);\n\t\treturn true;\n\t}\n\n\tprivate removeProjectedSlotNode(node: Node): boolean {\n\t\tfor (const [slotName, bucket] of this.projectedSlotContent.entries()) {\n\t\t\tconst nodeIndex = bucket.indexOf(node);\n\n\t\t\tif (nodeIndex === -1) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tbucket.splice(nodeIndex, 1);\n\n\t\t\tif (bucket.length === 0) {\n\t\t\t\tthis.projectedSlotContent.delete(slotName);\n\t\t\t}\n\n\t\t\treturn true;\n\t\t}\n\n\t\treturn false;\n\t}\n\n\tprivate observeSlotProjection(): void {\n\t\tif (typeof MutationObserver === 'undefined' || this.slotProjectionObserver || !this.isConnected) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.slotProjectionObserver = new MutationObserver((records) => this.handleSlotProjectionMutations(records));\n\t\tthis.slotProjectionObserver.observe(this, { childList: true });\n\t}\n\n\tprivate disconnectSlotProjectionObserver(): void {\n\t\tthis.slotProjectionObserver?.disconnect();\n\t\tthis.slotProjectionObserver = undefined;\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(): { containsSlots: boolean; value: JsxRenderable } {\n\t\tconst nextRenderSignal = new Computed(() => this.resolveRenderOutput());\n\t\tconst output = nextRenderSignal.get();\n\n\t\tif (!this.isConnected) {\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.renderSignal = nextRenderSignal;\n\t\tthis.renderWatcher.watch(nextRenderSignal);\n\t\treturn output;\n\t}\n\n\tprivate resolveRenderOutput(): { containsSlots: boolean; value: JsxRenderable } {\n\t\tthis.ensureSlotProjectionState();\n\t\treturn resolveSlotProjection(this.render(), this.projectedSlotContent);\n\t}\n}\n\nfunction requireRadiantElementSsrRuntime() {\n\tconst runtime = getRadiantElementSsrRuntime();\n\n\tif (!runtime) {\n\t\tthrow new Error(\n\t\t\t'Radiant SSR runtime is unavailable. Import `@ecopages/radiant/server/render-component` before using instance SSR methods.',\n\t\t);\n\t}\n\n\treturn runtime;\n}\n\nfunction shouldHydrateOnConnect(component: HTMLElement): boolean {\n\treturn isRadiantHydratorInstalled() && hasHydrationMarkers(component);\n}\n\nfunction escapeScriptText(value: string): string {\n\treturn value.replace(/</g, '\\\\u003c');\n}\n",
|
|
15
|
+
"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 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.connected = true;\n\t\tthis.reactiveHost.connectHost();\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.disconnectRenderWatcher();\n\t\tthis.reactiveHost.disconnectHost();\n\t\tthis.connected = false;\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.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.renderSignal = nextRenderSignal;\n\t\tthis.renderWatcher.watch(nextRenderSignal);\n\t\treturn output;\n\t}\n}\n",
|
|
16
|
+
"import type { SubscribableJsxValue } from '@ecopages/jsx';\nimport type { RadiantElement, ReactiveBindingValue } from './radiant-element';\n\n/**\n * Creates a stable JSX child binding backed by a Radiant reactive property or field.\n *\n * The returned value resolves eagerly on the server and subscribes to the host's\n * update callbacks on the client so the mounted child range can patch directly\n * when the selected property changes.\n */\nexport function bindReactiveValue<\n\tBindings extends object,\n\tHost extends RadiantElement<Bindings>,\n\tProperty extends Extract<keyof Bindings, string>,\n>(host: Host, property: Property): SubscribableJsxValue<ReactiveBindingValue<Bindings, Property>> {\n\treturn host.bind(property);\n}\n",
|
|
17
|
+
"export const CONTROLLER_IDENTIFIER = Symbol.for('@ecopages/radiant.controllerIdentifier');\n\ntype ControllerConstructorWithMetadata = CustomElementConstructor & {\n\t[CONTROLLER_IDENTIFIER]?: string;\n};\n\nexport function setControllerIdentifier(target: CustomElementConstructor, identifier: string): void {\n\t(target as ControllerConstructorWithMetadata)[CONTROLLER_IDENTIFIER] = identifier;\n}\n\nexport function getControllerIdentifier(target: CustomElementConstructor): string | undefined {\n\treturn (target as ControllerConstructorWithMetadata)[CONTROLLER_IDENTIFIER];\n}\n",
|
|
18
|
+
"import type { RadiantController } from './core/radiant-controller';\nimport { setControllerIdentifier } from './core/controller-metadata';\n\nexport const CONTROLLER_ATTRIBUTE = 'data-controller';\n\nexport type ControllerConstructor<TController extends RadiantController = RadiantController> = new (\n\thost: Element,\n) => TController;\n\nexport type ControllerRegistrationStrategy = 'keep-current' | 'replace';\n\ntype ControllerRegistryGlobalState = {\n\tactiveRuntimes: Set<ControllerRegistryRuntime>;\n\tcontrollerRegistrationStrategy: ControllerRegistrationStrategy;\n\tcontrollerRegistry: Map<string, ControllerConstructor>;\n};\n\nconst CONTROLLER_REGISTRY_STATE_KEY = Symbol.for('@ecopages/radiant.controller-registry-state');\n\nfunction getControllerRegistryGlobalState(): ControllerRegistryGlobalState {\n\tconst globalScope = globalThis as typeof globalThis & Record<PropertyKey, unknown>;\n\tconst existingState = globalScope[CONTROLLER_REGISTRY_STATE_KEY];\n\n\tif (existingState) {\n\t\treturn existingState as ControllerRegistryGlobalState;\n\t}\n\n\tconst nextState: ControllerRegistryGlobalState = {\n\t\tactiveRuntimes: new Set<ControllerRegistryRuntime>(),\n\t\tcontrollerRegistrationStrategy: 'keep-current',\n\t\tcontrollerRegistry: new Map<string, ControllerConstructor>(),\n\t};\n\n\tglobalScope[CONTROLLER_REGISTRY_STATE_KEY] = nextState;\n\n\treturn nextState;\n}\n\nconst controllerRegistryState = getControllerRegistryGlobalState();\nconst controllerRegistry = controllerRegistryState.controllerRegistry;\nconst activeRuntimes = controllerRegistryState.activeRuntimes;\n\nfunction parseControllerIdentifiers(element: Element): string[] {\n\tconst value = element.getAttribute(CONTROLLER_ATTRIBUTE);\n\n\tif (!value) {\n\t\treturn [];\n\t}\n\n\treturn value\n\t\t.split(/\\s+/)\n\t\t.map((identifier) => identifier.trim())\n\t\t.filter((identifier) => identifier.length > 0);\n}\n\nfunction visitControllerElements(root: ParentNode, visit: (element: Element) => void): void {\n\tif (root instanceof Element && root.hasAttribute(CONTROLLER_ATTRIBUTE)) {\n\t\tvisit(root);\n\t}\n\n\tfor (const element of Array.from(root.querySelectorAll(`[${CONTROLLER_ATTRIBUTE}]`))) {\n\t\tvisit(element);\n\t}\n}\n\nexport class ControllerRegistryRuntime {\n\tprivate readonly controllersByElement = new Map<Element, Map<string, RadiantController>>();\n\tprivate observer?: MutationObserver;\n\tprivate stopped = false;\n\n\tconstructor(private readonly root: ParentNode = document) {\n\t\tthis.start();\n\t}\n\n\tpublic stop(): void {\n\t\tif (this.stopped) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.stopped = true;\n\t\tthis.observer?.disconnect();\n\t\tthis.observer = undefined;\n\n\t\tfor (const [element, controllers] of this.controllersByElement) {\n\t\t\tfor (const [identifier] of controllers) {\n\t\t\t\tthis.disconnectController(element, identifier);\n\t\t\t}\n\t\t}\n\n\t\tactiveRuntimes.delete(this);\n\t}\n\n\tpublic reconcileRegisteredController(identifier: string): void {\n\t\tvisitControllerElements(this.root, (element) => {\n\t\t\tif (!parseControllerIdentifiers(element).includes(identifier)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.connectController(element, identifier);\n\t\t});\n\t}\n\n\tpublic replaceRegisteredController(identifier: string): void {\n\t\tfor (const [element, controllers] of Array.from(this.controllersByElement.entries())) {\n\t\t\tif (!controllers.has(identifier)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tthis.disconnectController(element, identifier);\n\t\t}\n\n\t\tthis.reconcileRegisteredController(identifier);\n\t}\n\n\tprivate start(): void {\n\t\tvisitControllerElements(this.root, (element) => {\n\t\t\tthis.reconcileElement(element);\n\t\t});\n\n\t\tif (typeof MutationObserver === 'undefined') {\n\t\t\tactiveRuntimes.add(this);\n\t\t\treturn;\n\t\t}\n\n\t\tthis.observer = new MutationObserver((records) => {\n\t\t\tfor (const record of records) {\n\t\t\t\tif (record.type === 'attributes' && record.target instanceof Element) {\n\t\t\t\t\tthis.reconcileElement(record.target);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\n\t\t\t\tfor (const removedNode of Array.from(record.removedNodes)) {\n\t\t\t\t\tif (!(removedNode instanceof Element)) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tvisitControllerElements(removedNode, (element) => {\n\t\t\t\t\t\tthis.disconnectElementControllers(element);\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\tfor (const addedNode of Array.from(record.addedNodes)) {\n\t\t\t\t\tif (!(addedNode instanceof Element)) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\tvisitControllerElements(addedNode, (element) => {\n\t\t\t\t\t\tthis.reconcileElement(element);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\tconst observerRoot = this.root instanceof Document ? this.root.documentElement : this.root;\n\n\t\tthis.observer.observe(observerRoot, {\n\t\t\tattributeFilter: [CONTROLLER_ATTRIBUTE],\n\t\t\tattributes: true,\n\t\t\tchildList: true,\n\t\t\tsubtree: true,\n\t\t});\n\n\t\tactiveRuntimes.add(this);\n\t}\n\n\tprivate reconcileElement(element: Element): void {\n\t\tconst nextIdentifiers = new Set(parseControllerIdentifiers(element));\n\t\tconst currentControllers = this.controllersByElement.get(element);\n\n\t\tif (currentControllers) {\n\t\t\tfor (const identifier of currentControllers.keys()) {\n\t\t\t\tif (!nextIdentifiers.has(identifier)) {\n\t\t\t\t\tthis.disconnectController(element, identifier);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor (const identifier of nextIdentifiers) {\n\t\t\tthis.connectController(element, identifier);\n\t\t}\n\t}\n\n\tprivate connectController(element: Element, identifier: string): void {\n\t\tconst controllerConstructor = controllerRegistry.get(identifier);\n\n\t\tif (!controllerConstructor) {\n\t\t\treturn;\n\t\t}\n\n\t\tlet controllers = this.controllersByElement.get(element);\n\n\t\tif (!controllers) {\n\t\t\tcontrollers = new Map();\n\t\t\tthis.controllersByElement.set(element, controllers);\n\t\t}\n\n\t\tif (controllers.has(identifier)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst controller = new controllerConstructor(element);\n\t\tcontrollers.set(identifier, controller);\n\t\tcontroller.connect();\n\t}\n\n\tprivate disconnectController(element: Element, identifier: string): void {\n\t\tconst controllers = this.controllersByElement.get(element);\n\n\t\tif (!controllers) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst controller = controllers.get(identifier);\n\n\t\tif (!controller) {\n\t\t\treturn;\n\t\t}\n\n\t\tcontroller.disconnect();\n\t\tcontrollers.delete(identifier);\n\n\t\tif (controllers.size === 0) {\n\t\t\tthis.controllersByElement.delete(element);\n\t\t}\n\t}\n\n\tprivate disconnectElementControllers(element: Element): void {\n\t\tconst controllers = this.controllersByElement.get(element);\n\n\t\tif (!controllers) {\n\t\t\treturn;\n\t\t}\n\n\t\tfor (const identifier of Array.from(controllers.keys())) {\n\t\t\tthis.disconnectController(element, identifier);\n\t\t}\n\t}\n}\n\nexport function registerController<\n\tTController extends RadiantController,\n\tTConstructor extends ControllerConstructor<TController>,\n>(identifier: string, controller: TConstructor): TConstructor {\n\tconst existingController = controllerRegistry.get(identifier);\n\n\tif (existingController) {\n\t\treturn existingController as TConstructor;\n\t}\n\n\tsetControllerIdentifier(controller as unknown as CustomElementConstructor, identifier);\n\tcontrollerRegistry.set(identifier, controller);\n\n\tfor (const runtime of Array.from(activeRuntimes)) {\n\t\truntime.reconcileRegisteredController(identifier);\n\t}\n\n\treturn controller;\n}\n\nexport function hasRegisteredController(identifier: string): boolean {\n\treturn controllerRegistry.has(identifier);\n}\n\nexport function replaceController<\n\tTController extends RadiantController,\n\tTConstructor extends ControllerConstructor<TController>,\n>(identifier: string, controller: TConstructor): TConstructor {\n\tconst existingController = controllerRegistry.get(identifier);\n\n\tif (existingController === controller) {\n\t\treturn controller;\n\t}\n\n\tsetControllerIdentifier(controller as unknown as CustomElementConstructor, identifier);\n\tcontrollerRegistry.set(identifier, controller);\n\n\tfor (const runtime of Array.from(activeRuntimes)) {\n\t\truntime.replaceRegisteredController(identifier);\n\t}\n\n\treturn controller;\n}\n\nexport function setControllerRegistrationStrategy(strategy: ControllerRegistrationStrategy): void {\n\tcontrollerRegistryState.controllerRegistrationStrategy = strategy;\n}\n\nexport function enableControllerReplacementForHmr(): void {\n\tsetControllerRegistrationStrategy('replace');\n}\n\nexport function disableControllerReplacementForHmr(): void {\n\tsetControllerRegistrationStrategy('keep-current');\n}\n\nexport function registerControllerWithConfiguredStrategy<\n\tTController extends RadiantController,\n\tTConstructor extends ControllerConstructor<TController>,\n>(identifier: string, controller: TConstructor): TConstructor {\n\tif (controllerRegistryState.controllerRegistrationStrategy === 'replace') {\n\t\treturn replaceController(identifier, controller);\n\t}\n\n\treturn registerController(identifier, controller);\n}\n\nexport function startControllers(root: ParentNode = document): ControllerRegistryRuntime {\n\treturn new ControllerRegistryRuntime(root);\n}\n\nexport function stopControllers(): void {\n\tfor (const runtime of Array.from(activeRuntimes)) {\n\t\truntime.stop();\n\t}\n}\n",
|
|
19
|
+
"import type { Context, ContextCallback, ContextType, UnknownContext } from './types';\n\n/**\n * List of events which can be emitted by a context provider or requester.\n */\nexport enum ContextEventsTypes {\n\tSUBSCRIPTION_REQUEST = 'context-subscription-request',\n\tCONTEXT_REQUEST = 'context-request',\n\tON_MOUNT = 'context-on-mount',\n\tMOUNTED = 'context-mounted',\n}\n\n/**\n * An event fired by a context requester to signal it desires a named context.\n *\n * A provider should inspect the `context` property of the event to determine if it has a value that can\n * satisfy the request, calling the `callback` with the requested value if so.\n *\n * If the requested context event contains a truthy `subscribe` value, then a provider can call the callback\n * multiple times if the value is changed, if this is the case the provider should pass an `unsubscribe`\n * function to the callback which requesters can invoke to indicate they no longer wish to receive these updates.\n */\nexport class ContextRequestEvent<T extends UnknownContext> extends Event {\n\tpublic handled = false;\n\n\tpublic constructor(\n\t\tpublic readonly context: T,\n\t\tpublic readonly callback: ContextCallback<ContextType<T>>,\n\t\tpublic readonly subscribe?: boolean,\n\t) {\n\t\tsuper(ContextEventsTypes.CONTEXT_REQUEST, { bubbles: true, composed: true });\n\t}\n\n\tpublic markHandled(): void {\n\t\tthis.handled = true;\n\t}\n}\n\n/**\n * A type which represents a subscription to a context value.\n */\ntype DirectContextSubscription<T extends UnknownContext> = {\n\tselect?: undefined;\n\tcallback: ContextCallback<ContextType<T>>;\n};\n\ntype SelectedContextSubscription<T extends UnknownContext, Selected> = {\n\tselect: (context: ContextType<T>) => Selected;\n\tcallback: ContextCallback<Selected>;\n};\n\nexport type ContextSubscription<T extends UnknownContext, Selected = ContextType<T>> =\n\t| DirectContextSubscription<T>\n\t| SelectedContextSubscription<T, Selected>;\n\n/**\n * An event fired by a context provider to signal that a context value has been mounted and is available for consumption.\n */\nexport class ContextOnMountEvent extends CustomEvent<{ context: UnknownContext }> {\n\tpublic constructor(context: UnknownContext) {\n\t\tsuper(ContextEventsTypes.ON_MOUNT, {\n\t\t\tdetail: { context },\n\t\t\tbubbles: true,\n\t\t\tcomposed: true,\n\t\t});\n\t}\n}\n\n/**\n * An event fired by a context requester to signal it desires a named context.\n *\n * A provider should inspect the `context` property of the event to determine if it has a value that can\n * satisfy the request, calling the `callback` with the requested value if so.\n *\n * If the requested context event contains a truthy `subscribe` value, then a provider can call the callback\n * multiple times if the value is changed, if this is the case the provider should pass an `unsubscribe`\n * function to the callback which requesters can invoke to indicate they no longer wish to receive these updates.\n *\n * It accepts a `selector` property which can be used to request a specific property of the context value.\n */\nexport class ContextSubscriptionRequestEvent<T extends UnknownContext, Selected = ContextType<T>> extends Event {\n\tpublic handled = false;\n\n\tpublic constructor(\n\t\tpublic readonly context: T,\n\t\tpublic readonly callback: ContextCallback<Selected>,\n\t\tpublic readonly select?: (context: ContextType<T>) => Selected,\n\t\tpublic readonly subscribe?: boolean,\n\t\tpublic readonly onSubscribe?: (unsubscribe: () => void) => void,\n\t) {\n\t\tsuper(ContextEventsTypes.SUBSCRIPTION_REQUEST, {\n\t\t\tbubbles: true,\n\t\t\tcomposed: true,\n\t\t});\n\t}\n\n\tpublic markHandled(): void {\n\t\tthis.handled = true;\n\t}\n}\n\ndeclare global {\n\tinterface HTMLElementEventMap {\n\t\t/**\n\t\t * A 'context-request-subscription' event can be emitted by any element which desires\n\t\t * a context value to be injected by an external provider.\n\t\t */\n\t\t[ContextEventsTypes.SUBSCRIPTION_REQUEST]: ContextSubscriptionRequestEvent<UnknownContext>;\n\t\t/**\n\t\t * A context-request-provider event can be emitted by a context requester to signal\n\t\t * that it desires a context value to be provided by a context provider.\n\t\t */\n\t\t[ContextEventsTypes.CONTEXT_REQUEST]: ContextRequestEvent<Context<unknown, unknown>>;\n\t\t/**\n\t\t * A 'context-mount' event can be emitted by a context provider to signal\n\t\t * that a context value has been mounted and is available for consumption.\n\t\t */\n\t\t[ContextEventsTypes.ON_MOUNT]: ContextOnMountEvent;\n\t}\n}\n",
|
|
20
|
+
"import { createHydrationScriptTag, escapeHydrationJson } from '../core/hydration-codec';\n\n/**\n * Creates the raw `<script type=\"application/json\">` tag used to hydrate a\n * serialized context provider.\n */\nexport function createContextHydrationScriptTag(options: { hydrationKey?: string; serializedValue: string }): string {\n\treturn createHydrationScriptTag({ type: 'context', ...options });\n}\n\n/**\n * Escapes serialized JSON so it remains safe when embedded inside an HTML\n * script tag.\n */\nexport function escapeContextHydrationJson(value: string): string {\n\treturn escapeHydrationJson(value);\n}\n",
|
|
21
|
+
"import type { UnknownContext } from './types';\n\ntype ContextHostApi = {\n\taddEventListener(\n\t\ttype: string,\n\t\tlistener: EventListenerOrEventListenerObject,\n\t\toptions?: boolean | AddEventListenerOptions,\n\t): void;\n\tremoveEventListener(\n\t\ttype: string,\n\t\tlistener: EventListenerOrEventListenerObject,\n\t\toptions?: boolean | EventListenerOptions,\n\t): void;\n\tdispatchEvent(event: Event): boolean;\n\tregisterConnectedCallback(callback: () => void): void;\n\tregisterCleanupCallback(callback: () => void): void;\n\tconnectedContextCallback(context: UnknownContext): void;\n\tregisterContextProvider(name: string, provider: unknown): void;\n};\n\ntype SsrHydrationContainer = {\n\tchildren?: ArrayLike<Element> | undefined;\n\tchildNodes?: ArrayLike<{ nodeType: number }> | undefined;\n};\n\nexport type ContextHydrationHost = Element | SsrHydrationContainer;\n\nexport type ContextHostLike =\n\t| (ContextHostApi & Element)\n\t| (ContextHostApi & { host: Element })\n\t| (ContextHostApi & { element: Element })\n\t| (ContextHostApi & SsrHydrationContainer);\n\nexport function resolveContextHostElement(host: ContextHostLike): Element | null {\n\tif (host instanceof Element) {\n\t\treturn host;\n\t}\n\n\tif ('host' in host) {\n\t\treturn host.host;\n\t}\n\n\tif ('element' in host) {\n\t\treturn host.element;\n\t}\n\n\treturn null;\n}\n\nexport function resolveContextHydrationHost(host: ContextHostLike): ContextHydrationHost {\n\tif (host instanceof Element) {\n\t\treturn host;\n\t}\n\n\tif ('host' in host) {\n\t\treturn host.host;\n\t}\n\n\tif ('element' in host) {\n\t\treturn host.element;\n\t}\n\n\treturn host;\n}\n",
|
|
22
|
+
"import { createMarkupNodeLike, type JsxRenderable } from '@ecopages/jsx';\nimport type { SsrSerializableHydrationBinding } from '../core/ssr-hydration-binding';\nimport type { AttributeTypeConstant } from '../utils/attribute-utils';\nimport {\n\tContextEventsTypes,\n\tContextOnMountEvent,\n\ttype ContextRequestEvent,\n\ttype ContextSubscription,\n\ttype ContextSubscriptionRequestEvent,\n} from './events';\nimport { findHydrationScript, parseHydrationPayload } from '../core/hydration-codec';\nimport { createContextHydrationScriptTag, escapeContextHydrationJson } from './hydration-script';\nimport type { Context, ContextType, UnknownContext } from './types';\nimport { resolveContextHydrationHost, type ContextHostLike } from './context-host';\n\ntype ContextProviderOptions<T extends UnknownContext> = {\n\tcontext: UnknownContext;\n\thydrationKey?: string;\n\tinitialValue?: T['__context__'];\n\thydrate?: AttributeTypeConstant;\n\tserialize?: (value: ContextType<T>) => unknown;\n};\n\ntype ActiveContextSubscription<T extends UnknownContext> = {\n\thasChanged(newContext: ContextType<T>, prevContext: ContextType<T> | undefined): boolean;\n\tnotify(context: ContextType<T>): void;\n\tunsubscribe: () => void;\n};\n\nexport interface SsrSerializableContextProvider extends SsrSerializableHydrationBinding {\n\t/** Returns the current context payload that should be visible to descendants. */\n\tgetContext(): unknown;\n\t/** Returns the context token used to match nested SSR consumers and providers. */\n\tgetContextKey(): UnknownContext;\n}\n\n/**\n * Represents a context provider that allows setting and getting the context,\n * as well as subscribing to context updates.\n *\n * @template T - The type of the context.\n */\nexport interface IContextProvider<T extends Context<unknown, unknown>> {\n\t/**\n\t * Sets the context with the provided update and invokes the optional callback function.\n\t *\n\t * @param update - The partial update to be applied to the context.\n\t * @param callback - An optional callback function that receives the updated context.\n\t */\n\tsetContext: (update: Partial<ContextType<T>>, callback?: (context: ContextType<T>) => void) => void;\n\n\t/**\n\t * Gets the current context.\n\t *\n\t * @returns The current context.\n\t */\n\tgetContext: () => ContextType<T>;\n\n\t/**\n\t * Subscribes to context updates.\n\t *\n\t * @param subscription - The subscription object that defines the callback function to be invoked on context updates.\n\t */\n\tsubscribe: <Selected = ContextType<T>>(subscription: ContextSubscription<T, Selected>) => () => void;\n}\n\n/**\n * It creates a context provider that allows setting and getting the context,\n * It will also be in charge of notifying the subscribers when the context changes.\n *\n * @template T - The type of the context.\n * @implements IContextProvider\n *\n * @example\n * ```ts\n * export class MyElement extends RadiantElement {\n * provider = new ContextProvider<typeof myContext>(this, {\n * context: myContext,\n * initialValue: {\n * value: 'Hello World',\n * },\n * });\n * ```\n */\nexport class ContextProvider<T extends Context<unknown, unknown>>\n\timplements IContextProvider<T>, SsrSerializableContextProvider\n{\n\tprivate host: ContextHostLike;\n\tprivate context: UnknownContext;\n\tprivate hydrationKey?: string;\n\tprivate hydrate?: AttributeTypeConstant;\n\tprivate serialize?: (value: ContextType<T>) => unknown;\n\tprivate pendingHostHydration: boolean;\n\tprivate value: ContextType<T> | undefined;\n\n\tsubscriptions: ActiveContextSubscription<T>[] = [];\n\n\t/**\n\t * Creates a new instance of the ContextProvider.\n\t *\n\t * @param host - The host element that will contain the context provider.\n\t * @param options - The options to configure the context provider.\n\t */\n\tconstructor(host: ContextHostLike, options: ContextProviderOptions<T>) {\n\t\tthis.host = host;\n\t\tthis.context = options.context;\n\t\tthis.hydrationKey = options.hydrationKey;\n\t\tthis.hydrate = options.hydrate;\n\t\tthis.serialize = options.serialize;\n\t\tthis.pendingHostHydration = Boolean(options.hydrate);\n\t\tthis.value = options.initialValue as ContextType<T>;\n\t\tthis.tryHydrateFromHost();\n\n\t\tthis.registerEvents();\n\t\tthis.host.dispatchEvent(new ContextOnMountEvent(this.context));\n\t}\n\n\tsetContext = (update: Partial<ContextType<T>>, callback?: (context: ContextType<T>) => void) => {\n\t\tthis.tryHydrateFromHost();\n\t\tthis.pendingHostHydration = false;\n\n\t\tif (typeof this.value === 'undefined' && this.isObject(update)) {\n\t\t\tconst oldContext = this.value;\n\t\t\tthis.value = { ...update } as ContextType<T>;\n\t\t\tif (callback) callback(this.value);\n\t\t\tthis.notifySubscribers(this.value, oldContext);\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.isObject(this.value) && this.isObject(update)) {\n\t\t\tconst oldContext = { ...this.value };\n\t\t\tthis.value = { ...this.value, ...update };\n\t\t\tif (callback) callback(this.value);\n\t\t\tthis.notifySubscribers(this.value, oldContext);\n\t\t}\n\t};\n\n\tgetContext = () => {\n\t\tthis.tryHydrateFromHost();\n\t\treturn this.value as ContextType<T>;\n\t};\n\n\t/**\n\t * Returns the provider's logical context token.\n\t *\n\t * SSR helpers use this token to resolve the closest matching provider while a\n\t * host subtree is being serialized.\n\t */\n\tgetContextKey = () => {\n\t\treturn this.context;\n\t};\n\n\t/**\n\t * Serializes the current provider value for inclusion in a hydration script.\n\t *\n\t * The serialized payload is JSON-escaped so it can be embedded safely inside a\n\t * `<script type=\"application/json\">` tag.\n\t */\n\tserializeHydrationValue = (): string | undefined => {\n\t\tthis.tryHydrateFromHost();\n\n\t\tif (!this.hydrate || typeof this.value === 'undefined') {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst hydrationValue = this.serialize ? this.serialize(this.value) : this.value;\n\n\t\tif (typeof hydrationValue === 'undefined') {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst serializedValue = JSON.stringify(hydrationValue);\n\n\t\tif (typeof serializedValue !== 'string') {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn escapeContextHydrationJson(serializedValue);\n\t};\n\n\t/**\n\t * Builds the raw HTML hydration script for this provider.\n\t *\n\t * When `hydrationKey` is present, the marker is scoped so sibling or nested\n\t * providers can recover their own payloads without accidentally reading a\n\t * descendant script.\n\t */\n\trenderHydrationScriptTag = (): string | undefined => {\n\t\tconst serializedValue = this.serializeHydrationValue();\n\n\t\tif (!serializedValue) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn createContextHydrationScriptTag({\n\t\t\thydrationKey: this.hydrationKey,\n\t\t\tserializedValue,\n\t\t});\n\t};\n\n\t/**\n\t * Wraps the provider hydration script in a minimal JSX node-like value.\n\t *\n\t * This lets JSX-based host renderers append the script without needing a real\n\t * DOM element instance during SSR.\n\t */\n\trenderHydrationScript = (): JsxRenderable | undefined => {\n\t\tconst outerHTML = this.renderHydrationScriptTag();\n\n\t\tif (!outerHTML) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn createMarkupNodeLike(outerHTML);\n\t};\n\n\tsubscribe = <Selected = ContextType<T>>(subscriptionSpec: ContextSubscription<T, Selected>) => {\n\t\tconst subscription: ActiveContextSubscription<T> = {\n\t\t\thasChanged: (newContext, prevContext) => {\n\t\t\t\tif (typeof prevContext === 'undefined' || !subscriptionSpec.select) {\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\n\t\t\t\treturn subscriptionSpec.select(newContext) !== subscriptionSpec.select(prevContext);\n\t\t\t},\n\t\t\tnotify: (context) => {\n\t\t\t\tif (subscriptionSpec.select) {\n\t\t\t\t\tsubscriptionSpec.callback(subscriptionSpec.select(context), subscription.unsubscribe);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tsubscriptionSpec.callback(context, subscription.unsubscribe);\n\t\t\t},\n\t\t\tunsubscribe: () => {\n\t\t\t\tconst index = this.subscriptions.indexOf(subscription);\n\n\t\t\t\tif (index !== -1) {\n\t\t\t\t\tthis.subscriptions.splice(index, 1);\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t\tthis.subscriptions.push(subscription);\n\n\t\treturn subscription.unsubscribe;\n\t};\n\n\tprivate tryHydrateFromHost(): void {\n\t\tif (!this.pendingHostHydration) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst hydrationScriptElement = this.findHydrationScriptElement();\n\n\t\tif (!hydrationScriptElement) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.value = this.mergeHydrationValue(\n\t\t\tparseHydrationPayload(hydrationScriptElement, this.value) as ContextType<T>,\n\t\t);\n\t\tthis.pendingHostHydration = false;\n\t}\n\n\tprivate mergeHydrationValue(parsedHydrationValue: ContextType<T>): ContextType<T> {\n\t\tif (\n\t\t\tthis.hydrate === Object &&\n\t\t\tthis.isObject(parsedHydrationValue) &&\n\t\t\t(this.isObject(this.value) || typeof this.value === 'undefined')\n\t\t) {\n\t\t\treturn {\n\t\t\t\t...(this.value ?? {}),\n\t\t\t\t...parsedHydrationValue,\n\t\t\t} as ContextType<T>;\n\t\t}\n\n\t\treturn parsedHydrationValue;\n\t}\n\n\tprivate isObject(value: unknown): value is Record<string, unknown> {\n\t\treturn typeof value === 'object' && !Array.isArray(value) && value !== null;\n\t}\n\n\tprivate findHydrationScriptElement(): Element | null {\n\t\treturn findHydrationScript(resolveContextHydrationHost(this.host), 'context', this.hydrationKey);\n\t}\n\n\tprivate notifySubscribers = (newContext: ContextType<T>, prevContext: ContextType<T> | undefined) => {\n\t\tfor (const sub of this.subscriptions) {\n\t\t\tif (sub.hasChanged(newContext, prevContext)) {\n\t\t\t\tsub.notify(newContext);\n\t\t\t}\n\t\t}\n\t};\n\n\tprivate handleSubscriptionRequest = (\n\t\tsubscription: ContextSubscription<T, unknown>,\n\t\t{\n\t\t\tsubscribe,\n\t\t\tonSubscribe,\n\t\t}: {\n\t\t\tsubscribe?: boolean;\n\t\t\tonSubscribe?: (unsubscribe: () => void) => void;\n\t\t},\n\t) => {\n\t\tthis.tryHydrateFromHost();\n\t\tconst unsubscribe = subscribe ? this.subscribe(subscription) : undefined;\n\n\t\tif (unsubscribe) {\n\t\t\tonSubscribe?.(unsubscribe);\n\t\t}\n\n\t\tif (typeof this.value === 'undefined') return;\n\n\t\tif (subscription.select) {\n\t\t\tsubscription.callback(subscription.select(this.value), unsubscribe);\n\t\t} else {\n\t\t\tsubscription.callback(this.value, unsubscribe);\n\t\t}\n\t};\n\n\tprivate onSubscriptionRequest = (event: ContextSubscriptionRequestEvent<UnknownContext>) => {\n\t\tconst { context, callback, subscribe, select, target, onSubscribe } = event;\n\t\tif (context !== this.context) return;\n\n\t\tevent.markHandled();\n\t\tevent.stopPropagation();\n\n\t\tif (target instanceof EventTarget) {\n\t\t\ttarget.dispatchEvent(new ContextOnMountEvent(this.context));\n\t\t}\n\n\t\tif (select) {\n\t\t\tthis.handleSubscriptionRequest({ select, callback }, { subscribe, onSubscribe });\n\t\t\treturn;\n\t\t}\n\n\t\tthis.handleSubscriptionRequest({ callback }, { subscribe, onSubscribe });\n\t};\n\n\tprivate onContextRequest = (event: ContextRequestEvent<UnknownContext>) => {\n\t\tconst { context, callback } = event;\n\t\tif (context !== this.context) return;\n\t\tevent.markHandled();\n\t\tevent.stopPropagation();\n\t\tcallback(this);\n\t};\n\n\tprivate registerEvents = () => {\n\t\tthis.host.addEventListener(\n\t\t\tContextEventsTypes.SUBSCRIPTION_REQUEST,\n\t\t\tthis.onSubscriptionRequest as EventListener,\n\t\t);\n\t\tthis.host.addEventListener(ContextEventsTypes.CONTEXT_REQUEST, this.onContextRequest as EventListener);\n\t};\n}\n",
|
|
23
|
+
"import type { Context } from './types';\n\n/**\n * A function which creates a Context value object\n */\nexport const createContext = <ValueType>(key: unknown) => key as Context<typeof key, ValueType>;\n",
|
|
24
|
+
"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",
|
|
25
|
+
"import type { ContextHostLike } from './context-host';\nimport { resolveAmbientSsrContextProvider } from './context-ssr-bridge';\nimport { ContextEventsTypes, ContextRequestEvent, ContextSubscriptionRequestEvent } from './events';\nimport type { ContextCallback, ContextType, UnknownContext } from './types';\n\ntype ConsumedContextAssignment = (provider: unknown) => void;\n\ntype DirectContextSelectionRequest<TContext extends UnknownContext> = {\n\tcallback: (value: ContextType<TContext>) => void;\n\tselect?: undefined;\n};\n\ntype SelectedContextSelectionRequest<TContext extends UnknownContext, Selected> = {\n\tcallback: (value: Selected) => void;\n\tselect: (context: ContextType<TContext>) => Selected;\n};\n\ntype ContextSelectionRequest<TContext extends UnknownContext, Selected = ContextType<TContext>> =\n\t| DirectContextSelectionRequest<TContext>\n\t| SelectedContextSelectionRequest<TContext, Selected>;\n\n/**\n * Resolves a consumed context from the active SSR provider stack when one is available.\n *\n * This keeps SSR-specific lookup outside decorator implementations while preserving\n * the same consumer initialization contract for both standard and legacy decorators.\n *\n * @returns `true` when the context was resolved synchronously from SSR state.\n */\nexport function initializeConsumedContext(\n\thost: ContextHostLike,\n\tcontext: UnknownContext,\n\tassign: ConsumedContextAssignment,\n\toptions: { emitMounted?: boolean } = {},\n): boolean {\n\tconst provider = resolveAmbientSsrContextProvider(context);\n\n\tif (!provider) {\n\t\treturn false;\n\t}\n\n\tassign(provider);\n\thost.connectedContextCallback(context);\n\n\tif (options.emitMounted) {\n\t\thost.dispatchEvent(new CustomEvent(ContextEventsTypes.MOUNTED, { detail: provider }));\n\t}\n\n\treturn true;\n}\n\n/**\n * Requests a context provider through the DOM event channel when SSR state is not active.\n */\nexport function requestConsumedContext(\n\thost: ContextHostLike,\n\tcontext: UnknownContext,\n\tassign: ConsumedContextAssignment,\n\toptions: { emitMounted?: boolean } = {},\n): boolean {\n\tconst event = new ContextRequestEvent(context, (provider) => {\n\t\tassign(provider);\n\t\thost.connectedContextCallback(context);\n\n\t\tif (options.emitMounted) {\n\t\t\thost.dispatchEvent(new CustomEvent(ContextEventsTypes.MOUNTED, { detail: provider }));\n\t\t}\n\t});\n\n\thost.dispatchEvent(event);\n\treturn event.handled;\n}\n\n/**\n * Resolves a selected context value from the active SSR provider stack when available.\n *\n * @returns `true` when the selection callback was satisfied synchronously from SSR state.\n */\nexport function initializeContextSelection<TContext extends UnknownContext>(\n\tcontext: TContext,\n\trequest: DirectContextSelectionRequest<TContext>,\n): boolean;\nexport function initializeContextSelection<TContext extends UnknownContext, Selected>(\n\tcontext: TContext,\n\trequest: SelectedContextSelectionRequest<TContext, Selected>,\n): boolean;\nexport function initializeContextSelection<TContext extends UnknownContext, Selected = ContextType<TContext>>(\n\tcontext: TContext,\n\trequest: ContextSelectionRequest<TContext, Selected>,\n): boolean {\n\tconst provider = resolveAmbientSsrContextProvider(context);\n\n\tif (!provider) {\n\t\treturn false;\n\t}\n\n\tconst resolvedContext = provider.getContext() as ContextType<TContext>;\n\n\tif (request.select) {\n\t\trequest.callback(request.select(resolvedContext));\n\t\treturn true;\n\t}\n\n\trequest.callback(resolvedContext);\n\treturn true;\n}\n\n/**\n * Requests a selected context value through the DOM event channel.\n */\nexport function requestContextSelection<TContext extends UnknownContext>(\n\thost: ContextHostLike,\n\tcontext: TContext,\n\trequest: DirectContextSelectionRequest<TContext>,\n\toptions: {\n\t\tsubscribe?: boolean;\n\t\tonSubscribe?: (unsubscribe: () => void) => void;\n\t},\n): boolean;\nexport function requestContextSelection<TContext extends UnknownContext, Selected>(\n\thost: ContextHostLike,\n\tcontext: TContext,\n\trequest: SelectedContextSelectionRequest<TContext, Selected>,\n\toptions: {\n\t\tsubscribe?: boolean;\n\t\tonSubscribe?: (unsubscribe: () => void) => void;\n\t},\n): boolean;\nexport function requestContextSelection<TContext extends UnknownContext, Selected = ContextType<TContext>>(\n\thost: ContextHostLike,\n\tcontext: TContext,\n\trequest: ContextSelectionRequest<TContext, Selected>,\n\toptions: {\n\t\tsubscribe?: boolean;\n\t\tonSubscribe?: (unsubscribe: () => void) => void;\n\t},\n): boolean {\n\tconst event = new ContextSubscriptionRequestEvent(\n\t\tcontext,\n\t\trequest.callback as ContextCallback<Selected>,\n\t\trequest.select,\n\t\toptions.subscribe,\n\t\toptions.onSubscribe,\n\t);\n\n\thost.dispatchEvent(event);\n\treturn event.handled;\n}\n",
|
|
26
|
+
"import type { ContextHostLike } from './context-host';\nimport { registerSsrPreparationCallback } from '../core/ssr-preparation';\nimport {\n\tinitializeConsumedContext,\n\tinitializeContextSelection,\n\trequestConsumedContext,\n\trequestContextSelection,\n} from './context-consumer-runtime';\nimport type { ContextType, UnknownContext } from './types';\n\ntype ConsumedContextAssignment = (provider: unknown) => void;\n\n/**\n * Resolves a consumed context immediately and registers the same resolution to\n * run again during the later SSR preparation phase.\n *\n * This keeps constructor-time state and pre-serialization state aligned after\n * instance fields, props, or authored host content change during SSR setup.\n */\nexport function bootstrapSsrConsumedContext(\n\thost: ContextHostLike,\n\tcontext: UnknownContext,\n\tassign: ConsumedContextAssignment,\n\toptions: { emitMounted?: boolean } = {},\n): boolean {\n\treturn registerAndResolveConsumerBootstrap(host, () => initializeConsumedContext(host, context, assign, options));\n}\n\n/**\n * Resolves a selected context value immediately and registers the same\n * selection for the later SSR preparation phase.\n *\n * This lets nested SSR renders recompute selector-backed state after the host\n * has finished construction and any server-side configuration hooks have run.\n */\nexport function bootstrapSsrContextSelection<TContext extends UnknownContext, Selected = ContextType<TContext>>(\n\thost: object,\n\tcontext: TContext,\n\tcallback: (value: Selected) => void,\n\tselect?: (context: ContextType<TContext>) => Selected,\n): boolean {\n\treturn registerAndResolveConsumerBootstrap(host, () => {\n\t\tif (select) {\n\t\t\treturn initializeContextSelection(context, { callback, select });\n\t\t}\n\n\t\treturn initializeContextSelection(context, {\n\t\t\tcallback: callback as (value: ContextType<TContext>) => void,\n\t\t});\n\t});\n}\n\n/**\n * Resolves a consumed context from SSR when available, otherwise requests it\n * through the DOM event channel for the current client-side lifecycle pass.\n *\n * @returns `true` when the value was satisfied synchronously from SSR state.\n */\nexport function connectConsumedContext(\n\thost: ContextHostLike,\n\tcontext: UnknownContext,\n\tassign: ConsumedContextAssignment,\n\toptions: { emitMounted?: boolean } = {},\n): boolean {\n\tif (initializeConsumedContext(host, context, assign, options)) {\n\t\treturn true;\n\t}\n\n\treturn requestConsumedContext(host, context, assign, options);\n}\n\n/**\n * Resolves a selected context value from SSR when available, otherwise requests\n * it through the DOM event channel for the current client-side lifecycle pass.\n *\n * @returns `true` when the value was satisfied synchronously from SSR state.\n */\nexport function connectContextSelection<TContext extends UnknownContext, Selected = ContextType<TContext>>(\n\thost: ContextHostLike,\n\tcontext: TContext,\n\tcallback: (value: Selected) => void,\n\toptions: {\n\t\tselect?: (context: ContextType<TContext>) => Selected;\n\t\tsubscribe?: boolean;\n\t\tonSubscribe?: (unsubscribe: () => void) => void;\n\t} = {},\n): boolean {\n\tif (options.select) {\n\t\tconst request = { callback, select: options.select };\n\n\t\tif (initializeContextSelection(context, request)) {\n\t\t\treturn true;\n\t\t}\n\n\t\treturn requestContextSelection(host, context, request, {\n\t\t\tsubscribe: options.subscribe,\n\t\t\tonSubscribe: options.onSubscribe,\n\t\t});\n\t}\n\n\tconst request = {\n\t\tcallback: callback as (value: ContextType<TContext>) => void,\n\t};\n\n\tif (initializeContextSelection(context, request)) {\n\t\treturn true;\n\t}\n\n\treturn requestContextSelection(host, context, request, {\n\t\tsubscribe: options.subscribe,\n\t\tonSubscribe: options.onSubscribe,\n\t});\n}\n\nfunction registerAndResolveConsumerBootstrap<TResult>(host: object, resolve: () => TResult): TResult {\n\tregisterSsrPreparationCallback(host, resolve);\n\treturn resolve();\n}\n",
|
|
27
|
+
"import type { ContextHostLike } from '../../context-host';\nimport { registerLegacyInstanceInitializer } from '../../../decorators/legacy/instance-initializers';\nimport { bootstrapSsrConsumedContext, connectConsumedContext } from '../../context-consumer-bootstrap';\nimport type { UnknownContext } from '../../types';\n\nexport function consumeContext(context: UnknownContext) {\n\treturn (proto: ContextHostLike, propertyKey: string) => {\n\t\tconst assignContextProvider = (element: ContextHostLike, provider: unknown) => {\n\t\t\t(element as any)[propertyKey] = provider;\n\t\t};\n\t\tconst initializeConsumedContextForHost = (\n\t\t\telement: ContextHostLike,\n\t\t\toptions: { emitMounted?: boolean } = {},\n\t\t) => {\n\t\t\tif ((element as any)[propertyKey]) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\treturn connectConsumedContext(\n\t\t\t\telement,\n\t\t\t\tcontext,\n\t\t\t\t(provider) => {\n\t\t\t\t\tassignContextProvider(element, provider);\n\t\t\t\t},\n\t\t\t\toptions,\n\t\t\t);\n\t\t};\n\n\t\tregisterLegacyInstanceInitializer(proto, (element) => {\n\t\t\tbootstrapSsrConsumedContext(element, context, (provider) => {\n\t\t\t\tassignContextProvider(element, provider);\n\t\t\t});\n\n\t\t\telement.registerConnectedCallback(() => {\n\t\t\t\tif (initializeConsumedContextForHost(element, { emitMounted: true })) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tqueueMicrotask(() => {\n\t\t\t\t\tinitializeConsumedContextForHost(element, { emitMounted: true });\n\t\t\t\t});\n\t\t\t});\n\t\t});\n\t};\n}\n",
|
|
28
|
+
"import type { ContextHostLike } from '../../context-host';\nimport { bootstrapSsrConsumedContext, connectConsumedContext } from '../../context-consumer-bootstrap';\nimport type { UnknownContext } from '../../types';\n\nexport function consumeContext(consumedContext: UnknownContext) {\n\treturn <T extends ContextHostLike, V>(target: undefined, context: ClassFieldDecoratorContext<T, V>) => {\n\t\tvoid target;\n\t\tconst contextName = String(context.name);\n\t\tconst assignContextProvider = (host: T, provider: unknown) => {\n\t\t\tconst hostRecord = host as T & Record<string, unknown>;\n\t\t\thostRecord[contextName] = provider;\n\t\t};\n\t\tconst initializeConsumedContextForHost = (host: T, options: { emitMounted?: boolean } = {}) => {\n\t\t\tconst hostRecord = host as T & Record<string, unknown>;\n\n\t\t\tif (hostRecord[contextName]) {\n\t\t\t\treturn true;\n\t\t\t}\n\n\t\t\treturn connectConsumedContext(\n\t\t\t\thost,\n\t\t\t\tconsumedContext,\n\t\t\t\t(provider) => {\n\t\t\t\t\tassignContextProvider(host, provider);\n\t\t\t\t},\n\t\t\t\toptions,\n\t\t\t);\n\t\t};\n\n\t\tcontext.addInitializer(function (this: T) {\n\t\t\tif (\n\t\t\t\tbootstrapSsrConsumedContext(\n\t\t\t\t\tthis,\n\t\t\t\t\tconsumedContext,\n\t\t\t\t\t(provider) => {\n\t\t\t\t\t\tassignContextProvider(this, provider);\n\t\t\t\t\t},\n\t\t\t\t\t{ emitMounted: true },\n\t\t\t\t)\n\t\t\t) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.registerConnectedCallback(() => {\n\t\t\t\tif (initializeConsumedContextForHost(this, { emitMounted: true })) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tqueueMicrotask(() => {\n\t\t\t\t\tinitializeConsumedContextForHost(this, { emitMounted: true });\n\t\t\t\t});\n\t\t\t});\n\t\t});\n\t};\n}\n",
|
|
29
|
+
"import type { Method } from '../types';\n\ntype StandardFieldFn<Host extends object, Value, Result> = (\n\ttarget: undefined,\n\tcontext: ClassFieldDecoratorContext<Host, Value>,\n) => Result;\n\ntype LegacyFieldFn<Proto, Result> = (proto: Proto, name: string) => Result;\n\ntype StandardMethodFn<Host extends object, TMethod extends Method, Result> = (\n\ttarget: TMethod,\n\tcontext: ClassMethodDecoratorContext<Host, TMethod>,\n) => Result;\n\ntype LegacyMethodFn<Proto, Result> = (proto: Proto, name: string, descriptor: PropertyDescriptor) => Result;\n\nfunction isMethod(value: unknown): value is Method {\n\treturn typeof value === 'function';\n}\n\nexport function fieldDecoratorBridge<Host extends object, Value, Result, Proto>(\n\tstandard: StandardFieldFn<Host, Value, Result>,\n\tlegacy: LegacyFieldFn<Proto, void>,\n\tprotoOrTarget: undefined,\n\tnameOrContext: ClassFieldDecoratorContext<Host, Value>,\n): Result;\nexport function fieldDecoratorBridge<Host extends object, Value, Proto, Result>(\n\tstandard: StandardFieldFn<Host, Value, void>,\n\tlegacy: LegacyFieldFn<Proto, Result>,\n\tprotoOrTarget: Proto,\n\tnameOrContext: string,\n): Result;\nexport function fieldDecoratorBridge<Host extends object, Value, StandardResult, Proto, LegacyResult>(\n\tstandard: StandardFieldFn<Host, Value, StandardResult>,\n\tlegacy: LegacyFieldFn<Proto, LegacyResult>,\n\tprotoOrTarget: Proto | undefined,\n\tnameOrContext: string | ClassFieldDecoratorContext<Host, Value>,\n): StandardResult | LegacyResult;\n\nexport function fieldDecoratorBridge(\n\tstandard: StandardFieldFn<object, unknown, unknown>,\n\tlegacy: LegacyFieldFn<unknown, unknown>,\n\tprotoOrTarget: unknown,\n\tnameOrContext: string | ClassFieldDecoratorContext<object, unknown>,\n): unknown {\n\tif (typeof nameOrContext === 'object') {\n\t\treturn standard(undefined, nameOrContext);\n\t}\n\n\treturn legacy(protoOrTarget, nameOrContext);\n}\n\nexport function methodDecoratorBridge<Host extends object, TMethod extends Method, Result, Proto>(\n\tstandard: StandardMethodFn<Host, TMethod, Result>,\n\tlegacy: LegacyMethodFn<Proto, void>,\n\tprotoOrTarget: TMethod,\n\tnameOrContext: ClassMethodDecoratorContext<Host, TMethod>,\n\tdescriptor?: undefined,\n): Result;\nexport function methodDecoratorBridge<Host extends object, TMethod extends Method, Proto, Result>(\n\tstandard: StandardMethodFn<Host, TMethod, void>,\n\tlegacy: LegacyMethodFn<Proto, Result>,\n\tprotoOrTarget: Proto,\n\tnameOrContext: string,\n\tdescriptor: PropertyDescriptor,\n): Result;\nexport function methodDecoratorBridge<Host extends object, TMethod extends Method, StandardResult, Proto, LegacyResult>(\n\tstandard: StandardMethodFn<Host, TMethod, StandardResult>,\n\tlegacy: LegacyMethodFn<Proto, LegacyResult>,\n\tprotoOrTarget: Proto | TMethod,\n\tnameOrContext: string | ClassMethodDecoratorContext<Host, TMethod>,\n\tdescriptor?: PropertyDescriptor,\n): StandardResult | LegacyResult;\n\nexport function methodDecoratorBridge(\n\tstandard: StandardMethodFn<object, Method, unknown>,\n\tlegacy: LegacyMethodFn<unknown, unknown>,\n\tprotoOrTarget: unknown,\n\tnameOrContext: string | ClassMethodDecoratorContext<object, Method>,\n\tdescriptor?: PropertyDescriptor,\n): unknown {\n\tif (typeof nameOrContext === 'object') {\n\t\tif (!isMethod(protoOrTarget)) {\n\t\t\tthrow new TypeError('Standard method decorators require a method target');\n\t\t}\n\n\t\treturn standard(protoOrTarget, nameOrContext);\n\t}\n\n\tif (!descriptor) {\n\t\tthrow new TypeError('Legacy method decorators require a property descriptor');\n\t}\n\n\treturn legacy(protoOrTarget, nameOrContext, descriptor);\n}\n",
|
|
30
|
+
"import type { ContextHostLike } from '../context-host';\nimport type { UnknownContext } from '../types';\nimport { consumeContext as legacyConsumeContext } from './legacy/consume-context';\nimport { consumeContext as standardConsumeContext } from './standard/consume-context';\nimport { fieldDecoratorBridge } from '../../decorators/bridge';\n\n/**\n * Injects the nearest matching context provider onto a decorated field.\n *\n * During SSR the field can be resolved from the active SSR context stack; on\n * the client it falls back to the DOM event-based context channel.\n *\n * @param context Context token to consume from ancestor providers.\n * @returns A standard-or-legacy decorator implementation for the target field.\n */\nexport function consumeContext(context: UnknownContext) {\n\tfunction decorator<Host extends ContextHostLike, V>(\n\t\tprotoOrTarget: undefined,\n\t\tnameOrContext: ClassFieldDecoratorContext<Host, V>,\n\t): void;\n\tfunction decorator(protoOrTarget: ContextHostLike, nameOrContext: string): void;\n\tfunction decorator(\n\t\tprotoOrTarget: ContextHostLike | undefined,\n\t\tnameOrContext: string | ClassFieldDecoratorContext<ContextHostLike, unknown>,\n\t): void {\n\t\treturn fieldDecoratorBridge(\n\t\t\tstandardConsumeContext(context),\n\t\t\tlegacyConsumeContext(context),\n\t\t\tprotoOrTarget,\n\t\t\tnameOrContext,\n\t\t);\n\t}\n\n\treturn decorator;\n}\n",
|
|
31
|
+
"import { SSR_PREPARATION_RUNNING } from '../../core/ssr-preparation';\n\ntype RequestUpdateCapable = {\n\trequestUpdate(): void;\n};\n\nexport function createContextSelectionDelivery<Value>(\n\thost: object,\n\tapply: (value: Value) => void,\n\trequestUpdate: boolean,\n) {\n\tlet hasDeliveredValue = false;\n\tlet previousValue: Value;\n\tconst target = host as Record<PropertyKey, unknown>;\n\n\treturn (value: Value) => {\n\t\tif (target[SSR_PREPARATION_RUNNING] !== true && hasDeliveredValue && Object.is(previousValue, value)) {\n\t\t\treturn;\n\t\t}\n\n\t\thasDeliveredValue = true;\n\t\tpreviousValue = value;\n\t\tapply(value);\n\n\t\tif (requestUpdate && typeof target.requestUpdate === 'function') {\n\t\t\t(target as RequestUpdateCapable).requestUpdate();\n\t\t}\n\t};\n}\n",
|
|
32
|
+
"import type { ContextHostLike } from '../../context-host';\nimport { registerLegacyInstanceInitializer } from '../../../decorators/legacy/instance-initializers';\nimport { bootstrapSsrContextSelection, connectContextSelection } from '../../context-consumer-bootstrap';\nimport type { Context, ContextType } from '../../types';\nimport type { OnContextUpdateOptions } from '../on-context-update';\nimport { createContextSelectionDelivery } from '../context-selection-delivery';\n\nexport function contextSelector<T extends Context<unknown, unknown>, Selected = ContextType<T>>({\n\tcontext,\n\tselect,\n\tsubscribe = true,\n\trequestUpdate = true,\n}: OnContextUpdateOptions<T, Selected>) {\n\treturn (proto: ContextHostLike, _: string, descriptor: PropertyDescriptor) => {\n\t\tconst originalMethod = descriptor.value;\n\n\t\tregisterLegacyInstanceInitializer(proto, (element) => {\n\t\t\tlet activeUnsubscribe: (() => void) | undefined;\n\t\t\tconst applySelectedContext = createContextSelectionDelivery(\n\t\t\t\telement,\n\t\t\t\t(value) => {\n\t\t\t\t\toriginalMethod.call(element, value);\n\t\t\t\t},\n\t\t\t\trequestUpdate,\n\t\t\t);\n\n\t\t\tbootstrapSsrContextSelection<T, Selected>(element, context, applySelectedContext, select);\n\n\t\t\telement.registerConnectedCallback(() => {\n\t\t\t\tif (\n\t\t\t\t\tconnectContextSelection<T, Selected>(element, context, applySelectedContext, {\n\t\t\t\t\t\tonSubscribe: (unsubscribe) => {\n\t\t\t\t\t\t\tactiveUnsubscribe = unsubscribe;\n\t\t\t\t\t\t},\n\t\t\t\t\t\tselect,\n\t\t\t\t\t\tsubscribe,\n\t\t\t\t\t})\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tqueueMicrotask(() => {\n\t\t\t\t\tconnectContextSelection<T, Selected>(element, context, applySelectedContext, {\n\t\t\t\t\t\tonSubscribe: (unsubscribe) => {\n\t\t\t\t\t\t\tactiveUnsubscribe = unsubscribe;\n\t\t\t\t\t\t},\n\t\t\t\t\t\tselect,\n\t\t\t\t\t\tsubscribe,\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t});\n\n\t\t\telement.registerCleanupCallback(() => {\n\t\t\t\tactiveUnsubscribe?.();\n\t\t\t\tactiveUnsubscribe = undefined;\n\t\t\t});\n\t\t});\n\n\t\treturn descriptor;\n\t};\n}\n",
|
|
33
|
+
"import type { ContextHostLike } from '../../context-host';\nimport { bootstrapSsrContextSelection, connectContextSelection } from '../../context-consumer-bootstrap';\nimport type { Context, ContextType } from '../../types';\nimport type { OnContextUpdateOptions } from '../on-context-update';\nimport { createContextSelectionDelivery } from '../context-selection-delivery';\n\nexport function contextSelector<T extends Context<unknown, unknown>, Selected = ContextType<T>>({\n\tcontext,\n\tselect,\n\tsubscribe = true,\n\trequestUpdate = true,\n}: OnContextUpdateOptions<T, Selected>) {\n\treturn function <Host extends ContextHostLike, TMethod extends (value: Selected) => unknown>(\n\t\toriginalMethod: TMethod,\n\t\ttargetContext: ClassMethodDecoratorContext<Host, TMethod>,\n\t): void {\n\t\ttargetContext.addInitializer(function (this: Host) {\n\t\t\tlet activeUnsubscribe: (() => void) | undefined;\n\t\t\tconst applySelectedContext = createContextSelectionDelivery<Selected>(\n\t\t\t\tthis,\n\t\t\t\t(value) => {\n\t\t\t\t\toriginalMethod.call(this, value);\n\t\t\t\t},\n\t\t\t\trequestUpdate,\n\t\t\t);\n\n\t\t\tif (bootstrapSsrContextSelection<T, Selected>(this, context, applySelectedContext, select)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst connectSelection = () => {\n\t\t\t\treturn connectContextSelection<T, Selected>(this, context, applySelectedContext, {\n\t\t\t\t\tonSubscribe: (unsubscribe) => {\n\t\t\t\t\t\tactiveUnsubscribe = unsubscribe;\n\t\t\t\t\t},\n\t\t\t\t\tselect,\n\t\t\t\t\tsubscribe,\n\t\t\t\t});\n\t\t\t};\n\n\t\t\tthis.registerCleanupCallback(() => {\n\t\t\t\tactiveUnsubscribe?.();\n\t\t\t\tactiveUnsubscribe = undefined;\n\t\t\t});\n\n\t\t\tthis.registerConnectedCallback(() => {\n\t\t\t\tif (connectSelection()) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tqueueMicrotask(() => {\n\t\t\t\t\tconnectSelection();\n\t\t\t\t});\n\t\t\t});\n\t\t});\n\t};\n}\n",
|
|
34
|
+
"import type { ContextHostLike } from '../../context-host';\nimport { registerLegacyInstanceInitializer } from '../../../decorators/legacy/instance-initializers';\nimport { bootstrapSsrContextSelection, connectContextSelection } from '../../context-consumer-bootstrap';\nimport type { Context, ContextType } from '../../types';\nimport { createContextSelectionDelivery } from '../context-selection-delivery';\n\nexport type ContextSelectorFieldOptions<T extends Context<unknown, unknown>, Selected = ContextType<T>> = {\n\tcontext: T;\n\tselect?: (context: ContextType<T>) => Selected;\n\tsubscribe?: boolean;\n};\n\nexport function contextSelectorField<T extends Context<unknown, unknown>, Selected = ContextType<T>>(\n\toptions: ContextSelectorFieldOptions<T, Selected>,\n) {\n\tconst { context, select, subscribe = true } = options;\n\n\treturn (target: ContextHostLike, propertyName: string) => {\n\t\tregisterLegacyInstanceInitializer(target, (element) => {\n\t\t\tlet activeUnsubscribe: (() => void) | undefined;\n\t\t\tconst applyValue = createContextSelectionDelivery<Selected>(\n\t\t\t\telement,\n\t\t\t\t(value) => {\n\t\t\t\t\t(element as unknown as Record<string, unknown>)[propertyName] = value;\n\t\t\t\t},\n\t\t\t\ttrue,\n\t\t\t);\n\n\t\t\tbootstrapSsrContextSelection<T, Selected>(element, context, applyValue, select);\n\n\t\t\telement.registerConnectedCallback(() => {\n\t\t\t\tif (\n\t\t\t\t\tconnectContextSelection<T, Selected>(element, context, applyValue, {\n\t\t\t\t\t\tonSubscribe: (unsubscribe) => {\n\t\t\t\t\t\t\tactiveUnsubscribe = unsubscribe;\n\t\t\t\t\t\t},\n\t\t\t\t\t\tselect,\n\t\t\t\t\t\tsubscribe,\n\t\t\t\t\t})\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tqueueMicrotask(() => {\n\t\t\t\t\tconnectContextSelection<T, Selected>(element, context, applyValue, {\n\t\t\t\t\t\tonSubscribe: (unsubscribe) => {\n\t\t\t\t\t\t\tactiveUnsubscribe = unsubscribe;\n\t\t\t\t\t\t},\n\t\t\t\t\t\tselect,\n\t\t\t\t\t\tsubscribe,\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t});\n\n\t\t\telement.registerCleanupCallback(() => {\n\t\t\t\tactiveUnsubscribe?.();\n\t\t\t\tactiveUnsubscribe = undefined;\n\t\t\t});\n\t\t});\n\t};\n}\n",
|
|
35
|
+
"import type { ContextHostLike } from '../../context-host';\nimport { bootstrapSsrContextSelection, connectContextSelection } from '../../context-consumer-bootstrap';\nimport type { Context, ContextType } from '../../types';\nimport { createContextSelectionDelivery } from '../context-selection-delivery';\n\nexport type ContextSelectorFieldOptions<T extends Context<unknown, unknown>, Selected = ContextType<T>> = {\n\tcontext: T;\n\tselect?: (context: ContextType<T>) => Selected;\n\tsubscribe?: boolean;\n};\n\nexport function contextSelectorField<T extends Context<unknown, unknown>, Selected = ContextType<T>>(\n\toptions: ContextSelectorFieldOptions<T, Selected>,\n) {\n\tconst { context, select, subscribe = true } = options;\n\n\treturn function <Host extends ContextHostLike>(\n\t\t_: undefined,\n\t\tfieldContext: ClassFieldDecoratorContext<Host, Selected>,\n\t) {\n\t\tconst propertyName = String(fieldContext.name);\n\n\t\tfieldContext.addInitializer(function (this: Host) {\n\t\t\tlet activeUnsubscribe: (() => void) | undefined;\n\t\t\tconst applyValue = createContextSelectionDelivery<Selected>(\n\t\t\t\tthis,\n\t\t\t\t(value) => {\n\t\t\t\t\tconst record = this as unknown as Record<string, unknown>;\n\t\t\t\t\trecord[propertyName] = value;\n\t\t\t\t},\n\t\t\t\ttrue,\n\t\t\t);\n\n\t\t\tif (bootstrapSsrContextSelection<T, Selected>(this, context, applyValue, select)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst connectSelection = () => {\n\t\t\t\treturn connectContextSelection<T, Selected>(this, context, applyValue, {\n\t\t\t\t\tonSubscribe: (unsubscribe) => {\n\t\t\t\t\t\tactiveUnsubscribe = unsubscribe;\n\t\t\t\t\t},\n\t\t\t\t\tselect,\n\t\t\t\t\tsubscribe,\n\t\t\t\t});\n\t\t\t};\n\n\t\t\tthis.registerCleanupCallback(() => {\n\t\t\t\tactiveUnsubscribe?.();\n\t\t\t\tactiveUnsubscribe = undefined;\n\t\t\t});\n\n\t\t\tthis.registerConnectedCallback(() => {\n\t\t\t\tif (connectSelection()) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tqueueMicrotask(() => {\n\t\t\t\t\tconnectSelection();\n\t\t\t\t});\n\t\t\t});\n\t\t});\n\n\t\treturn function (this: Host, initialValue: Selected) {\n\t\t\treturn initialValue;\n\t\t};\n\t};\n}\n",
|
|
36
|
+
"import type { Method } from '../../types';\nimport type { ContextHostLike } from '../context-host';\nimport type { Context, ContextType, UnknownContext } from '../types';\nimport { contextSelector as legacyContextSelectorMethod } from './legacy/context-selector';\nimport { contextSelector as standardContextSelectorMethod } from './standard/context-selector';\nimport { contextSelectorField as legacyContextSelectorField } from './legacy/context-selector-field';\nimport { contextSelectorField as standardContextSelectorField } from './standard/context-selector-field';\n\nexport type ContextSelectorOptions<T extends UnknownContext, Selected = ContextType<T>> = {\n\t/** Context token to resolve from ancestor providers. */\n\tcontext: T;\n\t/** Optional projection that narrows the resolved context before delivery. */\n\tselect?: (context: ContextType<T>) => Selected;\n\t/** Whether client-side event-channel subscriptions should stay active after the first value. */\n\tsubscribe?: boolean;\n};\n\ntype ContextUpdateMethod<Selected> = (value: Selected) => unknown;\n\ntype ContextSelectorDecorator<Selected> = {\n\t<Host extends ContextHostLike>(\n\t\tprotoOrTarget: undefined,\n\t\tnameOrContext: ClassFieldDecoratorContext<Host, Selected>,\n\t): (this: Host, initialValue: Selected) => Selected;\n\t<Host extends ContextHostLike, TMethod extends ContextUpdateMethod<Selected>>(\n\t\tprotoOrTarget: TMethod,\n\t\tnameOrContext: ClassMethodDecoratorContext<Host, TMethod>,\n\t): void;\n\t(protoOrTarget: ContextHostLike, nameOrContext: string): void;\n\t(\n\t\tprotoOrTarget: ContextHostLike,\n\t\tnameOrContext: string,\n\t\tdescriptor: TypedPropertyDescriptor<ContextUpdateMethod<Selected>>,\n\t): TypedPropertyDescriptor<ContextUpdateMethod<Selected>> | void;\n};\n\n/**\n * Subscribes a field or method to the current value, or a selected slice, of a context.\n *\n * **Field form (preferred):** The field holds the latest context value and is\n * updated whenever the provider changes. On `RadiantElement` hosts, each\n * update schedules `requestUpdate()` automatically so `render()` stays in sync.\n *\n * **Method form (deprecated — use `@onContextUpdate`):** The method is called\n * with the new value on each change.\n *\n * @param options Context subscription configuration.\n */\nexport function contextSelector<T extends Context<unknown, unknown>, Selected = ContextType<T>>(\n\toptions: ContextSelectorOptions<T, Selected>,\n): ContextSelectorDecorator<Selected> {\n\tfunction decorator<Host extends ContextHostLike>(\n\t\tprotoOrTarget: undefined,\n\t\tnameOrContext: ClassFieldDecoratorContext<Host, Selected>,\n\t): (this: Host, initialValue: Selected) => Selected;\n\tfunction decorator<Host extends ContextHostLike, TMethod extends ContextUpdateMethod<Selected>>(\n\t\tprotoOrTarget: TMethod,\n\t\tnameOrContext: ClassMethodDecoratorContext<Host, TMethod>,\n\t): void;\n\tfunction decorator(protoOrTarget: ContextHostLike, nameOrContext: string): void;\n\tfunction decorator(\n\t\tprotoOrTarget: ContextHostLike,\n\t\tnameOrContext: string,\n\t\tdescriptor: TypedPropertyDescriptor<ContextUpdateMethod<Selected>>,\n\t): TypedPropertyDescriptor<ContextUpdateMethod<Selected>> | void;\n\tfunction decorator(\n\t\tprotoOrTarget: ContextHostLike | Method | undefined,\n\t\tnameOrContext:\n\t\t\t| string\n\t\t\t| ClassFieldDecoratorContext<ContextHostLike, Selected>\n\t\t\t| ClassMethodDecoratorContext<ContextHostLike, ContextUpdateMethod<Selected>>,\n\t\tdescriptor?: TypedPropertyDescriptor<ContextUpdateMethod<Selected>>,\n\t):\n\t\t| ((this: ContextHostLike, initialValue: Selected) => Selected)\n\t\t| TypedPropertyDescriptor<ContextUpdateMethod<Selected>>\n\t\t| void {\n\t\tif (typeof nameOrContext === 'object') {\n\t\t\tif (nameOrContext.kind === 'field') {\n\t\t\t\tif (protoOrTarget !== undefined) {\n\t\t\t\t\tthrow new TypeError('@contextSelector field decorators require an undefined target');\n\t\t\t\t}\n\n\t\t\t\treturn standardContextSelectorField(options)(undefined, nameOrContext);\n\t\t\t}\n\n\t\t\tif (typeof protoOrTarget !== 'function') {\n\t\t\t\tthrow new TypeError('@contextSelector standard method decorators require a method target');\n\t\t\t}\n\n\t\t\treturn standardContextSelectorMethod(options)(protoOrTarget, nameOrContext);\n\t\t}\n\n\t\tif (descriptor) {\n\t\t\tif (typeof protoOrTarget === 'function' || protoOrTarget === undefined) {\n\t\t\t\tthrow new TypeError('@contextSelector legacy method decorators require a host target');\n\t\t\t}\n\n\t\t\treturn legacyContextSelectorMethod(options)(protoOrTarget, nameOrContext, descriptor);\n\t\t}\n\n\t\tif (typeof protoOrTarget === 'function' || protoOrTarget === undefined) {\n\t\t\tthrow new TypeError('@contextSelector legacy field decorators require a host target');\n\t\t}\n\n\t\treturn legacyContextSelectorField(options)(protoOrTarget, nameOrContext);\n\t}\n\n\treturn decorator;\n}\n",
|
|
37
|
+
"import type { Method } from '../../types';\nimport type { ContextHostLike } from '../context-host';\nimport type { Context, ContextType, UnknownContext } from '../types';\nimport { contextSelector as legacyContextSelectorMethod } from './legacy/context-selector';\nimport { contextSelector as standardContextSelectorMethod } from './standard/context-selector';\nimport { methodDecoratorBridge } from '../../decorators/bridge';\n\ntype ContextUpdateMethod<Selected> = (value: Selected) => unknown;\n\ntype OnContextUpdateDecorator<Selected> = {\n\t<Host extends ContextHostLike, TMethod extends ContextUpdateMethod<Selected>>(\n\t\tprotoOrTarget: TMethod,\n\t\tnameOrContext: ClassMethodDecoratorContext<Host, TMethod>,\n\t): void;\n\t(\n\t\tprotoOrTarget: ContextHostLike,\n\t\tnameOrContext: string,\n\t\tdescriptor: TypedPropertyDescriptor<ContextUpdateMethod<Selected>>,\n\t): TypedPropertyDescriptor<ContextUpdateMethod<Selected>> | void;\n};\n\nexport type OnContextUpdateOptions<T extends UnknownContext, Selected = ContextType<T>> = {\n\t/** Context token to resolve from ancestor providers. */\n\tcontext: T;\n\t/** Optional projection that narrows the resolved context before delivery. */\n\tselect?: (context: ContextType<T>) => Selected;\n\t/** Whether client-side event-channel subscriptions should stay active after the first value. */\n\tsubscribe?: boolean;\n\t/** Whether RadiantElement hosts should schedule `requestUpdate()` after delivery. */\n\trequestUpdate?: boolean;\n};\n\n/**\n * Subscribes a method to the current value, or a selected slice, of a context.\n *\n * The decorated method is invoked during SSR when an ambient provider is\n * available, and on the client it keeps receiving updates according to the\n * `subscribe` option.\n *\n * On `RadiantElement` hosts, each delivery also schedules `requestUpdate()`\n * unless `requestUpdate: false` is set explicitly.\n *\n * @param options Context subscription configuration.\n */\nexport function onContextUpdate<T extends Context<unknown, unknown>, Selected = ContextType<T>>(\n\toptions: OnContextUpdateOptions<T, Selected>,\n): OnContextUpdateDecorator<Selected> {\n\tfunction decorator<Host extends ContextHostLike, TMethod extends ContextUpdateMethod<Selected>>(\n\t\tprotoOrTarget: TMethod,\n\t\tnameOrContext: ClassMethodDecoratorContext<Host, TMethod>,\n\t): void;\n\tfunction decorator(\n\t\tprotoOrTarget: ContextHostLike,\n\t\tnameOrContext: string,\n\t\tdescriptor: TypedPropertyDescriptor<ContextUpdateMethod<Selected>>,\n\t): TypedPropertyDescriptor<ContextUpdateMethod<Selected>> | void;\n\tfunction decorator(\n\t\tprotoOrTarget: ContextHostLike | Method,\n\t\tnameOrContext: string | ClassMethodDecoratorContext<ContextHostLike, ContextUpdateMethod<Selected>>,\n\t\tdescriptor?: TypedPropertyDescriptor<ContextUpdateMethod<Selected>>,\n\t): TypedPropertyDescriptor<ContextUpdateMethod<Selected>> | void {\n\t\treturn methodDecoratorBridge(\n\t\t\tstandardContextSelectorMethod(options),\n\t\t\tlegacyContextSelectorMethod(options),\n\t\t\tprotoOrTarget,\n\t\t\tnameOrContext,\n\t\t\tdescriptor,\n\t\t);\n\t}\n\n\treturn decorator;\n}\n",
|
|
38
|
+
"import { ContextProvider } from '../../../context/context-provider';\nimport type { UnknownContext } from '../../../context/types';\nimport type { ContextHostLike } from '../../context-host';\nimport { registerLegacyInstanceInitializer } from '../../../decorators/legacy/instance-initializers';\nimport type { ProvideContextOptions } from '../provide-context';\n\nexport function provideContext<T extends UnknownContext>({\n\tcontext,\n\tinitialValue,\n\thydrate,\n\tserialize,\n}: ProvideContextOptions<T>) {\n\treturn (proto: ContextHostLike, propertyKey: string) => {\n\t\tconst initializeProvider = (element: ContextHostLike) => {\n\t\t\tif ((element as any)[propertyKey]) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst provider = new ContextProvider<T>(element, {\n\t\t\t\tcontext,\n\t\t\t\thydrationKey: propertyKey,\n\t\t\t\tinitialValue,\n\t\t\t\thydrate,\n\t\t\t\tserialize,\n\t\t\t});\n\t\t\t(element as any)[propertyKey] = provider;\n\t\t\telement.registerContextProvider(propertyKey, provider);\n\t\t\telement.connectedContextCallback(context);\n\t\t};\n\n\t\tregisterLegacyInstanceInitializer(proto, (element) => {\n\t\t\tinitializeProvider(element);\n\t\t\telement.registerConnectedCallback(() => {\n\t\t\t\tinitializeProvider(element);\n\t\t\t});\n\t\t});\n\t};\n}\n",
|
|
39
|
+
"import type { ContextHostLike } from '../../context-host';\nimport { ContextProvider } from '../../context-provider';\nimport type { UnknownContext } from '../../types';\nimport type { ProvideContextOptions } from '../provide-context';\n\nexport function provideContext<T extends UnknownContext>({\n\tcontext,\n\tinitialValue,\n\thydrate,\n\tserialize,\n}: ProvideContextOptions<T>) {\n\treturn <C extends ContextHostLike, V>(target: undefined, targetContext: ClassFieldDecoratorContext<C, V>) => {\n\t\tvoid target;\n\t\tconst contextName = String(targetContext.name);\n\t\ttargetContext.addInitializer(function (this: C) {\n\t\t\tconst hostRecord = this as C & Record<string, unknown>;\n\t\t\tconst provider = new ContextProvider<T>(this, {\n\t\t\t\tcontext,\n\t\t\t\thydrationKey: contextName,\n\t\t\t\tinitialValue,\n\t\t\t\thydrate,\n\t\t\t\tserialize,\n\t\t\t});\n\t\t\thostRecord[contextName] = provider;\n\t\t\tthis.registerContextProvider(contextName, provider);\n\t\t\tthis.connectedContextCallback(context);\n\t\t});\n\t};\n}\n",
|
|
40
|
+
"import type { AttributeTypeConstant } from '../../utils';\nimport type { ContextHostLike } from '../context-host';\nimport type { UnknownContext } from '../types';\nimport { provideContext as legacyProvideContext } from './legacy/provide-context';\nimport { provideContext as standardProvideContext } from './standard/provide-context';\nimport { fieldDecoratorBridge } from '../../decorators/bridge';\n\nexport type ProvideContextOptions<T extends UnknownContext> = {\n\t/** Context token made available to descendant consumers. */\n\tcontext: T;\n\t/** Client-side default value installed before any SSR hydration is merged. */\n\tinitialValue?: T['__context__'];\n\t/** Attribute type used to opt the provider into SSR hydration. */\n\thydrate?: AttributeTypeConstant;\n\t/**\n\t * Projects the current provider value into an SSR-safe hydration payload.\n\t *\n\t * Use this when the live client context includes instances or other values\n\t * that should stay client-only. When `hydrate: Object` is active, the parsed\n\t * payload merges back into `initialValue`, so omitted members keep their\n\t * client-side defaults.\n\t */\n\tserialize?: (value: T['__context__']) => unknown;\n};\n\n/**\n * A decorator to provide a context to the target element.\n * @param options {@link ProvideContextOptions}\n * @returns\n */\nexport function provideContext<T extends UnknownContext>(options: ProvideContextOptions<T>) {\n\tfunction decorator<Host extends ContextHostLike, V>(\n\t\tprotoOrTarget: undefined,\n\t\tnameOrContext: ClassFieldDecoratorContext<Host, V>,\n\t): void;\n\tfunction decorator(protoOrTarget: ContextHostLike, nameOrContext: string): void;\n\tfunction decorator(\n\t\tprotoOrTarget: ContextHostLike | undefined,\n\t\tnameOrContext: string | ClassFieldDecoratorContext<ContextHostLike, unknown>,\n\t): void {\n\t\treturn fieldDecoratorBridge(\n\t\t\tstandardProvideContext(options),\n\t\t\tlegacyProvideContext(options),\n\t\t\tprotoOrTarget,\n\t\t\tnameOrContext,\n\t\t);\n\t}\n\n\treturn decorator;\n}\n",
|
|
41
|
+
"import type { ReactiveHostLike } from '../../core/reactive-host';\nimport type { ReactiveBindingOption } from '../../core/radiant-element';\nimport {\n\tdefaultValueForType,\n\tisValueOfType,\n\treadAttributeValue,\n\ttype AttributeTypeConstant,\n\twriteAttributeValue,\n} from '../../utils/attribute-utils';\n\nexport type AttrConverter<T> = {\n\tfromAttribute?: (value: string | null) => T;\n\ttoAttribute?: (value: T) => string | null;\n};\n\nexport type AttrOptions<T = string | undefined> = {\n\tsource?: string;\n\ttype?: AttributeTypeConstant;\n\tbind?: ReactiveBindingOption;\n\tdefaultValue?: T;\n\tconverter?: AttrConverter<T>;\n};\n\ntype ReactiveAttributeHostApi<Bindings extends object = {}> = ReactiveHostLike<Bindings> & {\n\tregisterCleanupCallback(callback: () => void): void;\n\tregisterConnectedCallback(callback: () => void): void;\n};\n\nexport type ReactiveAttributeHostLike<Bindings extends object = {}> =\n\t| (ReactiveAttributeHostApi<Bindings> & Element)\n\t| (ReactiveAttributeHostApi<Bindings> & { host: Element })\n\t| (ReactiveAttributeHostApi<Bindings> & { element: Element });\n\nfunction resolveAttributeTarget(host: ReactiveAttributeHostLike): Element {\n\tif (host instanceof Element) {\n\t\treturn host;\n\t}\n\n\tif ('host' in host) {\n\t\treturn host.host;\n\t}\n\n\treturn host.element;\n}\n\nfunction toAttributeName(propertyName: string): string {\n\treturn propertyName\n\t\t.replace(/([a-z0-9])([A-Z])/g, '$1-$2')\n\t\t.replace(/_/g, '-')\n\t\t.toLowerCase();\n}\n\nfunction resolveAttributeValue<T>(rawValue: string | null, options: AttrOptions<T>): T {\n\tif (options.converter?.fromAttribute) {\n\t\tconst convertedValue = options.converter.fromAttribute(rawValue);\n\n\t\tif (rawValue === null && convertedValue === undefined && 'defaultValue' in options) {\n\t\t\treturn options.defaultValue as T;\n\t\t}\n\n\t\treturn convertedValue;\n\t}\n\n\tif (options.type) {\n\t\tif (rawValue === null) {\n\t\t\treturn (options.defaultValue ?? defaultValueForType(options.type)) as T;\n\t\t}\n\n\t\tif (options.type === Boolean && rawValue === '') {\n\t\t\treturn true as T;\n\t\t}\n\n\t\treturn readAttributeValue(rawValue, options.type) as T;\n\t}\n\n\tif (rawValue === null) {\n\t\treturn options.defaultValue as T;\n\t}\n\n\treturn rawValue as T;\n}\n\nfunction readReactiveAttributeValue<T>(\n\thost: ReactiveAttributeHostLike,\n\tattributeName: string,\n\toptions: AttrOptions<T>,\n): T {\n\treturn resolveAttributeValue(resolveAttributeTarget(host).getAttribute(attributeName), options);\n}\n\nfunction writeReactiveAttributeValue<T>(\n\ttarget: Element,\n\tattributeName: string,\n\tvalue: T,\n\toptions: AttrOptions<T>,\n): void {\n\tconst attributeValue = options.converter?.toAttribute\n\t\t? options.converter.toAttribute(value)\n\t\t: options.type\n\t\t\t? writeAttributeValue(value, options.type)\n\t\t\t: value == null\n\t\t\t\t? null\n\t\t\t\t: String(value);\n\n\tif (attributeValue === null) {\n\t\ttarget.removeAttribute(attributeName);\n\t\treturn;\n\t}\n\n\ttarget.setAttribute(attributeName, attributeValue);\n}\n\nexport function installReactiveAttribute<TBindings extends object, TValue>(\n\thost: ReactiveAttributeHostLike<TBindings>,\n\tpropertyName: string,\n\toptions: AttrOptions<TValue> = {},\n): void {\n\tif (options.type && options.defaultValue !== undefined && !isValueOfType(options.type, options.defaultValue)) {\n\t\tthrow new Error(`defaultValue does not match the expected type for ${options.type.name}`);\n\t}\n\n\tconst hostRecord = host as unknown as Record<PropertyKey, unknown>;\n\tconst attributeName = options.source ?? toAttributeName(propertyName);\n\tconst observerKey = Symbol(`@ecopages/radiant/attr:${propertyName}:observer`);\n\tconst lastValueKey = Symbol(`@ecopages/radiant/attr:${propertyName}:last-value`);\n\tconst bind =\n\t\toptions.bind ??\n\t\t(host as unknown as { shouldAutoBindReactiveMembers?: () => boolean }).shouldAutoBindReactiveMembers?.() ??\n\t\tfalse;\n\n\thost.defineReactiveBinding(propertyName, bind);\n\thost.registerReactiveDependencyReader(propertyName, () => readReactiveAttributeValue(host, attributeName, options));\n\thostRecord[lastValueKey] = readReactiveAttributeValue(host, attributeName, options);\n\n\tObject.defineProperty(host, propertyName, {\n\t\tget() {\n\t\t\thost.trackReactiveRead(propertyName);\n\t\t\treturn readReactiveAttributeValue(this as ReactiveAttributeHostLike, attributeName, options);\n\t\t},\n\t\tset(newValue: TValue) {\n\t\t\tconst target = resolveAttributeTarget(this as ReactiveAttributeHostLike);\n\t\t\tconst oldValue = readReactiveAttributeValue(this as ReactiveAttributeHostLike, attributeName, options);\n\t\t\twriteReactiveAttributeValue(target, attributeName, newValue, options);\n\t\t\tconst nextValue = readReactiveAttributeValue(this as ReactiveAttributeHostLike, attributeName, options);\n\n\t\t\tif (Object.is(oldValue, nextValue)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t(this as Record<PropertyKey, unknown>)[lastValueKey] = nextValue;\n\t\t\thost.notifyUpdate(propertyName, oldValue, nextValue);\n\t\t},\n\t\tenumerable: true,\n\t\tconfigurable: true,\n\t});\n\n\tconst disconnectObserver = () => {\n\t\tconst observer = hostRecord[observerKey] as MutationObserver | undefined;\n\t\tobserver?.disconnect();\n\t};\n\n\tconst syncAndObserve = () => {\n\t\tconst nextValue = readReactiveAttributeValue(host, attributeName, options);\n\t\tconst previousValue = hostRecord[lastValueKey];\n\n\t\tif (!Object.is(previousValue, nextValue)) {\n\t\t\thostRecord[lastValueKey] = nextValue;\n\t\t\thost.notifyUpdate(propertyName, previousValue, nextValue);\n\t\t}\n\n\t\tif (typeof MutationObserver === 'undefined') {\n\t\t\treturn;\n\t\t}\n\n\t\tconst target = resolveAttributeTarget(host);\n\n\t\tdisconnectObserver();\n\n\t\tconst observer = new MutationObserver(() => {\n\t\t\tconst currentValue = readReactiveAttributeValue(host, attributeName, options);\n\t\t\tconst lastValue = hostRecord[lastValueKey];\n\n\t\t\tif (Object.is(lastValue, currentValue)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\thostRecord[lastValueKey] = currentValue;\n\t\t\thost.notifyUpdate(propertyName, lastValue, currentValue);\n\t\t});\n\n\t\tobserver.observe(target, {\n\t\t\tattributeFilter: [attributeName],\n\t\t\tattributes: true,\n\t\t});\n\n\t\thostRecord[observerKey] = observer;\n\t};\n\n\tsyncAndObserve();\n\thost.registerConnectedCallback(syncAndObserve);\n\thost.registerCleanupCallback(disconnectObserver);\n}\n",
|
|
42
|
+
"import { installReactiveAttribute, type AttrOptions, type ReactiveAttributeHostLike } from '../shared/reactive-attr';\nimport { registerLegacyInstanceInitializer } from './instance-initializers';\n\nexport function reactiveAttr<TValue = string | undefined>(options: AttrOptions<TValue> = {}) {\n\treturn (target: ReactiveAttributeHostLike, propertyName: string) => {\n\t\tconst installedKey = Symbol(`@ecopages/radiant/attr:${propertyName}:installed`);\n\n\t\tregisterLegacyInstanceInitializer(target, (host) => {\n\t\t\t(host as ReactiveAttributeHostLike).registerConnectedCallback(() => {\n\t\t\t\tif ((host as unknown as Record<PropertyKey, unknown>)[installedKey]) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst initializerValue = (host as unknown as Record<PropertyKey, TValue | undefined>)[propertyName];\n\t\t\t\tconst defaultValue = (options.defaultValue === undefined ? initializerValue : options.defaultValue) as\n\t\t\t\t\t| TValue\n\t\t\t\t\t| undefined;\n\n\t\t\t\tinstallReactiveAttribute(host as ReactiveAttributeHostLike, propertyName, {\n\t\t\t\t\t...options,\n\t\t\t\t\tdefaultValue,\n\t\t\t\t});\n\n\t\t\t\t(host as unknown as Record<PropertyKey, unknown>)[installedKey] = true;\n\t\t\t});\n\t\t});\n\t};\n}\n",
|
|
43
|
+
"import { installReactiveAttribute, type AttrOptions, type ReactiveAttributeHostLike } from '../shared/reactive-attr';\n\nexport function reactiveAttr<TValue = string | undefined>(options: AttrOptions<TValue> = {}) {\n\treturn function <THost extends ReactiveAttributeHostLike>(\n\t\ttarget: undefined,\n\t\tcontext: ClassFieldDecoratorContext<THost, TValue>,\n\t) {\n\t\tvoid target;\n\t\tconst propertyName = String(context.name);\n\t\tconst initializerValueKey = Symbol(`@ecopages/radiant/attr:${propertyName}:initializer`);\n\n\t\tcontext.addInitializer(function (this: THost) {\n\t\t\tconst initializerValue = (this as Record<PropertyKey, TValue | undefined>)[initializerValueKey];\n\t\t\tconst defaultValue = (options.defaultValue === undefined ? initializerValue : options.defaultValue) as\n\t\t\t\t| TValue\n\t\t\t\t| undefined;\n\n\t\t\tinstallReactiveAttribute(this, propertyName, {\n\t\t\t\t...options,\n\t\t\t\tdefaultValue,\n\t\t\t});\n\t\t});\n\n\t\treturn function (this: THost, value: TValue) {\n\t\t\t(this as Record<PropertyKey, TValue | undefined>)[initializerValueKey] = value;\n\t\t\treturn value;\n\t\t};\n\t};\n}\n",
|
|
44
|
+
"import { fieldDecoratorBridge } from './bridge';\nimport { reactiveAttr as legacyReactiveAttr } from './legacy/attr';\nimport { reactiveAttr as standardReactiveAttr } from './standard/attr';\nimport type { ReactiveAttributeHostLike } from './shared/reactive-attr';\nexport type { AttrConverter, AttrOptions } from './shared/reactive-attr';\n\nexport function attr<TValue = string | undefined>(options: import('./shared/reactive-attr').AttrOptions<TValue> = {}) {\n\tfunction decorator<THost extends ReactiveAttributeHostLike>(\n\t\tprotoOrTarget: undefined,\n\t\tnameOrContext: ClassFieldDecoratorContext<THost, TValue>,\n\t): (this: THost, value: TValue) => TValue;\n\tfunction decorator(protoOrTarget: ReactiveAttributeHostLike, nameOrContext: string): void;\n\tfunction decorator(\n\t\tprotoOrTarget: ReactiveAttributeHostLike | undefined,\n\t\tnameOrContext: string | ClassFieldDecoratorContext<ReactiveAttributeHostLike, TValue>,\n\t): ((this: ReactiveAttributeHostLike, value: TValue) => TValue) | void {\n\t\treturn fieldDecoratorBridge(\n\t\t\tstandardReactiveAttr(options),\n\t\t\tlegacyReactiveAttr(options),\n\t\t\tprotoOrTarget,\n\t\t\tnameOrContext,\n\t\t);\n\t}\n\n\treturn decorator;\n}\n",
|
|
45
|
+
"import type { RadiantElement } from '../../core/radiant-element';\n\n/**\n * A decorator to bind a method to the instance.\n * @param target {@link RadiantElement}\n * @param propertyKey string\n * @param descriptor {@link PropertyDescriptor}\n * @returns\n */\nexport function bound(target: RadiantElement, propertyKey: string, descriptor: PropertyDescriptor): PropertyDescriptor {\n\tconst originalMethod = descriptor.value;\n\n\treturn {\n\t\tconfigurable: true,\n\t\tget() {\n\t\t\tif (this === (target as any).prototype || Object.prototype.hasOwnProperty.call(this, propertyKey)) {\n\t\t\t\treturn originalMethod;\n\t\t\t}\n\n\t\t\tconst boundMethod = originalMethod.bind(this);\n\t\t\tObject.defineProperty(this, propertyKey, {\n\t\t\t\tvalue: boundMethod,\n\t\t\t\tconfigurable: true,\n\t\t\t\twritable: true,\n\t\t\t});\n\t\t\treturn boundMethod;\n\t\t},\n\t};\n}\n",
|
|
46
|
+
"import type { Method } from '../../types';\n\nexport function bound<T extends Method>(_: T, context: ClassMethodDecoratorContext) {\n\tconst methodName = String(context.name);\n\tif (context.private) {\n\t\tthrow new Error(`'bound' cannot decorate private properties like ${methodName as string}.`);\n\t}\n\tcontext.addInitializer(function (this: any) {\n\t\tthis[methodName] = this[methodName].bind(this);\n\t});\n}\n",
|
|
47
|
+
"import type { Method } from '../types';\nimport type { RadiantElement } from '../core/radiant-element';\nimport { bound as legacyBound } from './legacy/bound';\nimport { bound as standardBound } from './standard/bound';\nimport { methodDecoratorBridge } from './bridge';\n\n/**\n * A decorator to bind a method to the instance.\n */\nexport function bound<Host extends object, TMethod extends Method>(\n\tprotoOrTarget: TMethod,\n\tnameOrContext: ClassMethodDecoratorContext<Host, TMethod>,\n): void;\nexport function bound(\n\tprotoOrTarget: RadiantElement,\n\tnameOrContext: string,\n\tdescriptor: TypedPropertyDescriptor<Method>,\n): TypedPropertyDescriptor<Method> | void;\nexport function bound(\n\tprotoOrTarget: RadiantElement | Method,\n\tnameOrContext: string | ClassMethodDecoratorContext<RadiantElement, Method>,\n\tdescriptor?: TypedPropertyDescriptor<Method>,\n): TypedPropertyDescriptor<Method> | void {\n\treturn methodDecoratorBridge(standardBound, legacyBound, protoOrTarget, nameOrContext, descriptor);\n}\n",
|
|
48
|
+
"import { registerControllerWithConfiguredStrategy, type ControllerConstructor } from '../controller-registry';\n\nexport function controller(identifier: string) {\n\treturn function <T extends ControllerConstructor>(target: T): T {\n\t\treturn registerControllerWithConfiguredStrategy(identifier, target);\n\t};\n}\n",
|
|
49
|
+
"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",
|
|
50
|
+
"import { setCustomElementTagName } from '../../core/custom-element-metadata';\n\n/**\n * Registers a web component with the given name on the global `window.customElements` registry.\n * @param name selector name.\n * @param options {@link ElementDefinitionOptions}\n */\nexport function customElement(name: string, options?: ElementDefinitionOptions) {\n\treturn (target: CustomElementConstructor) => {\n\t\tsetCustomElementTagName(target, name);\n\n\t\tif (typeof customElements !== 'undefined' && !customElements.get(name)) {\n\t\t\tcustomElements.define(name, target, options);\n\t\t}\n\t};\n}\n",
|
|
51
|
+
"import { setCustomElementTagName } from '../../core/custom-element-metadata';\n\nexport function customElement(name: string, options?: ElementDefinitionOptions) {\n\treturn function <T extends CustomElementConstructor>(_: T, context: ClassDecoratorContext<T>) {\n\t\tcontext.addInitializer(function () {\n\t\t\tsetCustomElementTagName(this, name);\n\n\t\t\tif (typeof customElements !== 'undefined' && !customElements.get(name)) {\n\t\t\t\tcustomElements.define(name, this, options);\n\t\t\t}\n\t\t});\n\t};\n}\n",
|
|
52
|
+
"import { customElement as legacyCustomElement } from './legacy/custom-element';\nimport { customElement as standardCustomElement } from './standard/custom-element';\n\n/**\n * Registers a web component with the given name on the global `window.customElements` registry.\n * @param name selector name.\n * @param options {@link ElementDefinitionOptions}\n */\nexport function customElement(name: string, options?: ElementDefinitionOptions) {\n\tfunction decorator<T extends CustomElementConstructor>(\n\t\tprotoOrTarget: T,\n\t\tnameOrContext: ClassDecoratorContext<T>,\n\t): void;\n\tfunction decorator(protoOrTarget: CustomElementConstructor): void;\n\tfunction decorator(\n\t\tprotoOrTarget: CustomElementConstructor,\n\t\tnameOrContext?: ClassDecoratorContext<CustomElementConstructor>,\n\t): void {\n\t\tif (typeof nameOrContext !== 'undefined') {\n\t\t\treturn standardCustomElement(name, options)(protoOrTarget, nameOrContext);\n\t\t}\n\n\t\treturn legacyCustomElement(name, options)(protoOrTarget);\n\t}\n\n\treturn decorator;\n}\n",
|
|
53
|
+
"import type { Method } from '../types';\n\n/**\n * A debounced function with imperative helpers for controlling pending work.\n *\n * @typeParam T The wrapped callback type.\n */\nexport interface DebouncedFunction<T extends Method> {\n\t(...args: Parameters<T>): void;\n\n\t/**\n\t * Cancels the pending callback invocation, if one exists.\n\t */\n\tcancel(): void;\n\n\t/**\n\t * Immediately invokes the latest pending callback invocation.\n\t *\n\t * @returns The callback result when a call is pending, or the last completed\n\t * result when no call is pending.\n\t */\n\tflush(): ReturnType<T> | undefined;\n\n\t/**\n\t * Reports whether the callback currently has a scheduled invocation.\n\t *\n\t * @returns True when a call is pending.\n\t */\n\tpending(): boolean;\n}\n\n/**\n * Creates a debounced wrapper around a function.\n *\n * The returned function delays invocation until the configured timeout has\n * elapsed since the latest call. It also exposes helpers to cancel, flush,\n * and inspect pending work.\n *\n * @typeParam T The wrapped callback type.\n * @param callback The callback to debounce.\n * @param timeout The debounce timeout in milliseconds.\n * @returns A debounced wrapper around the callback.\n */\nexport function debounce<T extends Method>(callback: T, timeout: number): DebouncedFunction<T> {\n\tlet timeoutRef: ReturnType<typeof setTimeout> | null = null;\n\tlet pendingInvocation: (() => ReturnType<T>) | null = null;\n\tlet lastResult: ReturnType<T> | undefined;\n\n\tconst clearPendingCall = () => {\n\t\tif (timeoutRef !== null) {\n\t\t\tclearTimeout(timeoutRef);\n\t\t\ttimeoutRef = null;\n\t\t}\n\t};\n\n\tconst invoke = (): ReturnType<T> | undefined => {\n\t\tif (pendingInvocation === null) {\n\t\t\treturn lastResult;\n\t\t}\n\n\t\tconst invocation = pendingInvocation;\n\t\tpendingInvocation = null;\n\t\tclearPendingCall();\n\t\tlastResult = invocation();\n\n\t\treturn lastResult;\n\t};\n\n\tconst debounced = function (this: ThisParameterType<T>, ...args: Parameters<T>) {\n\t\tpendingInvocation = () => callback.apply(this, args) as ReturnType<T>;\n\t\tclearPendingCall();\n\t\ttimeoutRef = setTimeout(() => {\n\t\t\tinvoke();\n\t\t}, timeout);\n\t} as DebouncedFunction<T>;\n\n\tdebounced.cancel = () => {\n\t\tclearPendingCall();\n\t\tpendingInvocation = null;\n\t};\n\n\tdebounced.flush = () => {\n\t\tif (pendingInvocation === null) {\n\t\t\treturn lastResult;\n\t\t}\n\n\t\treturn invoke();\n\t};\n\n\tdebounced.pending = () => pendingInvocation !== null;\n\n\treturn debounced;\n}\n",
|
|
54
|
+
"import type { RadiantElement } from '../../core/radiant-element';\nimport { debounce as debounceFunction } from '../../helpers/debounce';\n\nexport function debounce(\n\ttimeout: number,\n): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor {\n\treturn (_target: RadiantElement, _propertyKey: string, descriptor: PropertyDescriptor): PropertyDescriptor => {\n\t\tconst originalMethod = descriptor.value;\n\t\tconst debouncedByInstance = new WeakMap<object, ReturnType<typeof debounceFunction<typeof originalMethod>>>();\n\n\t\tdescriptor.value = function debounce(this: object, ...args: Parameters<typeof originalMethod>) {\n\t\t\tlet debounced = debouncedByInstance.get(this);\n\n\t\t\tif (!debounced) {\n\t\t\t\tdebounced = debounceFunction((...innerArgs: Parameters<typeof originalMethod>) => {\n\t\t\t\t\treturn originalMethod.apply(this, innerArgs);\n\t\t\t\t}, timeout);\n\t\t\t\tdebouncedByInstance.set(this, debounced);\n\t\t\t}\n\n\t\t\tdebounced(...args);\n\t\t};\n\n\t\treturn descriptor;\n\t};\n}\n",
|
|
55
|
+
"import { debounce as debounceFunction } from '../../helpers/debounce';\nimport type { Method } from '../../types';\n\nexport function debounce(timeout: number): Method {\n\treturn <T extends Method>(originalMethod: T): Method => {\n\t\tconst debouncedByInstance = new WeakMap<object, ReturnType<typeof debounceFunction<T>>>();\n\n\t\treturn function (this: object, ...args: Parameters<T>): void {\n\t\t\tlet debounced = debouncedByInstance.get(this);\n\n\t\t\tif (!debounced) {\n\t\t\t\tdebounced = debounceFunction((...innerArgs: Parameters<T>) => {\n\t\t\t\t\treturn originalMethod.apply(this, innerArgs);\n\t\t\t\t}, timeout);\n\t\t\t\tdebouncedByInstance.set(this, debounced);\n\t\t\t}\n\n\t\t\tdebounced(...args);\n\t\t};\n\t};\n}\n",
|
|
56
|
+
"import type { Method } from '../types';\nimport { debounce as legacyDebounce } from './legacy/debounce';\nimport { debounce as standardDebounce } from './standard/debounce';\nimport { methodDecoratorBridge } from './bridge';\n\n/**\n * A decorator to debounce a method.\n * @param timeout The debounce timeout in milliseconds.\n */\nexport function debounce(timeout: number) {\n\tfunction decorator<Host extends object, TMethod extends Method>(\n\t\tprotoOrTarget: TMethod,\n\t\tnameOrContext: ClassMethodDecoratorContext<Host, TMethod>,\n\t): Method;\n\tfunction decorator(\n\t\tprotoOrTarget: object,\n\t\tnameOrContext: string,\n\t\tdescriptor: TypedPropertyDescriptor<Method>,\n\t): TypedPropertyDescriptor<Method> | void;\n\tfunction decorator(\n\t\tprotoOrTarget: object | Method,\n\t\tnameOrContext: string | ClassMethodDecoratorContext<object, Method>,\n\t\tdescriptor?: TypedPropertyDescriptor<Method>,\n\t): Method | TypedPropertyDescriptor<Method> | void {\n\t\treturn methodDecoratorBridge(\n\t\t\tstandardDebounce(timeout),\n\t\t\tlegacyDebounce(timeout),\n\t\t\tprotoOrTarget,\n\t\t\tnameOrContext,\n\t\t\tdescriptor,\n\t\t);\n\t}\n\n\treturn decorator;\n}\n",
|
|
57
|
+
"import type { RadiantElement } from '../core/radiant-element';\n\nexport interface EventEmitterConfig {\n\tname: string;\n\tbubbles?: boolean;\n\tcancelable?: boolean;\n\tcomposed?: boolean;\n}\n\n/**\n * A generic event emitter class that allows emitting custom events.\n *\n * @template T - The type of the event detail.\n */\nexport class EventEmitter<T = unknown> {\n\tprivate host: RadiantElement;\n\tprivate eventConfig: EventEmitterConfig;\n\n\t/**\n\t * Constructs a new instance of the EventEmitter class.\n\t *\n\t * @param host - The host element on which the events will be dispatched.\n\t * @param eventConfig - The configuration for the event.\n\t */\n\tconstructor(host: RadiantElement, eventConfig: EventEmitterConfig) {\n\t\tthis.host = host;\n\t\tthis.eventConfig = eventConfig;\n\t}\n\n\t/**\n\t * Emits a custom event with the specified detail.\n\t *\n\t * @param detail - The detail object to be passed along with the event.\n\t */\n\temit(detail?: T) {\n\t\tconst event = new CustomEvent(this.eventConfig.name, {\n\t\t\tdetail: detail,\n\t\t\tbubbles: this.eventConfig.bubbles,\n\t\t\tcancelable: this.eventConfig.cancelable,\n\t\t\tcomposed: this.eventConfig.composed,\n\t\t});\n\t\tthis.host.dispatchEvent(event);\n\t}\n}\n",
|
|
58
|
+
"import type { RadiantElement } from '../core/radiant-element';\nimport { EventEmitter, type EventEmitterConfig } from '../tools/event-emitter';\n\n/**\n * Creates an EventEmitter bound to a host element and registers it on the host.\n * Functional equivalent of the `@event` decorator for vanilla JS usage.\n * @param host The host element that will dispatch the events.\n * @param config {@link EventEmitterConfig} The event emitter configuration.\n */\nexport function createEvent<T = unknown>(host: RadiantElement, config: EventEmitterConfig): EventEmitter<T> {\n\tconst emitter = new EventEmitter<T>(host, config);\n\thost.registerEventEmitter(config.name, emitter);\n\treturn emitter;\n}\n",
|
|
59
|
+
"import type { RadiantElement } from '../../core/radiant-element';\nimport { createEvent } from '../../helpers/create-event';\nimport type { EventEmitterConfig } from '../../tools/event-emitter';\nimport { registerLegacyInstanceInitializer } from './instance-initializers';\n\n/**\n * Decorator that attaches an EventEmitter to the class field property.\n * The EventEmitter can be used to dispatch custom events from the target element.\n * @param eventConfig Configuration for the event emitter.\n * @see {@link EventEmitter} for more details about how the EventEmitter works.\n */\nexport function event(eventConfig: EventEmitterConfig) {\n\treturn (proto: RadiantElement, propertyKey: string) => {\n\t\tregisterLegacyInstanceInitializer(proto, (element) => {\n\t\t\tconst emitter = createEvent(element, eventConfig);\n\n\t\t\telement.registerConnectedCallback(() => {\n\t\t\t\tObject.defineProperty(element, propertyKey, {\n\t\t\t\t\tget() {\n\t\t\t\t\t\treturn emitter;\n\t\t\t\t\t},\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",
|
|
60
|
+
"import type { RadiantElement } from '../../core/radiant-element';\nimport { createEvent } from '../../helpers/create-event';\nimport type { EventEmitterConfig } from '../../tools/event-emitter';\n\n/**\n * Decorator that attaches an EventEmitter to the class field property.\n * The EventEmitter can be used to dispatch custom events from the target element.\n * @param eventConfig Configuration for the event emitter.\n * @see {@link EventEmitter} for more details about how the EventEmitter works.\n */\nexport function event(eventConfig: EventEmitterConfig) {\n\treturn function <T extends RadiantElement, V>(_: undefined, context: ClassFieldDecoratorContext<T, V>) {\n\t\tcontext.addInitializer(function (this: T) {\n\t\t\tconst emitter = createEvent(this, eventConfig);\n\n\t\t\tObject.defineProperty(this, context.name, {\n\t\t\t\tget() {\n\t\t\t\t\treturn emitter;\n\t\t\t\t},\n\t\t\t\tenumerable: true,\n\t\t\t\tconfigurable: true,\n\t\t\t});\n\t\t});\n\t};\n}\n",
|
|
61
|
+
"import { type EventEmitterConfig } from '../tools/event-emitter';\nimport type { RadiantElement } from '../core/radiant-element';\nimport { event as legacyEvent } from './legacy/event';\nimport { event as standardEvent } from './standard/event';\nimport { fieldDecoratorBridge } from './bridge';\n\n/**\n * Decorator that attaches an EventEmitter to the class field property.\n * The EventEmitter can be used to dispatch custom events from the target element.\n * @param eventConfig {@link EventEmitterConfig} Configuration for the event emitter.\n * @see {@link EventEmitter} for more details about how the EventEmitter works.\n */\nexport function event(eventConfig: EventEmitterConfig) {\n\tfunction decorator<THost extends RadiantElement, TValue>(\n\t\tprotoOrTarget: undefined,\n\t\tnameOrContext: ClassFieldDecoratorContext<THost, TValue>,\n\t): void;\n\tfunction decorator(protoOrTarget: RadiantElement, nameOrContext: string): void;\n\tfunction decorator(\n\t\tprotoOrTarget: RadiantElement | undefined,\n\t\tnameOrContext: string | ClassFieldDecoratorContext<RadiantElement, unknown>,\n\t): void {\n\t\treturn fieldDecoratorBridge(standardEvent(eventConfig), legacyEvent(eventConfig), protoOrTarget, nameOrContext);\n\t}\n\n\treturn decorator;\n}\n",
|
|
62
|
+
"import type { RadiantElementEventListener } from '../core/radiant-element';\n\n/**\n * Selects which DOM tree delegated event listeners should observe.\n */\nexport type OnEventScope = 'light' | 'shadow' | 'both';\n\ntype BaseOnEventConfig = Pick<RadiantElementEventListener, 'type' | 'options'> & {\n\tscope?: OnEventScope;\n};\n\nexport type OnEventConfig = BaseOnEventConfig &\n\t(\n\t\t| {\n\t\t\t\tselector: string;\n\t\t }\n\t\t| {\n\t\t\t\tref: string;\n\t\t }\n\t\t| {\n\t\t\t\twindow: true;\n\t\t }\n\t\t| {\n\t\t\t\tdocument: true;\n\t\t }\n\t);\n\ntype DelegatedEventRoot = Element | ShadowRoot;\n\ntype EventListenerLifecycleHost = {\n\tregisterConnectedCallback(callback: () => void): void;\n\tregisterCleanupCallback(callback: () => void): void;\n\tisConnected: boolean;\n};\n\nexport type EventListenerHost =\n\t| (EventListenerLifecycleHost & Element)\n\t| (EventListenerLifecycleHost & { host: Element })\n\t| (EventListenerLifecycleHost & { element: Element });\n\nconst shadowRootListenerHooksKey = Symbol('radiant.shadowRootListenerHooks');\nconst patchedAttachShadowKey = Symbol('radiant.patchedAttachShadow');\n\ntype ShadowRootHookHost = Element & {\n\t[patchedAttachShadowKey]?: true;\n\t[shadowRootListenerHooksKey]?: Set<() => void>;\n};\n\nfunction resolveEventListenerHostElement(host: EventListenerHost): Element {\n\tif (host instanceof Element) {\n\t\treturn host;\n\t}\n\n\tif ('host' in host) {\n\t\treturn host.host;\n\t}\n\n\treturn host.element;\n}\n\nfunction isControllerEventHost(host: EventListenerHost): host is EventListenerLifecycleHost & { host: Element } {\n\treturn !(host instanceof Element);\n}\n\nfunction addDelegatedListener(\n\troot: DelegatedEventRoot,\n\tconfig: Pick<OnEventConfig, 'type' | 'options'>,\n\tselector: string,\n\tlistener: EventListener,\n): () => void {\n\tconst delegatedListener = (event: Event) => {\n\t\tif (event.target instanceof Element && event.target.matches(selector)) {\n\t\t\tlistener(event);\n\t\t}\n\t};\n\n\troot.addEventListener(config.type, delegatedListener, config.options);\n\n\treturn () => {\n\t\troot.removeEventListener(config.type, delegatedListener, config.options);\n\t};\n}\n\nfunction registerShadowRootHook(host: EventListenerHost, hook: () => void): void {\n\tconst shadowAwareHost = resolveEventListenerHostElement(host) as ShadowRootHookHost;\n\n\tif (!shadowAwareHost[shadowRootListenerHooksKey]) {\n\t\tshadowAwareHost[shadowRootListenerHooksKey] = new Set();\n\t}\n\n\tshadowAwareHost[shadowRootListenerHooksKey].add(hook);\n\n\tif (shadowAwareHost[patchedAttachShadowKey]) {\n\t\treturn;\n\t}\n\n\tconst originalAttachShadow = shadowAwareHost.attachShadow;\n\n\tshadowAwareHost.attachShadow = function patchedAttachShadow(init: ShadowRootInit): ShadowRoot {\n\t\tconst shadowRoot = originalAttachShadow.call(this, init);\n\t\tfor (const shadowRootHook of shadowAwareHost[shadowRootListenerHooksKey] ?? []) {\n\t\t\tshadowRootHook();\n\t\t}\n\t\treturn shadowRoot;\n\t};\n\n\tshadowAwareHost[patchedAttachShadowKey] = true;\n}\n\n/**\n * Subscribes to a DOM event with delegation, window, or document targeting.\n * Functional equivalent of the `@onEvent` decorator for vanilla JS usage.\n * Returns a cleanup function to remove the listener.\n * @param host The host RadiantElement.\n * @param config The event listener configuration.\n * @param callback The event handler function.\n */\nexport function createEventListener(\n\thost: EventListenerHost,\n\tconfig: OnEventConfig,\n\tcallback: (event: Event) => void,\n): () => void {\n\tif (isControllerEventHost(host) && 'scope' in config && config.scope && config.scope !== 'light') {\n\t\tthrow new Error('RadiantController event listeners only support light DOM scope.');\n\t}\n\n\tconst hostElement = resolveEventListenerHostElement(host);\n\tconst boundCallback = callback.bind(host);\n\tlet windowCleanup: (() => void) | null = null;\n\tlet documentCleanup: (() => void) | null = null;\n\tlet lightCleanup: (() => void) | null = null;\n\tlet shadowCleanup: (() => void) | null = null;\n\tlet disposed = false;\n\n\tconst detachListeners = () => {\n\t\twindowCleanup?.();\n\t\tdocumentCleanup?.();\n\t\tlightCleanup?.();\n\t\tshadowCleanup?.();\n\n\t\twindowCleanup = null;\n\t\tdocumentCleanup = null;\n\t\tlightCleanup = null;\n\t\tshadowCleanup = null;\n\t};\n\n\tconst attachListeners = () => {\n\t\tif (disposed) {\n\t\t\treturn;\n\t\t}\n\n\t\tif ('window' in config && !windowCleanup) {\n\t\t\twindow.addEventListener(config.type, boundCallback, config.options);\n\t\t\twindowCleanup = () => {\n\t\t\t\twindow.removeEventListener(config.type, boundCallback, config.options);\n\t\t\t};\n\t\t}\n\n\t\tif ('document' in config && !documentCleanup) {\n\t\t\tdocument.addEventListener(config.type, boundCallback, config.options);\n\t\t\tdocumentCleanup = () => {\n\t\t\t\tdocument.removeEventListener(config.type, boundCallback, config.options);\n\t\t\t};\n\t\t}\n\n\t\tif ('selector' in config || 'ref' in config) {\n\t\t\tconst selector = 'selector' in config ? config.selector : `[data-ref='${CSS.escape(config.ref)}']`;\n\n\t\t\tif (config.scope !== 'shadow' && !lightCleanup) {\n\t\t\t\tlightCleanup = addDelegatedListener(hostElement, config, selector, boundCallback);\n\t\t\t}\n\n\t\t\tif (config.scope !== 'light' && hostElement.shadowRoot && !shadowCleanup) {\n\t\t\t\tshadowCleanup = addDelegatedListener(hostElement.shadowRoot, config, selector, boundCallback);\n\t\t\t}\n\t\t}\n\t};\n\n\tif ('selector' in config || 'ref' in config) {\n\t\tif (config.scope !== 'light') {\n\t\t\tregisterShadowRootHook(host, () => {\n\t\t\t\tif (host.isConnected) {\n\t\t\t\t\tattachListeners();\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\n\thost.registerConnectedCallback(attachListeners);\n\thost.registerCleanupCallback(detachListeners);\n\n\tif (host.isConnected) {\n\t\tattachListeners();\n\t}\n\n\treturn () => {\n\t\tdisposed = true;\n\t\tdetachListeners();\n\t};\n}\n",
|
|
63
|
+
"import { createEventListener, type EventListenerHost } from '../../helpers/create-event-listener';\nimport type { OnEventConfig } from '../on-event';\nimport { registerLegacyInstanceInitializer } from './instance-initializers';\n\n/**\n * A decorator to subscribe to an event on the target element.\n * The event listener will be automatically unsubscribed when the element is disconnected.\n *\n * Note: This decorator uses event delegation, which means it relies on event bubbling.\n * Therefore, it will not work with events that do not bubble, such as `focus`, `blur`, `load`, `unload`, `scroll`, etc.\n * For focus and blur events, consider using `focusin` and `focusout` which are similar but do bubble.\n *\n * @param eventConfig The event configuration.\n * @param eventConfig.selectors The CSS selector(s) of the target element(s).\n * @param eventConfig.ref The data-ref attribute of the target element.\n * @param eventConfig.type The type of the event to listen for.\n * @param eventConfig.options Optional. An options object that specifies characteristics about the event listener.\n */\nexport function onEvent(eventConfig: OnEventConfig) {\n\treturn (proto: EventListenerHost, _: string, descriptor: PropertyDescriptor) => {\n\t\tconst originalMethod = descriptor.value;\n\n\t\tregisterLegacyInstanceInitializer(proto, (element) => {\n\t\t\tcreateEventListener(element, eventConfig, originalMethod.bind(element));\n\t\t});\n\n\t\treturn descriptor;\n\t};\n}\n",
|
|
64
|
+
"import { createEventListener, type EventListenerHost } from '../../helpers/create-event-listener';\nimport type { OnEventConfig } from '../on-event';\nimport type { Method } from '../../types';\n\n/**\n * A decorator to subscribe to an event on the target element.\n * The event listener will be automatically unsubscribed when the element is disconnected.\n *\n * Note: This decorator uses event delegation, which means it relies on event bubbling.\n * Therefore, it will not work with events that do not bubble, such as `focus`, `blur`, `load`, `unload`, `scroll`, etc.\n * For focus and blur events, consider using `focusin` and `focusout` which are similar but do bubble.\n *\n * @param eventConfig The event configuration.\n * @param eventConfig.selectors The CSS selector(s) of the target element(s).\n * @param eventConfig.ref The data-ref attribute of the target element.\n * @param eventConfig.type The type of the event to listen for.\n * @param eventConfig.options Optional. An options object that specifies characteristics about the event listener.\n */\nexport function onEvent(eventConfig: OnEventConfig) {\n\treturn function <Host extends EventListenerHost, T extends Method>(\n\t\toriginalMethod: T,\n\t\tcontext: ClassMethodDecoratorContext<Host, T>,\n\t): void {\n\t\tcontext.addInitializer(function (this: Host) {\n\t\t\tcreateEventListener(this, eventConfig, originalMethod.bind(this));\n\t\t});\n\t};\n}\n",
|
|
65
|
+
"import type { Method } from '../types';\nimport type { EventListenerHost, OnEventConfig, OnEventScope } from '../helpers/create-event-listener';\nimport { onEvent as legacyOnEvent } from './legacy/on-event';\nimport { onEvent as standardOnEvent } from './standard/on-event';\nimport { methodDecoratorBridge } from './bridge';\n\nexport type { OnEventConfig, OnEventScope };\n\n/**\n * A decorator to subscribe to an event on the target element.\n * The event listener will be automatically unsubscribed when the element is disconnected.\n *\n * Note: This decorator uses event delegation, which means it relies on event bubbling.\n * Therefore, it will not work with events that do not bubble, such as `focus`, `blur`, `load`, `unload`, `scroll`, etc.\n * For focus and blur events, consider using `focusin` and `focusout` which are similar but do bubble.\n * Delegated listeners observe the host light DOM by default, and can optionally observe the shadow root or both trees.\n *\n * @param options {@link OnEventConfig} The event configuration.\n */\nexport function onEvent(options: OnEventConfig) {\n\tfunction decorator<Host extends EventListenerHost, TMethod extends Method>(\n\t\tprotoOrTarget: TMethod,\n\t\tnameOrContext: ClassMethodDecoratorContext<Host, TMethod>,\n\t): void;\n\tfunction decorator(\n\t\tprotoOrTarget: EventListenerHost,\n\t\tnameOrContext: string,\n\t\tdescriptor: TypedPropertyDescriptor<Method>,\n\t): TypedPropertyDescriptor<Method> | void;\n\tfunction decorator(\n\t\tprotoOrTarget: EventListenerHost | Method,\n\t\tnameOrContext: string | ClassMethodDecoratorContext<EventListenerHost, Method>,\n\t\tdescriptor?: TypedPropertyDescriptor<Method>,\n\t): TypedPropertyDescriptor<Method> | void {\n\t\treturn methodDecoratorBridge(\n\t\t\tstandardOnEvent(options),\n\t\t\tlegacyOnEvent(options),\n\t\t\tprotoOrTarget,\n\t\t\tnameOrContext,\n\t\t\tdescriptor,\n\t\t);\n\t}\n\n\treturn decorator;\n}\n",
|
|
66
|
+
"type LegacyUpdatedHost = {\n\tregisterCleanupCallback(callback: () => void): void;\n\tregisterConnectedCallback(callback: () => void): void;\n\tregisterUpdateCallback(key: string, update: (...rest: any[]) => any): () => void;\n};\n\nimport { registerLegacyInstanceInitializer } from './instance-initializers';\n\n/**\n * A decorator to subscribe to an updated callback when a reactive field or property changes.\n * @param eventConfig The event configuration.\n */\nexport function onUpdated(keyOrKeys: string | string[]) {\n\treturn (target: LegacyUpdatedHost, methodName: string) => {\n\t\tconst cleanupKey = Symbol(`@ecopages/radiant/on-updated:${methodName}:cleanup`);\n\n\t\tregisterLegacyInstanceInitializer(target, (element) => {\n\t\t\telement.registerConnectedCallback(() => {\n\t\t\t\tconst boundedMethod = (element as any)[methodName].bind(element);\n\t\t\t\tconst cleanups: Array<() => void> = [];\n\n\t\t\t\tif (Array.isArray(keyOrKeys)) {\n\t\t\t\t\tfor (const key of keyOrKeys) {\n\t\t\t\t\t\tcleanups.push(element.registerUpdateCallback(key, boundedMethod));\n\t\t\t\t\t}\n\t\t\t\t} else if (typeof keyOrKeys === 'string') {\n\t\t\t\t\tcleanups.push(element.registerUpdateCallback(keyOrKeys, boundedMethod));\n\t\t\t\t}\n\n\t\t\t\t(element as unknown as Record<PropertyKey, unknown>)[cleanupKey] = () => {\n\t\t\t\t\tfor (const cleanup of cleanups) {\n\t\t\t\t\t\tcleanup();\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t});\n\n\t\t\telement.registerCleanupCallback(() => {\n\t\t\t\tconst cleanup = (element as unknown as Record<PropertyKey, unknown>)[cleanupKey];\n\n\t\t\t\tif (typeof cleanup === 'function') {\n\t\t\t\t\tcleanup();\n\t\t\t\t\tdelete (element as unknown as Record<PropertyKey, unknown>)[cleanupKey];\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t};\n}\n",
|
|
67
|
+
"import type { Method } from '../../types';\n\ntype UpdatedHost = {\n\tregisterUpdateCallback(key: string, update: (...args: unknown[]) => unknown): () => void;\n};\n\nexport function onUpdated(keyOrKeys: string | string[]) {\n\treturn function <THost extends UpdatedHost, T extends Method>(\n\t\toriginalMethod: T,\n\t\tcontext: ClassMethodDecoratorContext<THost, T>,\n\t): void {\n\t\tcontext.addInitializer(function (this: THost) {\n\t\t\tconst boundMethod = originalMethod.bind(this);\n\n\t\t\tObject.defineProperty(this, context.name, {\n\t\t\t\tvalue: boundMethod,\n\t\t\t\tconfigurable: true,\n\t\t\t\twritable: true,\n\t\t\t});\n\n\t\t\tif (Array.isArray(keyOrKeys)) {\n\t\t\t\tfor (const key of keyOrKeys) {\n\t\t\t\t\tthis.registerUpdateCallback(key, boundMethod);\n\t\t\t\t}\n\t\t\t} else if (typeof keyOrKeys === 'string') {\n\t\t\t\tthis.registerUpdateCallback(keyOrKeys, boundMethod);\n\t\t\t}\n\t\t});\n\t};\n}\n",
|
|
68
|
+
"import type { Method } from '../types';\nimport { onUpdated as legacyOnUpdated } from './legacy/on-updated';\nimport { onUpdated as standardOnUpdated } from './standard/on-updated';\nimport { methodDecoratorBridge } from './bridge';\n\ntype UpdateCallback = (...args: unknown[]) => unknown;\n\ntype UpdatedHost = {\n\tregisterCleanupCallback(callback: () => void): void;\n\tregisterConnectedCallback(callback: () => void): void;\n\tregisterUpdateCallback(key: string, update: UpdateCallback): () => void;\n};\n\n/**\n * A decorator to bind a method to the instance.\n */\nexport function onUpdated(keyOrKeys: string | string[]) {\n\tfunction decorator<THost extends UpdatedHost, TMethod extends Method>(\n\t\tprotoOrTarget: TMethod,\n\t\tnameOrContext: ClassMethodDecoratorContext<THost, TMethod>,\n\t): void;\n\tfunction decorator(\n\t\tprotoOrTarget: UpdatedHost,\n\t\tnameOrContext: string,\n\t\tdescriptor: TypedPropertyDescriptor<Method>,\n\t): TypedPropertyDescriptor<Method> | void;\n\tfunction decorator(\n\t\tprotoOrTarget: UpdatedHost | Method,\n\t\tnameOrContext: string | ClassMethodDecoratorContext<UpdatedHost, Method>,\n\t\tdescriptor?: TypedPropertyDescriptor<Method>,\n\t): TypedPropertyDescriptor<Method> | void {\n\t\treturn methodDecoratorBridge(\n\t\t\tstandardOnUpdated(keyOrKeys),\n\t\t\tlegacyOnUpdated(keyOrKeys),\n\t\t\tprotoOrTarget,\n\t\t\tnameOrContext,\n\t\t\tdescriptor,\n\t\t);\n\t}\n\n\treturn decorator;\n}\n",
|
|
69
|
+
"import type { ReactivePropertyOptions } from './radiant-element';\n\nconst REACTIVE_PROP_DEFINITIONS = Symbol.for('@ecopages/radiant.reactivePropDefinitions');\n\nexport type ReactivePropDefinition = {\n\tname: string;\n\toptions: ReactivePropertyOptions<unknown>;\n};\n\ntype RadiantConstructorWithReactiveProps = CustomElementConstructor & {\n\t[REACTIVE_PROP_DEFINITIONS]?: ReactivePropDefinition[];\n};\n\nexport function registerReactivePropDefinition(\n\ttarget: object,\n\tpropertyName: string,\n\toptions: ReactivePropertyOptions<unknown>,\n): void {\n\tconst constructor = target.constructor as RadiantConstructorWithReactiveProps;\n\tconst definitions = constructor[REACTIVE_PROP_DEFINITIONS] ?? [];\n\n\tif (definitions.some((definition) => definition.name === propertyName)) {\n\t\treturn;\n\t}\n\n\tdefinitions.push({ name: propertyName, options });\n\tconstructor[REACTIVE_PROP_DEFINITIONS] = definitions;\n}\n\nexport function getReactivePropDefinitions(target: object): ReactivePropDefinition[] {\n\treturn ((target.constructor as RadiantConstructorWithReactiveProps)[REACTIVE_PROP_DEFINITIONS] ?? []).slice();\n}\n",
|
|
70
|
+
"import type { ReactivePropertyOptions } from '../../core/radiant-element';\nimport { registerReactivePropDefinition } from '../../core/reactive-prop-metadata';\nimport { isValueOfType } from '../../utils/attribute-utils';\nimport { registerLegacyInstanceInitializer } from './instance-initializers';\n\ntype ReactivePropHost<T> = {\n\tcreateReactiveProp(propertyName: string, options: ReactivePropertyOptions<T>): void;\n\tregisterConnectedCallback(callback: () => void): void;\n};\n\n/**\n * Legacy-decorator implementation for `@prop(...)`.\n *\n * The decorated host is expected to expose `createReactiveProp(...)`, which\n * lets both `RadiantElement` and `RadiantController` share the same public\n * decorator while keeping their runtime channels different.\n */\nexport function reactiveProp<T = unknown>({\n\ttype,\n\tattribute,\n\treflect,\n\tdefaultValue,\n\tbind,\n}: ReactivePropertyOptions<T>) {\n\tif (defaultValue !== undefined && !isValueOfType(type, defaultValue)) {\n\t\tthrow new Error(`defaultValue does not match the expected type for ${type.name}`);\n\t}\n\n\treturn (target: ReactivePropHost<T>, propertyName: string) => {\n\t\tconst attributeKey = attribute ?? propertyName;\n\t\tregisterReactivePropDefinition(target, propertyName, {\n\t\t\ttype,\n\t\t\treflect,\n\t\t\tattribute: attributeKey,\n\t\t\tdefaultValue,\n\t\t\tbind,\n\t\t});\n\n\t\tconst ssrStoreKey = Symbol.for(`@ecopages/radiant.ssr-prop:${propertyName}`);\n\n\t\tObject.defineProperty(target, propertyName, {\n\t\t\tget(this: ReactivePropHost<T> & Record<PropertyKey, unknown>) {\n\t\t\t\treturn this[ssrStoreKey] ?? defaultValue;\n\t\t\t},\n\t\t\tset(this: ReactivePropHost<T> & Record<PropertyKey, unknown>, value: T) {\n\t\t\t\tthis[ssrStoreKey] = value;\n\t\t\t},\n\t\t\tconfigurable: true,\n\t\t\tenumerable: true,\n\t\t});\n\n\t\tregisterLegacyInstanceInitializer(target, (element) => {\n\t\t\telement.registerConnectedCallback(() => {\n\t\t\t\tconst initializerValue = element[propertyName as keyof typeof element] as T | undefined;\n\t\t\t\tconst resolvedDefaultValue = defaultValue === undefined ? initializerValue : defaultValue;\n\n\t\t\t\telement.createReactiveProp(propertyName, {\n\t\t\t\t\ttype,\n\t\t\t\t\treflect,\n\t\t\t\t\tattribute: attributeKey,\n\t\t\t\t\tdefaultValue: resolvedDefaultValue,\n\t\t\t\t\tbind,\n\t\t\t\t});\n\t\t\t});\n\t\t});\n\t};\n}\n",
|
|
71
|
+
"import type { ReactivePropertyOptions } from '../../core/radiant-element.js';\nimport { registerReactivePropDefinition } from '../../core/reactive-prop-metadata';\nimport { isValueOfType } from '../../utils/attribute-utils';\n\ntype ReactivePropHost<P> = {\n\tcreateReactiveProp(propertyName: string, options: ReactivePropertyOptions<P>): void;\n};\n\n/**\n * Standard-decorator implementation for `@prop(...)`.\n *\n * The decorated host is expected to expose `createReactiveProp(...)`, which\n * lets both `RadiantElement` and `RadiantController` share the same public\n * decorator while keeping their runtime channels different.\n */\nexport function reactiveProp<P = unknown>({\n\ttype,\n\tattribute,\n\treflect,\n\tdefaultValue,\n\tbind,\n}: ReactivePropertyOptions<P>) {\n\tif (defaultValue !== undefined && !isValueOfType(type, defaultValue)) {\n\t\tthrow new Error(`defaultValue does not match the expected type for ${type.name}`);\n\t}\n\treturn function <T extends ReactivePropHost<P>, V>(_: undefined, context: ClassFieldDecoratorContext<T, V>) {\n\t\tconst propertyName = String(context.name);\n\t\tconst attributeKey = attribute ?? propertyName;\n\t\tconst initializerValueKey = Symbol(`@ecopages/radiant/reactive-prop:${propertyName}:initializer`);\n\n\t\tcontext.addInitializer(function (this: T) {\n\t\t\tconst initializerValue = (this as T & Record<PropertyKey, V | undefined>)[initializerValueKey];\n\t\t\tconst resolvedDefaultValue = (defaultValue === undefined ? initializerValue : defaultValue) as\n\t\t\t\t| P\n\t\t\t\t| undefined;\n\n\t\t\tregisterReactivePropDefinition(this, propertyName, {\n\t\t\t\ttype,\n\t\t\t\treflect,\n\t\t\t\tattribute: attributeKey,\n\t\t\t\tdefaultValue,\n\t\t\t\tbind,\n\t\t\t});\n\t\t\tthis.createReactiveProp(propertyName, {\n\t\t\t\ttype,\n\t\t\t\treflect,\n\t\t\t\tattribute: attributeKey,\n\t\t\t\tdefaultValue: resolvedDefaultValue,\n\t\t\t\tbind,\n\t\t\t});\n\t\t});\n\n\t\treturn function (this: T, value: V) {\n\t\t\t(this as Record<PropertyKey, V | undefined>)[initializerValueKey] = value;\n\t\t\treturn value;\n\t\t};\n\t};\n}\n",
|
|
72
|
+
"import type { ReactivePropertyOptions } from '../core/radiant-element';\nimport { reactiveProp as legacyReactiveProp } from './legacy/reactive-prop';\nimport { reactiveProp as standardReactiveProp } from './standard/reactive-prop';\nimport { fieldDecoratorBridge } from './bridge';\n\ntype StandardReactivePropHost<T> = {\n\tcreateReactiveProp(propertyName: string, options: ReactivePropertyOptions<T>): void;\n};\n\ntype LegacyReactivePropHost<T> = StandardReactivePropHost<T> & {\n\tregisterConnectedCallback(callback: () => void): void;\n};\n\n/**\n * Declares a reactive property on a Radiant host.\n *\n * On `RadiantElement`, the property stays aligned with the element attribute\n * channel and can optionally reflect back to markup. On `RadiantController`,\n * the property is exposed through the attached host element as a real JS\n * property so callers can pass objects, arrays, and other non-string values\n * without serializing them into attributes.\n *\n * Every write triggers `notifyUpdate` so update callbacks, bindings, and\n * render lifecycles stay in sync.\n *\n * @param options {@link ReactivePropertyOptions} The options for the reactive property.\n */\nexport function prop<T = unknown>(options: ReactivePropertyOptions<T>) {\n\tfunction decorator<THost extends StandardReactivePropHost<T>, TValue>(\n\t\tprotoOrTarget: undefined,\n\t\tnameOrContext: ClassFieldDecoratorContext<THost, TValue>,\n\t): ((this: THost, value: TValue) => TValue) | void;\n\tfunction decorator(protoOrTarget: LegacyReactivePropHost<T>, nameOrContext: string): void;\n\tfunction decorator(\n\t\tprotoOrTarget: LegacyReactivePropHost<T> | undefined,\n\t\tnameOrContext: string | ClassFieldDecoratorContext<StandardReactivePropHost<T>, unknown>,\n\t): ((this: StandardReactivePropHost<T>, value: unknown) => unknown) | void {\n\t\treturn fieldDecoratorBridge(\n\t\t\tstandardReactiveProp(options),\n\t\t\tlegacyReactiveProp(options),\n\t\t\tprotoOrTarget,\n\t\t\tnameOrContext,\n\t\t);\n\t}\n\n\treturn decorator;\n}\n",
|
|
73
|
+
"type BaseQueryConfig = {\n\tall?: boolean;\n\tcache?: boolean;\n\tscope?: QueryScope;\n};\n\ntype QueryBySelector = { selector: string };\n\ntype QueryByRef = { ref: string };\n\nexport type QueryHostTarget = Element | { host: Element };\n\n/**\n * Selects which DOM tree a query should read from.\n */\nexport type QueryScope = 'light' | 'shadow' | 'both';\n\nexport type QueryConfig = BaseQueryConfig & (QueryBySelector | QueryByRef);\n\ntype QueryRoot = Element | ShadowRoot;\n\ntype QueryResult<T extends Element | Element[]> = {\n\tget value(): T | null;\n};\n\nfunction isControllerQueryTarget(target: QueryHostTarget): target is { host: Element } {\n\treturn !(target instanceof Element);\n}\n\nfunction resolveShadowRoot(host: Element): ShadowRoot | null {\n\treturn 'shadowRoot' in host ? ((host as Element & { shadowRoot?: ShadowRoot | null }).shadowRoot ?? null) : null;\n}\n\n/**\n * Resolves the DOM element that should serve as the query root.\n *\n * `@query(...)` can run on both element hosts and controller instances. This\n * helper normalizes those call sites to the underlying element that actually\n * owns the DOM subtree.\n */\nexport function resolveQueryHost(target: QueryHostTarget): Element {\n\treturn target instanceof Element ? target : target.host;\n}\n\nfunction getQueryRoots(host: Element, scope: QueryScope = 'light'): QueryRoot[] {\n\tconst shadowRoot = resolveShadowRoot(host);\n\n\tif (scope === 'shadow') {\n\t\treturn shadowRoot ? [shadowRoot] : [];\n\t}\n\n\tif (scope === 'both') {\n\t\treturn shadowRoot ? [host, shadowRoot] : [host];\n\t}\n\n\treturn [host];\n}\n\n/**\n * Creates a lazy DOM query accessor bound to an element host or controller.\n * Functional equivalent of the `@query` decorator for vanilla JS usage.\n * @param target The element host or controller to query within.\n * @param options {@link QueryConfig} The query configuration.\n */\nexport function createQuery<T extends Element | Element[] = Element>(\n\ttarget: QueryHostTarget,\n\toptions: QueryConfig,\n): QueryResult<T> {\n\tif (isControllerQueryTarget(target) && options.scope && options.scope !== 'light') {\n\t\tthrow new Error('RadiantController queries only support light DOM scope.');\n\t}\n\n\tconst host = resolveQueryHost(target);\n\tconst selector = 'selector' in options ? options.selector : `[data-ref=\"${options.ref}\"]`;\n\tlet cached: T | null = null;\n\n\tconst executeQuery = (): T | null => {\n\t\tconst roots = getQueryRoots(host, options.scope);\n\n\t\tif (options.all) {\n\t\t\treturn roots.flatMap((root) => Array.from(root.querySelectorAll(selector))) as T;\n\t\t}\n\n\t\tfor (const root of roots) {\n\t\t\tconst match = root.querySelector(selector);\n\t\t\tif (match) {\n\t\t\t\treturn match as T;\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t};\n\n\treturn {\n\t\tget value(): T | null {\n\t\t\tif (options.cache) {\n\t\t\t\tif (cached === null || (options.all && Array.isArray(cached) && !cached.length)) {\n\t\t\t\t\tcached = executeQuery();\n\t\t\t\t}\n\t\t\t\treturn cached;\n\t\t\t}\n\t\t\treturn executeQuery();\n\t\t},\n\t};\n}\n",
|
|
74
|
+
"import { createQuery } from '../../helpers/create-query';\nimport type { QueryConfig } from '../query';\nimport { registerLegacyInstanceInitializer } from './instance-initializers';\n\ntype QueryDecoratorInstance = (Element | { host: Element }) & {\n\tregisterConnectedCallback(callback: () => void): void;\n};\n\n/**\n * A decorator to query by CSS selector or data-ref attribute.\n * By default it queries for the first element that matches the selector, but it can be configured to query for all elements.\n *\n * @param {QueryConfig} options - The configuration object for the query.\n * @param {boolean} [options.all] - A flag to query for all elements that match the selector. Defaults to `false`.\n * @param {boolean} [options.cache] - A flag to cache the query result. Defaults to `true`.\n * @param {string} [options.selector] - A CSS selector to match elements against. This property is mutually exclusive with `options.ref`.\n * @param {string} [options.ref] - A reference to an element. This property is mutually exclusive with `options.selector`.\n *\n * @returns {Function} A decorator function that, when applied to a class property, will replace it with a getter. The getter will return the result of the query when accessed.\n *\n * @example\n * class MyElement extends HTMLElement {\n * @query({ selector: '.my-class' })\n * myElement;\n * }\n *\n * // Now, `myElement` will return the first element in the light DOM of `MyElement` that matches the selector '.my-class'.\n */\nexport function query<T extends Element | Element[]>({\n\tcache: shouldBeCached = true,\n\t...options\n}: QueryConfig): (proto: QueryDecoratorInstance, propertyName: string | symbol) => void {\n\treturn (proto: QueryDecoratorInstance, propertyKey: string | symbol) => {\n\t\tregisterLegacyInstanceInitializer(proto, (element) => {\n\t\t\telement.registerConnectedCallback(() => {\n\t\t\t\tconst accessor = createQuery<T>(element, {\n\t\t\t\t\tcache: shouldBeCached,\n\t\t\t\t\t...options,\n\t\t\t\t});\n\n\t\t\t\tObject.defineProperty(element, propertyKey, {\n\t\t\t\t\tget() {\n\t\t\t\t\t\treturn accessor.value;\n\t\t\t\t\t},\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",
|
|
75
|
+
"import { createQuery, type QueryHostTarget } from '../../helpers/create-query';\nimport type { QueryConfig } from '../query';\n\nexport function query(options: QueryConfig) {\n\treturn function <T extends QueryHostTarget, V extends Element | Element[]>(\n\t\ttarget: undefined,\n\t\tcontext: ClassFieldDecoratorContext<T, V>,\n\t) {\n\t\tvoid target;\n\t\tconst propertyName = String(context.name);\n\n\t\tcontext.addInitializer(function (this: T) {\n\t\t\tconst accessor = createQuery<V>(this, options);\n\n\t\t\tObject.defineProperty(this, propertyName, {\n\t\t\t\tget() {\n\t\t\t\t\treturn accessor.value;\n\t\t\t\t},\n\t\t\t\tenumerable: true,\n\t\t\t\tconfigurable: true,\n\t\t\t});\n\t\t});\n\t};\n}\n",
|
|
76
|
+
"import type { QueryConfig, QueryScope } from '../helpers/create-query';\nimport { query as legacyQuery } from './legacy/query';\nimport { query as standardQuery } from './standard/query';\nimport { fieldDecoratorBridge } from './bridge';\n\nexport type { QueryConfig, QueryScope };\n\ntype QueryDecoratorHost = (Element | { host: Element }) & {\n\tregisterConnectedCallback(callback: () => void): void;\n};\n\n/**\n * A decorator to query by CSS selector or data-ref attribute.\n * By default it queries for the first element that matches the selector, but it can be configured to query for all elements.\n * It caches the result only when `cache` is enabled.\n * Queries run against the host light DOM by default, but can be directed to the shadow root or both trees.\n * @param options {@link QueryConfig} The options for the reactive property.\n */\nexport function query<T extends Element | Element[]>(options: QueryConfig) {\n\tfunction decorator<Host extends QueryDecoratorHost>(\n\t\tprotoOrTarget: undefined,\n\t\tnameOrContext: ClassFieldDecoratorContext<Host, T>,\n\t): void;\n\tfunction decorator(protoOrTarget: QueryDecoratorHost, nameOrContext: string): void;\n\tfunction decorator(\n\t\tprotoOrTarget: QueryDecoratorHost | undefined,\n\t\tnameOrContext: string | ClassFieldDecoratorContext<QueryDecoratorHost, T>,\n\t): void {\n\t\treturn fieldDecoratorBridge(standardQuery(options), legacyQuery<T>(options), protoOrTarget, nameOrContext);\n\t}\n\n\treturn decorator;\n}\n",
|
|
77
|
+
"export type QuerySlotConfig = {\n\tall?: boolean;\n\tcache?: boolean;\n\tname?: string;\n};\n\ntype SlotQueryHost = HTMLElement & {\n\tgetSlotElement<T extends Element = Element>(name?: string): T | null;\n\tgetSlotElements<T extends Element = Element>(name?: string): T[];\n};\n\ntype QuerySlotResult<T extends Element | Element[]> = {\n\tget value(): T | null;\n};\n\n/**\n * Creates a lazy slot query accessor bound to a host element.\n * Functional equivalent of the `@querySlot` decorator for vanilla JS usage.\n * @param host The host element to query slots within.\n * @param options {@link QuerySlotConfig} The slot query configuration.\n */\nexport function createQuerySlot<T extends Element | Element[] = Element>(\n\thost: SlotQueryHost,\n\toptions: QuerySlotConfig = {},\n): QuerySlotResult<T> {\n\tlet cached: T | null = null;\n\tlet cachedVersion: number | undefined;\n\n\tconst executeQuery = (): T | null => {\n\t\tif (options.all) {\n\t\t\treturn (typeof host.getSlotElements === 'function' ? host.getSlotElements(options.name) : []) as T;\n\t\t}\n\t\treturn (typeof host.getSlotElement === 'function' ? host.getSlotElement(options.name) : null) as T | null;\n\t};\n\n\treturn {\n\t\tget value(): T | null {\n\t\t\tif (options.cache === false) {\n\t\t\t\treturn executeQuery();\n\t\t\t}\n\n\t\t\tconst currentVersion = (host as unknown as Record<string, number | undefined>).slotProjectionVersion ?? 0;\n\n\t\t\tif (cachedVersion !== currentVersion) {\n\t\t\t\tcached = executeQuery();\n\t\t\t\tcachedVersion = currentVersion;\n\t\t\t}\n\n\t\t\treturn cached;\n\t\t},\n\t};\n}\n",
|
|
78
|
+
"import type { RadiantElement } from '../../core/radiant-element';\nimport { createQuerySlot } from '../../helpers/create-query-slot';\nimport { registerSsrPreparationCallback } from '../../core/ssr-preparation';\nimport type { QuerySlotConfig } from '../query-slot';\nimport { registerLegacyInstanceInitializer } from './instance-initializers';\n\ntype SlotQueryHost = RadiantElement & {\n\tgetSlotElement<T extends Element = Element>(name?: string): T | null;\n\tgetSlotElements<T extends Element = Element>(name?: string): T[];\n\tslotProjectionVersion?: number;\n};\n\nexport function querySlot<T extends Element | Element[]>(\n\toptions: QuerySlotConfig = {},\n): (proto: RadiantElement, propertyName: string | symbol) => void {\n\treturn (proto: RadiantElement, propertyKey: string | symbol) => {\n\t\tconst hasDefinedInstanceQuery = (instance: SlotQueryHost) => {\n\t\t\tconst descriptor = Object.getOwnPropertyDescriptor(instance, propertyKey);\n\t\t\treturn typeof descriptor?.get === 'function';\n\t\t};\n\n\t\tconst defineSlotQueryProperty = (instance: SlotQueryHost) => {\n\t\t\tif (hasDefinedInstanceQuery(instance)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst accessor = createQuerySlot<T>(instance, options);\n\n\t\t\tObject.defineProperty(instance, propertyKey, {\n\t\t\t\tget() {\n\t\t\t\t\treturn accessor.value;\n\t\t\t\t},\n\t\t\t\tenumerable: true,\n\t\t\t\tconfigurable: true,\n\t\t\t});\n\t\t};\n\n\t\tconst protoAccessorCache = new WeakMap<SlotQueryHost, ReturnType<typeof createQuerySlot<T>>>();\n\n\t\tObject.defineProperty(proto, propertyKey, {\n\t\t\tget(this: SlotQueryHost) {\n\t\t\t\tlet accessor = protoAccessorCache.get(this);\n\t\t\t\tif (!accessor) {\n\t\t\t\t\taccessor = createQuerySlot<T>(this, options);\n\t\t\t\t\tprotoAccessorCache.set(this, accessor);\n\t\t\t\t}\n\t\t\t\treturn accessor.value;\n\t\t\t},\n\t\t\tenumerable: true,\n\t\t\tconfigurable: true,\n\t\t});\n\n\t\tregisterLegacyInstanceInitializer(proto, (element) => {\n\t\t\tregisterSsrPreparationCallback(element, () => {\n\t\t\t\tdefineSlotQueryProperty(element as SlotQueryHost);\n\t\t\t});\n\t\t\telement.registerConnectedCallback(() => {\n\t\t\t\tdefineSlotQueryProperty(element as SlotQueryHost);\n\t\t\t});\n\t\t});\n\t};\n}\n",
|
|
79
|
+
"import { createQuerySlot } from '../../helpers/create-query-slot';\nimport type { QuerySlotConfig } from '../query-slot';\n\ntype SlotQueryHost = HTMLElement & {\n\tgetSlotElement<T extends Element = Element>(name?: string): T | null;\n\tgetSlotElements<T extends Element = Element>(name?: string): T[];\n\tslotProjectionVersion?: number;\n};\n\nexport function querySlot(options: QuerySlotConfig = {}) {\n\treturn function <T extends SlotQueryHost, V extends Element | Element[]>(\n\t\ttarget: undefined,\n\t\tcontext: ClassFieldDecoratorContext<T, V>,\n\t) {\n\t\tvoid target;\n\t\tconst propertyName = String(context.name);\n\n\t\tcontext.addInitializer(function (this: T) {\n\t\t\tconst accessor = createQuerySlot<V>(this, options);\n\n\t\t\tObject.defineProperty(this, propertyName, {\n\t\t\t\tget() {\n\t\t\t\t\treturn accessor.value;\n\t\t\t\t},\n\t\t\t\tenumerable: true,\n\t\t\t\tconfigurable: true,\n\t\t\t});\n\t\t});\n\t};\n}\n",
|
|
80
|
+
"import type { QuerySlotConfig } from '../helpers/create-query-slot';\nimport type { RadiantElement } from '../core/radiant-element';\nimport { querySlot as legacyQuerySlot } from './legacy/query-slot';\nimport { querySlot as standardQuerySlot } from './standard/query-slot';\nimport { fieldDecoratorBridge } from './bridge';\n\nexport type { QuerySlotConfig };\n\ntype SlotQueryHost = HTMLElement & {\n\tgetSlotElement<T extends Element = Element>(name?: string): T | null;\n\tgetSlotElements<T extends Element = Element>(name?: string): T[];\n\tslotProjectionVersion?: number;\n};\n\n/**\n * Queries projected light-DOM content assigned to a RadiantElement slot.\n *\n * The decorator returns assigned elements from the default slot when `name` is\n * omitted, or from the named slot when `name` is provided. Results are cached\n * by default and automatically invalidated when slot projection changes.\n *\n * @param options Slot query options.\n */\nexport function querySlot<T extends Element | Element[]>(options: QuerySlotConfig = {}) {\n\tfunction decorator<THost extends SlotQueryHost>(\n\t\tprotoOrTarget: undefined,\n\t\tnameOrContext: ClassFieldDecoratorContext<THost, T>,\n\t): void;\n\tfunction decorator(protoOrTarget: RadiantElement, nameOrContext: string): void;\n\tfunction decorator(\n\t\tprotoOrTarget: RadiantElement | undefined,\n\t\tnameOrContext: string | ClassFieldDecoratorContext<SlotQueryHost, T>,\n\t): void {\n\t\treturn fieldDecoratorBridge(\n\t\t\tstandardQuerySlot(options),\n\t\t\tlegacyQuerySlot<T>(options),\n\t\t\tprotoOrTarget,\n\t\t\tnameOrContext,\n\t\t);\n\t}\n\n\treturn decorator;\n}\n",
|
|
81
|
+
"import { createHydrationScriptTag, escapeHydrationJson } from '../core/hydration-codec';\n\n/** Creates the raw `<script type=\"application/json\">` tag used to hydrate a signal field. */\nexport function createSignalHydrationScriptTag(options: { hydrationKey?: string; serializedValue: string }): string {\n\treturn createHydrationScriptTag({ type: 'signal', ...options });\n}\n\n/** Escapes serialized JSON so it remains safe inside an HTML script tag. */\nexport function escapeSignalHydrationJson(value: string): string {\n\treturn escapeHydrationJson(value);\n}\n",
|
|
82
|
+
"import { createMarkupNodeLike, type JsxRenderable } from '@ecopages/jsx';\nimport { state, type WritableSignal } from '@ecopages/signals';\nimport type { SsrSerializableHydrationBinding } from '../core/ssr-hydration-binding';\nimport type { AttributeTypeConstant } from '../utils/attribute-utils';\nimport { findHydrationScript, parseHydrationPayload } from '../core/hydration-codec';\nimport { createSignalHydrationScriptTag, escapeSignalHydrationJson } from './hydration-script';\n\ntype HostSignalOwner = {\n\tnotifyUpdate(property: string, oldValue: unknown, value: unknown): void;\n};\n\ntype HostSignalOptions<Value> = {\n\thost: HostSignalOwner;\n\thydrate?: AttributeTypeConstant;\n\thydrationKey?: string;\n\tinitialValue?: Value;\n\tproperty: string;\n\tsource?: WritableSignal<Value>;\n};\n\nexport function isWritableSignalLike<Value>(value: unknown): value is WritableSignal<Value> {\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\ttypeof (value as WritableSignal<Value>).get === 'function' &&\n\t\ttypeof (value as WritableSignal<Value>).set === 'function' &&\n\t\ttypeof (value as WritableSignal<Value>).subscribe === 'function' &&\n\t\ttypeof (value as WritableSignal<Value>).update === 'function'\n\t);\n}\n\n/**\n * Host-owned writable signal that bridges signal updates back into Radiant's\n * update callback channel and optional SSR hydration pipeline.\n */\nexport class HostSignal<Value> implements WritableSignal<Value>, SsrSerializableHydrationBinding {\n\tprivate readonly host: HostSignalOwner;\n\tprivate readonly hydrate?: AttributeTypeConstant;\n\tprivate readonly hydrationKey?: string;\n\tprivate readonly property: string;\n\tprivate readonly source: WritableSignal<Value>;\n\tprivate currentValue: Value;\n\tprivate hasAppliedHostHydration = false;\n\tprivate sourceUnsubscribe?: () => void;\n\n\tconstructor(options: HostSignalOptions<Value>) {\n\t\tthis.host = options.host;\n\t\tthis.hydrate = options.hydrate;\n\t\tthis.hydrationKey = options.hydrationKey;\n\t\tthis.property = options.property;\n\t\tthis.source = options.source ?? state(this.resolveInitialValue(options.initialValue as Value));\n\t\tthis.currentValue = this.source.get();\n\t}\n\n\tpublic get(): Value {\n\t\treturn this.source.get();\n\t}\n\n\tpublic set(nextValue: Value): void {\n\t\tthis.source.set(nextValue);\n\t}\n\n\tpublic subscribe(notify: (value: Value) => void): () => void {\n\t\treturn this.source.subscribe(notify);\n\t}\n\n\tpublic update(updater: (value: Value) => Value): void {\n\t\tthis.set(updater(this.get()));\n\t}\n\n\tpublic connectToSource(): void {\n\t\tif (this.sourceUnsubscribe) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst nextValue = this.source.get();\n\n\t\tif (!Object.is(this.currentValue, nextValue)) {\n\t\t\tconst previousValue = this.currentValue;\n\t\t\tthis.currentValue = nextValue;\n\t\t\tthis.host.notifyUpdate(this.property, previousValue, nextValue);\n\t\t}\n\n\t\tthis.sourceUnsubscribe = this.source.subscribe((value) => {\n\t\t\tthis.handleSourceChange(value);\n\t\t});\n\t}\n\n\tpublic disconnectFromSource(): void {\n\t\tthis.sourceUnsubscribe?.();\n\t\tthis.sourceUnsubscribe = undefined;\n\t}\n\n\tpublic hydrateFromHost(): void {\n\t\tif (!this.hydrate || this.hasAppliedHostHydration) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.hasAppliedHostHydration = true;\n\n\t\tconst previousValue = this.source.get();\n\t\tconst hydratedValue = this.resolveInitialValue(previousValue);\n\n\t\tif (!Object.is(previousValue, hydratedValue)) {\n\t\t\tthis.source.set(hydratedValue);\n\t\t\tthis.currentValue = this.source.get();\n\t\t\tthis.host.notifyUpdate(this.property, previousValue, this.currentValue);\n\t\t}\n\t}\n\n\tpublic renderHydrationScript(): JsxRenderable | undefined {\n\t\tconst outerHTML = this.renderHydrationScriptTag();\n\n\t\tif (!outerHTML) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn createMarkupNodeLike(outerHTML);\n\t}\n\n\tpublic renderHydrationScriptTag(): string | undefined {\n\t\tconst serializedValue = this.serializeHydrationValue();\n\n\t\tif (!serializedValue) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn createSignalHydrationScriptTag({\n\t\t\thydrationKey: this.hydrationKey,\n\t\t\tserializedValue,\n\t\t});\n\t}\n\n\tprivate findHydrationScriptElement(): Element | null {\n\t\tif (!(this.host instanceof Element)) {\n\t\t\treturn null;\n\t\t}\n\n\t\treturn findHydrationScript(this.host, 'signal', this.hydrationKey);\n\t}\n\n\tprivate isObject(value: unknown): value is Record<string, unknown> {\n\t\treturn typeof value === 'object' && !Array.isArray(value) && value !== null;\n\t}\n\n\tprivate resolveInitialValue(initialValue: Value): Value {\n\t\tif (!this.hydrate) {\n\t\t\treturn initialValue;\n\t\t}\n\n\t\tconst hydrationScriptElement = this.findHydrationScriptElement();\n\n\t\tif (!hydrationScriptElement) {\n\t\t\treturn initialValue;\n\t\t}\n\n\t\tconst parsedHydrationValue = parseHydrationPayload(hydrationScriptElement, initialValue);\n\n\t\tif (this.hydrate === Object && this.isObject(parsedHydrationValue) && this.isObject(initialValue)) {\n\t\t\treturn {\n\t\t\t\t...initialValue,\n\t\t\t\t...parsedHydrationValue,\n\t\t\t} as Value;\n\t\t}\n\n\t\treturn parsedHydrationValue;\n\t}\n\n\tprivate serializeHydrationValue(): string | undefined {\n\t\tif (!this.hydrate) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst serializedValue = JSON.stringify(this.get());\n\n\t\tif (typeof serializedValue !== 'string') {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn escapeSignalHydrationJson(serializedValue);\n\t}\n\n\tprivate handleSourceChange(nextValue: Value): void {\n\t\tconst previousValue = this.currentValue;\n\t\tthis.currentValue = nextValue;\n\n\t\tif (!Object.is(previousValue, nextValue)) {\n\t\t\tthis.host.notifyUpdate(this.property, previousValue, nextValue);\n\t\t}\n\t}\n}\n\nexport function createHostSignal<Value>(options: HostSignalOptions<Value>): HostSignal<Value> {\n\treturn new HostSignal(options);\n}\n",
|
|
83
|
+
"import type { ReactiveBindingOption } from '../../core/radiant-element';\nimport type { ReactiveHostLike } from '../../core/reactive-host';\nimport { createHostSignal, HostSignal, isWritableSignalLike } from '../../signals/host-signal';\nimport { registerLegacyInstanceInitializer } from './instance-initializers';\nimport type { AttributeTypeConstant } from '../../utils/attribute-utils';\nimport type { WritableSignal } from '@ecopages/signals';\n\nexport type SignalDecoratorOptions<Value = unknown> = {\n\tbind?: ReactiveBindingOption;\n\tinitial?: Value;\n\tsource?: WritableSignal<Value> | ((host: ReactiveHostLike) => WritableSignal<Value>);\n\thydrate?: AttributeTypeConstant;\n};\n\nexport function signal<Value = unknown>(options: SignalDecoratorOptions<Value> = {}) {\n\treturn (target: ReactiveHostLike, propertyName: string) => {\n\t\tconst initializeSignal = (element: ReactiveHostLike): HostSignal<unknown> => {\n\t\t\tconst currentValue = element[propertyName as keyof typeof element] as unknown;\n\n\t\t\tif (currentValue instanceof HostSignal) {\n\t\t\t\treturn currentValue;\n\t\t\t}\n\n\t\t\tconst resolvedSource =\n\t\t\t\ttypeof options.source === 'function'\n\t\t\t\t\t? options.source(element)\n\t\t\t\t\t: (options.source ?? (isWritableSignalLike(currentValue) ? currentValue : undefined));\n\n\t\t\tconst bind =\n\t\t\t\toptions.bind ??\n\t\t\t\t(\n\t\t\t\t\telement as unknown as { shouldAutoBindReactiveMembers?: () => boolean }\n\t\t\t\t).shouldAutoBindReactiveMembers?.() ??\n\t\t\t\tfalse;\n\n\t\t\tconst resolvedInitialValue =\n\t\t\t\tresolvedSource !== undefined\n\t\t\t\t\t? options.initial\n\t\t\t\t\t: ((currentValue === undefined ? options.initial : currentValue) as Value);\n\t\t\telement.defineReactiveBinding(propertyName, bind);\n\n\t\t\tconst hostSignal = createHostSignal({\n\t\t\t\thost: element,\n\t\t\t\thydrate: options.hydrate,\n\t\t\t\thydrationKey: propertyName,\n\t\t\t\tinitialValue: resolvedInitialValue,\n\t\t\t\tproperty: propertyName,\n\t\t\t\tsource: resolvedSource,\n\t\t\t});\n\n\t\t\telement.registerConnectedCallback(() => {\n\t\t\t\thostSignal.hydrateFromHost();\n\t\t\t\thostSignal.connectToSource();\n\t\t\t});\n\t\t\telement.registerCleanupCallback(() => {\n\t\t\t\thostSignal.disconnectFromSource();\n\t\t\t});\n\n\t\t\tif (options.hydrate) {\n\t\t\t\telement.registerHydrationBinding(propertyName, hostSignal);\n\t\t\t}\n\n\t\t\t(element as unknown as Record<string, unknown>)[propertyName] = hostSignal;\n\t\t\treturn hostSignal as unknown as HostSignal<unknown>;\n\t\t};\n\n\t\tregisterLegacyInstanceInitializer(target, (element) => {\n\t\t\tconst hostSignal = initializeSignal(element);\n\t\t\telement.registerConnectedCallback(() => {\n\t\t\t\tif (!((element as any)[propertyName] instanceof HostSignal)) {\n\t\t\t\t\t(element as unknown as Record<string, unknown>)[propertyName] = hostSignal;\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t};\n}\n",
|
|
84
|
+
"import type { WritableSignal } from '@ecopages/signals';\nimport type { ReactiveBindingOption } from '../../core/radiant-element';\nimport type { ReactiveHostLike } from '../../core/reactive-host';\nimport { createHostSignal, isWritableSignalLike } from '../../signals/host-signal';\nimport type { AttributeTypeConstant } from '../../utils/attribute-utils';\n\n/** Options for the `@signal` decorator. */\nexport type SignalDecoratorOptions<Value = unknown> = {\n\t/**\n\t * Exposes a JSX binding companion for the decorated signal.\n\t *\n\t * - `true` creates a `$propertyName` accessor.\n\t * - a string creates a custom accessor with that name.\n\t * - `undefined` defers to the host default.\n\t */\n\tbind?: ReactiveBindingOption;\n\n\t/**\n\t * Optional initial value used when the field does not provide one directly.\n\t *\n\t * This is primarily useful with `declare field: WritableSignal<T>` syntax,\n\t * which keeps the component surface clean while still letting the decorator\n\t * own signal construction.\n\t */\n\tinitial?: Value;\n\n\t/**\n\t * Connects an existing writable signal to the host instead of creating a\n\t * host-owned one.\n\t */\n\tsource?: WritableSignal<Value> | ((host: ReactiveHostLike) => WritableSignal<Value>);\n\n\t/**\n\t * Serializes the current signal value into a keyed hydration script during\n\t * SSR and restores it on the client.\n\t */\n\thydrate?: AttributeTypeConstant;\n};\n\nexport function signal<Value = unknown>(options: SignalDecoratorOptions<Value> = {}) {\n\treturn function <T extends ReactiveHostLike, Value>(_: undefined, context: ClassFieldDecoratorContext<T, unknown>) {\n\t\tconst propertyName = String(context.name);\n\n\t\treturn function (this: T, initialValue: Value | WritableSignal<Value>) {\n\t\t\tconst resolvedSource =\n\t\t\t\ttypeof options.source === 'function'\n\t\t\t\t\t? options.source(this)\n\t\t\t\t\t: (options.source ?? (isWritableSignalLike<Value>(initialValue) ? initialValue : undefined));\n\t\t\tconst resolvedInitialValue =\n\t\t\t\tresolvedSource !== undefined\n\t\t\t\t\t? options.initial\n\t\t\t\t\t: ((initialValue === undefined ? options.initial : initialValue) as Value);\n\t\t\tconst bind =\n\t\t\t\toptions.bind ??\n\t\t\t\t(\n\t\t\t\t\tthis as unknown as { shouldAutoBindReactiveMembers?: () => boolean }\n\t\t\t\t).shouldAutoBindReactiveMembers?.() ??\n\t\t\t\tfalse;\n\n\t\t\tthis.defineReactiveBinding(propertyName, bind);\n\n\t\t\tconst hostSignal = createHostSignal({\n\t\t\t\thost: this,\n\t\t\t\thydrate: options.hydrate,\n\t\t\t\thydrationKey: propertyName,\n\t\t\t\tinitialValue: resolvedInitialValue,\n\t\t\t\tproperty: propertyName,\n\t\t\t\tsource: resolvedSource,\n\t\t\t});\n\n\t\t\tthis.registerConnectedCallback(() => {\n\t\t\t\thostSignal.hydrateFromHost();\n\t\t\t\thostSignal.connectToSource();\n\t\t\t});\n\t\t\tthis.registerCleanupCallback(() => {\n\t\t\t\thostSignal.disconnectFromSource();\n\t\t\t});\n\n\t\t\tif (options.hydrate) {\n\t\t\t\tthis.registerHydrationBinding(propertyName, hostSignal);\n\t\t\t}\n\n\t\t\treturn hostSignal as unknown as WritableSignal<Value>;\n\t\t};\n\t};\n}\n",
|
|
85
|
+
"import type { LegacyFieldDecoratorArgs } from '../types';\nimport type { ReactiveHostLike } from '../core/reactive-host';\nimport { signal as legacySignal, type SignalDecoratorOptions } from './legacy/signal';\nimport { signal as standardSignal } from './standard/signal';\nimport type { WritableSignal } from '@ecopages/signals';\n\nexport type { SignalDecoratorOptions } from './standard/signal';\n\ntype SignalDecorator<Value = unknown> = {\n\t<THost extends ReactiveHostLike>(\n\t\tprotoOrTarget: undefined,\n\t\tnameOrContext: ClassFieldDecoratorContext<THost, WritableSignal<Value>>,\n\t): (this: THost, initialValue: Value | WritableSignal<Value>) => WritableSignal<Value>;\n\t(protoOrTarget: ReactiveHostLike, nameOrContext: string): void;\n};\n\n/**\n * Declares a host-aware writable signal field.\n *\n * The decorated member becomes a real `WritableSignal` instance that JSX can\n * consume directly in child or attribute positions. By default the decorator\n * creates a host-owned signal, but it can also connect an existing shared\n * signal through the `source` option or a signal-valued field initializer.\n *\n * Connected signals still flow through Radiant's update callback channel so\n * `@onUpdated(...)` and `this.$.name` bindings continue to work. On\n * `RadiantElement`, any signal or store reads performed during `render()`\n * now participate in rerender invalidation directly, which makes module-level\n * shared stores a natural fit without prop-bridging them through a second\n * reactive layer.\n *\n * When `hydrate` is provided, SSR host output appends a keyed JSON script so\n * the client can restore the signal's initial value during hydration.\n */\nexport function signal<THost extends ReactiveHostLike, Value>(\n\tprotoOrTarget: undefined,\n\tnameOrContext: ClassFieldDecoratorContext<THost, WritableSignal<Value>>,\n): (this: THost, initialValue: Value | WritableSignal<Value>) => WritableSignal<Value>;\nexport function signal(protoOrTarget: ReactiveHostLike, nameOrContext: string): void;\nexport function signal<Value = unknown>(options?: SignalDecoratorOptions<Value>): SignalDecorator<Value>;\nexport function signal<Value = unknown>(\n\tprotoOrOptions?: ReactiveHostLike | SignalDecoratorOptions<Value>,\n\tnameOrContext?: string | ClassFieldDecoratorContext<ReactiveHostLike, WritableSignal<Value>>,\n):\n\t| ((this: ReactiveHostLike, initialValue: Value | WritableSignal<Value>) => WritableSignal<Value>)\n\t| SignalDecorator<Value>\n\t| void {\n\tif (typeof nameOrContext !== 'undefined') {\n\t\tif (typeof nameOrContext === 'object') {\n\t\t\tif (protoOrOptions !== undefined) {\n\t\t\t\tthrow new TypeError('@signal standard decorators require an undefined target');\n\t\t\t}\n\n\t\t\treturn standardSignal<Value>()(undefined, nameOrContext);\n\t\t}\n\n\t\tif (protoOrOptions === undefined) {\n\t\t\tthrow new TypeError('@signal legacy decorators require a host target');\n\t\t}\n\n\t\treturn legacySignal<Value>()(protoOrOptions as LegacyFieldDecoratorArgs['protoOrTarget'], nameOrContext);\n\t}\n\n\tconst options = (protoOrOptions ?? {}) as SignalDecoratorOptions<Value>;\n\n\tfunction decorator<THost extends ReactiveHostLike>(\n\t\tprotoOrTarget: undefined,\n\t\tcontextOrName: ClassFieldDecoratorContext<THost, WritableSignal<Value>>,\n\t): (this: THost, initialValue: Value | WritableSignal<Value>) => WritableSignal<Value>;\n\tfunction decorator(protoOrTarget: ReactiveHostLike, contextOrName: string): void;\n\tfunction decorator(\n\t\tprotoOrTarget: ReactiveHostLike | undefined,\n\t\tcontextOrName: string | ClassFieldDecoratorContext<ReactiveHostLike, WritableSignal<Value>>,\n\t): ((this: ReactiveHostLike, initialValue: Value | WritableSignal<Value>) => WritableSignal<Value>) | void {\n\t\tif (typeof contextOrName === 'object') {\n\t\t\tif (protoOrTarget !== undefined) {\n\t\t\t\tthrow new TypeError('@signal standard decorators require an undefined target');\n\t\t\t}\n\n\t\t\treturn standardSignal<Value>(options)(undefined, contextOrName);\n\t\t}\n\n\t\tif (protoOrTarget === undefined) {\n\t\t\tthrow new TypeError('@signal legacy decorators require a host target');\n\t\t}\n\n\t\treturn legacySignal<Value>(options)(protoOrTarget as LegacyFieldDecoratorArgs['protoOrTarget'], contextOrName);\n\t}\n\n\treturn decorator;\n}\n",
|
|
86
|
+
"import type { ReactiveHostLike } from '../../core/reactive-host';\nimport { registerLegacyInstanceInitializer } from './instance-initializers';\n\n/**\n * A decorator to define a reactive field.\n * Every time the property changes, the `updated` method will be called.\n * Due the fact the value is always undefined before the first update,\n * we are adding a `isDefined` WeakSet to track if the property has been defined.\n * @param target The target element.\n * @param propertyKey The property key.\n */\nexport function reactiveField(target: ReactiveHostLike, propertyKey: string) {\n\tregisterLegacyInstanceInitializer(target, (element) => {\n\t\telement.registerConnectedCallback(() => {\n\t\t\telement.createReactiveField(propertyKey, element[propertyKey as keyof typeof element], {\n\t\t\t\tbind:\n\t\t\t\t\t(\n\t\t\t\t\t\telement as unknown as { shouldAutoBindReactiveMembers?: () => boolean }\n\t\t\t\t\t).shouldAutoBindReactiveMembers?.() ?? false,\n\t\t\t});\n\t\t});\n\t});\n}\n",
|
|
87
|
+
"import type { ReactiveHostLike } from '../../core/reactive-host';\n\nexport function reactiveField<T extends ReactiveHostLike, V>(_: undefined, context: ClassFieldDecoratorContext<T, V>) {\n\tconst privatePropertyKey = Symbol(`__${String(context.name)}__value`);\n\n\tconst contextName = String(context.name);\n\n\tcontext.addInitializer(function (this: T) {\n\t\tthis.defineReactiveBinding(\n\t\t\tcontextName,\n\t\t\t(this as unknown as { shouldAutoBindReactiveMembers?: () => boolean }).shouldAutoBindReactiveMembers?.() ??\n\t\t\t\tfalse,\n\t\t);\n\t\tthis.registerReactiveDependencyReader(\n\t\t\tcontextName,\n\t\t\t() => (this as unknown as Record<PropertyKey, unknown>)[privatePropertyKey],\n\t\t);\n\n\t\tObject.defineProperty(this, context.name, {\n\t\t\tget() {\n\t\t\t\t(this as ReactiveHostLike).trackReactiveRead(contextName);\n\t\t\t\treturn (this as unknown as Record<PropertyKey, unknown>)[privatePropertyKey];\n\t\t\t},\n\t\t\tset(newValue: unknown) {\n\t\t\t\tconst oldValue = (this as unknown as Record<PropertyKey, unknown>)[privatePropertyKey];\n\t\t\t\tif (oldValue !== newValue) {\n\t\t\t\t\t(this as unknown as Record<PropertyKey, unknown>)[privatePropertyKey] = newValue;\n\t\t\t\t\t(this as ReactiveHostLike).notifyUpdate(contextName, oldValue, newValue);\n\t\t\t\t}\n\t\t\t},\n\t\t\tenumerable: true,\n\t\t\tconfigurable: true,\n\t\t});\n\t});\n\n\treturn function (this: T, value: V) {\n\t\t(this as any)[privatePropertyKey] = value;\n\t\treturn value;\n\t};\n}\n",
|
|
88
|
+
"import type { ReactiveHostLike } from '../core/reactive-host';\nimport { reactiveField as legacyReactiveField } from './legacy/reactive-field';\nimport { reactiveField as standardReactiveField } from './standard/reactive-field';\nimport { fieldDecoratorBridge } from './bridge';\n\n/**\n * Declares internal mutable component state.\n *\n * Each write triggers `notifyUpdate` so update callbacks, bindings, and\n * `RadiantElement` renders stay in sync. When no explicit binding option\n * is supplied, `RadiantElement` hosts expose a JSX companion binding\n * accessor automatically while plain imperative hosts keep binding\n * opt-in.\n */\nexport function state<THost extends ReactiveHostLike, TValue>(\n\tprotoOrTarget: undefined,\n\tnameOrContext: ClassFieldDecoratorContext<THost, TValue>,\n): (this: THost, value: TValue) => TValue;\nexport function state(protoOrTarget: ReactiveHostLike, nameOrContext: string): void;\nexport function state(\n\tprotoOrTarget: ReactiveHostLike | undefined,\n\tnameOrContext: string | ClassFieldDecoratorContext<ReactiveHostLike, unknown>,\n): ((this: ReactiveHostLike, value: unknown) => unknown) | void {\n\treturn fieldDecoratorBridge(standardReactiveField, legacyReactiveField, protoOrTarget, nameOrContext);\n}\n"
|
|
5
89
|
],
|
|
6
|
-
"mappings": "",
|
|
7
|
-
"debugId": "
|
|
90
|
+
"mappings": "4PAE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