@origostudio/design-tokens 0.0.40

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 ADDED
@@ -0,0 +1,357 @@
1
+ ## 0.0.40 (2026-09-29)
2
+
3
+ ### 🚀 Features
4
+
5
+ - initialize packages, documentation site, and release workflow ([e0f7371](https://github.com/OrigoStudio/origo-design/commit/e0f7371))
6
+
7
+ ### ❤️ Thank You
8
+
9
+ - Hardik Patel @hardikpatelse
10
+
11
+ ## 0.0.39 (2026-09-29)
12
+
13
+ This was a version bump only for design-tokens to align it with other projects, there were no code changes.
14
+
15
+ ## 0.0.38 (2026-09-28)
16
+
17
+ This was a version bump only for design-tokens to align it with other projects, there were no code changes.
18
+
19
+ ## 0.0.37 (2026-09-24)
20
+
21
+ This was a version bump only for design-tokens to align it with other projects, there were no code changes.
22
+
23
+ ## 0.0.36 (2026-09-23)
24
+
25
+ This was a version bump only for design-tokens to align it with other projects, there were no code changes.
26
+
27
+ ## 0.0.35 (2026-09-22)
28
+
29
+ This was a version bump only for design-tokens to align it with other projects, there were no code changes.
30
+
31
+ ## 0.0.34 (2026-09-22)
32
+
33
+ This was a version bump only for design-tokens to align it with other projects, there were no code changes.
34
+
35
+ ## 0.0.33 (2026-09-21)
36
+
37
+ This was a version bump only for design-tokens to align it with other projects, there were no code changes.
38
+
39
+ ## 0.0.32 (2026-09-19)
40
+
41
+ This was a version bump only for design-tokens to align it with other projects, there were no code changes.
42
+
43
+ ## 0.0.31 (2026-09-16)
44
+
45
+ This was a version bump only for design-tokens to align it with other projects, there were no code changes.
46
+
47
+ ## 0.0.30 (2026-09-15)
48
+
49
+ This was a version bump only for design-tokens to align it with other projects, there were no code changes.
50
+
51
+ ## 0.0.29 (2026-09-14)
52
+
53
+ This was a version bump only for design-tokens to align it with other projects, there were no code changes.
54
+
55
+ ## 0.0.28 (2026-09-14)
56
+
57
+ This was a version bump only for design-tokens to align it with other projects, there were no code changes.
58
+
59
+ ## 0.0.27 (2026-09-09)
60
+
61
+ This was a version bump only for design-tokens to align it with other projects, there were no code changes.
62
+
63
+ ## 0.0.26 (2026-09-08)
64
+
65
+ This was a version bump only for design-tokens to align it with other projects, there were no code changes.
66
+
67
+ ## 0.0.25 (2026-09-07)
68
+
69
+ ### 🚀 Features
70
+
71
+ - initialize package.json files for cli, core, design-tokens, playground, and angular-renderer packages ([2dee8cc](https://github.com/OrigoStudio/origo-design/commit/2dee8cc))
72
+
73
+ ### ❤️ Thank You
74
+
75
+ - Hardik Patel @hardikpatelse
76
+
77
+ ## 0.0.24 (2026-09-07)
78
+
79
+ This was a version bump only for design-tokens to align it with other projects, there were no code changes.
80
+
81
+ ## 0.0.23 (2026-09-07)
82
+
83
+ This was a version bump only for design-tokens to align it with other projects, there were no code changes.
84
+
85
+ ## 0.0.22 (2026-09-04)
86
+
87
+ ### 🚀 Features
88
+
89
+ - scaffold playground application and e2e testing suite with initial editor component and schema registry ([f097894](https://github.com/OrigoStudio/origo-design/commit/f097894))
90
+ - add GitHub Actions workflow to automate library releases using Nx Release ([3d6651f](https://github.com/OrigoStudio/origo-design/commit/3d6651f))
91
+
92
+ ### ❤️ Thank You
93
+
94
+ - Hardik Patel @hardikpatelse
95
+
96
+ ## 0.0.21 (2026-09-02)
97
+
98
+ ### 🚀 Features
99
+
100
+ - add centralized test registry tool with validation logic, CI integration, and documentation artifacts ([384c1c7](https://github.com/OrigoStudio/origo-design/commit/384c1c7))
101
+ - implement central test registry with validation tools and CI integration ([02cf656](https://github.com/OrigoStudio/origo-design/commit/02cf656))
102
+ - initialize negative testing story and update sprint status tracking ([bbe5fdc](https://github.com/OrigoStudio/origo-design/commit/bbe5fdc))
103
+ - implement CLI framework with validation, testing, and CI/CD workflows ([ff6ce55](https://github.com/OrigoStudio/origo-design/commit/ff6ce55))
104
+ - implement validate command and schema validation logic for BADL files ([4f9e41d](https://github.com/OrigoStudio/origo-design/commit/4f9e41d))
105
+ - implement path traversal guards, remove process termination from library logic, and enable error cause preservation in @origo/cli ([0854f78](https://github.com/OrigoStudio/origo-design/commit/0854f78))
106
+ - initialize web-based editor component and track security remediation tasks in implementation artifacts ([65716bd](https://github.com/OrigoStudio/origo-design/commit/65716bd))
107
+ - document e2e npm verification plan for cli package releases ([22dab4c](https://github.com/OrigoStudio/origo-design/commit/22dab4c))
108
+ - initialize sprint status tracking and retrospective verification story for npm packaging ([c326751](https://github.com/OrigoStudio/origo-design/commit/c326751))
109
+ - add generated bundle for epic7-worker-csp spike ([16ca492](https://github.com/OrigoStudio/origo-design/commit/16ca492))
110
+ - add web worker CSP spike and associated implementation documentation ([ebf5aa4](https://github.com/OrigoStudio/origo-design/commit/ebf5aa4))
111
+ - implement web worker CSP spike with supporting documentation and harness tools ([f57b1e5](https://github.com/OrigoStudio/origo-design/commit/f57b1e5))
112
+ - add technical spike story for Epic 7 web worker CSP validation and ADR planning ([c977487](https://github.com/OrigoStudio/origo-design/commit/c977487))
113
+ - initialize sprint status tracking and create Epic 7 discovery research story ([b37b967](https://github.com/OrigoStudio/origo-design/commit/b37b967))
114
+ - implement entity generator command with template customization and ejection support ([02a3193](https://github.com/OrigoStudio/origo-design/commit/02a3193))
115
+ - implement entity generator command and template ejection logic in CLI ([d7d519a](https://github.com/OrigoStudio/origo-design/commit/d7d519a))
116
+ - implementation of 6-2-local-schema-validation ([45e67f6](https://github.com/OrigoStudio/origo-design/commit/45e67f6))
117
+
118
+ ### ❤️ Thank You
119
+
120
+ - Hardik Patel @hardikpatelse
121
+
122
+ ## 0.0.20 (2026-08-25)
123
+
124
+ ### 🚀 Features
125
+
126
+ - implementation of 6-1-cli-initialization-and-scaffolding ([f6aca9e](https://github.com/OrigoStudio/origo-design/commit/f6aca9e))
127
+
128
+ ### ❤️ Thank You
129
+
130
+ - Hardik Patel @hardikpatelse
131
+
132
+ ## 0.0.19 (2026-08-23)
133
+
134
+ ### 🚀 Features
135
+
136
+ - 5.5-5-define-secure-by-default-boilerplate-templates ([0eb6dde](https://github.com/OrigoStudio/origo-design/commit/0eb6dde))
137
+
138
+ ### ❤️ Thank You
139
+
140
+ - Hardik Patel @hardikpatelse
141
+
142
+ ## 0.0.18 (2026-08-23)
143
+
144
+ ### 🚀 Features
145
+
146
+ - 5.5-4-verify-core-compiler-source-map-preservation ([a3b0d9b](https://github.com/OrigoStudio/origo-design/commit/a3b0d9b))
147
+
148
+ ### 🩹 Fixes
149
+
150
+ - pipeline issue ([c1bbe47](https://github.com/OrigoStudio/origo-design/commit/c1bbe47))
151
+
152
+ ### ❤️ Thank You
153
+
154
+ - Hardik Patel @hardikpatelse
155
+
156
+ ## 0.0.17 (2026-08-21)
157
+
158
+ ### 🚀 Features
159
+
160
+ - 5.5-3-resolve-recursive-schema-resolution-tech-debt ([943e2e7](https://github.com/OrigoStudio/origo-design/commit/943e2e7))
161
+ - 5.5-2-establish-end-to-end-qa-protocols ([d8990ae](https://github.com/OrigoStudio/origo-design/commit/d8990ae))
162
+ - 5.5-2-establish-end-to-end-qa-protocols ([a31d97a](https://github.com/OrigoStudio/origo-design/commit/a31d97a))
163
+
164
+ ### ❤️ Thank You
165
+
166
+ - Hardik Patel @hardikpatelse
167
+
168
+ ## 0.0.16 (2026-08-21)
169
+
170
+ ### 🚀 Features
171
+
172
+ - 5.5-1-create-usability-quickstart-guide ([e740a1a](https://github.com/OrigoStudio/origo-design/commit/e740a1a))
173
+
174
+ ### ❤️ Thank You
175
+
176
+ - Hardik Patel @hardikpatelse
177
+
178
+ ## 0.0.15 (2026-08-20)
179
+
180
+ ### 🚀 Features
181
+
182
+ - code-review 5-5-reactive-state-event-binding ([b235951](https://github.com/OrigoStudio/origo-design/commit/b235951))
183
+ - implementation of 5-5-reactive-state-event-binding ([3a5948a](https://github.com/OrigoStudio/origo-design/commit/3a5948a))
184
+ - story creation 5-5-reactive-state-event-binding ([21104c6](https://github.com/OrigoStudio/origo-design/commit/21104c6))
185
+
186
+ ### ❤️ Thank You
187
+
188
+ - Hardik Patel @hardikpatelse
189
+
190
+ ## 0.0.14 (2026-08-19)
191
+
192
+ ### 🚀 Features
193
+
194
+ - 5-4-design-token-consumption ([c1f64ed](https://github.com/OrigoStudio/origo-design/commit/c1f64ed))
195
+ - add sprint status update and design token consumption story documentation ([49aec07](https://github.com/OrigoStudio/origo-design/commit/49aec07))
196
+
197
+ ### ❤️ Thank You
198
+
199
+ - Hardik Patel @hardikpatelse
200
+
201
+ ## 0.0.13 (2026-08-18)
202
+
203
+ ### 🚀 Features
204
+
205
+ - implement core primitives (Button, VBox, TextInput) with improved property coercion and accessibility support ([1be1def](https://github.com/OrigoStudio/origo-design/commit/1be1def))
206
+ - implement VBox, TextInput, and Button core primitives with accessibility testing and improved adapter coercion ([532417f](https://github.com/OrigoStudio/origo-design/commit/532417f))
207
+
208
+ ### ❤️ Thank You
209
+
210
+ - Hardik Patel @hardikpatelse
211
+
212
+ ## 0.0.12 (2026-08-17)
213
+
214
+ ### 🚀 Features
215
+
216
+ - implement InteractionContract-based OrigoAdapter and transition angular-renderer architecture to web adapter pattern ([1a8ea32](https://github.com/OrigoStudio/origo-design/commit/1a8ea32))
217
+
218
+ ### ❤️ Thank You
219
+
220
+ - Hardik Patel @hardikpatelse
221
+
222
+ ## 0.0.11 (2026-08-14)
223
+
224
+ ### 🚀 Features
225
+
226
+ - implement angular-renderer package with AST-based dynamic component instantiation and registry support ([500f396](https://github.com/OrigoStudio/origo-design/commit/500f396))
227
+
228
+ ### ❤️ Thank You
229
+
230
+ - Hardik Patel @hardikpatelse
231
+
232
+ ## 0.0.10 (2026-08-14)
233
+
234
+ ### 🚀 Features
235
+
236
+ - implement extension API scaffolding, define Angular signals patterns, and add renderer test utilities ([d2adbed](https://github.com/OrigoStudio/origo-design/commit/d2adbed))
237
+ - mark Epic 4 as complete and record its retrospective action items in sprint status ([37c2caa](https://github.com/OrigoStudio/origo-design/commit/37c2caa))
238
+
239
+ ### ❤️ Thank You
240
+
241
+ - Hardik Patel @hardikpatelse
242
+
243
+ ## 0.0.9 (2026-08-14)
244
+
245
+ ### 🚀 Features
246
+
247
+ - implement extension manager with manifest validation, permission security, and dependency resolution ([154b0d4](https://github.com/OrigoStudio/origo-design/commit/154b0d4))
248
+
249
+ ### ❤️ Thank You
250
+
251
+ - Hardik Patel @hardikpatelse
252
+
253
+ ## 0.0.8 (2026-08-14)
254
+
255
+ ### 🚀 Features
256
+
257
+ - implement formal extension manifest, capability negotiation, and lifecycle management in core extension-api ([808f113](https://github.com/OrigoStudio/origo-design/commit/808f113))
258
+
259
+ ### ❤️ Thank You
260
+
261
+ - Hardik Patel @hardikpatelse
262
+
263
+ ## 0.0.7 (2026-08-14)
264
+
265
+ ### 🚀 Features
266
+
267
+ - implement behavior validation test suite and expand AST validator test coverage ([d4c79ef](https://github.com/OrigoStudio/origo-design/commit/d4c79ef))
268
+ - register behavior validation suite story and update sprint status tracking ([798ec74](https://github.com/OrigoStudio/origo-design/commit/798ec74))
269
+
270
+ ### ❤️ Thank You
271
+
272
+ - Hardik Patel @hardikpatelse
273
+
274
+ ## 0.0.6 (2026-08-13)
275
+
276
+ ### 🚀 Features
277
+
278
+ - implement AST validation engine with support for circular dependency detection and reference integrity checks ([afd48c9](https://github.com/OrigoStudio/origo-design/commit/afd48c9))
279
+ - initialize sprint-status.yaml to track project development and retrospective action items ([66c6cdf](https://github.com/OrigoStudio/origo-design/commit/66c6cdf))
280
+
281
+ ### ❤️ Thank You
282
+
283
+ - Hardik Patel @hardikpatelse
284
+
285
+ ## 0.0.5 (2026-08-13)
286
+
287
+ ### 🚀 Features
288
+
289
+ - **core:** implement security and permissions engine ([d066d90](https://github.com/OrigoStudio/origo-design/commit/d066d90))
290
+ - add story 4.3 for security and permissions engine and update sprint status ([3eb4aae](https://github.com/OrigoStudio/origo-design/commit/3eb4aae))
291
+
292
+ ### ❤️ Thank You
293
+
294
+ - Hardik Patel @hardikpatelse
295
+
296
+ ## 0.0.4 (2026-08-13)
297
+
298
+ ### 🚀 Features
299
+
300
+ - implement semantic AST validator with domain, entity, and contract schema definitions ([e969466](https://github.com/OrigoStudio/origo-design/commit/e969466))
301
+ - update sprint status and initialize story 4-2 contracts and implementations documentation ([4b37c59](https://github.com/OrigoStudio/origo-design/commit/4b37c59))
302
+
303
+ ### ❤️ Thank You
304
+
305
+ - Hardik Patel @hardikpatelse
306
+
307
+ ## 0.0.3 (2026-08-13)
308
+
309
+ ### 🚀 Features
310
+
311
+ - 4-1-capabilities-schema-parsing ([869c872](https://github.com/OrigoStudio/origo-design/commit/869c872))
312
+
313
+ ### ❤️ Thank You
314
+
315
+ - Hardik Patel @hardikpatelse
316
+
317
+ ## 0.0.2 (2026-08-12)
318
+
319
+ ### 🚀 Features
320
+
321
+ - implement defensive AST validation with depth limiting, circular reference detection, and graceful error reporting ([d2f5f98](https://github.com/OrigoStudio/origo-design/commit/d2f5f98))
322
+ - initialize 3-5-3-defensive-ast-traversal story and update sprint status ([4f82702](https://github.com/OrigoStudio/origo-design/commit/4f82702))
323
+ - enforce JSON import standard and document AST validator ([162db09](https://github.com/OrigoStudio/origo-design/commit/162db09))
324
+ - implement automated semantic versioning with Nx release and commitlint enforcement ([5e7a25e](https://github.com/OrigoStudio/origo-design/commit/5e7a25e))
325
+ - implement AST validation engine and documentation for semantic versioning workflow ([838e472](https://github.com/OrigoStudio/origo-design/commit/838e472))
326
+ - implement AST validation engine and associated implementation artifacts ([49cbdf0](https://github.com/OrigoStudio/origo-design/commit/49cbdf0))
327
+ - implement deterministic canonical AST serialization and interfaces in @origo/core ([c35a2c9](https://github.com/OrigoStudio/origo-design/commit/c35a2c9))
328
+ - implement domain and entity schema parser with Ajv-based validation and circular dependency detection in new @origo/core package ([4165b5f](https://github.com/OrigoStudio/origo-design/commit/4165b5f))
329
+ - add design tokens documentation and update Starlight navigation configuration ([ba2404a](https://github.com/OrigoStudio/origo-design/commit/ba2404a))
330
+ - initialize Epic 3 planning and document Epic 2 retrospective findings ([4cc46f9](https://github.com/OrigoStudio/origo-design/commit/4cc46f9))
331
+ - implement runtime theme fetching, injection, and Angular renderer integration to complete the token resolution contract ([87f583e](https://github.com/OrigoStudio/origo-design/commit/87f583e))
332
+ - implement theme-fetcher runtime utility and create angular-renderer package with theme initialization provider ([1d5b7ab](https://github.com/OrigoStudio/origo-design/commit/1d5b7ab))
333
+ - implement secure theme injection with CSS token validation and scope management ([a708825](https://github.com/OrigoStudio/origo-design/commit/a708825))
334
+ - implement runtime theme injector for parsing and applying CSS variables ([969fed5](https://github.com/OrigoStudio/origo-design/commit/969fed5))
335
+ - add astro, @astrojs/starlight, and sharp dependencies to package.json ([1c40a92](https://github.com/OrigoStudio/origo-design/commit/1c40a92))
336
+ - implement design token compilation pipeline with CSS variable parsing and generation ([0ffe822](https://github.com/OrigoStudio/origo-design/commit/0ffe822))
337
+ - **nx-cloud:** setup nx cloud workspace ([ee09042](https://github.com/OrigoStudio/origo-design/commit/ee09042))
338
+ - **design-tokens:** implement css compilation pipeline ([7bd632d](https://github.com/OrigoStudio/origo-design/commit/7bd632d))
339
+ - add script to generate automated LLM review prompts from git diffs ([1ddbd39](https://github.com/OrigoStudio/origo-design/commit/1ddbd39))
340
+ - scaffold @origo/design-tokens package with JSON schema validation and Nx configuration ([ae61244](https://github.com/OrigoStudio/origo-design/commit/ae61244))
341
+ - scaffold @origo/design-tokens library with JSON schema validation and initial token definitions ([efbecc9](https://github.com/OrigoStudio/origo-design/commit/efbecc9))
342
+ - initialize Astro documentation site and relocate internal project scripts to the tools directory. ([1cd8e71](https://github.com/OrigoStudio/origo-design/commit/1cd8e71))
343
+ - add documentation story spec and update epic-1 status to done ([b612ea3](https://github.com/OrigoStudio/origo-design/commit/b612ea3))
344
+ - initialize and populate agent skill definitions, workflows, and technical knowledge resources ([8668c52](https://github.com/OrigoStudio/origo-design/commit/8668c52))
345
+ - initialize Starlight documentation site within the monorepo and add benchmark tools ([9a16b03](https://github.com/OrigoStudio/origo-design/commit/9a16b03))
346
+ - implement performance benchmark harness with regression and SLA gate logic ([350d472](https://github.com/OrigoStudio/origo-design/commit/350d472))
347
+ - implement performance benchmark harness with CI regression gating and SLA validation ([3230ac9](https://github.com/OrigoStudio/origo-design/commit/3230ac9))
348
+ - implement Husky pre-commit hooks and Nx-based lint-staged configuration ([9181885](https://github.com/OrigoStudio/origo-design/commit/9181885))
349
+ - add GitHub Actions CI workflow, Husky pre-commit hooks, and update package.json with necessary configuration ([95b8bf1](https://github.com/OrigoStudio/origo-design/commit/95b8bf1))
350
+ - configure Husky, lint-staged, and GitHub CI workflow for automated quality enforcement ([b6bf597](https://github.com/OrigoStudio/origo-design/commit/b6bf597))
351
+ - initialize Nx monorepo workspace with core configuration and tooling ([fd0665a](https://github.com/OrigoStudio/origo-design/commit/fd0665a))
352
+ - add sprint tracking artifacts and automation script for project bootstrapping ([ddc6149](https://github.com/OrigoStudio/origo-design/commit/ddc6149))
353
+ - document Origo Design functional requirements and architectural scope ([d1e0b7f](https://github.com/OrigoStudio/origo-design/commit/d1e0b7f))
354
+
355
+ ### ❤️ Thank You
356
+
357
+ - Hardik Patel @hardikpatelse
package/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # design-tokens
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Building
6
+
7
+ Run `nx build design-tokens` to build the library.
8
+
9
+ ## Running unit tests
10
+
11
+ Run `nx test design-tokens` to execute the unit tests via [Jest](https://jestjs.io).
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@origostudio/design-tokens",
3
+ "version": "0.0.40",
4
+ "private": false,
5
+ "type": "commonjs",
6
+ "main": "./src/index.js",
7
+ "types": "./src/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./src/index.d.ts",
11
+ "default": "./src/index.js"
12
+ },
13
+ "./runtime": {
14
+ "types": "./src/runtime/index.d.ts",
15
+ "default": "./src/runtime/index.js"
16
+ },
17
+ "./tokens.css": "./tokens.css",
18
+ "./tokens.json": "./tokens.json",
19
+ "./tokens.js": "./tokens.js"
20
+ },
21
+ "dependencies": {
22
+ "ajv": "^8.20.0"
23
+ },
24
+ "devDependencies": {},
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "https://github.com/OrigoStudio/origo-design.git"
28
+ }
29
+ }
package/src/build.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export declare function parseTokens(tokens: Record<string, unknown>, prefix: string): Record<string, string>;
2
+ export declare function generateCssVariables(baseTokensMap: Record<string, string>, semanticTokensMap?: Record<string, string>): string;
package/src/build.js ADDED
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseTokens = parseTokens;
4
+ exports.generateCssVariables = generateCssVariables;
5
+ function parseTokens(tokens, prefix) {
6
+ const result = {};
7
+ function traverse(obj, currentPath) {
8
+ if (!obj || typeof obj !== 'object')
9
+ return;
10
+ for (const [key, value] of Object.entries(obj)) {
11
+ if (value && typeof value === 'object' && !Array.isArray(value)) {
12
+ if ('$value' in value) {
13
+ const sanitizedPath = currentPath.concat(key).map(k => k.replace(/[^a-zA-Z0-9-]/g, '-'));
14
+ const varName = `--${prefix}-${sanitizedPath.join('-')}`;
15
+ const tokenObj = value;
16
+ const val = tokenObj['$value'];
17
+ let valStr;
18
+ if (Array.isArray(val)) {
19
+ valStr = val.join(', ');
20
+ }
21
+ else if (typeof val === 'object' && val !== null) {
22
+ valStr = JSON.stringify(val);
23
+ }
24
+ else {
25
+ valStr = String(val);
26
+ }
27
+ result[varName] = valStr;
28
+ }
29
+ else {
30
+ traverse(value, currentPath.concat(key));
31
+ }
32
+ }
33
+ }
34
+ }
35
+ traverse(tokens, []);
36
+ let changed = true;
37
+ let iterations = 0;
38
+ const maxIterations = 10;
39
+ while (changed && iterations < maxIterations) {
40
+ changed = false;
41
+ iterations++;
42
+ for (const [key, val] of Object.entries(result)) {
43
+ if (typeof val === 'string' && val.includes('{')) {
44
+ const newVal = val.replace(/\{([^}]+)\}/g, (match, refPath) => {
45
+ if (!refPath.trim())
46
+ throw new Error('Empty reference in token');
47
+ const sanitizedRefPath = refPath
48
+ .split('.')
49
+ .map((k) => k.replace(/[^a-zA-Z0-9-]/g, '-'))
50
+ .join('-');
51
+ const refVarName = `--${prefix}-${sanitizedRefPath}`;
52
+ if (refVarName === key)
53
+ throw new Error(`Circular reference detected: ${key}`);
54
+ return `var(${refVarName})`;
55
+ });
56
+ if (newVal !== val) {
57
+ result[key] = newVal;
58
+ changed = true;
59
+ }
60
+ }
61
+ }
62
+ }
63
+ return result;
64
+ }
65
+ function generateCssVariables(baseTokensMap, semanticTokensMap) {
66
+ let css = ':root{';
67
+ const usedBaseTokens = new Set();
68
+ if (semanticTokensMap) {
69
+ for (const val of Object.values(semanticTokensMap)) {
70
+ const matches = val.match(/var\((--[^)]+)\)/g);
71
+ if (matches) {
72
+ matches.forEach(m => usedBaseTokens.add(m.slice(4, -1)));
73
+ }
74
+ }
75
+ }
76
+ for (const [key, value] of Object.entries(baseTokensMap)) {
77
+ if (!semanticTokensMap || usedBaseTokens.has(key)) {
78
+ css += `${key}:${value};`;
79
+ }
80
+ }
81
+ if (semanticTokensMap) {
82
+ for (const [key, value] of Object.entries(semanticTokensMap)) {
83
+ css += `${key}:${value};`;
84
+ }
85
+ }
86
+ css += '}';
87
+ return css;
88
+ }
89
+ //# sourceMappingURL=build.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.js","sourceRoot":"","sources":["../../../../packages/design-tokens/src/build.ts"],"names":[],"mappings":";;AAAA,kCAgEC;AAED,oDA8BC;AAhGD,SAAgB,WAAW,CACzB,MAA+B,EAC/B,MAAc;IAEd,MAAM,MAAM,GAA2B,EAAE,CAAC;IAE1C,SAAS,QAAQ,CAAC,GAAY,EAAE,WAAqB;QACnD,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ;YAAE,OAAO;QAC5C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;YAC/C,IAA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AC;IAEnB,MAAM,cAAc,GAAG,IAAI,GAAG,EAAU,CAAC;IACzC,IAAI,iBAAiB,EAAE,CAAC;QACtB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,EAAE,CAAC;YACnD,MAAM,OAAO,GAAG,GAAG,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;YAC/C,IAAI,OAAO,EAAE,CAAC;gBACZ,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAC3D,CAAC;QACH,CAAC;IACH,CAAC;IAED,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC;QACzD,IAAI,CAAC,iBAAiB,IAAI,cAAc,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YAClD,GAAG,IAAI,GAAG,GAAG,IAAI,KAAK,GAAG,CAAC;QAC5B,CAAC;IACH,CAAC;IAED,IAAI,iBAAiB,EAAE,CAAC;QACtB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,EAAE,CAAC;YAC7D,GAAG,IAAI,GAAG,GAAG,IAAI,KAAK,GAAG,CAAC;QAC5B,CAAC;IACH,CAAC;IAED,GAAG,IAAI,GAAG,CAAC;IACX,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
package/src/compile.js ADDED
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const fs_1 = require("fs");
5
+ const path_1 = require("path");
6
+ const build_1 = require("./build");
7
+ const _2020_1 = tslib_1.__importDefault(require("ajv/dist/2020"));
8
+ function loadJson(path) {
9
+ try {
10
+ return JSON.parse((0, fs_1.readFileSync)(path, 'utf8'));
11
+ }
12
+ catch (e) {
13
+ throw new Error(`Failed to read or parse JSON at ${path}: ${e.message}`);
14
+ }
15
+ }
16
+ function main() {
17
+ const baseJsonPath = (0, path_1.join)(__dirname, 'tokens/base.json');
18
+ const semanticJsonPath = (0, path_1.join)(__dirname, 'tokens/semantic.json');
19
+ const baseSchemaPath = (0, path_1.join)(__dirname, 'schemas/base-tokens.schema.json');
20
+ const semanticSchemaPath = (0, path_1.join)(__dirname, 'schemas/semantic-tokens.schema.json');
21
+ const baseJson = loadJson(baseJsonPath);
22
+ const semanticJson = loadJson(semanticJsonPath);
23
+ const baseSchema = loadJson(baseSchemaPath);
24
+ const semanticSchema = loadJson(semanticSchemaPath);
25
+ const ajv = new _2020_1.default({ allErrors: true, strict: false });
26
+ if (!ajv.validate(baseSchema, baseJson)) {
27
+ throw new Error(`Base tokens failed validation: ${ajv.errorsText()}`);
28
+ }
29
+ if (!ajv.validate(semanticSchema, semanticJson)) {
30
+ throw new Error(`Semantic tokens failed validation: ${ajv.errorsText()}`);
31
+ }
32
+ const baseTokens = (0, build_1.parseTokens)(baseJson, 'origo');
33
+ const semanticTokens = (0, build_1.parseTokens)(semanticJson, 'origo');
34
+ const css = (0, build_1.generateCssVariables)(baseTokens, semanticTokens);
35
+ const allTokens = { ...baseTokens, ...semanticTokens };
36
+ const outDir = (0, path_1.join)(__dirname, '..');
37
+ (0, fs_1.mkdirSync)(outDir, { recursive: true });
38
+ // Write CSS
39
+ (0, fs_1.writeFileSync)((0, path_1.join)(outDir, 'tokens.css'), css, 'utf8');
40
+ // Write JSON
41
+ (0, fs_1.writeFileSync)((0, path_1.join)(outDir, 'tokens.json'), JSON.stringify(allTokens, null, 2), 'utf8');
42
+ // Write JS
43
+ const jsContent = `module.exports = ${JSON.stringify(allTokens, null, 2)};`;
44
+ (0, fs_1.writeFileSync)((0, path_1.join)(outDir, 'tokens.js'), jsContent, 'utf8');
45
+ // Write TS definitions
46
+ const tsContent = `declare const tokens: Record<string, string>;\nexport default tokens;`;
47
+ (0, fs_1.writeFileSync)((0, path_1.join)(outDir, 'tokens.d.ts'), tsContent, 'utf8');
48
+ console.log(`Successfully compiled design tokens to ${outDir}`);
49
+ }
50
+ main();
51
+ //# sourceMappingURL=compile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compile.js","sourceRoot":"","sources":["../../../../packages/design-tokens/src/compile.ts"],"names":[],"mappings":";;;AAAA,2BAA4D;AAC5D,+BAA4B;AAC5B,mCAA4D;AAC5D,kEAAoC;AAEpC,SAAS,QAAQ,CAAC,IAAY;IAC5B,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAA,iBAAY,EAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;IAChD,CAAC;IAAC,OAAO,CAAU,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,mCAAmC,IAAI,KAAM,CAAW,CAAC,OAAO,EAAE,CAAC,CAAC;IACtF,CAAC;AACH,CAAC;AAED,SAAS,IAAI;IACX,MAAM,YAAY,GAAG,IAAA,WAAI,EAAC,SAAS,EAAE,kBAAkB,CAAC,CAAC;IACzD,MAAM,gBAAgB,GAAG,IAAA,WAAI,EAAC,SAAS,EAAE,sBAAsB,CAAC,CAAC;IACjE,MAAM,cAAc,GAAG,IAAA,WAAI,EAAC,SAAS,EAAE,iCAAiC,CAAC,CAAC;IAC1E,MAAM,kBAAkB,GAAG,IAAA,WAAI,EAAC,SAAS,EAAE,qCAAqC,CAAC,CAAC;IAElF,MAAM,QAAQ,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAC;IACxC,MAAM,YAAY,GAAG,QAAQ,CAAC,gBAAgB,CAAC,CAAC;IAChD,MAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,CAAC,CAAC;IAC5C,MAAM,cAAc,GAAG,QAAQ,CAAC,kBAAkB,CAAC,CAAC;IAEpD,MAAM,GAA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AS,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC;IAC5E,IAAA,kBAAa,EAAC,IAAA,WAAI,EAAC,MAAM,EAAE,WAAW,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;IAE5D,uBAAuB;IACvB,MAAM,SAAS,GAAG,uEAAuE,CAAC;IAC1F,IAAA,kBAAa,EAAC,IAAA,WAAI,EAAC,MAAM,EAAE,aAAa,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;IAE9D,OAAO,CAAC,GAAG,CAAC,0CAA0C,MAAM,EAAE,CAAC,CAAC;AAClE,CAAC;AAED,IAAI,EAAE,CAAC"}
package/src/index.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import baseTokensSchema from './schemas/base-tokens.schema.json';
2
+ import semanticTokensSchema from './schemas/semantic-tokens.schema.json';
3
+ import baseTokens from './tokens/base.json';
4
+ import semanticTokens from './tokens/semantic.json';
5
+ export * from './build';
6
+ export { baseTokensSchema, semanticTokensSchema, baseTokens, semanticTokens };
package/src/index.js ADDED
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.semanticTokens = exports.baseTokens = exports.semanticTokensSchema = exports.baseTokensSchema = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const base_tokens_schema_json_1 = tslib_1.__importDefault(require("./schemas/base-tokens.schema.json"));
6
+ exports.baseTokensSchema = base_tokens_schema_json_1.default;
7
+ const semantic_tokens_schema_json_1 = tslib_1.__importDefault(require("./schemas/semantic-tokens.schema.json"));
8
+ exports.semanticTokensSchema = semantic_tokens_schema_json_1.default;
9
+ const base_json_1 = tslib_1.__importDefault(require("./tokens/base.json"));
10
+ exports.baseTokens = base_json_1.default;
11
+ const semantic_json_1 = tslib_1.__importDefault(require("./tokens/semantic.json"));
12
+ exports.semanticTokens = semantic_json_1.default;
13
+ tslib_1.__exportStar(require("./build"), exports);
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/design-tokens/src/index.ts"],"names":[],"mappings":";;;;AAAA,wGAAiE;AAMxD,2BANF,iCAAgB,CAME;AALzB,gHAAyE;AAK9C,+BALpB,qCAAoB,CAKoB;AAJ/C,2EAA4C;AAIK,qBAJ1C,mBAAU,CAI0C;AAH3D,mFAAoD;AAGS,yBAHtD,uBAAc,CAGsD;AAD3E,kDAAwB"}
@@ -0,0 +1,2 @@
1
+ export * from './theme-injector';
2
+ export * from './theme-fetcher';
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./theme-injector"), exports);
5
+ tslib_1.__exportStar(require("./theme-fetcher"), exports);
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/design-tokens/src/runtime/index.ts"],"names":[],"mappings":";;;AAAA,2DAAiC;AACjC,0DAAgC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Fetches a theme.json file from the specified URL.
3
+ *
4
+ * - Gracefully handles SSR environments by returning an empty object.
5
+ * - Handles network errors by catching them and returning an empty object.
6
+ *
7
+ * @param url The URL to fetch the theme JSON from.
8
+ * @returns A promise that resolves to the parsed theme JSON object, or an empty object on failure/SSR.
9
+ */
10
+ export declare function fetchTheme(url: string): Promise<Record<string, unknown>>;
11
+ /**
12
+ * Fetches a theme.json file and injects it into the DOM.
13
+ * Measures the time taken using the Performance API to ensure NFR-PERF-005 limits.
14
+ *
15
+ * @param url The URL to fetch the theme JSON from.
16
+ * @param target The target HTMLElement to scope the injected styles to. Defaults to documentElement.
17
+ * @returns A promise that resolves to a teardown function to remove the injected style tag.
18
+ */
19
+ export declare function loadAndInjectTheme(url: string, target?: HTMLElement | null): Promise<() => void>;
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.fetchTheme = fetchTheme;
4
+ exports.loadAndInjectTheme = loadAndInjectTheme;
5
+ const theme_injector_1 = require("./theme-injector");
6
+ /**
7
+ * Fetches a theme.json file from the specified URL.
8
+ *
9
+ * - Gracefully handles SSR environments by returning an empty object.
10
+ * - Handles network errors by catching them and returning an empty object.
11
+ *
12
+ * @param url The URL to fetch the theme JSON from.
13
+ * @returns A promise that resolves to the parsed theme JSON object, or an empty object on failure/SSR.
14
+ */
15
+ async function fetchTheme(url) {
16
+ // SSR guard: fetch might not exist, or we are in a server environment
17
+ if (typeof fetch === 'undefined' || typeof document === 'undefined') {
18
+ return {};
19
+ }
20
+ try {
21
+ const response = await fetch(url);
22
+ if (!response.ok) {
23
+ console.warn(`[origo-design] Failed to fetch theme from ${url}: ${response.status} ${response.statusText}`);
24
+ return {};
25
+ }
26
+ const data = await response.json();
27
+ return data;
28
+ }
29
+ catch (error) {
30
+ console.warn(`[origo-design] Error fetching theme from ${url}:`, error);
31
+ return {};
32
+ }
33
+ }
34
+ const activeLoads = new Map();
35
+ let globalLoadCounter = 0;
36
+ /**
37
+ * Fetches a theme.json file and injects it into the DOM.
38
+ * Measures the time taken using the Performance API to ensure NFR-PERF-005 limits.
39
+ *
40
+ * @param url The URL to fetch the theme JSON from.
41
+ * @param target The target HTMLElement to scope the injected styles to. Defaults to documentElement.
42
+ * @returns A promise that resolves to a teardown function to remove the injected style tag.
43
+ */
44
+ async function loadAndInjectTheme(url, target) {
45
+ const loadId = ++globalLoadCounter;
46
+ const loadKey = target || 'default';
47
+ activeLoads.set(loadKey, loadId);
48
+ const perfMarkStart = `theme-load-start-${url}`;
49
+ const perfMarkEnd = `theme-load-end-${url}`;
50
+ const perfMeasure = `theme-load-measure-${url}`;
51
+ if (typeof performance !== 'undefined' && performance.mark) {
52
+ performance.mark(perfMarkStart);
53
+ }
54
+ let teardown = () => {
55
+ // default no-op teardown
56
+ };
57
+ try {
58
+ const themeJson = await fetchTheme(url);
59
+ // Concurrency Lock: abort injection if a newer call has superseded this one for the same target
60
+ if (activeLoads.get(loadKey) !== loadId) {
61
+ return teardown;
62
+ }
63
+ const injected = (0, theme_injector_1.injectTheme)(themeJson, target);
64
+ if (typeof injected === 'function') {
65
+ teardown = injected;
66
+ }
67
+ }
68
+ catch (error) {
69
+ console.warn('[origo-design] Error in loadAndInjectTheme', error);
70
+ }
71
+ finally {
72
+ if (typeof performance !== 'undefined' && performance.mark && performance.measure) {
73
+ performance.mark(perfMarkEnd);
74
+ try {
75
+ performance.measure(perfMeasure, perfMarkStart, perfMarkEnd);
76
+ }
77
+ catch {
78
+ // Ignore measure errors
79
+ }
80
+ performance.clearMarks(perfMarkStart);
81
+ performance.clearMarks(perfMarkEnd);
82
+ performance.clearMeasures(perfMeasure);
83
+ }
84
+ }
85
+ return teardown;
86
+ }
87
+ //# sourceMappingURL=theme-fetcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme-fetcher.js","sourceRoot":"","sources":["../../../../../packages/design-tokens/src/runtime/theme-fetcher.ts"],"names":[],"mappings":";;AAWA,gCAoBC;AAaD,gDA6CC;AAzFD,qDAA+C;AAE/C;;;;;;;;GAQG;AACI,KAAK,UAAU,UAAU,CAAC,GAAW;IAC1C,sEAAsE;IACtE,IAAI,OAAO,KAAK,KAAK,WAAW,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE,CAAC;QACpE,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,CAAC;QAClC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,OAAO,CAAC,IAAI,CACV,6CAA6C,GAAG,KAAK,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,EAAE,CAC9F,CAAC;YACF,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI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AC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,IAAI,CAAC,4CAA4C,EAAE,KAAK,CAAC,CAAC;IACpE,CAAC;YAAS,CAAC;QACT,IAAI,OAAO,WAAW,KAAK,WAAW,IAAI,WAAW,CAAC,IAAI,IAAI,WAAW,CAAC,OAAO,EAAE,CAAC;YAClF,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YAC9B,IAAI,CAAC;gBACH,WAAW,CAAC,OAAO,CAAC,WAAW,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC;YAC/D,CAAC;YAAC,MAAM,CAAC;gBACP,wBAAwB;YAC1B,CAAC;YACD,WAAW,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;YACtC,WAAW,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;YACpC,WAAW,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Parses and sanitises a flat or single-level-nested theme JSON object into
3
+ * a safe map of `token-key → CSS value`.
4
+ *
5
+ * - Keys are validated against a CSS identifier allowlist.
6
+ * - Values are validated against explicit CSS format patterns.
7
+ * - Prototype-poisoning keys (`__proto__`, `constructor`, `prototype`) are blocked.
8
+ * - Arrays are rejected at every nesting level.
9
+ */
10
+ export declare function parseTheme(themeJson: unknown): Record<string, string>;
11
+ export declare function injectTheme(themeJson: unknown, target?: HTMLElement | null): () => void;
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseTheme = parseTheme;
4
+ exports.injectTheme = injectTheme;
5
+ /** CSS custom property name allowlist — alphanumeric, hyphens, underscores only */
6
+ const CSS_SAFE_KEY = /^[a-zA-Z0-9_-]+$/;
7
+ /** Keys that must never be set on a plain object to prevent prototype pollution */
8
+ const BLOCKED_KEYS = new Set(['__proto__', 'constructor', 'prototype']);
9
+ /**
10
+ * Allowed CSS value patterns for semantic token overrides.
11
+ * Validates concrete formats rather than relying solely on a denylist.
12
+ */
13
+ const SAFE_VALUE_PATTERNS = [
14
+ /^#[0-9a-fA-F]{3,8}$/, // hex colors: #fff, #ffffff, #ffffffaa
15
+ /^rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+(?:\s*,\s*[\d.]+)?\s*\)$/, // rgb / rgba
16
+ /^hsla?\(\s*[\d.]+\s*,\s*[\d.]+%\s*,\s*[\d.]+%(?:\s*,\s*[\d.]+)?\s*\)$/, // hsl / hsla
17
+ /^[\d.]+(?:px|rem|em|%|vh|vw|vmin|vmax|pt|ch|ex|fr|deg|rad|turn|ms|s)$/, // numeric with units
18
+ /^[\d.]+$/, // plain numbers (opacity, z-index, line-height)
19
+ /^[a-zA-Z][-a-zA-Z0-9]*$/, // CSS named values: red, transparent, inherit, currentColor, etc.
20
+ /^var\(--[a-zA-Z0-9_-]+\)$/, // CSS variables
21
+ /^calc\([^)]+\)$/, // CSS calc
22
+ /^clamp\([^)]+\)$/, // CSS clamp
23
+ /^(?:linear|radial|conic)-gradient\([^)]+\)$/, // CSS gradients
24
+ ];
25
+ function isSafeValue(value) {
26
+ return SAFE_VALUE_PATTERNS.some(pattern => pattern.test(value.trim()));
27
+ }
28
+ /**
29
+ * Parses and sanitises a flat or single-level-nested theme JSON object into
30
+ * a safe map of `token-key → CSS value`.
31
+ *
32
+ * - Keys are validated against a CSS identifier allowlist.
33
+ * - Values are validated against explicit CSS format patterns.
34
+ * - Prototype-poisoning keys (`__proto__`, `constructor`, `prototype`) are blocked.
35
+ * - Arrays are rejected at every nesting level.
36
+ */
37
+ function parseTheme(themeJson) {
38
+ if (!themeJson || typeof themeJson !== 'object' || Array.isArray(themeJson)) {
39
+ return {};
40
+ }
41
+ // Object.create(null) avoids prototype setter side-effects for any key written
42
+ const result = Object.create(null);
43
+ const flatten = (obj, prefix = '', depth = 0, visited = new WeakSet()) => {
44
+ if (depth > 1)
45
+ return; // Prevent arbitrary depth beyond single-level
46
+ if (visited.has(obj))
47
+ return; // Prevent circular reference crashes
48
+ visited.add(obj);
49
+ for (const key of Object.keys(obj)) {
50
+ if (BLOCKED_KEYS.has(key) || !CSS_SAFE_KEY.test(key))
51
+ continue;
52
+ const value = obj[key];
53
+ if (value !== null && typeof value === 'object' && !Array.isArray(value)) {
54
+ flatten(value, `${prefix}${key}-`, depth + 1, visited);
55
+ }
56
+ else if (typeof value === 'string' || typeof value === 'number') {
57
+ const strVal = String(value).trim();
58
+ const fullKey = `${prefix}${key}`;
59
+ // Block base token overrides, enforce semantic overrides
60
+ if (!fullKey.startsWith('base-') && isSafeValue(strVal)) {
61
+ result[fullKey] = strVal;
62
+ }
63
+ }
64
+ }
65
+ };
66
+ flatten(themeJson);
67
+ return result;
68
+ }
69
+ /**
70
+ * Applies a parsed theme to the DOM by injecting a `<style>` tag into
71
+ * `document.head` scoped to the target element.
72
+ *
73
+ * - When `target` is `document.documentElement` (the default), the style block
74
+ * targets `:root` for global override.
75
+ * - When `target` is any other element, the element receives a stable
76
+ * `data-origo-theme-id` attribute and the style block is scoped to that
77
+ * attribute selector, enabling per-subtree theme isolation.
78
+ * - Passing an empty or fully-invalid theme removes the previously injected
79
+ * style tag for that target rather than leaving stale rules.
80
+ * - Safe to call in SSR environments — returns immediately if `document` is
81
+ * not defined.
82
+ */
83
+ let nextTagId = 0;
84
+ function injectTheme(themeJson, target) {
85
+ // SSR guard — DOM APIs are not available in Node.js environments
86
+ if (typeof document === 'undefined')
87
+ return () => undefined;
88
+ const actualTarget = target === undefined ? document.documentElement : target;
89
+ if (!actualTarget)
90
+ return () => undefined;
91
+ const head = document.head || document.documentElement;
92
+ if (!head)
93
+ return () => undefined;
94
+ const parsed = parseTheme(themeJson);
95
+ // Determine the CSS selector and the style-tag attribute for this target
96
+ let selector;
97
+ let tagId;
98
+ if (actualTarget === document.documentElement) {
99
+ selector = ':root';
100
+ tagId = 'runtime';
101
+ }
102
+ else {
103
+ // Assign a stable per-element ID so repeated calls reuse the same tag
104
+ if (!actualTarget.dataset['origoThemeId']) {
105
+ actualTarget.dataset['origoThemeId'] = `t${++nextTagId}`;
106
+ }
107
+ tagId = actualTarget.dataset['origoThemeId'];
108
+ selector = `[data-origo-theme-id="${CSS.escape(tagId)}"]`;
109
+ }
110
+ let styleTag = head.querySelector(`style[data-origo-theme="${CSS.escape(tagId)}"]`);
111
+ // Empty theme → remove the style tag to prevent stale overrides
112
+ if (Object.keys(parsed).length === 0) {
113
+ styleTag?.remove();
114
+ return () => undefined;
115
+ }
116
+ if (!styleTag) {
117
+ styleTag = document.createElement('style');
118
+ styleTag.setAttribute('data-origo-theme', tagId);
119
+ head.appendChild(styleTag);
120
+ }
121
+ let cssVariables = '';
122
+ for (const [key, value] of Object.entries(parsed)) {
123
+ cssVariables += ` --origo-${key}: ${value};\n`;
124
+ }
125
+ styleTag.textContent = `${selector} {\n${cssVariables}}\n`;
126
+ // Return a teardown function to clean up scoped injections
127
+ return () => {
128
+ styleTag?.remove();
129
+ };
130
+ }
131
+ //# sourceMappingURL=theme-injector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"theme-injector.js","sourceRoot":"","sources":["../../../../../packages/design-tokens/src/runtime/theme-injector.ts"],"names":[],"mappings":";;AAoCA,gCAuCC;AAkBD,kCAuDC;AApJD,mFAAmF;AACnF,MAAM,YAAY,GAAG,kBAAkB,CAAC;AAExC,mFAAmF;AACnF,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC,CAAC;AAExE;;;GAGG;AACH,MAAM,mBAAmB,GAAa;IACpC,qBAAqB,EAAE,uCAAuC;IAC9D,4DAA4D,EAAE,aAAa;IAC3E,uEAAuE,EAAE,aAAa;IACtF,uEAAuE,EAAE,qBAAqB;IAC9F,UAAU,EAAE,gDAAgD;IAC5D,yBAAyB,EAAE,kEAAkE;IAC7F,2BAA2B,EAA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AED,QAAQ,CAAC,WAAW,GAAG,GAAG,QAAQ,OAAO,YAAY,KAAK,CAAC;IAE3D,2DAA2D;IAC3D,OAAO,GAAG,EAAE;QACV,QAAQ,EAAE,MAAM,EAAE,CAAC;IACrB,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,127 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://origo.dev/schemas/base-tokens.schema.json",
4
+ "title": "Origo Base Tokens Schema",
5
+ "description": "JSON Schema for Origo Base Tokens",
6
+ "type": "object",
7
+ "patternProperties": {
8
+ "^[^$][a-zA-Z0-9_\\-]*$": {
9
+ "$ref": "#/$defs/tokenOrGroup"
10
+ }
11
+ },
12
+ "additionalProperties": false,
13
+ "$defs": {
14
+ "tokenOrGroup": {
15
+ "anyOf": [{ "$ref": "#/$defs/token" }, { "$ref": "#/$defs/tokenGroup" }]
16
+ },
17
+ "token": {
18
+ "type": "object",
19
+ "properties": {
20
+ "$value": {
21
+ "type": ["string", "number", "object", "array", "boolean"]
22
+ },
23
+ "$type": {
24
+ "type": "string",
25
+ "enum": [
26
+ "color",
27
+ "dimension",
28
+ "fontFamily",
29
+ "fontWeight",
30
+ "duration",
31
+ "cubicBezier",
32
+ "number",
33
+ "shadow",
34
+ "strokeStyle",
35
+ "border",
36
+ "transition",
37
+ "typography",
38
+ "spacing",
39
+ "borderRadius",
40
+ "elevation",
41
+ "animation",
42
+ "motion",
43
+ "breakpoints",
44
+ "opacity",
45
+ "density"
46
+ ]
47
+ },
48
+ "$description": {
49
+ "type": "string"
50
+ }
51
+ },
52
+ "required": ["$value"],
53
+ "additionalProperties": false,
54
+ "allOf": [
55
+ {
56
+ "if": { "properties": { "$type": { "const": "typography" } }, "required": ["$type"] },
57
+ "then": { "properties": { "$value": { "$ref": "#/$defs/typographyValue" } } }
58
+ },
59
+ {
60
+ "if": { "properties": { "$type": { "const": "shadow" } }, "required": ["$type"] },
61
+ "then": { "properties": { "$value": { "$ref": "#/$defs/shadowValue" } } }
62
+ },
63
+ {
64
+ "if": { "properties": { "$type": { "const": "border" } }, "required": ["$type"] },
65
+ "then": { "properties": { "$value": { "$ref": "#/$defs/borderValue" } } }
66
+ }
67
+ ]
68
+ },
69
+ "tokenGroup": {
70
+ "type": "object",
71
+ "properties": {
72
+ "$type": {
73
+ "type": "string"
74
+ },
75
+ "$description": {
76
+ "type": "string"
77
+ }
78
+ },
79
+ "patternProperties": {
80
+ "^[^$][a-zA-Z0-9_\\-]*$": {
81
+ "$ref": "#/$defs/tokenOrGroup"
82
+ }
83
+ },
84
+ "additionalProperties": false
85
+ },
86
+ "typographyValue": {
87
+ "type": "object",
88
+ "properties": {
89
+ "fontFamily": { "type": "string" },
90
+ "fontSize": { "type": ["string", "number"] },
91
+ "fontWeight": { "type": ["string", "number"] },
92
+ "letterSpacing": { "type": ["string", "number"] },
93
+ "lineHeight": { "type": ["string", "number"] }
94
+ },
95
+ "required": ["fontFamily", "fontSize"],
96
+ "additionalProperties": false
97
+ },
98
+ "shadowValue": {
99
+ "anyOf": [
100
+ { "$ref": "#/$defs/singleShadowValue" },
101
+ { "type": "array", "items": { "$ref": "#/$defs/singleShadowValue" } }
102
+ ]
103
+ },
104
+ "singleShadowValue": {
105
+ "type": "object",
106
+ "properties": {
107
+ "color": { "type": "string" },
108
+ "offsetX": { "type": ["string", "number"] },
109
+ "offsetY": { "type": ["string", "number"] },
110
+ "blur": { "type": ["string", "number"] },
111
+ "spread": { "type": ["string", "number"] }
112
+ },
113
+ "required": ["color", "offsetX", "offsetY"],
114
+ "additionalProperties": false
115
+ },
116
+ "borderValue": {
117
+ "type": "object",
118
+ "properties": {
119
+ "color": { "type": "string" },
120
+ "width": { "type": ["string", "number"] },
121
+ "style": { "type": "string" }
122
+ },
123
+ "required": ["color", "width", "style"],
124
+ "additionalProperties": false
125
+ }
126
+ }
127
+ }
@@ -0,0 +1,52 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://origo.dev/schemas/semantic-tokens.schema.json",
4
+ "title": "Origo Semantic Tokens Schema",
5
+ "description": "JSON Schema for Origo Semantic Tokens (ensures references)",
6
+ "type": "object",
7
+ "patternProperties": {
8
+ "^[^$][a-zA-Z0-9_\\-]*$": {
9
+ "$ref": "#/$defs/tokenOrGroup"
10
+ }
11
+ },
12
+ "additionalProperties": false,
13
+ "$defs": {
14
+ "tokenOrGroup": {
15
+ "anyOf": [{ "$ref": "#/$defs/token" }, { "$ref": "#/$defs/tokenGroup" }]
16
+ },
17
+ "token": {
18
+ "type": "object",
19
+ "properties": {
20
+ "$value": {
21
+ "type": "string",
22
+ "pattern": "^.*\\{[a-zA-Z0-9_\\-\\.]+\\}.*$"
23
+ },
24
+ "$type": {
25
+ "type": "string"
26
+ },
27
+ "$description": {
28
+ "type": "string"
29
+ }
30
+ },
31
+ "required": ["$value"],
32
+ "additionalProperties": false
33
+ },
34
+ "tokenGroup": {
35
+ "type": "object",
36
+ "properties": {
37
+ "$type": {
38
+ "type": "string"
39
+ },
40
+ "$description": {
41
+ "type": "string"
42
+ }
43
+ },
44
+ "patternProperties": {
45
+ "^[^$][a-zA-Z0-9_\\-]*$": {
46
+ "$ref": "#/$defs/tokenOrGroup"
47
+ }
48
+ },
49
+ "additionalProperties": false
50
+ }
51
+ }
52
+ }
@@ -0,0 +1,46 @@
1
+ {
2
+ "color": {
3
+ "base": {
4
+ "blue": {
5
+ "100": {
6
+ "$value": "#E6F0FF",
7
+ "$type": "color"
8
+ },
9
+ "500": {
10
+ "$value": "#0066FF",
11
+ "$type": "color"
12
+ },
13
+ "900": {
14
+ "$value": "#002966",
15
+ "$type": "color"
16
+ }
17
+ },
18
+ "neutral": {
19
+ "100": {
20
+ "$value": "#F5F5F5",
21
+ "$type": "color"
22
+ },
23
+ "900": {
24
+ "$value": "#1A1A1A",
25
+ "$type": "color"
26
+ }
27
+ }
28
+ }
29
+ },
30
+ "spacing": {
31
+ "base": {
32
+ "1": {
33
+ "$value": "4px",
34
+ "$type": "dimension"
35
+ },
36
+ "2": {
37
+ "$value": "8px",
38
+ "$type": "dimension"
39
+ },
40
+ "4": {
41
+ "$value": "16px",
42
+ "$type": "dimension"
43
+ }
44
+ }
45
+ }
46
+ }
@@ -0,0 +1,33 @@
1
+ {
2
+ "color": {
3
+ "surface": {
4
+ "primary": {
5
+ "$value": "{color.base.blue.500}",
6
+ "$type": "color",
7
+ "$description": "Primary surface color for main actions"
8
+ },
9
+ "background": {
10
+ "$value": "{color.base.neutral.100}",
11
+ "$type": "color"
12
+ }
13
+ },
14
+ "text": {
15
+ "primary": {
16
+ "$value": "{color.base.neutral.900}",
17
+ "$type": "color"
18
+ },
19
+ "inverse": {
20
+ "$value": "{color.base.neutral.100}",
21
+ "$type": "color"
22
+ }
23
+ }
24
+ },
25
+ "spacing": {
26
+ "container": {
27
+ "padding": {
28
+ "$value": "{spacing.base.4}",
29
+ "$type": "dimension"
30
+ }
31
+ }
32
+ }
33
+ }
package/tokens.css ADDED
@@ -0,0 +1 @@
1
+ :root{--origo-color-base-blue-500:#0066FF;--origo-color-base-neutral-100:#F5F5F5;--origo-color-base-neutral-900:#1A1A1A;--origo-spacing-base-4:16px;--origo-color-surface-primary:var(--origo-color-base-blue-500);--origo-color-surface-background:var(--origo-color-base-neutral-100);--origo-color-text-primary:var(--origo-color-base-neutral-900);--origo-color-text-inverse:var(--origo-color-base-neutral-100);--origo-spacing-container-padding:var(--origo-spacing-base-4);}
package/tokens.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ declare const tokens: Record<string, string>;
2
+ export default tokens;
package/tokens.js ADDED
@@ -0,0 +1,15 @@
1
+ module.exports = {
2
+ "--origo-color-base-blue-100": "#E6F0FF",
3
+ "--origo-color-base-blue-500": "#0066FF",
4
+ "--origo-color-base-blue-900": "#002966",
5
+ "--origo-color-base-neutral-100": "#F5F5F5",
6
+ "--origo-color-base-neutral-900": "#1A1A1A",
7
+ "--origo-spacing-base-1": "4px",
8
+ "--origo-spacing-base-2": "8px",
9
+ "--origo-spacing-base-4": "16px",
10
+ "--origo-color-surface-primary": "var(--origo-color-base-blue-500)",
11
+ "--origo-color-surface-background": "var(--origo-color-base-neutral-100)",
12
+ "--origo-color-text-primary": "var(--origo-color-base-neutral-900)",
13
+ "--origo-color-text-inverse": "var(--origo-color-base-neutral-100)",
14
+ "--origo-spacing-container-padding": "var(--origo-spacing-base-4)"
15
+ };
package/tokens.json ADDED
@@ -0,0 +1,15 @@
1
+ {
2
+ "--origo-color-base-blue-100": "#E6F0FF",
3
+ "--origo-color-base-blue-500": "#0066FF",
4
+ "--origo-color-base-blue-900": "#002966",
5
+ "--origo-color-base-neutral-100": "#F5F5F5",
6
+ "--origo-color-base-neutral-900": "#1A1A1A",
7
+ "--origo-spacing-base-1": "4px",
8
+ "--origo-spacing-base-2": "8px",
9
+ "--origo-spacing-base-4": "16px",
10
+ "--origo-color-surface-primary": "var(--origo-color-base-blue-500)",
11
+ "--origo-color-surface-background": "var(--origo-color-base-neutral-100)",
12
+ "--origo-color-text-primary": "var(--origo-color-base-neutral-900)",
13
+ "--origo-color-text-inverse": "var(--origo-color-base-neutral-100)",
14
+ "--origo-spacing-container-padding": "var(--origo-spacing-base-4)"
15
+ }