@moku-labs/web 2.4.14 → 2.4.16
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/browser.d.mts +60 -7
- package/dist/browser.mjs +272 -3492
- package/dist/convention-tZrMQCJS.mjs +20 -0
- package/dist/index.cjs +510 -121
- package/dist/index.d.cts +60 -7
- package/dist/index.d.mts +60 -7
- package/dist/index.mjs +510 -121
- package/dist/render-DcOi8CU9.mjs +12 -0
- package/dist/testing.mjs +2 -1
- package/dist/writer-CIlDKFE1.mjs +48 -0
- package/package.json +1 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { render } from "preact";
|
|
2
|
+
//#region src/plugins/spa/render.ts
|
|
3
|
+
function renderVNode(vnode, region) {
|
|
4
|
+
render(null, region);
|
|
5
|
+
region.replaceChildren();
|
|
6
|
+
render(vnode, region);
|
|
7
|
+
}
|
|
8
|
+
function commitVNode(vnode, host) {
|
|
9
|
+
render(vnode, host);
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { commitVNode, renderVNode };
|
package/dist/testing.mjs
CHANGED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { r as relativeDataFile, t as BUNDLE_FILE } from "./convention-tZrMQCJS.mjs";
|
|
2
|
+
import { mkdir, writeFile } from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import pLimit from "p-limit";
|
|
5
|
+
//#region src/plugins/data/writer.ts
|
|
6
|
+
const DEFAULT_OUT_DIR = "./dist";
|
|
7
|
+
const WRITE_CONCURRENCY = 8;
|
|
8
|
+
async function writeEntry(entry, outDir, outputDir) {
|
|
9
|
+
const relative = relativeDataFile(outputDir, entry.path);
|
|
10
|
+
const filePath = path.join(outDir, relative);
|
|
11
|
+
await mkdir(path.dirname(filePath), { recursive: true });
|
|
12
|
+
const body = JSON.stringify(entry.data);
|
|
13
|
+
await writeFile(filePath, body, "utf8");
|
|
14
|
+
return {
|
|
15
|
+
relative,
|
|
16
|
+
bytes: Buffer.byteLength(body, "utf8")
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function compileSummary(written) {
|
|
20
|
+
return {
|
|
21
|
+
fileCount: written.length,
|
|
22
|
+
bytes: written.reduce((total, file) => total + file.bytes, 0),
|
|
23
|
+
files: written.map((file) => file.relative)
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
async function writeBundle(entries, outDir, outputDir) {
|
|
27
|
+
const bundle = {};
|
|
28
|
+
for (const entry of entries) bundle[entry.path] = entry.data;
|
|
29
|
+
const file = `${outputDir.endsWith("/") ? outputDir.slice(0, -1) : outputDir}/${BUNDLE_FILE}`;
|
|
30
|
+
const filePath = path.join(outDir, file);
|
|
31
|
+
await mkdir(path.dirname(filePath), { recursive: true });
|
|
32
|
+
const body = JSON.stringify(bundle);
|
|
33
|
+
await writeFile(filePath, body, "utf8");
|
|
34
|
+
return {
|
|
35
|
+
file,
|
|
36
|
+
bytes: Buffer.byteLength(body, "utf8")
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
async function writeData(ctx, entries, options) {
|
|
40
|
+
const outDir = options?.outDir ?? DEFAULT_OUT_DIR;
|
|
41
|
+
const limit = pLimit(WRITE_CONCURRENCY);
|
|
42
|
+
const summary = compileSummary(await Promise.all(entries.map((entry) => limit(() => writeEntry(entry, outDir, ctx.config.outputDir)))));
|
|
43
|
+
if (ctx.config.preload === "all") summary.bundle = await writeBundle(entries, outDir, ctx.config.outputDir);
|
|
44
|
+
ctx.state.lastWrite = summary;
|
|
45
|
+
return summary;
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
export { writeData };
|
package/package.json
CHANGED