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/CHANGELOG.md CHANGED
@@ -2,6 +2,58 @@
2
2
 
3
3
  All notable changes to SlexKit.
4
4
 
5
+ ## v0.3.0 - Examples overhaul with component audit and i18n
6
+
7
+ ### Added
8
+ - Example gallery: 17 high-quality examples organized by usage scenario (Getting Started, Calculators, Data Browsing, Dashboards, Config Wizards, Decision Support, Platform Features)
9
+ - English translations for all 17 example pages
10
+ - `toolhost-demo`: real `renderToolCall` API with chat-style conversation UI
11
+ - Example rendering infrastructure: `site/routes/examples.js`, `site/pages/examples.slex.js`, `site/data/examples.js`
12
+ - Content discovery: `site/data/content-discovery.js` with locale fallback and allowed-slug filtering
13
+ - `site/data/content-discovery.js`: `discoverExampleMarkdown()` with per-locale discovery
14
+ - SEO metadata for example pages
15
+ - `examples/minimal-cdn/index.html`: zero-build CDN usage example
16
+ - Formula component (`src/components/svelte/content/Formula.svelte`) with KaTeX rendering
17
+ - `src/engine/capabilities.ts`: structured capability docs for AI agents
18
+ - `src/engine/validation.ts`: SPEC contract validation for component specs
19
+ - `src/engine/stdlib.ts`: standard library with `math.clamp`, `math.safeDivide`, and other utilities
20
+ - `src/engine/sandbox-runner.ts`: sandbox runner for secure runtime
21
+ - Component state eval context shadowing test suite (`component-state-shadowing.test.ts`)
22
+ - Collapsible and Callout double-rendering regression tests
23
+ - Slider component name shadowing regression test
24
+ - Tests for content, playground, select, tabs, slider, disclosure, feedback, policy-api
25
+
26
+ ### Changed
27
+ - Examples reduced from 64 to 17 high-quality examples, organized by user story
28
+ - Example source locale: `zh-CN` (with `en-US` translations)
29
+ - `renderChildren` (`helpers.ts`) now clears existing content when children are present
30
+ - Switch component now accepts `checked`/`value` props for initialization consistency with Checkbox
31
+ - Site UI: DocsShell, DocRail, router, shell improvements
32
+ - Components: Input, Select, Tabs, Table, PlaygroundMarkdown refinements
33
+ - CSS: theme-shadcn, text-input, docs-shell styling updates
34
+ - MCP: enhanced with structured capability docs
35
+
36
+ ### Fixed
37
+ - Eval context shadowing: component names `g` and `api` no longer overwrite reserved context keys
38
+ - `renderChildren` double rendering in Collapsible and Callout
39
+ - Voltage divider summary typo ("输入输入电压")
40
+ - Salary calculator fallback numbers to match actual calculator output
41
+ - Tabs-and-branching: title and length conversion mismatch
42
+ - 4 pre-existing test failures (ai-docs, page-structure, theme, markdown-content)
43
+ - Toolhost test: added setup import to fix `document is not defined`
44
+ - Badge stretching in grid layout
45
+ - Project-dashboard syntax error
46
+ - Salary-calculator rate configuration
47
+
48
+ ### Removed
49
+ - 47 low-quality/duplicate examples (reduced from 64 to 17)
50
+ - Dead "Fallback" copywriting from all example files
51
+ - Post-slex explanatory text from example files
52
+ - Unused `DialogShell.svelte` component
53
+ - Orphaned `test-if` example directory
54
+ - Agent-generated `docs/compose` planning files
55
+ - Temporary `screenshot-*.png` files
56
+
5
57
  ## v0.2.0 - First public release
6
58
 
7
59
  ### Added
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 SlexKit
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 SlexKit
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -7,6 +7,7 @@ SlexKit's agent-readable source is Markdown with explicit `slex` fences. Do not
7
7
  - Emit explicit `slex` fenced code blocks for display-oriented interactive UI.
