@omerdlw/base-framework 3.2.2 → 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.
- package/MIGRATION.md +11 -0
- package/dist/ambient/index.js +1 -1
- package/dist/ambient/server/index.js +2 -2
- package/dist/ambient/worker/index.js +1 -1
- package/dist/{chunk-MMVVHQ7V.js → chunk-67MOKJFZ.js} +174 -75
- package/dist/chunk-67MOKJFZ.js.map +1 -0
- package/dist/{chunk-2LGI33JP.js → chunk-GKAJ4EM2.js} +169 -73
- package/dist/chunk-GKAJ4EM2.js.map +1 -0
- package/dist/{chunk-FXO4QJQ4.js → chunk-K3LXE6D5.js} +6 -6
- package/dist/{chunk-FXO4QJQ4.js.map → chunk-K3LXE6D5.js.map} +1 -1
- package/dist/{chunk-2EFQJITY.js → chunk-NCXFWCXP.js} +263 -229
- package/dist/chunk-NCXFWCXP.js.map +1 -0
- package/dist/{chunk-TKOGBAW3.js → chunk-UE2KBW3D.js} +3 -3
- package/dist/{chunk-TKOGBAW3.js.map → chunk-UE2KBW3D.js.map} +1 -1
- package/dist/{chunk-7XUAYJOA.js → chunk-VNSMNGWP.js} +3 -3
- package/dist/{chunk-7XUAYJOA.js.map → chunk-VNSMNGWP.js.map} +1 -1
- package/dist/{chunk-FS2R34VD.js → chunk-XGAYTDSI.js} +36 -36
- package/dist/chunk-XGAYTDSI.js.map +1 -0
- package/dist/context-menu/index.js +3 -3
- package/dist/dock/index.js +2 -2
- package/dist/index.js +6 -6
- package/dist/modules/ambient/analyze-ground.d.ts +42 -0
- package/dist/modules/ambient/analyze-ground.d.ts.map +1 -0
- package/dist/modules/ambient/analyze.d.ts +1 -1
- package/dist/modules/ambient/analyze.d.ts.map +1 -1
- package/dist/modules/ambient/dom.d.ts.map +1 -1
- package/dist/modules/ambient/hooks.d.ts.map +1 -1
- package/dist/modules/ambient/settings.d.ts.map +1 -1
- package/dist/modules/ambient/types.d.ts +16 -4
- package/dist/modules/ambient/types.d.ts.map +1 -1
- package/dist/modules/dock/hooks/use-dock-height-controller.d.ts +1 -1
- package/dist/modules/dock/hooks/use-dock-height-controller.d.ts.map +1 -1
- package/dist/modules/dock/hooks/use-dock-viewport.d.ts.map +1 -1
- package/dist/modules/dock/model/layout.d.ts +19 -4
- package/dist/modules/dock/model/layout.d.ts.map +1 -1
- package/dist/modules/dock/model/paths.d.ts +7 -0
- package/dist/modules/dock/model/paths.d.ts.map +1 -1
- package/dist/modules/dock/runtime/dock.d.ts.map +1 -1
- package/dist/modules/dock/runtime/hooks/use-dock.d.ts.map +1 -1
- package/dist/modules/dock/types/card.d.ts +6 -0
- package/dist/modules/dock/types/card.d.ts.map +1 -1
- package/dist/modules/dock/types/theme.d.ts +20 -0
- package/dist/modules/dock/types/theme.d.ts.map +1 -1
- package/dist/modules/index.js +6 -6
- package/dist/navigation/index.js +4 -4
- package/docs/modules/ambient.md +79 -58
- package/docs/modules/dock.md +15 -15
- package/package.json +1 -1
- package/dist/chunk-2EFQJITY.js.map +0 -1
- package/dist/chunk-2LGI33JP.js.map +0 -1
- package/dist/chunk-FS2R34VD.js.map +0 -1
- package/dist/chunk-MMVVHQ7V.js.map +0 -1
package/MIGRATION.md
CHANGED
|
@@ -86,3 +86,14 @@ The compiled output is larger. Total gzipped JavaScript is about 35% above the p
|
|
|
86
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
87
|
|
|
88
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.
|
package/dist/ambient/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
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-
|
|
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
3
|
import '../chunk-HFR6YROB.js';
|
|
4
4
|
import '../chunk-ZXRE2KZO.js';
|
|
5
5
|
import '../chunk-IH3STE7W.js';
|
|
@@ -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-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)$/;
|
|
@@ -78,14 +78,15 @@ var DEFAULT_ANALYSIS = Object.freeze({
|
|
|
78
78
|
letterbox: true,
|
|
79
79
|
minContrast: 4.5,
|
|
80
80
|
minHueDistance: 40,
|
|
81
|
-
|
|
82
|
-
|
|
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
|
-
|
|
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.
|
|
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 =
|
|
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
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
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
|
|
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,
|
|
919
|
-
vibrant: buildSwatch(roleTone(vivid,
|
|
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:
|
|
923
|
-
}, dilution), vivid ? share(vivid) : 0, true, minContrast),
|
|
924
|
-
muted: buildSwatch(roleTone(muted,
|
|
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,
|
|
928
|
-
}), muted ? share(muted) : 0, Boolean(muted) || neutral, minContrast),
|
|
929
|
-
accent: buildSwatch(roleTone(accentSource,
|
|
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:
|
|
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,
|
|
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,
|
|
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
|
|
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-
|
|
1766
|
-
//# sourceMappingURL=chunk-
|
|
1864
|
+
//# sourceMappingURL=chunk-67MOKJFZ.js.map
|
|
1865
|
+
//# sourceMappingURL=chunk-67MOKJFZ.js.map
|