@webority/canvas-kit 0.149.0 → 0.151.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.
@@ -0,0 +1,68 @@
1
+ import type { ComponentMeta, MetaProp } from "./meta.ts";
2
+ type IsAny<T> = 0 extends 1 & T ? true : false;
3
+ type Same<A, B> = (<T>() => T extends A ? 1 : 2) extends <T>() => (T extends B ? 1 : 2) ? true : false;
4
+ type Handler = (...args: never[]) => unknown;
5
+ type Constructor = abstract new (...args: never[]) => unknown;
6
+ type Defined<T> = Exclude<T, null | undefined>;
7
+ type Shape = Readonly<Record<string, MetaProp>>;
8
+ /** Every field a design sets at any depth: all but event handlers and component-typed fields. */
9
+ type FieldKeys<P> = {
10
+ [K in keyof P]-?: IsAny<P[K]> extends true ? K : [Defined<P[K]>] extends [Handler] ? never : [Extract<Defined<P[K]>, Constructor>] extends [never] ? K : never;
11
+ }[keyof P] & string;
12
+ /** Every prop a design sets: the field keys, less React's children, ref and key (a nested data field may be named key). */
13
+ export type DesignKeys<P> = Exclude<FieldKeys<P>, "children" | "ref" | "key">;
14
+ /** Every event handler prop of the component: the names a meta's handlers list may use. */
15
+ export type HandlerKeys<P> = {
16
+ [K in keyof P]-?: NonNullable<P[K]> extends Handler ? K : never;
17
+ }[keyof P] & string;
18
+ type RequiredKeys<P> = {
19
+ [K in keyof P]-?: Partial<Pick<P, K>> extends Pick<P, K> ? never : K;
20
+ }[keyof P];
21
+ type ItemOf<T> = Defined<T> extends readonly (infer I)[] ? I : Defined<T> extends ReadonlySet<infer I> ? I : never;
22
+ type KeysOfUnion<T> = T extends unknown ? keyof T : never;
23
+ type ValueIn<T, K extends PropertyKey> = T extends unknown ? (K extends keyof T ? T[K] : undefined) : never;
24
+ type RequiredInEvery<T, K extends PropertyKey> = [T extends unknown ? (K extends RequiredKeys<T> ? never : 1) : never] extends [never] ? K : never;
25
+ type Simplify<T> = {
26
+ [K in keyof T]: T[K];
27
+ };
28
+ /**
29
+ * A component's props as one object type. A union of props (a component whose props depend on one flag, such as
30
+ * multiple) becomes every key of any member, with the union of its values, required only when every member
31
+ * requires it. A props type that is not a union comes back unchanged.
32
+ */
33
+ export type Flatten<P> = Simplify<{
34
+ [K in KeysOfUnion<P> as RequiredInEvery<P, K>]-?: ValueIn<P, K>;
35
+ } & {
36
+ [K in KeysOfUnion<P> as K extends RequiredInEvery<P, K> ? never : K]?: ValueIn<P, K>;
37
+ }>;
38
+ type Inherited<P, K extends keyof P, D> = true extends {
39
+ [E in keyof D]: K extends keyof D[E] ? Same<P[K], D[E][K]> : false;
40
+ }[keyof D] ? true : false;
41
+ /** The props the component declares itself: not an inherited DOM attribute and not a data-* attribute. */
42
+ type OwnKeys<P, D> = {
43
+ [K in keyof P]-?: K extends `data-${string}` ? never : Inherited<P, K, D> extends true ? never : K;
44
+ }[keyof P];
45
+ type ValueOk<T, M extends MetaProp, N> = M["type"] extends "any" ? true : IsAny<T> extends true ? false : M["type"] extends "enum" ? Same<Defined<T>, NonNullable<M["values"]>[number]> : M["type"] extends "enumOrNumber" ? Same<Defined<T>, NonNullable<M["values"]>[number] | number> extends true ? true : Same<Defined<T>, NonNullable<M["values"]>[number] | number | `${number}`> : M["type"] extends "boolean" ? Same<Defined<T>, boolean> : M["type"] extends "number" ? Same<Defined<T>, number> : M["type"] extends "stringOrNumber" ? Same<Defined<T>, string | number> extends true ? true : Same<Defined<T>, string | number | Date> : M["type"] extends "string" | "url" ? Same<Defined<T>, string> : M["type"] extends "icon" ? string extends Defined<T> ? true : false : M["type"] extends "node" ? Defined<N> extends Defined<T> ? true : false : M["type"] extends "array" ? [Defined<T>] extends [readonly unknown[] | ReadonlySet<unknown>] ? true : false : M["type"] extends "object" ? [Defined<T>] extends [readonly unknown[] | ReadonlySet<unknown> | Handler] ? false : [Defined<T>] extends [object] ? true : false : false;
46
+ type RequiredOk<P, K extends keyof P, M extends MetaProp> = Same<K extends RequiredKeys<P> ? true : false, M["required"] extends true ? true : false>;
47
+ type OwnNull<T, N> = null extends T ? (Defined<N> extends Defined<T> ? false : true) : false;
48
+ type NullableOk<T, M extends MetaProp, N> = M["type"] extends "any" ? true : Same<OwnNull<T, N>, M["nullable"] extends true ? true : false>;
49
+ type NestedOk<T, M extends MetaProp, N> = M["type"] extends "object" ? M["fields"] extends Shape ? [keyof Defined<T>] extends [never] ? true : ShapeOk<Flatten<Defined<T>>, M["fields"], N> : true : M["type"] extends "array" ? M["itemFields"] extends Shape ? [keyof ItemOf<T>] extends [never] ? true : ShapeOk<Flatten<ItemOf<T>>, M["itemFields"], N> : true : true;
50
+ type ShapeOk<T, F extends Shape, N> = Same<FieldKeys<T>, keyof F & string> extends true ? ([PropsMismatch<T, F, N>] extends [never] ? true : false) : false;
51
+ /** The names of meta props whose type, required or nullable flag, or nested fields differ from the component's. */
52
+ export type PropsMismatch<P, F extends Shape, N> = {
53
+ [K in keyof F & keyof P & string]: ValueOk<P[K], F[K], N> extends true ? RequiredOk<P, K, F[K]> extends true ? NullableOk<P[K], F[K], N> extends true ? NestedOk<P[K], F[K], N> extends true ? never : K : K : K : K;
54
+ }[keyof F & keyof P & string];
55
+ type OmitOf<M extends ComponentMeta> = M extends {
56
+ readonly omit: infer O extends readonly string[];
57
+ } ? O[number] : never;
58
+ type FixedOf<M extends ComponentMeta> = M extends {
59
+ readonly fixedProps: infer F extends Readonly<Record<string, unknown>>;
60
+ } ? keyof F & string : never;
61
+ /** Props the component declares itself that the meta neither lists, omits nor fixes. Inherited DOM and data-* attributes are left out. */
62
+ export type ExtraProps<P, M extends ComponentMeta, D> = Exclude<DesignKeys<P> & OwnKeys<P, D>, keyof M["props"] | OmitOf<M> | FixedOf<M>>;
63
+ /** Props the meta lists that the component does not take. */
64
+ export type MissingProps<P, M extends ComponentMeta> = Exclude<keyof M["props"] & string, DesignKeys<P>>;
65
+ export type MismatchedProps<P, M extends ComponentMeta, N> = PropsMismatch<P, M["props"], N>;
66
+ /** children inherited unchanged from the DOM props says nothing about whether the component renders them, so either flag passes. */
67
+ export type ChildrenOk<P, M extends ComponentMeta, D> = "children" extends keyof P ? Inherited<P, "children" & keyof P, D> extends true ? true : Same<true, M["acceptsChildren"]> : Same<false, M["acceptsChildren"]>;
68
+ export {};
@@ -0,0 +1,37 @@
1
+ import type { CanvasManifestComponent } from "./manifest.ts";
2
+ import type { ComponentMeta } from "./meta.ts";
3
+ export interface MetaEntry {
4
+ meta: ComponentMeta;
5
+ file: string;
6
+ }
7
+ /** The HTML tags a MetaNode may place besides kit components. */
8
+ export declare const HTML_TAGS: readonly string[];
9
+ /** The roles a component can have in the manifest. */
10
+ export type Role = "title" | "navigation";
11
+ export declare const ROLES: readonly Role[];
12
+ /** Reads the metas the components glob names, sorted by name and checked. */
13
+ export declare function readMetas({ root, components, knownNames, icons, }: {
14
+ root: string;
15
+ components: string;
16
+ knownNames?: string[] | undefined;
17
+ icons?: string[] | undefined;
18
+ }): Promise<MetaEntry[]>;
19
+ /**
20
+ * Collects every problem across the metas and throws one Error, one line per problem.
21
+ */
22
+ export declare function checkMetas(metas: readonly {
23
+ meta: ComponentMeta;
24
+ file: string;
25
+ }[], options?: {
26
+ knownNames?: string[] | undefined;
27
+ icons?: string[] | undefined;
28
+ }): void;
29
+ export declare function manifestComponent(meta: ComponentMeta, { platform, source }: {
30
+ platform: "Web" | "Phone";
31
+ source: string;
32
+ }): CanvasManifestComponent;
33
+ /**
34
+ * The module (.jsx, .tsx, .js, .ts in that order) a meta draws: the sibling of a `<X>.meta.js` or `<X>.meta.ts` file
35
+ * for its own name, or `<the meta file's folder>/<exportName><ext>` for another export.
36
+ */
37
+ export declare function componentModuleOf(file: string, name: string): string;
package/dist/metas.js CHANGED
@@ -1,2 +1,2 @@
1
- import{toPosix as e}from"./files.js";import{existsSync as t,globSync as n}from"node:fs";import{basename as r,dirname as i,join as a,resolve as o}from"node:path";import{pathToFileURL as s}from"node:url";var c=Object.freeze([`a`,`b`,`button`,`div`,`h1`,`img`,`kbd`,`li`,`p`,`span`,`strong`,`table`,`tbody`,`td`,`th`,`thead`,`tr`,`ul`]),l=Object.freeze([`title`,`navigation`]),u=/^[A-Z][A-Za-z0-9]*$/,d=/^[A-Za-z0-9][A-Za-z0-9_-]*$/,f=/^App[A-Za-z0-9]*$/,p=/^(?:aria|data)-[a-z0-9-]+$/,m=/^on[A-Z][A-Za-z0-9]*$/,h=/^[a-z][A-Za-z0-9]*$/,g=/[\u2013\u2014]/,_=[`string`,`number`,`stringOrNumber`,`boolean`,`enum`,`enumOrNumber`,`url`,`icon`,`node`,`array`,`object`,`any`],v=[`.jsx`,`.tsx`,`.js`,`.ts`];async function y({root:e,components:t,knownNames:r,icons:i}){let a=n(t,{cwd:e});if(a.length===0)throw Error(`${e}: no component metadata matches ${t}`);let c=a.map(t=>o(e,t)).sort(K),l=[];for(let e of c){let t=await import(s(e).href);if(!(`meta`in t))throw Error(`${e}: exports no meta; write export const meta = defineMeta({...})`);l.push({meta:t.meta,file:e})}return b(l,{knownNames:r,icons:i}),l.sort((e,t)=>K(e.meta.name,t.meta.name))}function b(e,{knownNames:t=[],icons:n}={}){let r=new Map;for(let{meta:t}of e)q(t)&&typeof t.name==`string`&&!r.has(t.name)&&r.set(t.name,t);let i={byName:r,knownNames:new Set(t),icons:n},a=new Map,o=new Map,s=[];for(let{meta:t,file:n}of e){let e=[];C(t,n,a,o,i,e);for(let[t,r]of e)s.push(`${n}: ${t}: ${r}`)}if(s.length>0)throw Error(s.join(`
2
- `))}function x(e,{platform:t,source:n}){let r=Object.keys(e.props).sort(K),i=t===`Web`&&q(e.actions)?Object.values(e.actions):[];return{name:e.name,marker:e.marker,acceptsChildren:e.acceptsChildren,props:[...r.map(t=>B(t,e.props[t])),...i.map(e=>({name:e,type:`object`,fields:[],required:!1}))].sort((e,t)=>K(e.name,t.name)),itemsTakeAction:t===`Web`?r.filter(t=>U(e.props[t])):[...e.itemsTakeAction??[]].sort(K),takesAction:t===`Web`?[...i].sort(K):[...e.takesAction??[]].sort(K),source:n,...e.component===void 0?{}:{component:e.component},...e.fixedProps===void 0?{}:{fixedProps:e.fixedProps},...e.role===void 0?{}:{role:e.role},usage:e.usage}}function S(n,o){let s=n.replace(/\.meta\.[jt]s$/,``),c=r(s)===o?s:a(i(s),o);for(let n of v)if(t(c+n))return e(c+n);throw Error(`no component module for ${o} beside ${n}`)}function C(e,t,n,r,i,a){if(!q(e)){a.push([`meta`,`must be an object`]);return}let{name:o}=e;typeof o!=`string`||!u.test(o)?a.push([`name`,`"${o}" is not a catalogue name; start with a capital letter and use letters and digits`]):n.has(o)?a.push([`name`,`"${o}" is also the name in ${n.get(o)}`]):n.set(o,t),e.component!==void 0&&(Y(e.component)?e.component===o&&a.push([`component`,`"${e.component}" is the name; leave component out when the meta draws its own export`]):a.push([`component`,`must name an export as text`]));let{platforms:s}=e;Array.isArray(s)&&s.length>0&&s.every(e=>e===`web`||e===`phone`)||a.push([`platforms`,`must list web, phone or both`]),e.marker!==null&&typeof e.marker!=`string`&&a.push([`marker`,`must be a string or null`]),typeof e.acceptsChildren!=`boolean`&&a.push([`acceptsChildren`,`must be true or false`]),e.omit===void 0||Array.isArray(e.omit)&&e.omit.every(e=>typeof e==`string`)||a.push([`omit`,`must be a list of prop names`]),e.actions!==void 0&&w(e,a),e.role!==void 0&&!l.includes(e.role)&&a.push([`role`,`must be "title" or "navigation"`]),E(e,a);let c=q(e.props)?e.props:{};if(!q(e.props))a.push([`props`,`must be an object`]);else for(let[t,n]of Object.entries(e.props))D(n,`props.${t}`,i,a);let d=new Set;if(e.fixedProps!==void 0){if(e.component===void 0&&a.push([`fixedProps`,`needs component, the export the fixed props go to`]),!q(e.fixedProps)||Object.keys(e.fixedProps).length===0)a.push([`fixedProps`,`must be an object of the props the kit sets`]);else{let t=Array.isArray(e.omit)?e.omit:[];for(let n of Object.keys(e.fixedProps))d.add(n),Object.hasOwn(c,n)?a.push([`fixedProps.${n}`,`is also a prop; a fixed prop is set by the kit, not the panel`]):t.includes(n)&&a.push([`fixedProps.${n}`,`is listed in omit; a prop is fixed or omitted, not both`])}}i.fixed={name:o,keys:d},Array.isArray(e.examples)?e.examples.forEach((n,o)=>{F(n,`examples[${o}]`,e,c,t,r,i,a)}):a.push([`examples`,`must be a list`]),I(e.usage,i,a),i.fixed=null,z(e,``,a)}function w(e,t){let{actions:n}=e;if(!q(n)||Object.keys(n).length===0){t.push([`actions`,`must be an object of handler name to action prop name`]);return}Array.isArray(e.platforms)&&e.platforms.includes(`web`)||t.push([`actions`,`only a web component takes actions; add web to platforms or remove actions`]);let r=q(e.props)?e.props:{},i=q(e.fixedProps)?e.fixedProps:{},a=new Map;for(let[e,o]of Object.entries(n)){let n=`actions.${e}`;m.test(e)||t.push([n,`"${e}" is not a handler name (on<Event>)`]),typeof o!=`string`||!h.test(o)?t.push([n,`${G(o)} is not an action prop name; start with a lower-case letter and use letters and digits`]):Object.hasOwn(r,o)||Object.hasOwn(i,o)?t.push([n,`"${o}" is also a prop; an action stand-in is not a library prop`]):a.has(o)?t.push([n,`"${o}" is also the action prop of ${a.get(o)}`]):a.set(o,e)}}var T=[[`takesAction`,`object`],[`itemsTakeAction`,`array`]];function E(e,t){let n=q(e.props)?e.props:{},r=new Map,i=!1;for(let[a,o]of T){let s=e[a];if(s===void 0)continue;if(i=!0,!Array.isArray(s)||s.length===0||!s.every(e=>typeof e==`string`)){t.push([a,`must be a non-empty list of prop names`]);continue}let c=new Set;for(let e of s)c.has(e)?t.push([a,`"${e}" is listed twice`]):r.has(e)?t.push([a,`"${e}" is also in ${r.get(e)}`]):Object.hasOwn(n,e)&&q(n[e])&&n[e].type===o||t.push([a,`"${e}" is not ${o===`object`?`an object`:`an array`} prop`]),c.add(e),r.has(e)||r.set(e,a)}let a=Array.isArray(e.platforms)&&e.platforms.length===1&&e.platforms[0]===`phone`;i&&!a&&t.push([`takesAction`,`only a phone component declares takesAction and itemsTakeAction; a web component uses actions`])}function D(e,t,n,r){if(!q(e))r.push([t,`is not a prop`]);else if(!_.includes(e.type))r.push([`${t}.type`,`${G(e.type)} is not a prop type`]);else{if(e.type===`enum`||e.type===`enumOrNumber`?O(e,t,r):e.values!==void 0&&r.push([`${t}.values`,`only an enum or an enumOrNumber has values`]),e.fields!==void 0){if(e.type!==`object`)r.push([`${t}.fields`,`only an object has fields`]);else for(let[i,a]of Object.entries(e.fields))D(a,`${t}.fields.${i}`,n,r)}if(e.itemFields!==void 0){if(e.type!==`array`)r.push([`${t}.itemFields`,`only an array has itemFields`]);else for(let[i,a]of Object.entries(e.itemFields))D(a,`${t}.itemFields.${i}`,n,r)}if(Y(e.description)||r.push([`${t}.description`,`is empty`]),e.required!==void 0&&typeof e.required!=`boolean`&&r.push([`${t}.required`,`must be true or false`]),e.nullable!==void 0&&typeof e.nullable!=`boolean`&&r.push([`${t}.nullable`,`must be true or false`]),e.default!==void 0){if(e.required===!0)r.push([`${t}.default`,`a required prop has no default`]);else{let i=[];k(e.default,e,t,n,i),i.length>0&&r.push([`${t}.default`,`${G(e.default)} does not fit ${e.type}`])}}}}function O(e,t,n){let{type:r,values:i}=e;if(!Array.isArray(i)||i.length===0){n.push([`${t}.values`,`an ${r} lists its values`]);return}let a=new Set;for(let e of i)(r===`enum`?typeof e==`string`||J(e):typeof e==`string`)?a.has(e)&&n.push([`${t}.values`,`"${e}" is listed twice`]):n.push([`${t}.values`,`${G(e)} is not allowed here`]),a.add(e)}function k(e,t,n,r,i){if(!q(t)||e===null&&(t.nullable===!0||t.type===`node`||t.type===`icon`))return;let a=Array.isArray(t.values)?t.values:[];switch(t.type){case`string`:case`url`:typeof e!=`string`&&W(e,t.type,n,i);return;case`number`:J(e)||W(e,t.type,n,i);return;case`boolean`:typeof e!=`boolean`&&W(e,t.type,n,i);return;case`stringOrNumber`:typeof e!=`string`&&!J(e)&&W(e,t.type,n,i);return;case`enum`:a.includes(e)||i.push([n,`${G(e)} is not one of ${G(a)}`]);return;case`enumOrNumber`:!J(e)&&!a.includes(e)&&i.push([n,`${G(e)} is not one of ${G(a)}`]);return;case`icon`:X(e)?M(e,n,r,i):typeof e==`string`?Array.isArray(r.icons)&&!r.icons.includes(e)&&i.push([n,`"${e}" is not an icon of the kit`]):W(e,t.type,n,i);return;case`node`:Array.isArray(e)?e.forEach((e,t)=>{A(e,`${n}[${t}]`,r,i)}):A(e,n,r,i);return;case`array`:Array.isArray(e)?t.itemFields!==void 0&&e.forEach((e,a)=>{q(e)?j(e,t.itemFields,`${n}[${a}]`,r,i):i.push([`${n}[${a}]`,`${G(e)} is not an object`])}):W(e,t.type,n,i);return;case`object`:q(e)?t.fields!==void 0&&j(e,t.fields,n,r,i):W(e,t.type,n,i);return;default:return}}function A(e,t,n,r){X(e)?M(e,t,n,r):typeof e!=`string`&&!J(e)&&r.push([t,`${G(e)} is not a node`])}function j(e,t,n,r,i){for(let a of Object.keys(e))Object.hasOwn(t,a)?k(e[a],t[a],`${n}.${a}`,r,i):i.push([`${n}.${a}`,`not a field`]);for(let[r,a]of Object.entries(t))q(a)&&a.required===!0&&!Object.hasOwn(e,r)&&i.push([`${n}.${r}`,`missing, the field is required`])}function M(e,t,n,r){let{component:i}=e,a=n.byName.get(i);if(a||n.knownNames.has(i)||c.includes(i)||r.push([`${t}.component`,`"${i}" is neither a component of the kit nor one of the HTML tags`]),a&&e.props!==void 0){if(!q(e.props))r.push([`${t}.props`,`must be an object`]);else{let o=q(a.props)?a.props:{};for(let[a,s]of Object.entries(e.props))n.fixed&&n.fixed.name===i&&n.fixed.keys.has(a)?r.push([`${t}.props.${a}`,`is a fixed prop; the kit sets it`]):Object.hasOwn(o,a)?k(s,o[a],`${t}.props.${a}`,n,r):r.push([`${t}.props.${a}`,`not a prop of ${i}`])}}e.children!==void 0&&(a&&a.acceptsChildren===!1&&r.push([`${t}.children`,`${i} takes no children`]),P(e.children,`${t}.children`,n,r)),e.handlers!==void 0&&N(e.handlers,`${t}.handlers`,i,a,r)}function N(e,t,n,r,i){if(!Array.isArray(e)||!e.every(e=>typeof e==`string`)){i.push([t,`must be a list of handler names`]);return}if(c.includes(n)){i.push([t,`handlers need a kit component`]);return}if(e.length===0){i.push([t,`omit handlers when empty`]);return}let a=new Set;for(let o of e)m.test(o)?a.has(o)?i.push([t,`"${o}" is listed twice`]):r&&q(r.props)&&Object.hasOwn(r.props,o)&&i.push([t,`"${o}" is a data prop of ${n}, set it in props`]):i.push([t,`"${o}" is not a handler name (on<Event>)`]),a.add(o)}function P(e,t,n,r){typeof e!=`string`&&(Array.isArray(e)?e.forEach((e,i)=>{typeof e!=`string`&&(X(e)?M(e,`${t}[${i}]`,n,r):r.push([`${t}[${i}]`,`is neither text nor a placed element`]))}):r.push([t,`is text or a list of text and placed elements`]))}function F(e,t,n,r,i,a,o,s){if(!q(e)){s.push([t,`is not an example`]);return}let{name:c}=n,{id:l}=e;if(typeof l==`string`&&(l===c||l.startsWith(`${c}.`)&&d.test(l.slice(c.length+1)))?a.has(l)?s.push([`${t}.id`,`"${l}" is also used in ${a.get(l)}`]):a.set(l,i):s.push([`${t}.id`,`"${l}" must be ${c} or ${c}.<case>`]),Y(e.title)||s.push([`${t}.title`,`is empty`]),!q(e.props))s.push([`${t}.props`,`must be an object`]);else{for(let[n,i]of Object.entries(e.props))o.fixed?.keys.has(n)?s.push([`${t}.props.${n}`,`is a fixed prop; the kit sets it`]):!Object.hasOwn(r,n)&&p.test(n)&&Y(i)||(Object.hasOwn(r,n)?k(i,r[n],`${t}.props.${n}`,o,s):s.push([`${t}.props.${n}`,`not a prop of ${c}`]));for(let[n,i]of Object.entries(r))q(i)&&i.required===!0&&!Object.hasOwn(e.props,n)&&s.push([`${t}.props.${n}`,`missing, the prop is required`])}e.children!==void 0&&(n.acceptsChildren===!1&&s.push([`${t}.children`,`${c} takes no children`]),P(e.children,`${t}.children`,o,s)),e.wrap!==void 0&&(X(e.wrap)?M(e.wrap,`${t}.wrap`,o,s):s.push([`${t}.wrap`,`is not a placed element`])),e.handlers!==void 0&&N(e.handlers,`${t}.handlers`,c,n,s)}function I(e,t,n){q(e)?(Array.isArray(e.when)&&e.when.length!==0&&e.when.every(Y)||n.push([`usage.when`,`lists nothing; write at least one line`]),Array.isArray(e.whenNot)?e.whenNot.forEach((e,r)=>{L(e,`usage.whenNot[${r}]`,t,n)}):n.push([`usage.whenNot`,`must be a list`]),Array.isArray(e.do)||n.push([`usage.do`,`must be a list`]),Array.isArray(e.dont)||n.push([`usage.dont`,`must be a list`]),Array.isArray(e.do)&&Array.isArray(e.dont)&&(e.do.length!==e.dont.length&&n.push([`usage`,`${e.do.length} do against ${e.dont.length} dont; they pair up one to one`]),e.do.forEach((e,r)=>{R(e,`usage.do[${r}]`,t,n)}),e.dont.forEach((e,r)=>{R(e,`usage.dont[${r}]`,t,n)})),Array.isArray(e.a11y)?e.a11y.forEach((e,t)=>{Y(e)||n.push([`usage.a11y[${t}]`,`is empty`])}):n.push([`usage.a11y`,`must be a list`]),e.keyboard!==void 0&&(Array.isArray(e.keyboard)?e.keyboard.forEach((e,t)=>{for(let r of[`key`,`does`,`notes`])q(e)&&Y(e[r])||n.push([`usage.keyboard[${t}].${r}`,`is empty`])}):n.push([`usage.keyboard`,`must be a list`])),e.contrast!==void 0&&(Array.isArray(e.contrast)?e.contrast.forEach((e,t)=>{for(let r of[`pair`,`light`,`dark`])q(e)&&Y(e[r])||n.push([`usage.contrast[${t}].${r}`,`is empty`])}):n.push([`usage.contrast`,`must be a list`]))):n.push([`usage`,`must be an object`])}function L(e,t,n,r){q(e)?(Y(e.text)||r.push([`${t}.text`,`is empty`]),e.instead!==void 0&&(typeof e.instead==`string`?f.test(e.instead)&&!n.byName.has(e.instead)&&!n.knownNames.has(e.instead)&&r.push([`${t}.instead`,`"${e.instead}" is not a component of the kit`]):r.push([`${t}.instead`,`must be text`]))):r.push([t,`is not an object`])}function R(e,t,n,r){q(e)?(Y(e.note)||r.push([`${t}.note`,`is empty`]),!Array.isArray(e.example)||e.example.length===0?r.push([`${t}.example`,`needs at least one placed element`]):e.example.forEach((e,i)=>{let a=`${t}.example[${i}]`;X(e)?M(e,a,n,r):r.push([a,`is not a placed element`])})):r.push([t,`is not a practice`])}function z(e,t,n){if(typeof e==`string`)g.test(e)&&n.push([t,`contains an em or en dash; use a comma, colon or period`]);else if(Array.isArray(e))e.forEach((e,r)=>{z(e,`${t}[${r}]`,n)});else if(q(e))for(let[r,i]of Object.entries(e))z(i,t?`${t}.${r}`:r,n)}function B(e,t){let n={name:e,type:t.type};return(t.type===`enum`||t.type===`enumOrNumber`)&&(n.enum=H(t.values)),t.fields!==void 0&&(n.fields=V(t.fields)),t.itemFields!==void 0&&(n.itemFields=V(t.itemFields)),n.required=t.required===!0,t.nullable===!0&&(n.nullable=!0),t.description!==void 0&&(n.description=t.description),t.default!==void 0&&(n.default=t.default),n}function V(e){return Object.keys(e).sort(K).map(t=>B(t,e[t]))}function H(e){return[...e].sort((e,t)=>{let n=typeof e==`number`,r=typeof t==`number`;return n&&r?e-t:n===r?K(e,t):n?-1:1})}function U(e){return e.type===`array`&&Object.keys(e.itemFields??{}).some(e=>e===`href`||e===`to`)}function W(e,t,n,r){r.push([n,`${G(e)} is not a ${t}`])}function G(e){return JSON.stringify(e)}function K(e,t){return e<t?-1:+(e>t)}function q(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function J(e){return typeof e==`number`&&Number.isFinite(e)}function Y(e){return typeof e==`string`&&e.trim()!==``}function X(e){return q(e)&&typeof e.component==`string`}export{c as HTML_TAGS,l as ROLES,b as checkMetas,S as componentModuleOf,x as manifestComponent,y as readMetas};
1
+ import{toPosix as e}from"./files.js";import{existsSync as t,globSync as n}from"node:fs";import{basename as r,dirname as i,join as a,resolve as o}from"node:path";import{pathToFileURL as s}from"node:url";var c=Object.freeze([`a`,`b`,`button`,`div`,`h1`,`img`,`kbd`,`li`,`p`,`span`,`strong`,`table`,`tbody`,`td`,`th`,`thead`,`tr`,`ul`]),l=Object.freeze([`title`,`navigation`]),u=/^[A-Z][A-Za-z0-9]*$/,d=/^[A-Za-z0-9][A-Za-z0-9_-]*$/,f=/^App[A-Za-z0-9]*$/,p=/^(?:aria|data)-[a-z0-9-]+$/,m=/^on[A-Z][A-Za-z0-9]*$/,h=/^[a-z][A-Za-z0-9]*$/,g=/[\u2013\u2014]/,_=[`string`,`number`,`stringOrNumber`,`boolean`,`enum`,`enumOrNumber`,`url`,`icon`,`node`,`array`,`object`,`any`],v=[`.jsx`,`.tsx`,`.js`,`.ts`];async function y({root:e,components:t,knownNames:r,icons:i}){let a=n(t,{cwd:e});if(a.length===0)throw Error(`${e}: no component metadata matches ${t}`);let c=a.map(t=>o(e,t)).sort(B),l=[];for(let e of c){let t=await import(s(e).href);if(!H(t)||!(`meta`in t))throw Error(`${e}: exports no meta; write export const meta = defineMeta({...})`);l.push({meta:t.meta,file:e})}return x(l,{knownNames:r,icons:i}),ne(l).sort((e,t)=>B(e.meta.name,t.meta.name))}function b(e,t={}){x(e,t)}function x(e,{knownNames:t=[],icons:n}={}){if(!V(e))throw Error(`checkMetas takes a list of { meta, file } entries`);let r=new Map;for(let{meta:t}of e)H(t)&&typeof t.name==`string`&&!r.has(t.name)&&r.set(t.name,t);let i={byName:r,knownNames:new Set(t),icons:n},a=new Map,o=new Map,s=[];for(let{meta:t,file:n}of e){let e=[];S(t,n,a,o,i,e);for(let[t,r]of e)s.push(`${n}: ${t}: ${r}`)}if(s.length>0)throw Error(s.join(`
2
+ `))}function ee(e,{platform:t,source:n}){let r=Object.entries(e.props).sort(([e],[t])=>B(e,t)),i=t===`Web`&&H(e.actions)?Object.values(e.actions):[];return{name:e.name,marker:e.marker,acceptsChildren:e.acceptsChildren,props:[...r.map(([e,t])=>P(e,t)),...i.map(e=>({name:e,type:`object`,fields:[],required:!1}))].sort((e,t)=>B(e.name,t.name)),itemsTakeAction:t===`Web`?r.filter(([,e])=>L(e)).map(([e])=>e):[...e.itemsTakeAction??[]].sort(B),takesAction:t===`Web`?[...i].sort(B):[...e.takesAction??[]].sort(B),source:n,...e.component===void 0?{}:{component:e.component},...e.fixedProps===void 0?{}:{fixedProps:e.fixedProps},...e.role===void 0?{}:{role:e.role},usage:e.usage}}function te(n,o){let s=n.replace(/\.meta\.[jt]s$/,``),c=r(s)===o?s:a(i(s),o);for(let n of v)if(t(c+n))return e(c+n);throw Error(`no component module for ${o} beside ${n}`)}function ne(e){return e.map(({meta:e,file:t})=>{if(!ue(e)||typeof t!=`string`)throw Error(`${t}: not a component meta; checkMetas should have refused it`);return{meta:e,file:t}})}function S(e,t,n,r,i,a){if(!H(e)){a.push([`meta`,`must be an object`]);return}let{name:o}=e;typeof o!=`string`||!u.test(o)?a.push([`name`,`"${o}" is not a catalogue name; start with a capital letter and use letters and digits`]):n.has(o)?a.push([`name`,`"${o}" is also the name in ${n.get(o)}`]):n.set(o,t),e.component!==void 0&&(W(e.component)?e.component===o&&a.push([`component`,`"${e.component}" is the name; leave component out when the meta draws its own export`]):a.push([`component`,`must name an export as text`]));let{platforms:s}=e;Array.isArray(s)&&s.length>0&&s.every(e=>e===`web`||e===`phone`)||a.push([`platforms`,`must list web, phone or both`]),e.marker!==null&&typeof e.marker!=`string`&&a.push([`marker`,`must be a string or null`]),typeof e.acceptsChildren!=`boolean`&&a.push([`acceptsChildren`,`must be true or false`]),e.omit===void 0||Array.isArray(e.omit)&&e.omit.every(e=>typeof e==`string`)||a.push([`omit`,`must be a list of prop names`]),e.actions!==void 0&&re(e,a),e.role!==void 0&&!K(e.role)&&a.push([`role`,`must be "title" or "navigation"`]),w(e,a);let c=H(e.props)?e.props:{};if(!H(e.props))a.push([`props`,`must be an object`]);else for(let[t,n]of Object.entries(e.props))T(n,`props.${t}`,i,a);let l=new Set;if(e.fixedProps!==void 0){if(e.component===void 0&&a.push([`fixedProps`,`needs component, the export the fixed props go to`]),!H(e.fixedProps)||Object.keys(e.fixedProps).length===0)a.push([`fixedProps`,`must be an object of the props the kit sets`]);else{let t=Array.isArray(e.omit)?e.omit:[];for(let n of Object.keys(e.fixedProps))l.add(n),Object.hasOwn(c,n)?a.push([`fixedProps.${n}`,`is also a prop; a fixed prop is set by the kit, not the panel`]):t.includes(n)&&a.push([`fixedProps.${n}`,`is listed in omit; a prop is fixed or omitted, not both`])}}i.fixed={name:o,keys:l},Array.isArray(e.examples)?e.examples.forEach((n,o)=>{ae(n,`examples[${o}]`,e,c,t,r,i,a)}):a.push([`examples`,`must be a list`]),oe(e.usage,i,a),i.fixed=null,N(e,``,a)}function re(e,t){let{actions:n}=e;if(!H(n)||Object.keys(n).length===0){t.push([`actions`,`must be an object of handler name to action prop name`]);return}Array.isArray(e.platforms)&&e.platforms.includes(`web`)||t.push([`actions`,`only a web component takes actions; add web to platforms or remove actions`]);let r=H(e.props)?e.props:{},i=H(e.fixedProps)?e.fixedProps:{},a=new Map;for(let[e,o]of Object.entries(n)){let n=`actions.${e}`;m.test(e)||t.push([n,`"${e}" is not a handler name (on<Event>)`]),typeof o!=`string`||!h.test(o)?t.push([n,`${z(o)} is not an action prop name; start with a lower-case letter and use letters and digits`]):Object.hasOwn(r,o)||Object.hasOwn(i,o)?t.push([n,`"${o}" is also a prop; an action stand-in is not a library prop`]):a.has(o)?t.push([n,`"${o}" is also the action prop of ${a.get(o)}`]):a.set(o,e)}}var C=[[`takesAction`,`object`],[`itemsTakeAction`,`array`]];function w(e,t){let n=H(e.props)?e.props:{},r=new Map,i=!1;for(let[a,o]of C){let s=e[a];if(s===void 0)continue;if(i=!0,!G(s)||s.length===0){t.push([a,`must be a non-empty list of prop names`]);continue}let c=new Set;for(let e of s){let i=Object.hasOwn(n,e)?n[e]:void 0;c.has(e)?t.push([a,`"${e}" is listed twice`]):r.has(e)?t.push([a,`"${e}" is also in ${r.get(e)}`]):i!==void 0&&H(i)&&i.type===o||t.push([a,`"${e}" is not ${o===`object`?`an object`:`an array`} prop`]),c.add(e),r.has(e)||r.set(e,a)}}let a=Array.isArray(e.platforms)&&e.platforms.length===1&&e.platforms[0]===`phone`;i&&!a&&t.push([`takesAction`,`only a phone component declares takesAction and itemsTakeAction; a web component uses actions`])}function T(e,t,n,r){if(!H(e))r.push([t,`is not a prop`]);else if(!q(e.type))r.push([`${t}.type`,`${z(e.type)} is not a prop type`]);else{if(e.type===`enum`||e.type===`enumOrNumber`?ie(e,t,r):e.values!==void 0&&r.push([`${t}.values`,`only an enum or an enumOrNumber has values`]),e.fields!==void 0){if(e.type!==`object`)r.push([`${t}.fields`,`only an object has fields`]);else if(!H(e.fields))r.push([`${t}.fields`,`must be an object`]);else for(let[i,a]of Object.entries(e.fields))T(a,`${t}.fields.${i}`,n,r)}if(e.itemFields!==void 0){if(e.type!==`array`)r.push([`${t}.itemFields`,`only an array has itemFields`]);else if(!H(e.itemFields))r.push([`${t}.itemFields`,`must be an object`]);else for(let[i,a]of Object.entries(e.itemFields))T(a,`${t}.itemFields.${i}`,n,r)}if(W(e.description)||r.push([`${t}.description`,`is empty`]),e.required!==void 0&&typeof e.required!=`boolean`&&r.push([`${t}.required`,`must be true or false`]),e.nullable!==void 0&&typeof e.nullable!=`boolean`&&r.push([`${t}.nullable`,`must be true or false`]),e.default!==void 0){if(e.required===!0)r.push([`${t}.default`,`a required prop has no default`]);else{let i=[];E(e.default,e,t,n,i),i.length>0&&r.push([`${t}.default`,`${z(e.default)} does not fit ${e.type}`])}}}}function ie(e,t,n){let{type:r,values:i}=e;if(!Array.isArray(i)||i.length===0){n.push([`${t}.values`,`an ${r} lists its values`]);return}let a=new Set;i.forEach(e=>{(r===`enum`?typeof e==`string`||U(e):typeof e==`string`)?a.has(e)&&n.push([`${t}.values`,`"${e}" is listed twice`]):n.push([`${t}.values`,`${z(e)} is not allowed here`]),a.add(e)})}function E(e,t,n,r,i){if(!H(t)||e===null&&(t.nullable===!0||t.type===`node`||t.type===`icon`))return;let{type:a,fields:o,itemFields:s}=t,c=Array.isArray(t.values)?t.values:[];switch(a){case`string`:case`url`:typeof e!=`string`&&R(e,a,n,i);return;case`number`:U(e)||R(e,a,n,i);return;case`boolean`:typeof e!=`boolean`&&R(e,a,n,i);return;case`stringOrNumber`:typeof e!=`string`&&!U(e)&&R(e,a,n,i);return;case`enum`:c.includes(e)||i.push([n,`${z(e)} is not one of ${z(c)}`]);return;case`enumOrNumber`:!U(e)&&!c.includes(e)&&i.push([n,`${z(e)} is not one of ${z(c)}`]);return;case`icon`:J(e)?k(e,n,r,i):typeof e==`string`?Array.isArray(r.icons)&&!r.icons.includes(e)&&i.push([n,`"${e}" is not an icon of the kit`]):R(e,a,n,i);return;case`node`:Array.isArray(e)?e.forEach((e,t)=>{D(e,`${n}[${t}]`,r,i)}):D(e,n,r,i);return;case`array`:Array.isArray(e)?s!==void 0&&e.forEach((e,t)=>{H(e)?O(e,s,`${n}[${t}]`,r,i):i.push([`${n}[${t}]`,`${z(e)} is not an object`])}):R(e,a,n,i);return;case`object`:H(e)?o!==void 0&&O(e,o,n,r,i):R(e,a,n,i);return;default:return}}function D(e,t,n,r){J(e)?k(e,t,n,r):typeof e!=`string`&&!U(e)&&r.push([t,`${z(e)} is not a node`])}function O(e,t,n,r,i){if(H(t)){for(let a of Object.keys(e))Object.hasOwn(t,a)?E(e[a],t[a],`${n}.${a}`,r,i):i.push([`${n}.${a}`,`not a field`]);for(let[r,a]of Object.entries(t))H(a)&&a.required===!0&&!Object.hasOwn(e,r)&&i.push([`${n}.${r}`,`missing, the field is required`])}}function k(e,t,n,r){let{component:i}=e,a=n.byName.get(i);if(a||n.knownNames.has(i)||c.includes(i)||r.push([`${t}.component`,`"${i}" is neither a component of the kit nor one of the HTML tags`]),e.props!==void 0){if(!H(e.props))r.push([`${t}.props`,`must be an object`]);else if(a){let o=H(a.props)?a.props:{};for(let[a,s]of Object.entries(e.props))n.fixed&&n.fixed.name===i&&n.fixed.keys.has(a)?r.push([`${t}.props.${a}`,`is a fixed prop; the kit sets it`]):Object.hasOwn(o,a)?E(s,o[a],`${t}.props.${a}`,n,r):r.push([`${t}.props.${a}`,`not a prop of ${i}`])}}e.children!==void 0&&(a&&a.acceptsChildren===!1&&r.push([`${t}.children`,`${i} takes no children`]),j(e.children,`${t}.children`,n,r)),e.handlers!==void 0&&A(e.handlers,`${t}.handlers`,i,a,r)}function A(e,t,n,r,i){if(!G(e)){i.push([t,`must be a list of handler names`]);return}if(ce(n)){i.push([t,`handlers need a kit component`]);return}if(e.length===0){i.push([t,`omit handlers when empty`]);return}let a=new Set;for(let o of e)m.test(o)?a.has(o)?i.push([t,`"${o}" is listed twice`]):r&&H(r.props)&&Object.hasOwn(r.props,o)&&i.push([t,`"${o}" is a data prop of ${n}, set it in props`]):i.push([t,`"${o}" is not a handler name (on<Event>)`]),a.add(o)}function j(e,t,n,r){typeof e!=`string`&&(Array.isArray(e)?e.forEach((e,i)=>{typeof e!=`string`&&(J(e)?k(e,`${t}[${i}]`,n,r):r.push([`${t}[${i}]`,`is neither text nor a placed element`]))}):r.push([t,`is text or a list of text and placed elements`]))}function ae(e,t,n,r,i,a,o,s){if(!H(e)){s.push([t,`is not an example`]);return}let{name:c}=n,{id:l}=e;if(typeof l!=`string`||!le(l,c)?s.push([`${t}.id`,`"${l}" must be ${c} or ${c}.<case>`]):a.has(l)?s.push([`${t}.id`,`"${l}" is also used in ${a.get(l)}`]):a.set(l,i),W(e.title)||s.push([`${t}.title`,`is empty`]),!H(e.props))s.push([`${t}.props`,`must be an object`]);else{for(let[n,i]of Object.entries(e.props))o.fixed?.keys.has(n)?s.push([`${t}.props.${n}`,`is a fixed prop; the kit sets it`]):!Object.hasOwn(r,n)&&p.test(n)&&W(i)||(Object.hasOwn(r,n)?E(i,r[n],`${t}.props.${n}`,o,s):s.push([`${t}.props.${n}`,`not a prop of ${c}`]));for(let[n,i]of Object.entries(r))H(i)&&i.required===!0&&!Object.hasOwn(e.props,n)&&s.push([`${t}.props.${n}`,`missing, the prop is required`])}e.children!==void 0&&(n.acceptsChildren===!1&&s.push([`${t}.children`,`${c} takes no children`]),j(e.children,`${t}.children`,o,s)),e.wrap!==void 0&&(J(e.wrap)?k(e.wrap,`${t}.wrap`,o,s):s.push([`${t}.wrap`,`is not a placed element`])),e.handlers!==void 0&&A(e.handlers,`${t}.handlers`,c,n,s)}function oe(e,t,n){H(e)?(Array.isArray(e.when)&&e.when.length!==0&&e.when.every(W)||n.push([`usage.when`,`lists nothing; write at least one line`]),Array.isArray(e.whenNot)?e.whenNot.forEach((e,r)=>{se(e,`usage.whenNot[${r}]`,t,n)}):n.push([`usage.whenNot`,`must be a list`]),Array.isArray(e.do)||n.push([`usage.do`,`must be a list`]),Array.isArray(e.dont)||n.push([`usage.dont`,`must be a list`]),Array.isArray(e.do)&&Array.isArray(e.dont)&&(e.do.length!==e.dont.length&&n.push([`usage`,`${e.do.length} do against ${e.dont.length} dont; they pair up one to one`]),e.do.forEach((e,r)=>{M(e,`usage.do[${r}]`,t,n)}),e.dont.forEach((e,r)=>{M(e,`usage.dont[${r}]`,t,n)})),Array.isArray(e.a11y)?e.a11y.forEach((e,t)=>{W(e)||n.push([`usage.a11y[${t}]`,`is empty`])}):n.push([`usage.a11y`,`must be a list`]),e.keyboard!==void 0&&(Array.isArray(e.keyboard)?e.keyboard.forEach((e,t)=>{for(let r of[`key`,`does`,`notes`])H(e)&&W(e[r])||n.push([`usage.keyboard[${t}].${r}`,`is empty`])}):n.push([`usage.keyboard`,`must be a list`])),e.contrast!==void 0&&(Array.isArray(e.contrast)?e.contrast.forEach((e,t)=>{for(let r of[`pair`,`light`,`dark`])H(e)&&W(e[r])||n.push([`usage.contrast[${t}].${r}`,`is empty`])}):n.push([`usage.contrast`,`must be a list`]))):n.push([`usage`,`must be an object`])}function se(e,t,n,r){H(e)?(W(e.text)||r.push([`${t}.text`,`is empty`]),e.instead!==void 0&&(typeof e.instead==`string`?f.test(e.instead)&&!n.byName.has(e.instead)&&!n.knownNames.has(e.instead)&&r.push([`${t}.instead`,`"${e.instead}" is not a component of the kit`]):r.push([`${t}.instead`,`must be text`]))):r.push([t,`is not an object`])}function M(e,t,n,r){H(e)?(W(e.note)||r.push([`${t}.note`,`is empty`]),e.title!==void 0&&typeof e.title!=`string`&&r.push([`${t}.title`,`must be text`]),!Array.isArray(e.example)||e.example.length===0?r.push([`${t}.example`,`needs at least one placed element`]):e.example.forEach((e,i)=>{let a=`${t}.example[${i}]`;J(e)?k(e,a,n,r):r.push([a,`is not a placed element`])})):r.push([t,`is not a practice`])}function N(e,t,n){if(typeof e==`string`)g.test(e)&&n.push([t,`contains an em or en dash; use a comma, colon or period`]);else if(Array.isArray(e))e.forEach((e,r)=>{N(e,`${t}[${r}]`,n)});else if(H(e))for(let[r,i]of Object.entries(e))N(i,t?`${t}.${r}`:r,n)}function P(e,t){let n=t.type===`enum`||t.type===`enumOrNumber`;if(n&&t.values===void 0)throw Error(`${e}: an enum has no values; checkMetas refuses it`);return{name:e,type:t.type,...n&&t.values!==void 0?{enum:I(t.values)}:{},...t.fields===void 0?{}:{fields:F(t.fields)},...t.itemFields===void 0?{}:{itemFields:F(t.itemFields)},required:t.required===!0,...t.nullable===!0?{nullable:!0}:{},...t.description===void 0?{}:{description:t.description},...t.default===void 0?{}:{default:t.default}}}function F(e){return Object.entries(e).sort(([e],[t])=>B(e,t)).map(([e,t])=>P(e,t))}function I(e){return[...e].sort((e,t)=>{let n=typeof e==`number`,r=typeof t==`number`;return n&&r?e-t:n===r?B(String(e),String(t)):n?-1:1})}function L(e){return e.type===`array`&&Object.keys(e.itemFields??{}).some(e=>e===`href`||e===`to`)}function R(e,t,n,r){r.push([n,`${z(e)} is not a ${t}`])}function z(e){return JSON.stringify(e)}function B(e,t){return e<t?-1:+(e>t)}function V(e){return Array.isArray(e)&&e.every(e=>H(e))}function H(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function U(e){return typeof e==`number`&&Number.isFinite(e)}function W(e){return typeof e==`string`&&e.trim()!==``}function G(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function K(e){return l.some(t=>t===e)}function q(e){return _.some(t=>t===e)}function ce(e){return typeof e==`string`&&c.includes(e)}function le(e,t){return e===t||typeof t==`string`&&e.startsWith(`${t}.`)&&d.test(e.slice(t.length+1))}function J(e){return H(e)&&typeof e.component==`string`}function ue(e){return H(e)&&typeof e.name==`string`&&(e.component===void 0||typeof e.component==`string`)&&(e.fixedProps===void 0||H(e.fixedProps))&&(e.marker===null||typeof e.marker==`string`)&&de(e.platforms)&&typeof e.acceptsChildren==`boolean`&&Y(e.props)&&(e.actions===void 0||fe(e.actions))&&(e.role===void 0||K(e.role))&&(e.takesAction===void 0||G(e.takesAction))&&(e.itemsTakeAction===void 0||G(e.itemsTakeAction))&&(e.omit===void 0||G(e.omit))&&Array.isArray(e.examples)&&e.examples.every(he)&&ve(e.usage)}function de(e){return Array.isArray(e)&&e.every(e=>e===`web`||e===`phone`)}function fe(e){return H(e)&&Object.values(e).every(e=>typeof e==`string`)}function Y(e){return H(e)&&Object.values(e).every(pe)}function pe(e){return H(e)&&q(e.type)&&(e.values===void 0||me(e.values))&&(e.required===void 0||typeof e.required==`boolean`)&&(e.nullable===void 0||typeof e.nullable==`boolean`)&&typeof e.description==`string`&&(e.fields===void 0||Y(e.fields))&&(e.itemFields===void 0||Y(e.itemFields))}function me(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`||typeof e==`number`)}function X(e){return typeof e==`string`||Array.isArray(e)&&e.every(e=>typeof e==`string`||Z(e))}function Z(e){return H(e)&&typeof e.component==`string`&&(e.props===void 0||H(e.props))&&(e.children===void 0||X(e.children))&&(e.handlers===void 0||G(e.handlers))}function he(e){return H(e)&&typeof e.id==`string`&&typeof e.title==`string`&&H(e.props)&&(e.children===void 0||X(e.children))&&(e.wrap===void 0||Z(e.wrap))&&(e.handlers===void 0||G(e.handlers))}function Q(e){return H(e)&&(e.title===void 0||typeof e.title==`string`)&&typeof e.note==`string`&&Array.isArray(e.example)&&e.example.every(Z)}function ge(e){return H(e)&&typeof e.text==`string`&&(e.instead===void 0||typeof e.instead==`string`)}function _e(e,t){return H(e)&&t.every(t=>typeof e[t]==`string`)}function $(e,t){return Array.isArray(e)&&e.every(e=>_e(e,t))}function ve(e){return H(e)&&G(e.when)&&Array.isArray(e.whenNot)&&e.whenNot.every(ge)&&Array.isArray(e.do)&&e.do.every(Q)&&Array.isArray(e.dont)&&e.dont.every(Q)&&G(e.a11y)&&(e.keyboard===void 0||$(e.keyboard,[`key`,`does`,`notes`]))&&(e.contrast===void 0||$(e.contrast,[`pair`,`light`,`dark`]))}export{c as HTML_TAGS,l as ROLES,b as checkMetas,te as componentModuleOf,ee as manifestComponent,y as readMetas};
@@ -0,0 +1,27 @@
1
+ import type { CanvasManifestComponent } from "./manifest.ts";
2
+ export declare function phoneIcons(file: string): string[];
3
+ type EntryData = string | number | boolean | EntryData[] | {
4
+ [key: string]: EntryData;
5
+ };
6
+ export interface PhoneChromeEntry {
7
+ name: string;
8
+ marker: string;
9
+ acceptsChildren: boolean;
10
+ props: EntryData[];
11
+ itemsTakeAction: EntryData[];
12
+ takesAction: EntryData[];
13
+ source: string;
14
+ }
15
+ export declare function phoneChromeEntries(file: string, libraryPackage: string): PhoneChromeEntry[];
16
+ export declare function toManifestComponent(entry: PhoneChromeEntry): CanvasManifestComponent;
17
+ export interface PhoneKitComponent {
18
+ name: string;
19
+ props: {
20
+ name: string;
21
+ type: string;
22
+ }[];
23
+ itemsTakeAction: string[];
24
+ takesAction: string[];
25
+ }
26
+ export declare function applyPhoneActions(components: PhoneKitComponent[], itemActions: Partial<Record<"itemsTakeAction" | "takesAction", Record<string, string[]>>>): void;
27
+ export {};
package/dist/phone.js CHANGED
@@ -1 +1 @@
1
- import{readText as e}from"./files.js";import t from"@babel/parser";function n(n){return t.parse(e(n),{sourceType:`module`,plugins:[`typescript`]})}function r(e){return[...new Set(e)].sort((e,t)=>e<t?-1:+(e>t))}function i(e){return e.type===`Identifier`?e.name:e.type===`StringLiteral`?e.value:null}function a(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 o(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 s(e){let t=n(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 r(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 c(e,t,n){let r=o(e,t,n);switch(r.type){case`StringLiteral`:case`NumericLiteral`:case`BooleanLiteral`:return r.value;case`UnaryExpression`:if(r.operator===`!`&&r.argument.type===`NumericLiteral`)return!r.argument.value;break;case`ArrayExpression`:return r.elements.map(t=>c(e,t,n));case`ObjectExpression`:return Object.fromEntries(r.properties.map(t=>{if(t.type!==`ObjectProperty`||t.computed)throw Error(`phoneChromeEntries in ${n} has an object member the reader cannot follow.`);return[i(t.key),c(e,t.value,n)]}));case`MemberExpression`:if(!r.computed&&r.property.type===`Identifier`){let t=c(e,r.object,n);if(typeof t==`object`&&t&&r.property.name in t)return t[r.property.name]}}throw Error(`phoneChromeEntries in ${n} has a ${r.type} the reader cannot read as data.`)}function l(e){return new Set(e.program.body.filter(e=>e.type===`ExportNamedDeclaration`&&e.declaration).flatMap(({declaration:e})=>e.type===`VariableDeclaration`?e.declarations.map(e=>e.id.name):[e.id?.name]))}function u(n,r){let i=t.parse(e(n),{sourceType:`module`,plugins:[`jsx`]}),o=a(i);if(!o.has(`phoneChromeEntries`))throw Error(`phoneChromeEntries is not declared in ${n}; the phone kit's frame parts come from it.`);let s=c(o,o.get(`phoneChromeEntries`),n),u=l(i);if(!Array.isArray(s)||s.length===0)throw Error(`phoneChromeEntries in ${n} must be a list of manifest entries.`);return s.map(e=>{let{name:t,marker:i,acceptsChildren:a,props:o,itemsTakeAction:s,takesAction:c,source:l}=e??{};if(typeof t!=`string`||typeof i!=`string`||typeof a!=`boolean`||!Array.isArray(o)||!Array.isArray(s)||!Array.isArray(c))throw Error(`phoneChromeEntries in ${n} has an entry that is not a manifest component: ${JSON.stringify(e)}`);if(l!==r)throw Error(`phoneChromeEntries in ${n}: ${t} names the source ${l}, not ${r}.`);if(!u.has(t))throw Error(`phoneChromeEntries in ${n} lists ${t}, which the module does not export.`);return{name:t,marker:i,acceptsChildren:a,props:o,itemsTakeAction:s,takesAction:c,source:l}})}function d(e,t){for(let[n,i]of[[`itemsTakeAction`,`array`],[`takesAction`,`object`]])for(let[a,o]of Object.entries(t[n]??{})){let t=e.find(({name:e})=>e===a);if(!t)throw Error(`phoneStyleSupport.json ${n} names ${a}, which the kit does not have.`);for(let e of o)if(t.props.find(({name:t})=>t===e)?.type!==i)throw Error(`phoneStyleSupport.json ${n} names ${a}.${e}, which is not a prop of type ${i} in the kit.`);t[n]=r([...new Set([...t[n],...o])])}}export{d as applyPhoneActions,u as phoneChromeEntries,s as phoneIcons};
1
+ import{readText as e}from"./files.js";import t from"@babel/parser";function n(n){return t.parse(e(n),{sourceType:`module`,plugins:[`typescript`]})}function r(e){return[...new Set(e)].sort((e,t)=>e<t?-1:+(e>t))}function i(e){return e.type===`Identifier`?e.name:e.type===`StringLiteral`?e.value:null}function a(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 o(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)}if(r==null)throw Error(`${n} has a constant without a value the reader can follow.`);return r}function s(e){let t=n(e).program.body.map(e=>e.type===`ExportNamedDeclaration`?e.declaration:e).find(e=>e?.type===`TSTypeAliasDeclaration`&&e.id.name===`IconName`)?.typeAnnotation;if(t?.type!==`TSUnionType`)throw Error(`IconName union not found in ${e}`);return r(t.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 c(e,t,n){let r=o(e,t,n);switch(r.type){case`StringLiteral`:case`NumericLiteral`:case`BooleanLiteral`:return r.value;case`UnaryExpression`:if(r.operator===`!`&&r.argument.type===`NumericLiteral`)return!r.argument.value;break;case`ArrayExpression`:return r.elements.map(t=>c(e,t,n));case`ObjectExpression`:return Object.fromEntries(r.properties.map(t=>{if(t.type!==`ObjectProperty`||t.computed)throw Error(`phoneChromeEntries in ${n} has an object member the reader cannot follow.`);return[String(i(t.key)),c(e,t.value,n)]}));case`MemberExpression`:if(!r.computed&&r.property.type===`Identifier`){let t=c(e,r.object,n);if(typeof t==`object`&&t&&!Array.isArray(t)&&r.property.name in t){let e=t[r.property.name];if(e!==void 0)return e}}}throw Error(`phoneChromeEntries in ${n} has a ${r.type} the reader cannot read as data.`)}function l(e){let t=`id`in e?e.id:void 0;return t?.type===`Identifier`?t.name:void 0}function u(e){let t=new Set;for(let n of e.program.body){if(n.type!==`ExportNamedDeclaration`)continue;let e=n.declaration;if(e){if(e.type===`VariableDeclaration`)for(let n of e.declarations)t.add(n.id.type===`Identifier`?n.id.name:void 0);else t.add(l(e))}}return t}function d(n,r){let i=t.parse(e(n),{sourceType:`module`,plugins:[`jsx`]}),o=a(i);if(!o.has(`phoneChromeEntries`))throw Error(`phoneChromeEntries is not declared in ${n}; the phone kit's frame parts come from it.`);let s=o.get(`phoneChromeEntries`);if(s==null)throw Error(`canvas-kit: phoneChromeEntries is missing in ${n}.`);let l=c(o,s,n),d=u(i);if(!Array.isArray(l)||l.length===0)throw Error(`phoneChromeEntries in ${n} must be a list of manifest entries.`);return l.map(e=>{let{name:t,marker:i,acceptsChildren:a,props:o,itemsTakeAction:s,takesAction:c,source:l}=typeof e==`object`&&e&&!Array.isArray(e)?e:{};if(typeof t!=`string`||typeof i!=`string`||typeof a!=`boolean`||!Array.isArray(o)||!Array.isArray(s)||!Array.isArray(c))throw Error(`phoneChromeEntries in ${n} has an entry that is not a manifest component: ${JSON.stringify(e)}`);if(l!==r)throw Error(`phoneChromeEntries in ${n}: ${t} names the source ${String(l)}, not ${r}.`);if(!d.has(t))throw Error(`phoneChromeEntries in ${n} lists ${t}, which the module does not export.`);return{name:t,marker:i,acceptsChildren:a,props:o,itemsTakeAction:s,takesAction:c,source:String(l)}})}var f=[`any`,`array`,`boolean`,`enum`,`enumOrNumber`,`icon`,`node`,`number`,`object`,`string`,`stringOrNumber`,`url`],p=e=>typeof e==`object`&&!!e&&!Array.isArray(e),m=e=>typeof e==`string`||typeof e==`number`,h=e=>f.some(t=>t===e);function g(e){if(!p(e))return!1;let{name:t,type:n,required:r,enum:i,fields:a,itemFields:o,nullable:s,description:c}=e;return typeof t==`string`&&h(n)&&typeof r==`boolean`&&(i===void 0||Array.isArray(i)&&i.every(m))&&(a===void 0||Array.isArray(a)&&a.every(g))&&(o===void 0||Array.isArray(o)&&o.every(g))&&(s===void 0||s===!0)&&(c===void 0||typeof c==`string`)}function _(e,t){throw Error(`canvas-kit: phone chrome entry "${e.name}" has no ${t}.`)}function v(e,t){return e[t].map(n=>typeof n==`string`?n:_(e,t))}function y(e){return{name:e.name,marker:e.marker,acceptsChildren:e.acceptsChildren,props:e.props.map(t=>g(t)?t:_(e,`props`)),itemsTakeAction:v(e,`itemsTakeAction`),takesAction:v(e,`takesAction`),source:e.source}}function b(e,t){for(let[n,i]of[[`itemsTakeAction`,`array`],[`takesAction`,`object`]])for(let[a,o]of Object.entries(t[n]??{})){let t=e.find(({name:e})=>e===a);if(!t)throw Error(`phoneStyleSupport.json ${n} names ${a}, which the kit does not have.`);for(let e of o)if(t.props.find(({name:t})=>t===e)?.type!==i)throw Error(`phoneStyleSupport.json ${n} names ${a}.${e}, which is not a prop of type ${i} in the kit.`);t[n]=r([...new Set([...t[n],...o])])}}export{b as applyPhoneActions,d as phoneChromeEntries,s as phoneIcons,y as toManifestComponent};
@@ -0,0 +1,10 @@
1
+ import { type CanvasManifest, type CanvasReleaseStamp } from "./manifest.ts";
2
+ export declare function digest(content: string | Uint8Array): {
3
+ sha256: string;
4
+ bytes: number;
5
+ };
6
+ export declare function writeReleaseFolder(outDir: string, files: Readonly<Record<string, string | Uint8Array>>, stamp: unknown): void;
7
+ export declare function readReleaseManifest(dir: string): {
8
+ release: CanvasReleaseStamp;
9
+ manifest: CanvasManifest;
10
+ };
package/dist/release.js CHANGED
@@ -1 +1 @@
1
- import{readJson as e}from"./files.js";import{RELEASE_FILE as t,changedMessage as n,checkStampFiles as r}from"./releaseStamp.js";import{existsSync as i,mkdirSync as a,readFileSync as o,renameSync as s,rmSync as c,writeFileSync as l}from"node:fs";import{dirname as u,join as d}from"node:path";import{createHash as f}from"node:crypto";function p(e){let t=Buffer.from(e);return{sha256:f(`sha256`).update(t).digest(`hex`),bytes:t.length}}function m(e,n,r){if(i(e))throw Error(`${e} already exists. A release folder is never overwritten; choose a new folder.`);a(u(e),{recursive:!0});let o=`${e}.staging-${process.pid}-${Date.now()}`;a(o);try{for(let[e,t]of Object.entries(n))l(d(o,e),t,{flag:`wx`});l(d(o,t),`${JSON.stringify(r,null,2)}\n`,{flag:`wx`}),s(o,e)}catch(e){throw c(o,{recursive:!0,force:!0}),e}}function h(a){let s=d(a,t);if(!i(s))throw Error(`${a} has no ${t}; it is not a kit release.`);let c=e(s);r(c,a);for(let[e,t]of Object.entries(c.files)){let r=d(a,e);if(!i(r))throw Error(`${e} is missing from ${a}.`);let s=p(o(r));if(s.sha256!==t.sha256||s.bytes!==t.bytes)throw Error(n(e,a))}return{release:c,manifest:e(d(a,`manifest.json`))}}export{p as digest,h as readReleaseManifest,m as writeReleaseFolder};
1
+ import{isRecord as e,readJson as t}from"./files.js";import{parseCanvasManifest as n,parseCanvasReleaseStamp as r}from"./manifest.js";import{RELEASE_FILE as i,changedMessage as a,checkStampFiles as o}from"./releaseStamp.js";import{existsSync as s,mkdirSync as c,readFileSync as l,renameSync as u,rmSync as d,writeFileSync as f}from"node:fs";import{dirname as p,join as m}from"node:path";import{createHash as h}from"node:crypto";function g(e){let t=Buffer.from(e);return{sha256:h(`sha256`).update(t).digest(`hex`),bytes:t.length}}function _(e,t,n){if(s(e))throw Error(`${e} already exists. A release folder is never overwritten; choose a new folder.`);c(p(e),{recursive:!0});let r=`${e}.staging-${process.pid}-${Date.now()}`;c(r);try{for(let[e,n]of Object.entries(t))f(m(r,e),n,{flag:`wx`});f(m(r,i),`${JSON.stringify(n,null,2)}\n`,{flag:`wx`}),u(r,e)}catch(e){throw d(r,{recursive:!0,force:!0}),e}}function v(c){let u=m(c,i);if(!s(u))throw Error(`${c} has no ${i}; it is not a kit release.`);let d=t(u);o(e(d)&&e(d.files)?{files:d.files}:null,c);let f=r(d,u);for(let[e,t]of Object.entries(f.files)){let n=m(c,e);if(!s(n))throw Error(`${e} is missing from ${c}.`);let r=g(l(n));if(r.sha256!==t.sha256||r.bytes!==t.bytes)throw Error(a(e,c))}let p=m(c,`manifest.json`);return{release:f,manifest:n(t(p),p)}}export{g as digest,v as readReleaseManifest,_ as writeReleaseFolder};
@@ -0,0 +1,6 @@
1
+ export declare const RELEASE_FILE: "release.json";
2
+ export declare const RELEASE_CONTENT: readonly string[];
3
+ export declare function checkStampFiles(release: {
4
+ files?: Readonly<Record<string, unknown>> | undefined;
5
+ } | null | undefined, where: string): void;
6
+ export declare function changedMessage(name: string, where: string): string;
package/dist/renames.d.ts CHANGED
@@ -1,15 +1,13 @@
1
- import type { CanvasManifestRename } from "./manifest.js";
2
-
3
- // Reads every rename table in `renamesDir` whose version is at or below `version`, keeps the rules for `libraryPackage`,
4
- // drops event-handler props (`on` followed by a capital) and a rule whose component the kit does not list, and answers the
5
- // projection in ascending version order. Throws when the folder is missing, a table does not parse, or a rule of the table
6
- // whose version equals `version` names a target prop or value prop the kit's `components` do not declare.
7
- export function readRenames(
8
- renamesDir: string,
9
- libraryPackage: string,
10
- version: string,
11
- components: ReadonlyArray<{ name: string; props: ReadonlyArray<{ name: string }> }>,
12
- ): CanvasManifestRename[];
13
-
14
- // The entries with `from` < version <= `to`, in ascending order; an empty list when `from` is at or above `to`.
15
- export function renamesBetween(renames: readonly CanvasManifestRename[], from: string, to: string): CanvasManifestRename[];
1
+ import type { CanvasManifestRename } from "./manifest.ts";
2
+ export interface KitComponent {
3
+ name: string;
4
+ props: ReadonlyArray<{
5
+ name: string;
6
+ }>;
7
+ }
8
+ export declare function readRenamesWithWarnings(renamesDir: string, libraryPackage: string, version: string, components: readonly KitComponent[]): {
9
+ renames: CanvasManifestRename[];
10
+ warnings: string[];
11
+ };
12
+ export declare function readRenames(renamesDir: string, libraryPackage: string, version: string, components: readonly KitComponent[]): CanvasManifestRename[];
13
+ export declare function renamesBetween(renames: readonly CanvasManifestRename[], from: string, to: string): CanvasManifestRename[];
package/dist/renames.js CHANGED
@@ -1 +1 @@
1
- import{existsSync as e,readFileSync as t,readdirSync as n}from"node:fs";import{join as r}from"node:path";var i=/^\d+\.\d+\.\d+\.json$/,a=/^on[A-Z]/;function o(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 s(e){return Object.fromEntries(Object.entries(e).filter(([e])=>!a.test(e)))}function c(e){try{return JSON.parse(t(e,`utf8`))}catch(t){throw Error(`${e} is not valid JSON: ${t.message}`)}}function l(e,t){return e.has(t)||e.set(t,{name:t,props:{},values:{},added:{},removed:{}}),e.get(t)}function u(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=l(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=l(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 d({tableVersion:e,version:t,libraryPackage:n,warnings:r,component:i,prop:a,target:s,declared:c}){if(c.has(s))return!0;if(o(e,t)===0)throw Error(`${e}: ${i}.${a} renames to ${s}, which ${n} ${t} does not declare`);return r.push(`${e}: ${i}.${a} renames to ${s}, which this kit does not declare; left out.`),!1}function f(e,{libraryPackage:t,version:n,components:r,warnings:i}){let a=e.version,{entries:o,values:c}=u(e,t),l=[];for(let e of o.values()){let o=e.to??e.name,c=r.find(e=>e.name===o);if(!c){i.push(`${a}: ${o} is not a component of this kit; the renames of ${e.name} are left out.`);continue}let u=new Set(c.props.map(e=>e.name)),f=(r,o)=>d({tableVersion:a,version:n,libraryPackage:t,warnings:i,component:e.name,prop:r,target:o,declared:u}),p={};for(let[t,n]of Object.entries(s(e.props)))f(t,n)&&(p[t]=n);let m={};for(let[t,n]of Object.entries(s(e.values)))f(t,t)&&(m[t]=n);let h=s(e.added),g=s(e.removed);(e.to!==void 0||Object.keys(p).length+Object.keys(m).length+Object.keys(h).length+Object.keys(g).length!==0)&&l.push({name:e.name,...e.to===void 0?{}:{to:e.to},props:p,values:m,added:h,removed:g})}return{version:a,components:l,values:s(c)}}function p(t,a,s,l){if(!e(t))throw Error(`${t} does not exist. Set renames in canvas-kit.json to the folder of rename tables.`);let u=n(t).filter(e=>i.test(e)).map(e=>c(r(t,e))).filter(e=>o(e.version,s)<=0).sort((e,t)=>o(e.version,t.version)),d=[];return{renames:u.map(e=>f(e,{libraryPackage:a,version:s,components:l,warnings:d})),warnings:d}}function m(e,t,n,r){return p(e,t,n,r).renames}function h(e,t,n){return e.filter(e=>o(e.version,t)>0&&o(e.version,n)<=0).sort((e,t)=>o(e.version,t.version))}export{m as readRenames,p as readRenamesWithWarnings,h 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(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,26 +1,20 @@
1
1
  /** The attribute every stamped element carries: "<repo path>:<line>:<column>", line and column 1-based. */
2
2
  export declare const SOURCE_STAMP_ATTRIBUTE: "data-canvas-at";
3
-
4
3
  /** The environment the app is built for: its compiled AppSettings ENVIRONMENT, exactly. */
5
4
  export type SourceStampEnvironment = "Local" | "Development" | "Staging" | "Production";
6
-
7
5
  export interface SourceStampOptions {
8
6
  environment: SourceStampEnvironment;
9
7
  }
10
-
11
8
  /** The slice of Babel's plugin API the stamp uses (Babel 7.29 or 8). */
12
9
  export interface BabelPluginApi {
13
10
  assertVersion(range: string | number): void;
14
11
  types: unknown;
15
12
  }
16
-
17
13
  export interface BabelPlugin {
18
14
  name: string;
19
15
  visitor: Record<string, unknown>;
20
16
  }
21
-
22
17
  export type BabelPluginItem = [plugin: (api: BabelPluginApi) => BabelPlugin, options: Record<string, never>];
23
-
24
18
  /**
25
19
  * The Babel plugins for this environment: the stamp in Local, Development and Staging, none in Production.
26
20
  * Throws when environment is missing or not one of the four names.
@@ -1 +1 @@
1
- import{existsSync as e}from"node:fs";import{dirname as t,join as n,relative as r,sep as i}from"node:path";var a=`data-canvas-at`,o=[`Local`,`Development`,`Staging`,`Production`],s=new Map;function c(e){let t=e?.environment;if(!o.includes(t))throw Error(`sourceStamp: environment must be one of Local, Development, Staging, Production (the app's compiled AppSettings ENVIRONMENT); got ${JSON.stringify(t)}.`);return t===`Production`?[]:[[l,{}]]}function l(e){e.assertVersion(`^7.29.0 || ^8.0.0`);let t=e.types;return{name:`webority-source-stamp`,pre(){this.stampPath=u(this.filename)},visitor:{JSXOpeningElement(e){if(this.stampPath===null||!e.node.loc)return;let{node:n}=e;if(f(n.name)||n.attributes.some(p))return;let{line:r,column:i}=n.loc.start;n.attributes.unshift(t.jsxAttribute(t.jsxIdentifier(a),t.stringLiteral(`${this.stampPath}:${r}:${i+1}`)))}}}}function u(e){if(e===void 0||e===``)throw Error(`sourceStamp: Babel gave no file name; the transform must pass filename.`);let t=e.split(`?`,1)[0];return t.startsWith(`\0`)||t.split(/[/\\]/).includes(`node_modules`)?null:r(d(t),t).split(i).join(`/`)}function d(r){let i=[],a=t(r),o;for(;o===void 0;){if(s.has(a)){o=s.get(a);break}if(i.push(a),e(n(a,`.webority`,`settings.json`))){o=a;break}let c=t(a);if(c===a)throw Error(`sourceStamp: no .webority/settings.json at or above ${r}; the stamp path starts at the repository root.`);a=c}for(let e of i)s.set(e,o);return o}function f(e){return e.type===`JSXIdentifier`&&e.name===`Fragment`||e.type===`JSXMemberExpression`&&e.property.name===`Fragment`}function p(e){return e.type===`JSXAttribute`&&e.name.type===`JSXIdentifier`&&e.name.name===`data-canvas-at`}export{a as SOURCE_STAMP_ATTRIBUTE,c as sourceStampPlugins};
1
+ import{existsSync as e}from"node:fs";import{dirname as t,join as n,relative as r,sep as i}from"node:path";var a=`data-canvas-at`,o=[`Local`,`Development`,`Staging`,`Production`],s=new Map;function c(e){let t=e,n=typeof t==`object`&&t&&`environment`in t?t.environment:void 0;if(typeof n!=`string`||!o.includes(n))throw Error(`sourceStamp: environment must be one of Local, Development, Staging, Production (the app's compiled AppSettings ENVIRONMENT); got ${JSON.stringify(n)}.`);return n===`Production`?[]:[[u,{}]]}function l(e){return typeof e==`object`&&!!e&&`jsxAttribute`in e&&`jsxIdentifier`in e&&`stringLiteral`in e&&typeof e.jsxAttribute==`function`&&typeof e.jsxIdentifier==`function`&&typeof e.stringLiteral==`function`}function u(e){e.assertVersion(`^7.29.0 || ^8.0.0`);let t=e.types;if(!l(t))throw Error(`sourceStamp: Babel's types API has no jsxAttribute, jsxIdentifier or stringLiteral.`);return{name:`webority-source-stamp`,pre(){this.stampPath=d(this.filename)},visitor:{JSXOpeningElement(e){let n=e.node.loc;if(this.stampPath===null||!n)return;let{node:r}=e;if(p(r.name)||r.attributes.some(m))return;let{line:i,column:o}=n.start;r.attributes.unshift(t.jsxAttribute(t.jsxIdentifier(a),t.stringLiteral(`${this.stampPath}:${i}:${o+1}`)))}}}}function d(e){if(e===void 0||e===``)throw Error(`sourceStamp: Babel gave no file name; the transform must pass filename.`);let t=e.split(`?`,1)[0]??e;return t.startsWith(`\0`)||t.split(/[/\\]/).includes(`node_modules`)?null:r(f(t),t).split(i).join(`/`)}function f(r){let i=[],a=t(r),o;for(;o===void 0;){if(s.has(a)){let e=s.get(a);if(e===void 0)throw Error(`sourceStamp: the root cache lost ${a}.`);o=e;break}if(i.push(a),e(n(a,`.webority`,`settings.json`))){o=a;break}let c=t(a);if(c===a)throw Error(`sourceStamp: no .webority/settings.json at or above ${r}; the stamp path starts at the repository root.`);a=c}for(let e of i)s.set(e,o);return o}function p(e){return e.type===`JSXIdentifier`&&e.name===`Fragment`||e.type===`JSXMemberExpression`&&e.property?.name===`Fragment`}function m(e){return e.type===`JSXAttribute`&&e.name?.type===`JSXIdentifier`&&e.name.name===`data-canvas-at`}export{a as SOURCE_STAMP_ATTRIBUTE,c as sourceStampPlugins};
package/dist/spec.d.ts CHANGED
@@ -13,19 +13,19 @@ export interface CanvasSpecTokenValues {
13
13
  light: string;
14
14
  dark: string;
15
15
  // The token reference the style key names, with its sigil: "$leading.heading", or "-$space.2" for a negative.
16
- path?: string;
16
+ path?: string | undefined;
17
17
  }
18
18
 
19
19
  export interface CanvasSpecCode {
20
- component?: string;
21
- props?: Record<string, unknown>;
22
- source?: string;
23
- selector?: string;
24
- variantProps?: Record<string, unknown>;
20
+ component?: string | undefined;
21
+ props?: Record<string, unknown> | undefined;
22
+ source?: string | undefined;
23
+ selector?: string | undefined;
24
+ variantProps?: Record<string, unknown> | undefined;
25
25
  // The CSS classes the imported element carried, at most 8.
26
- classes?: string[];
26
+ classes?: string[] | undefined;
27
27
  // The Razor partial or other source file the element came from, when the page marked it.
28
- partial?: string;
28
+ partial?: string | undefined;
29
29
  }
30
30
 
31
31
  export interface CanvasSpecNode {
@@ -34,14 +34,14 @@ export interface CanvasSpecNode {
34
34
  // The component the node draws: a block type (Box, Text, Image, Icon, Vector) or a library component name.
35
35
  component: string;
36
36
  // The node's code entry, when the node carries one.
37
- code?: CanvasSpecCode;
37
+ code?: CanvasSpecCode | undefined;
38
38
  box: CanvasSpecBox;
39
39
  // The CSS the renderer applied to the node's element, keyed by property name.
40
40
  styles: Record<string, string>;
41
41
  // Each style key that names a token, keyed by style key ("color", or "border.color" for a part of an object).
42
42
  tokens: Record<string, CanvasSpecTokenValues>;
43
43
  // The text a Text node draws.
44
- text?: string;
44
+ text?: string | undefined;
45
45
  // The top-level sampleData keys the node's text and props read; empty when it reads none.
46
46
  sampleKeys: string[];
47
47
  }
@@ -0,0 +1,6 @@
1
+ import type { CanvasManifestTokens, CanvasManifestTokenValues } from "./manifest.ts";
2
+ export declare function tokensFromV2(tokensFile: string, meaningsFile: string, platform: string | undefined): {
3
+ tokens: CanvasManifestTokens;
4
+ tokenValues: CanvasManifestTokenValues;
5
+ };
6
+ export declare function webIcons(libraryDist: string): string[];
package/dist/tokens.js CHANGED
@@ -1 +1 @@
1
- import{readJson as e,readText as t}from"./files.js";import{join as n}from"node:path";var r=e=>typeof e==`object`&&!!e&&!Array.isArray(e),i=e=>typeof e==`number`&&Number.isFinite(e),a=e=>typeof e==`string`,o=[`x`,`y`,`blur`,`spread`,`color`,`elevation`],s=e=>e===null||r(e)&&Object.keys(e).every(e=>o.includes(e))&&i(e.x)&&i(e.y)&&i(e.blur)&&i(e.spread)&&a(e.color)&&(e.elevation===void 0||i(e.elevation));function c(e){return[...new Set(e)].sort((e,t)=>e<t?-1:+(e>t))}function l(e,t=e=>e){return Object.fromEntries(c(Object.keys(e)).map(n=>[n,t(e[n])]))}function u(e,t,n){if(!r(t[n]))throw Error(`${e} has no ${n} object.`);return t[n]}function d(e,t,n,r){for(let[i,a]of Object.entries(n))if(!r(a))throw Error(`${e}: ${t}.${i} is not a value the kit can draw.`)}function f(t,n,o){let f=e(t);if(f.format!==`webority-theme-tokens/2`)throw Error(`${t} has format ${JSON.stringify(f.format)}; this reader reads webority-theme-tokens/2.`);if(a(o)&&f.source?.platform!==o.toLowerCase())throw Error(`${t} is the ${f.source?.platform} token file; a ${o} kit needs the ${o.toLowerCase()} one.`);let p=r(f.colors)&&r(f.colors.light)?f.colors.light:null,m=r(f.colors)&&r(f.colors.dark)?f.colors.dark:null;if(!p||!m)throw Error(`${t} has no colors.${p?`dark`:`light`} object.`);let h=Object.keys(p).filter(e=>!Object.hasOwn(m,e)),g=Object.keys(m).filter(e=>!Object.hasOwn(p,e));if(h.length>0||g.length>0)throw Error(`${t}: the light and dark colours differ. Only in light: ${h.length>0?c(h).join(`, `):`none`}. Only in dark: ${g.length>0?c(g).join(`, `):`none`}.`);let _=c(Object.keys(p));d(t,`color`,p,a),d(t,`color`,m,a);let v=u(t,f,`space`);d(t,`space`,v,i);let y=u(t,f,`radius`);d(t,`radius`,y,i);let b=u(t,f,`shadow`);d(t,`shadow`,b,s);let x=u(t,f,`fonts`);d(t,`font`,x,e=>r(e)&&a(e.family)&&a(e.fallback));let S=u(t,f,`text`);d(t,`text`,S,e=>r(e)&&i(e.size));let C=u(t,u(t,f,`typography`),`leading`);d(t,`leading`,C,e=>i(e)&&e>0&&e<=4);let w=f.colorMeanings===void 0?{}:f.colorMeanings;if(!r(w))throw Error(`${t} has a colorMeanings entry that is not a description: colorMeanings`);for(let[e,n]of Object.entries(w))if(!a(n)||n===``)throw Error(`${t} has a colorMeanings entry that is not a description: ${e}`);let T=e(n);if(T.format!==`webority-meanings/1`)throw Error(`${n} has format ${JSON.stringify(T.format)}; this reader reads webority-meanings/1.`);let E={};for(let e of _){let t=w[e],r=a(t)&&t!==``?t:T.color?.[e]?.description;if(!a(r)||r===``)throw Error(`${n} has no meaning for the colour ${e}; move the @webority/tokens pin to a version that publishes one.`);E[e]=r}return{tokens:{color:_,space:c(Object.keys(v)),radius:c(Object.keys(y)),shadow:c(Object.keys(b)),font:c(Object.keys(x)),text:c(Object.keys(S)),leading:c(Object.keys(C)),colorMeanings:E},tokenValues:{color:Object.fromEntries(_.map(e=>[e,{light:p[e],dark:m[e]}])),space:l(v),radius:l(y),shadow:l(b),font:l(x,({family:e,fallback:t})=>({family:e,fallback:t})),text:l(S,({size:e})=>({size:e,weight:null})),leading:l(C)}}}function p(e){let r=n(e,`components`,`iconCatalogNames.g.js`),i=t(r),a=/`([^`]+)`\.split\(`\.`\)/.exec(i);if(!a)throw Error(`No icon name list in ${r}`);return c(a[1].split(`.`).filter(Boolean))}export{f as tokensFromV2,p as webIcons};
1
+ import{isRecord as e,readJson as t,readText as n}from"./files.js";import{join as r}from"node:path";var i=e=>typeof e==`object`&&!!e&&!Array.isArray(e),a=e=>typeof e==`number`&&Number.isFinite(e),o=e=>typeof e==`string`,s=[`x`,`y`,`blur`,`spread`,`color`,`elevation`],c=e=>e===null||i(e)&&Object.keys(e).every(e=>s.includes(e))&&a(e.x)&&a(e.y)&&a(e.blur)&&a(e.spread)&&o(e.color)&&(e.elevation===void 0||a(e.elevation)),l=e=>i(e)&&o(e.family)&&o(e.fallback),u=e=>i(e)&&a(e.size),d=e=>a(e)&&e>0&&e<=4;function f(e){return[...new Set(e)].sort((e,t)=>e<t?-1:+(e>t))}function p(e,t){return Object.fromEntries(f(Object.keys(e)).map(n=>{let r=e[n];if(r===void 0)throw Error(`canvas-kit: ${n} is missing.`);return[n,t(r)]}))}function m(t,n){if(!e(t))throw Error(`${n} must be a JSON object.`);return t}function h(e,t,n){let r=t[n];if(!i(r))throw Error(`${e} has no ${n} object.`);return r}function g(e,t,n,r){let i=[];for(let[a,o]of Object.entries(n)){if(!r(o))throw Error(`${e}: ${t}.${a} is not a value the kit can draw.`);i.push([a,o])}return Object.fromEntries(i)}function _(e,n,r){let s=m(t(e),e);if(s.format!==`webority-theme-tokens/2`)throw Error(`${e} has format ${JSON.stringify(s.format)}; this reader reads webority-theme-tokens/2.`);let _=i(s.source)?s.source:{};if(o(r)&&_.platform!==r.toLowerCase())throw Error(`${e} is the ${String(_.platform)} token file; a ${r} kit needs the ${r.toLowerCase()} one.`);let v=i(s.colors)&&i(s.colors.light)?s.colors.light:null,y=i(s.colors)&&i(s.colors.dark)?s.colors.dark:null;if(!v||!y)throw Error(`${e} has no colors.${v?`dark`:`light`} object.`);let b=Object.keys(v).filter(e=>!Object.hasOwn(y,e)),x=Object.keys(y).filter(e=>!Object.hasOwn(v,e));if(b.length>0||x.length>0)throw Error(`${e}: the light and dark colours differ. Only in light: ${b.length>0?f(b).join(`, `):`none`}. Only in dark: ${x.length>0?f(x).join(`, `):`none`}.`);let S=f(Object.keys(v)),C=g(e,`color`,v,o),w=g(e,`color`,y,o),T=g(e,`space`,h(e,s,`space`),a),E=g(e,`radius`,h(e,s,`radius`),a),D=g(e,`shadow`,h(e,s,`shadow`),c),O=g(e,`font`,h(e,s,`fonts`),l),k=g(e,`text`,h(e,s,`text`),u),A=g(e,`leading`,h(e,h(e,s,`typography`),`leading`),d),j=s.colorMeanings===void 0?{}:s.colorMeanings;if(!i(j))throw Error(`${e} has a colorMeanings entry that is not a description: colorMeanings`);for(let[t,n]of Object.entries(j))if(!o(n)||n===``)throw Error(`${e} has a colorMeanings entry that is not a description: ${t}`);let M=m(t(n),n);if(M.format!==`webority-meanings/1`)throw Error(`${n} has format ${JSON.stringify(M.format)}; this reader reads webority-meanings/1.`);let N=i(M.color)?M.color:{},P={};for(let e of S){let t=j[e],r=N[e],a=i(r)?r.description:void 0,s=o(t)&&t!==``?t:a;if(!o(s)||s===``)throw Error(`${n} has no meaning for the colour ${e}; move the @webority/tokens pin to a version that publishes one.`);P[e]=s}return{tokens:{color:S,space:f(Object.keys(T)),radius:f(Object.keys(E)),shadow:f(Object.keys(D)),font:f(Object.keys(O)),text:f(Object.keys(k)),leading:f(Object.keys(A)),colorMeanings:P},tokenValues:{color:Object.fromEntries(S.map(e=>{let t=C[e],n=w[e];if(t===void 0||n===void 0)throw Error(`canvas-kit: the colour ${e} is missing.`);return[e,{light:t,dark:n}]})),space:p(T,e=>e),radius:p(E,e=>e),shadow:p(D,e=>e),font:p(O,({family:e,fallback:t})=>({family:e,fallback:t})),text:p(k,({size:e})=>({size:e,weight:null})),leading:p(A,e=>e)}}}function v(e){let t=r(e,`components`,`iconCatalogNames.g.js`),i=n(t),a=/`([^`]+)`\.split\(`\.`\)/.exec(i);if(!a)throw Error(`No icon name list in ${t}`);let o=a[1];if(o===void 0)throw Error(`canvas-kit: the icon name list in ${t} is missing.`);return f(o.split(`.`).filter(Boolean))}export{_ as tokensFromV2,v as webIcons};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webority/canvas-kit",
3
- "version": "0.149.0",
3
+ "version": "0.151.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,
@@ -10,9 +10,18 @@
10
10
  ],
11
11
  "types": "./dist/spec.d.ts",
12
12
  "exports": {
13
- ".": "./dist/index.js",
14
- "./kitModule": "./dist/kitModule.js",
15
- "./browser": "./dist/browser.js",
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "default": "./dist/index.js"
16
+ },
17
+ "./kitModule": {
18
+ "types": "./dist/kitModule.d.ts",
19
+ "default": "./dist/kitModule.js"
20
+ },
21
+ "./browser": {
22
+ "types": "./dist/browser.d.ts",
23
+ "default": "./dist/browser.js"
24
+ },
16
25
  "./meta": {
17
26
  "types": "./dist/meta.d.ts",
18
27
  "default": "./dist/meta.js"
@@ -36,10 +45,15 @@
36
45
  },
37
46
  "devDependencies": {
38
47
  "@babel/core": "7.29.7",
48
+ "@babel/types": "7.29.8",
49
+ "@types/babel__core": "7.20.5",
50
+ "@types/node": "25.6.0",
51
+ "@webority/code-standards": "0.151.0",
39
52
  "react": "^19.3.1"
40
53
  },
41
54
  "scripts": {
42
- "build": "vite build --config vite.cli.config.js",
55
+ "build": "tsc -p tsconfig.json && vite build --config vite.cli.config.ts && tsc -p tsconfig.build.json",
56
+ "typecheck": "tsc -p tsconfig.json",
43
57
  "test": "node --test"
44
58
  }
45
59
  }