slexkit 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/LICENSE +21 -21
  3. package/dist/ai/llms-authoring.txt +2 -0
  4. package/dist/ai/llms-capabilities.txt +126 -0
  5. package/dist/ai/llms-components.txt +27 -6
  6. package/dist/ai/llms-full.txt +1729 -4
  7. package/dist/ai/llms-runtime.txt +7 -1
  8. package/dist/ai/llms.txt +22 -1
  9. package/dist/ai/slexkit-ai-manifest.json +674 -23
  10. package/dist/base.css +359 -359
  11. package/dist/chunks/{accordion-cfjyxw93.js → button-53ccjq5p.js} +11 -11
  12. package/dist/chunks/{accordion-nw12ytps.js → button-cr1fhsa7.js} +48 -2
  13. package/dist/chunks/{accordion-5f0nvjjm.js → button-dsftwzvg.js} +4 -3
  14. package/dist/chunks/{accordion-hzyrngd6.js → button-faf563xf.js} +2 -2
  15. package/dist/chunks/{accordion-ehnhpeca.js → button-jxv4c65t.js} +2 -2
  16. package/dist/chunks/{accordion-cw5r75jm.js → button-xv2dz7vn.js} +1 -1
  17. package/dist/chunks/{accordion-830dw78f.js → button-z5yv24ks.js} +2 -2
  18. package/dist/components/accordion.js +2 -2
  19. package/dist/components/badge.js +2 -2
  20. package/dist/components/button.css +101 -101
  21. package/dist/components/button.js +3 -3
  22. package/dist/components/callout.js +4 -4
  23. package/dist/components/card.js +2 -2
  24. package/dist/components/checkbox.js +2 -2
  25. package/dist/components/choice.css +151 -151
  26. package/dist/components/code-block.js +2 -2
  27. package/dist/components/collapsible.js +2 -2
  28. package/dist/components/column.js +1 -1
  29. package/dist/components/content.css +273 -250
  30. package/dist/components/divider.js +2 -2
  31. package/dist/components/grid.js +1 -1
  32. package/dist/components/index.js +13945 -26
  33. package/dist/components/input.css +777 -777
  34. package/dist/components/input.js +8 -8
  35. package/dist/components/link.js +2 -2
  36. package/dist/components/progress.js +2 -2
  37. package/dist/components/radio-group.js +2 -2
  38. package/dist/components/row.js +1 -1
  39. package/dist/components/section.js +2 -2
  40. package/dist/components/select.css +178 -178
  41. package/dist/components/select.js +3 -3
  42. package/dist/components/slider.css +116 -116
  43. package/dist/components/slider.js +2 -2
  44. package/dist/components/specs.js +32 -0
  45. package/dist/components/stat.js +2 -2
  46. package/dist/components/submit.css +8 -8
  47. package/dist/components/submit.js +1 -1
  48. package/dist/components/switch.css +105 -105
  49. package/dist/components/switch.js +3 -3
  50. package/dist/components/table.js +4 -4
  51. package/dist/components/tabs.css +95 -95
  52. package/dist/components/tabs.js +4 -4
  53. package/dist/components/text-input.css +23 -23
  54. package/dist/components/text.js +1 -1
  55. package/dist/components/toast.js +4 -4
  56. package/dist/components/tooling.js +73 -8
  57. package/dist/runtime.cjs +1590 -14
  58. package/dist/runtime.js +1589 -13
  59. package/dist/slexkit.cjs +28254 -13848
  60. package/dist/slexkit.css +1538 -1515
  61. package/dist/slexkit.js +28253 -13847
  62. package/dist/tooling.js +117 -11
  63. package/dist/types/components/svelte/helpers.d.ts +8 -1
  64. package/dist/types/engine/capabilities.d.ts +54 -0
  65. package/dist/types/engine/index.d.ts +6 -0
  66. package/dist/types/engine/secure-runtime.d.ts +9 -1
  67. package/dist/types/engine/stdlib.d.ts +30 -0
  68. package/dist/types/engine/types.d.ts +1 -0
  69. package/dist/types/engine/validation.d.ts +28 -0
  70. package/dist/types/index.d.ts +6 -3
  71. package/dist/types/runtime.d.ts +6 -3
  72. package/dist/types/version.d.ts +2 -2
  73. package/dist/umd/slexkit.tooling.umd.js +45016 -44626
  74. package/dist/umd/slexkit.umd.js +28255 -13849
  75. package/package.json +3 -2
  76. package/src/components/svelte/content/Formula.svelte +27 -0
  77. package/src/components/svelte/content/Table.svelte +1 -1
  78. package/src/components/svelte/helpers.ts +56 -1
  79. package/src/components/svelte/input/Input.svelte +7 -7
  80. package/src/components/svelte/input/Select.svelte +2 -2
  81. package/src/components/svelte/input/Switch.svelte +1 -1
  82. package/src/components/svelte/input/Tabs.svelte +7 -7
  83. package/src/components/svelte/tooling/PlaygroundMarkdown.svelte +84 -2
  84. package/src/styles/components/button.css +101 -101
  85. package/src/styles/components/choice.css +152 -152
  86. package/src/styles/components/select.css +178 -178
  87. package/src/styles/components/slider.css +116 -116
  88. package/src/styles/components/submit.css +8 -8
  89. package/src/styles/components/switch.css +105 -105
  90. package/src/styles/components/tabs.css +95 -95
  91. package/src/styles/components/text-input.css +23 -23
  92. package/src/styles/content.css +274 -251
  93. package/src/styles/input.css +8 -8
  94. package/src/styles/layout.css +360 -360
package/dist/runtime.js CHANGED
@@ -513,6 +513,163 @@ function isEngineeringNumberResult(value) {
513
513
  return !!value && typeof value === "object" && "raw" in value && "number" in value && "valid" in value && "prefix" in value && "unit" in value && "normalized" in value;
514
514
  }
515
515
 
516
+ // src/engine/stdlib.ts
517
+ function toNumber(value) {
518
+ return Number(value);
519
+ }
520
+ function finiteNumber(value, fallback = 0) {
521
+ const parsed = toNumber(value);
522
+ return Number.isFinite(parsed) ? parsed : fallback;
523
+ }
524
+ function digits(value, fallback) {
525
+ const parsed = Math.trunc(finiteNumber(value, fallback));
526
+ return Math.max(0, Math.min(20, parsed));
527
+ }
528
+ function finiteValues(values) {
529
+ if (!Array.isArray(values))
530
+ return [];
531
+ return values.map(toNumber).filter(Number.isFinite);
532
+ }
533
+ function formatFixed(value, digitCount = 2) {
534
+ const parsed = toNumber(value);
535
+ return Number.isFinite(parsed) ? parsed.toFixed(digitCount) : "NaN";
536
+ }
537
+ function locale(value) {
538
+ return typeof value === "string" && value.trim() ? value : "en-US";
539
+ }
540
+ function currencyCode(value) {
541
+ return typeof value === "string" && /^[A-Za-z]{3}$/.test(value) ? value.toUpperCase() : "USD";
542
+ }
543
+ function formatNumber(value, digitCount, localeName, notation, style, currency, minimumFractionDigits = 0) {
544
+ const parsed = toNumber(value);
545
+ if (!Number.isFinite(parsed))
546
+ return "NaN";
547
+ return new Intl.NumberFormat(localeName, {
548
+ maximumFractionDigits: digitCount,
549
+ minimumFractionDigits,
550
+ notation,
551
+ style,
552
+ currency
553
+ }).format(parsed);
554
+ }
555
+ function freezeDeep(value) {
556
+ for (const child of Object.values(value)) {
557
+ if (child && typeof child === "object")
558
+ freezeDeep(child);
559
+ }
560
+ return Object.freeze(value);
561
+ }
562
+ var slexkitStd = freezeDeep({
563
+ math: {
564
+ clamp(value, min, max) {
565
+ const lower = finiteNumber(min);
566
+ const upper = finiteNumber(max);
567
+ const parsed = finiteNumber(value);
568
+ return Math.min(Math.max(parsed, Math.min(lower, upper)), Math.max(lower, upper));
569
+ },
570
+ round(value, digitValue = 0) {
571
+ const factor = 10 ** digits(digitValue, 0);
572
+ return Math.round(finiteNumber(value) * factor) / factor;
573
+ },
574
+ safeDivide(numerator, denominator, fallback = 0) {
575
+ const divisor = toNumber(denominator);
576
+ if (!Number.isFinite(divisor) || divisor === 0)
577
+ return finiteNumber(fallback);
578
+ const quotient = toNumber(numerator) / divisor;
579
+ return Number.isFinite(quotient) ? quotient : finiteNumber(fallback);
580
+ },
581
+ percent(part, total, digitValue = 1) {
582
+ const ratio = slexkitStd.math.safeDivide(part, total, NaN) * 100;
583
+ return slexkitStd.math.round(ratio, digitValue);
584
+ },
585
+ lerp(start, end, t) {
586
+ const a = finiteNumber(start);
587
+ return a + (finiteNumber(end) - a) * finiteNumber(t);
588
+ }
589
+ },
590
+ stats: {
591
+ sum(values) {
592
+ return finiteValues(values).reduce((total, value) => total + value, 0);
593
+ },
594
+ mean(values) {
595
+ const numbers = finiteValues(values);
596
+ return numbers.length ? slexkitStd.stats.sum(numbers) / numbers.length : NaN;
597
+ },
598
+ min(values) {
599
+ const numbers = finiteValues(values);
600
+ return numbers.length ? Math.min(...numbers) : NaN;
601
+ },
602
+ max(values) {
603
+ const numbers = finiteValues(values);
604
+ return numbers.length ? Math.max(...numbers) : NaN;
605
+ },
606
+ median(values) {
607
+ const numbers = finiteValues(values).sort((a, b) => a - b);
608
+ if (!numbers.length)
609
+ return NaN;
610
+ const middle = Math.floor(numbers.length / 2);
611
+ return numbers.length % 2 ? numbers[middle] : (numbers[middle - 1] + numbers[middle]) / 2;
612
+ }
613
+ },
614
+ format: {
615
+ fixed(value, digitValue = 2) {
616
+ return formatFixed(value, digits(digitValue, 2));
617
+ },
618
+ number(value, digitValue = 0, localeName = "en-US") {
619
+ return formatNumber(value, digits(digitValue, 0), locale(localeName));
620
+ },
621
+ compact(value, digitValue = 1, localeName = "en-US") {
622
+ return formatNumber(value, digits(digitValue, 1), locale(localeName), "compact");
623
+ },
624
+ percent(ratio, digitValue = 1) {
625
+ return `${formatFixed(finiteNumber(ratio) * 100, digits(digitValue, 1))}%`;
626
+ },
627
+ currency(value, currency = "USD", localeName = "en-US") {
628
+ return formatNumber(value, 2, locale(localeName), undefined, "currency", currencyCode(currency), 2);
629
+ }
630
+ },
631
+ units: {
632
+ withUnit(value, unit, digitValue = 2) {
633
+ const suffix = typeof unit === "string" ? unit : String(unit ?? "");
634
+ return `${formatFixed(value, digits(digitValue, 2))}${suffix ? ` ${suffix}` : ""}`;
635
+ },
636
+ bytes(value, digitValue = 1) {
637
+ const units = ["B", "KB", "MB", "GB", "TB", "PB"];
638
+ let amount = Math.abs(finiteNumber(value));
639
+ let index = 0;
640
+ while (amount >= 1024 && index < units.length - 1) {
641
+ amount /= 1024;
642
+ index += 1;
643
+ }
644
+ const sign = finiteNumber(value) < 0 ? -1 : 1;
645
+ return `${formatFixed(amount * sign, digits(digitValue, 1))} ${units[index]}`;
646
+ },
647
+ duration(ms, digitValue = 1) {
648
+ const value = finiteNumber(ms);
649
+ const abs = Math.abs(value);
650
+ if (abs < 1000)
651
+ return `${formatFixed(value, 0)} ms`;
652
+ if (abs < 60000)
653
+ return `${formatFixed(value / 1000, digits(digitValue, 1))} s`;
654
+ if (abs < 3600000)
655
+ return `${formatFixed(value / 60000, digits(digitValue, 1))} min`;
656
+ return `${formatFixed(value / 3600000, digits(digitValue, 1))} h`;
657
+ },
658
+ si(value, unit = "", digitValue = 2) {
659
+ const units = ["", "k", "M", "G", "T", "P"];
660
+ let amount = Math.abs(finiteNumber(value));
661
+ let index = 0;
662
+ while (amount >= 1000 && index < units.length - 1) {
663
+ amount /= 1000;
664
+ index += 1;
665
+ }
666
+ const sign = finiteNumber(value) < 0 ? -1 : 1;
667
+ const suffix = typeof unit === "string" ? unit : String(unit ?? "");
668
+ return `${formatFixed(amount * sign, digits(digitValue, 2))} ${units[index]}${suffix}`.trim();
669
+ }
670
+ }
671
+ });
672
+
516
673
  // src/engine/component-state.ts
