@askrjs/askr 0.0.27 → 0.0.29
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 +55 -147
- package/dist/_virtual/_rolldown/runtime.js +7 -0
- package/dist/bench/components/benchmark-row.d.ts +20 -0
- package/dist/bench/components/benchmark-row.d.ts.map +1 -0
- package/dist/bench/components/benchmark-row.js +42 -0
- package/dist/bench/components/benchmark-row.js.map +1 -0
- package/dist/bench/components/benchmark-table.js +25 -0
- package/dist/bench/components/benchmark-table.js.map +1 -0
- package/dist/benchmark.d.ts +22 -0
- package/dist/benchmark.d.ts.map +1 -0
- package/dist/benchmark.js +64 -1
- package/dist/benchmark.js.map +1 -0
- package/dist/bin/askr-ssg.d.ts +28 -0
- package/dist/bin/askr-ssg.d.ts.map +1 -0
- package/dist/bin/askr-ssg.js +171 -0
- package/dist/bin/askr-ssg.js.map +1 -0
- package/dist/boot/index.d.ts +64 -42
- package/dist/boot/index.d.ts.map +1 -1
- package/dist/boot/index.js +416 -2
- package/dist/boot/index.js.map +1 -0
- package/dist/common/component.d.ts +14 -13
- package/dist/common/component.d.ts.map +1 -1
- package/dist/common/control.d.ts +13 -0
- package/dist/common/control.d.ts.map +1 -0
- package/dist/common/control.js +14 -0
- package/dist/common/control.js.map +1 -0
- package/dist/common/env.js +47 -0
- package/dist/common/env.js.map +1 -0
- package/dist/common/jsx.d.ts +17 -15
- package/dist/common/jsx.d.ts.map +1 -1
- package/dist/common/jsx.js +8 -1
- package/dist/common/jsx.js.map +1 -0
- package/dist/common/props.d.ts +14 -11
- package/dist/common/props.d.ts.map +1 -1
- package/dist/common/router.d.ts +190 -32
- package/dist/common/router.d.ts.map +1 -1
- package/dist/common/ssr-errors.d.ts +6 -3
- package/dist/common/ssr-errors.d.ts.map +1 -1
- package/dist/common/ssr-errors.js +16 -1
- package/dist/common/ssr-errors.js.map +1 -0
- package/dist/common/ssr.d.ts +12 -9
- package/dist/common/ssr.d.ts.map +1 -1
- package/dist/common/vnode.d.ts +17 -15
- package/dist/common/vnode.d.ts.map +1 -1
- package/dist/common/vnode.js +10 -1
- package/dist/common/vnode.js.map +1 -0
- package/dist/components/link.d.ts +37 -25
- package/dist/components/link.d.ts.map +1 -1
- package/dist/components/link.js +64 -1
- package/dist/components/link.js.map +1 -0
- package/dist/control/case.d.ts +17 -0
- package/dist/control/case.d.ts.map +1 -0
- package/dist/control/case.js +69 -0
- package/dist/control/case.js.map +1 -0
- package/dist/control/for.d.ts +23 -0
- package/dist/control/for.d.ts.map +1 -0
- package/dist/control/for.js +62 -0
- package/dist/control/for.js.map +1 -0
- package/dist/control/index.d.ts +4 -0
- package/dist/control/index.js +4 -0
- package/dist/control/shared.js +20 -0
- package/dist/control/shared.js.map +1 -0
- package/dist/control/show.d.ts +14 -0
- package/dist/control/show.d.ts.map +1 -0
- package/dist/control/show.js +33 -0
- package/dist/control/show.js.map +1 -0
- package/dist/dev/invariant.js +29 -2
- package/dist/dev/invariant.js.map +1 -0
- package/dist/dev/logger.js +37 -1
- package/dist/dev/logger.js.map +1 -0
- package/dist/foundations/icon/icon.d.ts +53 -0
- package/dist/foundations/icon/icon.d.ts.map +1 -0
- package/dist/foundations/icon/icon.js +88 -0
- package/dist/foundations/icon/icon.js.map +1 -0
- package/dist/foundations/icon/icon.types.d.ts +21 -0
- package/dist/foundations/icon/icon.types.d.ts.map +1 -0
- package/dist/foundations/index.d.ts +10 -3
- package/dist/foundations/index.js +9 -1
- package/dist/foundations/interactions/interaction-policy.js +93 -1
- package/dist/foundations/interactions/interaction-policy.js.map +1 -0
- package/dist/foundations/interactions/pressable.js +51 -1
- package/dist/foundations/interactions/pressable.js.map +1 -0
- package/dist/foundations/structures/collection.d.ts +25 -40
- package/dist/foundations/structures/collection.d.ts.map +1 -1
- package/dist/foundations/structures/collection.js +51 -1
- package/dist/foundations/structures/collection.js.map +1 -0
- package/dist/foundations/structures/layer.d.ts +47 -68
- package/dist/foundations/structures/layer.d.ts.map +1 -1
- package/dist/foundations/structures/layer.js +81 -1
- package/dist/foundations/structures/layer.js.map +1 -0
- package/dist/foundations/structures/layout.d.ts +6 -3
- package/dist/foundations/structures/layout.d.ts.map +1 -1
- package/dist/foundations/structures/layout.js +13 -1
- package/dist/foundations/structures/layout.js.map +1 -0
- package/dist/foundations/structures/portal.d.ts +17 -10
- package/dist/foundations/structures/portal.d.ts.map +1 -1
- package/dist/foundations/structures/portal.js +105 -1
- package/dist/foundations/structures/portal.js.map +1 -0
- package/dist/foundations/structures/presence.d.ts +11 -5
- package/dist/foundations/structures/presence.d.ts.map +1 -1
- package/dist/foundations/structures/presence.js +39 -1
- package/dist/foundations/structures/presence.js.map +1 -0
- package/dist/foundations/structures/slot.d.ts +11 -8
- package/dist/foundations/structures/slot.d.ts.map +1 -1
- package/dist/foundations/structures/slot.js +41 -1
- package/dist/foundations/structures/slot.js.map +1 -0
- package/dist/foundations/structures.d.ts +7 -14
- package/dist/foundations/structures.js +6 -1
- package/dist/foundations/utilities/aria.js +11 -1
- package/dist/foundations/utilities/aria.js.map +1 -0
- package/dist/foundations/utilities/compose-handlers.js +20 -1
- package/dist/foundations/utilities/compose-handlers.js.map +1 -0
- package/dist/foundations/utilities/compose-ref.d.ts +7 -4
- package/dist/foundations/utilities/compose-ref.d.ts.map +1 -1
- package/dist/foundations/utilities/compose-ref.js +18 -1
- package/dist/foundations/utilities/compose-ref.js.map +1 -0
- package/dist/foundations/utilities/merge-props.js +49 -1
- package/dist/foundations/utilities/merge-props.js.map +1 -0
- package/dist/fx/fx.d.ts +24 -21
- package/dist/fx/fx.d.ts.map +1 -1
- package/dist/fx/fx.js +212 -1
- package/dist/fx/fx.js.map +1 -0
- package/dist/fx/index.d.ts +4 -7
- package/dist/fx/index.js +4 -1
- package/dist/fx/noop.js +9 -1
- package/dist/fx/noop.js.map +1 -0
- package/dist/fx/timing.d.ts +24 -21
- package/dist/fx/timing.d.ts.map +1 -1
- package/dist/fx/timing.js +236 -1
- package/dist/fx/timing.js.map +1 -0
- package/dist/index.d.ts +21 -20
- package/dist/index.js +34 -1
- package/dist/index.js.map +1 -0
- package/dist/jsx/index.d.ts +1 -4
- package/dist/jsx/index.js +3 -1
- package/dist/jsx/types.d.ts +18 -25
- package/dist/jsx/types.d.ts.map +1 -1
- package/dist/jsx/types.js +1 -1
- package/dist/jsx/utils.d.ts +4 -3
- package/dist/jsx/utils.d.ts.map +1 -1
- package/dist/jsx/utils.js +19 -1
- package/dist/jsx/utils.js.map +1 -0
- package/dist/jsx-dev-runtime.d.ts +8 -0
- package/dist/jsx-dev-runtime.d.ts.map +1 -0
- package/dist/jsx-dev-runtime.js +32 -1
- package/dist/jsx-dev-runtime.js.map +1 -0
- package/dist/jsx-runtime.d.ts +12 -0
- package/dist/jsx-runtime.d.ts.map +1 -0
- package/dist/jsx-runtime.js +45 -1
- package/dist/jsx-runtime.js.map +1 -0
- package/dist/jsx-runtime2.d.ts +2 -0
- package/dist/jsx-runtime2.js +3 -0
- package/dist/renderer/children.js +293 -0
- package/dist/renderer/children.js.map +1 -0
- package/dist/renderer/cleanup.js +150 -1
- package/dist/renderer/cleanup.js.map +1 -0
- package/dist/renderer/dom.js +2439 -1
- package/dist/renderer/dom.js.map +1 -0
- package/dist/renderer/env.js +1 -0
- package/dist/renderer/evaluate.js +450 -1
- package/dist/renderer/evaluate.js.map +1 -0
- package/dist/renderer/fastpath.js +145 -1
- package/dist/renderer/fastpath.js.map +1 -0
- package/dist/renderer/index.js +24 -1
- package/dist/renderer/index.js.map +1 -0
- package/dist/renderer/keyed.js +119 -1
- package/dist/renderer/keyed.js.map +1 -0
- package/dist/renderer/reconcile.js +359 -1
- package/dist/renderer/reconcile.js.map +1 -0
- package/dist/renderer/types.js +1 -1
- package/dist/renderer/utils.js +220 -1
- package/dist/renderer/utils.js.map +1 -0
- package/dist/resources/index.d.ts +3 -9
- package/dist/resources/index.js +3 -1
- package/dist/router/index.d.ts +6 -10
- package/dist/router/index.js +5 -1
- package/dist/router/match.js +83 -1
- package/dist/router/match.js.map +1 -0
- package/dist/router/navigate.d.ts +20 -8
- package/dist/router/navigate.d.ts.map +1 -1
- package/dist/router/navigate.js +288 -1
- package/dist/router/navigate.js.map +1 -0
- package/dist/router/policy.d.ts +22 -0
- package/dist/router/policy.d.ts.map +1 -0
- package/dist/router/policy.js +116 -0
- package/dist/router/policy.js.map +1 -0
- package/dist/router/route-context.js +79 -0
- package/dist/router/route-context.js.map +1 -0
- package/dist/router/route.d.ts +101 -33
- package/dist/router/route.d.ts.map +1 -1
- package/dist/router/route.js +599 -1
- package/dist/router/route.js.map +1 -0
- package/dist/runtime/child-scope.d.ts +21 -0
- package/dist/runtime/child-scope.d.ts.map +1 -0
- package/dist/runtime/child-scope.js +77 -0
- package/dist/runtime/child-scope.js.map +1 -0
- package/dist/runtime/component.d.ts +67 -53
- package/dist/runtime/component.d.ts.map +1 -1
- package/dist/runtime/component.js +462 -1
- package/dist/runtime/component.js.map +1 -0
- package/dist/runtime/context.d.ts +28 -42
- package/dist/runtime/context.d.ts.map +1 -1
- package/dist/runtime/context.js +205 -1
- package/dist/runtime/context.js.map +1 -0
- package/dist/runtime/control.d.ts +43 -0
- package/dist/runtime/control.d.ts.map +1 -0
- package/dist/runtime/control.js +125 -0
- package/dist/runtime/control.js.map +1 -0
- package/dist/runtime/derive.d.ts +15 -6
- package/dist/runtime/derive.d.ts.map +1 -1
- package/dist/runtime/derive.js +134 -1
- package/dist/runtime/derive.js.map +1 -0
- package/dist/runtime/dev-namespace.js +57 -1
- package/dist/runtime/dev-namespace.js.map +1 -0
- package/dist/runtime/effect.d.ts +32 -0
- package/dist/runtime/effect.d.ts.map +1 -0
- package/dist/runtime/effect.js +146 -0
- package/dist/runtime/effect.js.map +1 -0
- package/dist/runtime/events.js +162 -1
- package/dist/runtime/events.js.map +1 -0
- package/dist/runtime/execution-model.js +15 -1
- package/dist/runtime/execution-model.js.map +1 -0
- package/dist/runtime/fastlane.js +204 -1
- package/dist/runtime/fastlane.js.map +1 -0
- package/dist/runtime/for-bench.d.ts +41 -0
- package/dist/runtime/for-bench.d.ts.map +1 -0
- package/dist/runtime/for-bench.js +173 -0
- package/dist/runtime/for-bench.js.map +1 -0
- package/dist/runtime/for.d.ts +62 -49
- package/dist/runtime/for.d.ts.map +1 -1
- package/dist/runtime/for.js +668 -1
- package/dist/runtime/for.js.map +1 -0
- package/dist/runtime/operations.d.ts +18 -15
- package/dist/runtime/operations.d.ts.map +1 -1
- package/dist/runtime/operations.js +209 -1
- package/dist/runtime/operations.js.map +1 -0
- package/dist/runtime/perf-metrics.js +64 -0
- package/dist/runtime/perf-metrics.js.map +1 -0
- package/dist/runtime/readable.d.ts +27 -0
- package/dist/runtime/readable.d.ts.map +1 -0
- package/dist/runtime/readable.js +118 -0
- package/dist/runtime/readable.js.map +1 -0
- package/dist/runtime/resource-cell.js +102 -1
- package/dist/runtime/resource-cell.js.map +1 -0
- package/dist/runtime/scheduler.d.ts +51 -35
- package/dist/runtime/scheduler.d.ts.map +1 -1
- package/dist/runtime/scheduler.js +328 -1
- package/dist/runtime/scheduler.js.map +1 -0
- package/dist/runtime/selector.d.ts +11 -0
- package/dist/runtime/selector.d.ts.map +1 -0
- package/dist/runtime/selector.js +188 -0
- package/dist/runtime/selector.js.map +1 -0
- package/dist/runtime/ssr-bridge.js +24 -1
- package/dist/runtime/ssr-bridge.js.map +1 -0
- package/dist/runtime/state.d.ts +11 -21
- package/dist/runtime/state.d.ts.map +1 -1
- package/dist/runtime/state.js +99 -1
- package/dist/runtime/state.js.map +1 -0
- package/dist/ssg/batch-render.d.ts +16 -0
- package/dist/ssg/batch-render.d.ts.map +1 -0
- package/dist/ssg/batch-render.js +84 -0
- package/dist/ssg/batch-render.js.map +1 -0
- package/dist/ssg/create-static-gen.d.ts +50 -0
- package/dist/ssg/create-static-gen.d.ts.map +1 -0
- package/dist/ssg/create-static-gen.js +282 -0
- package/dist/ssg/create-static-gen.js.map +1 -0
- package/dist/ssg/generate-metadata.d.ts +24 -0
- package/dist/ssg/generate-metadata.d.ts.map +1 -0
- package/dist/ssg/generate-metadata.js +94 -0
- package/dist/ssg/generate-metadata.js.map +1 -0
- package/dist/ssg/incremental-manifest.js +56 -0
- package/dist/ssg/incremental-manifest.js.map +1 -0
- package/dist/ssg/index.d.ts +8 -0
- package/dist/ssg/index.js +7 -0
- package/dist/ssg/resolve-ssg-data.d.ts +23 -0
- package/dist/ssg/resolve-ssg-data.d.ts.map +1 -0
- package/dist/ssg/resolve-ssg-data.js +46 -0
- package/dist/ssg/resolve-ssg-data.js.map +1 -0
- package/dist/ssg/route-utils.d.ts +16 -0
- package/dist/ssg/route-utils.d.ts.map +1 -0
- package/dist/ssg/route-utils.js +24 -0
- package/dist/ssg/route-utils.js.map +1 -0
- package/dist/ssg/types.d.ts +177 -0
- package/dist/ssg/types.d.ts.map +1 -0
- package/dist/ssg/write-static-files.d.ts +15 -0
- package/dist/ssg/write-static-files.d.ts.map +1 -0
- package/dist/ssg/write-static-files.js +73 -0
- package/dist/ssg/write-static-files.js.map +1 -0
- package/dist/ssr/attrs.js +93 -1
- package/dist/ssr/attrs.js.map +1 -0
- package/dist/ssr/context.d.ts +31 -32
- package/dist/ssr/context.d.ts.map +1 -1
- package/dist/ssr/context.js +63 -1
- package/dist/ssr/context.js.map +1 -0
- package/dist/ssr/errors.d.ts +6 -4
- package/dist/ssr/errors.d.ts.map +1 -1
- package/dist/ssr/errors.js +4 -1
- package/dist/ssr/errors.js.map +1 -0
- package/dist/ssr/escape.js +153 -1
- package/dist/ssr/escape.js.map +1 -0
- package/dist/ssr/index.d.ts +75 -46
- package/dist/ssr/index.d.ts.map +1 -1
- package/dist/ssr/index.js +543 -1
- package/dist/ssr/index.js.map +1 -0
- package/dist/ssr/render-keys.d.ts +27 -29
- package/dist/ssr/render-keys.d.ts.map +1 -1
- package/dist/ssr/render-keys.js +39 -1
- package/dist/ssr/render-keys.js.map +1 -0
- package/dist/ssr/sink.js +86 -1
- package/dist/ssr/sink.js.map +1 -0
- package/dist/ssr/stream-render.js +76 -1
- package/dist/ssr/stream-render.js.map +1 -0
- package/dist/ssr/types.d.ts +14 -13
- package/dist/ssr/types.d.ts.map +1 -1
- package/package.json +53 -48
- package/dist/_virtual/___vite-browser-external.js +0 -1
- package/dist/_virtual/__vite-browser-external.js +0 -1
- package/dist/_virtual/_commonjsHelpers.js +0 -1
- package/dist/_virtual/main.js +0 -1
- package/dist/_virtual/preload-helper.js +0 -1
- package/dist/bench/benchmark-entry.d.ts +0 -14
- package/dist/bench/benchmark-entry.d.ts.map +0 -1
- package/dist/common/errors.d.ts +0 -53
- package/dist/common/errors.d.ts.map +0 -1
- package/dist/common/index.d.ts +0 -14
- package/dist/common/index.d.ts.map +0 -1
- package/dist/dev/invariant.d.ts +0 -83
- package/dist/dev/invariant.d.ts.map +0 -1
- package/dist/dev/logger.d.ts +0 -13
- package/dist/dev/logger.d.ts.map +0 -1
- package/dist/dev/vite-plugin-askr.d.ts +0 -18
- package/dist/dev/vite-plugin-askr.d.ts.map +0 -1
- package/dist/dev/warnings.d.ts +0 -5
- package/dist/dev/warnings.d.ts.map +0 -1
- package/dist/for/for.d.ts +0 -16
- package/dist/for/for.d.ts.map +0 -1
- package/dist/for/for.js +0 -1
- package/dist/for/index.d.ts +0 -2
- package/dist/for/index.d.ts.map +0 -1
- package/dist/for/index.js +0 -1
- package/dist/foundations/core.d.ts +0 -23
- package/dist/foundations/core.d.ts.map +0 -1
- package/dist/foundations/core.js +0 -1
- package/dist/foundations/index.d.ts.map +0 -1
- package/dist/foundations/interactions/dismissable.d.ts +0 -58
- package/dist/foundations/interactions/dismissable.d.ts.map +0 -1
- package/dist/foundations/interactions/dismissable.js +0 -1
- package/dist/foundations/interactions/focusable.d.ts +0 -16
- package/dist/foundations/interactions/focusable.d.ts.map +0 -1
- package/dist/foundations/interactions/focusable.js +0 -1
- package/dist/foundations/interactions/hoverable.d.ts +0 -19
- package/dist/foundations/interactions/hoverable.d.ts.map +0 -1
- package/dist/foundations/interactions/hoverable.js +0 -1
- package/dist/foundations/interactions/index.d.ts +0 -5
- package/dist/foundations/interactions/index.d.ts.map +0 -1
- package/dist/foundations/interactions/interaction-policy.d.ts +0 -96
- package/dist/foundations/interactions/interaction-policy.d.ts.map +0 -1
- package/dist/foundations/interactions/pressable.d.ts +0 -54
- package/dist/foundations/interactions/pressable.d.ts.map +0 -1
- package/dist/foundations/interactions/roving-focus.d.ts +0 -117
- package/dist/foundations/interactions/roving-focus.d.ts.map +0 -1
- package/dist/foundations/interactions/roving-focus.js +0 -1
- package/dist/foundations/state/controllable.d.ts +0 -53
- package/dist/foundations/state/controllable.d.ts.map +0 -1
- package/dist/foundations/state/controllable.js +0 -1
- package/dist/foundations/state/index.d.ts +0 -2
- package/dist/foundations/state/index.d.ts.map +0 -1
- package/dist/foundations/structures/index.d.ts +0 -5
- package/dist/foundations/structures/index.d.ts.map +0 -1
- package/dist/foundations/structures.d.ts.map +0 -1
- package/dist/foundations/utilities/aria.d.ts +0 -13
- package/dist/foundations/utilities/aria.d.ts.map +0 -1
- package/dist/foundations/utilities/compose-handlers.d.ts +0 -34
- package/dist/foundations/utilities/compose-handlers.d.ts.map +0 -1
- package/dist/foundations/utilities/event-types.d.ts +0 -17
- package/dist/foundations/utilities/event-types.d.ts.map +0 -1
- package/dist/foundations/utilities/index.d.ts +0 -7
- package/dist/foundations/utilities/index.d.ts.map +0 -1
- package/dist/foundations/utilities/merge-props.d.ts +0 -2
- package/dist/foundations/utilities/merge-props.d.ts.map +0 -1
- package/dist/foundations/utilities/use-id.d.ts +0 -29
- package/dist/foundations/utilities/use-id.d.ts.map +0 -1
- package/dist/foundations/utilities/use-id.js +0 -1
- package/dist/fx/index.d.ts.map +0 -1
- package/dist/fx/noop.d.ts +0 -12
- package/dist/fx/noop.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/jsx/index.d.ts.map +0 -1
- package/dist/jsx/jsx-dev-runtime.d.ts +0 -4
- package/dist/jsx/jsx-dev-runtime.d.ts.map +0 -1
- package/dist/jsx/jsx-runtime.d.ts +0 -10
- package/dist/jsx/jsx-runtime.d.ts.map +0 -1
- package/dist/node_modules/esbuild/lib/main.js +0 -65
- package/dist/renderer/cleanup.d.ts +0 -25
- package/dist/renderer/cleanup.d.ts.map +0 -1
- package/dist/renderer/dom.d.ts +0 -62
- package/dist/renderer/dom.d.ts.map +0 -1
- package/dist/renderer/evaluate.d.ts +0 -4
- package/dist/renderer/evaluate.d.ts.map +0 -1
- package/dist/renderer/fastpath.d.ts +0 -7
- package/dist/renderer/fastpath.d.ts.map +0 -1
- package/dist/renderer/index.d.ts +0 -6
- package/dist/renderer/index.d.ts.map +0 -1
- package/dist/renderer/keyed.d.ts +0 -23
- package/dist/renderer/keyed.d.ts.map +0 -1
- package/dist/renderer/reconcile.d.ts +0 -88
- package/dist/renderer/reconcile.d.ts.map +0 -1
- package/dist/renderer/types.d.ts +0 -3
- package/dist/renderer/types.d.ts.map +0 -1
- package/dist/renderer/utils.d.ts +0 -63
- package/dist/renderer/utils.d.ts.map +0 -1
- package/dist/resources/index.d.ts.map +0 -1
- package/dist/router/index.d.ts.map +0 -1
- package/dist/router/match.d.ts +0 -22
- package/dist/router/match.d.ts.map +0 -1
- package/dist/runtime/dev-namespace.d.ts +0 -31
- package/dist/runtime/dev-namespace.d.ts.map +0 -1
- package/dist/runtime/events.d.ts +0 -52
- package/dist/runtime/events.d.ts.map +0 -1
- package/dist/runtime/execution-model.d.ts +0 -4
- package/dist/runtime/execution-model.d.ts.map +0 -1
- package/dist/runtime/fastlane.d.ts +0 -27
- package/dist/runtime/fastlane.d.ts.map +0 -1
- package/dist/runtime/hydration.d.ts +0 -25
- package/dist/runtime/hydration.d.ts.map +0 -1
- package/dist/runtime/resource-cell.d.ts +0 -35
- package/dist/runtime/resource-cell.d.ts.map +0 -1
- package/dist/runtime/snapshot.d.ts +0 -25
- package/dist/runtime/snapshot.d.ts.map +0 -1
- package/dist/runtime/ssr-bridge.d.ts +0 -10
- package/dist/runtime/ssr-bridge.d.ts.map +0 -1
- package/dist/ssr/attrs.d.ts +0 -26
- package/dist/ssr/attrs.d.ts.map +0 -1
- package/dist/ssr/create-ssr.d.ts +0 -19
- package/dist/ssr/create-ssr.d.ts.map +0 -1
- package/dist/ssr/escape.d.ts +0 -38
- package/dist/ssr/escape.d.ts.map +0 -1
- package/dist/ssr/sink.d.ts +0 -23
- package/dist/ssr/sink.d.ts.map +0 -1
- package/dist/ssr/stream-render.d.ts +0 -7
- package/dist/ssr/stream-render.d.ts.map +0 -1
- package/dist/vite/index.js +0 -3
package/dist/dev/logger.js
CHANGED
|
@@ -1 +1,37 @@
|
|
|
1
|
-
|
|
1
|
+
import { isProductionEnvironment } from "../common/env.js";
|
|
2
|
+
//#region src/dev/logger.ts
|
|
3
|
+
/**
|
|
4
|
+
* Centralized logger interface
|
|
5
|
+
* - Keeps production builds silent for debug/warn/info messages
|
|
6
|
+
* - Ensures consistent behavior across the codebase
|
|
7
|
+
* - Protects against missing `console` in some environments
|
|
8
|
+
*/
|
|
9
|
+
function callConsole(method, args) {
|
|
10
|
+
const c = typeof console !== "undefined" ? console : void 0;
|
|
11
|
+
if (!c) return;
|
|
12
|
+
const fn = c[method];
|
|
13
|
+
if (typeof fn === "function") try {
|
|
14
|
+
fn.apply(console, args);
|
|
15
|
+
} catch {}
|
|
16
|
+
}
|
|
17
|
+
const logger = {
|
|
18
|
+
debug: (...args) => {
|
|
19
|
+
if (isProductionEnvironment()) return;
|
|
20
|
+
callConsole("debug", args);
|
|
21
|
+
},
|
|
22
|
+
info: (...args) => {
|
|
23
|
+
if (isProductionEnvironment()) return;
|
|
24
|
+
callConsole("info", args);
|
|
25
|
+
},
|
|
26
|
+
warn: (...args) => {
|
|
27
|
+
if (isProductionEnvironment()) return;
|
|
28
|
+
callConsole("warn", args);
|
|
29
|
+
},
|
|
30
|
+
error: (...args) => {
|
|
31
|
+
callConsole("error", args);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
//#endregion
|
|
35
|
+
export { logger };
|
|
36
|
+
|
|
37
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","names":[],"sources":["../../src/dev/logger.ts"],"sourcesContent":["/**\n * Centralized logger interface\n * - Keeps production builds silent for debug/warn/info messages\n * - Ensures consistent behavior across the codebase\n * - Protects against missing `console` in some environments\n */\n\nimport { isProductionEnvironment } from '../common/env';\n\nfunction callConsole(method: string, args: unknown[]): void {\n const c = typeof console !== 'undefined' ? (console as unknown) : undefined;\n if (!c) return;\n const fn = (c as Record<string, unknown>)[method];\n if (typeof fn === 'function') {\n try {\n (fn as (...a: unknown[]) => unknown).apply(console, args as unknown[]);\n } catch {\n // ignore logging errors\n }\n }\n}\n\nexport const logger = {\n debug: (...args: unknown[]) => {\n if (isProductionEnvironment()) return;\n callConsole('debug', args);\n },\n\n info: (...args: unknown[]) => {\n if (isProductionEnvironment()) return;\n callConsole('info', args);\n },\n\n warn: (...args: unknown[]) => {\n if (isProductionEnvironment()) return;\n callConsole('warn', args);\n },\n\n error: (...args: unknown[]) => {\n callConsole('error', args);\n },\n};\n"],"mappings":";;;;;;;;AASA,SAAS,YAAY,QAAgB,MAAuB;CAC1D,MAAM,IAAI,OAAO,YAAY,cAAe,UAAsB;AAClE,KAAI,CAAC,EAAG;CACR,MAAM,KAAM,EAA8B;AAC1C,KAAI,OAAO,OAAO,WAChB,KAAI;AACD,KAAoC,MAAM,SAAS,KAAkB;SAChE;;AAMZ,MAAa,SAAS;CACpB,QAAQ,GAAG,SAAoB;AAC7B,MAAI,yBAAyB,CAAE;AAC/B,cAAY,SAAS,KAAK;;CAG5B,OAAO,GAAG,SAAoB;AAC5B,MAAI,yBAAyB,CAAE;AAC/B,cAAY,QAAQ,KAAK;;CAG3B,OAAO,GAAG,SAAoB;AAC5B,MAAI,yBAAyB,CAAE;AAC/B,cAAY,QAAQ,KAAK;;CAG3B,QAAQ,GAAG,SAAoB;AAC7B,cAAY,SAAS,KAAK;;CAE7B"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { JSXElement } from "../../common/jsx.js";
|
|
2
|
+
import { IconProps, IconSizeToken, IconStyleObject } from "./icon.types.js";
|
|
3
|
+
|
|
4
|
+
//#region src/foundations/icon/icon.d.ts
|
|
5
|
+
declare function isIconSizeToken(value: unknown): value is IconSizeToken;
|
|
6
|
+
declare function normalizeIconSizeValue(size: number | string): string;
|
|
7
|
+
declare function resolveIconSizeVariable(size: number | string): string;
|
|
8
|
+
declare function resolveIconStrokeWidthVariable(strokeWidth: number, sizeToken: IconSizeToken | undefined): string;
|
|
9
|
+
declare function serializeIconStyle(style: string | IconStyleObject | undefined): string;
|
|
10
|
+
declare function joinIconStyle(...styles: Array<string | undefined>): string | undefined;
|
|
11
|
+
declare function getIconContractProps({
|
|
12
|
+
size,
|
|
13
|
+
strokeWidth,
|
|
14
|
+
color,
|
|
15
|
+
title,
|
|
16
|
+
style,
|
|
17
|
+
iconName
|
|
18
|
+
}: Pick<IconProps, 'color' | 'iconName' | 'size' | 'strokeWidth' | 'style' | 'title'>): {
|
|
19
|
+
sizeToken: IconSizeToken | undefined;
|
|
20
|
+
decorative: string | undefined;
|
|
21
|
+
iconStyle: string | undefined;
|
|
22
|
+
attrs: {
|
|
23
|
+
xmlns: string;
|
|
24
|
+
width: string;
|
|
25
|
+
height: string;
|
|
26
|
+
fill: string;
|
|
27
|
+
stroke: string;
|
|
28
|
+
'stroke-width': string;
|
|
29
|
+
role: string;
|
|
30
|
+
'aria-hidden': string | undefined;
|
|
31
|
+
style: string | undefined;
|
|
32
|
+
'data-slot': string;
|
|
33
|
+
'data-icon': string | undefined;
|
|
34
|
+
'data-size': IconSizeToken | undefined;
|
|
35
|
+
'data-decorative': string | undefined;
|
|
36
|
+
'data-color': string | undefined;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
declare function IconBase({
|
|
40
|
+
size,
|
|
41
|
+
strokeWidth,
|
|
42
|
+
color,
|
|
43
|
+
title,
|
|
44
|
+
class: className,
|
|
45
|
+
style,
|
|
46
|
+
iconName,
|
|
47
|
+
children,
|
|
48
|
+
ref,
|
|
49
|
+
...rest
|
|
50
|
+
}: IconProps): JSXElement;
|
|
51
|
+
//#endregion
|
|
52
|
+
export { IconBase, getIconContractProps, isIconSizeToken, joinIconStyle, normalizeIconSizeValue, resolveIconSizeVariable, resolveIconStrokeWidthVariable, serializeIconStyle };
|
|
53
|
+
//# sourceMappingURL=icon.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icon.d.ts","names":[],"sources":["../../../src/foundations/icon/icon.tsx"],"mappings":";;;;iBAMgB,eAAA,CAAgB,KAAA,YAAiB,KAAA,IAAS,aAAA;AAAA,iBAO1C,sBAAA,CAAuB,IAAA;AAAA,iBAKvB,uBAAA,CAAwB,IAAA;AAAA,iBAOxB,8BAAA,CACd,WAAA,UACA,SAAA,EAAW,aAAA;AAAA,iBAYG,kBAAA,CACd,KAAA,WAAgB,eAAA;AAAA,iBAUF,aAAA,CAAA,GACX,MAAA,EAAQ,KAAA;AAAA,iBAMG,oBAAA,CAAA;EACd,IAAA;EACA,WAAA;EACA,KAAA;EACA,KAAA;EACA,KAAA;EACA;AAAA,GACC,IAAA,CACD,SAAA;;;;;;;;;;;;;;;;;;;;;iBA4Cc,QAAA,CAAA;EACd,IAAA;EACA,WAAA;EACA,KAAA;EACA,KAAA;EACA,KAAA,EAAO,SAAA;EACP,KAAA;EACA,QAAA;EACA,QAAA;EACA,GAAA;EAAA,GACG;AAAA,GACF,SAAA,GAAS,UAAA"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { jsx, jsxs } from "../../jsx-runtime.js";
|
|
2
|
+
//#region src/foundations/icon/icon.tsx
|
|
3
|
+
const ICON_SIZE_TOKENS = [
|
|
4
|
+
"sm",
|
|
5
|
+
"md",
|
|
6
|
+
"lg",
|
|
7
|
+
"xl"
|
|
8
|
+
];
|
|
9
|
+
function isIconSizeToken(value) {
|
|
10
|
+
return typeof value === "string" && ICON_SIZE_TOKENS.includes(value);
|
|
11
|
+
}
|
|
12
|
+
function normalizeIconSizeValue(size) {
|
|
13
|
+
if (typeof size === "number") return `${size}px`;
|
|
14
|
+
return size;
|
|
15
|
+
}
|
|
16
|
+
function resolveIconSizeVariable(size) {
|
|
17
|
+
if (isIconSizeToken(size)) return `var(--ak-icon-size-${size}, var(--ak-icon-size-md, 1.25rem))`;
|
|
18
|
+
return normalizeIconSizeValue(size);
|
|
19
|
+
}
|
|
20
|
+
function resolveIconStrokeWidthVariable(strokeWidth, sizeToken) {
|
|
21
|
+
if (sizeToken) return `var(--ak-icon-stroke-width-${sizeToken}, var(--ak-icon-stroke-width-md, ${strokeWidth}))`;
|
|
22
|
+
return `var(--ak-icon-stroke-width-md, ${strokeWidth})`;
|
|
23
|
+
}
|
|
24
|
+
function camelToKebab(key) {
|
|
25
|
+
return key.replace(/([A-Z])/g, (match) => `-${match.toLowerCase()}`);
|
|
26
|
+
}
|
|
27
|
+
function serializeIconStyle(style) {
|
|
28
|
+
if (!style) return "";
|
|
29
|
+
if (typeof style === "string") return style.trim();
|
|
30
|
+
return Object.entries(style).filter(([, value]) => value !== void 0 && value !== null).map(([key, value]) => `${camelToKebab(key)}:${String(value)}`).join(";");
|
|
31
|
+
}
|
|
32
|
+
function joinIconStyle(...styles) {
|
|
33
|
+
const merged = styles.map((style) => style?.trim()).filter(Boolean);
|
|
34
|
+
return merged.length > 0 ? merged.join(";") : void 0;
|
|
35
|
+
}
|
|
36
|
+
function getIconContractProps({ size = 20, strokeWidth = 2, color = "currentColor", title, style, iconName }) {
|
|
37
|
+
const sizeToken = isIconSizeToken(size) ? size : void 0;
|
|
38
|
+
const decorative = title ? void 0 : "true";
|
|
39
|
+
const resolvedSize = resolveIconSizeVariable(size);
|
|
40
|
+
const resolvedStrokeWidth = resolveIconStrokeWidthVariable(strokeWidth, sizeToken);
|
|
41
|
+
const iconStyle = joinIconStyle(`--ak-icon-size:${resolvedSize}`, `--ak-icon-stroke-width:${resolvedStrokeWidth}`, "display:inline-block", "flex-shrink:0", "width:var(--ak-icon-size)", "height:var(--ak-icon-size)", "stroke-width:var(--ak-icon-stroke-width)", serializeIconStyle(style));
|
|
42
|
+
return {
|
|
43
|
+
sizeToken,
|
|
44
|
+
decorative,
|
|
45
|
+
iconStyle,
|
|
46
|
+
attrs: {
|
|
47
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
48
|
+
width: "24",
|
|
49
|
+
height: "24",
|
|
50
|
+
fill: "none",
|
|
51
|
+
stroke: color,
|
|
52
|
+
"stroke-width": "var(--ak-icon-stroke-width)",
|
|
53
|
+
role: "img",
|
|
54
|
+
"aria-hidden": title ? void 0 : "true",
|
|
55
|
+
style: iconStyle,
|
|
56
|
+
"data-slot": "icon",
|
|
57
|
+
"data-icon": iconName,
|
|
58
|
+
"data-size": sizeToken,
|
|
59
|
+
"data-decorative": decorative,
|
|
60
|
+
"data-color": color === "currentColor" ? "current" : void 0
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function IconBase({ size = 20, strokeWidth = 2, color = "currentColor", title, class: className, style, iconName, children, ref, ...rest }) {
|
|
65
|
+
const { attrs } = getIconContractProps({
|
|
66
|
+
size,
|
|
67
|
+
strokeWidth,
|
|
68
|
+
color,
|
|
69
|
+
title,
|
|
70
|
+
style,
|
|
71
|
+
iconName
|
|
72
|
+
});
|
|
73
|
+
const finalChildren = title ? [jsx("title", { children: title }), children] : children;
|
|
74
|
+
return jsxs("svg", {
|
|
75
|
+
...rest,
|
|
76
|
+
...attrs,
|
|
77
|
+
viewBox: rest.viewBox ?? "0 0 24 24",
|
|
78
|
+
"stroke-linecap": rest["stroke-linecap"] ?? "round",
|
|
79
|
+
"stroke-linejoin": rest["stroke-linejoin"] ?? "round",
|
|
80
|
+
class: className,
|
|
81
|
+
ref,
|
|
82
|
+
children: finalChildren
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
//#endregion
|
|
86
|
+
export { IconBase, getIconContractProps, isIconSizeToken, joinIconStyle, normalizeIconSizeValue, resolveIconSizeVariable, resolveIconStrokeWidthVariable, serializeIconStyle };
|
|
87
|
+
|
|
88
|
+
//# sourceMappingURL=icon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icon.js","names":[],"sources":["../../../src/foundations/icon/icon.tsx"],"sourcesContent":["/* eslint-disable askr/no-hardcoded-theme-tokens -- Icon exposes a stable CSS variable contract consumed by themes. */\nimport { jsx, jsxs } from '../../jsx/jsx-runtime';\nimport type { IconProps, IconSizeToken, IconStyleObject } from './icon.types';\n\nconst ICON_SIZE_TOKENS: readonly IconSizeToken[] = ['sm', 'md', 'lg', 'xl'];\n\nexport function isIconSizeToken(value: unknown): value is IconSizeToken {\n return (\n typeof value === 'string' &&\n ICON_SIZE_TOKENS.includes(value as IconSizeToken)\n );\n}\n\nexport function normalizeIconSizeValue(size: number | string): string {\n if (typeof size === 'number') return `${size}px`;\n return size;\n}\n\nexport function resolveIconSizeVariable(size: number | string): string {\n if (isIconSizeToken(size)) {\n return `var(--ak-icon-size-${size}, var(--ak-icon-size-md, 1.25rem))`;\n }\n return normalizeIconSizeValue(size);\n}\n\nexport function resolveIconStrokeWidthVariable(\n strokeWidth: number,\n sizeToken: IconSizeToken | undefined\n): string {\n if (sizeToken) {\n return `var(--ak-icon-stroke-width-${sizeToken}, var(--ak-icon-stroke-width-md, ${strokeWidth}))`;\n }\n return `var(--ak-icon-stroke-width-md, ${strokeWidth})`;\n}\n\nfunction camelToKebab(key: string): string {\n return key.replace(/([A-Z])/g, (match) => `-${match.toLowerCase()}`);\n}\n\nexport function serializeIconStyle(\n style: string | IconStyleObject | undefined\n): string {\n if (!style) return '';\n if (typeof style === 'string') return style.trim();\n return Object.entries(style)\n .filter(([, value]) => value !== undefined && value !== null)\n .map(([key, value]) => `${camelToKebab(key)}:${String(value)}`)\n .join(';');\n}\n\nexport function joinIconStyle(\n ...styles: Array<string | undefined>\n): string | undefined {\n const merged = styles.map((style) => style?.trim()).filter(Boolean);\n return merged.length > 0 ? merged.join(';') : undefined;\n}\n\nexport function getIconContractProps({\n size = 20,\n strokeWidth = 2,\n color = 'currentColor',\n title,\n style,\n iconName,\n}: Pick<\n IconProps,\n 'color' | 'iconName' | 'size' | 'strokeWidth' | 'style' | 'title'\n>) {\n const sizeToken = isIconSizeToken(size) ? size : undefined;\n const decorative = title ? undefined : 'true';\n const resolvedSize = resolveIconSizeVariable(size);\n const resolvedStrokeWidth = resolveIconStrokeWidthVariable(\n strokeWidth,\n sizeToken\n );\n const iconStyle = joinIconStyle(\n `--ak-icon-size:${resolvedSize}`,\n `--ak-icon-stroke-width:${resolvedStrokeWidth}`,\n 'display:inline-block',\n 'flex-shrink:0',\n 'width:var(--ak-icon-size)',\n 'height:var(--ak-icon-size)',\n 'stroke-width:var(--ak-icon-stroke-width)',\n serializeIconStyle(style)\n );\n\n return {\n sizeToken,\n decorative,\n iconStyle,\n attrs: {\n xmlns: 'http://www.w3.org/2000/svg',\n width: '24',\n height: '24',\n fill: 'none',\n stroke: color,\n 'stroke-width': 'var(--ak-icon-stroke-width)',\n role: 'img',\n 'aria-hidden': title ? undefined : 'true',\n style: iconStyle,\n 'data-slot': 'icon',\n 'data-icon': iconName,\n 'data-size': sizeToken,\n 'data-decorative': decorative,\n 'data-color': color === 'currentColor' ? 'current' : undefined,\n },\n };\n}\n\nexport function IconBase({\n size = 20,\n strokeWidth = 2,\n color = 'currentColor',\n title,\n class: className,\n style,\n iconName,\n children,\n ref,\n ...rest\n}: IconProps) {\n const { attrs } = getIconContractProps({\n size,\n strokeWidth,\n color,\n title,\n style,\n iconName,\n });\n\n const finalChildren = title\n ? [jsx('title', { children: title }), children]\n : children;\n\n return jsxs('svg', {\n ...rest,\n ...attrs,\n viewBox: rest.viewBox ?? '0 0 24 24',\n 'stroke-linecap': rest['stroke-linecap'] ?? 'round',\n 'stroke-linejoin': rest['stroke-linejoin'] ?? 'round',\n class: className,\n ref,\n children: finalChildren,\n });\n}\n"],"mappings":";;AAIA,MAAM,mBAA6C;CAAC;CAAM;CAAM;CAAM;CAAK;AAE3E,SAAgB,gBAAgB,OAAwC;AACtE,QACE,OAAO,UAAU,YACjB,iBAAiB,SAAS,MAAuB;;AAIrD,SAAgB,uBAAuB,MAA+B;AACpE,KAAI,OAAO,SAAS,SAAU,QAAO,GAAG,KAAK;AAC7C,QAAO;;AAGT,SAAgB,wBAAwB,MAA+B;AACrE,KAAI,gBAAgB,KAAK,CACvB,QAAO,sBAAsB,KAAK;AAEpC,QAAO,uBAAuB,KAAK;;AAGrC,SAAgB,+BACd,aACA,WACQ;AACR,KAAI,UACF,QAAO,8BAA8B,UAAU,mCAAmC,YAAY;AAEhG,QAAO,kCAAkC,YAAY;;AAGvD,SAAS,aAAa,KAAqB;AACzC,QAAO,IAAI,QAAQ,aAAa,UAAU,IAAI,MAAM,aAAa,GAAG;;AAGtE,SAAgB,mBACd,OACQ;AACR,KAAI,CAAC,MAAO,QAAO;AACnB,KAAI,OAAO,UAAU,SAAU,QAAO,MAAM,MAAM;AAClD,QAAO,OAAO,QAAQ,MAAM,CACzB,QAAQ,GAAG,WAAW,UAAU,UAAa,UAAU,KAAK,CAC5D,KAAK,CAAC,KAAK,WAAW,GAAG,aAAa,IAAI,CAAC,GAAG,OAAO,MAAM,GAAG,CAC9D,KAAK,IAAI;;AAGd,SAAgB,cACd,GAAG,QACiB;CACpB,MAAM,SAAS,OAAO,KAAK,UAAU,OAAO,MAAM,CAAC,CAAC,OAAO,QAAQ;AACnE,QAAO,OAAO,SAAS,IAAI,OAAO,KAAK,IAAI,GAAG;;AAGhD,SAAgB,qBAAqB,EACnC,OAAO,IACP,cAAc,GACd,QAAQ,gBACR,OACA,OACA,YAIC;CACD,MAAM,YAAY,gBAAgB,KAAK,GAAG,OAAO;CACjD,MAAM,aAAa,QAAQ,SAAY;CACvC,MAAM,eAAe,wBAAwB,KAAK;CAClD,MAAM,sBAAsB,+BAC1B,aACA,UACD;CACD,MAAM,YAAY,cAChB,kBAAkB,gBAClB,0BAA0B,uBAC1B,wBACA,iBACA,6BACA,8BACA,4CACA,mBAAmB,MAAM,CAC1B;AAED,QAAO;EACL;EACA;EACA;EACA,OAAO;GACL,OAAO;GACP,OAAO;GACP,QAAQ;GACR,MAAM;GACN,QAAQ;GACR,gBAAgB;GAChB,MAAM;GACN,eAAe,QAAQ,SAAY;GACnC,OAAO;GACP,aAAa;GACb,aAAa;GACb,aAAa;GACb,mBAAmB;GACnB,cAAc,UAAU,iBAAiB,YAAY;GACtD;EACF;;AAGH,SAAgB,SAAS,EACvB,OAAO,IACP,cAAc,GACd,QAAQ,gBACR,OACA,OAAO,WACP,OACA,UACA,UACA,KACA,GAAG,QACS;CACZ,MAAM,EAAE,UAAU,qBAAqB;EACrC;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;CAEF,MAAM,gBAAgB,QAClB,CAAC,IAAI,SAAS,EAAE,UAAU,OAAO,CAAC,EAAE,SAAS,GAC7C;AAEJ,QAAO,KAAK,OAAO;EACjB,GAAG;EACH,GAAG;EACH,SAAS,KAAK,WAAW;EACzB,kBAAkB,KAAK,qBAAqB;EAC5C,mBAAmB,KAAK,sBAAsB;EAC9C,OAAO;EACP;EACA,UAAU;EACX,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Ref } from "../utilities/compose-ref.js";
|
|
2
|
+
|
|
3
|
+
//#region src/foundations/icon/icon.types.d.ts
|
|
4
|
+
type IconSizeToken = 'sm' | 'md' | 'lg' | 'xl';
|
|
5
|
+
type IconStyleObject = Record<string, unknown>;
|
|
6
|
+
type IconOwnProps = {
|
|
7
|
+
size?: number | string;
|
|
8
|
+
strokeWidth?: number;
|
|
9
|
+
color?: string;
|
|
10
|
+
title?: string;
|
|
11
|
+
class?: string;
|
|
12
|
+
style?: string | IconStyleObject;
|
|
13
|
+
iconName?: string;
|
|
14
|
+
};
|
|
15
|
+
type IconProps = Omit<JSX.IntrinsicElements['svg'], 'children' | 'class' | 'color' | 'height' | 'ref' | 'role' | 'stroke' | 'stroke-width' | 'style' | 'title' | 'width'> & IconOwnProps & {
|
|
16
|
+
children?: unknown;
|
|
17
|
+
ref?: Ref<SVGSVGElement>;
|
|
18
|
+
};
|
|
19
|
+
//#endregion
|
|
20
|
+
export { IconOwnProps, IconProps, IconSizeToken, IconStyleObject };
|
|
21
|
+
//# sourceMappingURL=icon.types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icon.types.d.ts","names":[],"sources":["../../../src/foundations/icon/icon.types.ts"],"mappings":";;;KAEY,aAAA;AAAA,KAEA,eAAA,GAAkB,MAAA;AAAA,KAElB,YAAA;EACV,IAAA;EACA,WAAA;EACA,KAAA;EACA,KAAA;EACA,KAAA;EACA,KAAA,YAAiB,eAAA;EACjB,QAAA;AAAA;AAAA,KAGU,SAAA,GAAY,IAAA,CACtB,GAAA,CAAI,iBAAA,iIAaJ,YAAA;EACE,QAAA;EACA,GAAA,GAAM,GAAA,CAAI,aAAA;AAAA"}
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { JSXElement } from "../common/jsx.js";
|
|
2
|
+
import { LayoutComponent, layout } from "./structures/layout.js";
|
|
3
|
+
import { Slot, SlotProps } from "./structures/slot.js";
|
|
4
|
+
import { Presence, PresenceProps } from "./structures/presence.js";
|
|
5
|
+
import { DefaultPortal, Portal, PortalProps, definePortal } from "./structures/portal.js";
|
|
6
|
+
import { Collection, CollectionItem, createCollection } from "./structures/collection.js";
|
|
7
|
+
import { Layer, LayerManager, LayerOptions, createLayer } from "./structures/layer.js";
|
|
8
|
+
import { IconOwnProps, IconProps, IconSizeToken, IconStyleObject } from "./icon/icon.types.js";
|
|
9
|
+
import { IconBase, getIconContractProps, isIconSizeToken, joinIconStyle, normalizeIconSizeValue, resolveIconSizeVariable, resolveIconStrokeWidthVariable, serializeIconStyle } from "./icon/icon.js";
|
|
10
|
+
export { Collection, CollectionItem, DefaultPortal, IconBase, type IconOwnProps, type IconProps, type IconSizeToken, type IconStyleObject, JSXElement, Layer, LayerManager, LayerOptions, LayoutComponent, Portal, PortalProps, Presence, PresenceProps, Slot, SlotProps, createCollection, createLayer, definePortal, getIconContractProps, isIconSizeToken, joinIconStyle, layout, normalizeIconSizeValue, resolveIconSizeVariable, resolveIconStrokeWidthVariable, serializeIconStyle };
|
|
@@ -1 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { DefaultPortal, Portal, definePortal } from "./structures/portal.js";
|
|
2
|
+
import { layout } from "./structures/layout.js";
|
|
3
|
+
import { Slot } from "./structures/slot.js";
|
|
4
|
+
import { Presence } from "./structures/presence.js";
|
|
5
|
+
import { createCollection } from "./structures/collection.js";
|
|
6
|
+
import { createLayer } from "./structures/layer.js";
|
|
7
|
+
import "./structures.js";
|
|
8
|
+
import { IconBase, getIconContractProps, isIconSizeToken, joinIconStyle, normalizeIconSizeValue, resolveIconSizeVariable, resolveIconStrokeWidthVariable, serializeIconStyle } from "./icon/icon.js";
|
|
9
|
+
export { DefaultPortal, IconBase, Portal, Presence, Slot, createCollection, createLayer, definePortal, getIconContractProps, isIconSizeToken, joinIconStyle, layout, normalizeIconSizeValue, resolveIconSizeVariable, resolveIconStrokeWidthVariable, serializeIconStyle };
|
|
@@ -1 +1,93 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import { pressable } from "./pressable.js";
|
|
2
|
+
import "../utilities/compose-handlers.js";
|
|
3
|
+
import "../utilities/compose-ref.js";
|
|
4
|
+
import "../utilities/merge-props.js";
|
|
5
|
+
//#region src/foundations/interactions/interaction-policy.ts
|
|
6
|
+
/**
|
|
7
|
+
* INTERACTION POLICY (FRAMEWORK LAW)
|
|
8
|
+
*
|
|
9
|
+
* This is THE ONLY way to create interactive elements. Components MUST NOT
|
|
10
|
+
* implement interaction logic directly.
|
|
11
|
+
*
|
|
12
|
+
* INVARIANTS (ENFORCED):
|
|
13
|
+
* 1. "Press" is the semantic. Click/touch/Enter/Space are implementation details.
|
|
14
|
+
* 2. Disabled is enforced exactly once, here. Components may not check disabled.
|
|
15
|
+
* 3. Keyboard handling is automatic. Components may not add onKeyDown for activation.
|
|
16
|
+
* 4. Native elements opt out of polyfills, not semantics.
|
|
17
|
+
* 5. asChild may replace the host element, not interaction behavior.
|
|
18
|
+
* 6. This policy is the SINGLE SOURCE OF TRUTH for interactive behavior.
|
|
19
|
+
*
|
|
20
|
+
* DESIGN:
|
|
21
|
+
* - Single public function: applyInteractionPolicy
|
|
22
|
+
* - Returns props that compose via mergeProps
|
|
23
|
+
* - Delegates to pressable for mechanics
|
|
24
|
+
* - Enforces disabled once and only once
|
|
25
|
+
* - No configuration beyond disabled and native element type
|
|
26
|
+
*
|
|
27
|
+
* PIT OF SUCCESS:
|
|
28
|
+
* ✓ Can't bypass policy (only way to get interaction behavior)
|
|
29
|
+
* ✓ Can't duplicate disabled checks (enforced once, here)
|
|
30
|
+
* ✓ Can't write custom keyboard handlers for buttons (policy owns it)
|
|
31
|
+
* ✓ Composes via mergeProps (standard props)
|
|
32
|
+
* ✓ Wrong usage is impossible (no escape hatch)
|
|
33
|
+
*
|
|
34
|
+
* USAGE:
|
|
35
|
+
* function Button({ onPress, disabled }) {
|
|
36
|
+
* const interaction = applyInteractionPolicy({
|
|
37
|
+
* isNative: true,
|
|
38
|
+
* disabled,
|
|
39
|
+
* onPress
|
|
40
|
+
* });
|
|
41
|
+
*
|
|
42
|
+
* return <button {...interaction}>Click me</button>;
|
|
43
|
+
* }
|
|
44
|
+
*
|
|
45
|
+
* MISUSE EXAMPLE (PREVENTED):
|
|
46
|
+
* ❌ Button checking disabled again:
|
|
47
|
+
* function Button({ disabled, onPress }) {
|
|
48
|
+
* if (disabled) return; // NO! Policy handles this
|
|
49
|
+
* const interaction = applyInteractionPolicy(...);
|
|
50
|
+
* }
|
|
51
|
+
*
|
|
52
|
+
* ❌ Custom keyboard handler:
|
|
53
|
+
* function Button({ onPress }) {
|
|
54
|
+
* const interaction = applyInteractionPolicy(...);
|
|
55
|
+
* return <button {...interaction} onKeyDown={...}>; // NO! Policy owns this
|
|
56
|
+
* }
|
|
57
|
+
*
|
|
58
|
+
* ❌ Direct event handler:
|
|
59
|
+
* <button onClick={onPress}>; // NO! Use applyInteractionPolicy
|
|
60
|
+
*/
|
|
61
|
+
/**
|
|
62
|
+
* THE interaction policy. Components MUST use this, NEVER implement
|
|
63
|
+
* interaction logic directly.
|
|
64
|
+
*/
|
|
65
|
+
function applyInteractionPolicy({ isNative, disabled, onPress, ref }) {
|
|
66
|
+
function invokePress(e) {
|
|
67
|
+
if (disabled) {
|
|
68
|
+
e.preventDefault?.();
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
onPress?.(e);
|
|
72
|
+
}
|
|
73
|
+
if (isNative) return {
|
|
74
|
+
disabled: disabled || void 0,
|
|
75
|
+
onClick: (e) => invokePress(e),
|
|
76
|
+
ref
|
|
77
|
+
};
|
|
78
|
+
const interaction = pressable({
|
|
79
|
+
disabled,
|
|
80
|
+
isNativeButton: false,
|
|
81
|
+
onPress: (e) => invokePress(e)
|
|
82
|
+
});
|
|
83
|
+
return {
|
|
84
|
+
...interaction,
|
|
85
|
+
"aria-disabled": disabled || void 0,
|
|
86
|
+
tabIndex: disabled ? -1 : interaction.tabIndex ?? 0,
|
|
87
|
+
ref
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
//#endregion
|
|
91
|
+
export { applyInteractionPolicy };
|
|
92
|
+
|
|
93
|
+
//# sourceMappingURL=interaction-policy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interaction-policy.js","names":["mergePropsBase"],"sources":["../../../src/foundations/interactions/interaction-policy.ts"],"sourcesContent":["/**\n * INTERACTION POLICY (FRAMEWORK LAW)\n *\n * This is THE ONLY way to create interactive elements. Components MUST NOT\n * implement interaction logic directly.\n *\n * INVARIANTS (ENFORCED):\n * 1. \"Press\" is the semantic. Click/touch/Enter/Space are implementation details.\n * 2. Disabled is enforced exactly once, here. Components may not check disabled.\n * 3. Keyboard handling is automatic. Components may not add onKeyDown for activation.\n * 4. Native elements opt out of polyfills, not semantics.\n * 5. asChild may replace the host element, not interaction behavior.\n * 6. This policy is the SINGLE SOURCE OF TRUTH for interactive behavior.\n *\n * DESIGN:\n * - Single public function: applyInteractionPolicy\n * - Returns props that compose via mergeProps\n * - Delegates to pressable for mechanics\n * - Enforces disabled once and only once\n * - No configuration beyond disabled and native element type\n *\n * PIT OF SUCCESS:\n * ✓ Can't bypass policy (only way to get interaction behavior)\n * ✓ Can't duplicate disabled checks (enforced once, here)\n * ✓ Can't write custom keyboard handlers for buttons (policy owns it)\n * ✓ Composes via mergeProps (standard props)\n * ✓ Wrong usage is impossible (no escape hatch)\n *\n * USAGE:\n * function Button({ onPress, disabled }) {\n * const interaction = applyInteractionPolicy({\n * isNative: true,\n * disabled,\n * onPress\n * });\n *\n * return <button {...interaction}>Click me</button>;\n * }\n *\n * MISUSE EXAMPLE (PREVENTED):\n * ❌ Button checking disabled again:\n * function Button({ disabled, onPress }) {\n * if (disabled) return; // NO! Policy handles this\n * const interaction = applyInteractionPolicy(...);\n * }\n *\n * ❌ Custom keyboard handler:\n * function Button({ onPress }) {\n * const interaction = applyInteractionPolicy(...);\n * return <button {...interaction} onKeyDown={...}>; // NO! Policy owns this\n * }\n *\n * ❌ Direct event handler:\n * <button onClick={onPress}>; // NO! Use applyInteractionPolicy\n */\n\nimport { pressable } from './pressable';\nimport { composeHandlers } from '../utilities/compose-handlers';\nimport { composeRefs, Ref } from '../utilities/compose-ref';\nimport { mergeProps as mergePropsBase } from '../utilities/merge-props';\n\nexport interface InteractionPolicyInput {\n /** Whether the host element is a native interactive element (button, a, etc) */\n isNative: boolean;\n /** Disabled state - checked ONLY here, never in components */\n disabled: boolean;\n /** User-provided press handler - semantic action, not DOM event */\n onPress?: (e: Event) => void;\n /** Optional ref to compose */\n ref?: Ref<unknown>;\n}\n\n/**\n * THE interaction policy. Components MUST use this, NEVER implement\n * interaction logic directly.\n */\nexport function applyInteractionPolicy({\n isNative,\n disabled,\n onPress,\n ref,\n}: InteractionPolicyInput) {\n // Disabled is enforced exactly once, here.\n // Components downstream may NOT check disabled.\n function invokePress(e: Event) {\n if (disabled) {\n e.preventDefault?.();\n return;\n }\n onPress?.(e);\n }\n\n if (isNative) {\n return {\n disabled: disabled || undefined,\n onClick: (e: Event) => invokePress(e),\n ref,\n };\n }\n\n // Non-native elements get full button semantics\n const interaction = pressable({\n disabled,\n isNativeButton: false,\n onPress: (e) => invokePress(e as Event),\n });\n\n return {\n ...interaction,\n 'aria-disabled': disabled || undefined,\n tabIndex: disabled ? -1 : (interaction.tabIndex ?? 0),\n ref,\n };\n}\n\n/**\n * Merge rule for Slot / asChild\n *\n * Precedence:\n * policy → user → child\n *\n * Event handlers are composed (policy first).\n * Refs are always composed.\n * Policy props MUST take precedence to enforce invariants.\n */\nexport function mergeInteractionProps(\n childProps: Record<string, unknown>,\n policyProps: Record<string, unknown>,\n userProps?: Record<string, unknown>\n) {\n let out = mergePropsBase(childProps, policyProps);\n if (userProps) out = mergePropsBase(out, userProps);\n\n // Ensure policy handlers always run first\n for (const k in out) {\n if (!k.startsWith('on')) continue;\n\n const policyHandler = policyProps?.[k];\n const userHandler = userProps?.[k];\n const childHandler = childProps?.[k];\n\n if (policyHandler || userHandler || childHandler) {\n const toHandler = (h: unknown) =>\n typeof h === 'function'\n ? (h as (...args: readonly unknown[]) => void)\n : undefined;\n\n out[k] = composeHandlers(\n toHandler(policyHandler),\n composeHandlers(toHandler(userHandler), toHandler(childHandler))\n );\n }\n }\n\n const childRef = childProps?.ref as Ref<unknown> | undefined;\n const userRef = userProps?.ref as Ref<unknown> | undefined;\n const policyRef = policyProps?.ref as Ref<unknown> | undefined;\n\n out.ref = composeRefs(childRef, userRef, policyRef);\n\n return out;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4EA,SAAgB,uBAAuB,EACrC,UACA,UACA,SACA,OACyB;CAGzB,SAAS,YAAY,GAAU;AAC7B,MAAI,UAAU;AACZ,KAAE,kBAAkB;AACpB;;AAEF,YAAU,EAAE;;AAGd,KAAI,SACF,QAAO;EACL,UAAU,YAAY;EACtB,UAAU,MAAa,YAAY,EAAE;EACrC;EACD;CAIH,MAAM,cAAc,UAAU;EAC5B;EACA,gBAAgB;EAChB,UAAU,MAAM,YAAY,EAAW;EACxC,CAAC;AAEF,QAAO;EACL,GAAG;EACH,iBAAiB,YAAY;EAC7B,UAAU,WAAW,KAAM,YAAY,YAAY;EACnD;EACD"}
|
|
@@ -1 +1,51 @@
|
|
|
1
|
-
import{ariaDisabled
|
|
1
|
+
import { ariaDisabled } from "../utilities/aria.js";
|
|
2
|
+
//#region src/foundations/interactions/pressable.ts
|
|
3
|
+
function pressable({ disabled, onPress, isNativeButton = false }) {
|
|
4
|
+
const props = { onClick: (e) => {
|
|
5
|
+
if (disabled) {
|
|
6
|
+
e.preventDefault?.();
|
|
7
|
+
e.stopPropagation?.();
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
onPress?.(e);
|
|
11
|
+
} };
|
|
12
|
+
if (isNativeButton) {
|
|
13
|
+
if (disabled) {
|
|
14
|
+
props.disabled = true;
|
|
15
|
+
Object.assign(props, ariaDisabled(disabled));
|
|
16
|
+
}
|
|
17
|
+
return props;
|
|
18
|
+
}
|
|
19
|
+
props.role = "button";
|
|
20
|
+
props.tabIndex = disabled ? -1 : 0;
|
|
21
|
+
props.onKeyDown = (e) => {
|
|
22
|
+
if (disabled) {
|
|
23
|
+
e.preventDefault?.();
|
|
24
|
+
e.stopPropagation?.();
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (e.key === "Enter") {
|
|
28
|
+
e.preventDefault?.();
|
|
29
|
+
onPress?.(e);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
if (e.key === " ") e.preventDefault?.();
|
|
33
|
+
};
|
|
34
|
+
props.onKeyUp = (e) => {
|
|
35
|
+
if (disabled) {
|
|
36
|
+
e.preventDefault?.();
|
|
37
|
+
e.stopPropagation?.();
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (e.key === " ") {
|
|
41
|
+
e.preventDefault?.();
|
|
42
|
+
onPress?.(e);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
if (disabled) Object.assign(props, ariaDisabled(disabled));
|
|
46
|
+
return props;
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
export { pressable };
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=pressable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pressable.js","names":[],"sources":["../../../src/foundations/interactions/pressable.ts"],"sourcesContent":["/**\n * pressable\n *\n * Interaction helper that produces VNode props for 'press' semantics.\n * - Pure and deterministic: no DOM construction or mutation here\n * - The runtime owns event attachment and scheduling\n * - This helper returns plain props (handlers) intended to be attached by the runtime\n *\n * Behaviour:\n * - For native buttons: only an `onClick` prop is provided (no ARIA or keyboard shims)\n * - For non-button elements: add `role=\"button\"` and `tabIndex` and keyboard handlers\n * - Activation: `Enter` activates on keydown, `Space` activates on keyup (matches native button)\n * - Disabled: handlers short-circuit and `aria-disabled` is set for all hosts\n *\n * POLICY DECISIONS (LOCKED):\n *\n * 1. Activation Timing (Platform Parity)\n * - Enter fires on keydown (immediate response)\n * - Space fires on keyup (allows cancel by moving focus, matches native)\n * - Space keydown prevents scroll (matches native button behavior)\n *\n * 2. Disabled Enforcement Strategy\n * - Native buttons: Use HTML `disabled` attribute (platform-enforced non-interactivity)\n * AND `aria-disabled` (consistent a11y signaling)\n * - Non-native: Use `tabIndex=-1` (removes from tab order)\n * AND `aria-disabled` (signals disabled state to AT)\n * - Click handler short-circuits as defense-in-depth (prevents leaked focus issues)\n *\n * 3. Key Repeat Behavior\n * - Held Enter/Space will fire onPress repeatedly (matches native button)\n * - No debouncing or repeat prevention (platform parity)\n */\n\nexport interface PressableOptions {\n disabled?: boolean;\n onPress?: (e: PressEvent) => void;\n /**\n * Whether the host is a native button. Defaults to false.\n */\n isNativeButton?: boolean;\n}\n\nimport type {\n DefaultPreventable,\n KeyboardLikeEvent,\n PropagationStoppable,\n} from '../utilities/event-types';\nimport { ariaDisabled } from '../utilities/aria';\n\ntype PressEvent = DefaultPreventable & PropagationStoppable;\n\nexport interface PressableResult {\n onClick: (e: PressEvent) => void;\n disabled?: true;\n role?: 'button';\n tabIndex?: number;\n onKeyDown?: (e: KeyboardLikeEvent) => void;\n onKeyUp?: (e: KeyboardLikeEvent) => void;\n 'aria-disabled'?: 'true';\n}\n\nexport function pressable({\n disabled,\n onPress,\n isNativeButton = false,\n}: PressableOptions): PressableResult {\n const props: PressableResult = {\n onClick: (e) => {\n if (disabled) {\n e.preventDefault?.();\n e.stopPropagation?.();\n return;\n }\n onPress?.(e);\n },\n };\n\n if (isNativeButton) {\n if (disabled) {\n props.disabled = true;\n Object.assign(props, ariaDisabled(disabled));\n }\n return props;\n }\n\n props.role = 'button';\n props.tabIndex = disabled ? -1 : 0;\n\n props.onKeyDown = (e) => {\n if (disabled) {\n e.preventDefault?.();\n e.stopPropagation?.();\n return;\n }\n\n if (e.key === 'Enter') {\n e.preventDefault?.();\n onPress?.(e);\n return;\n }\n\n if (e.key === ' ') {\n // Prevent scrolling while Space is held.\n e.preventDefault?.();\n }\n };\n\n props.onKeyUp = (e) => {\n if (disabled) {\n e.preventDefault?.();\n e.stopPropagation?.();\n return;\n }\n if (e.key === ' ') {\n e.preventDefault?.();\n onPress?.(e);\n }\n };\n\n if (disabled) Object.assign(props, ariaDisabled(disabled));\n return props;\n}\n"],"mappings":";;AA6DA,SAAgB,UAAU,EACxB,UACA,SACA,iBAAiB,SACmB;CACpC,MAAM,QAAyB,EAC7B,UAAU,MAAM;AACd,MAAI,UAAU;AACZ,KAAE,kBAAkB;AACpB,KAAE,mBAAmB;AACrB;;AAEF,YAAU,EAAE;IAEf;AAED,KAAI,gBAAgB;AAClB,MAAI,UAAU;AACZ,SAAM,WAAW;AACjB,UAAO,OAAO,OAAO,aAAa,SAAS,CAAC;;AAE9C,SAAO;;AAGT,OAAM,OAAO;AACb,OAAM,WAAW,WAAW,KAAK;AAEjC,OAAM,aAAa,MAAM;AACvB,MAAI,UAAU;AACZ,KAAE,kBAAkB;AACpB,KAAE,mBAAmB;AACrB;;AAGF,MAAI,EAAE,QAAQ,SAAS;AACrB,KAAE,kBAAkB;AACpB,aAAU,EAAE;AACZ;;AAGF,MAAI,EAAE,QAAQ,IAEZ,GAAE,kBAAkB;;AAIxB,OAAM,WAAW,MAAM;AACrB,MAAI,UAAU;AACZ,KAAE,kBAAkB;AACpB,KAAE,mBAAmB;AACrB;;AAEF,MAAI,EAAE,QAAQ,KAAK;AACjB,KAAE,kBAAkB;AACpB,aAAU,EAAE;;;AAIhB,KAAI,SAAU,QAAO,OAAO,OAAO,aAAa,SAAS,CAAC;AAC1D,QAAO"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/foundations/structures/collection.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* createCollection
|
|
3
4
|
*
|
|
@@ -22,46 +23,30 @@
|
|
|
22
23
|
* const allItems = collection.items();
|
|
23
24
|
* unregister();
|
|
24
25
|
*/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
type CollectionItem<TNode, TMetadata = unknown> = {
|
|
27
|
+
node: TNode;
|
|
28
|
+
metadata: TMetadata;
|
|
28
29
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
30
|
+
interface Collection<TNode, TMetadata = unknown> {
|
|
31
|
+
/**
|
|
32
|
+
* Register a node with optional metadata.
|
|
33
|
+
* Returns an unregister function.
|
|
34
|
+
*/
|
|
35
|
+
register(node: TNode, metadata: TMetadata): () => void;
|
|
36
|
+
/**
|
|
37
|
+
* Get all registered items in insertion order.
|
|
38
|
+
*/
|
|
39
|
+
items(): ReadonlyArray<CollectionItem<TNode, TMetadata>>;
|
|
40
|
+
/**
|
|
41
|
+
* Clear all registered items.
|
|
42
|
+
*/
|
|
43
|
+
clear(): void;
|
|
44
|
+
/**
|
|
45
|
+
* Get the count of registered items.
|
|
46
|
+
*/
|
|
47
|
+
size(): number;
|
|
47
48
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
*
|
|
52
|
-
* // Create a collection for menu items
|
|
53
|
-
* const menuItems = createCollection<HTMLElement, { disabled: boolean }>();
|
|
54
|
-
*
|
|
55
|
-
* // Register items
|
|
56
|
-
* const unregister1 = menuItems.register(element1, { disabled: false });
|
|
57
|
-
* const unregister2 = menuItems.register(element2, { disabled: true });
|
|
58
|
-
*
|
|
59
|
-
* // Query items
|
|
60
|
-
* const allItems = menuItems.items();
|
|
61
|
-
* const enabledItems = allItems.filter(item => !item.metadata.disabled);
|
|
62
|
-
*
|
|
63
|
-
* // Cleanup
|
|
64
|
-
* unregister1();
|
|
65
|
-
* unregister2();
|
|
66
|
-
*/
|
|
49
|
+
declare function createCollection<TNode, TMetadata = unknown>(): Collection<TNode, TMetadata>;
|
|
50
|
+
//#endregion
|
|
51
|
+
export { Collection, CollectionItem, createCollection };
|
|
67
52
|
//# sourceMappingURL=collection.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection.d.ts","
|
|
1
|
+
{"version":3,"file":"collection.d.ts","names":[],"sources":["../../../src/foundations/structures/collection.ts"],"mappings":";;AAyBA;;;;;;;;;;;;AAKA;;;;;;;;;;;KALY,cAAA;EACV,IAAA,EAAM,KAAA;EACN,QAAA,EAAU,SAAA;AAAA;AAAA,UAGK,UAAA;EAKiB;;;;EAAhC,QAAA,CAAS,IAAA,EAAM,KAAA,EAAO,QAAA,EAAU,SAAA;EAKM;;;EAAtC,KAAA,IAAS,aAAA,CAAc,cAAA,CAAe,KAAA,EAAO,SAAA;EAUzC;;AAGN;EARE,KAAA;EAQ8B;;;EAH9B,IAAA;AAAA;AAAA,iBAGc,gBAAA,4BAAA,CAAA,GAAgD,UAAA,CAC9D,KAAA,EACA,SAAA"}
|
|
@@ -1 +1,51 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/foundations/structures/collection.ts
|
|
2
|
+
function createCollection() {
|
|
3
|
+
const registry = /* @__PURE__ */ new Map();
|
|
4
|
+
function register(node, metadata) {
|
|
5
|
+
const item = {
|
|
6
|
+
node,
|
|
7
|
+
metadata
|
|
8
|
+
};
|
|
9
|
+
registry.set(node, item);
|
|
10
|
+
return () => {
|
|
11
|
+
registry.delete(node);
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function items() {
|
|
15
|
+
return Array.from(registry.values());
|
|
16
|
+
}
|
|
17
|
+
function clear() {
|
|
18
|
+
registry.clear();
|
|
19
|
+
}
|
|
20
|
+
function size() {
|
|
21
|
+
return registry.size;
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
register,
|
|
25
|
+
items,
|
|
26
|
+
clear,
|
|
27
|
+
size
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* USAGE EXAMPLE:
|
|
32
|
+
*
|
|
33
|
+
* // Create a collection for menu items
|
|
34
|
+
* const menuItems = createCollection<HTMLElement, { disabled: boolean }>();
|
|
35
|
+
*
|
|
36
|
+
* // Register items
|
|
37
|
+
* const unregister1 = menuItems.register(element1, { disabled: false });
|
|
38
|
+
* const unregister2 = menuItems.register(element2, { disabled: true });
|
|
39
|
+
*
|
|
40
|
+
* // Query items
|
|
41
|
+
* const allItems = menuItems.items();
|
|
42
|
+
* const enabledItems = allItems.filter(item => !item.metadata.disabled);
|
|
43
|
+
*
|
|
44
|
+
* // Cleanup
|
|
45
|
+
* unregister1();
|
|
46
|
+
* unregister2();
|
|
47
|
+
*/
|
|
48
|
+
//#endregion
|
|
49
|
+
export { createCollection };
|
|
50
|
+
|
|
51
|
+
//# sourceMappingURL=collection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collection.js","names":[],"sources":["../../../src/foundations/structures/collection.ts"],"sourcesContent":["/**\n * createCollection\n *\n * Ordered descendant registry for coordinating items without DOM queries.\n *\n * INVARIANTS:\n * 1. Registration order determines item order (no DOM queries)\n * 2. Stable ordering across renders (insertion order preserved)\n * 3. Each item may have metadata (type-safe, user-defined)\n * 4. No implicit global state (explicit collection instances)\n * 5. No automatic cleanup (caller controls lifecycle)\n *\n * DESIGN:\n * - Returns a registry API ({ register, items, clear })\n * - Items are stored in insertion order\n * - Registration returns an unregister function\n * - No side effects on registration (pure data structure)\n *\n * USAGE:\n * const collection = createCollection<HTMLElement, { disabled: boolean }>();\n * const unregister = collection.register(element, { disabled: false });\n * const allItems = collection.items();\n * unregister();\n */\n\nexport type CollectionItem<TNode, TMetadata = unknown> = {\n node: TNode;\n metadata: TMetadata;\n};\n\nexport interface Collection<TNode, TMetadata = unknown> {\n /**\n * Register a node with optional metadata.\n * Returns an unregister function.\n */\n register(node: TNode, metadata: TMetadata): () => void;\n\n /**\n * Get all registered items in insertion order.\n */\n items(): ReadonlyArray<CollectionItem<TNode, TMetadata>>;\n\n /**\n * Clear all registered items.\n */\n clear(): void;\n\n /**\n * Get the count of registered items.\n */\n size(): number;\n}\n\nexport function createCollection<TNode, TMetadata = unknown>(): Collection<\n TNode,\n TMetadata\n> {\n const registry = new Map<TNode, CollectionItem<TNode, TMetadata>>();\n\n function register(node: TNode, metadata: TMetadata): () => void {\n const item: CollectionItem<TNode, TMetadata> = { node, metadata };\n registry.set(node, item);\n\n return () => {\n registry.delete(node);\n };\n }\n\n function items(): ReadonlyArray<CollectionItem<TNode, TMetadata>> {\n return Array.from(registry.values());\n }\n\n function clear(): void {\n registry.clear();\n }\n\n function size(): number {\n return registry.size;\n }\n\n return {\n register,\n items,\n clear,\n size,\n };\n}\n\n/**\n * USAGE EXAMPLE:\n *\n * // Create a collection for menu items\n * const menuItems = createCollection<HTMLElement, { disabled: boolean }>();\n *\n * // Register items\n * const unregister1 = menuItems.register(element1, { disabled: false });\n * const unregister2 = menuItems.register(element2, { disabled: true });\n *\n * // Query items\n * const allItems = menuItems.items();\n * const enabledItems = allItems.filter(item => !item.metadata.disabled);\n *\n * // Cleanup\n * unregister1();\n * unregister2();\n */\n"],"mappings":";AAqDA,SAAgB,mBAGd;CACA,MAAM,2BAAW,IAAI,KAA8C;CAEnE,SAAS,SAAS,MAAa,UAAiC;EAC9D,MAAM,OAAyC;GAAE;GAAM;GAAU;AACjE,WAAS,IAAI,MAAM,KAAK;AAExB,eAAa;AACX,YAAS,OAAO,KAAK;;;CAIzB,SAAS,QAAyD;AAChE,SAAO,MAAM,KAAK,SAAS,QAAQ,CAAC;;CAGtC,SAAS,QAAc;AACrB,WAAS,OAAO;;CAGlB,SAAS,OAAe;AACtB,SAAO,SAAS;;AAGlB,QAAO;EACL;EACA;EACA;EACA;EACD"}
|