@epoch32/visage 1.1.3 → 1.1.5
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/api/index.js +55 -4085
- package/dist/charts/index.js +48 -2806
- package/dist/devtools/index.js +18 -4771
- package/dist/dom/index.js +32 -1639
- package/dist/form/index.js +13 -1498
- package/dist/index-061jf06a.js +848 -0
- package/dist/index-0madxn60.js +442 -0
- package/dist/index-1xtrtz1t.js +256 -0
- package/dist/index-2zz0g2n2.js +212 -0
- package/dist/index-5s255b3w.js +303 -0
- package/dist/index-6kfe1nr4.js +1179 -0
- package/dist/index-8czhpea8.js +338 -0
- package/dist/index-8x8xz80v.js +727 -0
- package/dist/index-921pn75b.js +0 -0
- package/dist/index-965ryh36.js +537 -0
- package/dist/index-9fvarkrx.js +98 -0
- package/dist/index-a4xns6cc.js +219 -0
- package/dist/index-b5wc752a.js +1696 -0
- package/dist/index-df5e614s.js +334 -0
- package/dist/index-dyvgtp43.js +1094 -0
- package/dist/index-grhdtcb5.js +234 -0
- package/dist/index-h6tjqk6e.js +158 -0
- package/dist/index-js199er4.js +101 -0
- package/dist/index-x2rs3vab.js +124 -0
- package/dist/index-y9bq7h9g.js +1162 -0
- package/dist/index-zr6cvset.js +2092 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +458 -11920
- package/dist/jsx-runtime/index.js +13 -1719
- package/dist/query/index.js +47 -2505
- package/dist/router/index.js +25 -1945
- package/dist/rpc/index.js +39 -3567
- package/dist/server/index.js +11 -1256
- package/dist/signals/index.js +52 -1160
- package/dist/style/index.js +77 -2429
- package/dist/template/index.js +7 -1232
- package/dist/ui/index.d.ts +1 -1
- package/dist/ui/index.js +150 -4249
- package/dist/ui/tabs.d.ts +23 -1
- package/dist/virtual/index.js +12 -2044
- package/dist/vite/index.js +27 -746
- package/package.json +2 -2
- package/src/dom/render.ts +20 -7
- package/src/index.ts +2 -0
- package/src/signals/computed.ts +19 -12
- package/src/signals/effect.ts +7 -7
- package/src/signals/signal.ts +16 -12
- package/src/signals/system.ts +50 -21
- package/src/ui/index.ts +2 -0
- package/src/ui/tabs.tsx +211 -10
- package/src/ui/utils.ts +1 -3
- package/src/vite/lucide.ts +22 -2
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
// src/form/schema.ts
|
|
2
|
+
class Schema2 {
|
|
3
|
+
"~standard" = {
|
|
4
|
+
version: 1,
|
|
5
|
+
vendor: "visage",
|
|
6
|
+
validate: (val) => {
|
|
7
|
+
const res = this.validate(val);
|
|
8
|
+
if (res.success) {
|
|
9
|
+
return { value: res.data };
|
|
10
|
+
}
|
|
11
|
+
return {
|
|
12
|
+
issues: (res.issues || []).map((i) => ({
|
|
13
|
+
path: [i.path],
|
|
14
|
+
message: i.message
|
|
15
|
+
}))
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
class StringSchema extends Schema2 {
|
|
22
|
+
_min;
|
|
23
|
+
_max;
|
|
24
|
+
_emailMsg;
|
|
25
|
+
_regex;
|
|
26
|
+
_isOptional = false;
|
|
27
|
+
min(length, message) {
|
|
28
|
+
this._min = { val: length, msg: message };
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
max(length, message) {
|
|
32
|
+
this._max = { val: length, msg: message };
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
35
|
+
email(message) {
|
|
36
|
+
this._emailMsg = message ?? "Invalid email address";
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
regex(pattern, message) {
|
|
40
|
+
this._regex = { pattern, msg: message };
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
43
|
+
optional() {
|
|
44
|
+
this._isOptional = true;
|
|
45
|
+
return this;
|
|
46
|
+
}
|
|
47
|
+
validate(value, path = "") {
|
|
48
|
+
if (value === undefined || value === null || value === "") {
|
|
49
|
+
if (this._isOptional)
|
|
50
|
+
return { success: true, data: undefined };
|
|
51
|
+
return { success: false, issues: [{ path, message: "This field is required" }] };
|
|
52
|
+
}
|
|
53
|
+
if (typeof value !== "string") {
|
|
54
|
+
return { success: false, issues: [{ path, message: "Must be a string" }] };
|
|
55
|
+
}
|
|
56
|
+
if (this._min && value.length < this._min.val) {
|
|
57
|
+
return {
|
|
58
|
+
success: false,
|
|
59
|
+
issues: [{ path, message: this._min.msg ?? `Must be at least ${this._min.val} characters` }]
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
if (this._max && value.length > this._max.val) {
|
|
63
|
+
return {
|
|
64
|
+
success: false,
|
|
65
|
+
issues: [{ path, message: this._max.msg ?? `Must be at most ${this._max.val} characters` }]
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
if (this._emailMsg) {
|
|
69
|
+
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
70
|
+
if (!emailRegex.test(value)) {
|
|
71
|
+
return { success: false, issues: [{ path, message: this._emailMsg }] };
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (this._regex && !this._regex.pattern.test(value)) {
|
|
75
|
+
return {
|
|
76
|
+
success: false,
|
|
77
|
+
issues: [{ path, message: this._regex.msg ?? "Invalid format" }]
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
return { success: true, data: value };
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
class NumberSchema extends Schema2 {
|
|
85
|
+
_min;
|
|
86
|
+
_max;
|
|
87
|
+
_integer;
|
|
88
|
+
_isOptional = false;
|
|
89
|
+
min(value, message) {
|
|
90
|
+
this._min = { val: value, msg: message };
|
|
91
|
+
return this;
|
|
92
|
+
}
|
|
93
|
+
max(value, message) {
|
|
94
|
+
this._max = { val: value, msg: message };
|
|
95
|
+
return this;
|
|
96
|
+
}
|
|
97
|
+
integer(message) {
|
|
98
|
+
this._integer = { msg: message };
|
|
99
|
+
return this;
|
|
100
|
+
}
|
|
101
|
+
optional() {
|
|
102
|
+
this._isOptional = true;
|
|
103
|
+
return this;
|
|
104
|
+
}
|
|
105
|
+
validate(value, path = "") {
|
|
106
|
+
if (value === undefined || value === null || value === "") {
|
|
107
|
+
if (this._isOptional)
|
|
108
|
+
return { success: true, data: undefined };
|
|
109
|
+
return { success: false, issues: [{ path, message: "This field is required" }] };
|
|
110
|
+
}
|
|
111
|
+
const num = Number(value);
|
|
112
|
+
if (Number.isNaN(num) || typeof value === "boolean") {
|
|
113
|
+
return { success: false, issues: [{ path, message: "Must be a valid number" }] };
|
|
114
|
+
}
|
|
115
|
+
if (this._integer && !Number.isInteger(num)) {
|
|
116
|
+
return {
|
|
117
|
+
success: false,
|
|
118
|
+
issues: [{ path, message: this._integer.msg ?? "Must be an integer" }]
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
if (this._min && num < this._min.val) {
|
|
122
|
+
return {
|
|
123
|
+
success: false,
|
|
124
|
+
issues: [{ path, message: this._min.msg ?? `Must be at least ${this._min.val}` }]
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
if (this._max && num > this._max.val) {
|
|
128
|
+
return {
|
|
129
|
+
success: false,
|
|
130
|
+
issues: [{ path, message: this._max.msg ?? `Must be at most ${this._max.val}` }]
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
return { success: true, data: num };
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
class BooleanSchema extends Schema2 {
|
|
138
|
+
validate(value, _path = "") {
|
|
139
|
+
return { success: true, data: Boolean(value) };
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
class ObjectSchema extends Schema2 {
|
|
144
|
+
shape;
|
|
145
|
+
constructor(shape) {
|
|
146
|
+
super();
|
|
147
|
+
this.shape = shape;
|
|
148
|
+
}
|
|
149
|
+
validate(value, basePath = "") {
|
|
150
|
+
if (typeof value !== "object" || value === null) {
|
|
151
|
+
return { success: false, issues: [{ path: basePath, message: "Must be an object" }] };
|
|
152
|
+
}
|
|
153
|
+
const issues = [];
|
|
154
|
+
const data = {};
|
|
155
|
+
for (const key in this.shape) {
|
|
156
|
+
const fieldSchema = this.shape[key];
|
|
157
|
+
const fieldVal = value[key];
|
|
158
|
+
const fieldPath = basePath ? `${basePath}.${key}` : key;
|
|
159
|
+
const res = validateWithSchema2(fieldSchema, fieldVal, fieldPath);
|
|
160
|
+
if (res.success) {
|
|
161
|
+
data[key] = res.data;
|
|
162
|
+
} else if (res.issues) {
|
|
163
|
+
issues.push(...res.issues);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (issues.length > 0) {
|
|
167
|
+
return { success: false, issues };
|
|
168
|
+
}
|
|
169
|
+
return { success: true, data };
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
function validateWithSchema2(schema, value, path = "") {
|
|
173
|
+
if (!schema)
|
|
174
|
+
return { success: true, data: value };
|
|
175
|
+
if (schema instanceof Schema2) {
|
|
176
|
+
return schema.validate(value, path);
|
|
177
|
+
}
|
|
178
|
+
if (typeof schema === "object" && "~standard" in schema) {
|
|
179
|
+
const res = schema["~standard"].validate(value);
|
|
180
|
+
if ("value" in res) {
|
|
181
|
+
return { success: true, data: res.value };
|
|
182
|
+
}
|
|
183
|
+
return {
|
|
184
|
+
success: false,
|
|
185
|
+
issues: res.issues.map((i) => ({
|
|
186
|
+
path: i.path ? i.path.join(".") : path,
|
|
187
|
+
message: i.message
|
|
188
|
+
}))
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
if (typeof schema === "function") {
|
|
192
|
+
const res = schema(value);
|
|
193
|
+
if (res === true || res === null || res === undefined) {
|
|
194
|
+
return { success: true, data: value };
|
|
195
|
+
}
|
|
196
|
+
if (typeof res === "string") {
|
|
197
|
+
return { success: false, issues: [{ path, message: res }] };
|
|
198
|
+
}
|
|
199
|
+
if (typeof res === "object") {
|
|
200
|
+
return res;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return { success: true, data: value };
|
|
204
|
+
}
|
|
205
|
+
var v2 = {
|
|
206
|
+
string: () => new StringSchema,
|
|
207
|
+
number: () => new NumberSchema,
|
|
208
|
+
boolean: () => new BooleanSchema,
|
|
209
|
+
object: (shape) => new ObjectSchema(shape)
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
export { Schema2, validateWithSchema2, v2 };
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
import {
|
|
2
|
+
untrack2,
|
|
3
|
+
resolveValue2,
|
|
4
|
+
insertChild2,
|
|
5
|
+
Scope2,
|
|
6
|
+
onCleanup2,
|
|
7
|
+
runInScope2,
|
|
8
|
+
getActiveScope2,
|
|
9
|
+
useContext2,
|
|
10
|
+
effect2
|
|
11
|
+
} from "./index-6kfe1nr4.js";
|
|
12
|
+
import {
|
|
13
|
+
SuspenseContext2,
|
|
14
|
+
createResource2
|
|
15
|
+
} from "./index-a4xns6cc.js";
|
|
16
|
+
|
|
17
|
+
// src/dom/lazy.ts
|
|
18
|
+
function lazy2(importer) {
|
|
19
|
+
let loadedComponent = null;
|
|
20
|
+
let loadingPromise = null;
|
|
21
|
+
const preload = () => {
|
|
22
|
+
if (loadedComponent) {
|
|
23
|
+
return Promise.resolve(loadedComponent);
|
|
24
|
+
}
|
|
25
|
+
if (!loadingPromise) {
|
|
26
|
+
loadingPromise = importer().then((mod) => {
|
|
27
|
+
const comp = mod && typeof mod === "object" && "default" in mod ? mod.default : mod;
|
|
28
|
+
loadedComponent = comp;
|
|
29
|
+
return comp;
|
|
30
|
+
}).catch((err) => {
|
|
31
|
+
loadingPromise = null;
|
|
32
|
+
throw err;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return loadingPromise;
|
|
36
|
+
};
|
|
37
|
+
const LazyWrapper = (props) => {
|
|
38
|
+
if (loadedComponent) {
|
|
39
|
+
return loadedComponent(props);
|
|
40
|
+
}
|
|
41
|
+
const promise = preload();
|
|
42
|
+
const suspense = useContext2(SuspenseContext2);
|
|
43
|
+
if (suspense) {
|
|
44
|
+
suspense.registerPromise(promise);
|
|
45
|
+
}
|
|
46
|
+
const res = createResource2(() => promise);
|
|
47
|
+
return () => {
|
|
48
|
+
const Comp = res();
|
|
49
|
+
return Comp ? Comp(props) : null;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
LazyWrapper.preload = preload;
|
|
53
|
+
return LazyWrapper;
|
|
54
|
+
}
|
|
55
|
+
// src/dom/control-flow.ts
|
|
56
|
+
function Show2(props) {
|
|
57
|
+
if (typeof document === "undefined") {
|
|
58
|
+
const condition = resolveValue2(props.when);
|
|
59
|
+
if (condition) {
|
|
60
|
+
return typeof props.children === "function" && props.children.length > 0 ? props.children(() => resolveValue2(props.when)) : typeof props.children === "function" ? props.children() : props.children;
|
|
61
|
+
}
|
|
62
|
+
return props.fallback ?? null;
|
|
63
|
+
}
|
|
64
|
+
const marker = document.createComment("visage-show");
|
|
65
|
+
const initialFrag = document.createDocumentFragment();
|
|
66
|
+
initialFrag.appendChild(marker);
|
|
67
|
+
let currentScope = null;
|
|
68
|
+
let currentContent = [];
|
|
69
|
+
effect2(() => {
|
|
70
|
+
const condition = resolveValue2(props.when);
|
|
71
|
+
if (currentScope) {
|
|
72
|
+
currentScope.dispose();
|
|
73
|
+
currentScope = null;
|
|
74
|
+
}
|
|
75
|
+
for (const node of currentContent) {
|
|
76
|
+
if (node.parentNode) {
|
|
77
|
+
node.parentNode.removeChild(node);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
currentContent = [];
|
|
81
|
+
const frag = document.createDocumentFragment();
|
|
82
|
+
if (condition) {
|
|
83
|
+
currentScope = new Scope2(getActiveScope2());
|
|
84
|
+
untrack2(() => {
|
|
85
|
+
runInScope2(currentScope, () => {
|
|
86
|
+
const childRes = typeof props.children === "function" && props.children.length > 0 ? props.children(() => resolveValue2(props.when)) : typeof props.children === "function" ? props.children() : props.children;
|
|
87
|
+
insertChild2(frag, childRes);
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
} else if (props.fallback !== undefined) {
|
|
91
|
+
currentScope = new Scope2(getActiveScope2());
|
|
92
|
+
untrack2(() => {
|
|
93
|
+
runInScope2(currentScope, () => {
|
|
94
|
+
const fallbackRes = typeof props.fallback === "function" ? props.fallback() : props.fallback;
|
|
95
|
+
insertChild2(frag, fallbackRes);
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
currentContent = Array.from(frag.childNodes);
|
|
100
|
+
const parent = marker.parentNode;
|
|
101
|
+
if (parent) {
|
|
102
|
+
parent.insertBefore(frag, marker);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
onCleanup2(() => {
|
|
106
|
+
if (currentScope) {
|
|
107
|
+
currentScope.dispose();
|
|
108
|
+
}
|
|
109
|
+
for (const node of currentContent) {
|
|
110
|
+
if (node.parentNode) {
|
|
111
|
+
node.parentNode.removeChild(node);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
if (marker.parentNode) {
|
|
115
|
+
marker.parentNode.removeChild(marker);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
return initialFrag;
|
|
119
|
+
}
|
|
120
|
+
function For2(props) {
|
|
121
|
+
if (typeof document === "undefined") {
|
|
122
|
+
const list = resolveValue2(props.each) ?? [];
|
|
123
|
+
if (list.length === 0) {
|
|
124
|
+
return props.fallback ?? null;
|
|
125
|
+
}
|
|
126
|
+
return list.map((item, idx) => props.children(item, () => idx));
|
|
127
|
+
}
|
|
128
|
+
const marker = document.createTextNode("");
|
|
129
|
+
const initialFrag = document.createDocumentFragment();
|
|
130
|
+
let items = [];
|
|
131
|
+
let fallbackScope = null;
|
|
132
|
+
let fallbackNodes = [];
|
|
133
|
+
let isMounted = false;
|
|
134
|
+
effect2(() => {
|
|
135
|
+
const list = resolveValue2(props.each) ?? [];
|
|
136
|
+
const parent = marker.parentNode ?? (!isMounted ? initialFrag : null);
|
|
137
|
+
if (list.length === 0) {
|
|
138
|
+
for (const rec of items) {
|
|
139
|
+
rec.scope.dispose();
|
|
140
|
+
for (const node of rec.nodes) {
|
|
141
|
+
if (node.parentNode)
|
|
142
|
+
node.parentNode.removeChild(node);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
items = [];
|
|
146
|
+
if (props.fallback !== undefined && fallbackNodes.length === 0 && parent) {
|
|
147
|
+
fallbackScope = new Scope2(getActiveScope2());
|
|
148
|
+
untrack2(() => {
|
|
149
|
+
runInScope2(fallbackScope, () => {
|
|
150
|
+
const frag = document.createDocumentFragment();
|
|
151
|
+
insertChild2(frag, props.fallback);
|
|
152
|
+
fallbackNodes = Array.from(frag.childNodes);
|
|
153
|
+
if (marker.parentNode) {
|
|
154
|
+
marker.parentNode.insertBefore(frag, marker);
|
|
155
|
+
} else if (!isMounted) {
|
|
156
|
+
initialFrag.appendChild(frag);
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
if (fallbackNodes.length > 0) {
|
|
164
|
+
if (fallbackScope) {
|
|
165
|
+
fallbackScope.dispose();
|
|
166
|
+
fallbackScope = null;
|
|
167
|
+
}
|
|
168
|
+
for (const node of fallbackNodes) {
|
|
169
|
+
if (node.parentNode)
|
|
170
|
+
node.parentNode.removeChild(node);
|
|
171
|
+
}
|
|
172
|
+
fallbackNodes = [];
|
|
173
|
+
}
|
|
174
|
+
if (!parent)
|
|
175
|
+
return;
|
|
176
|
+
const newItems = [];
|
|
177
|
+
const prevMap = new Map;
|
|
178
|
+
for (const rec of items) {
|
|
179
|
+
prevMap.set(rec.item, rec);
|
|
180
|
+
}
|
|
181
|
+
for (let i = 0;i < list.length; i++) {
|
|
182
|
+
const item = list[i];
|
|
183
|
+
const existing = prevMap.get(item);
|
|
184
|
+
if (existing) {
|
|
185
|
+
existing.indexSignal(i);
|
|
186
|
+
newItems.push(existing);
|
|
187
|
+
prevMap.delete(item);
|
|
188
|
+
} else {
|
|
189
|
+
let indexVal = i;
|
|
190
|
+
const indexSubscribers = new Set;
|
|
191
|
+
const indexSignal = (...args) => {
|
|
192
|
+
if (args.length > 0 && args[0] !== undefined && args[0] !== indexVal) {
|
|
193
|
+
indexVal = args[0];
|
|
194
|
+
for (const sub of Array.from(indexSubscribers))
|
|
195
|
+
sub();
|
|
196
|
+
}
|
|
197
|
+
return indexVal;
|
|
198
|
+
};
|
|
199
|
+
const itemScope = new Scope2(getActiveScope2());
|
|
200
|
+
let itemNodes = [];
|
|
201
|
+
untrack2(() => {
|
|
202
|
+
runInScope2(itemScope, () => {
|
|
203
|
+
const frag = document.createDocumentFragment();
|
|
204
|
+
const child = props.children(item, indexSignal);
|
|
205
|
+
insertChild2(frag, child);
|
|
206
|
+
itemNodes = Array.from(frag.childNodes);
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
newItems.push({
|
|
210
|
+
item,
|
|
211
|
+
scope: itemScope,
|
|
212
|
+
nodes: itemNodes,
|
|
213
|
+
indexSignal
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
for (const [, removed] of prevMap) {
|
|
218
|
+
removed.scope.dispose();
|
|
219
|
+
for (const node of removed.nodes) {
|
|
220
|
+
if (node.parentNode)
|
|
221
|
+
node.parentNode.removeChild(node);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
if (marker.parentNode) {
|
|
225
|
+
let currentMarker = marker;
|
|
226
|
+
for (let i = newItems.length - 1;i >= 0; i--) {
|
|
227
|
+
const rec = newItems[i];
|
|
228
|
+
for (let j = rec.nodes.length - 1;j >= 0; j--) {
|
|
229
|
+
const node = rec.nodes[j];
|
|
230
|
+
if (node.nextSibling !== currentMarker) {
|
|
231
|
+
marker.parentNode.insertBefore(node, currentMarker);
|
|
232
|
+
}
|
|
233
|
+
currentMarker = node;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
} else if (!isMounted) {
|
|
237
|
+
for (const rec of newItems) {
|
|
238
|
+
for (const node of rec.nodes) {
|
|
239
|
+
initialFrag.appendChild(node);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
items = newItems;
|
|
244
|
+
});
|
|
245
|
+
isMounted = true;
|
|
246
|
+
initialFrag.appendChild(marker);
|
|
247
|
+
onCleanup2(() => {
|
|
248
|
+
for (const rec of items) {
|
|
249
|
+
rec.scope.dispose();
|
|
250
|
+
}
|
|
251
|
+
if (fallbackScope) {
|
|
252
|
+
fallbackScope.dispose();
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
return initialFrag;
|
|
256
|
+
}
|
|
257
|
+
function Portal2(props) {
|
|
258
|
+
if (typeof document === "undefined") {
|
|
259
|
+
return null;
|
|
260
|
+
}
|
|
261
|
+
const marker = document.createTextNode("");
|
|
262
|
+
let currentScope = null;
|
|
263
|
+
let nodes = [];
|
|
264
|
+
effect2(() => {
|
|
265
|
+
const target = props.mount ?? (typeof document !== "undefined" ? document.body : null);
|
|
266
|
+
if (!target)
|
|
267
|
+
return;
|
|
268
|
+
if (currentScope) {
|
|
269
|
+
currentScope.dispose();
|
|
270
|
+
currentScope = null;
|
|
271
|
+
}
|
|
272
|
+
for (const node of nodes) {
|
|
273
|
+
if (node.parentNode) {
|
|
274
|
+
node.parentNode.removeChild(node);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
nodes = [];
|
|
278
|
+
currentScope = new Scope2(getActiveScope2());
|
|
279
|
+
untrack2(() => {
|
|
280
|
+
runInScope2(currentScope, () => {
|
|
281
|
+
const childRes = typeof props.children === "function" ? props.children() : props.children;
|
|
282
|
+
const frag = document.createDocumentFragment();
|
|
283
|
+
insertChild2(frag, childRes);
|
|
284
|
+
nodes = Array.from(frag.childNodes);
|
|
285
|
+
target.appendChild(frag);
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
});
|
|
289
|
+
onCleanup2(() => {
|
|
290
|
+
if (currentScope) {
|
|
291
|
+
currentScope.dispose();
|
|
292
|
+
currentScope = null;
|
|
293
|
+
}
|
|
294
|
+
for (const node of nodes) {
|
|
295
|
+
if (node.parentNode) {
|
|
296
|
+
node.parentNode.removeChild(node);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
nodes = [];
|
|
300
|
+
});
|
|
301
|
+
return marker;
|
|
302
|
+
}
|
|
303
|
+
export { lazy2, Show2, For2, Portal2 };
|