@wix/web5-core 1.61.0 → 1.62.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.
@@ -0,0 +1,103 @@
1
+ /**
2
+ * The theme-token contract (DL #193).
3
+ *
4
+ * One home for the answer to "who is allowed to set this token, and who wins
5
+ * when more than one of them does". Three things need that answer and must not
6
+ * each keep their own copy:
7
+ *
8
+ * - **`applyThemeOverrides`** decides, per key, whether to write the real
9
+ * token or its `--web5-host-*` alias.
10
+ * - **the seed's `validate-templates`** fails a template that sets a brand
11
+ * token.
12
+ * - **the shop owner's panel** renders a control per `editable` entry.
13
+ *
14
+ * A leaf module beside `hostScope.ts`, and for the same reason: both are data
15
+ * that several packages must agree on, and both have to be readable from plain
16
+ * Node tooling. Requiring this package's ENTRY from Node fails — the CSS import
17
+ * in it is a syntax error to the CJS loader, which is what `scope-css.ts`
18
+ * documents — but a deep import of a leaf like this one works, so the seed's
19
+ * validator can read it without loading a component library.
20
+ *
21
+ * It was briefly its own package. That was justified by `embed-loader` needing
22
+ * the list without taking core's eleven dependencies — and the loader turned
23
+ * out not to need it at all, because `applyThemeOverrides` has owned runtime
24
+ * token injection here since DL #131.
25
+ *
26
+ * ## The two buckets
27
+ *
28
+ * The split is about who WINS, not about what may be imported. A platform
29
+ * adapter is free to read anything the store states; the bucket decides what
30
+ * happens when a template has an opinion about the same token.
31
+ *
32
+ * - `brand` — the store's identity: colour roles and font families. The
33
+ * imported value is written as the real token, last, so it wins
34
+ * unconditionally. A template is not permitted to set these.
35
+ * - `host` — the store's shape: corner radius today. The imported value is
36
+ * written as `--web5-host-<name>` and consumed by core as a `var()`
37
+ * fallback, so a template stating the real token beats it and a template
38
+ * that stays silent inherits the store's.
39
+ *
40
+ * A token absent from this map is treated as `host`. That is deliberate and
41
+ * safe: an alias nothing consumes renders nothing, so an adapter that learns
42
+ * to read a token core has never heard of cannot override a template by
43
+ * accident. The wiring line in core is the real gate for a host token, not the
44
+ * entry here.
45
+ *
46
+ * ## Why all but one are brand
47
+ *
48
+ * This is not a new taxonomy. Twenty of these are the set
49
+ * `web50-shopify-adapter` already emits, with a bucket attached; the
50
+ * twenty-first, `--heading`, has been in core's catalogue since DL #131 and is
51
+ * consumed by the seed, but no adapter fills it yet. Exactly one token changes
52
+ * hands relative to the behaviour before DL #193 — `--radius`, which used to
53
+ * win against the template that had chosen a different one. That single
54
+ * misfiling is the whole of the bug this contract exists to fix.
55
+ */
56
+ /** How a value is spelled, which is what makes validation possible. */
57
+ export type TokenType =
58
+ /** An HSL triplet with no `hsl()` wrapper — `0 0% 9%`. The core bridge wraps it. */
59
+ 'color-hsl'
60
+ /** A CSS font stack — `'Poppins', ui-sans-serif, sans-serif`. */
61
+ | 'font-stack'
62
+ /** A CSS length. MUST carry a unit: a bare `0` turns `calc(var(--radius) - 4px)`
63
+ * into a type error and takes the derived radius scale out entirely. */
64
+ | 'length';
65
+ /** Which layer wins when both a store and a template state this token. */
66
+ export type TokenBucket = 'brand' | 'host';
67
+ export interface TokenContractEntry {
68
+ bucket: TokenBucket;
69
+ type: TokenType;
70
+ /** May the shop owner set this from the panel? */
71
+ editable: boolean;
72
+ /** Shown in the owner's panel. Absent for entries that are not editable. */
73
+ label?: string;
74
+ }
75
+ /**
76
+ * Every token a platform adapter may meaningfully emit today.
77
+ *
78
+ * Growth is adapter-driven on purpose: a token joins when an adapter can
79
+ * actually read it, not on spec. `theme_overrides` is capped at 32 entries by
80
+ * its proto, so there are twelve slots left and no reason to spend them on
81
+ * speculation. `--spacing` is the tempting next one and should be resisted —
82
+ * it scales every `p-*`, `m-*` and `gap-*` in the bundle from one number.
83
+ */
84
+ export declare const THEME_TOKEN_CONTRACT: Readonly<Record<string, TokenContractEntry>>;
85
+ /**
86
+ * The tokens written directly, which is the only question the loader has to
87
+ * answer per key — everything else takes the alias path.
88
+ */
89
+ export declare const BRAND_TOKENS: ReadonlySet<string>;
90
+ /**
91
+ * A token name we are willing to compose into a CSS declaration.
92
+ *
93
+ * The keys reaching the loader came out of a backend map, which came out of an
94
+ * adapter reading a merchant's theme file. A key carrying `:` or `;` would
95
+ * write arbitrary declarations onto the mount, so the shape is checked where
96
+ * the declaration is built rather than trusted from the source.
97
+ */
98
+ export declare const TOKEN_NAME_PATTERN: RegExp;
99
+ /** `--radius` → `--web5-host-radius`. Derived, never stored: one fewer thing to get wrong. */
100
+ export declare function hostAliasFor(token: string): string;
101
+ /** Whether this token is written directly (brand) or as an alias (host, and anything unknown). */
102
+ export declare function bucketOf(token: string): TokenBucket;
103
+ //# sourceMappingURL=tokenContract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokenContract.d.ts","sourceRoot":"","sources":["../../../src/theme/tokenContract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AAEH,uEAAuE;AACvE,MAAM,MAAM,SAAS;AACnB,oFAAoF;AAClF,WAAW;AACb,iEAAiE;GAC/D,YAAY;AACd;yEACyE;GACvE,QAAQ,CAAC;AAEb,0EAA0E;AAC1E,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,MAAM,CAAC;AAE3C,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,WAAW,CAAC;IACpB,IAAI,EAAE,SAAS,CAAC;IAChB,kDAAkD;IAClD,QAAQ,EAAE,OAAO,CAAC;IAClB,4EAA4E;IAC5E,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AASD;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CA8C1E,CAAC;AAEL;;;GAGG;AACH,eAAO,MAAM,YAAY,EAAE,WAAW,CAAC,MAAM,CAMrB,CAAC;AAEzB;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,QAAmB,CAAC;AAEnD,8FAA8F;AAC9F,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,kGAAkG;AAClG,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,CAEnD"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wix/web5-core",
3
3
  "license": "MIT",
