@oxyhq/bloom 0.85.0 → 0.87.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/LICENSE +202 -661
- package/NOTICE +4 -1
- package/README.md +121 -449
- package/lib/commonjs/theme/color-scope/seed-scope.js +49 -16
- package/lib/commonjs/theme/color-scope/seed-scope.js.map +1 -1
- package/lib/commonjs/theme/color-scope/style-builder.js +2 -17
- package/lib/commonjs/theme/color-scope/style-builder.js.map +1 -1
- package/lib/module/theme/color-scope/seed-scope.js +48 -16
- package/lib/module/theme/color-scope/seed-scope.js.map +1 -1
- package/lib/module/theme/color-scope/style-builder.js +3 -18
- package/lib/module/theme/color-scope/style-builder.js.map +1 -1
- package/lib/typescript/commonjs/theme/color-scope/seed-scope.d.ts +9 -0
- package/lib/typescript/commonjs/theme/color-scope/seed-scope.d.ts.map +1 -1
- package/lib/typescript/commonjs/theme/color-scope/style-builder.d.ts.map +1 -1
- package/lib/typescript/module/theme/color-scope/seed-scope.d.ts +9 -0
- package/lib/typescript/module/theme/color-scope/seed-scope.d.ts.map +1 -1
- package/lib/typescript/module/theme/color-scope/style-builder.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/design-tokens.test.ts +42 -4
- package/src/theme/color-scope/seed-scope.ts +48 -16
- package/src/theme/color-scope/style-builder.ts +3 -18
|
@@ -5,9 +5,56 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.buildSeedScopeVars = buildSeedScopeVars;
|
|
7
7
|
exports.roleColorsToPresetTokens = roleColorsToPresetTokens;
|
|
8
|
+
exports.withScopeAliases = withScopeAliases;
|
|
8
9
|
var _index = require("../color-engine/index.js");
|
|
9
10
|
var _colorPolicy = require("../color-policy.js");
|
|
10
|
-
var
|
|
11
|
+
var _colorRoles = require("../../design-tokens/color-roles.js");
|
|
12
|
+
/**
|
|
13
|
+
* Every alias `theme.css` declares at `:root` as a reference to a canonical
|
|
14
|
+
* token, keyed by the alias name. `--color-divider` is one of these and does not
|
|
15
|
+
* come from the role maps, so it is named here.
|
|
16
|
+
*
|
|
17
|
+
* An alias declared at the document root substitutes THERE, so a subtree that
|
|
18
|
+
* overrides `--foreground` cannot move a `--color-text: var(--foreground)` the
|
|
19
|
+
* root already computed — the subtree keeps painting the app-wide palette while
|
|
20
|
+
* every canonical token around it says otherwise. Re-declaring each alias inside
|
|
21
|
+
* the scope, against the scope's own values, is what closes that.
|
|
22
|
+
*
|
|
23
|
+
* An alias whose value is a literal (`--color-destructive-foreground: #ffffff`)
|
|
24
|
+
* is unaffected and deliberately absent.
|
|
25
|
+
*/
|
|
26
|
+
const SCOPED_ALIASES = {
|
|
27
|
+
..._colorRoles.FILL_ROLES,
|
|
28
|
+
..._colorRoles.TEXT_ROLES,
|
|
29
|
+
..._colorRoles.BORDER_ROLES,
|
|
30
|
+
divider: 'var(--border)'
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Give a resolved token map the `--color-x` alias layer, so utilities resolve
|
|
35
|
+
* against the scope instead of the document root.
|
|
36
|
+
*
|
|
37
|
+
* Shared by both scope builders — the preset path (`buildScopeVars`) and the
|
|
38
|
+
* seed path (`buildSeedScopeVars`) — because a gap here is invisible until a
|
|
39
|
+
* scoped page paints the wrong colour in one mode only.
|
|
40
|
+
*/
|
|
41
|
+
function withScopeAliases(tokens) {
|
|
42
|
+
const vars = {
|
|
43
|
+
...tokens
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// Policy tokens live outside the canonical set, so alias every token present.
|
|
47
|
+
for (const [key, value] of Object.entries(tokens)) {
|
|
48
|
+
vars[`--color-${key.slice(2)}`] = value;
|
|
49
|
+
}
|
|
50
|
+
for (const [alias, reference] of Object.entries(SCOPED_ALIASES)) {
|
|
51
|
+
const canonical = /^var\(--(.+)\)$/.exec(reference)?.[1];
|
|
52
|
+
const resolved = canonical === undefined ? undefined : tokens[`--${canonical}`];
|
|
53
|
+
if (resolved !== undefined) vars[`--color-${alias}`] = resolved;
|
|
54
|
+
}
|
|
55
|
+
return vars;
|
|
56
|
+
}
|
|
57
|
+
|
|
11
58
|
/**
|
|
12
59
|
* The canonical role → token assignment, sourced from an arbitrary seed's role
|
|
13
60
|
* set instead of a named preset.
|
|
@@ -101,20 +148,6 @@ function buildSeedScopeVars(options) {
|
|
|
101
148
|
tertiary: options.tertiarySeed
|
|
102
149
|
})
|
|
103
150
|
};
|
|
104
|
-
|
|
105
|
-
...tokens
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
// Policy tokens live outside CANONICAL_TOKENS, so alias every token present.
|
|
109
|
-
for (const [key, value] of Object.entries(tokens)) {
|
|
110
|
-
vars[`--color-${key.slice(2)}`] = value;
|
|
111
|
-
}
|
|
112
|
-
for (const token of _tokenRegistry.CANONICAL_TOKENS) {
|
|
113
|
-
const value = tokens[`--${token}`];
|
|
114
|
-
if (value !== undefined) {
|
|
115
|
-
vars[`--color-${token}`] = value;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
return vars;
|
|
151
|
+
return withScopeAliases(tokens);
|
|
119
152
|
}
|
|
120
153
|
//# sourceMappingURL=seed-scope.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_index","require","_colorPolicy","
|
|
1
|
+
{"version":3,"names":["_index","require","_colorPolicy","_colorRoles","SCOPED_ALIASES","FILL_ROLES","TEXT_ROLES","BORDER_ROLES","divider","withScopeAliases","tokens","vars","key","value","Object","entries","slice","alias","reference","canonical","exec","resolved","undefined","roleColorsToPresetTokens","r","background","onBackground","surfaceContainerLow","onSurface","surfaceContainer","primary","onPrimary","secondaryContainer","onSecondaryContainer","tertiaryContainer","onTertiaryContainer","surfaceContainerHigh","onSurfaceVariant","error","outlineVariant","surfaceContainerLowest","secondary","tertiary","primaryContainer","buildSeedScopeVars","options","roles","generateRoleColors","seed","variant","isColourlessSeed","isDark","mode","contrastLevel","secondarySeed","tertiarySeed","buildPolicyTokens"],"sourceRoot":"../../../../src","sources":["theme/color-scope/seed-scope.ts"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMG,cAAgD,GAAG;EACvD,GAAGC,sBAAU;EACb,GAAGC,sBAAU;EACb,GAAGC,wBAAY;EACfC,OAAO,EAAE;AACX,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,gBAAgBA,CAACC,MAA8B,EAA0B;EACvF,MAAMC,IAA4B,GAAG;IAAE,GAAGD;EAAO,CAAC;;EAElD;EACA,KAAK,MAAM,CAACE,GAAG,EAAEC,KAAK,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACL,MAAM,CAAC,EAAE;IACjDC,IAAI,CAAC,WAAWC,GAAG,CAACI,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,GAAGH,KAAK;EACzC;EAEA,KAAK,MAAM,CAACI,KAAK,EAAEC,SAAS,CAAC,IAAIJ,MAAM,CAACC,OAAO,CAACX,cAAc,CAAC,EAAE;IAC/D,MAAMe,SAAS,GAAG,iBAAiB,CAACC,IAAI,CAACF,SAAS,CAAC,GAAG,CAAC,CAAC;IACxD,MAAMG,QAAQ,GAAGF,SAAS,KAAKG,SAAS,GAAGA,SAAS,GAAGZ,MAAM,CAAC,KAAKS,SAAS,EAAE,CAAC;IAC/E,IAAIE,QAAQ,KAAKC,SAAS,EAAEX,IAAI,CAAC,WAAWM,KAAK,EAAE,CAAC,GAAGI,QAAQ;EACjE;EAEA,OAAOV,IAAI;AACb;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASY,wBAAwBA,CAACC,CAAa,EAA0B;EAC9E,OAAO;IACL;IACA,cAAc,EAAE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OAAO;IAC9B,8BAA8B,EAAEN,CAAC,CAACO,SAAS;IAC3C,kBAAkB,EAAEP,CAAC,CAACQ,kBAAkB;IACxC,6BAA6B,EAAER,CAAC,CAACS,oBAAoB;IACrD,kBAAkB,EAAET,CAAC,CAACe,cAAc;IACpC,gBAAgB,EAAEf,CAAC,CAACM;EACtB,CAAC;AACH;;AAEA;;AA2BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASc,kBAAkBA,CAACC,OAAyB,EAA0B;EACpF,MAAMC,KAAK,GAAG,IAAAC,yBAAkB,EAAC;IAC/BC,IAAI,EAAEH,OAAO,CAACG,IAAI;IAClB;IACA;IACA;IACA;IACAC,OAAO,EAAEJ,OAAO,CAACI,OAAO,KAAK,IAAAC,6BAAgB,EAACL,OAAO,CAACG,IAAI,CAAC,GAAG,YAAY,GAAG,OAAO,CAAC;IACrFG,MAAM,EAAEN,OAAO,CAACO,IAAI,KAAK,MAAM;IAC/BC,aAAa,EAAER,OAAO,CAACQ,aAAa,IAAI,CAAC;IACzCC,aAAa,EAAET,OAAO,CAACS,aAAa;IACpCC,YAAY,EAAEV,OAAO,CAACU;EACxB,CAAC,CAAC;EACF,MAAM7C,MAA8B,GAAG;IACrC,GAAGa,wBAAwB,CAACuB,KAAK,CAAC;IAClC,GAAG,IAAAU,8BAAiB,EAACX,OAAO,CAACG,IAAI,EAAEH,OAAO,CAACO,IAAI,KAAK,MAAM,EAAEN,KAAK,EAAE;MACjEL,SAAS,EAAEI,OAAO,CAACS,aAAa;MAChCZ,QAAQ,EAAEG,OAAO,CAACU;IACpB,CAAC;EACH,CAAC;EACD,OAAO9C,gBAAgB,CAACC,MAAM,CAAC;AACjC","ignoreList":[]}
|
|
@@ -8,6 +8,7 @@ exports.buildScopeVars = buildScopeVars;
|
|
|
8
8
|
exports.getVariableContextProvider = getVariableContextProvider;
|
|
9
9
|
var _reactNative = require("react-native");
|
|
10
10
|
var _tokenRegistry = require("../token-registry.js");
|
|
11
|
+
var _seedScope = require("./seed-scope.js");
|
|
11
12
|
/**
|
|
12
13
|
* The optional-peer boundary for `nativewind`.
|
|
13
14
|
*
|
|
@@ -120,23 +121,7 @@ function warnScopeInert(detail) {
|
|
|
120
121
|
* the document root and would otherwise keep pointing at the app-wide preset.
|
|
121
122
|
*/
|
|
122
123
|
function buildScopeVars(colorPreset, mode, accents) {
|
|
123
|
-
|
|
124
|
-
const vars = {
|
|
125
|
-
...tokens
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
// Policy tokens live outside CANONICAL_TOKENS, so give every token present a
|
|
129
|
-
// `--color-*` alias; NativeWind resolves its utilities through those.
|
|
130
|
-
for (const [key, value] of Object.entries(tokens)) {
|
|
131
|
-
vars[`--color-${key.slice(2)}`] = value;
|
|
132
|
-
}
|
|
133
|
-
for (const token of _tokenRegistry.CANONICAL_TOKENS) {
|
|
134
|
-
const value = tokens[`--${token}`];
|
|
135
|
-
if (value !== undefined) {
|
|
136
|
-
vars[`--color-${token}`] = value;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
return vars;
|
|
124
|
+
return (0, _seedScope.withScopeAliases)((0, _tokenRegistry.getResolvedTokens)(colorPreset, mode, accents));
|
|
140
125
|
}
|
|
141
126
|
|
|
142
127
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_tokenRegistry","nativeWindModule","unavailableReason","hasWarned","loadNativeWindVars","undefined","loaded","vars","error","Error","message","String","warnScopeInert","detail","process","env","NODE_ENV","console","warn","buildScopeVars","colorPreset","mode","accents","
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_tokenRegistry","_seedScope","nativeWindModule","unavailableReason","hasWarned","loadNativeWindVars","undefined","loaded","vars","error","Error","message","String","warnScopeInert","detail","process","env","NODE_ENV","console","warn","buildScopeVars","colorPreset","mode","accents","withScopeAliases","getResolvedTokens","getVariableContextProvider","Platform","OS","module","VariableContextProvider","buildNativePresetStyle"],"sourceRoot":"../../../../src","sources":["theme/color-scope/style-builder.ts"],"mappings":";;;;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,cAAA,GAAAD,OAAA;AAGA,IAAAE,UAAA,GAAAF,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;;AAMA;AACA,IAAIG,gBAAyD;AAC7D;AACA,IAAIC,iBAAiB,GAAG,EAAE;AAC1B,IAAIC,SAAS,GAAG,KAAK;;AAErB;AACA,SAASC,kBAAkBA,CAAA,EAAgC;EACzD,IAAIH,gBAAgB,KAAKI,SAAS,EAAE,OAAOJ,gBAAgB;EAC3DA,gBAAgB,GAAG,IAAI;;EAEvB;EACA;EACA;EACA,IAAI,OAAOH,OAAO,KAAK,WAAW,EAAE;IAClCI,iBAAiB,GAAG,uCAAuC;IAC3D,OAAOD,gBAAgB;EACzB;EAEA,IAAI;IACF,MAAMK,MAAM,GAAGR,OAAO,CAAC,YAAY,CAAqD;IAExF,IAAI,OAAOQ,MAAM,EAAEC,IAAI,KAAK,UAAU,EAAE;MACtCN,gBAAgB,GAAGK,MAA8B;IACnD,CAAC,MAAM;MACLJ,iBAAiB,GAAG,6CAA6C;IACnE;EACF,CAAC,CAAC,OAAOM,KAAK,EAAE;IACdN,iBAAiB,GAAGM,KAAK,YAAYC,KAAK,GAAGD,KAAK,CAACE,OAAO,GAAGC,MAAM,CAACH,KAAK,CAAC;EAC5E;EAEA,OAAOP,gBAAgB;AACzB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAASW,cAAcA,CAACC,MAAc,EAAQ;EAC5C,IAAIC,OAAO,CAACC,GAAG,CAACC,Q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,MAAM,CAACrB,IAAI,CAACY,cAAc,CAACC,WAAW,EAAEC,IAAI,CAAC,CAAC;AACvD","ignoreList":[]}
|
|
@@ -2,7 +2,53 @@
|
|
|
2
2
|
|
|
3
3
|
import { generateRoleColors } from "../color-engine/index.js";
|
|
4
4
|
import { buildPolicyTokens, isColourlessSeed } from "../color-policy.js";
|
|
5
|
-
import {
|
|
5
|
+
import { BORDER_ROLES, FILL_ROLES, TEXT_ROLES } from "../../design-tokens/color-roles.js";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Every alias `theme.css` declares at `:root` as a reference to a canonical
|
|
9
|
+
* token, keyed by the alias name. `--color-divider` is one of these and does not
|
|
10
|
+
* come from the role maps, so it is named here.
|
|
11
|
+
*
|
|
12
|
+
* An alias declared at the document root substitutes THERE, so a subtree that
|
|
13
|
+
* overrides `--foreground` cannot move a `--color-text: var(--foreground)` the
|
|
14
|
+
* root already computed — the subtree keeps painting the app-wide palette while
|
|
15
|
+
* every canonical token around it says otherwise. Re-declaring each alias inside
|
|
16
|
+
* the scope, against the scope's own values, is what closes that.
|
|
17
|
+
*
|
|
18
|
+
* An alias whose value is a literal (`--color-destructive-foreground: #ffffff`)
|
|
19
|
+
* is unaffected and deliberately absent.
|
|
20
|
+
*/
|
|
21
|
+
const SCOPED_ALIASES = {
|
|
22
|
+
...FILL_ROLES,
|
|
23
|
+
...TEXT_ROLES,
|
|
24
|
+
...BORDER_ROLES,
|
|
25
|
+
divider: 'var(--border)'
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Give a resolved token map the `--color-x` alias layer, so utilities resolve
|
|
30
|
+
* against the scope instead of the document root.
|
|
31
|
+
*
|
|
32
|
+
* Shared by both scope builders — the preset path (`buildScopeVars`) and the
|
|
33
|
+
* seed path (`buildSeedScopeVars`) — because a gap here is invisible until a
|
|
34
|
+
* scoped page paints the wrong colour in one mode only.
|
|
35
|
+
*/
|
|
36
|
+
export function withScopeAliases(tokens) {
|
|
37
|
+
const vars = {
|
|
38
|
+
...tokens
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// Policy tokens live outside the canonical set, so alias every token present.
|
|
42
|
+
for (const [key, value] of Object.entries(tokens)) {
|
|
43
|
+
vars[`--color-${key.slice(2)}`] = value;
|
|
44
|
+
}
|
|
45
|
+
for (const [alias, reference] of Object.entries(SCOPED_ALIASES)) {
|
|
46
|
+
const canonical = /^var\(--(.+)\)$/.exec(reference)?.[1];
|
|
47
|
+
const resolved = canonical === undefined ? undefined : tokens[`--${canonical}`];
|
|
48
|
+
if (resolved !== undefined) vars[`--color-${alias}`] = resolved;
|
|
49
|
+
}
|
|
50
|
+
return vars;
|
|
51
|
+
}
|
|
6
52
|
|
|
7
53
|
/**
|
|
8
54
|
* The canonical role → token assignment, sourced from an arbitrary seed's role
|
|
@@ -97,20 +143,6 @@ export function buildSeedScopeVars(options) {
|
|
|
97
143
|
tertiary: options.tertiarySeed
|
|
98
144
|
})
|
|
99
145
|
};
|
|
100
|
-
|
|
101
|
-
...tokens
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
// Policy tokens live outside CANONICAL_TOKENS, so alias every token present.
|
|
105
|
-
for (const [key, value] of Object.entries(tokens)) {
|
|
106
|
-
vars[`--color-${key.slice(2)}`] = value;
|
|
107
|
-
}
|
|
108
|
-
for (const token of CANONICAL_TOKENS) {
|
|
109
|
-
const value = tokens[`--${token}`];
|
|
110
|
-
if (value !== undefined) {
|
|
111
|
-
vars[`--color-${token}`] = value;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
return vars;
|
|
146
|
+
return withScopeAliases(tokens);
|
|
115
147
|
}
|
|
116
148
|
//# sourceMappingURL=seed-scope.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["generateRoleColors","buildPolicyTokens","isColourlessSeed","
|
|
1
|
+
{"version":3,"names":["generateRoleColors","buildPolicyTokens","isColourlessSeed","BORDER_ROLES","FILL_ROLES","TEXT_ROLES","SCOPED_ALIASES","divider","withScopeAliases","tokens","vars","key","value","Object","entries","slice","alias","reference","canonical","exec","resolved","undefined","roleColorsToPresetTokens","r","background","onBackground","surfaceContainerLow","onSurface","surfaceContainer","primary","onPrimary","secondaryContainer","onSecondaryContainer","tertiaryContainer","onTertiaryContainer","surfaceContainerHigh","onSurfaceVariant","error","outlineVariant","surfaceContainerLowest","secondary","tertiary","primaryContainer","buildSeedScopeVars","options","roles","seed","variant","isDark","mode","contrastLevel","secondarySeed","tertiarySeed"],"sourceRoot":"../../../../src","sources":["theme/color-scope/seed-scope.ts"],"mappings":";;AAAA,SAASA,kBAAkB,QAA6C,0BAAiB;AACzF,SAASC,iBAAiB,EAAEC,gBAAgB,QAAQ,oBAAiB;AACrE,SAASC,YAAY,EAAEC,UAAU,EAAEC,UAAU,QAAQ,oCAAiC;;AAEtF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,cAAgD,GAAG;EACvD,GAAGF,UAAU;EACb,GAAGC,UAAU;EACb,GAAGF,YAAY;EACfI,OAAO,EAAE;AACX,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAACC,MAA8B,EAA0B;EACvF,MAAMC,IAA4B,GAAG;IAAE,GAAGD;EAAO,CAAC;;EAElD;EACA,KAAK,MAAM,CAACE,GAAG,EAAEC,KAAK,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACL,MAAM,CAAC,EAAE;IACjDC,IAAI,CAAC,WAAWC,GAAG,CAACI,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,GAAGH,KAAK;EACzC;EAEA,KAAK,MAAM,CAACI,KAAK,EAAEC,SAAS,CAAC,IAAIJ,MAAM,CAACC,OAAO,CAACR,cAAc,CAAC,EAAE;IAC/D,MAAMY,SAAS,GAAG,iBAAiB,CAACC,IAAI,CAACF,SAAS,CAAC,GAAG,CAAC,CAAC;IACxD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E,IAAI,EAAEF,OAAO,CAACK,IAAI,KAAK,MAAM,EAAEJ,KAAK,EAAE;MACjEL,SAAS,EAAEI,OAAO,CAACO,aAAa;MAChCV,QAAQ,EAAEG,OAAO,CAACQ;IACpB,CAAC;EACH,CAAC;EACD,OAAO5C,gBAAgB,CAACC,MAAM,CAAC;AACjC","ignoreList":[]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { Platform } from 'react-native';
|
|
4
|
-
import {
|
|
4
|
+
import { getResolvedTokens } from "../token-registry.js";
|
|
5
|
+
import { withScopeAliases } from "./seed-scope.js";
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* The optional-peer boundary for `nativewind`.
|
|
@@ -115,23 +116,7 @@ function warnScopeInert(detail) {
|
|
|
115
116
|
* the document root and would otherwise keep pointing at the app-wide preset.
|
|
116
117
|
*/
|
|
117
118
|
export function buildScopeVars(colorPreset, mode, accents) {
|
|
118
|
-
|
|
119
|
-
const vars = {
|
|
120
|
-
...tokens
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
// Policy tokens live outside CANONICAL_TOKENS, so give every token present a
|
|
124
|
-
// `--color-*` alias; NativeWind resolves its utilities through those.
|
|
125
|
-
for (const [key, value] of Object.entries(tokens)) {
|
|
126
|
-
vars[`--color-${key.slice(2)}`] = value;
|
|
127
|
-
}
|
|
128
|
-
for (const token of CANONICAL_TOKENS) {
|
|
129
|
-
const value = tokens[`--${token}`];
|
|
130
|
-
if (value !== undefined) {
|
|
131
|
-
vars[`--color-${token}`] = value;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
return vars;
|
|
119
|
+
return withScopeAliases(getResolvedTokens(colorPreset, mode, accents));
|
|
135
120
|
}
|
|
136
121
|
|
|
137
122
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Platform","
|
|
1
|
+
{"version":3,"names":["Platform","getResolvedTokens","withScopeAliases","nativeWindModule","unavailableReason","hasWarned","loadNativeWindVars","undefined","require","loaded","vars","error","Error","message","String","warnScopeInert","detail","process","env","NODE_ENV","console","warn","buildScopeVars","colorPreset","mode","accents","getVariableContextProvider","OS","module","VariableContextProvider","buildNativePresetStyle"],"sourceRoot":"../../../../src","sources":["theme/color-scope/style-builder.ts"],"mappings":";;AACA,SAASA,QAAQ,QAAwC,cAAc;AAEvE,SAASC,iBAAiB,QAAQ,sBAAmB;AAGrD,SAASC,gBAAgB,QAAQ,iBAAc;;AAE/C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;;AAMA;AACA,IAAIC,gBAAyD;AAC7D;AACA,IAAIC,iBAAiB,GAAG,EAAE;AAC1B,IAAIC,SAAS,GAAG,KAAK;;AAErB;AACA,SAASC,kBAAkBA,CAAA,EAAgC;EACzD,IAAIH,gBAAgB,KAAKI,SAAS,EAAE,OAAOJ,gBAAgB;EAC3DA,gBAAgB,GAAG,IAAI;;EAEvB;EACA;EACA;EACA,IAAI,OAAOK,OAAO,KAAK,WAAW,EAAE;IAClCJ,iBAAiB,GAAG,uCAAuC;IAC3D,OAAOD,gBAAgB;EACzB;EAEA,IAAI;IACF,MAAMM,MAAM,GAAGD,OAAO,CAAC,YAAY,CAAqD;IAExF,IAAI,OAAOC,MAAM,EAAEC,IAAI,KAAK,UAAU,EAAE;MACtCP,gBAAgB,GAAGM,MAA8B;IACnD,CAAC,MAAM;MACLL,iBAAiB,GAAG,6CAA6C;IACnE;EACF,CAAC,CAAC,OAAOO,KAAK,EAAE;IACdP,iBAAiB,GAAGO,KAAK,YAAYC,KAAK,GAAGD,KAAK,CAACE,OAAO,GAAGC,MA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AE,OAAOpB,SAAS;EAC3C,MAAMqB,MAAM,GAAGtB,kBAAkB,CAAC,CAAC;EACnC,IAAI,CAACsB,MAAM,EAAE;IACXb,cAAc,CAAC,qDAAqD,CAAC;IACrE,OAAOR,SAAS;EAClB;EACA,OAAOqB,MAAM,CAAClB,IAAI,CAACY,cAAc,CAACC,WAAW,EAAEC,IAAI,CAAC,CAAC;AACvD","ignoreList":[]}
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import { type RoleColors, type SchemeVariant } from '../color-engine';
|
|
2
|
+
/**
|
|
3
|
+
* Give a resolved token map the `--color-x` alias layer, so utilities resolve
|
|
4
|
+
* against the scope instead of the document root.
|
|
5
|
+
*
|
|
6
|
+
* Shared by both scope builders — the preset path (`buildScopeVars`) and the
|
|
7
|
+
* seed path (`buildSeedScopeVars`) — because a gap here is invisible until a
|
|
8
|
+
* scoped page paints the wrong colour in one mode only.
|
|
9
|
+
*/
|
|
10
|
+
export declare function withScopeAliases(tokens: Record<string, string>): Record<string, string>;
|
|
2
11
|
/**
|
|
3
12
|
* The canonical role → token assignment, sourced from an arbitrary seed's role
|
|
4
13
|
* set instead of a named preset.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seed-scope.d.ts","sourceRoot":"","sources":["../../../../../src/theme/color-scope/seed-scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,UAAU,EAAE,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"seed-scope.d.ts","sourceRoot":"","sources":["../../../../../src/theme/color-scope/seed-scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,UAAU,EAAE,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAyB1F;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAevF;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA4C9E;AAED,mEAAmE;AACnE,MAAM,WAAW,gBAAgB;IAC/B,kCAAkC;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC;IACvB;;;;OAIG;IACH,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,uDAAuD;IACvD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;OAKG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAqBpF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style-builder.d.ts","sourceRoot":"","sources":["../../../../../src/theme/color-scope/style-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAY,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAGxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"style-builder.d.ts","sourceRoot":"","sources":["../../../../../src/theme/color-scope/style-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAY,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAGxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AA8CtD;;;;;GAKG;AACH,MAAM,MAAM,gCAAgC,GAAG,KAAK,CAAC,aAAa,CAAC;IACjE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAAC,CAAC;AAkEH;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC5B,WAAW,EAAE,YAAY,EACzB,IAAI,EAAE,OAAO,GAAG,MAAM,EACtB,OAAO,CAAC,EAAE,eAAe,GACxB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAExB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,0BAA0B,IAAI,gCAAgC,GAAG,IAAI,CAepF;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,YAAY,EACzB,IAAI,EAAE,OAAO,GAAG,MAAM,GACrB,SAAS,CAAC,SAAS,CAAC,CAQtB"}
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import { type RoleColors, type SchemeVariant } from '../color-engine';
|
|
2
|
+
/**
|
|
3
|
+
* Give a resolved token map the `--color-x` alias layer, so utilities resolve
|
|
4
|
+
* against the scope instead of the document root.
|
|
5
|
+
*
|
|
6
|
+
* Shared by both scope builders — the preset path (`buildScopeVars`) and the
|
|
7
|
+
* seed path (`buildSeedScopeVars`) — because a gap here is invisible until a
|
|
8
|
+
* scoped page paints the wrong colour in one mode only.
|
|
9
|
+
*/
|
|
10
|
+
export declare function withScopeAliases(tokens: Record<string, string>): Record<string, string>;
|
|
2
11
|
/**
|
|
3
12
|
* The canonical role → token assignment, sourced from an arbitrary seed's role
|
|
4
13
|
* set instead of a named preset.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"seed-scope.d.ts","sourceRoot":"","sources":["../../../../../src/theme/color-scope/seed-scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,UAAU,EAAE,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"seed-scope.d.ts","sourceRoot":"","sources":["../../../../../src/theme/color-scope/seed-scope.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,UAAU,EAAE,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAyB1F;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAevF;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA4C9E;AAED,mEAAmE;AACnE,MAAM,WAAW,gBAAgB;IAC/B,kCAAkC;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC;IACvB;;;;OAIG;IACH,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,uDAAuD;IACvD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;OAKG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAqBpF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style-builder.d.ts","sourceRoot":"","sources":["../../../../../src/theme/color-scope/style-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAY,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAGxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"style-builder.d.ts","sourceRoot":"","sources":["../../../../../src/theme/color-scope/style-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAY,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAGxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AA8CtD;;;;;GAKG;AACH,MAAM,MAAM,gCAAgC,GAAG,KAAK,CAAC,aAAa,CAAC;IACjE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAAC,CAAC;AAkEH;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC5B,WAAW,EAAE,YAAY,EACzB,IAAI,EAAE,OAAO,GAAG,MAAM,EACtB,OAAO,CAAC,EAAE,eAAe,GACxB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAExB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,0BAA0B,IAAI,gCAAgC,GAAG,IAAI,CAepF;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CACpC,WAAW,EAAE,YAAY,EACzB,IAAI,EAAE,OAAO,GAAG,MAAM,GACrB,SAAS,CAAC,SAAS,CAAC,CAQtB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oxyhq/bloom",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.87.0",
|
|
4
4
|
"packageManager": "bun@1.3.14",
|
|
5
5
|
"description": "Bloom UI — Oxy ecosystem component library for React Native + Expo + Web",
|
|
6
6
|
"main": "lib/commonjs/index.js",
|
|
@@ -1450,7 +1450,7 @@
|
|
|
1450
1450
|
"type": "git",
|
|
1451
1451
|
"url": "https://github.com/OxyHQ/Bloom.git"
|
|
1452
1452
|
},
|
|
1453
|
-
"license": "
|
|
1453
|
+
"license": "Apache-2.0",
|
|
1454
1454
|
"scripts": {
|
|
1455
1455
|
"generate:exports": "node scripts/generate-platform-exports.mjs",
|
|
1456
1456
|
"generate:theme-css": "bun scripts/generate-theme-css.ts",
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
bloomShadowStyle,
|
|
20
20
|
} from '../design-tokens';
|
|
21
21
|
import { APP_COLOR_PRESETS } from '../theme/color-presets';
|
|
22
|
+
import { buildScopeVars } from '../theme/color-scope/style-builder';
|
|
22
23
|
import { CANONICAL_TOKENS } from '../theme/token-registry';
|
|
23
24
|
|
|
24
25
|
describe('design-tokens color roles', () => {
|
|
@@ -205,10 +206,13 @@ describe('design-tokens resolved token values', () => {
|
|
|
205
206
|
|
|
206
207
|
it('buildSeedScopeVars also emits the --color-x aliases a scope needs', () => {
|
|
207
208
|
const vars = buildSeedScopeVars({ seed: '#7c5aed', mode: 'dark' });
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
209
|
+
// Every canonical token gets a same-named alias. The role vocabulary
|
|
210
|
+
// (`--color-fill` → `--card`) is checked against theme.css further down,
|
|
211
|
+
// where the mapping comes from rather than being restated here.
|
|
212
|
+
const canonical = Object.keys(vars).filter((k) => !k.startsWith('--color-'));
|
|
213
|
+
expect(canonical.length).toBeGreaterThan(0);
|
|
214
|
+
for (const token of canonical) {
|
|
215
|
+
expect(vars[`--color-${token.slice(2)}`]).toBe(vars[token]);
|
|
212
216
|
}
|
|
213
217
|
});
|
|
214
218
|
|
|
@@ -230,6 +234,40 @@ describe('design-tokens resolved token values', () => {
|
|
|
230
234
|
});
|
|
231
235
|
});
|
|
232
236
|
|
|
237
|
+
describe('a scope re-declares every alias theme.css points at a token', () => {
|
|
238
|
+
/* The failure this guards is silent and mode-dependent: a scope overrides
|
|
239
|
+
* `--foreground`, but `--color-text: var(--foreground)` was computed at the
|
|
240
|
+
* document root, so `text-text` inside the scope keeps painting the app-wide
|
|
241
|
+
* colour. It looks correct in whichever mode the root happens to match.
|
|
242
|
+
*
|
|
243
|
+
* The list is read out of `bloomThemeCss()` rather than written here, so an
|
|
244
|
+
* alias added there is covered the day it lands. */
|
|
245
|
+
const rootAliases = bloomThemeCss()
|
|
246
|
+
.split('\n')
|
|
247
|
+
.map((line) => /^\s*--color-([a-z0-9-]+):\s*var\(--([a-z0-9-]+)\);\s*$/.exec(line))
|
|
248
|
+
.filter((match): match is RegExpExecArray => match !== null)
|
|
249
|
+
.map((match) => ({ alias: match[1] as string, canonical: match[2] as string }))
|
|
250
|
+
|
|
251
|
+
it('covers a meaningful number of aliases', () => {
|
|
252
|
+
// A regex that stopped matching would otherwise leave every case below
|
|
253
|
+
// passing over an empty list.
|
|
254
|
+
expect(rootAliases.length).toBeGreaterThan(20)
|
|
255
|
+
})
|
|
256
|
+
|
|
257
|
+
for (const [label, scope] of [
|
|
258
|
+
['seed', buildSeedScopeVars({ seed: '#7c5aed', mode: 'dark' })],
|
|
259
|
+
['preset', buildScopeVars('faircoin', 'dark')],
|
|
260
|
+
] as const) {
|
|
261
|
+
it(`resolves them against the scope's own tokens (${label})`, () => {
|
|
262
|
+
const wrong = rootAliases
|
|
263
|
+
.filter(({ canonical }) => scope[`--${canonical}`] !== undefined)
|
|
264
|
+
.filter(({ alias, canonical }) => scope[`--color-${alias}`] !== scope[`--${canonical}`])
|
|
265
|
+
.map(({ alias, canonical }) => `--color-${alias} != --${canonical}`)
|
|
266
|
+
expect(wrong).toEqual([])
|
|
267
|
+
})
|
|
268
|
+
}
|
|
269
|
+
})
|
|
270
|
+
|
|
233
271
|
describe('design-tokens entry stays free of react / react-native', () => {
|
|
234
272
|
/* Build scripts import this entry from plain node/bun to emit a static theme
|
|
235
273
|
* stylesheet (see the export's doc comment). A `react-native` import anywhere
|
|
@@ -1,6 +1,52 @@
|
|
|
1
1
|
import { generateRoleColors, type RoleColors, type SchemeVariant } from '../color-engine';
|
|
2
2
|
import { buildPolicyTokens, isColourlessSeed } from '../color-policy';
|
|
3
|
-
import {
|
|
3
|
+
import { BORDER_ROLES, FILL_ROLES, TEXT_ROLES } from '../../design-tokens/color-roles';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Every alias `theme.css` declares at `:root` as a reference to a canonical
|
|
7
|
+
* token, keyed by the alias name. `--color-divider` is one of these and does not
|
|
8
|
+
* come from the role maps, so it is named here.
|
|
9
|
+
*
|
|
10
|
+
* An alias declared at the document root substitutes THERE, so a subtree that
|
|
11
|
+
* overrides `--foreground` cannot move a `--color-text: var(--foreground)` the
|
|
12
|
+
* root already computed — the subtree keeps painting the app-wide palette while
|
|
13
|
+
* every canonical token around it says otherwise. Re-declaring each alias inside
|
|
14
|
+
* the scope, against the scope's own values, is what closes that.
|
|
15
|
+
*
|
|
16
|
+
* An alias whose value is a literal (`--color-destructive-foreground: #ffffff`)
|
|
17
|
+
* is unaffected and deliberately absent.
|
|
18
|
+
*/
|
|
19
|
+
const SCOPED_ALIASES: Readonly<Record<string, string>> = {
|
|
20
|
+
...FILL_ROLES,
|
|
21
|
+
...TEXT_ROLES,
|
|
22
|
+
...BORDER_ROLES,
|
|
23
|
+
divider: 'var(--border)',
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Give a resolved token map the `--color-x` alias layer, so utilities resolve
|
|
28
|
+
* against the scope instead of the document root.
|
|
29
|
+
*
|
|
30
|
+
* Shared by both scope builders — the preset path (`buildScopeVars`) and the
|
|
31
|
+
* seed path (`buildSeedScopeVars`) — because a gap here is invisible until a
|
|
32
|
+
* scoped page paints the wrong colour in one mode only.
|
|
33
|
+
*/
|
|
34
|
+
export function withScopeAliases(tokens: Record<string, string>): Record<string, string> {
|
|
35
|
+
const vars: Record<string, string> = { ...tokens };
|
|
36
|
+
|
|
37
|
+
// Policy tokens live outside the canonical set, so alias every token present.
|
|
38
|
+
for (const [key, value] of Object.entries(tokens)) {
|
|
39
|
+
vars[`--color-${key.slice(2)}`] = value;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
for (const [alias, reference] of Object.entries(SCOPED_ALIASES)) {
|
|
43
|
+
const canonical = /^var\(--(.+)\)$/.exec(reference)?.[1];
|
|
44
|
+
const resolved = canonical === undefined ? undefined : tokens[`--${canonical}`];
|
|
45
|
+
if (resolved !== undefined) vars[`--color-${alias}`] = resolved;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return vars;
|
|
49
|
+
}
|
|
4
50
|
|
|
5
51
|
/**
|
|
6
52
|
* The canonical role → token assignment, sourced from an arbitrary seed's role
|
|
@@ -121,19 +167,5 @@ export function buildSeedScopeVars(options: SeedScopeOptions): Record<string, st
|
|
|
121
167
|
tertiary: options.tertiarySeed,
|
|
122
168
|
}),
|
|
123
169
|
};
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
// Policy tokens live outside CANONICAL_TOKENS, so alias every token present.
|
|
127
|
-
for (const [key, value] of Object.entries(tokens)) {
|
|
128
|
-
vars[`--color-${key.slice(2)}`] = value;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
for (const token of CANONICAL_TOKENS) {
|
|
132
|
-
const value = tokens[`--${token}`];
|
|
133
|
-
if (value !== undefined) {
|
|
134
|
-
vars[`--color-${token}`] = value;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
return vars;
|
|
170
|
+
return withScopeAliases(tokens);
|
|
139
171
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
2
|
import { Platform, type StyleProp, type ViewStyle } from 'react-native';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { getResolvedTokens } from '../token-registry';
|
|
5
5
|
import type { AppColorName } from '../color-presets';
|
|
6
6
|
import type { ExplicitAccents } from '../preset-vars';
|
|
7
|
+
import { withScopeAliases } from './seed-scope';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* The optional-peer boundary for `nativewind`.
|
|
@@ -138,23 +139,7 @@ export function buildScopeVars(
|
|
|
138
139
|
mode: 'light' | 'dark',
|
|
139
140
|
accents?: ExplicitAccents,
|
|
140
141
|
): Record<string, string> {
|
|
141
|
-
|
|
142
|
-
const vars: Record<string, string> = { ...tokens };
|
|
143
|
-
|
|
144
|
-
// Policy tokens live outside CANONICAL_TOKENS, so give every token present a
|
|
145
|
-
// `--color-*` alias; NativeWind resolves its utilities through those.
|
|
146
|
-
for (const [key, value] of Object.entries(tokens)) {
|
|
147
|
-
vars[`--color-${key.slice(2)}`] = value;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
for (const token of CANONICAL_TOKENS) {
|
|
151
|
-
const value = tokens[`--${token}`];
|
|
152
|
-
if (value !== undefined) {
|
|
153
|
-
vars[`--color-${token}`] = value;
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
return vars;
|
|
142
|
+
return withScopeAliases(getResolvedTokens(colorPreset, mode, accents));
|
|
158
143
|
}
|
|
159
144
|
|
|
160
145
|
/**
|