@ox-content/code-play 3.0.0-alpha.9 → 3.0.0-beta.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.
- package/README.md +31 -3
- package/dist/browser.mjs +412 -44
- package/dist/client.mjs +17 -4
- package/dist/client.mjs.map +1 -1
- package/dist/config.d.mts +47 -2
- package/dist/config.d.mts.map +1 -1
- package/dist/hydrate.d.mts +3 -1
- package/dist/hydrate.d.mts.map +1 -1
- package/dist/hydrate2.mjs +395 -43
- package/dist/hydrate2.mjs.map +1 -1
- package/dist/index.d.mts +49 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +4 -4
- package/dist/payload.mjs +5 -1
- package/dist/payload.mjs.map +1 -1
- package/dist/plugin.d.mts.map +1 -1
- package/dist/plugin2.mjs +712 -162
- package/dist/plugin2.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,6 +4,7 @@ Opt-in Code Play plugin for Ox Content. It runs documentation samples on demand
|
|
|
4
4
|
and exposes a headless API plus Headless / preset UI.
|
|
5
5
|
|
|
6
6
|
Nothing runs until you install this package **and** enable specific languages.
|
|
7
|
+
Pages without matching `play` blocks do not load `ox-code-play.js`.
|
|
7
8
|
|
|
8
9
|
## Install
|
|
9
10
|
|
|
@@ -33,21 +34,41 @@ export default {
|
|
|
33
34
|
## Authoring
|
|
34
35
|
|
|
35
36
|
````md
|
|
36
|
-
```ts play
|
|
37
|
+
```ts play typecheck play-title="Strict TypeScript" play-strict=false play-target=ESNext
|
|
37
38
|
const n: number = 1;
|
|
38
39
|
console.log(n);
|
|
39
40
|
```
|
|
40
41
|
|
|
41
|
-
```rust play typecheck
|
|
42
|
+
```rust play typecheck play-title="Release-mode Rust" play-mode=release
|
|
42
43
|
fn main() {
|
|
43
44
|
println!("ok");
|
|
44
45
|
}
|
|
45
46
|
```
|
|
46
47
|
````
|
|
47
48
|
|
|
49
|
+
Use `play-title`, `play-compact` / `play-headless`, `play-timeout=2500`,
|
|
50
|
+
`play-viewers=stdio,stderr,-timing`, and `play-<config-key>=...` for one
|
|
51
|
+
sample. The MDX-style `<CodePlay>` tag accepts `title`, `ui`, `timeout`,
|
|
52
|
+
`viewers`, and `config-*` attributes.
|
|
53
|
+
|
|
48
54
|
```html
|
|
49
|
-
<CodePlay lang="
|
|
55
|
+
<CodePlay lang="ts" title="Loose TS" typecheck ui="compact" config-strict="false">
|
|
56
|
+
const n = 1;
|
|
57
|
+
</CodePlay>
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Project-level examples stay opt-in per sample:
|
|
61
|
+
|
|
62
|
+
````md
|
|
63
|
+
```ts play play-project=stackblitz play-file=src/main.ts play-entry=src/main.ts play-files=package.json,src/App.tsx play-project-url=https://stackblitz.com/edit/example
|
|
64
|
+
console.log("project");
|
|
50
65
|
```
|
|
66
|
+
````
|
|
67
|
+
|
|
68
|
+
`play-file` names the current fence inside the project, `play-files` lists
|
|
69
|
+
extra files relative to the Markdown source file, and `play-project-url`
|
|
70
|
+
provides the external fallback link. Providers are metadata adapters; no
|
|
71
|
+
StackBlitz, CodeSandbox, or WebContainer script is loaded by Code Play.
|
|
51
72
|
|
|
52
73
|
## Headless API
|
|
53
74
|
|
|
@@ -66,6 +87,10 @@ run.provenance;
|
|
|
66
87
|
run.timing;
|
|
67
88
|
```
|
|
68
89
|
|
|
90
|
+
`run.status` is `ok`, `error`, `offline`, `timeout`, `cancelled`, or
|
|
91
|
+
`unsupported`. Custom UIs can use the exported `RunActionState` helpers to
|
|
92
|
+
model idle, running, result, error, and offline states.
|
|
93
|
+
|
|
69
94
|
## Security
|
|
70
95
|
|
|
71
96
|
`play` fences are trusted site content. Do not mark unreviewed or
|
|
@@ -83,6 +108,9 @@ visitor-supplied snippets as `play`.
|
|
|
83
108
|
The Vite `/__ox-code-play/*` proxy is **dev-only**.
|
|
84
109
|
- Other languages need a Piston-compatible `endpoint` you trust.
|
|
85
110
|
- `sh` never spawns a local shell.
|
|
111
|
+
- Project sandboxes include trusted source in the static payload. `play-files`
|
|
112
|
+
are read only from relative paths inside the configured Markdown source root,
|
|
113
|
+
with symlink real paths checked before embedding.
|
|
86
114
|
|
|
87
115
|
## Example
|
|
88
116
|
|