@omerdlw/base-framework 3.2.1 → 3.3.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.
Files changed (153) hide show
  1. package/MIGRATION.md +24 -0
  2. package/dist/ambient/index.js +8 -8
  3. package/dist/ambient/server/index.js +2 -2
  4. package/dist/ambient/worker/index.js +1 -1
  5. package/dist/background/index.js +7 -7
  6. package/dist/{chunk-GQKGOLHJ.js → chunk-67MOKJFZ.js} +178 -79
  7. package/dist/chunk-67MOKJFZ.js.map +1 -0
  8. package/dist/{chunk-2BLGNT5I.js → chunk-6IP6YFQX.js} +6 -6
  9. package/dist/{chunk-2BLGNT5I.js.map → chunk-6IP6YFQX.js.map} +1 -1
  10. package/dist/{chunk-CT4UILO2.js → chunk-7VU2OAJB.js} +4 -77
  11. package/dist/chunk-7VU2OAJB.js.map +1 -0
  12. package/dist/{chunk-5H6FZW3N.js → chunk-D222OCTV.js} +15 -9
  13. package/dist/chunk-D222OCTV.js.map +1 -0
  14. package/dist/{chunk-2LGI33JP.js → chunk-GKAJ4EM2.js} +169 -73
  15. package/dist/chunk-GKAJ4EM2.js.map +1 -0
  16. package/dist/{chunk-66MHDFNF.js → chunk-HFR6YROB.js} +9 -16
  17. package/dist/chunk-HFR6YROB.js.map +1 -0
  18. package/dist/{chunk-ZE6OGGA7.js → chunk-IH3STE7W.js} +120 -49
  19. package/dist/chunk-IH3STE7W.js.map +1 -0
  20. package/dist/chunk-K3LXE6D5.js +17 -0
  21. package/dist/{chunk-IR3DCLBM.js.map → chunk-K3LXE6D5.js.map} +1 -1
  22. package/dist/{chunk-NTUQYA73.js → chunk-KOYTJW5E.js} +60 -9
  23. package/dist/chunk-KOYTJW5E.js.map +1 -0
  24. package/dist/{chunk-WYVA6AN5.js → chunk-LKYW4LH6.js} +5 -5
  25. package/dist/{chunk-WYVA6AN5.js.map → chunk-LKYW4LH6.js.map} +1 -1
  26. package/dist/{chunk-PUD4IB3L.js → chunk-NCXFWCXP.js} +497 -366
  27. package/dist/chunk-NCXFWCXP.js.map +1 -0
  28. package/dist/{chunk-J4WUCHNR.js → chunk-QRXDXAQI.js} +5 -5
  29. package/dist/{chunk-J4WUCHNR.js.map → chunk-QRXDXAQI.js.map} +1 -1
  30. package/dist/{chunk-AAT3QWHN.js → chunk-R4K6VAOK.js} +4 -4
  31. package/dist/{chunk-AAT3QWHN.js.map → chunk-R4K6VAOK.js.map} +1 -1
  32. package/dist/{chunk-OEXWOZPS.js → chunk-RGC2VFQO.js} +6 -6
  33. package/dist/chunk-RGC2VFQO.js.map +1 -0
  34. package/dist/chunk-TAWTGCWJ.js +113 -0
  35. package/dist/chunk-TAWTGCWJ.js.map +1 -0
  36. package/dist/{chunk-LTO77WSO.js → chunk-UDJ7ARCH.js} +3 -3
  37. package/dist/{chunk-LTO77WSO.js.map → chunk-UDJ7ARCH.js.map} +1 -1
  38. package/dist/{chunk-26K6W4OQ.js → chunk-UE2KBW3D.js} +7 -7
  39. package/dist/{chunk-26K6W4OQ.js.map → chunk-UE2KBW3D.js.map} +1 -1
  40. package/dist/{chunk-WBBM67WL.js → chunk-UQLTP3XB.js} +6 -6
  41. package/dist/{chunk-WBBM67WL.js.map → chunk-UQLTP3XB.js.map} +1 -1
  42. package/dist/{chunk-LA3CQ6NY.js → chunk-VNSMNGWP.js} +5 -5
  43. package/dist/{chunk-LA3CQ6NY.js.map → chunk-VNSMNGWP.js.map} +1 -1
  44. package/dist/{chunk-Y2Q74PJP.js → chunk-WQTMOUCA.js} +3 -3
  45. package/dist/{chunk-Y2Q74PJP.js.map → chunk-WQTMOUCA.js.map} +1 -1
  46. package/dist/chunk-WZ5T2NXH.js +702 -0
  47. package/dist/chunk-WZ5T2NXH.js.map +1 -0
  48. package/dist/{chunk-RF2YGILF.js → chunk-XGAYTDSI.js} +37 -37
  49. package/dist/chunk-XGAYTDSI.js.map +1 -0
  50. package/dist/{chunk-KMN6J5SL.js → chunk-YZS2B6YE.js} +6 -6
  51. package/dist/{chunk-KMN6J5SL.js.map → chunk-YZS2B6YE.js.map} +1 -1
  52. package/dist/{chunk-5GVH4BQV.js → chunk-ZXRE2KZO.js} +5 -5
  53. package/dist/{chunk-5GVH4BQV.js.map → chunk-ZXRE2KZO.js.map} +1 -1
  54. package/dist/context-menu/index.js +13 -13
  55. package/dist/controls/index.js +4 -4
  56. package/dist/core/kernel/hooks.d.ts.map +1 -1
  57. package/dist/core/kernel/operations-records.d.ts +7 -0
  58. package/dist/core/kernel/operations-records.d.ts.map +1 -1
  59. package/dist/core/kernel/operations-resolve.d.ts.map +1 -1
  60. package/dist/core/kernel/operations.d.ts.map +1 -1
  61. package/dist/core/kernel/stabilize.d.ts.map +1 -1
  62. package/dist/core/provider/index.d.ts.map +1 -1
  63. package/dist/dock/index.js +12 -12
  64. package/dist/error/index.js +5 -5
  65. package/dist/foundation/recipes/cn.d.ts +3 -3
  66. package/dist/foundation/recipes/cn.d.ts.map +1 -1
  67. package/dist/foundation/recipes/define.d.ts +2 -3
  68. package/dist/foundation/recipes/define.d.ts.map +1 -1
  69. package/dist/foundation/recipes/recipe.d.ts +4 -4
  70. package/dist/foundation/recipes/recipe.d.ts.map +1 -1
  71. package/dist/foundation/utils/scheduler.d.ts +1 -1
  72. package/dist/foundation/utils/scheduler.d.ts.map +1 -1
  73. package/dist/hooks/index.js +2 -2
  74. package/dist/index.js +22 -22
  75. package/dist/kernel/index.js +3 -3
  76. package/dist/loading/index.js +6 -6
  77. package/dist/media/index.js +4 -4
  78. package/dist/modal/index.js +11 -11
  79. package/dist/modules/ambient/analyze-ground.d.ts +42 -0
  80. package/dist/modules/ambient/analyze-ground.d.ts.map +1 -0
  81. package/dist/modules/ambient/analyze.d.ts +1 -1
  82. package/dist/modules/ambient/analyze.d.ts.map +1 -1
  83. package/dist/modules/ambient/dom.d.ts.map +1 -1
  84. package/dist/modules/ambient/hooks.d.ts.map +1 -1
  85. package/dist/modules/ambient/settings.d.ts.map +1 -1
  86. package/dist/modules/ambient/types.d.ts +16 -4
  87. package/dist/modules/ambient/types.d.ts.map +1 -1
  88. package/dist/modules/background/context.d.ts.map +1 -1
  89. package/dist/modules/dock/hooks/use-card-item-model.d.ts +4 -4
  90. package/dist/modules/dock/hooks/use-dock-height-controller.d.ts +1 -1
  91. package/dist/modules/dock/hooks/use-dock-height-controller.d.ts.map +1 -1
  92. package/dist/modules/dock/hooks/use-dock-viewport.d.ts.map +1 -1
  93. package/dist/modules/dock/lib/helpers.d.ts +1 -1
  94. package/dist/modules/dock/lib/helpers.d.ts.map +1 -1
  95. package/dist/modules/dock/lib/styles.d.ts +2 -2
  96. package/dist/modules/dock/model/layout.d.ts +19 -4
  97. package/dist/modules/dock/model/layout.d.ts.map +1 -1
  98. package/dist/modules/dock/model/paths.d.ts +7 -0
  99. package/dist/modules/dock/model/paths.d.ts.map +1 -1
  100. package/dist/modules/dock/motion.d.ts +2 -2
  101. package/dist/modules/dock/routing/navigation.d.ts.map +1 -1
  102. package/dist/modules/dock/runtime/dock.d.ts.map +1 -1
  103. package/dist/modules/dock/runtime/hooks/use-dock.d.ts.map +1 -1
  104. package/dist/modules/dock/types/card.d.ts +6 -0
  105. package/dist/modules/dock/types/card.d.ts.map +1 -1
  106. package/dist/modules/dock/types/theme.d.ts +20 -0
  107. package/dist/modules/dock/types/theme.d.ts.map +1 -1
  108. package/dist/modules/index.js +20 -20
  109. package/dist/modules/modal/module.d.ts.map +1 -1
  110. package/dist/navigation/index.js +7 -7
  111. package/dist/notification/index.js +5 -5
  112. package/dist/overlay-7QLGWHCH.js +13 -0
  113. package/dist/{overlay-YC336DAS.js.map → overlay-7QLGWHCH.js.map} +1 -1
  114. package/dist/provider/index.js +9 -8
  115. package/dist/react/ui/components/tooltip-group.d.ts +34 -0
  116. package/dist/react/ui/components/tooltip-group.d.ts.map +1 -0
  117. package/dist/react/ui/components/tooltip-placement.d.ts +43 -0
  118. package/dist/react/ui/components/tooltip-placement.d.ts.map +1 -0
  119. package/dist/react/ui/components/tooltip-slot.d.ts +23 -0
  120. package/dist/react/ui/components/tooltip-slot.d.ts.map +1 -0
  121. package/dist/react/ui/components/tooltip.d.ts +9 -7
  122. package/dist/react/ui/components/tooltip.d.ts.map +1 -1
  123. package/dist/react/ui/types.d.ts +24 -3
  124. package/dist/react/ui/types.d.ts.map +1 -1
  125. package/dist/recipes/index.js +22 -3
  126. package/dist/recipes/index.js.map +1 -1
  127. package/dist/ui/index.js +8 -8
  128. package/dist/utils/index.js +13 -7
  129. package/dist/utils/index.js.map +1 -1
  130. package/docs/architecture-and-rules.md +0 -2
  131. package/docs/core-engine.md +2 -2
  132. package/docs/design.md +17 -17
  133. package/docs/getting-started.md +6 -7
  134. package/docs/modules/ambient.md +79 -58
  135. package/docs/modules/dock.md +15 -15
  136. package/docs/modules/modal.md +2 -2
  137. package/package.json +1 -4
  138. package/dist/chunk-2LGI33JP.js.map +0 -1
  139. package/dist/chunk-37OBXNEO.js +0 -116
  140. package/dist/chunk-37OBXNEO.js.map +0 -1
  141. package/dist/chunk-5H6FZW3N.js.map +0 -1
  142. package/dist/chunk-66MHDFNF.js.map +0 -1
  143. package/dist/chunk-7RSRDKYE.js +0 -22
  144. package/dist/chunk-7RSRDKYE.js.map +0 -1
  145. package/dist/chunk-CT4UILO2.js.map +0 -1
  146. package/dist/chunk-GQKGOLHJ.js.map +0 -1
  147. package/dist/chunk-IR3DCLBM.js +0 -17
  148. package/dist/chunk-NTUQYA73.js.map +0 -1
  149. package/dist/chunk-OEXWOZPS.js.map +0 -1
  150. package/dist/chunk-PUD4IB3L.js.map +0 -1
  151. package/dist/chunk-RF2YGILF.js.map +0 -1
  152. package/dist/chunk-ZE6OGGA7.js.map +0 -1
  153. package/dist/overlay-YC336DAS.js +0 -13
