rosetack 0.1.0 → 0.1.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.
Files changed (49) hide show
  1. package/dist-cli/compiler.mjs +2302 -0
  2. package/dist-cli/edge.mjs +297 -0
  3. package/dist-cli/rosetack.mjs +3411 -0
  4. package/dist-cli/runtime.mjs +619 -0
  5. package/dist-cli/test.mjs +2696 -0
  6. package/pack.mjs +49 -0
  7. package/package.json +25 -7
  8. package/src/FRAMEWORK_VERSION +1 -1
  9. package/src/cli/edge.ts +58 -23
  10. package/src/cli/index.ts +521 -65
  11. package/src/cli/shell.ts +75 -22
  12. package/src/cli/test.ts +400 -0
  13. package/src/compiler/index.ts +1277 -191
  14. package/src/runtime/index.ts +356 -65
  15. package/src/types/rosetack.d.ts +142 -0
  16. package/.github/workflows/ci.yml +0 -72
  17. package/.github/workflows/release.yml +0 -122
  18. package/benchmark.ts +0 -227
  19. package/example/public/favicon.ico +0 -0
  20. package/example/public/logo.svg +0 -148
  21. package/example/public/rose-mark-black.png +0 -0
  22. package/example/public/rose-mark.png +0 -0
  23. package/example/public/rose-mono.png +0 -0
  24. package/example/rosetack.config.js +0 -10
  25. package/example/src/locales/en.json +0 -8
  26. package/example/src/locales/zh.json +0 -8
  27. package/example/src/pages/404.rose +0 -15
  28. package/example/src/pages/500.rose +0 -10
  29. package/example/src/pages/[lang]/about.rose +0 -40
  30. package/example/src/pages/_layout.rose +0 -33
  31. package/example/src/pages/_middleware.rose +0 -37
  32. package/example/src/pages/about.rose +0 -67
  33. package/example/src/pages/admin.rose +0 -27
  34. package/example/src/pages/api/hello.rose +0 -19
  35. package/example/src/pages/api/login.rose +0 -55
  36. package/example/src/pages/api/posts.rose +0 -80
  37. package/example/src/pages/api/secret.rose +0 -14
  38. package/example/src/pages/blog/[id].rose +0 -25
  39. package/example/src/pages/broken.rose +0 -16
  40. package/example/src/pages/fresh.rose +0 -22
  41. package/example/src/pages/garden.rose +0 -27
  42. package/example/src/pages/index.rose +0 -84
  43. package/example/src/pages/sign.rose +0 -45
  44. package/example/src/pages/thorn.rose +0 -23
  45. package/example/src/pages/vault.rose +0 -14
  46. package/go.mod +0 -3
  47. package/main.go +0 -470
  48. package/tools/release-notes.mjs +0 -113
  49. package/tsconfig.json +0 -17
