valyrian.js 6.0.8 → 6.0.11
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/hooks/index.d.ts +21 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +182 -0
- package/{plugins/hooks.js → dist/hooks/index.mjs} +69 -75
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +554 -0
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/index.mjs +299 -305
- package/dist/interfaces.d.ts +104 -0
- package/dist/interfaces.d.ts.map +1 -0
- package/dist/node/index.d.ts +9 -0
- package/dist/node/index.d.ts.map +1 -0
- package/dist/node/index.js +839 -0
- package/dist/node/index.mjs +829 -0
- package/{plugins/node.sw.tpl.js → dist/node/node.sw.tpl} +0 -0
- package/dist/node/utils/icons.d.ts +34 -0
- package/dist/node/utils/icons.d.ts.map +1 -0
- package/dist/node/utils/inline.d.ts +17 -0
- package/dist/node/utils/inline.d.ts.map +1 -0
- package/dist/node/utils/node.sw.tpl +133 -0
- package/dist/node/utils/sw.d.ts +2 -0
- package/dist/node/utils/sw.d.ts.map +1 -0
- package/dist/node/utils/tree-adapter.d.ts +68 -0
- package/dist/node/utils/tree-adapter.d.ts.map +1 -0
- package/dist/request/index.d.ts +42 -0
- package/dist/request/index.d.ts.map +1 -0
- package/dist/request/index.js +199 -0
- package/dist/request/index.min.js +1 -0
- package/dist/request/index.min.js.map +1 -0
- package/dist/request/index.mjs +178 -0
- package/dist/router/index.d.ts +58 -0
- package/dist/router/index.d.ts.map +1 -0
- package/dist/router/index.js +229 -0
- package/dist/router/index.min.js +1 -0
- package/dist/router/index.min.js.map +1 -0
- package/{plugins/router.js → dist/router/index.mjs} +56 -109
- package/dist/signal/index.d.ts +23 -0
- package/dist/signal/index.d.ts.map +1 -0
- package/dist/signal/index.js +130 -0
- package/dist/signal/index.min.js +1 -0
- package/dist/signal/index.min.js.map +1 -0
- package/{plugins/signals.js → dist/signal/index.mjs} +28 -52
- package/dist/store/index.d.ts +27 -0
- package/dist/store/index.d.ts.map +1 -0
- package/dist/store/index.js +104 -0
- package/dist/store/index.min.js +1 -0
- package/dist/store/index.min.js.map +1 -0
- package/{plugins/store.js → dist/store/index.mjs} +30 -43
- package/dist/sw/index.d.ts +10 -0
- package/dist/sw/index.d.ts.map +1 -0
- package/dist/sw/index.js +42 -0
- package/dist/sw/index.mjs +21 -0
- package/lib/hooks/index.ts +242 -0
- package/lib/index.ts +357 -396
- package/lib/interfaces.ts +96 -95
- package/lib/node/index.ts +30 -0
- package/lib/node/utils/icons.ts +117 -0
- package/lib/node/utils/inline.ts +150 -0
- package/lib/node/utils/node.sw.tpl +133 -0
- package/lib/node/utils/sw.ts +26 -0
- package/lib/node/utils/tree-adapter.ts +746 -0
- package/lib/request/index.ts +278 -0
- package/lib/router/index.ts +308 -0
- package/lib/signal/index.ts +173 -0
- package/lib/store/index.ts +121 -0
- package/lib/sw/index.ts +29 -0
- package/package.json +52 -39
- package/tsconfig.json +5 -5
- package/dist/@types/lib/index.d.ts +0 -5
- package/dist/@types/lib/interfaces.d.ts +0 -103
- package/dist/index.cjs +0 -559
- package/plugins/node.js +0 -327
- package/plugins/request.js +0 -162
- package/plugins/sw.js +0 -30
- package/plugins/utils/tree-adapter.js +0 -635
- package/register.js +0 -49
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Valyrian } from "Valyrian";
|
|
2
|
+
export declare type Hook = any;
|
|
3
|
+
export interface HookDefinition {
|
|
4
|
+
onCreate: (...args: any[]) => any;
|
|
5
|
+
onUpdate?: (hook: Hook, ...args: any[]) => any;
|
|
6
|
+
onCleanup?: (hook: Hook) => any;
|
|
7
|
+
onRemove?: (hook: Hook) => any;
|
|
8
|
+
returnValue?: (hook: Hook) => any;
|
|
9
|
+
}
|
|
10
|
+
export interface CreateHook {
|
|
11
|
+
(HookDefinition: HookDefinition): (...args: any[]) => any;
|
|
12
|
+
}
|
|
13
|
+
export declare const createHook: CreateHook;
|
|
14
|
+
export declare const useState: (...args: any[]) => any;
|
|
15
|
+
export declare const useEffect: (...args: any[]) => any;
|
|
16
|
+
export declare const useRef: (...args: any[]) => any;
|
|
17
|
+
export declare const useCallback: (...args: any[]) => any;
|
|
18
|
+
export declare const useMemo: (...args: any[]) => any;
|
|
19
|
+
declare function plugin(v: Valyrian): void;
|
|
20
|
+
export default plugin;
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,QAAQ,EAAmC,MAAM,UAAU,CAAC;AA+BhF,oBAAY,IAAI,GAAG,GAAG,CAAC;AAEvB,MAAM,WAAW,cAAc;IAE7B,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;IAElC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;IAE/C,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,GAAG,CAAC;IAEhC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,GAAG,CAAC;IAE/B,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,GAAG,CAAC;CACnC;AAED,MAAM,WAAW,UAAU;IAEzB,CAAC,cAAc,EAAE,cAAc,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;CAC3D;AAED,eAAO,MAAM,UAAU,YA2EG,CAAC;AAG3B,eAAO,MAAM,QAAQ,YAjFyB,GAAG,EAAE,KAAK,GAyFtD,CAAC;AAGH,eAAO,MAAM,SAAS,YA5FwB,GAAG,EAAE,KAAK,GAgJtD,CAAC;AAEH,eAAO,MAAM,MAAM,YAlJ2B,GAAG,EAAE,KAAK,GAyJtD,CAAC;AAEH,eAAO,MAAM,WAAW,YA3JsB,GAAG,EAAE,KAAK,GAyKtD,CAAC;AAEH,eAAO,MAAM,OAAO,YA3K0B,GAAG,EAAE,KAAK,GA2LtD,CAAC;AAEH,iBAAS,MAAM,CAAC,CAAC,EAAE,QAAQ,QAE1B;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// lib/hooks/index.ts
|
|
21
|
+
var hooks_exports = {};
|
|
22
|
+
__export(hooks_exports, {
|
|
23
|
+
createHook: () => createHook,
|
|
24
|
+
default: () => hooks_default,
|
|
25
|
+
useCallback: () => useCallback,
|
|
26
|
+
useEffect: () => useEffect,
|
|
27
|
+
useMemo: () => useMemo,
|
|
28
|
+
useRef: () => useRef,
|
|
29
|
+
useState: () => useState
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(hooks_exports);
|
|
32
|
+
var localValyrian = {
|
|
33
|
+
current: {
|
|
34
|
+
component: null,
|
|
35
|
+
vnode: null,
|
|
36
|
+
oldVnode: null
|
|
37
|
+
},
|
|
38
|
+
onUnmount: () => {
|
|
39
|
+
},
|
|
40
|
+
onCleanup: () => {
|
|
41
|
+
},
|
|
42
|
+
onMount: () => {
|
|
43
|
+
},
|
|
44
|
+
onUpdate: () => {
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
var createHook = function createHook2({ onCreate, onUpdate, onCleanup, onRemove, returnValue }) {
|
|
48
|
+
return (...args) => {
|
|
49
|
+
let { component, vnode, oldVnode } = localValyrian.current;
|
|
50
|
+
if (!vnode.components) {
|
|
51
|
+
vnode.components = [];
|
|
52
|
+
localValyrian.onUnmount(() => Reflect.deleteProperty(vnode, "components"));
|
|
53
|
+
}
|
|
54
|
+
if (vnode.components.indexOf(component) === -1) {
|
|
55
|
+
vnode.components.push(component);
|
|
56
|
+
}
|
|
57
|
+
if (!component.hooks) {
|
|
58
|
+
component.hooks = [];
|
|
59
|
+
localValyrian.onUnmount(() => Reflect.deleteProperty(component, "hooks"));
|
|
60
|
+
}
|
|
61
|
+
let hook = void 0;
|
|
62
|
+
if (!oldVnode || !oldVnode.components || oldVnode.components[vnode.components.length - 1] !== component) {
|
|
63
|
+
hook = onCreate(...args);
|
|
64
|
+
component.hooks.push(hook);
|
|
65
|
+
if (onRemove) {
|
|
66
|
+
localValyrian.onUnmount(() => onRemove(hook));
|
|
67
|
+
}
|
|
68
|
+
} else {
|
|
69
|
+
if ("calls" in component === false) {
|
|
70
|
+
component.calls = -1;
|
|
71
|
+
localValyrian.onUnmount(() => Reflect.deleteProperty(component, "calls"));
|
|
72
|
+
}
|
|
73
|
+
localValyrian.onCleanup(() => component.calls = -1);
|
|
74
|
+
component.calls++;
|
|
75
|
+
hook = component.hooks[component.calls];
|
|
76
|
+
if (onUpdate) {
|
|
77
|
+
onUpdate(hook, ...args);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (onCleanup) {
|
|
81
|
+
localValyrian.onCleanup(() => onCleanup(hook));
|
|
82
|
+
}
|
|
83
|
+
if (returnValue) {
|
|
84
|
+
return returnValue(hook);
|
|
85
|
+
}
|
|
86
|
+
return hook;
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
var useState = createHook({
|
|
90
|
+
onCreate: (value) => {
|
|
91
|
+
let stateObj = /* @__PURE__ */ Object.create(null);
|
|
92
|
+
stateObj.value = value;
|
|
93
|
+
stateObj.toJSON = stateObj.toString = stateObj.valueOf = () => typeof stateObj.value === "function" ? stateObj.value() : stateObj.value;
|
|
94
|
+
return [stateObj, (value2) => stateObj.value = value2];
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
var useEffect = createHook({
|
|
98
|
+
onCreate: (effect, changes) => {
|
|
99
|
+
let hook = { effect, prev: [] };
|
|
100
|
+
if (changes === null) {
|
|
101
|
+
hook.onRemove = effect;
|
|
102
|
+
return hook;
|
|
103
|
+
}
|
|
104
|
+
hook.prev = changes;
|
|
105
|
+
hook.onCleanup = hook.effect();
|
|
106
|
+
return hook;
|
|
107
|
+
},
|
|
108
|
+
onUpdate: (hook, effect, changes) => {
|
|
109
|
+
if (typeof changes === "undefined") {
|
|
110
|
+
hook.prev = changes;
|
|
111
|
+
if (typeof hook.onCleanup === "function") {
|
|
112
|
+
hook.onCleanup();
|
|
113
|
+
}
|
|
114
|
+
hook.onCleanup = hook.effect();
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
if (Array.isArray(changes)) {
|
|
118
|
+
for (let i = 0, l = changes.length; i < l; i++) {
|
|
119
|
+
if (changes[i] !== hook.prev[i]) {
|
|
120
|
+
hook.prev = changes;
|
|
121
|
+
if (typeof hook.onCleanup === "function") {
|
|
122
|
+
hook.onCleanup();
|
|
123
|
+
}
|
|
124
|
+
hook.onCleanup = hook.effect();
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
onRemove: (hook) => {
|
|
131
|
+
if (typeof hook.onCleanup === "function") {
|
|
132
|
+
hook.onCleanup();
|
|
133
|
+
}
|
|
134
|
+
if (typeof hook.onRemove === "function") {
|
|
135
|
+
hook.onRemove();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
var useRef = createHook({
|
|
140
|
+
onCreate: (initialValue) => {
|
|
141
|
+
localValyrian.directive("ref", (ref, vnode) => {
|
|
142
|
+
ref.current = vnode.dom;
|
|
143
|
+
});
|
|
144
|
+
return { current: initialValue };
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
var useCallback = createHook({
|
|
148
|
+
onCreate: (callback, changes) => {
|
|
149
|
+
callback();
|
|
150
|
+
return { callback, changes };
|
|
151
|
+
},
|
|
152
|
+
onUpdate: (hook, callback, changes) => {
|
|
153
|
+
for (let i = 0, l = changes.length; i < l; i++) {
|
|
154
|
+
if (changes[i] !== hook.changes[i]) {
|
|
155
|
+
hook.changes = changes;
|
|
156
|
+
hook.callback();
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
var useMemo = createHook({
|
|
163
|
+
onCreate: (callback, changes) => {
|
|
164
|
+
return { callback, changes, value: callback() };
|
|
165
|
+
},
|
|
166
|
+
onUpdate: (hook, callback, changes) => {
|
|
167
|
+
for (let i = 0, l = changes.length; i < l; i++) {
|
|
168
|
+
if (changes[i] !== hook.changes[i]) {
|
|
169
|
+
hook.changes = changes;
|
|
170
|
+
hook.value = callback();
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
returnValue: (hook) => {
|
|
176
|
+
return hook.value;
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
function plugin(v) {
|
|
180
|
+
localValyrian = v;
|
|
181
|
+
}
|
|
182
|
+
var hooks_default = plugin;
|
|
@@ -1,81 +1,81 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// lib/hooks/index.ts
|
|
2
|
+
var localValyrian = {
|
|
3
|
+
current: {
|
|
4
|
+
component: null,
|
|
5
|
+
vnode: null,
|
|
6
|
+
oldVnode: null
|
|
7
|
+
},
|
|
8
|
+
onUnmount: () => {
|
|
9
|
+
},
|
|
10
|
+
onCleanup: () => {
|
|
11
|
+
},
|
|
12
|
+
onMount: () => {
|
|
13
|
+
},
|
|
14
|
+
onUpdate: () => {
|
|
15
|
+
}
|
|
3
16
|
};
|
|
4
|
-
|
|
5
|
-
function createHook({ create, update, remove, returnValue }) {
|
|
17
|
+
var createHook = function createHook2({ onCreate, onUpdate, onCleanup, onRemove, returnValue }) {
|
|
6
18
|
return (...args) => {
|
|
7
|
-
let { component, vnode, oldVnode } =
|
|
8
|
-
|
|
9
|
-
// Init the components array for the current vnode
|
|
10
|
-
if (vnode.components === undefined) {
|
|
19
|
+
let { component, vnode, oldVnode } = localValyrian.current;
|
|
20
|
+
if (!vnode.components) {
|
|
11
21
|
vnode.components = [];
|
|
12
|
-
|
|
22
|
+
localValyrian.onUnmount(() => Reflect.deleteProperty(vnode, "components"));
|
|
13
23
|
}
|
|
14
|
-
|
|
15
|
-
// Add the component to the components array if it's not already there
|
|
16
24
|
if (vnode.components.indexOf(component) === -1) {
|
|
17
25
|
vnode.components.push(component);
|
|
18
26
|
}
|
|
19
|
-
|
|
20
|
-
// Init the component hooks array
|
|
21
|
-
if (component.hooks === undefined) {
|
|
27
|
+
if (!component.hooks) {
|
|
22
28
|
component.hooks = [];
|
|
23
|
-
|
|
29
|
+
localValyrian.onUnmount(() => Reflect.deleteProperty(component, "hooks"));
|
|
24
30
|
}
|
|
25
|
-
let hook;
|
|
26
|
-
|
|
31
|
+
let hook = void 0;
|
|
27
32
|
if (!oldVnode || !oldVnode.components || oldVnode.components[vnode.components.length - 1] !== component) {
|
|
28
|
-
hook =
|
|
33
|
+
hook = onCreate(...args);
|
|
29
34
|
component.hooks.push(hook);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
// Add the hook to the onRemove array
|
|
33
|
-
v.onUnmount(() => remove(hook));
|
|
35
|
+
if (onRemove) {
|
|
36
|
+
localValyrian.onUnmount(() => onRemove(hook));
|
|
34
37
|
}
|
|
35
38
|
} else {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
if ("calls" in component === false) {
|
|
40
|
+
component.calls = -1;
|
|
41
|
+
localValyrian.onUnmount(() => Reflect.deleteProperty(component, "calls"));
|
|
39
42
|
}
|
|
43
|
+
localValyrian.onCleanup(() => component.calls = -1);
|
|
44
|
+
component.calls++;
|
|
45
|
+
hook = component.hooks[component.calls];
|
|
46
|
+
if (onUpdate) {
|
|
47
|
+
onUpdate(hook, ...args);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
if (onCleanup) {
|
|
51
|
+
localValyrian.onCleanup(() => onCleanup(hook));
|
|
40
52
|
}
|
|
41
|
-
|
|
42
53
|
if (returnValue) {
|
|
43
54
|
return returnValue(hook);
|
|
44
55
|
}
|
|
45
|
-
|
|
46
56
|
return hook;
|
|
47
57
|
};
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
let stateObj = Object.create(null);
|
|
56
|
-
stateObj.toJSON = stateObj.toString = stateObj.valueOf = () => (typeof state === "function" ? state() : state);
|
|
57
|
-
|
|
58
|
-
return [stateObj, setState];
|
|
58
|
+
};
|
|
59
|
+
var useState = createHook({
|
|
60
|
+
onCreate: (value) => {
|
|
61
|
+
let stateObj = /* @__PURE__ */ Object.create(null);
|
|
62
|
+
stateObj.value = value;
|
|
63
|
+
stateObj.toJSON = stateObj.toString = stateObj.valueOf = () => typeof stateObj.value === "function" ? stateObj.value() : stateObj.value;
|
|
64
|
+
return [stateObj, (value2) => stateObj.value = value2];
|
|
59
65
|
}
|
|
60
66
|
});
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const useEffect = createHook({
|
|
64
|
-
create: (effect, changes) => {
|
|
67
|
+
var useEffect = createHook({
|
|
68
|
+
onCreate: (effect, changes) => {
|
|
65
69
|
let hook = { effect, prev: [] };
|
|
66
|
-
// on unmount
|
|
67
70
|
if (changes === null) {
|
|
68
71
|
hook.onRemove = effect;
|
|
69
72
|
return hook;
|
|
70
73
|
}
|
|
71
|
-
|
|
72
|
-
// on create
|
|
73
74
|
hook.prev = changes;
|
|
74
75
|
hook.onCleanup = hook.effect();
|
|
75
76
|
return hook;
|
|
76
77
|
},
|
|
77
|
-
|
|
78
|
-
// on update
|
|
78
|
+
onUpdate: (hook, effect, changes) => {
|
|
79
79
|
if (typeof changes === "undefined") {
|
|
80
80
|
hook.prev = changes;
|
|
81
81
|
if (typeof hook.onCleanup === "function") {
|
|
@@ -84,8 +84,6 @@ const useEffect = createHook({
|
|
|
84
84
|
hook.onCleanup = hook.effect();
|
|
85
85
|
return;
|
|
86
86
|
}
|
|
87
|
-
|
|
88
|
-
// on update if there are changes
|
|
89
87
|
if (Array.isArray(changes)) {
|
|
90
88
|
for (let i = 0, l = changes.length; i < l; i++) {
|
|
91
89
|
if (changes[i] !== hook.prev[i]) {
|
|
@@ -99,7 +97,7 @@ const useEffect = createHook({
|
|
|
99
97
|
}
|
|
100
98
|
}
|
|
101
99
|
},
|
|
102
|
-
|
|
100
|
+
onRemove: (hook) => {
|
|
103
101
|
if (typeof hook.onCleanup === "function") {
|
|
104
102
|
hook.onCleanup();
|
|
105
103
|
}
|
|
@@ -108,22 +106,20 @@ const useEffect = createHook({
|
|
|
108
106
|
}
|
|
109
107
|
}
|
|
110
108
|
});
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
v.directive("ref", (ref, vnode) => {
|
|
109
|
+
var useRef = createHook({
|
|
110
|
+
onCreate: (initialValue) => {
|
|
111
|
+
localValyrian.directive("ref", (ref, vnode) => {
|
|
115
112
|
ref.current = vnode.dom;
|
|
116
113
|
});
|
|
117
114
|
return { current: initialValue };
|
|
118
115
|
}
|
|
119
116
|
});
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
create: (callback, changes) => {
|
|
117
|
+
var useCallback = createHook({
|
|
118
|
+
onCreate: (callback, changes) => {
|
|
123
119
|
callback();
|
|
124
120
|
return { callback, changes };
|
|
125
121
|
},
|
|
126
|
-
|
|
122
|
+
onUpdate: (hook, callback, changes) => {
|
|
127
123
|
for (let i = 0, l = changes.length; i < l; i++) {
|
|
128
124
|
if (changes[i] !== hook.changes[i]) {
|
|
129
125
|
hook.changes = changes;
|
|
@@ -133,12 +129,11 @@ const useCallback = createHook({
|
|
|
133
129
|
}
|
|
134
130
|
}
|
|
135
131
|
});
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
create: (callback, changes) => {
|
|
132
|
+
var useMemo = createHook({
|
|
133
|
+
onCreate: (callback, changes) => {
|
|
139
134
|
return { callback, changes, value: callback() };
|
|
140
135
|
},
|
|
141
|
-
|
|
136
|
+
onUpdate: (hook, callback, changes) => {
|
|
142
137
|
for (let i = 0, l = changes.length; i < l; i++) {
|
|
143
138
|
if (changes[i] !== hook.changes[i]) {
|
|
144
139
|
hook.changes = changes;
|
|
@@ -151,17 +146,16 @@ const useMemo = createHook({
|
|
|
151
146
|
return hook.value;
|
|
152
147
|
}
|
|
153
148
|
});
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
v = vInstance;
|
|
149
|
+
function plugin(v) {
|
|
150
|
+
localValyrian = v;
|
|
157
151
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
152
|
+
var hooks_default = plugin;
|
|
153
|
+
export {
|
|
154
|
+
createHook,
|
|
155
|
+
hooks_default as default,
|
|
156
|
+
useCallback,
|
|
157
|
+
useEffect,
|
|
158
|
+
useMemo,
|
|
159
|
+
useRef,
|
|
160
|
+
useState
|
|
161
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference path="interfaces.d.ts" />
|
|
2
|
+
import { Valyrian, VnodeComponentInterface, VnodeInterface, VnodeTextInterface } from "Valyrian";
|
|
3
|
+
export declare const Vnode: VnodeInterface;
|
|
4
|
+
export declare const VnodeText: VnodeTextInterface;
|
|
5
|
+
export declare const VnodeComponent: VnodeComponentInterface;
|
|
6
|
+
declare const v: Valyrian;
|
|
7
|
+
export default v;
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":";AAKA,OAAO,EASL,QAAQ,EAER,uBAAuB,EACvB,cAAc,EACd,kBAAkB,EAEnB,MAAM,UAAU,CAAC;AAiDlB,eAAO,MAAM,KAAK,gBAIY,CAAC;AAE/B,eAAO,MAAM,SAAS,oBAEY,CAAC;AAEnC,eAAO,MAAM,cAAc,yBASY,CAAC;AA8BxC,QAAA,MAAM,CAAC,EAAE,QAMR,CAAC;AA2gBF,eAAe,CAAC,CAAC"}
|