@webority/canvas-kit 0.86.0 → 0.86.3
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/build.js +2 -2
- package/dist/tokens.js +1 -1
- package/package.json +2 -2
package/dist/build.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import{findPackageDir as e,readJson as t,toPosix as n}from"./files.js";import{KIT_MODULE_EXTERNALS as r}from"./kitModule.js";import{libraryFiles as i,readManifest as a}from"./manifest.js";import{checkFleetFolder as o,digest as s,writeReleaseFolder as c}from"./release.js";import{existsSync as l}from"node:fs";import{dirname as u,join as d,resolve as f}from"node:path";import{fileURLToPath as p}from"node:url";import{build as m}from"vite";var h=19,g=[`react-redux`,`react-router-dom`,`axios`],_=[`kit`,`platform`,`entry`,`libraryPackage`,`rolesFile`,`rendererProtocolVersion`],v=[`kit`,`platform`,`libraryPackage`,`rendererProtocolVersion`],y=`canvas-kit:entry`,b=`\0${y}`,x=d(u(p(import.meta.url)),`kitModule.js`);function S(e){let n=t(e);if(typeof n!=`object`||!n||Array.isArray(n))throw Error(`${e} must be a JSON object.`);for(let t of Object.keys(n))if(!_.includes(t))throw Error(`${e} has the unknown key ${t}. The keys are ${_.join(`, `)}.`);for(let t of v)if(n[t]===void 0)throw Error(`${e} needs the key ${t}.`);for(let t of[`kit`,`platform`,`libraryPackage`])if(typeof n[t]!=`string`)throw Error(`${e}: ${t} must be a string.`);for(let t of[`entry`,`rolesFile`])if(n[t]!==void 0&&typeof n[t]!=`string`)throw Error(`${e}: ${t} must be a string path.`);return n}function C(n){let r=e(n,`react`);if(!r)throw Error(`react is not installed for ${n}. Run pnpm install there.`);let{version:i}=t(d(r,`package.json`));if(Number(String(i).split(`.`)[0])!==h)throw Error(`The product uses React ${i}; the Canvas renderer runs React ${h}. Pin react to ${h}.x and rebuild.`)}function w(e){let{version:n}=t(d(e,`package.json`));if(!n)throw Error(`${d(e,`package.json`)} needs a version; the release is stamped with it.`);return n}function T({entryFile:e,libraryFile:t,manifest:r,libraryNames:i,productNames:a}){let o=[`import { defineKit } from ${JSON.stringify(n(x))};`];e!==void 0&&o.push(`import * as product from ${JSON.stringify(n(e))};`),i.length>0&&o.push(`import { ${i.join(`, `)} } from ${JSON.stringify(n(t))};`);let s=[...i,...a.map(e=>`${e}: product.${e}`)],c=Object.fromEntries(r.components.filter(({marker:e})=>e!==null).map(({name:e,marker:t})=>[e,t]));return o.push(`export default defineKit({ components: { ${s.join(`, `)} }, markers: ${JSON.stringify(c)}, tokenValues: ${JSON.stringify(r.tokenValues)}, manifest: ${JSON.stringify(r)} });`,``),o.join(`
|
|
2
|
-
`)}function E(e){return{name:`canvas-kit-entry`,resolveId(e){return e===y?b:null},load(t){return t===b?e:null}}}function D(e){let t=`${n(d(e,`src`,`services`))}/`;return{name:`canvas-kit-banned-imports`,transform(e,r){let i=n(r.split(`?`)[0]),a=g.find(e=>i.includes(`/node_modules/${e}/`));if(a)throw Error(`The kit imports ${a} (${i}). A kit draws from its props only; the container that renders it holds the state and the calls.`);if(i.startsWith(t))throw Error(`The kit imports ${i}, which is in src/services. A kit draws from its props only; move the call into the container.`);return null}}}async function O({root:e,kit:t,platform:n,entryFile:i,libraryFile:a,libraryNames:o,productNames:s,manifest:c}){let l=r[n],u=await m({configFile:!1,root:e,logLevel:`warn`,publicDir:!1,envDir:!1,plugins:[E(T({entryFile:i,libraryFile:a,manifest:c,libraryNames:o,productNames:s})),D(e)],esbuild:{jsx:`automatic`,jsxImportSource:`react`,include:/\.[cm]?[jt]sx?$/},build:{write:!1,minify:!0,target:`es2022`,cssCodeSplit:!1,lib:{entry:y,formats:[`es`],fileName:()=>`kit.js`},rollupOptions:{input:y,external:e=>l.some(t=>e===t||e.startsWith(`${t}/`))}}}),d=(Array.isArray(u)?u:[u]).flatMap(e=>e.output),f=d.find(e=>e.type===`chunk`&&e.isEntry);if(!f)throw Error(`The bundle of ${t} has no entry module.`);let p=d.filter(e=>e.type===`asset`&&e.fileName.endsWith(`.css`)).map(e=>typeof e.source==`string`?e.source:Buffer.from(e.source).toString(`utf8`)).join(`
|
|
3
|
-
`);return{script:f.code,styles:
|
|
2
|
+
`)}function E(e){return{name:`canvas-kit-entry`,resolveId(e){return e===y?b:null},load(t){return t===b?e:null}}}function D(e){let t=`${n(d(e,`src`,`services`))}/`;return{name:`canvas-kit-banned-imports`,transform(e,r){let i=n(r.split(`?`)[0]),a=g.find(e=>i.includes(`/node_modules/${e}/`));if(a)throw Error(`The kit imports ${a} (${i}). A kit draws from its props only; the container that renders it holds the state and the calls.`);if(i.startsWith(t))throw Error(`The kit imports ${i}, which is in src/services. A kit draws from its props only; move the call into the container.`);return null}}}async function O({root:e,kit:t,platform:n,entryFile:i,libraryFile:a,libraryNames:o,productNames:s,manifest:c}){let l=r[n],u=await m({configFile:!1,root:e,logLevel:`warn`,publicDir:!1,envDir:!1,plugins:[E(T({entryFile:i,libraryFile:a,manifest:c,libraryNames:o,productNames:s})),D(e)],esbuild:{jsx:`automatic`,jsxImportSource:`react`,include:/\.[cm]?[jt]sx?$/},build:{write:!1,minify:!0,target:`es2022`,cssCodeSplit:!1,lib:{entry:y,formats:[`es`],fileName:()=>`kit.js`},rollupOptions:{input:y,external:e=>l.some(t=>e===t||e.startsWith(`${t}/`)),output:{inlineDynamicImports:!0}}}}),d=(Array.isArray(u)?u:[u]).flatMap(e=>e.output),f=d.find(e=>e.type===`chunk`&&e.isEntry);if(!f)throw Error(`The bundle of ${t} has no entry module.`);let p=d.filter(e=>e.type===`chunk`&&!e.isEntry);if(p.length>0)throw Error(`The bundle of ${t} split ${p.map(e=>e.fileName).join(`, `)} out of kit.js; a kit must be one file.`);let h=d.filter(e=>e.type===`asset`&&e.fileName.endsWith(`.css`)).map(e=>typeof e.source==`string`?e.source:Buffer.from(e.source).toString(`utf8`)).join(`
|
|
3
|
+
`);return{script:f.code,styles:h}}async function k({configFile:e,outDir:t,styleKeysFile:n,phoneRendererSupportFile:r}){let d=f(e),p=f(t);if(l(p))throw Error(`${p} already exists. A release folder is never overwritten; choose a new folder.`);let m=S(d),h=u(d),g=m.entry===void 0,_=g?void 0:f(h,m.entry);if(_!==void 0&&!l(_))throw Error(`The kit entry ${_} does not exist.`);if(g&&n===void 0)throw Error(`A library-only kit needs --style-keys: the style key table the renderer draws from.`);if(m.platform===`Phone`&&r===void 0)throw Error(`A Phone kit needs --phone-renderer-support: the phone renderer's support file.`);if(m.platform!==`Phone`&&r!==void 0)throw Error(`Only a Phone kit reads --phone-renderer-support; a Web kit takes no phone support file.`);C(h);let v=m.rolesFile===void 0?void 0:f(h,m.rolesFile),{manifest:y,warnings:b}=a({projectRoot:h,kit:m.kit,platform:m.platform,entry:_,libraryPackage:m.libraryPackage,rolesFile:v,rendererProtocolVersion:m.rendererProtocolVersion,phoneRendererSupportFile:r===void 0?void 0:f(r),styleKeysFile:n===void 0?void 0:f(n)}),x=i(h,m.libraryPackage),T=g?x.pkg.version:w(h);g&&o(p,m.kit,T);let E=y.components.filter(({source:e})=>e===m.libraryPackage).map(({name:e})=>e),D=y.components.filter(({source:e})=>e!==m.libraryPackage).map(({name:e})=>e),{script:k,styles:A}=await O({root:h,kit:m.kit,platform:m.platform,entryFile:_,libraryFile:x.entryFile,libraryNames:E,productNames:D,manifest:y}),j={"manifest.json":`${JSON.stringify(y,null,2)}\n`,"kit.js":k,"kit.css":A},M={name:m.kit,version:T,platform:m.platform,kitModuleVersion:2,rendererProtocolVersion:m.rendererProtocolVersion,library:y.library,files:Object.fromEntries(Object.entries(j).map(([e,t])=>[e,s(t)]))};return c(p,j,M),{outDir:p,release:M,manifest:y,warnings:b}}export{k as buildKitRelease,S as readConfig};
|
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(/^(#[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};
|
|
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`,`mono`],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.86.
|
|
3
|
+
"version": "0.86.3",
|
|
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.86.
|
|
26
|
+
"@webority/ui-react": "0.86.3"
|
|
27
27
|
},
|
|
28
28
|
"scripts": {
|
|
29
29
|
"build": "vite build --config vite.cli.config.js",
|