@@ -0,0 +1,619 @@
1
+ // src/runtime/index.ts
2
+ var currentEffect = null;
3
+ var signalMap = globalThis.__rosetack_signalMap ?? /* @__PURE__ */ new Map();
4
+ globalThis.__rosetack_signalMap = signalMap;
5
+ function entry(key, initial) {
6
+ const e = signalMap.get(key) ?? { value: initial, subs: /* @__PURE__ */ new Set() };
7
+ signalMap.set(key, e);
8
+ return e;
9
+ }
10
+ function state(key, initial) {
11
+ const e = entry(key, initial);
12
+ const getter = () => {
13
+ if (currentEffect) e.subs.add(currentEffect);
14
+ return e.value;
15
+ };
16
+ const setter = (v) => {
17
+ e.value = v;
18
+ e.subs.forEach((fn) => fn());
19
+ };
20
+ return [getter, setter];
21
+ }
22
+ function hasState(key) {
23
+ return signalMap.has(key);
24
+ }
25
+ function setState(key, value) {
26
+ const e = entry(key, value);
27
+ e.value = value;
28
+ e.subs.forEach((fn) => fn());
29
+ }
30
+ var cleanups = /* @__PURE__ */ new Set();
31
+ function effect(fn) {
32
+ const wrapped = () => {
33
+ try {
34
+ fn();
35
+ } catch {
36
+ }
37
+ };
38
+ const prev = currentEffect;
39
+ currentEffect = wrapped;
40
+ fn();
41
+ currentEffect = prev;
42
+ const cleanup = () => {
43
+ signalMap.forEach((e) => e.subs.delete(wrapped));
44
+ cleanups.delete(cleanup);
45
+ };
46
+ cleanups.add(cleanup);
47
+ return cleanup;
48
+ }
49
+ var ESC_MAP = {
50
+ "&": "&",
51
+ "<": "&lt;",
52
+ ">": "&gt;",
53
+ '"': "&quot;",
54
+ "'": "&#39;"
55
+ };
56
+ function esc(v) {
57
+ return String(v).replace(/[&<>"']/g, (c) => ESC_MAP[c]);
58
+ }
59
+ function textMark(closes, fn, pair, arg) {
60
+ const i = closes.push(fn) - 1;
61
+ return `<!--\u27E6m:${i}\u27E7-->` + esc(closes[i](arg)) + (pair ? `<!--\u27E6/m:${i}\u27E7-->` : "");
62
+ }
63
+ function attrMark(closes, fn, name, arg) {
64
+ const i = closes.push(fn) - 1;
65
+ return `${name}="${esc(closes[i](arg))}" data-b="${i}:${name}"`;
66
+ }
67
+ function ifMark(closes, cond, fn, scope) {
68
+ const i = closes.length;
69
+ let snap = null;
70
+ closes.push(() => {
71
+ if (!cond()) return null;
72
+ if (!snap) {
73
+ const c = [];
74
+ snap = { html: String(fn(scope, c)), closes: c };
75
+ }
76
+ return snap;
77
+ });
78
+ const r = closes[i]();
79
+ return `<!--\u27E6i:${i}\u27E7-->` + (r ? r.html : "") + `<!--\u27E6/i:${i}\u27E7-->`;
80
+ }
81
+ function eachMark(closes, items, fn) {
82
+ const i = closes.length;
83
+ closes.push(() => items().map((v) => {
84
+ const c = [];
85
+ return { html: String(fn(v, c)), closes: c, scope: v };
86
+ }));
87
+ let h = `<!--\u27E6l:${i}\u27E7-->`;
88
+ for (const r of closes[i]()) h += r.html;
89
+ return h + `<!--\u27E6/l:${i}\u27E7-->`;
90
+ }
91
+ function headMark(closes, fn) {
92
+ const i = closes.push(fn) - 1;
93
+ return `<!--\u27E6h:${i}\u27E7-->` + fn() + `<!--\u27E6/h:${i}\u27E7-->`;
94
+ }
95
+ var MARK_RE = /^\u27e6([milh]):(\d+)\u27e7$/;
96
+ var END_RE = /^\u27e6\/([milh]):(\d+)\u27e7$/;
97
+ var wired = /* @__PURE__ */ new WeakSet();
98
+ function tpl(html) {
99
+ const t = document.createElement("template");
100
+ t.innerHTML = html;
101
+ return t.content;
102
+ }
103
+ var HEAD_ATTR = "data-rosetack-head";
104
+ var handlers = globalThis.__rosetack_handlers ??= {};
105
+ function applyHead(html) {
106
+ const seen = /* @__PURE__ */ new Set();
107
+ const frag = tpl(html);
108
+ const title = frag.querySelector("title");
109
+ if (title) {
110
+ let cur = document.head.querySelector("title");
111
+ if (!cur) {
112
+ cur = document.createElement("title");
113
+ document.head.appendChild(cur);
114
+ }
115
+ cur.textContent = title.textContent ?? "";
116
+ }
117
+ for (const el of Array.from(document.head.querySelectorAll(`[${HEAD_ATTR}]`))) el.remove();
118
+ for (const el of Array.from(frag.children)) {
119
+ if (el.tagName === "TITLE") continue;
120
+ const key = el.getAttribute("name") ?? el.getAttribute("property") ?? el.getAttribute("rel") ?? el.getAttribute("charset");
121
+ if (!key) continue;
122
+ const managed = `${el.tagName.toLowerCase()}:${key}`;
123
+ if (seen.has(managed)) continue;
124
+ seen.add(managed);
125
+ el.setAttribute(HEAD_ATTR, managed);
126
+ document.head.appendChild(el);
127
+ }
128
+ }
129
+ function clearHead() {
130
+ document.head.querySelectorAll(`[${HEAD_ATTR}]`).forEach((el) => el.remove());
131
+ }
132
+ function wire(root, closes, scope) {
133
+ let holder = root;
134
+ if (root.nodeType === 11) {
135
+ const div = document.createElement("div");
136
+ div.appendChild(root);
137
+ holder = div;
138
+ }
139
+ const created = [];
140
+ const weff = (fn) => created.push(effect(fn));
141
+ const comments = [];
142
+ const walker = document.createTreeWalker(holder, NodeFilter.SHOW_COMMENT);
143
+ while (walker.nextNode()) comments.push(walker.currentNode);
144
+ const nested = /* @__PURE__ */ new Set();
145
+ for (let i = 0; i < comments.length; i++) {
146
+ const m = (comments[i].nodeValue ?? "").match(MARK_RE);
147
+ if (!m || m[1] !== "i" && m[1] !== "l") continue;
148
+ for (let j = i + 1; j < comments.length; j++) {
149
+ const em = (comments[j].nodeValue ?? "").match(END_RE);
150
+ if (em && em[1] === m[1] && +em[2] === +m[2]) {
151
+ for (let k = i + 1; k < j; k++) nested.add(comments[k]);
152
+ break;
153
+ }
154
+ }
155
+ }
156
+ const ends = /* @__PURE__ */ new Map();
157
+ for (const c of comments) {
158
+ if (nested.has(c)) continue;
159
+ const m = (c.nodeValue ?? "").match(END_RE);
160
+ if (m) ends.set(+m[2], c);
161
+ }
162
+ const headBlocks = [];
163
+ for (const c of comments) {
164
+ if (nested.has(c) || wired.has(c) || !c.parentNode) continue;
165
+ wired.add(c);
166
+ const m = (c.nodeValue ?? "").match(MARK_RE);
167
+ if (!m) continue;
168
+ const kind = m[1];
169
+ const idx = +m[2];
170
+ if (kind === "h") {
171
+ const end = ends.get(idx);
172
+ if (!end) continue;
173
+ const nodes = [];
174
+ let n = c.nextSibling;
175
+ while (n && n !== end) {
176
+ const nx = n.nextSibling;
177
+ nodes.push(n);
178
+ n = nx;
179
+ }
180
+ headBlocks.push({ idx, start: c, end, nodes });
181
+ } else if (kind === "m") {
182
+ let target = c.nextSibling;
183
+ if (!target || target.nodeType !== 3) {
184
+ target = document.createTextNode("");
185
+ c.parentNode.insertBefore(target, c.nextSibling);
186
+ }
187
+ const tn = target;
188
+ const end = ends.get(idx);
189
+ if (end) {
190
+ let n = tn.nextSibling;
191
+ while (n && n !== end) {
192
+ const nx = n.nextSibling;
193
+ n.remove();
194
+ n = nx;
195
+ }
196
+ }
197
+ weff(() => {
198
+ tn.nodeValue = String(closes[idx](scope));
199
+ });
200
+ } else if (kind === "i") {
201
+ const anchor = c;
202
+ const end = ends.get(idx);
203
+ if (!end) continue;
204
+ const st = anchor;
205
+ weff(() => {
206
+ if (st.__st) {
207
+ st.__st.nodes.forEach((n) => n.remove());
208
+ st.__st.disp();
209
+ st.__st = void 0;
210
+ }
211
+ const r = closes[idx](scope);
212
+ if (!r) return;
213
+ let frag;
214
+ if (st.__ever) {
215
+ frag = tpl(r.html);
216
+ } else {
217
+ st.__ever = true;
218
+ frag = document.createDocumentFragment();
219
+ let n = anchor.nextSibling;
220
+ while (n && n !== end) {
221
+ const nx = n.nextSibling;
222
+ frag.appendChild(n);
223
+ n = nx;
224
+ }
225
+ }
226
+ const disp = wire(frag, r.closes, r.scope ?? scope);
227
+ const nodes = Array.from(frag.childNodes);
228
+ const parent = anchor.parentNode;
229
+ for (const nd of nodes) parent.insertBefore(nd, anchor.nextSibling);
230
+ st.__st = { nodes, disp };
231
+ });
232
+ } else {
233
+ const start = c;
234
+ const end = ends.get(idx);
235
+ if (!end) continue;
236
+ const st = start;
237
+ weff(() => {
238
+ if (st.__disp) {
239
+ st.__disp();
240
+ st.__disp = void 0;
241
+ }
242
+ const items = closes[idx](scope);
243
+ let n = start.nextSibling;
244
+ while (n && n !== end) {
245
+ const nx = n.nextSibling;
246
+ n.remove();
247
+ n = nx;
248
+ }
249
+ const parent = start.parentNode;
250
+ const disps = [];
251
+ for (const r of items) {
252
+ const frag = tpl(r.html);
253
+ disps.push(wire(frag, r.closes, r.scope));
254
+ for (const nd of Array.from(frag.childNodes)) parent.insertBefore(nd, end);
255
+ }
256
+ st.__disp = () => disps.forEach((d) => d());
257
+ });
258
+ }
259
+ }
260
+ if (headBlocks.length > 0) {
261
+ const blocks = headBlocks;
262
+ weff(() => {
263
+ let html = "";
264
+ for (const b of blocks) html += String(closes[b.idx](scope));
265
+ applyHead(html);
266
+ });
267
+ for (const b of blocks) {
268
+ b.nodes.forEach((nd) => nd.remove());
269
+ b.start.remove();
270
+ b.end.remove();
271
+ }
272
+ } else if (root.nodeType !== 11) clearHead();
273
+ const els = holder.querySelectorAll("[data-b]");
274
+ els.forEach((el) => {
275
+ const spec = el.getAttribute("data-b");
276
+ const sep = spec.indexOf(":");
277
+ const idx = +spec.slice(0, sep);
278
+ const attr = spec.slice(sep + 1);
279
+ el.removeAttribute("data-b");
280
+ weff(() => {
281
+ el.setAttribute(attr, String(closes[idx](scope)));
282
+ });
283
+ });
284
+ if (holder !== root) {
285
+ while (holder.firstChild) root.appendChild(holder.firstChild);
286
+ }
287
+ return () => created.forEach((fn) => fn());
288
+ }
289
+ function resetEffects() {
290
+ cleanups.forEach((fn) => fn());
291
+ cleanups.clear();
292
+ }
293
+ var dataCache = /* @__PURE__ */ new Map();
294
+ function $data(fn) {
295
+ const key = fn.toString();
296
+ let p = dataCache.get(key);
297
+ if (!p) {
298
+ p = Promise.resolve(fn());
299
+ dataCache.set(key, p);
300
+ }
301
+ return p;
302
+ }
303
+ function clearRequestState() {
304
+ signalMap.clear();
305
+ dataCache.clear();
306
+ pendingDeltas.clear();
307
+ }
308
+ var requestContext = {};
309
+ function getContext() {
310
+ return requestContext;
311
+ }
312
+ function resetRequestContext() {
313
+ requestContext = {};
314
+ }
315
+ async function isolateStateAsync(fn) {
316
+ const savedSignals = signalMap;
317
+ const savedData = dataCache;
318
+ const savedDeltas = new Map(pendingDeltas);
319
+ pendingDeltas.clear();
320
+ const savedMounts = mountQueue.splice(0, mountQueue.length);
321
+ const savedCleanups = new Set(cleanups);
322
+ cleanups.clear();
323
+ signalMap = /* @__PURE__ */ new Map();
324
+ dataCache = /* @__PURE__ */ new Map();
325
+ try {
326
+ const result = await fn();
327
+ return {
328
+ result,
329
+ state: signalMap,
330
+ mounts: mountQueue.splice(0, mountQueue.length),
331
+ cleanups: new Set(cleanups)
332
+ };
333
+ } finally {
334
+ signalMap = savedSignals;
335
+ dataCache = savedData;
336
+ pendingDeltas.clear();
337
+ savedDeltas.forEach((d, k) => pendingDeltas.set(k, d));
338
+ mountQueue.splice(0, 0, ...savedMounts);
339
+ cleanups.clear();
340
+ savedCleanups.forEach((fn2) => cleanups.add(fn2));
341
+ }
342
+ }
343
+ function restoreState(entries) {
344
+ signalMap.clear();
345
+ entries.forEach((e, k) => signalMap.set(k, e));
346
+ }
347
+ function serializeState() {
348
+ const obj = {};
349
+ signalMap.forEach((v, k) => obj[k] = v.value);
350
+ return JSON.stringify(obj);
351
+ }
352
+ function resumeState(json) {
353
+ try {
354
+ const obj = JSON.parse(json);
355
+ Object.entries(obj).forEach(([k, v]) => {
356
+ entry(k, v).value = v;
357
+ });
358
+ } catch {
359
+ }
360
+ }
361
+ var refreshHook = null;
362
+ function setRefreshHook(fn) {
363
+ refreshHook = fn;
364
+ }
365
+ function refresh() {
366
+ return refreshHook ? refreshHook() : Promise.resolve();
367
+ }
368
+ var mountQueue = [];
369
+ function onMount(fn) {
370
+ if (typeof document === "undefined") return;
371
+ mountQueue.push(fn);
372
+ }
373
+ function clearMounts() {
374
+ mountQueue.length = 0;
375
+ }
376
+ function flushMounts() {
377
+ const q = mountQueue.splice(0, mountQueue.length);
378
+ for (const fn of q) fn();
379
+ }
380
+ function onCleanup(fn) {
381
+ cleanups.add(fn);
382
+ }
383
+ function adoptCleanups(fns) {
384
+ for (const fn of fns) cleanups.add(fn);
385
+ }
386
+ var LOCALES = {};
387
+ var DEFAULT_LOCALE = "en";
388
+ var LOCALE_PACKS = [];
389
+ function setLocales(dicts, def) {
390
+ LOCALES = dicts;
391
+ DEFAULT_LOCALE = def;
392
+ }
393
+ function setLocalePacks(langs) {
394
+ LOCALE_PACKS = langs;
395
+ }
396
+ function loadLocale(lang, dict) {
397
+ LOCALES[lang] = { ...LOCALES[lang], ...dict };
398
+ }
399
+ async function ensureLocale(lang) {
400
+ if (LOCALES[lang] || !LOCALE_PACKS.includes(lang)) return;
401
+ try {
402
+ const res = await fetch(`/locales/${encodeURIComponent(lang)}.json`);
403
+ if (res.ok) loadLocale(lang, await res.json());
404
+ } catch {
405
+ }
406
+ }
407
+ function localeList() {
408
+ return Object.keys(LOCALES);
409
+ }
410
+ function isLocale(lang) {
411
+ return Object.hasOwn(LOCALES, lang) || LOCALE_PACKS.includes(lang);
412
+ }
413
+ function bestLocale(header) {
414
+ for (const part of (header || "").split(",")) {
415
+ const tag = part.split(";")[0].trim().toLowerCase();
416
+ if (!tag || tag === "*") continue;
417
+ if (isLocale(tag)) return tag;
418
+ const base = tag.split("-")[0];
419
+ if (isLocale(base)) return base;
420
+ }
421
+ return null;
422
+ }
423
+ var RTL_RE = /^(ar|fa|he|ur|ps|sd|ug|yi|ckb|dv|ks|prs|haz|mzn|nqo)/;
424
+ function localeDir(lang) {
425
+ return RTL_RE.test(lang) ? "rtl" : "";
426
+ }
427
+ var ICU_RE = /\{([\w$]+),\s*(plural|selectordinal|select),\s*((?:\s*[=\w]+\s*\{(?:[^{}]|\{[^{}]*\})*\})*)\}/g;
428
+ var BRANCH_RE = /([=\w]+)\s*\{((?:[^{}]|\{[^{}]*\})*)\}/g;
429
+ function pluralCategory(locale, ordinal, n) {
430
+ try {
431
+ return new Intl.PluralRules(locale, ordinal ? { type: "ordinal" } : void 0).select(n);
432
+ } catch {
433
+ return null;
434
+ }
435
+ }
436
+ function expandIcu(msg, vars, locale) {
437
+ return msg.replace(ICU_RE, (whole, arg, kind, branchText) => {
438
+ const branches = {};
439
+ for (const m of branchText.matchAll(BRANCH_RE)) branches[m[1]] = m[2];
440
+ if (!branches.other) return whole;
441
+ const v = vars?.[arg];
442
+ if (kind === "select") return branches[typeof v === "string" && branches[v] ? v : "other"];
443
+ const num = typeof v === "number" ? v : Number(v);
444
+ const cat = isFinite(num) ? branches["=" + num] ? "=" + num : pluralCategory(locale, kind === "selectordinal", num) ?? "other" : "other";
445
+ return (branches[cat] ?? branches.other).replace(/#/g, String(v));
446
+ });
447
+ }
448
+ function $t(key, vars) {
449
+ const [lang] = state("lang", DEFAULT_LOCALE);
450
+ const dict = LOCALES[lang()] ?? LOCALES[DEFAULT_LOCALE] ?? {};
451
+ const msg = dict[key];
452
+ let out = expandIcu(typeof msg === "string" ? msg : key, vars, lang());
453
+ if (vars) for (const k in vars) out = out.split(`{${k}}`).join(String(vars[k]));
454
+ return out;
455
+ }
456
+ var STORES = /* @__PURE__ */ new Map();
457
+ var storeTransport = null;
458
+ function setStoreTransport(fn) {
459
+ storeTransport = fn;
460
+ }
461
+ function applyStorePatch(name, value) {
462
+ const entry2 = STORES.get(name);
463
+ if (entry2) entry2.value = value;
464
+ }
465
+ function $store(name, initial) {
466
+ let entry2 = STORES.get(name);
467
+ if (!entry2) {
468
+ entry2 = { value: initial };
469
+ STORES.set(name, entry2);
470
+ }
471
+ const box = entry2;
472
+ return {
473
+ get: () => box.value,
474
+ set: (v) => {
475
+ box.value = v;
476
+ storeTransport?.(name, v);
477
+ },
478
+ update: (fn) => {
479
+ box.value = fn(box.value);
480
+ storeTransport?.(name, box.value);
481
+ }
482
+ };
483
+ }
484
+ var ActionError = class extends Error {
485
+ /** the HTTP status the response carries (400/401/403/409/422/...) */
486
+ code;
487
+ /** the form field the failure belongs to, when it belongs to one */
488
+ field;
489
+ constructor(message, code = 400, field) {
490
+ super(message);
491
+ this.name = "ActionError";
492
+ this.code = code;
493
+ this.field = field;
494
+ }
495
+ };
496
+ function $actionError() {
497
+ const e = signalMap.get("actionError");
498
+ if (!e) return null;
499
+ if (currentEffect) e.subs.add(currentEffect);
500
+ return e.value ?? null;
501
+ }
502
+ function $actionErrorOrThrow() {
503
+ const info = $actionError();
504
+ if (info) throw new ActionError(info.message, info.code, info.field);
505
+ }
506
+ function $boundaryFallback(err) {
507
+ if (err instanceof ActionError) return `<p class="rosetack-action-error">${esc(err.message)}</p>`;
508
+ return "<p>This section failed to render.</p>";
509
+ }
510
+ var StateDelta = class {
511
+ constructor(op, value) {
512
+ this.op = op;
513
+ this.value = value;
514
+ }
515
+ };
516
+ var $append = (value) => new StateDelta("append", value);
517
+ var $prepend = (value) => new StateDelta("prepend", value);
518
+ var $merge = (value) => new StateDelta("merge", value);
519
+ var pendingDeltas = /* @__PURE__ */ new Map();
520
+ function setStateDelta(key, delta) {
521
+ pendingDeltas.set(key, delta);
522
+ }
523
+ function applyStateDeltas() {
524
+ if (pendingDeltas.size === 0) return;
525
+ for (const [key, delta] of [...pendingDeltas]) {
526
+ pendingDeltas.delete(key);
527
+ applyStateDelta(key, delta);
528
+ }
529
+ }
530
+ function applyStateDelta(key, delta) {
531
+ const cur = signalMap.get(key)?.value;
532
+ if (delta.op === "merge") {
533
+ setState(key, { ...cur, ...delta.value });
534
+ return;
535
+ }
536
+ const list = (v) => v == null ? [] : Array.isArray(v) ? v : [v];
537
+ const merged = delta.op === "append" ? [...list(cur), ...list(delta.value)] : [...list(delta.value), ...list(cur)];
538
+ setState(key, merged);
539
+ }
540
+ function $cookies(request) {
541
+ const raw = request ? request.headers.get("cookie") : typeof document !== "undefined" ? document.cookie : "";
542
+ const out = {};
543
+ for (const part of (raw || "").split(";")) {
544
+ const eq = part.indexOf("=");
545
+ if (eq < 0) continue;
546
+ const k = part.slice(0, eq).trim();
547
+ if (k) out[k] = decodeURIComponent(part.slice(eq + 1).trim());
548
+ }
549
+ return out;
550
+ }
551
+ function $sessionCookie(name, value, opts = {}) {
552
+ const { path = "/", maxAge = 60 * 60 * 24 * 7, sameSite = "Lax", secure = false, httpOnly = true } = opts;
553
+ return [
554
+ `${name}=${encodeURIComponent(value)}`,
555
+ `Path=${path}`,
556
+ `Max-Age=${maxAge}`,
557
+ `SameSite=${sameSite}`,
558
+ httpOnly ? "HttpOnly" : "",
559
+ secure || sameSite === "None" ? "Secure" : ""
560
+ ].filter(Boolean).join("; ");
561
+ }
562
+ export {
563
+ $actionError,
564
+ $actionErrorOrThrow,
565
+ $append,
566
+ $boundaryFallback,
567
+ $cookies,
568
+ $data,
569
+ $merge,
570
+ $prepend,
571
+ $sessionCookie,
572
+ $store,
573
+ $t,
574
+ ActionError,
575
+ StateDelta,
576
+ adoptCleanups,
577
+ applyHead,
578
+ applyStateDelta,
579
+ applyStateDeltas,
580
+ applyStorePatch,
581
+ attrMark,
582
+ bestLocale,
583
+ clearHead,
584
+ clearMounts,
585
+ clearRequestState,
586
+ eachMark,
587
+ effect,
588
+ ensureLocale,
589
+ esc,
590
+ flushMounts,
591
+ getContext,
592
+ handlers,
593
+ hasState,
594
+ headMark,
595
+ ifMark,
596
+ isLocale,
597
+ isolateStateAsync,
598
+ loadLocale,
599
+ localeDir,
600
+ localeList,
601
+ onCleanup,
602
+ onMount,
603
+ refresh,
604
+ resetEffects,
605
+ resetRequestContext,
606
+ restoreState,
607
+ resumeState,
608
+ serializeState,
609
+ setLocalePacks,
610
+ setLocales,
611
+ setRefreshHook,
612
+ setState,
613
+ setStateDelta,
614
+ setStoreTransport,
615
+ state,
616
+ textMark,
617
+ tpl,
618
+ wire
619
+ };