@pixerate/editor 0.21.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +100 -13
- package/THIRD_PARTY_NOTICES.md +88 -0
- package/dist/agent/index.cjs +86 -111
- package/dist/agent/index.cjs.map +1 -1
- package/dist/agent/index.d.cts +69 -211
- package/dist/agent/index.d.ts +69 -211
- package/dist/agent/index.js +77 -102
- package/dist/agent/index.js.map +1 -1
- package/dist/arrangeShortcuts-B8O3f8-P.d.cts +184 -0
- package/dist/arrangeShortcuts-sLlD2rSX.d.ts +184 -0
- package/dist/canvas/index.cjs +2112 -60
- package/dist/canvas/index.cjs.map +1 -1
- package/dist/canvas/index.d.cts +712 -181
- package/dist/canvas/index.d.ts +712 -181
- package/dist/canvas/index.js +2105 -53
- package/dist/canvas/index.js.map +1 -1
- package/dist/chunk-26BVFKHU.cjs +453 -0
- package/dist/chunk-26BVFKHU.cjs.map +1 -0
- package/dist/chunk-2H7ZHPEJ.js +762 -0
- package/dist/chunk-2H7ZHPEJ.js.map +1 -0
- package/dist/chunk-7DWMJCAT.js +453 -0
- package/dist/chunk-7DWMJCAT.js.map +1 -0
- package/dist/{chunk-TVRC4KVT.cjs → chunk-AA4ZEVCC.cjs} +845 -90
- package/dist/chunk-AA4ZEVCC.cjs.map +1 -0
- package/dist/chunk-ARRTP33I.js +101 -0
- package/dist/chunk-ARRTP33I.js.map +1 -0
- package/dist/{chunk-LA7PEGU3.cjs → chunk-CL37JGFW.cjs} +4 -4
- package/dist/{chunk-LA7PEGU3.cjs.map → chunk-CL37JGFW.cjs.map} +1 -1
- package/dist/chunk-CPOKFNBG.cjs +101 -0
- package/dist/chunk-CPOKFNBG.cjs.map +1 -0
- package/dist/chunk-G2I4QJOT.cjs +762 -0
- package/dist/chunk-G2I4QJOT.cjs.map +1 -0
- package/dist/{chunk-4QPLEUL2.cjs → chunk-GVSMRPHB.cjs} +1046 -54
- package/dist/chunk-GVSMRPHB.cjs.map +1 -0
- package/dist/{chunk-KYRZDWM4.js → chunk-JJDLPEWL.js} +2 -2
- package/dist/{chunk-GVW4P7BG.js → chunk-K3R5NG2D.js} +448 -54
- package/dist/chunk-K3R5NG2D.js.map +1 -0
- package/dist/{chunk-3TYMNULT.js → chunk-MJZBNWG7.js} +807 -52
- package/dist/chunk-MJZBNWG7.js.map +1 -0
- package/dist/{chunk-A7DKIA72.js → chunk-QBJ22YZR.js} +1059 -93
- package/dist/chunk-QBJ22YZR.js.map +1 -0
- package/dist/{chunk-CYFJCKC4.js → chunk-QGHGJ56O.js} +997 -5
- package/dist/chunk-QGHGJ56O.js.map +1 -0
- package/dist/{chunk-JYRIOFEN.cjs → chunk-RIKBJLS2.cjs} +1064 -98
- package/dist/chunk-RIKBJLS2.cjs.map +1 -0
- package/dist/{chunk-U6NDQFOK.cjs → chunk-XDMXXC4Z.cjs} +569 -175
- package/dist/chunk-XDMXXC4Z.cjs.map +1 -0
- package/dist/commands/index.cjs +860 -0
- package/dist/commands/index.cjs.map +1 -0
- package/dist/commands/index.d.cts +592 -0
- package/dist/commands/index.d.ts +592 -0
- package/dist/commands/index.js +860 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/{controller-OUdxPY-X.d.ts → controller-pePCJLT1.d.cts} +216 -11
- package/dist/{controller-OUdxPY-X.d.cts → controller-pePCJLT1.d.ts} +216 -11
- package/dist/extensions/index.cjs +14 -4
- package/dist/extensions/index.cjs.map +1 -1
- package/dist/extensions/index.d.cts +3 -3
- package/dist/extensions/index.d.ts +3 -3
- package/dist/extensions/index.js +13 -3
- package/dist/history/index.cjs +12 -2
- package/dist/history/index.cjs.map +1 -1
- package/dist/history/index.d.cts +211 -7
- package/dist/history/index.d.ts +211 -7
- package/dist/history/index.js +13 -3
- package/dist/image-editor/index.cjs +418 -13
- package/dist/image-editor/index.cjs.map +1 -1
- package/dist/image-editor/index.d.cts +154 -3
- package/dist/image-editor/index.d.ts +154 -3
- package/dist/image-editor/index.js +417 -12
- package/dist/image-editor/index.js.map +1 -1
- package/dist/{index-k3mFbPx_.d.cts → index-CCr_z9kF.d.cts} +3 -3
- package/dist/{index-Ng1pG7JE.d.ts → index-Ck6ajwXh.d.ts} +3 -3
- package/dist/index.cjs +275 -83
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +296 -47
- package/dist/index.d.ts +296 -47
- package/dist/index.js +266 -74
- package/dist/index.js.map +1 -1
- package/dist/registry-D5-R90p0.d.cts +209 -0
- package/dist/registry-D5-R90p0.d.ts +209 -0
- package/dist/{registry-iAHbqkYt.d.cts → registry-GJI4gToU.d.cts} +15 -4
- package/dist/{registry-iAHbqkYt.d.ts → registry-GJI4gToU.d.ts} +15 -4
- package/dist/serializers/index.cjs +3 -3
- package/dist/serializers/index.d.cts +1 -1
- package/dist/serializers/index.d.ts +1 -1
- package/dist/serializers/index.js +2 -2
- package/dist/spreadsheet/index.cjs +23 -3
- package/dist/spreadsheet/index.cjs.map +1 -1
- package/dist/spreadsheet/index.d.cts +97 -10
- package/dist/spreadsheet/index.d.ts +97 -10
- package/dist/spreadsheet/index.js +22 -2
- package/dist/{track-changes-G8JcWB8b.d.cts → track-changes-BSF58RK0.d.cts} +92 -9
- package/dist/{track-changes-G8JcWB8b.d.ts → track-changes-BSF58RK0.d.ts} +92 -9
- package/dist/{types-DMe0vFB1.d.cts → types-DX4Mh4SL.d.cts} +1 -1
- package/dist/{types-DMe0vFB1.d.ts → types-DX4Mh4SL.d.ts} +1 -1
- package/dist/types-GT5a5YAX.d.cts +86 -0
- package/dist/types-GT5a5YAX.d.ts +86 -0
- package/package.json +8 -2
- package/dist/chunk-2TWGLC5K.cjs +0 -262
- package/dist/chunk-2TWGLC5K.cjs.map +0 -1
- package/dist/chunk-3TYMNULT.js.map +0 -1
- package/dist/chunk-4QPLEUL2.cjs.map +0 -1
- package/dist/chunk-A7DKIA72.js.map +0 -1
- package/dist/chunk-CYFJCKC4.js.map +0 -1
- package/dist/chunk-GVW4P7BG.js.map +0 -1
- package/dist/chunk-JYRIOFEN.cjs.map +0 -1
- package/dist/chunk-KAADNAPF.js +0 -262
- package/dist/chunk-KAADNAPF.js.map +0 -1
- package/dist/chunk-TVRC4KVT.cjs.map +0 -1
- package/dist/chunk-U6NDQFOK.cjs.map +0 -1
- package/dist/types-BZgcDsC5.d.cts +0 -42
- package/dist/types-BZgcDsC5.d.ts +0 -42
- /package/dist/{chunk-KYRZDWM4.js.map → chunk-JJDLPEWL.js.map} +0 -0
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }// src/agent/schema.ts
|
|
2
|
+
function typeOf(value) {
|
|
3
|
+
if (value === null) return "null";
|
|
4
|
+
if (Array.isArray(value)) return "array";
|
|
5
|
+
if (typeof value === "number") return Number.isInteger(value) ? "integer" : "number";
|
|
6
|
+
if (typeof value === "string" || typeof value === "boolean" || typeof value === "object") {
|
|
7
|
+
return typeof value;
|
|
8
|
+
}
|
|
9
|
+
return "undefined";
|
|
10
|
+
}
|
|
11
|
+
function matchesType(value, type) {
|
|
12
|
+
const actual = typeOf(value);
|
|
13
|
+
if (type === "number") return actual === "number" || actual === "integer";
|
|
14
|
+
return actual === type;
|
|
15
|
+
}
|
|
16
|
+
var isEqual = (a, b) => a === b || JSON.stringify(a) === JSON.stringify(b);
|
|
17
|
+
function validateJsonSchema(value, schema, path = "") {
|
|
18
|
+
if (!schema || typeof schema !== "object") return [];
|
|
19
|
+
const errors = [];
|
|
20
|
+
const at = path || "/";
|
|
21
|
+
if (schema.type !== void 0) {
|
|
22
|
+
const types = Array.isArray(schema.type) ? schema.type : [schema.type];
|
|
23
|
+
if (!types.some((t) => matchesType(value, t))) {
|
|
24
|
+
errors.push({ path: at, message: `Expected ${types.join(" | ")}, got ${typeOf(value)}.` });
|
|
25
|
+
return errors;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (schema.const !== void 0 && !isEqual(value, schema.const)) {
|
|
29
|
+
errors.push({ path: at, message: `Expected ${JSON.stringify(schema.const)}.` });
|
|
30
|
+
}
|
|
31
|
+
if (schema.enum && !schema.enum.some((option) => isEqual(value, option))) {
|
|
32
|
+
errors.push({
|
|
33
|
+
path: at,
|
|
34
|
+
message: `Expected one of ${schema.enum.map((o) => JSON.stringify(o)).join(", ")}, got ${JSON.stringify(value)}.`
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
if (typeof value === "string") {
|
|
38
|
+
if (schema.minLength !== void 0 && value.length < schema.minLength) {
|
|
39
|
+
errors.push({ path: at, message: `Must be at least ${schema.minLength} characters.` });
|
|
40
|
+
}
|
|
41
|
+
if (schema.maxLength !== void 0 && value.length > schema.maxLength) {
|
|
42
|
+
errors.push({ path: at, message: `Must be at most ${schema.maxLength} characters.` });
|
|
43
|
+
}
|
|
44
|
+
if (schema.pattern !== void 0) {
|
|
45
|
+
let regex = null;
|
|
46
|
+
try {
|
|
47
|
+
regex = new RegExp(schema.pattern, "u");
|
|
48
|
+
} catch (e) {
|
|
49
|
+
}
|
|
50
|
+
if (regex && !regex.test(value)) {
|
|
51
|
+
errors.push({ path: at, message: `Must match pattern ${schema.pattern}.` });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (typeof value === "number") {
|
|
56
|
+
if (schema.minimum !== void 0 && value < schema.minimum) {
|
|
57
|
+
errors.push({ path: at, message: `Must be >= ${schema.minimum}.` });
|
|
58
|
+
}
|
|
59
|
+
if (schema.maximum !== void 0 && value > schema.maximum) {
|
|
60
|
+
errors.push({ path: at, message: `Must be <= ${schema.maximum}.` });
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (Array.isArray(value)) {
|
|
64
|
+
if (schema.minItems !== void 0 && value.length < schema.minItems) {
|
|
65
|
+
errors.push({ path: at, message: `Must have at least ${schema.minItems} items.` });
|
|
66
|
+
}
|
|
67
|
+
if (schema.maxItems !== void 0 && value.length > schema.maxItems) {
|
|
68
|
+
errors.push({ path: at, message: `Must have at most ${schema.maxItems} items.` });
|
|
69
|
+
}
|
|
70
|
+
if (schema.items) {
|
|
71
|
+
value.forEach((item, index) => {
|
|
72
|
+
errors.push(...validateJsonSchema(item, schema.items, `${path}/${index}`));
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (typeOf(value) === "object") {
|
|
77
|
+
const obj = value;
|
|
78
|
+
for (const key of _nullishCoalesce(schema.required, () => ( []))) {
|
|
79
|
+
if (obj[key] === void 0) {
|
|
80
|
+
errors.push({ path: `${path}/${key}`, message: `Missing required property "${key}".` });
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
const properties = _nullishCoalesce(schema.properties, () => ( {}));
|
|
84
|
+
for (const [key, child] of Object.entries(obj)) {
|
|
85
|
+
if (child === void 0) continue;
|
|
86
|
+
if (key in properties) {
|
|
87
|
+
errors.push(...validateJsonSchema(child, properties[key], `${path}/${key}`));
|
|
88
|
+
} else if (schema.additionalProperties === false) {
|
|
89
|
+
errors.push({ path: `${path}/${key}`, message: `Unknown property "${key}".` });
|
|
90
|
+
} else if (typeof schema.additionalProperties === "object") {
|
|
91
|
+
errors.push(...validateJsonSchema(child, schema.additionalProperties, `${path}/${key}`));
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return errors;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
exports.validateJsonSchema = validateJsonSchema;
|
|
101
|
+
//# sourceMappingURL=chunk-CPOKFNBG.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/editor/editor/packages/core/dist/chunk-CPOKFNBG.cjs","../src/agent/schema.ts"],"names":[],"mappings":"AAAA;ACiCA,SAAS,MAAA,CAAO,KAAA,EAA8C;AAC7D,EAAA,GAAA,CAAI,MAAA,IAAU,IA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O,IAAA,CAAK,GAAG,kBAAA,CAAmB,IAAA,EAAM,MAAA,CAAO,KAAA,EAAO,CAAA,EAAA;AACtD,MAAA;AACF,IAAA;AACD,EAAA;AAEgC,EAAA;AACnB,IAAA;AAC6B,IAAA;AACZ,MAAA;AACoB,QAAA;AAChD,MAAA;AACD,IAAA;AACyC,IAAA;AACO,IAAA;AACtB,MAAA;AACF,MAAA;AACiC,QAAA;AACN,MAAA;AACF,QAAA;AACE,MAAA;AACD,QAAA;AACjD,MAAA;AACD,IAAA;AACD,EAAA;AAEO,EAAA;AACR;AD/C+D;AACA;AACA;AACA","file":"/home/runner/work/editor/editor/packages/core/dist/chunk-CPOKFNBG.cjs","sourcesContent":[null,"/**\n * JSON-Schema-lite: the subset of JSON Schema used by MCP tool `inputSchema`s,\n * plus a small validator for tool-call arguments. Unknown keywords are ignored.\n */\nexport type JsonSchemaType = 'string' | 'number' | 'integer' | 'boolean' | 'object' | 'array' | 'null';\n\nexport interface JsonSchema {\n\ttype?: JsonSchemaType | readonly JsonSchemaType[];\n\tdescription?: string;\n\ttitle?: string;\n\tenum?: readonly unknown[];\n\tconst?: unknown;\n\tdefault?: unknown;\n\tproperties?: { readonly [key: string]: JsonSchema };\n\trequired?: readonly string[];\n\tadditionalProperties?: boolean | JsonSchema;\n\titems?: JsonSchema;\n\tminItems?: number;\n\tmaxItems?: number;\n\tminimum?: number;\n\tmaximum?: number;\n\tminLength?: number;\n\tmaxLength?: number;\n\tpattern?: string;\n\t[keyword: string]: unknown;\n}\n\nexport interface SchemaValidationError {\n\t/** JSON-pointer-like path to the offending value, e.g. `/node/id` (`\"\"` is the root). */\n\tpath: string;\n\tmessage: string;\n}\n\nfunction typeOf(value: unknown): JsonSchemaType | 'undefined' {\n\tif (value === null) return 'null';\n\tif (Array.isArray(value)) return 'array';\n\tif (typeof value === 'number') return Number.isInteger(value) ? 'integer' : 'number';\n\tif (typeof value === 'string' || typeof value === 'boolean' || typeof value === 'object') {\n\t\treturn typeof value as JsonSchemaType;\n\t}\n\treturn 'undefined';\n}\n\nfunction matchesType(value: unknown, type: JsonSchemaType): boolean {\n\tconst actual = typeOf(value);\n\tif (type === 'number') return actual === 'number' || actual === 'integer';\n\treturn actual === type;\n}\n\nconst isEqual = (a: unknown, b: unknown) => a === b || JSON.stringify(a) === JSON.stringify(b);\n\n/**\n * Validates `value` against `schema` and returns every error found (an empty\n * array means valid). Supports `type` (incl. arrays of types), `enum`, `const`,\n * `properties`, `required`, `additionalProperties`, `items`, `minItems`,\n * `maxItems`, `minimum`, `maximum`, `minLength`, `maxLength` and `pattern`.\n */\nexport function validateJsonSchema(value: unknown, schema: JsonSchema | undefined, path = ''): SchemaValidationError[] {\n\tif (!schema || typeof schema !== 'object') return [];\n\tconst errors: SchemaValidationError[] = [];\n\tconst at = path || '/';\n\n\tif (schema.type !== undefined) {\n\t\tconst types = (Array.isArray(schema.type) ? schema.type : [schema.type]) as JsonSchemaType[];\n\t\tif (!types.some((t) => matchesType(value, t))) {\n\t\t\terrors.push({ path: at, message: `Expected ${types.join(' | ')}, got ${typeOf(value)}.` });\n\t\t\treturn errors;\n\t\t}\n\t}\n\tif (schema.const !== undefined && !isEqual(value, schema.const)) {\n\t\terrors.push({ path: at, message: `Expected ${JSON.stringify(schema.const)}.` });\n\t}\n\tif (schema.enum && !schema.enum.some((option) => isEqual(value, option))) {\n\t\terrors.push({\n\t\t\tpath: at,\n\t\t\tmessage: `Expected one of ${schema.enum.map((o) => JSON.stringify(o)).join(', ')}, got ${JSON.stringify(value)}.`\n\t\t});\n\t}\n\n\tif (typeof value === 'string') {\n\t\tif (schema.minLength !== undefined && value.length < schema.minLength) {\n\t\t\terrors.push({ path: at, message: `Must be at least ${schema.minLength} characters.` });\n\t\t}\n\t\tif (schema.maxLength !== undefined && value.length > schema.maxLength) {\n\t\t\terrors.push({ path: at, message: `Must be at most ${schema.maxLength} characters.` });\n\t\t}\n\t\tif (schema.pattern !== undefined) {\n\t\t\tlet regex: RegExp | null = null;\n\t\t\ttry {\n\t\t\t\tregex = new RegExp(schema.pattern, 'u');\n\t\t\t} catch {\n\t\t\t\t// An invalid pattern in the schema is not the caller's fault.\n\t\t\t}\n\t\t\tif (regex && !regex.test(value)) {\n\t\t\t\terrors.push({ path: at, message: `Must match pattern ${schema.pattern}.` });\n\t\t\t}\n\t\t}\n\t}\n\n\tif (typeof value === 'number') {\n\t\tif (schema.minimum !== undefined && value < schema.minimum) {\n\t\t\terrors.push({ path: at, message: `Must be >= ${schema.minimum}.` });\n\t\t}\n\t\tif (schema.maximum !== undefined && value > schema.maximum) {\n\t\t\terrors.push({ path: at, message: `Must be <= ${schema.maximum}.` });\n\t\t}\n\t}\n\n\tif (Array.isArray(value)) {\n\t\tif (schema.minItems !== undefined && value.length < schema.minItems) {\n\t\t\terrors.push({ path: at, message: `Must have at least ${schema.minItems} items.` });\n\t\t}\n\t\tif (schema.maxItems !== undefined && value.length > schema.maxItems) {\n\t\t\terrors.push({ path: at, message: `Must have at most ${schema.maxItems} items.` });\n\t\t}\n\t\tif (schema.items) {\n\t\t\tvalue.forEach((item, index) => {\n\t\t\t\terrors.push(...validateJsonSchema(item, schema.items, `${path}/${index}`));\n\t\t\t});\n\t\t}\n\t}\n\n\tif (typeOf(value) === 'object') {\n\t\tconst obj = value as Record<string, unknown>;\n\t\tfor (const key of schema.required ?? []) {\n\t\t\tif (obj[key] === undefined) {\n\t\t\t\terrors.push({ path: `${path}/${key}`, message: `Missing required property \"${key}\".` });\n\t\t\t}\n\t\t}\n\t\tconst properties = schema.properties ?? {};\n\t\tfor (const [key, child] of Object.entries(obj)) {\n\t\t\tif (child === undefined) continue;\n\t\t\tif (key in properties) {\n\t\t\t\terrors.push(...validateJsonSchema(child, properties[key], `${path}/${key}`));\n\t\t\t} else if (schema.additionalProperties === false) {\n\t\t\t\terrors.push({ path: `${path}/${key}`, message: `Unknown property \"${key}\".` });\n\t\t\t} else if (typeof schema.additionalProperties === 'object') {\n\t\t\t\terrors.push(...validateJsonSchema(child, schema.additionalProperties, `${path}/${key}`));\n\t\t\t}\n\t\t}\n\t}\n\n\treturn errors;\n}\n"]}
|