@o3r/design 9.6.0-rc.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.
Files changed (143) hide show
  1. package/LICENSE +26 -0
  2. package/README.md +51 -0
  3. package/builders/generate-css/index.d.ts +8 -0
  4. package/builders/generate-css/index.d.ts.map +1 -0
  5. package/builders/generate-css/index.js +119 -0
  6. package/builders/generate-css/index.js.map +1 -0
  7. package/builders/generate-css/schema.d.ts +32 -0
  8. package/builders/generate-css/schema.d.ts.map +1 -0
  9. package/builders/generate-css/schema.js +3 -0
  10. package/builders/generate-css/schema.js.map +1 -0
  11. package/builders/generate-css/schema.json +68 -0
  12. package/builders/package.json +3 -0
  13. package/builders.json +10 -0
  14. package/cli/generate-css-from-design-token.cli.cjs +33 -0
  15. package/cli/generate-css-from-design-token.cli.cjs.map +1 -0
  16. package/cli/generate-css-from-design-token.cli.d.cts +3 -0
  17. package/cli/generate-css-from-design-token.cli.d.cts.map +1 -0
  18. package/collection.json +24 -0
  19. package/migration.json +5 -0
  20. package/package.json +206 -0
  21. package/schemas/design-token.schema.json +546 -0
  22. package/schematics/ extract-token/index.d.ts +8 -0
  23. package/schematics/ extract-token/index.d.ts.map +1 -0
  24. package/schematics/ extract-token/index.js +90 -0
  25. package/schematics/ extract-token/index.js.map +1 -0
  26. package/schematics/ extract-token/schema.d.ts +14 -0
  27. package/schematics/ extract-token/schema.d.ts.map +1 -0
  28. package/schematics/ extract-token/schema.js +3 -0
  29. package/schematics/ extract-token/schema.js.map +1 -0
  30. package/schematics/ extract-token/schema.json +43 -0
  31. package/schematics/generate-css/index.d.ts +8 -0
  32. package/schematics/generate-css/index.d.ts.map +1 -0
  33. package/schematics/generate-css/index.js +54 -0
  34. package/schematics/generate-css/index.js.map +1 -0
  35. package/schematics/generate-css/schema.d.ts +17 -0
  36. package/schematics/generate-css/schema.d.ts.map +1 -0
  37. package/schematics/generate-css/schema.js +3 -0
  38. package/schematics/generate-css/schema.js.map +1 -0
  39. package/schematics/generate-css/schema.json +43 -0
  40. package/schematics/ng-add/index.d.ts +7 -0
  41. package/schematics/ng-add/index.d.ts.map +1 -0
  42. package/schematics/ng-add/index.js +19 -0
  43. package/schematics/ng-add/index.js.map +1 -0
  44. package/schematics/ng-add/register-generate-css/index.d.ts +2 -0
  45. package/schematics/ng-add/register-generate-css/index.d.ts.map +1 -0
  46. package/schematics/ng-add/register-generate-css/index.js +5 -0
  47. package/schematics/ng-add/register-generate-css/index.js.map +1 -0
  48. package/schematics/ng-add/register-generate-css/register-task.d.ts +8 -0
  49. package/schematics/ng-add/register-generate-css/register-task.d.ts.map +1 -0
  50. package/schematics/ng-add/register-generate-css/register-task.js +68 -0
  51. package/schematics/ng-add/register-generate-css/register-task.js.map +1 -0
  52. package/schematics/ng-add/register-generate-css/templates/design-token.custom.json.template +3 -0
  53. package/schematics/ng-add/register-generate-css/templates/theme.scss.template +6 -0
  54. package/schematics/ng-add/schema.d.ts +6 -0
  55. package/schematics/ng-add/schema.d.ts.map +1 -0
  56. package/schematics/ng-add/schema.js +3 -0
  57. package/schematics/ng-add/schema.js.map +1 -0
  58. package/schematics/ng-add/schema.json +18 -0
  59. package/schematics/package.json +3 -0
  60. package/src/core/design-token/design-token-specification.interface.d.ts +195 -0
  61. package/src/core/design-token/design-token-specification.interface.d.ts.map +1 -0
  62. package/src/core/design-token/design-token-specification.interface.js +39 -0
  63. package/src/core/design-token/design-token-specification.interface.js.map +1 -0
  64. package/src/core/design-token/index.d.ts +4 -0
  65. package/src/core/design-token/index.d.ts.map +1 -0
  66. package/src/core/design-token/index.js +7 -0
  67. package/src/core/design-token/index.js.map +1 -0
  68. package/src/core/design-token/parsers/design-token-parser.interface.d.ts +70 -0
  69. package/src/core/design-token/parsers/design-token-parser.interface.d.ts.map +1 -0
  70. package/src/core/design-token/parsers/design-token-parser.interface.js +3 -0
  71. package/src/core/design-token/parsers/design-token-parser.interface.js.map +1 -0
  72. package/src/core/design-token/parsers/design-token.parser.d.ts +25 -0
  73. package/src/core/design-token/parsers/design-token.parser.d.ts.map +1 -0
  74. package/src/core/design-token/parsers/design-token.parser.js +143 -0
  75. package/src/core/design-token/parsers/design-token.parser.js.map +1 -0
  76. package/src/core/design-token/parsers/index.d.ts +3 -0
  77. package/src/core/design-token/parsers/index.d.ts.map +1 -0
  78. package/src/core/design-token/parsers/index.js +6 -0
  79. package/src/core/design-token/parsers/index.js.map +1 -0
  80. package/src/core/design-token/renderers/css/design-token-definition.renderers.d.ts +47 -0
  81. package/src/core/design-token/renderers/css/design-token-definition.renderers.d.ts.map +1 -0
  82. package/src/core/design-token/renderers/css/design-token-definition.renderers.js +53 -0
  83. package/src/core/design-token/renderers/css/design-token-definition.renderers.js.map +1 -0
  84. package/src/core/design-token/renderers/css/design-token-updater.renderers.d.ts +24 -0
  85. package/src/core/design-token/renderers/css/design-token-updater.renderers.d.ts.map +1 -0
  86. package/src/core/design-token/renderers/css/design-token-updater.renderers.js +29 -0
  87. package/src/core/design-token/renderers/css/design-token-updater.renderers.js.map +1 -0
  88. package/src/core/design-token/renderers/css/design-token-value.renderers.d.ts +19 -0
  89. package/src/core/design-token/renderers/css/design-token-value.renderers.d.ts.map +1 -0
  90. package/src/core/design-token/renderers/css/design-token-value.renderers.js +29 -0
  91. package/src/core/design-token/renderers/css/design-token-value.renderers.js.map +1 -0
  92. package/src/core/design-token/renderers/css/index.d.ts +4 -0
  93. package/src/core/design-token/renderers/css/index.d.ts.map +1 -0
  94. package/src/core/design-token/renderers/css/index.js +7 -0
  95. package/src/core/design-token/renderers/css/index.js.map +1 -0
  96. package/src/core/design-token/renderers/design-token-style.renderer.d.ts +25 -0
  97. package/src/core/design-token/renderers/design-token-style.renderer.d.ts.map +1 -0
  98. package/src/core/design-token/renderers/design-token-style.renderer.js +58 -0
  99. package/src/core/design-token/renderers/design-token-style.renderer.js.map +1 -0
  100. package/src/core/design-token/renderers/design-token.renderer.helpers.d.ts +8 -0
  101. package/src/core/design-token/renderers/design-token.renderer.helpers.d.ts.map +1 -0
  102. package/src/core/design-token/renderers/design-token.renderer.helpers.js +11 -0
  103. package/src/core/design-token/renderers/design-token.renderer.helpers.js.map +1 -0
  104. package/src/core/design-token/renderers/design-token.renderer.interface.d.ts +56 -0
  105. package/src/core/design-token/renderers/design-token.renderer.interface.d.ts.map +1 -0
  106. package/src/core/design-token/renderers/design-token.renderer.interface.js +3 -0
  107. package/src/core/design-token/renderers/design-token.renderer.interface.js.map +1 -0
  108. package/src/core/design-token/renderers/index.d.ts +7 -0
  109. package/src/core/design-token/renderers/index.d.ts.map +1 -0
  110. package/src/core/design-token/renderers/index.js +10 -0
  111. package/src/core/design-token/renderers/index.js.map +1 -0
  112. package/src/core/design-token/renderers/metadata/design-token-definition.renderers.d.ts +39 -0
  113. package/src/core/design-token/renderers/metadata/design-token-definition.renderers.d.ts.map +1 -0
  114. package/src/core/design-token/renderers/metadata/design-token-definition.renderers.js +41 -0
  115. package/src/core/design-token/renderers/metadata/design-token-definition.renderers.js.map +1 -0
  116. package/src/core/design-token/renderers/metadata/design-token-updater.renderers.d.ts +6 -0
  117. package/src/core/design-token/renderers/metadata/design-token-updater.renderers.d.ts.map +1 -0
  118. package/src/core/design-token/renderers/metadata/design-token-updater.renderers.js +13 -0
  119. package/src/core/design-token/renderers/metadata/design-token-updater.renderers.js.map +1 -0
  120. package/src/core/design-token/renderers/metadata/design-token-value.renderers.d.ts +18 -0
  121. package/src/core/design-token/renderers/metadata/design-token-value.renderers.d.ts.map +1 -0
  122. package/src/core/design-token/renderers/metadata/design-token-value.renderers.js +27 -0
  123. package/src/core/design-token/renderers/metadata/design-token-value.renderers.js.map +1 -0
  124. package/src/core/design-token/renderers/metadata/index.d.ts +4 -0
  125. package/src/core/design-token/renderers/metadata/index.d.ts.map +1 -0
  126. package/src/core/design-token/renderers/metadata/index.js +7 -0
  127. package/src/core/design-token/renderers/metadata/index.js.map +1 -0
  128. package/src/core/design-token/renderers/sass/design-token-definition.renderers.d.ts +23 -0
  129. package/src/core/design-token/renderers/sass/design-token-definition.renderers.d.ts.map +1 -0
  130. package/src/core/design-token/renderers/sass/design-token-definition.renderers.js +28 -0
  131. package/src/core/design-token/renderers/sass/design-token-definition.renderers.js.map +1 -0
  132. package/src/core/design-token/renderers/sass/index.d.ts +2 -0
  133. package/src/core/design-token/renderers/sass/index.d.ts.map +1 -0
  134. package/src/core/design-token/renderers/sass/index.js +5 -0
  135. package/src/core/design-token/renderers/sass/index.js.map +1 -0
  136. package/src/core/index.d.ts +2 -0
  137. package/src/core/index.d.ts.map +1 -0
  138. package/src/core/index.js +5 -0
  139. package/src/core/index.js.map +1 -0
  140. package/src/public_api.d.ts +2 -0
  141. package/src/public_api.d.ts.map +1 -0
  142. package/src/public_api.js +5 -0
  143. package/src/public_api.js.map +1 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"design-token-specification.interface.js","sourceRoot":"","sources":["../../../../src/core/design-token/design-token-specification.interface.ts"],"names":[],"mappings":";;;AAsOA;;;GAGG;AACI,MAAM,aAAa,GAAG,CAAC,IAAU,EAAuB,EAAE;IAC/D,OAAO,CAAC,CAAC,IAAI,IAAI,CAAC,OAAO,IAAI,CAAC,KAAK,KAAK,WAAW,IAAI,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC;AAC1F,CAAC,CAAC;AAFW,QAAA,aAAa,iBAExB;AAEF;;;GAGG;AACI,MAAM,kBAAkB,GAAG,CAAC,IAAU,EAA4B,EAAE;IACzE,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;AACvF,CAAC,CAAC;AAFW,QAAA,kBAAkB,sBAE7B;AAEF;;;;GAIG;AACH,6EAA6E;AACtE,MAAM,kCAAkC,GAAG,CAAC,KAAgD,EAAmD,EAAE;IACtJ,OAAO,CAAC,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC;AAC9C,CAAC,CAAC;AAFW,QAAA,kCAAkC,sCAE7C;AAEF;;;;GAIG;AACI,MAAM,6BAA6B,GAAG,CAAC,IAAiC,EAA8E,EAAE;IAC7J,OAAO,CAAC,CAAC,IAAI,IAAI,IAAA,0CAAkC,EAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AACnE,CAAC,CAAC;AAFW,QAAA,6BAA6B,iCAExC"}
