@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.
@@ -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
@@ -567,7 +567,8 @@ function createState(_ctx) {
567
567
  destroyRouter: null,
568
568
  started: false,
569
569
  navigate: null,
570
- kernel: null
570
+ kernel: null,
571
+ prefetch: null
571
572
  };
572
573
  }
573
574
  //#endregion
@@ -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
@@ -139,5 +139,5 @@
139
139
  "typescript-eslint": "8.58.0",
140
140
  "vitest": "4.0.18"
141
141
  },
142
- "version": "2.4.14"
142
+ "version": "2.4.16"
143
143
  }