valyrian.js 7.2.12 → 8.0.1
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 +6 -6
- package/dist/flux-store/index.d.ts +32 -0
- package/dist/flux-store/index.d.ts.map +1 -0
- package/dist/flux-store/index.js +267 -0
- package/dist/flux-store/index.js.map +7 -0
- package/dist/flux-store/index.min.js +1 -0
- package/dist/flux-store/index.min.js.map +1 -0
- package/dist/flux-store/index.mjs +246 -0
- package/dist/flux-store/index.mjs.map +7 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +35 -51
- package/dist/hooks/index.js.map +3 -3
- package/dist/hooks/index.min.js +1 -0
- package/dist/hooks/index.min.js.map +1 -0
- package/dist/hooks/index.mjs +36 -52
- package/dist/hooks/index.mjs.map +3 -3
- package/dist/index.d.ts +18 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +107 -88
- package/dist/index.js.map +3 -3
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +107 -88
- package/dist/index.mjs.map +3 -3
- package/dist/native-store/index.d.ts +14 -0
- package/dist/native-store/index.d.ts.map +1 -0
- package/dist/native-store/index.js +103 -0
- package/dist/native-store/index.js.map +7 -0
- package/dist/native-store/index.min.js +1 -0
- package/dist/native-store/index.min.js.map +1 -0
- package/dist/native-store/index.mjs +82 -0
- package/dist/native-store/index.mjs.map +7 -0
- package/dist/node/index.d.ts +1 -1
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +125 -10
- package/dist/node/index.js.map +4 -4
- package/dist/node/index.mjs +125 -10
- package/dist/node/index.mjs.map +4 -4
- package/dist/node/node.sw.js +152 -0
- package/dist/node/utils/icons.d.ts +4 -5
- package/dist/node/utils/icons.d.ts.map +1 -1
- package/dist/node/utils/inline.d.ts +1 -1
- package/dist/node/utils/inline.d.ts.map +1 -1
- package/dist/node/utils/node.sw.js +152 -0
- package/dist/node/utils/session-storage.d.ts +22 -0
- package/dist/node/utils/session-storage.d.ts.map +1 -0
- package/dist/node/utils/sw.d.ts.map +1 -1
- package/dist/node/utils/tree-adapter.d.ts +5 -1
- package/dist/node/utils/tree-adapter.d.ts.map +1 -1
- package/dist/pulse-store/index.d.ts +16 -0
- package/dist/pulse-store/index.d.ts.map +1 -0
- package/dist/pulse-store/index.js +143 -0
- package/dist/pulse-store/index.js.map +7 -0
- package/dist/pulse-store/index.min.js +1 -0
- package/dist/pulse-store/index.min.js.map +1 -0
- package/dist/pulse-store/index.mjs +122 -0
- package/dist/pulse-store/index.mjs.map +7 -0
- package/dist/request/index.d.ts +11 -11
- package/dist/request/index.d.ts.map +1 -1
- package/dist/request/index.js +63 -84
- package/dist/request/index.js.map +2 -2
- package/dist/request/index.min.js +1 -0
- package/dist/request/index.min.js.map +1 -0
- package/dist/request/index.mjs +63 -84
- package/dist/request/index.mjs.map +2 -2
- package/dist/router/index.d.ts +36 -33
- package/dist/router/index.d.ts.map +1 -1
- package/dist/router/index.js +247 -96
- package/dist/router/index.js.map +3 -3
- package/dist/router/index.min.js +1 -0
- package/dist/router/index.min.js.map +1 -0
- package/dist/router/index.mjs +247 -96
- package/dist/router/index.mjs.map +3 -3
- package/dist/signals/index.d.ts +6 -0
- package/dist/signals/index.d.ts.map +1 -0
- package/dist/signals/index.js +92 -0
- package/dist/signals/index.js.map +7 -0
- package/dist/signals/index.min.js +1 -0
- package/dist/signals/index.min.js.map +1 -0
- package/dist/signals/index.mjs +71 -0
- package/dist/signals/index.mjs.map +7 -0
- package/dist/suspense/index.d.ts +6 -0
- package/dist/suspense/index.d.ts.map +1 -0
- package/dist/suspense/index.js +67 -0
- package/dist/suspense/index.js.map +7 -0
- package/dist/suspense/index.min.js +1 -0
- package/dist/suspense/index.min.js.map +1 -0
- package/dist/suspense/index.mjs +46 -0
- package/dist/suspense/index.mjs.map +7 -0
- package/dist/sw/index.min.js +1 -0
- package/dist/sw/index.min.js.map +1 -0
- package/dist/translate/index.d.ts +19 -0
- package/dist/translate/index.d.ts.map +1 -0
- package/dist/translate/index.js +150 -0
- package/dist/translate/index.js.map +7 -0
- package/dist/translate/index.min.js +1 -0
- package/dist/translate/index.min.js.map +1 -0
- package/dist/translate/index.mjs +129 -0
- package/dist/translate/index.mjs.map +7 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/deep-freeze.d.ts +3 -0
- package/dist/utils/deep-freeze.d.ts.map +1 -0
- package/dist/utils/getter-setter.d.ts +3 -0
- package/dist/utils/getter-setter.d.ts.map +1 -0
- package/dist/utils/has-changed.d.ts +2 -0
- package/dist/utils/has-changed.d.ts.map +1 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +138 -0
- package/dist/utils/index.js.map +7 -0
- package/dist/utils/index.min.js +1 -0
- package/dist/utils/index.min.js.map +1 -0
- package/dist/utils/index.mjs +115 -0
- package/dist/utils/index.mjs.map +7 -0
- package/lib/flux-store/index.ts +312 -0
- package/lib/hooks/index.ts +39 -57
- package/lib/index.ts +135 -118
- package/lib/native-store/index.ts +106 -0
- package/lib/node/index.ts +3 -1
- package/lib/node/utils/icons.ts +4 -4
- package/lib/node/utils/inline.ts +2 -0
- package/lib/node/utils/node.sw.js +152 -0
- package/lib/node/utils/session-storage.ts +117 -0
- package/lib/node/utils/sw.ts +34 -10
- package/lib/node/utils/tree-adapter.ts +19 -1
- package/lib/pulse-store/index.ts +188 -0
- package/lib/request/index.ts +92 -122
- package/lib/router/index.ts +353 -164
- package/lib/signals/index.ts +98 -0
- package/lib/suspense/index.ts +57 -0
- package/lib/translate/index.ts +156 -0
- package/lib/utils/deep-freeze.ts +54 -0
- package/lib/utils/getter-setter.ts +40 -0
- package/lib/utils/has-changed.ts +43 -0
- package/lib/utils/index.ts +3 -0
- package/package.json +40 -57
- package/tsconfig.json +5 -4
- package/dist/dataset/index.d.ts +0 -24
- package/dist/dataset/index.d.ts.map +0 -1
- package/dist/dataset/index.js +0 -178
- package/dist/dataset/index.js.map +0 -7
- package/dist/dataset/index.mjs +0 -157
- package/dist/dataset/index.mjs.map +0 -7
- package/dist/node/node.sw.tpl +0 -133
- package/dist/node/utils/node.sw.tpl +0 -133
- package/dist/proxy-signal/index.d.ts +0 -23
- package/dist/proxy-signal/index.d.ts.map +0 -1
- package/dist/proxy-signal/index.js +0 -138
- package/dist/proxy-signal/index.js.map +0 -7
- package/dist/proxy-signal/index.mjs +0 -117
- package/dist/proxy-signal/index.mjs.map +0 -7
- package/dist/signal/index.d.ts +0 -9
- package/dist/signal/index.d.ts.map +0 -1
- package/dist/signal/index.js +0 -76
- package/dist/signal/index.js.map +0 -7
- package/dist/signal/index.mjs +0 -55
- package/dist/signal/index.mjs.map +0 -7
- package/dist/store/index.d.ts +0 -16
- package/dist/store/index.d.ts.map +0 -1
- package/dist/store/index.js +0 -93
- package/dist/store/index.js.map +0 -7
- package/dist/store/index.mjs +0 -72
- package/dist/store/index.mjs.map +0 -7
- package/lib/dataset/index.ts +0 -193
- package/lib/node/utils/node.sw.tpl +0 -133
- package/lib/proxy-signal/index.ts +0 -187
- package/lib/signal/index.ts +0 -86
- package/lib/store/index.ts +0 -101
package/dist/hooks/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// lib/hooks/index.ts
|
|
2
|
-
import { current, directive, onCleanup, onUnmount,
|
|
2
|
+
import { current, directive, onCleanup, onUnmount, debouncedUpdate } from "valyrian.js";
|
|
3
|
+
import { hasChanged } from "valyrian.js/utils";
|
|
3
4
|
var componentToHooksWeakMap = /* @__PURE__ */ new WeakMap();
|
|
4
5
|
var createHook = function createHook2({
|
|
5
6
|
onCreate,
|
|
@@ -10,19 +11,19 @@ var createHook = function createHook2({
|
|
|
10
11
|
}) {
|
|
11
12
|
return (...args) => {
|
|
12
13
|
const component = current.component;
|
|
13
|
-
let
|
|
14
|
-
if (
|
|
15
|
-
|
|
16
|
-
componentToHooksWeakMap.set(component,
|
|
17
|
-
onUnmount(() =>
|
|
14
|
+
let HookCalls = componentToHooksWeakMap.get(component);
|
|
15
|
+
if (!HookCalls) {
|
|
16
|
+
HookCalls = { hooks: [], hook_calls: -1 };
|
|
17
|
+
componentToHooksWeakMap.set(component, HookCalls);
|
|
18
|
+
onUnmount(() => {
|
|
19
|
+
componentToHooksWeakMap.delete(component);
|
|
20
|
+
});
|
|
18
21
|
}
|
|
19
|
-
const HookCalls = componentToHooksWeakMap.get(component);
|
|
20
22
|
onCleanup(() => HookCalls.hook_calls = -1);
|
|
21
|
-
hook = HookCalls.hooks[++HookCalls.hook_calls];
|
|
23
|
+
let hook = HookCalls.hooks[++HookCalls.hook_calls];
|
|
22
24
|
if (hook) {
|
|
23
|
-
onUpdateHook
|
|
24
|
-
}
|
|
25
|
-
if (!hook) {
|
|
25
|
+
onUpdateHook?.(hook, ...args);
|
|
26
|
+
} else {
|
|
26
27
|
hook = onCreate(...args);
|
|
27
28
|
HookCalls.hooks.push(hook);
|
|
28
29
|
onRemove && onUnmount(() => onRemove(hook));
|
|
@@ -31,27 +32,20 @@ var createHook = function createHook2({
|
|
|
31
32
|
return returnValue ? returnValue(hook) : hook;
|
|
32
33
|
};
|
|
33
34
|
};
|
|
34
|
-
var updateTimeout;
|
|
35
|
-
function delayedUpdate() {
|
|
36
|
-
clearTimeout(updateTimeout);
|
|
37
|
-
updateTimeout = setTimeout(update);
|
|
38
|
-
}
|
|
39
35
|
var useState = createHook({
|
|
40
36
|
onCreate: (value) => {
|
|
37
|
+
let state = value;
|
|
41
38
|
function get() {
|
|
42
|
-
return
|
|
39
|
+
return state;
|
|
43
40
|
}
|
|
44
|
-
get.value = value;
|
|
45
|
-
get.toJSON = get.valueOf = get;
|
|
46
|
-
get.toString = () => `${value}`;
|
|
47
41
|
function set(newValue) {
|
|
48
|
-
if (current.event) {
|
|
42
|
+
if (current.event && !current.event.defaultPrevented) {
|
|
49
43
|
current.event.preventDefault();
|
|
50
44
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
45
|
+
const resolvedValue = typeof newValue === "function" ? newValue(state) : newValue;
|
|
46
|
+
if (hasChanged(state, resolvedValue)) {
|
|
47
|
+
state = resolvedValue;
|
|
48
|
+
debouncedUpdate();
|
|
55
49
|
}
|
|
56
50
|
}
|
|
57
51
|
return [get, set];
|
|
@@ -77,17 +71,15 @@ var useEffect = createHook({
|
|
|
77
71
|
hook.onCleanup = hook.effect();
|
|
78
72
|
return;
|
|
79
73
|
}
|
|
80
|
-
if (Array.isArray(changes)) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
hook.onCleanup = hook.effect();
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
74
|
+
if (Array.isArray(changes) && changes.length === 0) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
if (Array.isArray(changes) && hasChanged(hook.prev, changes)) {
|
|
78
|
+
hook.prev = changes;
|
|
79
|
+
if (typeof hook.onCleanup === "function") {
|
|
80
|
+
hook.onCleanup();
|
|
90
81
|
}
|
|
82
|
+
hook.onCleanup = hook.effect();
|
|
91
83
|
}
|
|
92
84
|
},
|
|
93
85
|
onRemove: (hook) => {
|
|
@@ -109,35 +101,27 @@ var useRef = createHook({
|
|
|
109
101
|
});
|
|
110
102
|
var useCallback = createHook({
|
|
111
103
|
onCreate: (callback, changes) => {
|
|
112
|
-
callback();
|
|
113
104
|
return { callback, changes };
|
|
114
105
|
},
|
|
115
106
|
onUpdate: (hook, callback, changes) => {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
hook.callback();
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
107
|
+
if (hasChanged(hook.changes, changes)) {
|
|
108
|
+
hook.changes = changes;
|
|
109
|
+
hook.callback = callback;
|
|
122
110
|
}
|
|
123
|
-
}
|
|
111
|
+
},
|
|
112
|
+
returnValue: (hook) => hook.callback
|
|
124
113
|
});
|
|
125
114
|
var useMemo = createHook({
|
|
126
115
|
onCreate: (callback, changes) => {
|
|
127
116
|
return { callback, changes, value: callback() };
|
|
128
117
|
},
|
|
129
118
|
onUpdate: (hook, callback, changes) => {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
hook.value = callback();
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
119
|
+
if (hasChanged(hook.changes, changes)) {
|
|
120
|
+
hook.changes = changes;
|
|
121
|
+
hook.value = callback();
|
|
136
122
|
}
|
|
137
123
|
},
|
|
138
|
-
returnValue: (hook) =>
|
|
139
|
-
return hook.value;
|
|
140
|
-
}
|
|
124
|
+
returnValue: (hook) => hook.value
|
|
141
125
|
});
|
|
142
126
|
export {
|
|
143
127
|
createHook,
|
package/dist/hooks/index.mjs.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../lib/hooks/index.ts"],
|
|
4
|
-
"sourcesContent": ["import { Component, POJOComponent, current, directive, onCleanup, onUnmount,
|
|
5
|
-
"mappings": ";AAAA,SAAmC,SAAS,WAAW,WAAW,WAAW,
|
|
6
|
-
"names": ["createHook"
|
|
4
|
+
"sourcesContent": ["import { Component, POJOComponent, current, directive, onCleanup, onUnmount, debouncedUpdate } from \"valyrian.js\";\nimport { hasChanged } from \"valyrian.js/utils\";\n\nexport type Hook = any;\n\nexport interface HookDefinition {\n // eslint-disable-next-line no-unused-vars\n onCreate: (...args: any[]) => any;\n // eslint-disable-next-line no-unused-vars\n onUpdate?: (hook: Hook, ...args: any[]) => any;\n // eslint-disable-next-line no-unused-vars\n onCleanup?: (hook: Hook) => any;\n // eslint-disable-next-line no-unused-vars\n onRemove?: (hook: Hook) => any;\n // eslint-disable-next-line no-unused-vars\n returnValue?: (hook: Hook) => any;\n}\n\nexport interface CreateHook {\n // eslint-disable-next-line no-unused-vars\n (HookDefinition: HookDefinition): (...args: any[]) => any;\n}\n\ntype HookCalls = {\n hooks: Hook[];\n hook_calls: number;\n};\n\nconst componentToHooksWeakMap = new WeakMap<Component | POJOComponent, HookCalls>();\n\nexport const createHook = function createHook({\n onCreate,\n onUpdate: onUpdateHook,\n onCleanup: onCleanupHook,\n onRemove,\n returnValue\n}: HookDefinition): Hook {\n return (...args: any[]) => {\n const component = current.component as Component | POJOComponent;\n let HookCalls = componentToHooksWeakMap.get(component);\n\n if (!HookCalls) {\n HookCalls = { hooks: [], hook_calls: -1 } as HookCalls;\n componentToHooksWeakMap.set(component, HookCalls);\n onUnmount(() => {\n componentToHooksWeakMap.delete(component);\n });\n }\n\n onCleanup(() => ((HookCalls as HookCalls).hook_calls = -1));\n\n let hook = HookCalls.hooks[++HookCalls.hook_calls];\n if (hook) {\n onUpdateHook?.(hook, ...args);\n } else {\n hook = onCreate(...args);\n HookCalls.hooks.push(hook);\n onRemove && onUnmount(() => onRemove(hook));\n }\n\n onCleanupHook && onCleanup(() => onCleanupHook(hook));\n return returnValue ? returnValue(hook) : hook;\n };\n} as unknown as CreateHook;\n\n// Use state hook\nexport const useState = createHook({\n onCreate: (value) => {\n let state = value;\n function get() {\n return state;\n }\n\n function set(newValue: any) {\n if (current.event && !current.event.defaultPrevented) {\n current.event.preventDefault();\n }\n\n const resolvedValue = typeof newValue === \"function\" ? newValue(state) : newValue;\n\n if (hasChanged(state, resolvedValue)) {\n state = resolvedValue;\n debouncedUpdate();\n }\n }\n\n return [get, set];\n }\n});\n\nexport const useEffect = createHook({\n onCreate: (effect: Function, changes: any[]) => {\n const hook: {\n effect: Function;\n prev: any[];\n onRemove?: Function;\n onCleanup?: Function;\n } = { effect, prev: [] };\n // on unmount\n if (changes === null) {\n hook.onRemove = effect;\n return hook;\n }\n\n // on create\n hook.prev = changes;\n hook.onCleanup = hook.effect();\n return hook;\n },\n onUpdate: (hook, effect, changes) => {\n // on update\n if (typeof changes === \"undefined\") {\n hook.prev = changes;\n if (typeof hook.onCleanup === \"function\") {\n hook.onCleanup();\n }\n hook.onCleanup = hook.effect();\n return;\n }\n\n if (Array.isArray(changes) && changes.length === 0) {\n // Si las dependencias son un array vac\u00EDo, no se debe volver a ejecutar.\n return;\n }\n\n // on update if there are changes\n if (Array.isArray(changes) && hasChanged(hook.prev, changes)) {\n hook.prev = changes;\n if (typeof hook.onCleanup === \"function\") {\n hook.onCleanup();\n }\n hook.onCleanup = hook.effect();\n }\n },\n onRemove: (hook) => {\n if (typeof hook.onCleanup === \"function\") {\n hook.onCleanup();\n }\n if (typeof hook.onRemove === \"function\") {\n hook.onRemove();\n }\n }\n});\n\nexport const useRef = createHook({\n onCreate: (initialValue) => {\n directive(\"ref\", (ref, vnode) => {\n ref.current = vnode.dom;\n });\n return { current: initialValue };\n }\n});\n\nexport const useCallback = createHook({\n onCreate: (callback, changes) => {\n return { callback, changes };\n },\n onUpdate: (hook, callback, changes) => {\n if (hasChanged(hook.changes, changes)) {\n hook.changes = changes;\n hook.callback = callback;\n }\n },\n returnValue: (hook) => hook.callback\n});\n\nexport const useMemo = createHook({\n onCreate: (callback, changes) => {\n return { callback, changes, value: callback() };\n },\n onUpdate: (hook, callback, changes) => {\n if (hasChanged(hook.changes, changes)) {\n hook.changes = changes;\n hook.value = callback();\n }\n },\n returnValue: (hook) => hook.value\n});\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAmC,SAAS,WAAW,WAAW,WAAW,uBAAuB;AACpG,SAAS,kBAAkB;AA2B3B,IAAM,0BAA0B,oBAAI,QAA8C;AAE3E,IAAM,aAAa,SAASA,YAAW;AAAA,EAC5C;AAAA,EACA,UAAU;AAAA,EACV,WAAW;AAAA,EACX;AAAA,EACA;AACF,GAAyB;AACvB,SAAO,IAAI,SAAgB;AACzB,UAAM,YAAY,QAAQ;AAC1B,QAAI,YAAY,wBAAwB,IAAI,SAAS;AAErD,QAAI,CAAC,WAAW;AACd,kBAAY,EAAE,OAAO,CAAC,GAAG,YAAY,GAAG;AACxC,8BAAwB,IAAI,WAAW,SAAS;AAChD,gBAA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AAG;AACrC,WAAK,UAAU;AACf,WAAK,QAAQ,SAAS;AAAA,IACxB;AAAA,EACF;AAAA,EACA,aAAa,CAAC,SAAS,KAAK;AAC9B,CAAC;",
|
|
6
|
+
"names": ["createHook"]
|
|
7
7
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,17 +3,19 @@ declare global {
|
|
|
3
3
|
namespace JSX {
|
|
4
4
|
interface IntrinsicElements extends DefaultRecord {
|
|
5
5
|
}
|
|
6
|
+
type Element = ReturnType<typeof v | ((...args: any) => string | number | null | undefined | boolean | Promise<any>)>;
|
|
7
|
+
type ComponentReturnType = string | number | null | undefined | boolean | Element | Element[];
|
|
6
8
|
}
|
|
7
9
|
}
|
|
8
10
|
interface DefaultRecord extends Record<string | number | symbol, any> {
|
|
9
11
|
}
|
|
10
|
-
export interface
|
|
12
|
+
export interface Properties extends DefaultRecord {
|
|
11
13
|
key?: string | number;
|
|
12
14
|
}
|
|
13
15
|
export interface DomElement extends Element, DefaultRecord {
|
|
14
16
|
}
|
|
15
17
|
export interface Component extends DefaultRecord {
|
|
16
|
-
(props:
|
|
18
|
+
(props: Properties, children: any[]): Vnode | any;
|
|
17
19
|
}
|
|
18
20
|
export interface POJOComponent extends DefaultRecord {
|
|
19
21
|
view: Component;
|
|
@@ -25,30 +27,31 @@ export interface VnodeComponentInterface extends Vnode {
|
|
|
25
27
|
export interface Children extends Array<Vnode | VnodeComponentInterface | ValyrianComponent | any> {
|
|
26
28
|
}
|
|
27
29
|
export interface Directive {
|
|
28
|
-
(value: any, vnode: VnodeWithDom, oldProps:
|
|
30
|
+
(value: any, vnode: VnodeWithDom, oldProps: Properties | null): false | void | any;
|
|
29
31
|
}
|
|
30
32
|
export declare const isNodeJs: boolean;
|
|
31
33
|
export declare class Vnode {
|
|
32
34
|
tag: string | Component | POJOComponent;
|
|
33
|
-
props: null |
|
|
35
|
+
props: null | Properties;
|
|
34
36
|
children: Children;
|
|
35
37
|
dom?: DomElement | undefined;
|
|
36
38
|
isSVG?: boolean | undefined;
|
|
37
|
-
constructor(tag: string | Component | POJOComponent, props: null |
|
|
39
|
+
constructor(tag: string | Component | POJOComponent, props: null | Properties, children: Children, dom?: DomElement | undefined, isSVG?: boolean | undefined);
|
|
38
40
|
}
|
|
39
41
|
export interface VnodeWithDom extends Vnode {
|
|
40
42
|
tag: string;
|
|
41
43
|
dom: DomElement;
|
|
42
|
-
props:
|
|
44
|
+
props: Properties;
|
|
43
45
|
}
|
|
46
|
+
export declare const isPOJOComponent: (component: unknown) => component is POJOComponent;
|
|
44
47
|
export declare const isComponent: (component: unknown) => component is Component;
|
|
45
48
|
export declare const isVnode: (object?: unknown) => object is Vnode;
|
|
46
49
|
export declare const isVnodeComponent: (object?: unknown) => object is VnodeComponentInterface;
|
|
47
|
-
export declare function v(tagOrComponent: string |
|
|
50
|
+
export declare function v(tagOrComponent: string | ValyrianComponent, props: Properties | null, ...children: Children): Vnode;
|
|
48
51
|
export declare namespace v {
|
|
49
|
-
var fragment: (_:
|
|
52
|
+
var fragment: (_: Properties, ...children: Children) => Children;
|
|
50
53
|
}
|
|
51
|
-
export declare function
|
|
54
|
+
export declare function hidrateDomToVnode(dom: any): VnodeWithDom | void;
|
|
52
55
|
export declare function trust(htmlString: string): (void | VnodeWithDom)[];
|
|
53
56
|
export declare const current: {
|
|
54
57
|
vnode: Vnode | null;
|
|
@@ -62,13 +65,14 @@ export declare const onCleanup: (callback: Function) => Set<Function>;
|
|
|
62
65
|
export declare const onUnmount: (callback: Function) => false | Set<Function>;
|
|
63
66
|
export declare const directives: Record<string, Directive>;
|
|
64
67
|
export declare function directive(name: string, directive: Directive): void;
|
|
68
|
+
export declare function setPropNameReserved(name: string): void;
|
|
65
69
|
export declare function setAttribute(name: string, value: any, newVnode: VnodeWithDom): void;
|
|
66
|
-
export declare function updateAttributes(newVnode: VnodeWithDom, oldProps:
|
|
70
|
+
export declare function updateAttributes(newVnode: VnodeWithDom, oldProps: Properties | null): void;
|
|
67
71
|
export declare function createElement(tag: string, isSVG: boolean): DomElement;
|
|
68
|
-
export declare function patch(newVnode: VnodeWithDom): void;
|
|
69
72
|
export declare function updateVnode(vnode: VnodeWithDom): string | void;
|
|
70
|
-
export declare function update():
|
|
71
|
-
export declare function
|
|
72
|
-
export declare function
|
|
73
|
+
export declare function update(): string;
|
|
74
|
+
export declare function debouncedUpdate(): void;
|
|
75
|
+
export declare function unmount(): string;
|
|
76
|
+
export declare function mount(dom: string | DomElement, component: ValyrianComponent | VnodeComponentInterface | any): string;
|
|
73
77
|
export {};
|
|
74
78
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AACA,OAAO,CAAC,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AACA,OAAO,CAAC,MAAM,CAAC;IACb,IAAI,QAAQ,EAAE,QAAQ,CAAC;IACvB,UAAU,GAAG,CAAC;QACZ,UAAU,iBAAkB,SAAQ,aAAa;SAAG;QACpD,KAAK,OAAO,GAAG,UAAU,CACvB,OAAO,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAC3F,CAAC;QACF,KAAK,mBAAmB,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,GAAG,OAAO,EAAE,CAAC;KAC/F;CACF;AAED,UAAU,aAAc,SAAQ,MAAM,CAAC,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC;CAAG;AAExE,MAAM,WAAW,UAAW,SAAQ,aAAa;IAC/C,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACvB;AA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