@aippy/vite-plugins 0.4.0-dev.1 → 0.4.0-dev.2
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 +2 -0
- package/dist/aippy-preload/index.js +1 -1
- package/dist/{aippy-preload-QZY6fyKx.js → aippy-preload-Dhhw3O6d.js} +1 -1
- package/dist/asset-constants/index.js +1 -1
- package/dist/asset-constants/manifest.d.ts +2 -0
- package/dist/{asset-constants-C59CLHCE.js → asset-constants-BUK7zWRd.js} +4 -3
- package/dist/index/index.js +2 -2
- package/dist/{manifest-CI1ALLzl.js → manifest-DQGCd9CQ.js} +43 -9
- package/package.json +1 -1
- package/src/asset-constants/assets.schema.json +6 -0
package/README.md
CHANGED
|
@@ -107,3 +107,5 @@ UNLICENSED - Aippy Team
|
|
|
107
107
|
Version 0.4.0-dev.1 reads both legacy flat URL inventories and `schemaVersion: 1` manifests. Assets Agent writes resource plans; development builds preserve their metadata and supplement resources discovered by the existing scanner. Invalid v1 inventories and manifest/wrapper write failures stop the build.
|
|
108
108
|
|
|
109
109
|
Import the generated flat URL map from `@/config/assets`. Only entries with usable URLs appear in that map; the existing `window.getReplacedAssets` hook still mutates it in place. Source-code assets and generated fallbacks with an exact `implementation.path` retain their original source references. Preload reads resource URLs rather than generation prompts or error text. The JSON schema is exported as `@aippy/vite-plugins/assets.schema.json`; parser checks also enforce byte, reference and semantic constraints.
|
|
110
|
+
|
|
111
|
+
Pending the next dev release, wrappers retain only historical flat placeholder keys listed in `legacyPlaceholderKeys` as empty strings; other unavailable media remain absent. Concrete code assets continue to use their source references. These changes are not included in the published 0.4.0-dev.1 package.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as e } from "../aippy-preload-
|
|
1
|
+
import { t as e } from "../aippy-preload-Dhhw3O6d.js";
|
|
2
2
|
export { e as aippyPreloadPlugin, e as default };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { extractAssetsFromContent as e } from "./utils/index.js";
|
|
2
|
-
import { d as t, i as n, o as r, r as i, t as a } from "./manifest-
|
|
2
|
+
import { d as t, i as n, o as r, r as i, t as a } from "./manifest-DQGCd9CQ.js";
|
|
3
3
|
import { promises as o } from "fs";
|
|
4
4
|
import s from "path";
|
|
5
5
|
//#region src/aippy-preload/scanner-utils.ts
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as e } from "../asset-constants-
|
|
1
|
+
import { t as e } from "../asset-constants-BUK7zWRd.js";
|
|
2
2
|
export { e as assetConstantsPlugin, e as default };
|
|
@@ -43,6 +43,8 @@ export interface AssetManifest {
|
|
|
43
43
|
artStyle: string;
|
|
44
44
|
assets: Record<string, AssetEntry>;
|
|
45
45
|
planningError?: AssetError;
|
|
46
|
+
legacyInventory?: string;
|
|
47
|
+
legacyPlaceholderKeys?: string[];
|
|
46
48
|
}
|
|
47
49
|
export type AssetDocument = AssetManifest | Record<string, string>;
|
|
48
50
|
export declare function isManifest(doc: AssetDocument): doc is AssetManifest;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { extractAssetsFromContent as e, generateConstantName as t, processAssetURL as n } from "./utils/index.js";
|
|
2
|
-
import { a as r, c as i, d as a, f as o, i as s, l as c, n as l, o as u, p as d, r as f, s as p, t as m, u as h } from "./manifest-
|
|
2
|
+
import { a as r, c as i, d as a, f as o, i as s, l as c, n as l, o as u, p as d, r as f, s as p, t as m, u as h } from "./manifest-DQGCd9CQ.js";
|
|
3
3
|
import { promises as g } from "fs";
|
|
4
4
|
import _ from "path";
|
|
5
5
|
import { parse as v } from "@babel/parser";
|
|
@@ -185,11 +185,12 @@ import assetsData from "./${t}";
|
|
|
185
185
|
export default assetsData;
|
|
186
186
|
`;
|
|
187
187
|
if (this.document && f(this.document)) {
|
|
188
|
-
let e = Object.keys(m(this.document));
|
|
188
|
+
let e = [.../* @__PURE__ */ new Set([...Object.keys(m(this.document)), ...this.document.legacyPlaceholderKeys ?? []])];
|
|
189
189
|
n = `// Auto-generated asset URL map. Planning metadata stays in assets.json.
|
|
190
190
|
import manifest from "./${t}";
|
|
191
|
+
const entries = manifest.assets as Record<string, { url?: string; [field: string]: unknown }>;
|
|
191
192
|
const keys = ${JSON.stringify(e)} as const;
|
|
192
|
-
const assetsData = ${e.length ? "Object.fromEntries(keys.map(name => [name,
|
|
193
|
+
const assetsData = ${e.length ? "Object.fromEntries(keys.map(name => [name, entries[name]?.url ?? \"\"]))" : "{}"} as { [K in typeof keys[number]]: string };
|
|
193
194
|
(window as any).getReplacedAssets?.(assetsData);
|
|
194
195
|
export default assetsData;
|
|
195
196
|
`;
|
package/dist/index/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { extractAssetsFromContent as e, findProjectRoot as t, generateConstantName as n, isValidAsset as r, processAssetURL as i } from "../utils/index.js";
|
|
2
|
-
import { t as a } from "../asset-constants-
|
|
3
|
-
import { t as o } from "../aippy-preload-
|
|
2
|
+
import { t as a } from "../asset-constants-BUK7zWRd.js";
|
|
3
|
+
import { t as o } from "../aippy-preload-Dhhw3O6d.js";
|
|
4
4
|
import { t as s } from "../aippy-tagger-By5socAS.js";
|
|
5
5
|
export { o as aippyPreloadPlugin, s as aippyTaggerPlugin, a as assetConstantsPlugin, a as default, e as extractAssetsFromContent, t as findProjectRoot, n as generateConstantName, r as isValidAsset, i as processAssetURL };
|
|
@@ -180,7 +180,7 @@ function C(e, t, n = []) {
|
|
|
180
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
181
|
}
|
|
182
182
|
function w(e, t, n = !1) {
|
|
183
|
-
(typeof e != "string" || Buffer.byteLength(e) > t || /[\x00-\x08\x0b\x0c\x0e-\x1f\x7f\uFEFF]/.test(e) || n && !e.trim()) && S("invalid bounded text");
|
|
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
184
|
}
|
|
185
185
|
function T(e, t) {
|
|
186
186
|
(typeof e != "string" || !t.includes(e)) && S("unsupported field value");
|
|
@@ -247,16 +247,23 @@ function A(e) {
|
|
|
247
247
|
k(e);
|
|
248
248
|
let n = C(t, Object.keys(t));
|
|
249
249
|
if (!("schemaVersion" in n)) return Object.values(n).some((e) => typeof e != "string") && S("legacy inventory must contain URLs"), n;
|
|
250
|
-
C(n, [
|
|
250
|
+
if (C(n, [
|
|
251
251
|
"schemaVersion",
|
|
252
252
|
"artStyle",
|
|
253
253
|
"assets",
|
|
254
|
-
"planningError"
|
|
254
|
+
"planningError",
|
|
255
|
+
"legacyInventory",
|
|
256
|
+
"legacyPlaceholderKeys"
|
|
255
257
|
], [
|
|
256
258
|
"schemaVersion",
|
|
257
259
|
"artStyle",
|
|
258
260
|
"assets"
|
|
259
|
-
]), n.schemaVersion !== 1 && S("unsupported schema version"), w(n.artStyle, 2048), n.
|
|
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"));
|
|
260
267
|
let r = C(n.assets, Object.keys(n.assets ?? {}));
|
|
261
268
|
for (let [e, t] of Object.entries(r)) {
|
|
262
269
|
w(e, 256, !0);
|
|
@@ -295,7 +302,7 @@ function A(e) {
|
|
|
295
302
|
let e = C(n.generation, ["action", "prompt"], ["action", "prompt"]);
|
|
296
303
|
T(e.action, ["generate", "reuse"]), w(e.prompt, 4096, !0);
|
|
297
304
|
} else n.generation !== void 0 && S("non-generated assets cannot contain generation");
|
|
298
|
-
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" || !
|
|
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) {
|
|
299
306
|
let e = C(n.params, [
|
|
300
307
|
"width",
|
|
301
308
|
"height",
|
|
@@ -339,11 +346,38 @@ function A(e) {
|
|
|
339
346
|
}
|
|
340
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");
|
|
341
348
|
}
|
|
349
|
+
for (let e of n.legacyPlaceholderKeys ?? []) {
|
|
350
|
+
let t = r[e];
|
|
351
|
+
(!t || t.source !== "code" || t.type !== "file" || t.url) && S("invalid legacy placeholder key");
|
|
352
|
+
}
|
|
342
353
|
return n;
|
|
343
354
|
}
|
|
344
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) {
|
|
345
372
|
if (!e || e.trim() !== e || /[\r\n\t\\]/.test(e) || e.startsWith("//") || /%(?![0-9a-f]{2})/i.test(e.split("?")[0]) || /%(?![0-9a-f]{2})/i.test(e.split("#")[1] ?? "")) return !1;
|
|
346
|
-
if (!/^[a-z][a-z0-9+.-]*:/i.test(e))
|
|
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
|
+
}
|
|
347
381
|
if (!/^https?:\/\//i.test(e)) return !1;
|
|
348
382
|
try {
|
|
349
383
|
let t = e.slice(e.indexOf("://") + 3).split(/[/?#]/, 1)[0];
|
|
@@ -354,12 +388,12 @@ function j(e) {
|
|
|
354
388
|
return !1;
|
|
355
389
|
}
|
|
356
390
|
}
|
|
357
|
-
function
|
|
391
|
+
function N(e) {
|
|
358
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 };
|
|
359
393
|
}
|
|
360
|
-
function
|
|
394
|
+
function P(e) {
|
|
361
395
|
let t = e.split(/[?#]/)[0].toLowerCase();
|
|
362
396
|
return /\.(mp3|wav|ogg|m4a|aac|flac)$/.test(t) ? "sound" : /\.(mp4|webm|mov)$/.test(t) ? "video" : /\.(png|jpg|jpeg|gif|svg|webp|avif)$/.test(t) ? "image" : /\.(glb|gltf|obj)$/.test(t) ? "model" : "file";
|
|
363
397
|
}
|
|
364
398
|
//#endregion
|
|
365
|
-
export { m as a, _ as c, l as d, u as f, A as i, f as l,
|
|
399
|
+
export { m as a, _ as c, l as d, u as f, A as i, f as l, P as n, y as o, c as p, O as r, v as s, N as t, d as u };
|
package/package.json
CHANGED
|
@@ -7,6 +7,12 @@
|
|
|
7
7
|
"properties": {
|
|
8
8
|
"schemaVersion": { "const": 1 },
|
|
9
9
|
"artStyle": { "type": "string" },
|
|
10
|
+
"legacyInventory": { "type": "string" },
|
|
11
|
+
"legacyPlaceholderKeys": {
|
|
12
|
+
"type": "array",
|
|
13
|
+
"uniqueItems": true,
|
|
14
|
+
"items": { "type": "string", "minLength": 1 }
|
|
15
|
+
},
|
|
10
16
|
"planningError": {
|
|
11
17
|
"allOf": [
|
|
12
18
|
{ "$ref": "#/$defs/error" },
|