aktion-runtime 0.5.11 → 0.5.13

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/language.js CHANGED
@@ -707,11 +707,11 @@ function parseEffectDep(ctx, triggers, setRateLimit) {
707
707
  ctx.consume();
708
708
  let name = head.value;
709
709
  while (ctx.peek().type === "Punctuation" && ctx.peek().value === ".") {
710
- const prop = ctx.peek(1);
711
- if (prop.type !== "Identifier" && prop.type !== "Keyword") break;
710
+ const prop2 = ctx.peek(1);
711
+ if (prop2.type !== "Identifier" && prop2.type !== "Keyword") break;
712
712
  ctx.consume();
713
713
  ctx.consume();
714
- name += "." + prop.value;
714
+ name += "." + prop2.value;
715
715
  }
716
716
  triggers.push({ kind: "state", name });
717
717
  return;
@@ -2147,9 +2147,9 @@ function parseObjectProps(ctx) {
2147
2147
  ctx.expect("Punctuation", ":");
2148
2148
  value = parseExpression(ctx);
2149
2149
  }
2150
- const prop = { key, value };
2151
- if (computedKey) prop.computedKey = computedKey;
2152
- props.push(prop);
2150
+ const prop2 = { key, value };
2151
+ if (computedKey) prop2.computedKey = computedKey;
2152
+ props.push(prop2);
2153
2153
  skipWhitespace(ctx);
2154
2154
  if (ctx.peek().type === "Punctuation" && ctx.peek().value === ",") {
2155
2155
  ctx.consume();
@@ -2495,8 +2495,8 @@ function assertOnePositionalMax(specs) {
2495
2495
  }
2496
2496
  }
2497
2497
  }
