@webority/canvas-kit 0.125.0 → 0.126.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +7 -3
- package/dist/build.js +3 -3
- package/dist/kitModule.js +1 -1
- package/package.json +1 -1
package/LICENSE
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
Copyright (c) Webority Technologies. All rights reserved.
|
|
2
2
|
|
|
3
|
-
This software and its
|
|
4
|
-
Webority Technologies.
|
|
5
|
-
|
|
3
|
+
This software and its NuGet packages are the proprietary and confidential property
|
|
4
|
+
of Webority Technologies. They are published publicly only for the convenience of
|
|
5
|
+
Webority's own projects and internal consumption.
|
|
6
|
+
|
|
7
|
+
No license or right to use, copy, modify, merge, publish, distribute, sublicense,
|
|
8
|
+
or create derivative works is granted to any third party. Unauthorized use,
|
|
9
|
+
reproduction, or distribution is prohibited.
|
package/dist/build.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
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{digest as o,writeReleaseFolder as s}from"./release.js";import{existsSync as c,realpathSync 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`,`libraryPackage`,`components`,`tokens`,`rolesFile`,`styles`,`rendererProtocolVersion`],v=[`kit`,`platform`,`libraryPackage`,`components`,`tokens`,`rendererProtocolVersion`],y=`canvas-kit:entry`,b=`\0${y}`,x=d(u(p(import.meta.url)),`kitModule.js`),S={"process.env.NODE_ENV":JSON.stringify(`production`),"process.env":`{}`,__DEV__:`false`},C=/(?<![\w$."'`])(process\.env|__DEV__)(?![\w$])/;function w(e){let n=t(e);if(typeof n!=`object`||!n||Array.isArray(n))throw Error(`${e} must be a JSON object.`);if(n.entry!==void 0)throw Error(`${e}: A kit lists its components with components, a glob of .meta.js files; entry is retired.`);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`,`components`,`tokens`])if(typeof n[t]!=`string`)throw Error(`${e}: ${t} must be a string.`);for(let t of[`rolesFile`])if(n[t]!==void 0&&typeof n[t]!=`string`)throw Error(`${e}: ${t} must be a string path.`);if(n.styles!==void 0){if(!Array.isArray(n.styles)||n.styles.some(e=>typeof e!=`string`||e===``))throw Error(`${e}: styles must be a list of style file paths.`);for(let t of n.styles){if(!/\.(css|scss)$/.test(t))throw Error(`${e}: styles names ${t}, which is not a .css or .scss file.`);if(!c(f(u(e),t)))throw Error(`${e}: styles names ${t}, which does not exist.`)}}return n}function T(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 E(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 D({styleFiles:e,libraryFile:t,
|
|
2
|
-
`)}function O(e){return{name:`canvas-kit-entry`,resolveId(e){return e===y?b:null},load(t){return t===b?e:null}}}function k(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 A({root:e,kit:t,platform:n,styleFiles:i,libraryFile:a,
|
|
3
|
-
`);return{script:
|
|
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{digest as o,writeReleaseFolder as s}from"./release.js";import{existsSync as c,realpathSync 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`,`libraryPackage`,`components`,`tokens`,`rolesFile`,`styles`,`rendererProtocolVersion`],v=[`kit`,`platform`,`libraryPackage`,`components`,`tokens`,`rendererProtocolVersion`],y=`canvas-kit:entry`,b=`\0${y}`,x=d(u(p(import.meta.url)),`kitModule.js`),S={"process.env.NODE_ENV":JSON.stringify(`production`),"process.env":`{}`,__DEV__:`false`},C=/(?<![\w$."'`])(process\.env|__DEV__)(?![\w$])/;function w(e){let n=t(e);if(typeof n!=`object`||!n||Array.isArray(n))throw Error(`${e} must be a JSON object.`);if(n.entry!==void 0)throw Error(`${e}: A kit lists its components with components, a glob of .meta.js files; entry is retired.`);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`,`components`,`tokens`])if(typeof n[t]!=`string`)throw Error(`${e}: ${t} must be a string.`);for(let t of[`rolesFile`])if(n[t]!==void 0&&typeof n[t]!=`string`)throw Error(`${e}: ${t} must be a string path.`);if(n.styles!==void 0){if(!Array.isArray(n.styles)||n.styles.some(e=>typeof e!=`string`||e===``))throw Error(`${e}: styles must be a list of style file paths.`);for(let t of n.styles){if(!/\.(css|scss)$/.test(t))throw Error(`${e}: styles names ${t}, which is not a .css or .scss file.`);if(!c(f(u(e),t)))throw Error(`${e}: styles names ${t}, which does not exist.`)}}return n}function T(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 E(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 D({styleFiles:e,libraryFile:t,libraryPackage:r,chromeFile:i,manifest:a,libraryNames:o,chromeNames:s,productModules:c}){let l=[...c],u=[...o.map(({fixedProps:e})=>e),...l.map(([,{fixedProps:e}])=>e)].some(e=>e!==void 0),d=e.map(e=>`import ${JSON.stringify(n(e))};`);u&&d.push(`import { createElement } from "react";`),d.push(`import { ${u?`defineKit, withFixedProps`:`defineKit`} } from ${JSON.stringify(n(x))};`),l.forEach(([,{module:e,exportName:t}],r)=>{d.push(`import { ${t} as product${r} } from ${JSON.stringify(n(e))};`)});let f=a.platform===`Phone`,p=f&&r===`@webority/mobile-ui`,m=[...new Set(o.map(({exportName:e})=>e))];p&&!m.includes(`KitThemeBridge`)&&m.push(`KitThemeBridge`),m.length>0&&d.push(`import { ${m.join(`, `)} } from ${JSON.stringify(n(t))};`),s.length>0&&d.push(`import { ${s.join(`, `)} } from ${JSON.stringify(n(i))};`),f&&!p&&d.push(`import { KitThemeBridge } from "@webority/mobile-ui";`);let h=(e,t,n)=>n===void 0?e===t?e:`${e}: ${t}`:`${e}: withFixedProps(createElement, ${t}, ${JSON.stringify(n)}, ${JSON.stringify(e)})`,g=[...o.map(({name:e,exportName:t,fixedProps:n})=>h(e,t,n)),...s,...l.map(([e,{fixedProps:t}],n)=>h(e,`product${n}`,t))],_=Object.fromEntries(a.components.filter(({marker:e})=>e!==null).map(({name:e,marker:t})=>[e,t])),v=f?`, themeBridge: KitThemeBridge`:``;return d.push(`export default defineKit({ components: { ${g.join(`, `)} }, markers: ${JSON.stringify(_)}, tokenValues: ${JSON.stringify(a.tokenValues)}, manifest: ${JSON.stringify(a)}${v} });`,``),d.join(`
|
|
2
|
+
`)}function O(e){return{name:`canvas-kit-entry`,resolveId(e){return e===y?b:null},load(t){return t===b?e:null}}}function k(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 A({root:e,kit:t,platform:n,styleFiles:i,libraryFile:a,libraryPackage:o,chromeFile:s,libraryNames:c,chromeNames:l,productModules:u,manifest:d}){let f=r[n],p=await m({configFile:!1,root:e,logLevel:`warn`,publicDir:!1,envDir:!1,define:S,plugins:[O(D({styleFiles:i,libraryFile:a,libraryPackage:o,chromeFile:s,manifest:d,libraryNames:c,chromeNames:l,productModules:u})),k(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=>f.some(t=>e===t||e.startsWith(`${t}/`)),output:{codeSplitting:!1}}}}),h=(Array.isArray(p)?p:[p]).flatMap(e=>e.output),g=h.find(e=>e.type===`chunk`&&e.isEntry);if(!g)throw Error(`The bundle of ${t} has no entry module.`);let _=C.exec(g.code);if(_)throw Error(`The bundle of ${t} still reads ${_[1]}, which the renderer does not define.`);let v=h.filter(e=>e.type===`chunk`&&!e.isEntry);if(v.length>0)throw Error(`The bundle of ${t} split ${v.map(e=>e.fileName).join(`, `)} out of kit.js; a kit must be one file.`);let b=h.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:g.code,styles:b}}async function j({configFile:e,outDir:t,styleKeysFile:n,phoneRendererSupportFile:r}){let d=f(e),p=f(t);if(c(p))throw Error(`${p} already exists. A release folder is never overwritten; choose a new folder.`);let m=w(d),h=l(u(d));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.`);T(h);let g=m.rolesFile===void 0?void 0:f(h,m.rolesFile),{manifest:_,warnings:v,phoneChromeNames:y,productModules:b}=await a({projectRoot:h,kit:m.kit,platform:m.platform,components:m.components,tokens:m.tokens,libraryPackage:m.libraryPackage,rolesFile:g,rendererProtocolVersion:m.rendererProtocolVersion,phoneRendererSupportFile:r===void 0?void 0:f(r),styleKeysFile:n===void 0?void 0:f(n)}),x=i(h,m.libraryPackage),S=E(h),C=_.components.filter(({source:e,name:t})=>e===m.libraryPackage&&!y.includes(t)).map(({name:e,component:t,fixedProps:n})=>({name:e,exportName:t??e,...n===void 0?{}:{fixedProps:n}})),{script:D,styles:O}=await A({root:h,kit:m.kit,platform:m.platform,styleFiles:(m.styles??[]).map(e=>f(h,e)),libraryFile:x.entryFile,libraryPackage:m.libraryPackage,chromeFile:x.canvasKitFile,libraryNames:C,chromeNames:y,productModules:b,manifest:_}),k={"manifest.json":`${JSON.stringify(_,null,2)}\n`,"kit.js":D,"kit.css":O},j={name:m.kit,version:S,platform:m.platform,kitModuleVersion:2,rendererProtocolVersion:m.rendererProtocolVersion,library:_.library,files:Object.fromEntries(Object.entries(k).map(([e,t])=>[e,o(t)]))};return s(p,k,j),{outDir:p,release:j,manifest:_,warnings:v}}export{j as buildKitRelease,w as readConfig};
|
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`,`@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(e,t,n,r){let i=r=>e(t,{...r,...n});return i.displayName=r,i}function r({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
|
|
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(e,t,n,r){let i=r=>e(t,{...r,...n});return i.displayName=r,i}function r({components:e,markers:n,tokenValues:r,manifest:i,themeBridge:a}){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 o={};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.`);o[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(o,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.`);if(a!==void 0&&(a===null||typeof a!=`function`&&typeof a!=`object`))throw Error(`defineKit: themeBridge must be a React component.`);return{components:Object.freeze(o),markers:Object.freeze({...n}),tokenValues:r,manifest:i,themeBridge:a??null}}export{t as KIT_MODULE_EXTERNALS,r as defineKit,e as kitModuleVersion,n as withFixedProps};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webority/canvas-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.126.1",
|
|
4
4
|
"description": "Builds product kits for Webority Canvas: a kit bundle, its manifest, and the spec shape the renderers answer.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"private": false,
|