@terrazzo/plugin-js 2.0.0-alpha.0 → 2.0.0-alpha.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 +15 -0
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @terrazzo/plugin-js
|
|
2
2
|
|
|
3
|
+
## 2.0.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#530](https://github.com/terrazzoapp/terrazzo/pull/530) [`370ed7b`](https://github.com/terrazzoapp/terrazzo/commit/370ed7b0f578a64824124145d7f4936536b37bb3) Thanks [@drwpow](https://github.com/drwpow)! - ⚠️ Breaking change: lint on plugins no longer runs on individual files, rather, the full set once merged.
|
|
8
|
+
|
|
9
|
+
If your lint plugin is not using the `src` context value, no changes are needed. If it is, you’ll need to instead read from the `sources` array, and look up sources with a token’s `source.loc` filename manually. This change was because lint rules now run on all files in one pass, essentially.
|
|
10
|
+
|
|
11
|
+
- [#530](https://github.com/terrazzoapp/terrazzo/pull/530) [`370ed7b`](https://github.com/terrazzoapp/terrazzo/commit/370ed7b0f578a64824124145d7f4936536b37bb3) Thanks [@drwpow](https://github.com/drwpow)! - ⚠️ [Plugin API] Minor breaking change: token.originalValue may be undefined for tokens created with $ref. This shouldn’t affect any tokens or plugins not using $refs. But going forward this value will be missing if the token was created dynamically via $ref.
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#530](https://github.com/terrazzoapp/terrazzo/pull/530) [`370ed7b`](https://github.com/terrazzoapp/terrazzo/commit/370ed7b0f578a64824124145d7f4936536b37bb3) Thanks [@drwpow](https://github.com/drwpow)! - Validation moved to lint rules, which means token validation can be individually configured, and optionally extended.
|
|
16
|
+
- [#553](https://github.com/terrazzoapp/terrazzo/pull/553) [`e63a627`](https://github.com/terrazzoapp/terrazzo/commit/e63a6277f61282fb608744a8348689b16f977076) Thanks [@Sidnioulz](https://github.com/Sidnioulz)! - Add support for the Token Listing format
|
|
17
|
+
|
|
3
18
|
## 0.10.3
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -104,7 +104,8 @@ function pluginJS(options) {
|
|
|
104
104
|
setTransform(id, {
|
|
105
105
|
format: FORMAT_JS_ID,
|
|
106
106
|
value: transformedValue$1,
|
|
107
|
-
mode
|
|
107
|
+
mode,
|
|
108
|
+
meta: { "token-listing": { name: `tokens.${id}` } }
|
|
108
109
|
});
|
|
109
110
|
continue;
|
|
110
111
|
}
|
|
@@ -116,7 +117,8 @@ function pluginJS(options) {
|
|
|
116
117
|
if (transformedValue !== void 0) setTransform(id, {
|
|
117
118
|
format: FORMAT_JS_ID,
|
|
118
119
|
value: transformedValue,
|
|
119
|
-
mode
|
|
120
|
+
mode,
|
|
121
|
+
meta: { "token-listing": { name: `tokens.${id}` } }
|
|
120
122
|
});
|
|
121
123
|
}
|
|
122
124
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["TYPE_MAP: Record<Token['$type'], string>","output: string[]","tokenVals: Record<string, Record<string, string>>","transformedValue"],"sources":["../../token-tools/dist/js.js","../src/lib.ts","../src/build.ts","../src/index.ts"],"sourcesContent":["//#region src/js/index.ts\n/**\n* Convert token value to a JS string via acorn/astring.\n*/\nfunction transformJSValue(token, { mode, indent = 2, startingIndent = 0 }) {\n\tif (!(mode in token.mode)) return;\n\tconst indentStart = startingIndent > 0 ? \" \".repeat(startingIndent ?? 2) : \"\";\n\treturn JSON.stringify(token.mode[mode].$value, void 0, indent).replace(/\\n/g, `\\n${indentStart}`);\n}\n\n//#endregion\nexport { transformJSValue };\n//# sourceMappingURL=js.js.map","import type { Token, TokenNormalized, TokenTransformed } from '@terrazzo/parser';\n\nexport const FORMAT_JS_ID = 'js';\nexport const FORMAT_DTS_ID = 'd.ts';\n\nexport interface JSPluginOptions {\n /**\n * Output JS?\n * @default true\n */\n js?: boolean | string;\n /** Output JSON?\n * @default false\n */\n json?: boolean | string;\n /** Exclude token IDs from output? */\n exclude?: string[];\n /**\n * Return deeply-nested values?\n * @default: false\n */\n deep?: boolean;\n /** Override certain token values */\n transform?: (token: TokenNormalized, mode: string) => TokenTransformed['value'];\n}\n\nexport const FILE_HEADER = `/** ------------------------------------------\n * Autogenerated by ⛋ Terrazzo. DO NOT EDIT!\n * ------------------------------------------- */`;\n\nexport const TYPE_MAP: Record<Token['$type'], string> = {\n boolean: 'BooleanTokenNormalized',\n border: 'BorderTokenNormalized',\n color: 'ColorTokenNormalized',\n cubicBezier: 'CubicBezierTokenNormalized',\n dimension: 'DimensionTokenNormalized',\n duration: 'DurationTokenNormalized',\n fontFamily: 'FontFamilyTokenNormalized',\n fontWeight: 'FontWeightTokenNormalized',\n gradient: 'GradientTokenNormalized',\n link: 'LinkTokenNormalized',\n number: 'NumberTokenNormalized',\n shadow: 'ShadowTokenNormalized',\n string: 'StringTokenNormalized',\n strokeStyle: 'StrokeStyleTokenNormalized',\n typography: 'TypographyTokenNormalized',\n transition: 'TransitionTokenNormalized',\n};\n","import type { BuildHookOptions } from '@terrazzo/parser';\nimport { FILE_HEADER, FORMAT_DTS_ID, FORMAT_JS_ID, TYPE_MAP } from './lib.js';\n\nexport function buildJS({ getTransforms }: { getTransforms: BuildHookOptions['getTransforms'] }): string {\n const output: string[] = [FILE_HEADER, ''];\n\n // gather vals\n const tokenVals: Record<string, Record<string, string>> = {};\n for (const token of getTransforms({ format: FORMAT_JS_ID, id: '*' })) {\n if (!tokenVals[token.token.id]) {\n tokenVals[token.token.id] = {};\n }\n tokenVals[token.token.id]![token.mode] = token.value as string;\n }\n\n // body\n output.push('export const tokens = {');\n for (const [id, tokenValue] of Object.entries(tokenVals)) {\n output.push(` \"${id}\": {`);\n for (const [mode, modeValue] of Object.entries(tokenValue)) {\n output.push(` \"${mode}\": ${modeValue},`);\n }\n output.push(' },');\n }\n output.push('};', '');\n\n // footer\n output.push(\n `/** Get individual token */\nexport function token(tokenID, modeName = \".\") {\n return tokens[tokenID]?.[modeName];\n}`,\n '',\n );\n\n return output.join('\\n');\n}\n\nexport function buildDTS({ getTransforms }: { getTransforms: BuildHookOptions['getTransforms'] }): string {\n const output: string[] = [FILE_HEADER, ''];\n\n const importDeps = new Set<string>();\n const types = getTransforms({ format: FORMAT_DTS_ID, id: '*', mode: '.' }).map((t) => {\n importDeps.add(TYPE_MAP[t.token.$type]); // collect only necessary types\n if (t.type === 'MULTI_VALUE') {\n const description = t.value.description ? ` /** ${t.value.description} */\\n` : '';\n return `${description} \"${t.token.id}\": ${t.value.value};`;\n }\n return `\"${t.token.id}\": ${t.value};`;\n });\n\n output.push(\n 'import type {',\n ...[...importDeps].sort((a, b) => a.localeCompare(b)).map((dep) => ` ${dep},`),\n '} from \"@terrazzo/parser\";',\n '',\n 'export declare const tokens: {',\n ...types,\n '};',\n '',\n `export declare function token<K extends keyof typeof tokens>(tokenID: K, modeName?: never): (typeof tokens)[K][\".\"];\nexport declare function token<K extends keyof typeof tokens, M extends keyof (typeof tokens)[K]>(tokenID: K, modeName: M): (typeof tokens)[K][M];`,\n '',\n );\n\n return output.join('\\n');\n}\n","import type { Plugin } from '@terrazzo/parser';\nimport { transformJSValue } from '@terrazzo/token-tools/js';\nimport { buildDTS, buildJS } from './build.js';\nimport { FORMAT_DTS_ID, FORMAT_JS_ID, type JSPluginOptions, TYPE_MAP } from './lib.js';\n\nexport * from './build.js';\nexport * from './lib.js';\n\nexport default function pluginJS(options?: JSPluginOptions): Plugin {\n const customTransform = options?.transform;\n\n return {\n name: '@terrazzo/plugin-js',\n async transform({ tokens, getTransforms, setTransform }) {\n // skip work if another .js plugin has already run\n const jsTokens = getTransforms({ format: FORMAT_JS_ID, id: '*', mode: '.' });\n if (jsTokens.length) {\n return;\n }\n\n for (const [id, token] of Object.entries(tokens)) {\n // .d.ts (only default \".\" mode needed)\n setTransform(id, {\n format: FORMAT_DTS_ID,\n value: {\n description: token.$description ? String(token.$description) : '',\n value: `Record<\"${Object.keys(token.mode).join('\" | \"')}\", ${TYPE_MAP[token.$type]}[\"$value\"]>`,\n },\n mode: '.',\n });\n\n // .js (all modes)\n for (const mode of Object.keys(token.mode)) {\n if (customTransform) {\n const transformedValue = customTransform(token, mode);\n if (transformedValue !== undefined && transformedValue !== null) {\n setTransform(id, { format: FORMAT_JS_ID, value: transformedValue, mode });\n continue;\n }\n }\n const transformedValue = transformJSValue(token, { mode, startingIndent: 4 });\n if (transformedValue !== undefined) {\n setTransform(id, { format: FORMAT_JS_ID, value: transformedValue, mode });\n }\n }\n }\n },\n async build({ getTransforms, outputFile }) {\n // if (options?.json) {\n // const contents = buildJSON({ getTransforms });\n // outputFile(typeof options?.json === 'string' ? options.json : 'index.json', contents);\n // }\n if (options?.js) {\n const js = buildJS({ getTransforms });\n const jsFilename = typeof options?.js === 'string' ? options.js : 'index.js';\n outputFile(jsFilename, js);\n\n const dts = buildDTS({ getTransforms });\n const dtsFilename = typeof options?.js === 'string' ? options.js.replace(/\\.js$/, '.d.ts') : 'index.d.ts';\n outputFile(dtsFilename, dts);\n }\n },\n };\n}\n"],"mappings":";;;;AAIA,SAAS,iBAAiB,OAAO,EAAE,MAAM,SAAS,GAAG,iBAAiB,KAAK;AAC1E,KAAI,EAAE,QAAQ,MAAM,MAAO;CAC3B,MAAM,cAAc,iBAAiB,IAAI,IAAI,OAAO,kBAAkB,EAAE,GAAG;AAC3E,QAAO,KAAK,UAAU,MAAM,KAAK,MAAM,QAAQ,KAAK,GAAG,OAAO,CAAC,QAAQ,OAAO,KAAK,cAAc;;;;;ACLlG,MAAa,eAAe;AAC5B,MAAa,gBAAgB;AAuB7B,MAAa,cAAc;;;AAI3B,MAAaA,WAA2C;CACtD,SAAS;CACT,QAAQ;CACR,OAAO;CACP,aAAa;CACb,WAAW;CACX,UAAU;CAC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AAK;AAClE,eAAW,YAAY,GAAG;IAE1B,MAAM,MAAM,SAAS,EAAE,eAAe,CAAC;IACvC,MAAM,cAAc,OAAO,SAAS,OAAO,WAAW,QAAQ,GAAG,QAAQ,SAAS,QAAQ,GAAG;AAC7F,eAAW,aAAa,IAAI;;;EAGjC"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["TYPE_MAP: Record<Token['$type'], string>","output: string[]","tokenVals: Record<string, Record<string, string>>","transformedValue"],"sources":["../../token-tools/dist/js.js","../src/lib.ts","../src/build.ts","../src/index.ts"],"sourcesContent":["//#region src/js/index.ts\n/**\n* Convert token value to a JS string via acorn/astring.\n*/\nfunction transformJSValue(token, { mode, indent = 2, startingIndent = 0 }) {\n\tif (!(mode in token.mode)) return;\n\tconst indentStart = startingIndent > 0 ? \" \".repeat(startingIndent ?? 2) : \"\";\n\treturn JSON.stringify(token.mode[mode].$value, void 0, indent).replace(/\\n/g, `\\n${indentStart}`);\n}\n\n//#endregion\nexport { transformJSValue };\n//# sourceMappingURL=js.js.map","import type { Token, TokenNormalized, TokenTransformed } from '@terrazzo/parser';\n\nexport const FORMAT_JS_ID = 'js';\nexport const FORMAT_DTS_ID = 'd.ts';\n\nexport interface JSPluginOptions {\n /**\n * Output JS?\n * @default true\n */\n js?: boolean | string;\n /** Output JSON?\n * @default false\n */\n json?: boolean | string;\n /** Exclude token IDs from output? */\n exclude?: string[];\n /**\n * Return deeply-nested values?\n * @default: false\n */\n deep?: boolean;\n /** Override certain token values */\n transform?: (token: TokenNormalized, mode: string) => TokenTransformed['value'];\n}\n\nexport const FILE_HEADER = `/** ------------------------------------------\n * Autogenerated by ⛋ Terrazzo. DO NOT EDIT!\n * ------------------------------------------- */`;\n\nexport const TYPE_MAP: Record<Token['$type'], string> = {\n boolean: 'BooleanTokenNormalized',\n border: 'BorderTokenNormalized',\n color: 'ColorTokenNormalized',\n cubicBezier: 'CubicBezierTokenNormalized',\n dimension: 'DimensionTokenNormalized',\n duration: 'DurationTokenNormalized',\n fontFamily: 'FontFamilyTokenNormalized',\n fontWeight: 'FontWeightTokenNormalized',\n gradient: 'GradientTokenNormalized',\n link: 'LinkTokenNormalized',\n number: 'NumberTokenNormalized',\n shadow: 'ShadowTokenNormalized',\n string: 'StringTokenNormalized',\n strokeStyle: 'StrokeStyleTokenNormalized',\n typography: 'TypographyTokenNormalized',\n transition: 'TransitionTokenNormalized',\n};\n","import type { BuildHookOptions } from '@terrazzo/parser';\nimport { FILE_HEADER, FORMAT_DTS_ID, FORMAT_JS_ID, TYPE_MAP } from './lib.js';\n\nexport function buildJS({ getTransforms }: { getTransforms: BuildHookOptions['getTransforms'] }): string {\n const output: string[] = [FILE_HEADER, ''];\n\n // gather vals\n const tokenVals: Record<string, Record<string, string>> = {};\n for (const token of getTransforms({ format: FORMAT_JS_ID, id: '*' })) {\n if (!tokenVals[token.token.id]) {\n tokenVals[token.token.id] = {};\n }\n tokenVals[token.token.id]![token.mode] = token.value as string;\n }\n\n // body\n output.push('export const tokens = {');\n for (const [id, tokenValue] of Object.entries(tokenVals)) {\n output.push(` \"${id}\": {`);\n for (const [mode, modeValue] of Object.entries(tokenValue)) {\n output.push(` \"${mode}\": ${modeValue},`);\n }\n output.push(' },');\n }\n output.push('};', '');\n\n // footer\n output.push(\n `/** Get individual token */\nexport function token(tokenID, modeName = \".\") {\n return tokens[tokenID]?.[modeName];\n}`,\n '',\n );\n\n return output.join('\\n');\n}\n\nexport function buildDTS({ getTransforms }: { getTransforms: BuildHookOptions['getTransforms'] }): string {\n const output: string[] = [FILE_HEADER, ''];\n\n const importDeps = new Set<string>();\n const types = getTransforms({ format: FORMAT_DTS_ID, id: '*', mode: '.' }).map((t) => {\n importDeps.add(TYPE_MAP[t.token.$type]); // collect only necessary types\n if (t.type === 'MULTI_VALUE') {\n const description = t.value.description ? ` /** ${t.value.description} */\\n` : '';\n return `${description} \"${t.token.id}\": ${t.value.value};`;\n }\n return `\"${t.token.id}\": ${t.value};`;\n });\n\n output.push(\n 'import type {',\n ...[...importDeps].sort((a, b) => a.localeCompare(b)).map((dep) => ` ${dep},`),\n '} from \"@terrazzo/parser\";',\n '',\n 'export declare const tokens: {',\n ...types,\n '};',\n '',\n `export declare function token<K extends keyof typeof tokens>(tokenID: K, modeName?: never): (typeof tokens)[K][\".\"];\nexport declare function token<K extends keyof typeof tokens, M extends keyof (typeof tokens)[K]>(tokenID: K, modeName: M): (typeof tokens)[K][M];`,\n '',\n );\n\n return output.join('\\n');\n}\n","import type { Plugin } from '@terrazzo/parser';\nimport { transformJSValue } from '@terrazzo/token-tools/js';\nimport { buildDTS, buildJS } from './build.js';\nimport { FORMAT_DTS_ID, FORMAT_JS_ID, type JSPluginOptions, TYPE_MAP } from './lib.js';\n\nexport * from './build.js';\nexport * from './lib.js';\n\nexport default function pluginJS(options?: JSPluginOptions): Plugin {\n const customTransform = options?.transform;\n\n return {\n name: '@terrazzo/plugin-js',\n async transform({ tokens, getTransforms, setTransform }) {\n // skip work if another .js plugin has already run\n const jsTokens = getTransforms({ format: FORMAT_JS_ID, id: '*', mode: '.' });\n if (jsTokens.length) {\n return;\n }\n\n for (const [id, token] of Object.entries(tokens)) {\n // .d.ts (only default \".\" mode needed)\n setTransform(id, {\n format: FORMAT_DTS_ID,\n value: {\n description: token.$description ? String(token.$description) : '',\n value: `Record<\"${Object.keys(token.mode).join('\" | \"')}\", ${TYPE_MAP[token.$type]}[\"$value\"]>`,\n },\n mode: '.',\n });\n\n // .js (all modes)\n for (const mode of Object.keys(token.mode)) {\n if (customTransform) {\n const transformedValue = customTransform(token, mode);\n if (transformedValue !== undefined && transformedValue !== null) {\n setTransform(id, {\n format: FORMAT_JS_ID,\n value: transformedValue,\n mode,\n meta: { 'token-listing': { name: `tokens.${id}` } },\n });\n continue;\n }\n }\n const transformedValue = transformJSValue(token, { mode, startingIndent: 4 });\n if (transformedValue !== undefined) {\n setTransform(id, {\n format: FORMAT_JS_ID,\n value: transformedValue,\n mode,\n meta: { 'token-listing': { name: `tokens.${id}` } },\n });\n }\n }\n }\n },\n async build({ getTransforms, outputFile }) {\n // if (options?.json) {\n // const contents = buildJSON({ getTransforms });\n // outputFile(typeof options?.json === 'string' ? options.json : 'index.json', contents);\n // }\n if (options?.js) {\n const js = buildJS({ getTransforms });\n const jsFilename = typeof options?.js === 'string' ? options.js : 'index.js';\n outputFile(jsFilename, js);\n\n const dts = buildDTS({ getTransforms });\n const dtsFilename = typeof options?.js === 'string' ? options.js.replace(/\\.js$/, '.d.ts') : 'index.d.ts';\n outputFile(dtsFilename, dts);\n }\n },\n };\n}\n"],"mappings":";;;;AAIA,SAAS,iBAAiB,OAAO,EAAE,MAAM,SAAS,GAAG,iBAAiB,KAAK;AAC1E,KAAI,EAAE,QAAQ,MAAM,MAAO;CAC3B,MAAM,cAAc,iBAAiB,IAAI,IAAI,OAAO,kBAAkB,EAAE,GAAG;AAC3E,QAAO,KAAK,UAAU,MAAM,KAAK,MAAM,QAAQ,KAAK,GAAG,OAAO,CAAC,QAAQ,OAAO,KAAK,cAAc;;;;;ACLlG,MAAa,eAAe;AAC5B,MAAa,gBAAgB;AAuB7B,MAAa,cAAc;;;AAI3B,MAAaA,WAA2C;CACtD,SAAS;CACT,QAAQ;CACR,OAAO;CACP,aAAa;CACb,WAAW;CACX,UAAU;CACV,YAAY;CACZ,YAAY;CACZ,UAAU;CACV,MAAM;CACN,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,aAAa;CACb,YAAY;CACZ,YAAY;CACb;;;;AC5CD,SAAgB,QAAQ,EAAE,iBAA+E;CACvG,MAAMC,SAAmB,CAAC,aAAa,GAAG;CAG1C,MAAMC,YAAoD,EAAE;AAC5D,MAAK,MAAM,SAAS,cAAc;EAAE,QAAQ;EAAc,IAAI;EAAK,CAAC,EAAE;AACpE,MAAI,CAAC,UAAU,MAAM,MAAM,IACzB,WAAU,MAAM,MAAM,MAAM,EAAE;AAEhC,YAAU,MAAM,MAAM,IAAK,MAAM,QAAQ,MAAM;;AAIjD,QAAO,KAAK,0B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|
4
4
|
"description": "Generate JS, TS, and JSON from your DTCG design tokens JSON.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -28,15 +28,15 @@
|
|
|
28
28
|
"directory": "./packages/plugin-js/"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@terrazzo/cli": "^2.0.0-alpha.
|
|
31
|
+
"@terrazzo/cli": "^2.0.0-alpha.1"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@terrazzo/token-tools": "^2.0.0-alpha.
|
|
34
|
+
"@terrazzo/token-tools": "^2.0.0-alpha.1"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"dtcg-examples": "^0.3.4",
|
|
38
|
-
"@terrazzo/
|
|
39
|
-
"@terrazzo/
|
|
38
|
+
"@terrazzo/parser": "^2.0.0-alpha.1",
|
|
39
|
+
"@terrazzo/cli": "^2.0.0-alpha.1"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"build": "rolldown -c && attw --profile esm-only --pack .",
|