2498
- function propExpectsObject(prop) {
2499
- return /\bobject\b|\bRecord\b|\{|\bany\b/i.test(prop.type);
2498
+ function propExpectsObject(prop2) {
2499
+ return /\bobject\b|\bRecord\b|\{|\bany\b/i.test(prop2.type);
2500
2500
  }
2501
2501
  function knownPropNames(spec) {
2502
2502
  const names = /* @__PURE__ */ new Set();
@@ -2566,8 +2566,8 @@ function callArgShapes(args) {
2566
2566
  }
2567
2567
  function mapPositionalArgs(spec, args) {
2568
2568
  const out = {};
2569
- spec.props.forEach((prop, index) => {
2570
- if (index < args.length) out[prop.name] = args[index];
2569
+ spec.props.forEach((prop2, index) => {
2570
+ if (index < args.length) out[prop2.name] = args[index];
2571
2571
  });
2572
2572
  return out;
2573
2573
  }
@@ -2703,7 +2703,7 @@ function walkExpression(expr, library, out) {
2703
2703
  for (const e of expr.elements) walkExpression(e, library, out);
2704
2704
  return;
2705
2705
  case "Object":
2706
- for (const prop of expr.properties) walkExpression(prop.value, library, out);
2706
+ for (const prop2 of expr.properties) walkExpression(prop2.value, library, out);
2707
2707
  return;
2708
2708
  case "Template":
2709
2709
  for (const e of expr.expressions) walkExpression(e, library, out);
@@ -2800,21 +2800,21 @@ function validateCall(expr, library, out) {
2800
2800
  });
2801
2801
  }
2802
2802
  positionalArgs.forEach((arg, n) => {
2803
- const prop = slotForNthPositional(spec, n);
2804
- if (!prop) return;
2805
- if (prop.enum && arg.kind === "Literal" && typeof arg.value === "string") {
2803
+ const prop2 = slotForNthPositional(spec, n);
2804
+ if (!prop2) return;
2805
+ if (prop2.enum && arg.kind === "Literal" && typeof arg.value === "string") {
2806
2806
  const value = arg.value;
2807
- if (!prop.enum.includes(value) && !prop.enum.includes(canonicalSizeToken(value))) {
2807
+ if (!prop2.enum.includes(value) && !prop2.enum.includes(canonicalSizeToken(value))) {
2808
2808
  out.push({
2809
- message: `<${expr.callee}> ${prop.name}="${value}" — must be one of ${prop.enum.map((v) => `"${v}"`).join(", ")}.`,
2809
+ message: `<${expr.callee}> ${prop2.name}="${value}" — must be one of ${prop2.enum.map((v) => `"${v}"`).join(", ")}.`,
2810
2810
  line: arg.loc?.line ?? expr.loc?.line ?? 0,
2811
2811
  column: arg.loc?.column ?? expr.loc?.column ?? 0
2812
2812
  });
2813
2813
  }
2814
2814
  }
2815
- if (arg.kind === "Object" && !propExpectsObject(prop)) {
2815
+ if (arg.kind === "Object" && !propExpectsObject(prop2)) {
2816
2816
  out.push({
2817
- message: `<${expr.callee}> — object passed positionally for "${prop.name}" (${prop.type}). Use named props from: ${spec.props.map((p) => p.name).join(", ")}.`,
2817
+ message: `<${expr.callee}> — object passed positionally for "${prop2.name}" (${prop2.type}). Use named props from: ${spec.props.map((p) => p.name).join(", ")}.`,
2818
2818
  line: arg.loc?.line ?? expr.loc?.line ?? 0,
2819
2819
  column: arg.loc?.column ?? expr.loc?.column ?? 0
2820
2820
  });
@@ -2822,12 +2822,12 @@ function validateCall(expr, library, out) {
2822
2822
  });
2823
2823
  const namedEntries = [];
2824
2824
  if (trailingObj) {
2825
- for (const prop of trailingObj.properties) {
2826
- if (prop.spread) continue;
2825
+ for (const prop2 of trailingObj.properties) {
2826
+ if (prop2.spread) continue;
2827
2827
  namedEntries.push({
2828
- name: prop.key,
2829
- value: prop.value,
2830
- loc: prop.value.loc ?? trailingObj.loc
2828
+ name: prop2.key,
2829
+ value: prop2.value,
2830
+ loc: prop2.value.loc ?? trailingObj.loc
2831
2831
  });
2832
2832
  }
2833
2833
  }
@@ -2841,14 +2841,14 @@ function validateCall(expr, library, out) {
2841
2841
  });
2842
2842
  continue;
2843
2843
  }
2844
- const prop = spec.props.find(
2844
+ const prop2 = spec.props.find(
2845
2845
  (p) => p.name === entry.name || (p.aliases?.includes(entry.name) ?? false)
2846
2846
  );
2847
- if (prop?.enum && entry.value.kind === "Literal" && typeof entry.value.value === "string") {
2847
+ if (prop2?.enum && entry.value.kind === "Literal" && typeof entry.value.value === "string") {
2848
2848
  const value = entry.value.value;
2849
- if (!prop.enum.includes(value) && !prop.enum.includes(canonicalSizeToken(value))) {
2849
+ if (!prop2.enum.includes(value) && !prop2.enum.includes(canonicalSizeToken(value))) {
2850
2850
  out.push({
2851
- message: `<${expr.callee}> ${entry.name}="${value}" — must be one of ${prop.enum.map((v) => `"${v}"`).join(", ")}.`,
2851
+ message: `<${expr.callee}> ${entry.name}="${value}" — must be one of ${prop2.enum.map((v) => `"${v}"`).join(", ")}.`,
2852
2852
  line: entry.loc?.line ?? expr.loc?.line ?? 0,
2853
2853
  column: entry.loc?.column ?? expr.loc?.column ?? 0
2854
2854
  });
@@ -2861,12 +2861,12 @@ const THEME_METADATA_KEYS = /* @__PURE__ */ new Set(["name", "direction"]);
2861
2861
  function validateThemeCall(expr, out) {
2862
2862
  const arg = expr.arguments[0];
2863
2863
  if (!arg || arg.kind !== "Object") return;
2864
- for (const prop of arg.properties) {
2865
- if (prop.spread) continue;
2866
- if (STRUCTURED_THEME_GROUPS.has(prop.key)) continue;
2867
- if (THEME_METADATA_KEYS.has(prop.key)) continue;
2868
- const suggestion = suggestStructuredKey(prop.key);
2869
- const message = prop.key.startsWith("--") ? `$theme({"${prop.key}": ...}) — free-form CSS variable keys are removed in Aktion 0.5. Use the structured form: $theme({ colors: {...}, radius: {...}, font: {...} }).` : `$theme({${prop.key}: ...}) — legacy flat-shape token is removed in Aktion 0.5. Use ${suggestion}.`;
2864
+ for (const prop2 of arg.properties) {
2865
+ if (prop2.spread) continue;
2866
+ if (STRUCTURED_THEME_GROUPS.has(prop2.key)) continue;
2867
+ if (THEME_METADATA_KEYS.has(prop2.key)) continue;
2868
+ const suggestion = suggestStructuredKey(prop2.key);
2869
+ const message = prop2.key.startsWith("--") ? `$theme({"${prop2.key}": ...}) — free-form CSS variable keys are removed in Aktion 0.5. Use the structured form: $theme({ colors: {...}, radius: {...}, font: {...} }).` : `$theme({${prop2.key}: ...}) — legacy flat-shape token is removed in Aktion 0.5. Use ${suggestion}.`;
2870
2870
  out.push({
2871
2871
  message,
2872
2872
  line: expr.loc?.line ?? 0,
@@ -3382,6 +3382,20 @@ const builtinCatalog = [
3382
3382
  signature: "$sse({ url, event })",
3383
3383
  summary: 'Reactive Server-Sent Events stream — { status, connected, last, messages, close }. EventSource reconnects natively (status reads "connecting" while it does).'
3384
3384
  },
3385
+ {
3386
+ name: "script",
3387
+ sigil: "$script",
3388
+ category: "data",
3389
+ signature: "$script({ src, global? })",
3390
+ summary: "Load an external UMD/ESM script or stylesheet once → reactive { ready, loading, error, value }. `global` reads window[global] into `value` (e.g. window.Stripe). De-duplicated per src across the app; gate a third-party widget on `.ready`."
3391
+ },
3392
+ {
3393
+ name: "head",
3394
+ sigil: "$head",
3395
+ category: "app",
3396
+ signature: "$head({ title, meta, og, twitter, link, jsonLd })",
3397
+ summary: "Reactive document head: title, meta description, canonical/alternate links, Open Graph + Twitter cards, JSON-LD, <html> attrs. Per-route calls compose; renderToString emits the resolved <head> so SSR pages are crawlable."
3398
+ },
3385
3399
  // App / routing / theming / events.
3386
3400
  {
3387
3401
  name: "app",
@@ -3444,6 +3458,14 @@ const builtinCatalog = [
3444
3458
  summary: "Imperative toasts: $toast.show/.success/.error/.dismiss; reactive .items.",
3445
3459
  namespace: true
3446
3460
  },
3461
+ {
3462
+ name: "dom",
3463
+ sigil: "$dom",
3464
+ category: "namespace",
3465
+ signature: "$dom",
3466
+ summary: "Managed DOM-observer namespace: $dom.onResize(node, cb) / .onIntersect(node, cb, opts?) / .onMutation(node, cb, opts?) (auto-disposed on replan) and .measure(node) → { rect, scroll, viewport }. Pair with Mount/OnMount node refs.",
3467
+ namespace: true
3468
+ },
3447
3469
  {
3448
3470
  name: "i18n",
3449
3471
  sigil: "$i18n",
@@ -3464,6 +3486,440 @@ function findBuiltin(bareName) {
3464
3486
  function isBuiltinName(bareName) {
3465
3487
  return builtinNames.has(bareName);
3466
3488
  }
3489
+ const method = (name, signature, summary) => ({
3490
+ name,
3491
+ kind: "method",
3492
+ signature,
3493
+ summary
3494
+ });
3495
+ const prop = (name, summary) => ({
3496
+ name,
3497
+ kind: "property",
3498
+ signature: name,
3499
+ summary
3500
+ });
3501
+ const utilMembers = [
3502
+ // Aggregation
3503
+ method("count", "count(items)", "Number of items in an array."),
3504
+ method("sum", "sum(items)", "Sum of the numeric values."),
3505
+ method("avg", "avg(items)", "Arithmetic mean of the values."),
3506
+ method("min", "min(items)", "Smallest numeric value."),
3507
+ method("max", "max(items)", "Largest numeric value."),
3508
+ method("first", "first(items)", "First element, or null when empty."),
3509
+ method("last", "last(items)", "Last element, or null when empty."),
3510
+ // Reshaping
3511
+ method("filter", "filter(items, field?, op?, value?)", "Keep items where field matches. Operators: == != > < >= <= contains startsWith endsWith."),
3512
+ method("find", "find(items, field?, op?, value?)", "First item matching the comparator, or null."),
3513
+ method("sort", "sort(items, field?, direction?)", 'Sort by field, "asc" (default) or "desc".'),
3514
+ method("groupBy", "groupBy(items, field?)", "Group items into an object keyed by the field value."),
3515
+ method("slice", "slice(items, start?, end?)", "Subarray between start and end indices."),
3516
+ method("unique", "unique(items, field?)", "De-duplicate an array (optionally by a field)."),
3517
+ method("reverse", "reverse(items)", "Reversed copy of the array."),
3518
+ method("range", "range(start, end, step?)", "Array of numbers from start to end (inclusive)."),
3519
+ method("repeat", "repeat(value, n)", "Array with the value repeated n times."),
3520
+ method("pick", "pick(obj, keys)", "Object containing only the listed keys."),
3521
+ method("omit", "omit(obj, keys)", "Object without the listed keys."),
3522
+ method("chunk", "chunk(items, size)", "Split an array into chunks of the given size."),
3523
+ method("flatten", "flatten(items, depth?)", "Flatten nested arrays to the given depth (default 1)."),
3524
+ method("zip", "zip(...arrays)", "Combine arrays element-wise into tuples."),
3525
+ method("partition", "partition(items, field?, op?, value?)", "Split into [pass, fail] by a comparator."),
3526
+ method("keyBy", "keyBy(items, field?)", "Index an array into an object keyed by a field."),
3527
+ method("cloneDeep", "cloneDeep(value)", "Deep-clone a value (arrays / objects / dates)."),
3528
+ method("merge", "merge(target, ...sources)", "Deep-merge source objects onto a clone of the target."),
3529
+ // Formatting
3530
+ method("format", "format(value, mode?, options?)", 'Locale number format: "number" | "currency" | "percent" | "compact".'),
3531
+ method("formatDate", "formatDate(value, format?)", 'Format a date — a token pattern (MMM D, YYYY-MM-DD) or "relative"/"date"/"time"/"datetime"/"iso".'),
3532
+ method("plural", "plural(count, singular, plural?)", "Count + correctly pluralised noun: `3 items` / `1 item`."),
3533
+ method("capitalize", "capitalize(text)", "Capitalise the first letter."),
3534
+ method("lowercase", "lowercase(text)", "Lowercase the whole string."),
3535
+ method("uppercase", "uppercase(text)", "Uppercase the whole string."),
3536
+ method("titlecase", "titlecase(text)", "Title-case each word."),
3537
+ method("case", "case(text, kind?)", 'Recase: "camel" | "pascal" | "snake" | "kebab".'),
3538
+ // Date / time
3539
+ method("now", "now()", "Current time as epoch milliseconds."),
3540
+ method("today", "today()", "Start of today as an ISO string."),
3541
+ method("addDays", "addDays(date, days)", "Date shifted by n days (ISO)."),
3542
+ method("addHours", "addHours(date, hours)", "Date shifted by n hours (ISO)."),
3543
+ method("diffDays", "diffDays(start, end)", "Whole days between two dates."),
3544
+ method("startOfWeek", "startOfWeek(date)", "Start of the week containing the date (ISO)."),
3545
+ method("endOfMonth", "endOfMonth(date)", "End of the month containing the date (ISO)."),
3546
+ // String / regex
3547
+ method("join", "join(items, sep?)", "Join an array into a string with a separator."),
3548
+ method("split", "split(text, sep?)", "Split a string into an array on a separator."),
3549
+ method("trim", "trim(text)", "Trim surrounding whitespace."),
3550
+ method("replace", "replace(text, search, replacement?)", "Replace every occurrence of a substring."),
3551
+ method("substring", "substring(text, start, end?)", "Substring between two indices."),
3552
+ method("startsWith", "startsWith(text, prefix)", "True when the text starts with the prefix."),
3553
+ method("endsWith", "endsWith(text, suffix)", "True when the text ends with the suffix."),
3554
+ method("contains", "contains(text, needle)", "True when the text contains the needle."),
3555
+ method("match", "match(text, pattern)", "Test the text against a regular-expression pattern."),
3556
+ // Math
3557
+ method("round", "round(value, decimals?)", "Round to n decimal places."),
3558
+ method("floor", "floor(value)", "Round down to an integer."),
3559
+ method("ceil", "ceil(value)", "Round up to an integer."),
3560
+ method("abs", "abs(value)", "Absolute value."),
3561
+ method("clamp", "clamp(value, min, max)", "Constrain a number to a [min, max] range."),
3562
+ method("pow", "pow(base, exp)", "Exponentiation (base^exp)."),
3563
+ method("sqrt", "sqrt(value)", "Square root."),
3564
+ method("random", "random()", "Pseudo-random number in [0, 1)."),
3565
+ method("log", "log(value)", "Natural logarithm."),
3566
+ // Formatting / misc convenience
3567
+ method("slugify", "slugify(text)", 'URL-safe slug: "Hello World" → "hello-world".'),
3568
+ method("truncate", "truncate(text, length?, ellipsis?)", "Cut text to n chars with an ellipsis."),
3569
+ method("initials", "initials(name, max?)", "Up-to-`max` initials from a full name."),
3570
+ method("currency", "currency(value, code?, locale?)", "Locale currency string."),
3571
+ method("percent", "percent(value, decimals?)", 'Locale percent string (0.42 → "42%").'),
3572
+ method("bytes", "bytes(value)", 'Human-readable byte size (1536 → "1.5 KB").'),
3573
+ method("relativeTime", "relativeTime(value)", '"3 minutes ago" / "in 2 days" via Intl.'),
3574
+ method("copy", "copy(text)", "Copy to the clipboard — async; resolves true only when the write succeeds (`await $util.copy(x)`)."),
3575
+ method("sleep", "sleep(ms?)", "Awaitable pause: `await $util.sleep(ms)` (capped at 60s)."),
3576
+ method("uuid", "uuid()", "Random UUID v4 string."),
3577
+ method("debounceFn", "debounceFn(fn, wait?)", "Wrap a function so it fires `wait` ms after the LAST call."),
3578
+ method("throttleFn", "throttleFn(fn, wait?)", "Wrap a function to fire at most once per `wait` ms (leading + one trailing)."),
3579
+ // Computed + program hooks
3580
+ method("derived", "derived(fn)", "Computed reactive value — recomputes from the atoms the lambda reads."),
3581
+ method("onError", "onError(fn)", "Program-level error sink — fires with { error, source } when an action throws."),
3582
+ method("onNavigate", "onNavigate(fn)", "Navigation guard: return false to block, a path string to redirect, anything else to allow."),
3583
+ method("onRequest", "onRequest(fn)", "HTTP request interceptor — a partial return merges over every outgoing request."),
3584
+ method("onResponse", "onResponse(fn)", "HTTP response interceptor — replace the response or `await retry()`."),
3585
+ method("invalidate", "invalidate(keys)", "Refetch every cached $query whose key contains one of the substrings."),
3586
+ // Reactive environment (listeners attach lazily on first read)
3587
+ prop("scroll", 'Reactive scroll: .x / .y / .progress (0–1) / .direction ("up"|"down").'),
3588
+ prop("viewport", "Reactive viewport: .width / .height."),
3589
+ prop("breakpoint", 'Reactive breakpoint: .active ("base"|"sm"|"md"|"lg"|"xl") + boolean .sm/.md/.lg/.xl.'),
3590
+ prop("media", "Reactive media flags: .prefersDark / .prefersReducedMotion / .online / .pointer / .portrait."),
3591
+ prop("mouse", "Reactive pointer position: .x / .y."),
3592
+ // URL + query-param state
3593
+ prop("url", "Reactive URL snapshot: .path / .params / .query / .hash + .navigate(to)."),
3594
+ method("url.setQuery", "url.setQuery(key, value)", 'Write a query param in place (null/"" drops it) — shareable filter/tab state.'),
3595
+ method("url.removeQuery", "url.removeQuery(key)", "Drop a query param from the URL."),
3596
+ // Styling helpers ($util.style)
3597
+ { name: "style", kind: "namespace", signature: "style", summary: "Safe styling helpers: .cx / .gradient / .alpha / .clamp / .token / .toStyle." },
3598
+ method("style.cx", "style.cx(...args)", "clsx-style class composer — strings, arrays, { name: cond } objects."),
3599
+ method("style.gradient", "style.gradient(stops, angle?)", "Safe linear-gradient() from color stops + angle."),
3600
+ method("style.alpha", "style.alpha(color, amount)", "color-mix transparency: token or color at 0–1 alpha."),
3601
+ method("style.clamp", "style.clamp(min, preferred, max)", "Responsive clamp(min, preferred, max) size."),
3602
+ method("style.token", "style.token(path)", 'Resolve a theme token path to its CSS var: "colors.primary" → var(--rui-color-primary).'),
3603
+ method("style.toStyle", "style.toStyle(obj)", "Serialise a CSS-declarations object to a sanitised style string."),
3604
+ // Validators ($util.rules)
3605
+ { name: "rules", kind: "namespace", signature: "rules", summary: "Composable validators — compose per field; run with .validate / .validateAll or hand to $form." },
3606
+ method("rules.required", "rules.required(message?)", "Non-empty value."),
3607
+ method("rules.email", "rules.email(message?)", "Valid email address."),
3608
+ method("rules.url", "rules.url(message?)", "Valid http(s) URL."),
3609
+ method("rules.min", "rules.min(n, message?)", "Number ≥ n."),
3610
+ method("rules.max", "rules.max(n, message?)", "Number ≤ n."),
3611
+ method("rules.minLength", "rules.minLength(n, message?)", "String length ≥ n."),
3612
+ method("rules.maxLength", "rules.maxLength(n, message?)", "String length ≤ n."),
3613
+ method("rules.pattern", "rules.pattern(re, message?)", "Match a regular expression."),
3614
+ method("rules.oneOf", "rules.oneOf(options, message?)", "Value is in the allowed list."),
3615
+ method("rules.matches", "rules.matches(other, message?)", "Equals another value (password confirmation)."),
3616
+ method("rules.custom", "rules.custom(fn, message?)", "Custom sync rule — return true/null (valid), false, or an error string."),
3617
+ method("rules.asyncCustom", "rules.asyncCustom(fn, message?)", "Async rule (Promise) — server-side checks; $form awaits it before submitting."),
3618
+ method("rules.validate", "rules.validate(value, validators)", "Run validators — first error message or null (a Promise when an async rule is hit)."),
3619
+ method("rules.validateAll", "rules.validateAll(values, schema)", "Validate an object against { field: [validators] } → { field: message }."),
3620
+ // Device / platform
3621
+ method("vibrate", "vibrate(pattern?)", "Haptic pulse (ms or pattern array) on supporting devices."),
3622
+ method("share", "share(data)", "Native share sheet (Web Share API) — resolves true on share."),
3623
+ method("readClipboard", "readClipboard()", "Read clipboard text (async, permission-gated)."),
3624
+ method("geolocate", "geolocate(options?)", "Resolve { lat, lng, accuracy } via the Geolocation API."),
3625
+ method("isOnline", "isOnline()", "Current navigator.onLine flag."),
3626
+ method("deviceType", "deviceType()", '"mobile" | "tablet" | "desktop" heuristic.'),
3627
+ method("worker", "worker(fn, ...args)", "Run a closure-free function in a Web Worker; resolves its return value."),
3628
+ method("registerServiceWorker", "registerServiceWorker(url, scope?)", "Register a service worker for PWA/offline."),
3629
+ method("webManifest", "webManifest(config)", "Build a sanitised web-app manifest (name, icons, themeColor…)."),
3630
+ method("nativeShell", "nativeShell()", 'Detect the wrapper: capacitor/cordova/tauri/electron/react-native or "web".'),
3631
+ method("isNativeApp", "isNativeApp()", "True when running inside a native shell.")
3632
+ ];
3633
+ const storageBackendMembers = (prefix, label) => [
3634
+ method(`${prefix}set`, `${prefix}set(key, value, options?)`, `${label} write.`),
3635
+ method(`${prefix}get`, `${prefix}get(key)`, `${label} read. Returns null when missing.`),
3636
+ method(`${prefix}remove`, `${prefix}remove(key, options?)`, `Delete a key from ${label.toLowerCase()}.`),
3637
+ method(`${prefix}clear`, `${prefix}clear()`, `Wipe every ${label.toLowerCase()} entry.`)
3638
+ ];
3639
+ const storageMembers = [
3640
+ ...storageBackendMembers("", "localStorage (default namespace)"),
3641
+ { name: "local", kind: "namespace", signature: "local", summary: "localStorage backend — set/get/remove/clear." },
3642
+ ...storageBackendMembers("local.", "localStorage"),
3643
+ { name: "session", kind: "namespace", signature: "session", summary: "sessionStorage backend (per-tab) — set/get/remove/clear." },
3644
+ ...storageBackendMembers("session.", "Per-tab sessionStorage"),
3645
+ { name: "cookies", kind: "namespace", signature: "cookies", summary: "Document cookies — set/get/remove/clear (options: expires, maxAge, path, domain, secure, sameSite)." },
3646
+ method("cookies.set", "cookies.set(key, value, options?)", "Set a cookie. Options: expires, maxAge, path, domain, secure, sameSite."),
3647
+ method("cookies.get", "cookies.get(key)", "Read a cookie value."),
3648
+ method("cookies.remove", "cookies.remove(key, options?)", "Delete a cookie. Path/domain must match the original set call."),
3649
+ method("cookies.clear", "cookies.clear()", "Clear every cookie on this document.")
3650
+ ];
3651
+ const consoleMembers = [
3652
+ method("log", "log(...args)", "Log a message at the default level."),
3653
+ method("error", "error(...args)", "Log an error."),
3654
+ method("warn", "warn(...args)", "Log a warning."),
3655
+ method("info", "info(...args)", "Log an informational message."),
3656
+ method("debug", "debug(...args)", "Log a verbose debug message.")
3657
+ ];
3658
+ const toastMembers = [
3659
+ method("show", "show(message, options?)", "Show a toast; returns its id. Options: { title?, tone?, duration? }."),
3660
+ method("success", "success(message, options?)", '`show` with tone "success".'),
3661
+ method("error", "error(message, options?)", '`show` with tone "danger".'),
3662
+ method("info", "info(message, options?)", '`show` with tone "info".'),
3663
+ method("warning", "warning(message, options?)", '`show` with tone "warning".'),
3664
+ method("dismiss", "dismiss(id)", "Remove a single toast by id."),
3665
+ method("clear", "clear()", "Remove every toast."),
3666
+ prop("items", "Reactive list of live toasts (newest last). Treat as read-only.")
3667
+ ];
3668
+ const domMembers = [
3669
+ method("onResize", "onResize(node, callback)", "Observe element size with a ResizeObserver; callback gets { width, height, entry }. Returns a disposer; auto-disposed on replan."),
3670
+ method("onIntersect", "onIntersect(node, callback, options?)", "Observe viewport intersection with an IntersectionObserver; callback gets the entry. Options: { root?, rootMargin?, threshold? }."),
3671
+ method("onMutation", "onMutation(node, callback, options?)", "Observe DOM mutations with a MutationObserver. Options: { childList?, attributes?, subtree?, characterData? }."),
3672
+ method("measure", "measure(node)", "One-shot read → { rect, scroll, viewport } (getBoundingClientRect + scroll offsets + window size).")
3673
+ ];
3674
+ const namespaceCatalog = [
3675
+ { name: "util", sigil: "$util", summary: "Runtime helper + reactive-environment namespace.", members: utilMembers },
3676
+ { name: "storage", sigil: "$storage", summary: "Browser storage namespace (local / session / cookies).", members: storageMembers },
3677
+ { name: "console", sigil: "$console", summary: "Console namespace forwarding to the browser console.", members: consoleMembers },
3678
+ { name: "toast", sigil: "$toast", summary: "Imperative toast namespace.", members: toastMembers },
3679
+ { name: "dom", sigil: "$dom", summary: "Managed DOM-observer namespace (resize / intersection / mutation / measure).", members: domMembers }
3680
+ ];
3681
+ const namespacesByName = Object.freeze(
3682
+ Object.fromEntries(namespaceCatalog.map((n) => [n.name, n]))
3683
+ );
3684
+ const httpResourceMembers = [
3685
+ prop("data", "Parsed response body — `null` until the request resolves."),
3686
+ prop("error", "`null` on success; `{ status, body }` on a non-2xx; the thrown error on network failure."),
3687
+ prop("status", "HTTP status code of the last response, e.g. `200`."),
3688
+ prop("loading", "`true` while a request is in flight."),
3689
+ prop("headers", "Response headers as a plain object."),
3690
+ prop("lastUpdated", "Epoch-ms of the last successful response."),
3691
+ method("refetch", "refetch()", "Re-issue the original request."),
3692
+ method("cancel", "cancel()", "Abort the in-flight request."),
3693
+ prop("onDone", "Settable callback fired each time the request settles (success or error).")
3694
+ ];
3695
+ const queryResourceMembers = [
3696
+ ...httpResourceMembers,
3697
+ method("loadMore", "loadMore()", "Fetch the next page (infinite mode)."),
3698
+ prop("hasMore", "`true` while more pages are available (infinite mode)."),
3699
+ prop("loadingMore", "`true` while a `loadMore()` page is in flight."),
3700
+ prop("pages", "Raw page bodies loaded so far (infinite mode); `.data` is the flattened items.")
3701
+ ];
3702
+ const mutationResourceMembers = [
3703
+ method("mutate", "mutate(overrides?)", "Fire the request; overrides shallow-merge over the config. `optimistic` applies instantly and rolls back on failure."),
3704
+ prop("data", "Response body of the last successful mutation."),
3705
+ prop("error", "`null` on success; error details on failure."),
3706
+ prop("loading", "`true` while the mutation request is in flight."),
3707
+ prop("status", "HTTP status code of the last response."),
3708
+ prop("onDone", "Settable callback fired when the mutation settles.")
3709
+ ];
3710
+ const socketResourceMembers = [
3711
+ prop("status", 'Connection lifecycle: "connecting" | "open" | "closed".'),
3712
+ prop("connected", '`true` while status is "open".'),
3713
+ prop("last", "Most recent message (JSON auto-parsed), or null."),
3714
+ prop("messages", "Buffered messages, newest last (capped to bufferSize)."),
3715
+ prop("attempts", "Reconnect attempts in the current streak (resets on success)."),
3716
+ prop("error", "Last socket error event, if any."),
3717
+ method("send", "send(data)", "Send a message (objects JSON-stringified). Queues while connecting; flushes on open."),
3718
+ method("close", "close()", "Close for good — disables auto-reconnect.")
3719
+ ];
3720
+ const sseResourceMembers = [
3721
+ prop("status", '"connecting" | "open" | "closed" (EventSource retries natively).'),
3722
+ prop("connected", "`true` while the stream is open."),
3723
+ prop("last", "Most recent event payload (JSON auto-parsed)."),
3724
+ prop("messages", "Buffered events, newest last (capped to bufferSize)."),
3725
+ prop("error", "Last stream error, if any."),
3726
+ method("close", "close()", "Close the stream.")
3727
+ ];
3728
+ const formResourceMembers = [
3729
+ prop("values", "Reactive field values — two-way bind with an input's `value`."),
3730
+ prop("errors", "Per-field error messages (set after validate/touch/submit)."),
3731
+ prop("touched", "Per-field booleans — true once the user has interacted."),
3732
+ prop("dirty", "`true` once any value differs from the clean snapshot."),
3733
+ prop("valid", "`true` when the last validation pass found no errors."),
3734
+ prop("submitting", "`true` from submit() until an async onSubmit settles."),
3735
+ prop("validating", "`true` while async rules ($util.rules.asyncCustom) are in flight."),
3736
+ method("field", "field(name)", "Controlled prop bag: { value, error, name, onChange, onBlur } — spread onto an input."),
3737
+ method("touch", "touch(name)", "Mark a field touched + validate it (wire to `onBlur`)."),
3738
+ method("setField", "setField(name, value)", "Set one field value (clears its error)."),
3739
+ method("setValues", "setValues(values)", "Merge several field values at once."),
3740
+ method("validate", "validate()", "Validate every field → boolean (a Promise when async rules exist)."),
3741
+ method("validateField", "validateField(name)", "Validate one field → message | null (Promise for async rules)."),
3742
+ method("submit", "submit()", "Touch all → validate → onSubmit(values) when valid. Alias: handleSubmit()."),
3743
+ method("handleSubmit", "handleSubmit()", "Alias of submit()."),
3744
+ method("reset", "reset()", "Restore initial values; clears errors/touched/dirty.")
3745
+ ];
3746
+ const scriptResourceMembers = [
3747
+ prop("ready", "`true` once the external script / stylesheet has loaded successfully."),
3748
+ prop("loading", "`true` while the resource is still downloading."),
3749
+ prop("error", "The load error, or `null` on success."),
3750
+ prop("value", "The resolved value — `window[global]` for a script with a `global` (e.g. window.Stripe), else `true`. `null` until ready.")
3751
+ ];
3752
+ const storeResourceMembers = [
3753
+ method("undo", "undo()", "Undo the last change (`history: true|depth` stores)."),
3754
+ method("redo", "redo()", "Redo the last undone change."),
3755
+ prop("canUndo", "Reactive — `true` when an undo step is available."),
3756
+ prop("canRedo", "Reactive — `true` when a redo step is available."),
3757
+ method("clearHistory", "clearHistory()", "Drop the undo/redo stacks.")
3758
+ ];
3759
+ const factoryResourceCatalog = [
3760
+ { factory: "http", summary: "Reactive HTTP resource bag.", members: httpResourceMembers },
3761
+ { factory: "query", summary: "Cached query bag (HTTP + pagination).", members: queryResourceMembers },
3762
+ { factory: "mutation", summary: "Deferred mutation bag (fires on .mutate()).", members: mutationResourceMembers },
3763
+ { factory: "socket", summary: "Reactive WebSocket bag.", members: socketResourceMembers },
3764
+ { factory: "sse", summary: "Reactive Server-Sent Events bag.", members: sseResourceMembers },
3765
+ { factory: "script", summary: "External script / stylesheet load bag.", members: scriptResourceMembers },
3766
+ { factory: "form", summary: "Managed form engine bag.", members: formResourceMembers },
3767
+ { factory: "store", summary: "Global store handle (built-in history methods).", members: storeResourceMembers }
3768
+ ];
3769
+ const factoriesByName = Object.freeze(
3770
+ Object.fromEntries(factoryResourceCatalog.map((f) => [f.factory, f]))
3771
+ );
3772
+ const factoryResourceNames = new Set(
3773
+ factoryResourceCatalog.map((f) => f.factory)
3774
+ );
3775
+ const routeMembers = [
3776
+ prop("path", "Current URL path, e.g. `/users/42`."),
3777
+ prop("params", "Captured path segments from the matched route pattern (`route.params.id`)."),
3778
+ prop("query", "Parsed query-string parameters as an object."),
3779
+ prop("pattern", "The matched route pattern, or `null`."),
3780
+ method("navigate", "navigate(to)", "Imperatively navigate to a path.")
3781
+ ];
3782
+ const i18nResultMembers = [
3783
+ method("t", "t(key, vars?)", "Translate a key for the current language; interpolates {name} placeholders + ICU plural/select."),
3784
+ method("setCurrentLanguage", "setCurrentLanguage(lang)", "Switch the active language."),
3785
+ method("getCurrentLanguage", "getCurrentLanguage()", "Return the active language code.")
3786
+ ];
3787
+ function findNamespace(bareName) {
3788
+ return namespacesByName[bareName];
3789
+ }
3790
+ function isNamespaceName(bareName) {
3791
+ return bareName in namespacesByName;
3792
+ }
3793
+ function findFactoryResource(factory) {
3794
+ return factoriesByName[factory];
3795
+ }
3796
+ function namespaceMembersAt(bareName, path = []) {
3797
+ const ns = namespacesByName[bareName];
3798
+ if (!ns) return [];
3799
+ if (path.length === 0) return ns.members.slice();
3800
+ const prefix = `${path.join(".")}.`;
3801
+ const out = [];
3802
+ for (const m of ns.members) {
3803
+ if (m.name.startsWith(prefix)) {
3804
+ out.push({ ...m, name: m.name.slice(prefix.length) });
3805
+ }
3806
+ }
3807
+ return out;
3808
+ }
3809
+ function findNamespaceMember(bareName, memberPath) {
3810
+ const ns = namespacesByName[bareName];
3811
+ if (!ns) return void 0;
3812
+ return ns.members.find((m) => m.name === memberPath);
3813
+ }
3814
+ const cfg = (name, type, summary) => ({ name, type, summary });
3815
+ const httpConfigKeys = [
3816
+ cfg("url", "string", "Absolute request URL."),
3817
+ cfg("method", 'enum: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD" | "OPTIONS"', "HTTP method. Defaults to GET."),
3818
+ cfg("query", "object", "Object serialised into the URL querystring (`?k=v`)."),
3819
+ cfg("headers", "object", "Request headers as a plain object."),
3820
+ cfg("body", "object", "Request body. Objects are JSON-encoded automatically."),
3821
+ cfg("credentials", 'enum: "omit" | "same-origin" | "include"', "Fetch credentials mode."),
3822
+ cfg("mode", 'enum: "cors" | "no-cors" | "same-origin"', "Fetch request mode."),
3823
+ cfg("cache", 'enum: "default" | "no-store" | "reload" | "no-cache" | "force-cache"', "Fetch cache mode."),
3824
+ cfg("gql", "string", "GraphQL query — POSTs { query, variables }; `.data` is the unwrapped GraphQL data."),
3825
+ cfg("variables", "object", "GraphQL variables paired with `gql`.")
3826
+ ];
3827
+ const queryConfigKeys = [
3828
+ ...httpConfigKeys,
3829
+ cfg("key", "string", "Cache key — identical keys share one in-flight request + cached bag."),
3830
+ cfg("ttl", "number", "Milliseconds before cached data is considered stale and auto-refetched."),
3831
+ cfg("refetchInterval", "number", "Poll interval in ms (live dashboards)."),
3832
+ cfg("refetchOnFocus", "boolean", "Refetch when the tab regains focus."),
3833
+ cfg("refetchOnReconnect", "boolean", "Refetch when the network reconnects."),
3834
+ cfg("infinite", "object", "Pagination config: { param?, start?, limit?, mode?, select? } → .loadMore()/.hasMore.")
3835
+ ];
3836
+ const mutationConfigKeys = [
3837
+ cfg("url", "string", "Absolute request URL."),
3838
+ cfg("method", 'enum: "POST" | "PUT" | "PATCH" | "DELETE"', "HTTP method. Defaults to POST."),
3839
+ cfg("body", "object", "Default body; shallow-merged with `.mutate(overrides)`."),
3840
+ cfg("headers", "object", "Request headers as a plain object."),
3841
+ cfg("query", "object", "Object serialised into the URL querystring."),
3842
+ cfg("optimistic", "(vars) => void", "Runs synchronously before the request; auto-rolled-back on failure."),
3843
+ cfg("invalidates", "string[]", "Refetch every cached $query whose key contains a listed substring on success."),
3844
+ cfg("gql", "string", "GraphQL mutation document."),
3845
+ cfg("variables", "object", "GraphQL variables paired with `gql`.")
3846
+ ];
3847
+ const socketConfigKeys = [
3848
+ cfg("url", "string", "WebSocket URL (ws:// or wss://)."),
3849
+ cfg("protocols", "string | string[]", "Optional sub-protocol(s)."),
3850
+ cfg("bufferSize", "number", "Max buffered messages kept in `.messages`."),
3851
+ cfg("onMessage", "(msg) => void", "Callback fired for each received message."),
3852
+ cfg("reconnect", "boolean | number", "Retry dropped connections (true, or a max-attempt count) with backoff.")
3853
+ ];
3854
+ const sseConfigKeys = [
3855
+ cfg("url", "string", "EventSource URL."),
3856
+ cfg("event", "string", "Named event to listen for (defaults to message)."),
3857
+ cfg("withCredentials", "boolean", "Send credentials with the EventSource request."),
3858
+ cfg("bufferSize", "number", "Max buffered events kept in `.messages`.")
3859
+ ];
3860
+ const scriptConfigKeys = [
3861
+ cfg("src", "string", "URL of the script (or stylesheet) to load. De-duplicated per src."),
3862
+ cfg("global", "string", 'Name of the window global the script defines — read into `.value` once ready (e.g. "Stripe").'),
3863
+ cfg("type", "string", 'Script type attribute (e.g. "module" for ESM).'),
3864
+ cfg("as", 'enum: "script" | "style"', "Force the resource kind. Inferred from a `.css` src otherwise."),
3865
+ cfg("attributes", "object", "Extra attributes to set on the injected <script>/<link> (e.g. crossorigin, integrity).")
3866
+ ];
3867
+ const headConfigKeys = [
3868
+ cfg("title", "string", "Document title (sets document.title + <title>)."),
3869
+ cfg("titleTemplate", "string", 'Wrap `title` with a template, e.g. "%s — Acme".'),
3870
+ cfg("meta", "object", 'Named meta tags: { description, "theme-color", keywords, … } → <meta name content>.'),
3871
+ cfg("og", "object", 'Open Graph tags: { title, image, type, … } → <meta property="og:KEY">.'),
3872
+ cfg("twitter", "object", 'Twitter card tags: { card, site, … } → <meta name="twitter:KEY">.'),
3873
+ cfg("link", "object[]", 'Array of <link> descriptors, e.g. [{ rel: "canonical", href }].'),
3874
+ cfg("jsonLd", "object | object[]", 'JSON-LD structured data → <script type="application/ld+json">. @context defaults to schema.org.'),
3875
+ cfg("base", "string | object", "<base href> for the document."),
3876
+ cfg("htmlAttrs", "object", 'Attributes for the <html> element, e.g. { lang: "en", dir: "ltr" }.')
3877
+ ];
3878
+ const formConfigKeys = [
3879
+ cfg("values", "object", "Initial field values — the clean snapshot."),
3880
+ cfg("rules", "object", "Per-field validator arrays: { field: [$util.rules.required(), …] }."),
3881
+ cfg("onSubmit", "(values) => void", "Called with the values once validation passes.")
3882
+ ];
3883
+ const storeConfigKeys = [
3884
+ cfg("persist", "string", "Mirror the store's data to localStorage under this key (hydrates on first render)."),
3885
+ cfg("persistIn", 'enum: "local" | "session"', "Storage backend for `persist` (defaults to local)."),
3886
+ cfg("history", "boolean | number", "Enable undo()/redo()/clearHistory() + reactive canUndo/canRedo (number = depth).")
3887
+ ];
3888
+ const themeConfigKeys = [
3889
+ cfg("name", "string", 'Selects a built-in base theme ("dark", "neon", …).'),
3890
+ cfg("direction", 'enum: "ltr" | "rtl"', "Reading direction (metadata)."),
3891
+ cfg("colors", "object", "CSS color tokens: bg, surface, border, text, primary, accent, success, warning, danger, info, …."),
3892
+ cfg("radius", "object", "Border-radius tokens: xs, sm, md, lg, pill, button, input."),
3893
+ cfg("font", "object", "Font tokens: family, familyHeading, familyMono, sizeBase, weightBody, …."),
3894
+ cfg("spacing", "object", "Spacing scale tokens."),
3895
+ cfg("shadows", "object", "Box-shadow tokens."),
3896
+ cfg("gradients", "object", "Gradient color-stop arrays — referenced as gradient.<name>."),
3897
+ cfg("zIndex", "object", "Layer tokens (modal, toast, …) → sx.zIndex / --rui-z-*."),
3898
+ cfg("motion", "object", "Motion tokens: { fast, base, slow, ease } → --rui-motion-*."),
3899
+ cfg("fonts", "object", 'Web-font import: { import: ["Inter:400,700"] }.'),
3900
+ cfg("icons", "object", "Custom inline-SVG icons by name, usable anywhere an icon name is.")
3901
+ ];
3902
+ const i18nConfigKeys = [
3903
+ cfg("defaultLanguage", "string", "Fallback language when a key is missing for the current language."),
3904
+ cfg("currentLanguage", "string", "Active language — drive from a reactive atom for live switching."),
3905
+ cfg("translations", "object", '{ key: { lang: "text {name}" } }. Supports ICU plural/select.')
3906
+ ];
3907
+ const builtinConfigByName = Object.freeze({
3908
+ http: httpConfigKeys,
3909
+ query: queryConfigKeys,
3910
+ mutation: mutationConfigKeys,
3911
+ socket: socketConfigKeys,
3912
+ sse: sseConfigKeys,
3913
+ script: scriptConfigKeys,
3914
+ head: headConfigKeys,
3915
+ form: formConfigKeys,
3916
+ store: storeConfigKeys,
3917
+ theme: themeConfigKeys,
3918
+ i18n: i18nConfigKeys
3919
+ });
3920
+ function findBuiltinConfig(bareName) {
3921
+ return builtinConfigByName[bareName];
3922
+ }
3467
3923
  const GRID_COLUMNS = 12;
3468
3924
  const FLEX_ALIGN = {
3469
3925
  start: "flex-start",
@@ -3492,15 +3948,15 @@ function applyDirectionWithReverse(value, reverse) {
3492
3948
  if (value.endsWith("-reverse")) return value;
3493
3949
  return `${value}-reverse`;
3494
3950
  }
3495
- function emitResponsiveSpacingVars(styleParts, prop, cssPrefix) {
3951
+ function emitResponsiveSpacingVars(styleParts, prop2, cssPrefix) {
3496
3952
  for (const bp of RESPONSIVE_BREAKPOINTS) {
3497
- const v = prop.values[bp];
3953
+ const v = prop2.values[bp];
3498
3954
  if (v) styleParts.push(`${cssPrefix}-${bp}:${spacingCssValue(v) || `var(--rui-spacing-${v}, ${v})`}`);
3499
3955
  }
3500
3956
  }
3501
- function emitResponsiveFlexVars(styleParts, prop, cssPrefix, mapper) {
3957
+ function emitResponsiveFlexVars(styleParts, prop2, cssPrefix, mapper) {
3502
3958
  for (const bp of RESPONSIVE_BREAKPOINTS) {
3503
- const v = prop.values[bp];
3959
+ const v = prop2.values[bp];
3504
3960
  if (v) styleParts.push(`${cssPrefix}-${bp}:${mapper(String(v))}`);
3505
3961
  }
3506
3962
  }
@@ -5685,8 +6141,8 @@ const OnMouse = {
5685
6141
  if (asBoolean(props.draggable)) wrapper.setAttribute("draggable", "true");
5686
6142
  wrapper.append(renderChildAsNode(helpers, props.child));
5687
6143
  const passive = props.passiveScroll === void 0 ? true : asBoolean(props.passiveScroll);
5688
- for (const { prop, event } of MOUSE_EVENT_MAP) {
5689
- const handler = props[prop];
6144
+ for (const { prop: prop2, event } of MOUSE_EVENT_MAP) {
6145
+ const handler = props[prop2];
5690
6146
  if (handler == null) continue;
5691
6147
  const isScrollEvent = event === "scroll" || event === "wheel";
5692
6148
  const options = isScrollEvent ? { passive } : {};
@@ -5716,8 +6172,8 @@ const OnKeyboard = {
5716
6172
  const focusable = props.focusable === void 0 ? true : asBoolean(props.focusable);
5717
6173
  const wrapper = transparentWrapper("rui-on-keyboard", focusable ? { tabindex: "0" } : {});
5718
6174
  wrapper.append(renderChildAsNode(helpers, props.child));
5719
- for (const { prop, event } of KEYBOARD_EVENT_MAP) {
5720
- const handler = props[prop];
6175
+ for (const { prop: prop2, event } of KEYBOARD_EVENT_MAP) {
6176
+ const handler = props[prop2];
5721
6177
  if (handler == null) continue;
5722
6178
  wrapper.addEventListener(event, (ev) => {
5723
6179
  helpers.invoke(handler, ev);
@@ -14168,31 +14624,33 @@ const VirtualList = {
14168
14624
  windowEl.style.right = "0";
14169
14625
  scrollEl.style.maxHeight = `${Math.min(Math.max(total, 1), 12) * itemHeight}px`;
14170
14626
  scrollEl.style.overflow = "auto";
14171
- const renderSlice = (startIndex) => {
14172
- windowEl.replaceChildren();
14173
- const viewHeight = scrollEl.clientHeight || itemHeight * 12;
14627
+ const renderSlice = (winNode, scroller) => {
14628
+ winNode.replaceChildren();
14629
+ const viewHeight = scroller.clientHeight || itemHeight * 12;
14174
14630
  const visible = Math.ceil(viewHeight / itemHeight) + 2;
14175
- const start = Math.max(0, startIndex);
14631
+ const scrollTop = Number.isFinite(scroller.scrollTop) ? scroller.scrollTop : 0;
14632
+ const start = Math.max(0, Math.floor(scrollTop / itemHeight));
14176
14633
  const end = Math.min(total, start + visible);
14177
- windowEl.style.transform = `translateY(${start * itemHeight}px)`;
14634
+ winNode.style.transform = `translateY(${start * itemHeight}px)`;
14178
14635
  for (let i = start; i < end; i++) {
14179
14636
  const entry = rawItems[i];
14180
14637
  if (props.renderItem) {
14181
- windowEl.append(helpers.renderNode(entry ?? props.renderItem));
14638
+ winNode.append(helpers.renderNode(entry ?? props.renderItem));
14182
14639
  } else if (entry && typeof entry === "object" && entry.__kind) {
14183
- windowEl.append(helpers.renderNode(entry));
14640
+ winNode.append(helpers.renderNode(entry));
14184
14641
  } else {
14185
14642
  const row = el("div", { class: "rui-virtual-list-item", style: `height:${itemHeight}px` });
14186
14643
  row.append(el("span", {}, [asString(entry)]));
14187
- windowEl.append(row);
14644
+ winNode.append(row);
14188
14645
  }
14189
14646
  }
14190
14647
  };
14191
- scrollEl.onscroll = () => {
14192
- const start = Math.floor(scrollEl.scrollTop / itemHeight);
14193
- renderSlice(start);
14648
+ scrollEl.onscroll = (ev) => {
14649
+ const liveScroller = ev?.currentTarget ?? ev?.target ?? scrollEl;
14650
+ const liveWindow = liveScroller.querySelector(".rui-virtual-list-window");
14651
+ if (liveWindow) renderSlice(liveWindow, liveScroller);
14194
14652
  };
14195
- renderSlice(0);
14653
+ renderSlice(windowEl, scrollEl);
14196
14654
  scrollEl.append(spacer, windowEl);
14197
14655
  viewport.append(scrollEl);
14198
14656
  return viewport;
@@ -15000,6 +15458,175 @@ const Styles = {
15000
15458
  return node;
15001
15459
  }
15002
15460
  };
15461
+ function asRecord(value) {
15462
+ return value && typeof value === "object" && !Array.isArray(value) ? value : {};
15463
+ }
15464
+ function shallowEqual(a, b) {
15465
+ if (a === null) return false;
15466
+ const ak = Object.keys(a);
15467
+ const bk = Object.keys(b);
15468
+ if (ak.length !== bk.length) return false;
15469
+ for (const key of ak) {
15470
+ if (!Object.is(a[key], b[key])) return false;
15471
+ }
15472
+ return true;
15473
+ }
15474
+ function defer(run) {
15475
+ if (typeof queueMicrotask === "function") queueMicrotask(run);
15476
+ else void Promise.resolve().then(run);
15477
+ }
15478
+ const HOST_TAGS = /* @__PURE__ */ new Set([
15479
+ "div",
15480
+ "span",
15481
+ "section",
15482
+ "article",
15483
+ "aside",
15484
+ "figure",
15485
+ "canvas",
15486
+ "p",
15487
+ "pre",
15488
+ "form"
15489
+ ]);
15490
+ function resolveHostTag(input) {
15491
+ const name = asString(input).trim().toLowerCase();
15492
+ return HOST_TAGS.has(name) ? name : "div";
15493
+ }
15494
+ const Mount = {
15495
+ name: "Mount",
15496
+ description: "First-class host for an imperative / third-party widget that owns its own DOM (chart, map, editor, payment element, captcha, video SDK). Aktion creates the host element; `setup(node, props)` runs once after it attaches and returns an instance handle, `update(instance, props)` runs when `props` change (shallow-compared), and `cleanup(instance)` runs on unmount. The host is preserved across re-renders so the widget is never rebuilt. Apply layout with `sx`.",
15497
+ props: [
15498
+ { name: "setup", type: "callable", required: true, description: "`(node, props) => instance` — runs once after the host attaches; return value is the instance handle passed to `update`/`cleanup`." },
15499
+ { name: "update", type: "callable", optional: true, description: "`(instance, props) => void` — runs when `props` change (shallow-compared)." },
15500
+ { name: "cleanup", type: "callable", optional: true, description: "`(instance) => void` — runs when the component leaves the tree (destroy/teardown)." },
15501
+ { name: "props", type: "object", optional: true, description: "Reactive prop bag handed to `setup`/`update`. Bind `$state` here to drive the widget." },
15502
+ { name: "tag", type: "string", optional: true, enum: ["div", "span", "section", "article", "aside", "figure", "canvas", "p", "pre", "form"], description: 'Host element tag (default "div").' }
15503
+ ],
15504
+ render: (_node, props, helpers) => {
15505
+ const host = el(resolveHostTag(props.tag), {
15506
+ class: "rui-mount",
15507
+ "data-rui-preserve": ""
15508
+ });
15509
+ const widgetProps = asRecord(props.props);
15510
+ const slot = helpers.useInstanceState("rui-mount", {
15511
+ started: false,
15512
+ instance: void 0,
15513
+ props: widgetProps,
15514
+ prevProps: null
15515
+ });
15516
+ const state = slot.get();
15517
+ state.prevProps = state.props;
15518
+ state.props = widgetProps;
15519
+ if (!state.started) {
15520
+ state.started = true;
15521
+ defer(() => {
15522
+ try {
15523
+ state.instance = typeof props.setup === "function" ? props.setup(host, state.props) : void 0;
15524
+ } catch (err) {
15525
+ console.error("[aktion] Mount setup threw", err);
15526
+ }
15527
+ if (props.cleanup != null) {
15528
+ helpers.registerDisposer(() => {
15529
+ defer(() => {
15530
+ try {
15531
+ if (typeof props.cleanup === "function") {
15532
+ props.cleanup(state.instance);
15533
+ }
15534
+ } catch (err) {
15535
+ console.error("[aktion] Mount cleanup threw", err);
15536
+ }
15537
+ });
15538
+ }, "rui-mount-cleanup");
15539
+ }
15540
+ });
15541
+ return host;
15542
+ }
15543
+ if (state.instance !== void 0 && typeof props.update === "function" && !shallowEqual(state.prevProps, widgetProps)) {
15544
+ const update = props.update;
15545
+ const instance = state.instance;
15546
+ defer(() => {
15547
+ try {
15548
+ update(instance, widgetProps);
15549
+ } catch (err) {
15550
+ console.error("[aktion] Mount update threw", err);
15551
+ }
15552
+ });
15553
+ }
15554
+ return host;
15555
+ }
15556
+ };
15557
+ const CUSTOM_ELEMENT_RE = /^[a-z][a-z0-9]*(-[a-z0-9]+)+$/;
15558
+ function resolveCustomTag(input) {
15559
+ const name = asString(input).trim().toLowerCase();
15560
+ return CUSTOM_ELEMENT_RE.test(name) ? name : "div";
15561
+ }
15562
+ function applyAttributes(node, attributes) {
15563
+ for (const [key, value] of Object.entries(attributes)) {
15564
+ if (/^on/i.test(key)) continue;
15565
+ if (value === null || value === void 0 || value === false) {
15566
+ node.removeAttribute(key);
15567
+ continue;
15568
+ }
15569
+ node.setAttribute(key, value === true ? "" : String(value));
15570
+ }
15571
+ }
15572
+ function applyProperties(node, properties) {
15573
+ const target = node;
15574
+ for (const [key, value] of Object.entries(properties)) {
15575
+ try {
15576
+ target[key] = value;
15577
+ } catch {
15578
+ }
15579
+ }
15580
+ }
15581
+ const WebComponent = {
15582
+ name: "WebComponent",
15583
+ description: "Render and hydrate any native custom element / web component with reactive `attributes`, JS `properties`, and `on` event hooks. Use to drop a third-party web component (`<stripe-pricing-table>`, `<model-viewer>`, a design-system element) into an Aktion app. The element is preserved across re-renders; attribute changes flow through reactively and listeners stay current. Invalid (hyphen-less) tag names fall back to a `div`.",
15584
+ props: [
15585
+ { name: "tag", type: "string", positional: true, required: true, description: 'Custom-element tag name (must contain a hyphen, e.g. "stripe-pricing-table").' },
15586
+ { name: "attributes", type: "object", optional: true, aliases: ["attrs"], description: "Reactive attribute map. `$state` values update the element on change; `on*` keys are ignored." },
15587
+ { name: "properties", type: "object", optional: true, aliases: ["props"], description: "JS properties assigned on the element (for components that take rich, non-string props)." },
15588
+ { name: "on", type: "object", optional: true, aliases: ["events"], description: "Event map `{ eventName: handler }` bound once to the live element (handlers stay current across re-renders)." },
15589
+ { name: "children", type: "Node[]", optional: true, description: "Light-DOM child nodes / text to slot inside the element." }
15590
+ ],
15591
+ render: (_node, props, helpers) => {
15592
+ const tag = resolveCustomTag(props.tag);
15593
+ const node = el(tag, {
15594
+ class: "rui-web-component",
15595
+ "data-rui-preserve": ""
15596
+ });
15597
+ applyAttributes(node, asRecord(props.attributes));
15598
+ applyProperties(node, asRecord(props.properties));
15599
+ const children = Array.isArray(props.children) ? props.children : props.children != null ? [props.children] : [];
15600
+ for (const child of children) {
15601
+ if (child == null) continue;
15602
+ node.append(typeof child === "string" ? document.createTextNode(child) : helpers.renderNode(child));
15603
+ }
15604
+ const handlers = asRecord(props.on);
15605
+ const slot = helpers.useInstanceState("rui-web-component", {
15606
+ bound: false,
15607
+ handlers,
15608
+ node: null
15609
+ });
15610
+ const state = slot.get();
15611
+ state.handlers = handlers;
15612
+ if (!state.bound) {
15613
+ state.bound = true;
15614
+ defer(() => {
15615
+ state.node = node;
15616
+ for (const eventName of Object.keys(handlers)) {
15617
+ node.addEventListener(eventName, (event) => {
15618
+ const fn = state.handlers[eventName];
15619
+ if (typeof fn === "function") helpers.invoke(fn, event);
15620
+ });
15621
+ }
15622
+ });
15623
+ } else if (state.node) {
15624
+ applyAttributes(state.node, asRecord(props.attributes));
15625
+ applyProperties(state.node, asRecord(props.properties));
15626
+ }
15627
+ return node;
15628
+ }
15629
+ };
15003
15630
  const GradientText = {
15004
15631
  name: "GradientText",
15005
15632
  description: 'Inline text painted with a brand gradient. Use inside a Display/Heading title to emphasise a phrase: `Display(["Build in ", GradientText("record time")])`. `gradient` selects a named theme gradient (brand|accent|warm|cool|success|danger).',
@@ -15586,14 +16213,14 @@ function startBackdropEngine(canvas, helpers) {
15586
16213
  return { count, type, speed, link, size, colors: colors.length > 0 ? colors : BACKDROP_PALETTE };
15587
16214
  };
15588
16215
  const seed = () => {
15589
- const cfg = readConfig();
15590
- particles = Array.from({ length: cfg.count }, (_unused, i) => ({
16216
+ const cfg2 = readConfig();
16217
+ particles = Array.from({ length: cfg2.count }, (_unused, i) => ({
15591
16218
  x: Math.random() * w,
15592
16219
  y: Math.random() * h,
15593
16220
  vx: (Math.random() - 0.5) * 0.5 * dpr,
15594
16221
  vy: (Math.random() - 0.5) * 0.5 * dpr,
15595
- r: (Math.random() * (cfg.size - 0.5) + 0.5) * dpr,
15596
- c: cfg.colors[i % cfg.colors.length],
16222
+ r: (Math.random() * (cfg2.size - 0.5) + 0.5) * dpr,
16223
+ c: cfg2.colors[i % cfg2.colors.length],
15597
16224
  phase: Math.random() * Math.PI * 2
15598
16225
  }));
15599
16226
  };
@@ -15608,8 +16235,8 @@ function startBackdropEngine(canvas, helpers) {
15608
16235
  seed();
15609
16236
  };
15610
16237
  const drawFrame = () => {
15611
- const cfg = readConfig();
15612
- const sig = `${cfg.count}|${cfg.type}|${cfg.colors.join(",")}`;
16238
+ const cfg2 = readConfig();
16239
+ const sig = `${cfg2.count}|${cfg2.type}|${cfg2.colors.join(",")}`;
15613
16240
  if (sig !== signature) {
15614
16241
  signature = sig;
15615
16242
  seed();
@@ -15618,9 +16245,9 @@ function startBackdropEngine(canvas, helpers) {
15618
16245
  if (canvas.height !== h) canvas.height = h;
15619
16246
  ctx.clearRect(0, 0, w, h);
15620
16247
  tick += 1;
15621
- const sp = cfg.speed;
16248
+ const sp = cfg2.speed;
15622
16249
  for (const p of particles) {
15623
- switch (cfg.type) {
16250
+ switch (cfg2.type) {
15624
16251
  case "drift":
15625
16252
  p.x += p.vx * 0.5 * sp;
15626
16253
  p.y += p.vy * 0.5 * sp;
@@ -15660,7 +16287,7 @@ function startBackdropEngine(canvas, helpers) {
15660
16287
  }
15661
16288
  ctx.beginPath();
15662
16289
  ctx.arc(p.x, p.y, p.r, 0, Math.PI * 2);
15663
- if (cfg.type === "bubbles") {
16290
+ if (cfg2.type === "bubbles") {
15664
16291
  ctx.strokeStyle = p.c;
15665
16292
  ctx.lineWidth = dpr;
15666
16293
  ctx.stroke();
@@ -15672,8 +16299,8 @@ function startBackdropEngine(canvas, helpers) {
15672
16299
  ctx.fill();
15673
16300
  }
15674
16301
  }
15675
- if (cfg.type === "network") {
15676
- const link = cfg.link * dpr;
16302
+ if (cfg2.type === "network") {
16303
+ const link = cfg2.link * dpr;
15677
16304
  for (let i = 0; i < particles.length; i += 1) {
15678
16305
  for (let j = i + 1; j < particles.length; j += 1) {
15679
16306
  const a = particles[i];
@@ -15749,7 +16376,7 @@ const Backdrop = {
15749
16376
  ].filter(Boolean).join(";");
15750
16377
  root.append(el("div", { class: "rui-backdrop-blob", style }));
15751
16378
  });
15752
- const count = Math.max(0, Math.min(120, Math.round(asNumber(props.particles || 50, 0))));
16379
+ const count = Math.max(0, Math.min(120, Math.round(asNumber(props.particles, 0))));
15753
16380
  if (count > 0) {
15754
16381
  const typeRaw = asString(props.type, "network");
15755
16382
  const palette = asArray(props.particleColors).map((c) => safeCssColor(asString(c), "")).filter(Boolean).slice(0, 8);
@@ -17532,29 +18159,29 @@ function readGcalEvents(raw) {
17532
18159
  }
17533
18160
  return { chips, dots };
17534
18161
  }
17535
- function buildCalendarInto(root, year, month, cfg) {
18162
+ function buildCalendarInto(root, year, month, cfg2) {
17536
18163
  const liveRootOf = (event) => (event.currentTarget ?? event.target)?.closest(".rui-gcal") ?? root;
17537
18164
  const navigateTo = (event, y, m) => {
17538
18165
  const live = liveRootOf(event);
17539
- const prev = cfg.viewSlot.get();
17540
- cfg.viewSlot.set({
18166
+ const prev = cfg2.viewSlot.get();
18167
+ cfg2.viewSlot.set({
17541
18168
  propsYear: prev?.propsYear ?? y,
17542
18169
  propsMonth: prev?.propsMonth ?? m,
17543
18170
  year: y,
17544
18171
  month: m
17545
18172
  });
17546
- buildCalendarInto(live, y, m, cfg);
17547
- cfg.helpers.invoke(cfg.onNavigate, y, m);
18173
+ buildCalendarInto(live, y, m, cfg2);
18174
+ cfg2.helpers.invoke(cfg2.onNavigate, y, m);
17548
18175
  };
17549
18176
  const navigateBy = (event, delta) => {
17550
- const current = cfg.viewSlot.get();
18177
+ const current = cfg2.viewSlot.get();
17551
18178
  const baseYear = current?.year ?? year;
17552
18179
  const baseMonth = current?.month ?? month;
17553
18180
  const shifted = new Date(baseYear, baseMonth + delta, 1);
17554
18181
  navigateTo(event, shifted.getFullYear(), shifted.getMonth());
17555
18182
  };
17556
18183
  const toolbar = el("div", { class: "rui-gcal-toolbar" });
17557
- if (cfg.navigable) {
18184
+ if (cfg2.navigable) {
17558
18185
  const todayBtn = el("button", { type: "button", class: "rui-gcal-today" }, ["Today"]);
17559
18186
  todayBtn.onclick = (event) => {
17560
18187
  const now = /* @__PURE__ */ new Date();
@@ -17575,7 +18202,7 @@ function buildCalendarInto(root, year, month, cfg) {
17575
18202
  toolbar.append(el("span", { class: "rui-gcal-title" }, [`${MONTH_NAMES[month]} ${year}`]));
17576
18203
  const grid = el("div", { class: "rui-gcal-grid", role: "grid" });
17577
18204
  for (let i = 0; i < 7; i += 1) {
17578
- grid.append(el("div", { class: "rui-gcal-weekday", role: "columnheader" }, [WEEKDAY_LABELS[(cfg.firstDay + i) % 7]]));
18205
+ grid.append(el("div", { class: "rui-gcal-weekday", role: "columnheader" }, [WEEKDAY_LABELS[(cfg2.firstDay + i) % 7]]));
17579
18206
  }
17580
18207
  grid.onkeydown = (event) => {
17581
18208
  const key = event.key;
@@ -17598,7 +18225,7 @@ function buildCalendarInto(root, year, month, cfg) {
17598
18225
  };
17599
18226
  const firstOfMonth = new Date(year, month, 1);
17600
18227
  const daysInMonth = new Date(year, month + 1, 0).getDate();
17601
- const lead = (firstOfMonth.getDay() - cfg.firstDay + 7) % 7;
18228
+ const lead = (firstOfMonth.getDay() - cfg2.firstDay + 7) % 7;
17602
18229
  const totalCells = Math.ceil((lead + daysInMonth) / 7) * 7;
17603
18230
  const start = new Date(year, month, 1 - lead);
17604
18231
  for (let i = 0; i < totalCells; i += 1) {
@@ -17610,16 +18237,16 @@ function buildCalendarInto(root, year, month, cfg) {
17610
18237
  class: "rui-gcal-day",
17611
18238
  role: "gridcell",
17612
18239
  "data-in-month": inMonth ? "true" : "false",
17613
- "data-today": iso === cfg.todayIso ? "true" : null,
17614
- "data-selected": cfg.selected && iso === cfg.selected ? "true" : null,
18240
+ "data-today": iso === cfg2.todayIso ? "true" : null,
18241
+ "data-selected": cfg2.selected && iso === cfg2.selected ? "true" : null,
17615
18242
  "data-iso": iso,
17616
18243
  // Human-readable for screen readers ("June 10, 2026", not the ISO).
17617
18244
  "aria-label": `${MONTH_NAMES[date.getMonth()]} ${date.getDate()}, ${date.getFullYear()}`,
17618
- "aria-pressed": cfg.selected && iso === cfg.selected ? "true" : "false"
18245
+ "aria-pressed": cfg2.selected && iso === cfg2.selected ? "true" : "false"
17619
18246
  });
17620
18247
  cell.append(el("span", { class: "rui-gcal-daynum" }, [String(date.getDate())]));
17621
- const chipEvents = cfg.chips.get(iso) ?? [];
17622
- const dotCount = cfg.dots.get(iso) ?? 0;
18248
+ const chipEvents = cfg2.chips.get(iso) ?? [];
18249
+ const dotCount = cfg2.dots.get(iso) ?? 0;
17623
18250
  if (chipEvents.length > 0 || dotCount > 0) {
17624
18251
  const eventsEl = el("div", { class: "rui-gcal-events" });
17625
18252
  const visible = chipEvents.slice(0, 2);
@@ -17649,8 +18276,8 @@ function buildCalendarInto(root, year, month, cfg) {
17649
18276
  const liveCell = origin?.closest?.(".rui-gcal-day");
17650
18277
  liveCell?.setAttribute("data-selected", "true");
17651
18278
  liveCell?.setAttribute("aria-pressed", "true");
17652
- if (cfg.selRef) cfg.helpers.setState(cfg.selRef, iso);
17653
- cfg.helpers.invoke(cfg.onSelect, iso);
18279
+ if (cfg2.selRef) cfg2.helpers.setState(cfg2.selRef, iso);
18280
+ cfg2.helpers.invoke(cfg2.onSelect, iso);
17654
18281
  };
17655
18282
  grid.append(cell);
17656
18283
  }
@@ -17681,7 +18308,7 @@ const Calendar = {
17681
18308
  const view = followProps ? { propsYear, propsMonth, year: propsYear, month: propsMonth } : stored;
17682
18309
  viewSlot.set(view);
17683
18310
  const { chips, dots } = readGcalEvents(props.events);
17684
- const cfg = {
18311
+ const cfg2 = {
17685
18312
  todayIso: isoOf(now.getFullYear(), now.getMonth(), now.getDate()),
17686
18313
  selected: asString(props.selected),
17687
18314
  chips,
@@ -17695,7 +18322,7 @@ const Calendar = {
17695
18322
  viewSlot
17696
18323
  };
17697
18324
  const root = el("div", { class: "rui-gcal" });
17698
- buildCalendarInto(root, view.year, view.month, cfg);
18325
+ buildCalendarInto(root, view.year, view.month, cfg2);
17699
18326
  return root;
17700
18327
  }
17701
18328
  };
@@ -18709,7 +19336,10 @@ const components = [
18709
19336
  SignaturePad,
18710
19337
  // Escape hatches for raw HTML / CSS — last-resort primitives
18711
19338
  HTMLTag,
18712
- Styles
19339
+ Styles,
19340
+ // Imperative / third-party widget interop
19341
+ Mount,
19342
+ WebComponent
18713
19343
  ];
18714
19344
  const componentGroups = [
18715
19345
  {
@@ -19106,6 +19736,16 @@ const componentGroups = [
19106
19736
  "- `Link(label_or_child, { to?, href?, external?, variant? })` is the anchor primitive — accepts either a plain string label or a wrapped component. Use `to` for client-side router navigation and `href` (with `external: true`) for outbound links."
19107
19737
  ]
19108
19738
  },
19739
+ {
19740
+ name: "Interop",
19741
+ components: ["Mount", "WebComponent"],
19742
+ notes: [
19743
+ "- Interop primitives are the bridge to imperative / third-party libraries that own their own DOM. Reach for them ONLY when a real widget (chart, map, editor, payment element, captcha) cannot be expressed with built-in components.",
19744
+ '- `Mount({ setup, update?, cleanup?, props?, tag?, sx? })` is the managed imperative-component host. `setup(node, props)` runs once after the host attaches and returns an instance handle; `update(instance, props)` runs when the (shallow-compared) `props` bag changes; `cleanup(instance)` runs on unmount. Aktion owns + preserves the host element so the widget is never rebuilt mid-session. Example: `Mount({ sx: { h: "320px" }, setup: (node, p) => new Chart(node, p.config), update: (c, p) => { c.data = p.data; c.update() }, cleanup: c => c.destroy(), props: { config: $cfg, data: $series } })`.',
19745
+ '- `WebComponent(tag, { attributes?, properties?, on?, children? })` renders + hydrates a native custom element. `attributes` is reactive (re-applies on `$state` change); `properties` assigns rich JS props; `on` binds event listeners that stay current across renders. Example: `WebComponent("stripe-pricing-table", { attributes: { "pricing-table-id": $id, "publishable-key": $pk }, on: { checkout: e => route.navigate("/thanks") } })`.',
19746
+ "- Pair these with the `$script({ src, global? })` loader (gate a widget on its SDK being ready) and the `$dom` observer namespace (`$dom.onResize`/`onIntersect`/`measure`) for layout-aware widgets."
19747
+ ]
19748
+ },
19109
19749
  {
19110
19750
  name: "Escape hatches",
19111
19751
  components: ["HTMLTag", "Styles"],
@@ -19122,14 +19762,14 @@ const defaultLibrary = {
19122
19762
  components,
19123
19763
  componentGroups
19124
19764
  };
19125
- const projectParam = (prop) => {
19765
+ const projectParam = (prop2) => {
19126
19766
  const param = {
19127
- name: prop.name,
19128
- type: prop.type,
19129
- required: !prop.optional
19767
+ name: prop2.name,
19768
+ type: prop2.type,
19769
+ required: !prop2.optional
19130
19770
  };
19131
- if (prop.description) param.description = prop.description;
19132
- if (prop.enum && prop.enum.length > 0) param.enumValues = prop.enum;
19771
+ if (prop2.description) param.description = prop2.description;
19772
+ if (prop2.enum && prop2.enum.length > 0) param.enumValues = prop2.enum;
19133
19773
  return param;
19134
19774
  };
19135
19775
  const buildSignature = (spec) => {
@@ -19168,7 +19808,7 @@ function getSignatureHelp(source, position, library = defaultLibrary) {
19168
19808
  const activeParameter2 = resolveActiveSlot(call, spec, signature2.parameters.length);
19169
19809
  return { signatures: [signature2], activeSignature: 0, activeParameter: activeParameter2 };
19170
19810
  }
19171
- const signature = builtinSignature(call.callee) ?? userSignature(call.callee, source);
19811
+ const signature = builtinSignature(call.callee) ?? memberCallSignature(call.callee, source) ?? userSignature(call.callee, source);
19172
19812
  if (!signature) return null;
19173
19813
  const activeParameter = resolveDeclaredParam(call, signature.parameters.map((p) => p.label));
19174
19814
  return { signatures: [signature], activeSignature: 0, activeParameter };
@@ -19232,6 +19872,37 @@ function builtinSignature(callee) {
19232
19872
  if (!builtin) return null;
19233
19873
  return { label: builtin.signature, documentation: builtin.summary, parameters: [] };
19234
19874
  }
19875
+ function memberCallSignature(callee, source) {
19876
+ const dot = callee.indexOf(".");
19877
+ if (dot < 0) return null;
19878
+ const root = callee.slice(0, dot);
19879
+ const memberPath = callee.slice(dot + 1);
19880
+ let member;
19881
+ if (root.startsWith("$") && isNamespaceName(root.slice(1))) {
19882
+ member = findNamespaceMember(root.slice(1), memberPath);
19883
+ } else if (root === "route" && !memberPath.includes(".")) {
19884
+ member = routeMembers.find((m) => m.name === memberPath);
19885
+ } else if (!memberPath.includes(".")) {
19886
+ const factory = factoryBindingFor$1(source, root);
19887
+ if (factory) member = findFactoryResource(factory)?.members.find((m) => m.name === memberPath);
19888
+ }
19889
+ if (!member) return null;
19890
+ return memberToSignature(callee, member);
19891
+ }
19892
+ function memberToSignature(callee, member) {
19893
+ const open = member.signature.indexOf("(");
19894
+ const close = member.signature.lastIndexOf(")");
19895
+ const params = open >= 0 && close > open ? member.signature.slice(open + 1, close).split(",").map((p) => p.trim()).filter((p) => p.length > 0).map((p) => ({ label: p })) : [];
19896
+ return { label: `${callee}${member.signature.slice(open >= 0 ? open : member.signature.length)}`, documentation: member.summary, parameters: params };
19897
+ }
19898
+ const FACTORY_ALTERNATION$1 = [...factoryResourceNames].join("|");
19899
+ function factoryBindingFor$1(source, receiver) {
19900
+ if (!FACTORY_ALTERNATION$1) return void 0;
19901
+ const lhs = receiver.replace(/\$/g, "\\$");
19902
+ const re = new RegExp(`(?:^|[^\\w$.])${lhs}\\s*=\\s*(?:await\\s+)?\\$(${FACTORY_ALTERNATION$1})\\s*\\(`);
19903
+ const match = re.exec(source);
19904
+ return match ? match[1] : void 0;
19905
+ }
19235
19906
  function userSignature(callee, source) {
19236
19907
  let program;
19237
19908
  try {
@@ -19391,7 +20062,7 @@ function identifierBefore$1(source, parenIndex) {
19391
20062
  let end = parenIndex;
19392
20063
  while (end > 0 && /\s/.test(source[end - 1])) end -= 1;
19393
20064
  let start = end;
19394
- while (start > 0 && /[\w$]/.test(source[start - 1])) start -= 1;
20065
+ while (start > 0 && /[\w$.]/.test(source[start - 1])) start -= 1;
19395
20066
  return source.slice(start, end);
19396
20067
  }
19397
20068
  function lineColumnToOffset$1(source, pos) {
@@ -19457,6 +20128,11 @@ function getCompletions(source, position, library) {
19457
20128
  }))
19458
20129
  ];
19459
20130
  }
20131
+ const member = analyseMemberAccess(source, position);
20132
+ if (member) {
20133
+ const items = memberCompletionsFor(member.objectExpr, source);
20134
+ if (items) return items;
20135
+ }
19460
20136
  const general = generalCompletions(library, user);
19461
20137
  const call = analyseCallContext(source, position);
19462
20138
  if (ctx.objectCallee) {
@@ -19465,6 +20141,10 @@ function getCompletions(source, position, library) {
19465
20141
  const isNamedBag = !call || call.objectArg === null || chooseNamedBagIndex(call.args, spec) === call.argIndex;
19466
20142
  if (isNamedBag) return [...propCompletions(spec), ...general];
19467
20143
  }
20144
+ if (ctx.objectCallee.startsWith("$")) {
20145
+ const config = findBuiltinConfig(ctx.objectCallee.slice(1));
20146
+ if (config) return [...configKeyCompletions(config, ctx.objectCallee), ...general];
20147
+ }
19468
20148
  return general;
19469
20149
  }
19470
20150
  if (call?.callee && call.objectArg === null) {
@@ -19554,9 +20234,129 @@ function collectUserSymbols(source) {
19554
20234
  }
19555
20235
  return { atoms: [...atoms], components: [...components2], actions: [...actions] };
19556
20236
  }
20237
+ const MEMBER_ACCESS_RE = /(\$?[A-Za-z_]\w*(?:\.[A-Za-z_]\w*)*)\.([A-Za-z_]\w*)?$/;
20238
+ function analyseMemberAccess(source, position) {
20239
+ const prefix = source.slice(0, lineColumnToOffset(source, position));
20240
+ const match = MEMBER_ACCESS_RE.exec(prefix);
20241
+ if (!match) return null;
20242
+ return { objectExpr: match[1], typing: match[2] ?? "" };
20243
+ }
20244
+ function memberKind(m) {
20245
+ return m.kind === "method" ? "builtin" : "prop";
20246
+ }
20247
+ function toMemberCompletion(m, detail) {
20248
+ return {
20249
+ label: m.name,
20250
+ kind: memberKind(m),
20251
+ detail: `${detail} · ${m.signature}`,
20252
+ documentation: m.summary
20253
+ };
20254
+ }
20255
+ function configKeyCompletions(keys, callee) {
20256
+ return keys.map((k) => ({
20257
+ label: k.name,
20258
+ kind: "prop",
20259
+ detail: `${callee} config · ${k.name}: ${k.type}`,
20260
+ documentation: k.summary
20261
+ }));
20262
+ }
20263
+ function memberCompletionsFor(objectExpr, source) {
20264
+ const segments = objectExpr.split(".");
20265
+ const root = segments[0];
20266
+ if (root.startsWith("$")) {
20267
+ const bare = root.slice(1);
20268
+ if (isNamespaceName(bare)) {
20269
+ const members = namespaceMembersAt(bare, segments.slice(1));
20270
+ if (members.length > 0) {
20271
+ return members.map((m) => toMemberCompletion(m, root));
20272
+ }
20273
+ return [];
20274
+ }
20275
+ }
20276
+ if (segments.length === 1) {
20277
+ if (root === "route") return routeMembers.map((m) => toMemberCompletion(m, "route"));
20278
+ const factory = factoryBindingFor(source, root);
20279
+ if (factory) {
20280
+ const entry = findFactoryResource(factory);
20281
+ if (entry) return entry.members.map((m) => toMemberCompletion(m, root));
20282
+ }
20283
+ }
20284
+ return null;
20285
+ }
20286
+ const FACTORY_ALTERNATION = [...factoryResourceNames].join("|");
20287
+ function factoryBindingFor(source, receiver) {
20288
+ if (!FACTORY_ALTERNATION) return void 0;
20289
+ const lhs = receiver.replace(/\$/g, "\\$");
20290
+ const re = new RegExp(`(?:^|[^\\w$.])${lhs}\\s*=\\s*(?:await\\s+)?\\$(${FACTORY_ALTERNATION})\\s*\\(`);
20291
+ const match = re.exec(source);
20292
+ return match ? match[1] : void 0;
20293
+ }
20294
+ function memberHoverAt(source, position, word) {
20295
+ const offset = lineColumnToOffset(source, position);
20296
+ let end = offset;
20297
+ while (end < source.length && /[\w$]/.test(source[end])) end += 1;
20298
+ const prefix = source.slice(0, end);
20299
+ const match = MEMBER_ACCESS_RE.exec(prefix);
20300
+ if (!match || (match[2] ?? "") !== word) return null;
20301
+ const objectExpr = match[1];
20302
+ const segments = objectExpr.split(".");
20303
+ const root = segments[0];
20304
+ if (root.startsWith("$")) {
20305
+ const bare = root.slice(1);
20306
+ if (isNamespaceName(bare)) {
20307
+ const path = [...segments.slice(1), word].join(".");
20308
+ const m = findNamespaceMember(bare, path);
20309
+ if (m) return memberHover(`${root}.${path}`, m);
20310
+ return null;
20311
+ }
20312
+ const factory = factoryBindingFor(source, root);
20313
+ if (factory && segments.length === 1) {
20314
+ const entry = findFactoryResource(factory);
20315
+ const m = entry?.members.find((x) => x.name === word);
20316
+ if (m) return memberHover(`${root}.${word}`, m);
20317
+ }
20318
+ return null;
20319
+ }
20320
+ if (segments.length === 1) {
20321
+ if (root === "route") {
20322
+ const m = routeMembers.find((x) => x.name === word);
20323
+ if (m) return memberHover(`route.${word}`, m);
20324
+ }
20325
+ const factory = factoryBindingFor(source, root);
20326
+ if (factory) {
20327
+ const entry = findFactoryResource(factory);
20328
+ const m = entry?.members.find((x) => x.name === word);
20329
+ if (m) return memberHover(`${root}.${word}`, m);
20330
+ }
20331
+ }
20332
+ return null;
20333
+ }
20334
+ function memberHover(qualified, m) {
20335
+ return {
20336
+ kind: m.kind === "method" ? "builtin" : "prop",
20337
+ contents: `**${qualified}** — ${m.summary}
20338
+
20339
+ Signature: \`${m.signature}\``
20340
+ };
20341
+ }
20342
+ function configKeyHoverAt(source, position, word) {
20343
+ const ctx = analyseCursor(source, position);
20344
+ if (!ctx.objectCallee || !ctx.objectCallee.startsWith("$")) return null;
20345
+ const keys = findBuiltinConfig(ctx.objectCallee.slice(1));
20346
+ const key = keys?.find((k) => k.name === word);
20347
+ if (!key) return null;
20348
+ return {
20349
+ kind: "prop",
20350
+ contents: `**${ctx.objectCallee} config · ${key.name}** — ${key.summary}
20351
+
20352
+ Type: \`${key.type}\``
20353
+ };
20354
+ }
19557
20355
  function getHoverInfo(source, position, library) {
19558
20356
  const word = wordAt(source, position);
19559
20357
  if (!word) return null;
20358
+ const memberHover2 = memberHoverAt(source, position, word);
20359
+ if (memberHover2) return memberHover2;
19560
20360
  const spec = findComponent(library, word);
19561
20361
  if (spec) {
19562
20362
  return {
@@ -19566,6 +20366,8 @@ function getHoverInfo(source, position, library) {
19566
20366
  Signature: \`${signaturePreview(spec)}\``
19567
20367
  };
19568
20368
  }
20369
+ const configHover = configKeyHoverAt(source, position, word);
20370
+ if (configHover) return configHover;
19569
20371
  if (word.startsWith("$")) {
19570
20372
  const builtin = findBuiltin(word.slice(1));
19571
20373
  if (builtin) {
@@ -19665,20 +20467,20 @@ function identifierBefore(source, openIndex) {
19665
20467
  }
19666
20468
  function propCompletions(spec) {
19667
20469
  const positional = findPositionalProp(spec);
19668
- return spec.props.map((prop) => ({
19669
- label: `${prop.name}:`,
20470
+ return spec.props.map((prop2) => ({
20471
+ label: `${prop2.name}:`,
19670
20472
  kind: "prop",
19671
- detail: propDetail(prop, positional?.name === prop.name),
19672
- documentation: prop.description
20473
+ detail: propDetail(prop2, positional?.name === prop2.name),
20474
+ documentation: prop2.description
19673
20475
  }));
19674
20476
  }
19675
- function propDetail(prop, isPositional) {
20477
+ function propDetail(prop2, isPositional) {
19676
20478
  const tags = [];
19677
20479
  if (isPositional) tags.push("positional");
19678
- if (prop.required) tags.push("required");
19679
- if (prop.enum) tags.push(`enum: ${prop.enum.map((e) => `"${e}"`).join(" | ")}`);
20480
+ if (prop2.required) tags.push("required");
20481
+ if (prop2.enum) tags.push(`enum: ${prop2.enum.map((e) => `"${e}"`).join(" | ")}`);
19680
20482
  const tagText = tags.length > 0 ? ` (${tags.join(", ")})` : "";
19681
- return `${prop.type}${tagText}`;
20483
+ return `${prop2.type}${tagText}`;
19682
20484
  }
19683
20485
  function signaturePreview(spec) {
19684
20486
  const positional = findPositionalProp(spec);
@@ -20007,28 +20809,148 @@ function getSemanticTokens(source, library = defaultLibrary) {
20007
20809
  const userActions = /* @__PURE__ */ new Set();
20008
20810
  const hooks = /* @__PURE__ */ new Set();
20009
20811
  collectUserDeclarations(tokens, userComponents, userActions, hooks);
20812
+ const factories = collectFactoryBindings(tokens);
20010
20813
  const out = [];
20011
20814
  let prev;
20012
- for (const t of tokens) {
20013
- const classified = classify(t, prev, {
20014
- components: components2,
20015
- userComponents,
20016
- userActions,
20017
- hooks
20815
+ let chain = null;
20816
+ let dotPending = false;
20817
+ const brackets = [];
20818
+ const emit = (t, c) => {
20819
+ out.push({
20820
+ line: t.line,
20821
+ column: t.column,
20822
+ length: tokenLength(t),
20823
+ tokenType: c.type,
20824
+ tokenModifiers: c.modifiers
20018
20825
  });
20019
- if (classified) {
20020
- out.push({
20021
- line: t.line,
20022
- column: t.column,
20023
- length: tokenLength(t),
20024
- tokenType: classified.type,
20025
- tokenModifiers: classified.modifiers
20026
- });
20826
+ };
20827
+ for (let i = 0; i < tokens.length; i += 1) {
20828
+ const t = tokens[i];
20829
+ if (t.type === "Newline") continue;
20830
+ if (t.type === "Punctuation" && (t.value === "(" || t.value === "[" || t.value === "{")) {
20831
+ brackets.push({ bracket: t.value, isObject: t.value === "{" && isValuePosition(prev) });
20832
+ } else if (t.type === "Punctuation" && (t.value === ")" || t.value === "]" || t.value === "}")) {
20833
+ brackets.pop();
20834
+ }
20835
+ if (isMemberAccess(t)) {
20836
+ dotPending = chain !== null;
20837
+ prev = t;
20838
+ continue;
20839
+ }
20840
+ if (dotPending && chain && t.type === "Identifier") {
20841
+ const resolved = resolveMember(chain, t.value);
20842
+ emit(t, resolved.token);
20843
+ chain = resolved.next;
20844
+ dotPending = false;
20845
+ prev = t;
20846
+ continue;
20027
20847
  }
20028
- if (t.type !== "Newline") prev = t;
20848
+ dotPending = false;
20849
+ if (t.type === "Identifier" && brackets[brackets.length - 1]?.isObject && isEntryStart(prev) && nextMeaningful(tokens, i + 1)?.value === ":") {
20850
+ emit(t, { type: "property", modifiers: [] });
20851
+ chain = null;
20852
+ prev = t;
20853
+ continue;
20854
+ }
20855
+ const classified = classify(t, prev, { components: components2, userComponents, userActions, hooks });
20856
+ if (classified) emit(t, classified);
20857
+ chain = chainRootFor(t, factories);
20858
+ prev = t;
20029
20859
  }
20030
20860
  return out;
20031
20861
  }
20862
+ function isValuePosition(prev) {
20863
+ if (!prev) return false;
20864
+ if (prev.type === "Operator") return true;
20865
+ if (prev.type === "Keyword") return prev.value === "return";
20866
+ if (prev.type === "Punctuation") {
20867
+ return prev.value === "(" || prev.value === "[" || prev.value === "," || prev.value === ":" || prev.value === "?";
20868
+ }
20869
+ return false;
20870
+ }
20871
+ function isEntryStart(prev) {
20872
+ return Boolean(prev && prev.type === "Punctuation" && (prev.value === "{" || prev.value === ","));
20873
+ }
20874
+ function chainRootFor(t, factories) {
20875
+ if (t.type === "StateIdentifier") {
20876
+ if (isNamespaceName(t.value)) return { kind: "namespace", ns: t.value, path: [] };
20877
+ const factory = factories.state.get(t.value);
20878
+ if (factory) {
20879
+ const entry = findFactoryResource(factory);
20880
+ if (entry) return { kind: "factory", members: entry.members };
20881
+ }
20882
+ return null;
20883
+ }
20884
+ if (t.type === "Identifier") {
20885
+ if (t.value === "route") return { kind: "route" };
20886
+ const factory = factories.ident.get(t.value);
20887
+ if (factory) {
20888
+ const entry = findFactoryResource(factory);
20889
+ if (entry) return { kind: "factory", members: entry.members };
20890
+ }
20891
+ }
20892
+ return null;
20893
+ }
20894
+ function resolveMember(chain, name) {
20895
+ const asProperty = { type: "property", modifiers: [] };
20896
+ if (!chain) return { token: asProperty, next: null };
20897
+ if (chain.kind === "namespace") {
20898
+ const ns = findNamespace(chain.ns);
20899
+ const path = [...chain.path, name].join(".");
20900
+ const member2 = ns?.members.find((m) => m.name === path);
20901
+ if (member2) {
20902
+ if (member2.kind === "namespace") {
20903
+ return {
20904
+ token: { type: "namespace", modifiers: ["defaultLibrary"] },
20905
+ next: { kind: "namespace", ns: chain.ns, path: [...chain.path, name] }
20906
+ };
20907
+ }
20908
+ return {
20909
+ token: {
20910
+ type: member2.kind === "method" ? "function" : "property",
20911
+ modifiers: ["defaultLibrary"]
20912
+ },
20913
+ next: null
20914
+ };
20915
+ }
20916
+ return { token: asProperty, next: null };
20917
+ }
20918
+ const members = chain.kind === "factory" ? chain.members : routeMembers;
20919
+ const member = members.find((m) => m.name === name);
20920
+ if (member) {
20921
+ return {
20922
+ token: { type: member.kind === "method" ? "function" : "property", modifiers: [] },
20923
+ next: null
20924
+ };
20925
+ }
20926
+ return { token: asProperty, next: null };
20927
+ }
20928
+ function collectFactoryBindings(tokens) {
20929
+ const state = /* @__PURE__ */ new Map();
20930
+ const ident = /* @__PURE__ */ new Map();
20931
+ for (let i = 0; i < tokens.length; i += 1) {
20932
+ const t = tokens[i];
20933
+ if (!(t.type === "Operator" && t.value === "=")) continue;
20934
+ const receiver = prevMeaningful(tokens, i - 1);
20935
+ if (!receiver) continue;
20936
+ let j = i + 1;
20937
+ let rhs = nextMeaningful(tokens, j);
20938
+ if (rhs && rhs.type === "Keyword" && rhs.value === "await") {
20939
+ j = tokens.indexOf(rhs) + 1;
20940
+ rhs = nextMeaningful(tokens, j);
20941
+ }
20942
+ if (!rhs || rhs.type !== "StateIdentifier" || !factoryResourceNames.has(rhs.value)) continue;
20943
+ if (receiver.type === "StateIdentifier") state.set(receiver.value, rhs.value);
20944
+ else if (receiver.type === "Identifier") ident.set(receiver.value, rhs.value);
20945
+ }
20946
+ return { state, ident };
20947
+ }
20948
+ function prevMeaningful(tokens, from) {
20949
+ for (let i = from; i >= 0; i -= 1) {
20950
+ if (tokens[i].type !== "Newline") return tokens[i];
20951
+ }
20952
+ return void 0;
20953
+ }
20032
20954
  function classify(t, prev, scope) {
20033
20955
  if (t.type === "Keyword") return { type: "keyword", modifiers: [] };
20034
20956
  if (t.type === "Number") return { type: "number", modifiers: [] };
@@ -21085,13 +22007,13 @@ ${printStatement({ kind: "ExpressionStatement", expression: { kind: "Identifier"
21085
22007
  ${body}
21086
22008
  ${INDENT.repeat(indent + 1)}break`;
21087
22009
  }
21088
- function printObjectProp(prop, indent) {
21089
- if (prop.spread) return `...${printExpression(prop.value, indent)}`;
21090
- const value = printExpression(prop.value, indent);
21091
- if (prop.value.kind === "Identifier" && prop.value.name === prop.key && SAFE_IDENT.test(prop.key)) {
21092
- return prop.key;
22010
+ function printObjectProp(prop2, indent) {
22011
+ if (prop2.spread) return `...${printExpression(prop2.value, indent)}`;
22012
+ const value = printExpression(prop2.value, indent);
22013
+ if (prop2.value.kind === "Identifier" && prop2.value.name === prop2.key && SAFE_IDENT.test(prop2.key)) {
22014
+ return prop2.key;
21093
22015
  }
21094
- const key = SAFE_IDENT.test(prop.key) ? prop.key : printStringLiteral(prop.key);
22016
+ const key = SAFE_IDENT.test(prop2.key) ? prop2.key : printStringLiteral(prop2.key);
21095
22017
  return `${key}: ${value}`;
21096
22018
  }
21097
22019
  function printLiteral(value) {
@@ -21122,8 +22044,14 @@ function printTemplate(quasis, expressions, indent) {
21122
22044
  export {
21123
22045
  builtinCatalog,
21124
22046
  defaultLibrary,
22047
+ factoryResourceCatalog,
22048
+ factoryResourceNames,
21125
22049
  findBuiltin,
22050
+ findBuiltinConfig,
21126
22051
  findDeclaration,
22052
+ findFactoryResource,
22053
+ findNamespace,
22054
+ findNamespaceMember,
21127
22055
  formatProgram,
21128
22056
  getCompletions,
21129
22057
  getComponentCatalog,
@@ -21140,8 +22068,13 @@ export {
21140
22068
  getSignatureHelp,
21141
22069
  getSnippets,
21142
22070
  grammarSpec,
22071
+ i18nResultMembers,
21143
22072
  isBuiltinName,
22073
+ isNamespaceName,
21144
22074
  keywordDocs,
22075
+ namespaceCatalog,
22076
+ namespaceMembersAt,
22077
+ routeMembers,
21145
22078
  semanticTokenModifiers,
21146
22079
  semanticTokenTypes
21147
22080
  };