@canonical/token-types 0.1.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,9 @@
1
+ /**
2
+ * Canonical artifact types — the JSON contract between the Terrazzo CSS plugin
3
+ * (producer) and the LSP (consumer).
4
+ *
5
+ * This is the single source of truth. Both `@canonical/terrazzo-plugin-css` and
6
+ * `@canonical/terrazzo-lsp` import from this package.
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/artifact/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Canonical artifact types — the JSON contract between the Terrazzo CSS plugin
3
+ * (producer) and the LSP (consumer).
4
+ *
5
+ * This is the single source of truth. Both `@canonical/terrazzo-plugin-css` and
6
+ * `@canonical/terrazzo-lsp` import from this package.
7
+ */
8
+ /** Tier classification for a token. */
9
+ export type TokenTier = "primitive" | "semantic" | "derived";
10
+ /** Derivation formula kind for derived-tier tokens. */
11
+ export type DerivationKind = "hover" | "active" | "disabled" | "delta" | "channel-modifier" | "channel-surface";
12
+ /** An at-rule context surrounding a declaration (e.g. `@layer ds.modifiers`). */
13
+ export interface ArtifactAtRule {
14
+ /** At-rule name (e.g. "layer", "media"). */
15
+ name: string;
16
+ /** At-rule prelude (e.g. "ds.modifiers", "(prefers-color-scheme: dark)"). */
17
+ prelude: string;
18
+ }
19
+ /** A declaration site for an artifact token. */
20
+ export interface ArtifactDeclaration {
21
+ /** CSS selector (e.g. ":root", ".warning", "*"). */
22
+ selector: string;
23
+ /** CSS output file (e.g. "modifiers.theme.css"). */
24
+ file: string;
25
+ /** 0-indexed line number in the CSS output file. */
26
+ line: number;
27
+ /** Enclosing at-rules, innermost-first (e.g. `@layer`, `@media`). */
28
+ atRules?: ArtifactAtRule[];
29
+ }
30
+ /** A single token entry in the artifact JSON. */
31
+ export interface ArtifactToken {
32
+ /** CSS custom property name as emitted. */
33
+ cssVar: string;
34
+ /** DTCG token ID from source, or `null` for derived tokens. */
35
+ id: string | null;
36
+ /** DTCG $type. */
37
+ type: string;
38
+ /** Token tier classification. */
39
+ tier: TokenTier;
40
+ /** DTCG $description. */
41
+ description?: string;
42
+ /** Full alias resolution chain (token IDs). */
43
+ aliasChain?: string[];
44
+ /** Resolved CSS value (mode-invariant tokens). */
45
+ value?: string;
46
+ /** Light-mode resolved CSS value. */
47
+ valueLight?: string;
48
+ /** Dark-mode resolved CSS value. */
49
+ valueDark?: string;
50
+ /** `true` when valueLight !== valueDark. */
51
+ isPaired: boolean;
52
+ /** DTCG source file path (relative). */
53
+ sourceFile?: string;
54
+ /** Line number in the DTCG source file. */
55
+ sourceLine?: number;
56
+ /** CSS output file containing this token's declaration. */
57
+ cssOutputFile: string;
58
+ /** 0-indexed line number in the CSS output file (legacy, prefer `declarations`). */
59
+ cssOutputLine?: number;
60
+ /** Declaration sites: where this token is provided in the CSS output. */
61
+ declarations?: ArtifactDeclaration[];
62
+ /** CSS var name of the source token (derived tier). */
63
+ derivedFrom?: string;
64
+ /** Formula kind (derived tier). */
65
+ derivation?: DerivationKind;
66
+ /** `true` when the token has a CSS `@property` registration. */
67
+ registered?: boolean;
68
+ /** `@property` syntax (e.g. `"<color>"`). */
69
+ syntax?: string | null;
70
+ /** `@property` inherits flag. */
71
+ inherits?: boolean | null;
72
+ /** `@property` initial-value. */
73
+ initialValue?: string | null;
74
+ /** DTCG $extensions passthrough. */
75
+ extensions?: Record<string, unknown>;
76
+ }
77
+ /** The complete artifact: CSS variable name → token metadata. */
78
+ export type Artifact = Record<string, ArtifactToken>;
79
+ /**
80
+ * Wrapped artifact format (supports legacy/spec envelope).
81
+ * The plugin may emit either flat or wrapped.
82
+ */
83
+ export type ArtifactEnvelope = Artifact | {
84
+ version: string;
85
+ generator: string;
86
+ tokens: Artifact;
87
+ };
88
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/artifact/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,uCAAuC;AACvC,MAAM,MAAM,SAAS,GAAG,WAAW,GAAG,UAAU,GAAG,SAAS,CAAC;AAE7D,uDAAuD;AACvD,MAAM,MAAM,cAAc,GACtB,OAAO,GACP,QAAQ,GACR,UAAU,GACV,OAAO,GACP,kBAAkB,GAClB,iBAAiB,CAAC;AAMtB,iFAAiF;AACjF,MAAM,WAAW,cAAc;IAC7B,4CAA4C;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,6EAA6E;IAC7E,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,gDAAgD;AAChD,MAAM,WAAW,mBAAmB;IAClC,oDAAoD;IACpD,QAAQ,EAAE,MAAM,CAAC;IACjB,oDAAoD;IACpD,IAAI,EAAE,MAAM,CAAC;IACb,oDAAoD;IACpD,IAAI,EAAE,MAAM,CAAC;IACb,qEAAqE;IACrE,OAAO,CAAC,EAAE,cAAc,EAAE,CAAC;CAC5B;AAMD,iDAAiD;AACjD,MAAM,WAAW,aAAa;IAC5B,2CAA2C;IAC3C,MAAM,EAAE,MAAM,CAAC;IAEf,+DAA+D;IAC/D,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAElB,kBAAkB;IAClB,IAAI,EAAE,MAAM,CAAC;IAEb,iCAAiC;IACjC,IAAI,EAAE,SAAS,CAAC;IAEhB,yBAAyB;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,+CAA+C;IAC/C,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IAEtB,kDAAkD;IAClD,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,qCAAqC;IACrC,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,oCAAoC;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,4CAA4C;IAC5C,QAAQ,EAAE,OAAO,CAAC;IAElB,wCAAwC;IACxC,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,2CAA2C;IAC3C,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,2DAA2D;IAC3D,aAAa,EAAE,MAAM,CAAC;IAEtB,oFAAoF;IACpF,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB,yEAAyE;IACzE,YAAY,CAAC,EAAE,mBAAmB,EAAE,CAAC;IAIrC,uDAAuD;IACvD,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,mCAAmC;IACnC,UAAU,CAAC,EAAE,cAAc,CAAC;IAI5B,gEAAgE;IAChE,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB,6CAA6C;IAC7C,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAEvB,iCAAiC;IACjC,QAAQ,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAE1B,iCAAiC;IACjC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAE7B,oCAAoC;IACpC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC;AAMD,iEAAiE;AACjE,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;AAErD;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GACxB,QAAQ,GACR;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,QAAQ,CAAA;CAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export type { Artifact, ArtifactAtRule, ArtifactDeclaration, ArtifactEnvelope, ArtifactToken, DerivationKind, TokenTier, } from "./artifact/types.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,QAAQ,EACR,cAAc,EACd,mBAAmB,EACnB,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,SAAS,GACV,MAAM,qBAAqB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@canonical/token-types",
3
+ "version": "0.1.0",
4
+ "description": "Shared types for Canonical design token tooling.",
5
+ "type": "module",
6
+ "license": "LGPL-3.0",
7
+ "author": {
8
+ "email": "webteam@canonical.com",
9
+ "name": "Canonical Webteam"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://github.com/canonical/design-tokens"
14
+ },
15
+ "bugs": {
16
+ "url": "https://github.com/canonical/design-tokens/issues"
17
+ },
18
+ "homepage": "https://github.com/canonical/design-tokens#readme",
19
+ "engines": {
20
+ "bun": ">=1.3",
21
+ "node": ">=22"
22
+ },
23
+ "keywords": [
24
+ "design-tokens",
25
+ "typescript",
26
+ "canonical",
27
+ "dtcg"
28
+ ],
29
+ "main": "dist/esm/index.js",
30
+ "module": "dist/esm/index.js",
31
+ "types": "dist/types/index.d.ts",
32
+ "files": [
33
+ "dist"
34
+ ],
35
+ "scripts": {
36
+ "build": "tsc -p tsconfig.build.json",
37
+ "check": "bun run check:ts",
38
+ "check:ts": "tsc --noEmit"
39
+ },
40
+ "devDependencies": {
41
+ "@canonical/typescript-config-base": "^0.10.0-experimental.4",
42
+ "typescript": "^5.9.3"
43
+ }
44
+ }