517
674
  var IDENTIFIER = /^[A-Za-z_$][\w$]*$/;
518
675
  var componentStateProxies = new WeakMap;
@@ -743,6 +900,20 @@ function warnDuplicateState(ns, name, currentType, currentPath, previous) {
743
900
  console.warn(`[SlexKit][${ns}] Component state '${name}' is used by multiple component types (${previous.type}, ${currentType}); the latest rendered type controls write behavior.`);
744
901
  }
745
902
  }
903
+ function dynamicStateBinding(type, props) {
904
+ const mode = getComponentStateMode(type);
905
+ const value = mode === "checked" ? props.$checked ?? props.$value : mode === "enabled" ? props.$enabled : props.$value;
906
+ return typeof value === "string" ? value.trim() : undefined;
907
+ }
908
+ function isMirroredValueControlPair(previousType, currentType) {
909
+ return previousType === "input" && currentType === "slider" || previousType === "slider" && currentType === "input";
910
+ }
911
+ function shouldWarnDuplicateState(currentType, currentBinding, previous) {
912
+ if (currentBinding && previous.stateBinding === currentBinding && isMirroredValueControlPair(previous.type, currentType)) {
913
+ return false;
914
+ }
915
+ return true;
916
+ }
746
917
  function warnForState(ns, name, path) {
747
918
  console.warn(`[SlexKit][${ns}] Component state '${name}' is used with $for at ${path}; repeated items share one namespace-level instance state.`);
748
919
  }