4
- "version": "1.61.0",
4
+ "version": "1.62.0",
5
5
  "author": {
6
6
  "name": "tsachis",
7
7
  "email": "tsachis@wix.com"
@@ -100,5 +100,5 @@
100
100
  "wallaby": {
101
101
  "autoDetect": true
102
102
  },
103
- "falconPackageHash": "9694f910a3ae343f13fc3432bb04b42ad38df91bfab9b5288fddc2e6"
103
+ "falconPackageHash": "6796550854d3a51bfecb2ebb957ef475051e33aae7c4e8f71812d718"
104
104
  }
@@ -36,7 +36,14 @@
36
36
  --font-display: var(--font-sans);
37
37
 
38
38
  /* Spacing & shape tokens */
39
- --radius: 0.5rem;
39
+ /* Shape follows the host page unless a template states its own (DL #193).
40
+ * `embed-loader` writes `--web5-host-radius` from the store's imported theme;
41
+ * a template declaring `--radius` outright beats this fallback, and with
42
+ * neither present the seed default applies exactly as before. The whole
43
+ * derived scale rides on it — `--radius-sm/md/lg/xl` in tailwind-theme.css
44
+ * are live `var()`/`calc()` references, so one value reaches all 48
45
+ * `rounded-*` call sites. */
46
+ --radius: var(--web5-host-radius, 0.5rem);
40
47
  --tracking-normal: -0.02em;
41
48
  --spacing: 0.25rem;
42
49