@@ -0,0 +1,4 @@
1
+ export * from './renderers/index';
2
+ export * from './parsers/index';
3
+ export * from './design-token-specification.interface';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/design-token/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,iBAAiB,CAAC;AAChC,cAAc,wCAAwC,CAAC"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./renderers/index"), exports);
5
+ tslib_1.__exportStar(require("./parsers/index"), exports);
6
+ tslib_1.__exportStar(require("./design-token-specification.interface"), exports);
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/design-token/index.ts"],"names":[],"mappings":";;;AAAA,4DAAkC;AAClC,0DAAgC;AAChC,iFAAuD"}
@@ -0,0 +1,70 @@
1
+ import type { DesignToken, DesignTokenContext, DesignTokenExtensions, DesignTokenGroup, DesignTokenGroupExtensions } from '../design-token-specification.interface';
2
+ /** Reference to a parent node*/
3
+ export interface ParentReference {
4
+ /** Design Token name */
5
+ name: string;
6
+ /** Design Token Group node */
7
+ tokenNode: DesignTokenGroup;
8
+ }
9
+ /**
10
+ * Function rendering the Design Token Value
11
+ * @param tokenStructure Parsed Design Token
12
+ * @param variableSet Complete list of the parsed Design Token
13
+ */
14
+ export type TokenValueRenderer = (tokenStructure: DesignTokenVariableStructure, variableSet: Map<string, DesignTokenVariableStructure>) => string;
15
+ /**
16
+ * Function rendering the Design Token Key
17
+ * @param tokenStructure Parsed Design Token
18
+ */
19
+ export type TokenKeyRenderer = (tokenStructure: DesignTokenVariableStructure) => string;
20
+ /** Complete list of the parsed Design Token */
21
+ export type DesignTokenVariableSet = Map<string, DesignTokenVariableStructure>;
22
+ /** Parsed Design Token variable */
23
+ export interface DesignTokenVariableStructure {
24
+ /** Context of the Token determined or provided during the parsing process */
25
+ context?: DesignTokenContext;
26
+ /** Design Token Extension */
27
+ extensions: DesignTokenGroupExtensions & DesignTokenExtensions;
28
+ /** Reference to the Design Token node */
29
+ node: DesignToken;
30
+ /** Name of the token in references */
31
+ tokenReferenceName: string;
32
+ /** Description of the Token */
33
+ description?: string;
34
+ /** List of the Ancestors references */
35
+ ancestors: ParentReference[];
36
+ /** Reference to the direct parent node */
37
+ parent?: ParentReference;
38
+ /**
39
+ * Retrieve the list of the references of the Design Token
40
+ * @param variableSet Complete list of the parsed Design Token
41
+ */
42
+ getReferences: (variableSet?: DesignTokenVariableSet) => string[];
43
+ /**
44
+ * Raw CSS value of the Token
45
+ * @param variableSet Complete list of the parsed Design Token
46
+ */
47
+ getCssRawValue: (variableSet?: DesignTokenVariableSet) => string;
48
+ /**
49
+ * Determine if the Token is an alias
50
+ * @param variableSet Complete list of the parsed Design Token
51
+ */
52
+ getIsAlias: (variableSet?: DesignTokenVariableSet) => boolean;
53
+ /**
54
+ * Retrieve the type calculated for the Token
55
+ * @param followReference Determine if the references should be follow to calculate the type
56
+ * @param variableSet Complete list of the parsed Design Token
57
+ */
58
+ getType: (variableSet?: DesignTokenVariableSet, followReference?: boolean) => DesignToken['$type'];
59
+ /**
60
+ * Retrieve the list of the references of the Design Token node
61
+ * @param followReference Determine if the references should be follow to calculate the type
62
+ */
63
+ getReferencesNode: (variableSet?: DesignTokenVariableSet) => DesignTokenVariableStructure[];
64
+ /**
65
+ * Retrieve the Design Token Key as rendered by the provided renderer
66
+ * @param keyRenderer Renderer for the Design Token key
67
+ */
68
+ getKey: (keyRenderer?: TokenKeyRenderer) => string;
69
+ }
70
+ //# sourceMappingURL=design-token-parser.interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"design-token-parser.interface.d.ts","sourceRoot":"","sources":["../../../../../src/core/design-token/parsers/design-token-parser.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AAEpK,gCAAgC;AAChC,MAAM,WAAW,eAAe;IAC9B,wBAAwB;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,8BAA8B;IAC9B,SAAS,EAAE,gBAAgB,CAAC;CAC7B;AAED;;;;GAIG;AAEH,MAAM,MAAM,kBAAkB,GAAG,CAAC,cAAc,EAAE,4BAA4B,EAAE,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,4BAA4B,CAAC,KAAK,MAAM,CAAC;AAElJ;;;GAGG;AAEH,MAAM,MAAM,gBAAgB,GAAG,CAAC,cAAc,EAAE,4BAA4B,KAAK,MAAM,CAAC;AAExF,+CAA+C;AAE/C,MAAM,MAAM,sBAAsB,GAAG,GAAG,CAAC,MAAM,EAAE,4BAA4B,CAAC,CAAC;AAE/E,mCAAmC;AACnC,MAAM,WAAW,4BAA4B;IAC3C,6EAA6E;IAC7E,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAC7B,6BAA6B;IAC7B,UAAU,EAAE,0BAA0B,GAAG,qBAAqB,CAAC;IAC/D,yCAAyC;IACzC,IAAI,EAAE,WAAW,CAAC;IAClB,sCAAsC;IACtC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,+BAA+B;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,uCAAuC;IACvC,SAAS,EAAE,eAAe,EAAE,CAAC;IAC7B,0CAA0C;IAC1C,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB;;;OAGG;IACH,aAAa,EAAE,CAAC,WAAW,CAAC,EAAE,sBAAsB,KAAK,MAAM,EAAE,CAAC;IAClE;;;OAGG;IACH,cAAc,EAAE,CAAC,WAAW,CAAC,EAAE,sBAAsB,KAAK,MAAM,CAAC;IACjE;;;OAGG;IACH,UAAU,EAAE,CAAC,WAAW,CAAC,EAAE,sBAAsB,KAAK,OAAO,CAAC;IAC9D;;;;OAIG;IACH,OAAO,EAAE,CAAC,WAAW,CAAC,EAAE,sBAAsB,EAAE,eAAe,CAAC,EAAE,OAAO,KAAK,WAAW,CAAC,OAAO,CAAC,CAAC;IACnG;;;OAGG;IACH,iBAAiB,EAAE,CAAC,WAAW,CAAC,EAAE,sBAAsB,KAAK,4BAA4B,EAAE,CAAC;IAC5F;;;OAGG;IACH,MAAM,EAAE,CAAC,WAAW,CAAC,EAAE,gBAAgB,KAAK,MAAM,CAAC;CACpD"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=design-token-parser.interface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"design-token-parser.interface.js","sourceRoot":"","sources":["../../../../../src/core/design-token/parsers/design-token-parser.interface.ts"],"names":[],"mappings":""}
@@ -0,0 +1,25 @@
1
+ import type { DesignTokenVariableSet } from './design-token-parser.interface';
2
+ import type { DesignTokenContext, DesignTokenSpecification } from '../design-token-specification.interface';
3
+ /**
4
+ * Parse a Design Token Object to provide the map of Token with helpers to generate the different output
5
+ * @param specification Design Token content as specified on https://design-tokens.github.io/community-group/format/
6
+ */
7
+ export declare const parseDesignToken: (specification: DesignTokenSpecification) => DesignTokenVariableSet;
8
+ interface ParseDesignTokenFileOptions {
9
+ /**
10
+ * Custom function to read a file required by the token renderer
11
+ * @default {@see fs.promises.readFile}
12
+ * @param filePath Path to the file to read
13
+ */
14
+ readFile?: (filePath: string) => string | Promise<string>;
15
+ /** Custom context to provide to the parser and override the information determined by the specification parse process */
16
+ specificationContext?: DesignTokenContext;
17
+ }
18
+ /**
19
+ * Parse a Design Token File to provide the map of Token with helpers to generate the different output
20
+ * @param specificationFilePath Path to the a Design Token file following the specification on https://design-tokens.github.io/community-group/format/
21
+ * @param options
22
+ */
23
+ export declare const parseDesignTokenFile: (specificationFilePath: string, options?: ParseDesignTokenFileOptions) => Promise<DesignTokenVariableSet>;
24
+ export {};
25
+ //# sourceMappingURL=design-token.parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"design-token.parser.d.ts","sourceRoot":"","sources":["../../../../../src/core/design-token/parsers/design-token.parser.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAiD,MAAM,iCAAiC,CAAC;AAC7H,OAAO,KAAK,EAEV,kBAAkB,EAKlB,wBAAwB,EACzB,MAAM,yCAAyC,CAAC;AA6IjD;;;GAGG;AACH,eAAO,MAAM,gBAAgB,kBAAmB,wBAAwB,2BAEvE,CAAC;AAEF,UAAU,2BAA2B;IACnC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAE1D,yHAAyH;IACzH,oBAAoB,CAAC,EAAE,kBAAkB,CAAC;CAC3C;AAED;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,0BAAiC,MAAM,YAAY,2BAA2B,oCAM9G,CAAC"}
@@ -0,0 +1,143 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseDesignTokenFile = exports.parseDesignToken = void 0;
4
+ const node_fs_1 = require("node:fs");
5
+ const design_token_specification_interface_1 = require("../design-token-specification.interface");
6
+ const node_path_1 = require("node:path");
7
+ const tokenReferenceRegExp = /\{([^}]+)\}/g;
8
+ const getTokenReferenceName = (tokenName, parents) => (`${parents.join('.')}.${tokenName}`);
9
+ const getExtensions = (parentNode) => parentNode.reduce((acc, node) => ({ ...acc, ...node.$extensions }), {});
10
+ const getReferences = (cssRawValue) => Array.from(cssRawValue.matchAll(tokenReferenceRegExp)).map(([, tokenRef]) => tokenRef);
11
+ // eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
12
+ const renderCssTypeStrokeStyleValue = (value) => (0, design_token_specification_interface_1.isTokenTypeStrokeStyleValueComplex)(value) ? `${value.lineCap} ${value.dashArray.join(' ')}` : value;
13
+ const getCssRawValue = (variableSet, { node, getType }) => {
14
+ const nodeType = getType(variableSet, false);
15
+ if (!nodeType && node.$value) {
16
+ return typeof node.$value.toString !== undefined ? node.$value.toString() : JSON.stringify(node.$value);
17
+ }
18
+ const checkNode = {
19
+ ...node,
20
+ $type: node.$type || nodeType
21
+ };
22
+ // TODO in the following code, `typeof checkNode.$value === 'string' ? checkNode.$value :` is defined to please Jest TS compilation. It should be removed when supported
23
+ switch (checkNode.$type) {
24
+ case 'color':
25
+ case 'number':
26
+ case 'duration':
27
+ case 'fontWeight':
28
+ case 'fontFamily':
29
+ case 'dimension': {
30
+ return checkNode.$value.toString();
31
+ }
32
+ case 'strokeStyle': {
33
+ return renderCssTypeStrokeStyleValue(checkNode.$value);
34
+ }
35
+ case 'cubicBezier': {
36
+ return typeof checkNode.$value === 'string' ? checkNode.$value :
37
+ checkNode.$value.join(', ');
38
+ }
39
+ case 'border': {
40
+ return typeof checkNode.$value === 'string' ? checkNode.$value :
41
+ `${checkNode.$value.width} ${renderCssTypeStrokeStyleValue(checkNode.$value.style)} ${checkNode.$value.color}`;
42
+ }
43
+ case 'gradient': {
44
+ return typeof checkNode.$value === 'string' ? checkNode.$value :
45
+ // TODO: add support of different gradient type when design-tokens/community-group#101 is fixed.
46
+ `linear-gradient(0deg, ${checkNode.$value.map(({ color, position }) => `${color} ${position}`).join(', ')})`;
47
+ }
48
+ case 'shadow': {
49
+ return typeof checkNode.$value === 'string' ? checkNode.$value :
50
+ `${checkNode.$value.offsetX} ${checkNode.$value.offsetY} ${checkNode.$value.blur} ${checkNode.$value.spread} ${checkNode.$value.color}`;
51
+ }
52
+ case 'transition': {
53
+ return typeof checkNode.$value === 'string' ? checkNode.$value :
54
+ typeof checkNode.$value.timingFunction === 'string' ? checkNode.$value.timingFunction : checkNode.$value.timingFunction.join(' ') +
55
+ ` ${checkNode.$value.duration} ${checkNode.$value.delay}`;
56
+ }
57
+ case 'typography': {
58
+ return typeof checkNode.$value === 'string' ? checkNode.$value :
59
+ `${checkNode.$value.fontWeight} ${checkNode.$value.fontFamily} ${checkNode.$value.fontSize} ${checkNode.$value.letterSpacing} ${checkNode.$value.lineHeight}`;
60
+ }
61
+ default: {
62
+ // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
63
+ throw new Error(`Not supported type ${checkNode.$type || 'unknown'} (value: ${checkNode.$value || 'unknown'})`);
64
+ }
65
+ }
66
+ };
67
+ const walkThroughDesignTokenNodes = (node, context, ancestors, mem, nodeName) => {
68
+ if ((0, design_token_specification_interface_1.isDesignTokenGroup)(node)) {
69
+ Object.entries(node)
70
+ .filter(([tokenName, tokenNode]) => !tokenName.startsWith('$') && ((0, design_token_specification_interface_1.isDesignToken)(tokenNode) || (0, design_token_specification_interface_1.isDesignTokenGroup)(tokenNode)))
71
+ .forEach(([tokenName, tokenNode]) => walkThroughDesignTokenNodes(tokenNode, context, nodeName ? [...ancestors, { name: nodeName, tokenNode: node }] : ancestors, mem, tokenName));
72
+ }
73
+ if ((0, design_token_specification_interface_1.isDesignToken)(node)) {
74
+ if (!nodeName) {
75
+ throw new Error('The first node of the Design Specification can not be a token');
76
+ }
77
+ const parentNames = ancestors.map(({ name }) => name);
78
+ const tokenReferenceName = getTokenReferenceName(nodeName, parentNames);
79
+ const tokenVariable = {
80
+ context,
81
+ extensions: getExtensions([...ancestors.map(({ tokenNode }) => tokenNode), node]),
82
+ node,
83
+ tokenReferenceName,
84
+ ancestors,
85
+ parent: ancestors.slice(-1)[0],
86
+ description: node.$description,
87
+ getCssRawValue: function (variableSet = mem) {
88
+ return getCssRawValue(variableSet, this);
89
+ },
90
+ getReferences: function (variableSet = mem) {
91
+ return getReferences(this.getCssRawValue(variableSet));
92
+ },
93
+ getIsAlias: function (variableSet = mem) {
94
+ return this.getReferences(variableSet).length === 1 && typeof node.$value === 'string' && !!node.$value?.toString().match(/^\{[^}]*\}$/);
95
+ },
96
+ getReferencesNode: function (variableSet = mem) {
97
+ return this.getReferences(variableSet)
98
+ .map((ref) => {
99
+ if (!variableSet.has(ref)) {
100
+ throw new Error(`Reference to ${ref} not found`);
101
+ }
102
+ return variableSet.get(ref);
103
+ });
104
+ },
105
+ getType: function (variableSet = mem, followReference = true) {
106
+ return node.$type ||
107
+ followReference && this.getIsAlias(variableSet) && this.getReferencesNode(variableSet)[0]?.getType(variableSet, followReference) ||
108
+ followReference && this.parent?.name && variableSet.get(this.parent.name)?.getType(variableSet, followReference) ||
109
+ undefined;
110
+ },
111
+ getKey: function (keyRenderer) {
112
+ return keyRenderer ? keyRenderer(this) : this.tokenReferenceName.replace(/[ .]+/g, '-');
113
+ }
114
+ };
115
+ mem.set(tokenReferenceName, tokenVariable);
116
+ }
117
+ else if (!(0, design_token_specification_interface_1.isDesignTokenGroup)(node)) {
118
+ throw new Error('Fail to determine the Design Token Node type');
119
+ }
120
+ return mem;
121
+ };
122
+ /**
123
+ * Parse a Design Token Object to provide the map of Token with helpers to generate the different output
124
+ * @param specification Design Token content as specified on https://design-tokens.github.io/community-group/format/
125
+ */
126
+ const parseDesignToken = (specification) => {
127
+ return walkThroughDesignTokenNodes(specification.document, specification.context, [], new Map());
128
+ };
129
+ exports.parseDesignToken = parseDesignToken;
130
+ /**
131
+ * Parse a Design Token File to provide the map of Token with helpers to generate the different output
132
+ * @param specificationFilePath Path to the a Design Token file following the specification on https://design-tokens.github.io/community-group/format/
133
+ * @param options
134
+ */
135
+ const parseDesignTokenFile = async (specificationFilePath, options) => {
136
+ const readFile = options?.readFile || ((filePath) => node_fs_1.promises.readFile(filePath, { encoding: 'utf-8' }));
137
+ const context = {
138
+ basePath: (0, node_path_1.dirname)(specificationFilePath)
139
+ };
140
+ return (0, exports.parseDesignToken)({ document: JSON.parse(await readFile(specificationFilePath)), context });
141
+ };
142
+ exports.parseDesignTokenFile = parseDesignTokenFile;
143
+ //# sourceMappingURL=design-token.parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"design-token.parser.js","sourceRoot":"","sources":["../../../../../src/core/design-token/parsers/design-token.parser.ts"],"names":[],"mappings":";;;AAAA,qCAAyC;AAWzC,kGAKiD;AACjD,yCAAoC;AAEpC,MAAM,oBAAoB,GAAG,cAAc,CAAC;AAE5C,MAAM,qBAAqB,GAAG,CAAC,SAAiB,EAAE,OAAiB,EAAE,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,SAAS,EAAE,CAAC,CAAC;AAC9G,MAAM,aAAa,GAAG,CAAC,UAA6B,EAAE,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,EAAC,GAAG,GAAG,EAAE,GAAG,IAAI,CAAC,WAAW,EAAC,CAAC,EAAE,EAAwD,CAAC,CAAC;AACrL,MAAM,aAAa,GAAG,CAAC,WAAmB,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,oBAAoB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC;AACrI,6EAA6E;AAC7E,MAAM,6BAA6B,GAAG,CAAC,KAA+C,EAAE,EAAE,CAAC,IAAA,yEAAkC,EAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,C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,CAAC,OAAO,EAAE,EAAE,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;AACnG,CAAC,CAAC;AAFW,QAAA,gBAAgB,oBAE3B;AAcF;;;;GAIG;AACI,MAAM,oBAAoB,GAAG,KAAK,EAAE,qBAA6B,EAAE,OAAqC,EAAE,EAAE;IACjH,MAAM,QAAQ,GAAG,OAAO,EAAE,QAAQ,IAAI,CAAC,CAAC,QAAgB,EAAE,EAAE,CAAC,kBAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;IAC3G,MAAM,OAAO,GAAuB;QAClC,QAAQ,EAAE,IAAA,mBAAO,EAAC,qBAAqB,CAAC;KACzC,CAAC;IACF,OAAO,IAAA,wBAAgB,EAAC,EAAE,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,qBAAqB,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;AACpG,CAAC,CAAC;AANW,QAAA,oBAAoB,wBAM/B"}
@@ -0,0 +1,3 @@
1
+ export * from './design-token-parser.interface';
2
+ export * from './design-token.parser';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/core/design-token/parsers/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,uBAAuB,CAAC"}
@@ -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("./design-token-parser.interface"), exports);
5
+ tslib_1.__exportStar(require("./design-token.parser"), exports);
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/core/design-token/parsers/index.ts"],"names":[],"mappings":";;;AAAA,0EAAgD;AAChD,gEAAsC"}
@@ -0,0 +1,47 @@
1
+ import type { DesignTokenVariableStructure, TokenKeyRenderer, TokenValueRenderer } from '../../parsers/design-token-parser.interface';
2
+ import { TokenDefinitionRenderer } from '../design-token.renderer.interface';
3
+ /** Options for {@link CssTokenDefinitionRendererOptions} */
4
+ export interface CssTokenDefinitionRendererOptions {
5
+ /**
6
+ * Determine if the variable is private and should not be rendered
7
+ * @default {@see isO3rPrivateVariable}
8
+ */
9
+ isPrivateVariable?: (variable: DesignTokenVariableStructure) => boolean;
10
+ /** Custom Design Token value renderer */
11
+ tokenValueRenderer?: TokenValueRenderer;
12
+ /**
13
+ * Renderer the name of the CSS Variable (with the initial --)
14
+ */
15
+ tokenVariableNameRenderer?: TokenKeyRenderer;
16
+ /**
17
+ * Private Design Token definition renderer
18
+ * The private variable will not be rendered if not provided
19
+ */
20
+ privateDefinitionRenderer?: TokenDefinitionRenderer;
21
+ }
22
+ /**
23
+ * Retrieve the Design Token variable renderer for CSS
24
+ * @param options
25
+ * @returns
26
+ * @example CSS renderer with Sass fallback
27
+ * ```typescript
28
+ * import { getSassTokenDefinitionRenderer } from '@o3r/design';
29
+ *
30
+ * // List of parsed Design Token items
31
+ * const parsedTokenDesign = await parseDesignTokenFile('./path/to/spec.json');
32
+ *
33
+ * // Sass variable renderer
34
+ * const sassTokenDefinitionRenderer = getSassTokenDefinitionRenderer();
35
+ *
36
+ * // CSS variable renderer
37
+ * const cssTokenDefinitionRenderer = getCssTokenDefinitionRenderer({
38
+ * // Specify that the private variable should be rendered in Sass variable
39
+ * privateDefinitionRenderer: sassTokenDefinitionRenderer
40
+ * });
41
+ *
42
+ * // Render the CSS variables
43
+ * await renderDesignTokens(parsedTokenDesign, { tokenDefinitionRenderer: cssTokenDefinitionRenderer });
44
+ * ```
45
+ */
46
+ export declare const getCssTokenDefinitionRenderer: (options?: CssTokenDefinitionRendererOptions) => TokenDefinitionRenderer;
47
+ //# sourceMappingURL=design-token-definition.renderers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"design-token-definition.renderers.d.ts","sourceRoot":"","sources":["../../../../../../src/core/design-token/renderers/css/design-token-definition.renderers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AAEtI,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAG7E,4DAA4D;AAC5D,MAAM,WAAW,iCAAiC;IAChD;;;OAGG;IACH,iBAAiB,CAAC,EAAE,CAAC,QAAQ,EAAE,4BAA4B,KAAK,OAAO,CAAC;IAExE,yCAAyC;IACzC,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;IAExC;;OAEG;IACH,yBAAyB,CAAC,EAAE,gBAAgB,CAAC;IAE7C;;;OAGG;IACH,yBAAyB,CAAC,EAAE,uBAAuB,CAAC;CACrD;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,6BAA6B,aAAc,iCAAiC,KAAG,uBAqB3F,CAAC"}
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCssTokenDefinitionRenderer = void 0;
4
+ const design_token_renderer_helpers_1 = require("../design-token.renderer.helpers");
5
+ const design_token_value_renderers_1 = require("./design-token-value.renderers");
6
+ /**
7
+ * Retrieve the Design Token variable renderer for CSS
8
+ * @param options
9
+ * @returns
10
+ * @example CSS renderer with Sass fallback
11
+ * ```typescript
12
+ * import { getSassTokenDefinitionRenderer } from '@o3r/design';
13
+ *
14
+ * // List of parsed Design Token items
15
+ * const parsedTokenDesign = await parseDesignTokenFile('./path/to/spec.json');
16
+ *
17
+ * // Sass variable renderer
18
+ * const sassTokenDefinitionRenderer = getSassTokenDefinitionRenderer();
19
+ *
20
+ * // CSS variable renderer
21
+ * const cssTokenDefinitionRenderer = getCssTokenDefinitionRenderer({
22
+ * // Specify that the private variable should be rendered in Sass variable
23
+ * privateDefinitionRenderer: sassTokenDefinitionRenderer
24
+ * });
25
+ *
26
+ * // Render the CSS variables
27
+ * await renderDesignTokens(parsedTokenDesign, { tokenDefinitionRenderer: cssTokenDefinitionRenderer });
28
+ * ```
29
+ */
30
+ const getCssTokenDefinitionRenderer = (options) => {
31
+ const isPrivateVariable = options?.isPrivateVariable || design_token_renderer_helpers_1.isO3rPrivateVariable;
32
+ const tokenVariableNameRenderer = options?.tokenVariableNameRenderer;
33
+ const tokenValueRenderer = options?.tokenValueRenderer || (0, design_token_value_renderers_1.getCssTokenValueRenderer)({ isPrivateVariable, tokenVariableNameRenderer });
34
+ const renderer = (variable, variableSet) => {
35
+ let variableString;
36
+ if (!isPrivateVariable(variable)) {
37
+ variableString = `--${variable.getKey(tokenVariableNameRenderer)}: ${tokenValueRenderer(variable, variableSet)};`;
38
+ if (variable.extensions.o3rScope) {
39
+ variableString = `${variable.extensions.o3rScope} { ${variableString} }`;
40
+ }
41
+ }
42
+ else if (options?.privateDefinitionRenderer && variable.extensions.o3rPrivate) {
43
+ variableString = options.privateDefinitionRenderer(variable, variableSet);
44
+ }
45
+ if (variableString && variable.description) {
46
+ variableString = `/* ${variable.description} */\n${variableString}`;
47
+ }
48
+ return variableString;
49
+ };
50
+ return renderer;
51
+ };
52
+ exports.getCssTokenDefinitionRenderer = getCssTokenDefinitionRenderer;
53
+ //# sourceMappingURL=design-token-definition.renderers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"design-token-definition.renderers.js","sourceRoot":"","sources":["../../../../../../src/core/design-token/renderers/css/design-token-definition.renderers.ts"],"names":[],"mappings":";;;AACA,oFAAwE;AAExE,iFAA0E;AAyB1E;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACI,MAAM,6BAA6B,GAAG,CAAC,OAA2C,EAA2B,EAAE;IACpH,MAAM,iBAAiB,GAAG,OAAO,EAAE,iBAAiB,IAAI,oDAAoB,CAAC;IAC7E,MAAM,yBAAyB,GAAG,OAAO,EAAE,yBAAyB,CAAC;IACrE,MAAM,kBAAkB,GAAG,OAAO,EAAE,kBAAkB,IAAI,IAAA,uDAAwB,EAAC,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,CAAC,CAAC;IAErI,MAAM,QAAQ,GAAG,CAAC,QAAsC,EAAE,WAAsD,EAAE,EAAE;QAClH,IAAI,cAAkC,CAAC;QACvC,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,EAAE;YAChC,cAAc,GAAG,KAAK,QAAQ,CAAC,MAAM,CAAC,yBAAyB,CAAC,KAAK,kBAAkB,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,CAAC;YAClH,IAAI,QAAQ,CAAC,UAAU,CAAC,QAAQ,EAAE;gBAChC,cAAc,GAAG,GAAG,QAAQ,CAAC,UAAU,CAAC,QAAQ,MAAM,cAAc,IAAI,CAAC;aAC1E;SACF;aAAM,IAAI,OAAO,EAAE,yBAAyB,IAAI,QAAQ,CAAC,UAAU,CAAC,UAAU,EAAE;YAC/E,cAAc,GAAG,OAAO,CAAC,yBAAyB,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;SAC3E;QACD,IAAI,cAAc,IAAI,QAAQ,CAAC,WAAW,EAAE;YAC1C,cAAc,GAAG,MAAM,QAAQ,CAAC,WAAW,QAAQ,cAAc,EAAE,CAAC;SACrE;QACD,OAAO,cAAc,CAAC;IACxB,CAAC,CAAC;IACF,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AArBW,QAAA,6BAA6B,iCAqBxC"}
@@ -0,0 +1,24 @@
1
+ import type { DesignContentFileUpdater } from '../design-token.renderer.interface';
2
+ /** Default CSS starting tag */
3
+ export declare const AUTO_GENERATED_START = "/* --- BEGIN THEME Auto-generated --- */";
4
+ /** Default CSS ending tag */
5
+ export declare const AUTO_GENERATED_END = "/* --- END THEME Auto-generated --- */";
6
+ /** Options for {@link getCssStyleContentUpdater} */
7
+ export interface CssStyleContentUpdaterOptions {
8
+ /**
9
+ * Opening tag marking the content edition part
10
+ * @default {@see AUTO_GENERATED_START}
11
+ */
12
+ startTag?: string;
13
+ /**
14
+ * Closing tag marking the content edition part
15
+ * @default {@see AUTO_GENERATED_END}
16
+ */
17
+ endTag?: string;
18
+ }
19
+ /**
20
+ * Retrieve a Content Updater function for CSS generator
21
+ * @param options
22
+ */
23
+ export declare const getCssStyleContentUpdater: (options?: CssStyleContentUpdaterOptions) => DesignContentFileUpdater;
24
+ //# sourceMappingURL=design-token-updater.renderers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"design-token-updater.renderers.d.ts","sourceRoot":"","sources":["../../../../../../src/core/design-token/renderers/css/design-token-updater.renderers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,oCAAoC,CAAC;AAOnF,+BAA+B;AAC/B,eAAO,MAAM,oBAAoB,6CAA6C,CAAC;AAE/E,6BAA6B;AAC7B,eAAO,MAAM,kBAAkB,2CAA2C,CAAC;AAE3E,oDAAoD;AACpD,MAAM,WAAW,6BAA6B;IAC5C;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,eAAO,MAAM,yBAAyB,aAAc,6BAA6B,KAAG,wBAcnF,CAAC"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCssStyleContentUpdater = exports.AUTO_GENERATED_END = exports.AUTO_GENERATED_START = void 0;
4
+ const SANITIZE_TAG_INPUTS_REGEXP = /[.*+?^${}()|[\]\\]/g;
5
+ const generateVars = (variables, startTag, endTag, addCssScope = false) => `${addCssScope ? ':root {\n' : ''}${startTag}\n${variables.join('\n')}\n${endTag}${addCssScope ? '\n}' : ''}`;
6
+ /** Default CSS starting tag */
7
+ exports.AUTO_GENERATED_START = '/* --- BEGIN THEME Auto-generated --- */';
8
+ /** Default CSS ending tag */
9
+ exports.AUTO_GENERATED_END = '/* --- END THEME Auto-generated --- */';
10
+ /**
11
+ * Retrieve a Content Updater function for CSS generator
12
+ * @param options
13
+ */
14
+ const getCssStyleContentUpdater = (options) => {
15
+ const startTag = options?.startTag || exports.AUTO_GENERATED_START;
16
+ const endTag = options?.endTag || exports.AUTO_GENERATED_END;
17
+ /** Regexp to replace the content between the detected tags. It also handle possible inputted special character sanitization */
18
+ const regexToReplace = new RegExp(`${startTag.replace(SANITIZE_TAG_INPUTS_REGEXP, '\\$&')}(:?(.|[\n\r])*)${endTag.replace(SANITIZE_TAG_INPUTS_REGEXP, '\\$&')}`);
19
+ return (variables, _file, styleContent = '') => {
20
+ if (styleContent.indexOf(startTag) >= 0 && styleContent.indexOf(endTag) >= 0) {
21
+ return styleContent.replace(regexToReplace, generateVars(variables, startTag, endTag));
22
+ }
23
+ else {
24
+ return styleContent + '\n' + generateVars(variables, startTag, endTag, true);
25
+ }
26
+ };
27
+ };
28
+ exports.getCssStyleContentUpdater = getCssStyleContentUpdater;
29
+ //# sourceMappingURL=design-token-updater.renderers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"design-token-updater.renderers.js","sourceRoot":"","sources":["../../../../../../src/core/design-token/renderers/css/design-token-updater.renderers.ts"],"names":[],"mappings":";;;AAEA,MAAM,0BAA0B,GAAG,qBAAqB,CAAC;AAEzD,MAAM,YAAY,GAAG,CAAC,SAAmB,EAAE,QAAgB,EAAE,MAAc,EAAE,WAAW,GAAG,KAAK,EAAE,EAAE,CAClG,GAAG,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,GAAG,QAAQ,KAAK,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,MAAM,GAAG,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;AAEhH,+BAA+B;AAClB,QAAA,oBAAoB,GAAG,0CAA0C,CAAC;AAE/E,6BAA6B;AAChB,QAAA,kBAAkB,GAAG,wCAAwC,CAAC;AAiB3E;;;GAGG;AACI,MAAM,yBAAyB,GAAG,CAAC,OAAuC,EAA4B,EAAE;IAC7G,MAAM,QAAQ,GAAG,OAAO,EAAE,QAAQ,IAAI,4BAAoB,CAAC;IAC3D,MAAM,MAAM,GAAG,OAAO,EAAE,MAAM,IAAI,0BAAkB,CAAC;IAErD,+HAA+H;IAC/H,MAAM,cAAc,GAAG,IAAI,MAAM,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,0BAA0B,EAAE,MAAM,CAAC,kBAAkB,MAAM,CAAC,OAAO,CAAC,0BAA0B,EAAE,MAAM,CAAC,EAAE,CAAC,CAAC;IAEjK,OAAO,CAAC,SAAS,EAAE,KAAK,EAAE,YAAY,GAAG,EAAE,EAAE,EAAE;QAC7C,IAAI,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;YAC5E,OAAO,YAAY,CAAC,OAAO,CAAC,cAAc,EAAE,YAAY,CAAC,SAAS,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;SACxF;aAAM;YACL,OAAO,YAAY,GAAG,IAAI,GAAG,YAAY,CAAC,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;SAC9E;IACH,CAAC,CAAC;AACJ,CAAC,CAAC;AAdW,QAAA,yBAAyB,6BAcpC"}
@@ -0,0 +1,19 @@
1
+ import type { DesignTokenVariableStructure, TokenKeyRenderer, TokenValueRenderer } from '../../parsers/design-token-parser.interface';
2
+ /** Options for {@link getCssTokenValueRenderer} */
3
+ export interface CssTokenValueRendererOptions {
4
+ /**
5
+ * Determine if the variable is private and should not be rendered
6
+ * @default {@see isO3rPrivateVariable}
7
+ */
8
+ isPrivateVariable?: (variable: DesignTokenVariableStructure) => boolean;
9
+ /**
10
+ * Renderer the name of the CSS Variable (without initial --)
11
+ */
12
+ tokenVariableNameRenderer?: TokenKeyRenderer;
13
+ }
14
+ /**
15
+ * Retrieve the Design Token value renderer
16
+ * @param options
17
+ */
18
+ export declare const getCssTokenValueRenderer: (options?: CssTokenValueRendererOptions) => TokenValueRenderer;
19
+ //# sourceMappingURL=design-token-value.renderers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"design-token-value.renderers.d.ts","sourceRoot":"","sources":["../../../../../../src/core/design-token/renderers/css/design-token-value.renderers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,6CAA6C,CAAC;AAGtI,mDAAmD;AACnD,MAAM,WAAW,4BAA4B;IAC3C;;;OAGG;IACH,iBAAiB,CAAC,EAAE,CAAC,QAAQ,EAAE,4BAA4B,KAAK,OAAO,CAAC;IAExE;;OAEG;IACH,yBAAyB,CAAC,EAAE,gBAAgB,CAAC;CAC9C;AAED;;;GAGG;AACH,eAAO,MAAM,wBAAwB,aAAc,4BAA4B,KAAG,kBAoBjF,CAAC"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCssTokenValueRenderer = void 0;
4
+ const design_token_renderer_helpers_1 = require("../design-token.renderer.helpers");
5
+ /**
6
+ * Retrieve the Design Token value renderer
7
+ * @param options
8
+ */
9
+ const getCssTokenValueRenderer = (options) => {
10
+ const isPrivateVariable = options?.isPrivateVariable || design_token_renderer_helpers_1.isO3rPrivateVariable;
11
+ const tokenVariableNameRenderer = options?.tokenVariableNameRenderer;
12
+ const referenceRenderer = (variable, variableSet) => {
13
+ if (!isPrivateVariable(variable)) {
14
+ return `var(--${variable.getKey(tokenVariableNameRenderer)})`;
15
+ }
16
+ else {
17
+ // eslint-disable-next-line no-use-before-define
18
+ return `var(--${variable.getKey(tokenVariableNameRenderer)}, ${renderer(variable, variableSet)})`;
19
+ }
20
+ };
21
+ const renderer = (variable, variableSet) => {
22
+ let variableValue = variable.getCssRawValue(variableSet).replaceAll(/\{([^}]*)\}/g, (defaultValue, matcher) => (variableSet.has(matcher) ? referenceRenderer(variableSet.get(matcher), variableSet) : defaultValue));
23
+ variableValue += variableValue && variable.extensions.o3rImportant ? ' !important' : '';
24
+ return variableValue;
25
+ };
26
+ return renderer;
27
+ };
28
+ exports.getCssTokenValueRenderer = getCssTokenValueRenderer;
29
+ //# sourceMappingURL=design-token-value.renderers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"design-token-value.renderers.js","sourceRoot":"","sources":["../../../../../../src/core/design-token/renderers/css/design-token-value.renderers.ts"],"names":[],"mappings":";;;AACA,oFAAwE;AAgBxE;;;GAGG;AACI,MAAM,wBAAwB,GAAG,CAAC,OAAsC,EAAsB,EAAE;IACrG,MAAM,iBAAiB,GAAG,OAAO,EAAE,iBAAiB,IAAI,oDAAoB,CAAC;IAC7E,MAAM,yBAAyB,GAAG,OAAO,EAAE,yBAAyB,CAAC;IAErE,MAAM,iBAAiB,GAAG,CAAC,QAAsC,EAAE,WAAsD,EAAU,EAAE;QACnI,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,EAAE;YAChC,OAAO,SAAS,QAAQ,CAAC,MAAM,CAAC,yBAAyB,CAAC,GAAG,CAAC;SAC/D;aAAM;YACL,gDAAgD;YAChD,OAAO,SAAS,QAAQ,CAAC,MAAM,CAAC,yBAAyB,CAAC,KAAK,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,CAAC;SACnG;IACH,CAAC,CAAC;IACF,MAAM,QAAQ,GAAG,CAAC,QAAsC,EAAE,WAAsD,EAAE,EAAE;QAClH,IAAI,aAAa,GAAG,QAAQ,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,UAAU,CAAC,cAAc,EAAE,CAAC,YAAY,EAAE,OAAO,EAAE,EAAE,CAC5G,CAAC,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,WAAW,CAAC,GAAG,CAAC,OAAO,CAAE,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CACtG,CAAC;QACF,aAAa,IAAI,aAAa,IAAI,QAAQ,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC;QACxF,OAAO,aAAa,CAAC;IACvB,CAAC,CAAC;IACF,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AApBW,QAAA,wBAAwB,4BAoBnC"}
@@ -0,0 +1,4 @@
1
+ export * from './design-token-definition.renderers';
2
+ export * from './design-token-value.renderers';
3
+ export * from './design-token-updater.renderers';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/core/design-token/renderers/css/index.ts"],"names":[],"mappings":"AAAA,cAAc,qCAAqC,CAAC;AACpD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./design-token-definition.renderers"), exports);
5
+ tslib_1.__exportStar(require("./design-token-value.renderers"), exports);
6
+ tslib_1.__exportStar(require("./design-token-updater.renderers"), exports);
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/core/design-token/renderers/css/index.ts"],"names":[],"mappings":";;;AAAA,8EAAoD;AACpD,yEAA+C;AAC/C,2EAAiD"}
@@ -0,0 +1,25 @@
1
+ import type { DesignTokenVariableSet, DesignTokenVariableStructure } from '../parsers/design-token-parser.interface';
2
+ import type { DesignTokenRendererOptions } from './design-token.renderer.interface';
3
+ /**
4
+ * Retrieve the function that determines which file to update for a given token
5
+ * @param root Root path used if no base path
6
+ * @param defaultFile Default file if not requested by the Token
7
+ */
8
+ export declare const computeFileToUpdatePath: (root?: string, defaultFile?: string) => (token: DesignTokenVariableStructure) => string;
9
+ /**
10
+ * Process the parsed Design Token variables and render them according to the given options and renderers
11
+ * @param variableSet Complete list of the parsed Design Token
12
+ * @param options Parameters of the Design Token renderer
13
+ * @example Basic renderer usage
14
+ * ```typescript
15
+ * import { parseDesignTokenFile, renderDesignTokens } from '@o3r/design';
16
+ *
17
+ * // List of parsed Design Token items
18
+ * const parsedTokenDesign = await parseDesignTokenFile('./path/to/spec.json');
19
+ *
20
+ * // Render the CSS variables
21
+ * await renderDesignTokens(parsedTokenDesign, { logger: console });
22
+ * ```
23
+ */
24
+ export declare const renderDesignTokens: (variableSet: DesignTokenVariableSet, options?: DesignTokenRendererOptions) => Promise<void>;
25
+ //# sourceMappingURL=design-token-style.renderer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"design-token-style.renderer.d.ts","sourceRoot":"","sources":["../../../../../src/core/design-token/renderers/design-token-style.renderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,4BAA4B,EAAE,MAAM,0CAA0C,CAAC;AAKrH,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAC;AAEpF;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,mDAAkE,4BAA4B,WAMjI,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,kBAAkB,kDAAyD,0BAA0B,kBAwBjH,CAAC"}