@kudzujs/core 0.17.13 → 0.17.15
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/framework/jsx-runtime.d.ts +10 -0
- 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.15](https://github.com/kudzujs/kudzu/releases/tag/v0.17.15).** The development server rebuilds when `kudzu.config.mjs` or `kudzu.config.js` is created, changed, or deleted. Successful builds synchronize `base` and public-directory watchers; failed builds retain the previous serving paths. Generator `create-kudzu@0.1.173` retains its compatible core `^0.17.12` range. No browser runtime or compiler syntax 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
|
}
|
|
@@ -16,10 +16,20 @@ export namespace JSX {
|
|
|
16
16
|
onBlur?: (event: TargetedEvent<Target, FocusEvent>) => unknown
|
|
17
17
|
onChange?: (event: TargetedEvent<Target>) => unknown
|
|
18
18
|
onClick?: (event: TargetedEvent<Target, MouseEvent>) => unknown
|
|
19
|
+
onCompositionStart?: (event: TargetedEvent<Target, CompositionEvent>) => unknown
|
|
20
|
+
onCompositionEnd?: (event: TargetedEvent<Target, CompositionEvent>) => unknown
|
|
21
|
+
onDrop?: (event: TargetedEvent<Target, DragEvent>) => unknown
|
|
19
22
|
onFocus?: (event: TargetedEvent<Target, FocusEvent>) => unknown
|
|
20
23
|
onInput?: (event: TargetedEvent<Target, InputEvent>) => unknown
|
|
21
24
|
onKeyDown?: (event: TargetedEvent<Target, KeyboardEvent>) => unknown
|
|
22
25
|
onKeyUp?: (event: TargetedEvent<Target, KeyboardEvent>) => unknown
|
|
26
|
+
onMouseEnter?: (event: TargetedEvent<Target, MouseEvent>) => unknown
|
|
27
|
+
onMouseLeave?: (event: TargetedEvent<Target, MouseEvent>) => unknown
|
|
28
|
+
onPaste?: (event: TargetedEvent<Target, ClipboardEvent>) => unknown
|
|
29
|
+
onPointerDown?: (event: TargetedEvent<Target, PointerEvent>) => unknown
|
|
30
|
+
onPointerMove?: (event: TargetedEvent<Target, PointerEvent>) => unknown
|
|
31
|
+
onPointerUp?: (event: TargetedEvent<Target, PointerEvent>) => unknown
|
|
32
|
+
onScroll?: (event: TargetedEvent<Target>) => unknown
|
|
23
33
|
onSubmit?: (event: TargetedEvent<Target, SubmitEvent>) => unknown
|
|
24
34
|
}
|
|
25
35
|
|