@pitlane/theme 0.3.0 → 0.3.1
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/CHANGELOG.md +8 -0
- package/dist/default.d.mts +1 -1
- package/dist/default.mjs +1 -1
- package/dist/dtcg.d.mts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{theme-Ck-4suI4.d.mts → theme-CaHfWYnM.d.mts} +2 -0
- package/dist/{theme-CMaWrQJ5.mjs → theme-iDUjQhE0.mjs} +17 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @pitlane/theme
|
|
2
2
|
|
|
3
|
+
## 0.3.1
|
|
4
|
+
|
|
5
|
+
- `createTheme`, `extend`, `select`, and a mode all take their token tree under
|
|
6
|
+
a `tokens` key, and leaving that wrapper off now raises `ThemeError` naming
|
|
7
|
+
the key. A bare tree used to reach the compiler and fail as
|
|
8
|
+
`Object.entries(undefined)`, and a mode missing the key reported
|
|
9
|
+
`override at ""`, which named neither the key nor the mistake.
|
|
10
|
+
|
|
3
11
|
## 0.3.0
|
|
4
12
|
|
|
5
13
|
Authoring moves off W3C DTCG. `createTheme` now takes a schema tree and the
|
package/dist/default.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { o as TokenSchema, t as SELF } from "./schema-CRP607Pg.mjs";
|
|
2
|
-
import { t as ThemeComponent } from "./theme-
|
|
2
|
+
import { t as ThemeComponent } from "./theme-CaHfWYnM.mjs";
|
|
3
3
|
//#region src/default.d.ts
|
|
4
4
|
declare let schema: {
|
|
5
5
|
font: TokenSchema<"fontFamily">;
|
package/dist/default.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { c as duration, f as group, g as scale, l as easing, m as number, o as color, r as any, s as dimension, u as font, v as shadow } from "./schema-JmfNnMzr.mjs";
|
|
2
|
-
import { t as createTheme } from "./theme-
|
|
2
|
+
import { t as createTheme } from "./theme-iDUjQhE0.mjs";
|
|
3
3
|
/**
|
|
4
4
|
* Tailwind CSS v4.3.2's default primitive theme.
|
|
5
5
|
*
|
package/dist/dtcg.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as SchemaTag } from "./schema-CRP607Pg.mjs";
|
|
2
|
-
import { l as ThemeInit, r as ThemeResult, t as ThemeComponent } from "./theme-
|
|
2
|
+
import { l as ThemeInit, r as ThemeResult, t as ThemeComponent } from "./theme-CaHfWYnM.mjs";
|
|
3
3
|
//#region src/dtcg.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* A JSON-compatible W3C Design Tokens Community Group document.
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { A as DimensionToken, B as UntypedToken, E as BorderToken, F as NumberToken, I as ShadowToken, L as StrokeStyleToken, M as FontFamilyToken, N as FontWeightToken, O as ColorToken, P as GradientToken, R as TokenType, T as AnyToken, j as DurationToken, k as CubicBezierToken, z as TransitionToken } from "./schema-CRP607Pg.mjs";
|
|
2
|
-
import { a as DeepPartialTokens, c as ScaleFn, d as ThemePatch, f as TokenTree, i as createTheme, l as ThemeInit, m as Tokens, n as ThemeProps, o as Merged, p as TokenValue, r as ThemeResult, s as ScalableToken, t as ThemeComponent, u as ThemeMode } from "./theme-
|
|
2
|
+
import { a as DeepPartialTokens, c as ScaleFn, d as ThemePatch, f as TokenTree, i as createTheme, l as ThemeInit, m as Tokens, n as ThemeProps, o as Merged, p as TokenValue, r as ThemeResult, s as ScalableToken, t as ThemeComponent, u as ThemeMode } from "./theme-CaHfWYnM.mjs";
|
|
3
3
|
import { ElementProps, MixinDescriptor, css as css$1 } from "remix/ui";
|
|
4
4
|
import * as CSS from "csstype";
|
|
5
5
|
//#region src/props.d.ts
|
package/dist/index.mjs
CHANGED
|
@@ -192,6 +192,7 @@ interface ThemeResult<T> {
|
|
|
192
192
|
*
|
|
193
193
|
* @param patch - The tokens and schema to merge, or a callback returning them
|
|
194
194
|
* @returns A new theme
|
|
195
|
+
* @throws ThemeError when the patch holds no `tokens` group
|
|
195
196
|
*/
|
|
196
197
|
extend<const schema extends object, const tokens extends object>(patch: ExtendPatch<T, schema, tokens> | ((base: TokenTree<T>) => ExtendPatch<T, schema, tokens>)): ThemeResult<Merged<T, {
|
|
197
198
|
schema: schema;
|
|
@@ -205,6 +206,7 @@ interface ThemeResult<T> {
|
|
|
205
206
|
*
|
|
206
207
|
* @param projection - A callback returning the schema and tokens to keep
|
|
207
208
|
* @returns A new theme
|
|
209
|
+
* @throws ThemeError when the projection holds no `tokens` group
|
|
208
210
|
*/
|
|
209
211
|
select<const P extends ThemeInit>(projection: (base: TokenTree<T>) => P): ThemeResult<P>;
|
|
210
212
|
}
|
|
@@ -31,7 +31,9 @@ function compose(tokens, schema, inherited) {
|
|
|
31
31
|
//#region src/theme.ts
|
|
32
32
|
const REF_RE = /^var\((--[a-z0-9-]+)\)$/;
|
|
33
33
|
function createTheme(input) {
|
|
34
|
-
|
|
34
|
+
let init = typeof input === "function" ? input.$theme : input;
|
|
35
|
+
assertTokensGroup(init, "createTheme()", "createTheme({ schema: { … }, tokens: { … } })");
|
|
36
|
+
return compile(init);
|
|
35
37
|
}
|
|
36
38
|
function compile(init) {
|
|
37
39
|
parse(composeSchema(init.tokens, init.schema), init.tokens, { abortEarly: false });
|
|
@@ -50,6 +52,7 @@ function compile(init) {
|
|
|
50
52
|
extend(patch) {
|
|
51
53
|
let accessor = buildAccessor(entries);
|
|
52
54
|
let next = typeof patch === "function" ? patch(accessor) : patch;
|
|
55
|
+
assertTokensGroup(next, "extend()", ".extend(base => ({ schema: { … }, tokens: { … } }))");
|
|
53
56
|
return compile({
|
|
54
57
|
schema: mergeDeep(init.schema, next.schema ?? {}),
|
|
55
58
|
tokens: mergeDeep(init.tokens, next.tokens),
|
|
@@ -61,6 +64,7 @@ function compile(init) {
|
|
|
61
64
|
},
|
|
62
65
|
select(projection) {
|
|
63
66
|
let next = projection(buildAccessor(entries));
|
|
67
|
+
assertTokensGroup(next, "select()", ".select(base => ({ schema: { … }, tokens: { … } }))");
|
|
64
68
|
let projected = reroot(next.tokens, byVarName);
|
|
65
69
|
assertNoDroppedReferences(projected, byVarName);
|
|
66
70
|
return compile({
|
|
@@ -87,11 +91,23 @@ function declare(entry, ctx) {
|
|
|
87
91
|
if (entry.aliasOf !== void 0) return ctx.varRefFor(entry.aliasOf, entry.key, entry.type);
|
|
88
92
|
return serializeValue(entry.type, entry.value, ctx, entry.key);
|
|
89
93
|
}
|
|
94
|
+
/**
|
|
95
|
+
* A schema tree, a patch, a projection, and a mode all carry their token tree
|
|
96
|
+
* under a `tokens` key, and leaving the wrapper off is a plausible mistake:
|
|
97
|
+
* 0.2.0 took a bare document, and the wrapper is what the 0.3.0 migration
|
|
98
|
+
* teaches for modes. Without this the bare tree reaches the compiler, where it
|
|
99
|
+
* fails as `Object.entries(undefined)` from inside a bundled chunk.
|
|
100
|
+
*/
|
|
101
|
+
function assertTokensGroup(node, label, example) {
|
|
102
|
+
if (!isPlainRecord(node) || !("tokens" in node)) throw new ThemeError(`${label} is missing its "tokens" group: ${example}`);
|
|
103
|
+
if (!isPlainRecord(node.tokens)) throw new ThemeError(`${label} has a "tokens" that is not a group`);
|
|
104
|
+
}
|
|
90
105
|
function modeBlocks(modes, byKey, ctx) {
|
|
91
106
|
if (modes === void 0) return [];
|
|
92
107
|
let selectorBlocks = [];
|
|
93
108
|
let mediaBlocks = [];
|
|
94
109
|
for (let [name, mode] of Object.entries(modes)) {
|
|
110
|
+
assertTokensGroup(mode, `Mode "${name}"`, `modes: { ${name}: { tokens: { … } } }`);
|
|
95
111
|
let overrides = [];
|
|
96
112
|
walkMode(mode.tokens, [], name, byKey, ctx, overrides);
|
|
97
113
|
if (overrides.length === 0) continue;
|