@lifeart/async-dom 2.0.0-alpha.3

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.
Files changed (117) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +623 -0
  3. package/dist/base.d.cts +398 -0
  4. package/dist/base.d.cts.map +1 -0
  5. package/dist/base.d.ts +398 -0
  6. package/dist/base.d.ts.map +1 -0
  7. package/dist/cli.cjs +528 -0
  8. package/dist/cli.cjs.map +1 -0
  9. package/dist/cli.d.cts +1 -0
  10. package/dist/cli.d.ts +1 -0
  11. package/dist/cli.js +493 -0
  12. package/dist/cli.js.map +1 -0
  13. package/dist/debug.d.cts +145 -0
  14. package/dist/debug.d.cts.map +1 -0
  15. package/dist/debug.d.ts +145 -0
  16. package/dist/debug.d.ts.map +1 -0
  17. package/dist/index.cjs +26 -0
  18. package/dist/index.d.cts +560 -0
  19. package/dist/index.d.cts.map +1 -0
  20. package/dist/index.d.ts +560 -0
  21. package/dist/index.d.ts.map +1 -0
  22. package/dist/index.js +5 -0
  23. package/dist/index2.d.cts +5 -0
  24. package/dist/index2.d.ts +5 -0
  25. package/dist/index3.d.cts +882 -0
  26. package/dist/index3.d.cts.map +1 -0
  27. package/dist/index3.d.ts +882 -0
  28. package/dist/index3.d.ts.map +1 -0
  29. package/dist/main-thread.cjs +5459 -0
  30. package/dist/main-thread.cjs.map +1 -0
  31. package/dist/main-thread.js +5429 -0
  32. package/dist/main-thread.js.map +1 -0
  33. package/dist/react.cjs +116 -0
  34. package/dist/react.cjs.map +1 -0
  35. package/dist/react.d.cts +91 -0
  36. package/dist/react.d.cts.map +1 -0
  37. package/dist/react.d.ts +91 -0
  38. package/dist/react.d.ts.map +1 -0
  39. package/dist/react.js +113 -0
  40. package/dist/react.js.map +1 -0
  41. package/dist/resolve-debug.cjs +24 -0
  42. package/dist/resolve-debug.cjs.map +1 -0
  43. package/dist/resolve-debug.js +19 -0
  44. package/dist/resolve-debug.js.map +1 -0
  45. package/dist/server.cjs +250 -0
  46. package/dist/server.cjs.map +1 -0
  47. package/dist/server.d.cts +127 -0
  48. package/dist/server.d.cts.map +1 -0
  49. package/dist/server.d.ts +127 -0
  50. package/dist/server.d.ts.map +1 -0
  51. package/dist/server.js +245 -0
  52. package/dist/server.js.map +1 -0
  53. package/dist/svelte.cjs +48 -0
  54. package/dist/svelte.cjs.map +1 -0
  55. package/dist/svelte.d.cts +38 -0
  56. package/dist/svelte.d.cts.map +1 -0
  57. package/dist/svelte.d.ts +38 -0
  58. package/dist/svelte.d.ts.map +1 -0
  59. package/dist/svelte.js +47 -0
  60. package/dist/svelte.js.map +1 -0
  61. package/dist/sync-channel.cjs +532 -0
  62. package/dist/sync-channel.cjs.map +1 -0
  63. package/dist/sync-channel.js +425 -0
  64. package/dist/sync-channel.js.map +1 -0
  65. package/dist/transport.cjs +213 -0
  66. package/dist/transport.cjs.map +1 -0
  67. package/dist/transport.d.cts +79 -0
  68. package/dist/transport.d.cts.map +1 -0
  69. package/dist/transport.d.ts +79 -0
  70. package/dist/transport.d.ts.map +1 -0
  71. package/dist/transport.js +202 -0
  72. package/dist/transport.js.map +1 -0
  73. package/dist/vite-plugin.cjs +112 -0
  74. package/dist/vite-plugin.cjs.map +1 -0
  75. package/dist/vite-plugin.d.cts +39 -0
  76. package/dist/vite-plugin.d.cts.map +1 -0
  77. package/dist/vite-plugin.d.ts +39 -0
  78. package/dist/vite-plugin.d.ts.map +1 -0
  79. package/dist/vite-plugin.js +107 -0
  80. package/dist/vite-plugin.js.map +1 -0
  81. package/dist/vue.cjs +123 -0
  82. package/dist/vue.cjs.map +1 -0
  83. package/dist/vue.d.cts +126 -0
  84. package/dist/vue.d.cts.map +1 -0
  85. package/dist/vue.d.ts +126 -0
  86. package/dist/vue.d.ts.map +1 -0
  87. package/dist/vue.js +120 -0
  88. package/dist/vue.js.map +1 -0
  89. package/dist/worker-thread.cjs +2751 -0
  90. package/dist/worker-thread.cjs.map +1 -0
  91. package/dist/worker-thread.js +2692 -0
  92. package/dist/worker-thread.js.map +1 -0
  93. package/dist/worker-transport.cjs +136 -0
  94. package/dist/worker-transport.cjs.map +1 -0
  95. package/dist/worker-transport.d.cts +162 -0
  96. package/dist/worker-transport.d.cts.map +1 -0
  97. package/dist/worker-transport.d.ts +162 -0
  98. package/dist/worker-transport.d.ts.map +1 -0
  99. package/dist/worker-transport.js +125 -0
  100. package/dist/worker-transport.js.map +1 -0
  101. package/dist/worker.cjs +12 -0
  102. package/dist/worker.d.cts +2 -0
  103. package/dist/worker.d.ts +2 -0
  104. package/dist/worker.js +2 -0
  105. package/dist/ws-server-transport.cjs +147 -0
  106. package/dist/ws-server-transport.cjs.map +1 -0
  107. package/dist/ws-server-transport.d.cts +64 -0
  108. package/dist/ws-server-transport.d.cts.map +1 -0
  109. package/dist/ws-server-transport.d.ts +64 -0
  110. package/dist/ws-server-transport.d.ts.map +1 -0
  111. package/dist/ws-server-transport.js +142 -0
  112. package/dist/ws-server-transport.js.map +1 -0
  113. package/dist/ws-transport.cjs +954 -0
  114. package/dist/ws-transport.cjs.map +1 -0
  115. package/dist/ws-transport.js +913 -0
  116. package/dist/ws-transport.js.map +1 -0
  117. package/package.json +145 -0
