@gunkin/uiify 0.0.26-alpha → 0.0.27-alpha
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/README.md +59 -0
- package/agents/components.md +2 -0
- package/agents/index.md +1 -0
- package/dist/ai/UiDocument.d.ts +16 -0
- package/dist/ai/UiDocument.d.ts.map +1 -0
- package/dist/ai/UiDocument.js +33 -0
- package/dist/ai/UiDocument.js.map +1 -0
- package/dist/ai/catalog.generated.d.ts +2766 -0
- package/dist/ai/catalog.generated.d.ts.map +1 -0
- package/dist/ai/catalog.generated.js +214 -0
- package/dist/ai/catalog.generated.js.map +1 -0
- package/dist/ai/index.d.ts +9 -0
- package/dist/ai/index.d.ts.map +1 -0
- package/dist/ai/index.js +13 -0
- package/dist/ai/index.js.map +1 -0
- package/dist/ai/issues.d.ts +10 -0
- package/dist/ai/issues.d.ts.map +1 -0
- package/dist/ai/issues.js +178 -0
- package/dist/ai/issues.js.map +1 -0
- package/dist/ai/layout.d.ts +26 -0
- package/dist/ai/layout.d.ts.map +1 -0
- package/dist/ai/layout.js +46 -0
- package/dist/ai/layout.js.map +1 -0
- package/dist/ai/limits.d.ts +16 -0
- package/dist/ai/limits.d.ts.map +1 -0
- package/dist/ai/limits.js +99 -0
- package/dist/ai/limits.js.map +1 -0
- package/dist/ai/load.d.ts +16 -0
- package/dist/ai/load.d.ts.map +1 -0
- package/dist/ai/load.js +69 -0
- package/dist/ai/load.js.map +1 -0
- package/dist/ai/loaders.generated.d.ts +5 -0
- package/dist/ai/loaders.generated.d.ts.map +1 -0
- package/dist/ai/loaders.generated.js +122 -0
- package/dist/ai/loaders.generated.js.map +1 -0
- package/dist/ai/rules.d.ts +11 -0
- package/dist/ai/rules.d.ts.map +1 -0
- package/dist/ai/rules.js +126 -0
- package/dist/ai/rules.js.map +1 -0
- package/dist/ai/schema.generated.d.ts +8 -0
- package/dist/ai/schema.generated.d.ts.map +1 -0
- package/dist/ai/schema.generated.js +3316 -0
- package/dist/ai/schema.generated.js.map +1 -0
- package/dist/ai/types.d.ts +33 -0
- package/dist/ai/types.d.ts.map +1 -0
- package/dist/ai/types.js +14 -0
- package/dist/ai/types.js.map +1 -0
- package/dist/ai/validate.d.ts +15 -0
- package/dist/ai/validate.d.ts.map +1 -0
- package/dist/ai/validate.js +32 -0
- package/dist/ai/validate.js.map +1 -0
- package/dist/ai/validator.generated.d.ts +13 -0
- package/dist/ai/validator.generated.d.ts.map +1 -0
- package/dist/ai/validator.generated.js +49133 -0
- package/dist/ai/validator.generated.js.map +1 -0
- package/dist/components/virtual-scroll/VirtualScroll.d.ts.map +1 -1
- package/dist/components/virtual-scroll/VirtualScroll.js +1 -1
- package/dist/components/virtual-scroll/VirtualScroll.js.map +1 -1
- package/dist/styles/index.css +1 -1
- package/package.json +10 -1
- package/skills/uiify/SKILL.md +14 -10
- package/skills/uiify/references/guides/verification.md +13 -2
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ComponentType } from "react";
|
|
2
|
+
import type { UiNode, UiType } from "./catalog.generated.js";
|
|
3
|
+
/** A stored UI document: a version and one root node. */
|
|
4
|
+
export interface UiDocumentData {
|
|
5
|
+
readonly version: 1;
|
|
6
|
+
readonly root: UiNode;
|
|
7
|
+
}
|
|
8
|
+
/** One problem found in a document, written so a person or a model can repair it. */
|
|
9
|
+
export interface UiValidationIssue {
|
|
10
|
+
/** JSON Pointer into the validated value, e.g. `/root/children/0/props/variant`. */
|
|
11
|
+
readonly path: string;
|
|
12
|
+
/** Readable location, e.g. `form › Field.Root › Button.props.variant`. */
|
|
13
|
+
readonly breadcrumb: string;
|
|
14
|
+
readonly message: string;
|
|
15
|
+
/** The values that would have been accepted, when the problem is a closed set. */
|
|
16
|
+
readonly allowed?: readonly unknown[];
|
|
17
|
+
}
|
|
18
|
+
/** Thrown when a document is invalid; carries the same issues `validateDocument` returns. */
|
|
19
|
+
export declare class UiDocumentError extends Error {
|
|
20
|
+
readonly issues: readonly UiValidationIssue[];
|
|
21
|
+
constructor(issues: readonly UiValidationIssue[]);
|
|
22
|
+
}
|
|
23
|
+
/** A validated document with the component of every part type it uses, ready to render. */
|
|
24
|
+
export interface LoadedDocument {
|
|
25
|
+
readonly root: UiNode;
|
|
26
|
+
/** Component and layout parts by type; native types render as their own tag. */
|
|
27
|
+
readonly components: ReadonlyMap<UiType, ComponentType<any>>;
|
|
28
|
+
}
|
|
29
|
+
export interface UiDocumentProps {
|
|
30
|
+
/** Untrusted document data: `{ version: 1, root }` or a bare node. */
|
|
31
|
+
readonly node: unknown;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/ai/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAE7D,yDAAyD;AACzD,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,qFAAqF;AACrF,MAAM,WAAW,iBAAiB;IAChC,oFAAoF;IACpF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,0EAA0E;IAC1E,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,kFAAkF;IAClF,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,OAAO,EAAE,CAAC;CACvC;AAED,6FAA6F;AAC7F,qBAAa,eAAgB,SAAQ,KAAK;IACxC,QAAQ,CAAC,MAAM,EAAE,SAAS,iBAAiB,EAAE,CAAC;gBAElC,MAAM,EAAE,SAAS,iBAAiB,EAAE;CAOjD;AAED,2FAA2F;AAC3F,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,gFAAgF;IAEhF,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC;CAC9D;AAED,MAAM,WAAW,eAAe;IAC9B,sEAAsE;IACtE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;CACxB"}
|
package/dist/ai/types.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
class UiDocumentError extends Error {
|
|
2
|
+
issues;
|
|
3
|
+
constructor(issues) {
|
|
4
|
+
const shown = issues.slice(0, 10).map((issue) => `- ${issue.breadcrumb}: ${issue.message}`);
|
|
5
|
+
const more = issues.length > shown.length ? [`- and ${issues.length - shown.length} more`] : [];
|
|
6
|
+
super(["Invalid UI document:", ...shown, ...more].join("\n"));
|
|
7
|
+
this.name = "UiDocumentError";
|
|
8
|
+
this.issues = issues;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
UiDocumentError
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/ai/types.ts"],"sourcesContent":["import type { ComponentType } from \"react\";\nimport type { UiNode, UiType } from \"./catalog.generated.js\";\n\n/** A stored UI document: a version and one root node. */\nexport interface UiDocumentData {\n readonly version: 1;\n readonly root: UiNode;\n}\n\n/** One problem found in a document, written so a person or a model can repair it. */\nexport interface UiValidationIssue {\n /** JSON Pointer into the validated value, e.g. `/root/children/0/props/variant`. */\n readonly path: string;\n /** Readable location, e.g. `form › Field.Root › Button.props.variant`. */\n readonly breadcrumb: string;\n readonly message: string;\n /** The values that would have been accepted, when the problem is a closed set. */\n readonly allowed?: readonly unknown[];\n}\n\n/** Thrown when a document is invalid; carries the same issues `validateDocument` returns. */\nexport class UiDocumentError extends Error {\n readonly issues: readonly UiValidationIssue[];\n\n constructor(issues: readonly UiValidationIssue[]) {\n const shown = issues.slice(0, 10).map((issue) => `- ${issue.breadcrumb}: ${issue.message}`);\n const more = issues.length > shown.length ? [`- and ${issues.length - shown.length} more`] : [];\n super([\"Invalid UI document:\", ...shown, ...more].join(\"\\n\"));\n this.name = \"UiDocumentError\";\n this.issues = issues;\n }\n}\n\n/** A validated document with the component of every part type it uses, ready to render. */\nexport interface LoadedDocument {\n readonly root: UiNode;\n /** Component and layout parts by type; native types render as their own tag. */\n // oxlint-disable-next-line typescript/no-explicit-any -- each part takes its own props\n readonly components: ReadonlyMap<UiType, ComponentType<any>>;\n}\n\nexport interface UiDocumentProps {\n /** Untrusted document data: `{ version: 1, root }` or a bare node. */\n readonly node: unknown;\n}\n"],"mappings":"AAqBO,MAAM,wBAAwB,MAAM;AAAA,EAChC;AAAA,EAET,YAAY,QAAsC;AAChD,UAAM,QAAQ,OAAO,MAAM,GAAG,EAAE,EAAE,IAAI,CAAC,UAAU,KAAK,MAAM,UAAU,KAAK,MAAM,OAAO,EAAE;AAC1F,UAAM,OAAO,OAAO,SAAS,MAAM,SAAS,CAAC,SAAS,OAAO,SAAS,MAAM,MAAM,OAAO,IAAI,CAAC;AAC9F,UAAM,CAAC,wBAAwB,GAAG,OAAO,GAAG,IAAI,EAAE,KAAK,IAAI,CAAC;AAC5D,SAAK,OAAO;AACZ,SAAK,SAAS;AAAA,EAChB;AACF;","names":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { UiDocumentData, UiValidationIssue } from "./types.js";
|
|
2
|
+
export type UiValidationResult = {
|
|
3
|
+
readonly ok: true;
|
|
4
|
+
readonly document: UiDocumentData;
|
|
5
|
+
} | {
|
|
6
|
+
readonly ok: false;
|
|
7
|
+
readonly issues: readonly UiValidationIssue[];
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Validates untrusted data as a UI document: `{ version: 1, root }`, or a bare node, which is
|
|
11
|
+
* wrapped. Stages run in order and stop at the first that fails: limits, version, schema, rules.
|
|
12
|
+
* Nothing in the value is evaluated or modified.
|
|
13
|
+
*/
|
|
14
|
+
export declare function validateDocument(value: unknown): UiValidationResult;
|
|
15
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/ai/validate.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAGpE,MAAM,MAAM,kBAAkB,GAC1B;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAA;CAAE,GACxD;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,iBAAiB,EAAE,CAAA;CAAE,CAAC;AAM1E;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,kBAAkB,CA+BnE"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { toIssues } from "./issues.js";
|
|
2
|
+
import { checkLimits } from "./limits.js";
|
|
3
|
+
import { checkRules } from "./rules.js";
|
|
4
|
+
import { validateSchema } from "./validator.generated.js";
|
|
5
|
+
function fail(issues) {
|
|
6
|
+
return { ok: false, issues };
|
|
7
|
+
}
|
|
8
|
+
function validateDocument(value) {
|
|
9
|
+
const limitIssues = checkLimits(value);
|
|
10
|
+
if (limitIssues.length > 0) return fail(limitIssues);
|
|
11
|
+
const isObject = typeof value === "object" && value !== null && !Array.isArray(value);
|
|
12
|
+
const bare = isObject && Object.hasOwn(value, "type");
|
|
13
|
+
if (isObject && !bare && Object.hasOwn(value, "version") && value.version !== 1) {
|
|
14
|
+
const version = value.version;
|
|
15
|
+
return fail([
|
|
16
|
+
{
|
|
17
|
+
path: "/version",
|
|
18
|
+
breadcrumb: "version",
|
|
19
|
+
message: `unsupported version ${typeof version === "string" ? JSON.stringify(version) : String(JSON.stringify(version))}; this validator reads version 1`,
|
|
20
|
+
allowed: [1]
|
|
21
|
+
}
|
|
22
|
+
]);
|
|
23
|
+
}
|
|
24
|
+
if (!validateSchema(value)) return fail(toIssues(validateSchema.errors, value));
|
|
25
|
+
const document = bare ? { version: 1, root: value } : value;
|
|
26
|
+
const ruleIssues = checkRules(document.root, bare ? "" : "/root");
|
|
27
|
+
return ruleIssues.length > 0 ? fail(ruleIssues) : { ok: true, document };
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
validateDocument
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=validate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/ai/validate.ts"],"sourcesContent":["import type { UiNode } from \"./catalog.generated.js\";\nimport { toIssues } from \"./issues.js\";\nimport { checkLimits } from \"./limits.js\";\nimport { checkRules } from \"./rules.js\";\nimport type { UiDocumentData, UiValidationIssue } from \"./types.js\";\nimport { validateSchema } from \"./validator.generated.js\";\n\nexport type UiValidationResult =\n | { readonly ok: true; readonly document: UiDocumentData }\n | { readonly ok: false; readonly issues: readonly UiValidationIssue[] };\n\nfunction fail(issues: readonly UiValidationIssue[]): UiValidationResult {\n return { ok: false, issues };\n}\n\n/**\n * Validates untrusted data as a UI document: `{ version: 1, root }`, or a bare node, which is\n * wrapped. Stages run in order and stop at the first that fails: limits, version, schema, rules.\n * Nothing in the value is evaluated or modified.\n */\nexport function validateDocument(value: unknown): UiValidationResult {\n const limitIssues = checkLimits(value);\n if (limitIssues.length > 0) return fail(limitIssues);\n\n const isObject = typeof value === \"object\" && value !== null && !Array.isArray(value);\n const bare = isObject && Object.hasOwn(value, \"type\");\n\n if (\n isObject &&\n !bare &&\n Object.hasOwn(value, \"version\") &&\n (value as { version: unknown }).version !== 1\n ) {\n const version = (value as { version: unknown }).version;\n return fail([\n {\n path: \"/version\",\n breadcrumb: \"version\",\n message: `unsupported version ${typeof version === \"string\" ? JSON.stringify(version) : String(JSON.stringify(version))}; this validator reads version 1`,\n allowed: [1],\n },\n ]);\n }\n\n if (!validateSchema(value)) return fail(toIssues(validateSchema.errors, value));\n\n const document: UiDocumentData = bare\n ? { version: 1, root: value as UiNode }\n : (value as UiDocumentData);\n const ruleIssues = checkRules(document.root, bare ? \"\" : \"/root\");\n return ruleIssues.length > 0 ? fail(ruleIssues) : { ok: true, document };\n}\n"],"mappings":"AACA,SAAS,gBAAgB;AACzB,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB;AAE3B,SAAS,sBAAsB;AAM/B,SAAS,KAAK,QAA0D;AACtE,SAAO,EAAE,IAAI,OAAO,OAAO;AAC7B;AAOO,SAAS,iBAAiB,OAAoC;AACnE,QAAM,cAAc,YAAY,KAAK;AACrC,MAAI,YAAY,SAAS,EAAG,QAAO,KAAK,WAAW;AAEnD,QAAM,WAAW,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AACpF,QAAM,OAAO,YAAY,OAAO,OAAO,OAAO,MAAM;AAEpD,MACE,YACA,CAAC,QACD,OAAO,OAAO,OAAO,SAAS,KAC7B,MAA+B,YAAY,GAC5C;AACA,UAAM,UAAW,MAA+B;AAChD,WAAO,KAAK;AAAA,MACV;AAAA,QACE,MAAM;AAAA,QACN,YAAY;AAAA,QACZ,SAAS,uBAAuB,OAAO,YAAY,WAAW,KAAK,UAAU,OAAO,IAAI,OAAO,KAAK,UAAU,OAAO,CAAC,CAAC;AAAA,QACvH,SAAS,CAAC,CAAC;AAAA,MACb;AAAA,IACF,CAAC;AAAA,EACH;AAEA,MAAI,CAAC,eAAe,KAAK,EAAG,QAAO,KAAK,SAAS,eAAe,QAAQ,KAAK,CAAC;AAE9E,QAAM,WAA2B,OAC7B,EAAE,SAAS,GAAG,MAAM,MAAgB,IACnC;AACL,QAAM,aAAa,WAAW,SAAS,MAAM,OAAO,KAAK,OAAO;AAChE,SAAO,WAAW,SAAS,IAAI,KAAK,UAAU,IAAI,EAAE,IAAI,MAAM,SAAS;AACzE;","names":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** One schema error, as Ajv reports it. */
|
|
2
|
+
export interface AjvError {
|
|
3
|
+
readonly keyword: string;
|
|
4
|
+
readonly instancePath: string;
|
|
5
|
+
readonly schemaPath: string;
|
|
6
|
+
readonly params: Readonly<Record<string, unknown>>;
|
|
7
|
+
readonly propertyName?: string;
|
|
8
|
+
readonly message?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const validateSchema: ((value: unknown) => boolean) & {
|
|
11
|
+
errors?: AjvError[] | null;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=validator.generated.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validator.generated.d.ts","sourceRoot":"","sources":["../../src/ai/validator.generated.ts"],"names":[],"mappings":"AAKA,2CAA2C;AAC3C,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACnD,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,eAAO,MAAM,cAAc,EAAE,CAAC,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC,GAAG;IAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAA;CAC7E,CAAC"}
|