package/MIGRATION.md CHANGED
@@ -73,3 +73,27 @@ Rendering is the same. What changes:
73
73
  The published JavaScript is built with `babel-plugin-react-compiler`. Components and hooks memoize automatically, so the source no longer carries most hand-written `useMemo`/`useCallback`/`memo`. Behaviour does not depend on the compiler: identities that effects, subscriptions, context values and public hook returns rely on stay stable in uncompiled code too.
74
74
 
75
75
  The compiled output is larger. Total gzipped JavaScript is about 35% above the previous build (about 273 KB vs 201 KB across all entries and chunks). The compiler accounts for most of that, about 25%. Bundlers still tree-shake per entry, so an app pays only for the entries it imports.
76
+
77
+ ## Tooltip without Radix (3.2.2)
78
+
79
+ `Tooltip` and `TooltipProvider` no longer wrap `@radix-ui/react-tooltip`; placement, delay groups and presence are built in. `@radix-ui/react-tooltip`, `clsx` and `loading-dev` are no longer dependencies, so a fresh install pulls less. The public props are the same except:
80
+
81
+ - `contentProps` takes plain `div` attributes and `data-*` hooks. Radix-only props (`onEscapeKeyDown`, `onPointerDownOutside`, `avoidCollisions`, `forceMount`, `asChild`, `hideWhenDetached`, `sticky`) are gone; flipping and shifting into the viewport always apply.
82
+ - CSS variables are renamed: `--radix-tooltip-content-transform-origin` → `--tooltip-transform-origin`, `--radix-tooltip-content-available-width/height` → `--tooltip-available-width/height`, `--radix-tooltip-trigger-width/height` → `--tooltip-trigger-width/height`.
83
+ - The portal wrapper is `[data-tooltip-wrapper]` (was `[data-radix-popper-content-wrapper]`). It still copies the content's `z-index`.
84
+ - `data-state` (`delayed-open`, `instant-open`, `closed`) and `data-side` keep their values; `data-align` is new, and so is the `align` prop (`start`, `center`, `end`).
85
+ - A `TooltipProvider` is optional. A `Tooltip` outside one uses a shared default group (700 ms delay, 300 ms skip window).
86
+ - `ClassValue` from `clsx` is no longer re-exported through `cn`'s types; `cn` takes the framework's `Classes` type, which accepts the same strings, arrays, objects and falsy values.
87
+
88
+ The modal overlay now loads with `React.lazy` instead of `next/dynamic`, mounts only after the first modal opens, and preloads its chunk when the browser is idle.
89
+
90
+ ## Ambient grounds and dock sizing (3.3.0)
91
+
92
+ Ambient palettes are now made for a **ground**, the kind of page they lie on: `"dark"` (the default, as before) or `"light"`. Set it once with `configureAmbient({ analysis: { ground: "light" } })` and pass the same `analysis` to the server extractor.
93
+
94
+ - `AmbientPalette.shadow` is replaced by `page` (the page tone for the ground) and `presence` (how colourful the image is, `0` to `1`). Palettes also carry `ground`.
95
+ - The `--ambient-shadow` variable is now `--ambient-page`, and `--ambient-presence` is new. In `cssVars`, rename `shadow` to `page`; `presence` can be renamed or turned off the same way.
96
+ - `AmbientAnalysisOptions.shadowLightness` is replaced by `ground`. On the dark ground the page tone keeps its old lightness (0.16).
97
+ - An `initialPalette` made for another ground than the configured one is ignored. Palettes cached across deploys should carry `AMBIENT_ANALYSIS_VERSION` in their key.
98
+
99
+ The dock card is sized to its content plus `motion.deck.padding` above and below (default 10 px), instead of a fixed 68 px base. `motion.deck.width` sets the resting card width (default 460 px). `motion.deck.heightVar` names the CSS variable published on `<html>` (default `--dock-h`); `false` publishes none, so an app can read `dockHeight` from state and avoid restyling the whole page on every height change.
@@ -1,13 +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-GQKGOLHJ.js';
3
- import '../chunk-66MHDFNF.js';
4
- import '../chunk-5GVH4BQV.js';
5
- import '../chunk-ZE6OGGA7.js';
6
- import '../chunk-Y2Q74PJP.js';
7
- import '../chunk-CT4UILO2.js';
8
- import '../chunk-7RSRDKYE.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-67MOKJFZ.js';
3
+ import '../chunk-HFR6YROB.js';
4
+ import '../chunk-ZXRE2KZO.js';
5
+ import '../chunk-IH3STE7W.js';
6
+ import '../chunk-WQTMOUCA.js';
7
+ import '../chunk-7VU2OAJB.js';
8
+ import '../chunk-TAWTGCWJ.js';
9
9
  import '../chunk-ESD5EQ5H.js';
