@aippy/vite-plugins 0.4.0-dev.3 → 0.4.0-dev.5

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.
@@ -1,435 +0,0 @@
1
- import { promises as e } from "fs";
2
- import t from "path";
3
- import { parse as n } from "@babel/parser";
4
- import r from "@babel/traverse";
5
- import * as i from "@babel/types";
6
- //#region \0@oxc-project+runtime@0.144.0/helpers/esm/typeof.js
7
- function a(e) {
8
- "@babel/helpers - typeof";
9
- return a = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
10
- return typeof e;
11
- } : function(e) {
12
- return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
13
- }, a(e);
14
- }
15
- //#endregion
16
- //#region \0@oxc-project+runtime@0.144.0/helpers/esm/toPrimitive.js
17
- function o(e, t) {
18
- if (a(e) != "object" || !e) return e;
19
- var n = e[Symbol.toPrimitive];
20
- if (n !== void 0) {
21
- var r = n.call(e, t || "default");
22
- if (a(r) != "object") return r;
23
- throw TypeError("@@toPrimitive must return a primitive value.");
24
- }
25
- return (t === "string" ? String : Number)(e);
26
- }
27
- //#endregion
28
- //#region \0@oxc-project+runtime@0.144.0/helpers/esm/toPropertyKey.js
29
- function s(e) {
30
- var t = o(e, "string");
31
- return a(t) == "symbol" ? t : t + "";
32
- }
33
- //#endregion
34
- //#region \0@oxc-project+runtime@0.144.0/helpers/esm/defineProperty.js
35
- function c(e, t, n) {
36
- return (t = s(t)) in e ? Object.defineProperty(e, t, {
37
- value: n,
38
- enumerable: !0,
39
- configurable: !0,
40
- writable: !0
41
- }) : e[t] = n, e;
42
- }
43
- //#endregion
44
- //#region src/utils/file-scanner.ts
45
- async function l(n, r) {
46
- let i = [];
47
- try {
48
- let a = await e.readdir(n, { withFileTypes: !0 });
49
- for (let e of a) {
50
- let a = t.join(n, e.name);
51
- if (e.isDirectory()) {
52
- let e = await l(a, r);
53
- i.push(...e);
54
- } else if (e.isFile()) {
55
- let n = t.extname(e.name);
56
- r.includes(n) && i.push(a);
57
- }
58
- }
59
- } catch (e) {
60
- console.warn(`Warning: Failed to read directory ${n}:`, e);
61
- }
62
- return i;
63
- }
64
- function u(e, n) {
65
- let r = t.relative(t.dirname(e), n).replace(/\.(ts|tsx|js|jsx|json)$/, "");
66
- return r.startsWith(".") ? r : `./${r}`;
67
- }
68
- function d(e, n) {
69
- return `@/${t.relative(n, e).replace(/\.(ts|tsx|js|jsx|json)$/, "")}`;
70
- }
71
- var f = class {
72
- constructor() {
73
- c(this, "cache", /* @__PURE__ */ new Map());
74
- }
75
- async read(t) {
76
- if (this.cache.has(t)) return this.cache.get(t);
77
- let n = await e.readFile(t, "utf-8");
78
- return this.cache.set(t, n), n;
79
- }
80
- invalidate(e) {
81
- this.cache.delete(e);
82
- }
83
- clear() {
84
- this.cache.clear();
85
- }
86
- }, p = typeof r == "function" ? r : r.default;
87
- function m(e) {
88
- return i.isImportDefaultSpecifier(e) || i.isImportSpecifier(e) && (i.isIdentifier(e.imported, { name: "default" }) || i.isStringLiteral(e.imported, { value: "default" }));
89
- }
90
- function h(e) {
91
- return i.isTSAsExpression(e) || i.isTSTypeAssertion(e) || i.isTSNonNullExpression(e) || i.isTSSatisfiesExpression(e) || i.isParenthesizedExpression(e);
92
- }
93
- function g(e) {
94
- for (; h(e);) e = e.expression;
95
- return e;
96
- }
97
- function _(e, t) {
98
- let n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set();
99
- p(e, { ImportDeclaration: (e) => {
100
- if (!(!t.has(e.node.source.value) || e.node.importKind === "type")) for (let t of e.node.specifiers) {
101
- if (t.importKind === "type") continue;
102
- let a = e.scope.getBinding(t.local.name);
103
- i.isImportNamespaceSpecifier(t) && r.add(a), m(t) && n.add(a);
104
- }
105
- } });
106
- let a = (e, t, o = /* @__PURE__ */ new Set()) => {
107
- if (e = g(e), i.isIdentifier(e)) {
108
- let s = t.getBinding(e.name);
109
- if (n.has(s)) return "map";
110
- if (r.has(s)) return "namespace";
111
- if (s?.constant && s.kind === "const" && !o.has(s) && s.path.isVariableDeclarator() && s.path.node.init) {
112
- o.add(s);
113
- let t = s.path.node, n = a(t.init, s.path.scope, o);
114
- if (i.isIdentifier(t.id, { name: e.name })) return n;
115
- if (n === "namespace" && i.isObjectPattern(t.id) && t.id.properties.find((t) => i.isObjectProperty(t) && i.isIdentifier(t.value, { name: e.name }) && (t.computed ? i.isStringLiteral(g(t.key), { value: "default" }) : i.isIdentifier(t.key, { name: "default" }) || i.isStringLiteral(t.key, { value: "default" })))) return "map";
116
- }
117
- }
118
- if ((i.isMemberExpression(e) || i.isOptionalMemberExpression(e)) && (e.computed ? i.isStringLiteral(g(e.property), { value: "default" }) : i.isIdentifier(e.property, { name: "default" })) && a(e.object, t, o) === "namespace") return "map";
119
- };
120
- return (e) => {
121
- for (; h(e.parent) && e.key === "expression";) e = e.parentPath;
122
- let t = e.parent;
123
- if ((i.isMemberExpression(t) || i.isOptionalMemberExpression(t)) && e.key === "property" && t.computed) return a(t.object, e.scope) === "map";
124
- if (i.isObjectProperty(t) && e.key === "key" && i.isObjectPattern(e.parentPath.parent)) {
125
- let t = e.parentPath.parentPath;
126
- if (i.isVariableDeclarator(t.parent) && t.key === "id" && t.parent.init) return a(t.parent.init, e.scope) === "map";
127
- if (i.isAssignmentExpression(t.parent) && t.key === "left") return a(t.parent.right, e.scope) === "map";
128
- }
129
- return !1;
130
- };
131
- }
132
- function v(e, t, n) {
133
- let r = n.replace(/\.json$/, ".ts"), i = d(r, t), a = u(e, r);
134
- return /* @__PURE__ */ new Set([
135
- i,
136
- i + ".ts",
137
- a,
138
- a + ".ts",
139
- u(e, n) + ".json",
140
- "@/config/assets.json"
141
- ]);
142
- }
143
- function y(e, t, r, i) {
144
- let a = n(e, {
145
- sourceType: "module",
146
- plugins: [
147
- "typescript",
148
- "jsx",
149
- "decorators-legacy"
150
- ]
151
- }), o = _(a, v(t, r, i)), s = [];
152
- p(a, { StringLiteral: (e) => {
153
- o(e) && s.push([e.node.start, e.node.end]);
154
- } });
155
- for (let [t, n] of s.sort((e, t) => t[0] - e[0])) e = e.slice(0, t) + " ".repeat(n - t) + e.slice(n);
156
- return e;
157
- }
158
- //#endregion
159
- //#region src/asset-constants/manifest.ts
160
- var b = 1 << 20, x = [
161
- "image",
162
- "image-bg",
163
- "image-sprite",
164
- "image-icon",
165
- "image-tile",
166
- "sound",
167
- "music",
168
- "synth",
169
- "model",
170
- "animation",
171
- "video",
172
- "file"
173
- ];
174
- function S(e) {
175
- throw Error(`assets: ${e}`);
176
- }
177
- function C(e, t, n = []) {
178
- (!e || typeof e != "object" || Array.isArray(e)) && S("object required");
179
- let r = e;
180
- return Object.keys(r).some((e) => !t.includes(e)) && S("unknown field"), n.some((e) => !(e in r) || r[e] === null) && S("required field missing"), r;
181
- }
182
- function w(e, t, n = !1) {
183
- (typeof e != "string" || Buffer.byteLength(e) > t || /[\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\x9f\uFEFF]/.test(e) || n && !e.trim()) && S("invalid bounded text");
184
- }
185
- function T(e, t) {
186
- (typeof e != "string" || !t.includes(e)) && S("unsupported field value");
187
- }
188
- function E(e, t = !1) {
189
- (typeof e != "number" || !Number.isFinite(e) || e <= 0 || t && !Number.isInteger(e)) && S("positive dimension/duration required");
190
- }
191
- function D(e) {
192
- let t = C(e, [
193
- "stage",
194
- "code",
195
- "message",
196
- "retryable"
197
- ], [
198
- "stage",
199
- "code",
200
- "message",
201
- "retryable"
202
- ]);
203
- w(t.stage, 128, !0), w(t.code, 128, !0), w(t.message, 4096, !0), typeof t.retryable != "boolean" && S("retryable boolean required");
204
- }
205
- function O(e) {
206
- return typeof e.schemaVersion == "number";
207
- }
208
- function k(e) {
209
- let t = 0, n = () => {
210
- for (; /\s/.test(e[t] ?? "") && t < e.length;) t++;
211
- }, r = () => {
212
- let n = t++;
213
- for (; t < e.length;) {
214
- if (e[t] === "\\") {
215
- t += 2;
216
- continue;
217
- }
218
- if (e[t++] === "\"") return JSON.parse(e.slice(n, t));
219
- }
220
- return S("invalid string");
221
- }, i = () => {
222
- if (n(), e[t] === "{") {
223
- t++, n();
224
- let a = /* @__PURE__ */ new Set();
225
- for (; e[t] !== "}";) {
226
- let o = r();
227
- if (a.has(o) && S("duplicate object key"), a.add(o), n(), t++, i(), n(), e[t] !== ",") break;
228
- t++, n();
229
- }
230
- t++;
231
- } else if (e[t] === "[") {
232
- for (t++, n(); e[t] !== "]" && (i(), n(), e[t] === ",");) t++, n();
233
- t++;
234
- } else if (e[t] === "\"") r();
235
- else for (; t < e.length && !/[\s,\]}]/.test(e[t]);) t++;
236
- };
237
- i();
238
- }
239
- function A(e) {
240
- (!e || Buffer.byteLength(e) > b) && S("invalid document size");
241
- let t;
242
- try {
243
- t = JSON.parse(e);
244
- } catch {
245
- S("invalid JSON syntax");
246
- }
247
- k(e);
248
- let n = C(t, Object.keys(t));
249
- if (!("schemaVersion" in n)) return Object.values(n).some((e) => typeof e != "string") && S("legacy inventory must contain URLs"), n;
250
- if (C(n, [
251
- "schemaVersion",
252
- "artStyle",
253
- "assets",
254
- "planningError",
255
- "legacyInventory",
256
- "legacyPlaceholderKeys"
257
- ], [
258
- "schemaVersion",
259
- "artStyle",
260
- "assets"
261
- ]), n.schemaVersion !== 1 && S("unsupported schema version"), w(n.artStyle, 2048), n.legacyInventory !== void 0 && w(n.legacyInventory, b), n.legacyPlaceholderKeys !== void 0) {
262
- Array.isArray(n.legacyPlaceholderKeys) || S("legacy placeholder keys must be an array");
263
- for (let e of n.legacyPlaceholderKeys) w(e, 256, !0);
264
- new Set(n.legacyPlaceholderKeys).size !== n.legacyPlaceholderKeys.length && S("duplicate legacy placeholder key");
265
- }
266
- n.planningError !== void 0 && (D(n.planningError), n.planningError.stage !== "planning" && S("planningError stage must be planning"));
267
- let r = C(n.assets, Object.keys(n.assets ?? {}));
268
- for (let [e, t] of Object.entries(r)) {
269
- w(e, 256, !0);
270
- let n = C(t, [
271
- "type",
272
- "source",
273
- "replaceable",
274
- "description",
275
- "params",
276
- "generation",
277
- "status",
278
- "url",
279
- "output",
280
- "error",
281
- "implementation"
282
- ], [
283
- "type",
284
- "source",
285
- "replaceable",
286
- "description",
287
- "status"
288
- ]);
289
- if (T(n.type, x), T(n.source, [
290
- "generated",
291
- "user",
292
- "existing",
293
- "code"
294
- ]), (typeof n.replaceable != "boolean" || n.replaceable !== (n.source !== "code")) && S("source/replaceable mismatch"), w(n.description, 4096, !0), T(n.status, [
295
- "planned",
296
- "ready",
297
- "failed",
298
- "skipped",
299
- "degraded"
300
- ]), n.source === "generated") {
301
- String(n.type).startsWith("image") || n.type === "sound" || n.type === "music" || S("unsupported generation type");
302
- let e = C(n.generation, ["action", "prompt"], ["action", "prompt"]);
303
- T(e.action, ["generate", "reuse"]), w(e.prompt, 4096, !0);
304
- } else n.generation !== void 0 && S("non-generated assets cannot contain generation");
305
- if ((n.type === "synth" || n.type === "animation") && n.source !== "code" && S("type requires code source"), n.url !== void 0 && (w(n.url, 4096), (typeof n.url != "string" || !M(n.url)) && S("invalid resource reference")), (n.source === "user" || n.source === "existing") && (!n.url || n.status !== "ready") && S("existing resource requires ready URL"), n.source === "generated" && n.status === "ready" && !n.url && S("ready media requires URL"), n.status === "degraded" && (n.source !== "generated" || !n.url || !n.error) && S("degraded media requires temporary URL and reason"), n.params !== void 0) {
306
- let e = C(n.params, [
307
- "width",
308
- "height",
309
- "durationSeconds",
310
- "loop"
311
- ]);
312
- for (let t of ["width", "height"]) e[t] !== void 0 && E(e[t], !0);
313
- e.durationSeconds !== void 0 && E(e.durationSeconds), e.loop !== void 0 && typeof e.loop != "boolean" && S("loop boolean required");
314
- }
315
- if (n.output !== void 0) {
316
- let e = C(n.output, [
317
- "format",
318
- "width",
319
- "height",
320
- "durationSeconds"
321
- ]);
322
- e.format !== void 0 && w(e.format, 32);
323
- for (let t of ["width", "height"]) e[t] !== void 0 && E(e[t], !0);
324
- e.durationSeconds !== void 0 && E(e.durationSeconds);
325
- }
326
- if (n.error !== void 0 && D(n.error), n.implementation !== void 0) {
327
- let e = C(n.implementation, [
328
- "method",
329
- "description",
330
- "status",
331
- "path",
332
- "symbol"
333
- ], [
334
- "method",
335
- "description",
336
- "status"
337
- ]);
338
- T(e.method, [
339
- "svg",
340
- "canvas",
341
- "css",
342
- "synth",
343
- "animation",
344
- "three"
345
- ]), T(e.status, ["planned", "ready"]), w(e.description, 4096, !0), e.path !== void 0 && w(e.path, 4096), e.symbol !== void 0 && w(e.symbol, 256), e.status === "ready" && !e.path && !e.symbol && S("ready implementation requires path or symbol"), n.source === "code" && n.status !== e.status && S("code status mismatch");
346
- }
347
- n.source === "code" && (!n.implementation || n.url || n.output || n.error || !["planned", "ready"].includes(String(n.status))) && S("code requires implementation without media result");
348
- }
349
- for (let e of n.legacyPlaceholderKeys ?? []) {
350
- let t = r[e];
351
- (!t || t.url) && S("invalid legacy placeholder key");
352
- }
353
- return n;
354
- }
355
- function j(e) {
356
- return Buffer.byteLength(e, "utf8") <= 4096 && [
357
- "",
358
- "-",
359
- "--",
360
- "tbd",
361
- "todo",
362
- "none",
363
- "n/a",
364
- "null",
365
- "pending",
366
- "not-generated",
367
- "待生成",
368
- "待制作"
369
- ].includes(e.trim().toLowerCase());
370
- }
371
- function M(e) {
372
- if (!e || e.trim() !== e || /[\s\\]/u.test(e) || e.startsWith("//") || /%(?![0-9a-f]{2})/i.test(e.split("?")[0]) || /%(?![0-9a-f]{2})/i.test(e.split("#")[1] ?? "")) return !1;
373
- if (!/^[a-z][a-z0-9+.-]*:/i.test(e)) {
374
- if (e.split(/[?#]/, 1)[0].split("/", 1)[0].includes(":")) return !1;
375
- let t = e.split(/[?#]/, 1)[0].replace(/%([0-9a-f]{2})/gi, (e, t) => String.fromCharCode(Number.parseInt(t, 16)));
376
- if (!t || t.endsWith("/") || j(t)) return !1;
377
- if (t.includes("/")) return !0;
378
- let n = t.lastIndexOf(".");
379
- return n > 0 && n < t.length - 1;
380
- }
381
- if (!/^https?:\/\//i.test(e)) return !1;
382
- try {
383
- let t = e.slice(e.indexOf("://") + 3).split(/[/?#]/, 1)[0];
384
- if (!t || t.includes("%")) return !1;
385
- let n = new URL(e);
386
- return ["http:", "https:"].includes(n.protocol) && !!n.hostname && !n.username && !n.password;
387
- } catch {
388
- return !1;
389
- }
390
- }
391
- function N(e) {
392
- return O(e) ? Object.fromEntries(Object.entries(e.assets).filter(([, e]) => e.replaceable && typeof e.url == "string" && e.url.length > 0).map(([e, t]) => [e, t.url])) : { ...e };
393
- }
394
- //#endregion
395
- //#region src/asset-constants/generator-utils.ts
396
- function P(e) {
397
- if (!e || typeof e != "object" || Array.isArray(e)) return !1;
398
- let t = e;
399
- return typeof t.schemaVersion == "number" && !!t.assets && typeof t.assets == "object" && !Array.isArray(t.assets);
400
- }
401
- function F(e, t, n = {}) {
402
- let r = { ...n }, i = new Set(Object.keys(r));
403
- for (let [e, n] of t.entries()) i.has(n) || Object.values(r).includes(e) || (r[n] = e, i.add(n));
404
- for (let t of e.values()) {
405
- let e = Object.entries(r).find(([, e]) => e === t.originalUri);
406
- if (e) {
407
- t.constantName = e[0];
408
- continue;
409
- }
410
- let n = t.constantName, a = n, o = 2;
411
- for (; i.has(a);) a = `${n}_${o++}`;
412
- i.add(a), t.constantName = a, r[a] = t.originalUri;
413
- }
414
- return JSON.stringify(r, null, 2) + "\n";
415
- }
416
- function I(e) {
417
- let t = /* @__PURE__ */ new Map();
418
- try {
419
- if (!e.trim()) return t;
420
- let n = JSON.parse(e);
421
- if (P(n)) throw Error("assets: single-file asset plan is not supported");
422
- if (!n || typeof n != "object" || Array.isArray(n)) throw Error("assets: URL dictionary object required");
423
- for (let [e, r] of Object.entries(n)) typeof r == "string" && t.set(r, e);
424
- t.size > 0 && console.log(`📋 Found ${t.size} existing constants in assets.json`);
425
- } catch (e) {
426
- throw e instanceof Error && e.message.startsWith("assets:") ? e : Error("assets: invalid JSON syntax");
427
- }
428
- return t;
429
- }
430
- function L(e, t, n, r) {
431
- let i = Array.from(n.values()).filter((e) => t.has(e.originalUri)).length, a = e - i;
432
- console.log(a > 0 ? `✅ Generated ${e} asset constants (${a} new, ${i} reused) in ${r}` : e > 0 ? `✅ Generated ${e} asset constants (all reused from existing) in ${r}` : "✅ No asset constants found");
433
- }
434
- //#endregion
435
- export { N as a, m as c, _ as d, f, c as g, u as h, I as i, y as l, l as m, P as n, O as o, d as p, L as r, A as s, F as t, v as u };
@@ -1,239 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/draft/2020-12/schema",
3
- "title": "Aippy asset manifest",
4
- "type": "object",
5
- "additionalProperties": false,
6
- "required": ["schemaVersion", "artStyle", "assets"],
7
- "properties": {
8
- "schemaVersion": { "const": 1 },
9
- "artStyle": { "type": "string" },
10
- "legacyInventory": { "type": "string" },
11
- "legacyPlaceholderKeys": {
12
- "description": "Server-owned historical flat keys without a resource URL, retained as empty wrapper values regardless of current asset type or source.",
13
- "type": "array",
14
- "uniqueItems": true,
15
- "items": { "type": "string", "minLength": 1 }
16
- },
17
- "planningError": {
18
- "allOf": [
19
- { "$ref": "#/$defs/error" },
20
- { "properties": { "stage": { "const": "planning" } } }
21
- ]
22
- },
23
- "assets": {
24
- "type": "object",
25
- "propertyNames": { "minLength": 1 },
26
- "additionalProperties": { "$ref": "#/$defs/entry" }
27
- }
28
- },
29
- "$defs": {
30
- "error": {
31
- "type": "object",
32
- "additionalProperties": false,
33
- "required": ["stage", "code", "message", "retryable"],
34
- "properties": {
35
- "stage": { "type": "string", "minLength": 1 },
36
- "code": { "type": "string", "minLength": 1 },
37
- "message": { "type": "string", "minLength": 1 },
38
- "retryable": { "type": "boolean" }
39
- }
40
- },
41
- "params": {
42
- "type": "object",
43
- "additionalProperties": false,
44
- "properties": {
45
- "width": { "type": "integer", "minimum": 1 },
46
- "height": { "type": "integer", "minimum": 1 },
47
- "durationSeconds": { "type": "number", "exclusiveMinimum": 0 },
48
- "loop": { "type": "boolean" }
49
- }
50
- },
51
- "output": {
52
- "type": "object",
53
- "additionalProperties": false,
54
- "properties": {
55
- "format": { "type": "string" },
56
- "width": { "type": "integer", "minimum": 1 },
57
- "height": { "type": "integer", "minimum": 1 },
58
- "durationSeconds": { "type": "number", "exclusiveMinimum": 0 }
59
- }
60
- },
61
- "implementation": {
62
- "type": "object",
63
- "additionalProperties": false,
64
- "required": ["method", "description", "status"],
65
- "properties": {
66
- "method": {
67
- "enum": ["svg", "canvas", "css", "synth", "animation", "three"]
68
- },
69
- "description": { "type": "string", "minLength": 1 },
70
- "status": { "enum": ["planned", "ready"] },
71
- "path": { "type": "string" },
72
- "symbol": { "type": "string" }
73
- },
74
- "allOf": [
75
- {
76
- "if": { "properties": { "status": { "const": "ready" } } },
77
- "then": {
78
- "anyOf": [
79
- {
80
- "required": ["path"],
81
- "properties": { "path": { "minLength": 1 } }
82
- },
83
- {
84
- "required": ["symbol"],
85
- "properties": { "symbol": { "minLength": 1 } }
86
- }
87
- ]
88
- }
89
- }
90
- ]
91
- },
92
- "entry": {
93
- "type": "object",
94
- "additionalProperties": false,
95
- "required": ["type", "source", "replaceable", "description", "status"],
96
- "properties": {
97
- "type": {
98
- "enum": [
99
- "image",
100
- "image-bg",
101
- "image-sprite",
102
- "image-icon",
103
- "image-tile",
104
- "sound",
105
- "music",
106
- "synth",
107
- "model",
108
- "animation",
109
- "video",
110
- "file"
111
- ]
112
- },
113
- "source": { "enum": ["generated", "user", "existing", "code"] },
114
- "replaceable": { "type": "boolean" },
115
- "description": { "type": "string", "minLength": 1 },
116
- "params": { "$ref": "#/$defs/params" },
117
- "generation": {
118
- "type": "object",
119
- "additionalProperties": false,
120
- "required": ["action", "prompt"],
121
- "properties": {
122
- "action": { "enum": ["generate", "reuse"] },
123
- "prompt": { "type": "string", "minLength": 1 }
124
- }
125
- },
126
- "status": {
127
- "enum": ["planned", "ready", "failed", "skipped", "degraded"]
128
- },
129
- "url": { "type": "string" },
130
- "output": { "$ref": "#/$defs/output" },
131
- "error": { "$ref": "#/$defs/error" },
132
- "implementation": { "$ref": "#/$defs/implementation" }
133
- },
134
- "allOf": [
135
- {
136
- "if": { "properties": { "source": { "const": "generated" } } },
137
- "then": {
138
- "required": ["generation"],
139
- "properties": {
140
- "replaceable": { "const": true },
141
- "type": {
142
- "enum": [
143
- "image",
144
- "image-bg",
145
- "image-sprite",
146
- "image-icon",
147
- "image-tile",
148
- "sound",
149
- "music"
150
- ]
151
- }
152
- }
153
- },
154
- "else": { "not": { "required": ["generation"] } }
155
- },
156
- {
157
- "if": { "properties": { "source": { "const": "code" } } },
158
- "then": {
159
- "required": ["implementation"],
160
- "properties": {
161
- "replaceable": { "const": false },
162
- "status": { "enum": ["planned", "ready"] }
163
- },
164
- "not": {
165
- "anyOf": [
166
- { "required": ["url"] },
167
- { "required": ["output"] },
168
- { "required": ["error"] }
169
- ]
170
- },
171
- "allOf": [
172
- {
173
- "if": { "properties": { "status": { "const": "ready" } } },
174
- "then": {
175
- "properties": {
176
- "implementation": {
177
- "properties": { "status": { "const": "ready" } }
178
- }
179
- }
180
- }
181
- },
182
- {
183
- "if": { "properties": { "status": { "const": "planned" } } },
184
- "then": {
185
- "properties": {
186
- "implementation": {
187
- "properties": { "status": { "const": "planned" } }
188
- }
189
- }
190
- }
191
- }
192
- ]
193
- },
194
- "else": { "properties": { "replaceable": { "const": true } } }
195
- },
196
- {
197
- "if": {
198
- "properties": { "type": { "enum": ["synth", "animation"] } }
199
- },
200
- "then": { "properties": { "source": { "const": "code" } } }
201
- },
202
- {
203
- "if": {
204
- "properties": { "source": { "enum": ["user", "existing"] } }
205
- },
206
- "then": {
207
- "required": ["url"],
208
- "properties": {
209
- "url": { "minLength": 1 },
210
- "status": { "const": "ready" }
211
- }
212
- }
213
- },
214
- {
215
- "if": {
216
- "properties": {
217
- "source": { "const": "generated" },
218
- "status": { "const": "ready" }
219
- }
220
- },
221
- "then": {
222
- "required": ["url"],
223
- "properties": { "url": { "minLength": 1 } }
224
- }
225
- },
226
- {
227
- "if": { "properties": { "status": { "const": "degraded" } } },
228
- "then": {
229
- "required": ["url", "error"],
230
- "properties": {
231
- "source": { "const": "generated" },
232
- "url": { "minLength": 1 }
233
- }
234
- }
235
- }
236
- ]
237
- }
238
- }
239
- }