kiru 0.48.3 → 0.49.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/action.d.ts +22 -0
- package/dist/action.d.ts.map +1 -0
- package/dist/action.js +20 -0
- package/dist/action.js.map +1 -0
- package/dist/components/index.d.ts +5 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +5 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/lazy.d.ts.map +1 -0
- package/dist/{lazy.js → components/lazy.js} +11 -11
- package/dist/components/lazy.js.map +1 -0
- package/dist/{memo.d.ts → components/memo.d.ts} +1 -1
- package/dist/components/memo.d.ts.map +1 -0
- package/dist/{memo.js → components/memo.js} +2 -2
- package/dist/components/memo.js.map +1 -0
- package/dist/components/portal.d.ts.map +1 -0
- package/dist/{portal.js → components/portal.js} +6 -6
- package/dist/components/portal.js.map +1 -0
- package/dist/components/router/index.d.ts.map +1 -0
- package/dist/components/router/index.js.map +1 -0
- package/dist/components/router/route.d.ts.map +1 -0
- package/dist/{router → components/router}/route.js +1 -1
- package/dist/components/router/route.js.map +1 -0
- package/dist/{router → components/router}/router.d.ts +1 -1
- package/dist/components/router/router.d.ts.map +1 -0
- package/dist/{router → components/router}/router.js +8 -8
- package/dist/components/router/router.js.map +1 -0
- package/dist/components/router/routerUtils.d.ts.map +1 -0
- package/dist/components/router/routerUtils.js.map +1 -0
- package/dist/components/transition.d.ts.map +1 -0
- package/dist/{transition.js → components/transition.js} +5 -5
- package/dist/components/transition.js.map +1 -0
- package/dist/constants.d.ts +2 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +79 -1
- package/dist/constants.js.map +1 -1
- package/dist/context.js +1 -1
- package/dist/context.js.map +1 -1
- package/dist/dom.d.ts.map +1 -1
- package/dist/dom.js +8 -9
- package/dist/dom.js.map +1 -1
- package/dist/element.js +2 -2
- package/dist/element.js.map +1 -1
- package/dist/error.js +1 -1
- package/dist/error.js.map +1 -1
- package/dist/form/index.d.ts.map +1 -1
- package/dist/form/index.js +1 -2
- package/dist/form/index.js.map +1 -1
- package/dist/hmr.js +1 -1
- package/dist/hmr.js.map +1 -1
- package/dist/hooks/useAsync.d.ts.map +1 -1
- package/dist/hooks/useAsync.js +2 -2
- package/dist/hooks/useAsync.js.map +1 -1
- package/dist/hooks/useCallback.d.ts.map +1 -1
- package/dist/hooks/useCallback.js +2 -1
- package/dist/hooks/useCallback.js.map +1 -1
- package/dist/hooks/useEffect.d.ts.map +1 -1
- package/dist/hooks/useEffect.js +2 -1
- package/dist/hooks/useEffect.js.map +1 -1
- package/dist/hooks/useEffectEvent.d.ts.map +1 -1
- package/dist/hooks/useEffectEvent.js +2 -1
- package/dist/hooks/useEffectEvent.js.map +1 -1
- package/dist/hooks/useLayoutEffect.d.ts.map +1 -1
- package/dist/hooks/useLayoutEffect.js +2 -1
- package/dist/hooks/useLayoutEffect.js.map +1 -1
- package/dist/hooks/useMemo.d.ts.map +1 -1
- package/dist/hooks/useMemo.js +2 -1
- package/dist/hooks/useMemo.js.map +1 -1
- package/dist/hooks/useReducer.js +2 -2
- package/dist/hooks/useReducer.js.map +1 -1
- package/dist/hooks/useRef.d.ts.map +1 -1
- package/dist/hooks/useRef.js +2 -1
- package/dist/hooks/useRef.js.map +1 -1
- package/dist/hooks/useState.js +2 -2
- package/dist/hooks/useState.js.map +1 -1
- package/dist/hooks/useSyncExternalStore.js +2 -2
- package/dist/hooks/useSyncExternalStore.js.map +1 -1
- package/dist/hooks/useViewTransition.d.ts.map +1 -1
- package/dist/hooks/useViewTransition.js +1 -2
- package/dist/hooks/useViewTransition.js.map +1 -1
- package/dist/hooks/utils.d.ts +0 -1
- package/dist/hooks/utils.d.ts.map +1 -1
- package/dist/hooks/utils.js +1 -2
- package/dist/hooks/utils.js.map +1 -1
- package/dist/index.d.ts +2 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -5
- package/dist/index.js.map +1 -1
- package/dist/reconciler.js +8 -7
- package/dist/reconciler.js.map +1 -1
- package/dist/renderToString.js +1 -2
- package/dist/renderToString.js.map +1 -1
- package/dist/scheduler.js +2 -2
- package/dist/scheduler.js.map +1 -1
- package/dist/signals/base.d.ts.map +1 -1
- package/dist/signals/base.js +1 -2
- package/dist/signals/base.js.map +1 -1
- package/dist/signals/computed.js +1 -1
- package/dist/signals/computed.js.map +1 -1
- package/dist/signals/effect.js +1 -1
- package/dist/signals/effect.js.map +1 -1
- package/dist/signals/watch.d.ts.map +1 -1
- package/dist/signals/watch.js +2 -3
- package/dist/signals/watch.js.map +1 -1
- package/dist/ssr/server.js +1 -2
- package/dist/ssr/server.js.map +1 -1
- package/dist/store.d.ts +1 -1
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +2 -2
- package/dist/store.js.map +1 -1
- package/dist/swr.js +1 -1
- package/dist/swr.js.map +1 -1
- package/dist/types.d.ts +4 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/types.dom.d.ts +2 -2
- package/dist/types.dom.d.ts.map +1 -1
- package/dist/utils/compare.d.ts +3 -0
- package/dist/utils/compare.d.ts.map +1 -0
- package/dist/utils/compare.js +123 -0
- package/dist/utils/compare.js.map +1 -0
- package/dist/utils/format.d.ts +20 -0
- package/dist/utils/format.d.ts.map +1 -0
- package/dist/utils/format.js +129 -0
- package/dist/utils/format.js.map +1 -0
- package/dist/utils/generateId.d.ts.map +1 -0
- package/dist/utils/generateId.js.map +1 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +7 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/runtime.d.ts +11 -0
- package/dist/utils/runtime.d.ts.map +1 -0
- package/dist/utils/runtime.js +23 -0
- package/dist/utils/runtime.js.map +1 -0
- package/dist/utils/vdom.d.ts +25 -0
- package/dist/utils/vdom.d.ts.map +1 -0
- package/dist/utils/vdom.js +124 -0
- package/dist/utils/vdom.js.map +1 -0
- package/package.json +6 -6
- package/src/action.ts +42 -0
- package/src/components/index.ts +4 -0
- package/src/{lazy.ts → components/lazy.ts} +12 -12
- package/src/{memo.ts → components/memo.ts} +3 -3
- package/src/{portal.ts → components/portal.ts} +6 -6
- package/src/{router → components/router}/route.ts +1 -1
- package/src/{router → components/router}/router.ts +9 -9
- package/src/{transition.ts → components/transition.ts} +5 -5
- package/src/constants.ts +80 -1
- package/src/context.ts +1 -1
- package/src/customEvents.ts +22 -22
- package/src/dom.ts +7 -8
- package/src/element.ts +2 -2
- package/src/error.ts +1 -1
- package/src/form/index.ts +5 -2
- package/src/hmr.ts +1 -1
- package/src/hooks/useAsync.ts +5 -3
- package/src/hooks/useCallback.ts +2 -1
- package/src/hooks/useEffect.ts +2 -6
- package/src/hooks/useEffectEvent.ts +2 -1
- package/src/hooks/useLayoutEffect.ts +2 -6
- package/src/hooks/useMemo.ts +2 -1
- package/src/hooks/useReducer.ts +2 -2
- package/src/hooks/useRef.ts +2 -1
- package/src/hooks/useState.ts +2 -2
- package/src/hooks/useSyncExternalStore.ts +2 -2
- package/src/hooks/useViewTransition.ts +1 -2
- package/src/hooks/utils.ts +1 -2
- package/src/index.ts +2 -5
- package/src/reconciler.ts +13 -11
- package/src/renderToString.ts +2 -2
- package/src/scheduler.ts +2 -2
- package/src/signals/base.ts +6 -2
- package/src/signals/computed.ts +1 -1
- package/src/signals/effect.ts +1 -1
- package/src/signals/watch.ts +2 -3
- package/src/ssr/server.ts +2 -2
- package/src/store.ts +6 -2
- package/src/swr.ts +3 -3
- package/src/types.dom.ts +2 -1
- package/src/types.ts +9 -2
- package/src/utils/compare.ts +125 -0
- package/src/utils/format.ts +158 -0
- package/src/utils/index.ts +7 -0
- package/src/utils/runtime.ts +25 -0
- package/src/utils/vdom.ts +184 -0
- package/dist/cloneVNode.d.ts +0 -2
- package/dist/cloneVNode.d.ts.map +0 -1
- package/dist/cloneVNode.js +0 -14
- package/dist/cloneVNode.js.map +0 -1
- package/dist/generateId.d.ts.map +0 -1
- package/dist/generateId.js.map +0 -1
- package/dist/lazy.d.ts.map +0 -1
- package/dist/lazy.js.map +0 -1
- package/dist/memo.d.ts.map +0 -1
- package/dist/memo.js.map +0 -1
- package/dist/portal.d.ts.map +0 -1
- package/dist/portal.js.map +0 -1
- package/dist/props.d.ts +0 -4
- package/dist/props.d.ts.map +0 -1
- package/dist/props.js +0 -27
- package/dist/props.js.map +0 -1
- package/dist/router/index.d.ts.map +0 -1
- package/dist/router/index.js.map +0 -1
- package/dist/router/route.d.ts.map +0 -1
- package/dist/router/route.js.map +0 -1
- package/dist/router/router.d.ts.map +0 -1
- package/dist/router/router.js.map +0 -1
- package/dist/router/routerUtils.d.ts.map +0 -1
- package/dist/router/routerUtils.js.map +0 -1
- package/dist/transition.d.ts.map +0 -1
- package/dist/transition.js.map +0 -1
- package/dist/utils.d.ts +0 -52
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js +0 -433
- package/dist/utils.js.map +0 -1
- package/dist/warning.d.ts +0 -2
- package/dist/warning.d.ts.map +0 -1
- package/dist/warning.js +0 -4
- package/dist/warning.js.map +0 -1
- package/src/cloneVNode.ts +0 -14
- package/src/props.ts +0 -34
- package/src/utils.ts +0 -518
- package/src/warning.ts +0 -9
- /package/dist/{lazy.d.ts → components/lazy.d.ts} +0 -0
- /package/dist/{portal.d.ts → components/portal.d.ts} +0 -0
- /package/dist/{router → components/router}/index.d.ts +0 -0
- /package/dist/{router → components/router}/index.js +0 -0
- /package/dist/{router → components/router}/route.d.ts +0 -0
- /package/dist/{router → components/router}/routerUtils.d.ts +0 -0
- /package/dist/{router → components/router}/routerUtils.js +0 -0
- /package/dist/{transition.d.ts → components/transition.d.ts} +0 -0
- /package/dist/{generateId.d.ts → utils/generateId.d.ts} +0 -0
- /package/dist/{generateId.js → utils/generateId.js} +0 -0
- /package/src/{router → components/router}/index.ts +0 -0
- /package/src/{router → components/router}/routerUtils.ts +0 -0
- /package/src/{generateId.ts → utils/generateId.ts} +0 -0
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { Signal } from "../signals/index.js";
|
|
2
|
+
import { FLAG_DELETION, $FRAGMENT, $CONTEXT_PROVIDER, $HYDRATION_BOUNDARY, FLAG_PLACEMENT, FLAG_UPDATE, } from "../constants.js";
|
|
3
|
+
import { createElement } from "../index.js";
|
|
4
|
+
import { KiruError } from "../error.js";
|
|
5
|
+
import { node } from "../globals.js";
|
|
6
|
+
export { cloneVNode, isVNodeDeleted, isVNode, isExoticType, isFragment, isLazy, isMemo, isContextProvider, vNodeContains, getCurrentVNode, getVNodeAppContext, commitSnapshot, traverseApply, findParent, assertValidElementProps, isValidElementKeyProp, isValidElementRefProp, };
|
|
7
|
+
function cloneVNode(vNode) {
|
|
8
|
+
const children = vNode.props.children;
|
|
9
|
+
let clonedChildren;
|
|
10
|
+
if (isVNode(children)) {
|
|
11
|
+
clonedChildren = cloneVNode(children);
|
|
12
|
+
}
|
|
13
|
+
else if (Array.isArray(children)) {
|
|
14
|
+
clonedChildren = children.map((c) => (isVNode(c) ? cloneVNode(c) : c));
|
|
15
|
+
}
|
|
16
|
+
return createElement(vNode.type, { ...vNode.props, children: clonedChildren });
|
|
17
|
+
}
|
|
18
|
+
function isVNodeDeleted(vNode) {
|
|
19
|
+
return (vNode.flags & FLAG_DELETION) !== 0;
|
|
20
|
+
}
|
|
21
|
+
function isVNode(thing) {
|
|
22
|
+
return typeof thing === "object" && thing !== null && "type" in thing;
|
|
23
|
+
}
|
|
24
|
+
function isExoticType(type) {
|
|
25
|
+
return (type === $FRAGMENT ||
|
|
26
|
+
type === $CONTEXT_PROVIDER ||
|
|
27
|
+
type === $HYDRATION_BOUNDARY);
|
|
28
|
+
}
|
|
29
|
+
function isFragment(vNode) {
|
|
30
|
+
return vNode.type === $FRAGMENT;
|
|
31
|
+
}
|
|
32
|
+
function isLazy(vNode) {
|
|
33
|
+
return (typeof vNode.type === "function" &&
|
|
34
|
+
"displayName" in vNode.type &&
|
|
35
|
+
vNode.type.displayName === "Kiru.lazy");
|
|
36
|
+
}
|
|
37
|
+
function isMemo(vNode) {
|
|
38
|
+
return (typeof vNode.type === "function" &&
|
|
39
|
+
"displayName" in vNode.type &&
|
|
40
|
+
vNode.type.displayName === "Kiru.memo");
|
|
41
|
+
}
|
|
42
|
+
function isContextProvider(thing) {
|
|
43
|
+
return isVNode(thing) && thing.type === $CONTEXT_PROVIDER;
|
|
44
|
+
}
|
|
45
|
+
function getCurrentVNode() {
|
|
46
|
+
return node.current;
|
|
47
|
+
}
|
|
48
|
+
function getVNodeAppContext(vNode) {
|
|
49
|
+
let n = vNode;
|
|
50
|
+
while (n) {
|
|
51
|
+
if (n.app) {
|
|
52
|
+
return (vNode.app = n.app);
|
|
53
|
+
}
|
|
54
|
+
n = n.parent;
|
|
55
|
+
}
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
function commitSnapshot(vNode) {
|
|
59
|
+
const { props: { children, ...props }, memoizedProps, index, } = vNode;
|
|
60
|
+
vNode.prev = { props, memoizedProps, index };
|
|
61
|
+
vNode.flags &= ~(FLAG_UPDATE | FLAG_PLACEMENT | FLAG_DELETION);
|
|
62
|
+
}
|
|
63
|
+
function vNodeContains(haystack, needle) {
|
|
64
|
+
if (needle.depth < haystack.depth)
|
|
65
|
+
return false;
|
|
66
|
+
if (haystack === needle)
|
|
67
|
+
return true;
|
|
68
|
+
let checkSiblings = false;
|
|
69
|
+
const stack = [haystack];
|
|
70
|
+
while (stack.length) {
|
|
71
|
+
const n = stack.pop();
|
|
72
|
+
if (n === needle)
|
|
73
|
+
return true;
|
|
74
|
+
n.child && stack.push(n.child);
|
|
75
|
+
checkSiblings && n.sibling && stack.push(n.sibling);
|
|
76
|
+
checkSiblings = true;
|
|
77
|
+
}
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
function traverseApply(vNode, func) {
|
|
81
|
+
func(vNode);
|
|
82
|
+
let child = vNode.child;
|
|
83
|
+
while (child) {
|
|
84
|
+
func(child);
|
|
85
|
+
if (child.child) {
|
|
86
|
+
traverseApply(child, func);
|
|
87
|
+
}
|
|
88
|
+
child = child.sibling;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
function findParent(vNode, predicate) {
|
|
92
|
+
let n = vNode.parent;
|
|
93
|
+
while (n) {
|
|
94
|
+
if (predicate(n))
|
|
95
|
+
return n;
|
|
96
|
+
n = n.parent;
|
|
97
|
+
}
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
function assertValidElementProps(vNode) {
|
|
101
|
+
if ("children" in vNode.props && vNode.props.innerHTML) {
|
|
102
|
+
throw new KiruError({
|
|
103
|
+
message: "Cannot use both children and innerHTML on an element",
|
|
104
|
+
vNode,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
for (const key in vNode.props) {
|
|
108
|
+
if ("bind:" + key in vNode.props) {
|
|
109
|
+
throw new KiruError({
|
|
110
|
+
message: `Cannot use both bind:${key} and ${key} on an element`,
|
|
111
|
+
vNode,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
function isValidElementKeyProp(thing) {
|
|
117
|
+
return typeof thing === "string" || typeof thing === "number";
|
|
118
|
+
}
|
|
119
|
+
function isValidElementRefProp(thing) {
|
|
120
|
+
return (typeof thing === "function" ||
|
|
121
|
+
(typeof thing === "object" && !!thing && "current" in thing) ||
|
|
122
|
+
Signal.isSignal(thing));
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=vdom.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vdom.js","sourceRoot":"","sources":["../../src/utils/vdom.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAC5C,OAAO,EACL,aAAa,EACb,SAAS,EACT,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,WAAW,GACZ,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;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
4
|
"description": "A batteries-included, easy-to-use rendering library with a tiny footprint",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -15,16 +15,16 @@
|
|
|
15
15
|
"default": "./dist/form/index.js"
|
|
16
16
|
},
|
|
17
17
|
"./router": {
|
|
18
|
-
"types": "./dist/router/index.d.ts",
|
|
19
|
-
"default": "./dist/router/index.js"
|
|
18
|
+
"types": "./dist/components/router/index.d.ts",
|
|
19
|
+
"default": "./dist/components/router/index.js"
|
|
20
20
|
},
|
|
21
21
|
"./swr": {
|
|
22
22
|
"types": "./dist/swr.d.ts",
|
|
23
23
|
"default": "./dist/swr.js"
|
|
24
24
|
},
|
|
25
25
|
"./utils": {
|
|
26
|
-
"types": "./dist/utils.d.ts",
|
|
27
|
-
"default": "./dist/utils.js"
|
|
26
|
+
"types": "./dist/utils/index.d.ts",
|
|
27
|
+
"default": "./dist/utils/index.js"
|
|
28
28
|
},
|
|
29
29
|
"./ssr": {
|
|
30
30
|
"types": "./dist/ssr/index.d.ts",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
},
|
|
76
76
|
"scripts": {
|
|
77
77
|
"build": "rm -rf dist && pnpm i && tsc",
|
|
78
|
-
"test": "node --test",
|
|
78
|
+
"test": "node --test dist/**/*.test.js",
|
|
79
79
|
"dev": "tsc --watch"
|
|
80
80
|
}
|
|
81
81
|
}
|
package/src/action.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export type ActionResult<T> =
|
|
2
|
+
| {
|
|
3
|
+
error: ActionError
|
|
4
|
+
data: null
|
|
5
|
+
}
|
|
6
|
+
| {
|
|
7
|
+
error: null
|
|
8
|
+
data: T
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface ActionConfig<T> {
|
|
12
|
+
/**
|
|
13
|
+
* Executes the action and returns the result.
|
|
14
|
+
*/
|
|
15
|
+
execute: () => Promise<T>
|
|
16
|
+
/**
|
|
17
|
+
* Called when the action fails.
|
|
18
|
+
*/
|
|
19
|
+
onError?: (error: ActionError) => void
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export class ActionError extends Error {
|
|
23
|
+
constructor(cause: unknown) {
|
|
24
|
+
super("Error occurred during action execution", { cause })
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function defineAction<T extends readonly unknown[], R>(
|
|
29
|
+
callback: (...args: T) => ActionConfig<R>
|
|
30
|
+
): (...args: T) => Promise<ActionResult<R>> {
|
|
31
|
+
return async (...args: T) => {
|
|
32
|
+
const { execute, onError } = callback(...args)
|
|
33
|
+
try {
|
|
34
|
+
const data = await execute()
|
|
35
|
+
return { error: null, data }
|
|
36
|
+
} catch (e) {
|
|
37
|
+
const error = new ActionError(e)
|
|
38
|
+
onError?.(error)
|
|
39
|
+
return { error, data: null }
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { createElement } from "
|
|
2
|
-
import { __DEV__ } from "
|
|
3
|
-
import { KiruError } from "
|
|
4
|
-
import { node, renderMode } from "
|
|
5
|
-
import { useContext } from "
|
|
6
|
-
import { useRef } from "
|
|
7
|
-
import { useRequestUpdate } from "
|
|
8
|
-
import { hydrationStack } from "
|
|
9
|
-
import { flushSync, nextIdle } from "
|
|
1
|
+
import { createElement } from "../element.js"
|
|
2
|
+
import { __DEV__ } from "../env.js"
|
|
3
|
+
import { KiruError } from "../error.js"
|
|
4
|
+
import { node, renderMode } from "../globals.js"
|
|
5
|
+
import { useContext } from "../hooks/useContext.js"
|
|
6
|
+
import { useRef } from "../hooks/useRef.js"
|
|
7
|
+
import { useRequestUpdate } from "../hooks/utils.js"
|
|
8
|
+
import { hydrationStack } from "../hydration.js"
|
|
9
|
+
import { flushSync, nextIdle } from "../scheduler.js"
|
|
10
10
|
import {
|
|
11
11
|
HYDRATION_BOUNDARY_MARKER,
|
|
12
12
|
HydrationBoundaryContext,
|
|
13
|
-
} from "
|
|
14
|
-
import
|
|
15
|
-
import {
|
|
13
|
+
} from "../ssr/hydrationBoundary.js"
|
|
14
|
+
import { noop } from "../utils/index.js"
|
|
15
|
+
import type { SomeDom } from "../types.utils"
|
|
16
16
|
|
|
17
17
|
interface FCModule {
|
|
18
18
|
default: Kiru.FC<any>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { $MEMO } from "
|
|
2
|
-
import { createElement } from "
|
|
3
|
-
import { __DEV__ } from "
|
|
1
|
+
import { $MEMO } from "../constants.js"
|
|
2
|
+
import { createElement } from "../element.js"
|
|
3
|
+
import { __DEV__ } from "../env.js"
|
|
4
4
|
|
|
5
5
|
function _arePropsEqual<T extends Record<string, unknown>>(
|
|
6
6
|
prevProps: T,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { FLAG_STATIC_DOM } from "
|
|
2
|
-
import { __DEV__ } from "
|
|
3
|
-
import { KiruError } from "
|
|
4
|
-
import { renderMode } from "
|
|
5
|
-
import { useVNode } from "
|
|
6
|
-
import { nextIdle, requestUpdate } from "
|
|
1
|
+
import { FLAG_STATIC_DOM } from "../constants.js"
|
|
2
|
+
import { __DEV__ } from "../env.js"
|
|
3
|
+
import { KiruError } from "../error.js"
|
|
4
|
+
import { renderMode } from "../globals.js"
|
|
5
|
+
import { useVNode } from "../hooks/utils.js"
|
|
6
|
+
import { nextIdle, requestUpdate } from "../scheduler.js"
|
|
7
7
|
|
|
8
8
|
interface PortalProps {
|
|
9
9
|
children?: JSX.Children
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { createElement } from "
|
|
1
|
+
import { createElement } from "../../element.js"
|
|
2
2
|
import {
|
|
3
3
|
useState,
|
|
4
4
|
useMemo,
|
|
5
5
|
useContext,
|
|
6
6
|
useLayoutEffect,
|
|
7
7
|
useRef,
|
|
8
|
-
} from "
|
|
9
|
-
import { __DEV__ } from "
|
|
8
|
+
} from "../../hooks/index.js"
|
|
9
|
+
import { __DEV__ } from "../../env.js"
|
|
10
|
+
import { createContext } from "../../context.js"
|
|
11
|
+
import { isRoute, Route } from "./route.js"
|
|
12
|
+
import { noop } from "../../utils/index.js"
|
|
13
|
+
import { node } from "../../globals.js"
|
|
14
|
+
import type { ElementProps } from "../../types.js"
|
|
15
|
+
import { flushSync, nextIdle } from "../../scheduler.js"
|
|
10
16
|
import {
|
|
11
17
|
parsePathParams,
|
|
12
18
|
parseSearchParams,
|
|
13
19
|
routeMatchesPath,
|
|
14
20
|
} from "./routerUtils.js"
|
|
15
|
-
import { createContext } from "../context.js"
|
|
16
|
-
import { isRoute, Route } from "./route.js"
|
|
17
|
-
import { noop } from "../utils.js"
|
|
18
|
-
import { node } from "../globals.js"
|
|
19
|
-
import type { ElementProps } from "../types"
|
|
20
|
-
import { flushSync, nextIdle } from "../scheduler.js"
|
|
21
21
|
|
|
22
22
|
export interface LinkProps extends Omit<ElementProps<"a">, "href"> {
|
|
23
23
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { useCallback } from "
|
|
2
|
-
import { useEffect } from "
|
|
3
|
-
import { useLayoutEffect } from "
|
|
4
|
-
import { useRef } from "
|
|
5
|
-
import { useState } from "
|
|
1
|
+
import { useCallback } from "../hooks/useCallback.js"
|
|
2
|
+
import { useEffect } from "../hooks/useEffect.js"
|
|
3
|
+
import { useLayoutEffect } from "../hooks/useLayoutEffect.js"
|
|
4
|
+
import { useRef } from "../hooks/useRef.js"
|
|
5
|
+
import { useState } from "../hooks/useState.js"
|
|
6
6
|
|
|
7
7
|
export type TransitionState = "entering" | "entered" | "exiting" | "exited"
|
|
8
8
|
interface TransitionProps {
|
package/src/constants.ts
CHANGED
|
@@ -19,7 +19,7 @@ export {
|
|
|
19
19
|
FLAG_DIRTY,
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export { voidElements, svgTags, booleanAttributes }
|
|
22
|
+
export { voidElements, svgTags, booleanAttributes, snakeCaseAttributes }
|
|
23
23
|
|
|
24
24
|
const $SIGNAL = Symbol.for("kiru.signal")
|
|
25
25
|
const $CONTEXT = Symbol.for("kiru.context")
|
|
@@ -155,3 +155,82 @@ const booleanAttributes = new Set([
|
|
|
155
155
|
"translate",
|
|
156
156
|
"wrap",
|
|
157
157
|
])
|
|
158
|
+
|
|
159
|
+
const snakeCaseAttributes = new Map([
|
|
160
|
+
["acceptCharset", "accept-charset"],
|
|
161
|
+
["accentHeight", "accent-height"],
|
|
162
|
+
["alignmentBaseline", "alignment-baseline"],
|
|
163
|
+
["arabicForm", "arabic-form"],
|
|
164
|
+
["baselineShift", "baseline-shift"],
|
|
165
|
+
["capHeight", "cap-height"],
|
|
166
|
+
["clipPath", "clip-path"],
|
|
167
|
+
["clipRule", "clip-rule"],
|
|
168
|
+
["colorInterpolation", "color-interpolation"],
|
|
169
|
+
["colorInterpolationFilters", "color-interpolation-filters"],
|
|
170
|
+
["colorProfile", "color-profile"],
|
|
171
|
+
["colorRendering", "color-rendering"],
|
|
172
|
+
["dominantBaseline", "dominant-baseline"],
|
|
173
|
+
["enableBackground", "enable-background"],
|
|
174
|
+
["fillOpacity", "fill-opacity"],
|
|
175
|
+
["fillRule", "fill-rule"],
|
|
176
|
+
["floodColor", "flood-color"],
|
|
177
|
+
["floodOpacity", "flood-opacity"],
|
|
178
|
+
["fontFamily", "font-family"],
|
|
179
|
+
["fontSize", "font-size"],
|
|
180
|
+
["fontSizeAdjust", "font-size-adjust"],
|
|
181
|
+
["fontStretch", "font-stretch"],
|
|
182
|
+
["fontStyle", "font-style"],
|
|
183
|
+
["fontVariant", "font-variant"],
|
|
184
|
+
["fontWeight", "font-weight"],
|
|
185
|
+
["glyphName", "glyph-name"],
|
|
186
|
+
["glyphOrientationHorizontal", "glyph-orientation-horizontal"],
|
|
187
|
+
["glyphOrientationVertical", "glyph-orientation-vertical"],
|
|
188
|
+
["horizAdvX", "horiz-adv-x"],
|
|
189
|
+
["horizOriginX", "horiz-origin-x"],
|
|
190
|
+
["httpEquiv", "http-equiv"],
|
|
191
|
+
["imageRendering", "image-rendering"],
|
|
192
|
+
["letterSpacing", "letter-spacing"],
|
|
193
|
+
["lightingColor", "lighting-color"],
|
|
194
|
+
["markerEnd", "marker-end"],
|
|
195
|
+
["markerMid", "marker-mid"],
|
|
196
|
+
["markerStart", "marker-start"],
|
|
197
|
+
["overlinePosition", "overline-position"],
|
|
198
|
+
["overlineThickness", "overline-thickness"],
|
|
199
|
+
["paintOrder", "paint-order"],
|
|
200
|
+
["panose-1", "panose-1"],
|
|
201
|
+
["pointerEvents", "pointer-events"],
|
|
202
|
+
["renderingIntent", "rendering-intent"],
|
|
203
|
+
["shapeRendering", "shape-rendering"],
|
|
204
|
+
["stopColor", "stop-color"],
|
|
205
|
+
["stopOpacity", "stop-opacity"],
|
|
206
|
+
["strikethroughPosition", "strikethrough-position"],
|
|
207
|
+
["strikethroughThickness", "strikethrough-thickness"],
|
|
208
|
+
["strokeDasharray", "stroke-dasharray"],
|
|
209
|
+
["strokeDashoffset", "stroke-dashoffset"],
|
|
210
|
+
["strokeLinecap", "stroke-linecap"],
|
|
211
|
+
["strokeLinejoin", "stroke-linejoin"],
|
|
212
|
+
["strokeMiterlimit", "stroke-miterlimit"],
|
|
213
|
+
["strokeOpacity", "stroke-opacity"],
|
|
214
|
+
["strokeWidth", "stroke-width"],
|
|
215
|
+
["textAnchor", "text-anchor"],
|
|
216
|
+
["textDecoration", "text-decoration"],
|
|
217
|
+
["textRendering", "text-rendering"],
|
|
218
|
+
["transformOrigin", "transform-origin"],
|
|
219
|
+
["underlinePosition", "underline-position"],
|
|
220
|
+
["underlineThickness", "underline-thickness"],
|
|
221
|
+
["unicodeBidi", "unicode-bidi"],
|
|
222
|
+
["unicodeRange", "unicode-range"],
|
|
223
|
+
["unitsPerEm", "units-per-em"],
|
|
224
|
+
["vAlphabetic", "v-alphabetic"],
|
|
225
|
+
["vHanging", "v-hanging"],
|
|
226
|
+
["vIdeographic", "v-ideographic"],
|
|
227
|
+
["vMathematical", "v-mathematical"],
|
|
228
|
+
["vectorEffect", "vector-effect"],
|
|
229
|
+
["vertAdvY", "vert-adv-y"],
|
|
230
|
+
["vertOriginX", "vert-origin-x"],
|
|
231
|
+
["vertOriginY", "vert-origin-y"],
|
|
232
|
+
["wordSpacing", "word-spacing"],
|
|
233
|
+
["writingMode", "writing-mode"],
|
|
234
|
+
["xmlnsXlink", "xmlns:xlink"],
|
|
235
|
+
["xHeight", "x-height"],
|
|
236
|
+
])
|
package/src/context.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { __DEV__ } from "./env.js"
|
|
|
4
4
|
import { GenericHMRAcceptor } from "./hmr.js"
|
|
5
5
|
import { useState } from "./hooks/useState.js"
|
|
6
6
|
import { requestUpdate } from "./scheduler.js"
|
|
7
|
-
import { traverseApply } from "./utils.js"
|
|
7
|
+
import { traverseApply } from "./utils/index.js"
|
|
8
8
|
|
|
9
9
|
export function createContext<T>(defaultValue: T): Kiru.Context<T> {
|
|
10
10
|
const ctx: Kiru.Context<T> = {
|
package/src/customEvents.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
export class CustomEvents {
|
|
2
|
-
private constructor() {}
|
|
3
|
-
|
|
4
|
-
static on<K extends keyof Kiru.CustomEvents & string>(
|
|
5
|
-
type: K,
|
|
6
|
-
callback: (event: CustomEvent<Kiru.CustomEvents[K]>) => void
|
|
7
|
-
) {
|
|
8
|
-
window.addEventListener(type, callback as unknown as EventListener)
|
|
9
|
-
return () =>
|
|
10
|
-
window.removeEventListener(type, callback as unknown as EventListener)
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
static dispatch<K extends keyof Kiru.CustomEvents & string>(
|
|
14
|
-
type: K,
|
|
15
|
-
detail: Kiru.CustomEvents[K],
|
|
16
|
-
target?: Element
|
|
17
|
-
) {
|
|
18
|
-
;(target || document).dispatchEvent(
|
|
19
|
-
new CustomEvent(type, { detail, bubbles: true })
|
|
20
|
-
)
|
|
21
|
-
}
|
|
22
|
-
}
|
|
1
|
+
export class CustomEvents {
|
|
2
|
+
private constructor() {}
|
|
3
|
+
|
|
4
|
+
static on<K extends keyof Kiru.CustomEvents & string>(
|
|
5
|
+
type: K,
|
|
6
|
+
callback: (event: CustomEvent<Kiru.CustomEvents[K]>) => void
|
|
7
|
+
) {
|
|
8
|
+
window.addEventListener(type, callback as unknown as EventListener)
|
|
9
|
+
return () =>
|
|
10
|
+
window.removeEventListener(type, callback as unknown as EventListener)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
static dispatch<K extends keyof Kiru.CustomEvents & string>(
|
|
14
|
+
type: K,
|
|
15
|
+
detail: Kiru.CustomEvents[K],
|
|
16
|
+
target?: Element
|
|
17
|
+
) {
|
|
18
|
+
;(target || document).dispatchEvent(
|
|
19
|
+
new CustomEvent(type, { detail, bubbles: true })
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
}
|
package/src/dom.ts
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
propFilters,
|
|
5
5
|
propToHtmlAttr,
|
|
6
6
|
getVNodeAppContext,
|
|
7
|
-
} from "./utils.js"
|
|
7
|
+
} from "./utils/index.js"
|
|
8
8
|
import {
|
|
9
9
|
booleanAttributes,
|
|
10
10
|
FLAG_PLACEMENT,
|
|
@@ -100,15 +100,14 @@ function createDom(vNode: DomVNode): SomeDom {
|
|
|
100
100
|
return dom
|
|
101
101
|
}
|
|
102
102
|
function createTextNode(vNode: VNode): Text {
|
|
103
|
-
const nodeValue = vNode.props
|
|
104
|
-
if (Signal.isSignal(nodeValue)) {
|
|
105
|
-
|
|
106
|
-
const textNode = document.createTextNode(value)
|
|
107
|
-
subTextNode(vNode, textNode, nodeValue)
|
|
108
|
-
return textNode
|
|
103
|
+
const { nodeValue } = vNode.props
|
|
104
|
+
if (!Signal.isSignal(nodeValue)) {
|
|
105
|
+
return document.createTextNode(nodeValue)
|
|
109
106
|
}
|
|
110
107
|
|
|
111
|
-
const
|
|
108
|
+
const value = nodeValue.peek() ?? ""
|
|
109
|
+
const textNode = document.createTextNode(value)
|
|
110
|
+
subTextNode(vNode, textNode, nodeValue)
|
|
112
111
|
return textNode
|
|
113
112
|
}
|
|
114
113
|
|
package/src/element.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { $FRAGMENT, $MEMO, FLAG_MEMO } from "./constants.js"
|
|
2
|
-
import { isMemoFn } from "./memo.js"
|
|
3
|
-
import { isValidElementKeyProp, isValidElementRefProp } from "./
|
|
2
|
+
import { isMemoFn } from "./components/memo.js"
|
|
3
|
+
import { isValidElementKeyProp, isValidElementRefProp } from "./utils/index.js"
|
|
4
4
|
|
|
5
5
|
export function createElement<T extends Kiru.VNode["type"]>(
|
|
6
6
|
type: T,
|
package/src/error.ts
CHANGED
package/src/form/index.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { __DEV__ } from "../env.js"
|
|
2
2
|
import { Fragment } from "../element.js"
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import {
|
|
4
|
+
safeStringify,
|
|
5
|
+
shallowCompare,
|
|
6
|
+
generateRandomID,
|
|
7
|
+
} from "../utils/index.js"
|
|
5
8
|
import { useEffect } from "../hooks/useEffect.js"
|
|
6
9
|
import { useMemo } from "../hooks/useMemo.js"
|
|
7
10
|
import { useRef } from "../hooks/useRef.js"
|
package/src/hmr.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { $HMR_ACCEPT } from "./constants.js"
|
|
2
2
|
import { __DEV__ } from "./env.js"
|
|
3
|
-
import { traverseApply } from "./utils.js"
|
|
3
|
+
import { traverseApply } from "./utils/index.js"
|
|
4
4
|
import { requestUpdate } from "./scheduler.js"
|
|
5
5
|
import { Signal } from "./signals/base.js"
|
|
6
6
|
import type { WatchEffect } from "./signals/watch.js"
|
package/src/hooks/useAsync.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __DEV__ } from "../env.js"
|
|
2
|
-
import { noop } from "../utils.js"
|
|
3
|
-
import { depsRequireChange,
|
|
2
|
+
import { noop, sideEffectsEnabled } from "../utils/index.js"
|
|
3
|
+
import { depsRequireChange, useHook } from "./utils.js"
|
|
4
4
|
import type { AsyncTaskState } from "../types.utils.js"
|
|
5
5
|
|
|
6
6
|
export type UseAsyncState<T> = AsyncTaskState<T, UseAsyncError> & {
|
|
@@ -48,7 +48,9 @@ export function useAsync<T>(
|
|
|
48
48
|
deps,
|
|
49
49
|
id: 0,
|
|
50
50
|
task: null as any as InternalTaskState<T>,
|
|
51
|
-
load: noop as (
|
|
51
|
+
load: noop as (
|
|
52
|
+
func: (ctx: UseAsyncCallbackContext) => Promise<T>
|
|
53
|
+
) => void,
|
|
52
54
|
},
|
|
53
55
|
({ hook, isInit, isHMR, update }) => {
|
|
54
56
|
if (__DEV__) {
|
package/src/hooks/useCallback.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { __DEV__ } from "../env.js"
|
|
2
|
-
import {
|
|
2
|
+
import { sideEffectsEnabled } from "../utils/index.js"
|
|
3
|
+
import { depsRequireChange, useHook } from "./utils.js"
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Creates a memoized callback function.
|
package/src/hooks/useEffect.ts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
+
import { sideEffectsEnabled } from "../utils/index.js"
|
|
1
2
|
import { __DEV__ } from "../env.js"
|
|
2
|
-
import {
|
|
3
|
-
cleanupHook,
|
|
4
|
-
depsRequireChange,
|
|
5
|
-
sideEffectsEnabled,
|
|
6
|
-
useHook,
|
|
7
|
-
} from "./utils.js"
|
|
3
|
+
import { cleanupHook, depsRequireChange, useHook } from "./utils.js"
|
|
8
4
|
|
|
9
5
|
/**
|
|
10
6
|
* Runs a function after the component is rendered, or when a value provided in the optional [dependency
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { sideEffectsEnabled } from "../utils/index.js"
|
|
1
2
|
import { node } from "../globals.js"
|
|
2
3
|
import { __DEV__ } from "../env.js"
|
|
3
|
-
import {
|
|
4
|
+
import { useHook } from "./utils.js"
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Wraps a function to be called within effects and other callbacks.
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
+
import { sideEffectsEnabled } from "../utils/index.js"
|
|
1
2
|
import { __DEV__ } from "../env.js"
|
|
2
|
-
import {
|
|
3
|
-
cleanupHook,
|
|
4
|
-
depsRequireChange,
|
|
5
|
-
sideEffectsEnabled,
|
|
6
|
-
useHook,
|
|
7
|
-
} from "./utils.js"
|
|
3
|
+
import { cleanupHook, depsRequireChange, useHook } from "./utils.js"
|
|
8
4
|
|
|
9
5
|
/**
|
|
10
6
|
* Runs a function before the component is rendered, or when a value provided in the optional [dependency
|
package/src/hooks/useMemo.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { sideEffectsEnabled } from "../utils/index.js"
|
|
1
2
|
import { __DEV__ } from "../env.js"
|
|
2
|
-
import { depsRequireChange,
|
|
3
|
+
import { depsRequireChange, useHook } from "./utils.js"
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Creates a memoized value that only changes when the [dependency
|
package/src/hooks/useReducer.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __DEV__ } from "../env.js"
|
|
2
|
-
import { noop } from "../utils.js"
|
|
3
|
-
import {
|
|
2
|
+
import { noop, sideEffectsEnabled } from "../utils/index.js"
|
|
3
|
+
import { useHook } from "./utils.js"
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Creates 'dispatcher-driven' state.
|
package/src/hooks/useRef.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { __DEV__ } from "../env.js"
|
|
2
|
-
import { sideEffectsEnabled
|
|
2
|
+
import { sideEffectsEnabled } from "../utils/index.js"
|
|
3
|
+
import { useHook } from "./utils.js"
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Creates a ref object. Useful for persisting values between renders or getting
|