10
- import '../chunk-5H6FZW3N.js';
10
+ import '../chunk-D222OCTV.js';
11
11
  import '../chunk-J3VTDBC6.js';
12
12
  import '../chunk-BMFHS3GV.js';
13
13
  //# sourceMappingURL=index.js.map
@@ -1,5 +1,5 @@
1
- import { resolveAnalysis, analyzeAmbientPixels } from '../../chunk-2LGI33JP.js';
2
- export { AMBIENT_ANALYSIS_VERSION, analyzeAmbientPixels, configureAmbient, contrastRatio, findContentBounds, fitSample, formatOklch, getAmbientSettings, maxChroma, onColorFor, srgbToOklab, toneOf } from '../../chunk-2LGI33JP.js';
1
+ import { resolveAnalysis, analyzeAmbientPixels } from '../../chunk-GKAJ4EM2.js';
2
+ export { AMBIENT_ANALYSIS_VERSION, analyzeAmbientPixels, configureAmbient, contrastRatio, findContentBounds, fitSample, formatOklch, getAmbientSettings, maxChroma, onColorFor, srgbToOklab, toneOf } from '../../chunk-GKAJ4EM2.js';
3
3
 
4
4
  // src/modules/ambient/server/address.ts
5
5
  var PRIVATE_NAMES = /(^|\.)(localhost|local|internal|intranet|lan|home\.arpa|localdomain)$/;
