rosetack 0.1.2 → 0.1.4
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/deploy/cloudflare/functions/[[path]].ts +61 -0
- package/deploy/cloudflare/wrangler.toml +14 -0
- package/deploy/netlify/functions/rosetack.ts +38 -0
- package/deploy/netlify.toml +17 -0
- package/devtools/devtools.html +7 -0
- package/devtools/devtools.js +1 -0
- package/devtools/manifest.json +8 -0
- package/devtools/panel.html +28 -0
- package/devtools/panel.js +54 -0
- package/dist-cli/compiler.mjs +2194 -561
- package/dist-cli/edge.mjs +159 -48
- package/dist-cli/rosetack.mjs +2899 -739
- package/dist-cli/runtime.mjs +305 -43
- package/dist-cli/test.mjs +2332 -630
- package/package.json +4 -3
- package/src/FRAMEWORK_VERSION +1 -1
- package/src/cli/content.ts +186 -0
- package/src/cli/edge.ts +78 -62
- package/src/cli/image-size.ts +83 -0
- package/src/cli/index.ts +391 -334
- package/src/cli/prod-server.ts +324 -0
- package/src/cli/prompt.ts +51 -20
- package/src/cli/shell.ts +105 -74
- package/src/cli/test.ts +9 -70
- package/src/compiler/index.ts +2107 -913
- package/src/runtime/index.ts +367 -168
- package/src/types/rosetack.d.ts +16 -66
- package/templates/admin/package.json +14 -0
- package/templates/admin/rosetack.config.js +1 -0
- package/templates/admin/src/pages/_middleware.rose +33 -0
- package/templates/admin/src/pages/api/items.rose +37 -0
- package/templates/admin/src/pages/api/login.rose +25 -0
- package/templates/admin/src/pages/index.rose +79 -0
- package/templates/api/package.json +14 -0
- package/templates/api/rosetack.config.js +1 -0
- package/templates/api/src/pages/api/health.rose +7 -0
- package/templates/api/src/pages/api/items.rose +46 -0
- package/templates/api/src/pages/api/login.rose +24 -0
- package/templates/api/src/pages/index.rose +25 -0
- package/templates/blog/package.json +14 -0
- package/templates/blog/rosetack.config.js +1 -0
- package/templates/blog/src/pages/404.rose +2 -0
- package/templates/blog/src/pages/_layout.rose +42 -0
- package/templates/blog/src/pages/_middleware.rose +74 -0
- package/templates/blog/src/pages/admin.rose +85 -0
- package/templates/blog/src/pages/api/login.rose +46 -0
- package/templates/blog/src/pages/api/posts/[id].rose +37 -0
- package/templates/blog/src/pages/api/posts.rose +72 -0
- package/templates/blog/src/pages/index.rose +31 -0
- package/templates/blog/src/pages/post/[id].rose +36 -0
- package/templates/site/package.json +14 -0
- package/templates/site/rosetack.config.js +1 -0
- package/templates/site/src/pages/404.rose +2 -0
- package/templates/site/src/pages/_layout.rose +40 -0
- package/templates/site/src/pages/about.rose +6 -0
- package/templates/site/src/pages/index.rose +13 -0
- package/templates/site/src/pages/pricing.rose +8 -0
package/dist-cli/runtime.mjs
CHANGED
|
@@ -8,6 +8,7 @@ function entry(key, initial) {
|
|
|
8
8
|
return e;
|
|
9
9
|
}
|
|
10
10
|
function state(key, initial) {
|
|
11
|
+
ownerKeys()?.add(key);
|
|
11
12
|
const e = entry(key, initial);
|
|
12
13
|
const getter = () => {
|
|
13
14
|
if (currentEffect) e.subs.add(currentEffect);
|
|
@@ -16,6 +17,7 @@ function state(key, initial) {
|
|
|
16
17
|
const setter = (v) => {
|
|
17
18
|
e.value = v;
|
|
18
19
|
e.subs.forEach((fn) => fn());
|
|
20
|
+
if (persistedKeys.has(key)) writeStorage(key, v);
|
|
19
21
|
};
|
|
20
22
|
return [getter, setter];
|
|
21
23
|
}
|
|
@@ -26,8 +28,77 @@ function setState(key, value) {
|
|
|
26
28
|
const e = entry(key, value);
|
|
27
29
|
e.value = value;
|
|
28
30
|
e.subs.forEach((fn) => fn());
|
|
31
|
+
if (persistedKeys.has(key)) writeStorage(key, value);
|
|
32
|
+
}
|
|
33
|
+
var persistedKeys = /* @__PURE__ */ new Set();
|
|
34
|
+
function writeStorage(key, v) {
|
|
35
|
+
try {
|
|
36
|
+
globalThis.localStorage?.setItem("rosetack:" + key, JSON.stringify(v));
|
|
37
|
+
} catch {
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function persistState(key, initial) {
|
|
41
|
+
persistedKeys.add(key);
|
|
42
|
+
let seeded = initial;
|
|
43
|
+
let hasStored = false;
|
|
44
|
+
try {
|
|
45
|
+
const raw = globalThis.localStorage?.getItem("rosetack:" + key);
|
|
46
|
+
if (raw != null) {
|
|
47
|
+
seeded = JSON.parse(raw);
|
|
48
|
+
hasStored = true;
|
|
49
|
+
}
|
|
50
|
+
} catch {
|
|
51
|
+
}
|
|
52
|
+
const [get, set] = state(key, seeded);
|
|
53
|
+
if (hasStored) set(seeded);
|
|
54
|
+
return [get, set];
|
|
55
|
+
}
|
|
56
|
+
var lastBoundaryError = null;
|
|
57
|
+
function $setBoundaryError(e) {
|
|
58
|
+
lastBoundaryError = e instanceof Error ? e : new Error(String(e));
|
|
59
|
+
}
|
|
60
|
+
function $boundaryError() {
|
|
61
|
+
return lastBoundaryError;
|
|
29
62
|
}
|
|
30
63
|
var cleanups = /* @__PURE__ */ new Set();
|
|
64
|
+
var fxOwner = null;
|
|
65
|
+
var fxByOwner = /* @__PURE__ */ new WeakMap();
|
|
66
|
+
var keysByOwner = /* @__PURE__ */ new WeakMap();
|
|
67
|
+
var fxSet = () => {
|
|
68
|
+
if (!fxOwner) return cleanups;
|
|
69
|
+
let s = fxByOwner.get(fxOwner);
|
|
70
|
+
if (!s) {
|
|
71
|
+
s = /* @__PURE__ */ new Set();
|
|
72
|
+
fxByOwner.set(fxOwner, s);
|
|
73
|
+
}
|
|
74
|
+
return s;
|
|
75
|
+
};
|
|
76
|
+
var ownerKeys = () => {
|
|
77
|
+
if (!fxOwner) return null;
|
|
78
|
+
let s = keysByOwner.get(fxOwner);
|
|
79
|
+
if (!s) {
|
|
80
|
+
s = /* @__PURE__ */ new Set();
|
|
81
|
+
keysByOwner.set(fxOwner, s);
|
|
82
|
+
}
|
|
83
|
+
return s;
|
|
84
|
+
};
|
|
85
|
+
function setFxOwner(container) {
|
|
86
|
+
fxOwner = container;
|
|
87
|
+
}
|
|
88
|
+
function resetContainerFx(container) {
|
|
89
|
+
const set = fxByOwner.get(container);
|
|
90
|
+
if (set) {
|
|
91
|
+
set.forEach((fn) => fn());
|
|
92
|
+
fxByOwner.delete(container);
|
|
93
|
+
}
|
|
94
|
+
const keys = keysByOwner.get(container);
|
|
95
|
+
if (keys) {
|
|
96
|
+
keys.forEach((k) => signalMap.delete(k));
|
|
97
|
+
keysByOwner.delete(container);
|
|
98
|
+
}
|
|
99
|
+
dataCache.clear();
|
|
100
|
+
pendingDeltas.clear();
|
|
101
|
+
}
|
|
31
102
|
function effect(fn) {
|
|
32
103
|
const wrapped = () => {
|
|
33
104
|
try {
|
|
@@ -41,9 +112,9 @@ function effect(fn) {
|
|
|
41
112
|
currentEffect = prev;
|
|
42
113
|
const cleanup = () => {
|
|
43
114
|
signalMap.forEach((e) => e.subs.delete(wrapped));
|
|
44
|
-
|
|
115
|
+
fxSet().delete(cleanup);
|
|
45
116
|
};
|
|
46
|
-
|
|
117
|
+
fxSet().add(cleanup);
|
|
47
118
|
return cleanup;
|
|
48
119
|
}
|
|
49
120
|
var ESC_MAP = {
|
|
@@ -58,35 +129,35 @@ function esc(v) {
|
|
|
58
129
|
}
|
|
59
130
|
function textMark(closes, fn, pair, arg) {
|
|
60
131
|
const i = closes.push(fn) - 1;
|
|
61
|
-
return `<!--\u27E6m:${i}\u27E7-->` + esc(
|
|
132
|
+
return `<!--\u27E6m:${i}\u27E7-->` + esc(fn(arg)) + (pair ? `<!--\u27E6/m:${i}\u27E7-->` : "");
|
|
62
133
|
}
|
|
63
134
|
function attrMark(closes, fn, name, arg) {
|
|
64
135
|
const i = closes.push(fn) - 1;
|
|
65
|
-
return `${name}="${esc(
|
|
136
|
+
return `${name}="${esc(fn(arg))}" data-b${i}="${name}"`;
|
|
137
|
+
}
|
|
138
|
+
function boolAttrMark(closes, fn, name, arg) {
|
|
139
|
+
const i = closes.push(fn) - 1;
|
|
140
|
+
return (fn(arg) ? ` ${name}=""` : "") + ` data-b${i}="!${name}"`;
|
|
66
141
|
}
|
|
67
142
|
function ifMark(closes, cond, fn, scope) {
|
|
68
|
-
const i = closes.length;
|
|
69
143
|
let snap = null;
|
|
70
|
-
closes.push(() => {
|
|
144
|
+
const i = closes.push(() => {
|
|
71
145
|
if (!cond()) {
|
|
72
146
|
snap = null;
|
|
73
147
|
return null;
|
|
74
148
|
}
|
|
75
149
|
if (!snap) {
|
|
76
|
-
|
|
77
|
-
snap = { html: String(fn(scope, c)), closes: c };
|
|
150
|
+
snap = { html: String(fn(scope, closes)), closes };
|
|
78
151
|
}
|
|
79
152
|
return snap;
|
|
80
|
-
});
|
|
153
|
+
}) - 1;
|
|
81
154
|
const r = closes[i]();
|
|
82
155
|
return `<!--\u27E6i:${i}\u27E7-->` + (r ? r.html : "") + `<!--\u27E6/i:${i}\u27E7-->`;
|
|
83
156
|
}
|
|
84
157
|
function eachMark(closes, items, fn) {
|
|
85
|
-
const i = closes.
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
return { html: String(fn(v, c)), closes: c, scope: v };
|
|
89
|
-
}));
|
|
158
|
+
const i = closes.push(() => items().map((v, vi) => {
|
|
159
|
+
return { html: String(fn(v, closes, vi)), closes, scope: v };
|
|
160
|
+
})) - 1;
|
|
90
161
|
let h = `<!--\u27E6l:${i}\u27E7-->`;
|
|
91
162
|
for (const r of closes[i]()) h += r.html;
|
|
92
163
|
return h + `<!--\u27E6/l:${i}\u27E7-->`;
|
|
@@ -96,13 +167,22 @@ function headMark(closes, fn) {
|
|
|
96
167
|
return `<!--\u27E6h:${i}\u27E7-->` + fn() + `<!--\u27E6/h:${i}\u27E7-->`;
|
|
97
168
|
}
|
|
98
169
|
function rawMark(closes, fn, arg) {
|
|
99
|
-
const i = closes.push((s) => ({ html: String(fn(s) ?? ""), closes
|
|
170
|
+
const i = closes.push((s) => ({ html: String(fn(s) ?? ""), closes })) - 1;
|
|
100
171
|
const r = closes[i](arg);
|
|
101
172
|
return `<!--\u27E6i:${i}\u27E7-->` + r.html + `<!--\u27E6/i:${i}\u27E7-->`;
|
|
102
173
|
}
|
|
174
|
+
function slotBlockMark(closes, hit) {
|
|
175
|
+
if (!hit) return "";
|
|
176
|
+
const i = closes.push(() => {
|
|
177
|
+
if (!hit) return null;
|
|
178
|
+
return { html: String(hit.fn(hit.o, closes)), closes, scope: hit.o };
|
|
179
|
+
}) - 1;
|
|
180
|
+
return `<!--\u27E6i:${i}\u27E7-->` + String(hit.fn(hit.o, closes)) + `<!--\u27E6/i:${i}\u27E7-->`;
|
|
181
|
+
}
|
|
103
182
|
var MARK_RE = /^\u27e6([milh]):(\d+)\u27e7$/;
|
|
104
183
|
var END_RE = /^\u27e6\/([milh]):(\d+)\u27e7$/;
|
|
105
184
|
var wired = /* @__PURE__ */ new WeakSet();
|
|
185
|
+
var pendingIslandObservers = /* @__PURE__ */ new Set();
|
|
106
186
|
function tpl(html) {
|
|
107
187
|
const t = document.createElement("template");
|
|
108
188
|
t.innerHTML = html;
|
|
@@ -110,6 +190,13 @@ function tpl(html) {
|
|
|
110
190
|
}
|
|
111
191
|
var HEAD_ATTR = "data-rosetack-head";
|
|
112
192
|
var handlers = globalThis.__rosetack_handlers ??= {};
|
|
193
|
+
var actionDispatch = null;
|
|
194
|
+
function setActionDispatcher(fn) {
|
|
195
|
+
actionDispatch = fn;
|
|
196
|
+
}
|
|
197
|
+
var directBound = /* @__PURE__ */ new WeakMap();
|
|
198
|
+
var directives = globalThis.__rosetack_directives ??= {};
|
|
199
|
+
var actionRecords = /* @__PURE__ */ new WeakMap();
|
|
113
200
|
function applyHead(html) {
|
|
114
201
|
const seen = /* @__PURE__ */ new Set();
|
|
115
202
|
const positional = /* @__PURE__ */ new Map();
|
|
@@ -158,10 +245,11 @@ function wire(root, closes, scope) {
|
|
|
158
245
|
const walker = document.createTreeWalker(holder, NodeFilter.SHOW_COMMENT);
|
|
159
246
|
while (walker.nextNode()) comments.push(walker.currentNode);
|
|
160
247
|
const nested = /* @__PURE__ */ new Set();
|
|
248
|
+
const headPair = /* @__PURE__ */ new Set();
|
|
161
249
|
const open = [];
|
|
162
250
|
for (let i = 0; i < comments.length; i++) {
|
|
163
251
|
const m = (comments[i].nodeValue ?? "").match(MARK_RE);
|
|
164
|
-
if (m && (m[1] === "i" || m[1] === "l")) {
|
|
252
|
+
if (m && (m[1] === "i" || m[1] === "l" || m[1] === "h")) {
|
|
165
253
|
open.push(i);
|
|
166
254
|
continue;
|
|
167
255
|
}
|
|
@@ -170,16 +258,22 @@ function wire(root, closes, scope) {
|
|
|
170
258
|
const key = em[1] + em[2];
|
|
171
259
|
let at = -1;
|
|
172
260
|
for (let k = open.length - 1; k >= 0; k--) {
|
|
173
|
-
const
|
|
174
|
-
if (
|
|
261
|
+
const om2 = (comments[open[k]].nodeValue ?? "").match(MARK_RE);
|
|
262
|
+
if (om2[1] + om2[2] === key) {
|
|
175
263
|
at = k;
|
|
176
264
|
break;
|
|
177
265
|
}
|
|
178
266
|
}
|
|
179
267
|
if (at < 0) continue;
|
|
268
|
+
const om = (comments[open[at]].nodeValue ?? "").match(MARK_RE);
|
|
269
|
+
if (om[1] === "h") {
|
|
270
|
+
headPair.add(comments[open[at]]);
|
|
271
|
+
headPair.add(comments[i]);
|
|
272
|
+
}
|
|
180
273
|
for (let k = open[at] + 1; k < i; k++) nested.add(comments[k]);
|
|
181
274
|
open.length = at;
|
|
182
275
|
}
|
|
276
|
+
for (const c of headPair) nested.delete(c);
|
|
183
277
|
const ends = /* @__PURE__ */ new Map();
|
|
184
278
|
for (const c of comments) {
|
|
185
279
|
if (nested.has(c)) continue;
|
|
@@ -187,13 +281,42 @@ function wire(root, closes, scope) {
|
|
|
187
281
|
if (m) ends.set(+m[2], c);
|
|
188
282
|
}
|
|
189
283
|
const headBlocks = [];
|
|
284
|
+
const ownsHead = root === document.getElementById("app");
|
|
285
|
+
let islandSkip = false;
|
|
286
|
+
if (ownsHead) {
|
|
287
|
+
const islandEls = Array.from(
|
|
288
|
+
holder.querySelectorAll("[data-rv-island]")
|
|
289
|
+
).filter((el) => !(el.parentElement && el.parentElement.closest("[data-rv-island]")));
|
|
290
|
+
islandSkip = islandEls.length > 0;
|
|
291
|
+
for (const isl of islandEls) {
|
|
292
|
+
const fire = () => wire(isl, closes, scope);
|
|
293
|
+
const mode = isl.getAttribute("data-rv-island-hydrate");
|
|
294
|
+
if (mode === "visible" && typeof IntersectionObserver !== "undefined") {
|
|
295
|
+
const io = new IntersectionObserver((entries) => {
|
|
296
|
+
if (entries.some((en) => en.isIntersecting)) {
|
|
297
|
+
io.disconnect();
|
|
298
|
+
pendingIslandObservers.delete(io);
|
|
299
|
+
fire();
|
|
300
|
+
}
|
|
301
|
+
});
|
|
302
|
+
io.observe(isl);
|
|
303
|
+
pendingIslandObservers.add(io);
|
|
304
|
+
} else if (mode === "idle" && typeof globalThis.requestIdleCallback === "function") {
|
|
305
|
+
globalThis.requestIdleCallback(() => fire());
|
|
306
|
+
} else {
|
|
307
|
+
fire();
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
190
311
|
for (const c of comments) {
|
|
191
312
|
if (nested.has(c) || wired.has(c) || !c.parentNode) continue;
|
|
192
|
-
wired.add(c);
|
|
193
313
|
const m = (c.nodeValue ?? "").match(MARK_RE);
|
|
194
314
|
if (!m) continue;
|
|
195
315
|
const kind = m[1];
|
|
196
316
|
const idx = +m[2];
|
|
317
|
+
if (islandSkip && kind !== "h" && c.parentNode.closest?.("[data-rv-island]")) continue;
|
|
318
|
+
if (kind === "h" && !ownsHead) continue;
|
|
319
|
+
wired.add(c);
|
|
197
320
|
if (kind === "h") {
|
|
198
321
|
const end = ends.get(idx);
|
|
199
322
|
if (!end) continue;
|
|
@@ -256,7 +379,7 @@ function wire(root, closes, scope) {
|
|
|
256
379
|
const disp = wire(frag, r.closes, r.scope ?? scope);
|
|
257
380
|
const nodes = Array.from(frag.childNodes);
|
|
258
381
|
const parent = anchor.parentNode;
|
|
259
|
-
for (const nd of nodes) parent.insertBefore(nd,
|
|
382
|
+
for (const nd of nodes) parent.insertBefore(nd, end);
|
|
260
383
|
st.__st = { nodes, disp };
|
|
261
384
|
});
|
|
262
385
|
} else {
|
|
@@ -287,30 +410,134 @@ function wire(root, closes, scope) {
|
|
|
287
410
|
});
|
|
288
411
|
}
|
|
289
412
|
}
|
|
290
|
-
if (
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
413
|
+
if (root === document.getElementById("app")) {
|
|
414
|
+
if (headBlocks.length > 0) {
|
|
415
|
+
const blocks = headBlocks;
|
|
416
|
+
weff(() => {
|
|
417
|
+
let html = "";
|
|
418
|
+
for (const b of blocks) html += String(closes[b.idx](scope));
|
|
419
|
+
applyHead(html);
|
|
420
|
+
});
|
|
421
|
+
for (const b of blocks) {
|
|
422
|
+
b.nodes.forEach((nd) => nd.remove());
|
|
423
|
+
b.start.remove();
|
|
424
|
+
b.end.remove();
|
|
425
|
+
}
|
|
426
|
+
} else if (root.nodeType !== 11) clearHead();
|
|
427
|
+
}
|
|
428
|
+
const all = holder.querySelectorAll("*");
|
|
429
|
+
all.forEach((el) => {
|
|
430
|
+
if (islandSkip && el.closest("[data-rv-island]")) return;
|
|
431
|
+
for (const an of el.getAttributeNames()) {
|
|
432
|
+
if (!an.startsWith("data-b")) continue;
|
|
433
|
+
const idx = Number(an.slice(6));
|
|
434
|
+
if (!Number.isFinite(idx)) continue;
|
|
435
|
+
const attr = el.getAttribute(an);
|
|
436
|
+
el.removeAttribute(an);
|
|
437
|
+
const effect2 = () => String(closes[idx](scope));
|
|
438
|
+
if (attr === "data-use-param") {
|
|
439
|
+
weff(() => {
|
|
440
|
+
const raw = effect2();
|
|
441
|
+
let p = raw;
|
|
442
|
+
try {
|
|
443
|
+
p = JSON.parse(raw);
|
|
444
|
+
} catch {
|
|
445
|
+
}
|
|
446
|
+
actionRecords.get(el)?.update?.(p);
|
|
447
|
+
});
|
|
448
|
+
continue;
|
|
449
|
+
}
|
|
450
|
+
if (attr === "value") {
|
|
451
|
+
weff(() => {
|
|
452
|
+
const v = effect2();
|
|
453
|
+
const inp = el;
|
|
454
|
+
if (inp.value !== v) inp.value = v;
|
|
455
|
+
});
|
|
456
|
+
} else if (attr.startsWith("!")) {
|
|
457
|
+
const name = attr.slice(1);
|
|
458
|
+
weff(() => {
|
|
459
|
+
const v = closes[idx](scope);
|
|
460
|
+
const live = !(v === false || v == null || v === "" || v === "false" || v === 0);
|
|
461
|
+
const target = el;
|
|
462
|
+
if (target[name] !== live) target[name] = live;
|
|
463
|
+
if (live) el.setAttribute(name, "");
|
|
464
|
+
else el.removeAttribute(name);
|
|
465
|
+
});
|
|
466
|
+
} else {
|
|
467
|
+
weff(() => {
|
|
468
|
+
el.setAttribute(attr, effect2());
|
|
469
|
+
});
|
|
470
|
+
}
|
|
301
471
|
}
|
|
302
|
-
} else if (root.nodeType !== 11) clearHead();
|
|
303
|
-
const els = holder.querySelectorAll("[data-b]");
|
|
304
|
-
els.forEach((el) => {
|
|
305
|
-
const spec = el.getAttribute("data-b");
|
|
306
|
-
const sep = spec.indexOf(":");
|
|
307
|
-
const idx = +spec.slice(0, sep);
|
|
308
|
-
const attr = spec.slice(sep + 1);
|
|
309
|
-
el.removeAttribute("data-b");
|
|
310
|
-
weff(() => {
|
|
311
|
-
el.setAttribute(attr, String(closes[idx](scope)));
|
|
312
|
-
});
|
|
313
472
|
});
|
|
473
|
+
const uses = holder.querySelectorAll("[data-use]");
|
|
474
|
+
uses.forEach((el) => {
|
|
475
|
+
if (islandSkip && el.closest("[data-rv-island]")) return;
|
|
476
|
+
const name = el.getAttribute("data-use");
|
|
477
|
+
const fn = directives[name];
|
|
478
|
+
if (!fn) {
|
|
479
|
+
console.warn(`rosetack: use:${name} has no registered action (directives.${name}?)`);
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
const rawParam = el.getAttribute("data-use-param");
|
|
483
|
+
let initial = rawParam ?? void 0;
|
|
484
|
+
if (typeof initial === "string") {
|
|
485
|
+
try {
|
|
486
|
+
initial = JSON.parse(initial);
|
|
487
|
+
} catch {
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
const ret = fn(el, initial);
|
|
491
|
+
if (typeof ret === "function") created.push(ret);
|
|
492
|
+
else if (ret && typeof ret === "object") {
|
|
493
|
+
actionRecords.set(el, { update: ret.update, destroy: ret.destroy });
|
|
494
|
+
if (ret.destroy) created.push(ret.destroy);
|
|
495
|
+
}
|
|
496
|
+
});
|
|
497
|
+
const refs = holder.querySelectorAll("[data-bind-this]");
|
|
498
|
+
refs.forEach((el) => {
|
|
499
|
+
if (islandSkip && el.closest("[data-rv-island]")) return;
|
|
500
|
+
const key = el.getAttribute("data-bind-this");
|
|
501
|
+
setState(key, el);
|
|
502
|
+
created.push(() => setState(key, null));
|
|
503
|
+
});
|
|
504
|
+
const DELEGATED_SET = /* @__PURE__ */ new Set(["click", "input", "change", "submit"]);
|
|
505
|
+
const evRoot = holder;
|
|
506
|
+
const evTargets = [evRoot, ...Array.from(evRoot.querySelectorAll("*"))];
|
|
507
|
+
for (const el of evTargets) {
|
|
508
|
+
if (!el.getAttributeNames) continue;
|
|
509
|
+
if (islandSkip && el.closest && el.closest("[data-rv-island]")) continue;
|
|
510
|
+
for (const an of el.getAttributeNames()) {
|
|
511
|
+
const mm = /^data-on(w|d)?-(.+)$/.exec(an);
|
|
512
|
+
if (!mm) continue;
|
|
513
|
+
const ev = mm[2];
|
|
514
|
+
if (!mm[1] && DELEGATED_SET.has(ev)) continue;
|
|
515
|
+
const g = globalThis;
|
|
516
|
+
const win = g.window ?? g.document?.defaultView;
|
|
517
|
+
const target = mm[1] === "w" ? win : mm[1] === "d" ? g.document : el;
|
|
518
|
+
if (!target) continue;
|
|
519
|
+
let seen = directBound.get(el);
|
|
520
|
+
if (!seen) directBound.set(el, seen = /* @__PURE__ */ new Set());
|
|
521
|
+
if (seen.has(ev)) continue;
|
|
522
|
+
seen.add(ev);
|
|
523
|
+
const spec = el.getAttribute(an);
|
|
524
|
+
const listener = (e) => {
|
|
525
|
+
if (!el.hasAttribute(an)) return;
|
|
526
|
+
if (spec.startsWith("$action:")) {
|
|
527
|
+
if (actionDispatch) actionDispatch(spec.slice("$action:".length), e);
|
|
528
|
+
return;
|
|
529
|
+
}
|
|
530
|
+
const h = handlers[spec];
|
|
531
|
+
if (h) h(e);
|
|
532
|
+
};
|
|
533
|
+
target.addEventListener(ev, listener);
|
|
534
|
+
created.push(() => {
|
|
535
|
+
target.removeEventListener(ev, listener);
|
|
536
|
+
const s = directBound.get(el);
|
|
537
|
+
if (s) s.delete(ev);
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
}
|
|
314
541
|
if (holder !== root) {
|
|
315
542
|
while (holder.firstChild) root.appendChild(holder.firstChild);
|
|
316
543
|
}
|
|
@@ -319,6 +546,8 @@ function wire(root, closes, scope) {
|
|
|
319
546
|
function resetEffects() {
|
|
320
547
|
cleanups.forEach((fn) => fn());
|
|
321
548
|
cleanups.clear();
|
|
549
|
+
pendingIslandObservers.forEach((io) => io.disconnect());
|
|
550
|
+
pendingIslandObservers.clear();
|
|
322
551
|
}
|
|
323
552
|
var dataCache = /* @__PURE__ */ new Map();
|
|
324
553
|
function $data(fn) {
|
|
@@ -425,7 +654,7 @@ function flushMounts() {
|
|
|
425
654
|
for (const fn of q) fn();
|
|
426
655
|
}
|
|
427
656
|
function onCleanup(fn) {
|
|
428
|
-
|
|
657
|
+
fxSet().add(fn);
|
|
429
658
|
}
|
|
430
659
|
function adoptCleanups(fns) {
|
|
431
660
|
for (const fn of fns) cleanups.add(fn);
|
|
@@ -467,6 +696,26 @@ function bestLocale(header) {
|
|
|
467
696
|
}
|
|
468
697
|
return null;
|
|
469
698
|
}
|
|
699
|
+
var RoseRedirect = class extends Error {
|
|
700
|
+
constructor(path, status = 307) {
|
|
701
|
+
super(`redirect to ${path}`);
|
|
702
|
+
this.path = path;
|
|
703
|
+
this.status = status;
|
|
704
|
+
}
|
|
705
|
+
__rosetack = "redirect";
|
|
706
|
+
};
|
|
707
|
+
var RoseNotFound = class extends Error {
|
|
708
|
+
__rosetack = "notFound";
|
|
709
|
+
constructor() {
|
|
710
|
+
super("notFound()");
|
|
711
|
+
}
|
|
712
|
+
};
|
|
713
|
+
function redirect(path, status = 307) {
|
|
714
|
+
throw new RoseRedirect(path, status);
|
|
715
|
+
}
|
|
716
|
+
function notFound() {
|
|
717
|
+
throw new RoseNotFound();
|
|
718
|
+
}
|
|
470
719
|
var RTL_RE = /^(ar|fa|he|ur|ps|sd|ug|yi|ckb|dv|ks|prs|haz|mzn|nqo)/;
|
|
471
720
|
function localeDir(lang) {
|
|
472
721
|
return RTL_RE.test(lang) ? "rtl" : "";
|
|
@@ -642,6 +891,7 @@ export {
|
|
|
642
891
|
$actionError,
|
|
643
892
|
$actionErrorOrThrow,
|
|
644
893
|
$append,
|
|
894
|
+
$boundaryError,
|
|
645
895
|
$boundaryFallback,
|
|
646
896
|
$cookies,
|
|
647
897
|
$data,
|
|
@@ -649,9 +899,12 @@ export {
|
|
|
649
899
|
$prepend,
|
|
650
900
|
$query,
|
|
651
901
|
$sessionCookie,
|
|
902
|
+
$setBoundaryError,
|
|
652
903
|
$store,
|
|
653
904
|
$t,
|
|
654
905
|
ActionError,
|
|
906
|
+
RoseNotFound,
|
|
907
|
+
RoseRedirect,
|
|
655
908
|
StateDelta,
|
|
656
909
|
adoptCleanups,
|
|
657
910
|
applyHead,
|
|
@@ -660,9 +913,11 @@ export {
|
|
|
660
913
|
applyStorePatch,
|
|
661
914
|
attrMark,
|
|
662
915
|
bestLocale,
|
|
916
|
+
boolAttrMark,
|
|
663
917
|
clearHead,
|
|
664
918
|
clearMounts,
|
|
665
919
|
clearRequestState,
|
|
920
|
+
directives,
|
|
666
921
|
eachMark,
|
|
667
922
|
effect,
|
|
668
923
|
ensureLocale,
|
|
@@ -678,16 +933,22 @@ export {
|
|
|
678
933
|
loadLocale,
|
|
679
934
|
localeDir,
|
|
680
935
|
localeList,
|
|
936
|
+
notFound,
|
|
681
937
|
onCleanup,
|
|
682
938
|
onMount,
|
|
939
|
+
persistState,
|
|
683
940
|
rawMark,
|
|
941
|
+
redirect,
|
|
684
942
|
refresh,
|
|
685
943
|
reportVitals,
|
|
944
|
+
resetContainerFx,
|
|
686
945
|
resetEffects,
|
|
687
946
|
resetRequestContext,
|
|
688
947
|
restoreState,
|
|
689
948
|
resumeState,
|
|
690
949
|
serializeState,
|
|
950
|
+
setActionDispatcher,
|
|
951
|
+
setFxOwner,
|
|
691
952
|
setLocalePacks,
|
|
692
953
|
setLocales,
|
|
693
954
|
setPrefetchOverride,
|
|
@@ -696,6 +957,7 @@ export {
|
|
|
696
957
|
setState,
|
|
697
958
|
setStateDelta,
|
|
698
959
|
setStoreTransport,
|
|
960
|
+
slotBlockMark,
|
|
699
961
|
state,
|
|
700
962
|
textMark,
|
|
701
963
|
tpl,
|