8
8
  - Use a Slex expression envelope: `slex`, `namespace`, `g`, and `layout`.
9
9
  - Put mutable state and helper functions in `g`; put component structure in `layout`.
10
+ - Use `std.*` for common calculations, formatting, units, and small statistics.
10
11
  - Use component keys in `type:identifier` form, such as `card:summary`.
11
12
  - Use `$` read-pipes for dynamic props and `on*` write-pipes for event handlers.
12
13
  - Include readable Markdown fallback text after the fence.
@@ -18,6 +19,7 @@ SlexKit's agent-readable source is Markdown with explicit `slex` fences. Do not
18
19
  - Do not ask hosts to scan plain JavaScript, JSON, or untagged code blocks.
19
20
  - Do not wrap ordinary status cards or summaries in ToolHost.
20
21
  - Do not bypass the sandbox for untrusted source.
22
+ - Do not use native `fetch`, `XMLHttpRequest`, `WebSocket`, `setTimeout`, or `requestAnimationFrame` in secure mode; use policy-gated `api.*` instead.
21
23
  - Do not invent `.mdx` routes for SlexKit docs.
22
24
 
23
25
  ## Display UI Example
@@ -0,0 +1,126 @@
1
+ # SlexKit Capabilities for LLMs
2
+
3
+ Use `std.*` for pure deterministic calculations and formatting. Use `api.*` only for host-injected or secure-runtime capabilities that may require policy.
4
+
5
+ ## Expression Context
6
+
7
+ - `g` (always): Reactive state proxy.
8
+ - `std` (always): Pure deterministic SlexKit standard library.
9
+ - `api` (host-injected): Host or secure runtime capability object.
10
+ - `$event` (event handlers): Event payload for on* handlers.
11
+ - `$item` ($for): Current array item.
12
+ - `$index` ($for): Current item index.
13
+ - `$key` ($for): Current item key.
14
+
15
+ ## std.math
16
+
17
+ Small numeric helpers for common interactive calculations.
18
+
19
+ - `std.math.clamp(value, min, max)`: Clamp a number into a range. Example: `std.math.clamp(g.score, 0, 100)`
20
+ - `std.math.round(value, digits = 0)`: Round with a fixed number of decimal digits. Example: `std.math.round(g.latency, 1)`
21
+ - `std.math.safeDivide(numerator, denominator, fallback = 0)`: Divide with a fallback for zero or invalid denominators. Example: `std.math.safeDivide(g.used, g.total, 0)`
22
+ - `std.math.percent(part, total, digits = 1)`: Return part / total as a percentage number. Example: `std.math.percent(g.done, g.total, 1)`
23
+ - `std.math.lerp(start, end, t)`: Linear interpolation. Example: `std.math.lerp(0, 100, g.progress)`
24
+
25
+ ## std.stats
26
+
27
+ Finite-number aggregations for arrays.
28
+
29
+ - `std.stats.sum(values)`: Sum finite numeric values. Empty arrays return 0. Example: `std.stats.sum(g.samples)`
30
+ - `std.stats.mean(values)`: Average finite numeric values. Empty arrays return NaN. Example: `std.stats.mean(g.samples)`
31
+ - `std.stats.min(values)`: Minimum finite numeric value. Empty arrays return NaN. Example: `std.stats.min(g.samples)`
32
+ - `std.stats.max(values)`: Maximum finite numeric value. Empty arrays return NaN. Example: `std.stats.max(g.samples)`
33
+ - `std.stats.median(values)`: Median finite numeric value. Empty arrays return NaN. Example: `std.stats.median(g.samples)`
34
+
35
+ ## std.format
36
+
37
+ Deterministic display formatting with en-US defaults.
38
+
39
+ - `std.format.fixed(value, digits = 2)`: Format a number with fixed decimal places. Example: `std.format.fixed(g.voltage, 3)`
40
+ - `std.format.number(value, digits = 0, locale = 'en-US')`: Locale number formatting. Example: `std.format.number(g.requests)`
41
+ - `std.format.compact(value, digits = 1, locale = 'en-US')`: Compact number formatting. Example: `std.format.compact(g.users)`
42
+ - `std.format.percent(ratio, digits = 1)`: Format a ratio as a percentage string. Example: `std.format.percent(g.done / g.total, 1)`
43
+ - `std.format.currency(value, currency = 'USD', locale = 'en-US')`: Format a currency value. Example: `std.format.currency(g.revenue, 'USD')`
44
+
45
+ ## std.units
46
+
47
+ Small unit display helpers for common dashboards.
48
+
49
+ - `std.units.withUnit(value, unit, digits = 2)`: Format a value with a unit suffix. Example: `std.units.withUnit(g.power, 'W', 1)`
50
+ - `std.units.bytes(value, digits = 1)`: Format bytes as B, KB, MB, GB, TB, or PB. Example: `std.units.bytes(g.payloadBytes)`
51
+ - `std.units.duration(ms, digits = 1)`: Format milliseconds as ms, s, min, or h. Example: `std.units.duration(g.elapsedMs)`
52
+ - `std.units.si(value, unit = '', digits = 2)`: Format with SI prefixes. Example: `std.units.si(g.frequency, 'Hz', 2)`
53
+
54
+ ## Policy-Gated Runtime API
55
+
56
+ - `api.get(url, options)` (network, secure default: denied): Policy-gated GET request.
57
+ - `api.post(url, body, options)` (network, secure default: denied): Policy-gated POST request.
58
+ - `api.fetch(url, options)` (network, secure default: denied): Policy-gated GET or POST request.
59
+ - `api.setTimeout(fn, ms)` (timer, secure default: denied): Policy-gated timeout.
60
+ - `api.clearTimeout(id)` (timer, secure default: denied): Clear a policy-gated timeout.
61
+ - `api.setInterval(fn, ms)` (timer, secure default: denied): Policy-gated interval.
62
+ - `api.clearInterval(id)` (timer, secure default: denied): Clear a policy-gated interval.
63
+ - `api.raf(fn)` (animation, secure default: denied): Policy-gated animation frame.
64
+ - `api.cancelRaf(id)` (animation, secure default: denied): Cancel a policy-gated animation frame.
65
+ - `api.createCanvas(width, height)` (canvas, secure default: denied): Create a policy-counted canvas.
66
+ - `api.getCanvasContext(canvas, contextId, options)` (canvas, secure default: denied): Get a policy-checked canvas context.
67
+ - `api.onDispose(fn)` (lifecycle, secure default: available): Register runtime cleanup.
68
+ - `api.now()` (lifecycle, secure default: available): Runtime clock.
69
+ - `api.isTimeoutError(error)` (diagnostics, secure default: available): Check timeout errors.
70
+ - `api.isNetworkError(error)` (diagnostics, secure default: available): Check network errors.
71
+ - `api.isPolicyError(error)` (diagnostics, secure default: available): Check policy errors.
72
+ - `api.errorMessage(error)` (diagnostics, secure default: available): Extract a displayable error message.
73
+
74
+ Secure mode blocks native `fetch`, `XMLHttpRequest`, `WebSocket`, `setTimeout`, `setInterval`, and `requestAnimationFrame`. Use `api.get`, `api.post`, `api.fetch`, `api.setTimeout`, `api.setInterval`, and `api.raf` when host policy enables them.
75
+
76
+ ## Recipe: Std Calculator
77
+
78
+ ```slex
79
+ {
80
+ slex: "0.1",
81
+ namespace: "std_calculator",
82
+ g: { done: 7, total: 12, samples: [120, 95, 143, 110], bytes: 1536000 },
83
+ layout: {
84
+ "card:summary": {
85
+ title: "Stdlib calculator",
86
+ "stat:progress": { label: "Progress", "$value": "std.format.percent(std.math.safeDivide(g.done, g.total), 1)" },
87
+ "stat:average": { label: "Average", "$value": "std.format.fixed(std.stats.mean(g.samples), 1)", unit: "ms" },
88
+ "stat:payload": { label: "Payload", "$value": "std.units.bytes(g.bytes)" }
89
+ }
90
+ }
91
+ }
92
+ ```
93
+
94
+ ## Recipe: Secure Network Card
95
+
96
+ ```slex
97
+ {
98
+ slex: "0.1",
99
+ namespace: "secure_network_card",
100
+ g: {
101
+ status: "idle",
102
+ async load() {
103
+ this.status = "loading";
104
+ try {
105
+ var result = await api.get("https://api.example.com/status", { credentials: "omit" });
106
+ this.status = "HTTP " + result.status;
107
+ } catch (error) {
108
+ this.status = api.isPolicyError(error) ? "blocked by policy" : api.errorMessage(error);
109
+ }
110
+ }
111
+ },
112
+ layout: {
113
+ "card:network": {
114
+ title: "Secure network card",
115
+ "button:load": { label: "Load", onclick: "g.load()" },
116
+ "text:status": { "$text": "g.status" }
117
+ }
118
+ }
119
+ }
120
+ ```
121
+
122
+ ## Recipe: Timer and Animation Policy
123
+
124
+ - Timers are disabled in secure mode unless `policy.timer.enabled` is true.
125
+ - Use `api.setTimeout` and `api.setInterval`; do not use native scheduling globals.
126
+ - Animation is disabled unless `policy.animation.enabled` is true; use `api.raf`.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Use these components inside Markdown `slex` fences. Raw component docs are ordinary `.md` pages that preserve `slex` examples.
4
4
 