@@ -1,4 +1,4 @@
1
- import { analyzeAmbientPixels, fitSample } from '../../chunk-2LGI33JP.js';
1
+ import { analyzeAmbientPixels, fitSample } from '../../chunk-GKAJ4EM2.js';
2
2
 
3
3
  // src/modules/ambient/pipeline.ts
4
4
  async function fetchImageBlob(src, proxyUrl) {
@@ -1,12 +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-66MHDFNF.js';
3
- import '../chunk-5GVH4BQV.js';
4
- import '../chunk-ZE6OGGA7.js';
5
- import '../chunk-Y2Q74PJP.js';
6
- import '../chunk-CT4UILO2.js';
7
- import '../chunk-7RSRDKYE.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-HFR6YROB.js';
3
+ import '../chunk-ZXRE2KZO.js';
4
+ import '../chunk-IH3STE7W.js';
5
+ import '../chunk-WQTMOUCA.js';
6
+ import '../chunk-7VU2OAJB.js';
7
+ import '../chunk-TAWTGCWJ.js';
8
8
  import '../chunk-ESD5EQ5H.js';
9
- import '../chunk-5H6FZW3N.js';
9
+ import '../chunk-D222OCTV.js';
10
10
  import '../chunk-J3VTDBC6.js';
11
11
  import '../chunk-BMFHS3GV.js';
12
12
  //# sourceMappingURL=index.js.map
@@ -1,8 +1,8 @@
1
- import { useOptionalBackgroundState } from './chunk-66MHDFNF.js';
2
- import { defineModule } from './chunk-ZE6OGGA7.js';
3
- import { useRequiredContext, useStore } from './chunk-Y2Q74PJP.js';
1
+ import { useOptionalBackgroundState } from './chunk-HFR6YROB.js';
2
+ import { defineModule } from './chunk-IH3STE7W.js';
3
+ import { useRequiredContext, useStore } from './chunk-WQTMOUCA.js';
4
4
  import { defineThemeSpec, useTheme } from './chunk-ESD5EQ5H.js';
5
- import { createStore } from './chunk-5H6FZW3N.js';
5
+ import { createStore } from './chunk-D222OCTV.js';
6
6
  import { getOrCreateGlobalContext } from './chunk-J3VTDBC6.js';
7
7
  import { shallowEqual } from './chunk-BMFHS3GV.js';
8
8
  import { c } from 'react/compiler-runtime';
@@ -78,14 +78,15 @@ var DEFAULT_ANALYSIS = Object.freeze({
78
78
  letterbox: true,
79
79
  minContrast: 4.5,
80
80
  minHueDistance: 40,
81
- sampleSize: 128,
82
- shadowLightness: 0.16
81
+ ground: "dark",
82
+ sampleSize: 128
83
83
  });
84
84
  var DEFAULT_CSS_VAR_NAMES = Object.freeze({
85
85
  on: "--ambient-on-{role}",
86
86
  region: "--ambient-{region}",
87
87
  role: "--ambient-{role}",
88
- shadow: "--ambient-shadow",
88
+ page: "--ambient-page",
89
+ presence: "--ambient-presence",
89
90
  tone: "--ambient-{role}-{tone}"
90
91
  });
91
92
  var DEFAULT_PROXY = "/api/ambient/proxy?url=";
@@ -249,7 +250,8 @@ function applyScopedCssVariables(element, varMap, {
249
250
  function paletteVarMap(palette, names = resolveCssVarNames()) {
250
251
  const varMap = {};
251
252
  if (!palette) return varMap;
252
- if (names.shadow) varMap[names.shadow] = palette.shadow;
253
+ if (names.page) varMap[names.page] = palette.page;
254
+ if (names.presence) varMap[names.presence] = String(palette.presence);
253
255
  for (const role of AMBIENT_ROLES) {
254
256
  const swatch = palette.roles[role];
255
257
  if (names.role) varMap[fill(names.role, {
@@ -814,8 +816,113 @@ function roleTone(source, spec, fallback, dilution = 1) {
814
816
  return fitTone(source.h, clamp(source.l, spec.min, spec.max), roleChroma(source, spec) * dilution);
815
817
  }
816
818
 
819
+ // src/modules/ambient/analyze-ground.ts
820
+ var GROUNDS = {
821
+ dark: {
822
+ fallback: {
823
+ accent: 0.72,
824
+ vibrant: 0.78
825
+ },
826
+ page: {
827
+ drift: 0.02,
828
+ gain: 0.06,
829
+ l: 0.16
830
+ },
831
+ region: [0.42, 0.72],
832
+ regionFallback: [0.3, 0.7],
833
+ roleContrast: 3,
834
+ roles: {
835
+ accent: [0.55, 0.8],
836
+ dominant: [0.42, 0.74],
837
+ muted: [0.38, 0.66],
838
+ vibrant: [0.62, 0.84]
839
+ }
840
+ },
841
+ light: {
842
+ fallback: {
843
+ accent: 0.52,
844
+ vibrant: 0.56
845
+ },
846
+ page: {
847
+ drift: 8e-3,
848
+ gain: 0.03,
849
+ l: 0.955
850
+ },
851
+ region: [0.8, 0.9],
852
+ // A region with no colour of its own sits at the page's lightness: no
853
+ // grey stain on the paper.
854
+ regionFallback: [0.945, 0.965],
855
+ // On paper a role is mostly text and marks: it reads as text does.
856
+ roleContrast: 4.5,
857
+ roles: {
858
+ accent: [0.46, 0.62],
859
+ dominant: [0.42, 0.6],
860
+ muted: [0.42, 0.58],
861
+ vibrant: [0.5, 0.64]
862
+ }
863
+ }
864
+ };
865
+ var PAGE_MEAN_LIGHTNESS_PIVOT = 0.45;
866
+ var SHADOW_MAX_SOURCE_LIGHTNESS = 0.5;
867
+ var SHADOW_MIN_SOURCE_CHROMA = 0.02;
868
+ var SHADOW_MIN_SOURCE_POPULATION = 0.02;
869
+ var DARK_PAGE_CHROMA_CAP = 0.1;
870
+ var LIGHT_PAGE_CHROMA_SHARE = 0.35;
871
+ var LIGHT_PAGE_CHROMA_MIN = 0.01;
872
+ var LIGHT_PAGE_CHROMA_CAP = 0.05;
873
+ var LIGHT_PAGE_FLOOR = 0.9;
874
+ var LIGHT_PAGE_STEP = 5e-3;
875
+ var READABLE_STEP = 0.01;
876
+ function readableOn(tone, page, min, toward) {
877
+ let current = tone;
878
+ while (contrastRatio(current, page) < min && current.l > READABLE_STEP && current.l < 1 - READABLE_STEP) {
879
+ current = fitTone(current.h, current.l + (toward === "dark" ? -READABLE_STEP : READABLE_STEP), current.c);
880
+ }
881
+ return current;
882
+ }
883
+ function pageLightness({
884
+ meanL,
885
+ ground
886
+ }) {
887
+ const {
888
+ drift,
889
+ gain,
890
+ l
891
+ } = ground.page;
892
+ return clamp(l + (meanL - PAGE_MEAN_LIGHTNESS_PIVOT) * gain, l - drift, l + drift);
893
+ }
894
+ function buildDarkPage(dominant, context) {
895
+ const {
896
+ clusters,
897
+ neutral
898
+ } = context;
899
+ const shadowPick = neutral ? null : pickBest(clusters.filter((cluster) => cluster.l <= SHADOW_MAX_SOURCE_LIGHTNESS && cluster.c >= SHADOW_MIN_SOURCE_CHROMA && cluster.pop >= SHADOW_MIN_SOURCE_POPULATION), (cluster) => cluster.pop * cluster.rel * smoothstep(0.05, 0.14, cluster.l));
900
+ const deepSource = shadowPick ?? dominant;
901
+ const lightness = pageLightness(context);
902
+ if (!deepSource) return {
903
+ c: 0,
904
+ h: 0,
905
+ l: lightness
906
+ };
907
+ return toneOf(deepSource.h, lightness, clamp(0.3 + 0.7 * deepSource.rel, 0, 0.85), DARK_PAGE_CHROMA_CAP);
908
+ }
909
+ function buildLightPage(dominant, context) {
910
+ const lightness = pageLightness(context);
911
+ if (context.neutral || !dominant) return {
912
+ c: 0,
913
+ h: 0,
914
+ l: lightness
915
+ };
916
+ const chroma = clamp(dominant.c * LIGHT_PAGE_CHROMA_SHARE, LIGHT_PAGE_CHROMA_MIN, LIGHT_PAGE_CHROMA_CAP) * (1 - 0.3 * warmth(dominant.h)) * (1 - 0.3 * skinLikeness(dominant)) * context.dilution;
917
+ let l = lightness;
918
+ while (l - LIGHT_PAGE_STEP >= LIGHT_PAGE_FLOOR && maxChroma(l, dominant.h) * GAMUT_HEADROOM < chroma) {
919
+ l -= LIGHT_PAGE_STEP;
920
+ }
921
+ return fitTone(dominant.h, l, chroma);
922
+ }
923
+
817
924
  // src/modules/ambient/analyze.ts
818
- var AMBIENT_ANALYSIS_VERSION = 2;
925
+ var AMBIENT_ANALYSIS_VERSION = 4;
819
926
  var FAMILY_HUE_RANGE = 20;
820
927
  var MUTED_MAX_CHROMA = 0.09;
821
928
  var MUTED_CHROMA_SPAN = 0.12;
@@ -826,43 +933,29 @@ var FULL_DILUTION_PRESENCE = 0.25;
826
933
  var MIN_DILUTION = 0.55;
827
934
  var DILUTION_RANGE = 0.45;
828
935
  var GREY_LIGHTNESS_RANGE = [0.3, 0.8];
829
- var DOMINANT_SPEC = {
830
- cap: 0.2,
831
- gain: 1.15,
832
- max: 0.74,
833
- min: 0.42
834
- };
835
- var VIBRANT_SPEC = {
836
- cap: 0.22,
837
- gain: 1.35,
838
- max: 0.84,
839
- min: 0.62
840
- };
841
- var MUTED_SPEC = {
842
- cap: 0.07,
843
- gain: 1,
844
- max: 0.66,
845
- min: 0.38
846
- };
847
- var ACCENT_SPEC = {
848
- cap: 0.22,
849
- gain: 1.3,
850
- max: 0.8,
851
- min: 0.55
852
- };
853
- var REGION_SPEC = {
854
- cap: 0.18,
855
- gain: 1.15
936
+ var CHROMA = {
937
+ accent: {
938
+ cap: 0.22,
939
+ gain: 1.3
940
+ },
941
+ dominant: {
942
+ cap: 0.2,
943
+ gain: 1.15
944
+ },
945
+ muted: {
946
+ cap: 0.07,
947
+ gain: 1
948
+ },
949
+ region: {
950
+ cap: 0.18,
951
+ gain: 1.15
952
+ },
953
+ vibrant: {
954
+ cap: 0.22,
955
+ gain: 1.35
956
+ }
856
957
  };
857
- var REGION_LIGHTNESS_RANGE = [0.42, 0.72];
858
- var REGION_FALLBACK_LIGHTNESS_RANGE = [0.3, 0.7];
859
- var SHADOW_MAX_SOURCE_LIGHTNESS = 0.5;
860
- var SHADOW_MIN_SOURCE_CHROMA = 0.02;
861
- var SHADOW_MIN_SOURCE_POPULATION = 0.02;
862
- var SHADOW_LIGHTNESS_DRIFT = 0.02;
863
- var SHADOW_MEAN_LIGHTNESS_PIVOT = 0.45;
864
- var SHADOW_MEAN_LIGHTNESS_GAIN = 0.06;
865
- var SHADOW_CHROMA_CAP = 0.1;
958
+ var FULL_PRESENCE = FULL_DILUTION_PRESENCE;
866
959
  function createFamilyShare(chromatic) {
867
960
  const family = /* @__PURE__ */ new Map();
868
961
  for (const cluster of chromatic) {
@@ -894,13 +987,14 @@ function pickRoleClusters(chromatic, share, neutral, minHueDistance) {
894
987
  vivid
895
988
  };
896
989
  }
897
- function buildRoles(picks, {
990
+ function buildRoles(picks, page, {
898
991
  dilution,
992
+ ground,
899
993
  meanL,
900
994
  minContrast,
901
995
  neutral,
902
996
  share
903
- }) {
997
+ }, isLight) {
904
998
  const {
905
999
  accent,
906
1000
  dominant,
@@ -914,39 +1008,34 @@ function buildRoles(picks, {
914
1008
  };
915
1009
  const dominantHue = dominant?.h ?? vivid?.h ?? 0;
916
1010
  const accentSource = accent ?? vivid;
1011
+ const spec = (role) => {
1012
+ const [min, max] = ground.roles[role];
1013
+ return {
1014
+ ...CHROMA[role],
1015
+ max,
1016
+ min
1017
+ };
1018
+ };
1019
+ const readable = (tone) => readableOn(tone, page, ground.roleContrast, isLight ? "dark" : "light");
1020
+ const [mutedMin, mutedMax] = ground.roles.muted;
917
1021
  return {
918
- dominant: buildSwatch(roleTone(dominant, DOMINANT_SPEC, grey), dominant ? share(dominant) : 0, true, minContrast),
919
- vibrant: buildSwatch(roleTone(vivid, VIBRANT_SPEC, {
1022
+ dominant: buildSwatch(readable(roleTone(dominant, spec("dominant"), grey)), dominant ? share(dominant) : 0, true, minContrast),
1023
+ vibrant: buildSwatch(readable(roleTone(vivid, spec("vibrant"), {
920
1024
  c: 0,
921
1025
  h: dominantHue,
922
- l: 0.78
923
- }, dilution), vivid ? share(vivid) : 0, true, minContrast),
924
- muted: buildSwatch(roleTone(muted, MUTED_SPEC, {
1026
+ l: ground.fallback.vibrant
1027
+ }, dilution)), vivid ? share(vivid) : 0, true, minContrast),
1028
+ muted: buildSwatch(readable(roleTone(muted, spec("muted"), {
925
1029
  c: dominant ? 0.035 : 0,
926
1030
  h: dominantHue,
927
- l: clamp(meanL, 0.38, 0.66)
928
- }), muted ? share(muted) : 0, Boolean(muted) || neutral, minContrast),
929
- accent: buildSwatch(roleTone(accentSource, ACCENT_SPEC, {
1031
+ l: clamp(meanL, mutedMin, mutedMax)
1032
+ })), muted ? share(muted) : 0, Boolean(muted) || neutral, minContrast),
1033
+ accent: buildSwatch(readable(roleTone(accentSource, spec("accent"), {
930
1034
  c: 0,
931
1035
  h: dominantHue,
932
- l: 0.72
933
- }, dilution), accentSource ? share(accentSource) : 0, Boolean(accent), minContrast)
934
- };
935
- }
936
- function buildShadow(dominant, {
937
- clusters,
938
- meanL,
939
- neutral
940
- }, baseLightness) {
941
- const shadowPick = neutral ? null : pickBest(clusters.filter((cluster) => cluster.l <= SHADOW_MAX_SOURCE_LIGHTNESS && cluster.c >= SHADOW_MIN_SOURCE_CHROMA && cluster.pop >= SHADOW_MIN_SOURCE_POPULATION), (cluster) => cluster.pop * cluster.rel * smoothstep(0.05, 0.14, cluster.l));
942
- const deepSource = shadowPick ?? dominant;
943
- const lightness = clamp(baseLightness + (meanL - SHADOW_MEAN_LIGHTNESS_PIVOT) * SHADOW_MEAN_LIGHTNESS_GAIN, baseLightness - SHADOW_LIGHTNESS_DRIFT, baseLightness + SHADOW_LIGHTNESS_DRIFT);
944
- if (!deepSource) return {
945
- c: 0,
946
- h: 0,
947
- l: lightness
1036
+ l: ground.fallback.accent
1037
+ }, dilution)), accentSource ? share(accentSource) : 0, Boolean(accent), minContrast)
948
1038
  };
949
- return toneOf(deepSource.h, lightness, clamp(0.3 + 0.7 * deepSource.rel, 0, 0.85), SHADOW_CHROMA_CAP);
950
1039
  }
951
1040
  function pickRegionColor(clusters, weights, lab, regionTotal) {
952
1041
  let strength = 0;
@@ -973,6 +1062,7 @@ function pickRegionColor(clusters, weights, lab, regionTotal) {
973
1062
  }
974
1063
  function buildRegion(weights, lab, {
975
1064
  clusters,
1065
+ ground,
976
1066
  meanL,
977
1067
  neutral
978
1068
  }) {
@@ -986,11 +1076,13 @@ function buildRegion(weights, lab, {
986
1076
  pick,
987
1077
  strength
988
1078
  } = pickRegionColor(clusters, weights, lab, regionTotal);
1079
+ const [regionMin, regionMax] = ground.region;
1080
+ const [fallbackMin, fallbackMax] = ground.regionFallback;
989
1081
  const chosen = neutral || strength < MIN_PRESENCE ? null : pick;
990
- const tone = chosen ? fitTone(chosen.h, clamp(chosen.l, REGION_LIGHTNESS_RANGE[0], REGION_LIGHTNESS_RANGE[1]), roleChroma(chosen, REGION_SPEC)) : {
1082
+ const tone = chosen ? fitTone(chosen.h, clamp(chosen.l, regionMin, regionMax), roleChroma(chosen, CHROMA.region)) : {
991
1083
  c: 0,
992
1084
  h: 0,
993
- l: clamp(regionTotal > 0 ? regionL / regionTotal : meanL, REGION_FALLBACK_LIGHTNESS_RANGE[0], REGION_FALLBACK_LIGHTNESS_RANGE[1])
1085
+ l: clamp(regionTotal > 0 ? regionL / regionTotal : meanL, fallbackMin, fallbackMax)
994
1086
  };
995
1087
  return {
996
1088
  c: round3(tone.c),
@@ -1023,17 +1115,22 @@ function analyzeAmbientPixels(pixels, overrides = {}) {
1023
1115
  const context = {
1024
1116
  clusters,
1025
1117
  dilution: MIN_DILUTION + DILUTION_RANGE * Math.min(1, presence / FULL_DILUTION_PRESENCE),
1118
+ ground: GROUNDS[options.ground],
1026
1119
  meanL,
1027
1120
  minContrast: options.minContrast,
1028
1121
  neutral: presence < MIN_PRESENCE,
1029
1122
  share: createFamilyShare(chromatic)
1030
1123
  };
1031
1124
  const picks = pickRoleClusters(chromatic, context.share, context.neutral, options.minHueDistance);
1125
+ const isLight = options.ground === "light";
1126
+ const page = isLight ? buildLightPage(picks.dominant, context) : buildDarkPage(picks.dominant, context);
1032
1127
  return {
1128
+ ground: options.ground,
1033
1129
  neutral: context.neutral,
1130
+ page: formatOklch(page),
1131
+ presence: context.neutral ? 0 : round3(clamp(presence / FULL_PRESENCE, 0, 1)),
1034
1132
  regions: buildRegions(context, regionWeights, regionLab),
1035
- roles: buildRoles(picks, context),
1036
- shadow: formatOklch(buildShadow(picks.dominant, context, options.shadowLightness))
1133
+ roles: buildRoles(picks, page, context, isLight)
1037
1134
  };
1038
1135
  }
1039
1136
  function fitSample(width, height, size) {
@@ -1334,7 +1431,9 @@ function useAmbientColor(imageSource, t0) {
1334
1431
  const $ = c(13);
1335
1432
  const options = t0 === void 0 ? null : t0;
1336
1433
  const stableOptions = useStableObject(options);
1337
- const initialPalette = useStableObject(options?.initialPalette ?? null);
1434
+ const offered = useStableObject(options?.initialPalette ?? null);
1435
+ const ground = resolveAnalysis(stableOptions?.analysis).ground;
1436
+ const initialPalette = offered?.ground === ground ? offered : null;
1338
1437
  const srcKey = typeof imageSource === "string" ? imageSource : imageSource?.src;
1339
1438
  const seeded = srcKey && initialPalette?.source === srcKey ? initialPalette : null;
1340
1439
  const [result, setResult] = useState(null);
@@ -1762,5 +1861,5 @@ function defineAmbient(definition = {}) {
1762
1861
  }
1763
1862
 
1764
1863
  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 };
1765
- //# sourceMappingURL=chunk-GQKGOLHJ.js.map
1766
- //# sourceMappingURL=chunk-GQKGOLHJ.js.map
1864
+ //# sourceMappingURL=chunk-67MOKJFZ.js.map
1865
+ //# sourceMappingURL=chunk-67MOKJFZ.js.map