@@ -756,11 +927,15 @@ function prepareComponentStatesInner(layout, components, componentTypes, ns, see
756
927
  const props = val;
757
928
  const path = parentPath ? `${parentPath}.${key}` : key;
758
929
  if (name && isStatefulComponent(type)) {
930
+ const stateBinding = dynamicStateBinding(type, props);
759
931
  const previous = seen.get(name);
760
- if (previous)
761
- warnDuplicateState(ns, name, type, path, previous);
762
- else
763
- seen.set(name, { type, path });
932
+ if (previous) {
933
+ if (shouldWarnDuplicateState(type, stateBinding, previous)) {
934
+ warnDuplicateState(ns, name, type, path, previous);
935
+ }
936
+ } else {
937
+ seen.set(name, { type, path, stateBinding });
938
+ }
764
939
  if (props.$for && isWritableComponent(type))
765
940
  warnForState(ns, name, path);
766
941
  const state = ensureComponentState(name, type, components, componentTypes);
@@ -773,9 +948,15 @@ function prepareComponentStates(layout, components, componentTypes, ns) {
773
948
  prepareComponentStatesInner(layout, components, componentTypes, ns, new Map);
774
949
  }
775
950
  function buildComponentEvalContext(g, components, componentTypes, api, forCtx) {
776
- const ctx = { g: createGProxy(g, components, componentTypes) };
951
+ const ctx = {
952
+ g: createGProxy(g, components, componentTypes),
953
+ std: slexkitStd
954
+ };
955
+ const gKeys = new Set(Object.keys(rawRecord(g)));
777
956
  for (const name of Object.keys(rawRecord(components))) {
778
- if (IDENTIFIER.test(name)) {
957
+ if (name === "std" || name === "g" || name === "api")
958
+ continue;
959
+ if (IDENTIFIER.test(name) && !gKeys.has(name)) {
779
960
  ctx[name] = publicComponentState(name, components[name], componentTypes);
780
961
  }
781
962
  }
@@ -783,6 +964,8 @@ function buildComponentEvalContext(g, components, componentTypes, api, forCtx) {
783
964
  ctx.api = api;
784
965
  if (forCtx) {
785
966
  for (const k of Object.keys(forCtx)) {
967
+ if (k === "std")
968
+ continue;
786
969
  Object.defineProperty(ctx, k, {
787
970
  get: () => {
788
971
  const current = forCtx[k];
@@ -953,6 +1136,7 @@ function renderIfNode(fullKey, props, container, g, components, componentTypes,
953
1136
  };
954
1137
  currentEl = renderWithFallback(renderer, innerProps, name, {
955
1138
  g,
1139
+ std: slexkitStd,
956
1140
  api,
957
1141
  dir: options.dir,
958
1142
  labels: options.labels,
@@ -1031,6 +1215,7 @@ function renderAndMountSlot(item, index, keyVal, indexSignal, revisionSignal, re
1031
1215
  };
1032
1216
  el = renderWithFallback(renderer, innerProps, name, {
1033
1217
  g,
1218
+ std: slexkitStd,
1034
1219
  api,
1035
1220
  dir: options.dir,
1036
1221
  labels: options.labels,
@@ -1180,6 +1365,7 @@ function renderNormalNode(fullKey, props, container, g, components, componentTyp
1180
1365
  };
1181
1366
  const el = renderWithFallback(renderer, nodeProps, name, {
1182
1367
  g,
1368
+ std: slexkitStd,
1183
1369
  api,
1184
1370
  dir: options.dir,
1185
1371
  labels: options.labels,
@@ -1533,7 +1719,7 @@ ${parseSource}
1533
1719
  var parseSlexKitDsl = parseSlexSource;
1534
1720
 
1535
1721
  // src/version.ts
1536
- var SLEXKIT_VERSION = "0.2.0";
1722
+ var SLEXKIT_VERSION = "0.3.0";
1537
1723
  var SLEX_PROTOCOL_VERSION = "0.1";
1538
1724
  var SLEXKIT_COMPONENTS_VERSION = SLEXKIT_VERSION;
1539
1725
  function getSlexKitInfo() {
@@ -1573,6 +1759,9 @@ function currentOrigin() {
1573
1759
  return "http://localhost";
1574
1760
  }
1575
1761
  function resolveUrl(url) {
1762
+ try {
1763
+ return new URL(url);
1764
+ } catch {}
1576
1765
  try {
1577
1766
  return new URL(url, currentOrigin());
1578
1767
  } catch {
@@ -2133,6 +2322,1324 @@ function createSecureRuntime(policy, hostAdapter) {
2133
2322
  }
2134
2323
  };
2135
2324
  }
2325
+ // src/components/spec-helpers.ts
2326
+ var SINCE = "0.1.0";
2327
+ function docs(type) {
2328
+ return {
2329
+ href: `/docs/components/${type}`,
2330
+ anchors: {
2331
+ api: `${type}-api-reference`,
2332
+ examples: `${type}-canonical-example`
2333
+ }
2334
+ };
2335
+ }
2336
+ function isSlexExpression(value) {
2337
+ return typeof value.namespace === "string" && typeof value.layout === "object" && value.layout !== null;
2338
+ }
2339
+ function example(type, propsOrSource, title = "Basic usage") {
2340
+ return {
2341
+ id: "basic",
2342
+ title,
2343
+ source: isSlexExpression(propsOrSource) ? {
2344
+ slex: propsOrSource.slex ?? SLEX_PROTOCOL_VERSION,
2345
+ ...propsOrSource
2346
+ } : {
2347
+ slex: SLEX_PROTOCOL_VERSION,
2348
+ namespace: `spec_${type.replaceAll("-", "_")}_basic`,
2349
+ layout: {
2350
+ [`${type}:demo`]: propsOrSource
2351
+ }
2352
+ }
2353
+ };
2354
+ }
2355
+ var semanticTones = ["info", "success", "warning", "danger", "muted"];
2356
+ var inputState = ["input", "slider", "select", "tabs", "radio-group"];
2357
+ var checkedState = ["checkbox"];
2358
+ var enabledState = ["switch"];
2359
+ var readableState = ["stat", "text", "progress", "badge", "callout", "code-block", "divider", "link", "table", "section"];
2360
+ function stateFor(type) {
2361
+ if (inputState.includes(type))
2362
+ return "value";
2363
+ if (checkedState.includes(type))
2364
+ return "checked";
2365
+ if (enabledState.includes(type))
2366
+ return "enabled";
2367
+ if (readableState.includes(type))
2368
+ return "readable";
2369
+ return "none";
2370
+ }
2371
+ function component(spec) {
2372
+ return {
2373
+ status: "ready",
2374
+ since: SINCE,
2375
+ docs: docs(spec.type),
2376
+ state: spec.state ?? stateFor(spec.type),
2377
+ ...spec
2378
+ };
2379
+ }
2380
+ var childContent = {
2381
+ allowed: true,
2382
+ description: "Nested component fields are rendered as child content in field order."
2383
+ };
2384
+ var noChildren = {
2385
+ allowed: false,
2386
+ description: "This component does not render nested child components."
2387
+ };
2388
+
2389
+ // src/components/entries/accordion.spec.ts
2390
+ var accordionSpec = component({
2391
+ type: "accordion",
2392
+ category: "Disclosure",
2393
+ title: "Accordion",
2394
+ summary: "Expandable grouped panels.",
2395
+ description: "Use accordion to reveal one or more sections from a compact list of panels.",
2396
+ props: {
2397
+ value: { type: "string | string[]", dynamic: true, description: "Current expanded item value; use an array when multiple is true." },
2398
+ multiple: { type: "boolean", default: false, description: "Allow multiple items to be expanded at the same time." },
2399
+ items: { type: "array", description: "Panel definitions with value, label, content, and optional icon." },
2400
+ "items[].icon": { type: "string", description: "Icon name shown before an item trigger label." },
2401
+ onchange: { type: "write-expression", description: "Write expression invoked when expanded items change." }
2402
+ },
2403
+ children: noChildren,
2404
+ examples: [example("accordion", {
2405
+ namespace: "doc_accordion_typical",
2406
+ layout: {
2407
+ "accordion:faq": {
2408
+ multiple: true,
2409
+ value: [
2410
+ "install"
2411
+ ],
2412
+ items: [
2413
+ {
2414
+ value: "install",
2415
+ label: "Install",
2416
+ icon: "download-simple",
2417
+ content: "Prepare dependencies."
2418
+ },
2419
+ {
2420
+ value: "review",
2421
+ label: "Review",
2422
+ icon: "check-circle",
2423
+ content: "Check the result."
2424
+ },
2425
+ {
2426
+ value: "ship",
2427
+ label: "Ship",
2428
+ icon: "rocket-launch",
2429
+ content: "Publish the change."
2430
+ }
2431
+ ]
2432
+ }
2433
+ }
2434
+ })]
2435
+ });
2436
+
2437
+ // src/components/entries/badge.spec.ts
2438
+ var badgeSpec = component({
2439
+ type: "badge",
2440
+ category: "Content",
2441
+ title: "Badge",
2442
+ summary: "Compact label for status or classification.",
2443
+ description: "Use badge to annotate nearby content with a short semantic label.",
2444
+ props: {
2445
+ label: { type: "string", dynamic: true, description: "Badge text." },
2446
+ text: { type: "string", dynamic: true, description: "Alias for label." },
2447
+ content: { type: "string", dynamic: true, description: "Alias for label." },
2448
+ icon: { type: "string", description: "Icon name shown before the badge label." },
2449
+ tone: { type: "string", values: semanticTones, default: "info", description: "Semantic tone applied to the badge." },
2450
+ variant: { type: "string", values: semanticTones, description: "Alias for tone." }
2451
+ },
2452
+ children: noChildren,
2453
+ examples: [example("badge", {
2454
+ namespace: "doc_badge_typical",
2455
+ layout: {
2456
+ "row:badges": {
2457
+ "badge:ready": {
2458
+ label: "ready",
2459
+ icon: "check-circle",
2460
+ tone: "success"
2461
+ },
2462
+ "badge:pending": {
2463
+ label: "pending",
2464
+ tone: "warning"
2465
+ },
2466
+ "badge:info": {
2467
+ label: "info",
2468
+ tone: "info"
2469
+ }
2470
+ }
2471
+ }
2472
+ })]
2473
+ });
2474
+
2475
+ // src/components/entries/button.spec.ts
2476
+ var buttonSpec = component({
2477
+ type: "button",
2478
+ category: "Action",
2479
+ title: "Button",
2480
+ summary: "Action trigger.",
2481
+ description: "Use button for explicit actions in interactive SlexKit layouts.",
2482
+ props: {
2483
+ label: { type: "string", dynamic: true, description: "Visible button text and accessible name." },
2484
+ icon: { type: "string", description: "Icon name shown before the label." },
2485
+ iconOnly: { type: "boolean", default: false, description: "Show only the icon while retaining label as the accessible name." },
2486
+ variant: { type: "string", values: ["primary", "secondary", "danger", "ghost"], default: "primary", description: "Semantic action variant." },
2487
+ disabled: { type: "boolean", default: false, dynamic: true, description: "Disable the action." },
2488
+ href: { type: "string", dynamic: true, description: "Render the button surface as a link to this URL." },
2489
+ target: { type: "string", description: "Link target used when href is present." },
2490
+ title: { type: "string", dynamic: true, description: "Tooltip and accessible-label fallback." },
2491
+ selected: { type: "boolean", dynamic: true, description: "Render the icon in its selected visual state." },
2492
+ active: { type: "boolean", dynamic: true, description: "Render the icon in its active visual state." },
2493
+ pressed: { type: "boolean", dynamic: true, description: "Expose pressed state and render the selected icon style." },
2494
+ onclick: { type: "write-expression", description: "Write expression invoked when the button is clicked." }
2495
+ },
2496
+ children: noChildren,
2497
+ examples: [example("button", {
2498
+ namespace: "doc_button_typical",
2499
+ layout: {
2500
+ "row:actions": {
2501
+ "button:save": {
2502
+ label: "Save",
2503
+ icon: "floppy-disk",
2504
+ variant: "primary"
2505
+ },
2506
+ "button:cancel": {
2507
+ label: "Cancel",
2508
+ variant: "secondary"
2509
+ },
2510
+ "button:delete": {
2511
+ label: "Delete",
2512
+ variant: "danger"
2513
+ }
2514
+ }
2515
+ }
2516
+ })]
2517
+ });
2518
+
2519
+ // src/components/entries/callout.spec.ts
2520
+ var calloutSpec = component({
2521
+ type: "callout",
2522
+ category: "Content",
2523
+ title: "Callout",
2524
+ summary: "Highlighted contextual message.",
2525
+ description: "Use callout for notes, warnings, and other contextual blocks.",
2526
+ props: {
2527
+ title: { type: "string", dynamic: true, description: "Callout title." },
2528
+ heading: { type: "string", dynamic: true, description: "Alias for title." },
2529
+ label: { type: "string", dynamic: true, description: "Alias for title." },
2530
+ icon: { type: "string", description: "Icon name shown before the title." },
2531
+ text: { type: "string", dynamic: true, description: "Callout body text." },
2532
+ message: { type: "string", dynamic: true, description: "Alias for text." },
2533
+ content: { type: "string", dynamic: true, description: "Alias for text." },
2534
+ tone: { type: "string", values: ["info", "success", "warning", "danger"], default: "info", description: "Semantic tone for the callout." }
2535
+ },
2536
+ children: childContent,
2537
+ examples: [example("callout", {
2538
+ namespace: "doc_callout_typical",
2539
+ layout: {
2540
+ "callout:notice": {
2541
+ tone: "info",
2542
+ title: "Notice",
2543
+ icon: "info",
2544
+ text: "Use callout for information that should stand out."
2545
+ }
2546
+ }
2547
+ })]
2548
+ });
2549
+
2550
+ // src/components/entries/card.spec.ts
2551
+ var cardSpec = component({
2552
+ type: "card",
2553
+ category: "Layout",
2554
+ title: "Card",
2555
+ summary: "Bordered grouping container.",
2556
+ description: "Use card to group related content on a bounded surface.",
2557
+ props: {
2558
+ title: { type: "string", dynamic: true, description: "Card title." },
2559
+ icon: { type: "string", description: "Icon name shown before the title." },
2560
+ tone: { type: "string", values: semanticTones, description: "Optional semantic tone for the card surface." }
2561
+ },
2562
+ children: childContent,
2563
+ examples: [example("card", {
2564
+ namespace: "doc_card_typical",
2565
+ layout: {
2566
+ "card:metrics": {
2567
+ title: "Metrics",
2568
+ icon: "chart-bar",
2569
+ "grid:items": {
2570
+ columns: 2,
2571
+ "stat:requests": {
2572
+ label: "Requests",
2573
+ value: "1.2k",
2574
+ unit: "/min"
2575
+ },
2576
+ "stat:latency": {
2577
+ label: "Latency",
2578
+ value: "42",
2579
+ unit: "ms"
2580
+ }
2581
+ }
2582
+ }
2583
+ }
2584
+ })]
2585
+ });
2586
+
2587
+ // src/components/entries/checkbox.spec.ts
2588
+ var checkboxSpec = component({
2589
+ type: "checkbox",
2590
+ category: "Input",
2591
+ title: "Checkbox",
2592
+ summary: "Boolean checkbox input.",
2593
+ description: "Use checkbox for binary choices that can be toggled independently.",
2594
+ props: {
2595
+ checked: { type: "boolean", default: false, dynamic: true, description: "Checked state." },
2596
+ label: { type: "string", dynamic: true, description: "Checkbox label." },
2597
+ icon: { type: "string", description: "Icon name shown before the visible label." },
2598
+ disabled: { type: "boolean", default: false, dynamic: true, description: "Disable the checkbox." },
2599
+ haptic: { type: "boolean", default: true, description: "Enable vibration feedback on supported devices." },
2600
+ haptics: { type: "boolean", default: true, description: "Alias for haptic." },
2601
+ onchange: { type: "write-expression", description: "Write expression invoked when checked state changes." }
2602
+ },
2603
+ children: noChildren,
2604
+ examples: [example("checkbox", {
2605
+ namespace: "doc_checkbox_typical",
2606
+ layout: {
2607
+ "checkbox:agree": {
2608
+ checked: true,
2609
+ label: "I agree",
2610
+ icon: "handshake"
2611
+ }
2612
+ }
2613
+ })]
2614
+ });
2615
+
2616
+ // src/components/entries/code-block.spec.ts
2617
+ var codeBlockSpec = component({
2618
+ type: "code-block",
2619
+ category: "Content",
2620
+ title: "Code Block",
2621
+ summary: "Formatted code or log block.",
2622
+ description: "Use code-block for static code samples, configuration snippets, and logs.",
2623
+ props: {
2624
+ code: { type: "string", dynamic: true, description: "Code text content." },
2625
+ source: { type: "string", dynamic: true, description: "Alias for code." },
2626
+ content: { type: "string", dynamic: true, description: "Alias for code." },
2627
+ language: { type: "string", description: "Language label." },
2628
+ title: { type: "string", description: "Code block title." },
2629
+ icon: { type: "string", description: "Icon name shown before the title." },
2630
+ lineNumbers: { type: "boolean", default: true, description: "Show line numbers." }
2631
+ },
2632
+ children: noChildren,
2633
+ examples: [example("code-block", {
2634
+ namespace: "doc_code_block_typical",
2635
+ layout: {
2636
+ "code-block:config": {
2637
+ title: "Config",
2638
+ icon: "code",
2639
+ language: "js",
2640
+ code: "export const enabled = true;"
2641
+ }
2642
+ }
2643
+ })]
2644
+ });
2645
+
2646
+ // src/components/entries/collapsible.spec.ts
2647
+ var collapsibleSpec = component({
2648
+ type: "collapsible",
2649
+ category: "Disclosure",
2650
+ title: "Collapsible",
2651
+ summary: "Single expandable region.",
2652
+ description: "Use collapsible to show or hide one related content region.",
2653
+ props: {
2654
+ open: { type: "boolean", default: false, dynamic: true, description: "Expanded state." },
2655
+ trigger: { type: "string", dynamic: true, description: "Trigger button text." },
2656
+ icon: { type: "string", description: "Icon name shown before trigger text." },
2657
+ content: { type: "string", dynamic: true, description: "Static body content." },
2658
+ onchange: { type: "write-expression", description: "Write expression invoked when open state changes." }
2659
+ },
2660
+ children: childContent,
2661
+ examples: [example("collapsible", {
2662
+ namespace: "doc_collapsible_typical",
2663
+ layout: {
2664
+ "collapsible:more": {
2665
+ open: true,
2666
+ trigger: "Details",
2667
+ icon: "caret-circle-down",
2668
+ content: "This secondary content can be collapsed."
2669
+ }
2670
+ }
2671
+ })]
2672
+ });
2673
+
2674
+ // src/components/entries/column.spec.ts
2675
+ var columnSpec = component({
2676
+ type: "column",
2677
+ category: "Layout",
2678
+ title: "Column",
2679
+ summary: "Vertical layout container.",
2680
+ description: "Use column to stack child components vertically in field order.",
2681
+ props: {},
2682
+ children: childContent,
2683
+ examples: [example("column", {
2684
+ namespace: "doc_column_typical",
2685
+ layout: {
2686
+ "column:form": {
2687
+ "input:name": {
2688
+ placeholder: "Name"
2689
+ },
2690
+ "input:email": {
2691
+ placeholder: "Email"
2692
+ },
2693
+ "button:save": {
2694
+ label: "Save"
2695
+ }
2696
+ }
2697
+ }
2698
+ })]
2699
+ });
2700
+
2701
+ // src/components/entries/divider.spec.ts
2702
+ var dividerSpec = component({
2703
+ type: "divider",
2704
+ category: "Content",
2705
+ title: "Divider",
2706
+ summary: "Visual separator.",
2707
+ description: "Use divider to separate related regions, optionally with a label.",
2708
+ props: {
2709
+ label: { type: "string", dynamic: true, description: "Text shown in the divider." },
2710
+ icon: { type: "string", description: "Icon name shown before the label." }
2711
+ },
2712
+ children: noChildren,
2713
+ examples: [example("divider", {
2714
+ namespace: "doc_divider_typical",
2715
+ layout: {
2716
+ "column:content": {
2717
+ "text:top": {
2718
+ text: "Above"
2719
+ },
2720
+ "divider:line": {
2721
+ label: "Divider",
2722
+ icon: "flag"
2723
+ },
2724
+ "text:bottom": {
2725
+ text: "Below"
2726
+ }
2727
+ }
2728
+ }
2729
+ })]
2730
+ });
2731
+
2732
+ // src/components/entries/formula.spec.ts
2733
+ var formulaSpec = component({
2734
+ type: "formula",
2735
+ category: "Display",
2736
+ title: "Formula",
2737
+ summary: "Reactive KaTeX formula display.",
2738
+ description: "Use formula to render SlexKit state and computed values through KaTeX.",
2739
+ props: {
2740
+ tex: { type: "string", dynamic: true, description: "KaTeX source to render." },
2741
+ formula: { type: "string", dynamic: true, description: "Alias for tex." },
2742
+ value: { type: "string", dynamic: true, description: "Alias for tex." },
2743
+ displayMode: { type: "boolean", default: true, description: "Render as display math when true; inline math when false." },
2744
+ display: { type: "boolean", default: true, description: "Alias for displayMode." },
2745
+ block: { type: "boolean", default: true, description: "Alias for displayMode." }
2746
+ },
2747
+ children: noChildren,
2748
+ examples: [example("formula", {
2749
+ namespace: "doc_formula_typical",
2750
+ g: {
2751
+ r: 1e4,
2752
+ c: 100,
2753
+ fc: 159.15
2754
+ },
2755
+ layout: {
2756
+ "formula:cutoff": {
2757
+ $tex: "'f_c = \\\\frac{1}{2\\\\pi RC} = ' + g.fc + '\\\\text{ Hz}'"
2758
+ }
2759
+ }
2760
+ })]
2761
+ });
2762
+
2763
+ // src/components/entries/grid.spec.ts
2764
+ var gridSpec = component({
2765
+ type: "grid",
2766
+ category: "Layout",
2767
+ title: "Grid",
2768
+ summary: "Responsive grid container.",
2769
+ description: "Use grid to arrange child components in responsive columns.",
2770
+ props: {
2771
+ columns: { type: "number", default: 1, dynamic: true, description: "Base column count." },
2772
+ smColumns: { type: "number", dynamic: true, description: "Column count at the small breakpoint." },
2773
+ mdColumns: { type: "number", dynamic: true, description: "Column count at the medium breakpoint." },
2774
+ lgColumns: { type: "number", dynamic: true, description: "Column count at the large breakpoint." },
2775
+ xlColumns: { type: "number", dynamic: true, description: "Column count at the extra-large breakpoint." },
2776
+ gap: { type: "string", dynamic: true, description: "Spacing between grid items." }
2777
+ },
2778
+ children: childContent,
2779
+ examples: [example("grid", {
2780
+ namespace: "doc_grid_typical",
2781
+ layout: {
2782
+ "grid:stats": {
2783
+ columns: 1,
2784
+ mdColumns: 3,
2785
+ "stat:a": {
2786
+ label: "Requests",
2787
+ value: "1.2k"
2788
+ },
2789
+ "stat:b": {
2790
+ label: "Success",
2791
+ value: "98%"
2792
+ },
2793
+ "stat:c": {
2794
+ label: "Errors",
2795
+ value: "3"
2796
+ }
2797
+ }
2798
+ }
2799
+ })]
2800
+ });
2801
+
2802
+ // src/components/entries/icon.spec.ts
2803
+ var iconSpec = component({
2804
+ type: "icon",
2805
+ category: "Component",
2806
+ title: "Icon",
2807
+ summary: "Shared icon field capability.",
2808
+ description: "Icon is a shared field capability, not an independent icon component type.",
2809
+ props: {
2810
+ icon: { type: "string", description: "Icon name resolved through the global icon manager." },
2811
+ iconOnly: { type: "boolean", description: "Render only the icon while retaining an accessible label where supported." },
2812
+ "items[].icon": { type: "string", description: "Accordion item trigger icon." },
2813
+ "options[].icon": { type: "string", description: "Select or radio option icon." },
2814
+ "columns[].icon": { type: "string", description: "Table column header icon." },
2815
+ "tabs[].icon": { type: "string", description: "Tab trigger icon." },
2816
+ "tabs[].iconOnly": { type: "boolean", description: "Tab trigger icon-only mode." }
2817
+ },
2818
+ children: noChildren,
2819
+ examples: [example("button", { label: "Settings", icon: "gear-six", iconOnly: true, variant: "ghost" }, "Icon field usage")]
2820
+ });
2821
+
2822
+ // src/components/entries/input.spec.ts
2823
+ var inputSpec = component({
2824
+ type: "input",
2825
+ category: "Input",
2826
+ title: "Input",
2827
+ summary: "Text or engineering-value input.",
2828
+ description: "Use input for editable text and engineering numeric values.",
2829
+ props: {
2830
+ value: { type: "string", dynamic: true, description: "Current input value." },
2831
+ label: { type: "string", dynamic: true, description: "Input label." },
2832
+ unit: { type: "string", dynamic: true, description: "Trailing unit text." },
2833
+ description: { type: "string", dynamic: true, description: "Assistive description below the input." },
2834
+ help: { type: "string", dynamic: true, description: "Alias for description." },
2835
+ hint: { type: "string", dynamic: true, description: "Alias for description." },
2836
+ error: { type: "string", dynamic: true, description: "Error text shown below the input and linked with aria-describedby." },
2837
+ errorMessage: { type: "string", dynamic: true, description: "Alias for error." },
2838
+ invalid: { type: "boolean", default: false, dynamic: true, description: "Mark the input as invalid with aria-invalid and error styling." },
2839
+ placeholder: { type: "string", description: "Placeholder text for empty values." },
2840
+ type: { type: "string", default: "text", description: "Input value kind; use engineering for parsed engineering values." },
2841
+ disabled: { type: "boolean", default: false, dynamic: true, description: "Disable editing." },
2842
+ readonly: { type: "boolean", default: false, dynamic: true, description: "Make the input read-only." },
2843
+ readOnly: { type: "boolean", default: false, dynamic: true, description: "Alias for readonly." },
2844
+ required: { type: "boolean", default: false, dynamic: true, description: "Mark the input as required." },
2845
+ id: { type: "string", description: "Native input id; defaults to a stable id derived from the component name." },
2846
+ name: { type: "string", description: "Native input name attribute." },
2847
+ min: { type: "string | number", dynamic: true, description: "Minimum value used by numeric input controls." },
2848
+ max: { type: "string | number", dynamic: true, description: "Maximum value used by numeric input controls." },
2849
+ step: { type: "string | number", dynamic: true, description: "Step size used by numeric input controls." },
2850
+ controls: { type: "boolean", default: true, dynamic: true, description: "Show decrement and increment buttons for numeric inputs." },
2851
+ onchange: { type: "write-expression", description: "Write expression invoked when the value changes." }
2852
+ },
2853
+ children: noChildren,
2854
+ examples: [example("input", {
2855
+ namespace: "doc_input_typical",
2856
+ layout: {
2857
+ "input:name": {
2858
+ label: "Project",
2859
+ value: "SlexKit",
2860
+ placeholder: "Enter name",
2861
+ description: "Visible labels keep form fields scannable."
2862
+ }
2863
+ }
2864
+ })]
2865
+ });
2866
+
2867
+ // src/components/entries/link.spec.ts
2868
+ var linkSpec = component({
2869
+ type: "link",
2870
+ category: "Content",
2871
+ title: "Link",
2872
+ summary: "Inline navigation link.",
2873
+ description: "Use link to navigate to another page or resource.",
2874
+ props: {
2875
+ href: { type: "string", description: "Target URL." },
2876
+ text: { type: "string", dynamic: true, description: "Visible link text." },
2877
+ label: { type: "string", dynamic: true, description: "Alias for text." },
2878
+ content: { type: "string", dynamic: true, description: "Alias for text." },
2879
+ icon: { type: "string", description: "Icon name shown before link text." },
2880
+ target: { type: "string", description: "Native link target attribute." },
2881
+ variant: { type: "string", values: ["default", "muted"], default: "default", description: "Link visual variant." }
2882
+ },
2883
+ children: noChildren,
2884
+ examples: [example("link", {
2885
+ namespace: "doc_link_typical",
2886
+ layout: {
2887
+ "column:links": {
2888
+ "link:docs": {
2889
+ href: "/components",
2890
+ icon: "arrow-square-out",
2891
+ text: "View components"
2892
+ }
2893
+ }
2894
+ }
2895
+ })]
2896
+ });
2897
+
2898
+ // src/components/entries/playground.spec.ts
2899
+ var playgroundSpec = component({
2900
+ type: "playground",
2901
+ category: "Tooling",
2902
+ title: "Playground",
2903
+ summary: "Interactive source preview.",
2904
+ description: "Use playground in documentation surfaces to render editable SlexKit or Markdown examples.",
2905
+ props: {
2906
+ source: { type: "object | string", description: "SlexKit or Markdown source to preview." },
2907
+ sourceType: { type: "string", values: ["slex", "markdown", "auto-markdown"], default: "slex", description: "Source parser mode." },
2908
+ title: { type: "string", description: "Playground title." },
2909
+ previewAlign: { type: "string", values: ["center", "start"], default: "center", description: "Vertical preview alignment in render mode." },
2910
+ alignPreview: { type: "string", values: ["center", "start"], description: "Alias for previewAlign." },
2911
+ previewPlacement: { type: "string", values: ["center", "start"], description: "Alias for previewAlign." },
2912
+ previewMinHeight: { type: "string", description: "Minimum preview area height." },
2913
+ previewMaxWidth: { type: "string", description: "Maximum preview content width." },
2914
+ themeToggle: { type: "boolean", default: false, description: "Show the theme toggle action." },
2915
+ showThemeToggle: { type: "boolean", default: false, description: "Alias for themeToggle." },
2916
+ enableThemeToggle: { type: "boolean", default: false, description: "Alias for themeToggle." },
2917
+ themeLabel: { type: "string", description: "Accessible label for the theme toggle action." },
2918
+ themeToggleLabel: { type: "string", description: "Alias for themeLabel." },
2919
+ sourceTypeLabel: { type: "string", description: "Accessible label for the source type selector." },
2920
+ copyLabel: { type: "string", description: "Accessible label for the copy source action." },
2921
+ openWebLabel: { type: "string", description: "Accessible label for opening the source in the standalone playground." },
2922
+ webUrl: { type: "string", description: "Standalone playground URL used by the open action." },
2923
+ playgroundUrl: { type: "string", description: "Alias for webUrl." }
2924
+ },
2925
+ children: noChildren,
2926
+ examples: [example("playground", {
2927
+ namespace: "doc_playground_typical",
2928
+ layout: {
2929
+ "playground:demo": {
2930
+ title: "Stat Playground",
2931
+ previewMinHeight: "180px",
2932
+ source: {
2933
+ namespace: "inner_stat_demo",
2934
+ layout: {
2935
+ "stat:value": {
2936
+ label: "Requests",
2937
+ value: "1.2k",
2938
+ unit: "/min"
2939
+ }
2940
+ }
2941
+ }
2942
+ }
2943
+ }
2944
+ })]
2945
+ });
2946
+
2947
+ // src/components/entries/progress.spec.ts
2948
+ var progressSpec = component({
2949
+ type: "progress",
2950
+ category: "Feedback",
2951
+ title: "Progress",
2952
+ summary: "Progress bar.",
2953
+ description: "Use progress to show completion as a percentage.",
2954
+ props: {
2955
+ value: { type: "number", default: 0, dynamic: true, description: "Progress percentage from 0 to 100." },
2956
+ label: { type: "string", dynamic: true, description: "Progress label." },
2957
+ icon: { type: "string", description: "Icon name shown before the label." },
2958
+ indeterminate: { type: "boolean", default: false, dynamic: true, description: "Render an indeterminate progress state without aria-valuenow." }
2959
+ },
2960
+ children: noChildren,
2961
+ examples: [example("progress", {
2962
+ namespace: "doc_progress_typical",
2963
+ layout: {
2964
+ "progress:build": {
2965
+ label: "Build progress",
2966
+ icon: "gear-six",
2967
+ value: 64
2968
+ }
2969
+ }
2970
+ })]
2971
+ });
2972
+
2973
+ // src/components/entries/radio-group.spec.ts
2974
+ var radioGroupSpec = component({
2975
+ type: "radio-group",
2976
+ category: "Input",
2977
+ title: "Radio Group",
2978
+ summary: "Single-choice option group.",
2979
+ description: "Use radio-group for one-of-many choices.",
2980
+ props: {
2981
+ value: { type: "string", dynamic: true, description: "Current selected value." },
2982
+ label: { type: "string", dynamic: true, description: "Group label." },
2983
+ icon: { type: "string", description: "Icon name shown before the group label." },
2984
+ options: { type: "array", description: "Options with label, value, and optional icon." },
2985
+ "options[].icon": { type: "string", description: "Icon name shown before a single option label." },
2986
+ disabled: { type: "boolean", default: false, dynamic: true, description: "Disable every radio option in the group." },
2987
+ orientation: { type: "string", values: ["vertical", "horizontal"], default: "vertical", description: "Radio option layout direction." },
2988
+ haptic: { type: "boolean", default: true, description: "Enable vibration feedback on supported devices." },
2989
+ haptics: { type: "boolean", default: true, description: "Alias for haptic." },
2990
+ name: { type: "string", description: "Native radio group name shared by options." },
2991
+ onchange: { type: "write-expression", description: "Write expression invoked when selection changes." }
2992
+ },
2993
+ children: noChildren,
2994
+ examples: [example("radio-group", {
2995
+ namespace: "doc_radio_group_typical",
2996
+ layout: {
2997
+ "radio-group:mode": {
2998
+ label: "Mode",
2999
+ icon: "sliders-horizontal",
3000
+ value: "auto",
3001
+ options: [
3002
+ {
3003
+ label: "Auto",
3004
+ value: "auto",
3005
+ icon: "sparkle"
3006
+ },
3007
+ {
3008
+ label: "Manual",
3009
+ value: "manual",
3010
+ icon: "wrench"
3011
+ }
3012
+ ]
3013
+ }
3014
+ }
3015
+ })]
3016
+ });
3017
+
3018
+ // src/components/entries/row.spec.ts
3019
+ var rowSpec = component({
3020
+ type: "row",
3021
+ category: "Layout",
3022
+ title: "Row",
3023
+ summary: "Horizontal layout container.",
3024
+ description: "Use row to place child components horizontally in field order.",
3025
+ props: {
3026
+ justify: { type: "string", values: ["start", "center", "end", "space-between", "space-around"], default: "start", description: "Main-axis distribution." },
3027
+ align: { type: "string", values: ["start", "center", "end", "baseline", "stretch"], default: "center", description: "Cross-axis alignment." },
3028
+ gap: { type: "string", dynamic: true, description: "Spacing between children." }
3029
+ },
3030
+ children: childContent,
3031
+ examples: [example("row", {
3032
+ namespace: "doc_row_typical",
3033
+ layout: {
3034
+ "row:toolbar": {
3035
+ justify: "space-between",
3036
+ "text:title": {
3037
+ text: "Runtime status"
3038
+ },
3039
+ "button:refresh": {
3040
+ label: "Refresh"
3041
+ }
3042
+ }
3043
+ }
3044
+ })]
3045
+ });
3046
+
3047
+ // src/components/entries/section.spec.ts
3048
+ var sectionSpec = component({
3049
+ type: "section",
3050
+ category: "Content",
3051
+ title: "Section",
3052
+ summary: "Page section with optional heading chrome.",
3053
+ description: "Use section to group page content with title, subtitle, and optional action link.",
3054
+ props: {
3055
+ title: { type: "string", dynamic: true, description: "Section title." },
3056
+ icon: { type: "string", description: "Icon name shown before the title." },
3057
+ eyebrow: { type: "string", dynamic: true, description: "Small label above the title." },
3058
+ subtitle: { type: "string", dynamic: true, description: "Subtitle text below the title." },
3059
+ actionLabel: { type: "string", dynamic: true, description: "Optional action link label." },
3060
+ actionHref: { type: "string", description: "Optional action link target." }
3061
+ },
3062
+ children: childContent,
3063
+ examples: [example("section", {
3064
+ namespace: "doc_section_typical",
3065
+ layout: {
3066
+ "section:overview": {
3067
+ eyebrow: "Dashboard",
3068
+ title: "Runtime overview",
3069
+ icon: "chart-bar",
3070
+ subtitle: "This section groups the most important state.",
3071
+ "stat:latency": {
3072
+ label: "Latency",
3073
+ value: "42",
3074
+ unit: "ms"
3075
+ }
3076
+ }
3077
+ }
3078
+ })]
3079
+ });
3080
+
3081
+ // src/components/entries/select.spec.ts
3082
+ var selectSpec = component({
3083
+ type: "select",
3084
+ category: "Input",
3085
+ title: "Select",
3086
+ summary: "Dropdown selection input.",
3087
+ description: "Use select for compact single-choice selection from an option list.",
3088
+ props: {
3089
+ label: { type: "string", dynamic: true, description: "Select label." },
3090
+ icon: { type: "string", description: "Icon name shown before the top label." },
3091
+ value: { type: "string", dynamic: true, description: "Current selected value." },
3092
+ options: { type: "array", description: "Options with label, value, and optional icon." },
3093
+ "options[].icon": { type: "string", description: "Icon name shown before an option label." },
3094
+ placeholder: { type: "string", description: "Placeholder shown when no value is selected." },
3095
+ disabled: { type: "boolean", default: false, dynamic: true, description: "Disable the select trigger and native select." },
3096
+ required: { type: "boolean", default: false, dynamic: true, description: "Require a non-placeholder value in the native select." },
3097
+ variant: { type: "string", values: ["default", "toolbar"], default: "default", description: "Select surface variant." },
3098
+ onchange: { type: "write-expression", description: "Write expression invoked when selection changes." }
3099
+ },
3100
+ children: noChildren,
3101
+ examples: [example("select", {
3102
+ namespace: "doc_select_typical",
3103
+ layout: {
3104
+ "select:env": {
3105
+ label: "Environment",
3106
+ icon: "server",
3107
+ value: "prod",
3108
+ options: [
3109
+ {
3110
+ label: "Development",
3111
+ value: "dev",
3112
+ icon: "code"
3113
+ },
3114
+ {
3115
+ label: "Production",
3116
+ value: "prod",
3117
+ icon: "rocket-launch"
3118
+ }
3119
+ ]
3120
+ }
3121
+ }
3122
+ })]
3123
+ });
3124
+
3125
+ // src/components/entries/slider.spec.ts
3126
+ var sliderSpec = component({
3127
+ type: "slider",
3128
+ category: "Input",
3129
+ title: "Slider",
3130
+ summary: "Numeric range input.",
3131
+ description: "Use slider for bounded numeric adjustments such as volume, brightness, or thresholds.",
3132
+ props: {
3133
+ label: { type: "string", dynamic: true, description: "Slider label." },
3134
+ icon: { type: "string", description: "Icon name shown before the label." },
3135
+ value: { type: "number", default: 0, dynamic: true, description: "Current numeric value." },
3136
+ min: { type: "number", default: 0, dynamic: true, description: "Minimum value." },
3137
+ max: { type: "number", default: 100, dynamic: true, description: "Maximum value." },
3138
+ step: { type: "number", default: 1, dynamic: true, description: "Step interval." },
3139
+ unit: { type: "string", dynamic: true, description: "Unit shown after the value." },
3140
+ disabled: { type: "boolean", default: false, dynamic: true, description: "Disable the range input." },
3141
+ orientation: { type: "string", values: ["horizontal", "vertical"], default: "horizontal", description: "Slider orientation metadata used for styling." },
3142
+ haptic: { type: "boolean", default: true, description: "Enable vibration feedback on supported devices." },
3143
+ haptics: { type: "boolean", default: true, description: "Alias for haptic." },
3144
+ onchange: { type: "write-expression", description: "Write expression invoked when the value changes." }
3145
+ },
3146
+ children: noChildren,
3147
+ examples: [example("slider", {
3148
+ namespace: "doc_slider_typical",
3149
+ layout: {
3150
+ "slider:volume": {
3151
+ label: "Volume",
3152
+ icon: "speaker-high",
3153
+ value: 42,
3154
+ min: 0,
3155
+ max: 100,
3156
+ step: 1,
3157
+ unit: "%"
3158
+ }
3159
+ }
3160
+ })]
3161
+ });
3162
+
3163
+ // src/components/entries/stat.spec.ts
3164
+ var statSpec = component({
3165
+ type: "stat",
3166
+ category: "Display",
3167
+ title: "Stat",
3168
+ summary: "Metric display.",
3169
+ description: "Use stat to present a labeled metric value with optional unit and semantic tone.",
3170
+ props: {
3171
+ label: { type: "string", dynamic: true, description: "Metric label." },
3172
+ icon: { type: "string", description: "Icon name shown before the label." },
3173
+ value: { type: "string | number", dynamic: true, description: "Metric value." },
3174
+ unit: { type: "string", dynamic: true, description: "Unit shown after the value." },
3175
+ tone: { type: "string", values: semanticTones, description: "Optional semantic tone." },
3176
+ animateInitial: { type: "boolean", default: false, description: "Animate the initial rendered value." }
3177
+ },
3178
+ children: noChildren,
3179
+ examples: [example("stat", {
3180
+ namespace: "doc_stat_typical",
3181
+ layout: {
3182
+ "grid:stats": {
3183
+ columns: 2,
3184
+ "stat:requests": {
3185
+ label: "Requests",
3186
+ icon: "activity",
3187
+ value: "1.2k",
3188
+ unit: "/min"
3189
+ },
3190
+ "stat:success": {
3191
+ label: "Success",
3192
+ icon: "check-circle",
3193
+ value: "98.4",
3194
+ unit: "%",
3195
+ tone: "success"
3196
+ }
3197
+ }
3198
+ }
3199
+ })]
3200
+ });
3201
+
3202
+ // src/components/entries/submit.spec.ts
3203
+ var submitSpec = component({
3204
+ type: "submit",
3205
+ category: "Action",
3206
+ title: "Submit",
3207
+ summary: "ToolHost submit and ignore controls.",
3208
+ description: "Use submit inside tool templates to return selected state fields to the host.",
3209
+ props: {
3210
+ submitLabel: { type: "string", default: "Submit", description: "Submit button text." },
3211
+ ignoreLabel: { type: "string", default: "Ignore", description: "Ignore button text." },
3212
+ returnKeys: { type: "string[]", description: "State field paths returned to ToolHost." },
3213
+ disabled: { type: "boolean", default: false, dynamic: true, description: "Disable submit action." }
3214
+ },
3215
+ children: noChildren,
3216
+ examples: [example("submit", {
3217
+ namespace: "doc_submit_typical",
3218
+ layout: {
3219
+ "column:tool": {
3220
+ "input:title": {
3221
+ value: "Release note",
3222
+ placeholder: "Title"
3223
+ },
3224
+ "submit:done": {
3225
+ submitLabel: "Submit",
3226
+ ignoreLabel: "Ignore",
3227
+ returnKeys: [
3228
+ "title"
3229
+ ]
3230
+ }
3231
+ }
3232
+ }
3233
+ })]
3234
+ });
3235
+
3236
+ // src/components/entries/switch.spec.ts
3237
+ var switchSpec = component({
3238
+ type: "switch",
3239
+ category: "Input",
3240
+ title: "Switch",
3241
+ summary: "Boolean switch input.",
3242
+ description: "Use switch for an on/off setting.",
3243
+ props: {
3244
+ enabled: { type: "boolean", default: false, dynamic: true, description: "Enabled state." },
3245
+ label: { type: "string", dynamic: true, description: "Switch label." },
3246
+ icon: { type: "string", description: "Icon name shown before the visible label." },
3247
+ disabled: { type: "boolean", default: false, dynamic: true, description: "Disable the switch." },
3248
+ haptic: { type: "boolean", default: true, description: "Enable vibration feedback on supported devices." },
3249
+ haptics: { type: "boolean", default: true, description: "Alias for haptic." },
3250
+ onchange: { type: "write-expression", description: "Write expression invoked when enabled state changes." }
3251
+ },
3252
+ children: noChildren,
3253
+ examples: [example("switch", {
3254
+ namespace: "doc_switch_typical",
3255
+ layout: {
3256
+ "switch:feature": {
3257
+ enabled: true,
3258
+ label: "Enable sync",
3259
+ icon: "arrows-clockwise"
3260
+ }
3261
+ }
3262
+ })]
3263
+ });
3264
+
3265
+ // src/components/entries/table.spec.ts
3266
+ var tableSpec = component({
3267
+ type: "table",
3268
+ category: "Data",
3269
+ title: "Table",
3270
+ summary: "Simple data table.",
3271
+ description: "Use table to render rows of keyed data against a column definition.",
3272
+ props: {
3273
+ columns: { type: "array", description: "Column definitions with key, label, and optional icon." },
3274
+ "columns[].icon": { type: "string", description: "Icon name shown before a column label." },
3275
+ rows: { type: "array", description: "Row data objects keyed by column key." },
3276
+ items: { type: "array", description: "Alias for rows." }
3277
+ },
3278
+ children: noChildren,
3279
+ examples: [example("table", {
3280
+ namespace: "doc_table_typical",
3281
+ layout: {
3282
+ "table:routes": {
3283
+ columns: [
3284
+ {
3285
+ key: "name",
3286
+ label: "Name",
3287
+ icon: "text-t"
3288
+ },
3289
+ {
3290
+ key: "status",
3291
+ label: "Status",
3292
+ icon: "check-circle"
3293
+ }
3294
+ ],
3295
+ rows: [
3296
+ {
3297
+ name: "Parse",
3298
+ status: "ready"
3299
+ },
3300
+ {
3301
+ name: "Publish",
3302
+ status: "pending"
3303
+ }
3304
+ ]
3305
+ }
3306
+ }
3307
+ })]
3308
+ });
3309
+
3310
+ // src/components/entries/tabs.spec.ts
3311
+ var tabsSpec = component({
3312
+ type: "tabs",
3313
+ category: "Navigation",
3314
+ title: "Tabs",
3315
+ summary: "Tabbed view switcher.",
3316
+ description: "Use tabs to switch between named content panels.",
3317
+ props: {
3318
+ value: { type: "string", dynamic: true, description: "Current active tab value." },
3319
+ tabs: { type: "array", description: "Tab definitions with value, label, content, icon, and iconOnly." },
3320
+ "tabs[].icon": { type: "string", description: "Icon name shown before a tab trigger label." },
3321
+ "tabs[].iconOnly": { type: "boolean", description: "Show only the tab icon while retaining label as accessible text." },
3322
+ orientation: { type: "string", values: ["horizontal", "vertical"], default: "horizontal", description: "Tab list orientation." },
3323
+ onchange: { type: "write-expression", description: "Write expression invoked when the active tab changes." }
3324
+ },
3325
+ children: noChildren,
3326
+ examples: [example("tabs", {
3327
+ namespace: "doc_tabs_typical",
3328
+ layout: {
3329
+ "tabs:main": {
3330
+ value: "overview",
3331
+ tabs: [
3332
+ {
3333
+ value: "overview",
3334
+ label: "Overview"
3335
+ },
3336
+ {
3337
+ value: "settings",
3338
+ label: "Settings"
3339
+ }
3340
+ ]
3341
+ }
3342
+ }
3343
+ })]
3344
+ });
3345
+
3346
+ // src/components/entries/text.spec.ts
3347
+ var textSpec = component({
3348
+ type: "text",
3349
+ category: "Display",
3350
+ title: "Text",
3351
+ summary: "Plain text display.",
3352
+ description: "Use text for short static or dynamic copy inside SlexKit layouts.",
3353
+ props: {
3354
+ text: { type: "string", dynamic: true, description: "Displayed text." },
3355
+ content: { type: "string", dynamic: true, description: "Alias for text." },
3356
+ label: { type: "string", dynamic: true, description: "Alias for text." },
3357
+ variant: { type: "string", values: ["default", "muted"], default: "default", description: "Text visual variant." },
3358
+ class: { type: "string", description: "Additional host-controlled CSS class." }
3359
+ },
3360
+ children: noChildren,
3361
+ examples: [example("text", {
3362
+ namespace: "doc_text_typical",
3363
+ layout: {
3364
+ "text:status": {
3365
+ text: "System is healthy"
3366
+ }
3367
+ }
3368
+ })]
3369
+ });
3370
+
3371
+ // src/components/entries/toast.spec.ts
3372
+ var toastSpec = component({
3373
+ type: "toast",
3374
+ category: "Feedback",
3375
+ title: "Toast",
3376
+ summary: "Transient notification.",
3377
+ description: "Use toast to show an inline notification with semantic status.",
3378
+ props: {
3379
+ title: { type: "string", dynamic: true, description: "Toast title." },
3380
+ heading: { type: "string", dynamic: true, description: "Alias for title." },
3381
+ label: { type: "string", dynamic: true, description: "Alias for title." },
3382
+ icon: { type: "string", description: "Icon name shown at the left of the toast." },
3383
+ description: { type: "string", dynamic: true, description: "Toast body text." },
3384
+ text: { type: "string", dynamic: true, description: "Alias for description." },
3385
+ message: { type: "string", dynamic: true, description: "Alias for description." },
3386
+ content: { type: "string", dynamic: true, description: "Alias for description." },
3387
+ type: { type: "string", values: ["info", "success", "warning", "danger"], default: "info", description: "Semantic notification type." },
3388
+ tone: { type: "string", values: ["info", "success", "warning", "danger"], default: "info", description: "Alias for type." },
3389
+ duration: { type: "number", description: "Auto-hide delay in milliseconds." },
3390
+ dismissable: { type: "boolean", default: true, description: "Show a close button." },
3391
+ dismissible: { type: "boolean", default: true, description: "Alias for dismissable." },
3392
+ closeLabel: { type: "string", default: "Close notification", description: "Accessible close button label." },
3393
+ closeAriaLabel: { type: "string", description: "Alias for closeLabel." }
3394
+ },
3395
+ children: noChildren,
3396
+ examples: [example("toast", {
3397
+ namespace: "doc_toast_typical",
3398
+ layout: {
3399
+ "toast:saved": {
3400
+ type: "success",
3401
+ title: "Saved",
3402
+ icon: "check-circle",
3403
+ description: "Changes have been written."
3404
+ }
3405
+ }
3406
+ })]
3407
+ });
3408
+
3409
+ // src/components/entries/specs.ts
3410
+ var componentSpecs = [
3411
+ accordionSpec,
3412
+ badgeSpec,
3413
+ buttonSpec,
3414
+ calloutSpec,
3415
+ cardSpec,
3416
+ checkboxSpec,
3417
+ codeBlockSpec,
3418
+ collapsibleSpec,
3419
+ columnSpec,
3420
+ dividerSpec,
3421
+ formulaSpec,
3422
+ gridSpec,
3423
+ iconSpec,
3424
+ inputSpec,
3425
+ linkSpec,
3426
+ playgroundSpec,
3427
+ progressSpec,
3428
+ radioGroupSpec,
3429
+ rowSpec,
3430
+ sectionSpec,
3431
+ selectSpec,
3432
+ sliderSpec,
3433
+ statSpec,
3434
+ submitSpec,
3435
+ switchSpec,
3436
+ tableSpec,
3437
+ tabsSpec,
3438
+ textSpec,
3439
+ toastSpec
3440
+ ];
3441
+
3442
+ // src/components/spec-registry.ts
3443
+ var publicComponentTypes = componentSpecs.map((spec) => spec.type);
3444
+ var componentSpecByType = new Map(componentSpecs.map((spec) => [spec.type, spec]));
3445
+
3446
+ // src/engine/capabilities.ts
3447
+ var slexkitStdlibDocs = [
3448
+ {
3449
+ name: "math",
3450
+ summary: "Small numeric helpers for common interactive calculations.",
3451
+ functions: [
3452
+ { name: "std.math.clamp", signature: "clamp(value, min, max)", summary: "Clamp a number into a range.", pure: true, example: "std.math.clamp(g.score, 0, 100)" },
3453
+ { name: "std.math.round", signature: "round(value, digits = 0)", summary: "Round with a fixed number of decimal digits.", pure: true, example: "std.math.round(g.latency, 1)" },
3454
+ { name: "std.math.safeDivide", signature: "safeDivide(numerator, denominator, fallback = 0)", summary: "Divide with a fallback for zero or invalid denominators.", pure: true, example: "std.math.safeDivide(g.used, g.total, 0)" },
3455
+ { name: "std.math.percent", signature: "percent(part, total, digits = 1)", summary: "Return part / total as a percentage number.", pure: true, example: "std.math.percent(g.done, g.total, 1)" },
3456
+ { name: "std.math.lerp", signature: "lerp(start, end, t)", summary: "Linear interpolation.", pure: true, example: "std.math.lerp(0, 100, g.progress)" }
3457
+ ]
3458
+ },
3459
+ {
3460
+ name: "stats",
3461
+ summary: "Finite-number aggregations for arrays.",
3462
+ functions: [
3463
+ { name: "std.stats.sum", signature: "sum(values)", summary: "Sum finite numeric values. Empty arrays return 0.", pure: true, example: "std.stats.sum(g.samples)" },
3464
+ { name: "std.stats.mean", signature: "mean(values)", summary: "Average finite numeric values. Empty arrays return NaN.", pure: true, example: "std.stats.mean(g.samples)" },
3465
+ { name: "std.stats.min", signature: "min(values)", summary: "Minimum finite numeric value. Empty arrays return NaN.", pure: true, example: "std.stats.min(g.samples)" },
3466
+ { name: "std.stats.max", signature: "max(values)", summary: "Maximum finite numeric value. Empty arrays return NaN.", pure: true, example: "std.stats.max(g.samples)" },
3467
+ { name: "std.stats.median", signature: "median(values)", summary: "Median finite numeric value. Empty arrays return NaN.", pure: true, example: "std.stats.median(g.samples)" }
3468
+ ]
3469
+ },
3470
+ {
3471
+ name: "format",
3472
+ summary: "Deterministic display formatting with en-US defaults.",
3473
+ functions: [
3474
+ { name: "std.format.fixed", signature: "fixed(value, digits = 2)", summary: "Format a number with fixed decimal places.", pure: true, example: "std.format.fixed(g.voltage, 3)" },
3475
+ { name: "std.format.number", signature: "number(value, digits = 0, locale = 'en-US')", summary: "Locale number formatting.", pure: true, example: "std.format.number(g.requests)" },
3476
+ { name: "std.format.compact", signature: "compact(value, digits = 1, locale = 'en-US')", summary: "Compact number formatting.", pure: true, example: "std.format.compact(g.users)" },
3477
+ { name: "std.format.percent", signature: "percent(ratio, digits = 1)", summary: "Format a ratio as a percentage string.", pure: true, example: "std.format.percent(g.done / g.total, 1)" },
3478
+ { name: "std.format.currency", signature: "currency(value, currency = 'USD', locale = 'en-US')", summary: "Format a currency value.", pure: true, example: "std.format.currency(g.revenue, 'USD')" }
3479
+ ]
3480
+ },
3481
+ {
3482
+ name: "units",
3483
+ summary: "Small unit display helpers for common dashboards.",
3484
+ functions: [
3485
+ { name: "std.units.withUnit", signature: "withUnit(value, unit, digits = 2)", summary: "Format a value with a unit suffix.", pure: true, example: "std.units.withUnit(g.power, 'W', 1)" },
3486
+ { name: "std.units.bytes", signature: "bytes(value, digits = 1)", summary: "Format bytes as B, KB, MB, GB, TB, or PB.", pure: true, example: "std.units.bytes(g.payloadBytes)" },
3487
+ { name: "std.units.duration", signature: "duration(ms, digits = 1)", summary: "Format milliseconds as ms, s, min, or h.", pure: true, example: "std.units.duration(g.elapsedMs)" },
3488
+ { name: "std.units.si", signature: "si(value, unit = '', digits = 2)", summary: "Format with SI prefixes.", pure: true, example: "std.units.si(g.frequency, 'Hz', 2)" }
3489
+ ]
3490
+ }
3491
+ ];
3492
+ var slexkitRuntimeCapabilities = [
3493
+ { name: "api.get", policy: "network", signature: "get(url, options)", summary: "Policy-gated GET request.", example: "await api.get('https://api.example.com/status')", secureDefault: "denied", forbidden: ["fetch(url)", "XMLHttpRequest", "WebSocket"] },
3494
+ { name: "api.post", policy: "network", signature: "post(url, body, options)", summary: "Policy-gated POST request.", example: "await api.post('https://api.example.com/items', { ok: true })", secureDefault: "denied", forbidden: ["fetch(url)", "XMLHttpRequest", "WebSocket"] },
3495
+ { name: "api.fetch", policy: "network", signature: "fetch(url, options)", summary: "Policy-gated GET or POST request.", example: "await api.fetch(url, { method: 'GET' })", secureDefault: "denied", forbidden: ["fetch(url)", "XMLHttpRequest", "WebSocket"] },
3496
+ { name: "api.setTimeout", policy: "timer", signature: "setTimeout(fn, ms)", summary: "Policy-gated timeout.", example: "api.setTimeout(function () { g.ready = true; }, 500)", secureDefault: "denied", forbidden: ["setTimeout(fn, ms)"] },
3497
+ { name: "api.clearTimeout", policy: "timer", signature: "clearTimeout(id)", summary: "Clear a policy-gated timeout.", example: "api.clearTimeout(g.timeoutId)", secureDefault: "denied" },
3498
+ { name: "api.setInterval", policy: "timer", signature: "setInterval(fn, ms)", summary: "Policy-gated interval.", example: "api.setInterval(function () { g.ticks += 1; }, 1000)", secureDefault: "denied", forbidden: ["setInterval(fn, ms)"] },
3499
+ { name: "api.clearInterval", policy: "timer", signature: "clearInterval(id)", summary: "Clear a policy-gated interval.", example: "api.clearInterval(g.intervalId)", secureDefault: "denied" },
3500
+ { name: "api.raf", policy: "animation", signature: "raf(fn)", summary: "Policy-gated animation frame.", example: "api.raf(function (time) { g.time = time; })", secureDefault: "denied", forbidden: ["requestAnimationFrame(fn)"] },
3501
+ { name: "api.cancelRaf", policy: "animation", signature: "cancelRaf(id)", summary: "Cancel a policy-gated animation frame.", example: "api.cancelRaf(g.rafId)", secureDefault: "denied" },
3502
+ { name: "api.createCanvas", policy: "canvas", signature: "createCanvas(width, height)", summary: "Create a policy-counted canvas.", example: "var canvas = api.createCanvas(320, 180)", secureDefault: "denied" },
3503
+ { name: "api.getCanvasContext", policy: "canvas", signature: "getCanvasContext(canvas, contextId, options)", summary: "Get a policy-checked canvas context.", example: "var ctx = api.getCanvasContext(canvas, '2d')", secureDefault: "denied" },
3504
+ { name: "api.onDispose", policy: "lifecycle", signature: "onDispose(fn)", summary: "Register runtime cleanup.", example: "api.onDispose(function () { g.closed = true; })", secureDefault: "available" },
3505
+ { name: "api.now", policy: "lifecycle", signature: "now()", summary: "Runtime clock.", example: "api.now()", secureDefault: "available" },
3506
+ { name: "api.isTimeoutError", policy: "diagnostics", signature: "isTimeoutError(error)", summary: "Check timeout errors.", example: "api.isTimeoutError(error)", secureDefault: "available" },
3507
+ { name: "api.isNetworkError", policy: "diagnostics", signature: "isNetworkError(error)", summary: "Check network errors.", example: "api.isNetworkError(error)", secureDefault: "available" },
3508
+ { name: "api.isPolicyError", policy: "diagnostics", signature: "isPolicyError(error)", summary: "Check policy errors.", example: "api.isPolicyError(error)", secureDefault: "available" },
3509
+ { name: "api.errorMessage", policy: "diagnostics", signature: "errorMessage(error)", summary: "Extract a displayable error message.", example: "api.errorMessage(error)", secureDefault: "available" }
3510
+ ];
3511
+ var slexkitStdlibFunctionNames = slexkitStdlibDocs.flatMap((namespace) => namespace.functions.map((fn) => fn.name));
3512
+ var slexkitRuntimeCapabilityNames = slexkitRuntimeCapabilities.map((capability) => capability.name);
3513
+
3514
+ // src/engine/validation.ts
3515
+ var componentSpecByType2 = new Map(componentSpecs.map((spec) => [spec.type, spec]));
3516
+ var stdlibFunctions = new Set(slexkitStdlibFunctionNames);
3517
+ var stdlibNamespaces = new Set(slexkitStdlibFunctionNames.map((name) => name.split(".").slice(0, 2).join(".")));
3518
+ var apiMembers = new Set(slexkitRuntimeCapabilityNames);
3519
+ var directiveProps = new Set(["$if", "$for", "$key"]);
3520
+ var nativeSecureCapabilities = [
3521
+ { value: "fetch", pattern: /(?<!\.)\bfetch\s*\(/ },
3522
+ { value: "XMLHttpRequest", pattern: /\bXMLHttpRequest\b/ },
3523
+ { value: "WebSocket", pattern: /\bWebSocket\b/ },
3524
+ { value: "setTimeout", pattern: /(?<!\.)\bsetTimeout\s*\(/ },
3525
+ { value: "requestAnimationFrame", pattern: /(?<!\.)\brequestAnimationFrame\s*\(/ }
3526
+ ];
3527
+ function collectMemberUsage(source, root) {
3528
+ const matches = source.matchAll(new RegExp(`\\b${root}\\.([A-Za-z_$][\\w$]*)(?:\\.([A-Za-z_$][\\w$]*))?`, "g"));
3529
+ const found = new Set;
3530
+ for (const match of matches) {
3531
+ found.add([root, match[1], match[2]].filter(Boolean).join("."));
3532
+ }
3533
+ return [...found].sort();
3534
+ }
3535
+ function componentKeyType(key) {
3536
+ const colon = key.indexOf(":");
3537
+ return colon > 0 ? key.slice(0, colon) : null;
3538
+ }
3539
+ function isKnownProp(type, key) {
3540
+ if (directiveProps.has(key) || key.startsWith("on"))
3541
+ return true;
3542
+ const spec = componentSpecByType2.get(type);
3543
+ if (!spec)
3544
+ return true;
3545
+ const propName = key.startsWith("$") ? key.slice(1) : key;
3546
+ return propName in spec.props;
3547
+ }
3548
+ function walkComponents(value, warnings, usage, path = "") {
3549
+ if (!value || typeof value !== "object")
3550
+ return;
3551
+ for (const [key, child] of Object.entries(value)) {
3552
+ const childPath = path ? `${path}.${key}` : key;
3553
+ const type = componentKeyType(key);
3554
+ if (type) {
3555
+ usage.add(type);
3556
+ const spec = componentSpecByType2.get(type);
3557
+ if (!spec) {
3558
+ warnings.push({
3559
+ code: "unknown_component",
3560
+ message: `Unknown SlexKit component '${type}'.`,
3561
+ path: childPath,
3562
+ value: type
3563
+ });
3564
+ }
3565
+ if (child && typeof child === "object") {
3566
+ for (const propName of Object.keys(child)) {
3567
+ if (componentKeyType(propName))
3568
+ continue;
3569
+ if (!isKnownProp(type, propName)) {
3570
+ warnings.push({
3571
+ code: "unknown_prop",
3572
+ message: `Unknown prop '${propName}' on component '${type}'.`,
3573
+ path: `${childPath}.${propName}`,
3574
+ value: propName
3575
+ });
3576
+ }
3577
+ }
3578
+ }
3579
+ }
3580
+ walkComponents(child, warnings, usage, childPath);
3581
+ }
3582
+ }
3583
+ function sourceWarnings(source, mode) {
3584
+ const warnings = [];
3585
+ const stdlibUsage = collectMemberUsage(source, "std");
3586
+ const apiUsage = collectMemberUsage(source, "api");
3587
+ for (const name of stdlibUsage) {
3588
+ if (stdlibFunctions.has(name) || stdlibNamespaces.has(name))
3589
+ continue;
3590
+ warnings.push({
3591
+ code: "unknown_std_member",
3592
+ message: `Unknown SlexKit stdlib member '${name}'.`,
3593
+ value: name
3594
+ });
3595
+ }
3596
+ for (const name of apiUsage) {
3597
+ if (apiMembers.has(name))
3598
+ continue;
3599
+ warnings.push({
3600
+ code: "unknown_api_member",
3601
+ message: `Unknown SlexKit runtime API member '${name}'.`,
3602
+ value: name
3603
+ });
3604
+ }
3605
+ if (mode === "secure") {
3606
+ for (const capability of nativeSecureCapabilities) {
3607
+ if (capability.pattern.test(source)) {
3608
+ warnings.push({
3609
+ code: "native_secure_capability",
3610
+ message: `Native '${capability.value}' is not supported in secure mode. Use policy-gated api.* instead.`,
3611
+ value: capability.value
3612
+ });
3613
+ }
3614
+ }
3615
+ }
3616
+ return { warnings, stdlibUsage, apiUsage };
3617
+ }
3618
+ function validateSlexSource(source, options = {}) {
3619
+ const mode = options.mode ?? "trusted";
3620
+ const parsed = parseSlexSource(source);
3621
+ const usage = new Set;
3622
+ const { warnings, stdlibUsage, apiUsage } = sourceWarnings(source, mode);
3623
+ if (!parsed.ok) {
3624
+ return {
3625
+ ok: false,
3626
+ diagnostic: parsed.diagnostic,
3627
+ warnings,
3628
+ componentUsage: [],
3629
+ stdlibUsage,
3630
+ apiUsage
3631
+ };
3632
+ }
3633
+ walkComponents(parsed.value, warnings, usage);
3634
+ return {
3635
+ ok: true,
3636
+ value: parsed.value,
3637
+ warnings,
3638
+ componentUsage: [...usage].sort(),
3639
+ stdlibUsage,
3640
+ apiUsage
3641
+ };
3642
+ }
2136
3643
  // src/engine/markdown-runtime.ts
2137
3644
  var DEFAULT_POLICY = {};
2138
3645
  function isRecord(value) {
@@ -2258,7 +3765,7 @@ function createSlexKitMarkdownRuntimeHost(initialOptions = {}) {
2258
3765
  const __target = { slex: "0.1", namespace: __artifactPrefix + "default", g: {}, layout: {} };
2259
3766
  const __layouts = [];
2260
3767
  for (const __entry of __sources) {
2261
- const __script = __entry.kind === "json" ? JSON.parse(__entry.source) : (0, eval)(__entry.source);
3768
+ const __script = __entry.kind === "json" ? JSON.parse(__entry.source) : (0, eval)("(" + __entry.source + ")");
2262
3769
  if (!__isRecord(__script)) continue;
2263
3770
  if ("slex" in __script) __target.slex = String(__script.slex || "0.1");
2264
3771
  if ("namespace" in __script) __target.namespace = __artifactPrefix + String(__script.namespace || "default");
@@ -2696,14 +4203,20 @@ function createSecureFrameTarget(input, container, mountOptions) {
2696
4203
  iframe.title = options.title ?? "SlexKit secure artifact";
2697
4204
  iframe.setAttribute("data-slexkit-secure-frame", "true");
2698
4205
  iframe.setAttribute("referrerpolicy", "no-referrer");
4206
+ iframe.style.display = "block";
4207
+ iframe.style.width = "100%";
4208
+ iframe.style.border = "0";
4209
+ iframe.style.background = "transparent";
2699
4210
  const runtimeUrl = options.runtimeUrl ?? options.runnerUrl ?? defaultRuntimeUrl;
2700
4211
  if (runtimeUrl) {
2701
4212
  const resolvedRuntimeUrl = resolveRuntimeUrl(runtimeUrl);
4213
+ const styleUrl = options.styleUrl === false ? "" : options.styleUrl ?? defaultSecureFrameStyleUrl(resolvedRuntimeUrl);
4214
+ const resolvedStyleUrl = styleUrl ? resolveRuntimeUrl(styleUrl) : undefined;
2702
4215
  assertSandboxCloneable(input);
2703
4216
  iframe.setAttribute("sandbox", secureSandboxAttribute(options));
2704
4217
  container.replaceChildren(iframe);
2705
4218
  const bridge = createSandboxBridge(input, container, iframe, mountOptions);
2706
- iframe.srcdoc = secureRunnerSrcdoc(resolvedRuntimeUrl);
4219
+ iframe.srcdoc = secureRunnerSrcdoc(resolvedRuntimeUrl, resolvedStyleUrl);
2707
4220
  return bridge;
2708
4221
  }
2709
4222
  if (frame) {
@@ -2763,23 +4276,38 @@ function cspSourceForRuntime(runtimeUrl) {
2763
4276
  return "'self'";
2764
4277
  }
2765
4278
  }
4279
+ function defaultSecureFrameStyleUrl(runtimeUrl) {
4280
+ try {
4281
+ const url = new URL(runtimeUrl);
4282
+ if (url.protocol === "blob:" || url.protocol === "data:")
4283
+ return "";
4284
+ url.pathname = url.pathname.replace(/[^/]+$/, "slexkit.css");
4285
+ url.search = "";
4286
+ url.hash = "";
4287
+ return url.href;
4288
+ } catch {
4289
+ return "";
4290
+ }
4291
+ }
2766
4292
  function escapeHtmlAttribute(value) {
2767
4293
  return value.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
2768
4294
  }
2769
- function secureRunnerSrcdoc(runtimeUrl) {
4295
+ function secureRunnerSrcdoc(runtimeUrl, styleUrl) {
2770
4296
  const nonce = randomToken(12);
4297
+ const styleSource = styleUrl ? ` ${cspSourceForRuntime(styleUrl)}` : "";
2771
4298
  const csp = [
2772
4299
  "default-src 'none'",
2773
4300
  `script-src 'nonce-${nonce}' 'unsafe-eval' ${cspSourceForRuntime(runtimeUrl)}`,
2774
4301
  "connect-src 'none'",
2775
4302
  "img-src data: blob:",
2776
- "style-src 'unsafe-inline'",
4303
+ `style-src 'unsafe-inline'${styleSource}`,
2777
4304
  "font-src data:",
2778
4305
  "form-action 'none'",
2779
4306
  "base-uri 'none'"
2780
4307
  ].join("; ");
2781
4308
  const style = "html,body{margin:0;min-height:100%;overflow:hidden;}#slexkit-secure-root{min-height:100%;}";
2782
- return `<!doctype html><html><head><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="${escapeHtmlAttribute(csp)}"><style>${style}</style></head><body><div id="slexkit-secure-root"></div><script type="module" nonce="${nonce}">import { startSlexKitSandboxRunner } from ${JSON.stringify(runtimeUrl)}; startSlexKitSandboxRunner();</script></body></html>`;
4309
+ const stylesheet = styleUrl ? `<link rel="stylesheet" href="${escapeHtmlAttribute(styleUrl)}">` : "";
4310
+ return `<!doctype html><html><head><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="${escapeHtmlAttribute(csp)}">${stylesheet}<style>${style}</style></head><body><div id="slexkit-secure-root"></div><script type="module" nonce="${nonce}">import { startSlexKitSandboxRunner } from ${JSON.stringify(runtimeUrl)}; startSlexKitSandboxRunner();</script></body></html>`;
2783
4311
  }
2784
4312
  function secureFrameLoadTimeout(options) {
2785
4313
  const frame = options.frame;
@@ -3031,11 +4559,21 @@ function createSandboxBridge(input, container, iframe, options) {
3031
4559
  if (data.type === "slot-size" && data.id === id && data.token === token && typeof data.slotId === "string") {
3032
4560
  const slot = artifactSlots.find((item) => item.id === data.slotId);
3033
4561
  if (slot && typeof data.height === "number" && Number.isFinite(data.height)) {
3034
- slot.container.style.minHeight = `${Math.max(0, Math.ceil(data.height))}px`;
4562
+ const height = Math.max(0, Math.ceil(data.height));
4563
+ slot.container.style.minHeight = `${height}px`;
4564
+ if (artifactSlots.length === 1) {
4565
+ iframe.style.height = `${Math.max(1, height)}px`;
4566
+ }
3035
4567
  requestArtifactSlotSync();
3036
4568
  }
3037
4569
  return;
3038
4570
  }
4571
+ if (data.type === "frame-size" && data.id === id && data.token === token) {
4572
+ if (artifactSlots.length <= 1 && typeof data.height === "number" && Number.isFinite(data.height)) {
4573
+ iframe.style.height = `${Math.max(1, Math.ceil(data.height))}px`;
4574
+ }
4575
+ return;
4576
+ }
3039
4577
  if (data.type === "error" && (!data.id || data.id === id) && (!data.token || data.token === token)) {
3040
4578
  const error = data;
3041
4579
  failLoad(ready ? "mounted" : "ready", typeof error.error?.message === "string" ? error.error.message : undefined);
@@ -3452,6 +4990,7 @@ function startSlexKitSandboxRunner() {
3452
4990
  let activeId;
3453
4991
  let activeToken;
3454
4992
  let heartbeatTimer;
4993
+ let rootResizeObserver;
3455
4994
  let slotResizeObserver;
3456
4995
  function clearHeartbeat() {
3457
4996
  if (heartbeatTimer === undefined)
@@ -3477,6 +5016,8 @@ function startSlexKitSandboxRunner() {
3477
5016
  if (id && activeId && id !== activeId)
3478
5017
  return;
3479
5018
  clearHeartbeat();
5019
+ rootResizeObserver?.disconnect();
5020
+ rootResizeObserver = undefined;
3480
5021
  slotResizeObserver?.disconnect();
3481
5022
  slotResizeObserver = undefined;
3482
5023
  cleanup?.();
@@ -3510,6 +5051,36 @@ function startSlexKitSandboxRunner() {
3510
5051
  height
3511
5052
  });
3512
5053
  }
5054
+ function reportFrameSize() {
5055
+ if (!activeId || !activeToken)
5056
+ return;
5057
+ const root = frameRoot();
5058
+ const rootRect = root.getBoundingClientRect();
5059
+ let contentBottom = rootRect.height;
5060
+ for (const child of root.querySelectorAll("*")) {
5061
+ const rect = child.getBoundingClientRect();
5062
+ contentBottom = Math.max(contentBottom, rect.bottom - rootRect.top);
5063
+ }
5064
+ const height = Math.max(root.scrollHeight, root.getBoundingClientRect().height, contentBottom, document.body?.scrollHeight ?? 0, document.documentElement?.scrollHeight ?? 0, 1);
5065
+ post({
5066
+ channel: "slexkit-secure",
5067
+ type: "frame-size",
5068
+ id: activeId,
5069
+ token: activeToken,
5070
+ height
5071
+ });
5072
+ }
5073
+ function observeFrameSize() {
5074
+ rootResizeObserver?.disconnect();
5075
+ rootResizeObserver = typeof ResizeObserver !== "undefined" ? new ResizeObserver(() => reportFrameSize()) : undefined;
5076
+ const root = frameRoot();
5077
+ rootResizeObserver?.observe(root);
5078
+ for (const child of root.children) {
5079
+ rootResizeObserver?.observe(child);
5080
+ }
5081
+ reportFrameSize();
5082
+ schedulingSnapshot.requestAnimationFrame?.(() => reportFrameSize());
5083
+ }
3513
5084
  function applySlotRects(slots) {
3514
5085
  const root = frameRoot();
3515
5086
  const multiSlot = slots.length > 1;
@@ -3566,6 +5137,7 @@ function startSlexKitSandboxRunner() {
3566
5137
  api: runtime.api
3567
5138
  });
3568
5139
  startHeartbeat(message.policy, message.id, message.token);
5140
+ observeFrameSize();
3569
5141
  post({
3570
5142
  channel: "slexkit-secure",
3571
5143
  type: "mounted",
@@ -3645,6 +5217,7 @@ var formatSlexKitDiagnosticApi = formatSlexKitDiagnostic;
3645
5217
  var mountSecureArtifactApi = mountSecureArtifact;
3646
5218
  var parseSlexSourceApi = parseSlexSource;
3647
5219
  var parseSlexKitDslApi = parseSlexKitDsl;
5220
+ var validateSlexSourceApi = validateSlexSource;
3648
5221
  var createSecureRuntimeApi = createSecureRuntime;
3649
5222
  var SlexKitRuntimeErrorApi = SlexKitRuntimeError;
3650
5223
  var getSlexKitRuntimeUrlApi = getSlexKitRuntimeUrl;
@@ -3652,12 +5225,15 @@ var setSlexKitRuntimeUrlApi = setSlexKitRuntimeUrl;
3652
5225
  var createSlexKitMarkdownRuntimeHostApi = createSlexKitMarkdownRuntimeHost;
3653
5226
  var getSlexKitMarkdownRuntimeHostApi = getSlexKitMarkdownRuntimeHost;
3654
5227
  var installSlexKitMarkdownRuntimeHostApi = installSlexKitMarkdownRuntimeHost;
5228
+ var slexkitStdApi = slexkitStd;
3655
5229
  var attachComponentDisposerApi = attachComponentDisposer;
3656
5230
  var configureComponentScopeApi = configureComponentScope;
3657
5231
  var startSlexKitSandboxRunnerApi = startSlexKitSandboxRunner;
3658
5232
  var getSlexKitInfoApi = getSlexKitInfo;
3659
5233
  export {
5234
+ validateSlexSourceApi as validateSlexSource,
3660
5235
  startSlexKitSandboxRunnerApi as startSlexKitSandboxRunner,
5236
+ slexkitStdApi as slexkitStd,
3661
5237
  setSlexKitRuntimeUrlApi as setSlexKitRuntimeUrl,
3662
5238
  registerApi as register,
3663
5239
  parseSlexSourceApi as parseSlexSource,