@kudzujs/core 0.17.14 → 0.17.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 +1 -1
- package/framework/build.mjs +2 -2
- package/framework/dev-server.mjs +37 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ Kudzu compiles ordinary React-shaped TypeScript and TSX into complete static HTM
|
|
|
14
14
|
|
|
15
15
|
> Experimental `0.17.x`: the compiler API and supported TSX surface may change.
|
|
16
16
|
|
|
17
|
-
**Current release: [0.17.
|
|
17
|
+
**Current release: [0.17.16](https://github.com/kudzujs/kudzu/releases/tag/v0.17.16).** This evidence release records real renderer-crash and heartbeat handoff checks against pinned Actual Budget. A separate upstream spreadsheet patch handles rejected reads, reports one visible warning, and preserves uncertain mutation outcomes without replay. The patch is retained as migration evidence, not installed into Kudzu or submitted upstream. Generator `create-kudzu@0.1.173` retains its compatible core `^0.17.12` range. No compiler or browser runtime changes.
|
|
18
18
|
|
|
19
19
|
- [Documentation](https://kudzujs.cloud/docs)
|
|
20
20
|
- [Installation guide](https://kudzujs.cloud/docs#install)
|
package/framework/build.mjs
CHANGED
|
@@ -600,7 +600,7 @@ async function buildInto(project, outputDirectory, { changedFiles, minify, quiet
|
|
|
600
600
|
|
|
601
601
|
const incremental = { compiledModules, renderedPages }
|
|
602
602
|
return {
|
|
603
|
-
result: { sourceResults, incremental },
|
|
603
|
+
result: { sourceResults, incremental, base, publicDirectory },
|
|
604
604
|
inspectionData: { sourceFiles: sourceFiles.map(file => relative(root, file).replaceAll(sep, "/")), sourceResults, compatibility, artifacts },
|
|
605
605
|
explanation,
|
|
606
606
|
htmlSummary,
|
|
@@ -936,7 +936,7 @@ export async function dev({ port = parseDevPort(process.env.PORT), host = parseD
|
|
|
936
936
|
const config = await loadConfig(root)
|
|
937
937
|
const base = normalizeBase(config.base)
|
|
938
938
|
const publicDirectory = normalizePublicDirectory(config.publicDir, project)
|
|
939
|
-
return startDevServer({ build: options => buildWithSession(project, options), port, host, base, sourceDirectory, publicDirectory, workDirectory, outputDirectory })
|
|
939
|
+
return startDevServer({ build: options => buildWithSession(project, options), port, host, base, root, sourceDirectory, publicDirectory, workDirectory, outputDirectory })
|
|
940
940
|
}
|
|
941
941
|
|
|
942
942
|
function inlineJson(value) {
|
package/framework/dev-server.mjs
CHANGED
|
@@ -19,12 +19,19 @@ export function parseDevHost(value) {
|
|
|
19
19
|
return value?.trim() || "127.0.0.1"
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export async function startDevServer({ build, port, host, base, sourceDirectory, publicDirectory, workDirectory, outputDirectory }) {
|
|
22
|
+
export async function startDevServer({ build, port, host, base, root, sourceDirectory, publicDirectory, workDirectory, outputDirectory }) {
|
|
23
23
|
let buildError
|
|
24
24
|
let revision = 0
|
|
25
|
+
let watchController
|
|
26
|
+
const rebuildOutput = async options => {
|
|
27
|
+
const result = await build(options)
|
|
28
|
+
base = result.base
|
|
29
|
+
if (publicDirectory !== result.publicDirectory) watchController?.abort()
|
|
30
|
+
publicDirectory = result.publicDirectory
|
|
31
|
+
}
|
|
25
32
|
const session = randomUUID()
|
|
26
33
|
try {
|
|
27
|
-
await
|
|
34
|
+
await rebuildOutput({ minify: false })
|
|
28
35
|
revision++
|
|
29
36
|
} catch (error) {
|
|
30
37
|
buildError = errorText(error)
|
|
@@ -97,7 +104,7 @@ export async function startDevServer({ build, port, host, base, sourceDirectory,
|
|
|
97
104
|
const changes = [...changedFiles]
|
|
98
105
|
changedFiles.clear()
|
|
99
106
|
try {
|
|
100
|
-
await
|
|
107
|
+
await rebuildOutput({ changedFiles: changes, quiet: true, minify: false })
|
|
101
108
|
buildError = undefined
|
|
102
109
|
revision++
|
|
103
110
|
console.log(`Rebuilt after ${changedFile ?? "source change"}`)
|
|
@@ -111,17 +118,35 @@ export async function startDevServer({ build, port, host, base, sourceDirectory,
|
|
|
111
118
|
} while (pending)
|
|
112
119
|
rebuilding = false
|
|
113
120
|
}
|
|
114
|
-
const
|
|
115
|
-
await Promise.all(directories.map(directory => watchDirectory(directory, file => {
|
|
121
|
+
const changed = file => {
|
|
116
122
|
changedFile = file
|
|
117
123
|
changedFiles.add(file)
|
|
118
124
|
clearTimeout(timer)
|
|
119
125
|
timer = setTimeout(rebuild, 80)
|
|
120
|
-
}
|
|
126
|
+
}
|
|
127
|
+
for (;;) {
|
|
128
|
+
watchController = new AbortController()
|
|
129
|
+
const { signal } = watchController
|
|
130
|
+
const directories = publicDirectory === sourceDirectory || publicDirectory.startsWith(`${sourceDirectory}${sep}`) ? [sourceDirectory] : [sourceDirectory, publicDirectory]
|
|
131
|
+
await Promise.all([
|
|
132
|
+
...directories.map(directory => watchDirectory(directory, changed, signal)),
|
|
133
|
+
watchConfig(root, changed, signal)
|
|
134
|
+
])
|
|
135
|
+
}
|
|
121
136
|
}
|
|
122
137
|
|
|
123
|
-
async function
|
|
124
|
-
|
|
138
|
+
async function watchConfig(root, changed, signal) {
|
|
139
|
+
try {
|
|
140
|
+
for await (const event of watch(root, { signal })) {
|
|
141
|
+
if (event.filename == null || ["kudzu.config.mjs", "kudzu.config.js"].includes(event.filename)) changed(event.filename == null ? undefined : resolve(root, event.filename))
|
|
142
|
+
}
|
|
143
|
+
} catch (error) {
|
|
144
|
+
if (error.name !== "AbortError") throw error
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
async function watchDirectory(directory, changed, signal) {
|
|
149
|
+
while (!signal.aborted) {
|
|
125
150
|
let ancestor = dirname(directory)
|
|
126
151
|
let missing
|
|
127
152
|
while (!await exists(ancestor)) {
|
|
@@ -129,6 +154,9 @@ async function watchDirectory(directory, changed) {
|
|
|
129
154
|
ancestor = dirname(ancestor)
|
|
130
155
|
}
|
|
131
156
|
const controller = new AbortController()
|
|
157
|
+
const abort = () => controller.abort()
|
|
158
|
+
signal.addEventListener("abort", abort, { once: true })
|
|
159
|
+
if (signal.aborted) controller.abort()
|
|
132
160
|
try {
|
|
133
161
|
// A parent watch detects replacement even when the directory is recreated before stat().
|
|
134
162
|
const observe = async (root, recursive) => {
|
|
@@ -150,6 +178,7 @@ async function watchDirectory(directory, changed) {
|
|
|
150
178
|
} catch (error) {
|
|
151
179
|
if (error.code !== "ENOENT" && error.name !== "AbortError") throw error
|
|
152
180
|
} finally {
|
|
181
|
+
signal.removeEventListener("abort", abort)
|
|
153
182
|
controller.abort()
|
|
154
183
|
}
|
|
155
184
|
}
|