slexkit 0.2.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +70 -0
- package/LICENSE +21 -21
- package/README.md +4 -3
- package/README.zh-CN.md +4 -3
- package/dist/ai/llms-authoring.txt +2 -0
- package/dist/ai/llms-capabilities.txt +126 -0
- package/dist/ai/llms-components.txt +29 -7
- package/dist/ai/llms-full.txt +1909 -153
- package/dist/ai/llms-runtime.txt +18 -13
- package/dist/ai/llms.txt +22 -1
- package/dist/ai/slexkit-ai-manifest.json +717 -62
- package/dist/base.css +359 -359
- package/dist/chunks/{accordion-cfjyxw93.js → button-53ccjq5p.js} +11 -11
- package/dist/chunks/{accordion-nw12ytps.js → button-cr1fhsa7.js} +48 -2
- package/dist/chunks/{accordion-5f0nvjjm.js → button-dsftwzvg.js} +4 -3
- package/dist/chunks/{accordion-hzyrngd6.js → button-faf563xf.js} +2 -2
- package/dist/chunks/{accordion-ehnhpeca.js → button-jxv4c65t.js} +2 -2
- package/dist/chunks/{accordion-cw5r75jm.js → button-xv2dz7vn.js} +1 -1
- package/dist/chunks/{accordion-830dw78f.js → button-z5yv24ks.js} +2 -2
- package/dist/components/accordion.js +2 -2
- package/dist/components/badge.js +2 -2
- package/dist/components/button.css +101 -101
- package/dist/components/button.js +3 -3
- package/dist/components/callout.js +4 -4
- package/dist/components/card.js +2 -2
- package/dist/components/checkbox.js +3 -2
- package/dist/components/choice.css +151 -151
- package/dist/components/code-block.js +2 -2
- package/dist/components/collapsible.js +2 -2
- package/dist/components/column.js +1 -1
- package/dist/components/content.css +273 -250
- package/dist/components/display.css +1 -1
- package/dist/components/divider.js +2 -2
- package/dist/components/grid.js +1 -1
- package/dist/components/index.js +13994 -172
- package/dist/components/input.css +786 -852
- package/dist/components/input.js +34 -144
- package/dist/components/link.js +2 -2
- package/dist/components/progress.js +2 -2
- package/dist/components/radio-group.js +3 -2
- package/dist/components/row.js +1 -1
- package/dist/components/section.js +2 -2
- package/dist/components/select.css +175 -181
- package/dist/components/select.js +3 -3
- package/dist/components/slider.css +125 -116
- package/dist/components/slider.js +2 -2
- package/dist/components/specs.js +34 -1
- package/dist/components/stat.js +2 -2
- package/dist/components/submit.css +8 -8
- package/dist/components/submit.js +1 -1
- package/dist/components/switch.css +105 -105
- package/dist/components/switch.js +4 -3
- package/dist/components/table.js +4 -4
- package/dist/components/tabs.css +95 -95
- package/dist/components/tabs.js +4 -4
- package/dist/components/text-input.css +26 -95
- package/dist/components/text.js +13 -1
- package/dist/components/toast.js +4 -4
- package/dist/components/tooling.css +0 -1
- package/dist/components/tooling.js +73 -8
- package/dist/runtime.cjs +1610 -17
- package/dist/runtime.js +1609 -16
- package/dist/slexkit.cjs +28191 -13865
- package/dist/slexkit.css +1525 -1569
- package/dist/slexkit.js +28190 -13864
- package/dist/tooling.js +117 -11
- package/dist/types/components/svelte/helpers.d.ts +8 -1
- package/dist/types/engine/capabilities.d.ts +54 -0
- package/dist/types/engine/index.d.ts +6 -0
- package/dist/types/engine/secure-runtime.d.ts +9 -1
- package/dist/types/engine/stdlib.d.ts +30 -0
- package/dist/types/engine/types.d.ts +1 -0
- package/dist/types/engine/validation.d.ts +28 -0
- package/dist/types/index.d.ts +6 -3
- package/dist/types/runtime.d.ts +6 -3
- package/dist/types/version.d.ts +2 -2
- package/dist/umd/slexkit.tooling.umd.js +45084 -44775
- package/dist/umd/slexkit.umd.js +28191 -13865
- package/package.json +5 -3
- package/skills/slexkit-host-integration/SKILL.md +1 -1
- package/src/components/svelte/content/Formula.svelte +27 -0
- package/src/components/svelte/content/Table.svelte +1 -1
- package/src/components/svelte/display/Text.svelte +14 -1
- package/src/components/svelte/helpers.ts +56 -1
- package/src/components/svelte/input/Checkbox.svelte +1 -1
- package/src/components/svelte/input/Input.svelte +0 -110
- package/src/components/svelte/input/RadioGroup.svelte +1 -1
- package/src/components/svelte/input/Select.svelte +2 -2
- package/src/components/svelte/input/Switch.svelte +2 -2
- package/src/components/svelte/input/Tabs.svelte +7 -7
- package/src/components/svelte/tooling/PlaygroundMarkdown.svelte +84 -2
- package/src/styles/components/button.css +101 -101
- package/src/styles/components/choice.css +152 -152
- package/src/styles/components/select.css +175 -181
- package/src/styles/components/slider.css +125 -116
- package/src/styles/components/submit.css +8 -8
- package/src/styles/components/switch.css +105 -105
- package/src/styles/components/tabs.css +95 -95
- package/src/styles/components/text-input.css +26 -95
- package/src/styles/content.css +274 -251
- package/src/styles/display.css +1 -1
- package/src/styles/input.css +8 -8
- package/src/styles/layout.css +360 -360
- package/src/styles/tooling.css +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,76 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to SlexKit.
|
|
4
4
|
|
|
5
|
+
## v0.3.1 - Host stability and control rendering hardening
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- Runtime style safety tests that block broad `:has()` selectors, `clip-path`, and slider track regressions in shipped CSS.
|
|
9
|
+
- Regression coverage for disabled Switch, Checkbox, and Radio state attributes.
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
- CI now installs dependencies with `bun install --frozen-lockfile` and runs lint before tests.
|
|
13
|
+
- Disabled Switch, Checkbox, and Radio styling now uses explicit `data-disabled` attributes instead of broad relational selectors.
|
|
14
|
+
- Select and sr-only helper styles avoid `clip-path` for better host and Obsidian CSS compatibility.
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
- Slider thumb rendering artifacts caused by painting the range track on the native input box.
|
|
18
|
+
- Input focus visibility after removing custom engineering steppers.
|
|
19
|
+
- Home RC example input labels now use native Input component labels instead of separate text labels.
|
|
20
|
+
- Stat cards no longer clip updated text during cross-document state examples.
|
|
21
|
+
- Markdown calculator examples no longer render duplicate section labels.
|
|
22
|
+
|
|
23
|
+
## v0.3.0 - Examples overhaul with component audit and i18n
|
|
24
|
+
|
|
25
|
+
### Added
|
|
26
|
+
- Example gallery: 17 high-quality examples organized by usage scenario (Getting Started, Calculators, Data Browsing, Dashboards, Config Wizards, Decision Support, Platform Features)
|
|
27
|
+
- English translations for all 17 example pages
|
|
28
|
+
- `toolhost-demo`: real `renderToolCall` API with chat-style conversation UI
|
|
29
|
+
- Example rendering infrastructure: `site/routes/examples.js`, `site/pages/examples.slex.js`, `site/data/examples.js`
|
|
30
|
+
- Content discovery: `site/data/content-discovery.js` with locale fallback and allowed-slug filtering
|
|
31
|
+
- `site/data/content-discovery.js`: `discoverExampleMarkdown()` with per-locale discovery
|
|
32
|
+
- SEO metadata for example pages
|
|
33
|
+
- `examples/minimal-cdn/index.html`: zero-build CDN usage example
|
|
34
|
+
- Formula component (`src/components/svelte/content/Formula.svelte`) with KaTeX rendering
|
|
35
|
+
- `src/engine/capabilities.ts`: structured capability docs for AI agents
|
|
36
|
+
- `src/engine/validation.ts`: SPEC contract validation for component specs
|
|
37
|
+
- `src/engine/stdlib.ts`: standard library with `math.clamp`, `math.safeDivide`, and other utilities
|
|
38
|
+
- `src/engine/sandbox-runner.ts`: sandbox runner for secure runtime
|
|
39
|
+
- Component state eval context shadowing test suite (`component-state-shadowing.test.ts`)
|
|
40
|
+
- Collapsible and Callout double-rendering regression tests
|
|
41
|
+
- Slider component name shadowing regression test
|
|
42
|
+
- Tests for content, playground, select, tabs, slider, disclosure, feedback, policy-api
|
|
43
|
+
|
|
44
|
+
### Changed
|
|
45
|
+
- Examples reduced from 64 to 17 high-quality examples, organized by user story
|
|
46
|
+
- Example source locale: `zh-CN` (with `en-US` translations)
|
|
47
|
+
- `renderChildren` (`helpers.ts`) now clears existing content when children are present
|
|
48
|
+
- Switch component now accepts `checked`/`value` props for initialization consistency with Checkbox
|
|
49
|
+
- Site UI: DocsShell, DocRail, router, shell improvements
|
|
50
|
+
- Components: Input, Select, Tabs, Table, PlaygroundMarkdown refinements
|
|
51
|
+
- CSS: theme-shadcn, text-input, docs-shell styling updates
|
|
52
|
+
- MCP: enhanced with structured capability docs
|
|
53
|
+
|
|
54
|
+
### Fixed
|
|
55
|
+
- Eval context shadowing: component names `g` and `api` no longer overwrite reserved context keys
|
|
56
|
+
- `renderChildren` double rendering in Collapsible and Callout
|
|
57
|
+
- Voltage divider summary typo ("输入输入电压")
|
|
58
|
+
- Salary calculator fallback numbers to match actual calculator output
|
|
59
|
+
- Tabs-and-branching: title and length conversion mismatch
|
|
60
|
+
- 4 pre-existing test failures (ai-docs, page-structure, theme, markdown-content)
|
|
61
|
+
- Toolhost test: added setup import to fix `document is not defined`
|
|
62
|
+
- Badge stretching in grid layout
|
|
63
|
+
- Project-dashboard syntax error
|
|
64
|
+
- Salary-calculator rate configuration
|
|
65
|
+
|
|
66
|
+
### Removed
|
|
67
|
+
- 47 low-quality/duplicate examples (reduced from 64 to 17)
|
|
68
|
+
- Dead "Fallback" copywriting from all example files
|
|
69
|
+
- Post-slex explanatory text from example files
|
|
70
|
+
- Unused `DialogShell.svelte` component
|
|
71
|
+
- Orphaned `test-if` example directory
|
|
72
|
+
- Agent-generated `docs/compose` planning files
|
|
73
|
+
- Temporary `screenshot-*.png` files
|
|
74
|
+
|
|
5
75
|
## v0.2.0 - First public release
|
|
6
76
|
|
|
7
77
|
### 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.
|
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
<a href="README.zh-CN.md">简体中文</a>
|
|
16
16
|
</p>
|
|
17
17
|
<p>
|
|
18
|
-
<img alt="version" src="https://img.shields.io/badge/version-0.
|
|
18
|
+
<img alt="version" src="https://img.shields.io/badge/version-0.3.1-18181b">
|
|
19
19
|
<img alt="script" src="https://img.shields.io/badge/Slex-v0.1-18181b">
|
|
20
20
|
<img alt="TypeScript" src="https://img.shields.io/badge/runtime-TypeScript-3178c6">
|
|
21
21
|
<img alt="Svelte 5" src="https://img.shields.io/badge/components-Svelte_5-ff3e00">
|
|
@@ -31,6 +31,8 @@ It is built for chat messages, documents, agent panels, tool results, and AI-aut
|
|
|
31
31
|
|
|
32
32
|
## Installation
|
|
33
33
|
|
|
34
|
+
> Just want to use SlexKit in Obsidian? Open **Settings -> Community plugins**, search for **SlexKit**, then install and enable it. The npm package below is for developers integrating SlexKit into web apps, Markdown renderers, Streamdown, or custom hosts.
|
|
35
|
+
|
|
34
36
|
```sh
|
|
35
37
|
npm install slexkit
|
|
36
38
|
```
|
|
@@ -115,7 +117,6 @@ Markdown platforms without SlexKit support show the fallback text. Hosts with Sl
|
|
|
115
117
|
| `@slexkit/components-svelte` | `npm install slexkit @slexkit/runtime @slexkit/components-svelte` | Svelte component registration |
|
|
116
118
|
| `@slexkit/theme-shadcn` | `npm install @slexkit/theme-shadcn` | CSS theme tokens |
|
|
117
119
|
| `@slexkit/streamdown` | `npm install slexkit @slexkit/theme-shadcn @slexkit/streamdown streamdown react react-dom` | React / Streamdown Markdown renderer |
|
|
118
|
-
| `@slexkit/obsidian` | `npm install slexkit @slexkit/obsidian` | Obsidian plugin adapter |
|
|
119
120
|
| `@slexkit/mcp` | `npx -y @slexkit/mcp` | Read-only MCP server for docs, examples, and source validation |
|
|
120
121
|
|
|
121
122
|
See [Package Boundaries](site/content/reference/packages/en-US.md) for details.
|
|
@@ -127,7 +128,7 @@ See [Package Boundaries](site/content/reference/packages/en-US.md) for details.
|
|
|
127
128
|
| Browser DOM | `mount()`, `ingest()`, `boot()`, `disposeNamespace()` |
|
|
128
129
|
| Markdown renderers | `createSlexKitMarkdownRuntimeHost()` |
|
|
129
130
|
| React / Streamdown | `@slexkit/streamdown` |
|
|
130
|
-
| Obsidian |
|
|
131
|
+
| Obsidian | Install **SlexKit** from Community Plugins; release repo: <https://github.com/slexkit/obsidian-slexkit> |
|
|
131
132
|
| AI agents | `@slexkit/mcp`, `llms.txt`, SlexKit skill docs |
|
|
132
133
|
| Custom components | `register()`, `registerSvelteComponent()`, `registerSubset()` |
|
|
133
134
|
|
package/README.zh-CN.md
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
<a href="README.md">English</a>
|
|
16
16
|
</p>
|
|
17
17
|
<p>
|
|
18
|
-
<img alt="version" src="https://img.shields.io/badge/version-0.
|
|
18
|
+
<img alt="version" src="https://img.shields.io/badge/version-0.3.1-18181b">
|
|
19
19
|
<img alt="script" src="https://img.shields.io/badge/Slex-v0.1-18181b">
|
|
20
20
|
<img alt="TypeScript" src="https://img.shields.io/badge/runtime-TypeScript-3178c6">
|
|
21
21
|
<img alt="Svelte 5" src="https://img.shields.io/badge/components-Svelte_5-ff3e00">
|
|
@@ -31,6 +31,8 @@
|
|
|
31
31
|
|
|
32
32
|
## 安装
|
|
33
33
|
|
|
34
|
+
> 只想在 Obsidian 里使用 SlexKit?打开 **Settings -> Community plugins**,搜索 **SlexKit**,安装并启用即可。下面的 npm 安装方式主要面向需要把 SlexKit 接入网页、Markdown renderer、Streamdown 或自定义宿主的开发者。
|
|
35
|
+
|
|
34
36
|
```sh
|
|
35
37
|
npm install slexkit
|
|
36
38
|
```
|
|
@@ -115,7 +117,6 @@ import "slexkit/style.css";
|
|
|
115
117
|
| `@slexkit/components-svelte` | `npm install slexkit @slexkit/runtime @slexkit/components-svelte` | Svelte 组件注册 |
|
|
116
118
|
| `@slexkit/theme-shadcn` | `npm install @slexkit/theme-shadcn` | CSS 主题 token |
|
|
117
119
|
| `@slexkit/streamdown` | `npm install slexkit @slexkit/theme-shadcn @slexkit/streamdown streamdown react react-dom` | React / Streamdown Markdown 渲染器 |
|
|
118
|
-
| `@slexkit/obsidian` | `npm install slexkit @slexkit/obsidian` | Obsidian 插件适配器 |
|
|
119
120
|
| `@slexkit/mcp` | `npx -y @slexkit/mcp` | 面向文档、示例和源码校验的只读 MCP 服务 |
|
|
120
121
|
|
|
121
122
|
更多说明见 [Package Boundaries](site/content/reference/packages/zh-CN.md)。
|
|
@@ -127,7 +128,7 @@ import "slexkit/style.css";
|
|
|
127
128
|
| 浏览器 DOM | `mount()`、`ingest()`、`boot()`、`disposeNamespace()` |
|
|
128
129
|
| Markdown 渲染器 | `createSlexKitMarkdownRuntimeHost()` |
|
|
129
130
|
| React / Streamdown | `@slexkit/streamdown` |
|
|
130
|
-
| Obsidian |
|
|
131
|
+
| Obsidian | 从 Community Plugins 安装 **SlexKit**;发布仓库:<https://github.com/slexkit/obsidian-slexkit> |
|
|
131
132
|
| AI Agents | `@slexkit/mcp`、`llms.txt`、SlexKit skill 文档 |
|
|
132
133
|
| 自定义组件 | `register()`、`registerSvelteComponent()`、`registerSubset()` |
|
|
133
134
|
|
|
@@ -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:
|
|
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
|
|
@@ -334,7 +355,6 @@ Since: 0.1.0
|
|
|
334
355
|
- `min` (string | number; optional; dynamic): Minimum value used by numeric input controls.
|
|
335
356
|
- `max` (string | number; optional; dynamic): Maximum value used by numeric input controls.
|
|
336
357
|
- `step` (string | number; optional; dynamic): Step size used by numeric input controls.
|
|
337
|
-
- `controls` (boolean; optional; dynamic; default: true): Show decrement and increment buttons for numeric inputs.
|
|
338
358
|
- `onchange` (write-expression; optional; static): Write expression invoked when the value changes.
|
|
339
359
|
|
|
340
360
|
### Children
|
|
@@ -634,6 +654,8 @@ Since: 0.1.0
|
|
|
634
654
|
- `content` (string; optional; dynamic): Alias for text.
|
|
635
655
|
- `label` (string; optional; dynamic): Alias for text.
|
|
636
656
|
- `variant` (string; optional; static; default: "default"; values: default, muted): Text visual variant.
|
|
657
|
+
- `color` (string; optional; dynamic): Optional CSS color for controlled previews.
|
|
658
|
+
- `size` (string | number; optional; dynamic): Optional font size. Numbers are treated as px.
|
|
637
659
|
- `class` (string; optional; static): Additional host-controlled CSS class.
|
|
638
660
|
|
|
639
661
|
### Children
|