domflax 0.1.2 → 0.1.4
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 +25 -8
- package/dist/{chunk-DNHOGPYV.js → chunk-3Z5ZWLXX.js} +407 -51
- package/dist/chunk-3Z5ZWLXX.js.map +1 -0
- package/dist/{chunk-DOQEBGWB.js → chunk-5FWENSD2.js} +63 -8
- package/dist/chunk-5FWENSD2.js.map +1 -0
- package/dist/chunk-EVENAJYI.js +336 -0
- package/dist/chunk-EVENAJYI.js.map +1 -0
- package/dist/{chunk-DWLB7FRR.js → chunk-H5KTGI3A.js} +153 -7
- package/dist/chunk-H5KTGI3A.js.map +1 -0
- package/dist/{chunk-6WVVF6AD.js → chunk-U5GOONKV.js} +5 -2
- package/dist/{chunk-6WVVF6AD.js.map → chunk-U5GOONKV.js.map} +1 -1
- package/dist/cli.cjs +995 -166
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +245 -229
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +614 -68
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +34 -18
- package/dist/index.d.ts +34 -18
- package/dist/index.js +4 -4
- package/dist/{pattern-F5xBtIE-.d.cts → pattern-CP9_HpVK.d.cts} +1 -1
- package/dist/{pattern-CV607P87.d.ts → pattern-CYgsv-jO.d.ts} +1 -1
- package/dist/pattern-kit.cjs.map +1 -1
- package/dist/pattern-kit.d.cts +2 -2
- package/dist/pattern-kit.d.ts +2 -2
- package/dist/pattern-kit.js +2 -2
- package/dist/{resolve-ops-DIwEelH-.d.ts → resolve-ops-Ci7LgYHC.d.cts} +9 -0
- package/dist/{resolve-ops-DIwEelH-.d.cts → resolve-ops-Ci7LgYHC.d.ts} +9 -0
- package/dist/verify.d.cts +1 -1
- package/dist/verify.d.ts +1 -1
- package/dist/verify.js +1 -1
- package/dist/webpack-loader.cjs +614 -68
- package/dist/webpack-loader.cjs.map +1 -1
- package/dist/webpack-loader.d.cts +2 -2
- package/dist/webpack-loader.d.ts +2 -2
- package/dist/webpack-loader.js +4 -4
- package/dist/worker.cjs +5955 -0
- package/dist/worker.cjs.map +1 -0
- package/dist/worker.d.cts +2 -0
- package/dist/worker.d.ts +2 -0
- package/dist/worker.js +72 -0
- package/dist/worker.js.map +1 -0
- package/package.json +4 -2
- package/dist/chunk-DNHOGPYV.js.map +0 -1
- package/dist/chunk-DOQEBGWB.js.map +0 -1
- package/dist/chunk-DWLB7FRR.js.map +0 -1
package/dist/worker.d.ts
ADDED
package/dist/worker.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createTransform,
|
|
3
|
+
destinationFor
|
|
4
|
+
} from "./chunk-EVENAJYI.js";
|
|
5
|
+
import "./chunk-3Z5ZWLXX.js";
|
|
6
|
+
import "./chunk-H5KTGI3A.js";
|
|
7
|
+
import {
|
|
8
|
+
init_esm_shims
|
|
9
|
+
} from "./chunk-U5GOONKV.js";
|
|
10
|
+
|
|
11
|
+
// src/worker.ts
|
|
12
|
+
init_esm_shims();
|
|
13
|
+
|
|
14
|
+
// ../cli/src/worker.ts
|
|
15
|
+
init_esm_shims();
|
|
16
|
+
|
|
17
|
+
// ../cli/src/worker-main.ts
|
|
18
|
+
init_esm_shims();
|
|
19
|
+
import { mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
20
|
+
import * as path from "path";
|
|
21
|
+
import { isMainThread, parentPort, workerData } from "worker_threads";
|
|
22
|
+
function runWorker() {
|
|
23
|
+
if (isMainThread || !parentPort) return;
|
|
24
|
+
const port = parentPort;
|
|
25
|
+
const init = workerData;
|
|
26
|
+
const { inputRoot, plan } = init;
|
|
27
|
+
const transform = createTransform(init.options);
|
|
28
|
+
const processOne = (file) => {
|
|
29
|
+
try {
|
|
30
|
+
const code = readFileSync(file, "utf8");
|
|
31
|
+
const result = transform.transformFile(code, file);
|
|
32
|
+
let wrote = null;
|
|
33
|
+
if (result.changed) {
|
|
34
|
+
const target = destinationFor(file, inputRoot, plan);
|
|
35
|
+
if (!target.ok) throw new Error(target.error);
|
|
36
|
+
mkdirSync(path.dirname(target.value), { recursive: true });
|
|
37
|
+
writeFileSync(target.value, result.code, "utf8");
|
|
38
|
+
wrote = target.value;
|
|
39
|
+
}
|
|
40
|
+
port.postMessage({
|
|
41
|
+
type: "result",
|
|
42
|
+
path: file,
|
|
43
|
+
ok: true,
|
|
44
|
+
stats: result.stats,
|
|
45
|
+
changed: result.changed,
|
|
46
|
+
wrote
|
|
47
|
+
});
|
|
48
|
+
} catch (err) {
|
|
49
|
+
port.postMessage({
|
|
50
|
+
type: "result",
|
|
51
|
+
path: file,
|
|
52
|
+
ok: false,
|
|
53
|
+
error: String(err?.message ?? err)
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
port.on("message", (msg) => {
|
|
58
|
+
if (msg.type === "file") {
|
|
59
|
+
processOne(msg.path);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (msg.type === "stop") {
|
|
63
|
+
port.close();
|
|
64
|
+
process.exit(0);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
port.postMessage({ type: "ready" });
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// ../cli/src/worker.ts
|
|
71
|
+
runWorker();
|
|
72
|
+
//# sourceMappingURL=worker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/worker.ts","../../cli/src/worker.ts","../../cli/src/worker-main.ts"],"sourcesContent":["/**\n * `domflax` worker-pool entry.\n *\n * The published `domflax` bin (`cli.cjs`) spins up a parallel worker pool for large batches. The pool\n * loads its worker by path RELATIVE to the running bundle, so the worker must ship alongside `cli.cjs`\n * in `domflax/dist`. This thin entry re-runs the bundled `@domflax/cli` worker (inlined here via tsup's\n * `noExternal`), producing `domflax/dist/worker.cjs` + `worker.js`.\n */\nimport '@domflax/cli/worker';\n","/**\n * @domflax/cli — worker-pool entry point (FEATURE B).\n *\n * A dedicated, self-contained module so tsup emits it as its OWN bundle (`worker.cjs`/`worker.js`),\n * loadable by `new Worker(...)` both from `packages/cli/dist` and when inlined into `domflax/dist`.\n * Importing it starts the worker loop (a no-op on the main thread).\n */\n\nimport { runWorker } from './worker-main';\n\nrunWorker();\n","/**\n * @domflax/cli — worker-thread body for the parallel pool (FEATURE B).\n *\n * Runs inside a `worker_threads` Worker. It builds ONE transform engine (reusing Feature A's per-file\n * resolver logic) from the {@link WorkerInit} handed over in `workerData`, then services one file at a\n * time on request from the main thread: read → transform → write to the planned destination → post\n * back only stats numbers. File contents never cross back to the main thread.\n *\n * Every file is wrapped in try/catch: a bad file fails in isolation (reported, pool continues) and can\n * never take the worker — or the whole run — down.\n */\n\nimport { mkdirSync, readFileSync, writeFileSync } from 'node:fs';\nimport * as path from 'node:path';\nimport { isMainThread, parentPort, workerData } from 'node:worker_threads';\n\nimport { destinationFor } from './safety';\nimport { createTransform } from './transform';\nimport type { MainToWorker, WorkerInit, WorkerToMain } from './pool';\n\n/** Start the worker message loop. A no-op on the main thread (import is side-effect-safe). */\nexport function runWorker(): void {\n if (isMainThread || !parentPort) return;\n const port = parentPort;\n const init = workerData as WorkerInit;\n const { inputRoot, plan } = init;\n\n // Build the engine ONCE per worker (this is the ~PER_WORKER_MB cost the pool provisions for).\n const transform = createTransform(init.options);\n\n const processOne = (file: string): void => {\n try {\n const code = readFileSync(file, 'utf8');\n const result = transform.transformFile(code, file);\n let wrote: string | null = null;\n if (result.changed) {\n const target = destinationFor(file, inputRoot, plan);\n if (!target.ok) throw new Error(target.error);\n mkdirSync(path.dirname(target.value), { recursive: true });\n writeFileSync(target.value, result.code, 'utf8');\n wrote = target.value;\n }\n port.postMessage({\n type: 'result',\n path: file,\n ok: true,\n stats: result.stats,\n changed: result.changed,\n wrote,\n } satisfies WorkerToMain);\n } catch (err) {\n port.postMessage({\n type: 'result',\n path: file,\n ok: false,\n error: String((err as Error)?.message ?? err),\n } satisfies WorkerToMain);\n }\n };\n\n port.on('message', (msg: MainToWorker) => {\n if (msg.type === 'file') {\n processOne(msg.path);\n return;\n }\n if (msg.type === 'stop') {\n port.close();\n process.exit(0);\n }\n });\n\n // Signal the main thread the engine is built and we're ready for the first file.\n port.postMessage({ type: 'ready' } satisfies WorkerToMain);\n}\n"],"mappings":";;;;;;;;;;;AAAA;;;ACAA;;;ACAA;AAYA,SAAS,WAAW,cAAc,qBAAqB;AACvD,YAAY,UAAU;AACtB,SAAS,cAAc,YAAY,kBAAkB;AAO9C,SAAS,YAAkB;AAChC,MAAI,gBAAgB,CAAC,WAAY;AACjC,QAAM,OAAO;AACb,QAAM,OAAO;AACb,QAAM,EAAE,WAAW,KAAK,IAAI;AAG5B,QAAM,YAAY,gBAAgB,KAAK,OAAO;AAE9C,QAAM,aAAa,CAAC,SAAuB;AACzC,QAAI;AACF,YAAM,OAAO,aAAa,MAAM,MAAM;AACtC,YAAM,SAAS,UAAU,cAAc,MAAM,IAAI;AACjD,UAAI,QAAuB;AAC3B,UAAI,OAAO,SAAS;AAClB,cAAM,SAAS,eAAe,MAAM,WAAW,IAAI;AACnD,YAAI,CAAC,OAAO,GAAI,OAAM,IAAI,MAAM,OAAO,KAAK;AAC5C,kBAAe,aAAQ,OAAO,KAAK,GAAG,EAAE,WAAW,KAAK,CAAC;AACzD,sBAAc,OAAO,OAAO,OAAO,MAAM,MAAM;AAC/C,gBAAQ,OAAO;AAAA,MACjB;AACA,WAAK,YAAY;AAAA,QACf,MAAM;AAAA,QACN,MAAM;AAAA,QACN,IAAI;AAAA,QACJ,OAAO,OAAO;AAAA,QACd,SAAS,OAAO;AAAA,QAChB;AAAA,MACF,CAAwB;AAAA,IAC1B,SAAS,KAAK;AACZ,WAAK,YAAY;AAAA,QACf,MAAM;AAAA,QACN,MAAM;AAAA,QACN,IAAI;AAAA,QACJ,OAAO,OAAQ,KAAe,WAAW,GAAG;AAAA,MAC9C,CAAwB;AAAA,IAC1B;AAAA,EACF;AAEA,OAAK,GAAG,WAAW,CAAC,QAAsB;AACxC,QAAI,IAAI,SAAS,QAAQ;AACvB,iBAAW,IAAI,IAAI;AACnB;AAAA,IACF;AACA,QAAI,IAAI,SAAS,QAAQ;AACvB,WAAK,MAAM;AACX,cAAQ,KAAK,CAAC;AAAA,IAChB;AAAA,EACF,CAAC;AAGD,OAAK,YAAY,EAAE,MAAM,QAAQ,CAAwB;AAC3D;;;AD/DA,UAAU;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "domflax",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Compile-time DOM flattener and semantic CSS compressor — fewer DOM nodes, smaller class sets, identical rendered UI.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dom",
|
|
@@ -78,13 +78,15 @@
|
|
|
78
78
|
"@babel/parser": "^7.26.0",
|
|
79
79
|
"@babel/traverse": "^7.26.0",
|
|
80
80
|
"@babel/types": "^7.26.0",
|
|
81
|
-
"magic-string": "^0.30.21"
|
|
81
|
+
"magic-string": "^0.30.21",
|
|
82
|
+
"parse5": "^7.3.0"
|
|
82
83
|
},
|
|
83
84
|
"devDependencies": {
|
|
84
85
|
"@domflax/core": "*",
|
|
85
86
|
"@domflax/patterns": "*",
|
|
86
87
|
"@domflax/pattern-kit": "*",
|
|
87
88
|
"@domflax/frontend-jsx": "*",
|
|
89
|
+
"@domflax/frontend-html": "*",
|
|
88
90
|
"@domflax/resolver-tailwind": "*",
|
|
89
91
|
"@domflax/resolver-css": "*",
|
|
90
92
|
"@domflax/verify": "*",
|