@pitlane/theme 0.3.0 → 0.4.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/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  # @pitlane/theme
2
2
 
3
+ ## 0.4.0
4
+
5
+ Target Remix `3.0.0-rc.1`.
6
+
7
+ - Raised the `remix` peer dependency to `^3.0.0-rc.1` (from
8
+ `^3.0.0-beta.10`). No API changes — `createTheme`, `extend`, `select`,
9
+ `<Theme />`, and the `css`/`tva`/`combine`/`cx` helpers are unchanged, and
10
+ the package still has no runtime dependency on Remix beyond
11
+ `createElement` from `remix/ui`.
12
+ - One rc.1 change is worth knowing about when reading generated markup: the
13
+ marker on server-rendered style elements is now `data-rmx-style`, where
14
+ beta.10 emitted a bare `data-rmx`. A stylesheet or test that selected
15
+ `[data-rmx]` needs the new attribute. The class hashes this package emits
16
+ (`rmxc-…`) and the `@layer rmx` / `@layer rmx-reset` cascade layers are
17
+ unaffected.
18
+ - Tested against `remix@3.0.0-rc.1`.
19
+
20
+ ## 0.3.1
21
+
22
+ - `createTheme`, `extend`, `select`, and a mode all take their token tree under
23
+ a `tokens` key, and leaving that wrapper off now raises `ThemeError` naming
24
+ the key. A bare tree used to reach the compiler and fail as
25
+ `Object.entries(undefined)`, and a mode missing the key reported
26
+ `override at ""`, which named neither the key nor the mistake.
27
+
3
28
  ## 0.3.0
4
29
 
5
30
  Authoring moves off W3C DTCG. `createTheme` now takes a schema tree and the
package/README.md CHANGED
@@ -10,7 +10,7 @@ npm install @pitlane/theme
10
10
  vp add @pitlane/theme
11
11
  ```
12
12
 
13
- Requires `remix@^3.0.0-beta.10` as a peer.
13
+ Requires `remix@^3.0.0-rc.1` as a peer.
14
14
 
15
15
  ## Quick start
16
16
 
@@ -120,6 +120,7 @@ A layer's declarations follow the ones they reference, which moves them later in
120
120
  - `lightDark(light, dark)` returns CSS `light-dark()` text. `scale(token)` returns a multiplier for an ordinary dimension, duration, or number token.
121
121
  - `ThemeError` reports structural failures: a reference whose type does not match its position, a reference to an untyped token, a variable collision, an undeclared token, a mode overriding an unknown token, and a `"{a.b.c}"` string left over from the pre-0.3.0 format. Invalid values raise `ValidationError` from `remix/data-schema`, whose `issues` array contains the detail.
122
122
  - `@pitlane/theme/schema` exports `s.color()`, `s.dimension()`, `s.duration()`, `s.number()`, `s.easing()`, `s.shadow()`, `s.border()`, `s.transition()`, `s.gradient()`, `s.stroke()`, `s.font.family()`, `s.font.weight()`, `s.scale()`, `s.any()`, and `s.group()`.
123
+ - `@pitlane/theme/dtcg` is the DTCG interchange: `fromDTCG(document)` reads a W3C DTCG document into a `createTheme` init, and `toDTCG(theme)` exports a theme as a document plus per-mode overrides.
123
124
  - Types include `ThemeInit`, `ThemeMode`, `ThemeResult`, `ThemeComponent`, `ThemeProps`, `TokenTree`, `ScaleFn`, `Tokens`, `TokenValue`, `ThemedCSSProps`, `ThemedCSSMixin`, TVA types, and per-type token brands.
124
125
 
125
126
  ## Links
@@ -1,5 +1,5 @@
1
1
  import { o as TokenSchema, t as SELF } from "./schema-CRP607Pg.mjs";
2
- import { t as ThemeComponent } from "./theme-Ck-4suI4.mjs";
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-CMaWrQJ5.mjs";
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-Ck-4suI4.mjs";
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-Ck-4suI4.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-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
@@ -1,5 +1,5 @@
1
1
  import { S as ThemeError } from "./schema-JmfNnMzr.mjs";
2
- import { t as createTheme } from "./theme-CMaWrQJ5.mjs";
2
+ import { t as createTheme } from "./theme-iDUjQhE0.mjs";
3
3
  import { css as css$1 } from "remix/ui";
4
4
  //#region src/css.ts
5
5
  /**
@@ -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
- return compile(typeof input === "function" ? input.$theme : input);
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;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pitlane/theme",
3
- "version": "0.3.0",
4
- "description": "Type-safe styling with W3C design tokens for Remix 3.",
3
+ "version": "0.4.0",
4
+ "description": "Type-safe styling with design tokens for Remix 3: a schema tree plus the CSS values it describes compile to a typed token accessor and a <Theme /> component.",
5
5
  "keywords": [
6
6
  "css-variables",
7
7
  "design-tokens",
@@ -49,12 +49,12 @@
49
49
  "csstype": "^3.2.3"
50
50
  },
51
51
  "devDependencies": {
52
- "remix": "3.0.0-beta.10",
52
+ "remix": "3.0.0-rc.1",
53
53
  "typescript": "^7.0.2",
54
54
  "vite-plus": "^0.2.6"
55
55
  },
56
56
  "peerDependencies": {
57
- "remix": "^3.0.0-beta.10"
57
+ "remix": "^3.0.0-rc.1"
58
58
  },
59
59
  "engines": {
60
60
  "node": "^20.19.0 || >=22.12.0"