package/dist/cli.js ADDED
@@ -0,0 +1,493 @@
1
+ #!/usr/bin/env node
2
+ import * as fs from "node:fs";
3
+ import * as path from "node:path";
4
+ import * as readline from "node:readline";
5
+ //#region src/cli/templates.ts
6
+ /**
7
+ * Returns the list of files for a given project template.
8
+ *
9
+ * @param template - Template name (one of {@link AVAILABLE_TEMPLATES}).
10
+ * @param name - Project name, used in package.json and HTML title.
11
+ * @returns Array of files to write to disk.
12
+ * @throws If the template name is not recognized.
13
+ */
14
+ function getTemplate(template, name) {
15
+ switch (template) {
16
+ case "vanilla-ts": return vanillaTs(name);
17
+ case "react-ts": return reactTs(name);
18
+ case "vue-ts": return vueTs(name);
19
+ default: throw new Error(`Unknown template: ${template}. Available: vanilla-ts, react-ts, vue-ts`);
20
+ }
21
+ }
22
+ /** The list of available project templates for `async-dom init`. */
23
+ const AVAILABLE_TEMPLATES = [
24
+ "vanilla-ts",
25
+ "react-ts",
26
+ "vue-ts"
27
+ ];
28
+ function escapeHtml(str) {
29
+ return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
30
+ }
31
+ function vanillaTs(name) {
32
+ return [
33
+ {
34
+ path: "package.json",
35
+ content: JSON.stringify({
36
+ name,
37
+ private: true,
38
+ version: "0.0.0",
39
+ type: "module",
40
+ scripts: {
41
+ dev: "vite",
42
+ build: "tsc && vite build",
43
+ preview: "vite preview"
44
+ },
45
+ devDependencies: {
46
+ typescript: "^5.8.0",
47
+ vite: "^6.0.0",
48
+ "@lifeart/async-dom": "latest"
49
+ }
50
+ }, null, 2)
51
+ },
52
+ {
53
+ path: "index.html",
54
+ content: `<!DOCTYPE html>
55
+ <html lang="en">
56
+ <head>
57
+ <meta charset="UTF-8" />
58
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
59
+ <title>${escapeHtml(name)}</title>
60
+ </head>
61
+ <body>
62
+ <div id="app"></div>
63
+ <script type="module" src="/src/main.ts"><\/script>
64
+ </body>
65
+ </html>
66
+ `
67
+ },
68
+ {
69
+ path: "src/main.ts",
70
+ content: `import { createAsyncDom } from "@lifeart/async-dom";
71
+
72
+ const worker = new Worker(new URL("./app.worker.ts", import.meta.url), {
73
+ type: "module",
74
+ });
75
+
76
+ const instance = createAsyncDom({
77
+ target: document.getElementById("app")!,
78
+ worker,
79
+ });
80
+
81
+ instance.start();
82
+ `
83
+ },
84
+ {
85
+ path: "src/app.worker.ts",
86
+ content: `import { createWorkerDom } from "@lifeart/async-dom/worker";
87
+
88
+ const { document } = createWorkerDom();
89
+
90
+ const heading = document.createElement("h1");
91
+ heading.textContent = "Hello from async-dom!";
92
+ document.body.appendChild(heading);
93
+
94
+ const counter = document.createElement("button");
95
+ counter.textContent = "Count: 0";
96
+ let count = 0;
97
+ counter.addEventListener("click", () => {
98
+ count++;
99
+ counter.textContent = \`Count: \${count}\`;
100
+ });
101
+ document.body.appendChild(counter);
102
+ `
103
+ },
104
+ {
105
+ path: "src/vite-env.d.ts",
106
+ content: `/// <reference types="vite/client" />
107
+ `
108
+ },
109
+ {
110
+ path: "tsconfig.json",
111
+ content: JSON.stringify({
112
+ compilerOptions: {
113
+ target: "ES2022",
114
+ module: "ESNext",
115
+ moduleResolution: "bundler",
116
+ strict: true,
117
+ esModuleInterop: true,
118
+ skipLibCheck: true,
119
+ forceConsistentCasingInFileNames: true,
120
+ isolatedModules: true,
121
+ noEmit: true,
122
+ lib: [
123
+ "ES2022",
124
+ "DOM",
125
+ "DOM.Iterable"
126
+ ]
127
+ },
128
+ include: ["src"]
129
+ }, null, 2)
130
+ },
131
+ {
132
+ path: "vite.config.ts",
133
+ content: `import { defineConfig } from "vite";
134
+ import { asyncDomPlugin } from "@lifeart/async-dom/vite-plugin";
135
+
136
+ export default defineConfig({
137
+ plugins: [asyncDomPlugin()],
138
+ });
139
+ `
140
+ }
141
+ ];
142
+ }
143
+ function reactTs(name) {
144
+ return [
145
+ {
146
+ path: "package.json",
147
+ content: JSON.stringify({
148
+ name,
149
+ private: true,
150
+ version: "0.0.0",
151
+ type: "module",
152
+ scripts: {
153
+ dev: "vite",
154
+ build: "tsc && vite build",
155
+ preview: "vite preview"
156
+ },
157
+ dependencies: {
158
+ react: "^19.0.0",
159
+ "react-dom": "^19.0.0"
160
+ },
161
+ devDependencies: {
162
+ "@types/react": "^19.0.0",
163
+ "@types/react-dom": "^19.0.0",
164
+ "@vitejs/plugin-react": "^4.0.0",
165
+ typescript: "^5.8.0",
166
+ vite: "^6.0.0",
167
+ "@lifeart/async-dom": "latest"
168
+ }
169
+ }, null, 2)
170
+ },
171
+ {
172
+ path: "index.html",
173
+ content: `<!DOCTYPE html>
174
+ <html lang="en">
175
+ <head>
176
+ <meta charset="UTF-8" />
177
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
178
+ <title>${escapeHtml(name)}</title>
179
+ </head>
180
+ <body>
181
+ <div id="root"></div>
182
+ <script type="module" src="/src/main.tsx"><\/script>
183
+ </body>
184
+ </html>
185
+ `
186
+ },
187
+ {
188
+ path: "src/main.tsx",
189
+ content: `import { StrictMode } from "react";
190
+ import { createRoot } from "react-dom/client";
191
+ import { App } from "./App";
192
+
193
+ createRoot(document.getElementById("root")!).render(
194
+ <StrictMode>
195
+ <App />
196
+ </StrictMode>,
197
+ );
198
+ `
199
+ },
200
+ {
201
+ path: "src/App.tsx",
202
+ content: `import { AsyncDom } from "@lifeart/async-dom/react";
203
+
204
+ export function App() {
205
+ return (
206
+ <AsyncDom
207
+ worker="./app.worker.ts"
208
+ fallback={<p>Loading...</p>}
209
+ onReady={(instance) => console.log("async-dom ready", instance)}
210
+ />
211
+ );
212
+ }
213
+ `
214
+ },
215
+ {
216
+ path: "src/app.worker.ts",
217
+ content: `import { createWorkerDom } from "@lifeart/async-dom/worker";
218
+
219
+ const { document } = createWorkerDom();
220
+
221
+ const heading = document.createElement("h1");
222
+ heading.textContent = "Hello from async-dom + React!";
223
+ document.body.appendChild(heading);
224
+ `
225
+ },
226
+ {
227
+ path: "src/vite-env.d.ts",
228
+ content: `/// <reference types="vite/client" />
229
+ `
230
+ },
231
+ {
232
+ path: "tsconfig.json",
233
+ content: JSON.stringify({
234
+ compilerOptions: {
235
+ target: "ES2022",
236
+ module: "ESNext",
237
+ moduleResolution: "bundler",
238
+ strict: true,
239
+ esModuleInterop: true,
240
+ skipLibCheck: true,
241
+ forceConsistentCasingInFileNames: true,
242
+ isolatedModules: true,
243
+ noEmit: true,
244
+ jsx: "react-jsx",
245
+ lib: [
246
+ "ES2022",
247
+ "DOM",
248
+ "DOM.Iterable"
249
+ ]
250
+ },
251
+ include: ["src"]
252
+ }, null, 2)
253
+ },
254
+ {
255
+ path: "vite.config.ts",
256
+ content: `import { defineConfig } from "vite";
257
+ import react from "@vitejs/plugin-react";
258
+ import { asyncDomPlugin } from "@lifeart/async-dom/vite-plugin";
259
+
260
+ export default defineConfig({
261
+ plugins: [react(), asyncDomPlugin()],
262
+ });
263
+ `
264
+ }
265
+ ];
266
+ }
267
+ function vueTs(name) {
268
+ return [
269
+ {
270
+ path: "package.json",
271
+ content: JSON.stringify({
272
+ name,
273
+ private: true,
274
+ version: "0.0.0",
275
+ type: "module",
276
+ scripts: {
277
+ dev: "vite",
278
+ build: "vue-tsc && vite build",
279
+ preview: "vite preview"
280
+ },
281
+ dependencies: { vue: "^3.5.0" },
282
+ devDependencies: {
283
+ "@vitejs/plugin-vue": "^5.0.0",
284
+ typescript: "^5.8.0",
285
+ "vue-tsc": "^2.0.0",
286
+ vite: "^6.0.0",
287
+ "@lifeart/async-dom": "latest"
288
+ }
289
+ }, null, 2)
290
+ },
291
+ {
292
+ path: "index.html",
293
+ content: `<!DOCTYPE html>
294
+ <html lang="en">
295
+ <head>
296
+ <meta charset="UTF-8" />
297
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
298
+ <title>${escapeHtml(name)}</title>
299
+ </head>
300
+ <body>
301
+ <div id="app"></div>
302
+ <script type="module" src="/src/main.ts"><\/script>
303
+ </body>
304
+ </html>
305
+ `
306
+ },
307
+ {
308
+ path: "src/main.ts",
309
+ content: `import { createApp } from "vue";
310
+ import App from "./App.vue";
311
+
312
+ createApp(App).mount("#app");
313
+ `
314
+ },
315
+ {
316
+ path: "src/App.vue",
317
+ content: `<script setup lang="ts">
318
+ import { AsyncDom } from "@lifeart/async-dom/vue";
319
+
320
+ function onReady(instance: any) {
321
+ console.log("async-dom ready", instance);
322
+ }
323
+ <\/script>
324
+
325
+ <template>
326
+ <AsyncDom worker="./app.worker.ts" @ready="onReady">
327
+ <template #fallback>
328
+ <p>Loading...</p>
329
+ </template>
330
+ </AsyncDom>
331
+ </template>
332
+ `
333
+ },
334
+ {
335
+ path: "src/app.worker.ts",
336
+ content: `import { createWorkerDom } from "@lifeart/async-dom/worker";
337
+
338
+ const { document } = createWorkerDom();
339
+
340
+ const heading = document.createElement("h1");
341
+ heading.textContent = "Hello from async-dom + Vue!";
342
+ document.body.appendChild(heading);
343
+ `
344
+ },
345
+ {
346
+ path: "src/vite-env.d.ts",
347
+ content: `/// <reference types="vite/client" />
348
+ declare module "*.vue" {
349
+ import type { DefineComponent } from "vue";
350
+ const component: DefineComponent<{}, {}, any>;
351
+ export default component;
352
+ }
353
+ `
354
+ },
355
+ {
356
+ path: "tsconfig.json",
357
+ content: JSON.stringify({
358
+ compilerOptions: {
359
+ target: "ES2022",
360
+ module: "ESNext",
361
+ moduleResolution: "bundler",
362
+ strict: true,
363
+ esModuleInterop: true,
364
+ skipLibCheck: true,
365
+ forceConsistentCasingInFileNames: true,
366
+ isolatedModules: true,
367
+ noEmit: true,
368
+ lib: [
369
+ "ES2022",
370
+ "DOM",
371
+ "DOM.Iterable"
372
+ ]
373
+ },
374
+ include: ["src"]
375
+ }, null, 2)
376
+ },
377
+ {
378
+ path: "vite.config.ts",
379
+ content: `import { defineConfig } from "vite";
380
+ import vue from "@vitejs/plugin-vue";
381
+ import { asyncDomPlugin } from "@lifeart/async-dom/vite-plugin";
382
+
383
+ export default defineConfig({
384
+ plugins: [vue(), asyncDomPlugin()],
385
+ });
386
+ `
387
+ }
388
+ ];
389
+ }
390
+ //#endregion
391
+ //#region src/cli/index.ts
392
+ function ask(question) {
393
+ const rl = readline.createInterface({
394
+ input: process.stdin,
395
+ output: process.stdout
396
+ });
397
+ return new Promise((resolve) => {
398
+ rl.question(question, (answer) => {
399
+ rl.close();
400
+ resolve(answer.trim());
401
+ });
402
+ });
403
+ }
404
+ async function init(args) {
405
+ let name;
406
+ let template = "";
407
+ for (let i = 0; i < args.length; i++) if (args[i] === "--template" && args[i + 1]) {
408
+ template = args[i + 1];
409
+ i++;
410
+ } else if (!args[i].startsWith("-") && !name) name = args[i];
411
+ if (!name) {
412
+ name = await ask("Project name: ");
413
+ if (!name) {
414
+ console.error("Project name is required.");
415
+ process.exit(1);
416
+ }
417
+ }
418
+ if (!template) {
419
+ console.log("\nAvailable templates:");
420
+ for (const t of AVAILABLE_TEMPLATES) console.log(` - ${t}`);
421
+ template = await ask("\nTemplate (default: vanilla-ts): ");
422
+ if (!template) template = "vanilla-ts";
423
+ }
424
+ if (!AVAILABLE_TEMPLATES.includes(template)) {
425
+ console.error(`Unknown template: ${template}. Available: ${AVAILABLE_TEMPLATES.join(", ")}`);
426
+ process.exit(1);
427
+ }
428
+ const targetDir = path.resolve(process.cwd(), name);
429
+ if (fs.existsSync(targetDir)) {
430
+ if (fs.readdirSync(targetDir).length > 0) {
431
+ console.error(`Directory "${name}" already exists and is not empty.`);
432
+ process.exit(1);
433
+ }
434
+ }
435
+ console.log(`\nScaffolding project in ${targetDir}...`);
436
+ const files = getTemplate(template, name);
437
+ for (const file of files) {
438
+ const filePath = path.join(targetDir, file.path);
439
+ const dir = path.dirname(filePath);
440
+ fs.mkdirSync(dir, { recursive: true });
441
+ fs.writeFileSync(filePath, file.content);
442
+ console.log(` created ${file.path}`);
443
+ }
444
+ console.log(`\nDone! Now run:\n`);
445
+ console.log(` cd ${name}`);
446
+ console.log(" npm install");
447
+ console.log(" npm run dev");
448
+ console.log("");
449
+ }
450
+ function printHelp() {
451
+ console.log(`
452
+ @lifeart/async-dom - Asynchronous DOM rendering CLI
453
+
454
+ Usage:
455
+ async-dom init [name] [--template <template>]
456
+
457
+ Commands:
458
+ init Scaffold a new async-dom project
459
+
460
+ Templates:
461
+ ${AVAILABLE_TEMPLATES.join(", ")}
462
+
463
+ Examples:
464
+ npx @lifeart/async-dom init my-app
465
+ npx @lifeart/async-dom init my-app --template react-ts
466
+ `);
467
+ }
468
+ async function main() {
469
+ const args = process.argv.slice(2);
470
+ const command = args[0];
471
+ switch (command) {
472
+ case "init":
473
+ await init(args.slice(1));
474
+ break;
475
+ case "--help":
476
+ case "-h":
477
+ case void 0:
478
+ printHelp();
479
+ break;
480
+ default:
481
+ console.error(`Unknown command: ${command}`);
482
+ printHelp();
483
+ process.exit(1);
484
+ }
485
+ }
486
+ main().catch((err) => {
487
+ console.error(err);
488
+ process.exit(1);
489
+ });
490
+ //#endregion
491
+ export {};
492
+
493
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","names":[],"sources":["../src/cli/templates.ts","../src/cli/index.ts"],"sourcesContent":["/** A file to be written during project scaffolding. */\nexport interface TemplateFile {\n\t/** Relative path from the project root (e.g., \"src/main.ts\"). */\n\tpath: string;\n\t/** The full file content to write. */\n\tcontent: string;\n}\n\n/**\n * Returns the list of files for a given project template.\n *\n * @param template - Template name (one of {@link AVAILABLE_TEMPLATES}).\n * @param name - Project name, used in package.json and HTML title.\n * @returns Array of files to write to disk.\n * @throws If the template name is not recognized.\n */\nexport function getTemplate(template: string, name: string): TemplateFile[] {\n\tswitch (template) {\n\t\tcase \"vanilla-ts\":\n\t\t\treturn vanillaTs(name);\n\t\tcase \"react-ts\":\n\t\t\treturn reactTs(name);\n\t\tcase \"vue-ts\":\n\t\t\treturn vueTs(name);\n\t\tdefault:\n\t\t\tthrow new Error(`Unknown template: ${template}. Available: vanilla-ts, react-ts, vue-ts`);\n\t}\n}\n\n/** The list of available project templates for `async-dom init`. */\nexport const AVAILABLE_TEMPLATES = [\"vanilla-ts\", \"react-ts\", \"vue-ts\"] as const;\n\nfunction escapeHtml(str: string): string {\n\treturn str\n\t\t.replace(/&/g, \"&amp;\")\n\t\t.replace(/</g, \"&lt;\")\n\t\t.replace(/>/g, \"&gt;\")\n\t\t.replace(/\"/g, \"&quot;\");\n}\n\nfunction vanillaTs(name: string): TemplateFile[] {\n\treturn [\n\t\t{\n\t\t\tpath: \"package.json\",\n\t\t\tcontent: JSON.stringify(\n\t\t\t\t{\n\t\t\t\t\tname,\n\t\t\t\t\tprivate: true,\n\t\t\t\t\tversion: \"0.0.0\",\n\t\t\t\t\ttype: \"module\",\n\t\t\t\t\tscripts: {\n\t\t\t\t\t\tdev: \"vite\",\n\t\t\t\t\t\tbuild: \"tsc && vite build\",\n\t\t\t\t\t\tpreview: \"vite preview\",\n\t\t\t\t\t},\n\t\t\t\t\tdevDependencies: {\n\t\t\t\t\t\ttypescript: \"^5.8.0\",\n\t\t\t\t\t\tvite: \"^6.0.0\",\n\t\t\t\t\t\t\"@lifeart/async-dom\": \"latest\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tnull,\n\t\t\t\t2,\n\t\t\t),\n\t\t},\n\t\t{\n\t\t\tpath: \"index.html\",\n\t\t\tcontent: `<!DOCTYPE html>\n<html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <title>${escapeHtml(name)}</title>\n </head>\n <body>\n <div id=\"app\"></div>\n <script type=\"module\" src=\"/src/main.ts\"></script>\n </body>\n</html>\n`,\n\t\t},\n\t\t{\n\t\t\tpath: \"src/main.ts\",\n\t\t\tcontent: `import { createAsyncDom } from \"@lifeart/async-dom\";\n\nconst worker = new Worker(new URL(\"./app.worker.ts\", import.meta.url), {\n type: \"module\",\n});\n\nconst instance = createAsyncDom({\n target: document.getElementById(\"app\")!,\n worker,\n});\n\ninstance.start();\n`,\n\t\t},\n\t\t{\n\t\t\tpath: \"src/app.worker.ts\",\n\t\t\tcontent: `import { createWorkerDom } from \"@lifeart/async-dom/worker\";\n\nconst { document } = createWorkerDom();\n\nconst heading = document.createElement(\"h1\");\nheading.textContent = \"Hello from async-dom!\";\ndocument.body.appendChild(heading);\n\nconst counter = document.createElement(\"button\");\ncounter.textContent = \"Count: 0\";\nlet count = 0;\ncounter.addEventListener(\"click\", () => {\n count++;\n counter.textContent = \\`Count: \\${count}\\`;\n});\ndocument.body.appendChild(counter);\n`,\n\t\t},\n\t\t{\n\t\t\tpath: \"src/vite-env.d.ts\",\n\t\t\tcontent: `/// <reference types=\"vite/client\" />\n`,\n\t\t},\n\t\t{\n\t\t\tpath: \"tsconfig.json\",\n\t\t\tcontent: JSON.stringify(\n\t\t\t\t{\n\t\t\t\t\tcompilerOptions: {\n\t\t\t\t\t\ttarget: \"ES2022\",\n\t\t\t\t\t\tmodule: \"ESNext\",\n\t\t\t\t\t\tmoduleResolution: \"bundler\",\n\t\t\t\t\t\tstrict: true,\n\t\t\t\t\t\tesModuleInterop: true,\n\t\t\t\t\t\tskipLibCheck: true,\n\t\t\t\t\t\tforceConsistentCasingInFileNames: true,\n\t\t\t\t\t\tisolatedModules: true,\n\t\t\t\t\t\tnoEmit: true,\n\t\t\t\t\t\tlib: [\"ES2022\", \"DOM\", \"DOM.Iterable\"],\n\t\t\t\t\t},\n\t\t\t\t\tinclude: [\"src\"],\n\t\t\t\t},\n\t\t\t\tnull,\n\t\t\t\t2,\n\t\t\t),\n\t\t},\n\t\t{\n\t\t\tpath: \"vite.config.ts\",\n\t\t\tcontent: `import { defineConfig } from \"vite\";\nimport { asyncDomPlugin } from \"@lifeart/async-dom/vite-plugin\";\n\nexport default defineConfig({\n plugins: [asyncDomPlugin()],\n});\n`,\n\t\t},\n\t];\n}\n\nfunction reactTs(name: string): TemplateFile[] {\n\treturn [\n\t\t{\n\t\t\tpath: \"package.json\",\n\t\t\tcontent: JSON.stringify(\n\t\t\t\t{\n\t\t\t\t\tname,\n\t\t\t\t\tprivate: true,\n\t\t\t\t\tversion: \"0.0.0\",\n\t\t\t\t\ttype: \"module\",\n\t\t\t\t\tscripts: {\n\t\t\t\t\t\tdev: \"vite\",\n\t\t\t\t\t\tbuild: \"tsc && vite build\",\n\t\t\t\t\t\tpreview: \"vite preview\",\n\t\t\t\t\t},\n\t\t\t\t\tdependencies: {\n\t\t\t\t\t\treact: \"^19.0.0\",\n\t\t\t\t\t\t\"react-dom\": \"^19.0.0\",\n\t\t\t\t\t},\n\t\t\t\t\tdevDependencies: {\n\t\t\t\t\t\t\"@types/react\": \"^19.0.0\",\n\t\t\t\t\t\t\"@types/react-dom\": \"^19.0.0\",\n\t\t\t\t\t\t\"@vitejs/plugin-react\": \"^4.0.0\",\n\t\t\t\t\t\ttypescript: \"^5.8.0\",\n\t\t\t\t\t\tvite: \"^6.0.0\",\n\t\t\t\t\t\t\"@lifeart/async-dom\": \"latest\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tnull,\n\t\t\t\t2,\n\t\t\t),\n\t\t},\n\t\t{\n\t\t\tpath: \"index.html\",\n\t\t\tcontent: `<!DOCTYPE html>\n<html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <title>${escapeHtml(name)}</title>\n </head>\n <body>\n <div id=\"root\"></div>\n <script type=\"module\" src=\"/src/main.tsx\"></script>\n </body>\n</html>\n`,\n\t\t},\n\t\t{\n\t\t\tpath: \"src/main.tsx\",\n\t\t\tcontent: `import { StrictMode } from \"react\";\nimport { createRoot } from \"react-dom/client\";\nimport { App } from \"./App\";\n\ncreateRoot(document.getElementById(\"root\")!).render(\n <StrictMode>\n <App />\n </StrictMode>,\n);\n`,\n\t\t},\n\t\t{\n\t\t\tpath: \"src/App.tsx\",\n\t\t\tcontent: `import { AsyncDom } from \"@lifeart/async-dom/react\";\n\nexport function App() {\n return (\n <AsyncDom\n worker=\"./app.worker.ts\"\n fallback={<p>Loading...</p>}\n onReady={(instance) => console.log(\"async-dom ready\", instance)}\n />\n );\n}\n`,\n\t\t},\n\t\t{\n\t\t\tpath: \"src/app.worker.ts\",\n\t\t\tcontent: `import { createWorkerDom } from \"@lifeart/async-dom/worker\";\n\nconst { document } = createWorkerDom();\n\nconst heading = document.createElement(\"h1\");\nheading.textContent = \"Hello from async-dom + React!\";\ndocument.body.appendChild(heading);\n`,\n\t\t},\n\t\t{\n\t\t\tpath: \"src/vite-env.d.ts\",\n\t\t\tcontent: `/// <reference types=\"vite/client\" />\n`,\n\t\t},\n\t\t{\n\t\t\tpath: \"tsconfig.json\",\n\t\t\tcontent: JSON.stringify(\n\t\t\t\t{\n\t\t\t\t\tcompilerOptions: {\n\t\t\t\t\t\ttarget: \"ES2022\",\n\t\t\t\t\t\tmodule: \"ESNext\",\n\t\t\t\t\t\tmoduleResolution: \"bundler\",\n\t\t\t\t\t\tstrict: true,\n\t\t\t\t\t\tesModuleInterop: true,\n\t\t\t\t\t\tskipLibCheck: true,\n\t\t\t\t\t\tforceConsistentCasingInFileNames: true,\n\t\t\t\t\t\tisolatedModules: true,\n\t\t\t\t\t\tnoEmit: true,\n\t\t\t\t\t\tjsx: \"react-jsx\",\n\t\t\t\t\t\tlib: [\"ES2022\", \"DOM\", \"DOM.Iterable\"],\n\t\t\t\t\t},\n\t\t\t\t\tinclude: [\"src\"],\n\t\t\t\t},\n\t\t\t\tnull,\n\t\t\t\t2,\n\t\t\t),\n\t\t},\n\t\t{\n\t\t\tpath: \"vite.config.ts\",\n\t\t\tcontent: `import { defineConfig } from \"vite\";\nimport react from \"@vitejs/plugin-react\";\nimport { asyncDomPlugin } from \"@lifeart/async-dom/vite-plugin\";\n\nexport default defineConfig({\n plugins: [react(), asyncDomPlugin()],\n});\n`,\n\t\t},\n\t];\n}\n\nfunction vueTs(name: string): TemplateFile[] {\n\treturn [\n\t\t{\n\t\t\tpath: \"package.json\",\n\t\t\tcontent: JSON.stringify(\n\t\t\t\t{\n\t\t\t\t\tname,\n\t\t\t\t\tprivate: true,\n\t\t\t\t\tversion: \"0.0.0\",\n\t\t\t\t\ttype: \"module\",\n\t\t\t\t\tscripts: {\n\t\t\t\t\t\tdev: \"vite\",\n\t\t\t\t\t\tbuild: \"vue-tsc && vite build\",\n\t\t\t\t\t\tpreview: \"vite preview\",\n\t\t\t\t\t},\n\t\t\t\t\tdependencies: {\n\t\t\t\t\t\tvue: \"^3.5.0\",\n\t\t\t\t\t},\n\t\t\t\t\tdevDependencies: {\n\t\t\t\t\t\t\"@vitejs/plugin-vue\": \"^5.0.0\",\n\t\t\t\t\t\ttypescript: \"^5.8.0\",\n\t\t\t\t\t\t\"vue-tsc\": \"^2.0.0\",\n\t\t\t\t\t\tvite: \"^6.0.0\",\n\t\t\t\t\t\t\"@lifeart/async-dom\": \"latest\",\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tnull,\n\t\t\t\t2,\n\t\t\t),\n\t\t},\n\t\t{\n\t\t\tpath: \"index.html\",\n\t\t\tcontent: `<!DOCTYPE html>\n<html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\" />\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" />\n <title>${escapeHtml(name)}</title>\n </head>\n <body>\n <div id=\"app\"></div>\n <script type=\"module\" src=\"/src/main.ts\"></script>\n </body>\n</html>\n`,\n\t\t},\n\t\t{\n\t\t\tpath: \"src/main.ts\",\n\t\t\tcontent: `import { createApp } from \"vue\";\nimport App from \"./App.vue\";\n\ncreateApp(App).mount(\"#app\");\n`,\n\t\t},\n\t\t{\n\t\t\tpath: \"src/App.vue\",\n\t\t\tcontent: `<script setup lang=\"ts\">\nimport { AsyncDom } from \"@lifeart/async-dom/vue\";\n\nfunction onReady(instance: any) {\n console.log(\"async-dom ready\", instance);\n}\n</script>\n\n<template>\n <AsyncDom worker=\"./app.worker.ts\" @ready=\"onReady\">\n <template #fallback>\n <p>Loading...</p>\n </template>\n </AsyncDom>\n</template>\n`,\n\t\t},\n\t\t{\n\t\t\tpath: \"src/app.worker.ts\",\n\t\t\tcontent: `import { createWorkerDom } from \"@lifeart/async-dom/worker\";\n\nconst { document } = createWorkerDom();\n\nconst heading = document.createElement(\"h1\");\nheading.textContent = \"Hello from async-dom + Vue!\";\ndocument.body.appendChild(heading);\n`,\n\t\t},\n\t\t{\n\t\t\tpath: \"src/vite-env.d.ts\",\n\t\t\tcontent: `/// <reference types=\"vite/client\" />\ndeclare module \"*.vue\" {\n import type { DefineComponent } from \"vue\";\n const component: DefineComponent<{}, {}, any>;\n export default component;\n}\n`,\n\t\t},\n\t\t{\n\t\t\tpath: \"tsconfig.json\",\n\t\t\tcontent: JSON.stringify(\n\t\t\t\t{\n\t\t\t\t\tcompilerOptions: {\n\t\t\t\t\t\ttarget: \"ES2022\",\n\t\t\t\t\t\tmodule: \"ESNext\",\n\t\t\t\t\t\tmoduleResolution: \"bundler\",\n\t\t\t\t\t\tstrict: true,\n\t\t\t\t\t\tesModuleInterop: true,\n\t\t\t\t\t\tskipLibCheck: true,\n\t\t\t\t\t\tforceConsistentCasingInFileNames: true,\n\t\t\t\t\t\tisolatedModules: true,\n\t\t\t\t\t\tnoEmit: true,\n\t\t\t\t\t\tlib: [\"ES2022\", \"DOM\", \"DOM.Iterable\"],\n\t\t\t\t\t},\n\t\t\t\t\tinclude: [\"src\"],\n\t\t\t\t},\n\t\t\t\tnull,\n\t\t\t\t2,\n\t\t\t),\n\t\t},\n\t\t{\n\t\t\tpath: \"vite.config.ts\",\n\t\t\tcontent: `import { defineConfig } from \"vite\";\nimport vue from \"@vitejs/plugin-vue\";\nimport { asyncDomPlugin } from \"@lifeart/async-dom/vite-plugin\";\n\nexport default defineConfig({\n plugins: [vue(), asyncDomPlugin()],\n});\n`,\n\t\t},\n\t];\n}\n","import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\nimport * as readline from \"node:readline\";\nimport { AVAILABLE_TEMPLATES, getTemplate } from \"./templates.ts\";\n\nfunction ask(question: string): Promise<string> {\n\tconst rl = readline.createInterface({\n\t\tinput: process.stdin,\n\t\toutput: process.stdout,\n\t});\n\treturn new Promise((resolve) => {\n\t\trl.question(question, (answer) => {\n\t\t\trl.close();\n\t\t\tresolve(answer.trim());\n\t\t});\n\t});\n}\n\nasync function init(args: string[]): Promise<void> {\n\tlet name: string | undefined;\n\tlet template = \"\";\n\n\t// Parse flags\n\tfor (let i = 0; i < args.length; i++) {\n\t\tif (args[i] === \"--template\" && args[i + 1]) {\n\t\t\ttemplate = args[i + 1];\n\t\t\ti++;\n\t\t} else if (!args[i].startsWith(\"-\") && !name) {\n\t\t\tname = args[i];\n\t\t}\n\t}\n\n\t// Interactive prompts for missing values\n\tif (!name) {\n\t\tname = await ask(\"Project name: \");\n\t\tif (!name) {\n\t\t\tconsole.error(\"Project name is required.\");\n\t\t\tprocess.exit(1);\n\t\t}\n\t}\n\n\tif (!template) {\n\t\tconsole.log(\"\\nAvailable templates:\");\n\t\tfor (const t of AVAILABLE_TEMPLATES) {\n\t\t\tconsole.log(` - ${t}`);\n\t\t}\n\t\ttemplate = await ask(\"\\nTemplate (default: vanilla-ts): \");\n\t\tif (!template) template = \"vanilla-ts\";\n\t}\n\n\t// Validate template\n\tif (!AVAILABLE_TEMPLATES.includes(template as (typeof AVAILABLE_TEMPLATES)[number])) {\n\t\tconsole.error(`Unknown template: ${template}. Available: ${AVAILABLE_TEMPLATES.join(\", \")}`);\n\t\tprocess.exit(1);\n\t}\n\n\tconst targetDir = path.resolve(process.cwd(), name);\n\n\tif (fs.existsSync(targetDir)) {\n\t\tconst contents = fs.readdirSync(targetDir);\n\t\tif (contents.length > 0) {\n\t\t\tconsole.error(`Directory \"${name}\" already exists and is not empty.`);\n\t\t\tprocess.exit(1);\n\t\t}\n\t}\n\n\tconsole.log(`\\nScaffolding project in ${targetDir}...`);\n\n\tconst files = getTemplate(template, name);\n\n\tfor (const file of files) {\n\t\tconst filePath = path.join(targetDir, file.path);\n\t\tconst dir = path.dirname(filePath);\n\t\tfs.mkdirSync(dir, { recursive: true });\n\t\tfs.writeFileSync(filePath, file.content);\n\t\tconsole.log(` created ${file.path}`);\n\t}\n\n\tconsole.log(`\\nDone! Now run:\\n`);\n\tconsole.log(` cd ${name}`);\n\tconsole.log(\" npm install\");\n\tconsole.log(\" npm run dev\");\n\tconsole.log(\"\");\n}\n\nfunction printHelp(): void {\n\tconsole.log(`\n@lifeart/async-dom - Asynchronous DOM rendering CLI\n\nUsage:\n async-dom init [name] [--template <template>]\n\nCommands:\n init Scaffold a new async-dom project\n\nTemplates:\n ${AVAILABLE_TEMPLATES.join(\", \")}\n\nExamples:\n npx @lifeart/async-dom init my-app\n npx @lifeart/async-dom init my-app --template react-ts\n`);\n}\n\nasync function main(): Promise<void> {\n\tconst args = process.argv.slice(2);\n\tconst command = args[0];\n\n\tswitch (command) {\n\t\tcase \"init\":\n\t\t\tawait init(args.slice(1));\n\t\t\tbreak;\n\t\tcase \"--help\":\n\t\tcase \"-h\":\n\t\tcase undefined:\n\t\t\tprintHelp();\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tconsole.error(`Unknown command: ${command}`);\n\t\t\tprintHelp();\n\t\t\tprocess.exit(1);\n\t}\n}\n\nmain().catch((err) => {\n\tconsole.error(err);\n\tprocess.exit(1);\n});\n"],"mappings":";;;;;;;;;;;;AAgBA,SAAgB,YAAY,UAAkB,MAA8B;AAC3E,SAAQ,UAAR;EACC,KAAK,aACJ,QAAO,UAAU,KAAK;EACvB,KAAK,WACJ,QAAO,QAAQ,KAAK;EACrB,KAAK,SACJ,QAAO,MAAM,KAAK;EACnB,QACC,OAAM,IAAI,MAAM,qBAAqB,SAAS,2CAA2C;;;;AAK5F,MAAa,sBAAsB;CAAC;CAAc;CAAY;CAAS;AAEvE,SAAS,WAAW,KAAqB;AACxC,QAAO,IACL,QAAQ,MAAM,QAAQ,CACtB,QAAQ,MAAM,OAAO,CACrB,QAAQ,MAAM,OAAO,CACrB,QAAQ,MAAM,SAAS;;AAG1B,SAAS,UAAU,MAA8B;AAChD,QAAO;EACN;GACC,MAAM;GACN,SAAS,KAAK,UACb;IACC;IACA,SAAS;IACT,SAAS;IACT,MAAM;IACN,SAAS;KACR,KAAK;KACL,OAAO;KACP,SAAS;KACT;IACD,iBAAiB;KAChB,YAAY;KACZ,MAAM;KACN,sBAAsB;KACtB;IACD,EACD,MACA,EACA;GACD;EACD;GACC,MAAM;GACN,SAAS;;;;;aAKC,WAAW,KAAK,CAAC;;;;;;;;GAQ3B;EACD;GACC,MAAM;GACN,SAAS;;;;;;;;;;;;;GAaT;EACD;GACC,MAAM;GACN,SAAS;;;;;;;;;;;;;;;;;GAiBT;EACD;GACC,MAAM;GACN,SAAS;;GAET;EACD;GACC,MAAM;GACN,SAAS,KAAK,UACb;IACC,iBA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M,OAAO,QAAQ,KAAK,MAAM,EAAE;CAClC,MAAM,UAAU,KAAK;AAErB,SAAQ,SAAR;EACC,KAAK;AACJ,SAAM,KAAK,KAAK,MAAM,EAAE,CAAC;AACzB;EACD,KAAK;EACL,KAAK;EACL,KAAK,KAAA;AACJ,cAAW;AACX;EACD;AACC,WAAQ,MAAM,oBAAoB,UAAU;AAC5C,cAAW;AACX,WAAQ,KAAK,EAAE;;;AAIlB,MAAM,CAAC,OAAO,QAAQ;AACrB,SAAQ,MAAM,IAAI;AAClB,SAAQ,KAAK,EAAE;EACd"}
@@ -0,0 +1,145 @@
1
+ import { c as DomMutation } from "./base.cjs";
2
+
3
+ //#region src/core/debug.d.ts
4
+
5
+ /**
6
+ * Options for enabling debug logging and the in-page devtools panel.
7
+ *
8
+ * Each `log*` flag enables a category of structured log output. Provide a
9
+ * custom `logger` to redirect output (e.g. to a remote telemetry service).
10
+ */
11
+ interface DebugOptions {
12
+ /** Log every DOM mutation applied by the renderer. */
13
+ logMutations?: boolean;
14
+ /** Log event serialization and dispatch timing. */
15
+ logEvents?: boolean;
16
+ /** Log synchronous DOM read requests (getBoundingClientRect, computedStyle, etc.). */
17
+ logSyncReads?: boolean;
18
+ /** Log per-frame scheduler statistics (actions processed, frame time, queue depth). */
19
+ logScheduler?: boolean;
20
+ /** Log warnings such as missing nodes, sync timeouts, and blocked properties. */
21
+ logWarnings?: boolean;
22
+ /** Custom logger implementation. Unset methods fall back to `console.*`. */
23
+ logger?: Partial<DebugLogger>;
24
+ /** Expose `__ASYNC_DOM_DEVTOOLS__` on `globalThis` and inject the in-page devtools panel. */
25
+ exposeDevtools?: boolean;
26
+ }
27
+ /**
28
+ * Custom logger that receives structured debug entries.
29
+ *
30
+ * Implement any subset of these methods and pass via `DebugOptions.logger`.
31
+ */
32
+ interface DebugLogger {
33
+ /** Called for each DOM mutation applied on the main thread. */
34
+ mutation(entry: MutationLogEntry): void;
35
+ /** Called for event serialization and dispatch timing. */
36
+ event(entry: EventLogEntry): void;
37
+ /** Called for each synchronous DOM read request. */
38
+ syncRead(entry: SyncReadLogEntry): void;
39
+ /** Called once per scheduler frame with aggregate statistics. */
40
+ scheduler(entry: SchedulerLogEntry): void;
41
+ /** Called for async-dom warnings (missing nodes, timeouts, etc.). */
42
+ warning(entry: WarningLogEntry): void;
43
+ }
44
+ /** A single DOM mutation log entry emitted by the debug system. */
45
+ interface MutationLogEntry {
46
+ /** Which thread generated this entry. */
47
+ side: "worker" | "main";
48
+ /** The mutation action name (e.g. "createElement", "setAttribute"). */
49
+ action: string;
50
+ /** The full mutation payload. */
51
+ mutation: DomMutation;
52
+ /** High-resolution timestamp (via `performance.now()`). */
53
+ timestamp: number;
54
+ /** Batch UID that groups related mutations from a single flush. */
55
+ batchUid?: number;
56
+ }
57
+ /** A single event timing log entry emitted by the debug system. */
58
+ interface EventLogEntry {
59
+ /** Which thread generated this entry. */
60
+ side: "worker" | "main";
61
+ /** Whether this captures serialization or dispatch timing. */
62
+ phase: "serialize" | "dispatch";
63
+ /** The DOM event type (e.g. "click", "input"). */
64
+ eventType: string;
65
+ /** Unique listener identifier. */
66
+ listenerId: string;
67
+ /** Node ID of the event target, or `null` if unavailable. */
68
+ targetId: string | null;
69
+ /** High-resolution timestamp (via `performance.now()`). */
70
+ timestamp: number;
71
+ /** Time in ms the event spent in transport between threads. */
72
+ transportMs?: number;
73
+ /** Time in ms the worker spent dispatching the event handler. */
74
+ dispatchMs?: number;
75
+ /** Number of DOM mutations produced by the event handler. */
76
+ mutationCount?: number;
77
+ }
78
+ /** A single synchronous DOM read log entry. */
79
+ interface SyncReadLogEntry {
80
+ /** The query type enum value (BoundingRect, ComputedStyle, etc.). */
81
+ queryType: number;
82
+ /** The target node ID as a string. */
83
+ nodeId: string;
84
+ /** Round-trip latency in milliseconds. */
85
+ latencyMs: number;
86
+ /** Whether the read succeeded, timed out, or threw an error. */
87
+ result: "success" | "timeout" | "error";
88
+ /** High-resolution timestamp (via `performance.now()`). */
89
+ timestamp: number;
90
+ }
91
+ /** A single scheduler frame log entry. */
92
+ interface SchedulerLogEntry {
93
+ /** Monotonically increasing frame counter. */
94
+ frameId: number;
95
+ /** Number of mutations processed in this frame. */
96
+ actionsProcessed: number;
97
+ /** Total wall-clock time spent processing this frame in ms. */
98
+ frameTimeMs: number;
99
+ /** Number of mutations remaining in the queue after this frame. */
100
+ queueDepth: number;
101
+ /** High-resolution timestamp (via `performance.now()`). */
102
+ timestamp: number;
103
+ }
104
+ /** A warning entry emitted when async-dom detects a potential problem. */
105
+ interface WarningLogEntry {
106
+ /** Machine-readable warning code (see `WarningCode`). */
107
+ code: string;
108
+ /** Human-readable description of the problem. */
109
+ message: string;
110
+ /** Additional context data relevant to the warning. */
111
+ context: Record<string, unknown>;
112
+ /** High-resolution timestamp (via `performance.now()`). */
113
+ timestamp: number;
114
+ }
115
+ declare const WarningCode: {
116
+ readonly MISSING_NODE: "ASYNC_DOM_MISSING_NODE";
117
+ readonly SYNC_TIMEOUT: "ASYNC_DOM_SYNC_TIMEOUT";
118
+ readonly LISTENER_NOT_FOUND: "ASYNC_DOM_LISTENER_NOT_FOUND";
119
+ readonly EVENT_ATTACH_FAILED: "ASYNC_DOM_EVENT_ATTACH_FAILED";
120
+ readonly TRANSPORT_NOT_OPEN: "ASYNC_DOM_TRANSPORT_NOT_OPEN";
121
+ readonly BLOCKED_PROPERTY: "ASYNC_DOM_BLOCKED_PROPERTY";
122
+ readonly WORKER_ERROR: "WORKER_ERROR";
123
+ readonly WORKER_UNHANDLED_REJECTION: "WORKER_UNHANDLED_REJECTION";
124
+ };
125
+ declare class DebugStats {
126
+ mutationsAdded: number;
127
+ mutationsCoalesced: number;
128
+ mutationsFlushed: number;
129
+ mutationsApplied: number;
130
+ eventsForwarded: number;
131
+ eventsDispatched: number;
132
+ syncReadRequests: number;
133
+ syncReadTimeouts: number;
134
+ snapshot(): Record<string, number>;
135
+ reset(): void;
136
+ }
137
+ /**
138
+ * Mutation-to-event correlation index (Feature 19: "Why Was This Node Updated?").
139
+ *
140
+ * Indexes mutations by nodeId and links them to their batch and causal event,
141
+ * allowing reverse lookups: given a nodeId, find why it was updated.
142
+ */
143
+ //#endregion
144
+ export { MutationLogEntry as a, WarningCode as c, EventLogEntry as i, WarningLogEntry as l, DebugOptions as n, SchedulerLogEntry as o, DebugStats as r, SyncReadLogEntry as s, DebugLogger as t };
145
+ //# sourceMappingURL=debug.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debug.d.cts","names":[],"sources":["../src/core/debug.ts"],"sourcesContent":[],"mappings":";;;;;;AAQA;;;;AAYiB,UAZA,YAAA,CAYA;EAUA;EAAW,YAAA,CAAA,EAAA,OAAA;;WAId,CAAA,EAAA,OAAA;;cAII,CAAA,EAAA,OAAA;;EAEa,YAAA,CAAA,EAAA,OAAA;EAId;EAcA,WAAA,CAAA,EAAA,OAAa;EAsBb;EAcA,MAAA,CAAA,EA1EP,OA0EO,CA1EC,WA0EgB,CAAA;EAcjB;EAWJ,cASH,CAAA,EAAA,OAAA;AAsEV;;;;;;UAxKiB,WAAA;;kBAEA;;eAEH;;kBAEG;;mBAEC;;iBAEF;;;UAIC,gBAAA;;;;;;YAMN;;;;;;;UAQM,aAAA;;;;;;;;;;;;;;;;;;;;;UAsBA,gBAAA;;;;;;;;;;;;;UAcA,iBAAA;;;;;;;;;;;;;UAcA,eAAA;;;;;;WAMP;;;;cAKG;;;;;;;;;;cA+EA,UAAA;;;;;;;;;cAUA"}