@webority/tokens 0.0.0-stage → 0.90.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.
Files changed (140) hide show
  1. package/LICENSE +5 -0
  2. package/dist/_virtual/_rolldown/runtime.js +1 -0
  3. package/dist/brand.d.ts +33 -0
  4. package/dist/brand.js +2 -0
  5. package/dist/build.js +5 -0
  6. package/dist/canvas/renames.json +159 -0
  7. package/dist/canvas/webority-phone.json +763 -0
  8. package/dist/canvas/webority-web-390.json +423 -0
  9. package/dist/canvas/webority-web.json +423 -0
  10. package/dist/canvas-renames.js +1 -0
  11. package/dist/check.js +2 -0
  12. package/dist/cli.d.ts +91 -0
  13. package/dist/cli.js +2 -0
  14. package/dist/deviations.js +1 -0
  15. package/dist/emit/canvas.js +1 -0
  16. package/dist/emit/email.js +2 -0
  17. package/dist/emit/meanings.js +1 -0
  18. package/dist/emit/phone.js +3 -0
  19. package/dist/emit/web.js +23 -0
  20. package/dist/index.d.ts +7 -0
  21. package/dist/index.js +1 -0
  22. package/dist/meanings.json +879 -0
  23. package/dist/model/colour.js +1 -0
  24. package/dist/model/derive.js +1 -0
  25. package/dist/model/index.js +1 -0
  26. package/dist/model/length.js +1 -0
  27. package/dist/model/load.js +1 -0
  28. package/dist/model/references.js +1 -0
  29. package/dist/model/resolve.js +2 -0
  30. package/dist/names.d.ts +13 -0
  31. package/dist/names.js +1 -0
  32. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/2020.js +1 -0
  33. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/code.js +1 -0
  34. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/index.js +2 -0
  35. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/codegen/scope.js +1 -0
  36. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/errors.js +1 -0
  37. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/index.js +1 -0
  38. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/names.js +1 -0
  39. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/ref_error.js +1 -0
  40. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/resolve.js +1 -0
  41. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/rules.js +1 -0
  42. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/util.js +1 -0
  43. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/applicability.js +1 -0
  44. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/boolSchema.js +1 -0
  45. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/dataType.js +4 -0
  46. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/defaults.js +1 -0
  47. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/index.js +1 -0
  48. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/keyword.js +1 -0
  49. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/compile/validate/subschema.js +1 -0
  50. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/core.js +1 -0
  51. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/data.js +1 -0
  52. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/index.js +1 -0
  53. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/applicator.js +1 -0
  54. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/content.js +1 -0
  55. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/core.js +1 -0
  56. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/format-annotation.js +1 -0
  57. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/meta-data.js +1 -0
  58. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/unevaluated.js +1 -0
  59. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/meta/validation.js +1 -0
  60. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/refs/json-schema-2020-12/schema.js +1 -0
  61. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/equal.js +1 -0
  62. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/ucs2length.js +1 -0
  63. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/uri.js +1 -0
  64. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/runtime/validation_error.js +1 -0
  65. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js +1 -0
  66. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +1 -0
  67. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/allOf.js +1 -0
  68. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/anyOf.js +1 -0
  69. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/contains.js +1 -0
  70. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/dependencies.js +4 -0
  71. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/dependentSchemas.js +1 -0
  72. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/if.js +1 -0
  73. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/index.js +1 -0
  74. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/items.js +1 -0
  75. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/items2020.js +1 -0
  76. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/not.js +1 -0
  77. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/oneOf.js +1 -0
  78. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js +1 -0
  79. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js +1 -0
  80. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/properties.js +1 -0
  81. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js +1 -0
  82. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/applicator/thenElse.js +1 -0
  83. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/code.js +1 -0
  84. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/core/id.js +1 -0
  85. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/core/index.js +1 -0
  86. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/core/ref.js +1 -0
  87. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/discriminator/index.js +1 -0
  88. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/discriminator/types.js +1 -0
  89. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/draft2020.js +1 -0
  90. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/dynamicAnchor.js +1 -0
  91. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/dynamicRef.js +1 -0
  92. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/index.js +1 -0
  93. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/recursiveAnchor.js +1 -0
  94. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/dynamic/recursiveRef.js +1 -0
  95. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/format/format.js +1 -0
  96. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/format/index.js +1 -0
  97. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/metadata.js +1 -0
  98. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/next.js +1 -0
  99. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/unevaluated/index.js +1 -0
  100. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedItems.js +1 -0
  101. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedProperties.js +1 -0
  102. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/const.js +1 -0
  103. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/dependentRequired.js +1 -0
  104. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/enum.js +1 -0
  105. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/index.js +1 -0
  106. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitContains.js +1 -0
  107. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitItems.js +1 -0
  108. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitLength.js +1 -0
  109. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitNumber.js +1 -0
  110. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/limitProperties.js +1 -0
  111. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/multipleOf.js +1 -0
  112. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/pattern.js +1 -0
  113. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/required.js +1 -0
  114. package/dist/node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js +1 -0
  115. package/dist/node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/index.js +1 -0
  116. package/dist/node_modules/.pnpm/fast-uri@3.1.9/node_modules/fast-uri/index.js +1 -0
  117. package/dist/node_modules/.pnpm/fast-uri@3.1.9/node_modules/fast-uri/lib/schemes.js +1 -0
  118. package/dist/node_modules/.pnpm/fast-uri@3.1.9/node_modules/fast-uri/lib/utils.js +1 -0
  119. package/dist/node_modules/.pnpm/json-schema-traverse@1.0.0/node_modules/json-schema-traverse/index.js +1 -0
  120. package/dist/outputs.d.ts +139 -0
  121. package/dist/source/component.tokens.json +1672 -0
  122. package/dist/source/meaning.tokens.json +1025 -0
  123. package/dist/source/mode.dark.tokens.json +594 -0
  124. package/dist/source/palette.tokens.json +1406 -0
  125. package/dist/source/platform.phone.tokens.json +395 -0
  126. package/dist/source/scale.tokens.json +869 -0
  127. package/dist/source/width.390.tokens.json +96 -0
  128. package/dist/upgrade/css.js +2 -0
  129. package/dist/upgrade/index.js +5 -0
  130. package/dist/upgrade/razorAttributes.js +3 -0
  131. package/dist/upgrade/themeReads.js +2 -0
  132. package/dist/webority.js +2 -0
  133. package/dist/webority.resolver.json +18 -0
  134. package/package.json +46 -3
  135. package/renames/0.87.1.json +14 -0
  136. package/renames/0.89.0.json +1423 -0
  137. package/renames/renames.d.ts +42 -0
  138. package/schema/design-map.schema.json +143 -0
  139. package/schema/webority-tokens.schema.json +211 -0
  140. package/README.md +0 -3