5
- Public component count: 28
5
+ Public component count: 29
6
6
 
7
7
  ## Disclosure
8
8
 
@@ -39,6 +39,12 @@ Public component count: 28
39
39
  - [Slider](/docs/components/slider.md): `slider` - Numeric range input.
40
40
  - [Switch](/docs/components/switch.md): `switch` - Boolean switch input.
41
41
 
42
+ ## Display
43
+
44
+ - [Formula](/docs/components/formula.md): `formula` - Reactive KaTeX formula display.
45
+ - [Stat](/docs/components/stat.md): `stat` - Metric display.
46
+ - [Text](/docs/components/text.md): `text` - Plain text display.
47
+
42
48
  ## Component
43
49
 
44
50
  - [Icon](/docs/components/icon.md): `icon` - Shared icon field capability.
@@ -52,11 +58,6 @@ Public component count: 28
52
58
  - [Progress](/docs/components/progress.md): `progress` - Progress bar.
53
59
  - [Toast](/docs/components/toast.md): `toast` - Transient notification.
54
60
 
55
- ## Display
56
-
57
- - [Stat](/docs/components/stat.md): `stat` - Metric display.
58
- - [Text](/docs/components/text.md): `text` - Plain text display.
59
-
60
61
  ## Data
61
62
 
62
63
  - [Table](/docs/components/table.md): `table` - Simple data table.
@@ -265,6 +266,26 @@ No child components.
265
266
 
266
267
  ---
267
268
 
269
+ ## Formula API (`formula`)
270
+
271
+ Category: Display
272
+ Status: ready
273
+ State mode: none
274
+ Since: 0.1.0
275
+
276
+ ### Props
277
+ - `tex` (string; optional; dynamic): KaTeX source to render.
278
+ - `formula` (string; optional; dynamic): Alias for tex.
279
+ - `value` (string; optional; dynamic): Alias for tex.
280
+ - `displayMode` (boolean; optional; static; default: true): Render as display math when true; inline math when false.
281
+ - `display` (boolean; optional; static; default: true): Alias for displayMode.
282
+ - `block` (boolean; optional; static; default: true): Alias for displayMode.
283
+
284
+ ### Children
285
+ No child components.
286
+
287
+ ---
288
+
268
289
  ## Grid API (`grid`)
269
290
 
270
291
  Category: Layout