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.cjs CHANGED
@@ -39,7 +39,9 @@ var __export = (target, all) => {
39
39
  // src/runtime.ts
40
40
  var exports_runtime = {};
41
41
  __export(exports_runtime, {
42
+ validateSlexSource: () => validateSlexSourceApi,
42
43
  startSlexKitSandboxRunner: () => startSlexKitSandboxRunnerApi,
44
+ slexkitStd: () => slexkitStdApi,
43
45
  setSlexKitRuntimeUrl: () => setSlexKitRuntimeUrlApi,
44
46
  register: () => registerApi,
45
47
  parseSlexSource: () => parseSlexSourceApi,
@@ -583,6 +585,163 @@ function isEngineeringNumberResult(value) {
583
585
  return !!value && typeof value === "object" && "raw" in value && "number" in value && "valid" in value && "prefix" in value && "unit" in value && "normalized" in value;
584
586
  }
585
587
 
588
+ // src/engine/stdlib.ts
589
+ function toNumber(value) {
590
+ return Number(value);
591
+ }
592
+ function finiteNumber(value, fallback = 0) {
593
+ const parsed = toNumber(value);
594
+ return Number.isFinite(parsed) ? parsed : fallback;
595
+ }
596
+ function digits(value, fallback) {
597
+ const parsed = Math.trunc(finiteNumber(value, fallback));
598
+ return Math.max(0, Math.min(20, parsed));
599
+ }
600
+ function finiteValues(values) {
601
+ if (!Array.isArray(values))
602
+ return [];
603
+ return values.map(toNumber).filter(Number.isFinite);
604
+ }
605
+ function formatFixed(value, digitCount = 2) {
606
+ const parsed = toNumber(value);
607
+ return Number.isFinite(parsed) ? parsed.toFixed(digitCount) : "NaN";
608
+ }
609
+ function locale(value) {
610
+ return typeof value === "string" && value.trim() ? value : "en-US";
611
+ }
612
+ function currencyCode(value) {
613
+ return typeof value === "string" && /^[A-Za-z]{3}$/.test(value) ? value.toUpperCase() : "USD";
614
+ }
615
+ function formatNumber(value, digitCount, localeName, notation, style, currency, minimumFractionDigits = 0) {
616
+ const parsed = toNumber(value);
617
+ if (!Number.isFinite(parsed))
618
+ return "NaN";
619
+ return new Intl.NumberFormat(localeName, {
620
+ maximumFractionDigits: digitCount,
621
+ minimumFractionDigits,
622
+ notation,
623
+ style,
624
+ currency
625
+ }).format(parsed);
626
+ }
627
+ function freezeDeep(value) {
628
+ for (const child of Object.values(value)) {
629
+ if (child && typeof child === "object")
630
+ freezeDeep(child);
631
+ }
632
+ return Object.freeze(value);
633
+ }
634
+ var slexkitStd = freezeDeep({
635
+ math: {
636
+ clamp(value, min, max) {
637
+ const lower = finiteNumber(min);
638
+ const upper = finiteNumber(max);
639
+ const parsed = finiteNumber(value);
640
+ return Math.min(Math.max(parsed, Math.min(lower, upper)), Math.max(lower, upper));
641
+ },
642
+ round(value, digitValue = 0) {
643
+ const factor = 10 ** digits(digitValue, 0);
644
+ return Math.round(finiteNumber(value) * factor) / factor;
645
+ },
646
+ safeDivide(numerator, denominator, fallback = 0) {
647
+ const divisor = toNumber(denominator);
648
+ if (!Number.isFinite(divisor) || divisor === 0)
649
+ return finiteNumber(fallback);
650
+ const quotient = toNumber(numerator) / divisor;
651
+ return Number.isFinite(quotient) ? quotient : finiteNumber(fallback);
652
+ },
653
+ percent(part, total, digitValue = 1) {
654
+ const ratio = slexkitStd.math.safeDivide(part, total, NaN) * 100;
655
+ return slexkitStd.math.round(ratio, digitValue);
656
+ },
657
+ lerp(start, end, t) {
658
+ const a = finiteNumber(start);
659
+ return a + (finiteNumber(end) - a) * finiteNumber(t);
660
+ }
661
+ },
662
+ stats: {
663
+ sum(values) {
664
+ return finiteValues(values).reduce((total, value) => total + value, 0);
665
+ },
666
+ mean(values) {
667
+ const numbers = finiteValues(values);
668
+ return numbers.length ? slexkitStd.stats.sum(numbers) / numbers.length : NaN;
669
+ },
670
+ min(values) {
671
+ const numbers = finiteValues(values);
672
+ return numbers.length ? Math.min(...numbers) : NaN;
673
+ },
674
+ max(values) {
675
+ const numbers = finiteValues(values);
676
+ return numbers.length ? Math.max(...numbers) : NaN;
677
+ },
678
+ median(values) {
679
+ const numbers = finiteValues(values).sort((a, b) => a - b);
680
+ if (!numbers.length)
681
+ return NaN;
682
+ const middle = Math.floor(numbers.length / 2);
683
+ return numbers.length % 2 ? numbers[middle] : (numbers[middle - 1] + numbers[middle]) / 2;
684
+ }
685
+ },
686
+ format: {
687
+ fixed(value, digitValue = 2) {
688
+ return formatFixed(value, digits(digitValue, 2));
689
+ },
690
+ number(value, digitValue = 0, localeName = "en-US") {
691
+ return formatNumber(value, digits(digitValue, 0), locale(localeName));
692
+ },
693
+ compact(value, digitValue = 1, localeName = "en-US") {
694
+ return formatNumber(value, digits(digitValue, 1), locale(localeName), "compact");
695
+ },
696
+ percent(ratio, digitValue = 1) {
697
+ return `${formatFixed(finiteNumber(ratio) * 100, digits(digitValue, 1))}%`;
698
+ },
699
+ currency(value, currency = "USD", localeName = "en-US") {
700
+ return formatNumber(value, 2, locale(localeName), undefined, "currency", currencyCode(currency), 2);
701
+ }
702
+ },
703
+ units: {
704
+ withUnit(value, unit, digitValue = 2) {
705
+ const suffix = typeof unit === "string" ? unit : String(unit ?? "");
706
+ return `${formatFixed(value, digits(digitValue, 2))}${suffix ? ` ${suffix}` : ""}`;
707
+ },
708
+ bytes(value, digitValue = 1) {
709
+ const units = ["B", "KB", "MB", "GB", "TB", "PB"];
710
+ let amount = Math.abs(finiteNumber(value));
711
+ let index = 0;
712
+ while (amount >= 1024 && index < units.length - 1) {
713
+ amount /= 1024;
714
+ index += 1;
715
+ }
716
+ const sign = finiteNumber(value) < 0 ? -1 : 1;
717
+ return `${formatFixed(amount * sign, digits(digitValue, 1))} ${units[index]}`;
718
+ },
719
+ duration(ms, digitValue = 1) {
720
+ const value = finiteNumber(ms);
721
+ const abs = Math.abs(value);
722
+ if (abs < 1000)
723
+ return `${formatFixed(value, 0)} ms`;
724
+ if (abs < 60000)
725
+ return `${formatFixed(value / 1000, digits(digitValue, 1))} s`;
726
+ if (abs < 3600000)
727
+ return `${formatFixed(value / 60000, digits(digitValue, 1))} min`;
728
+ return `${formatFixed(value / 3600000, digits(digitValue, 1))} h`;
729
+ },
730
+ si(value, unit = "", digitValue = 2) {
731
+ const units = ["", "k", "M", "G", "T", "P"];
732
+ let amount = Math.abs(finiteNumber(value));
733
+ let index = 0;
734
+ while (amount >= 1000 && index < units.length - 1) {
735
+ amount /= 1000;
736
+ index += 1;
737
+ }
738
+ const sign = finiteNumber(value) < 0 ? -1 : 1;
739
+ const suffix = typeof unit === "string" ? unit : String(unit ?? "");
740
+ return `${formatFixed(amount * sign, digits(digitValue, 2))} ${units[index]}${suffix}`.trim();
741
+ }
742
+ }
743
+ });
744
+
586
745
  // src/engine/component-state.ts
587
746
  var IDENTIFIER = /^[A-Za-z_$][\w$]*$/;
588
747
  var componentStateProxies = new WeakMap;
@@ -813,6 +972,20 @@ function warnDuplicateState(ns, name, currentType, currentPath, previous) {
813
972
  console.warn(`[SlexKit][${ns}] Component state '${name}' is used by multiple component types (${previous.type}, ${currentType}); the latest rendered type controls write behavior.`);
814
973
  }
815
974
  }
975
+ function dynamicStateBinding(type, props) {
976
+ const mode = getComponentStateMode(type);
977
+ const value = mode === "checked" ? props.$checked ?? props.$value : mode === "enabled" ? props.$enabled : props.$value;
978
+ return typeof value === "string" ? value.trim() : undefined;
979
+ }
980
+ function isMirroredValueControlPair(previousType, currentType) {
981
+ return previousType === "input" && currentType === "slider" || previousType === "slider" && currentType === "input";
982
+ }
983
+ function shouldWarnDuplicateState(currentType, currentBinding, previous) {
984
+ if (currentBinding && previous.stateBinding === currentBinding && isMirroredValueControlPair(previous.type, currentType)) {
985
+ return false;
986
+ }
987
+ return true;
988
+ }
816
989
  function warnForState(ns, name, path) {
817
990
  console.warn(`[SlexKit][${ns}] Component state '${name}' is used with $for at ${path}; repeated items share one namespace-level instance state.`);
818
991
  }
@@ -826,11 +999,15 @@ function prepareComponentStatesInner(layout, components, componentTypes, ns, see
826
999
  const props = val;
827
1000
  const path = parentPath ? `${parentPath}.${key}` : key;
828
1001
  if (name && isStatefulComponent(type)) {
1002
+ const stateBinding = dynamicStateBinding(type, props);
829
1003
  const previous = seen.get(name);
830
- if (previous)
831
- warnDuplicateState(ns, name, type, path, previous);
832
- else
833
- seen.set(name, { type, path });
1004
+ if (previous) {
1005
+ if (shouldWarnDuplicateState(type, stateBinding, previous)) {
1006
+ warnDuplicateState(ns, name, type, path, previous);
1007
+ }
1008
+ } else {
1009
+ seen.set(name, { type, path, stateBinding });
1010
+ }
834
1011
  if (props.$for && isWritableComponent(type))
835
1012
  warnForState(ns, name, path);
836
1013
  const state = ensureComponentState(name, type, components, componentTypes);
@@ -843,9 +1020,15 @@ function prepareComponentStates(layout, components, componentTypes, ns) {
843
1020
  prepareComponentStatesInner(layout, components, componentTypes, ns, new Map);
844
1021
  }
845
1022
  function buildComponentEvalContext(g, components, componentTypes, api, forCtx) {
846
- const ctx = { g: createGProxy(g, components, componentTypes) };
1023
+ const ctx = {
1024
+ g: createGProxy(g, components, componentTypes),
1025
+ std: slexkitStd
1026
+ };
1027
+ const gKeys = new Set(Object.keys(rawRecord(g)));
847
1028
  for (const name of Object.keys(rawRecord(components))) {
848
- if (IDENTIFIER.test(name)) {
1029
+ if (name === "std" || name === "g" || name === "api")
1030
+ continue;
1031
+ if (IDENTIFIER.test(name) && !gKeys.has(name)) {
849
1032
  ctx[name] = publicComponentState(name, components[name], componentTypes);
850
1033
  }
851
1034
  }
@@ -853,6 +1036,8 @@ function buildComponentEvalContext(g, components, componentTypes, api, forCtx) {
853
1036
  ctx.api = api;
854
1037
  if (forCtx) {
855
1038
  for (const k of Object.keys(forCtx)) {
1039
+ if (k === "std")
1040
+ continue;
856
1041
  Object.defineProperty(ctx, k, {
857
1042
  get: () => {
858
1043
  const current = forCtx[k];
@@ -1023,6 +1208,7 @@ function renderIfNode(fullKey, props, container, g, components, componentTypes,
1023
1208
  };
1024
1209
  currentEl = renderWithFallback(renderer, innerProps, name, {
1025
1210
  g,
1211
+ std: slexkitStd,
1026
1212
  api,
1027
1213
  dir: options.dir,
1028
1214
  labels: options.labels,
@@ -1101,6 +1287,7 @@ function renderAndMountSlot(item, index, keyVal, indexSignal, revisionSignal, re
1101
1287
  };
1102
1288
  el = renderWithFallback(renderer, innerProps, name, {
1103
1289
  g,
1290
+ std: slexkitStd,
1104
1291
  api,
1105
1292
  dir: options.dir,
1106
1293
  labels: options.labels,
@@ -1250,6 +1437,7 @@ function renderNormalNode(fullKey, props, container, g, components, componentTyp
1250
1437
  };
1251
1438
  const el = renderWithFallback(renderer, nodeProps, name, {
1252
1439
  g,
1440
+ std: slexkitStd,
1253
1441
  api,
1254
1442
  dir: options.dir,
1255
1443
  labels: options.labels,
@@ -1603,7 +1791,7 @@ ${parseSource}
1603
1791
  var parseSlexKitDsl = parseSlexSource;
1604
1792
 
1605
1793
  // src/version.ts
1606
- var SLEXKIT_VERSION = "0.2.0";
1794
+ var SLEXKIT_VERSION = "0.3.0";
1607
1795
  var SLEX_PROTOCOL_VERSION = "0.1";
1608
1796
  var SLEXKIT_COMPONENTS_VERSION = SLEXKIT_VERSION;
1609
1797
  function getSlexKitInfo() {
@@ -1643,6 +1831,9 @@ function currentOrigin() {
1643
1831
  return "http://localhost";
1644
1832
  }
1645
1833
  function resolveUrl(url) {
1834
+ try {
1835
+ return new URL(url);
1836
+ } catch {}
1646
1837
  try {
1647
1838
  return new URL(url, currentOrigin());
1648
1839
  } catch {
@@ -2203,6 +2394,1324 @@ function createSecureRuntime(policy, hostAdapter) {
2203
2394
  }
2204
2395
  };
2205
2396
  }
2397
+ // src/components/spec-helpers.ts
2398
+ var SINCE = "0.1.0";
2399
+ function docs(type) {
2400
+ return {
2401
+ href: `/docs/components/${type}`,
2402
+ anchors: {
2403
+ api: `${type}-api-reference`,
2404
+ examples: `${type}-canonical-example`
2405
+ }
2406
+ };
2407
+ }
2408
+ function isSlexExpression(value) {
2409
+ return typeof value.namespace === "string" && typeof value.layout === "object" && value.layout !== null;
2410
+ }
2411
+ function example(type, propsOrSource, title = "Basic usage") {
2412
+ return {
2413
+ id: "basic",
2414
+ title,
2415
+ source: isSlexExpression(propsOrSource) ? {
2416
+ slex: propsOrSource.slex ?? SLEX_PROTOCOL_VERSION,
2417
+ ...propsOrSource
2418
+ } : {
2419
+ slex: SLEX_PROTOCOL_VERSION,
2420
+ namespace: `spec_${type.replaceAll("-", "_")}_basic`,
2421
+ layout: {
2422
+ [`${type}:demo`]: propsOrSource
2423
+ }
2424
+ }
2425
+ };
2426
+ }
2427
+ var semanticTones = ["info", "success", "warning", "danger", "muted"];
2428
+ var inputState = ["input", "slider", "select", "tabs", "radio-group"];
2429
+ var checkedState = ["checkbox"];
2430
+ var enabledState = ["switch"];
2431
+ var readableState = ["stat", "text", "progress", "badge", "callout", "code-block", "divider", "link", "table", "section"];
2432
+ function stateFor(type) {
2433
+ if (inputState.includes(type))
2434
+ return "value";
2435
+ if (checkedState.includes(type))
2436
+ return "checked";
2437
+ if (enabledState.includes(type))
2438
+ return "enabled";
2439
+ if (readableState.includes(type))
2440
+ return "readable";
2441
+ return "none";
2442
+ }
2443
+ function component(spec) {
2444
+ return {
2445
+ status: "ready",
2446
+ since: SINCE,
2447
+ docs: docs(spec.type),
2448
+ state: spec.state ?? stateFor(spec.type),
2449
+ ...spec
2450
+ };
2451
+ }
2452
+ var childContent = {
2453
+ allowed: true,
2454
+ description: "Nested component fields are rendered as child content in field order."
2455
+ };
2456
+ var noChildren = {
2457
+ allowed: false,
2458
+ description: "This component does not render nested child components."
2459
+ };
2460
+
2461
+ // src/components/entries/accordion.spec.ts
2462
+ var accordionSpec = component({
2463
+ type: "accordion",
2464
+ category: "Disclosure",
2465
+ title: "Accordion",
2466
+ summary: "Expandable grouped panels.",
2467
+ description: "Use accordion to reveal one or more sections from a compact list of panels.",
2468
+ props: {
2469
+ value: { type: "string | string[]", dynamic: true, description: "Current expanded item value; use an array when multiple is true." },
2470
+ multiple: { type: "boolean", default: false, description: "Allow multiple items to be expanded at the same time." },
2471
+ items: { type: "array", description: "Panel definitions with value, label, content, and optional icon." },
2472
+ "items[].icon": { type: "string", description: "Icon name shown before an item trigger label." },
2473
+ onchange: { type: "write-expression", description: "Write expression invoked when expanded items change." }
2474
+ },
2475
+ children: noChildren,
2476
+ examples: [example("accordion", {
2477
+ namespace: "doc_accordion_typical",
2478
+ layout: {
2479
+ "accordion:faq": {
2480
+ multiple: true,
2481
+ value: [
2482
+ "install"
2483
+ ],
2484
+ items: [
2485
+ {
2486
+ value: "install",
2487
+ label: "Install",
2488
+ icon: "download-simple",
2489
+ content: "Prepare dependencies."
2490
+ },
2491
+ {
2492
+ value: "review",
2493
+ label: "Review",
2494
+ icon: "check-circle",
2495
+ content: "Check the result."
2496
+ },
2497
+ {
2498
+ value: "ship",
2499
+ label: "Ship",
2500
+ icon: "rocket-launch",
2501
+ content: "Publish the change."
2502
+ }
2503
+ ]
2504
+ }
2505
+ }
2506
+ })]
2507
+ });
2508
+
2509
+ // src/components/entries/badge.spec.ts
2510
+ var badgeSpec = component({
2511
+ type: "badge",
2512
+ category: "Content",
2513
+ title: "Badge",
2514
+ summary: "Compact label for status or classification.",
2515
+ description: "Use badge to annotate nearby content with a short semantic label.",
2516
+ props: {
2517
+ label: { type: "string", dynamic: true, description: "Badge text." },
2518
+ text: { type: "string", dynamic: true, description: "Alias for label." },
2519
+ content: { type: "string", dynamic: true, description: "Alias for label." },
2520
+ icon: { type: "string", description: "Icon name shown before the badge label." },
2521
+ tone: { type: "string", values: semanticTones, default: "info", description: "Semantic tone applied to the badge." },
2522
+ variant: { type: "string", values: semanticTones, description: "Alias for tone." }
2523
+ },
2524
+ children: noChildren,
2525
+ examples: [example("badge", {
2526
+ namespace: "doc_badge_typical",
2527
+ layout: {
2528
+ "row:badges": {
2529
+ "badge:ready": {
2530
+ label: "ready",
2531
+ icon: "check-circle",
2532
+ tone: "success"
2533
+ },
2534
+ "badge:pending": {
2535
+ label: "pending",
2536
+ tone: "warning"
2537
+ },
2538
+ "badge:info": {
2539
+ label: "info",
2540
+ tone: "info"
2541
+ }
2542
+ }
2543
+ }
2544
+ })]
2545
+ });
2546
+
2547
+ // src/components/entries/button.spec.ts
2548
+ var buttonSpec = component({
2549
+ type: "button",
2550
+ category: "Action",
2551
+ title: "Button",
2552
+ summary: "Action trigger.",
2553
+ description: "Use button for explicit actions in interactive SlexKit layouts.",
2554
+ props: {
2555
+ label: { type: "string", dynamic: true, description: "Visible button text and accessible name." },
2556
+ icon: { type: "string", description: "Icon name shown before the label." },
2557
+ iconOnly: { type: "boolean", default: false, description: "Show only the icon while retaining label as the accessible name." },
2558
+ variant: { type: "string", values: ["primary", "secondary", "danger", "ghost"], default: "primary", description: "Semantic action variant." },
2559
+ disabled: { type: "boolean", default: false, dynamic: true, description: "Disable the action." },
2560
+ href: { type: "string", dynamic: true, description: "Render the button surface as a link to this URL." },
2561
+ target: { type: "string", description: "Link target used when href is present." },
2562
+ title: { type: "string", dynamic: true, description: "Tooltip and accessible-label fallback." },
2563
+ selected: { type: "boolean", dynamic: true, description: "Render the icon in its selected visual state." },
2564
+ active: { type: "boolean", dynamic: true, description: "Render the icon in its active visual state." },
2565
+ pressed: { type: "boolean", dynamic: true, description: "Expose pressed state and render the selected icon style." },
2566
+ onclick: { type: "write-expression", description: "Write expression invoked when the button is clicked." }
2567
+ },
2568
+ children: noChildren,
2569
+ examples: [example("button", {
2570
+ namespace: "doc_button_typical",
2571
+ layout: {
2572
+ "row:actions": {
2573
+ "button:save": {
2574
+ label: "Save",
2575
+ icon: "floppy-disk",
2576
+ variant: "primary"
2577
+ },
2578
+ "button:cancel": {
2579
+ label: "Cancel",
2580
+ variant: "secondary"
2581
+ },
2582
+ "button:delete": {
2583
+ label: "Delete",
2584
+ variant: "danger"
2585
+ }
2586
+ }
2587
+ }
2588
+ })]
2589
+ });
2590
+
2591
+ // src/components/entries/callout.spec.ts
2592
+ var calloutSpec = component({
2593
+ type: "callout",
2594
+ category: "Content",
2595
+ title: "Callout",
2596
+ summary: "Highlighted contextual message.",
2597
+ description: "Use callout for notes, warnings, and other contextual blocks.",
2598
+ props: {
2599
+ title: { type: "string", dynamic: true, description: "Callout title." },
2600
+ heading: { type: "string", dynamic: true, description: "Alias for title." },
2601
+ label: { type: "string", dynamic: true, description: "Alias for title." },
2602
+ icon: { type: "string", description: "Icon name shown before the title." },
2603
+ text: { type: "string", dynamic: true, description: "Callout body text." },
2604
+ message: { type: "string", dynamic: true, description: "Alias for text." },
2605
+ content: { type: "string", dynamic: true, description: "Alias for text." },
2606
+ tone: { type: "string", values: ["info", "success", "warning", "danger"], default: "info", description: "Semantic tone for the callout." }
2607
+ },
2608
+ children: childContent,
2609
+ examples: [example("callout", {
2610
+ namespace: "doc_callout_typical",
2611
+ layout: {
2612
+ "callout:notice": {
2613
+ tone: "info",
2614
+ title: "Notice",
2615
+ icon: "info",
2616
+ text: "Use callout for information that should stand out."
2617
+ }
2618
+ }
2619
+ })]
2620
+ });
2621
+
2622
+ // src/components/entries/card.spec.ts
2623
+ var cardSpec = component({
2624
+ type: "card",
2625
+ category: "Layout",
2626
+ title: "Card",
2627
+ summary: "Bordered grouping container.",
2628
+ description: "Use card to group related content on a bounded surface.",
2629
+ props: {
2630
+ title: { type: "string", dynamic: true, description: "Card title." },
2631
+ icon: { type: "string", description: "Icon name shown before the title." },
2632
+ tone: { type: "string", values: semanticTones, description: "Optional semantic tone for the card surface." }
2633
+ },
2634
+ children: childContent,
2635
+ examples: [example("card", {
2636
+ namespace: "doc_card_typical",
2637
+ layout: {
2638
+ "card:metrics": {
2639
+ title: "Metrics",
2640
+ icon: "chart-bar",
2641
+ "grid:items": {
2642
+ columns: 2,
2643
+ "stat:requests": {
2644
+ label: "Requests",
2645
+ value: "1.2k",
2646
+ unit: "/min"
2647
+ },
2648
+ "stat:latency": {
2649
+ label: "Latency",
2650
+ value: "42",
2651
+ unit: "ms"
2652
+ }
2653
+ }
2654
+ }
2655
+ }
2656
+ })]
2657
+ });
2658
+
2659
+ // src/components/entries/checkbox.spec.ts
2660
+ var checkboxSpec = component({
2661
+ type: "checkbox",
2662
+ category: "Input",
2663
+ title: "Checkbox",
2664
+ summary: "Boolean checkbox input.",
2665
+ description: "Use checkbox for binary choices that can be toggled independently.",
2666
+ props: {
2667
+ checked: { type: "boolean", default: false, dynamic: true, description: "Checked state." },
2668
+ label: { type: "string", dynamic: true, description: "Checkbox label." },
2669
+ icon: { type: "string", description: "Icon name shown before the visible label." },
2670
+ disabled: { type: "boolean", default: false, dynamic: true, description: "Disable the checkbox." },
2671
+ haptic: { type: "boolean", default: true, description: "Enable vibration feedback on supported devices." },
2672
+ haptics: { type: "boolean", default: true, description: "Alias for haptic." },
2673
+ onchange: { type: "write-expression", description: "Write expression invoked when checked state changes." }
2674
+ },
2675
+ children: noChildren,
2676
+ examples: [example("checkbox", {
2677
+ namespace: "doc_checkbox_typical",
2678
+ layout: {
2679
+ "checkbox:agree": {
2680
+ checked: true,
2681
+ label: "I agree",
2682
+ icon: "handshake"
2683
+ }
2684
+ }
2685
+ })]
2686
+ });
2687
+
2688
+ // src/components/entries/code-block.spec.ts
2689
+ var codeBlockSpec = component({
2690
+ type: "code-block",
2691
+ category: "Content",
2692
+ title: "Code Block",
2693
+ summary: "Formatted code or log block.",
2694
+ description: "Use code-block for static code samples, configuration snippets, and logs.",
2695
+ props: {
2696
+ code: { type: "string", dynamic: true, description: "Code text content." },
2697
+ source: { type: "string", dynamic: true, description: "Alias for code." },
2698
+ content: { type: "string", dynamic: true, description: "Alias for code." },
2699
+ language: { type: "string", description: "Language label." },
2700
+ title: { type: "string", description: "Code block title." },
2701
+ icon: { type: "string", description: "Icon name shown before the title." },
2702
+ lineNumbers: { type: "boolean", default: true, description: "Show line numbers." }
2703
+ },
2704
+ children: noChildren,
2705
+ examples: [example("code-block", {
2706
+ namespace: "doc_code_block_typical",
2707
+ layout: {
2708
+ "code-block:config": {
2709
+ title: "Config",
2710
+ icon: "code",
2711
+ language: "js",
2712
+ code: "export const enabled = true;"
2713
+ }
2714
+ }
2715
+ })]
2716
+ });
2717
+
2718
+ // src/components/entries/collapsible.spec.ts
2719
+ var collapsibleSpec = component({
2720
+ type: "collapsible",
2721
+ category: "Disclosure",
2722
+ title: "Collapsible",
2723
+ summary: "Single expandable region.",
2724
+ description: "Use collapsible to show or hide one related content region.",
2725
+ props: {
2726
+ open: { type: "boolean", default: false, dynamic: true, description: "Expanded state." },
2727
+ trigger: { type: "string", dynamic: true, description: "Trigger button text." },
2728
+ icon: { type: "string", description: "Icon name shown before trigger text." },
2729
+ content: { type: "string", dynamic: true, description: "Static body content." },
2730
+ onchange: { type: "write-expression", description: "Write expression invoked when open state changes." }
2731
+ },
2732
+ children: childContent,
2733
+ examples: [example("collapsible", {
2734
+ namespace: "doc_collapsible_typical",
2735
+ layout: {
2736
+ "collapsible:more": {
2737
+ open: true,
2738
+ trigger: "Details",
2739
+ icon: "caret-circle-down",
2740
+ content: "This secondary content can be collapsed."
2741
+ }
2742
+ }
2743
+ })]
2744
+ });
2745
+
2746
+ // src/components/entries/column.spec.ts
2747
+ var columnSpec = component({
2748
+ type: "column",
2749
+ category: "Layout",
2750
+ title: "Column",
2751
+ summary: "Vertical layout container.",
2752
+ description: "Use column to stack child components vertically in field order.",
2753
+ props: {},
2754
+ children: childContent,
2755
+ examples: [example("column", {
2756
+ namespace: "doc_column_typical",
2757
+ layout: {
2758
+ "column:form": {
2759
+ "input:name": {
2760
+ placeholder: "Name"
2761
+ },
2762
+ "input:email": {
2763
+ placeholder: "Email"
2764
+ },
2765
+ "button:save": {
2766
+ label: "Save"
2767
+ }
2768
+ }
2769
+ }
2770
+ })]
2771
+ });
2772
+
2773
+ // src/components/entries/divider.spec.ts
2774
+ var dividerSpec = component({
2775
+ type: "divider",
2776
+ category: "Content",
2777
+ title: "Divider",
2778
+ summary: "Visual separator.",
2779
+ description: "Use divider to separate related regions, optionally with a label.",
2780
+ props: {
2781
+ label: { type: "string", dynamic: true, description: "Text shown in the divider." },
2782
+ icon: { type: "string", description: "Icon name shown before the label." }
2783
+ },
2784
+ children: noChildren,
2785
+ examples: [example("divider", {
2786
+ namespace: "doc_divider_typical",
2787
+ layout: {
2788
+ "column:content": {
2789
+ "text:top": {
2790
+ text: "Above"
2791
+ },
2792
+ "divider:line": {
2793
+ label: "Divider",
2794
+ icon: "flag"
2795
+ },
2796
+ "text:bottom": {
2797
+ text: "Below"
2798
+ }
2799
+ }
2800
+ }
2801
+ })]
2802
+ });
2803
+
2804
+ // src/components/entries/formula.spec.ts
2805
+ var formulaSpec = component({
2806
+ type: "formula",
2807
+ category: "Display",
2808
+ title: "Formula",
2809
+ summary: "Reactive KaTeX formula display.",
2810
+ description: "Use formula to render SlexKit state and computed values through KaTeX.",
2811
+ props: {
2812
+ tex: { type: "string", dynamic: true, description: "KaTeX source to render." },
2813
+ formula: { type: "string", dynamic: true, description: "Alias for tex." },
2814
+ value: { type: "string", dynamic: true, description: "Alias for tex." },
2815
+ displayMode: { type: "boolean", default: true, description: "Render as display math when true; inline math when false." },
2816
+ display: { type: "boolean", default: true, description: "Alias for displayMode." },
2817
+ block: { type: "boolean", default: true, description: "Alias for displayMode." }
2818
+ },
2819
+ children: noChildren,
2820
+ examples: [example("formula", {
2821
+ namespace: "doc_formula_typical",
2822
+ g: {
2823
+ r: 1e4,
2824
+ c: 100,
2825
+ fc: 159.15
2826
+ },
2827
+ layout: {
2828
+ "formula:cutoff": {
2829
+ $tex: "'f_c = \\\\frac{1}{2\\\\pi RC} = ' + g.fc + '\\\\text{ Hz}'"
2830
+ }
2831
+ }
2832
+ })]
2833
+ });
2834
+
2835
+ // src/components/entries/grid.spec.ts
2836
+ var gridSpec = component({
2837
+ type: "grid",
2838
+ category: "Layout",
2839
+ title: "Grid",
2840
+ summary: "Responsive grid container.",
2841
+ description: "Use grid to arrange child components in responsive columns.",
2842
+ props: {
2843
+ columns: { type: "number", default: 1, dynamic: true, description: "Base column count." },
2844
+ smColumns: { type: "number", dynamic: true, description: "Column count at the small breakpoint." },
2845
+ mdColumns: { type: "number", dynamic: true, description: "Column count at the medium breakpoint." },
2846
+ lgColumns: { type: "number", dynamic: true, description: "Column count at the large breakpoint." },
2847
+ xlColumns: { type: "number", dynamic: true, description: "Column count at the extra-large breakpoint." },
2848
+ gap: { type: "string", dynamic: true, description: "Spacing between grid items." }
2849
+ },
2850
+ children: childContent,
2851
+ examples: [example("grid", {
2852
+ namespace: "doc_grid_typical",
2853
+ layout: {
2854
+ "grid:stats": {
2855
+ columns: 1,
2856
+ mdColumns: 3,
2857
+ "stat:a": {
2858
+ label: "Requests",
2859
+ value: "1.2k"
2860
+ },
2861
+ "stat:b": {
2862
+ label: "Success",
2863
+ value: "98%"
2864
+ },
2865
+ "stat:c": {
2866
+ label: "Errors",
2867
+ value: "3"
2868
+ }
2869
+ }
2870
+ }
2871
+ })]
2872
+ });
2873
+
2874
+ // src/components/entries/icon.spec.ts
2875
+ var iconSpec = component({
2876
+ type: "icon",
2877
+ category: "Component",
2878
+ title: "Icon",
2879
+ summary: "Shared icon field capability.",
2880
+ description: "Icon is a shared field capability, not an independent icon component type.",
2881
+ props: {
2882
+ icon: { type: "string", description: "Icon name resolved through the global icon manager." },
2883
+ iconOnly: { type: "boolean", description: "Render only the icon while retaining an accessible label where supported." },
2884
+ "items[].icon": { type: "string", description: "Accordion item trigger icon." },
2885
+ "options[].icon": { type: "string", description: "Select or radio option icon." },
2886
+ "columns[].icon": { type: "string", description: "Table column header icon." },
2887
+ "tabs[].icon": { type: "string", description: "Tab trigger icon." },
2888
+ "tabs[].iconOnly": { type: "boolean", description: "Tab trigger icon-only mode." }
2889
+ },
2890
+ children: noChildren,
2891
+ examples: [example("button", { label: "Settings", icon: "gear-six", iconOnly: true, variant: "ghost" }, "Icon field usage")]
2892
+ });
2893
+
2894
+ // src/components/entries/input.spec.ts
2895
+ var inputSpec = component({
2896
+ type: "input",
2897
+ category: "Input",
2898
+ title: "Input",
2899
+ summary: "Text or engineering-value input.",
2900
+ description: "Use input for editable text and engineering numeric values.",
2901
+ props: {
2902
+ value: { type: "string", dynamic: true, description: "Current input value." },
2903
+ label: { type: "string", dynamic: true, description: "Input label." },
2904
+ unit: { type: "string", dynamic: true, description: "Trailing unit text." },
2905
+ description: { type: "string", dynamic: true, description: "Assistive description below the input." },
2906
+ help: { type: "string", dynamic: true, description: "Alias for description." },
2907
+ hint: { type: "string", dynamic: true, description: "Alias for description." },
2908
+ error: { type: "string", dynamic: true, description: "Error text shown below the input and linked with aria-describedby." },
2909
+ errorMessage: { type: "string", dynamic: true, description: "Alias for error." },
2910
+ invalid: { type: "boolean", default: false, dynamic: true, description: "Mark the input as invalid with aria-invalid and error styling." },
2911
+ placeholder: { type: "string", description: "Placeholder text for empty values." },
2912
+ type: { type: "string", default: "text", description: "Input value kind; use engineering for parsed engineering values." },
2913
+ disabled: { type: "boolean", default: false, dynamic: true, description: "Disable editing." },
2914
+ readonly: { type: "boolean", default: false, dynamic: true, description: "Make the input read-only." },
2915
+ readOnly: { type: "boolean", default: false, dynamic: true, description: "Alias for readonly." },
2916
+ required: { type: "boolean", default: false, dynamic: true, description: "Mark the input as required." },
2917
+ id: { type: "string", description: "Native input id; defaults to a stable id derived from the component name." },
2918
+ name: { type: "string", description: "Native input name attribute." },
2919
+ min: { type: "string | number", dynamic: true, description: "Minimum value used by numeric input controls." },
2920
+ max: { type: "string | number", dynamic: true, description: "Maximum value used by numeric input controls." },
2921
+ step: { type: "string | number", dynamic: true, description: "Step size used by numeric input controls." },
2922
+ controls: { type: "boolean", default: true, dynamic: true, description: "Show decrement and increment buttons for numeric inputs." },
2923
+ onchange: { type: "write-expression", description: "Write expression invoked when the value changes." }
2924
+ },
2925
+ children: noChildren,
2926
+ examples: [example("input", {
2927
+ namespace: "doc_input_typical",
2928
+ layout: {
2929
+ "input:name": {
2930
+ label: "Project",
2931
+ value: "SlexKit",
2932
+ placeholder: "Enter name",
2933
+ description: "Visible labels keep form fields scannable."
2934
+ }
2935
+ }
2936
+ })]
2937
+ });
2938
+
2939
+ // src/components/entries/link.spec.ts
2940
+ var linkSpec = component({
2941
+ type: "link",
2942
+ category: "Content",
2943
+ title: "Link",
2944
+ summary: "Inline navigation link.",
2945
+ description: "Use link to navigate to another page or resource.",
2946
+ props: {
2947
+ href: { type: "string", description: "Target URL." },
2948
+ text: { type: "string", dynamic: true, description: "Visible link text." },
2949
+ label: { type: "string", dynamic: true, description: "Alias for text." },
2950
+ content: { type: "string", dynamic: true, description: "Alias for text." },
2951
+ icon: { type: "string", description: "Icon name shown before link text." },
2952
+ target: { type: "string", description: "Native link target attribute." },
2953
+ variant: { type: "string", values: ["default", "muted"], default: "default", description: "Link visual variant." }
2954
+ },
2955
+ children: noChildren,
2956
+ examples: [example("link", {
2957
+ namespace: "doc_link_typical",
2958
+ layout: {
2959
+ "column:links": {
2960
+ "link:docs": {
2961
+ href: "/components",
2962
+ icon: "arrow-square-out",
2963
+ text: "View components"
2964
+ }
2965
+ }
2966
+ }
2967
+ })]
2968
+ });
2969
+
2970
+ // src/components/entries/playground.spec.ts
2971
+ var playgroundSpec = component({
2972
+ type: "playground",
2973
+ category: "Tooling",
2974
+ title: "Playground",
2975
+ summary: "Interactive source preview.",
2976
+ description: "Use playground in documentation surfaces to render editable SlexKit or Markdown examples.",
2977
+ props: {
2978
+ source: { type: "object | string", description: "SlexKit or Markdown source to preview." },
2979
+ sourceType: { type: "string", values: ["slex", "markdown", "auto-markdown"], default: "slex", description: "Source parser mode." },
2980
+ title: { type: "string", description: "Playground title." },
2981
+ previewAlign: { type: "string", values: ["center", "start"], default: "center", description: "Vertical preview alignment in render mode." },
2982
+ alignPreview: { type: "string", values: ["center", "start"], description: "Alias for previewAlign." },
2983
+ previewPlacement: { type: "string", values: ["center", "start"], description: "Alias for previewAlign." },
2984
+ previewMinHeight: { type: "string", description: "Minimum preview area height." },
2985
+ previewMaxWidth: { type: "string", description: "Maximum preview content width." },
2986
+ themeToggle: { type: "boolean", default: false, description: "Show the theme toggle action." },
2987
+ showThemeToggle: { type: "boolean", default: false, description: "Alias for themeToggle." },
2988
+ enableThemeToggle: { type: "boolean", default: false, description: "Alias for themeToggle." },
2989
+ themeLabel: { type: "string", description: "Accessible label for the theme toggle action." },
2990
+ themeToggleLabel: { type: "string", description: "Alias for themeLabel." },
2991
+ sourceTypeLabel: { type: "string", description: "Accessible label for the source type selector." },
2992
+ copyLabel: { type: "string", description: "Accessible label for the copy source action." },
2993
+ openWebLabel: { type: "string", description: "Accessible label for opening the source in the standalone playground." },
2994
+ webUrl: { type: "string", description: "Standalone playground URL used by the open action." },
2995
+ playgroundUrl: { type: "string", description: "Alias for webUrl." }
2996
+ },
2997
+ children: noChildren,
2998
+ examples: [example("playground", {
2999
+ namespace: "doc_playground_typical",
3000
+ layout: {
3001
+ "playground:demo": {
3002
+ title: "Stat Playground",
3003
+ previewMinHeight: "180px",
3004
+ source: {
3005
+ namespace: "inner_stat_demo",
3006
+ layout: {
3007
+ "stat:value": {
3008
+ label: "Requests",
3009
+ value: "1.2k",
3010
+ unit: "/min"
3011
+ }
3012
+ }
3013
+ }
3014
+ }
3015
+ }
3016
+ })]
3017
+ });
3018
+
3019
+ // src/components/entries/progress.spec.ts
3020
+ var progressSpec = component({
3021
+ type: "progress",
3022
+ category: "Feedback",
3023
+ title: "Progress",
3024
+ summary: "Progress bar.",
3025
+ description: "Use progress to show completion as a percentage.",
3026
+ props: {
3027
+ value: { type: "number", default: 0, dynamic: true, description: "Progress percentage from 0 to 100." },
3028
+ label: { type: "string", dynamic: true, description: "Progress label." },
3029
+ icon: { type: "string", description: "Icon name shown before the label." },
3030
+ indeterminate: { type: "boolean", default: false, dynamic: true, description: "Render an indeterminate progress state without aria-valuenow." }
3031
+ },
3032
+ children: noChildren,
3033
+ examples: [example("progress", {
3034
+ namespace: "doc_progress_typical",
3035
+ layout: {
3036
+ "progress:build": {
3037
+ label: "Build progress",
3038
+ icon: "gear-six",
3039
+ value: 64
3040
+ }
3041
+ }
3042
+ })]
3043
+ });
3044
+
3045
+ // src/components/entries/radio-group.spec.ts
3046
+ var radioGroupSpec = component({
3047
+ type: "radio-group",
3048
+ category: "Input",
3049
+ title: "Radio Group",
3050
+ summary: "Single-choice option group.",
3051
+ description: "Use radio-group for one-of-many choices.",
3052
+ props: {
3053
+ value: { type: "string", dynamic: true, description: "Current selected value." },
3054
+ label: { type: "string", dynamic: true, description: "Group label." },
3055
+ icon: { type: "string", description: "Icon name shown before the group label." },
3056
+ options: { type: "array", description: "Options with label, value, and optional icon." },
3057
+ "options[].icon": { type: "string", description: "Icon name shown before a single option label." },
3058
+ disabled: { type: "boolean", default: false, dynamic: true, description: "Disable every radio option in the group." },
3059
+ orientation: { type: "string", values: ["vertical", "horizontal"], default: "vertical", description: "Radio option layout direction." },
3060
+ haptic: { type: "boolean", default: true, description: "Enable vibration feedback on supported devices." },
3061
+ haptics: { type: "boolean", default: true, description: "Alias for haptic." },
3062
+ name: { type: "string", description: "Native radio group name shared by options." },
3063
+ onchange: { type: "write-expression", description: "Write expression invoked when selection changes." }
3064
+ },
3065
+ children: noChildren,
3066
+ examples: [example("radio-group", {
3067
+ namespace: "doc_radio_group_typical",
3068
+ layout: {
3069
+ "radio-group:mode": {
3070
+ label: "Mode",
3071
+ icon: "sliders-horizontal",
3072
+ value: "auto",
3073
+ options: [
3074
+ {
3075
+ label: "Auto",
3076
+ value: "auto",
3077
+ icon: "sparkle"
3078
+ },
3079
+ {
3080
+ label: "Manual",
3081
+ value: "manual",
3082
+ icon: "wrench"
3083
+ }
3084
+ ]
3085
+ }
3086
+ }
3087
+ })]
3088
+ });
3089
+
3090
+ // src/components/entries/row.spec.ts
3091
+ var rowSpec = component({
3092
+ type: "row",
3093
+ category: "Layout",
3094
+ title: "Row",
3095
+ summary: "Horizontal layout container.",
3096
+ description: "Use row to place child components horizontally in field order.",
3097
+ props: {
3098
+ justify: { type: "string", values: ["start", "center", "end", "space-between", "space-around"], default: "start", description: "Main-axis distribution." },
3099
+ align: { type: "string", values: ["start", "center", "end", "baseline", "stretch"], default: "center", description: "Cross-axis alignment." },
3100
+ gap: { type: "string", dynamic: true, description: "Spacing between children." }
3101
+ },
3102
+ children: childContent,
3103
+ examples: [example("row", {
3104
+ namespace: "doc_row_typical",
3105
+ layout: {
3106
+ "row:toolbar": {
3107
+ justify: "space-between",
3108
+ "text:title": {
3109
+ text: "Runtime status"
3110
+ },
3111
+ "button:refresh": {
3112
+ label: "Refresh"
3113
+ }
3114
+ }
3115
+ }
3116
+ })]
3117
+ });
3118
+
3119
+ // src/components/entries/section.spec.ts
3120
+ var sectionSpec = component({
3121
+ type: "section",
3122
+ category: "Content",
3123
+ title: "Section",
3124
+ summary: "Page section with optional heading chrome.",
3125
+ description: "Use section to group page content with title, subtitle, and optional action link.",
3126
+ props: {
3127
+ title: { type: "string", dynamic: true, description: "Section title." },
3128
+ icon: { type: "string", description: "Icon name shown before the title." },
3129
+ eyebrow: { type: "string", dynamic: true, description: "Small label above the title." },
3130
+ subtitle: { type: "string", dynamic: true, description: "Subtitle text below the title." },
3131
+ actionLabel: { type: "string", dynamic: true, description: "Optional action link label." },
3132
+ actionHref: { type: "string", description: "Optional action link target." }
3133
+ },
3134
+ children: childContent,
3135
+ examples: [example("section", {
3136
+ namespace: "doc_section_typical",
3137
+ layout: {
3138
+ "section:overview": {
3139
+ eyebrow: "Dashboard",
3140
+ title: "Runtime overview",
3141
+ icon: "chart-bar",
3142
+ subtitle: "This section groups the most important state.",
3143
+ "stat:latency": {
3144
+ label: "Latency",
3145
+ value: "42",
3146
+ unit: "ms"
3147
+ }
3148
+ }
3149
+ }
3150
+ })]
3151
+ });
3152
+
3153
+ // src/components/entries/select.spec.ts
3154
+ var selectSpec = component({
3155
+ type: "select",
3156
+ category: "Input",
3157
+ title: "Select",
3158
+ summary: "Dropdown selection input.",
3159
+ description: "Use select for compact single-choice selection from an option list.",
3160
+ props: {
3161
+ label: { type: "string", dynamic: true, description: "Select label." },
3162
+ icon: { type: "string", description: "Icon name shown before the top label." },
3163
+ value: { type: "string", dynamic: true, description: "Current selected value." },
3164
+ options: { type: "array", description: "Options with label, value, and optional icon." },
3165
+ "options[].icon": { type: "string", description: "Icon name shown before an option label." },
3166
+ placeholder: { type: "string", description: "Placeholder shown when no value is selected." },
3167
+ disabled: { type: "boolean", default: false, dynamic: true, description: "Disable the select trigger and native select." },
3168
+ required: { type: "boolean", default: false, dynamic: true, description: "Require a non-placeholder value in the native select." },
3169
+ variant: { type: "string", values: ["default", "toolbar"], default: "default", description: "Select surface variant." },
3170
+ onchange: { type: "write-expression", description: "Write expression invoked when selection changes." }
3171
+ },
3172
+ children: noChildren,
3173
+ examples: [example("select", {
3174
+ namespace: "doc_select_typical",
3175
+ layout: {
3176
+ "select:env": {
3177
+ label: "Environment",
3178
+ icon: "server",
3179
+ value: "prod",
3180
+ options: [
3181
+ {
3182
+ label: "Development",
3183
+ value: "dev",
3184
+ icon: "code"
3185
+ },
3186
+ {
3187
+ label: "Production",
3188
+ value: "prod",
3189
+ icon: "rocket-launch"
3190
+ }
3191
+ ]
3192
+ }
3193
+ }
3194
+ })]
3195
+ });
3196
+
3197
+ // src/components/entries/slider.spec.ts
3198
+ var sliderSpec = component({
3199
+ type: "slider",
3200
+ category: "Input",
3201
+ title: "Slider",
3202
+ summary: "Numeric range input.",
3203
+ description: "Use slider for bounded numeric adjustments such as volume, brightness, or thresholds.",
3204
+ props: {
3205
+ label: { type: "string", dynamic: true, description: "Slider label." },
3206
+ icon: { type: "string", description: "Icon name shown before the label." },
3207
+ value: { type: "number", default: 0, dynamic: true, description: "Current numeric value." },
3208
+ min: { type: "number", default: 0, dynamic: true, description: "Minimum value." },
3209
+ max: { type: "number", default: 100, dynamic: true, description: "Maximum value." },
3210
+ step: { type: "number", default: 1, dynamic: true, description: "Step interval." },
3211
+ unit: { type: "string", dynamic: true, description: "Unit shown after the value." },
3212
+ disabled: { type: "boolean", default: false, dynamic: true, description: "Disable the range input." },
3213
+ orientation: { type: "string", values: ["horizontal", "vertical"], default: "horizontal", description: "Slider orientation metadata used for styling." },
3214
+ haptic: { type: "boolean", default: true, description: "Enable vibration feedback on supported devices." },
3215
+ haptics: { type: "boolean", default: true, description: "Alias for haptic." },
3216
+ onchange: { type: "write-expression", description: "Write expression invoked when the value changes." }
3217
+ },
3218
+ children: noChildren,
3219
+ examples: [example("slider", {
3220
+ namespace: "doc_slider_typical",
3221
+ layout: {
3222
+ "slider:volume": {
3223
+ label: "Volume",
3224
+ icon: "speaker-high",
3225
+ value: 42,
3226
+ min: 0,
3227
+ max: 100,
3228
+ step: 1,
3229
+ unit: "%"
3230
+ }
3231
+ }
3232
+ })]
3233
+ });
3234
+
3235
+ // src/components/entries/stat.spec.ts
3236
+ var statSpec = component({
3237
+ type: "stat",
3238
+ category: "Display",
3239
+ title: "Stat",
3240
+ summary: "Metric display.",
3241
+ description: "Use stat to present a labeled metric value with optional unit and semantic tone.",
3242
+ props: {
3243
+ label: { type: "string", dynamic: true, description: "Metric label." },
3244
+ icon: { type: "string", description: "Icon name shown before the label." },
3245
+ value: { type: "string | number", dynamic: true, description: "Metric value." },
3246
+ unit: { type: "string", dynamic: true, description: "Unit shown after the value." },
3247
+ tone: { type: "string", values: semanticTones, description: "Optional semantic tone." },
3248
+ animateInitial: { type: "boolean", default: false, description: "Animate the initial rendered value." }
3249
+ },
3250
+ children: noChildren,
3251
+ examples: [example("stat", {
3252
+ namespace: "doc_stat_typical",
3253
+ layout: {
3254
+ "grid:stats": {
3255
+ columns: 2,
3256
+ "stat:requests": {
3257
+ label: "Requests",
3258
+ icon: "activity",
3259
+ value: "1.2k",
3260
+ unit: "/min"
3261
+ },
3262
+ "stat:success": {
3263
+ label: "Success",
3264
+ icon: "check-circle",
3265
+ value: "98.4",
3266
+ unit: "%",
3267
+ tone: "success"
3268
+ }
3269
+ }
3270
+ }
3271
+ })]
3272
+ });
3273
+
3274
+ // src/components/entries/submit.spec.ts
3275
+ var submitSpec = component({
3276
+ type: "submit",
3277
+ category: "Action",
3278
+ title: "Submit",
3279
+ summary: "ToolHost submit and ignore controls.",
3280
+ description: "Use submit inside tool templates to return selected state fields to the host.",
3281
+ props: {
3282
+ submitLabel: { type: "string", default: "Submit", description: "Submit button text." },
3283
+ ignoreLabel: { type: "string", default: "Ignore", description: "Ignore button text." },
3284
+ returnKeys: { type: "string[]", description: "State field paths returned to ToolHost." },
3285
+ disabled: { type: "boolean", default: false, dynamic: true, description: "Disable submit action." }
3286
+ },
3287
+ children: noChildren,
3288
+ examples: [example("submit", {
3289
+ namespace: "doc_submit_typical",
3290
+ layout: {
3291
+ "column:tool": {
3292
+ "input:title": {
3293
+ value: "Release note",
3294
+ placeholder: "Title"
3295
+ },
3296
+ "submit:done": {
3297
+ submitLabel: "Submit",
3298
+ ignoreLabel: "Ignore",
3299
+ returnKeys: [
3300
+ "title"
3301
+ ]
3302
+ }
3303
+ }
3304
+ }
3305
+ })]
3306
+ });
3307
+
3308
+ // src/components/entries/switch.spec.ts
3309
+ var switchSpec = component({
3310
+ type: "switch",
3311
+ category: "Input",
3312
+ title: "Switch",
3313
+ summary: "Boolean switch input.",
3314
+ description: "Use switch for an on/off setting.",
3315
+ props: {
3316
+ enabled: { type: "boolean", default: false, dynamic: true, description: "Enabled state." },
3317
+ label: { type: "string", dynamic: true, description: "Switch label." },
3318
+ icon: { type: "string", description: "Icon name shown before the visible label." },
3319
+ disabled: { type: "boolean", default: false, dynamic: true, description: "Disable the switch." },
3320
+ haptic: { type: "boolean", default: true, description: "Enable vibration feedback on supported devices." },
3321
+ haptics: { type: "boolean", default: true, description: "Alias for haptic." },
3322
+ onchange: { type: "write-expression", description: "Write expression invoked when enabled state changes." }
3323
+ },
3324
+ children: noChildren,
3325
+ examples: [example("switch", {
3326
+ namespace: "doc_switch_typical",
3327
+ layout: {
3328
+ "switch:feature": {
3329
+ enabled: true,
3330
+ label: "Enable sync",
3331
+ icon: "arrows-clockwise"
3332
+ }
3333
+ }
3334
+ })]
3335
+ });
3336
+
3337
+ // src/components/entries/table.spec.ts
3338
+ var tableSpec = component({
3339
+ type: "table",
3340
+ category: "Data",
3341
+ title: "Table",
3342
+ summary: "Simple data table.",
3343
+ description: "Use table to render rows of keyed data against a column definition.",
3344
+ props: {
3345
+ columns: { type: "array", description: "Column definitions with key, label, and optional icon." },
3346
+ "columns[].icon": { type: "string", description: "Icon name shown before a column label." },
3347
+ rows: { type: "array", description: "Row data objects keyed by column key." },
3348
+ items: { type: "array", description: "Alias for rows." }
3349
+ },
3350
+ children: noChildren,
3351
+ examples: [example("table", {
3352
+ namespace: "doc_table_typical",
3353
+ layout: {
3354
+ "table:routes": {
3355
+ columns: [
3356
+ {
3357
+ key: "name",
3358
+ label: "Name",
3359
+ icon: "text-t"
3360
+ },
3361
+ {
3362
+ key: "status",
3363
+ label: "Status",
3364
+ icon: "check-circle"
3365
+ }
3366
+ ],
3367
+ rows: [
3368
+ {
3369
+ name: "Parse",
3370
+ status: "ready"
3371
+ },
3372
+ {
3373
+ name: "Publish",
3374
+ status: "pending"
3375
+ }
3376
+ ]
3377
+ }
3378
+ }
3379
+ })]
3380
+ });
3381
+
3382
+ // src/components/entries/tabs.spec.ts
3383
+ var tabsSpec = component({
3384
+ type: "tabs",
3385
+ category: "Navigation",
3386
+ title: "Tabs",
3387
+ summary: "Tabbed view switcher.",
3388
+ description: "Use tabs to switch between named content panels.",
3389
+ props: {
3390
+ value: { type: "string", dynamic: true, description: "Current active tab value." },
3391
+ tabs: { type: "array", description: "Tab definitions with value, label, content, icon, and iconOnly." },
3392
+ "tabs[].icon": { type: "string", description: "Icon name shown before a tab trigger label." },
3393
+ "tabs[].iconOnly": { type: "boolean", description: "Show only the tab icon while retaining label as accessible text." },
3394
+ orientation: { type: "string", values: ["horizontal", "vertical"], default: "horizontal", description: "Tab list orientation." },
3395
+ onchange: { type: "write-expression", description: "Write expression invoked when the active tab changes." }
3396
+ },
3397
+ children: noChildren,
3398
+ examples: [example("tabs", {
3399
+ namespace: "doc_tabs_typical",
3400
+ layout: {
3401
+ "tabs:main": {
3402
+ value: "overview",
3403
+ tabs: [
3404
+ {
3405
+ value: "overview",
3406
+ label: "Overview"
3407
+ },
3408
+ {
3409
+ value: "settings",
3410
+ label: "Settings"
3411
+ }
3412
+ ]
3413
+ }
3414
+ }
3415
+ })]
3416
+ });
3417
+
3418
+ // src/components/entries/text.spec.ts
3419
+ var textSpec = component({
3420
+ type: "text",
3421
+ category: "Display",
3422
+ title: "Text",
3423
+ summary: "Plain text display.",
3424
+ description: "Use text for short static or dynamic copy inside SlexKit layouts.",
3425
+ props: {
3426
+ text: { type: "string", dynamic: true, description: "Displayed text." },
3427
+ content: { type: "string", dynamic: true, description: "Alias for text." },
3428
+ label: { type: "string", dynamic: true, description: "Alias for text." },
3429
+ variant: { type: "string", values: ["default", "muted"], default: "default", description: "Text visual variant." },
3430
+ class: { type: "string", description: "Additional host-controlled CSS class." }
3431
+ },
3432
+ children: noChildren,
3433
+ examples: [example("text", {
3434
+ namespace: "doc_text_typical",
3435
+ layout: {
3436
+ "text:status": {
3437
+ text: "System is healthy"
3438
+ }
3439
+ }
3440
+ })]
3441
+ });
3442
+
3443
+ // src/components/entries/toast.spec.ts
3444
+ var toastSpec = component({
3445
+ type: "toast",
3446
+ category: "Feedback",
3447
+ title: "Toast",
3448
+ summary: "Transient notification.",
3449
+ description: "Use toast to show an inline notification with semantic status.",
3450
+ props: {
3451
+ title: { type: "string", dynamic: true, description: "Toast title." },
3452
+ heading: { type: "string", dynamic: true, description: "Alias for title." },
3453
+ label: { type: "string", dynamic: true, description: "Alias for title." },
3454
+ icon: { type: "string", description: "Icon name shown at the left of the toast." },
3455
+ description: { type: "string", dynamic: true, description: "Toast body text." },
3456
+ text: { type: "string", dynamic: true, description: "Alias for description." },
3457
+ message: { type: "string", dynamic: true, description: "Alias for description." },
3458
+ content: { type: "string", dynamic: true, description: "Alias for description." },
3459
+ type: { type: "string", values: ["info", "success", "warning", "danger"], default: "info", description: "Semantic notification type." },
3460
+ tone: { type: "string", values: ["info", "success", "warning", "danger"], default: "info", description: "Alias for type." },
3461
+ duration: { type: "number", description: "Auto-hide delay in milliseconds." },
3462
+ dismissable: { type: "boolean", default: true, description: "Show a close button." },
3463
+ dismissible: { type: "boolean", default: true, description: "Alias for dismissable." },
3464
+ closeLabel: { type: "string", default: "Close notification", description: "Accessible close button label." },
3465
+ closeAriaLabel: { type: "string", description: "Alias for closeLabel." }
3466
+ },
3467
+ children: noChildren,
3468
+ examples: [example("toast", {
3469
+ namespace: "doc_toast_typical",
3470
+ layout: {
3471
+ "toast:saved": {
3472
+ type: "success",
3473
+ title: "Saved",
3474
+ icon: "check-circle",
3475
+ description: "Changes have been written."
3476
+ }
3477
+ }
3478
+ })]
3479
+ });
3480
+
3481
+ // src/components/entries/specs.ts
3482
+ var componentSpecs = [
3483
+ accordionSpec,
3484
+ badgeSpec,
3485
+ buttonSpec,
3486
+ calloutSpec,
3487
+ cardSpec,
3488
+ checkboxSpec,
3489
+ codeBlockSpec,
3490
+ collapsibleSpec,
3491
+ columnSpec,
3492
+ dividerSpec,
3493
+ formulaSpec,
3494
+ gridSpec,
3495
+ iconSpec,
3496
+ inputSpec,
3497
+ linkSpec,
3498
+ playgroundSpec,
3499
+ progressSpec,
3500
+ radioGroupSpec,
3501
+ rowSpec,
3502
+ sectionSpec,
3503
+ selectSpec,
3504
+ sliderSpec,
3505
+ statSpec,
3506
+ submitSpec,
3507
+ switchSpec,
3508
+ tableSpec,
3509
+ tabsSpec,
3510
+ textSpec,
3511
+ toastSpec
3512
+ ];
3513
+
3514
+ // src/components/spec-registry.ts
3515
+ var publicComponentTypes = componentSpecs.map((spec) => spec.type);
3516
+ var componentSpecByType = new Map(componentSpecs.map((spec) => [spec.type, spec]));
3517
+
3518
+ // src/engine/capabilities.ts
3519
+ var slexkitStdlibDocs = [
3520
+ {
3521
+ name: "math",
3522
+ summary: "Small numeric helpers for common interactive calculations.",
3523
+ functions: [
3524
+ { 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)" },
3525
+ { 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)" },
3526
+ { 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)" },
3527
+ { 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)" },
3528
+ { name: "std.math.lerp", signature: "lerp(start, end, t)", summary: "Linear interpolation.", pure: true, example: "std.math.lerp(0, 100, g.progress)" }
3529
+ ]
3530
+ },
3531
+ {
3532
+ name: "stats",
3533
+ summary: "Finite-number aggregations for arrays.",
3534
+ functions: [
3535
+ { name: "std.stats.sum", signature: "sum(values)", summary: "Sum finite numeric values. Empty arrays return 0.", pure: true, example: "std.stats.sum(g.samples)" },
3536
+ { name: "std.stats.mean", signature: "mean(values)", summary: "Average finite numeric values. Empty arrays return NaN.", pure: true, example: "std.stats.mean(g.samples)" },
3537
+ { name: "std.stats.min", signature: "min(values)", summary: "Minimum finite numeric value. Empty arrays return NaN.", pure: true, example: "std.stats.min(g.samples)" },
3538
+ { name: "std.stats.max", signature: "max(values)", summary: "Maximum finite numeric value. Empty arrays return NaN.", pure: true, example: "std.stats.max(g.samples)" },
3539
+ { name: "std.stats.median", signature: "median(values)", summary: "Median finite numeric value. Empty arrays return NaN.", pure: true, example: "std.stats.median(g.samples)" }
3540
+ ]
3541
+ },
3542
+ {
3543
+ name: "format",
3544
+ summary: "Deterministic display formatting with en-US defaults.",
3545
+ functions: [
3546
+ { 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)" },
3547
+ { name: "std.format.number", signature: "number(value, digits = 0, locale = 'en-US')", summary: "Locale number formatting.", pure: true, example: "std.format.number(g.requests)" },
3548
+ { name: "std.format.compact", signature: "compact(value, digits = 1, locale = 'en-US')", summary: "Compact number formatting.", pure: true, example: "std.format.compact(g.users)" },
3549
+ { 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)" },
3550
+ { 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')" }
3551
+ ]
3552
+ },
3553
+ {
3554
+ name: "units",
3555
+ summary: "Small unit display helpers for common dashboards.",
3556
+ functions: [
3557
+ { 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)" },
3558
+ { 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)" },
3559
+ { 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)" },
3560
+ { 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)" }
3561
+ ]
3562
+ }
3563
+ ];
3564
+ var slexkitRuntimeCapabilities = [
3565
+ { 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"] },
3566
+ { 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"] },
3567
+ { 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"] },
3568
+ { 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)"] },
3569
+ { name: "api.clearTimeout", policy: "timer", signature: "clearTimeout(id)", summary: "Clear a policy-gated timeout.", example: "api.clearTimeout(g.timeoutId)", secureDefault: "denied" },
3570
+ { 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)"] },
3571
+ { name: "api.clearInterval", policy: "timer", signature: "clearInterval(id)", summary: "Clear a policy-gated interval.", example: "api.clearInterval(g.intervalId)", secureDefault: "denied" },
3572
+ { 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)"] },
3573
+ { name: "api.cancelRaf", policy: "animation", signature: "cancelRaf(id)", summary: "Cancel a policy-gated animation frame.", example: "api.cancelRaf(g.rafId)", secureDefault: "denied" },
3574
+ { name: "api.createCanvas", policy: "canvas", signature: "createCanvas(width, height)", summary: "Create a policy-counted canvas.", example: "var canvas = api.createCanvas(320, 180)", secureDefault: "denied" },
3575
+ { 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" },
3576
+ { name: "api.onDispose", policy: "lifecycle", signature: "onDispose(fn)", summary: "Register runtime cleanup.", example: "api.onDispose(function () { g.closed = true; })", secureDefault: "available" },
3577
+ { name: "api.now", policy: "lifecycle", signature: "now()", summary: "Runtime clock.", example: "api.now()", secureDefault: "available" },
3578
+ { name: "api.isTimeoutError", policy: "diagnostics", signature: "isTimeoutError(error)", summary: "Check timeout errors.", example: "api.isTimeoutError(error)", secureDefault: "available" },
3579
+ { name: "api.isNetworkError", policy: "diagnostics", signature: "isNetworkError(error)", summary: "Check network errors.", example: "api.isNetworkError(error)", secureDefault: "available" },
3580
+ { name: "api.isPolicyError", policy: "diagnostics", signature: "isPolicyError(error)", summary: "Check policy errors.", example: "api.isPolicyError(error)", secureDefault: "available" },
3581
+ { name: "api.errorMessage", policy: "diagnostics", signature: "errorMessage(error)", summary: "Extract a displayable error message.", example: "api.errorMessage(error)", secureDefault: "available" }
3582
+ ];
3583
+ var slexkitStdlibFunctionNames = slexkitStdlibDocs.flatMap((namespace) => namespace.functions.map((fn) => fn.name));
3584
+ var slexkitRuntimeCapabilityNames = slexkitRuntimeCapabilities.map((capability) => capability.name);
3585
+
3586
+ // src/engine/validation.ts
3587
+ var componentSpecByType2 = new Map(componentSpecs.map((spec) => [spec.type, spec]));
3588
+ var stdlibFunctions = new Set(slexkitStdlibFunctionNames);
3589
+ var stdlibNamespaces = new Set(slexkitStdlibFunctionNames.map((name) => name.split(".").slice(0, 2).join(".")));
3590
+ var apiMembers = new Set(slexkitRuntimeCapabilityNames);
3591
+ var directiveProps = new Set(["$if", "$for", "$key"]);
3592
+ var nativeSecureCapabilities = [
3593
+ { value: "fetch", pattern: /(?<!\.)\bfetch\s*\(/ },
3594
+ { value: "XMLHttpRequest", pattern: /\bXMLHttpRequest\b/ },
3595
+ { value: "WebSocket", pattern: /\bWebSocket\b/ },
3596
+ { value: "setTimeout", pattern: /(?<!\.)\bsetTimeout\s*\(/ },
3597
+ { value: "requestAnimationFrame", pattern: /(?<!\.)\brequestAnimationFrame\s*\(/ }
3598
+ ];
3599
+ function collectMemberUsage(source, root) {
3600
+ const matches = source.matchAll(new RegExp(`\\b${root}\\.([A-Za-z_$][\\w$]*)(?:\\.([A-Za-z_$][\\w$]*))?`, "g"));
3601
+ const found = new Set;
3602
+ for (const match of matches) {
3603
+ found.add([root, match[1], match[2]].filter(Boolean).join("."));
3604
+ }
3605
+ return [...found].sort();
3606
+ }
3607
+ function componentKeyType(key) {
3608
+ const colon = key.indexOf(":");
3609
+ return colon > 0 ? key.slice(0, colon) : null;
3610
+ }
3611
+ function isKnownProp(type, key) {
3612
+ if (directiveProps.has(key) || key.startsWith("on"))
3613
+ return true;
3614
+ const spec = componentSpecByType2.get(type);
3615
+ if (!spec)
3616
+ return true;
3617
+ const propName = key.startsWith("$") ? key.slice(1) : key;
3618
+ return propName in spec.props;
3619
+ }
3620
+ function walkComponents(value, warnings, usage, path = "") {
3621
+ if (!value || typeof value !== "object")
3622
+ return;
3623
+ for (const [key, child] of Object.entries(value)) {
3624
+ const childPath = path ? `${path}.${key}` : key;
3625
+ const type = componentKeyType(key);
3626
+ if (type) {
3627
+ usage.add(type);
3628
+ const spec = componentSpecByType2.get(type);
3629
+ if (!spec) {
3630
+ warnings.push({
3631
+ code: "unknown_component",
3632
+ message: `Unknown SlexKit component '${type}'.`,
3633
+ path: childPath,
3634
+ value: type
3635
+ });
3636
+ }
3637
+ if (child && typeof child === "object") {
3638
+ for (const propName of Object.keys(child)) {
3639
+ if (componentKeyType(propName))
3640
+ continue;
3641
+ if (!isKnownProp(type, propName)) {
3642
+ warnings.push({
3643
+ code: "unknown_prop",
3644
+ message: `Unknown prop '${propName}' on component '${type}'.`,
3645
+ path: `${childPath}.${propName}`,
3646
+ value: propName
3647
+ });
3648
+ }
3649
+ }
3650
+ }
3651
+ }
3652
+ walkComponents(child, warnings, usage, childPath);
3653
+ }
3654
+ }
3655
+ function sourceWarnings(source, mode) {
3656
+ const warnings = [];
3657
+ const stdlibUsage = collectMemberUsage(source, "std");
3658
+ const apiUsage = collectMemberUsage(source, "api");
3659
+ for (const name of stdlibUsage) {
3660
+ if (stdlibFunctions.has(name) || stdlibNamespaces.has(name))
3661
+ continue;
3662
+ warnings.push({
3663
+ code: "unknown_std_member",
3664
+ message: `Unknown SlexKit stdlib member '${name}'.`,
3665
+ value: name
3666
+ });
3667
+ }
3668
+ for (const name of apiUsage) {
3669
+ if (apiMembers.has(name))
3670
+ continue;
3671
+ warnings.push({
3672
+ code: "unknown_api_member",
3673
+ message: `Unknown SlexKit runtime API member '${name}'.`,
3674
+ value: name
3675
+ });
3676
+ }
3677
+ if (mode === "secure") {
3678
+ for (const capability of nativeSecureCapabilities) {
3679
+ if (capability.pattern.test(source)) {
3680
+ warnings.push({
3681
+ code: "native_secure_capability",
3682
+ message: `Native '${capability.value}' is not supported in secure mode. Use policy-gated api.* instead.`,
3683
+ value: capability.value
3684
+ });
3685
+ }
3686
+ }
3687
+ }
3688
+ return { warnings, stdlibUsage, apiUsage };
3689
+ }
3690
+ function validateSlexSource(source, options = {}) {
3691
+ const mode = options.mode ?? "trusted";
3692
+ const parsed = parseSlexSource(source);
3693
+ const usage = new Set;
3694
+ const { warnings, stdlibUsage, apiUsage } = sourceWarnings(source, mode);
3695
+ if (!parsed.ok) {
3696
+ return {
3697
+ ok: false,
3698
+ diagnostic: parsed.diagnostic,
3699
+ warnings,
3700
+ componentUsage: [],
3701
+ stdlibUsage,
3702
+ apiUsage
3703
+ };
3704
+ }
3705
+ walkComponents(parsed.value, warnings, usage);
3706
+ return {
3707
+ ok: true,
3708
+ value: parsed.value,
3709
+ warnings,
3710
+ componentUsage: [...usage].sort(),
3711
+ stdlibUsage,
3712
+ apiUsage
3713
+ };
3714
+ }
2206
3715
  // src/engine/markdown-runtime.ts
2207
3716
  var DEFAULT_POLICY = {};
2208
3717
  function isRecord(value) {
@@ -2328,7 +3837,7 @@ function createSlexKitMarkdownRuntimeHost(initialOptions = {}) {
2328
3837
  const __target = { slex: "0.1", namespace: __artifactPrefix + "default", g: {}, layout: {} };
2329
3838
  const __layouts = [];
2330
3839
  for (const __entry of __sources) {
2331
- const __script = __entry.kind === "json" ? JSON.parse(__entry.source) : (0, eval)(__entry.source);
3840
+ const __script = __entry.kind === "json" ? JSON.parse(__entry.source) : (0, eval)("(" + __entry.source + ")");
2332
3841
  if (!__isRecord(__script)) continue;
2333
3842
  if ("slex" in __script) __target.slex = String(__script.slex || "0.1");
2334
3843
  if ("namespace" in __script) __target.namespace = __artifactPrefix + String(__script.namespace || "default");
@@ -2766,14 +4275,20 @@ function createSecureFrameTarget(input, container, mountOptions) {
2766
4275
  iframe.title = options.title ?? "SlexKit secure artifact";
2767
4276
  iframe.setAttribute("data-slexkit-secure-frame", "true");
2768
4277
  iframe.setAttribute("referrerpolicy", "no-referrer");
4278
+ iframe.style.display = "block";
4279
+ iframe.style.width = "100%";
4280
+ iframe.style.border = "0";
4281
+ iframe.style.background = "transparent";
2769
4282
  const runtimeUrl = options.runtimeUrl ?? options.runnerUrl ?? defaultRuntimeUrl;
2770
4283
  if (runtimeUrl) {
2771
4284
  const resolvedRuntimeUrl = resolveRuntimeUrl(runtimeUrl);
4285
+ const styleUrl = options.styleUrl === false ? "" : options.styleUrl ?? defaultSecureFrameStyleUrl(resolvedRuntimeUrl);
4286
+ const resolvedStyleUrl = styleUrl ? resolveRuntimeUrl(styleUrl) : undefined;
2772
4287
  assertSandboxCloneable(input);
2773
4288
  iframe.setAttribute("sandbox", secureSandboxAttribute(options));
2774
4289
  container.replaceChildren(iframe);
2775
4290
  const bridge = createSandboxBridge(input, container, iframe, mountOptions);
2776
- iframe.srcdoc = secureRunnerSrcdoc(resolvedRuntimeUrl);
4291
+ iframe.srcdoc = secureRunnerSrcdoc(resolvedRuntimeUrl, resolvedStyleUrl);
2777
4292
  return bridge;
2778
4293
  }
2779
4294
  if (frame) {
@@ -2833,23 +4348,38 @@ function cspSourceForRuntime(runtimeUrl) {
2833
4348
  return "'self'";
2834
4349
  }
2835
4350
  }
4351
+ function defaultSecureFrameStyleUrl(runtimeUrl) {
4352
+ try {
4353
+ const url = new URL(runtimeUrl);
4354
+ if (url.protocol === "blob:" || url.protocol === "data:")
4355
+ return "";
4356
+ url.pathname = url.pathname.replace(/[^/]+$/, "slexkit.css");
4357
+ url.search = "";
4358
+ url.hash = "";
4359
+ return url.href;
4360
+ } catch {
4361
+ return "";
4362
+ }
4363
+ }
2836
4364
  function escapeHtmlAttribute(value) {
2837
4365
  return value.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
2838
4366
  }
2839
- function secureRunnerSrcdoc(runtimeUrl) {
4367
+ function secureRunnerSrcdoc(runtimeUrl, styleUrl) {
2840
4368
  const nonce = randomToken(12);
4369
+ const styleSource = styleUrl ? ` ${cspSourceForRuntime(styleUrl)}` : "";
2841
4370
  const csp = [
2842
4371
  "default-src 'none'",
2843
4372
  `script-src 'nonce-${nonce}' 'unsafe-eval' ${cspSourceForRuntime(runtimeUrl)}`,
2844
4373
  "connect-src 'none'",
2845
4374
  "img-src data: blob:",
2846
- "style-src 'unsafe-inline'",
4375
+ `style-src 'unsafe-inline'${styleSource}`,
2847
4376
  "font-src data:",
2848
4377
  "form-action 'none'",
2849
4378
  "base-uri 'none'"
2850
4379
  ].join("; ");
2851
4380
  const style = "html,body{margin:0;min-height:100%;overflow:hidden;}#slexkit-secure-root{min-height:100%;}";
2852
- 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>`;
4381
+ const stylesheet = styleUrl ? `<link rel="stylesheet" href="${escapeHtmlAttribute(styleUrl)}">` : "";
4382
+ 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>`;
2853
4383
  }
2854
4384
  function secureFrameLoadTimeout(options) {
2855
4385
  const frame = options.frame;
@@ -3101,11 +4631,21 @@ function createSandboxBridge(input, container, iframe, options) {
3101
4631
  if (data.type === "slot-size" && data.id === id && data.token === token && typeof data.slotId === "string") {
3102
4632
  const slot = artifactSlots.find((item) => item.id === data.slotId);
3103
4633
  if (slot && typeof data.height === "number" && Number.isFinite(data.height)) {
3104
- slot.container.style.minHeight = `${Math.max(0, Math.ceil(data.height))}px`;
4634
+ const height = Math.max(0, Math.ceil(data.height));
4635
+ slot.container.style.minHeight = `${height}px`;
4636
+ if (artifactSlots.length === 1) {
4637
+ iframe.style.height = `${Math.max(1, height)}px`;
4638
+ }
3105
4639
  requestArtifactSlotSync();
3106
4640
  }
3107
4641
  return;
3108
4642
  }
4643
+ if (data.type === "frame-size" && data.id === id && data.token === token) {
4644
+ if (artifactSlots.length <= 1 && typeof data.height === "number" && Number.isFinite(data.height)) {
4645
+ iframe.style.height = `${Math.max(1, Math.ceil(data.height))}px`;
4646
+ }
4647
+ return;
4648
+ }
3109
4649
  if (data.type === "error" && (!data.id || data.id === id) && (!data.token || data.token === token)) {
3110
4650
  const error = data;
3111
4651
  failLoad(ready ? "mounted" : "ready", typeof error.error?.message === "string" ? error.error.message : undefined);
@@ -3522,6 +5062,7 @@ function startSlexKitSandboxRunner() {
3522
5062
  let activeId;
3523
5063
  let activeToken;
3524
5064
  let heartbeatTimer;
5065
+ let rootResizeObserver;
3525
5066
  let slotResizeObserver;
3526
5067
  function clearHeartbeat() {
3527
5068
  if (heartbeatTimer === undefined)
@@ -3547,6 +5088,8 @@ function startSlexKitSandboxRunner() {
3547
5088
  if (id && activeId && id !== activeId)
3548
5089
  return;
3549
5090
  clearHeartbeat();
5091
+ rootResizeObserver?.disconnect();
5092
+ rootResizeObserver = undefined;
3550
5093
  slotResizeObserver?.disconnect();
3551
5094
  slotResizeObserver = undefined;
3552
5095
  cleanup?.();
@@ -3580,6 +5123,36 @@ function startSlexKitSandboxRunner() {
3580
5123
  height
3581
5124
  });
3582
5125
  }
5126
+ function reportFrameSize() {
5127
+ if (!activeId || !activeToken)
5128
+ return;
5129
+ const root = frameRoot();
5130
+ const rootRect = root.getBoundingClientRect();
5131
+ let contentBottom = rootRect.height;
5132
+ for (const child of root.querySelectorAll("*")) {
5133
+ const rect = child.getBoundingClientRect();
5134
+ contentBottom = Math.max(contentBottom, rect.bottom - rootRect.top);
5135
+ }
5136
+ const height = Math.max(root.scrollHeight, root.getBoundingClientRect().height, contentBottom, document.body?.scrollHeight ?? 0, document.documentElement?.scrollHeight ?? 0, 1);
5137
+ post({
5138
+ channel: "slexkit-secure",
5139
+ type: "frame-size",
5140
+ id: activeId,
5141
+ token: activeToken,
5142
+ height
5143
+ });
5144
+ }
5145
+ function observeFrameSize() {
5146
+ rootResizeObserver?.disconnect();
5147
+ rootResizeObserver = typeof ResizeObserver !== "undefined" ? new ResizeObserver(() => reportFrameSize()) : undefined;
5148
+ const root = frameRoot();
5149
+ rootResizeObserver?.observe(root);
5150
+ for (const child of root.children) {
5151
+ rootResizeObserver?.observe(child);
5152
+ }
5153
+ reportFrameSize();
5154
+ schedulingSnapshot.requestAnimationFrame?.(() => reportFrameSize());
5155
+ }
3583
5156
  function applySlotRects(slots) {
3584
5157
  const root = frameRoot();
3585
5158
  const multiSlot = slots.length > 1;
@@ -3636,6 +5209,7 @@ function startSlexKitSandboxRunner() {
3636
5209
  api: runtime.api
3637
5210
  });
3638
5211
  startHeartbeat(message.policy, message.id, message.token);
5212
+ observeFrameSize();
3639
5213
  post({
3640
5214
  channel: "slexkit-secure",
3641
5215
  type: "mounted",
@@ -3702,7 +5276,7 @@ function startSlexKitSandboxRunner() {
3702
5276
  }
3703
5277
 
3704
5278
  // src/runtime.ts
3705
- setSlexKitRuntimeUrl("file:///D:/Project/slexkit/src/runtime.ts");
5279
+ setSlexKitRuntimeUrl("file:///home/runner/work/slexkit/slexkit/src/runtime.ts");
3706
5280
  var mountApi = mount;
3707
5281
  var ingestApi = ingest;
3708
5282
  var bootApi = boot;
@@ -3715,6 +5289,7 @@ var formatSlexKitDiagnosticApi = formatSlexKitDiagnostic;
3715
5289
  var mountSecureArtifactApi = mountSecureArtifact;
3716
5290
  var parseSlexSourceApi = parseSlexSource;
3717
5291
  var parseSlexKitDslApi = parseSlexKitDsl;
5292
+ var validateSlexSourceApi = validateSlexSource;
3718
5293
  var createSecureRuntimeApi = createSecureRuntime;
3719
5294
  var SlexKitRuntimeErrorApi = SlexKitRuntimeError;
3720
5295
  var getSlexKitRuntimeUrlApi = getSlexKitRuntimeUrl;
@@ -3722,6 +5297,7 @@ var setSlexKitRuntimeUrlApi = setSlexKitRuntimeUrl;
3722
5297
  var createSlexKitMarkdownRuntimeHostApi = createSlexKitMarkdownRuntimeHost;
3723
5298
  var getSlexKitMarkdownRuntimeHostApi = getSlexKitMarkdownRuntimeHost;
3724
5299
  var installSlexKitMarkdownRuntimeHostApi = installSlexKitMarkdownRuntimeHost;
5300
+ var slexkitStdApi = slexkitStd;
3725
5301
  var attachComponentDisposerApi = attachComponentDisposer;
3726
5302
  var configureComponentScopeApi = configureComponentScope;
3727
5303
  var startSlexKitSandboxRunnerApi = startSlexKitSandboxRunner;