@webority/canvas-kit 0.85.0 → 0.86.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.
- package/dist/kitModule.js +1 -1
- package/dist/manifest.js +1 -1
- package/dist/phone.js +1 -1
- package/dist/spec.d.ts +16 -2
- package/dist/tokens.js +1 -1
- package/package.json +2 -2
package/dist/kitModule.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=2,t=Object.freeze({Web:[`react`,`react-dom`,`react/jsx-runtime`],Phone:[`react`,`react-dom`,`react/jsx-runtime`,`react-native`,`react-native-svg`]});function n({components:e,markers:n,tokenValues:r,manifest:i}){if(typeof i!=`object`||!i)throw Error(`defineKit needs the manifest, the kit's manifest object.`);if(!Object.hasOwn(t,i.platform))throw Error(`defineKit: platform ${JSON.stringify(i.platform)} is not Web or Phone.`);if(typeof e!=`object`||!e)throw Error(`defineKit: components must be an object of React components.`);let a={};for(let[t,n]of Object.entries(e)){if(n===null||typeof n!=`function`&&typeof n!=`object`)throw Error(`defineKit: component ${t} is not a React component.`);a[t]=n}if(typeof n!=`object`||!n)throw Error(`defineKit: markers must be an object of marker names by component name.`);for(let[e,t]of Object.entries(n))if(!Object.hasOwn(a,e)||typeof t!=`string`||t===``)throw Error(`defineKit: the marker of ${e} must name a component with a non-empty marker.`);if(r===void 0||r!==null&&typeof r!=`object`)throw Error(`defineKit: tokenValues must be an object, or null on a release built before it existed.`);return{components:Object.freeze(a),markers:Object.freeze({...n}),tokenValues:r,manifest:i}}export{t as KIT_MODULE_EXTERNALS,n as defineKit,e as kitModuleVersion};
|
|
1
|
+
var e=2,t=Object.freeze({Web:[`react`,`react-dom`,`react/jsx-runtime`],Phone:[`react`,`react-dom`,`react/jsx-runtime`,`react-native`,`react-native-svg`,`@webority/mobile-core`,`expo-image`,`expo-haptics`,`expo-file-system`,`react-hook-form`,`react-native-gesture-handler`,`react-native-keyboard-controller`,`react-native-reanimated`,`react-native-safe-area-context`,`react-native-worklets`]});function n({components:e,markers:n,tokenValues:r,manifest:i}){if(typeof i!=`object`||!i)throw Error(`defineKit needs the manifest, the kit's manifest object.`);if(!Object.hasOwn(t,i.platform))throw Error(`defineKit: platform ${JSON.stringify(i.platform)} is not Web or Phone.`);if(typeof e!=`object`||!e)throw Error(`defineKit: components must be an object of React components.`);let a={};for(let[t,n]of Object.entries(e)){if(n===null||typeof n!=`function`&&typeof n!=`object`)throw Error(`defineKit: component ${t} is not a React component.`);a[t]=n}if(typeof n!=`object`||!n)throw Error(`defineKit: markers must be an object of marker names by component name.`);for(let[e,t]of Object.entries(n))if(!Object.hasOwn(a,e)||typeof t!=`string`||t===``)throw Error(`defineKit: the marker of ${e} must name a component with a non-empty marker.`);if(r===void 0||r!==null&&typeof r!=`object`)throw Error(`defineKit: tokenValues must be an object, or null on a release built before it existed.`);return{components:Object.freeze(a),markers:Object.freeze({...n}),tokenValues:r,manifest:i}}export{t as KIT_MODULE_EXTERNALS,n as defineKit,e as kitModuleVersion};
|
package/dist/manifest.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{findPackageDir as e,readJson as t,readText as n,toPosix as r}from"./files.js";import"./kitModule.js";import{collectComponents as i}from"./declarations.js";import{PHONE_EXCLUDED_COMPONENTS as a,applyPhoneActions as o,phoneIcons as s,phoneTokenValues as c,phoneTokens as l}from"./phone.js";import{colourMeanings as u,webIcons as d,webTokenValues as
|
|
1
|
+
import{findPackageDir as e,readJson as t,readText as n,toPosix as r}from"./files.js";import"./kitModule.js";import{collectComponents as i}from"./declarations.js";import{PHONE_EXCLUDED_COMPONENTS as a,applyPhoneActions as o,phoneIcons as s,phoneTokenValues as c,phoneTokens as l}from"./phone.js";import{colourMeanings as u,webIcons as d,webTokenValues as f,webTokens as p}from"./tokens.js";import{createRequire as m}from"node:module";import{existsSync as h,mkdtempSync as g,rmSync as _}from"node:fs";import{dirname as v,join as y,relative as b,resolve as x}from"node:path";import{execFileSync as S}from"node:child_process";import{tmpdir as C}from"node:os";import w from"@babel/parser";var T=/^[a-z][a-z0-9-]{1,39}$/,E=[`Web`,`Phone`],D=[`title`,`navigation`],O=y(v(m(import.meta.url).resolve(`typescript/package.json`)),`bin`,`tsc`),k=[`.jsx`,`.js`,`.tsx`,`.ts`,`.mjs`],A=/^App[A-Z]/,j={Web:`WeborityWeb`,Phone:`WeborityPhone`};function M(n,r){let i=e(n,r);if(!i)throw Error(`${r} is not installed for ${n}. Run pnpm install there.`);let a=t(y(i,`package.json`)),o=(e,t)=>{if(typeof e==`string`)return t==="default"?e:void 0;if(!(!e||typeof e!=`object`))return typeof e[t]==`string`?e[t]:o(e.import,t)??o(e.default,t)},s=a.exports?.[`.`],c=a.types??o(s,`types`),l=o(s,`default`)??a.main;if(!c)throw Error(`${r} declares no types, and the manifest reads its declaration files.`);if(!l)throw Error(`${r} declares no entry file for its runtime.`);return{dir:i,pkg:a,typesFile:y(i,c),entryFile:y(i,l)}}function N(t){let n=e(t,`@webority/theme`);if(!n)throw Error(`@webority/theme is not installed for ${t}. Run pnpm install.`);return n}function P(e,n,r){let i=t(y(e,`package.json`)),a=i.dependencies?.[n]??i.devDependencies?.[n];if(/^\d+\.\d+\.\d+$/.test(a??``)&&a!==r)throw Error(`${n} is pinned to ${a} in package.json but ${r} is installed. Run pnpm install first.`)}function F(e,t){let n=g(y(C(),`canvas-kit-declarations-`));try{S(process.execPath,[O,`--allowJs`,`--declaration`,`--emitDeclarationOnly`,`--jsx`,`react-jsx`,`--module`,`esnext`,`--moduleResolution`,`bundler`,`--target`,`es2022`,`--skipLibCheck`,`--rootDir`,e,`--outDir`,n,t],{cwd:e,encoding:`utf8`,stdio:`pipe`})}catch(e){throw _(n,{recursive:!0,force:!0}),Error(`Could not read the declarations of ${t}: ${e.stdout||e.stderr||e.message}`)}return n}function I(e,t,n){let i=b(t,n).replace(/\.d\.ts$/,``);for(let t of k)if(h(y(e,`${i}${t}`)))return r(`${i}${t}`);throw Error(`No source file for the declarations in ${n}`)}function ee(e,t,r){let i=/\.tsx?$/.test(t)?[`jsx`,`typescript`]:[`jsx`],a=w.parse(n(y(e,t)),{sourceType:`module`,plugins:i});for(let e of a.program.body){let t=e.type===`ExpressionStatement`?e.expression:null;if(t?.type===`AssignmentExpression`&&t.left.type===`MemberExpression`&&!t.left.computed&&t.left.object.type===`Identifier`&&t.left.object.name===r&&t.left.property.name===`displayName`&&t.right.type===`StringLiteral`)return t.right.value}return null}function te(e){return e.filter(e=>e.type===`array`&&(e.itemFields??[]).some(e=>[`href`,`to`].includes(e.name))).map(e=>e.name)}function L(e,n){if(!n)return;let r=t(n);if(typeof r!=`object`||!r||Array.isArray(r))throw Error(`${n} must be an object from component name to role.`);for(let[t,i]of Object.entries(r)){let r=e.find(e=>e.name===t);if(!r)throw Error(`${n} names ${t}, which the kit does not have.`);if(!D.includes(i))throw Error(`${n}: ${t} has role ${JSON.stringify(i)}; a role is title or navigation.`);r.role=i}}function R(e){let n=t(e);if(!Array.isArray(n)||n.some(e=>typeof e?.name!=`string`))throw Error(`${e} must be the style key table: a list of style keys, each with a name.`);return n}function z(e){let n=t(e);if(n?.schema!==1)throw Error(`${e} has schema ${n?.schema}; this reader reads schema 1.`);if(!n.itemActions)throw Error(`${e} has no itemActions; the phone kit's action lists come from it.`);return{flags:n.styleKeys??{},itemActions:n.itemActions}}function B(e,t,n){let r=e.map(({name:e})=>e),i=r.filter(e=>typeof t[e]!=`boolean`),a=Object.keys(t).filter(e=>!r.includes(e));if(i.length>0||a.length>0)throw Error(`${n} must list exactly the style keys of the style key table, each true or false. Missing or not a boolean: ${i.join(`, `)||`none`}. Not in the table: ${a.join(`, `)||`none`}.`)}function V(e,t){return e.map(({name:e,type:n,values:r,appliesTo:i,description:a})=>({name:e,type:n,values:r,appliesTo:i,...t?{phoneSupported:t[e]}:{},description:a}))}function H({projectRoot:e,kit:r,platform:m,entry:h,libraryPackage:g,rolesFile:v,rendererProtocolVersion:S,phoneRendererSupportFile:C,styleKeysFile:w}){if(!T.test(r??``))throw Error(`kit ${JSON.stringify(r)} must be 2 to 40 characters: lowercase letters, digits and hyphens, starting with a letter.`);if(!E.includes(m))throw Error(`platform must be Web or Phone, not ${JSON.stringify(m)}.`);if(!Number.isInteger(S)||S<1)throw Error(`rendererProtocolVersion must be a positive integer, not ${JSON.stringify(S)}.`);if(m===`Phone`&&!C)throw Error(`A Phone kit needs phoneRendererSupportFile, the phone renderer's support file.`);let D=x(e),O=M(D,g);P(D,g,O.pkg.version);let k=C?z(C):null,H=m===`Phone`?k:null,U=w?R(w):null;U&&k&&B(U,k.flags,C);let W=i(O.typesFile,{namedConsts:!0,kit:g}),G=m===`Phone`?W.components.filter(({name:e})=>!a.has(e)):W.components,K={components:[],warnings:[]},q=new Map;if(h!==void 0){let e=x(h);if(b(D,e).startsWith(`..`))throw Error(`The kit entry ${e} is outside the product folder ${D}.`);let t=F(D,e);try{K=i(y(t,b(D,e)).replace(/\.[^./\\]+$/,`.d.ts`),{kit:r}),q=new Map(K.components.map(e=>[e.name,I(D,t,e.file)]))}finally{_(t,{recursive:!0,force:!0})}}let J=new Set(G.map(({name:e})=>e)),Y=K.components.filter(({name:e})=>J.has(e)).map(({name:e})=>e);if(Y.length>0)throw Error(`The kit names ${Y.join(`, `)} as ${g} already has them; rename the product components.`);let X=[...G.map(e=>({...e,source:g,marker:A.test(e.name)?e.name:null})),...K.components.map(e=>{let t=q.get(e.name);return{...e,source:t,marker:ee(D,t,e.name)}})].sort((e,t)=>e.name<t.name?-1:+(e.name>t.name)).map(({name:e,marker:t,acceptsChildren:n,props:r,source:i})=>({name:e,marker:t,acceptsChildren:n,props:r,itemsTakeAction:m===`Web`?te(r):[],takesAction:[],source:i}));H&&o(X,H.itemActions),L(X,v);let Z,Q,$;if(m===`Web`){let e=N(D);Z=p(n(y(e,`scss`,`_tokens.scss`))),Z.colorMeanings=u(Z.color,t(y(e,`token-meanings.json`))),Q=f(y(e,`dist`,`published-theme.json`),Z),$=d(y(O.dir,`dist`))}else{let e=y(O.dir,`lib`,`module`,`theme`,`tokens.js`);Z=l(e),Q=c(e),$=s(y(O.dir,`lib`,`typescript`,`module`,`components`,`AppIcon`,`catalog.g.d.ts`))}return{manifest:{kind:h===void 0?j[m]:`Product`,library:{name:O.pkg.name,version:O.pkg.version},rendererProtocolVersion:S,platform:m,kitModuleVersion:2,productKit:null,components:X,tokens:Z,tokenValues:Q,icons:$,...U?{styleKeys:V(U,k?k.flags:null)}:{}},warnings:[...W.warnings,...K.warnings]}}export{M as libraryFiles,H as readManifest,z as readPhoneSupport};
|
package/dist/phone.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readText as e}from"./files.js";import t from"@babel/parser";var n=new Set([`Form`,`NetworkStatusBanner`,`SkeletonClockProvider`,`SkeletonProvider`,`SkeletonSkip`,`ThemeProvider`,`ToastProvider`,`Box`,`Text`]),r=[`sans`],i=`System`;function a(n){return t.parse(e(n),{sourceType:`module`,plugins:[`typescript`]})}function o(e){return[...new Set(e)].sort((e,t)=>e<t?-1:+(e>t))}function s(e){return e.type===`Identifier`?e.name:e.type===`StringLiteral`?e.value:null}function c(e){let t=new Map;for(let n of e.program.body){let e=n.type===`ExportNamedDeclaration`?n.declaration:n;if(e?.type===`VariableDeclaration`)for(let n of e.declarations)n.id.type===`Identifier`&&t.set(n.id.name,n.init)}return t}function l(e,t,n){let r=t;for(let t=0;r?.type===`Identifier`;t+=1){if(t>10||!e.has(r.name))throw Error(`${r.name} in ${n} is not a constant the reader can follow.`);r=e.get(r.name)}return r}function u(e,t,n,r){let i=n.properties.find(e=>e.type===`ObjectProperty`&&s(e.key)===r);if(!i)throw Error(`${r} is missing from the theme in ${t}`);return l(e,i.value,t)}function d(e){return e.properties.filter(e=>e.type===`ObjectProperty`).map(e=>s(e.key))}function f(e,t,n,r=``){return n.properties.flatMap(n=>{if(n.type!==`ObjectProperty`)return[];let i=`${r}${s(n.key)}`,a=l(e,n.value,t);return a.type===`StringLiteral`?[i]:a.type===`ObjectExpression`?f(e,t,a,`${i}.`):[]})}function p(e){let t=c(a(e));if(!t.has(`lightTheme`))throw Error(`lightTheme is not declared in ${e}`);let n=l(t,t.get(`lightTheme`),e),i=u(t,e,n,`typography`);return{color:o(f(t,e,u(t,e,n,`colors`))),space:o(d(u(t,e,n,`spacing`))),radius:o(d(u(t,e,n,`radius`))),shadow:o(d(u(t,e,n,`shadows`))),font:r,text:o(d(u(t,e,i,`fontSize`)))}}function m(e,t,n){let r=l(e,t,n);if(r.type===`StringLiteral`||r.type===`NumericLiteral`)return r.value;if(r.type===`UnaryExpression`&&r.operator===`-`&&r.argument.type===`NumericLiteral`)return-r.argument.value;if(r.type===`ObjectExpression`)return Object.fromEntries(r.properties.map(t=>{if(t.type!==`ObjectProperty`)throw Error(`${n} spreads an object the reader cannot follow.`);return[s(t.key),m(e,t.value,n)]}));throw Error(`${n} has a ${r.type} the reader cannot read as a value.`)}function h(e,t,n,r){let i=l(e,n,t);for(let n of r)i=u(e,t,i,n);return m(e,i,t)}function
|
|
1
|
+
import{readText as e}from"./files.js";import t from"@babel/parser";var n=new Set([`Form`,`NetworkStatusBanner`,`SkeletonClockProvider`,`SkeletonProvider`,`SkeletonSkip`,`ThemeProvider`,`ToastProvider`,`Box`,`Text`]),r=[`sans`],i=`System`;function a(n){return t.parse(e(n),{sourceType:`module`,plugins:[`typescript`]})}function o(e){return[...new Set(e)].sort((e,t)=>e<t?-1:+(e>t))}function s(e){return e.type===`Identifier`?e.name:e.type===`StringLiteral`?e.value:null}function c(e){let t=new Map;for(let n of e.program.body){let e=n.type===`ExportNamedDeclaration`?n.declaration:n;if(e?.type===`VariableDeclaration`)for(let n of e.declarations)n.id.type===`Identifier`&&t.set(n.id.name,n.init)}return t}function l(e,t,n){let r=t;for(let t=0;r?.type===`Identifier`;t+=1){if(t>10||!e.has(r.name))throw Error(`${r.name} in ${n} is not a constant the reader can follow.`);r=e.get(r.name)}return r}function u(e,t,n,r){let i=n.properties.find(e=>e.type===`ObjectProperty`&&s(e.key)===r);if(!i)throw Error(`${r} is missing from the theme in ${t}`);return l(e,i.value,t)}function d(e){return e.properties.filter(e=>e.type===`ObjectProperty`).map(e=>s(e.key))}function f(e,t,n,r=``){return n.properties.flatMap(n=>{if(n.type!==`ObjectProperty`)return[];let i=`${r}${s(n.key)}`,a=l(e,n.value,t);return a.type===`StringLiteral`?[i]:a.type===`ObjectExpression`?f(e,t,a,`${i}.`):[]})}function p(e){let t=c(a(e));if(!t.has(`lightTheme`))throw Error(`lightTheme is not declared in ${e}`);let n=l(t,t.get(`lightTheme`),e),i=u(t,e,n,`typography`);return{color:o(f(t,e,u(t,e,n,`colors`))),space:o(d(u(t,e,n,`spacing`))),radius:o(d(u(t,e,n,`radius`))),shadow:o(d(u(t,e,n,`shadows`))),font:r,text:o(d(u(t,e,i,`fontSize`)))}}function m(e,t,n){let r=l(e,t,n);if(r.type===`StringLiteral`||r.type===`NumericLiteral`)return r.value;if(r.type===`UnaryExpression`&&r.operator===`-`&&r.argument.type===`NumericLiteral`)return-r.argument.value;if(r.type===`ObjectExpression`)return Object.fromEntries(r.properties.map(t=>{if(t.type!==`ObjectProperty`)throw Error(`${n} spreads an object the reader cannot follow.`);return[s(t.key),m(e,t.value,n)]}));throw Error(`${n} has a ${r.type} the reader cannot read as a value.`)}function h(e,t,n){for(let r of[[`typography`,`fontFamily`,`sans`],[`fontFamily`,`sans`]])try{let i=g(e,t,n,r);if(typeof i==`string`&&i!==``)return i}catch{}return`System`}function g(e,t,n,r){let i=l(e,n,t);for(let n of r)i=u(e,t,i,n);return m(e,i,t)}function _(e,t,n){return Object.fromEntries(Object.entries(e).map(([e,r])=>{if(typeof r!=`number`)throw Error(`${t}.${e} in ${n} is not a number.`);return[e,r]}))}function v(e,t,n){if(Object.keys(e).length===0)return`none`;let{shadowColor:r,shadowOffset:i,shadowOpacity:a,shadowRadius:o}=e,s=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(typeof r==`string`?r:``);if(!s||typeof i?.width!=`number`||typeof i?.height!=`number`||typeof a!=`number`||typeof o!=`number`)throw Error(`shadows.${t} in ${n} is not a shadow the reader can draw.`);let c=s[1].length===3?[...s[1]].map(e=>e+e).join(``):s[1],[l,u,d]=[0,2,4].map(e=>Number.parseInt(c.slice(e,e+2),16));return`${i.width}px ${i.height}px ${o}px rgba(${l}, ${u}, ${d}, ${a})`}function y(e){let t=c(a(e));for(let n of[`lightTheme`,`darkTheme`])if(!t.has(n))throw Error(`${n} is not declared in ${e}; the phone kit's token values need the light and dark themes.`);let n=t.get(`lightTheme`),r=t.get(`darkTheme`),o=u(t,e,l(t,n,e),`colors`),s=u(t,e,l(t,r,e),`colors`),d=h(t,e,n);return{color:Object.fromEntries(f(t,e,o).map(n=>{let r=n.split(`.`);return[n,{light:g(t,e,o,r),dark:g(t,e,s,r)}]})),space:_(g(t,e,n,[`spacing`]),`spacing`,e),radius:_(g(t,e,n,[`radius`]),`radius`,e),shadow:Object.fromEntries(Object.entries(g(t,e,n,[`shadows`])).map(([t,n])=>[t,v(n,t,e)])),font:{sans:{family:d,fallback:i}},text:Object.fromEntries(Object.entries(_(g(t,e,n,[`typography`,`fontSize`]),`fontSize`,e)).map(([e,t])=>[e,{size:t,lineHeight:null,weight:null}]))}}function b(e){let t=a(e).program.body.map(e=>e.type===`ExportNamedDeclaration`?e.declaration:e).find(e=>e?.type===`TSTypeAliasDeclaration`&&e.id.name===`IconName`);if(t?.typeAnnotation.type!==`TSUnionType`)throw Error(`IconName union not found in ${e}`);return o(t.typeAnnotation.types.map(t=>{if(t.type!==`TSLiteralType`||t.literal.type!==`StringLiteral`)throw Error(`IconName in ${e} has a member that is not a string literal`);return t.literal.value}))}function x(e,t){for(let[n,r]of[[`itemsTakeAction`,`array`],[`takesAction`,`object`]])for(let[i,a]of Object.entries(t[n]??{})){let t=e.find(({name:e})=>e===i);if(!t)throw Error(`phoneStyleSupport.json ${n} names ${i}, which the kit does not have.`);for(let e of a)if(t.props.find(({name:t})=>t===e)?.type!==r)throw Error(`phoneStyleSupport.json ${n} names ${i}.${e}, which is not a prop of type ${r} in the kit.`);t[n]=o(a)}}export{n as PHONE_EXCLUDED_COMPONENTS,x as applyPhoneActions,b as phoneIcons,y as phoneTokenValues,p as phoneTokens};
|
package/dist/spec.d.ts
CHANGED
|
@@ -14,13 +14,25 @@ export interface CanvasSpecTokenValues {
|
|
|
14
14
|
dark: string;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
export interface CanvasSpecCode {
|
|
18
|
+
component?: string;
|
|
19
|
+
props?: Record<string, unknown>;
|
|
20
|
+
source?: string;
|
|
21
|
+
selector?: string;
|
|
22
|
+
variantProps?: Record<string, unknown>;
|
|
23
|
+
// The CSS classes the imported element carried, at most 8.
|
|
24
|
+
classes?: string[];
|
|
25
|
+
// The Razor partial or other source file the element came from, when the page marked it.
|
|
26
|
+
partial?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
17
29
|
export interface CanvasSpecNode {
|
|
18
30
|
// The node id as the document holds it; an instance inside a placed component is "<instanceId>.<innerId>".
|
|
19
31
|
id: string;
|
|
20
32
|
// The component the node draws: a block type (Box, Text, Image, Icon, Vector) or a library component name.
|
|
21
33
|
component: string;
|
|
22
|
-
// The
|
|
23
|
-
code?:
|
|
34
|
+
// The node's code entry, when the node carries one.
|
|
35
|
+
code?: CanvasSpecCode;
|
|
24
36
|
box: CanvasSpecBox;
|
|
25
37
|
// The CSS the renderer applied to the node's element, keyed by property name.
|
|
26
38
|
styles: Record<string, string>;
|
|
@@ -28,6 +40,8 @@ export interface CanvasSpecNode {
|
|
|
28
40
|
tokens: Record<string, CanvasSpecTokenValues>;
|
|
29
41
|
// The text a Text node draws.
|
|
30
42
|
text?: string;
|
|
43
|
+
// The top-level sampleData keys the node's text and props read; empty when it reads none.
|
|
44
|
+
sampleKeys: string[];
|
|
31
45
|
}
|
|
32
46
|
|
|
33
47
|
export interface CanvasSpec {
|
package/dist/tokens.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readJson as e,readText as t}from"./files.js";import{existsSync as n}from"node:fs";import{join as r}from"node:path";var i=[`none`,`xxs`,`xs`,`sm`,`md`,`lg`,`xl`,`2xl`,`3xl`,`4xl`],a=[`sans`,`display`],o=e=>typeof e==`object`&&!!e&&!Array.isArray(e),s=e=>typeof e==`number`&&Number.isFinite(e),c=e=>typeof e==`string`,l={color:e=>o(e)&&c(e.light)&&c(e.dark),space:s,radius:s,shadow:c,font:e=>o(e)&&c(e.family)&&c(e.fallback),text:e=>o(e)&&s(e.size)&&[e.lineHeight,e.weight].every(e=>e==null||s(e))};function u(e){return[...new Set(e)].sort((e,t)=>e<t?-1:+(e>t))}function d(e){let t=e.replace(/\/\*[\s\S]*?\*\//g,``).replace(/(^|\s)\/\/.*$/gm,`$1`),n=new Map;for(let e of t.matchAll(/(?<![\w-])(--wui-[a-z0-9-]+)\s*:([^;]*);/g))n.has(e[1])||n.set(e[1],e[2].replace(/\s+/g,` `).trim());let r=(e,t=0)=>{let i=n.get(e);if(i===void 0)return!1;if(/^(
|
|
1
|
+
import{readJson as e,readText as t}from"./files.js";import{existsSync as n}from"node:fs";import{join as r}from"node:path";var i=[`none`,`xxs`,`xs`,`sm`,`md`,`lg`,`xl`,`2xl`,`3xl`,`4xl`],a=[`sans`,`display`],o=e=>typeof e==`object`&&!!e&&!Array.isArray(e),s=e=>typeof e==`number`&&Number.isFinite(e),c=e=>typeof e==`string`,l={color:e=>o(e)&&c(e.light)&&c(e.dark),space:s,radius:s,shadow:c,font:e=>o(e)&&c(e.family)&&c(e.fallback),text:e=>o(e)&&s(e.size)&&[e.lineHeight,e.weight].every(e=>e==null||s(e))};function u(e){return[...new Set(e)].sort((e,t)=>e<t?-1:+(e>t))}function d(e){let t=e.replace(/\/\*[\s\S]*?\*\//g,``).replace(/(^|\s)\/\/.*$/gm,`$1`),n=new Map;for(let e of t.matchAll(/(?<![\w-])(--wui-[a-z0-9-]+)\s*:([^;]*);/g))n.has(e[1])||n.set(e[1],e[2].replace(/\s+/g,` `).trim());let r=(e,t=0)=>{let i=n.get(e);if(i===void 0)return!1;if(/^(#[0-9a-fA-F]|rgba?\(|hsla?\()/.test(i))return!0;let a=/^var\((--wui-[a-z0-9-]+)\)$/.exec(i);return a!==null&&t<10&&r(a[1],t+1)},o=e=>u([...n.keys()].filter(t=>t.startsWith(e)).map(t=>t.slice(e.length)));return{color:u([...n.keys()].filter(e=>r(e)&&!e.startsWith(`--wui-font-`)&&!e.startsWith(`--wui-dark-`)).map(e=>e.slice(6))),space:u(i),radius:o(`--wui-radius-`),shadow:o(`--wui-shadow-`),font:u(a),text:o(`--wui-fs-`)}}function f(e,t){return Object.fromEntries(e.map(e=>{let n=t[`--wui-${e}`];if(typeof n!=`string`||n===``)throw Error(`@webority/theme token-meanings.json has no meaning for --wui-${e}; move the theme pin to a version that publishes one.`);return[e,n]}))}function p(e){let n=r(e,`components`,`iconCatalogNames.g.js`),i=t(n),a=/`([^`]+)`\.split\(`\.`\)/.exec(i);if(!a)throw Error(`No icon name list in ${n}`);return u(a[1].split(`.`).filter(Boolean))}function m(t,r){if(!n(t))throw Error(`${t} is missing; rebuild the release with canvas-kit build.`);let i=e(t),a={};for(let[e,n]of Object.entries(l)){let s=o(i)&&o(i[e])?i[e]:null;if(!s)throw Error(`${t} has no ${e} object; rebuild the release with canvas-kit build.`);for(let[r,i]of Object.entries(s))if(!n(i))throw Error(`${t}: ${e}.${r} is not a value the kit can draw; rebuild the release with canvas-kit build.`);if(e!==`space`){let n=r[e].filter(e=>!Object.hasOwn(s,e));if(n.length>0)throw Error(`${t} has no ${e} value for ${n.join(`, `)}; rebuild the release with canvas-kit build.`)}a[e]=e===`text`?g(s,h):s}return a}function h({size:e,lineHeight:t,weight:n}){return{size:e,lineHeight:t??null,weight:n??null}}function g(e,t){return Object.fromEntries(Object.entries(e).map(([e,n])=>[e,t(n)]))}export{f as colourMeanings,p as webIcons,m as webTokenValues,d as webTokens};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webority/canvas-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.86.0",
|
|
4
4
|
"description": "Builds product kits for Webority Canvas: a kit bundle, its manifest, and the spec shape the renderers answer.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"react": "^19.2.6",
|
|
26
|
-
"@webority/ui-react": "0.
|
|
26
|
+
"@webority/ui-react": "0.86.0"
|
|
27
27
|
},
|
|
28
28
|
"scripts": {
|
|
29
29
|
"build": "vite build --config vite.cli.config.js",
|