@webority/canvas-kit 0.165.0 → 0.167.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/metaCheck.js +4 -4
- package/dist/metaCheckRunner.mjs +47 -48
- package/dist/renames.js +1 -1
- package/package.json +2 -2
package/dist/metaCheck.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{toPosix as e}from"./files.js";import{createRequire as t}from"node:module";import{
|
|
2
|
-
`)}\n`);let i=
|
|
1
|
+
import{toPosix as e}from"./files.js";import{createRequire as t}from"node:module";import{existsSync as n,mkdirSync as r,readFileSync as i,readdirSync as a,realpathSync as o,rmSync as s,writeFileSync as c}from"node:fs";import{dirname as l,join as u}from"node:path";import{fileURLToPath as d}from"node:url";import{execFileSync as f}from"node:child_process";import{availableParallelism as p}from"node:os";var m=u(l(t(import.meta.url).resolve(`typescript/package.json`)),`bin`,`tsc`),h=u(l(d(import.meta.url)),`metaRules`),g=u(l(d(import.meta.url)),`metaCheckRunner.mts`),_=n(g)?g:u(l(g),`metaCheckRunner.mjs`),v=20,y=1;function b(){if(process.platform!==`linux`||!n(`/proc/self/cgroup`))return null;let e=i(`/proc/self/cgroup`,`utf8`).match(/^0::(.*)$/m)?.[1];if(e===void 0)return null;let t=`/sys/fs/cgroup${e}`;if(!n(`${t}/memory.max`)||!n(`${t}/memory.current`))return null;let r=i(`${t}/memory.max`,`utf8`).trim();return r===`max`?null:(Number(r)-Number(i(`${t}/memory.current`,`utf8`).trim()))/2**30}function x(){let e=Math.max(1,Math.min(4,p())),t=b();return t===null?e:Math.max(1,Math.min(e,Math.floor(t/y)))}var S=/^check\.ts\((\d+),\d+\): error TS\d+: (.*)$/,C=/^(.+?)\(\d+,\d+\): error TS\d+: (.*)$/,w=[`propsNotInMeta`,`metaPropsNotOnComponent`,`propsThatDiffer`,`children`,`fixedProps`],T={propsNotInMeta:`props the component takes that the meta does not list`,metaPropsNotOnComponent:`props the meta lists that the component does not take`,propsThatDiffer:`props whose type, required or nullable flag, or nested fields differ from the component`,fixedProps:`fixed props whose value does not fit the component's prop`};function E(e){return Object.hasOwn(T,e)}function D(e){return j(e)&&typeof e.status==`number`&&typeof e.output==`string`}function O(t){let n=e(t);return/\.d\.ts$/.test(n)?n.replace(/\.d\.ts$/,``):n.replace(/\.(jsx|tsx|js|ts|mjs)$/,``)}function k(e){let t=[];for(let n of e.split(/\r?\n/)){let e=S.exec(n);if(e){t.push({line:Number(e[1]),file:null,message:e[2]??``});continue}let r=C.exec(n);r&&t.push({line:null,file:r[1]??null,message:r[2]??``})}return t}function A(e){let t=/Type '(\{[^']*\})'/.exec(e);return t?[...(t[1]??``).matchAll(/: "([^"]+)"/g)].map(e=>e[1]??``):[]}function j(e){return typeof e==`object`&&!!e}function M(e){let t=new Map,n=(e,n,r,i)=>{let a=`${e} ${n}`;t.has(a)||t.set(a,{component:e,handler:n,path:r,owner:i})},r=(e,t,i)=>{if(!j(e))return;let a=e.handlers??[];if(!Array.isArray(a))throw Error(`handlerPairs: the handlers at ${t} are not a list`);for(let r of a)n(String(e.component),String(r),t,i);Array.isArray(e.children)&&e.children.forEach((e,n)=>{r(e,`${t}.children[${n}]`,i)})};return e.forEach(({meta:e},t)=>{(e.examples??[]).forEach((i,a)=>{let o=`examples[${a}]`;for(let r of i.handlers??[])n(e.name,r,o,t);r({children:i.children},o,t),r(i.wrap,`${o}.wrap`,t)});for(let r of Object.keys(e.actions??{}))n(e.name,r,`actions.${r}`,t);for(let n of[`do`,`dont`])(e.usage?.[n]??[]).forEach((e,i)=>{(e.example??[]).forEach((e,a)=>{r(e,`usage.${n}[${i}].example[${a}]`,t)})})}),t}function N(e){let t=``;return typeof e==`object`&&e&&`stdout`in e&&(t+=String(e.stdout??``)),typeof e==`object`&&e&&`stderr`in e&&(t+=String(e.stderr??``)),t}var P=/^\.canvas-kit-check-(\d+)$/;function F(e){return typeof e==`object`&&e&&`code`in e?e.code:void 0}function I(e){try{return process.kill(e,0),!0}catch(e){if(F(e)===`EPERM`)return!0;if(F(e)===`ESRCH`)return!1;throw e}}function L(e){let t;try{t=a(e)}catch(e){if(F(e)===`ENOENT`)return[];throw e}let n=[];for(let r of t){let t=Number(P.exec(r)?.[1]);t&&t!==process.pid&&!I(t)&&(s(u(e,r),{recursive:!0,force:!0}),n.push(r))}return n}function R(){return{lines:[`import type { ExtraProps, MissingProps, MismatchedProps, ChildrenOk, HandlerKeys, Flatten } from "${e(h)}";`,`type N = import("react").ReactNode;`,`type D = { "html attributes": import("react").AllHTMLAttributes<HTMLElement>; "svg attributes": import("react").SVGAttributes<SVGElement> } & import("react").JSX.IntrinsicElements;`,`type Empty = { [key: string]: never };`],owners:new Map,kinds:new Map,handlerLines:new Map}}function z(e,t,n=-1,r=null){e.lines.push(t);let i=e.lines.length;n>=0&&e.owners.set(i,n),r&&e.kinds.set(i,r)}function B({root:t,metas:n,componentOf:i}){let a=u(o(t),`node_modules`);L(a);let l=u(a,`.canvas-kit-check-${process.pid}`);try{r(l,{recursive:!0});let t=n.map(({meta:e,file:t})=>({component:O(i(t,e.component??e.name)),meta:O(t)})),a=new Map;for(let e=0;e<Math.ceil(n.length/v);e+=1)a.set(e,R());let o=e=>{let t=a.get(Math.floor(e/v));if(!t)throw Error(`checkMetaTypes: no chunk holds meta ${e}`);return t};n.forEach((e,n)=>{let r=o(n);z(r,`import type * as C${n} from "${t[n]?.component}";`,n),z(r,`import type { meta as M${n} } from "${t[n]?.meta}";`,n)});let s=e=>`{ [K in ${e}]: K }`;n.forEach(({meta:e},t)=>{let n=o(t),r=(e,r=null)=>z(n,e,t,r),i=e.name;r(`type P${t} = Flatten<import("react").ComponentProps<typeof C${t}.${e.component??e.name}>>;`),r(`export const ${i}__propsNotInMeta: Empty = null as unknown as ${s(`ExtraProps<P${t}, typeof M${t}, D>`)};`,`propsNotInMeta`),r(`export const ${i}__metaPropsNotOnComponent: Empty = null as unknown as ${s(`MissingProps<P${t}, typeof M${t}>`)};`,`metaPropsNotOnComponent`),r(`export const ${i}__propsThatDiffer: Empty = null as unknown as ${s(`MismatchedProps<P${t}, typeof M${t}, N>`)};`,`propsThatDiffer`),r(`export const ${i}__children: true = null as unknown as ChildrenOk<P${t}, typeof M${t}, D>;`,`children`),e.fixedProps!==void 0&&r(`export const ${i}__fixedProps: Partial<P${t}> = null as unknown as NonNullable<(typeof M${t})["fixedProps"]>;`,`fixedProps`)});let d=new Map(n.map(({meta:e},t)=>[e.name,t])),p=0;for(let{component:t,handler:r,path:i,owner:a}of M(n).values()){let s=d.get(t);if(s===void 0)continue;p+=1;let c=o(s);z(c,`export const ${t.replace(/[^A-Za-z0-9_]/g,`_`)}__handler_${r}_${p}: Empty = null as unknown as { [K in Exclude<"${r}", HandlerKeys<P${s}>>]: K };`),c.handlerLines.set(c.lines.length,{owner:a,where:`${e(n[a]?.file??``)}: ${i}`,component:t,handler:r})}let h=[];for(let[e,t]of a){let n=u(l,`chunk-${e}`);r(n),c(u(n,`check.ts`),`${t.lines.join(`
|
|
2
|
+
`)}\n`);let i=u(n,`tsconfig.json`);c(i,JSON.stringify({compilerOptions:{strict:!0,noEmit:!0,allowJs:!0,checkJs:!1,jsx:`react-jsx`,module:`esnext`,moduleResolution:`bundler`,allowImportingTsExtensions:!0,target:`es2022`,skipLibCheck:!0,noErrorTruncation:!0,types:[]},files:[`check.ts`]},null,2)),h.push(i)}let g;try{g=f(process.execPath,[_,m,String(x()),...h],{encoding:`utf8`,stdio:`pipe`,maxBuffer:268435456,windowsHide:!0})}catch(e){throw Error(`checkMetaTypes: the type check runner failed: ${N(e)}`)}let y=JSON.parse(g);if(!Array.isArray(y)||!y.every(D)||y.length!==a.size)throw Error(`checkMetaTypes: the type check runner did not answer with one result per chunk: ${g}`);let b=y;if(b.every(e=>e.status===0))return;let S=new Map,C=[],j=[],P=(r,i)=>{for(let a of k(r)){let r=a.line===null?void 0:i.handlerLines.get(a.line);if(r){C.push({owner:r.owner,rank:w.length,text:`${r.where}: "${r.handler}" is not a function prop of ${r.component}`});continue}let o=a.line===null?void 0:i.owners.get(a.line),s=a.line===null?void 0:i.kinds.get(a.line);if(s&&o!==void 0){let e=`${o}:${s}`;if(S.has(e)||S.set(e,{owner:o,kind:s,names:new Set}),s!==`children`)for(let t of A(a.message))S.get(e)?.names.add(t);continue}let c=o??t.findIndex(e=>[a.file,a.message].some(t=>t&&(t.includes(e.component)||t.includes(e.meta)))),l=a.line===null?`${e(a.file??``)}: `:``;C.push({owner:c,rank:-1,text:`${c>=0?n[c]?.meta.name:`metaCheck`}: tsc could not read the check file: ${l}${a.message}`})}};for(let[e,t]of a){let n=b[e];if(!n)throw Error(`checkMetaTypes: the type check runner gave no result for chunk ${e}`);n.status!==0&&(j.push(n.output),P(n.output,t))}for(let{owner:e,kind:t,names:r}of S.values()){let i=n[e];if(!i)throw Error(`checkMetaTypes: no meta at index ${e} to report on`);let{meta:a}=i,o;if(t===`children`)o=`${a.name}: acceptsChildren is ${a.acceptsChildren} but the component ${a.acceptsChildren?`does not take`:`takes`} children`;else{if(!E(t))throw Error(`metaCheck: no sentence for finding kind ${t}`);o=r.size>0?`${a.name}: ${T[t]}: ${[...r].sort().join(`, `)}`:`${a.name}: ${T[t]}: see the meta against the component's props`}C.push({owner:e,rank:w.indexOf(t),text:o})}throw C.length===0?Error(`metaCheck: tsc failed: ${j.join(`
|
|
3
3
|
`).split(/\r?\n/).slice(0,20).join(`
|
|
4
|
-
`)}`):(
|
|
5
|
-
`)))}finally{
|
|
4
|
+
`)}`):(C.sort((e,t)=>e.owner-t.owner||e.rank-t.rank),Error(C.map(e=>e.text).join(`
|
|
5
|
+
`)))}finally{s(l,{recursive:!0,force:!0})}}export{m as TSC,B as checkMetaTypes,L as removeDeadCheckFolders,O as specifierOf};
|
package/dist/metaCheckRunner.mjs
CHANGED
|
@@ -1,59 +1,58 @@
|
|
|
1
|
-
// Runs tsc on each meta check chunk, a few at a time, and prints one { status, output } per chunk as JSON on stdout.
|
|
2
|
-
// A tsc that exits non-zero is a finding, not a failure of the runner; a tsc that cannot start is.
|
|
3
|
-
|
|
4
1
|
import { execFile } from "node:child_process";
|
|
5
2
|
import { dirname } from "node:path";
|
|
6
|
-
|
|
7
3
|
const MAX_BUFFER = 64 * 1024 * 1024;
|
|
8
4
|
const [tsc, concurrencyText, ...tsconfigs] = process.argv.slice(2);
|
|
9
5
|
const concurrency = Number(concurrencyText);
|
|
10
6
|
let failure = null;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
);
|
|
32
|
-
|
|
7
|
+
function runTsc(tsc2, tsconfig) {
|
|
8
|
+
return new Promise((resolve) => {
|
|
9
|
+
execFile(
|
|
10
|
+
process.execPath,
|
|
11
|
+
[tsc2, "-p", tsconfig, "--pretty", "false"],
|
|
12
|
+
{ cwd: dirname(tsconfig), encoding: "utf8", maxBuffer: MAX_BUFFER, windowsHide: true },
|
|
13
|
+
(error, stdout, stderr) => {
|
|
14
|
+
const output = `${stdout}${stderr}`;
|
|
15
|
+
if (error === null) {
|
|
16
|
+
resolve({ status: 0, output });
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (typeof error.code === "number") {
|
|
20
|
+
resolve({ status: error.code, output });
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const cause = [
|
|
24
|
+
error.code !== void 0 && error.code !== null ? `code ${error.code}` : null,
|
|
25
|
+
error.signal ? `signal ${error.signal}` : null
|
|
26
|
+
].filter((part) => part !== null).join(", ");
|
|
27
|
+
const tail = output.trim().split("\n").slice(-20).join("\n");
|
|
28
|
+
failure = failure ?? `metaCheckRunner: could not run tsc on ${tsconfig}: ${cause || error.message}${tail ? `
|
|
29
|
+
${tail}` : "\n(tsc printed nothing)"}`;
|
|
30
|
+
resolve(null);
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
});
|
|
33
34
|
}
|
|
34
|
-
|
|
35
35
|
async function main() {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
next += 1;
|
|
47
|
-
results[index] = await runTsc(tsconfigs[index]);
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
await Promise.all(Array.from({ length: Math.min(concurrency, tsconfigs.length) }, worker));
|
|
51
|
-
if (failure !== null) {
|
|
52
|
-
process.stderr.write(`${failure}\n`);
|
|
53
|
-
process.exitCode = 1;
|
|
54
|
-
return;
|
|
36
|
+
if (!tsc || !Number.isInteger(concurrency) || concurrency < 1) {
|
|
37
|
+
process.stderr.write("metaCheckRunner: usage: metaCheckRunner.mjs <tsc> <concurrency> <tsconfig>...\n");
|
|
38
|
+
process.exitCode = 1;
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const results = new Array(tsconfigs.length).fill(null);
|
|
42
|
+
const queue = tsconfigs.entries();
|
|
43
|
+
const worker = async () => {
|
|
44
|
+
for (const [index, tsconfig] of queue) {
|
|
45
|
+
results[index] = await runTsc(tsc, tsconfig);
|
|
55
46
|
}
|
|
56
|
-
|
|
47
|
+
};
|
|
48
|
+
await Promise.all(Array.from({ length: Math.min(concurrency, tsconfigs.length) }, worker));
|
|
49
|
+
if (failure !== null) {
|
|
50
|
+
process.stderr.write(`${failure}
|
|
51
|
+
`);
|
|
52
|
+
process.exitCode = 1;
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
process.stdout.write(`${JSON.stringify(results)}
|
|
56
|
+
`);
|
|
57
57
|
}
|
|
58
|
-
|
|
59
58
|
await main();
|
package/dist/renames.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isRecord as e,readJson as t}from"./files.js";import{existsSync as n,readdirSync as r}from"node:fs";import{join as i}from"node:path";var a=/^\d+\.\d+\.\d+\.json$/,o=/^on[A-Z]/;function s(e,t){let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number);for(let e=0;e<Math.max(n.length,r.length);e++){let t=(n[e]??0)-(r[e]??0);if(t!==0)return t}return 0}function c(e){return Object.fromEntries(Object.entries(e).filter(([e])=>!o.test(e)))}function l(e,t){return e===``?t:`${e}.${t}`}function u(e,t,n){throw Error(`${e}: ${t===``?`the table`:t} must be ${n}`)}function d(t,n,r){return e(r)||u(t,n,`an object`),r}function f(e,t,n){return typeof e!=`string`&&u(t,n,`a string`),e}function p(e,t,n){if(typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return e;u(t,n,`a string, number or boolean`)}function m(e){return(t,n,r)=>(Array.isArray(t)||u(n,r,`an array`),t.map((t,i)=>e(t,n,`${r}[${i}]`)))}function h(e){return(t,n,r)=>{let i=d(n,r,t);return Object.fromEntries(Object.entries(i).map(([t,i])=>[t,e(i,n,l(r,t))]))}}function g(e,t,n){let r=d(t,n,e);return{package:f(r.package,t,l(n,`package`)),components:m(f)(r.components,t,l(n,`components`)),prop:f(r.prop,t,l(n,`prop`)),...r.to===void 0?{}:{to:f(r.to,t,l(n,`to`))},...r.values===void 0?{}:{values:h(f)(r.values,t,l(n,`values`))},...r.flag===void 0?{}:{flag:f(r.flag,t,l(n,`flag`))}}}function _(e,t,n){let r=d(t,n,e);return{package:f(r.package,t,l(n,`package`)),from:f(r.from,t,l(n,`from`)),to:f(r.to,t,l(n,`to`)),renameProps:h(f)(r.renameProps,t,l(n,`renameProps`)),valueMaps:h(h(f))(r.valueMaps,t,l(n,`valueMaps`)),addProps:h(p)(r.addProps,t,l(n,`addProps`)),removeProps:h(f)(r.removeProps,t,l(n,`removeProps`))}}function v(e,t,n){let r=d(t,n,e);return{package:f(r.package,t,l(n,`package`)),props:m(f)(r.props,t,l(n,`props`)),from:f(r.from,t,l(n,`from`)),to:f(r.to,t,l(n,`to`))}}function y(e,t){let n=d(t,``,e);return{version:f(n.version,t,`version`),...n.componentProps===void 0?{}:{componentProps:m(g)(n.componentProps,t,`componentProps`)},...n.components===void 0?{}:{components:m(_)(n.components,t,`components`)},...n.props===void 0?{}:{props:m(v)(n.props,t,`props`)}}}function b(e){let n;try{n=t(e)}catch(t){throw Error(`${e} is not valid JSON: ${t instanceof Error?t.message:String(t)}`)}return y(n,e)}function x(e,t){e.has(t)||e.set(t,{name:t,props:{},values:{},added:{},removed:{}});let n=e.get(t);if(n===void 0)throw Error(`canvas-kit: the rename entry for ${t} is missing.`);return n}function S(e,t){let n=new Map,r={};for(let r of e.componentProps??[])if(r.package===t)for(let e of r.components){let t=x(n,e);r.to!==void 0&&(t.props[r.prop]=r.to),r.values!==void 0&&(t.values[r.to??r.prop]={...r.values}),r.to===void 0&&r.values===void 0&&r.flag!==void 0&&(t.removed[r.prop]=r.flag)}for(let r of e.components??[]){if(r.package!==t)continue;let e=x(n,r.from);r.to!==r.from&&(e.to=r.to),Object.assign(e.props,r.renameProps);for(let[t,n]of Object.entries(r.valueMaps))e.values[t]={...e.values[t],...n};Object.assign(e.added,r.addProps),Object.assign(e.removed,r.removeProps)}for(let n of e.props??[])if(n.package===t)for(let e of n.props)r[e]={...r[e],[n.from]:n.to};return{entries:n,values:r}}function C({tableVersion:e,version:t,libraryPackage:n,warnings:r,component:i,prop:a,target:o,declared:c}){if(c.has(o))return!0;if(s(e,t)===0)throw Error(`${e}: ${i}.${a} renames to ${o}, which ${n} ${t} does not declare`);return r.push(`${e}: ${i}.${a} renames to ${o}, which this kit does not declare; left out.`),!1}function w(e,{libraryPackage:t,version:n,components:r,warnings:i}){let a=e.version,{entries:o,values:s}=S(e,t),l=[];for(let e of o.values()){let o=e.to??e.name,s=r.find(e=>e.name===o);if(!s){i.push(`${a}: ${o} is not a component of this kit; the renames of ${e.name} are left out.`);continue}let u=new Set(s.props.map(e=>e.name)),d=(r,o)=>C({tableVersion:a,version:n,libraryPackage:t,warnings:i,component:e.name,prop:r,target:o,declared:u}),f={};for(let[t,n]of Object.entries(c(e.props)))d(t,n)&&(f[t]=n);let p={};for(let[t,n]of Object.entries(c(e.values)))d(t,t)&&(p[t]=n);let m=c(e.added),h=c(e.removed);(e.to!==void 0||Object.keys(f).length+Object.keys(p).length+Object.keys(m).length+Object.keys(h).length!==0)&&l.push({name:e.name,...e.to===void 0?{}:{to:e.to},props:f,values:p,added:m,removed:h})}return{version:a,components:l,values:c(s)}}function T(e,t,o,c){if(!n(e))throw Error(`${e} does not exist. Set renames in canvas-kit.json to the folder of rename tables.`);let l=r(e).filter(e=>a.test(e)).map(t=>b(i(e,t))).filter(e=>s(e.version,o)<=0).sort((e,t)=>s(e.version,t.version)),u=[];return{renames:l.map(e=>w(e,{libraryPackage:t,version:o,components:c,warnings:u})),warnings:u}}function E(e,t,n,r){return T(e,t,n,r).renames}function D(e,t,n){return e.filter(e=>s(e.version,t)>0&&s(e.version,n)<=0).sort((e,t)=>s(e.version,t.version))}export{E as readRenames,T as readRenamesWithWarnings,D as renamesBetween};
|
|
1
|
+
import{isRecord as e,readJson as t}from"./files.js";import{existsSync as n,readdirSync as r}from"node:fs";import{join as i}from"node:path";var a=/^\d+\.\d+\.\d+\.json$/,o=/^on[A-Z]/;function s(e,t){let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number);for(let e=0;e<Math.max(n.length,r.length);e++){let t=(n[e]??0)-(r[e]??0);if(t!==0)return t}return 0}function c(e){return Object.fromEntries(Object.entries(e).filter(([e])=>!o.test(e)))}function l(e,t){return e===``?t:`${e}.${t}`}function u(e,t,n){throw Error(`${e}: ${t===``?`the table`:t} must be ${n}`)}function d(t,n,r){return e(r)||u(t,n,`an object`),r}function f(e,t,n){return typeof e!=`string`&&u(t,n,`a string`),e}function p(e,t,n){if(typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return e;u(t,n,`a string, number or boolean`)}function m(e){return(t,n,r)=>(Array.isArray(t)||u(n,r,`an array`),t.map((t,i)=>e(t,n,`${r}[${i}]`)))}function h(e){return(t,n,r)=>{let i=d(n,r,t);return Object.fromEntries(Object.entries(i).map(([t,i])=>[t,e(i,n,l(r,t))]))}}function g(e,t,n){let r=d(t,n,e);return{package:f(r.package,t,l(n,`package`)),components:m(f)(r.components,t,l(n,`components`)),prop:f(r.prop,t,l(n,`prop`)),...r.to===void 0?{}:{to:f(r.to,t,l(n,`to`))},...r.values===void 0?{}:{values:h(f)(r.values,t,l(n,`values`))},...r.flag===void 0?{}:{flag:f(r.flag,t,l(n,`flag`))}}}function _(e,t,n){let r=d(t,n,e);return{package:f(r.package,t,l(n,`package`)),from:f(r.from,t,l(n,`from`)),to:f(r.to,t,l(n,`to`)),renameProps:h(f)(r.renameProps,t,l(n,`renameProps`)),valueMaps:h(h(f))(r.valueMaps,t,l(n,`valueMaps`)),addProps:h(p)(r.addProps,t,l(n,`addProps`)),removeProps:h(f)(r.removeProps,t,l(n,`removeProps`))}}function v(e,t,n){let r=d(t,n,e);return{package:f(r.package,t,l(n,`package`)),props:m(f)(r.props,t,l(n,`props`)),from:f(r.from,t,l(n,`from`)),to:f(r.to,t,l(n,`to`))}}function y(e,t){let n=d(t,``,e);return{version:f(n.version,t,`version`),...n.componentProps===void 0?{}:{componentProps:m(g)(n.componentProps,t,`componentProps`)},...n.components===void 0?{}:{components:m(_)(n.components,t,`components`)},...n.props===void 0?{}:{props:m(v)(n.props,t,`props`)}}}function b(e){let n;try{n=t(e)}catch(t){throw Error(`${e} is not valid JSON: ${t instanceof Error?t.message:String(t)}`)}return y(n,e)}function x(e,t){e.has(t)||e.set(t,{name:t,props:{},values:{},added:{},removed:{}});let n=e.get(t);if(n===void 0)throw Error(`canvas-kit: the rename entry for ${t} is missing.`);return n}function S(e,t){let n=new Map,r={};for(let r of e.componentProps??[])if(r.package===t)for(let e of r.components){let t=x(n,e);r.to!==void 0&&(t.props[r.prop]=r.to),r.values!==void 0&&(t.values[r.to??r.prop]={...r.values}),r.to===void 0&&r.values===void 0&&r.flag!==void 0&&(t.removed[r.prop]=r.flag)}for(let r of e.components??[]){if(r.package!==t)continue;let e=x(n,r.from);r.to!==r.from&&(e.to=r.to),Object.assign(e.props,r.renameProps);for(let[t,n]of Object.entries(r.valueMaps))e.values[t]={...e.values[t],...n};Object.assign(e.added,r.addProps),Object.assign(e.removed,r.removeProps)}for(let n of e.props??[])if(n.package===t)for(let e of n.props)r[e]={...r[e],[n.from]:n.to};return{entries:n,values:r}}function C({tableVersion:e,version:t,libraryPackage:n,warnings:r,component:i,prop:a,target:o,declared:c}){if(c.has(o))return!0;if(!c.has(a))return!1;if(s(e,t)===0)throw Error(`${e}: ${i}.${a} renames to ${o}, which ${n} ${t} does not declare`);return r.push(`${e}: ${i}.${a} renames to ${o}, which this kit does not declare; left out.`),!1}function w(e,{libraryPackage:t,version:n,components:r,warnings:i}){let a=e.version,{entries:o,values:s}=S(e,t),l=[];for(let e of o.values()){let o=e.to??e.name,s=r.find(e=>e.name===o);if(!s){i.push(`${a}: ${o} is not a component of this kit; the renames of ${e.name} are left out.`);continue}let u=new Set(s.props.map(e=>e.name)),d=(r,o)=>C({tableVersion:a,version:n,libraryPackage:t,warnings:i,component:e.name,prop:r,target:o,declared:u}),f={};for(let[t,n]of Object.entries(c(e.props)))d(t,n)&&(f[t]=n);let p={};for(let[t,n]of Object.entries(c(e.values)))d(t,t)&&(p[t]=n);let m=c(e.added),h=c(e.removed);(e.to!==void 0||Object.keys(f).length+Object.keys(p).length+Object.keys(m).length+Object.keys(h).length!==0)&&l.push({name:e.name,...e.to===void 0?{}:{to:e.to},props:f,values:p,added:m,removed:h})}return{version:a,components:l,values:c(s)}}function T(e,t,o,c){if(!n(e))throw Error(`${e} does not exist. Set renames in canvas-kit.json to the folder of rename tables.`);let l=r(e).filter(e=>a.test(e)).map(t=>b(i(e,t))).filter(e=>s(e.version,o)<=0).sort((e,t)=>s(e.version,t.version)),u=[];return{renames:l.map(e=>w(e,{libraryPackage:t,version:o,components:c,warnings:u})),warnings:u}}function E(e,t,n,r){return T(e,t,n,r).renames}function D(e,t,n){return e.filter(e=>s(e.version,t)>0&&s(e.version,n)<=0).sort((e,t)=>s(e.version,t.version))}export{E as readRenames,T as readRenamesWithWarnings,D as renamesBetween};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webority/canvas-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.167.0",
|
|
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,
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@babel/types": "7.29.8",
|
|
49
49
|
"@types/babel__core": "7.20.5",
|
|
50
50
|
"@types/node": "25.6.0",
|
|
51
|
-
"@webority/biome-config": "0.
|
|
51
|
+
"@webority/biome-config": "0.167.0",
|
|
52
52
|
"react": "^19.3.1"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|