@omerdlw/base-framework 3.4.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +56 -72
- package/dist/ambient/index.js +9 -10
- package/dist/ambient/server/index.js +3 -3
- package/dist/ambient/server/index.js.map +1 -1
- package/dist/ambient/worker/index.js +7 -4
- package/dist/ambient/worker/index.js.map +1 -1
- package/dist/background/index.js +8 -9
- package/dist/{chunk-KOYTJW5E.js → chunk-3FSDBJ7V.js} +7 -7
- package/dist/chunk-3FSDBJ7V.js.map +1 -0
- package/dist/{chunk-CRKJAACG.js → chunk-4QQ3QVY7.js} +10 -10
- package/dist/{chunk-CRKJAACG.js.map → chunk-4QQ3QVY7.js.map} +1 -1
- package/dist/{chunk-UQLTP3XB.js → chunk-5TQSH6KE.js} +143 -144
- package/dist/chunk-5TQSH6KE.js.map +1 -0
- package/dist/{chunk-HFR6YROB.js → chunk-6P3F4JU3.js} +1160 -1172
- package/dist/chunk-6P3F4JU3.js.map +1 -0
- package/dist/chunk-AKPH5CEJ.js +357 -0
- package/dist/chunk-AKPH5CEJ.js.map +1 -0
- package/dist/{chunk-QGPRTUED.js → chunk-AWLK2I56.js} +35 -39
- package/dist/chunk-AWLK2I56.js.map +1 -0
- package/dist/{chunk-ZXRE2KZO.js → chunk-C3SEBNF5.js} +11 -15
- package/dist/chunk-C3SEBNF5.js.map +1 -0
- package/dist/{chunk-R4K6VAOK.js → chunk-C527JOJQ.js} +11 -18
- package/dist/chunk-C527JOJQ.js.map +1 -0
- package/dist/{chunk-VNSMNGWP.js → chunk-DMQKXBWO.js} +5 -5
- package/dist/{chunk-VNSMNGWP.js.map → chunk-DMQKXBWO.js.map} +1 -1
- package/dist/{chunk-IH3STE7W.js → chunk-ED32WLAD.js} +1168 -1215
- package/dist/chunk-ED32WLAD.js.map +1 -0
- package/dist/{chunk-67MOKJFZ.js → chunk-EXB7VFD3.js} +16 -16
- package/dist/chunk-EXB7VFD3.js.map +1 -0
- package/dist/chunk-FG2AKFXP.js +108 -0
- package/dist/chunk-FG2AKFXP.js.map +1 -0
- package/dist/chunk-GA5SZ6E2.js +17 -0
- package/dist/{chunk-AZ2ZDFNP.js.map → chunk-GA5SZ6E2.js.map} +1 -1
- package/dist/chunk-GG2ILNK2.js +44 -0
- package/dist/chunk-GG2ILNK2.js.map +1 -0
- package/dist/{chunk-6IP6YFQX.js → chunk-JA75E4BG.js} +21 -31
- package/dist/chunk-JA75E4BG.js.map +1 -0
- package/dist/{chunk-WQTMOUCA.js → chunk-JWUKAZ3A.js} +45 -67
- package/dist/chunk-JWUKAZ3A.js.map +1 -0
- package/dist/{chunk-LKYW4LH6.js → chunk-QZA5AIT6.js} +37 -47
- package/dist/chunk-QZA5AIT6.js.map +1 -0
- package/dist/{chunk-D222OCTV.js → chunk-S67HGKJ2.js} +49 -55
- package/dist/chunk-S67HGKJ2.js.map +1 -0
- package/dist/chunk-T53WFIZN.js +29 -0
- package/dist/chunk-T53WFIZN.js.map +1 -0
- package/dist/{chunk-RDYYP36I.js → chunk-TMKA5ZHO.js} +7 -6
- package/dist/chunk-TMKA5ZHO.js.map +1 -0
- package/dist/{chunk-XGAYTDSI.js → chunk-UWX7GCNX.js} +23 -26
- package/dist/chunk-UWX7GCNX.js.map +1 -0
- package/dist/{chunk-QRXDXAQI.js → chunk-WVED7PDH.js} +161 -165
- package/dist/chunk-WVED7PDH.js.map +1 -0
- package/dist/{chunk-FFJWJ4OB.js → chunk-XIFQMK2Z.js} +12317 -12355
- package/dist/chunk-XIFQMK2Z.js.map +1 -0
- package/dist/{chunk-BMFHS3GV.js → chunk-YHWA7FXX.js} +22 -12
- package/dist/chunk-YHWA7FXX.js.map +1 -0
- package/dist/{chunk-YZS2B6YE.js → chunk-YKHAFHB7.js} +9 -12
- package/dist/chunk-YKHAFHB7.js.map +1 -0
- package/dist/{chunk-GKAJ4EM2.js → chunk-ZQI4ZCVU.js} +83 -83
- package/dist/chunk-ZQI4ZCVU.js.map +1 -0
- package/dist/context-menu/index.js +13 -15
- package/dist/controls/index.js +7 -6
- package/dist/core/error/boundary.d.ts.map +1 -1
- package/dist/core/error/constants.d.ts +9 -0
- package/dist/core/error/constants.d.ts.map +1 -1
- package/dist/core/error/index.d.ts +2 -3
- package/dist/core/error/index.d.ts.map +1 -1
- package/dist/core/error/listener.d.ts.map +1 -1
- package/dist/core/error/reporter.d.ts +7 -6
- package/dist/core/error/reporter.d.ts.map +1 -1
- package/dist/core/error/utils.d.ts.map +1 -1
- package/dist/core/kernel/constants.d.ts +1 -1
- package/dist/core/kernel/constants.d.ts.map +1 -1
- package/dist/core/kernel/{compose.d.ts → host/compose.d.ts} +0 -4
- package/dist/core/kernel/host/compose.d.ts.map +1 -0
- package/dist/core/kernel/{installed.d.ts → host/installed.d.ts} +1 -1
- package/dist/core/kernel/host/installed.d.ts.map +1 -0
- package/dist/core/kernel/{module.d.ts → host/module.d.ts} +2 -5
- package/dist/core/kernel/host/module.d.ts.map +1 -0
- package/dist/core/kernel/{adapters.d.ts → host/registration.d.ts} +2 -2
- package/dist/core/kernel/host/registration.d.ts.map +1 -0
- package/dist/core/kernel/index.d.ts +12 -12
- package/dist/core/kernel/index.d.ts.map +1 -1
- package/dist/core/kernel/{page-controller.d.ts → page.d.ts} +2 -2
- package/dist/core/kernel/page.d.ts.map +1 -0
- package/dist/core/kernel/{handlers.d.ts → registry/apply.d.ts} +2 -2
- package/dist/core/kernel/registry/apply.d.ts.map +1 -0
- package/dist/core/kernel/{hooks.d.ts → registry/hooks.d.ts} +1 -1
- package/dist/core/kernel/registry/hooks.d.ts.map +1 -0
- package/dist/core/kernel/{operations.d.ts → registry/operations.d.ts} +2 -2
- package/dist/core/kernel/registry/operations.d.ts.map +1 -0
- package/dist/core/kernel/{provider.d.ts → registry/provider.d.ts} +2 -2
- package/dist/core/kernel/registry/provider.d.ts.map +1 -0
- package/dist/core/kernel/{operations-records.d.ts → registry/records.d.ts} +2 -2
- package/dist/core/kernel/registry/records.d.ts.map +1 -0
- package/dist/core/kernel/registry/registration.d.ts +13 -0
- package/dist/core/kernel/registry/registration.d.ts.map +1 -0
- package/dist/core/kernel/{schema.d.ts → registry/schema.d.ts} +1 -1
- package/dist/core/kernel/registry/schema.d.ts.map +1 -0
- package/dist/core/kernel/{store-snapshots.d.ts → registry/snapshots.d.ts} +3 -3
- package/dist/core/kernel/registry/snapshots.d.ts.map +1 -0
- package/dist/core/kernel/{stabilize.d.ts → registry/stabilize.d.ts} +1 -1
- package/dist/core/kernel/registry/stabilize.d.ts.map +1 -0
- package/dist/core/kernel/{store.d.ts → registry/store.d.ts} +2 -2
- package/dist/core/kernel/registry/store.d.ts.map +1 -0
- package/dist/core/kernel/{store-subscriptions.d.ts → registry/subscriptions.d.ts} +2 -6
- package/dist/core/kernel/registry/subscriptions.d.ts.map +1 -0
- package/dist/core/kernel/{runtime.d.ts → registry/transaction.d.ts} +2 -2
- package/dist/core/kernel/registry/transaction.d.ts.map +1 -0
- package/dist/core/kernel/{types-modules.d.ts → types/modules.d.ts} +4 -4
- package/dist/core/kernel/types/modules.d.ts.map +1 -0
- package/dist/core/kernel/{types-page.d.ts → types/page.d.ts} +3 -3
- package/dist/core/kernel/types/page.d.ts.map +1 -0
- package/dist/core/kernel/{types.d.ts → types/registry.d.ts} +4 -4
- package/dist/core/kernel/types/registry.d.ts.map +1 -0
- package/dist/core/kernel/{types-store.d.ts → types/store.d.ts} +3 -3
- package/dist/core/kernel/types/store.d.ts.map +1 -0
- package/dist/core/kernel/utils.d.ts +1 -1
- package/dist/core/kernel/utils.d.ts.map +1 -1
- package/dist/core/navigation/{navigator-holds.d.ts → holds.d.ts} +2 -1
- package/dist/core/navigation/holds.d.ts.map +1 -0
- package/dist/core/navigation/navigator.d.ts.map +1 -1
- package/dist/core/navigation/{navigator-patience.d.ts → patience.d.ts} +1 -1
- package/dist/core/navigation/patience.d.ts.map +1 -0
- package/dist/core/navigation/{navigator-payload.d.ts → payload.d.ts} +2 -1
- package/dist/core/navigation/payload.d.ts.map +1 -0
- package/dist/core/navigation/{navigator-prefetch.d.ts → prefetch.d.ts} +2 -1
- package/dist/core/navigation/prefetch.d.ts.map +1 -0
- package/dist/core/navigation/settings.d.ts.map +1 -1
- package/dist/core/navigation/state.d.ts.map +1 -1
- package/dist/core/navigation/utils.d.ts +3 -0
- package/dist/core/navigation/utils.d.ts.map +1 -1
- package/dist/core/provider/index.d.ts +4 -9
- package/dist/core/provider/index.d.ts.map +1 -1
- package/dist/dock/index.js +12 -14
- package/dist/error/index.js +4 -7
- package/dist/events/index.js +24 -20
- package/dist/events/index.js.map +1 -1
- package/dist/foundation/events/index.d.ts.map +1 -1
- package/dist/foundation/recipes/index.d.ts +0 -7
- package/dist/foundation/recipes/index.d.ts.map +1 -1
- package/dist/foundation/recipes/recipe.d.ts.map +1 -1
- package/dist/foundation/result/index.d.ts.map +1 -1
- package/dist/foundation/utils/collections.d.ts +11 -0
- package/dist/foundation/utils/collections.d.ts.map +1 -0
- package/dist/foundation/utils/dom.d.ts.map +1 -1
- package/dist/foundation/utils/report.d.ts.map +1 -1
- package/dist/foundation/utils/scheduler.d.ts.map +1 -1
- package/dist/foundation/utils/store.d.ts.map +1 -1
- package/dist/foundation/utils/string.d.ts.map +1 -1
- package/dist/foundation/utils/tempo.d.ts.map +1 -1
- package/dist/foundation/utils/timing.d.ts.map +1 -1
- package/dist/foundation/utils/user-message.d.ts.map +1 -1
- package/dist/hooks/index.js +3 -3
- package/dist/index.js +22 -24
- package/dist/kernel/index.js +4 -4
- package/dist/loading/index.js +6 -8
- package/dist/media/index.js +5 -5
- package/dist/modal/index.js +153 -166
- package/dist/modal/index.js.map +1 -1
- package/dist/modules/ambient/{analyze.d.ts → analysis/analyze.d.ts} +3 -3
- package/dist/modules/ambient/analysis/analyze.d.ts.map +1 -0
- package/dist/modules/ambient/{analyze-bounds.d.ts → analysis/bounds.d.ts} +2 -2
- package/dist/modules/ambient/analysis/bounds.d.ts.map +1 -0
- package/dist/modules/ambient/{analyze-clusters.d.ts → analysis/clusters.d.ts} +3 -3
- package/dist/modules/ambient/analysis/clusters.d.ts.map +1 -0
- package/dist/modules/ambient/{analyze-ground.d.ts → analysis/ground.d.ts} +3 -3
- package/dist/modules/ambient/analysis/ground.d.ts.map +1 -0
- package/dist/modules/ambient/{analyze-measures.d.ts → analysis/measures.d.ts} +2 -2
- package/dist/modules/ambient/analysis/measures.d.ts.map +1 -0
- package/dist/modules/ambient/{oklab.d.ts → analysis/oklab.d.ts} +1 -3
- package/dist/modules/ambient/analysis/oklab.d.ts.map +1 -0
- package/dist/modules/ambient/analysis/quantize.d.ts.map +1 -0
- package/dist/modules/ambient/{analyze-swatches.d.ts → analysis/swatches.d.ts} +3 -3
- package/dist/modules/ambient/analysis/swatches.d.ts.map +1 -0
- package/dist/modules/ambient/hooks.d.ts +0 -1
- package/dist/modules/ambient/hooks.d.ts.map +1 -1
- package/dist/modules/ambient/index.d.ts +2 -2
- package/dist/modules/ambient/index.d.ts.map +1 -1
- package/dist/modules/ambient/module.d.ts +0 -3
- package/dist/modules/ambient/module.d.ts.map +1 -1
- package/dist/modules/ambient/pipeline.d.ts +6 -5
- package/dist/modules/ambient/pipeline.d.ts.map +1 -1
- package/dist/modules/ambient/server/index.d.ts +2 -2
- package/dist/modules/ambient/server/index.d.ts.map +1 -1
- package/dist/modules/ambient/settings.d.ts +0 -2
- package/dist/modules/ambient/settings.d.ts.map +1 -1
- package/dist/modules/ambient/worker/index.d.ts.map +1 -1
- package/dist/modules/background/constants.d.ts +3 -1
- package/dist/modules/background/constants.d.ts.map +1 -1
- package/dist/modules/background/context.d.ts +1 -1
- package/dist/modules/background/context.d.ts.map +1 -1
- package/dist/modules/background/hooks.d.ts +929 -0
- package/dist/modules/background/hooks.d.ts.map +1 -1
- package/dist/modules/background/index.d.ts +6 -6
- package/dist/modules/background/index.d.ts.map +1 -1
- package/dist/modules/background/module.d.ts +1 -1
- package/dist/modules/background/module.d.ts.map +1 -1
- package/dist/modules/background/{hooks/use-native-video-model.d.ts → native-video.d.ts} +4 -8
- package/dist/modules/background/native-video.d.ts.map +1 -0
- package/dist/modules/background/overlay.d.ts.map +1 -0
- package/dist/modules/background/playback.d.ts.map +1 -0
- package/dist/modules/background/{model/state.d.ts → state.d.ts} +11 -1
- package/dist/modules/background/state.d.ts.map +1 -0
- package/dist/modules/background/{model/visual.d.ts → visual.d.ts} +43 -6
- package/dist/modules/background/visual.d.ts.map +1 -0
- package/dist/modules/background/youtube/audio.d.ts.map +1 -0
- package/dist/modules/background/youtube/iframe.d.ts +92 -0
- package/dist/modules/background/youtube/iframe.d.ts.map +1 -0
- package/dist/modules/background/youtube/{lib/parse.d.ts → parse.d.ts} +1 -1
- package/dist/modules/background/youtube/parse.d.ts.map +1 -0
- package/dist/modules/background/youtube/{components/player.d.ts → player.d.ts} +1 -1
- package/dist/modules/background/youtube/player.d.ts.map +1 -0
- package/dist/modules/background/youtube/{lib/timing.d.ts → timing.d.ts} +0 -2
- package/dist/modules/background/youtube/timing.d.ts.map +1 -0
- package/dist/modules/background/youtube/use-iframe-player.d.ts +37 -0
- package/dist/modules/background/youtube/use-iframe-player.d.ts.map +1 -0
- package/dist/modules/background/youtube/{hooks/use-youtube-background-player-model.d.ts → use-player.d.ts} +2 -2
- package/dist/modules/background/youtube/use-player.d.ts.map +1 -0
- package/dist/modules/background/youtube/{hooks/use-youtube-video-sync.d.ts → use-video-sync.d.ts} +8 -4
- package/dist/modules/background/youtube/use-video-sync.d.ts.map +1 -0
- package/dist/modules/background/youtube/{lib/video-events.d.ts → video-events.d.ts} +8 -8
- package/dist/modules/background/youtube/video-events.d.ts.map +1 -0
- package/dist/modules/context-menu/dom.d.ts.map +1 -1
- package/dist/modules/context-menu/items.d.ts.map +1 -1
- package/dist/modules/context-menu/overlay.d.ts +3 -10
- package/dist/modules/context-menu/overlay.d.ts.map +1 -1
- package/dist/modules/context-menu/resolver.d.ts.map +1 -1
- package/dist/modules/controls/overlay.d.ts +0 -10
- package/dist/modules/controls/overlay.d.ts.map +1 -1
- package/dist/modules/dock/{lib → card}/banner.d.ts +3 -16
- package/dist/modules/dock/card/banner.d.ts.map +1 -0
- package/dist/modules/dock/{components/card-item.d.ts → card/card.d.ts} +5 -2
- package/dist/modules/dock/card/card.d.ts.map +1 -0
- package/dist/modules/dock/card/compact.d.ts.map +1 -0
- package/dist/modules/dock/{components/item-content.d.ts → card/content.d.ts} +1 -1
- package/dist/modules/dock/card/content.d.ts.map +1 -0
- package/dist/modules/dock/card/header.d.ts +8 -0
- package/dist/modules/dock/card/header.d.ts.map +1 -0
- package/dist/modules/dock/{components → card}/icon.d.ts +1 -1
- package/dist/modules/dock/card/icon.d.ts.map +1 -0
- package/dist/modules/dock/{lib/card-item.d.ts → card/model.d.ts} +20 -2
- package/dist/modules/dock/card/model.d.ts.map +1 -0
- package/dist/modules/dock/{hooks/use-card-item-model.d.ts → card/use-card.d.ts} +44 -43
- package/dist/modules/dock/{hooks/use-card-item-model.d.ts.map → card/use-card.d.ts.map} +1 -1
- package/dist/modules/dock/commands/command-bar.d.ts.map +1 -0
- package/dist/modules/dock/{runtime/commands.d.ts → commands/registry.d.ts} +1 -1
- package/dist/modules/dock/commands/registry.d.ts.map +1 -0
- package/dist/modules/dock/constants.d.ts +4 -7
- package/dist/modules/dock/constants.d.ts.map +1 -1
- package/dist/modules/dock/context.d.ts +1 -1
- package/dist/modules/dock/context.d.ts.map +1 -1
- package/dist/modules/dock/hooks.d.ts +47 -0
- package/dist/modules/dock/hooks.d.ts.map +1 -0
- package/dist/modules/dock/{hud.d.ts → hud/hud.d.ts} +14 -7
- package/dist/modules/dock/hud/hud.d.ts.map +1 -0
- package/dist/modules/dock/{model/hud-definition.d.ts → hud/model.d.ts} +7 -1
- package/dist/modules/dock/hud/model.d.ts.map +1 -0
- package/dist/modules/dock/{components/hud-view.d.ts → hud/view.d.ts} +1 -1
- package/dist/modules/dock/hud/view.d.ts.map +1 -0
- package/dist/modules/dock/index.d.ts +22 -22
- package/dist/modules/dock/index.d.ts.map +1 -1
- package/dist/modules/dock/items/attention.d.ts +43 -0
- package/dist/modules/dock/items/attention.d.ts.map +1 -0
- package/dist/modules/dock/{runtime/model/items.d.ts → items/build.d.ts} +2 -2
- package/dist/modules/dock/items/build.d.ts.map +1 -0
- package/dist/modules/dock/{runtime → items}/display.d.ts +2 -5
- package/dist/modules/dock/items/display.d.ts.map +1 -0
- package/dist/modules/dock/items/operations.d.ts +22 -0
- package/dist/modules/dock/items/operations.d.ts.map +1 -0
- package/dist/modules/dock/{runtime → items}/pipeline.d.ts +1 -1
- package/dist/modules/dock/items/pipeline.d.ts.map +1 -0
- package/dist/modules/dock/{components/media-action.d.ts → media/controls.d.ts} +5 -2
- package/dist/modules/dock/media/controls.d.ts.map +1 -0
- package/dist/modules/dock/{lib/media.d.ts → media/model.d.ts} +1 -3
- package/dist/modules/dock/media/model.d.ts.map +1 -0
- package/dist/modules/dock/{components/media-scrubber.d.ts → media/scrubber.d.ts} +1 -1
- package/dist/modules/dock/media/scrubber.d.ts.map +1 -0
- package/dist/modules/dock/{hooks/use-media-controls-model.d.ts → media/use-controls.d.ts} +8 -8
- package/dist/modules/dock/media/use-controls.d.ts.map +1 -0
- package/dist/modules/dock/module.d.ts.map +1 -1
- package/dist/modules/dock/motion.d.ts +27 -28
- package/dist/modules/dock/motion.d.ts.map +1 -1
- package/dist/modules/dock/provider.d.ts.map +1 -1
- package/dist/modules/dock/routing/breadcrumbs-card.d.ts.map +1 -0
- package/dist/modules/dock/routing/{model/continuity.d.ts → continuity-state.d.ts} +2 -2
- package/dist/modules/dock/routing/continuity-state.d.ts.map +1 -0
- package/dist/modules/dock/routing/continuity.d.ts +8 -8
- package/dist/modules/dock/routing/continuity.d.ts.map +1 -1
- package/dist/modules/dock/routing/navigation.d.ts +0 -10
- package/dist/modules/dock/routing/navigation.d.ts.map +1 -1
- package/dist/modules/dock/routing/paths.d.ts.map +1 -0
- package/dist/modules/dock/routing/{model/policy.d.ts → policy.d.ts} +1 -1
- package/dist/modules/dock/routing/policy.d.ts.map +1 -0
- package/dist/modules/dock/routing/{hooks/use-route-prefetch.d.ts → prefetch.d.ts} +3 -3
- package/dist/modules/dock/routing/prefetch.d.ts.map +1 -0
- package/dist/modules/dock/routing/route-bridge.d.ts +8 -0
- package/dist/modules/dock/routing/route-bridge.d.ts.map +1 -0
- package/dist/modules/dock/routing/{model/topology.d.ts → topology.d.ts} +1 -1
- package/dist/modules/dock/routing/topology.d.ts.map +1 -0
- package/dist/modules/dock/{runtime/model → stack}/cards.d.ts +8 -5
- package/dist/modules/dock/stack/cards.d.ts.map +1 -0
- package/dist/modules/dock/stack/dock.d.ts.map +1 -0
- package/dist/modules/dock/stack/focus.d.ts +22 -0
- package/dist/modules/dock/stack/focus.d.ts.map +1 -0
- package/dist/modules/dock/{model → stack}/layout.d.ts +8 -2
- package/dist/modules/dock/stack/layout.d.ts.map +1 -0
- package/dist/modules/dock/{runtime/dock.d.ts → stack/use-dock-model.d.ts} +2 -1
- package/dist/modules/dock/stack/use-dock-model.d.ts.map +1 -0
- package/dist/modules/dock/{runtime/hooks → stack}/use-dock.d.ts +9 -9
- package/dist/modules/dock/stack/use-dock.d.ts.map +1 -0
- package/dist/modules/dock/stack/use-height.d.ts +12 -0
- package/dist/modules/dock/stack/use-height.d.ts.map +1 -0
- package/dist/modules/dock/{components/status-actions.d.ts → status/actions.d.ts} +1 -1
- package/dist/modules/dock/status/actions.d.ts.map +1 -0
- package/dist/modules/dock/status/events.d.ts +4 -4
- package/dist/modules/dock/status/events.d.ts.map +1 -1
- package/dist/modules/dock/status/hooks.d.ts.map +1 -1
- package/dist/modules/dock/status/model.d.ts +34 -4
- package/dist/modules/dock/status/model.d.ts.map +1 -1
- package/dist/modules/dock/surface/{model/builder.d.ts → builder.d.ts} +13 -7
- package/dist/modules/dock/surface/builder.d.ts.map +1 -0
- package/dist/modules/dock/{components/surface/item-content.d.ts → surface/content.d.ts} +2 -2
- package/dist/modules/dock/surface/content.d.ts.map +1 -0
- package/dist/modules/dock/surface/context.d.ts +12 -3
- package/dist/modules/dock/surface/context.d.ts.map +1 -1
- package/dist/modules/dock/surface/controls.d.ts +26 -0
- package/dist/modules/dock/surface/controls.d.ts.map +1 -0
- package/dist/modules/dock/surface/definition.d.ts.map +1 -1
- package/dist/modules/dock/{components/surface → surface}/extensions-bar.d.ts +1 -1
- package/dist/modules/dock/surface/extensions-bar.d.ts.map +1 -0
- package/dist/modules/dock/{components/surface/action.d.ts → surface/extensions.d.ts} +4 -2
- package/dist/modules/dock/surface/extensions.d.ts.map +1 -0
- package/dist/modules/dock/{components/surface → surface}/header-button.d.ts +3 -3
- package/dist/modules/dock/surface/header-button.d.ts.map +1 -0
- package/dist/modules/dock/surface/helpers.d.ts +13 -1
- package/dist/modules/dock/surface/helpers.d.ts.map +1 -1
- package/dist/modules/dock/surface/{model/normalize.d.ts → normalize.d.ts} +1 -1
- package/dist/modules/dock/surface/normalize.d.ts.map +1 -0
- package/dist/modules/dock/surface/runtime/choreography.d.ts +28 -2
- package/dist/modules/dock/surface/runtime/choreography.d.ts.map +1 -1
- package/dist/modules/dock/surface/runtime/flows.d.ts +1 -1
- package/dist/modules/dock/surface/runtime/flows.d.ts.map +1 -1
- package/dist/modules/dock/surface/{machine.d.ts → runtime/machine.d.ts} +1 -1
- package/dist/modules/dock/surface/runtime/machine.d.ts.map +1 -0
- package/dist/modules/dock/surface/runtime/open.d.ts +1 -2
- package/dist/modules/dock/surface/runtime/open.d.ts.map +1 -1
- package/dist/modules/dock/surface/{model → runtime}/records.d.ts +1 -1
- package/dist/modules/dock/surface/runtime/records.d.ts.map +1 -0
- package/dist/modules/dock/surface/{stack.d.ts → runtime/stack.d.ts} +10 -10
- package/dist/modules/dock/surface/runtime/stack.d.ts.map +1 -0
- package/dist/modules/dock/surface/runtime/steps.d.ts +1 -1
- package/dist/modules/dock/surface/runtime/steps.d.ts.map +1 -1
- package/dist/modules/dock/surface/{model/transition-state.d.ts → runtime/transition.d.ts} +1 -1
- package/dist/modules/dock/surface/runtime/transition.d.ts.map +1 -0
- package/dist/modules/dock/surface/runtime/url.d.ts.map +1 -0
- package/dist/modules/dock/surface/{hooks/use-surface-shell-model.d.ts → shell.d.ts} +9 -3
- package/dist/modules/dock/surface/shell.d.ts.map +1 -0
- package/dist/modules/dock/surface/{hooks/use-surface-flow.d.ts → use-flow.d.ts} +2 -2
- package/dist/modules/dock/surface/use-flow.d.ts.map +1 -0
- package/dist/modules/dock/surface/view-model.d.ts.map +1 -1
- package/dist/modules/dock/{lib/styles.d.ts → theme.d.ts} +22 -18
- package/dist/modules/dock/theme.d.ts.map +1 -0
- package/dist/modules/dock/types/card.d.ts +12 -3
- package/dist/modules/dock/types/card.d.ts.map +1 -1
- package/dist/modules/dock/types/index.d.ts +1 -1
- package/dist/modules/dock/types/index.d.ts.map +1 -1
- package/dist/modules/dock/types/surface.d.ts +2 -2
- package/dist/modules/dock/types/surface.d.ts.map +1 -1
- package/dist/modules/dock/{lib/helpers.d.ts → utils.d.ts} +10 -3
- package/dist/modules/dock/utils.d.ts.map +1 -0
- package/dist/modules/index.js +20 -22
- package/dist/modules/loading/hooks.d.ts +2 -1
- package/dist/modules/loading/hooks.d.ts.map +1 -1
- package/dist/modules/loading/state.d.ts.map +1 -1
- package/dist/modules/media/hooks.d.ts.map +1 -1
- package/dist/modules/media/playback.d.ts.map +1 -1
- package/dist/modules/modal/constants.d.ts +3 -1
- package/dist/modules/modal/constants.d.ts.map +1 -1
- package/dist/modules/modal/{components/modal-container.d.ts → container.d.ts} +2 -2
- package/dist/modules/modal/container.d.ts.map +1 -0
- package/dist/modules/modal/context.d.ts +5 -1
- package/dist/modules/modal/context.d.ts.map +1 -1
- package/dist/modules/modal/dom.d.ts.map +1 -0
- package/dist/modules/modal/hooks.d.ts +3 -2
- package/dist/modules/modal/hooks.d.ts.map +1 -1
- package/dist/modules/modal/index.d.ts +7 -7
- package/dist/modules/modal/index.d.ts.map +1 -1
- package/dist/modules/modal/{model/layout.d.ts → layout.d.ts} +1 -1
- package/dist/modules/modal/layout.d.ts.map +1 -0
- package/dist/modules/modal/module.d.ts +1 -1
- package/dist/modules/modal/module.d.ts.map +1 -1
- package/dist/modules/modal/overlay.d.ts.map +1 -0
- package/dist/modules/modal/state.d.ts +52 -0
- package/dist/modules/modal/state.d.ts.map +1 -0
- package/dist/modules/navigation/hooks.d.ts.map +1 -1
- package/dist/modules/notification/hooks.d.ts.map +1 -1
- package/dist/modules/notification/overlay.d.ts +0 -1
- package/dist/modules/notification/overlay.d.ts.map +1 -1
- package/dist/navigation/index.js +33 -41
- package/dist/navigation/index.js.map +1 -1
- package/dist/notification/index.js +8 -7
- package/dist/overlay-ZCMQVNYT.js +12 -0
- package/dist/{overlay-7QLGWHCH.js.map → overlay-ZCMQVNYT.js.map} +1 -1
- package/dist/provider/index.js +7 -11
- package/dist/react/hooks/index.d.ts +3 -1
- package/dist/react/hooks/index.d.ts.map +1 -1
- package/dist/react/hooks/use-client-value.d.ts +15 -0
- package/dist/react/hooks/use-client-value.d.ts.map +1 -0
- package/dist/react/hooks/use-controllable-state.d.ts +8 -1
- package/dist/react/hooks/use-controllable-state.d.ts.map +1 -1
- package/dist/react/hooks/use-fullscreen-state.d.ts +0 -2
- package/dist/react/hooks/use-fullscreen-state.d.ts.map +1 -1
- package/dist/react/hooks/use-global-event.d.ts +7 -1
- package/dist/react/hooks/use-global-event.d.ts.map +1 -1
- package/dist/react/hooks/use-hotkey.d.ts +9 -1
- package/dist/react/hooks/use-hotkey.d.ts.map +1 -1
- package/dist/react/hooks/use-scroll-lock.d.ts.map +1 -1
- package/dist/react/hooks/use-store.d.ts +3 -0
- package/dist/react/hooks/use-store.d.ts.map +1 -1
- package/dist/react/theme/index.d.ts +7 -2
- package/dist/react/theme/index.d.ts.map +1 -1
- package/dist/react/theme/parts.d.ts +89 -0
- package/dist/react/theme/parts.d.ts.map +1 -0
- package/dist/recipes/index.js +6 -121
- package/dist/recipes/index.js.map +1 -1
- package/dist/result/index.js +12 -15
- package/dist/result/index.js.map +1 -1
- package/dist/theme/index.js +2 -2
- package/dist/utils/index.js +31 -34
- package/dist/utils/index.js.map +1 -1
- package/docs/README.md +11 -12
- package/docs/architecture-and-rules.md +43 -32
- package/docs/core-engine.md +11 -13
- package/docs/custom-modules.md +1 -1
- package/docs/design.md +60 -153
- package/docs/getting-started.md +3 -5
- package/docs/modules/README.md +16 -16
- package/docs/modules/ambient.md +23 -23
- package/docs/modules/background.md +24 -19
- package/docs/modules/context-menu.md +1 -1
- package/docs/modules/dock.md +47 -43
- package/docs/modules/error-boundary.md +2 -3
- package/docs/modules/kernel.md +28 -30
- package/docs/modules/loading.md +1 -1
- package/docs/modules/modal.md +17 -16
- package/docs/modules/navigation.md +14 -14
- package/docs/testing.md +1 -1
- package/package.json +1 -8
- package/templates/AGENTS.md +4 -3
- package/MIGRATION.md +0 -99
- package/dist/chunk-67MOKJFZ.js.map +0 -1
- package/dist/chunk-6IP6YFQX.js.map +0 -1
- package/dist/chunk-7VU2OAJB.js +0 -464
- package/dist/chunk-7VU2OAJB.js.map +0 -1
- package/dist/chunk-AZ2ZDFNP.js +0 -17
- package/dist/chunk-BMFHS3GV.js.map +0 -1
- package/dist/chunk-D222OCTV.js.map +0 -1
- package/dist/chunk-ESD5EQ5H.js +0 -178
- package/dist/chunk-ESD5EQ5H.js.map +0 -1
- package/dist/chunk-FFJWJ4OB.js.map +0 -1
- package/dist/chunk-GKAJ4EM2.js.map +0 -1
- package/dist/chunk-HFR6YROB.js.map +0 -1
- package/dist/chunk-IH3STE7W.js.map +0 -1
- package/dist/chunk-KOYTJW5E.js.map +0 -1
- package/dist/chunk-LKYW4LH6.js.map +0 -1
- package/dist/chunk-QGPRTUED.js.map +0 -1
- package/dist/chunk-QRXDXAQI.js.map +0 -1
- package/dist/chunk-R4K6VAOK.js.map +0 -1
- package/dist/chunk-RDYYP36I.js.map +0 -1
- package/dist/chunk-RGC2VFQO.js +0 -139
- package/dist/chunk-RGC2VFQO.js.map +0 -1
- package/dist/chunk-TAWTGCWJ.js +0 -113
- package/dist/chunk-TAWTGCWJ.js.map +0 -1
- package/dist/chunk-UDJ7ARCH.js +0 -140
- package/dist/chunk-UDJ7ARCH.js.map +0 -1
- package/dist/chunk-UQLTP3XB.js.map +0 -1
- package/dist/chunk-WQTMOUCA.js.map +0 -1
- package/dist/chunk-WZ5T2NXH.js +0 -702
- package/dist/chunk-WZ5T2NXH.js.map +0 -1
- package/dist/chunk-XGAYTDSI.js.map +0 -1
- package/dist/chunk-YZS2B6YE.js.map +0 -1
- package/dist/chunk-ZXRE2KZO.js.map +0 -1
- package/dist/core/error/theme.d.ts +0 -10
- package/dist/core/error/theme.d.ts.map +0 -1
- package/dist/core/kernel/adapters.d.ts.map +0 -1
- package/dist/core/kernel/compose.d.ts.map +0 -1
- package/dist/core/kernel/handlers.d.ts.map +0 -1
- package/dist/core/kernel/hooks.d.ts.map +0 -1
- package/dist/core/kernel/installed.d.ts.map +0 -1
- package/dist/core/kernel/module.d.ts.map +0 -1
- package/dist/core/kernel/operations-records.d.ts.map +0 -1
- package/dist/core/kernel/operations-resolve.d.ts +0 -5
- package/dist/core/kernel/operations-resolve.d.ts.map +0 -1
- package/dist/core/kernel/operations.d.ts.map +0 -1
- package/dist/core/kernel/page-controller.d.ts.map +0 -1
- package/dist/core/kernel/provider.d.ts.map +0 -1
- package/dist/core/kernel/runtime.d.ts.map +0 -1
- package/dist/core/kernel/schema.d.ts.map +0 -1
- package/dist/core/kernel/stabilize.d.ts.map +0 -1
- package/dist/core/kernel/store-batch.d.ts +0 -17
- package/dist/core/kernel/store-batch.d.ts.map +0 -1
- package/dist/core/kernel/store-entries.d.ts +0 -6
- package/dist/core/kernel/store-entries.d.ts.map +0 -1
- package/dist/core/kernel/store-handles.d.ts +0 -4
- package/dist/core/kernel/store-handles.d.ts.map +0 -1
- package/dist/core/kernel/store-registration.d.ts +0 -14
- package/dist/core/kernel/store-registration.d.ts.map +0 -1
- package/dist/core/kernel/store-snapshots.d.ts.map +0 -1
- package/dist/core/kernel/store-subscriptions.d.ts.map +0 -1
- package/dist/core/kernel/store.d.ts.map +0 -1
- package/dist/core/kernel/types-modules.d.ts.map +0 -1
- package/dist/core/kernel/types-page.d.ts.map +0 -1
- package/dist/core/kernel/types-store.d.ts.map +0 -1
- package/dist/core/kernel/types.d.ts.map +0 -1
- package/dist/core/navigation/navigator-defaults.d.ts +0 -4
- package/dist/core/navigation/navigator-defaults.d.ts.map +0 -1
- package/dist/core/navigation/navigator-holds.d.ts.map +0 -1
- package/dist/core/navigation/navigator-patience.d.ts.map +0 -1
- package/dist/core/navigation/navigator-payload.d.ts.map +0 -1
- package/dist/core/navigation/navigator-prefetch.d.ts.map +0 -1
- package/dist/foundation/recipes/anatomy.d.ts +0 -139
- package/dist/foundation/recipes/anatomy.d.ts.map +0 -1
- package/dist/foundation/recipes/define.d.ts +0 -133
- package/dist/foundation/recipes/define.d.ts.map +0 -1
- package/dist/modules/ambient/analyze-bounds.d.ts.map +0 -1
- package/dist/modules/ambient/analyze-clusters.d.ts.map +0 -1
- package/dist/modules/ambient/analyze-ground.d.ts.map +0 -1
- package/dist/modules/ambient/analyze-measures.d.ts.map +0 -1
- package/dist/modules/ambient/analyze-swatches.d.ts.map +0 -1
- package/dist/modules/ambient/analyze.d.ts.map +0 -1
- package/dist/modules/ambient/oklab.d.ts.map +0 -1
- package/dist/modules/ambient/quantize.d.ts.map +0 -1
- package/dist/modules/background/components/background-gradients.d.ts +0 -8
- package/dist/modules/background/components/background-gradients.d.ts.map +0 -1
- package/dist/modules/background/components/edge-gradient.d.ts +0 -9
- package/dist/modules/background/components/edge-gradient.d.ts.map +0 -1
- package/dist/modules/background/components/native-video.d.ts +0 -4
- package/dist/modules/background/components/native-video.d.ts.map +0 -1
- package/dist/modules/background/components/noise-overlay.d.ts +0 -11
- package/dist/modules/background/components/noise-overlay.d.ts.map +0 -1
- package/dist/modules/background/components/overlay.d.ts.map +0 -1
- package/dist/modules/background/components/solid-overlay.d.ts +0 -10
- package/dist/modules/background/components/solid-overlay.d.ts.map +0 -1
- package/dist/modules/background/hooks/use-background-media-source.d.ts +0 -4
- package/dist/modules/background/hooks/use-background-media-source.d.ts.map +0 -1
- package/dist/modules/background/hooks/use-background-motion-model.d.ts +0 -15
- package/dist/modules/background/hooks/use-background-motion-model.d.ts.map +0 -1
- package/dist/modules/background/hooks/use-background-overlay-model.d.ts +0 -929
- package/dist/modules/background/hooks/use-background-overlay-model.d.ts.map +0 -1
- package/dist/modules/background/hooks/use-native-video-model.d.ts.map +0 -1
- package/dist/modules/background/lib/theme.d.ts +0 -4
- package/dist/modules/background/lib/theme.d.ts.map +0 -1
- package/dist/modules/background/model/override.d.ts +0 -14
- package/dist/modules/background/model/override.d.ts.map +0 -1
- package/dist/modules/background/model/playback.d.ts.map +0 -1
- package/dist/modules/background/model/state.d.ts.map +0 -1
- package/dist/modules/background/model/video-frame.d.ts +0 -31
- package/dist/modules/background/model/video-frame.d.ts.map +0 -1
- package/dist/modules/background/model/visual.d.ts.map +0 -1
- package/dist/modules/background/youtube/components/player.d.ts.map +0 -1
- package/dist/modules/background/youtube/hooks/use-youtube-background-player-model.d.ts.map +0 -1
- package/dist/modules/background/youtube/hooks/use-youtube-iframe-player.d.ts +0 -20
- package/dist/modules/background/youtube/hooks/use-youtube-iframe-player.d.ts.map +0 -1
- package/dist/modules/background/youtube/hooks/use-youtube-stream-sources.d.ts +0 -8
- package/dist/modules/background/youtube/hooks/use-youtube-stream-sources.d.ts.map +0 -1
- package/dist/modules/background/youtube/hooks/use-youtube-video-sync.d.ts.map +0 -1
- package/dist/modules/background/youtube/lib/audio.d.ts.map +0 -1
- package/dist/modules/background/youtube/lib/iframe-engine.d.ts +0 -29
- package/dist/modules/background/youtube/lib/iframe-engine.d.ts.map +0 -1
- package/dist/modules/background/youtube/lib/iframe-proxy.d.ts +0 -47
- package/dist/modules/background/youtube/lib/iframe-proxy.d.ts.map +0 -1
- package/dist/modules/background/youtube/lib/iframe.d.ts +0 -47
- package/dist/modules/background/youtube/lib/iframe.d.ts.map +0 -1
- package/dist/modules/background/youtube/lib/parse.d.ts.map +0 -1
- package/dist/modules/background/youtube/lib/timing.d.ts.map +0 -1
- package/dist/modules/background/youtube/lib/video-events.d.ts.map +0 -1
- package/dist/modules/dock/components/badge.d.ts +0 -5
- package/dist/modules/dock/components/badge.d.ts.map +0 -1
- package/dist/modules/dock/components/breadcrumbs-card.d.ts.map +0 -1
- package/dist/modules/dock/components/card-banner.d.ts +0 -4
- package/dist/modules/dock/components/card-banner.d.ts.map +0 -1
- package/dist/modules/dock/components/card-header.d.ts +0 -4
- package/dist/modules/dock/components/card-header.d.ts.map +0 -1
- package/dist/modules/dock/components/card-item.d.ts.map +0 -1
- package/dist/modules/dock/components/command-bar.d.ts.map +0 -1
- package/dist/modules/dock/components/compact.d.ts.map +0 -1
- package/dist/modules/dock/components/description.d.ts +0 -4
- package/dist/modules/dock/components/description.d.ts.map +0 -1
- package/dist/modules/dock/components/dock.d.ts.map +0 -1
- package/dist/modules/dock/components/hud-view.d.ts.map +0 -1
- package/dist/modules/dock/components/icon.d.ts.map +0 -1
- package/dist/modules/dock/components/item-content.d.ts.map +0 -1
- package/dist/modules/dock/components/media-action.d.ts.map +0 -1
- package/dist/modules/dock/components/media-controls.d.ts +0 -4
- package/dist/modules/dock/components/media-controls.d.ts.map +0 -1
- package/dist/modules/dock/components/media-scrubber.d.ts.map +0 -1
- package/dist/modules/dock/components/status-actions.d.ts.map +0 -1
- package/dist/modules/dock/components/surface/action.d.ts.map +0 -1
- package/dist/modules/dock/components/surface/controls.d.ts +0 -12
- package/dist/modules/dock/components/surface/controls.d.ts.map +0 -1
- package/dist/modules/dock/components/surface/extensions-bar.d.ts.map +0 -1
- package/dist/modules/dock/components/surface/header-button.d.ts.map +0 -1
- package/dist/modules/dock/components/surface/item-content.d.ts.map +0 -1
- package/dist/modules/dock/components/surface/shell.d.ts +0 -3
- package/dist/modules/dock/components/surface/shell.d.ts.map +0 -1
- package/dist/modules/dock/components/title.d.ts +0 -4
- package/dist/modules/dock/components/title.d.ts.map +0 -1
- package/dist/modules/dock/hooks/use-action-slot.d.ts +0 -6
- package/dist/modules/dock/hooks/use-action-slot.d.ts.map +0 -1
- package/dist/modules/dock/hooks/use-badge.d.ts +0 -4
- package/dist/modules/dock/hooks/use-badge.d.ts.map +0 -1
- package/dist/modules/dock/hooks/use-card-banner-model.d.ts +0 -18
- package/dist/modules/dock/hooks/use-card-banner-model.d.ts.map +0 -1
- package/dist/modules/dock/hooks/use-card-header-model.d.ts +0 -7
- package/dist/modules/dock/hooks/use-card-header-model.d.ts.map +0 -1
- package/dist/modules/dock/hooks/use-command-bar-model.d.ts +0 -12
- package/dist/modules/dock/hooks/use-command-bar-model.d.ts.map +0 -1
- package/dist/modules/dock/hooks/use-dock-banner.d.ts +0 -11
- package/dist/modules/dock/hooks/use-dock-banner.d.ts.map +0 -1
- package/dist/modules/dock/hooks/use-dock-config.d.ts +0 -19
- package/dist/modules/dock/hooks/use-dock-config.d.ts.map +0 -1
- package/dist/modules/dock/hooks/use-dock-dimensions.d.ts +0 -7
- package/dist/modules/dock/hooks/use-dock-dimensions.d.ts.map +0 -1
- package/dist/modules/dock/hooks/use-dock-focus-trap.d.ts +0 -7
- package/dist/modules/dock/hooks/use-dock-focus-trap.d.ts.map +0 -1
- package/dist/modules/dock/hooks/use-dock-height-controller.d.ts +0 -6
- package/dist/modules/dock/hooks/use-dock-height-controller.d.ts.map +0 -1
- package/dist/modules/dock/hooks/use-dock-keyboard.d.ts +0 -11
- package/dist/modules/dock/hooks/use-dock-keyboard.d.ts.map +0 -1
- package/dist/modules/dock/hooks/use-dock-registration.d.ts +0 -8
- package/dist/modules/dock/hooks/use-dock-registration.d.ts.map +0 -1
- package/dist/modules/dock/hooks/use-dock-route-reset.d.ts +0 -2
- package/dist/modules/dock/hooks/use-dock-route-reset.d.ts.map +0 -1
- package/dist/modules/dock/hooks/use-dock-theme.d.ts +0 -6
- package/dist/modules/dock/hooks/use-dock-theme.d.ts.map +0 -1
- package/dist/modules/dock/hooks/use-dock-viewport.d.ts +0 -6
- package/dist/modules/dock/hooks/use-dock-viewport.d.ts.map +0 -1
- package/dist/modules/dock/hooks/use-element-height.d.ts +0 -3
- package/dist/modules/dock/hooks/use-element-height.d.ts.map +0 -1
- package/dist/modules/dock/hooks/use-hud-registry.d.ts +0 -16
- package/dist/modules/dock/hooks/use-hud-registry.d.ts.map +0 -1
- package/dist/modules/dock/hooks/use-hud-view-model.d.ts +0 -9
- package/dist/modules/dock/hooks/use-hud-view-model.d.ts.map +0 -1
- package/dist/modules/dock/hooks/use-media-controls-model.d.ts.map +0 -1
- package/dist/modules/dock/hooks/use-media-scrubber-model.d.ts +0 -27
- package/dist/modules/dock/hooks/use-media-scrubber-model.d.ts.map +0 -1
- package/dist/modules/dock/hooks/use-pending-skeleton.d.ts +0 -7
- package/dist/modules/dock/hooks/use-pending-skeleton.d.ts.map +0 -1
- package/dist/modules/dock/hooks/use-standard-item-content-model.d.ts +0 -12
- package/dist/modules/dock/hooks/use-standard-item-content-model.d.ts.map +0 -1
- package/dist/modules/dock/hooks/use-surface-return.d.ts +0 -8
- package/dist/modules/dock/hooks/use-surface-return.d.ts.map +0 -1
- package/dist/modules/dock/hud.d.ts.map +0 -1
- package/dist/modules/dock/lib/banner.d.ts.map +0 -1
- package/dist/modules/dock/lib/card-item.d.ts.map +0 -1
- package/dist/modules/dock/lib/card.d.ts +0 -20
- package/dist/modules/dock/lib/card.d.ts.map +0 -1
- package/dist/modules/dock/lib/command-bar.d.ts +0 -8
- package/dist/modules/dock/lib/command-bar.d.ts.map +0 -1
- package/dist/modules/dock/lib/dom.d.ts +0 -7
- package/dist/modules/dock/lib/dom.d.ts.map +0 -1
- package/dist/modules/dock/lib/element-helpers.d.ts +0 -8
- package/dist/modules/dock/lib/element-helpers.d.ts.map +0 -1
- package/dist/modules/dock/lib/helpers.d.ts.map +0 -1
- package/dist/modules/dock/lib/media.d.ts.map +0 -1
- package/dist/modules/dock/lib/styles.d.ts.map +0 -1
- package/dist/modules/dock/model/hud-definition.d.ts.map +0 -1
- package/dist/modules/dock/model/hud.d.ts +0 -10
- package/dist/modules/dock/model/hud.d.ts.map +0 -1
- package/dist/modules/dock/model/layout.d.ts.map +0 -1
- package/dist/modules/dock/model/page-entry.d.ts +0 -11
- package/dist/modules/dock/model/page-entry.d.ts.map +0 -1
- package/dist/modules/dock/model/page-surface.d.ts +0 -4
- package/dist/modules/dock/model/page-surface.d.ts.map +0 -1
- package/dist/modules/dock/model/paths.d.ts.map +0 -1
- package/dist/modules/dock/model/state.d.ts +0 -28
- package/dist/modules/dock/model/state.d.ts.map +0 -1
- package/dist/modules/dock/model/surface-return.d.ts +0 -14
- package/dist/modules/dock/model/surface-return.d.ts.map +0 -1
- package/dist/modules/dock/routing/hooks/use-route-prefetch.d.ts.map +0 -1
- package/dist/modules/dock/routing/lib/restore.d.ts +0 -7
- package/dist/modules/dock/routing/lib/restore.d.ts.map +0 -1
- package/dist/modules/dock/routing/model/continuity.d.ts.map +0 -1
- package/dist/modules/dock/routing/model/policy.d.ts.map +0 -1
- package/dist/modules/dock/routing/model/topology.d.ts.map +0 -1
- package/dist/modules/dock/runtime/commands.d.ts.map +0 -1
- package/dist/modules/dock/runtime/display.d.ts.map +0 -1
- package/dist/modules/dock/runtime/dock.d.ts.map +0 -1
- package/dist/modules/dock/runtime/hooks/use-dock-expansion.d.ts +0 -10
- package/dist/modules/dock/runtime/hooks/use-dock-expansion.d.ts.map +0 -1
- package/dist/modules/dock/runtime/hooks/use-dock-layout.d.ts +0 -10
- package/dist/modules/dock/runtime/hooks/use-dock-layout.d.ts.map +0 -1
- package/dist/modules/dock/runtime/hooks/use-dock-operation-state.d.ts +0 -14
- package/dist/modules/dock/runtime/hooks/use-dock-operation-state.d.ts.map +0 -1
- package/dist/modules/dock/runtime/hooks/use-dock-route-bridge.d.ts +0 -7
- package/dist/modules/dock/runtime/hooks/use-dock-route-bridge.d.ts.map +0 -1
- package/dist/modules/dock/runtime/hooks/use-dock.d.ts.map +0 -1
- package/dist/modules/dock/runtime/model/attention.d.ts +0 -25
- package/dist/modules/dock/runtime/model/attention.d.ts.map +0 -1
- package/dist/modules/dock/runtime/model/cards.d.ts.map +0 -1
- package/dist/modules/dock/runtime/model/items.d.ts.map +0 -1
- package/dist/modules/dock/runtime/model/layout.d.ts +0 -10
- package/dist/modules/dock/runtime/model/layout.d.ts.map +0 -1
- package/dist/modules/dock/runtime/pipeline.d.ts.map +0 -1
- package/dist/modules/dock/runtime/provider-actions.d.ts +0 -38
- package/dist/modules/dock/runtime/provider-actions.d.ts.map +0 -1
- package/dist/modules/dock/status/action-options.d.ts +0 -35
- package/dist/modules/dock/status/action-options.d.ts.map +0 -1
- package/dist/modules/dock/surface/components/surface-extensions-provider.d.ts +0 -5
- package/dist/modules/dock/surface/components/surface-extensions-provider.d.ts.map +0 -1
- package/dist/modules/dock/surface/components/surface-flow-provider.d.ts +0 -7
- package/dist/modules/dock/surface/components/surface-flow-provider.d.ts.map +0 -1
- package/dist/modules/dock/surface/constants.d.ts +0 -5
- package/dist/modules/dock/surface/constants.d.ts.map +0 -1
- package/dist/modules/dock/surface/hooks/use-surface-controls-model.d.ts +0 -15
- package/dist/modules/dock/surface/hooks/use-surface-controls-model.d.ts.map +0 -1
- package/dist/modules/dock/surface/hooks/use-surface-extensions-bar-model.d.ts +0 -7
- package/dist/modules/dock/surface/hooks/use-surface-extensions-bar-model.d.ts.map +0 -1
- package/dist/modules/dock/surface/hooks/use-surface-extensions.d.ts +0 -14
- package/dist/modules/dock/surface/hooks/use-surface-extensions.d.ts.map +0 -1
- package/dist/modules/dock/surface/hooks/use-surface-flow.d.ts.map +0 -1
- package/dist/modules/dock/surface/hooks/use-surface-header-button-model.d.ts +0 -13
- package/dist/modules/dock/surface/hooks/use-surface-header-button-model.d.ts.map +0 -1
- package/dist/modules/dock/surface/hooks/use-surface-shell-model.d.ts.map +0 -1
- package/dist/modules/dock/surface/lib/drag.d.ts +0 -9
- package/dist/modules/dock/surface/lib/drag.d.ts.map +0 -1
- package/dist/modules/dock/surface/lib/target.d.ts +0 -8
- package/dist/modules/dock/surface/lib/target.d.ts.map +0 -1
- package/dist/modules/dock/surface/machine.d.ts.map +0 -1
- package/dist/modules/dock/surface/model/builder.d.ts.map +0 -1
- package/dist/modules/dock/surface/model/normalize.d.ts.map +0 -1
- package/dist/modules/dock/surface/model/open.d.ts +0 -26
- package/dist/modules/dock/surface/model/open.d.ts.map +0 -1
- package/dist/modules/dock/surface/model/records.d.ts.map +0 -1
- package/dist/modules/dock/surface/model/steps.d.ts +0 -9
- package/dist/modules/dock/surface/model/steps.d.ts.map +0 -1
- package/dist/modules/dock/surface/model/transition-state.d.ts.map +0 -1
- package/dist/modules/dock/surface/model/url.d.ts.map +0 -1
- package/dist/modules/dock/surface/runtime/context.d.ts +0 -29
- package/dist/modules/dock/surface/runtime/context.d.ts.map +0 -1
- package/dist/modules/dock/surface/runtime/release.d.ts +0 -9
- package/dist/modules/dock/surface/runtime/release.d.ts.map +0 -1
- package/dist/modules/dock/surface/stack.d.ts.map +0 -1
- package/dist/modules/dock/types/compact.d.ts +0 -13
- package/dist/modules/dock/types/compact.d.ts.map +0 -1
- package/dist/modules/modal/components/close-button.d.ts +0 -6
- package/dist/modules/modal/components/close-button.d.ts.map +0 -1
- package/dist/modules/modal/components/modal-container.d.ts.map +0 -1
- package/dist/modules/modal/components/modal-layer-switcher.d.ts +0 -9
- package/dist/modules/modal/components/modal-layer-switcher.d.ts.map +0 -1
- package/dist/modules/modal/components/modal-layer.d.ts +0 -17
- package/dist/modules/modal/components/modal-layer.d.ts.map +0 -1
- package/dist/modules/modal/components/overlay.d.ts.map +0 -1
- package/dist/modules/modal/components/resolve-header.d.ts +0 -10
- package/dist/modules/modal/components/resolve-header.d.ts.map +0 -1
- package/dist/modules/modal/components/slot-row.d.ts +0 -12
- package/dist/modules/modal/components/slot-row.d.ts.map +0 -1
- package/dist/modules/modal/hooks/use-mobile-viewport.d.ts +0 -3
- package/dist/modules/modal/hooks/use-mobile-viewport.d.ts.map +0 -1
- package/dist/modules/modal/hooks/use-modal-focus-trap.d.ts +0 -12
- package/dist/modules/modal/hooks/use-modal-focus-trap.d.ts.map +0 -1
- package/dist/modules/modal/hooks/use-modal-scroll-lock.d.ts +0 -3
- package/dist/modules/modal/hooks/use-modal-scroll-lock.d.ts.map +0 -1
- package/dist/modules/modal/lib/dom.d.ts.map +0 -1
- package/dist/modules/modal/lib/theme.d.ts +0 -4
- package/dist/modules/modal/lib/theme.d.ts.map +0 -1
- package/dist/modules/modal/model/entry.d.ts +0 -18
- package/dist/modules/modal/model/entry.d.ts.map +0 -1
- package/dist/modules/modal/model/header.d.ts +0 -16
- package/dist/modules/modal/model/header.d.ts.map +0 -1
- package/dist/modules/modal/model/identity.d.ts +0 -13
- package/dist/modules/modal/model/identity.d.ts.map +0 -1
- package/dist/modules/modal/model/layout.d.ts.map +0 -1
- package/dist/modules/modal/model/state.d.ts +0 -10
- package/dist/modules/modal/model/state.d.ts.map +0 -1
- package/dist/overlay-7QLGWHCH.js +0 -13
- package/dist/react/hooks/types.d.ts +0 -25
- package/dist/react/hooks/types.d.ts.map +0 -1
- package/dist/react/ui/components/avatar.d.ts +0 -6
- package/dist/react/ui/components/avatar.d.ts.map +0 -1
- package/dist/react/ui/components/button.d.ts +0 -6
- package/dist/react/ui/components/button.d.ts.map +0 -1
- package/dist/react/ui/components/carousel.d.ts +0 -6
- package/dist/react/ui/components/carousel.d.ts.map +0 -1
- package/dist/react/ui/components/checkbox.d.ts +0 -10
- package/dist/react/ui/components/checkbox.d.ts.map +0 -1
- package/dist/react/ui/components/icon.d.ts +0 -6
- package/dist/react/ui/components/icon.d.ts.map +0 -1
- package/dist/react/ui/components/image.d.ts +0 -6
- package/dist/react/ui/components/image.d.ts.map +0 -1
- package/dist/react/ui/components/indicator.d.ts +0 -45
- package/dist/react/ui/components/indicator.d.ts.map +0 -1
- package/dist/react/ui/components/input.d.ts +0 -10
- package/dist/react/ui/components/input.d.ts.map +0 -1
- package/dist/react/ui/components/loader.d.ts +0 -10
- package/dist/react/ui/components/loader.d.ts.map +0 -1
- package/dist/react/ui/components/segmented.d.ts +0 -6
- package/dist/react/ui/components/segmented.d.ts.map +0 -1
- package/dist/react/ui/components/select-parts.d.ts +0 -22
- package/dist/react/ui/components/select-parts.d.ts.map +0 -1
- package/dist/react/ui/components/select.d.ts +0 -6
- package/dist/react/ui/components/select.d.ts.map +0 -1
- package/dist/react/ui/components/skeleton.d.ts +0 -10
- package/dist/react/ui/components/skeleton.d.ts.map +0 -1
- package/dist/react/ui/components/switch.d.ts +0 -6
- package/dist/react/ui/components/switch.d.ts.map +0 -1
- package/dist/react/ui/components/tooltip-group.d.ts +0 -34
- package/dist/react/ui/components/tooltip-group.d.ts.map +0 -1
- package/dist/react/ui/components/tooltip-placement.d.ts +0 -43
- package/dist/react/ui/components/tooltip-placement.d.ts.map +0 -1
- package/dist/react/ui/components/tooltip-slot.d.ts +0 -23
- package/dist/react/ui/components/tooltip-slot.d.ts.map +0 -1
- package/dist/react/ui/components/tooltip.d.ts +0 -13
- package/dist/react/ui/components/tooltip.d.ts.map +0 -1
- package/dist/react/ui/index.d.ts +0 -19
- package/dist/react/ui/index.d.ts.map +0 -1
- package/dist/react/ui/provider.d.ts +0 -22
- package/dist/react/ui/provider.d.ts.map +0 -1
- package/dist/react/ui/types-controls.d.ts +0 -133
- package/dist/react/ui/types-controls.d.ts.map +0 -1
- package/dist/react/ui/types.d.ts +0 -213
- package/dist/react/ui/types.d.ts.map +0 -1
- package/dist/react/ui/utils.d.ts +0 -65
- package/dist/react/ui/utils.d.ts.map +0 -1
- package/dist/ui/index.d.ts +0 -1
- package/dist/ui/index.js +0 -2268
- package/dist/ui/index.js.map +0 -1
- package/docs/proposals/navigation.md +0 -210
- /package/dist/modules/ambient/{quantize.d.ts → analysis/quantize.d.ts} +0 -0
- /package/dist/modules/background/{components/overlay.d.ts → overlay.d.ts} +0 -0
- /package/dist/modules/background/{model/playback.d.ts → playback.d.ts} +0 -0
- /package/dist/modules/background/youtube/{lib/audio.d.ts → audio.d.ts} +0 -0
- /package/dist/modules/dock/{components → card}/compact.d.ts +0 -0
- /package/dist/modules/dock/{components → commands}/command-bar.d.ts +0 -0
- /package/dist/modules/dock/{components → routing}/breadcrumbs-card.d.ts +0 -0
- /package/dist/modules/dock/{model → routing}/paths.d.ts +0 -0
- /package/dist/modules/dock/{components → stack}/dock.d.ts +0 -0
- /package/dist/modules/dock/surface/{model → runtime}/url.d.ts +0 -0
- /package/dist/modules/modal/{lib/dom.d.ts → dom.d.ts} +0 -0
- /package/dist/modules/modal/{components/overlay.d.ts → overlay.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -1,73 +1,56 @@
|
|
|
1
1
|
# @omerdlw/base-framework
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A microkernel and a set of declarative UI modules for app-like Next.js (App Router) and React 19 products.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@omerdlw/base-framework)
|
|
6
6
|
[](https://opensource.org/licenses/MIT)
|
|
7
|
-
[](https://www.typescriptlang.org/)
|
|
8
|
-
[](https://react.dev/)
|
|
9
7
|
|
|
10
|
-
|
|
8
|
+
A page describes the chrome it needs (its dock card, background, modals, loading state) in one `usePage()` call. The kernel collects those declarations from every mounted route, resolves conflicts by priority and lifecycle, and hands each slice to the module that renders it. Modules never import each other's internals; they meet through typed contracts, peers and an event bus.
|
|
11
9
|
|
|
12
|
-
|
|
10
|
+
The framework holds no design. Every class, timing and icon comes from the app's theme, so two products built on it look nothing alike.
|
|
13
11
|
|
|
14
|
-
|
|
12
|
+
## Architecture
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
- ⚙️ **[Core Engine Deep Dive](./docs/core-engine.md)** — CoreProvider, theme engine, event bus, pure utils & stores
|
|
24
|
-
- 🧪 **[Testing Guide](./docs/testing.md)** — 740-test suite, test harness, happy-dom, downstream testing
|
|
25
|
-
- 🤖 **[AI Agent Blueprint (`AGENTS.md`)](./templates/AGENTS.md)** — Drop-in rules for AI coding assistants
|
|
26
|
-
|
|
27
|
-
### Module & Component Reference
|
|
28
|
-
|
|
29
|
-
- ⚡ **[Microkernel Engine (`kernel`)](./docs/modules/kernel.md)** — `usePage()`, `defineModule()`, topological registry
|
|
30
|
-
- ⚓ **[Dock Module (`dock`)](./docs/modules/dock.md)** — Floating app chrome, cards, surfaces, flows, HUD, guards
|
|
31
|
-
- 🪟 **[Modal Module (`modal`)](./docs/modules/modal.md)** — Stackable dialogs, focus trap, smooth scroll lock
|
|
32
|
-
- 🔔 **[Notification Module (`notification`)](./docs/modules/notification.md)** — Toasts, `toast.fromResult`, auto 401 listener
|
|
33
|
-
- 🎨 **[Ambient Lighting (`ambient`)](./docs/modules/ambient.md)** — Media color extraction, OKLCH canvas glow
|
|
34
|
-
- 🖼️ **[Background Canvas (`background`)](./docs/modules/background.md)** — Multi-layer video, YouTube loop, cross-fades
|
|
35
|
-
- 🖱️ **[Context Menu (`context-menu`)](./docs/modules/context-menu.md)** — Viewport clamping, declarative menus
|
|
36
|
-
- 🎛️ **[Controls Module (`controls`)](./docs/modules/controls.md)** — Paired HUD action rails beside the dock
|
|
37
|
-
- ⏳ **[Loading & Skeleton (`loading`)](./docs/modules/loading.md)** — Coordinated loading, anti-flicker delay
|
|
38
|
-
- 🧭 **[Navigation (`navigation`)](./docs/modules/navigation.md)** — Exit holds, payload for the next page, back-button hold, intent prefetch
|
|
39
|
-
- 🎵 **[Media Transport (`media`)](./docs/modules/media.md)** — Session sync, leader vs audible displacement
|
|
40
|
-
- 🔒 **[Result Pattern (`result`)](./docs/modules/result.md)** — Functional `Result<T, E>`, `ok()`, `err()`
|
|
41
|
-
- 🛡️ **[Error Boundary (`error-boundary`)](./docs/modules/error-boundary.md)** — Isolated boundaries, deduplicating reporter
|
|
14
|
+
```
|
|
15
|
+
src/
|
|
16
|
+
├── foundation/ Layer 0 Pure and server-safe: Result, event bus, utils, recipes
|
|
17
|
+
├── react/ Layer 1 React primitives: hooks, theme, headless UI components
|
|
18
|
+
├── core/ Layer 2 Kernel (registry, module host, usePage), errors, navigation
|
|
19
|
+
└── modules/ Layer 3 dock, modal, notification, background, ambient, …
|
|
20
|
+
```
|
|
42
21
|
|
|
43
|
-
|
|
22
|
+
- **Layers only import downwards.** The foundation never touches React or the DOM and is safe in Server Components and Edge functions.
|
|
23
|
+
- **Modules are isolated.** A module reaches another only through its public barrel, and only when it declares it in `uses`.
|
|
24
|
+
- **Code is grouped by feature.** Small modules use one flat folder; the dock splits into `stack/`, `card/`, `routing/`, `surface/` and so on.
|
|
44
25
|
|
|
45
|
-
|
|
26
|
+
`npm run check:architecture` enforces the first two, along with the absence of import cycles and a 500-line limit per file. The full set of rules is in [docs/architecture-and-rules.md](./docs/architecture-and-rules.md).
|
|
46
27
|
|
|
47
|
-
|
|
48
|
-
- 🧩 **First-Party Declarative UI Modules:** 10 production-tested modules (`dock`, `modal`, `notification`, `ambient`, `background`, `context-menu`, `controls`, `loading`, `media`, `navigation`) that communicate strictly through typed contracts without tight coupling.
|
|
49
|
-
- 🎯 **Single Route Declaration (`usePage`):** Cleanly declare titles, navigation cards, modals, loading states, and background media in a single atomic hook call.
|
|
50
|
-
- 🔒 **Type-Safe Result Pattern (`Result<T, E>`):** Functional, bulletproof error handling with `ok()`, `err()`, and direct feedback bridging via `toast.fromResult()`.
|
|
51
|
-
- 🛡️ **Cross-Bundle Context Deduplication:** Guarantees stable React Context singletons across Next.js split chunks and monorepo boundaries.
|
|
52
|
-
- 🎨 **No design inside:** no CSS, tokens or motion values. Modules and components take every class, timing and icon from your app's theme and `defineUi`.
|
|
28
|
+
## Modules
|
|
53
29
|
|
|
54
|
-
|
|
30
|
+
| Module | What it does |
|
|
31
|
+
| :----------------------------------------------- | :---------------------------------------------------------------------- |
|
|
32
|
+
| [`dock`](./docs/modules/dock.md) | Floating app chrome: route cards, surfaces and flows, HUD, guards. |
|
|
33
|
+
| [`modal`](./docs/modules/modal.md) | Stackable dialogs with focus trap and scroll lock. |
|
|
34
|
+
| [`notification`](./docs/modules/notification.md) | Toasts, `toast.fromResult`, session-expiry handling. |
|
|
35
|
+
| [`navigation`](./docs/modules/navigation.md) | Exit holds, payloads for the next page, back-button holds, prefetch. |
|
|
36
|
+
| [`background`](./docs/modules/background.md) | Layered video and image backgrounds, YouTube loops, cross-fades. |
|
|
37
|
+
| [`ambient`](./docs/modules/ambient.md) | Palette extraction from media, applied as CSS variables. |
|
|
38
|
+
| [`context-menu`](./docs/modules/context-menu.md) | Declarative, route-aware context menus. |
|
|
39
|
+
| [`controls`](./docs/modules/controls.md) | Paired action rails beside the dock. |
|
|
40
|
+
| [`loading`](./docs/modules/loading.md) | Coordinated loading states with an anti-flicker delay. |
|
|
41
|
+
| [`media`](./docs/modules/media.md) | One media session across players, with audible and leader displacement. |
|
|
55
42
|
|
|
56
|
-
##
|
|
43
|
+
## Installation
|
|
57
44
|
|
|
58
45
|
```bash
|
|
59
46
|
npm install @omerdlw/base-framework motion
|
|
60
47
|
```
|
|
61
48
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
Requires Node `>=22`. Upgrading from 3.x? See [MIGRATION.md](./MIGRATION.md).
|
|
49
|
+
Peer dependencies: `next >= 15`, `react >= 19.2`, `react-dom >= 19.2`, `motion >= 12`. Node 22 or later. Upgrading from 3.x? See [MIGRATION.md](./MIGRATION.md).
|
|
65
50
|
|
|
66
|
-
|
|
51
|
+
## Quick start
|
|
67
52
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
### 1. Configure Providers in Your Next.js App
|
|
53
|
+
### 1. Install the modules
|
|
71
54
|
|
|
72
55
|
Create your client providers component (e.g. `src/app/providers.tsx`):
|
|
73
56
|
|
|
@@ -119,7 +102,7 @@ export default function RootLayout({
|
|
|
119
102
|
}
|
|
120
103
|
```
|
|
121
104
|
|
|
122
|
-
### 2. Tailwind
|
|
105
|
+
### 2. Let Tailwind see the package
|
|
123
106
|
|
|
124
107
|
Add the package path to your `@source` scanning inside `src/app/globals.css`:
|
|
125
108
|
|
|
@@ -128,7 +111,7 @@ Add the package path to your `@source` scanning inside `src/app/globals.css`:
|
|
|
128
111
|
@source "../node_modules/@omerdlw/base-framework";
|
|
129
112
|
```
|
|
130
113
|
|
|
131
|
-
### 3. Declare
|
|
114
|
+
### 3. Declare a page
|
|
132
115
|
|
|
133
116
|
In any route client component:
|
|
134
117
|
|
|
@@ -165,33 +148,34 @@ export default function DashboardPage() {
|
|
|
165
148
|
}
|
|
166
149
|
```
|
|
167
150
|
|
|
168
|
-
|
|
151
|
+
## Public entry points
|
|
152
|
+
|
|
153
|
+
| Subpath | Purpose & Key Exports |
|
|
154
|
+
| :
|
|
155
|
+
|
|
156
|
+
Only these subpaths are public. File paths inside `dist/` are not part of the API.
|
|
169
157
|
|
|
170
|
-
##
|
|
158
|
+
## Documentation
|
|
171
159
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
| `@omerdlw/base-framework/theme` | `ThemeProvider`, `useTheme`, `defineThemeSpec` |
|
|
180
|
-
| `@omerdlw/base-framework/ui` | Unstyled components the app gives a look (`Button`, `Icon`, `Select`, …) |
|
|
181
|
-
| `@omerdlw/base-framework/recipes` | Server-safe `defineUi`, recipes, `cn`, `createCn`, `ANATOMY` |
|
|
182
|
-
| `@omerdlw/base-framework/utils` | Pure utilities (`report`, `createStore`, `createScheduler`, `defineMotion`) |
|
|
183
|
-
| `@omerdlw/base-framework/hooks` | Essential hooks (`useClickOutside`, `useGlobalEvent`, `useStore`) |
|
|
184
|
-
| `@omerdlw/base-framework/error` | Error boundaries (`GlobalError`, `ModuleError`, `ComponentError`) and `getErrorReporter` |
|
|
185
|
-
| `@omerdlw/base-framework/<module>` | 10 standalone modules (`dock`, `modal`, `notification`, `navigation`, etc.) |
|
|
160
|
+
- [Getting started](./docs/getting-started.md): installation, Tailwind, root layout
|
|
161
|
+
- [Architecture and rules](./docs/architecture-and-rules.md): layers, module layout, the ten rules
|
|
162
|
+
- [Core engine](./docs/core-engine.md): `CoreProvider`, themes, event bus, stores
|
|
163
|
+
- [Theming](./docs/theming.md): `defineTheme`, `ThemeProvider`, motion tokens
|
|
164
|
+
- [Custom modules](./docs/custom-modules.md): writing a module with `defineModule` and `usePage`
|
|
165
|
+
- [Module reference](./docs/modules/README.md): one page per module
|
|
166
|
+
- [Testing](./docs/testing.md): the test harness and testing downstream apps
|
|
186
167
|
|
|
187
|
-
|
|
168
|
+
Working with an AI coding assistant? Copy [`templates/AGENTS.md`](./templates/AGENTS.md) into your app as `AGENTS.md`.
|
|
188
169
|
|
|
189
|
-
##
|
|
170
|
+
## Development
|
|
190
171
|
|
|
191
|
-
|
|
172
|
+
```bash
|
|
173
|
+
npm install
|
|
174
|
+
npm run verify # format, lint, type-check, architecture, tests, build, dist smoke tests
|
|
175
|
+
```
|
|
192
176
|
|
|
193
|
-
|
|
177
|
+
Tests run with Node's built-in test runner on the uncompiled source; the build compiles client entries with the React Compiler and smoke-tests the bundle.
|
|
194
178
|
|
|
195
|
-
##
|
|
179
|
+
## License
|
|
196
180
|
|
|
197
181
|
MIT © [Ömer Deliavcı](https://github.com/omerdlw)
|
package/dist/ambient/index.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
export { AMBIENT_ANALYSIS_VERSION, AMBIENT_REGIONS, AMBIENT_ROLES, AMBIENT_TONES, AmbientContext, AmbientProvider, DEFAULT_ANALYSIS, DEFAULT_CSS_VAR_NAMES, DEFAULT_LINGER_MS, ambientModule, ambientTheme, analyzeAmbientPixels, applyScopedCssVariables, configureAmbient, contrastRatio, defineAmbient, extractPaletteFromImage, findContentBounds, formatOklch, getAmbientSettings, getCachedAmbientPalette, maxChroma, normalizeColorMap, onColorFor, paletteVarMap, primeAmbientPalette, resolveAmbientVarMap, resolveCssVarNames, resolvePageAmbientTheme, resolveTargetElement, skinLikeness, srgbToOklab, toneOf, useAmbient, useAmbientColor, useAmbientTheme } from '../chunk-
|
|
3
|
-
import '../chunk-
|
|
4
|
-
import '../chunk-
|
|
5
|
-
import '../chunk-
|
|
6
|
-
import '../chunk-
|
|
7
|
-
import '../chunk-
|
|
8
|
-
import '../chunk-
|
|
9
|
-
import '../chunk-
|
|
10
|
-
import '../chunk-D222OCTV.js';
|
|
2
|
+
export { AMBIENT_ANALYSIS_VERSION, AMBIENT_REGIONS, AMBIENT_ROLES, AMBIENT_TONES, AmbientContext, AmbientProvider, DEFAULT_ANALYSIS, DEFAULT_CSS_VAR_NAMES, DEFAULT_LINGER_MS, ambientModule, ambientTheme, analyzeAmbientPixels, applyScopedCssVariables, configureAmbient, contrastRatio, defineAmbient, extractPaletteFromImage, findContentBounds, formatOklch, getAmbientSettings, getCachedAmbientPalette, maxChroma, normalizeColorMap, onColorFor, paletteVarMap, primeAmbientPalette, resolveAmbientVarMap, resolveCssVarNames, resolvePageAmbientTheme, resolveTargetElement, skinLikeness, srgbToOklab, toneOf, useAmbient, useAmbientColor, useAmbientTheme } from '../chunk-EXB7VFD3.js';
|
|
3
|
+
import '../chunk-6P3F4JU3.js';
|
|
4
|
+
import '../chunk-C3SEBNF5.js';
|
|
5
|
+
import '../chunk-GG2ILNK2.js';
|
|
6
|
+
import '../chunk-ED32WLAD.js';
|
|
7
|
+
import '../chunk-JWUKAZ3A.js';
|
|
8
|
+
import '../chunk-AKPH5CEJ.js';
|
|
9
|
+
import '../chunk-S67HGKJ2.js';
|
|
11
10
|
import '../chunk-J3VTDBC6.js';
|
|
12
|
-
import '../chunk-
|
|
11
|
+
import '../chunk-YHWA7FXX.js';
|
|
13
12
|
//# sourceMappingURL=index.js.map
|
|
14
13
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { resolveAnalysis, analyzeAmbientPixels } from '../../chunk-
|
|
2
|
-
export { AMBIENT_ANALYSIS_VERSION, analyzeAmbientPixels, configureAmbient, contrastRatio, findContentBounds, fitSample, formatOklch, getAmbientSettings, maxChroma, onColorFor, srgbToOklab, toneOf } from '../../chunk-
|
|
1
|
+
import { resolveAnalysis, analyzeAmbientPixels } from '../../chunk-ZQI4ZCVU.js';
|
|
2
|
+
export { AMBIENT_ANALYSIS_VERSION, analyzeAmbientPixels, configureAmbient, contrastRatio, findContentBounds, fitSample, formatOklch, getAmbientSettings, maxChroma, onColorFor, srgbToOklab, toneOf } from '../../chunk-ZQI4ZCVU.js';
|
|
3
3
|
|
|
4
4
|
// src/modules/ambient/server/address.ts
|
|
5
5
|
var PRIVATE_NAMES = /(^|\.)(localhost|local|internal|intranet|lan|home\.arpa|localdomain)$/;
|
|
@@ -70,6 +70,7 @@ var CACHE_LIMIT = 500;
|
|
|
70
70
|
var MAX_REDIRECTS = 5;
|
|
71
71
|
var REDIRECT_STATUS_MIN = 300;
|
|
72
72
|
var REDIRECT_STATUS_MAX = 400;
|
|
73
|
+
var SHARP = "sharp";
|
|
73
74
|
function isPublicImageUrl(url) {
|
|
74
75
|
return (url.protocol === "https:" || url.protocol === "http:") && !url.username && !url.password && !isPrivateHostname(url.hostname);
|
|
75
76
|
}
|
|
@@ -96,7 +97,6 @@ var AmbientDecoderMissingError = class extends Error {
|
|
|
96
97
|
name = "AmbientDecoderMissingError";
|
|
97
98
|
};
|
|
98
99
|
var sharpModule = null;
|
|
99
|
-
var SHARP = "sharp";
|
|
100
100
|
function loadSharp() {
|
|
101
101
|
sharpModule ??= import(
|
|
102
102
|
/* webpackIgnore: true */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/modules/ambient/server/address.ts","../../../src/modules/ambient/server/index.ts"],"names":["PRIVATE_NAMES","normalizeHost","hostname","toLowerCase","replace","parseIPv4","value","parts","split","length","bytes","map","part","test","Number","NaN","every","byte","isPrivateIPv4","a","b","c","parseIPv6","text","tail","exec","v4","toString","halves","read","head","rest","missing","groups","Array","fill","words","group","parseInt","word","isPrivateIPv6","w0","w1","w2","w3","w4","w5","w6","w7","embedded","slice","isPrivateAddress","address","host","v6","isIpLiteral","isPrivateHostname","includes","MAX_BYTES","TIMEOUT_MS","CACHE_LIMIT","MAX_REDIRECTS","REDIRECT_STATUS_MIN","REDIRECT_STATUS_MAX","isPublicImageUrl","url","protocol","username","password","lookupAll","lookup","all","verbatim","entry","reachesOnlyPublic","resolve","addresses","some","AmbientDecoderMissingError","Error","name","sharpModule","SHARP","loadSharp","then","mod","default","catch","error","cause","sharpDecoder","size","sharp","data","info","failOn","rotate","resize","fit","withoutEnlargement","ensureAlpha","raw","toBuffer","resolveWithObject","height","width","readLimited","response","maxBytes","declared","headers","get","body","Uint8Array","arrayBuffer","reader","getReader","chunks","done","byteLength","cancel","push","offset","chunk","set","extractAmbientPaletteFromBytes","options","analysis","resolveAnalysis","pixels","decode","sampleSize","analyzeAmbientPixels","cache","Map","inFlight","remember","key","palette","delete","oldest","keys","next","undefined","fetchAndExtract","allow","doFetch","fetch","signal","AbortSignal","timeout","timeoutMs","current","hop","init","redirect","status","location","URL","ok","type","startsWith","source","href","extractAmbientPalette","src","useCache","JSON","stringify","hit","pending","task","shared","finally"],"mappings":";;;;AAAA,IAAMA,aAAAA,GACJ,uEAAA;AAEK,SAASC,cAAcC,QAAAA,EAA0B;AACtD,EAAA,OAAOA,QAAAA,CACJC,aAAY,CACZC,OAAAA,CAAQ,QAAQ,EAAE,CAAA,CAClBA,OAAAA,CAAQ,UAAA,EAAY,EAAE,CAAA;AAC3B;AAEA,SAASC,UAAUC,KAAAA,EAAgC;AACjD,EAAA,MAAMC,KAAAA,GAAQD,KAAAA,CAAME,KAAAA,CAAM,GAAG,CAAA;AAC7B,EAAA,IAAID,KAAAA,CAAME,MAAAA,KAAW,CAAA,EAAG,OAAO,IAAA;AAC/B,EAAA,MAAMC,KAAAA,GAAQH,KAAAA,C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GAAG,CAAC,CAAA;AACrCF,EAAAA,QAAAA,CAASX,GAAAA,CAAIa,KAAKmC,MAAM,CAAA;AACxB,EAAA,OAAOA,MAAAA;AACT","file":"index.js","sourcesContent":["const PRIVATE_NAMES =\n /(^|\\.)(localhost|local|internal|intranet|lan|home\\.arpa|localdomain)$/;\n\nexport function normalizeHost(hostname: string): string {\n return hostname\n .toLowerCase()\n .replace(/\\.+$/, \"\")\n .replace(/^\\[|\\]$/g, \"\");\n}\n\nfunction parseIPv4(value: string): number[] | null {\n const parts = value.split(\".\");\n if (parts.length !== 4) return null;\n const bytes = parts.map((part) =>\n /^\\d{1,3}$/.test(part) ? Number(part) : NaN,\n );\n return bytes.every((byte) => byte >= 0 && byte <= 255) ? bytes : null;\n}\n\nfunction isPrivateIPv4([a, b, c]: number[]): boolean {\n return (\n a === 0 ||\n a === 10 ||\n a === 127 ||\n (a === 100 && b >= 64 && b <= 127) ||\n (a === 169 && b === 254) ||\n (a === 172 && b >= 16 && b <= 31) ||\n (a === 192 && b === 168) ||\n (a === 192 && b === 0 && c === 0) ||\n (a === 198 && (b === 18 || b === 19)) ||\n a >= 224\n );\n}\n\nfunction parseIPv6(value: string): number[] | null {\n let text = value.split(\"%\")[0];\n const tail = /^(.*:)(\\d+\\.\\d+\\.\\d+\\.\\d+)$/.exec(text);\n if (tail) {\n const v4 = parseIPv4(tail[2]);\n if (!v4) return null;\n text = `${tail[1]}${((v4[0] << 8) | v4[1]).toString(16)}:${((v4[2] << 8) | v4[3]).toString(16)}`;\n }\n const halves = text.split(\"::\");\n if (halves.length > 2) return null;\n const read = (part: string) => (part ? part.split(\":\") : []);\n const head = read(halves[0]);\n const rest = halves.length === 2 ? read(halves[1]) : [];\n const missing = 8 - head.length - rest.length;\n if (halves.length === 1 ? missing !== 0 : missing < 1) return null;\n const groups = [\n ...head,\n ...Array<string>(halves.length === 2 ? missing : 0).fill(\"0\"),\n ...rest,\n ];\n const words = groups.map((group) =>\n /^[0-9a-f]{1,4}$/.test(group) ? parseInt(group, 16) : NaN,\n );\n return words.length === 8 && words.every((word) => word >= 0) ? words : null;\n}\n\nfunction isPrivateIPv6(words: number[]): boolean {\n const [w0, w1, w2, w3, w4, w5, w6, w7] = words;\n const embedded = () => [w6 >> 8, w6 & 255, w7 >> 8, w7 & 255];\n if (words.slice(0, 7).every((word) => word === 0)) return w7 <= 1;\n if (\n w0 === 0 &&\n w1 === 0 &&\n w2 === 0 &&\n w3 === 0 &&\n w4 === 0 &&\n (w5 === 0xffff || w5 === 0)\n ) {\n return isPrivateIPv4(embedded());\n }\n if (w0 === 0x64 && w1 === 0xff9b) return isPrivateIPv4(embedded());\n if (w0 === 0x2002)\n return isPrivateIPv4([w1 >> 8, w1 & 255, w2 >> 8, w2 & 255]);\n return (\n (w0 & 0xfe00) === 0xfc00 ||\n (w0 & 0xffc0) === 0xfe80 ||\n (w0 & 0xff00) === 0xff00 ||\n (w0 === 0x2001 && w1 === 0xdb8)\n );\n}\n\n/**\n * Whether an IP address is loopback, private, link-local or otherwise not\n * publicly routable.\n */\nexport function isPrivateAddress(address: string): boolean {\n const host = normalizeHost(address);\n const v4 = parseIPv4(host);\n if (v4) return isPrivateIPv4(v4);\n const v6 = parseIPv6(host);\n return v6 ? isPrivateIPv6(v6) : false;\n}\n\nexport const isIpLiteral = (hostname: string) => {\n const host = normalizeHost(hostname);\n return parseIPv4(host) !== null || parseIPv6(host) !== null;\n};\n\n/**\n * Whether a hostname is an IP literal or local name that points at a private\n * network.\n */\nexport function isPrivateHostname(hostname: string): boolean {\n const host = normalizeHost(hostname);\n if (!host) return true;\n if (isIpLiteral(host)) return isPrivateAddress(host);\n return PRIVATE_NAMES.test(host) || !host.includes(\".\");\n}\n","import { analyzeAmbientPixels } from \"../analyze\";\nimport { resolveAnalysis } from \"../settings\";\nimport type {\n AmbientAnalysisOptions,\n AmbientPalette,\n AmbientPixels,\n} from \"../types\";\nimport {\n isIpLiteral,\n isPrivateAddress,\n isPrivateHostname,\n normalizeHost,\n} from \"./address\";\n\nexport {\n AMBIENT_ANALYSIS_VERSION,\n analyzeAmbientPixels,\n findContentBounds,\n fitSample,\n} from \"../analyze\";\nexport { isPrivateAddress, isPrivateHostname } from \"./address\";\nexport { configureAmbient, getAmbientSettings } from \"../settings\";\nexport {\n contrastRatio,\n formatOklch,\n maxChroma,\n onColorFor,\n srgbToOklab,\n toneOf,\n} from \"../oklab\";\nexport type * from \"../types\";\n\n/**\n * Turns image bytes into RGBA pixels no larger than `size`.\n */\nexport type AmbientDecoder = (\n bytes: Uint8Array,\n size: number,\n) => Promise<AmbientPixels>;\n\n/**\n * Options for server-side palette extraction: fetching, limits, SSRF checks and\n * caching.\n */\nexport interface AmbientServerOptions {\n analysis?: Partial<AmbientAnalysisOptions>;\n allow?: (url: URL) => boolean;\n cache?: boolean;\n decode?: AmbientDecoder;\n fetch?: typeof fetch;\n init?: RequestInit;\n maxBytes?: number;\n resolve?: ((hostname: string) => Promise<string[]>) | false;\n timeoutMs?: number;\n}\n\nconst MAX_BYTES = 12 * 1024 * 1024;\nconst TIMEOUT_MS = 8_000;\nconst CACHE_LIMIT = 500;\nconst MAX_REDIRECTS = 5;\nconst REDIRECT_STATUS_MIN = 300;\nconst REDIRECT_STATUS_MAX = 400;\n\n/**\n * Whether a URL is plain http(s) without credentials and not on a private\n * hostname.\n */\nexport function isPublicImageUrl(url: URL): boolean {\n return (\n (url.protocol === \"https:\" || url.protocol === \"http:\") &&\n !url.username &&\n !url.password &&\n !isPrivateHostname(url.hostname)\n );\n}\n\nasync function lookupAll(hostname: string): Promise<string[]> {\n const { lookup } = await import(\"node:dns/promises\");\n return (await lookup(hostname, { all: true, verbatim: true })).map(\n (entry) => entry.address,\n );\n}\n\nasync function reachesOnlyPublic(\n url: URL,\n resolve: AmbientServerOptions[\"resolve\"],\n): Promise<boolean> {\n if (resolve === false) return true;\n const host = normalizeHost(url.hostname);\n try {\n const addresses = isIpLiteral(host)\n ? [host]\n : await (resolve ?? lookupAll)(host);\n return addresses.length > 0 && !addresses.some(isPrivateAddress);\n } catch {\n return false;\n }\n}\n\ntype SharpLike = (\n input: Uint8Array,\n options?: Record<string, unknown>,\n) => SharpPipeline;\ninterface SharpPipeline {\n ensureAlpha(): SharpPipeline;\n raw(): SharpPipeline;\n resize(\n width: number,\n height: number,\n options: Record<string, unknown>,\n ): SharpPipeline;\n rotate(): SharpPipeline;\n toBuffer(options: { resolveWithObject: true }): Promise<{\n data: Uint8Array;\n info: { height: number; width: number };\n }>;\n}\n\n/**\n * Thrown when no decoder is passed and `sharp` is not installed.\n */\nexport class AmbientDecoderMissingError extends Error {\n override name = \"AmbientDecoderMissingError\";\n}\n\nlet sharpModule: Promise<SharpLike> | null = null;\nconst SHARP = \"sharp\";\n\nfunction loadSharp(): Promise<SharpLike> {\n sharpModule ??= import(\n /* webpackIgnore: true */ /* turbopackIgnore: true */ SHARP\n )\n .then((mod: { default?: SharpLike }) => (mod.default ?? mod) as SharpLike)\n .catch((error: unknown) => {\n sharpModule = null;\n throw new AmbientDecoderMissingError(\n \"ambient/server: `sharp` is not installed. Install it or pass `decode`.\",\n { cause: error },\n );\n });\n return sharpModule;\n}\n\n/**\n * Default decoder, backed by `sharp`.\n */\nexport const sharpDecoder: AmbientDecoder = async (bytes, size) => {\n const sharp = await loadSharp();\n const { data, info } = await sharp(bytes, { failOn: \"none\" })\n .rotate()\n .resize(size, size, { fit: \"inside\", withoutEnlargement: true })\n .ensureAlpha()\n .raw()\n .toBuffer({ resolveWithObject: true });\n return { data, height: info.height, width: info.width };\n};\n\nasync function readLimited(\n response: Response,\n maxBytes: number,\n): Promise<Uint8Array> {\n const declared = Number(response.headers.get(\"content-length\"));\n if (declared > maxBytes) throw new Error(\"ambient/server: image too large\");\n if (!response.body) return new Uint8Array(await response.arrayBuffer());\n\n const reader = response.body.getReader();\n const chunks: Uint8Array[] = [];\n let length = 0;\n for (;;) {\n const { done, value } = await reader.read();\n if (done) break;\n length += value.byteLength;\n if (length > maxBytes) {\n await reader.cancel();\n throw new Error(\"ambient/server: image too large\");\n }\n chunks.push(value);\n }\n const bytes = new Uint8Array(length);\n let offset = 0;\n for (const chunk of chunks) {\n bytes.set(chunk, offset);\n offset += chunk.byteLength;\n }\n return bytes;\n}\n\n/**\n * Extracts a palette from encoded image bytes.\n */\nexport async function extractAmbientPaletteFromBytes(\n bytes: Uint8Array,\n options: Pick<AmbientServerOptions, \"analysis\" | \"decode\"> = {},\n): Promise<AmbientPalette> {\n const analysis = resolveAnalysis(options.analysis);\n const pixels = await (options.decode ?? sharpDecoder)(\n bytes,\n analysis.sampleSize,\n );\n return analyzeAmbientPixels(pixels, analysis);\n}\n\nconst cache = new Map<string, AmbientPalette>();\nconst inFlight = new Map<string, Promise<AmbientPalette | null>>();\n\nfunction remember(key: string, palette: AmbientPalette): void {\n cache.delete(key);\n while (cache.size >= CACHE_LIMIT) {\n const oldest = cache.keys().next().value;\n if (oldest === undefined) break;\n cache.delete(oldest);\n }\n cache.set(key, palette);\n}\n\nasync function fetchAndExtract(\n url: URL,\n options: AmbientServerOptions,\n): Promise<AmbientPalette | null> {\n const allow = options.allow ?? isPublicImageUrl;\n const doFetch = options.fetch ?? fetch;\n const signal = AbortSignal.timeout(options.timeoutMs ?? TIMEOUT_MS);\n\n let current = url;\n for (let hop = 0; hop <= MAX_REDIRECTS; hop++) {\n if (!allow(current)) return null;\n if (!(await reachesOnlyPublic(current, options.resolve))) return null;\n const response = await doFetch(current, {\n ...options.init,\n redirect: \"manual\",\n signal,\n });\n if (\n response.status >= REDIRECT_STATUS_MIN &&\n response.status < REDIRECT_STATUS_MAX\n ) {\n const location = response.headers.get(\"location\");\n await response.body?.cancel();\n if (!location) return null;\n current = new URL(location, current);\n continue;\n }\n if (!response.ok) return null;\n const type = response.headers.get(\"content-type\") ?? \"\";\n if (type && !type.toLowerCase().startsWith(\"image/\")) return null;\n const bytes = await readLimited(response, options.maxBytes ?? MAX_BYTES);\n const palette = await extractAmbientPaletteFromBytes(bytes, options);\n return { ...palette, source: url.href };\n }\n return null;\n}\n\n/**\n * Downloads an image and extracts its palette, or returns null when the URL is\n * unsafe or the download fails. Results are cached.\n */\nexport async function extractAmbientPalette(\n src: string | URL,\n options: AmbientServerOptions = {},\n): Promise<AmbientPalette | null> {\n let url: URL;\n try {\n url = new URL(src);\n } catch {\n return null;\n }\n const useCache = options.cache !== false;\n const key = options.analysis\n ? `${url.href}#${JSON.stringify(options.analysis)}`\n : url.href;\n if (useCache) {\n const hit = cache.get(key);\n if (hit) return hit;\n const pending = inFlight.get(key);\n if (pending) return pending;\n }\n\n const task = fetchAndExtract(url, options).catch((error: unknown) => {\n if (error instanceof AmbientDecoderMissingError) throw error;\n return null;\n });\n if (!useCache) return task;\n\n const shared = task\n .then((palette) => {\n if (palette) remember(key, palette);\n return palette;\n })\n .finally(() => inFlight.delete(key));\n inFlight.set(key, shared);\n return shared;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/modules/ambient/server/address.ts","../../../src/modules/ambient/server/index.ts"],"names":["PRIVATE_NAMES","normalizeHost","hostname","toLowerCase","replace","parseIPv4","value","parts","split","length","bytes","map","part","test","Number","NaN","every","byte","isPrivateIPv4","a","b","c","parseIPv6","text","tail","exec","v4","toString","halves","read","head","rest","missing","groups","Array","fill","words","group","parseInt","word","isPrivateIPv6","w0","w1","w2","w3","w4","w5","w6","w7","embedded","slice","isPrivateAddress","address","host","v6","isIpLiteral","isPrivateHostname","includes","MAX_BYTES","TIMEOUT_MS","CACHE_LIMIT","MAX_REDIRECTS","REDIRECT_STATUS_MIN","REDIRECT_STATUS_MAX","SHARP","isPublicImageUrl","url","protocol","username","password","lookupAll","lookup","all","verbatim","entry","reachesOnlyPublic","resolve","addresses","some","AmbientDecoderMissingError","Error","name","sharpModule","loadSharp","then","mod","default","catch","error","cause","sharpDecoder","size","sharp","data","info","failOn","rotate","resize","fit","withoutEnlargement","ensureAlpha","raw","toBuffer","resolveWithObject","height","width","readLimited","response","maxBytes","declared","headers","get","body","Uint8Array","arrayBuffer","reader","getReader","chunks","done","byteLength","cancel","push","offset","chunk","set","extractAmbientPaletteFromBytes","options","analysis","resolveAnalysis","pixels","decode","sampleSize","analyzeAmbientPixels","cache","Map","inFlight","remember","key","palette","delete","oldest","keys","next","undefined","fetchAndExtract","allow","doFetch","fetch","signal","AbortSignal","timeout","timeoutMs","current","hop","init","redirect","status","location","URL","ok","type","startsWith","source","href","extractAmbientPalette","src","useCache","JSON","stringify","hit","pending","task","shared","finally"],"mappings":";;;;AAAA,IAAMA,aAAAA,GACJ,uEAAA;AAEK,SAASC,cAAcC,QAAAA,EAA0B;AACtD,EAAA,OAAOA,QAAAA,CACJC,aAAY,CACZC,OAAAA,CAAQ,QAAQ,EAAE,CAAA,CAClBA,OAAAA,CAAQ,UAAA,EAAY,EAAE,CAAA;AAC3B;AAEA,SAASC,UAAUC,KAAAA,EAAgC;AACjD,EAAA,MAAMC,KAAAA,GAAQD,KAAAA,CAAME,KAAAA,CAAM,GAAG,CAAA;AAC7B,EAAA,IAAID,KAAAA,CAAME,MAAAA,KAAW,CAAA,EAAG,OAAO,IAAA;AAC/B,EAAA,MAAMC,KAAAA,GAAQH,KAAAA,CAAMI,GAAAA,CAAKC,CAAAA,IAAAA,KACvB,WAAA,CAAYC,IAAAA,CAAKD,IAAI,CAAA,GAAIE,MAAAA,CAAOF,IAAI,CAAA,GAAIG,GAC1C,CAAA;AACA,EAAA,OAAOL,KAAAA,CAAMM,MAAOC,CAAAA,IAAAA,KAASA,IAAAA,IAAQ,KAAKA,IAAAA,IAAQ,GAAG,IAAIP,KAAAA,GAAQ,IAAA;AACnE;AAEA,SAASQ,aAAAA,CAAc,CAACC,CAAAA,EAAGC,CAAAA,EAAGC,CAAC,CAAA,EAAsB;AACnD,EAAA,OACEF,MAAM,CAAA,IACNA,CAAAA,KAAM,EAAA,IACNA,CAAAA,KAAM,OACLA,CAAAA,KAAM,GAAA,IAAOC,CAAAA,IAAK,EAAA,IAAMA,KAAK,GAAA,IAC7BD,CAAAA,KA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,CAAMtB,GAAAA,CAAI0B,GAAG,CAAA;AACzB,IAAA,IAAIgC,KAAK,OAAOA,GAAAA;AAChB,IAAA,MAAMC,OAAAA,GAAUnC,QAAAA,CAASxB,GAAAA,CAAI0B,GAAG,CAAA;AAChC,IAAA,IAAIiC,SAAS,OAAOA,OAAAA;AACtB,EAAA;AAEA,EAAA,MAAMC,OAAO3B,eAAAA,CAAgB9E,GAAAA,EAAK4D,OAAO,CAAA,CAAEvC,MAAOC,CAAAA,KAAAA,KAAmB;AACnE,IAAA,IAAIA,KAAAA,YAAiBT,4BAA4B,MAAMS,KAAAA;AACvD,IAAA,OAAO,IAAA;EACT,CAAC,CAAA;AACD,EAAA,IAAI,CAAC8E,UAAU,OAAOK,IAAAA;AAEtB,EAAA,MAAMC,MAAAA,GAASD,IAAAA,CACZvF,IAAAA,CAAMsD,CAAAA,OAAAA,KAAY;AACjB,IAAA,IAAIA,OAAAA,EAASF,QAAAA,CAASC,GAAAA,EAAKC,OAAO,CAAA;AAClC,IAAA,OAAOA,OAAAA;AACT,EAAA,CAAC,EACAmC,OAAAA,CAAQ,MAAMtC,QAAAA,CAASI,MAAAA,CAAOF,GAAG,CAAC,CAAA;AACrCF,EAAAA,QAAAA,CAASX,GAAAA,CAAIa,KAAKmC,MAAM,CAAA;AACxB,EAAA,OAAOA,MAAAA;AACT","file":"index.js","sourcesContent":["const PRIVATE_NAMES =\n /(^|\\.)(localhost|local|internal|intranet|lan|home\\.arpa|localdomain)$/;\n\nexport function normalizeHost(hostname: string): string {\n return hostname\n .toLowerCase()\n .replace(/\\.+$/, \"\")\n .replace(/^\\[|\\]$/g, \"\");\n}\n\nfunction parseIPv4(value: string): number[] | null {\n const parts = value.split(\".\");\n if (parts.length !== 4) return null;\n const bytes = parts.map((part) =>\n /^\\d{1,3}$/.test(part) ? Number(part) : NaN,\n );\n return bytes.every((byte) => byte >= 0 && byte <= 255) ? bytes : null;\n}\n\nfunction isPrivateIPv4([a, b, c]: number[]): boolean {\n return (\n a === 0 ||\n a === 10 ||\n a === 127 ||\n (a === 100 && b >= 64 && b <= 127) ||\n (a === 169 && b === 254) ||\n (a === 172 && b >= 16 && b <= 31) ||\n (a === 192 && b === 168) ||\n (a === 192 && b === 0 && c === 0) ||\n (a === 198 && (b === 18 || b === 19)) ||\n a >= 224\n );\n}\n\nfunction parseIPv6(value: string): number[] | null {\n let text = value.split(\"%\")[0];\n const tail = /^(.*:)(\\d+\\.\\d+\\.\\d+\\.\\d+)$/.exec(text);\n if (tail) {\n const v4 = parseIPv4(tail[2]);\n if (!v4) return null;\n text = `${tail[1]}${((v4[0] << 8) | v4[1]).toString(16)}:${((v4[2] << 8) | v4[3]).toString(16)}`;\n }\n const halves = text.split(\"::\");\n if (halves.length > 2) return null;\n const read = (part: string) => (part ? part.split(\":\") : []);\n const head = read(halves[0]);\n const rest = halves.length === 2 ? read(halves[1]) : [];\n const missing = 8 - head.length - rest.length;\n if (halves.length === 1 ? missing !== 0 : missing < 1) return null;\n const groups = [\n ...head,\n ...Array<string>(halves.length === 2 ? missing : 0).fill(\"0\"),\n ...rest,\n ];\n const words = groups.map((group) =>\n /^[0-9a-f]{1,4}$/.test(group) ? parseInt(group, 16) : NaN,\n );\n return words.length === 8 && words.every((word) => word >= 0) ? words : null;\n}\n\nfunction isPrivateIPv6(words: number[]): boolean {\n const [w0, w1, w2, w3, w4, w5, w6, w7] = words;\n const embedded = () => [w6 >> 8, w6 & 255, w7 >> 8, w7 & 255];\n if (words.slice(0, 7).every((word) => word === 0)) return w7 <= 1;\n if (\n w0 === 0 &&\n w1 === 0 &&\n w2 === 0 &&\n w3 === 0 &&\n w4 === 0 &&\n (w5 === 0xffff || w5 === 0)\n ) {\n return isPrivateIPv4(embedded());\n }\n if (w0 === 0x64 && w1 === 0xff9b) return isPrivateIPv4(embedded());\n if (w0 === 0x2002)\n return isPrivateIPv4([w1 >> 8, w1 & 255, w2 >> 8, w2 & 255]);\n return (\n (w0 & 0xfe00) === 0xfc00 ||\n (w0 & 0xffc0) === 0xfe80 ||\n (w0 & 0xff00) === 0xff00 ||\n (w0 === 0x2001 && w1 === 0xdb8)\n );\n}\n\n/**\n * Whether an IP address is loopback, private, link-local or otherwise not\n * publicly routable.\n */\nexport function isPrivateAddress(address: string): boolean {\n const host = normalizeHost(address);\n const v4 = parseIPv4(host);\n if (v4) return isPrivateIPv4(v4);\n const v6 = parseIPv6(host);\n return v6 ? isPrivateIPv6(v6) : false;\n}\n\nexport const isIpLiteral = (hostname: string) => {\n const host = normalizeHost(hostname);\n return parseIPv4(host) !== null || parseIPv6(host) !== null;\n};\n\n/**\n * Whether a hostname is an IP literal or local name that points at a private\n * network.\n */\nexport function isPrivateHostname(hostname: string): boolean {\n const host = normalizeHost(hostname);\n if (!host) return true;\n if (isIpLiteral(host)) return isPrivateAddress(host);\n return PRIVATE_NAMES.test(host) || !host.includes(\".\");\n}\n","import { analyzeAmbientPixels } from \"../analysis/analyze\";\nimport { resolveAnalysis } from \"../settings\";\nimport type {\n AmbientAnalysisOptions,\n AmbientPalette,\n AmbientPixels,\n} from \"../types\";\nimport {\n isIpLiteral,\n isPrivateAddress,\n isPrivateHostname,\n normalizeHost,\n} from \"./address\";\n\nexport {\n AMBIENT_ANALYSIS_VERSION,\n analyzeAmbientPixels,\n findContentBounds,\n fitSample,\n} from \"../analysis/analyze\";\nexport { isPrivateAddress, isPrivateHostname } from \"./address\";\nexport { configureAmbient, getAmbientSettings } from \"../settings\";\nexport {\n contrastRatio,\n formatOklch,\n maxChroma,\n onColorFor,\n srgbToOklab,\n toneOf,\n} from \"../analysis/oklab\";\nexport type * from \"../types\";\n\n/**\n * Turns image bytes into RGBA pixels no larger than `size`.\n */\nexport type AmbientDecoder = (\n bytes: Uint8Array,\n size: number,\n) => Promise<AmbientPixels>;\n\n/**\n * Options for server-side palette extraction: fetching, limits, SSRF checks and\n * caching.\n */\nexport interface AmbientServerOptions {\n analysis?: Partial<AmbientAnalysisOptions>;\n allow?: (url: URL) => boolean;\n cache?: boolean;\n decode?: AmbientDecoder;\n fetch?: typeof fetch;\n init?: RequestInit;\n maxBytes?: number;\n resolve?: ((hostname: string) => Promise<string[]>) | false;\n timeoutMs?: number;\n}\n\nconst MAX_BYTES = 12 * 1024 * 1024;\nconst TIMEOUT_MS = 8_000;\nconst CACHE_LIMIT = 500;\nconst MAX_REDIRECTS = 5;\nconst REDIRECT_STATUS_MIN = 300;\nconst REDIRECT_STATUS_MAX = 400;\n\nconst SHARP = \"sharp\";\n\n/**\n * Whether a URL is plain http(s) without credentials and not on a private\n * hostname.\n */\nexport function isPublicImageUrl(url: URL): boolean {\n return (\n (url.protocol === \"https:\" || url.protocol === \"http:\") &&\n !url.username &&\n !url.password &&\n !isPrivateHostname(url.hostname)\n );\n}\n\nasync function lookupAll(hostname: string): Promise<string[]> {\n const { lookup } = await import(\"node:dns/promises\");\n return (await lookup(hostname, { all: true, verbatim: true })).map(\n (entry) => entry.address,\n );\n}\n\nasync function reachesOnlyPublic(\n url: URL,\n resolve: AmbientServerOptions[\"resolve\"],\n): Promise<boolean> {\n if (resolve === false) return true;\n const host = normalizeHost(url.hostname);\n try {\n const addresses = isIpLiteral(host)\n ? [host]\n : await (resolve ?? lookupAll)(host);\n return addresses.length > 0 && !addresses.some(isPrivateAddress);\n } catch {\n // A host that does not resolve is never fetched.\n return false;\n }\n}\n\ntype SharpLike = (\n input: Uint8Array,\n options?: Record<string, unknown>,\n) => SharpPipeline;\ninterface SharpPipeline {\n ensureAlpha(): SharpPipeline;\n raw(): SharpPipeline;\n resize(\n width: number,\n height: number,\n options: Record<string, unknown>,\n ): SharpPipeline;\n rotate(): SharpPipeline;\n toBuffer(options: { resolveWithObject: true }): Promise<{\n data: Uint8Array;\n info: { height: number; width: number };\n }>;\n}\n\n/**\n * Thrown when no decoder is passed and `sharp` is not installed.\n */\nexport class AmbientDecoderMissingError extends Error {\n override name = \"AmbientDecoderMissingError\";\n}\n\nlet sharpModule: Promise<SharpLike> | null = null;\n\nfunction loadSharp(): Promise<SharpLike> {\n sharpModule ??= import(\n /* webpackIgnore: true */ /* turbopackIgnore: true */ SHARP\n )\n .then((mod: { default?: SharpLike }) => (mod.default ?? mod) as SharpLike)\n .catch((error: unknown) => {\n sharpModule = null;\n throw new AmbientDecoderMissingError(\n \"ambient/server: `sharp` is not installed. Install it or pass `decode`.\",\n { cause: error },\n );\n });\n return sharpModule;\n}\n\n/**\n * Default decoder, backed by `sharp`.\n */\nexport const sharpDecoder: AmbientDecoder = async (bytes, size) => {\n const sharp = await loadSharp();\n const { data, info } = await sharp(bytes, { failOn: \"none\" })\n .rotate()\n .resize(size, size, { fit: \"inside\", withoutEnlargement: true })\n .ensureAlpha()\n .raw()\n .toBuffer({ resolveWithObject: true });\n return { data, height: info.height, width: info.width };\n};\n\nasync function readLimited(\n response: Response,\n maxBytes: number,\n): Promise<Uint8Array> {\n const declared = Number(response.headers.get(\"content-length\"));\n if (declared > maxBytes) throw new Error(\"ambient/server: image too large\");\n if (!response.body) return new Uint8Array(await response.arrayBuffer());\n\n const reader = response.body.getReader();\n const chunks: Uint8Array[] = [];\n let length = 0;\n for (;;) {\n const { done, value } = await reader.read();\n if (done) break;\n length += value.byteLength;\n if (length > maxBytes) {\n await reader.cancel();\n throw new Error(\"ambient/server: image too large\");\n }\n chunks.push(value);\n }\n const bytes = new Uint8Array(length);\n let offset = 0;\n for (const chunk of chunks) {\n bytes.set(chunk, offset);\n offset += chunk.byteLength;\n }\n return bytes;\n}\n\n/**\n * Extracts a palette from encoded image bytes.\n */\nexport async function extractAmbientPaletteFromBytes(\n bytes: Uint8Array,\n options: Pick<AmbientServerOptions, \"analysis\" | \"decode\"> = {},\n): Promise<AmbientPalette> {\n const analysis = resolveAnalysis(options.analysis);\n const pixels = await (options.decode ?? sharpDecoder)(\n bytes,\n analysis.sampleSize,\n );\n return analyzeAmbientPixels(pixels, analysis);\n}\n\nconst cache = new Map<string, AmbientPalette>();\nconst inFlight = new Map<string, Promise<AmbientPalette | null>>();\n\nfunction remember(key: string, palette: AmbientPalette): void {\n cache.delete(key);\n while (cache.size >= CACHE_LIMIT) {\n const oldest = cache.keys().next().value;\n if (oldest === undefined) break;\n cache.delete(oldest);\n }\n cache.set(key, palette);\n}\n\nasync function fetchAndExtract(\n url: URL,\n options: AmbientServerOptions,\n): Promise<AmbientPalette | null> {\n const allow = options.allow ?? isPublicImageUrl;\n const doFetch = options.fetch ?? fetch;\n const signal = AbortSignal.timeout(options.timeoutMs ?? TIMEOUT_MS);\n\n let current = url;\n for (let hop = 0; hop <= MAX_REDIRECTS; hop++) {\n if (!allow(current)) return null;\n if (!(await reachesOnlyPublic(current, options.resolve))) return null;\n const response = await doFetch(current, {\n ...options.init,\n redirect: \"manual\",\n signal,\n });\n if (\n response.status >= REDIRECT_STATUS_MIN &&\n response.status < REDIRECT_STATUS_MAX\n ) {\n const location = response.headers.get(\"location\");\n await response.body?.cancel();\n if (!location) return null;\n current = new URL(location, current);\n continue;\n }\n if (!response.ok) return null;\n const type = response.headers.get(\"content-type\") ?? \"\";\n if (type && !type.toLowerCase().startsWith(\"image/\")) return null;\n const bytes = await readLimited(response, options.maxBytes ?? MAX_BYTES);\n const palette = await extractAmbientPaletteFromBytes(bytes, options);\n return { ...palette, source: url.href };\n }\n return null;\n}\n\n/**\n * Downloads an image and extracts its palette, or returns null when the URL is\n * unsafe or the download fails. Results are cached.\n */\nexport async function extractAmbientPalette(\n src: string | URL,\n options: AmbientServerOptions = {},\n): Promise<AmbientPalette | null> {\n let url: URL;\n try {\n url = new URL(src);\n } catch {\n return null;\n }\n const useCache = options.cache !== false;\n const key = options.analysis\n ? `${url.href}#${JSON.stringify(options.analysis)}`\n : url.href;\n if (useCache) {\n const hit = cache.get(key);\n if (hit) return hit;\n const pending = inFlight.get(key);\n if (pending) return pending;\n }\n\n const task = fetchAndExtract(url, options).catch((error: unknown) => {\n if (error instanceof AmbientDecoderMissingError) throw error;\n return null;\n });\n if (!useCache) return task;\n\n const shared = task\n .then((palette) => {\n if (palette) remember(key, palette);\n return palette;\n })\n .finally(() => inFlight.delete(key));\n inFlight.set(key, shared);\n return shared;\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { analyzeAmbientPixels, fitSample } from '../../chunk-
|
|
1
|
+
import { analyzeAmbientPixels, fitSample } from '../../chunk-ZQI4ZCVU.js';
|
|
2
2
|
|
|
3
3
|
// src/modules/ambient/pipeline.ts
|
|
4
4
|
async function fetchImageBlob(src, proxyUrl) {
|
|
@@ -116,9 +116,7 @@ async function extractHere(request) {
|
|
|
116
116
|
var AMBIENT_WORKER_REQUEST = "ambient:extract";
|
|
117
117
|
var AMBIENT_WORKER_RESPONSE = "ambient:palette";
|
|
118
118
|
function serveAmbientWorker(scope = globalThis) {
|
|
119
|
-
const
|
|
120
|
-
const request = event.data;
|
|
121
|
-
if (request?.type !== AMBIENT_WORKER_REQUEST) return;
|
|
119
|
+
const respond = async (request) => {
|
|
122
120
|
let result;
|
|
123
121
|
try {
|
|
124
122
|
result = await extractHere(request);
|
|
@@ -134,6 +132,11 @@ function serveAmbientWorker(scope = globalThis) {
|
|
|
134
132
|
type: AMBIENT_WORKER_RESPONSE
|
|
135
133
|
});
|
|
136
134
|
};
|
|
135
|
+
const onMessage = (event) => {
|
|
136
|
+
const request = event.data;
|
|
137
|
+
if (request?.type !== AMBIENT_WORKER_REQUEST) return;
|
|
138
|
+
void respond(request);
|
|
139
|
+
};
|
|
137
140
|
scope.addEventListener("message", onMessage);
|
|
138
141
|
return () => scope.removeEventListener("message", onMessage);
|
|
139
142
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/modules/ambient/pipeline.ts","../../../src/modules/ambient/worker/index.ts"],"names":["fetchImageBlob","src","proxyUrl","fetch","read","url","init","response","mode","ok","blob","type","startsWith","isCrossOrigin","cache","URL","origin","globalThis","location","createContext2D","width","height","OffscreenCanvas","getContext","willReadFrequently","document","canvas","createElement","readPixels","image","sourceWidth","sourceHeight","size","fitSample","context","drawImage","data","getImageData","decodeBlob","createImageBitmap","bitmap","resizeQuality","resizeWidth","close","canDecodeHere","extractHere","request","supported","palette","pixels","analysis","sampleSize","analyzeAmbientPixels","AMBIENT_WORKER_REQUEST","AMBIENT_WORKER_RESPONSE","serveAmbientWorker","scope","onMessage","event","result","postMessage","id","addEventListener","removeEventListener"],"mappings":";;;AAkBA,eAAsBA,cAAAA,CACpBC,KACAC,QAAAA,EACsB;AACtB,EAAA,IAAI,OAAOC,KAAAA,KAAU,UAAA,EAAY,OAAO,IAAA;AAExC,EAAA,MAAMC,IAAAA,GAAO,OAAOC,GAAAA,EAAaC,IAAAA,KAAuB;AACtD,IAAA,MAAMC,QAAAA,GAAW,MAAMJ,KAAAA,CAAME,GAAAA,EAAK;MAAE,GAAGC,IAAAA;MAAME,IAAAA,EAAM;KAAQ,CAAA;AAC3D,IAAA,IAAI,CAACD,QAAAA,CAASE,EAAAA,EAAI,OAAO,IAAA;AACzB,IAAA,MAAMC,IAAAA,GAAO,MAAMH,QAAAA,CAASG,IAAAA,EAAK;AACjC,IAAA,OAAOA,IAAAA,CAAKC,IAAAA,CAAKC,UAAAA,CAAW,OAAO,IAAI,IAAA,GAAOF,IAAAA;AAChD,EAAA,CAAA;AAEA,EAAA,IAAI;AACF,IAAA,MAAMA,IAAAA,GAAO,MAAMN,IAAAA,CAAKH,GAAG,CAAA;AAC3B,IAAA,IAAIS,MAAM,OAAOA,IAAAA;EACnB,CAAA,CAAA,MAAQ;AACN,IAAA,IAAIG,aAAAA,CAAcZ,GAAG,CAAA,EAAG;AACtB,MAAA,IAAI;AACF,QAAA,MAAMS,IAAAA,GAAO,MAAMN,IAAAA,CAAKH,GAAAA,EAAK;UAAEa,KAAAA,EAAO;SAAU,CAAA;AAChD,QAAA,IAAIJ,MAAM,OAAOA,IAAAA;MACnB,CAAA,CAAA,MAAQ;AAAC,MAAA;AACX,IAAA;AACF,EAAA;AAEA,EAAA,IAAIR,QAAAA,EAAU;AACZ,IAAA,IAAI;AACF,MA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mBAAAA,CAAoB,SAAA,EAAWN,SAAS,CAAA;AAC7D","file":"index.js","sourcesContent":["import { analyzeAmbientPixels, fitSample } from \"./analyze\";\nimport type {\n AmbientAnalysisOptions,\n AmbientPalette,\n AmbientPixels,\n} from \"./types\";\n\nexport interface AmbientExtractRequest {\n analysis: AmbientAnalysisOptions;\n proxyUrl: string | null;\n src: string;\n}\n\nexport type AmbientExtractResult =\n { palette: AmbientPalette | null; supported: true } | { supported: false };\n\ntype Context2D = OffscreenCanvasRenderingContext2D | CanvasRenderingContext2D;\n\nexport async function fetchImageBlob(\n src: string,\n proxyUrl: string | null,\n): Promise<Blob | null> {\n if (typeof fetch !== \"function\") return null;\n\n const read = async (url: string, init?: RequestInit) => {\n const response = await fetch(url, { ...init, mode: \"cors\" });\n if (!response.ok) return null;\n const blob = await response.blob();\n return blob.type.startsWith(\"text/\") ? null : blob;\n };\n\n try {\n const blob = await read(src);\n if (blob) return blob;\n } catch {\n if (isCrossOrigin(src)) {\n try {\n const blob = await read(src, { cache: \"reload\" });\n if (blob) return blob;\n } catch {}\n }\n }\n\n if (proxyUrl) {\n try {\n return await read(proxyUrl);\n } catch {}\n }\n return null;\n}\n\nfunction isCrossOrigin(url: string): boolean {\n try {\n return new URL(url).origin !== globalThis.location?.origin;\n } catch {\n return false;\n }\n}\n\nexport function createContext2D(\n width: number,\n height: number,\n): Context2D | null {\n if (typeof OffscreenCanvas === \"function\") {\n return new OffscreenCanvas(width, height).getContext(\"2d\", {\n willReadFrequently: true,\n });\n }\n if (typeof document !== \"undefined\") {\n const canvas = document.createElement(\"canvas\");\n canvas.width = width;\n canvas.height = height;\n return canvas.getContext(\"2d\", { willReadFrequently: true });\n }\n return null;\n}\n\nexport function readPixels(\n image: CanvasImageSource,\n sourceWidth: number,\n sourceHeight: number,\n size: number,\n): AmbientPixels | null {\n const { height, width } = fitSample(sourceWidth, sourceHeight, size);\n const context = createContext2D(width, height);\n if (!context) return null;\n context.drawImage(image, 0, 0, width, height);\n return {\n data: context.getImageData(0, 0, width, height).data,\n height,\n width,\n };\n}\n\nexport async function decodeBlob(\n blob: Blob,\n size: number,\n): Promise<AmbientPixels | null> {\n if (typeof createImageBitmap !== \"function\") return null;\n let bitmap: ImageBitmap;\n try {\n bitmap = await createImageBitmap(blob, {\n resizeQuality: \"medium\",\n resizeWidth: size,\n });\n } catch {\n bitmap = await createImageBitmap(blob);\n }\n try {\n return readPixels(bitmap, bitmap.width, bitmap.height, size);\n } finally {\n bitmap.close();\n }\n}\n\nexport const canDecodeHere = () =>\n typeof createImageBitmap === \"function\" &&\n (typeof OffscreenCanvas === \"function\" || typeof document !== \"undefined\");\n\nexport async function extractHere(\n request: AmbientExtractRequest,\n): Promise<AmbientExtractResult> {\n if (!canDecodeHere()) return { supported: false };\n const blob = await fetchImageBlob(request.src, request.proxyUrl);\n if (!blob) return { palette: null, supported: true };\n try {\n const pixels = await decodeBlob(blob, request.analysis.sampleSize);\n return {\n palette: pixels ? analyzeAmbientPixels(pixels, request.analysis) : null,\n supported: true,\n };\n } catch {\n return { palette: null, supported: true };\n }\n}\n","import { type AmbientExtractRequest, extractHere } from \"../pipeline\";\n\n/**\n * Message type of an extraction request sent to the worker.\n */\nexport const AMBIENT_WORKER_REQUEST = \"ambient:extract\";\n/**\n * Message type of the worker's reply.\n */\nexport const AMBIENT_WORKER_RESPONSE = \"ambient:palette\";\n\n/**\n * An extraction request posted to the ambient worker.\n */\nexport interface AmbientWorkerRequest extends AmbientExtractRequest {\n id: number;\n type: typeof AMBIENT_WORKER_REQUEST;\n}\n\n/**\n * The part of a worker global scope that serveAmbientWorker uses.\n */\nexport interface AmbientWorkerScope {\n addEventListener(\n type: \"message\",\n listener: (event: MessageEvent) => void,\n ): void;\n postMessage(message: unknown): void;\n removeEventListener(\n type: \"message\",\n listener: (event: MessageEvent) => void,\n ): void;\n}\n\n/**\n * Starts answering extraction requests in a worker. Returns a function that\n * stops it.\n */\nexport function serveAmbientWorker(\n scope: AmbientWorkerScope = globalThis,\n): () => void {\n const onMessage = async (event: MessageEvent) => {\n const request = event.data as AmbientWorkerRequest | null;\n if (request?.type !== AMBIENT_WORKER_REQUEST) return;\n let result: Awaited<ReturnType<typeof extractHere>>;\n try {\n result = await extractHere(request);\n } catch {\n result = { palette: null, supported: true };\n }\n scope.postMessage({\n ...result,\n id: request.id,\n type: AMBIENT_WORKER_RESPONSE,\n });\n };\n // onMessage is async but catches its own errors; the listener ignores its result.\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n scope.addEventListener(\"message\", onMessage);\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n return () => scope.removeEventListener(\"message\", onMessage);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/modules/ambient/pipeline.ts","../../../src/modules/ambient/worker/index.ts"],"names":["fetchImageBlob","src","proxyUrl","fetch","read","url","init","response","mode","ok","blob","type","startsWith","isCrossOrigin","cache","URL","origin","globalThis","location","createContext2D","width","height","OffscreenCanvas","getContext","willReadFrequently","document","canvas","createElement","readPixels","image","sourceWidth","sourceHeight","size","fitSample","context","drawImage","data","getImageData","decodeBlob","createImageBitmap","bitmap","resizeQuality","resizeWidth","close","canDecodeHere","extractHere","request","supported","palette","pixels","analysis","sampleSize","analyzeAmbientPixels","AMBIENT_WORKER_REQUEST","AMBIENT_WORKER_RESPONSE","serveAmbientWorker","scope","respond","result","postMessage","id","onMessage","event","addEventListener","removeEventListener"],"mappings":";;;AAsBA,eAAsBA,cAAAA,CACpBC,KACAC,QAAAA,EACsB;AACtB,EAAA,IAAI,OAAOC,KAAAA,KAAU,UAAA,EAAY,OAAO,IAAA;AAExC,EAAA,MAAMC,IAAAA,GAAO,OAAOC,GAAAA,EAAaC,IAAAA,KAAuB;AACtD,IAAA,MAAMC,QAAAA,GAAW,MAAMJ,KAAAA,CAAME,GAAAA,EAAK;MAAE,GAAGC,IAAAA;MAAME,IAAAA,EAAM;KAAQ,CAAA;AAC3D,IAAA,IAAI,CAACD,QAAAA,CAASE,EAAAA,EAA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A4BvC,UAAAA,EAChB;AACZ,EAAA,MAAMwC,OAAAA,GAAU,OAAOX,OAAAA,KAAkC;AACvD,IAAA,IAAIY,MAAAA;AACJ,IAAA,IAAI;AACFA,MAAAA,MAAAA,GAAS,MAAMb,YAAYC,OAAO,CAAA;IACpC,CAAA,CAAA,MAAQ;AAENY,MAAAA,MAAAA,GAAS;QAAEV,OAAAA,EAAS,IAAA;QAAMD,SAAAA,EAAW;AAAK,OAAA;AAC5C,IAAA;AACAS,IAAAA,KAAAA,CAAMG,WAAAA,CAAY;MAChB,GAAGD,MAAAA;AACHE,MAAAA,EAAAA,EAAId,OAAAA,CAAQc,EAAAA;MACZjD,IAAAA,EAAM2C;KACP,CAAA;AACH,EAAA,CAAA;AACA,EAAA,MAAMO,YAAaC,CAAAA,KAAAA,KAAwB;AACzC,IAAA,MAAMhB,UAAUgB,KAAAA,CAAM1B,IAAAA;AACtB,IAAA,IAAIU,OAAAA,EAASnC,SAAS0C,sBAAAA,EAAwB;AAC9C,IAAA,KAAKI,QAAQX,OAAO,CAAA;AACtB,EAAA,CAAA;AACAU,EAAAA,KAAAA,CAAMO,gBAAAA,CAAiB,WAAWF,SAAS,CAAA;AAC3C,EAAA,OAAO,MAAML,KAAAA,CAAMQ,mBAAAA,CAAoB,SAAA,EAAWH,SAAS,CAAA;AAC7D","file":"index.js","sourcesContent":["import { analyzeAmbientPixels, fitSample } from \"./analysis/analyze\";\nimport type {\n AmbientAnalysisOptions,\n AmbientPalette,\n AmbientPixels,\n} from \"./types\";\n\nexport interface AmbientExtractRequest {\n analysis: AmbientAnalysisOptions;\n proxyUrl: string | null;\n src: string;\n}\n\nexport type AmbientExtractResult =\n { palette: AmbientPalette | null; supported: true } | { supported: false };\n\ntype Context2D = OffscreenCanvasRenderingContext2D | CanvasRenderingContext2D;\n\n/**\n * Fetches an image as a blob, retrying cross-origin images without the cache\n * and then through the proxy. Null when every attempt fails.\n */\nexport async function fetchImageBlob(\n src: string,\n proxyUrl: string | null,\n): Promise<Blob | null> {\n if (typeof fetch !== \"function\") return null;\n\n const read = async (url: string, init?: RequestInit) => {\n const response = await fetch(url, { ...init, mode: \"cors\" });\n if (!response.ok) return null;\n const blob = await response.blob();\n return blob.type.startsWith(\"text/\") ? null : blob;\n };\n\n try {\n const blob = await read(src);\n if (blob) return blob;\n } catch {\n // A cached opaque response can fail CORS; retry once without the cache.\n if (isCrossOrigin(src)) {\n try {\n const blob = await read(src, { cache: \"reload\" });\n if (blob) return blob;\n } catch {\n // Still refused: try the proxy next.\n }\n }\n }\n\n if (proxyUrl) {\n try {\n return await read(proxyUrl);\n } catch {\n // The proxy failed too: there is nothing to analyse.\n }\n }\n return null;\n}\n\nfunction isCrossOrigin(url: string): boolean {\n try {\n return new URL(url).origin !== globalThis.location?.origin;\n } catch {\n // A relative or malformed URL is treated as same-origin.\n return false;\n }\n}\n\nfunction createContext2D(width: number, height: number): Context2D | null {\n if (typeof OffscreenCanvas === \"function\") {\n return new OffscreenCanvas(width, height).getContext(\"2d\", {\n willReadFrequently: true,\n });\n }\n if (typeof document !== \"undefined\") {\n const canvas = document.createElement(\"canvas\");\n canvas.width = width;\n canvas.height = height;\n return canvas.getContext(\"2d\", { willReadFrequently: true });\n }\n return null;\n}\n\n/** Draws an image scaled to the sample size and reads its RGBA pixels. */\nexport function readPixels(\n image: CanvasImageSource,\n sourceWidth: number,\n sourceHeight: number,\n size: number,\n): AmbientPixels | null {\n const { height, width } = fitSample(sourceWidth, sourceHeight, size);\n const context = createContext2D(width, height);\n if (!context) return null;\n context.drawImage(image, 0, 0, width, height);\n return {\n data: context.getImageData(0, 0, width, height).data,\n height,\n width,\n };\n}\n\nasync function decodeBlob(\n blob: Blob,\n size: number,\n): Promise<AmbientPixels | null> {\n if (typeof createImageBitmap !== \"function\") return null;\n let bitmap: ImageBitmap;\n try {\n bitmap = await createImageBitmap(blob, {\n resizeQuality: \"medium\",\n resizeWidth: size,\n });\n } catch {\n // Some browsers reject resize options; decode at full size instead.\n bitmap = await createImageBitmap(blob);\n }\n try {\n return readPixels(bitmap, bitmap.width, bitmap.height, size);\n } finally {\n bitmap.close();\n }\n}\n\nconst canDecodeHere = () =>\n typeof createImageBitmap === \"function\" &&\n (typeof OffscreenCanvas === \"function\" || typeof document !== \"undefined\");\n\n/** Fetches, decodes and analyses an image on the current thread. */\nexport async function extractHere(\n request: AmbientExtractRequest,\n): Promise<AmbientExtractResult> {\n if (!canDecodeHere()) return { supported: false };\n const blob = await fetchImageBlob(request.src, request.proxyUrl);\n if (!blob) return { palette: null, supported: true };\n try {\n const pixels = await decodeBlob(blob, request.analysis.sampleSize);\n return {\n palette: pixels ? analyzeAmbientPixels(pixels, request.analysis) : null,\n supported: true,\n };\n } catch {\n // An undecodable image simply has no palette.\n return { palette: null, supported: true };\n }\n}\n","import { type AmbientExtractRequest, extractHere } from \"../pipeline\";\n\n/**\n * Message type of an extraction request sent to the worker.\n */\nexport const AMBIENT_WORKER_REQUEST = \"ambient:extract\";\n/**\n * Message type of the worker's reply.\n */\nexport const AMBIENT_WORKER_RESPONSE = \"ambient:palette\";\n\n/**\n * An extraction request posted to the ambient worker.\n */\nexport interface AmbientWorkerRequest extends AmbientExtractRequest {\n id: number;\n type: typeof AMBIENT_WORKER_REQUEST;\n}\n\n/**\n * The part of a worker global scope that serveAmbientWorker uses.\n */\nexport interface AmbientWorkerScope {\n addEventListener(\n type: \"message\",\n listener: (event: MessageEvent) => void,\n ): void;\n postMessage(message: unknown): void;\n removeEventListener(\n type: \"message\",\n listener: (event: MessageEvent) => void,\n ): void;\n}\n\n/**\n * Starts answering extraction requests in a worker. Returns a function that\n * stops it.\n */\nexport function serveAmbientWorker(\n scope: AmbientWorkerScope = globalThis,\n): () => void {\n const respond = async (request: AmbientWorkerRequest) => {\n let result: Awaited<ReturnType<typeof extractHere>>;\n try {\n result = await extractHere(request);\n } catch {\n // A failed extraction is answered with an empty palette.\n result = { palette: null, supported: true };\n }\n scope.postMessage({\n ...result,\n id: request.id,\n type: AMBIENT_WORKER_RESPONSE,\n });\n };\n const onMessage = (event: MessageEvent) => {\n const request = event.data as AmbientWorkerRequest | null;\n if (request?.type !== AMBIENT_WORKER_REQUEST) return;\n void respond(request);\n };\n scope.addEventListener(\"message\", onMessage);\n return () => scope.removeEventListener(\"message\", onMessage);\n}\n"]}
|
package/dist/background/index.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
export { BACKGROUND_MEDIA_ID, BACKGROUND_REGISTRY_KEY, BG_TOKEN_TO_OBJECT_STYLE, BackgroundContext, BackgroundOverlay, BackgroundProvider, DEFAULT_BACKGROUND, DEFAULT_BACKGROUND_COMPUTED, DEFAULT_COLOR, INERT_BACKGROUND_ACTIONS, OBJECT_FITS, YouTubeBackgroundPlayer, applyVideoPlaybackState, backgroundModule, backgroundTheme, computeBackgroundState, defineBackground, extractYouTubeVideoId, generateBaseGradient, generateEdgeGradient, getEdgeFadeMask, getYouTubeStreamUrl, getYouTubeThumbnailUrl, isDirectVideoUrl, isYouTubeUrl, mergeBackgroundState, normalizeBackgroundInput, parseYouTubeUrlConfig, resolveBackgroundState, resolveVideoClassNames, resolveVideoOptions, selectPageBackground, syncVideoLoopDirect, syncVideoMutedDirect, triggerVideoPlaybackDirect, useBackground, useBackgroundActions, useBackgroundRegistration, useBackgroundState, useOptionalBackgroundActions, useOptionalBackgroundState } from '../chunk-
|
|
3
|
-
import '../chunk-
|
|
4
|
-
import '../chunk-
|
|
5
|
-
import '../chunk-
|
|
6
|
-
import '../chunk-
|
|
7
|
-
import '../chunk-
|
|
8
|
-
import '../chunk-
|
|
9
|
-
import '../chunk-D222OCTV.js';
|
|
2
|
+
export { BACKGROUND_MEDIA_ID, BACKGROUND_REGISTRY_KEY, BG_TOKEN_TO_OBJECT_STYLE, BackgroundContext, BackgroundOverlay, BackgroundProvider, DEFAULT_BACKGROUND, DEFAULT_BACKGROUND_COMPUTED, DEFAULT_COLOR, INERT_BACKGROUND_ACTIONS, OBJECT_FITS, YouTubeBackgroundPlayer, applyVideoPlaybackState, backgroundModule, backgroundTheme, computeBackgroundState, defineBackground, extractYouTubeVideoId, generateBaseGradient, generateEdgeGradient, getEdgeFadeMask, getYouTubeStreamUrl, getYouTubeThumbnailUrl, isDirectVideoUrl, isYouTubeUrl, mergeBackgroundState, normalizeBackgroundInput, parseYouTubeUrlConfig, resolveBackgroundState, resolveVideoClassNames, resolveVideoOptions, selectPageBackground, syncVideoLoopDirect, syncVideoMutedDirect, triggerVideoPlaybackDirect, useBackground, useBackgroundActions, useBackgroundRegistration, useBackgroundState, useOptionalBackgroundActions, useOptionalBackgroundState } from '../chunk-6P3F4JU3.js';
|
|
3
|
+
import '../chunk-C3SEBNF5.js';
|
|
4
|
+
import '../chunk-GG2ILNK2.js';
|
|
5
|
+
import '../chunk-ED32WLAD.js';
|
|
6
|
+
import '../chunk-JWUKAZ3A.js';
|
|
7
|
+
import '../chunk-AKPH5CEJ.js';
|
|
8
|
+
import '../chunk-S67HGKJ2.js';
|
|
10
9
|
import '../chunk-J3VTDBC6.js';
|
|
11
|
-
import '../chunk-
|
|
10
|
+
import '../chunk-YHWA7FXX.js';
|
|
12
11
|
//# sourceMappingURL=index.js.map
|
|
13
12
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { INITIAL_MODAL_STATE, ModalProvider, ModalContext, useModalActions, getModalIdentity, useModal } from './chunk-
|
|
2
|
-
import { defineModule } from './chunk-
|
|
3
|
-
import { useStore } from './chunk-
|
|
4
|
-
import { createStore } from './chunk-
|
|
1
|
+
import { INITIAL_MODAL_STATE, ModalProvider, ModalContext, useModalActions, getModalIdentity, useModal } from './chunk-WVED7PDH.js';
|
|
2
|
+
import { defineModule } from './chunk-ED32WLAD.js';
|
|
3
|
+
import { useStore } from './chunk-JWUKAZ3A.js';
|
|
4
|
+
import { createStore } from './chunk-S67HGKJ2.js';
|
|
5
5
|
import { c } from 'react/compiler-runtime';
|
|
6
6
|
import { lazy, useRef, useLayoutEffect, use, useState, useEffect, Suspense } from 'react';
|
|
7
7
|
import { jsx } from 'react/jsx-runtime';
|
|
8
8
|
|
|
9
9
|
var overlayChunk = null;
|
|
10
|
-
var loadOverlay = () => overlayChunk ??= import('./overlay-
|
|
10
|
+
var loadOverlay = () => overlayChunk ??= import('./overlay-ZCMQVNYT.js');
|
|
11
11
|
var LazyModal = lazy(() => loadOverlay().then((view) => ({
|
|
12
12
|
default: view.Modal
|
|
13
13
|
})));
|
|
@@ -157,5 +157,5 @@ function defineModal(definition = {}) {
|
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
export { defineModal, modalModule };
|
|
160
|
-
//# sourceMappingURL=chunk-
|
|
161
|
-
//# sourceMappingURL=chunk-
|
|
160
|
+
//# sourceMappingURL=chunk-3FSDBJ7V.js.map
|
|
161
|
+
//# sourceMappingURL=chunk-3FSDBJ7V.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/modules/modal/module.tsx"],"names":["overlayChunk","loadOverlay","LazyModal","lazy","then","view","default","Modal","IDLE_STORE","createStore","INITIAL_MODAL_STATE","freezeSnapshots","IDLE_PRELOAD_FALLBACK_MS","preloadWhenIdle","preload","window","requestIdleCallback","handle","cancelIdleCallback","timer","setTimeout","clearTimeout","hasOpenModal","state","isOpen","ModalOverlay","$","_c","modal","use","ModalContext","useStore","store","needed","setNeeded","useState","t0","t1","undefined","useEffect","t2","Symbol","for","selectPageModals","config","useModalPage","slice","page","actions","useModalActions","sliceRef","useRef","current","useLayoutEffect","t3","data","own","openModal","modal_0","set","t4","open","modalModule","defineModule","id","context","Provider","ModalProvider","Overlay","registry","cleanupDelayMs","keyPolicy","lifecycle","valueKind","select","entries","Object","map","key","value","defineModal","definition","type","getModalIdentity","modalDefinition","freeze","isModalDefinition","useDefinedModal","useModal"],"mappings":";;;;;;;;AAkCA,IAAIA,YAAAA,GAAmD,IAAA;AACvD,IAAMC,WAAAA,GAAcA,MAAOD,YAAAA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A,CAAa;EACtCC,EAAAA,EAAI,OAAA;EACJC,OAAAA,EAASnC,YAAAA;EACToC,QAAAA,EAAUC,aAAAA;EACVC,OAAAA,EAAS3C,YAAAA;EACT4C,QAAAA,EAAU;IACRC,cAAAA,EAAgB,GAAA;IAChBC,SAAAA,EAAW,OAAA;IACXC,SAAAA,EAAW,WAAA;IACXC,SAAAA,EAAW;AACb,GAAA;EACA1B,IAAAA,EAAM;IACJ2B,MAAAA,EAAQ/B,gBAAAA;IACRgC,OAAAA,EAAU7B,CAAAA,KAAAA,KACR8B,MAAAA,CAAOD,OAAAA,CAAQ7B,KAAK,CAAA,CAAE+B,IAAI,CAAC,CAACC,GAAAA,EAAKC,KAAK,CAAA,MAAO;AAAED,MAAAA,GAAAA;AAAKC,MAAAA;KAAM,CAAE,CAAA;IAC9DlD,GAAAA,EAAKgB;AACP;AACF,CAAC;AAcM,SAASmC,WAAAA,CACdC,UAAAA,GAAiC,EAAC,EACjB;AACjB,EAAA,MAAM;AAAEC,IAAAA;AAAK,GAAA,GAAIC,iBAAiBF,UAAU,CAAA;AAE5C,EAAA,MAAMG,eAAAA,GAAmCR,OAAOS,MAAAA,CAAO;IACrD,GAAGJ,UAAAA;AACHjB,IAAAA,EAAAA,EAAIiB,WAAWjB,EAAAA,IAAMkB,IAAAA;IACrBI,iBAAAA,EAAmB,IAAA;AACnBJ,IAAAA,IAAAA;AACArD,IAAAA,GAAAA,EAAK,SAAS0D,eAAAA,GAAkB;AAC9B,MAAA,OAAOC,SAASJ,eAAe,CAAA;AACjC,IAAA;GACD,CAAA;AACD,EAAA,OAAOA,eAAAA;AACT","file":"chunk-3FSDBJ7V.js","sourcesContent":["\"use client\";\n\nimport {\n lazy,\n Suspense,\n use,\n useEffect,\n useLayoutEffect,\n useMemo,\n useRef,\n useState,\n} from \"react\";\n\nimport {\n defineModule,\n type PageConfig,\n type PageModuleApi,\n} from \"@/core/kernel\";\nimport { createStore } from \"@/foundation/utils\";\nimport { useStore } from \"@/react/hooks\";\n\nimport { ModalContext, ModalProvider } from \"./context\";\nimport { useModal, useModalActions } from \"./hooks\";\nimport type * as OverlayView from \"./overlay\";\nimport { getModalIdentity, INITIAL_MODAL_STATE } from \"./state\";\nimport type {\n DefineModalOptions,\n ModalDefinition,\n ModalInput,\n ModalPageApi,\n ModalPageConfig,\n ModalState,\n} from \"./types\";\n\nlet overlayChunk: Promise<typeof OverlayView> | null = null;\nconst loadOverlay = () => (overlayChunk ??= import(\"./overlay\"));\n\nconst LazyModal = lazy(() =>\n loadOverlay().then((view) => ({ default: view.Modal })),\n);\n\nconst IDLE_STORE = createStore<ModalState>(INITIAL_MODAL_STATE, {\n freezeSnapshots: false,\n});\n\nconst IDLE_PRELOAD_FALLBACK_MS = 2000;\n\n/** Warms the overlay chunk once the page is idle, off the hydration path. */\nfunction preloadWhenIdle(): () => void {\n const preload = () => void loadOverlay();\n if (typeof window.requestIdleCallback === \"function\") {\n const handle = window.requestIdleCallback(preload);\n return () => window.cancelIdleCallback(handle);\n }\n const timer = setTimeout(preload, IDLE_PRELOAD_FALLBACK_MS);\n return () => clearTimeout(timer);\n}\n\nconst hasOpenModal = (state: ModalState) => state.isOpen;\n\n/**\n * Mounts the modal overlay the first time a modal opens and keeps it mounted\n * afterwards (exit animations need it). Until then no overlay code runs: no\n * viewport listeners, registry subscription or portal, and its chunk loads\n * on idle instead of during hydration.\n */\nfunction ModalOverlay() {\n const modal = use(ModalContext);\n const isOpen = useStore(modal?.store ?? IDLE_STORE, hasOpenModal);\n const [needed, setNeeded] = useState(false);\n if (isOpen && !needed) setNeeded(true);\n\n useEffect(() => (modal ? preloadWhenIdle() : undefined), [modal]);\n\n if (!needed) return null;\n return (\n <Suspense fallback={null}>\n <LazyModal />\n </Suspense>\n );\n}\n\nfunction selectPageModals(config: PageConfig): ModalPageConfig | null {\n return config.modal ?? null;\n}\n\nfunction useModalPage(\n slice: ModalPageConfig | null,\n page: PageModuleApi,\n): ModalPageApi {\n const actions = useModalActions();\n const sliceRef = useRef(slice);\n useLayoutEffect(() => {\n sliceRef.current = slice;\n }, [slice]);\n\n // stable identity: part of the public hook contract\n return useMemo(\n () => ({\n ...actions,\n open: (modal: ModalInput, data: Record<string, unknown> = {}) => {\n const own =\n typeof modal === \"string\" && modal !== \"registry\"\n ? sliceRef.current?.[modal]\n : undefined;\n return actions.openModal((own as ModalInput) ?? modal, { data });\n },\n set: (modal: ModalPageConfig) => page.set({ modal }),\n }),\n [actions, page],\n );\n}\n\n/**\n * The modal module definition: install it on the framework to render a modal stack\n * and let pages register modals through `page.modal`.\n */\nexport const modalModule = defineModule({\n id: \"modal\",\n context: ModalContext,\n Provider: ModalProvider,\n Overlay: ModalOverlay,\n registry: {\n cleanupDelayMs: 600,\n keyPolicy: \"named\",\n lifecycle: \"immediate\",\n valueKind: \"component\",\n },\n page: {\n select: selectPageModals,\n entries: (slice: ModalPageConfig) =>\n Object.entries(slice).map(([key, value]) => ({ key, value })),\n use: useModalPage,\n },\n});\n\ndeclare module \"@omerdlw/base-framework/kernel\" {\n interface CoreModules {\n modal: typeof modalModule;\n }\n interface PageConfig {\n modal?: ModalPageConfig;\n }\n}\n\n/**\n * Defines a reusable modal. Its `use` hook returns the `[open, controls]` binding.\n */\nexport function defineModal(\n definition: DefineModalOptions = {},\n): ModalDefinition {\n const { type } = getModalIdentity(definition);\n\n const modalDefinition: ModalDefinition = Object.freeze({\n ...definition,\n id: definition.id || type,\n isModalDefinition: true,\n type,\n use: function useDefinedModal() {\n return useModal(modalDefinition);\n },\n });\n return modalDefinition;\n}\n"]}
|
|
@@ -9,14 +9,6 @@ var USER_MESSAGES = Object.freeze({
|
|
|
9
9
|
rateLimited: "Too many attempts. Please wait a moment and try again",
|
|
10
10
|
server: "We're having trouble on our end. Please try again in a moment"
|
|
11
11
|
});
|
|
12
|
-
var UserError = class extends Error {
|
|
13
|
-
status;
|
|
14
|
-
constructor(message, status) {
|
|
15
|
-
super(message);
|
|
16
|
-
this.name = "UserError";
|
|
17
|
-
this.status = status;
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
12
|
var NETWORK_FAILURE = /failed to fetch|network|load failed|fetch failed/i;
|
|
21
13
|
var STATUS_UNAUTHORIZED = 401;
|
|
22
14
|
var STATUS_FORBIDDEN = 403;
|
|
@@ -26,6 +18,14 @@ var STATUS_RATE_LIMITED = 429;
|
|
|
26
18
|
var STATUS_GATEWAY_TIMEOUT = 504;
|
|
27
19
|
var STATUS_CLIENT_ERROR_MIN = 400;
|
|
28
20
|
var STATUS_SERVER_ERROR_MIN = 500;
|
|
21
|
+
var UserError = class extends Error {
|
|
22
|
+
status;
|
|
23
|
+
constructor(message, status) {
|
|
24
|
+
super(message);
|
|
25
|
+
this.name = "UserError";
|
|
26
|
+
this.status = status;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
29
|
function readField(source, field, type) {
|
|
30
30
|
const value = source?.[field];
|
|
31
31
|
return typeof value === type ? value : void 0;
|
|
@@ -77,5 +77,5 @@ function toUserMessage(error, { codes, fallback = USER_MESSAGES.generic } = {})
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
export { USER_MESSAGES, UserError, toUserMessage };
|
|
80
|
-
//# sourceMappingURL=chunk-
|
|
81
|
-
//# sourceMappingURL=chunk-
|
|
80
|
+
//# sourceMappingURL=chunk-4QQ3QVY7.js.map
|
|
81
|
+
//# sourceMappingURL=chunk-4QQ3QVY7.js.map
|