@potok-web-framework/core 0.7.0 → 0.10.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/block.d.ts +11 -6
- package/dist/client/potok-preload.d.ts +6 -0
- package/dist/{dom/utils.d.ts → client/utils/dom.d.ts} +1 -1
- package/dist/client.mjs +93 -71
- package/dist/constants-Bxn0R4hW.mjs +34 -0
- package/dist/constants.d.ts +4 -2
- package/dist/css-BercB0Kp.mjs +8 -0
- package/dist/escape-from-script-tag-CRT2evI1.mjs +4 -0
- package/dist/exports/client.d.ts +1 -1
- package/dist/exports/hmr.d.ts +2 -0
- package/dist/exports/index.d.ts +2 -2
- package/dist/exports/jsx-runtime.d.ts +2 -1
- package/dist/exports/server.d.ts +2 -1
- package/dist/exports/store.d.ts +2 -0
- package/dist/footer-scripts.d.ts +2 -0
- package/dist/fragment-CXNEPBWB.mjs +18 -0
- package/dist/get-component-instance-id-CP6LDtpX.mjs +97 -0
- package/dist/header-scripts.d.ts +2 -0
- package/dist/hmr/constants.d.ts +12 -0
- package/dist/hmr/register-component.d.ts +4 -0
- package/dist/hmr/register-style.d.ts +1 -0
- package/dist/hmr/registered-component.d.ts +1 -6
- package/dist/hmr/remove-style.d.ts +1 -0
- package/dist/hmr/utils.d.ts +0 -2
- package/dist/hmr.mjs +13 -41
- package/dist/html-element-DBut4UCf.mjs +31 -0
- package/dist/html-element.d.ts +9 -1
- package/dist/index.mjs +203 -129
- package/dist/is-pure-object-s_MkQp1w.mjs +4 -0
- package/dist/jsx-runtime.mjs +4 -4
- package/dist/lib-node-DyXPvvVQ.mjs +192 -0
- package/dist/lib-node.d.ts +6 -0
- package/dist/list.d.ts +3 -0
- package/dist/normalize-children-BWrn16R7.mjs +48 -0
- package/dist/prop-types.d.ts +219 -240
- package/dist/register-component-B92kGFqC.mjs +67 -0
- package/dist/serialization-qOayQbjE.mjs +108 -0
- package/dist/{bootstrap-app.d.ts → server/bootstrap-app.d.ts} +3 -4
- package/dist/{render-to-string.d.ts → server/render-to-string.d.ts} +1 -1
- package/dist/server-node.d.ts +1 -1
- package/dist/server.mjs +84 -1145
- package/dist/signals.d.ts +5 -0
- package/dist/store/create-store.d.ts +2 -0
- package/dist/store/http-extension.d.ts +26 -0
- package/dist/store/types.d.ts +40 -0
- package/dist/store.mjs +137 -0
- package/dist/text-node.d.ts +12 -0
- package/dist/types.d.ts +11 -14
- package/dist/utils/css.d.ts +2 -0
- package/dist/utils/deep-assign-object.d.ts +1 -0
- package/dist/utils/escape-from-script-tag.d.ts +1 -0
- package/dist/utils/escape-html.d.ts +1 -0
- package/dist/utils/get-component-instance-id.d.ts +2 -0
- package/dist/utils/is-pure-object.d.ts +1 -0
- package/dist/utils/merge-context.d.ts +2 -0
- package/dist/utils/normalize-array.d.ts +2 -0
- package/dist/utils/normalize-children.d.ts +2 -0
- package/dist/utils/serialization.d.ts +2 -0
- package/package.json +6 -5
- package/dist/constants-BOAOReQ3.mjs +0 -26
- package/dist/fragment-BSt6shYv.mjs +0 -103
- package/dist/hmr/hmr-dev.d.ts +0 -9
- package/dist/html-element-DeGD0uGZ.mjs +0 -24
- package/dist/lib-scripts.d.ts +0 -2
- package/dist/lifecycle-C9_o5zOU.mjs +0 -58
- package/dist/portal-BxUviJsE.mjs +0 -45
- package/dist/signals-ZsU9bGc3.mjs +0 -262
- package/dist/store.d.ts +0 -26
- package/dist/text.d.ts +0 -5
- package/dist/utils.d.ts +0 -9
- /package/dist/{dom → client}/hydrate.d.ts +0 -0
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import { a as deepTrack, c as untrack, i as createSignal, o as getSignal, r as createEffect, s as isSignal
|
|
2
|
-
import { i as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { a as deepTrack, c as untrack, i as createSignal, l as LibBlock, n as batch, o as getSignal, r as createEffect, s as isSignal } from "./lib-node-DyXPvvVQ.mjs";
|
|
2
|
+
import { i as mergeContext, n as text, t as normalizeChildren } from "./normalize-children-BWrn16R7.mjs";
|
|
3
|
+
import { a as Lifecycle, i as HMR_STYLES, o as LibContextReader } from "./get-component-instance-id-CP6LDtpX.mjs";
|
|
4
|
+
import { r as Show, t as isRegisteredComponentElement } from "./register-component-B92kGFqC.mjs";
|
|
5
|
+
import { n as isPotokPreloader, t as htmlElement } from "./html-element-DBut4UCf.mjs";
|
|
6
|
+
import { t as fragment } from "./fragment-CXNEPBWB.mjs";
|
|
7
|
+
import { i as PRELOAD_SCRIPTS_SCRIPT_ID, n as HYDRATION_STATE_SCRIPT_ID } from "./constants-Bxn0R4hW.mjs";
|
|
8
|
+
import { t as escapeFromScriptTag } from "./escape-from-script-tag-CRT2evI1.mjs";
|
|
9
|
+
import { n as serializeWithTypes } from "./serialization-qOayQbjE.mjs";
|
|
10
|
+
import { clientEntry } from "virtual:client-variables";
|
|
5
11
|
function ClientOnly(e) {
|
|
6
12
|
return LibContextReader({ children: (t) => Show({
|
|
7
13
|
get when() {
|
|
@@ -43,88 +49,115 @@ function ErrorBoundary(e) {
|
|
|
43
49
|
function Lazy(e) {
|
|
44
50
|
return LibContextReader({ children: (t) => {
|
|
45
51
|
let r = createSignal({ block: null });
|
|
46
|
-
return
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
52
|
+
return Lifecycle({
|
|
53
|
+
onMounted() {
|
|
54
|
+
if (isPotokPreloader(e.import)) {
|
|
55
|
+
let n = e.import.dependencies;
|
|
56
|
+
return t.preload.addScripts(n), createEffect(() => {
|
|
57
|
+
n.every((e) => t.preload.scripts.some((t) => t.path === e && t.isLoaded)) && r.block === null && t.promises.push(e.import().then((t) => {
|
|
58
|
+
let n = e.resolve(t);
|
|
59
|
+
process.env.NODE_ENV === "development" && isRegisteredComponentElement(n), r.block = n;
|
|
60
|
+
}).catch((e) => {
|
|
61
|
+
throw e;
|
|
62
|
+
}));
|
|
63
|
+
}, !0).dispose;
|
|
64
|
+
}
|
|
51
65
|
},
|
|
52
|
-
children: [
|
|
53
|
-
|
|
66
|
+
children: [fragment({ children: [Show({
|
|
67
|
+
get when() {
|
|
68
|
+
return r.block !== null;
|
|
69
|
+
},
|
|
70
|
+
children: [fragment({ get children() {
|
|
71
|
+
return r.block;
|
|
72
|
+
} })]
|
|
73
|
+
}), Show({
|
|
74
|
+
get when() {
|
|
75
|
+
return r.block === null;
|
|
76
|
+
},
|
|
77
|
+
children: [fragment({ get children() {
|
|
78
|
+
return e.fallback;
|
|
79
|
+
} })]
|
|
80
|
+
})] })]
|
|
81
|
+
});
|
|
82
|
+
} });
|
|
83
|
+
}
|
|
84
|
+
function FooterScripts() {
|
|
85
|
+
return LibContextReader({ children: (e) => {
|
|
86
|
+
let t = [Show({
|
|
54
87
|
get when() {
|
|
55
|
-
return
|
|
88
|
+
return e.isServer || e.isHydrating;
|
|
56
89
|
},
|
|
57
|
-
children: [
|
|
58
|
-
|
|
90
|
+
children: [htmlElement({
|
|
91
|
+
tag: "script",
|
|
92
|
+
id: HYDRATION_STATE_SCRIPT_ID,
|
|
93
|
+
type: "application/json",
|
|
94
|
+
children: [text({ get text() {
|
|
95
|
+
return escapeFromScriptTag(serializeWithTypes(e.states));
|
|
96
|
+
} })]
|
|
97
|
+
}), htmlElement({
|
|
98
|
+
tag: "script",
|
|
99
|
+
id: PRELOAD_SCRIPTS_SCRIPT_ID,
|
|
100
|
+
type: "application/json",
|
|
101
|
+
children: [text({ get text() {
|
|
102
|
+
return escapeFromScriptTag(serializeWithTypes(e.preload.scripts));
|
|
103
|
+
} })]
|
|
104
|
+
})]
|
|
105
|
+
})];
|
|
106
|
+
return process.env.NODE_ENV === "development" && t.push(htmlElement({
|
|
107
|
+
tag: "script",
|
|
108
|
+
type: "module",
|
|
109
|
+
src: "/@vite/client"
|
|
110
|
+
})), t.push(htmlElement({
|
|
111
|
+
tag: "script",
|
|
112
|
+
type: "module",
|
|
113
|
+
src: clientEntry
|
|
114
|
+
})), fragment({ children: t });
|
|
59
115
|
} });
|
|
60
116
|
}
|
|
61
|
-
function LibScripts() {
|
|
62
|
-
return PortalOut({ name: "lib-scripts" });
|
|
63
|
-
}
|
|
64
117
|
var ListClass = class extends LibBlock {
|
|
65
|
-
|
|
66
|
-
constructor(
|
|
67
|
-
super(), this.props =
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
if (e.type === "add") {
|
|
74
|
-
let t = createSignal({
|
|
75
|
-
item: e.item,
|
|
76
|
-
index: e.index
|
|
77
|
-
});
|
|
78
|
-
this.children.splice(e.index, 0, null), this.signals.splice(e.index, 0, getSignal(t));
|
|
79
|
-
let i = o.render(t)(mergeContext(s, {
|
|
80
|
-
parentBlock: this,
|
|
81
|
-
get index() {
|
|
82
|
-
return t.index;
|
|
83
|
-
}
|
|
84
|
-
}));
|
|
85
|
-
this.children[e.index] = i;
|
|
86
|
-
} else if (e.type === "replace") this.signals[e.index].proxy.item = e.newItem;
|
|
87
|
-
else if (e.type === "delete") {
|
|
88
|
-
let t = this.children[e.index];
|
|
89
|
-
this.children.splice(e.index, 1), this.signals.splice(e.index, 1), t?.unmount();
|
|
90
|
-
}
|
|
91
|
-
}), this.signals.forEach((e, t) => {
|
|
92
|
-
e.value.index !== t && (e.proxy.index = t);
|
|
93
|
-
}), l = [...i];
|
|
118
|
+
entries = /* @__PURE__ */ new Map();
|
|
119
|
+
constructor(n, r) {
|
|
120
|
+
super(), this.props = n, this.context = r, this.addEffect(createEffect(() => {
|
|
121
|
+
let r = n.items;
|
|
122
|
+
isSignal(r) && deepTrack(r, 1), untrack(() => {
|
|
123
|
+
batch(() => {
|
|
124
|
+
this.reconcile(r);
|
|
125
|
+
});
|
|
94
126
|
});
|
|
95
127
|
}, !0));
|
|
96
128
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
n
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
124
|
-
|
|
129
|
+
reconcile(e) {
|
|
130
|
+
this.children = [];
|
|
131
|
+
let t = /* @__PURE__ */ new Map(), r = [];
|
|
132
|
+
e.forEach((e, n) => {
|
|
133
|
+
let i = this.props.keyExtractor(e, n), a = this.entries.get(i);
|
|
134
|
+
a ? (a.signal.item = e, a.signal.index = n, this.children.push(a.block), t.set(i, a)) : (r.push({
|
|
135
|
+
key: i,
|
|
136
|
+
index: n,
|
|
137
|
+
item: e
|
|
138
|
+
}), this.children.push(null));
|
|
139
|
+
}), r.forEach(({ key: e, index: r, item: i }) => {
|
|
140
|
+
let a = createSignal({
|
|
141
|
+
item: i,
|
|
142
|
+
index: r
|
|
143
|
+
}), o = this.props.render(a)(mergeContext(this.context, {
|
|
144
|
+
parentBlock: this,
|
|
145
|
+
get index() {
|
|
146
|
+
return a.index;
|
|
147
|
+
}
|
|
148
|
+
}));
|
|
149
|
+
this.children[r] = o, t.set(e, {
|
|
150
|
+
signal: a,
|
|
151
|
+
block: o
|
|
152
|
+
});
|
|
153
|
+
}), this.entries.forEach((e, n) => {
|
|
154
|
+
t.has(n) || e.block.unmount();
|
|
155
|
+
}), this.children.forEach((e) => {
|
|
156
|
+
e?.isNode() && e.insert();
|
|
157
|
+
}), this.entries = t;
|
|
125
158
|
}
|
|
126
159
|
unmount() {
|
|
127
|
-
super.unmount(), this.
|
|
160
|
+
super.unmount(), this.entries.clear();
|
|
128
161
|
}
|
|
129
162
|
};
|
|
130
163
|
function List(e) {
|
|
@@ -135,65 +168,106 @@ function List(e) {
|
|
|
135
168
|
function createElementReference() {
|
|
136
169
|
return createSignal({ element: null });
|
|
137
170
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
171
|
+
function HeaderScripts() {
|
|
172
|
+
return LibContextReader({ children: (e) => {
|
|
173
|
+
let n = [List({
|
|
174
|
+
get items() {
|
|
175
|
+
return e.preload.scripts;
|
|
176
|
+
},
|
|
177
|
+
keyExtractor(e) {
|
|
178
|
+
return e.path;
|
|
179
|
+
},
|
|
180
|
+
render(e) {
|
|
181
|
+
let n = createElementReference();
|
|
182
|
+
return Lifecycle({
|
|
183
|
+
onMounted() {
|
|
184
|
+
if (e.item.isLoaded) return;
|
|
185
|
+
let r = createEffect(() => {
|
|
186
|
+
let r = n.element;
|
|
187
|
+
r && (r.onload = () => {
|
|
188
|
+
untrack(() => {
|
|
189
|
+
e.item.isLoaded = !0;
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
}, !0);
|
|
193
|
+
return () => {
|
|
194
|
+
r.dispose(), n.element && (n.element.onload = null);
|
|
195
|
+
};
|
|
196
|
+
},
|
|
197
|
+
children: [htmlElement({
|
|
198
|
+
tag: "link",
|
|
199
|
+
get rel() {
|
|
200
|
+
return e.item.path.endsWith(".css") ? "stylesheet" : "modulepreload";
|
|
201
|
+
},
|
|
202
|
+
get href() {
|
|
203
|
+
return e.item.path;
|
|
204
|
+
},
|
|
205
|
+
ref: n
|
|
206
|
+
})]
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
})];
|
|
210
|
+
return process.env.NODE_ENV === "development" && n.push(ClientOnly({ children: [List({
|
|
211
|
+
get items() {
|
|
212
|
+
return HMR_STYLES.styles;
|
|
213
|
+
},
|
|
214
|
+
keyExtractor(e) {
|
|
215
|
+
return e.id;
|
|
216
|
+
},
|
|
217
|
+
render(e) {
|
|
218
|
+
return htmlElement({
|
|
219
|
+
tag: "style",
|
|
220
|
+
get "data-id"() {
|
|
221
|
+
return e.item.id;
|
|
222
|
+
},
|
|
223
|
+
children: [text({ get text() {
|
|
224
|
+
return e.item.css;
|
|
225
|
+
} })]
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
})] })), fragment({ children: n });
|
|
229
|
+
} });
|
|
230
|
+
}
|
|
231
|
+
var PortalInClass = class extends LibBlock {
|
|
232
|
+
constructor(e, n) {
|
|
150
233
|
super(), this.props = e, this.context = n;
|
|
151
|
-
let r
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
234
|
+
let r;
|
|
235
|
+
n.portals[e.name] ? console.warn(`Портал ${e.name} уже существует`) : this.addEffect(createEffect(() => {
|
|
236
|
+
let i = e.name;
|
|
237
|
+
i !== r && untrack(() => {
|
|
238
|
+
delete n.portals[i], n.portals[i] = e.children;
|
|
239
|
+
}), r = i;
|
|
240
|
+
}));
|
|
241
|
+
}
|
|
242
|
+
unmount() {
|
|
243
|
+
super.unmount(), delete this.context.portals[this.props.name];
|
|
159
244
|
}
|
|
160
245
|
};
|
|
161
|
-
function
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
provider(t) {
|
|
165
|
-
return function(n) {
|
|
166
|
-
return new ContextProvider(t, e, n);
|
|
167
|
-
};
|
|
168
|
-
},
|
|
169
|
-
reader(t) {
|
|
170
|
-
return function(n) {
|
|
171
|
-
return new ContextConsumer(t, e, n);
|
|
172
|
-
};
|
|
173
|
-
}
|
|
246
|
+
function PortalIn(e) {
|
|
247
|
+
return function(t) {
|
|
248
|
+
return new PortalInClass(e, t);
|
|
174
249
|
};
|
|
175
250
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
actions: s
|
|
189
|
-
},
|
|
190
|
-
children: r.children
|
|
251
|
+
var PortalOutClass = class extends LibBlock {
|
|
252
|
+
constructor(e, n) {
|
|
253
|
+
super(), this.props = e, this.context = n;
|
|
254
|
+
let r;
|
|
255
|
+
this.addEffect(createEffect(() => {
|
|
256
|
+
let i = e.name, a = normalizeChildren(n.portals[i]);
|
|
257
|
+
a ? a !== r && (this.unmountChildren(), untrack(() => {
|
|
258
|
+
a.forEach((e, t) => {
|
|
259
|
+
this.children.push(e(mergeContext(n, {
|
|
260
|
+
parentBlock: this,
|
|
261
|
+
index: t
|
|
262
|
+
})));
|
|
191
263
|
});
|
|
192
|
-
},
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
264
|
+
}), r = a) : (this.unmountChildren(), r = null);
|
|
265
|
+
}));
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
function PortalOut(e) {
|
|
269
|
+
return function(t) {
|
|
270
|
+
return new PortalOutClass(e, t);
|
|
197
271
|
};
|
|
198
272
|
}
|
|
199
|
-
export { ClientOnly, ErrorBoundary, Lazy, LibContextReader,
|
|
273
|
+
export { ClientOnly, ErrorBoundary, FooterScripts, HeaderScripts, Lazy, LibContextReader, Lifecycle, List, PortalIn, PortalOut, Show, batch, createEffect, createElementReference, createSignal, deepTrack, getSignal, untrack };
|
package/dist/jsx-runtime.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import {
|
|
3
|
-
import { t as
|
|
1
|
+
import { n as text } from "./normalize-children-BWrn16R7.mjs";
|
|
2
|
+
import { r as potokPreload, t as htmlElement } from "./html-element-DBut4UCf.mjs";
|
|
3
|
+
import { t as fragment } from "./fragment-CXNEPBWB.mjs";
|
|
4
4
|
function detectChild(e) {
|
|
5
5
|
let t = e.value, n = typeof t;
|
|
6
6
|
return n === "string" || n === "number" || n === "boolean" ? text({ get text() {
|
|
7
7
|
return e.value;
|
|
8
8
|
} }) : t;
|
|
9
9
|
}
|
|
10
|
-
export { detectChild, fragment, htmlElement, text };
|
|
10
|
+
export { detectChild, fragment, htmlElement, potokPreload, text };
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
var LibBlock = class {
|
|
2
|
+
effects = /* @__PURE__ */ new Set();
|
|
3
|
+
children = [];
|
|
4
|
+
get parentBlock() {
|
|
5
|
+
return this.context.parentBlock;
|
|
6
|
+
}
|
|
7
|
+
get parentElementNode() {
|
|
8
|
+
let e = this.parentBlock;
|
|
9
|
+
return e ? e.isHTMLElementNode() ? e : e.parentElementNode : null;
|
|
10
|
+
}
|
|
11
|
+
get previousBlock() {
|
|
12
|
+
let e = this.context.parentBlock;
|
|
13
|
+
return e ? e.children[this.context.index - 1] || (e.isNode() ? null : e.previousBlock) : null;
|
|
14
|
+
}
|
|
15
|
+
get nearestPreviousNode() {
|
|
16
|
+
if (this.isNode()) return this;
|
|
17
|
+
let e = this.children[this.children.length - 1];
|
|
18
|
+
if (e) return e.nearestPreviousNode;
|
|
19
|
+
let t = this.previousBlock;
|
|
20
|
+
return t ? t.nearestPreviousNode : null;
|
|
21
|
+
}
|
|
22
|
+
get previousNode() {
|
|
23
|
+
let e = this.previousBlock;
|
|
24
|
+
return e ? e.nearestPreviousNode : null;
|
|
25
|
+
}
|
|
26
|
+
isNode() {
|
|
27
|
+
return !1;
|
|
28
|
+
}
|
|
29
|
+
isHTMLElementNode() {
|
|
30
|
+
return !1;
|
|
31
|
+
}
|
|
32
|
+
isTextNode() {
|
|
33
|
+
return !1;
|
|
34
|
+
}
|
|
35
|
+
addEffect(e) {
|
|
36
|
+
this.effects.add(e);
|
|
37
|
+
}
|
|
38
|
+
unmountChildren() {
|
|
39
|
+
this.children.forEach((e) => {
|
|
40
|
+
e?.unmount();
|
|
41
|
+
}), this.children = [];
|
|
42
|
+
}
|
|
43
|
+
unmount() {
|
|
44
|
+
this.unmountChildren(), this.effects.forEach((e) => {
|
|
45
|
+
e.dispose();
|
|
46
|
+
}), this.effects.clear();
|
|
47
|
+
}
|
|
48
|
+
}, currentEffect = null, currentBatch = null, currentDisposer = null, VALUE_SIGNAL_SYMBOL = Symbol("VALUE_SIGNAL"), ANY_KEY_SYMBOL = Symbol("ANY_KEY");
|
|
49
|
+
function getSignal(e) {
|
|
50
|
+
return e[VALUE_SIGNAL_SYMBOL];
|
|
51
|
+
}
|
|
52
|
+
function isSignal(e) {
|
|
53
|
+
return getSignal(e) !== void 0;
|
|
54
|
+
}
|
|
55
|
+
function canBeSignal(e) {
|
|
56
|
+
return typeof e == "object" && !!e && (Array.isArray(e) || Object.getPrototypeOf(e).isPrototypeOf(Object));
|
|
57
|
+
}
|
|
58
|
+
function createSignal(e) {
|
|
59
|
+
let n = getSignal(e);
|
|
60
|
+
if (n) return n.proxy;
|
|
61
|
+
let r = {
|
|
62
|
+
value: e,
|
|
63
|
+
proxy: new Proxy(e, {
|
|
64
|
+
get(e, n, a) {
|
|
65
|
+
if (n === VALUE_SIGNAL_SYMBOL) return r;
|
|
66
|
+
let o = Reflect.get(e, n, a);
|
|
67
|
+
return currentEffect && r.subscribe(currentEffect, n), canBeSignal(o) ? createSignal(o) : typeof o == "function" ? o.bind(e) : o;
|
|
68
|
+
},
|
|
69
|
+
set(e, t, n, i) {
|
|
70
|
+
let o = Reflect.set(e, t, n, i);
|
|
71
|
+
return o && r.subscribers.forEach((e) => {
|
|
72
|
+
let n = e.subscriptions.get(r);
|
|
73
|
+
(e.ignoreVersion || n?.get(ANY_KEY_SYMBOL) === e.version || n?.get(t) === e.version) && e.runCallback();
|
|
74
|
+
}), o;
|
|
75
|
+
}
|
|
76
|
+
}),
|
|
77
|
+
subscribers: /* @__PURE__ */ new Set(),
|
|
78
|
+
subscribe(e, t) {
|
|
79
|
+
let n = e.subscriptions.get(r);
|
|
80
|
+
n || (n = /* @__PURE__ */ new Map(), e.subscriptions.set(r, n), r.subscribers.add(e)), n.get(t) !== e.version && n.set(t, e.version);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
return Object.defineProperty(e, VALUE_SIGNAL_SYMBOL, {
|
|
84
|
+
value: r,
|
|
85
|
+
enumerable: !1,
|
|
86
|
+
writable: !1,
|
|
87
|
+
configurable: !1
|
|
88
|
+
}), r.proxy;
|
|
89
|
+
}
|
|
90
|
+
function createEffect(e, i = !1) {
|
|
91
|
+
let a = !1, o = {
|
|
92
|
+
callback: e,
|
|
93
|
+
subscriptions: /* @__PURE__ */ new Map(),
|
|
94
|
+
version: 0,
|
|
95
|
+
ignoreVersion: i,
|
|
96
|
+
dispose() {
|
|
97
|
+
a = !0;
|
|
98
|
+
},
|
|
99
|
+
runCallback() {
|
|
100
|
+
if (a) {
|
|
101
|
+
o.subscriptions.forEach((e, t) => {
|
|
102
|
+
t.subscribers.delete(o);
|
|
103
|
+
}), o.subscriptions.clear();
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
if (currentBatch) {
|
|
107
|
+
currentBatch.add(o);
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
currentEffect = o, o.version++, e(), currentEffect = null;
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
return currentDisposer && currentDisposer.effects.add(o), o.runCallback(), o;
|
|
114
|
+
}
|
|
115
|
+
function batch(e) {
|
|
116
|
+
if (currentBatch) return e();
|
|
117
|
+
currentBatch = {
|
|
118
|
+
effects: /* @__PURE__ */ new Set(),
|
|
119
|
+
add(e) {
|
|
120
|
+
this.effects.add(e);
|
|
121
|
+
},
|
|
122
|
+
run() {
|
|
123
|
+
this.effects.forEach((e) => {
|
|
124
|
+
e.runCallback();
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
let t = e(), r = currentBatch;
|
|
129
|
+
return currentBatch = null, r.run(), t;
|
|
130
|
+
}
|
|
131
|
+
function untrack(e) {
|
|
132
|
+
let n = currentEffect;
|
|
133
|
+
currentEffect = null;
|
|
134
|
+
let r = e();
|
|
135
|
+
return currentEffect = n, r;
|
|
136
|
+
}
|
|
137
|
+
function _deepTrack(e, n, r = 0) {
|
|
138
|
+
if (n !== void 0 && n <= 0) {
|
|
139
|
+
console.warn(`depth=${n} не может быть меньше или равен 0`);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
if (!currentEffect) {
|
|
143
|
+
console.warn("deepTrack можно использовать только внутри эффекта");
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
let i = currentEffect;
|
|
147
|
+
untrack(() => {
|
|
148
|
+
let s = getSignal(e);
|
|
149
|
+
if (!s) {
|
|
150
|
+
console.warn("deepTrack можно использовать только с сигналами");
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
if (s.subscribe(i, ANY_KEY_SYMBOL), r++, !(n !== void 0 && r >= n)) if (Array.isArray(e)) for (let a = 0; a < e.length; a++) {
|
|
154
|
+
let o = e[a];
|
|
155
|
+
canBeSignal(o) && (currentEffect = i, _deepTrack(o, n, r));
|
|
156
|
+
}
|
|
157
|
+
else for (let a in e) {
|
|
158
|
+
let o = e[a];
|
|
159
|
+
canBeSignal(o) && (currentEffect = i, _deepTrack(o, n, r));
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
function deepTrack(e, t) {
|
|
164
|
+
_deepTrack(e, t);
|
|
165
|
+
}
|
|
166
|
+
function createDisposer(e) {
|
|
167
|
+
let t = {
|
|
168
|
+
effects: /* @__PURE__ */ new Set(),
|
|
169
|
+
dispose() {
|
|
170
|
+
t.effects.forEach((e) => {
|
|
171
|
+
e.dispose();
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
return currentDisposer = t, e(), currentDisposer = null, t;
|
|
176
|
+
}
|
|
177
|
+
var LibNode = class extends LibBlock {
|
|
178
|
+
isNode() {
|
|
179
|
+
return !0;
|
|
180
|
+
}
|
|
181
|
+
insert() {
|
|
182
|
+
createDisposer(() => {
|
|
183
|
+
this.context.insertNode(this);
|
|
184
|
+
}).effects.forEach((e) => {
|
|
185
|
+
this.effects.add(e);
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
unmount() {
|
|
189
|
+
this.context.removeNode(this), super.unmount();
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
export { deepTrack as a, untrack as c, createSignal as i, LibBlock as l, batch as n, getSignal as o, createEffect as r, isSignal as s, LibNode as t };
|
package/dist/list.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { PotokElement } from './types';
|
|
2
|
+
type ListKey = string | number;
|
|
2
3
|
export type ListProps<Item> = {
|
|
3
4
|
items: Item[];
|
|
5
|
+
keyExtractor: (item: Item, index: number) => ListKey;
|
|
4
6
|
render: (each: {
|
|
5
7
|
item: Item;
|
|
6
8
|
index: number;
|
|
7
9
|
}) => PotokElement;
|
|
8
10
|
};
|
|
9
11
|
export declare function List<Item>(props: ListProps<Item>): PotokElement;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { t as LibNode } from "./lib-node-DyXPvvVQ.mjs";
|
|
2
|
+
function mergeContext(e, t) {
|
|
3
|
+
return {
|
|
4
|
+
parentBlock: t.parentBlock,
|
|
5
|
+
get index() {
|
|
6
|
+
return t.index;
|
|
7
|
+
},
|
|
8
|
+
portals: e.portals,
|
|
9
|
+
preload: e.preload,
|
|
10
|
+
states: e.states,
|
|
11
|
+
contexts: {
|
|
12
|
+
...e.contexts,
|
|
13
|
+
...t.contexts
|
|
14
|
+
},
|
|
15
|
+
isServer: e.isServer,
|
|
16
|
+
promises: e.promises,
|
|
17
|
+
get isHydrating() {
|
|
18
|
+
return e.isHydrating;
|
|
19
|
+
},
|
|
20
|
+
insertNode: e.insertNode,
|
|
21
|
+
removeNode: e.removeNode
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function normalizeArray(e) {
|
|
25
|
+
return Array.isArray(e) ? e : [e];
|
|
26
|
+
}
|
|
27
|
+
var LibTextNode = class extends LibNode {
|
|
28
|
+
constructor(e, t) {
|
|
29
|
+
super(), this.props = e, this.context = t, this.insert();
|
|
30
|
+
}
|
|
31
|
+
isTextNode() {
|
|
32
|
+
return !0;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
function text(e) {
|
|
36
|
+
return function(t) {
|
|
37
|
+
return new LibTextNode(e, t);
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function normalizeChild(e) {
|
|
41
|
+
return typeof e == "string" || typeof e == "number" ? [text({ get text() {
|
|
42
|
+
return String(e);
|
|
43
|
+
} })] : Array.isArray(e) ? e.flatMap(normalizeChildren) : [e];
|
|
44
|
+
}
|
|
45
|
+
function normalizeChildren(e) {
|
|
46
|
+
return e ? normalizeArray(e).filter((e) => e != null).flatMap(normalizeChild) : [];
|
|
47
|
+
}
|
|
48
|
+
export { mergeContext as i, text as n, normalizeArray as r, normalizeChildren as t };
|