@ox-content/code-play 3.0.0-alpha.1 → 3.0.0-alpha.10

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 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,20 +34,27 @@ 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="python"> print("hello") </CodePlay>
55
+ <CodePlay lang="ts" title="Loose TS" typecheck ui="compact" config-strict="false">
56
+ const n = 1;
57
+ </CodePlay>
50
58
  ```
51
59
 
52
60
  ## Headless API
@@ -66,15 +74,20 @@ run.provenance;
66
74
  run.timing;
67
75
  ```
68
76
 
77
+ `run.status` is `ok`, `error`, `offline`, `timeout`, `cancelled`, or
78
+ `unsupported`. Custom UIs can use the exported `RunActionState` helpers to
79
+ model idle, running, result, error, and offline states.
80
+
69
81
  ## Security
70
82
 
71
83
  `play` fences are trusted site content. Do not mark unreviewed or
72
84
  visitor-supplied snippets as `play`.
73
85
 
74
86
  - No sample is executed during Markdown transform or SSG.
75
- - JavaScript and TypeScript run in `node:vm` on Node, or in
76
- `<iframe sandbox="allow-scripts">` in the browser (no `allow-same-origin`).
77
- They are never run with page-origin `Function`.
87
+ - JavaScript and TypeScript run in `node:vm` on Node, or in a Web Worker in the
88
+ browser. Browsers without Worker support fall back to
89
+ `<iframe sandbox="allow-scripts">` with no `allow-same-origin`. Snippets are
90
+ never run with page-origin `Function`.
78
91
  - Published widgets hide **Typecheck** unless `endpoints.typecheck` is set.
79
92
  **Cancel** appears while a run is in flight.
80
93
  - Framework previews use the same iframe flags and load runtimes from esm.sh.