kiru 1.0.1 → 1.1.0
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/dist/appHandle.js +2 -2
- package/dist/appHandle.js.map +1 -1
- package/dist/components/lazy.d.ts.map +1 -1
- package/dist/components/lazy.js +2 -2
- package/dist/components/lazy.js.map +1 -1
- package/dist/components/transition.js +1 -5
- package/dist/components/transition.js.map +1 -1
- package/dist/devtools.d.ts.map +1 -1
- package/dist/devtools.js +6 -2
- package/dist/devtools.js.map +1 -1
- package/dist/dom/commit.d.ts +5 -0
- package/dist/dom/commit.d.ts.map +1 -0
- package/dist/dom/commit.js +94 -0
- package/dist/dom/commit.js.map +1 -0
- package/dist/dom/focus.d.ts +4 -0
- package/dist/dom/focus.d.ts.map +1 -0
- package/dist/dom/focus.js +32 -0
- package/dist/dom/focus.js.map +1 -0
- package/dist/dom/index.d.ts +4 -0
- package/dist/dom/index.d.ts.map +1 -0
- package/dist/dom/index.js +4 -0
- package/dist/dom/index.js.map +1 -0
- package/dist/dom/nodes.d.ts +12 -0
- package/dist/dom/nodes.d.ts.map +1 -0
- package/dist/dom/nodes.js +165 -0
- package/dist/dom/nodes.js.map +1 -0
- package/dist/dom/props.d.ts +8 -0
- package/dist/dom/props.d.ts.map +1 -0
- package/dist/dom/props.js +675 -0
- package/dist/dom/props.js.map +1 -0
- package/dist/env.d.ts +2 -0
- package/dist/env.d.ts.map +1 -1
- package/dist/env.js +2 -0
- package/dist/env.js.map +1 -1
- package/dist/globalContext.d.ts +3 -8
- package/dist/globalContext.d.ts.map +1 -1
- package/dist/globalContext.js +4 -16
- package/dist/globalContext.js.map +1 -1
- package/dist/globals.d.ts +21 -1
- package/dist/globals.d.ts.map +1 -1
- package/dist/globals.js +22 -2
- package/dist/globals.js.map +1 -1
- package/dist/hmr.d.ts +17 -2
- package/dist/hmr.d.ts.map +1 -1
- package/dist/hmr.js +31 -5
- package/dist/hmr.js.map +1 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/onBeforeMount.d.ts +1 -1
- package/dist/hooks/onBeforeMount.d.ts.map +1 -1
- package/dist/hooks/onBeforeMount.js +10 -3
- package/dist/hooks/onBeforeMount.js.map +1 -1
- package/dist/hooks/onCleanup.d.ts +1 -1
- package/dist/hooks/onCleanup.d.ts.map +1 -1
- package/dist/hooks/onCleanup.js +7 -4
- package/dist/hooks/onCleanup.js.map +1 -1
- package/dist/hooks/onMount.d.ts +2 -2
- package/dist/hooks/onMount.d.ts.map +1 -1
- package/dist/hooks/onMount.js +11 -4
- package/dist/hooks/onMount.js.map +1 -1
- package/dist/hooks/setup.d.ts +13 -0
- package/dist/hooks/setup.d.ts.map +1 -0
- package/dist/hooks/setup.js +54 -0
- package/dist/hooks/setup.js.map +1 -0
- package/dist/hooks/utils.d.ts +2 -3
- package/dist/hooks/utils.d.ts.map +1 -1
- package/dist/hooks/utils.js +9 -14
- package/dist/hooks/utils.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/reconciler.js +3 -3
- package/dist/reconciler.js.map +1 -1
- package/dist/router/head.js +2 -2
- package/dist/router/head.js.map +1 -1
- package/dist/router/pageConfig.js +2 -2
- package/dist/router/pageConfig.js.map +1 -1
- package/dist/scheduler.js +62 -57
- package/dist/scheduler.js.map +1 -1
- package/dist/signals/base.js +3 -3
- package/dist/signals/base.js.map +1 -1
- package/dist/signals/effect.d.ts.map +1 -1
- package/dist/signals/effect.js +6 -6
- package/dist/signals/effect.js.map +1 -1
- package/dist/signals/tracking.d.ts +3 -2
- package/dist/signals/tracking.d.ts.map +1 -1
- package/dist/signals/tracking.js.map +1 -1
- package/dist/statefulPromise.js +2 -2
- package/dist/statefulPromise.js.map +1 -1
- package/dist/types.d.ts +5 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/types.dom.d.ts +1 -1
- package/dist/types.dom.d.ts.map +1 -1
- package/dist/utils/format.d.ts.map +1 -1
- package/dist/utils/format.js +4 -1
- package/dist/utils/format.js.map +1 -1
- package/dist/utils/vdom.d.ts +2 -2
- package/dist/utils/vdom.d.ts.map +1 -1
- package/dist/utils/vdom.js +2 -2
- package/dist/utils/vdom.js.map +1 -1
- package/dist/viewTransitions.d.ts.map +1 -1
- package/dist/viewTransitions.js +2 -1
- package/dist/viewTransitions.js.map +1 -1
- package/package.json +1 -1
- package/src/appHandle.ts +2 -2
- package/src/components/lazy.ts +5 -6
- package/src/components/transition.ts +2 -6
- package/src/devtools.ts +4 -2
- package/src/dom/commit.ts +133 -0
- package/src/dom/focus.ts +34 -0
- package/src/dom/index.ts +3 -0
- package/src/dom/nodes.ts +204 -0
- package/src/dom/props.ts +818 -0
- package/src/env.ts +3 -0
- package/src/globalContext.ts +7 -24
- package/src/globals.ts +25 -2
- package/src/hmr.ts +32 -5
- package/src/hooks/index.ts +1 -0
- package/src/hooks/onBeforeMount.ts +9 -3
- package/src/hooks/onCleanup.ts +10 -4
- package/src/hooks/onMount.ts +10 -4
- package/src/hooks/setup.ts +70 -0
- package/src/hooks/utils.ts +14 -19
- package/src/index.ts +4 -2
- package/src/reconciler.ts +3 -3
- package/src/router/head.ts +2 -2
- package/src/router/pageConfig.ts +2 -2
- package/src/scheduler.ts +79 -64
- package/src/signals/base.ts +3 -3
- package/src/signals/effect.ts +5 -7
- package/src/signals/tracking.ts +3 -2
- package/src/statefulPromise.ts +2 -2
- package/src/types.dom.ts +2 -2
- package/src/types.ts +7 -1
- package/src/utils/format.ts +3 -1
- package/src/utils/vdom.ts +2 -2
- package/src/viewTransitions.ts +2 -1
- package/dist/dom.d.ts +0 -10
- package/dist/dom.d.ts.map +0 -1
- package/dist/dom.js +0 -601
- package/dist/dom.js.map +0 -1
- package/src/dom.ts +0 -775
package/src/scheduler.ts
CHANGED
|
@@ -6,18 +6,13 @@ import {
|
|
|
6
6
|
FLAG_DIRTY,
|
|
7
7
|
} from "./constants.js"
|
|
8
8
|
import {
|
|
9
|
+
captureFocus,
|
|
9
10
|
commitDeletion,
|
|
10
11
|
commitWork,
|
|
11
12
|
createDom,
|
|
12
13
|
hydrateDom,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
} from "./dom.js"
|
|
16
|
-
import { __DEV__ } from "./env.js"
|
|
17
|
-
import { KiruError } from "./error.js"
|
|
18
|
-
import { node, renderMode } from "./globals.js"
|
|
19
|
-
import { hydrationStack } from "./hydration.js"
|
|
20
|
-
import { reconcileChildren } from "./reconciler.js"
|
|
14
|
+
reinstateFocus,
|
|
15
|
+
} from "./dom/index.js"
|
|
21
16
|
import {
|
|
22
17
|
assertValidElementProps,
|
|
23
18
|
latest,
|
|
@@ -28,8 +23,13 @@ import {
|
|
|
28
23
|
call,
|
|
29
24
|
propsChanged,
|
|
30
25
|
} from "./utils/index.js"
|
|
31
|
-
import
|
|
26
|
+
import { __DEV__ } from "./env.js"
|
|
27
|
+
import { KiruError } from "./error.js"
|
|
28
|
+
import { node, postEffectCleanups, renderMode, setups } from "./globals.js"
|
|
29
|
+
import { hydrationStack } from "./hydration.js"
|
|
30
|
+
import { reconcileChildren } from "./reconciler.js"
|
|
32
31
|
import { isHmrUpdate } from "./hmr.js"
|
|
32
|
+
import type { AppHandle } from "./appHandle"
|
|
33
33
|
|
|
34
34
|
type VNode = Kiru.VNode
|
|
35
35
|
|
|
@@ -93,21 +93,8 @@ export function useRequestUpdate(): () => void {
|
|
|
93
93
|
return () => requestUpdate(n)
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
function queueBeginWork(): void {
|
|
97
|
-
if (isRunningOrQueued) return
|
|
98
|
-
isRunningOrQueued = true
|
|
99
|
-
animationFrameHandle = window.requestAnimationFrame(doWork)
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function onWorkFinished(): void {
|
|
103
|
-
isRunningOrQueued = false
|
|
104
|
-
while (nextIdleEffects.length) {
|
|
105
|
-
nextIdleEffects.shift()!()
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
96
|
function queueUpdate(vNode: VNode): void {
|
|
110
|
-
// In immediate effect mode (
|
|
97
|
+
// In immediate effect mode (onBeforeMount), immediately mark the render as dirty
|
|
111
98
|
if (isImmediateEffectsMode) {
|
|
112
99
|
immediateEffectDirtiedRender = true
|
|
113
100
|
}
|
|
@@ -126,7 +113,12 @@ function queueUpdate(vNode: VNode): void {
|
|
|
126
113
|
|
|
127
114
|
if (!treesInProgress.length) {
|
|
128
115
|
treesInProgress.push(vNode)
|
|
129
|
-
|
|
116
|
+
|
|
117
|
+
if (!isRunningOrQueued) {
|
|
118
|
+
isRunningOrQueued = true
|
|
119
|
+
animationFrameHandle = window.requestAnimationFrame(doWork)
|
|
120
|
+
}
|
|
121
|
+
return
|
|
130
122
|
}
|
|
131
123
|
|
|
132
124
|
treesInProgress.push(vNode)
|
|
@@ -154,7 +146,7 @@ function doWork(): void {
|
|
|
154
146
|
|
|
155
147
|
let len = 1
|
|
156
148
|
|
|
157
|
-
|
|
149
|
+
captureFocus()
|
|
158
150
|
while (treesInProgress.length) {
|
|
159
151
|
if (treesInProgress.length > len) {
|
|
160
152
|
treesInProgress.sort(depthSort)
|
|
@@ -177,7 +169,7 @@ function doWork(): void {
|
|
|
177
169
|
currentWorkRoot.flags &= ~FLAG_DIRTY
|
|
178
170
|
}
|
|
179
171
|
}
|
|
180
|
-
|
|
172
|
+
reinstateFocus()
|
|
181
173
|
|
|
182
174
|
isImmediateEffectsMode = true
|
|
183
175
|
flushEffects(preEffects)
|
|
@@ -196,8 +188,14 @@ function doWork(): void {
|
|
|
196
188
|
}
|
|
197
189
|
consecutiveDirtyCount = 0
|
|
198
190
|
|
|
199
|
-
|
|
200
|
-
|
|
191
|
+
isRunningOrQueued = false
|
|
192
|
+
while (nextIdleEffects.length) {
|
|
193
|
+
nextIdleEffects.shift()!()
|
|
194
|
+
}
|
|
195
|
+
queueMicrotask(() => {
|
|
196
|
+
flushEffects(postEffectCleanups)
|
|
197
|
+
flushEffects(postEffects)
|
|
198
|
+
})
|
|
201
199
|
if (__DEV__) {
|
|
202
200
|
window.__kiru.emit("update", app!)
|
|
203
201
|
window.__kiru.profilingContext?.emit("update", app!)
|
|
@@ -324,6 +322,9 @@ function updateExoticComponent(vNode: VNode): VNode | null {
|
|
|
324
322
|
function updateFunctionComponent(vNode: FunctionVNode): VNode | null {
|
|
325
323
|
const { type, props, subs } = vNode
|
|
326
324
|
|
|
325
|
+
/** Only sync prop-derived signals when update came from parent (new props), not from internal subscription (e.g. signal). */
|
|
326
|
+
const shouldSyncProps = (vNode.flags & FLAG_DIRTY) === 0
|
|
327
|
+
|
|
327
328
|
try {
|
|
328
329
|
node.current = vNode
|
|
329
330
|
let newChild
|
|
@@ -346,34 +347,26 @@ function updateFunctionComponent(vNode: FunctionVNode): VNode | null {
|
|
|
346
347
|
subs.clear()
|
|
347
348
|
}
|
|
348
349
|
|
|
349
|
-
if (__DEV__) {
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
delete vNode.cleanups
|
|
355
|
-
}
|
|
356
|
-
if (hooks) {
|
|
357
|
-
const { preCleanups, postCleanups } = hooks
|
|
358
|
-
preCleanups.forEach(call)
|
|
359
|
-
postCleanups.forEach(call)
|
|
360
|
-
preCleanups.length = postCleanups.length = 0
|
|
361
|
-
}
|
|
362
|
-
delete vNode.render
|
|
350
|
+
if (__DEV__ && isHmrUpdate()) {
|
|
351
|
+
const { hooks, cleanups } = vNode
|
|
352
|
+
if (cleanups) {
|
|
353
|
+
Object.values(cleanups).forEach(call)
|
|
354
|
+
delete vNode.cleanups
|
|
363
355
|
}
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
if (typeof newChild === "function") {
|
|
370
|
-
vNode.subs?.forEach(call)
|
|
371
|
-
vNode.render = newChild as (props: any) => unknown
|
|
372
|
-
newChild = vNode.render(props)
|
|
373
|
-
}
|
|
356
|
+
if (hooks) {
|
|
357
|
+
const { preCleanups, postCleanups } = hooks
|
|
358
|
+
preCleanups.forEach(call)
|
|
359
|
+
postCleanups.forEach(call)
|
|
360
|
+
preCleanups.length = postCleanups.length = 0
|
|
374
361
|
}
|
|
362
|
+
delete vNode.propSyncs
|
|
363
|
+
delete vNode.render
|
|
364
|
+
}
|
|
375
365
|
|
|
376
|
-
|
|
366
|
+
newChild = renderFunctionComponent(vNode, type, props, shouldSyncProps)
|
|
367
|
+
|
|
368
|
+
if (++renderTryCount > CONSECUTIVE_DIRTY_LIMIT) {
|
|
369
|
+
if (__DEV__) {
|
|
377
370
|
throw new KiruError({
|
|
378
371
|
message:
|
|
379
372
|
"Too many re-renders. Kiru limits the number of renders to prevent an infinite loop.",
|
|
@@ -381,17 +374,7 @@ function updateFunctionComponent(vNode: FunctionVNode): VNode | null {
|
|
|
381
374
|
vNode,
|
|
382
375
|
})
|
|
383
376
|
}
|
|
384
|
-
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
if (vNode.render) {
|
|
388
|
-
newChild = vNode.render(props)
|
|
389
|
-
} else {
|
|
390
|
-
newChild = type(props)
|
|
391
|
-
if (typeof newChild === "function") {
|
|
392
|
-
vNode.render = newChild as (props: any) => unknown
|
|
393
|
-
newChild = vNode.render(props)
|
|
394
|
-
}
|
|
377
|
+
break
|
|
395
378
|
}
|
|
396
379
|
} while (isRenderDirtied)
|
|
397
380
|
|
|
@@ -401,6 +384,38 @@ function updateFunctionComponent(vNode: FunctionVNode): VNode | null {
|
|
|
401
384
|
}
|
|
402
385
|
}
|
|
403
386
|
|
|
387
|
+
function renderFunctionComponent(
|
|
388
|
+
vNode: FunctionVNode,
|
|
389
|
+
type: Function,
|
|
390
|
+
props: Record<string, unknown>,
|
|
391
|
+
shouldSyncProps: boolean
|
|
392
|
+
): unknown {
|
|
393
|
+
const { render, propSyncs } = vNode
|
|
394
|
+
|
|
395
|
+
if (render) {
|
|
396
|
+
if (shouldSyncProps) {
|
|
397
|
+
const p = { ...props }
|
|
398
|
+
propSyncs?.forEach((sync) => sync(p))
|
|
399
|
+
}
|
|
400
|
+
return render(props)
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
let newChild = latest(type)(props)
|
|
404
|
+
if (typeof newChild === "function") {
|
|
405
|
+
vNode.subs?.forEach(call) // unsub from signals observered during setup
|
|
406
|
+
vNode.render = newChild
|
|
407
|
+
if (shouldSyncProps) {
|
|
408
|
+
const p = { ...props }
|
|
409
|
+
propSyncs?.forEach((sync) => sync(p))
|
|
410
|
+
}
|
|
411
|
+
newChild = newChild(props)
|
|
412
|
+
} else if (__DEV__ && setups.has(vNode)) {
|
|
413
|
+
throw new Error("setup() must not be called inside a render function")
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
return newChild
|
|
417
|
+
}
|
|
418
|
+
|
|
404
419
|
function updateHostComponent(vNode: DomVNode): VNode | null {
|
|
405
420
|
const { props, type } = vNode
|
|
406
421
|
if (__DEV__) {
|
package/src/signals/base.ts
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
registerVNodeCleanup,
|
|
7
7
|
} from "../utils/index.js"
|
|
8
8
|
import { $HMR_ACCEPT, $SIGNAL } from "../constants.js"
|
|
9
|
-
import { __DEV__ } from "../env.js"
|
|
9
|
+
import { __DEV__, isBrowser } from "../env.js"
|
|
10
10
|
import { node } from "../globals.js"
|
|
11
11
|
import { requestUpdate } from "../scheduler.js"
|
|
12
12
|
import { signalSubsMap } from "./globals.js"
|
|
@@ -39,7 +39,7 @@ export class Signal<T> {
|
|
|
39
39
|
return this as Signal<any>
|
|
40
40
|
},
|
|
41
41
|
inject: (prev) => {
|
|
42
|
-
if (
|
|
42
|
+
if (isBrowser) window.__kiru.devtools?.untrack(prev)
|
|
43
43
|
signalSubsMap.get(this.$id)?.clear?.()
|
|
44
44
|
signalSubsMap.delete(this.$id)
|
|
45
45
|
this.$id = prev.$id
|
|
@@ -201,7 +201,7 @@ export class Signal<T> {
|
|
|
201
201
|
signal.$isDisposed = true
|
|
202
202
|
if (__DEV__) {
|
|
203
203
|
signalSubsMap.delete(signal.$id)
|
|
204
|
-
if (
|
|
204
|
+
if (isBrowser) window.__kiru.devtools?.untrack(signal)
|
|
205
205
|
return
|
|
206
206
|
}
|
|
207
207
|
signal.$subs!.clear()
|
package/src/signals/effect.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __DEV__ } from "../env.js"
|
|
1
|
+
import { __DEV__, isBrowser } from "../env.js"
|
|
2
2
|
import { effectQueue } from "./globals.js"
|
|
3
3
|
import { executeWithTracking } from "./tracking.js"
|
|
4
4
|
import {
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
generateRandomID,
|
|
7
7
|
call,
|
|
8
8
|
registerVNodeCleanup,
|
|
9
|
+
sideEffectsEnabled,
|
|
9
10
|
} from "../utils/index.js"
|
|
10
11
|
import type { Signal } from "./base.js"
|
|
11
12
|
import type { SignalValues } from "./types.js"
|
|
@@ -31,11 +32,12 @@ export class Effect<const Deps extends readonly Signal<unknown>[] = []> {
|
|
|
31
32
|
this.unsubs = new Map()
|
|
32
33
|
this.isRunning = false
|
|
33
34
|
this.cleanup = null
|
|
34
|
-
if (__DEV__ &&
|
|
35
|
+
if (__DEV__ && isBrowser) {
|
|
35
36
|
window.__kiru.HMRContext!.moduleEffects.push(this)
|
|
36
37
|
}
|
|
37
38
|
const n = node.current
|
|
38
39
|
if (n) {
|
|
40
|
+
if (!sideEffectsEnabled()) return // prevent side effects in non-browser environments
|
|
39
41
|
registerVNodeCleanup(n, this.id, this.stop.bind(this))
|
|
40
42
|
}
|
|
41
43
|
this.start()
|
|
@@ -49,11 +51,7 @@ export class Effect<const Deps extends readonly Signal<unknown>[] = []> {
|
|
|
49
51
|
this.isRunning = true
|
|
50
52
|
|
|
51
53
|
// postpone execution during HMR
|
|
52
|
-
if (
|
|
53
|
-
__DEV__ &&
|
|
54
|
-
"window" in globalThis &&
|
|
55
|
-
window.__kiru.HMRContext?.isReplacement()
|
|
56
|
-
) {
|
|
54
|
+
if (__DEV__ && isBrowser && window.__kiru.HMRContext?.isReplacement()) {
|
|
57
55
|
return queueMicrotask(() => {
|
|
58
56
|
if (this.isRunning) {
|
|
59
57
|
Effect.run(this as Effect)
|
package/src/signals/tracking.ts
CHANGED
|
@@ -5,10 +5,11 @@ import { tick } from "./utils.js"
|
|
|
5
5
|
import type { Signal } from "./base.js"
|
|
6
6
|
import type { SignalValues } from "./types.js"
|
|
7
7
|
|
|
8
|
+
export type TrackingStackObservations = Map<string, Signal<unknown>>
|
|
8
9
|
export const tracking = {
|
|
9
10
|
enabled: true,
|
|
10
|
-
stack: new Array<
|
|
11
|
-
current: function ():
|
|
11
|
+
stack: new Array<TrackingStackObservations>(),
|
|
12
|
+
current: function (): TrackingStackObservations | undefined {
|
|
12
13
|
return this.stack[this.stack.length - 1]
|
|
13
14
|
},
|
|
14
15
|
}
|
package/src/statefulPromise.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { $STREAM_DATA, STREAMED_DATA_EVENT } from "./constants.js"
|
|
2
2
|
import { hydrationMode, node, renderMode } from "./globals.js"
|
|
3
3
|
import { Signal, signal } from "./signals/base.js"
|
|
4
|
-
import {
|
|
4
|
+
import { createVNodeId } from "./utils/vdom.js"
|
|
5
5
|
import { onCleanup } from "./hooks/onCleanup.js"
|
|
6
6
|
|
|
7
7
|
export interface StreamDataThrowValue {
|
|
@@ -42,7 +42,7 @@ export function statefulPromise<T>(
|
|
|
42
42
|
if (!vNode) {
|
|
43
43
|
throw new Error("statefulPromise must be called inside a Kiru component")
|
|
44
44
|
}
|
|
45
|
-
const id =
|
|
45
|
+
const id = createVNodeId(vNode)
|
|
46
46
|
const isPending = signal(true)
|
|
47
47
|
|
|
48
48
|
isPending.value = true
|
package/src/types.dom.ts
CHANGED
|
@@ -153,8 +153,8 @@ type AllStyleRules = Omit<
|
|
|
153
153
|
type StyleObject = Prettify<
|
|
154
154
|
Partial<{
|
|
155
155
|
[Key in keyof AllStyleRules & string]: Key extends NumericStyleKeys
|
|
156
|
-
? number | string
|
|
157
|
-
: AllStyleRules[Key]
|
|
156
|
+
? Signalable<number | string | undefined>
|
|
157
|
+
: Signalable<AllStyleRules[Key] | undefined>
|
|
158
158
|
}>
|
|
159
159
|
>
|
|
160
160
|
|
package/src/types.ts
CHANGED
|
@@ -162,7 +162,11 @@ declare global {
|
|
|
162
162
|
| typeof $ERROR_BOUNDARY
|
|
163
163
|
|
|
164
164
|
interface Element {
|
|
165
|
-
type:
|
|
165
|
+
type:
|
|
166
|
+
| (Function & { displayName?: string })
|
|
167
|
+
| ExoticSymbol
|
|
168
|
+
| "#text"
|
|
169
|
+
| (string & {})
|
|
166
170
|
key: JSX.ElementKey | null
|
|
167
171
|
props: {
|
|
168
172
|
[key: string]: any
|
|
@@ -193,6 +197,8 @@ declare global {
|
|
|
193
197
|
post: LifecycleHookCallback[]
|
|
194
198
|
postCleanups: (() => void)[]
|
|
195
199
|
}
|
|
200
|
+
/** Run before each render with current props to sync prop-derived signals */
|
|
201
|
+
propSyncs?: ((props: VNode["props"]) => void)[]
|
|
196
202
|
render?: (props: VNode["props"]) => unknown
|
|
197
203
|
}
|
|
198
204
|
interface VNodeSnapshot {
|
package/src/utils/format.ts
CHANGED
|
@@ -84,8 +84,10 @@ function propToHtmlAttr(key: string): string {
|
|
|
84
84
|
function styleObjectToString(obj: Partial<CSSStyleDeclaration>): string {
|
|
85
85
|
let cssString = ""
|
|
86
86
|
for (const key in obj) {
|
|
87
|
+
const val = unwrap((obj as Record<string, unknown>)[key])
|
|
88
|
+
if (val === null || val === undefined) continue
|
|
87
89
|
const cssKey = key.replace(REGEX_ALPHA_UPPER, "-$&").toLowerCase()
|
|
88
|
-
cssString += `${cssKey}:${
|
|
90
|
+
cssString += `${cssKey}:${val};`
|
|
89
91
|
}
|
|
90
92
|
return cssString
|
|
91
93
|
}
|
package/src/utils/vdom.ts
CHANGED
|
@@ -31,7 +31,7 @@ export {
|
|
|
31
31
|
findParentErrorBoundary,
|
|
32
32
|
assertValidElementProps,
|
|
33
33
|
normalizeElementKey,
|
|
34
|
-
|
|
34
|
+
createVNodeId,
|
|
35
35
|
registerVNodeCleanup,
|
|
36
36
|
propsChanged,
|
|
37
37
|
}
|
|
@@ -186,7 +186,7 @@ function normalizeElementKey(thing: unknown): JSX.ElementKey | null {
|
|
|
186
186
|
return null
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
-
function
|
|
189
|
+
function createVNodeId(vNode: Kiru.VNode): string {
|
|
190
190
|
const accumulator: number[] = []
|
|
191
191
|
let n: Kiru.VNode | null = vNode
|
|
192
192
|
while (n) {
|
package/src/viewTransitions.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { flushSync } from "./scheduler.js"
|
|
2
|
+
import { isBrowser } from "./env.js"
|
|
2
3
|
|
|
3
4
|
export namespace ViewTransitions {
|
|
4
5
|
type ViewTransitionJob = () => Promise<void>
|
|
@@ -8,7 +9,7 @@ export namespace ViewTransitions {
|
|
|
8
9
|
let scheduled = false
|
|
9
10
|
let transition: ViewTransition | null = null
|
|
10
11
|
const supported =
|
|
11
|
-
|
|
12
|
+
isBrowser && typeof document.startViewTransition === "function"
|
|
12
13
|
|
|
13
14
|
export function run<T>(
|
|
14
15
|
callback: () => T | Promise<T>,
|
package/dist/dom.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { DomVNode, SomeDom } from "./types.utils";
|
|
2
|
-
export { commitWork, onBeforeFlushDomChanges, onAfterFlushDomChanges, commitDeletion, createDom, hydrateDom, };
|
|
3
|
-
type VNode = Kiru.VNode;
|
|
4
|
-
declare function onBeforeFlushDomChanges(): void;
|
|
5
|
-
declare function onAfterFlushDomChanges(): void;
|
|
6
|
-
declare function createDom(vNode: DomVNode): SomeDom;
|
|
7
|
-
declare function hydrateDom(vNode: VNode): void;
|
|
8
|
-
declare function commitWork(vNode: VNode): void;
|
|
9
|
-
declare function commitDeletion(vNode: VNode): void;
|
|
10
|
-
//# sourceMappingURL=dom.d.ts.map
|
package/dist/dom.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../src/dom.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EACV,QAAQ,EAGR,OAAO,EAER,MAAM,eAAe,CAAA;AAGtB,OAAO,EACL,UAAU,EACV,uBAAuB,EACvB,sBAAsB,EACtB,cAAc,EACd,SAAS,EACT,UAAU,GACX,CAAA;AAED,KAAK,KAAK,GAAG,IAAI,CAAC,KAAK,CAAA;AAiBvB,iBAAS,uBAAuB,SAM/B;AAED,iBAAS,sBAAsB,SAa9B;AAED,iBAAS,SAAS,CAAC,KAAK,EAAE,QAAQ,GAAG,OAAO,CAU3C;AA0TD,iBAAS,UAAU,CAAC,KAAK,EAAE,KAAK,QA+C/B;AAuND,iBAAS,UAAU,CAAC,KAAK,EAAE,KAAK,QAa/B;AA6CD,iBAAS,cAAc,CAAC,KAAK,EAAE,KAAK,QA8CnC"}
|