@animus-ui/cli 0.1.32 → 0.1.37
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 +4 -1
- package/dist/build.d.ts.map +1 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/index.cjs +34 -17
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +31 -20
- package/dist/writer.d.ts +4 -0
- package/dist/writer.d.ts.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -109,7 +109,10 @@ files, and structural emptiness are fatal in every mode.
|
|
|
109
109
|
|
|
110
110
|
`animus build` publishes to `--out-dir` (default `<root>/.animus/` —
|
|
111
111
|
`.gitignore` it) at fixed paths: `styles.css`, `system-props.js`,
|
|
112
|
-
`manifest.json`,
|
|
112
|
+
`manifest.json`, `font-preloads.json` (the font faces' preloads, for
|
|
113
|
+
`renderFontPreloads`; present only when a face preloads, as the faces'
|
|
114
|
+
`preload` flags or the config's `fontPreloads` entries select them), and
|
|
115
|
+
`commit.json` — written last, carrying a content hash
|
|
113
116
|
per payload, so one read verifies set completeness and freshness. Bytes are
|
|
114
117
|
deterministic and identity-free; `lock.json` is a single-writer advisory
|
|
115
118
|
lock that fails loud. The full contract, including the consistency-check
|
package/dist/build.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAOA,OAAO,EAIL,iBAAiB,
|
|
1
|
+
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAOA,OAAO,EAIL,iBAAiB,EAMlB,MAAM,4BAA4B,CAAC;AAcpC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAKlD,qBAAa,iBAAkB,SAAQ,KAAK;CAAG;AAC/C,qBAAa,YAAa,SAAQ,KAAK;CAAG;AAC1C,qBAAa,kBAAmB,SAAQ,KAAK;CAAG;AAEhD,eAAO,MAAM,GAAG,aAAc,OAAO,EAAE,KAAG,IACL,CAAC;AAEtC,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;qCACqC;AACrC,wBAAsB,YAAY,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAqB3E;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,iBAAiB,GAAG,iBAAiB,CAkC7E;AAED,MAAM,WAAW,cAAc;IAC7B,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,iBAAiB,EACzB,OAAO,EAAE,iBAAiB,GACzB,cAAc,CAmEhB;AAqBD,wBAAgB,qBAAqB,CACnC,UAAU,EAAE,MAAM,iBAAiB,GAAG,IAAI,EAC1C,WAAW,EAAE,MAAM,IAAI,GACtB,MAAM,IAAI,CAOZ;AAED,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,iBAAiB,EACzB,OAAO,EAAE,iBAAiB,GACzB,IAAI,CAUN;AAED,MAAM,WAAW,UAAU;IACzB,iDAAiD;IACjD,GAAG,CAAC,EAAE,OAAO,CAAC;CACf;AAgBD,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,iBAAiB,EACzB,KAAK,GAAE,UAAe,GACrB,OAAO,CAAC,WAAW,CAAC,CAwDtB"}
|
package/dist/config.d.ts
CHANGED
|
@@ -52,6 +52,7 @@ export declare function projectResolvedConfig(config: ResolvedCliConfig): {
|
|
|
52
52
|
staticCss: StaticCssConfig | null;
|
|
53
53
|
runtimeImport: string | null;
|
|
54
54
|
closedDynamicImports: import("@animus-ui/extract/pipeline").ClosedDynamicImport[] | null;
|
|
55
|
+
fontPreloads: import("@animus-ui/extract/pipeline").FontPreloadEntry[] | null;
|
|
55
56
|
exclude: readonly string[];
|
|
56
57
|
provenance: Record<string, OptionProvenance>;
|
|
57
58
|
};
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACV,iBAAiB,EACjB,UAAU,EACV,eAAe,EAEf,gBAAgB,EAEhB,eAAe,EAChB,MAAM,6BAA6B,CAAC;AAErC,eAAO,MAAM,gBAAgB,YAC3B,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,CACV,CAAC;AAEX,MAAM,WAAW,mBAAmB;IAClC,0EAA0E;IAC1E,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,QAAQ;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,aAAa,GAAG,YAAY,GAAG,KAAK,CAAC;AAE1E,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,KAAK,CAAC;IACd,2DAA2D;IAC3D,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,aAAa,CAAC;IAC1B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,OAAO,EAAE,iBAAiB,CAAC;IAC3B,0CAA0C;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,IAAI,EAAE,UAAU,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;CAC9C;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACV,iBAAiB,EACjB,UAAU,EACV,eAAe,EAEf,gBAAgB,EAEhB,eAAe,EAChB,MAAM,6BAA6B,CAAC;AAErC,eAAO,MAAM,gBAAgB,YAC3B,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,CACV,CAAC;AAEX,MAAM,WAAW,mBAAmB;IAClC,0EAA0E;IAC1E,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,QAAQ;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,aAAa,GAAG,YAAY,GAAG,KAAK,CAAC;AAE1E,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,KAAK,CAAC;IACd,2DAA2D;IAC3D,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,aAAa,CAAC;IAC1B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,OAAO,EAAE,iBAAiB,CAAC;IAC3B,0CAA0C;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,IAAI,EAAE,UAAU,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;CAC9C;AAuPD,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,QAAQ,EACf,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,iBAAiB,CAAC,CAuI5B;AAED;kEACkE;AAClE,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,iBAAiB,EACzB,GAAG,EAAE,MAAM,GACV,MAAM,GAAG,IAAI,CAOf;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,iBAAiB;IAE3D,MAAM;IACN,IAAI;IACJ,UAAU;IACV,MAAM;IACN,IAAI;IACJ,MAAM;IACN,MAAM;IACN,WAAW;IACX,OAAO;IACP,OAAO;IACP,MAAM;IACN,MAAM;IACN,oBAAoB;IACpB,MAAM;IACN,UAAU;IACV,SAAS;IACT,aAAa;IACb,oBAAoB;IACpB,YAAY;IACZ,OAAO;IACP,UAAU;EAEb"}
|
package/dist/index.cjs
CHANGED
|
@@ -62,6 +62,7 @@ const MANIFEST_FILE = _animus_ui_extract_session.MANIFEST_ARTIFACT;
|
|
|
62
62
|
const COMMIT_FILE = _animus_ui_extract_session.CLI_COMMIT_ARTIFACT;
|
|
63
63
|
const LOCK_FILE = _animus_ui_extract_session.CLI_LOCK_ARTIFACT;
|
|
64
64
|
const ASSETS_DIR = _animus_ui_extract_session.SESSION_ASSETS_DIR;
|
|
65
|
+
const FONT_PRELOADS_FILE = _animus_ui_extract_session.CLI_FONT_PRELOADS_ARTIFACT;
|
|
65
66
|
function isFileExistsError(error) {
|
|
66
67
|
return error instanceof Object && "code" in error && error.code === "EEXIST";
|
|
67
68
|
}
|
|
@@ -101,7 +102,8 @@ const STAGING_PREFIX = ".staging-";
|
|
|
101
102
|
const NAMED_PAYLOAD_FIELDS = [
|
|
102
103
|
[STYLES_FILE, "stylesCss"],
|
|
103
104
|
[SYSTEM_PROPS_FILE, "systemPropsJs"],
|
|
104
|
-
[MANIFEST_FILE, "manifestJson"]
|
|
105
|
+
[MANIFEST_FILE, "manifestJson"],
|
|
106
|
+
[FONT_PRELOADS_FILE, "fontPreloadsJson"]
|
|
105
107
|
];
|
|
106
108
|
const PUBLISHED_NAMES = [...NAMED_PAYLOAD_FIELDS.map(([name]) => name), COMMIT_FILE];
|
|
107
109
|
/** Called only while the claim is held — deciding a tree is debris and
|
|
@@ -165,21 +167,21 @@ function acquireLock(outDir) {
|
|
|
165
167
|
startedAt
|
|
166
168
|
});
|
|
167
169
|
}
|
|
168
|
-
|
|
170
|
+
/** Every name the current commit record publishes. */
|
|
171
|
+
function publishedNames(outDir) {
|
|
169
172
|
let record;
|
|
170
173
|
try {
|
|
171
174
|
record = (0, _animus_ui_extract_session.decodeCommitRecord)((0, fs.readFileSync)((0, path.join)(outDir, COMMIT_FILE), "utf-8"));
|
|
172
175
|
} catch {
|
|
173
176
|
return /* @__PURE__ */ new Set();
|
|
174
177
|
}
|
|
175
|
-
|
|
176
|
-
return new Set(Object.keys(record.payloads).filter((name) => name.startsWith(`${ASSETS_DIR}/`)).map((name) => name.slice(ASSETS_DIR.length + 1)));
|
|
178
|
+
return new Set(record === null ? [] : Object.keys(record.payloads));
|
|
177
179
|
}
|
|
178
180
|
/** Staged, verified, then renamed into place with the commit record LAST. A
|
|
179
181
|
* set that cannot verify throws with the previous generation untouched. */
|
|
180
182
|
function publishArtifacts(outDir, payloads) {
|
|
181
183
|
(0, fs.mkdirSync)(outDir, { recursive: true });
|
|
182
|
-
const
|
|
184
|
+
const previouslyPublished = publishedNames(outDir);
|
|
183
185
|
const staging = (0, path.join)(outDir, `${STAGING_PREFIX}${process.pid}`);
|
|
184
186
|
(0, fs.rmSync)(staging, {
|
|
185
187
|
recursive: true,
|
|
@@ -187,7 +189,11 @@ function publishArtifacts(outDir, payloads) {
|
|
|
187
189
|
});
|
|
188
190
|
(0, fs.mkdirSync)(staging, { recursive: true });
|
|
189
191
|
try {
|
|
190
|
-
const namedPayloads =
|
|
192
|
+
const namedPayloads = [];
|
|
193
|
+
for (const [name, field] of NAMED_PAYLOAD_FIELDS) {
|
|
194
|
+
const text = payloads[field];
|
|
195
|
+
if (text !== void 0) namedPayloads.push([name, text]);
|
|
196
|
+
}
|
|
191
197
|
const record = {
|
|
192
198
|
schema: 1,
|
|
193
199
|
payloads: {}
|
|
@@ -221,11 +227,11 @@ function publishArtifacts(outDir, payloads) {
|
|
|
221
227
|
landed.push(`${ASSETS_DIR}/${name}`);
|
|
222
228
|
}
|
|
223
229
|
}
|
|
224
|
-
const expectedNames = new Set(assets.map((asset) => asset.name));
|
|
225
|
-
for (const name of
|
|
226
|
-
if (expectedNames.has(name)) continue;
|
|
230
|
+
const expectedNames = /* @__PURE__ */ new Set([...namedPayloads.map(([name]) => name), ...assets.map((asset) => `${ASSETS_DIR}/${asset.name}`)]);
|
|
231
|
+
for (const name of previouslyPublished) {
|
|
232
|
+
if (expectedNames.has(name) || name === COMMIT_FILE) continue;
|
|
227
233
|
try {
|
|
228
|
-
(0, fs.unlinkSync)((0, path.join)(
|
|
234
|
+
(0, fs.unlinkSync)((0, path.join)(outDir, name));
|
|
229
235
|
} catch {}
|
|
230
236
|
}
|
|
231
237
|
(0, fs.renameSync)((0, path.join)(staging, COMMIT_FILE), (0, path.join)(outDir, COMMIT_FILE));
|
|
@@ -285,6 +291,7 @@ function publishSharedPayloads(config, session) {
|
|
|
285
291
|
const manifestJson = (0, _animus_ui_extract_session.getManifestJson)(session.key) ?? "";
|
|
286
292
|
const stylesCss = (0, _animus_ui_extract_session.getSharedCss)(session.key);
|
|
287
293
|
const systemPropsJs = (0, _animus_ui_extract_session.getSharedSystemProps)(session.key);
|
|
294
|
+
const fontPreloads = (0, _animus_ui_extract_session.getSharedFontPreloads)(session.key);
|
|
288
295
|
let componentCount = session.lastComponentCount ?? -1;
|
|
289
296
|
if (componentCount < 0) try {
|
|
290
297
|
const manifest = JSON.parse(manifestJson);
|
|
@@ -303,14 +310,15 @@ function publishSharedPayloads(config, session) {
|
|
|
303
310
|
variableMapJson: session.variableMapJson
|
|
304
311
|
});
|
|
305
312
|
if (failures.length > 0) throw new ExtractionFailure(`Structural self-check failed:\n - ${failures.join("\n - ")}`);
|
|
306
|
-
const
|
|
313
|
+
const payloads = {
|
|
314
|
+
stylesCss,
|
|
315
|
+
systemPropsJs,
|
|
316
|
+
manifestJson,
|
|
317
|
+
assets: (0, _animus_ui_extract_session.collectSessionAssets)(session.sessionDir)
|
|
318
|
+
};
|
|
319
|
+
if (fontPreloads.length > 0) payloads.fontPreloadsJson = JSON.stringify(fontPreloads);
|
|
307
320
|
try {
|
|
308
|
-
publishArtifacts(outDir,
|
|
309
|
-
stylesCss,
|
|
310
|
-
systemPropsJs,
|
|
311
|
-
manifestJson,
|
|
312
|
-
assets
|
|
313
|
-
});
|
|
321
|
+
publishArtifacts(outDir, payloads);
|
|
314
322
|
} catch (error) {
|
|
315
323
|
if (error instanceof PublishInconsistencyError) throw new EnvironmentFailure(error.message);
|
|
316
324
|
throw error;
|
|
@@ -473,6 +481,7 @@ function parseLoadedCliConfig(raw) {
|
|
|
473
481
|
layers: isConfigStringArray(raw.layers) ? raw.layers : void 0,
|
|
474
482
|
runtimeImport: isConfigString(raw.runtimeImport) ? raw.runtimeImport : void 0,
|
|
475
483
|
closedDynamicImports: Array.isArray(raw.closedDynamicImports) ? raw.closedDynamicImports : void 0,
|
|
484
|
+
fontPreloads: Array.isArray(raw.fontPreloads) ? raw.fontPreloads : void 0,
|
|
476
485
|
mode: raw.mode === "development" || raw.mode === "production" ? raw.mode : void 0
|
|
477
486
|
},
|
|
478
487
|
cli: { outDir: cli.outDir }
|
|
@@ -567,6 +576,7 @@ async function resolveCliConfig(flags, cwd) {
|
|
|
567
576
|
layers: pick("layers", void 0),
|
|
568
577
|
runtimeImport: pick("runtimeImport", void 0),
|
|
569
578
|
closedDynamicImports: pick("closedDynamicImports", void 0),
|
|
579
|
+
fontPreloads: pick("fontPreloads", void 0),
|
|
570
580
|
mode: resolvedMode.mode
|
|
571
581
|
};
|
|
572
582
|
const excludePatterns = (0, _animus_ui_extract_pipeline.createExcludeMatcher)(options.exclude).patterns;
|
|
@@ -608,6 +618,7 @@ function projectResolvedConfig(config) {
|
|
|
608
618
|
staticCss: config.options.staticCss ?? null,
|
|
609
619
|
runtimeImport: config.options.runtimeImport ?? null,
|
|
610
620
|
closedDynamicImports: config.options.closedDynamicImports ?? null,
|
|
621
|
+
fontPreloads: config.options.fontPreloads ?? null,
|
|
611
622
|
exclude: config.excludePatterns,
|
|
612
623
|
provenance: config.provenance
|
|
613
624
|
};
|
|
@@ -931,3 +942,9 @@ exports.EXIT_OK = EXIT_OK;
|
|
|
931
942
|
exports.EXIT_USAGE = EXIT_USAGE;
|
|
932
943
|
exports.exitCodeFor = exitCodeFor;
|
|
933
944
|
exports.main = main;
|
|
945
|
+
Object.defineProperty(exports, "renderFontPreloads", {
|
|
946
|
+
enumerable: true,
|
|
947
|
+
get: function() {
|
|
948
|
+
return _animus_ui_extract_pipeline.renderFontPreloads;
|
|
949
|
+
}
|
|
950
|
+
});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/** The supported consumer surface is the `animus` binary; the programmatic
|
|
2
2
|
* exports may change without semver ceremony. */
|
|
3
|
+
export { renderFontPreloads } from '@animus-ui/extract/pipeline';
|
|
4
|
+
export type { FontPreload } from '@animus-ui/extract/pipeline';
|
|
3
5
|
export declare const EXIT_OK = 0;
|
|
4
6
|
export declare const EXIT_EXTRACTION = 1;
|
|
5
7
|
export declare const EXIT_USAGE = 2;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;kDACkD;AAiBlD,eAAO,MAAM,OAAO,IAAI,CAAC;AACzB,eAAO,MAAM,eAAe,IAAI,CAAC;AACjC,eAAO,MAAM,UAAU,IAAI,CAAC;AAC5B,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAClC;qEACqE;AACrE,eAAO,MAAM,YAAY,IAAI,CAAC;AA4D9B;sDACsD;AACtD,wBAAgB,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAMzD;AAQD,wBAAsB,IAAI,CACxB,IAAI,GAAE,MAAM,EAA0B,GACrC,OAAO,CAAC,IAAI,CAAC,CA4Ff"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;kDACkD;AAiBlD,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,YAAY,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE/D,eAAO,MAAM,OAAO,IAAI,CAAC;AACzB,eAAO,MAAM,eAAe,IAAI,CAAC;AACjC,eAAO,MAAM,UAAU,IAAI,CAAC;AAC5B,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAClC;qEACqE;AACrE,eAAO,MAAM,YAAY,IAAI,CAAC;AA4D9B;sDACsD;AACtD,wBAAgB,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAMzD;AAQD,wBAAsB,IAAI,CACxB,IAAI,GAAE,MAAM,EAA0B,GACrC,OAAO,CAAC,IAAI,CAAC,CA4Ff"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AnimusConfigError, DIAGNOSTIC_LEVELS, KIT_DESCRIPTOR_FILE, REPLACEABLE_DEFAULT_EXCLUDE, STRUCTURAL_EXCLUDE, assertKnownOptionKeys, assertSupportedEngine, buildKitDescriptor, contentHash, createExcludeMatcher, kitPublicationFailures, outputExclusion, resolveMode, runStructuralSelfCheck } from "@animus-ui/extract/pipeline";
|
|
1
|
+
import { AnimusConfigError, DIAGNOSTIC_LEVELS, KIT_DESCRIPTOR_FILE, REPLACEABLE_DEFAULT_EXCLUDE, STRUCTURAL_EXCLUDE, assertKnownOptionKeys, assertSupportedEngine, buildKitDescriptor, contentHash, createExcludeMatcher, kitPublicationFailures, outputExclusion, renderFontPreloads, resolveMode, runStructuralSelfCheck } from "@animus-ui/extract/pipeline";
|
|
2
2
|
import { parseArgs } from "node:util";
|
|
3
|
-
import { ANIMUS_ARTIFACT_DIR, CLI_COMMIT_ARTIFACT, CLI_LOCK_ARTIFACT, ExtractionSession, MANIFEST_ARTIFACT, SESSION_ASSETS_DIR, STYLES_ARTIFACT, SYSTEM_PROPS_ARTIFACT, checkLockLiveness, collectSessionAssets, decodeCommitRecord, engineApi, getAnalyzedHashes, getManifestJson, getSharedCss, getSharedSystemProps, holdDirectoryClaim, isLockHolderAlive, lockRecordBytes, readCliLockRecord, startTurbopackWatcher, verifyCommitRecord } from "@animus-ui/extract/session";
|
|
3
|
+
import { ANIMUS_ARTIFACT_DIR, CLI_COMMIT_ARTIFACT, CLI_FONT_PRELOADS_ARTIFACT, CLI_LOCK_ARTIFACT, ExtractionSession, MANIFEST_ARTIFACT, SESSION_ASSETS_DIR, STYLES_ARTIFACT, SYSTEM_PROPS_ARTIFACT, checkLockLiveness, collectSessionAssets, decodeCommitRecord, engineApi, getAnalyzedHashes, getManifestJson, getSharedCss, getSharedFontPreloads, getSharedSystemProps, holdDirectoryClaim, isLockHolderAlive, lockRecordBytes, readCliLockRecord, startTurbopackWatcher, verifyCommitRecord } from "@animus-ui/extract/session";
|
|
4
4
|
import { existsSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, unlinkSync, writeFileSync } from "fs";
|
|
5
5
|
import { dirname, isAbsolute, join, relative, resolve } from "path";
|
|
6
6
|
import { pathToFileURL } from "url";
|
|
@@ -61,6 +61,7 @@ const MANIFEST_FILE = MANIFEST_ARTIFACT;
|
|
|
61
61
|
const COMMIT_FILE = CLI_COMMIT_ARTIFACT;
|
|
62
62
|
const LOCK_FILE = CLI_LOCK_ARTIFACT;
|
|
63
63
|
const ASSETS_DIR = SESSION_ASSETS_DIR;
|
|
64
|
+
const FONT_PRELOADS_FILE = CLI_FONT_PRELOADS_ARTIFACT;
|
|
64
65
|
function isFileExistsError(error) {
|
|
65
66
|
return error instanceof Object && "code" in error && error.code === "EEXIST";
|
|
66
67
|
}
|
|
@@ -100,7 +101,8 @@ const STAGING_PREFIX = ".staging-";
|
|
|
100
101
|
const NAMED_PAYLOAD_FIELDS = [
|
|
101
102
|
[STYLES_FILE, "stylesCss"],
|
|
102
103
|
[SYSTEM_PROPS_FILE, "systemPropsJs"],
|
|
103
|
-
[MANIFEST_FILE, "manifestJson"]
|
|
104
|
+
[MANIFEST_FILE, "manifestJson"],
|
|
105
|
+
[FONT_PRELOADS_FILE, "fontPreloadsJson"]
|
|
104
106
|
];
|
|
105
107
|
const PUBLISHED_NAMES = [...NAMED_PAYLOAD_FIELDS.map(([name]) => name), COMMIT_FILE];
|
|
106
108
|
/** Called only while the claim is held — deciding a tree is debris and
|
|
@@ -164,21 +166,21 @@ function acquireLock(outDir) {
|
|
|
164
166
|
startedAt
|
|
165
167
|
});
|
|
166
168
|
}
|
|
167
|
-
|
|
169
|
+
/** Every name the current commit record publishes. */
|
|
170
|
+
function publishedNames(outDir) {
|
|
168
171
|
let record;
|
|
169
172
|
try {
|
|
170
173
|
record = decodeCommitRecord(readFileSync(join(outDir, COMMIT_FILE), "utf-8"));
|
|
171
174
|
} catch {
|
|
172
175
|
return /* @__PURE__ */ new Set();
|
|
173
176
|
}
|
|
174
|
-
|
|
175
|
-
return new Set(Object.keys(record.payloads).filter((name) => name.startsWith(`${ASSETS_DIR}/`)).map((name) => name.slice(ASSETS_DIR.length + 1)));
|
|
177
|
+
return new Set(record === null ? [] : Object.keys(record.payloads));
|
|
176
178
|
}
|
|
177
179
|
/** Staged, verified, then renamed into place with the commit record LAST. A
|
|
178
180
|
* set that cannot verify throws with the previous generation untouched. */
|
|
179
181
|
function publishArtifacts(outDir, payloads) {
|
|
180
182
|
mkdirSync(outDir, { recursive: true });
|
|
181
|
-
const
|
|
183
|
+
const previouslyPublished = publishedNames(outDir);
|
|
182
184
|
const staging = join(outDir, `${STAGING_PREFIX}${process.pid}`);
|
|
183
185
|
rmSync(staging, {
|
|
184
186
|
recursive: true,
|
|
@@ -186,7 +188,11 @@ function publishArtifacts(outDir, payloads) {
|
|
|
186
188
|
});
|
|
187
189
|
mkdirSync(staging, { recursive: true });
|
|
188
190
|
try {
|
|
189
|
-
const namedPayloads =
|
|
191
|
+
const namedPayloads = [];
|
|
192
|
+
for (const [name, field] of NAMED_PAYLOAD_FIELDS) {
|
|
193
|
+
const text = payloads[field];
|
|
194
|
+
if (text !== void 0) namedPayloads.push([name, text]);
|
|
195
|
+
}
|
|
190
196
|
const record = {
|
|
191
197
|
schema: 1,
|
|
192
198
|
payloads: {}
|
|
@@ -220,11 +226,11 @@ function publishArtifacts(outDir, payloads) {
|
|
|
220
226
|
landed.push(`${ASSETS_DIR}/${name}`);
|
|
221
227
|
}
|
|
222
228
|
}
|
|
223
|
-
const expectedNames = new Set(assets.map((asset) => asset.name));
|
|
224
|
-
for (const name of
|
|
225
|
-
if (expectedNames.has(name)) continue;
|
|
229
|
+
const expectedNames = /* @__PURE__ */ new Set([...namedPayloads.map(([name]) => name), ...assets.map((asset) => `${ASSETS_DIR}/${asset.name}`)]);
|
|
230
|
+
for (const name of previouslyPublished) {
|
|
231
|
+
if (expectedNames.has(name) || name === COMMIT_FILE) continue;
|
|
226
232
|
try {
|
|
227
|
-
unlinkSync(join(
|
|
233
|
+
unlinkSync(join(outDir, name));
|
|
228
234
|
} catch {}
|
|
229
235
|
}
|
|
230
236
|
renameSync(join(staging, COMMIT_FILE), join(outDir, COMMIT_FILE));
|
|
@@ -284,6 +290,7 @@ function publishSharedPayloads(config, session) {
|
|
|
284
290
|
const manifestJson = getManifestJson(session.key) ?? "";
|
|
285
291
|
const stylesCss = getSharedCss(session.key);
|
|
286
292
|
const systemPropsJs = getSharedSystemProps(session.key);
|
|
293
|
+
const fontPreloads = getSharedFontPreloads(session.key);
|
|
287
294
|
let componentCount = session.lastComponentCount ?? -1;
|
|
288
295
|
if (componentCount < 0) try {
|
|
289
296
|
const manifest = JSON.parse(manifestJson);
|
|
@@ -302,14 +309,15 @@ function publishSharedPayloads(config, session) {
|
|
|
302
309
|
variableMapJson: session.variableMapJson
|
|
303
310
|
});
|
|
304
311
|
if (failures.length > 0) throw new ExtractionFailure(`Structural self-check failed:\n - ${failures.join("\n - ")}`);
|
|
305
|
-
const
|
|
312
|
+
const payloads = {
|
|
313
|
+
stylesCss,
|
|
314
|
+
systemPropsJs,
|
|
315
|
+
manifestJson,
|
|
316
|
+
assets: collectSessionAssets(session.sessionDir)
|
|
317
|
+
};
|
|
318
|
+
if (fontPreloads.length > 0) payloads.fontPreloadsJson = JSON.stringify(fontPreloads);
|
|
306
319
|
try {
|
|
307
|
-
publishArtifacts(outDir,
|
|
308
|
-
stylesCss,
|
|
309
|
-
systemPropsJs,
|
|
310
|
-
manifestJson,
|
|
311
|
-
assets
|
|
312
|
-
});
|
|
320
|
+
publishArtifacts(outDir, payloads);
|
|
313
321
|
} catch (error) {
|
|
314
322
|
if (error instanceof PublishInconsistencyError) throw new EnvironmentFailure(error.message);
|
|
315
323
|
throw error;
|
|
@@ -472,6 +480,7 @@ function parseLoadedCliConfig(raw) {
|
|
|
472
480
|
layers: isConfigStringArray(raw.layers) ? raw.layers : void 0,
|
|
473
481
|
runtimeImport: isConfigString(raw.runtimeImport) ? raw.runtimeImport : void 0,
|
|
474
482
|
closedDynamicImports: Array.isArray(raw.closedDynamicImports) ? raw.closedDynamicImports : void 0,
|
|
483
|
+
fontPreloads: Array.isArray(raw.fontPreloads) ? raw.fontPreloads : void 0,
|
|
475
484
|
mode: raw.mode === "development" || raw.mode === "production" ? raw.mode : void 0
|
|
476
485
|
},
|
|
477
486
|
cli: { outDir: cli.outDir }
|
|
@@ -566,6 +575,7 @@ async function resolveCliConfig(flags, cwd) {
|
|
|
566
575
|
layers: pick("layers", void 0),
|
|
567
576
|
runtimeImport: pick("runtimeImport", void 0),
|
|
568
577
|
closedDynamicImports: pick("closedDynamicImports", void 0),
|
|
578
|
+
fontPreloads: pick("fontPreloads", void 0),
|
|
569
579
|
mode: resolvedMode.mode
|
|
570
580
|
};
|
|
571
581
|
const excludePatterns = createExcludeMatcher(options.exclude).patterns;
|
|
@@ -607,6 +617,7 @@ function projectResolvedConfig(config) {
|
|
|
607
617
|
staticCss: config.options.staticCss ?? null,
|
|
608
618
|
runtimeImport: config.options.runtimeImport ?? null,
|
|
609
619
|
closedDynamicImports: config.options.closedDynamicImports ?? null,
|
|
620
|
+
fontPreloads: config.options.fontPreloads ?? null,
|
|
610
621
|
exclude: config.excludePatterns,
|
|
611
622
|
provenance: config.provenance
|
|
612
623
|
};
|
|
@@ -923,4 +934,4 @@ async function main(argv = process.argv.slice(2)) {
|
|
|
923
934
|
}
|
|
924
935
|
}
|
|
925
936
|
//#endregion
|
|
926
|
-
export { EXIT_ENVIRONMENT, EXIT_EXTRACTION, EXIT_INSTALL, EXIT_OK, EXIT_USAGE, exitCodeFor, main };
|
|
937
|
+
export { EXIT_ENVIRONMENT, EXIT_EXTRACTION, EXIT_INSTALL, EXIT_OK, EXIT_USAGE, exitCodeFor, main, renderFontPreloads };
|
package/dist/writer.d.ts
CHANGED
|
@@ -6,10 +6,14 @@ export declare const MANIFEST_FILE = "manifest.json";
|
|
|
6
6
|
export declare const COMMIT_FILE = "commit.json";
|
|
7
7
|
export declare const LOCK_FILE = "lock.json";
|
|
8
8
|
export declare const ASSETS_DIR = "assets";
|
|
9
|
+
export declare const FONT_PRELOADS_FILE = "font-preloads.json";
|
|
9
10
|
export interface ArtifactPayloads {
|
|
10
11
|
stylesCss: string;
|
|
11
12
|
systemPropsJs: string;
|
|
12
13
|
manifestJson: string;
|
|
14
|
+
/** The faces' preloads, hrefs relative to styles.css, for
|
|
15
|
+
* `renderFontPreloads`; absent when no face preloads. */
|
|
16
|
+
fontPreloadsJson?: string;
|
|
13
17
|
/** Published under `assets/<name>` beside styles.css — the stylesheet's
|
|
14
18
|
* relative urls dangle without them. */
|
|
15
19
|
assets?: readonly SessionAsset[];
|
package/dist/writer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writer.d.ts","sourceRoot":"","sources":["../src/writer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAe,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"writer.d.ts","sourceRoot":"","sources":["../src/writer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAe,MAAM,6BAA6B,CAAC;AA6B7E,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAI7E,eAAO,MAAM,WAAW,eAAkB,CAAC;AAC3C,eAAO,MAAM,iBAAiB,oBAAwB,CAAC;AACvD,eAAO,MAAM,aAAa,kBAAoB,CAAC;AAC/C,eAAO,MAAM,WAAW,gBAAsB,CAAC;AAC/C,eAAO,MAAM,SAAS,cAAoB,CAAC;AAC3C,eAAO,MAAM,UAAU,WAAqB,CAAC;AAC7C,eAAO,MAAM,kBAAkB,uBAA6B,CAAC;AAE7D,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB;8DAC0D;IAC1D,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;6CACyC;IACzC,MAAM,CAAC,EAAE,SAAS,YAAY,EAAE,CAAC;CAClC;AAYD;8DAC8D;AAC9D,qBAAa,yBAA0B,SAAQ,KAAK;IACtC,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE;IAAvC,YAAqB,QAAQ,EAAE,MAAM,EAAE,EAKtC;CACF;AAED,qBAAa,0BAA0B,CAAC,MAAM,CAAE,SAAQ,KAAK;IAEzD,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,wDAAwD;IACxD,QAAQ,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE;IAClC,QAAQ,CAAC,OAAO,EAAE,MAAM;IAJ1B,YACW,MAAM,EAAE,MAAM;IACvB,wDAAwD;IAC/C,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,OAAO,EAAE,MAAM,EASzB;CACF;AAED;yEACyE;AACzE,qBAAa,uBAAwB,SAAQ,iBAAiB;IAC5D,YAAY,OAAO,EAAE,MAAM,EAG1B;CACF;AAoDD,6EAA6E;AAC7E,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,IAAI,CAoDtD;AAeD;4EAC4E;AAC5E,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,gBAAgB,GACzB,YAAY,CAqFd"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@animus-ui/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.37",
|
|
4
4
|
"description": "Standalone Animus extraction CLI — one-shot builds and artifact emission for any build system",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"animus",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"compile": "bun check"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@animus-ui/extract": "0.1.
|
|
44
|
+
"@animus-ui/extract": "0.1.37"
|
|
45
45
|
},
|
|
46
46
|
"engines": {
|
|
47
47
|
"node": ">=22.12.0"
|