@pantoken/sd-config 0.1.4

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Danny Wahl
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,40 @@
1
+ # @pantoken/sd-config
2
+
3
+ The shared [Style Dictionary](https://styledictionary.com) setup for pantoken's native emitters. It
4
+ takes the concrete, resolved dictionary produced by `@pantoken/core`'s `toStyleDictionary()` and
5
+ builds a platform's source file (Swift, Compose, Flutter, SCSS, JSON, and Android).
6
+
7
+ Internal build tooling. Not published.
8
+
9
+ ## Usage
10
+
11
+ ```ts
12
+ import { buildPlatform, PLATFORMS } from "@pantoken/sd-config";
13
+
14
+ const file = await buildPlatform({
15
+ dictionary, // Record<name, { value, type }> from @pantoken/core.toStyleDictionary()
16
+ platform: "swift", // key of PLATFORMS
17
+ outDir: "./out",
18
+ className: "PanTokens",
19
+ });
20
+ ```
21
+
22
+ `@pantoken/swift` and `@pantoken/cli` consume this; new native platforms are added by extending the
23
+ `PLATFORMS` map — no new Style Dictionary wiring per platform. Values are fed to Style Dictionary
24
+ pre-resolved, so built-in transform groups are enough; `@tokens-studio/sd-transforms` is a dependency
25
+ for the future raw-JSON lineage.
26
+
27
+ ## API
28
+
29
+ - **`buildPlatform(options): Promise<string>`** — build a native source file for one platform via
30
+ Style Dictionary. Returns the path of the written file. Options: `dictionary`, `platform` (a
31
+ `PLATFORMS` key), `outDir`, `className` (default `PanTokens`), and `fileName` (default `Tokens`).
32
+ - **`PLATFORMS: Record<string, NativePlatform>`** — the supported platforms and their Style
33
+ Dictionary wiring: `swift`, `compose`, `flutter`, `scss`, `json`, `android-colors`, and
34
+ `android-dimens`.
35
+ - **`SdDictionary`, `NativePlatform`, `BuildPlatformOptions`** — the dictionary, platform, and option
36
+ types.
37
+
38
+ ## License
39
+
40
+ MIT
@@ -0,0 +1,36 @@
1
+ //#region src/index.d.ts
2
+ /** A flat, concrete Style Dictionary dictionary (from `@pantoken/core`'s `toStyleDictionary`). */
3
+ type SdDictionary = Record<string, {
4
+ value: string;
5
+ type: string;
6
+ }>;
7
+ /** A native platform pantoken can emit. */
8
+ interface NativePlatform {
9
+ transformGroup: string;
10
+ format: string;
11
+ ext: string;
12
+ }
13
+ /** The supported native platforms and their Style Dictionary wiring. */
14
+ declare const PLATFORMS: Record<string, NativePlatform>;
15
+ /** Options for {@link buildPlatform}. */
16
+ interface BuildPlatformOptions {
17
+ /** The concrete token dictionary. */
18
+ dictionary: SdDictionary;
19
+ /** The platform key (see {@link PLATFORMS}). */
20
+ platform: string;
21
+ /** The output directory. */
22
+ outDir: string;
23
+ /** The generated class/object name (default: `PanTokens`). */
24
+ className?: string;
25
+ /** The output file base name (default: `Tokens`). */
26
+ fileName?: string;
27
+ }
28
+ /**
29
+ * Build a native source file for one platform via Style Dictionary.
30
+ *
31
+ * @param options - {@link BuildPlatformOptions}.
32
+ * @returns The path of the written file.
33
+ */
34
+ declare function buildPlatform(options: BuildPlatformOptions): Promise<string>;
35
+ //#endregion
36
+ export { BuildPlatformOptions, NativePlatform, PLATFORMS, SdDictionary, buildPlatform };
package/dist/index.mjs ADDED
@@ -0,0 +1,86 @@
1
+ import { join } from "node:path";
2
+ import StyleDictionary from "style-dictionary";
3
+ //#region src/index.ts
4
+ /**
5
+ * Shared Style Dictionary setup for pantoken's native emitters. It takes the concrete, resolved
6
+ * dictionary produced by `@pantoken/core`'s `toStyleDictionary()` and builds a platform's source
7
+ * file (Swift now; Compose / Flutter / SCSS / JSON as they come online).
8
+ *
9
+ * `@tokens-studio/sd-transforms` is a dependency for the future raw-JSON lineage; the current path
10
+ * feeds SD pre-resolved values, so built-in transform groups are enough.
11
+ *
12
+ * @module
13
+ * @beta
14
+ */
15
+ /** The supported native platforms and their Style Dictionary wiring. */
16
+ const PLATFORMS = {
17
+ swift: {
18
+ transformGroup: "ios-swift",
19
+ format: "ios-swift/class.swift",
20
+ ext: "swift"
21
+ },
22
+ compose: {
23
+ transformGroup: "compose",
24
+ format: "compose/object",
25
+ ext: "kt"
26
+ },
27
+ flutter: {
28
+ transformGroup: "flutter",
29
+ format: "flutter/class.dart",
30
+ ext: "dart"
31
+ },
32
+ scss: {
33
+ transformGroup: "scss",
34
+ format: "scss/variables",
35
+ ext: "scss"
36
+ },
37
+ json: {
38
+ transformGroup: "js",
39
+ format: "json/flat",
40
+ ext: "json"
41
+ },
42
+ "android-colors": {
43
+ transformGroup: "android",
44
+ format: "android/colors",
45
+ ext: "xml"
46
+ },
47
+ "android-dimens": {
48
+ transformGroup: "android",
49
+ format: "android/dimens",
50
+ ext: "xml"
51
+ }
52
+ };
53
+ /**
54
+ * Build a native source file for one platform via Style Dictionary.
55
+ *
56
+ * @param options - {@link BuildPlatformOptions}.
57
+ * @returns The path of the written file.
58
+ */
59
+ async function buildPlatform(options) {
60
+ const platform = PLATFORMS[options.platform];
61
+ if (!platform) throw new Error(`Unknown pantoken native platform: ${options.platform}`);
62
+ const className = options.className ?? "PanTokens";
63
+ const fileName = options.fileName ?? "Tokens";
64
+ const buildPath = options.outDir.endsWith("/") ? options.outDir : `${options.outDir}/`;
65
+ const config = {
66
+ tokens: options.dictionary,
67
+ platforms: { [options.platform]: {
68
+ transformGroup: platform.transformGroup,
69
+ buildPath,
70
+ files: [{
71
+ destination: `${fileName}.${platform.ext}`,
72
+ format: platform.format,
73
+ options: {
74
+ className,
75
+ packageName: className,
76
+ showFileHeader: true
77
+ }
78
+ }]
79
+ } },
80
+ log: { verbosity: "silent" }
81
+ };
82
+ await new StyleDictionary(config).buildAllPlatforms();
83
+ return join(options.outDir, `${fileName}.${platform.ext}`);
84
+ }
85
+ //#endregion
86
+ export { PLATFORMS, buildPlatform };
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@pantoken/sd-config",
3
+ "version": "0.1.4",
4
+ "description": "Shared Style Dictionary setup for pantoken's native emitters (Swift, Compose, Flutter, SCSS, JSON).",
5
+ "homepage": "https://pantoken.iywahl.com",
6
+ "bugs": "https://github.com/thedannywahl/pantoken/issues",
7
+ "license": "MIT",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/thedannywahl/pantoken.git",
11
+ "directory": "tools/sd-config"
12
+ },
13
+ "files": [
14
+ "dist"
15
+ ],
16
+ "type": "module",
17
+ "sideEffects": false,
18
+ "exports": {
19
+ ".": "./dist/index.mjs",
20
+ "./package.json": "./package.json"
21
+ },
22
+ "publishConfig": {
23
+ "access": "public",
24
+ "provenance": true
25
+ },
26
+ "dependencies": {
27
+ "@pantoken/model": "0.3.1",
28
+ "@tokens-studio/sd-transforms": "^2.0.3",
29
+ "style-dictionary": "^5.5.2"
30
+ },
31
+ "devDependencies": {
32
+ "@types/node": "^26.3.0",
33
+ "typescript": "^7.0.2",
34
+ "vite": "npm:@voidzero-dev/vite-plus-core@0.3.0",
35
+ "vite-plus": "0.3.0"
36
+ },
37
+ "engines": {
38
+ "node": ">=22.18.0"
39
+ },
40
+ "scripts": {
41
+ "dev": "vp pack --watch",
42
+ "test": "vp test",
43
+ "check": "vp check"
44
+ }
45
+ }