package/LICENSE ADDED
@@ -0,0 +1,5 @@
1
+ Copyright (c) Webority Technologies. All rights reserved.
2
+
3
+ This software and its source code are proprietary and confidential to
4
+ Webority Technologies. Use is restricted to Webority products and teams under
5
+ internal license. Redistribution outside Webority Technologies is prohibited.
@@ -0,0 +1 @@
1
+ import"node:module";var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t,n)=>()=>{if(n)throw n[0];try{return e&&(t=e(e=0)),t}catch(e){throw n=[e],e}},s=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),c=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},l=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},u=(n,r,a)=>(a=n==null?{}:e(i(n)),l(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n)),d=e=>a.call(e,`module.exports`)?e[`module.exports`]:l(t({},`__esModule`,{value:!0}),e);export{s as __commonJSMin,o as __esmMin,c as __exportAll,d as __toCommonJS,u as __toESM};
@@ -0,0 +1,33 @@
1
+ /** The parsed library source trees the model already holds. */
2
+ export interface LibrarySources {
3
+ palette: object;
4
+ scale: object;
5
+ meaning: object;
6
+ modeDark: object;
7
+ }
8
+
9
+ /** A validated brand: base overrides every mode, dark overrides the dark context only. */
10
+ export interface BrandLayer {
11
+ name: string;
12
+ base: object;
13
+ dark: object;
14
+ }
15
+
16
+ /** The recorded deviations, keyed by slug (src/deviations.json). */
17
+ export type Deviations = Readonly<Record<string, { reason: string }>>;
18
+
19
+ /** Reads and validates a product brand file; throws one Error listing every problem. */
20
+ export declare function loadBrand(path: string, library: LibrarySources, deviations: Deviations): BrandLayer;
21
+
22
+ export declare const BRAND_OUTPUT_FILES: {
23
+ readonly css: "brand.css";
24
+ readonly bootstrap: "_brand-variables.scss";
25
+ readonly web: "webority-web.json";
26
+ readonly web390: "webority-web-390.json";
27
+ readonly phoneTheme: "webority-phone.json";
28
+ readonly phone: "brand.phone.js";
29
+ readonly email: "email.json";
30
+ };
31
+
32
+ /** The folder inside each head that receives the copies of the generated files. */
33
+ export declare const HEAD_FOLDER: "generated";
package/dist/brand.js ADDED
@@ -0,0 +1,2 @@
1
+ import{readFileSync as e}from"node:fs";var t=Object.freeze({css:`brand.css`,bootstrap:`_brand-variables.scss`,web:`webority-web.json`,web390:`webority-web-390.json`,phoneTheme:`webority-phone.json`,phone:`brand.phone.js`,email:`email.json`}),n=`generated`,r=/\{([a-z0-9-]+(?:\.[a-z0-9-]+)+)\}/g,i=[`palette`,`color`,`effect`,`font`,`radius`],a=[`space`,`text`,`shadow`,`section`,`component`];function o(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function s(e){return o(e)&&Object.hasOwn(e,`$value`)}function c(e,t){let n=[],r=(e,t)=>{for(let i of Object.keys(e)){if(i.startsWith(`$`))continue;let a=e[i],c=`${t}.${i}`;s(a)?n.push({path:c,node:a}):o(a)&&r(a,c)}};return r(e,t),n}function l(e,t){let n=e;for(let e of t.split(`.`)){if(!o(n)||!Object.hasOwn(n,e))return!1;n=n[e]}return s(n)}function u(e){let t=e?.$extensions?.[`com.webority`];return o(t)?t:{}}function d(e){return/^[a-z0-9]+(-[a-z0-9]+)*$/.test(e)&&!/^[0-9]+$/.test(e)}function f(t,n,f){let p;try{p=JSON.parse(e(t,`utf8`))}catch(e){throw Error(`${t}: (file): cannot be read as JSON (${e.message}). Restore the file or fix the JSON`)}if(!o(p))throw Error(`${t}: (file): is not a JSON object. Write the brand as one object with the groups palette, color, effect, font and radius`);let m=[],h=(e,n,r)=>{let i=`${t}: ${e}: ${n}. ${r}`;m.includes(i)||m.push(i)},g=u(p);for(let e of Object.keys(g))e!==`brand`&&e!==`deviation`&&h(`$extensions.com.webority.${e}`,`is not a brand file key`,`Remove it`);let _=Object.hasOwn(g,`deviation`),v=_&&typeof g.deviation==`string`&&Object.hasOwn(f,g.deviation);_&&!v&&h(`$extensions.com.webority.deviation`,`${g.deviation} is not in deviations.json`,`Use a key of deviations.json`),(typeof g.brand!=`string`||!/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/.test(g.brand))&&h(`$extensions.com.webority.brand`,`is missing or not kebab case`,`Name the product in kebab case, such as capnix`);let y={};for(let e of Object.keys(p))if(!e.startsWith(`$`)){if(!i.includes(e)&&!a.includes(e)){h(e,`is not a brand group`,`A brand file holds only palette, color, effect, font and radius, plus the groups a recorded deviation allows`);continue}if(a.includes(e)&&!v){h(e,`this group needs a recorded deviation`,`Add $extensions.com.webority.deviation naming an entry of deviations.json, or remove the group`);continue}if(!o(p[e])){h(e,`is not a group`,`Write it as an object of tokens`);continue}y[e]=p[e]}for(let[e,t]of Object.entries(y))for(let{path:n,node:r}of c(t,e)){let t=u(r);for(let e of Object.keys(t))e!==`platforms`&&e!==`dark`&&h(n,`$extensions.com.webority.${e} is not allowed on a token`,`Remove it`);if(Object.hasOwn(t,`platforms`)){let e=t.platforms;Array.isArray(e)&&e.length>0&&e.every(e=>e===`web`||e===`phone`)||h(n,`$extensions.com.webority.platforms is not a list of web and phone`,`Write it as ["phone"], ["web"] or both`)}Object.hasOwn(t,`dark`)&&e!==`color`&&e!==`effect`&&h(n,`$extensions.com.webority.dark applies to colour and effect tokens only`,`Remove it`)}for(let{path:e,node:t}of c(y.palette??{},`palette`))e.split(`.`).slice(1).every(d)||h(e,`the step name is not kebab case`,`Name it such as primary-500`),typeof t.$value!=`string`&&h(e,`$value is not a string`,`Write the colour as text such as "#0F766E" or a reference such as "{palette.primary}"`);let b=(e,t,r)=>{let i=`${e}.${t}`,a=u(r),o=l(n.meaning,i);typeof r.$value!=`string`&&h(i,`$value is not a string`,e===`color`?`Write a colour or a reference such as "{palette.primary}"`:`Write the effect as text such as a filter, colour or gradient`),o?l(n.modeDark,i)&&typeof a.dark!=`string`&&h(i,`needs $extensions.com.webority.dark because the meaning has a dark value`,`Add the dark value beside the light one`):(d(t)||h(i,`the name is not kebab case`,`Name it in kebab case`),(typeof r.$description!=`string`||r.$description===``)&&h(i,`is not a fleet meaning and has no $description`,`Add a $description saying what the colour is for, or use a meaning the library defines`)),Object.hasOwn(a,`dark`)&&typeof a.dark!=`string`&&h(i,`$extensions.com.webority.dark is not a string`,`Write a colour or a reference`)};for(let e of[`color`,`effect`]){let t=y[e]??{};for(let n of Object.keys(t))if(!n.startsWith(`$`)){if(!s(t[n])){h(`${e}.${n}`,`is not a token`,`Give it a $value`);continue}b(e,n,t[n])}}let x=Object.keys(n.scale.font??{}).filter(e=>s(n.scale.font[e]));for(let{path:e,node:t}of c(y.font??{},`font`)){l(n.scale,e)||h(e,`is not a fleet font`,`Use one of ${x.join(`, `)}`);let r=t.$value;(!Array.isArray(r)||r.length===0||!r.every(e=>typeof e==`string`))&&h(e,`$value is not a list of font family names`,`Write it as ["Webority Sans", "system-ui", "sans-serif"]`)}let S=Object.keys(n.scale.radius??{}).filter(e=>s(n.scale.radius[e]));for(let{path:e,node:t}of c(y.radius??{},`radius`)){l(n.scale,e)||h(e,`is not on the radius scale`,`Use one of ${S.join(`, `)}`);let r=t.$value;(!(o(r)&&typeof r.value==`number`&&Number.isFinite(r.value)&&r.value>=0)||r.unit!==`px`)&&h(e,`$value is not { value, unit }`,`Write it as { "value": 12, "unit": "px" }`)}let C=structuredClone(p);delete C.$extensions,delete C.$description;for(let e of[`color`,`effect`])for(let{node:t}of c(C[e]??{},e))Object.hasOwn(u(t),`dark`)&&(delete t.$extensions[`com.webority`].dark,Object.keys(t.$extensions[`com.webority`]).length===0&&delete t.$extensions[`com.webority`],Object.keys(t.$extensions).length===0&&delete t.$extensions);let w=e=>l(C,e)||l(n.palette,e)||l(n.scale,e)||l(n.meaning,e);for(let e of Object.keys(y))for(let{path:t,node:n}of c(y[e],e)){let e=[n.$value,u(n).dark].filter(e=>typeof e==`string`);for(let n of e)for(let e of n.matchAll(r))w(e[1])||h(t,`references {${e[1]}}, which no palette step, meaning, scale step or brand token defines`,`Name an existing token or add it to the brand file`)}if(m.length>0)throw Error(m.join(`
2
+ `));let T={};for(let e of[`color`,`effect`])for(let{path:t,node:n}of c(y[e]??{},e)){let r=u(n).dark;if(typeof r!=`string`)continue;let i=t.slice(e.length+1);T[e]??={},T[e][i]=n.$type===void 0?{$value:r}:{$value:r,$type:n.$type}}return{name:g.brand,base:C,dark:T}}export{t as BRAND_OUTPUT_FILES,n as HEAD_FOLDER,f as loadBrand};
package/dist/build.js ADDED
@@ -0,0 +1,5 @@
1
+ import{__toESM as e}from"./_virtual/_rolldown/runtime.js";import{BRAND_OUTPUT_FILES as t,HEAD_FOLDER as n,loadBrand as r}from"./brand.js";import{require__2020 as i}from"./node_modules/.pnpm/ajv@8.20.0/node_modules/ajv/dist/2020.js";import a from"./canvas-renames.js";import o from"./deviations.js";import{emitCanvas as s}from"./emit/canvas.js";import{emitEmail as c}from"./emit/email.js";import{emitMeanings as l}from"./emit/meanings.js";import{emitPhoneBrand as u,emitPhoneTheme as d,phoneSets as f}from"./emit/phone.js";import{emitWeb as p}from"./emit/web.js";import{loadModel as m}from"./model/index.js";import{mkdir as h,readFile as g,writeFile as _}from"node:fs/promises";import v from"node:path";var y=e(i(),1),b=new URL(`../schema/design-map.schema.json`,import.meta.url),x=new URL(`../package.json`,import.meta.url),S={palette:`palette.tokens.json`,scale:`scale.tokens.json`,meaning:`meaning.tokens.json`,modeDark:`mode.dark.tokens.json`},C=/^.+: \S+: .+\. .+$/;async function w(e){let n=v.resolve(e.root??process.cwd()),i=e.check===!0,{version:S}=JSON.parse(await g(x,`utf8`)),w=[],O=[],k=async(e,t)=>{if(i){let n=null;try{n=await g(e,`utf8`)}catch(e){if(e.code!==`ENOENT`)throw e}n!==t&&O.push(e);return}await h(v.dirname(e),{recursive:!0}),await _(e,t,`utf8`),w.push(e)};if(e.library===!0){if(e.brand!==void 0)throw Error(`brand: --brand: not allowed with --library. Remove it.`);if(!e.out)throw Error(`brand: --out: required with --library. Pass --out <dir>.`);let r=v.resolve(n,e.out),i=await m(),o=s(i),c=[[v.join(r,`canvas`,t.web),T(o.web)],[v.join(r,`canvas`,t.web390),T(o.web390)],[v.join(r,`canvas`,t.phoneTheme),T(o.phone)],[v.join(r,`meanings.json`),T(l(i))],[v.join(r,`canvas`,`renames.json`),T(a)]];if(e.web){let t=p(i),r=v.resolve(n,e.web);c.push([r,t.tokens]),c.push([v.join(v.dirname(r),`_bootstrap.generated.scss`),t.bootstrap])}if(e.phone){let t=d({light:f(i,`light`),dark:f(i,`dark`)});c.push([v.resolve(n,e.phone),t.contents])}for(let[e,t]of c)await k(e,t);return{written:w,stale:O}}let A=v.join(n,`.webority`,`design.json`),j;try{j=await g(A,`utf8`)}catch(e){throw e.code===`ENOENT`?Error(`${A}: file missing. Run from the repo root or create the design map.`):e}let M;try{M=JSON.parse(j)}catch(e){throw Error(`${A}: /: ${e.message}. Fix the design map.`)}let N=JSON.parse(await g(b,`utf8`)),P=new y.Ajv2020({allErrors:!0,strict:!1}).compile(N);if(!P(M))throw Error(P.errors.map(e=>`${A}: ${e.instancePath||`/`}: ${e.message}. Fix the design map.`).join(`
2
+ `));let F=M.tokens.brands,I=M.tokens.heads??[];if((e.brand!==void 0||e.out!==void 0)&&F.length>1)throw Error(`brand: --brand/--out: the repo has ${F.length} brands. Remove the flag to build every brand.`);let L=[];if(F.forEach((e,t)=>{e.source===`library`&&L.push(`${A}: tokens.brands[${t}].source: "library" is built with --library. Run webority brand --library --out <dir>.`)}),I.forEach((e,t)=>{F.some(t=>t.name===e.brand)||L.push(`${A}: tokens.heads[${t}].brand: no brand named ${e.brand}. Add it to tokens.brands.`)}),L.length>0)throw Error(L.join(`
3
+ `));let R=await D(),z=await m(),B={light:f(z,`light`),dark:f(z,`dark`)},V=[];for(let i of F){let a=F.length===1&&e.brand!==void 0?e.brand:i.source,l=F.length===1&&e.out!==void 0?e.out:i.export,d=v.resolve(n,a);try{let e=r(d,R,o),a=await m({brand:e}),h=s(a),g=p(a,{library:z}),_=u(B,{light:f(a,`light`),dark:f(a,`dark`)},{package:`@webority/tokens`,version:S,brand:e.name}),y=T(c(h.web,h.web390)),b={css:g.css,phone:_.contents,email:y},x=v.resolve(n,l),C=[[v.join(x,t.css),g.css],[v.join(x,t.bootstrap),g.variables],[v.join(x,t.web),T(h.web)],[v.join(x,t.web390),T(h.web390)],[v.join(x,t.phoneTheme),T(h.phone)],[v.join(x,t.phone),_.contents],[v.join(x,t.email),y]];V.push(...C);for(let e of I)e.brand===i.name&&V.push(E(n,e,b))}catch(e){for(let t of String(e?.message??e).split(`
4
+ `))t.length!==0&&L.push(C.test(t)?t:`${d}: -: ${t}. Fix the source.`)}}if(L.length>0)throw Error(L.join(`
5
+ `));for(let[e,t]of V)await k(e,t);return{written:w,stale:O}}function T(e){return`${JSON.stringify(e,null,4)}\n`}function E(e,r,i){let a=v.resolve(e,r.path);return r.kind===`razor`?[v.join(a,`wwwroot`,n,t.css),i.css]:r.kind===`spa`?[v.join(a,`src`,n,t.css),i.css]:r.kind===`phone`?[v.join(a,n,t.phone),i.phone]:[v.join(a,n,t.email),i.email]}async function D(){let e={};for(let[t,n]of Object.entries(S))e[t]=JSON.parse(await g(new URL(`./source/${n}`,import.meta.url),`utf8`));return e}export{w as brand};
@@ -0,0 +1,159 @@
1
+ {
2
+ "from": "webority-theme-tokens/1",
3
+ "to": "webority-theme-tokens/2",
4
+ "color": {
5
+ "accent-dark": "primary-hover",
6
+ "bg-elevated": "bg-subtle",
7
+ "bg-light": "surface",
8
+ "bg-muted": "bg-muted",
9
+ "bg-page": "bg",
10
+ "border-light": "border",
11
+ "border-soft": "border-subtle",
12
+ "border-strong": "border-strong",
13
+ "chart-1": "chart-1",
14
+ "chart-2": "chart-2",
15
+ "chart-3": "chart-3",
16
+ "chart-4": "chart-4",
17
+ "chart-5": "chart-5",
18
+ "chart-6": "chart-6",
19
+ "chart-7": "chart-7",
20
+ "chart-8": "chart-8",
21
+ "chart-diverging-high": "chart-diverging-high",
22
+ "chart-diverging-low": "chart-diverging-low",
23
+ "chart-diverging-mid": "chart-diverging-mid",
24
+ "chart-neutral": "chart-neutral",
25
+ "chart-seq-0": "chart-seq-0",
26
+ "chart-seq-1": "chart-seq-1",
27
+ "chart-seq-2": "chart-seq-2",
28
+ "chart-seq-3": "chart-seq-3",
29
+ "chart-seq-4": "chart-seq-4",
30
+ "chart-seq-5": "chart-seq-5",
31
+ "chart-seq-6": "chart-seq-6",
32
+ "danger": "danger",
33
+ "danger-10": "danger-soft",
34
+ "danger-20": null,
35
+ "danger-30": "danger-border",
36
+ "danger-5": null,
37
+ "danger-50": null,
38
+ "danger-active": "danger-pressed",
39
+ "danger-strong": "danger-strong",
40
+ "danger-strong-hover": "danger-strong-hover",
41
+ "danger-text": "danger-text",
42
+ "fg-2": "text-body",
43
+ "fg-3": "text-muted",
44
+ "fg-4": "text-subtle",
45
+ "fg-5": "border-strong",
46
+ "field-bg": "field-bg",
47
+ "field-border": "field-border",
48
+ "field-border-hover": "field-border-hover",
49
+ "info": "info",
50
+ "info-10": "info-soft",
51
+ "info-20": null,
52
+ "info-30": "info-border",
53
+ "info-5": null,
54
+ "info-50": null,
55
+ "info-active": "info-pressed",
56
+ "info-text": "info-text",
57
+ "ink": null,
58
+ "neutral-bg-dark": "bg-muted",
59
+ "neutral-bg-light": "bg-subtle",
60
+ "neutral-border-dark": "border",
61
+ "neutral-border-light": "border-subtle",
62
+ "primary": "primary",
63
+ "primary-10": "primary-soft",
64
+ "primary-15": null,
65
+ "primary-20": null,
66
+ "primary-30": null,
67
+ "primary-5": null,
68
+ "primary-50": null,
69
+ "primary-hover": "primary-hover",
70
+ "primary-ink": "primary-text",
71
+ "primary-pressed": "primary-hover",
72
+ "primary-text": "on-primary",
73
+ "progress-track": "progress-track",
74
+ "scrollbar": "scrollbar",
75
+ "scrollbar-active": "scrollbar-active",
76
+ "scrollbar-hover": "scrollbar-hover",
77
+ "shadow-overlay": null,
78
+ "shadow-overlay-lg": null,
79
+ "success": "success",
80
+ "success-10": "success-soft",
81
+ "success-20": null,
82
+ "success-30": "success-border",
83
+ "success-5": null,
84
+ "success-50": null,
85
+ "success-active": "success-pressed",
86
+ "success-strong": "success-strong",
87
+ "success-text": "success-text",
88
+ "surface-mute": "bg-subtle",
89
+ "surface-soft": null,
90
+ "surface-violet": null,
91
+ "surface-violet-soft": null,
92
+ "text-1": "text-body",
93
+ "text-2": "text-muted",
94
+ "text-3": "text-subtle",
95
+ "text-4": "text-subtle",
96
+ "text-5": "border-strong",
97
+ "text-heading": "text",
98
+ "warning": "warning",
99
+ "warning-10": "warning-soft",
100
+ "warning-20": null,
101
+ "warning-30": "warning-border",
102
+ "warning-5": null,
103
+ "warning-50": null,
104
+ "warning-active": "warning-pressed",
105
+ "warning-strong": "warning-strong",
106
+ "warning-strong-hover": "warning-strong-hover",
107
+ "warning-text": "warning-text"
108
+ },
109
+ "font": {
110
+ "display": "display",
111
+ "mono": "mono",
112
+ "sans": "ui"
113
+ },
114
+ "text": {
115
+ "48": "4xl",
116
+ "64": "5xl",
117
+ "2xl": "2xl",
118
+ "3xl": "3xl",
119
+ "4xl": "4xl",
120
+ "5xl": "5xl",
121
+ "6xl": "6xl",
122
+ "7xl": "7xl",
123
+ "8xl": "8xl",
124
+ "base": "base",
125
+ "lg": "lg",
126
+ "sm": "sm",
127
+ "smb": "sm",
128
+ "xl": "xl",
129
+ "xs": "xs"
130
+ },
131
+ "space": {
132
+ "2xl": "2xl",
133
+ "3xl": "3xl",
134
+ "4xl": "4xl",
135
+ "lg": "lg",
136
+ "md": "md",
137
+ "none": "none",
138
+ "sm": "sm",
139
+ "xl": "xl",
140
+ "xs": "xs",
141
+ "xxs": "xxs"
142
+ },
143
+ "radius": {
144
+ "lg": "lg",
145
+ "md": "md",
146
+ "pill": "pill",
147
+ "sm": "sm",
148
+ "xl": "xl"
149
+ },
150
+ "shadow": {
151
+ "card": "card",
152
+ "card-lifted": null,
153
+ "card-lifted-hover": null,
154
+ "overlay": "popover",
155
+ "overlay-lg": "modal",
156
+ "thumb": null,
157
+ "thumb-hover": null
158
+ }
159
+ }