@kubohiroya/turbowarp-structured-data 0.6.2 → 0.7.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.ja.md +38 -0
- package/README.md +61 -7
- package/dist/structured-data.js +43 -22
- package/docs/.nojekyll +0 -0
- package/docs/assets/github-mark.svg +1 -0
- package/docs/assets/site.css +847 -0
- package/docs/index.html +577 -21
- package/docs/ja/index.html +549 -0
- package/lib-editor/src/config.d.ts +6 -0
- package/lib-module/src/bundle-module.d.ts +7 -0
- package/lib-module/src/bundle-module.js +1384 -0
- package/lib-module/src/codecs.d.ts +10 -0
- package/lib-module/src/config.d.ts +25 -0
- package/lib-module/src/core.d.ts +34 -0
- package/lib-module/src/editor-schema.d.ts +2 -0
- package/lib-module/src/extension.d.ts +74 -0
- package/lib-module/src/fixed-input-editors.d.ts +9 -0
- package/lib-module/src/fixed-input-schema.d.ts +3 -0
- package/lib-module/src/runtime-api.d.ts +41 -0
- package/lib-module/src/source-editor.d.ts +8 -0
- package/lib-module/src/structured-provider.d.ts +33 -0
- package/package.json +19 -11
- package/src/bundle-module.ts +23 -0
- package/src/config.ts +11 -0
- package/src/extension.ts +17 -15
- package/src/globals.d.ts +7 -36
- package/src/index.ts +2 -2
- package/src/runtime-api.ts +43 -0
- package/src/structured-provider.ts +38 -7
- package/templates/README.ja.md +36 -0
- package/templates/README.md +48 -6
package/docs/index.html
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
1
|
<!doctype html>
|
|
2
2
|
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
+
<meta name="theme-color" content="#0b0912">
|
|
7
|
+
<meta name="description" content="User guide for the Structured Data TurboWarp extension: load JSON or YAML into a named value, read and update it by path, loop over it, and turn it back into text.">
|
|
8
|
+
<meta property="og:type" content="website">
|
|
9
|
+
<meta property="og:title" content="Structured Data — User Guide">
|
|
10
|
+
<meta property="og:description" content="Work with JSON and YAML in TurboWarp: named values, safe paths, bounded loops.">
|
|
11
|
+
<meta property="og:url" content="https://kubohiroya.github.io/turbowarp-structured-data/">
|
|
12
|
+
<link rel="canonical" href="https://kubohiroya.github.io/turbowarp-structured-data/">
|
|
13
|
+
<link rel="alternate" hreflang="en" href="https://kubohiroya.github.io/turbowarp-structured-data/">
|
|
14
|
+
<link rel="alternate" hreflang="ja" href="https://kubohiroya.github.io/turbowarp-structured-data/ja/">
|
|
15
|
+
<link rel="alternate" hreflang="x-default" href="https://kubohiroya.github.io/turbowarp-structured-data/">
|
|
16
|
+
<link rel="stylesheet" href="./assets/site.css">
|
|
17
|
+
<title>Structured Data — User Guide</title>
|
|
12
18
|
<style id="block-reference-style">
|
|
13
19
|
#extension-block-reference{max-width:72rem;margin:2rem auto;padding:1rem;line-height:1.6;overflow-wrap:anywhere}
|
|
14
20
|
#extension-block-reference .block-reference-entry{display:block;scroll-margin-top:6rem;margin:2rem 0;padding:1rem;border:1px solid currentColor;border-radius:.5rem}
|
|
@@ -18,19 +24,569 @@
|
|
|
18
24
|
#extension-block-reference code{white-space:pre-wrap}
|
|
19
25
|
#extension-block-reference a:focus-visible{outline:3px solid currentColor;outline-offset:3px}
|
|
20
26
|
</style>
|
|
21
|
-
</head>
|
|
22
|
-
<body
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
</head>
|
|
28
|
+
<body>
|
|
29
|
+
<a class="skip-link" href="#content">Skip to content</a>
|
|
30
|
+
<header class="site-header">
|
|
31
|
+
<div class="header-inner">
|
|
32
|
+
<a class="brand" href="./" aria-label="Structured Data home">
|
|
33
|
+
<span class="brand-mark" aria-hidden="true">{ }</span>
|
|
34
|
+
<span class="brand-name">Structured Data</span>
|
|
35
|
+
</a>
|
|
36
|
+
<nav class="main-nav" aria-label="Guide sections">
|
|
37
|
+
<a href="#start">Start</a>
|
|
38
|
+
<a href="#flow">Flow</a>
|
|
39
|
+
<a href="#paths">Paths</a>
|
|
40
|
+
<a href="#loops">Loops</a>
|
|
41
|
+
<a href="#blocks">Blocks</a>
|
|
42
|
+
<a href="#help">Help</a>
|
|
43
|
+
<a href="#extension-block-reference">Reference</a>
|
|
44
|
+
</nav>
|
|
45
|
+
<a
|
|
46
|
+
class="github-link"
|
|
47
|
+
href="https://github.com/kubohiroya/turbowarp-structured-data"
|
|
48
|
+
aria-label="View the source code on GitHub"
|
|
49
|
+
>
|
|
50
|
+
<img src="./assets/github-mark.svg" width="24" height="24" alt="">
|
|
51
|
+
<span class="github-link-label">GitHub</span>
|
|
52
|
+
</a>
|
|
53
|
+
<nav class="language-nav" aria-label="Language">
|
|
54
|
+
<a href="./" lang="en" hreflang="en" aria-current="page">English</a>
|
|
55
|
+
<a href="./ja/" lang="ja" hreflang="ja">日本語</a>
|
|
56
|
+
</nav>
|
|
57
|
+
</div>
|
|
58
|
+
</header>
|
|
25
59
|
|
|
26
|
-
|
|
27
|
-
|
|
60
|
+
<main id="content" class="page-shell"><p lang="en" class="complete-block-reference-link"><a href="#extension-block-reference">Complete block reference (16 blocks)</a></p>
|
|
61
|
+
<section class="hero" aria-labelledby="hero-title">
|
|
62
|
+
<div>
|
|
63
|
+
<p class="eyebrow">TurboWarp custom extension</p>
|
|
64
|
+
<h1 id="hero-title">Real data, without the string juggling.</h1>
|
|
65
|
+
<p class="lede">
|
|
66
|
+
Load JSON or YAML once, give it a name, and work with it directly: read one
|
|
67
|
+
field, change one value, loop over a list, then turn the result back into text.
|
|
68
|
+
No more splitting strings or keeping parallel lists in sync.
|
|
69
|
+
</p>
|
|
70
|
+
<div class="hero-actions">
|
|
71
|
+
<a class="button button-primary" href="#start">Set it up</a>
|
|
72
|
+
<a class="button button-secondary" href="#recipes">See examples</a>
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
75
|
+
<div class="hero-visual" aria-label="Example: YAML is parsed as cfg, one value is changed, and JSON is rendered">
|
|
76
|
+
<div class="visual-window">
|
|
77
|
+
<div class="window-bar" aria-hidden="true">
|
|
78
|
+
<i></i><i></i><i></i><span>Structured Data</span>
|
|
79
|
+
</div>
|
|
80
|
+
<div class="scratch-stack">
|
|
81
|
+
<div class="scratch-block">
|
|
82
|
+
parse YAML <code>speed: 4</code> as <code>cfg</code>
|
|
83
|
+
</div>
|
|
84
|
+
<div class="scratch-block">
|
|
85
|
+
set <code>cfg</code> at path <code>$.speed</code> to JSON <code>6</code>
|
|
86
|
+
</div>
|
|
87
|
+
<div class="result-line">
|
|
88
|
+
<span>to JSON <code>cfg</code></span>
|
|
89
|
+
<span aria-hidden="true">→</span>
|
|
90
|
+
<span class="result-pill">{"speed":6}</span>
|
|
91
|
+
</div>
|
|
92
|
+
</div>
|
|
93
|
+
</div>
|
|
94
|
+
</div>
|
|
95
|
+
</section>
|
|
28
96
|
|
|
29
|
-
|
|
30
|
-
|
|
97
|
+
<section id="start" class="section" aria-labelledby="start-title">
|
|
98
|
+
<div class="section-heading">
|
|
99
|
+
<div>
|
|
100
|
+
<p class="eyebrow">01 · Start here</p>
|
|
101
|
+
<h2 id="start-title">Ready in three steps.</h2>
|
|
102
|
+
</div>
|
|
103
|
+
<p>
|
|
104
|
+
Structured Data is an opt-in preview. Its blocks appear only when the startup
|
|
105
|
+
flag is set before the extension loads, so an existing project is never
|
|
106
|
+
affected by accident.
|
|
107
|
+
</p>
|
|
108
|
+
</div>
|
|
31
109
|
|
|
32
|
-
|
|
33
|
-
|
|
110
|
+
<div class="step-grid">
|
|
111
|
+
<article class="step">
|
|
112
|
+
<span class="step-number">1</span>
|
|
113
|
+
<h3>Turn on the feature flag</h3>
|
|
114
|
+
<p>
|
|
115
|
+
In the page that runs TurboWarp (for example, from the browser console or
|
|
116
|
+
your own host page), run <code>globalThis.STRUCTURED_DATA_MVP = true</code>
|
|
117
|
+
<em>before</em> loading the extension.
|
|
118
|
+
</p>
|
|
119
|
+
</article>
|
|
120
|
+
<article class="step">
|
|
121
|
+
<span class="step-number">2</span>
|
|
122
|
+
<h3>Load the extension</h3>
|
|
123
|
+
<p>
|
|
124
|
+
Add the extension URL below as a custom extension and choose
|
|
125
|
+
<strong>Run extension without sandbox</strong>.
|
|
126
|
+
</p>
|
|
127
|
+
</article>
|
|
128
|
+
<article class="step">
|
|
129
|
+
<span class="step-number">3</span>
|
|
130
|
+
<h3>Parse your first value</h3>
|
|
131
|
+
<p>
|
|
132
|
+
Drag <code>parse JSON [ ] as [data]</code> or
|
|
133
|
+
<code>parse YAML [ ] as [data]</code> into a script and click it. The name
|
|
134
|
+
<code>data</code> now holds your value.
|
|
135
|
+
</p>
|
|
136
|
+
</article>
|
|
137
|
+
</div>
|
|
138
|
+
|
|
139
|
+
<div class="code-card" style="margin-top: 1rem">
|
|
140
|
+
<span class="code-label">Version-pinned extension URL</span>
|
|
141
|
+
<pre><code>https://cdn.jsdelivr.net/npm/@kubohiroya/turbowarp-structured-data@0.6.2/dist/structured-data.js</code></pre>
|
|
142
|
+
</div>
|
|
143
|
+
|
|
144
|
+
<div class="callout" role="note" style="margin-top: 1rem">
|
|
145
|
+
<span class="callout-mark" aria-hidden="true">!</span>
|
|
146
|
+
<p>
|
|
147
|
+
<strong>Unsandboxed access is required.</strong> Each sprite and the stage keep
|
|
148
|
+
their own named values, and loops track the running script. That needs direct
|
|
149
|
+
access to the TurboWarp VM. The extension makes no network requests and stores
|
|
150
|
+
nothing outside the running project. Only load extension files from a source
|
|
151
|
+
you trust.
|
|
152
|
+
</p>
|
|
153
|
+
</div>
|
|
154
|
+
</section>
|
|
155
|
+
|
|
156
|
+
<section id="flow" class="section" aria-labelledby="flow-title">
|
|
157
|
+
<div class="section-heading">
|
|
158
|
+
<div>
|
|
159
|
+
<p class="eyebrow">02 · How it works</p>
|
|
160
|
+
<h2 id="flow-title">Parse once. Work by name. Render when you need text.</h2>
|
|
161
|
+
</div>
|
|
162
|
+
<p>
|
|
163
|
+
Text goes in, a named value lives in the sprite, and you only get text back
|
|
164
|
+
when you ask for it. In between, every block works on the real structure:
|
|
165
|
+
objects, arrays, numbers, strings, Booleans, and <code>null</code>.
|
|
166
|
+
</p>
|
|
167
|
+
</div>
|
|
168
|
+
|
|
169
|
+
<figure class="diagram" aria-labelledby="flow-diagram-title">
|
|
170
|
+
<figcaption id="flow-diagram-title" class="diagram-title">
|
|
171
|
+
The life of a named value
|
|
172
|
+
</figcaption>
|
|
173
|
+
<div class="flow">
|
|
174
|
+
<div class="flow-node">
|
|
175
|
+
<strong>JSON or YAML text</strong>
|
|
176
|
+
<small>from a variable, a list item, a file, or a web response</small>
|
|
177
|
+
</div>
|
|
178
|
+
<div class="flow-arrow" aria-hidden="true">→</div>
|
|
179
|
+
<div class="flow-node flow-node-accent">
|
|
180
|
+
<strong>Named value</strong>
|
|
181
|
+
<small>read, test, set, delete, and loop by <code>$.path</code></small>
|
|
182
|
+
</div>
|
|
183
|
+
<div class="flow-arrow" aria-hidden="true">→</div>
|
|
184
|
+
<div class="flow-node flow-node-result">
|
|
185
|
+
<strong>JSON or YAML text</strong>
|
|
186
|
+
<small>stable key order, ready to save or send</small>
|
|
187
|
+
</div>
|
|
188
|
+
</div>
|
|
189
|
+
</figure>
|
|
190
|
+
|
|
191
|
+
<div class="two-column" style="margin-top: 1rem">
|
|
192
|
+
<article class="card">
|
|
193
|
+
<h3>Each sprite has its own names</h3>
|
|
194
|
+
<p>
|
|
195
|
+
<code>config</code> in Sprite1 and <code>config</code> on the stage are two
|
|
196
|
+
separate values. Parsing the same name again replaces it.
|
|
197
|
+
</p>
|
|
198
|
+
</article>
|
|
199
|
+
<article class="card">
|
|
200
|
+
<h3>Values last until Stop</h3>
|
|
201
|
+
<p>
|
|
202
|
+
Named values live only while the project runs. Clicking Stop clears them, and
|
|
203
|
+
they are not saved in the project file. Keep the source text in a variable
|
|
204
|
+
if you need it later.
|
|
205
|
+
</p>
|
|
206
|
+
</article>
|
|
207
|
+
</div>
|
|
208
|
+
|
|
209
|
+
<div id="recipes" class="recipe-grid" style="margin-top: 1rem">
|
|
210
|
+
<article class="recipe">
|
|
211
|
+
<h3>Read a setting</h3>
|
|
212
|
+
<div class="code-card">
|
|
213
|
+
<span class="code-label">blocks</span>
|
|
214
|
+
<pre><code>parse JSON [{"level":{"speed":4}}] as [cfg]
|
|
215
|
+
get JSON from [cfg] at path [$.level.speed]
|
|
216
|
+
→ 4</code></pre>
|
|
217
|
+
</div>
|
|
218
|
+
<p>Use the reporter wherever you would use a number or a piece of text.</p>
|
|
219
|
+
</article>
|
|
220
|
+
<article class="recipe">
|
|
221
|
+
<h3>Update and save</h3>
|
|
222
|
+
<div class="code-card">
|
|
223
|
+
<span class="code-label">blocks</span>
|
|
224
|
+
<pre><code>set [save] at path [$.score] to JSON [120]
|
|
225
|
+
set [save] at path [$.name] to JSON ["Mio"]
|
|
226
|
+
set [saved text] to (to JSON [save])</code></pre>
|
|
227
|
+
</div>
|
|
228
|
+
<p>The value is JSON, so text needs quotes: <code>"Mio"</code>, not <code>Mio</code>.</p>
|
|
229
|
+
</article>
|
|
230
|
+
<article class="recipe">
|
|
231
|
+
<h3>Check before you read</h3>
|
|
232
|
+
<div class="code-card">
|
|
233
|
+
<span class="code-label">blocks</span>
|
|
234
|
+
<pre><code>if <structured data [save] has path [$.items]?>
|
|
235
|
+
say (length of array in [save] at path [$.items])</code></pre>
|
|
236
|
+
</div>
|
|
237
|
+
<p>Test first to avoid errors from missing data or paths.</p>
|
|
238
|
+
</article>
|
|
239
|
+
</div>
|
|
240
|
+
</section>
|
|
241
|
+
|
|
242
|
+
<section id="paths" class="section" aria-labelledby="paths-title">
|
|
243
|
+
<div class="section-heading">
|
|
244
|
+
<div>
|
|
245
|
+
<p class="eyebrow">03 · Paths</p>
|
|
246
|
+
<h2 id="paths-title">Point at exactly one place.</h2>
|
|
247
|
+
</div>
|
|
248
|
+
<p>
|
|
249
|
+
A path starts at <code>$</code>, the whole value, and steps into it one key or
|
|
250
|
+
index at a time. Paths are deliberately simple: each one names a single
|
|
251
|
+
location, so a block can never touch more than you meant.
|
|
252
|
+
</p>
|
|
253
|
+
</div>
|
|
254
|
+
|
|
255
|
+
<div class="table-wrap">
|
|
256
|
+
<table>
|
|
257
|
+
<thead>
|
|
258
|
+
<tr>
|
|
259
|
+
<th scope="col">Path</th>
|
|
260
|
+
<th scope="col">Points at</th>
|
|
261
|
+
</tr>
|
|
262
|
+
</thead>
|
|
263
|
+
<tbody>
|
|
264
|
+
<tr>
|
|
265
|
+
<td><code>$</code></td>
|
|
266
|
+
<td>The whole value.</td>
|
|
267
|
+
</tr>
|
|
268
|
+
<tr>
|
|
269
|
+
<td><code>$.player.name</code></td>
|
|
270
|
+
<td>Key <code>name</code> inside key <code>player</code>. Dot keys use letters, digits, and <code>_</code>, and do not start with a digit.</td>
|
|
271
|
+
</tr>
|
|
272
|
+
<tr>
|
|
273
|
+
<td><code>$.items[0]</code></td>
|
|
274
|
+
<td>The first item of the <code>items</code> array. Indexes start at 0.</td>
|
|
275
|
+
</tr>
|
|
276
|
+
<tr>
|
|
277
|
+
<td><code>$["key.with dots"]</code></td>
|
|
278
|
+
<td>Any key, including spaces, dots, or Japanese text, written in quotes and brackets.</td>
|
|
279
|
+
</tr>
|
|
280
|
+
</tbody>
|
|
281
|
+
</table>
|
|
282
|
+
</div>
|
|
283
|
+
|
|
284
|
+
<div class="syntax-layout" style="margin-top: 1rem">
|
|
285
|
+
<article class="syntax-list supported">
|
|
286
|
+
<h3>What <code>set</code> and <code>delete path</code> do</h3>
|
|
287
|
+
<ul>
|
|
288
|
+
<li><code>set</code> can replace the root, replace an existing array item, or add or replace a key in an existing object.</li>
|
|
289
|
+
<li>Deleting an array item moves later items forward by one.</li>
|
|
290
|
+
<li>A change is applied only after it fully succeeds, so a failed block leaves your value unchanged.</li>
|
|
291
|
+
</ul>
|
|
292
|
+
</article>
|
|
293
|
+
<article class="syntax-list rejected">
|
|
294
|
+
<h3>What is rejected</h3>
|
|
295
|
+
<ul>
|
|
296
|
+
<li>Creating missing parent objects or arrays automatically.</li>
|
|
297
|
+
<li>Appending past the end of an array.</li>
|
|
298
|
+
<li>Deleting <code>$</code>; use <code>delete structured data</code> instead.</li>
|
|
299
|
+
<li>Wildcards, slices, filters, recursive search, and expressions.</li>
|
|
300
|
+
</ul>
|
|
301
|
+
</article>
|
|
302
|
+
</div>
|
|
303
|
+
</section>
|
|
304
|
+
|
|
305
|
+
<section id="loops" class="section" aria-labelledby="loops-title">
|
|
306
|
+
<div class="section-heading">
|
|
307
|
+
<div>
|
|
308
|
+
<p class="eyebrow">04 · Loops</p>
|
|
309
|
+
<h2 id="loops-title">Visit every item, in a predictable order.</h2>
|
|
310
|
+
</div>
|
|
311
|
+
<p>
|
|
312
|
+
<code>for each in [ ] at path [ ] max [ ]</code> runs its inner blocks once per
|
|
313
|
+
array item or object key. Inside the loop, three reporters tell you where you
|
|
314
|
+
are.
|
|
315
|
+
</p>
|
|
316
|
+
</div>
|
|
317
|
+
|
|
318
|
+
<div class="two-column">
|
|
319
|
+
<div class="code-card">
|
|
320
|
+
<span class="code-label">blocks</span>
|
|
321
|
+
<pre><code>parse JSON [{"items":["apple","pear"]}] as [shop]
|
|
322
|
+
for each in [shop] at path [$.items] max [100]
|
|
323
|
+
say (join (current index) (current value JSON))
|
|
324
|
+
→ 0"apple" 1"pear"</code></pre>
|
|
325
|
+
</div>
|
|
326
|
+
<div class="table-wrap">
|
|
327
|
+
<table>
|
|
328
|
+
<thead>
|
|
329
|
+
<tr>
|
|
330
|
+
<th scope="col">Reporter</th>
|
|
331
|
+
<th scope="col">Inside the loop</th>
|
|
332
|
+
</tr>
|
|
333
|
+
</thead>
|
|
334
|
+
<tbody>
|
|
335
|
+
<tr>
|
|
336
|
+
<td><code>current key</code></td>
|
|
337
|
+
<td>The object key, or the array index as text.</td>
|
|
338
|
+
</tr>
|
|
339
|
+
<tr>
|
|
340
|
+
<td><code>current index</code></td>
|
|
341
|
+
<td>The step number, starting at 0.</td>
|
|
342
|
+
</tr>
|
|
343
|
+
<tr>
|
|
344
|
+
<td><code>current value JSON</code></td>
|
|
345
|
+
<td>The current item as JSON.</td>
|
|
346
|
+
</tr>
|
|
347
|
+
</tbody>
|
|
348
|
+
</table>
|
|
349
|
+
</div>
|
|
350
|
+
</div>
|
|
351
|
+
|
|
352
|
+
<div class="card-grid" style="margin-top: 1rem">
|
|
353
|
+
<article class="card">
|
|
354
|
+
<h3>Same order every time</h3>
|
|
355
|
+
<p>Arrays go by index. Objects go by key, sorted by Unicode code point, so results do not depend on how the text was written.</p>
|
|
356
|
+
</article>
|
|
357
|
+
<article class="card">
|
|
358
|
+
<h3><code>max</code> is a safety limit</h3>
|
|
359
|
+
<p>Use a whole number from 1 to 1000 (default 100). If the collection is bigger, the loop fails instead of silently skipping items.</p>
|
|
360
|
+
</article>
|
|
361
|
+
<article class="card">
|
|
362
|
+
<h3>Safe to nest</h3>
|
|
363
|
+
<p>Loops can be placed inside other loops. The reporters always describe the innermost loop that is running.</p>
|
|
364
|
+
</article>
|
|
365
|
+
</div>
|
|
366
|
+
</section>
|
|
367
|
+
|
|
368
|
+
<section id="blocks" class="section" aria-labelledby="blocks-title">
|
|
369
|
+
<div class="section-heading">
|
|
370
|
+
<div>
|
|
371
|
+
<p class="eyebrow">05 · Block guide</p>
|
|
372
|
+
<h2 id="blocks-title">Choose a block by what you want to do.</h2>
|
|
373
|
+
</div>
|
|
374
|
+
<p>
|
|
375
|
+
Every block below takes a <code>NAME</code>. The
|
|
376
|
+
<a href="#extension-block-reference">complete block reference</a> lists each
|
|
377
|
+
argument and default value.
|
|
378
|
+
</p>
|
|
379
|
+
</div>
|
|
380
|
+
|
|
381
|
+
<div class="table-wrap">
|
|
382
|
+
<table>
|
|
383
|
+
<thead>
|
|
384
|
+
<tr>
|
|
385
|
+
<th scope="col">I want to…</th>
|
|
386
|
+
<th scope="col">Use</th>
|
|
387
|
+
</tr>
|
|
388
|
+
</thead>
|
|
389
|
+
<tbody>
|
|
390
|
+
<tr>
|
|
391
|
+
<td>Load text into a named value</td>
|
|
392
|
+
<td><a href="#block-parseJson"><code>parse JSON [ ] as [ ]</code></a>, <a href="#block-parseYaml"><code>parse YAML [ ] as [ ]</code></a></td>
|
|
393
|
+
</tr>
|
|
394
|
+
<tr>
|
|
395
|
+
<td>Get the whole value back as text</td>
|
|
396
|
+
<td><a href="#block-toJson"><code>to JSON [ ]</code></a>, <a href="#block-toYaml"><code>to YAML [ ]</code></a></td>
|
|
397
|
+
</tr>
|
|
398
|
+
<tr>
|
|
399
|
+
<td>Check or remove a named value</td>
|
|
400
|
+
<td><a href="#block-hasStructuredData"><code>structured data [ ] exists?</code></a>, <a href="#block-deleteStructuredData"><code>delete structured data [ ]</code></a></td>
|
|
401
|
+
</tr>
|
|
402
|
+
<tr>
|
|
403
|
+
<td>Read or test one location</td>
|
|
404
|
+
<td><a href="#block-getJsonAtPath"><code>get JSON from [ ] at path [ ]</code></a>, <a href="#block-hasPath"><code>structured data [ ] has path [ ]?</code></a></td>
|
|
405
|
+
</tr>
|
|
406
|
+
<tr>
|
|
407
|
+
<td>Change one location</td>
|
|
408
|
+
<td><a href="#block-setJsonAtPath"><code>set [ ] at path [ ] to JSON [ ]</code></a>, <a href="#block-deleteAtPath"><code>delete path [ ] from [ ]</code></a></td>
|
|
409
|
+
</tr>
|
|
410
|
+
<tr>
|
|
411
|
+
<td>Inspect a collection</td>
|
|
412
|
+
<td><a href="#block-keysAtPath"><code>keys in [ ] at path [ ]</code></a> (sorted, as a JSON array), <a href="#block-lengthAtPath"><code>length of array in [ ] at path [ ]</code></a></td>
|
|
413
|
+
</tr>
|
|
414
|
+
<tr>
|
|
415
|
+
<td>Repeat for each item</td>
|
|
416
|
+
<td><a href="#block-forEachAtPath"><code>for each in [ ] at path [ ] max [ ]</code></a> with <a href="#block-currentKey"><code>current key</code></a>, <a href="#block-currentIndex"><code>current index</code></a>, <a href="#block-currentValueJson"><code>current value JSON</code></a></td>
|
|
417
|
+
</tr>
|
|
418
|
+
</tbody>
|
|
419
|
+
</table>
|
|
420
|
+
</div>
|
|
421
|
+
</section>
|
|
422
|
+
|
|
423
|
+
<section id="safety" class="section" aria-labelledby="safety-title">
|
|
424
|
+
<div class="section-heading">
|
|
425
|
+
<div>
|
|
426
|
+
<p class="eyebrow">06 · Limits and safety</p>
|
|
427
|
+
<h2 id="safety-title">Strict input, predictable output.</h2>
|
|
428
|
+
</div>
|
|
429
|
+
<p>
|
|
430
|
+
Structured Data accepts plain data only and fails clearly instead of guessing.
|
|
431
|
+
That keeps large or unusual input from freezing a project or changing meaning.
|
|
432
|
+
</p>
|
|
433
|
+
</div>
|
|
434
|
+
|
|
435
|
+
<div class="card-grid">
|
|
436
|
+
<article class="card">
|
|
437
|
+
<h3>Size limits</h3>
|
|
438
|
+
<p>Each parse accepts up to 256 KiB of text, nesting up to 64 levels deep, and up to 50,000 values in total.</p>
|
|
439
|
+
</article>
|
|
440
|
+
<article class="card">
|
|
441
|
+
<h3>Safe YAML</h3>
|
|
442
|
+
<p>Aliases, unknown tags, duplicate keys, non-text keys, unsupported scalar types, and parser warnings are rejected.</p>
|
|
443
|
+
</article>
|
|
444
|
+
<article class="card">
|
|
445
|
+
<h3>Stable output</h3>
|
|
446
|
+
<p><code>to JSON</code> and <code>to YAML</code> always sort keys, so the same data gives the same text: easy to compare, save, or send.</p>
|
|
447
|
+
</article>
|
|
448
|
+
</div>
|
|
449
|
+
</section>
|
|
450
|
+
|
|
451
|
+
<section id="editors" class="section" aria-labelledby="editors-title">
|
|
452
|
+
<div class="section-heading">
|
|
453
|
+
<div>
|
|
454
|
+
<p class="eyebrow">07 · Optional integrations</p>
|
|
455
|
+
<h2 id="editors-title">Editing forms and shared named data.</h2>
|
|
456
|
+
</div>
|
|
457
|
+
<p>
|
|
458
|
+
These features are off by default and need nothing for normal use. Turn them on
|
|
459
|
+
only in a TurboWarp build or host that supports them.
|
|
460
|
+
</p>
|
|
461
|
+
</div>
|
|
462
|
+
|
|
463
|
+
<div class="card-grid">
|
|
464
|
+
<article class="card">
|
|
465
|
+
<h3>Source and Form editor</h3>
|
|
466
|
+
<p>
|
|
467
|
+
With the GUI startup options <code>blockEditorDialogs=1</code> and
|
|
468
|
+
<code>blockEditorSourceForms=1</code>, the JSON/YAML inputs of
|
|
469
|
+
<code>parse JSON</code>, <code>parse YAML</code>, and <code>set … to JSON</code>
|
|
470
|
+
open in an editor that switches between source text and a form. Unchanged
|
|
471
|
+
text is kept exactly as written, and input the block would reject cannot be saved.
|
|
472
|
+
</p>
|
|
473
|
+
</article>
|
|
474
|
+
<article class="card">
|
|
475
|
+
<h3>Fixed-input editor for <code>max</code></h3>
|
|
476
|
+
<p>
|
|
477
|
+
With <code>blockEditorDialogs</code> and <code>blockEditorFixedInputs</code>
|
|
478
|
+
both on, the <code>max</code> input of <code>for each</code> gets a form that
|
|
479
|
+
accepts whole numbers from 1 to 1000. Existing values are not rewritten unless
|
|
480
|
+
you edit them, and connected reporters are never evaluated.
|
|
481
|
+
</p>
|
|
482
|
+
</article>
|
|
483
|
+
<article class="card">
|
|
484
|
+
<h3>Named Data provider</h3>
|
|
485
|
+
<p>
|
|
486
|
+
With <code>globalThis.NAMED_DATA_REGISTRY_MVP = true</code>, named values are
|
|
487
|
+
also offered to other extensions through the shared
|
|
488
|
+
<a href="https://kubohiroya.github.io/turbowarp-named-data/">Named Data</a>
|
|
489
|
+
registry as <code>structured</code> data. Add
|
|
490
|
+
<code>__TW_NAMED_DATA_FEATURE_FLAGS__ = {NAMED_DATA_SCHEMA_REF: true}</code>
|
|
491
|
+
to pass along schema identities.
|
|
492
|
+
</p>
|
|
493
|
+
</article>
|
|
494
|
+
</div>
|
|
495
|
+
</section>
|
|
496
|
+
|
|
497
|
+
<section id="help" class="section" aria-labelledby="help-title">
|
|
498
|
+
<div class="section-heading">
|
|
499
|
+
<div>
|
|
500
|
+
<p class="eyebrow">08 · Troubleshooting</p>
|
|
501
|
+
<h2 id="help-title">When a block does not do what you expect.</h2>
|
|
502
|
+
</div>
|
|
503
|
+
<p>
|
|
504
|
+
Most problems come from the startup flag, JSON quoting, or a value that was
|
|
505
|
+
cleared by Stop. When a block fails it reports one of the stable error codes
|
|
506
|
+
below, and your named value stays as it was.
|
|
507
|
+
</p>
|
|
508
|
+
</div>
|
|
509
|
+
|
|
510
|
+
<div class="card-grid">
|
|
511
|
+
<article class="card">
|
|
512
|
+
<h3>The palette is empty</h3>
|
|
513
|
+
<p>
|
|
514
|
+
Set <code>globalThis.STRUCTURED_DATA_MVP = true</code> first, then load the
|
|
515
|
+
extension again. The flag is read only once, at startup.
|
|
516
|
+
</p>
|
|
517
|
+
</article>
|
|
518
|
+
<article class="card">
|
|
519
|
+
<h3>Text values come back with quotes</h3>
|
|
520
|
+
<p>
|
|
521
|
+
<code>get JSON</code> returns JSON, so the text <code>Mio</code> comes back as
|
|
522
|
+
<code>"Mio"</code>. Store text with quotes too: <code>set … to JSON ["Mio"]</code>.
|
|
523
|
+
</p>
|
|
524
|
+
</article>
|
|
525
|
+
<article class="card">
|
|
526
|
+
<h3>“DATA_NOT_FOUND” after Stop</h3>
|
|
527
|
+
<p>
|
|
528
|
+
Stop clears all named values. Parse your data again from a
|
|
529
|
+
<em>when green flag clicked</em> script.
|
|
530
|
+
</p>
|
|
531
|
+
</article>
|
|
532
|
+
<article class="card">
|
|
533
|
+
<h3>Another sprite cannot see my data</h3>
|
|
534
|
+
<p>
|
|
535
|
+
Names belong to the sprite or stage that ran the parse. Parse in each sprite
|
|
536
|
+
that needs the value, or pass the JSON text through a global variable.
|
|
537
|
+
</p>
|
|
538
|
+
</article>
|
|
539
|
+
<article class="card">
|
|
540
|
+
<h3>“PATH_NOT_FOUND” when setting</h3>
|
|
541
|
+
<p>
|
|
542
|
+
<code>set</code> does not create missing parents. Set the parent first, for
|
|
543
|
+
example <code>$.player</code> to <code>{}</code>, then <code>$.player.name</code>.
|
|
544
|
+
</p>
|
|
545
|
+
</article>
|
|
546
|
+
<article class="card">
|
|
547
|
+
<h3>“ITERATION_LIMIT_EXCEEDED”</h3>
|
|
548
|
+
<p>
|
|
549
|
+
The collection is larger than <code>max</code>. Raise <code>max</code> (up to
|
|
550
|
+
1000) or loop over a smaller part of the data.
|
|
551
|
+
</p>
|
|
552
|
+
</article>
|
|
553
|
+
</div>
|
|
554
|
+
|
|
555
|
+
<div class="table-wrap" style="margin-top: 1rem">
|
|
556
|
+
<table>
|
|
557
|
+
<thead>
|
|
558
|
+
<tr>
|
|
559
|
+
<th scope="col">Error code</th>
|
|
560
|
+
<th scope="col">Meaning</th>
|
|
561
|
+
</tr>
|
|
562
|
+
</thead>
|
|
563
|
+
<tbody>
|
|
564
|
+
<tr><td><code>INVALID_JSON</code> / <code>INVALID_YAML</code></td><td>The text could not be parsed, or uses YAML features that are not allowed.</td></tr>
|
|
565
|
+
<tr><td><code>PARSE_LIMIT_EXCEEDED</code></td><td>The text is larger, deeper, or has more values than the limits allow.</td></tr>
|
|
566
|
+
<tr><td><code>INVALID_NAME</code></td><td>The name is empty or only spaces.</td></tr>
|
|
567
|
+
<tr><td><code>DATA_NOT_FOUND</code></td><td>No value with that name exists in this sprite.</td></tr>
|
|
568
|
+
<tr><td><code>INVALID_PATH</code></td><td>The path is not written in the supported form.</td></tr>
|
|
569
|
+
<tr><td><code>PATH_NOT_FOUND</code></td><td>The path, or its parent, does not exist.</td></tr>
|
|
570
|
+
<tr><td><code>TYPE_MISMATCH</code></td><td>The location holds a different type, such as a number where an array was expected.</td></tr>
|
|
571
|
+
<tr><td><code>INDEX_OUT_OF_RANGE</code></td><td>The array index is past the end of the array.</td></tr>
|
|
572
|
+
<tr><td><code>ITERATION_LIMIT_EXCEEDED</code></td><td>The collection has more items than <code>max</code>.</td></tr>
|
|
573
|
+
<tr><td><code>ITERATION_CONTEXT_REQUIRED</code></td><td>A <code>current …</code> reporter was used outside a <code>for each</code> loop.</td></tr>
|
|
574
|
+
</tbody>
|
|
575
|
+
</table>
|
|
576
|
+
</div>
|
|
577
|
+
</section>
|
|
578
|
+
</main>
|
|
579
|
+
|
|
580
|
+
<footer class="site-footer">
|
|
581
|
+
<div class="footer-inner">
|
|
582
|
+
<p>Structured Data 0.6.2 · MPL-2.0</p>
|
|
583
|
+
<div class="footer-links">
|
|
584
|
+
<a href="https://www.npmjs.com/package/@kubohiroya/turbowarp-structured-data">npm</a>
|
|
585
|
+
<a href="https://github.com/kubohiroya/turbowarp-structured-data/blob/main/docs/architecture.md">Architecture</a>
|
|
586
|
+
<a href="https://github.com/kubohiroya/turbowarp-structured-data/issues">Report a problem</a>
|
|
587
|
+
</div>
|
|
588
|
+
</div>
|
|
589
|
+
</footer>
|
|
34
590
|
<!-- BEGIN COMPLETE BLOCK REFERENCE -->
|
|
35
591
|
<section lang="en" id="extension-block-reference" aria-labelledby="block-reference-title">
|
|
36
592
|
<h2 id="block-reference-title">Structured Data: complete block reference</h2>
|
|
@@ -52,9 +608,9 @@
|
|
|
52
608
|
<li><a href="#block-currentIndex"><code>current index</code></a></li>
|
|
53
609
|
<li><a href="#block-currentValueJson"><code>current value JSON</code></a></li>
|
|
54
610
|
</ul></nav>
|
|
55
|
-
<article id="block-parseJson" class="block-reference-entry"><h3><code>parse JSON [TEXT] as [NAME]</code></h3><p>Parse JSON text into the target-local structured data namespace.</p><p>Block type: COMMAND. Opcode: <code>parseJson</code>. <a href="#block-parseJson">Permanent link</a></p><div class="block-reference-table"><table><thead><tr><th>Argument</th><th>Type</th><th>Default value</th><th>Menu choices</th></tr></thead><tbody><tr><th scope="row"><code>TEXT</code></th><td>STRING</td><td><code>{"name":"TurboWarp"}</code></td><td></td></tr><tr><th scope="row"><code>NAME</code></th><td>STRING</td><td><code>data</code></td><td></td></tr></tbody></table></div></article><article id="block-parseYaml" class="block-reference-entry"><h3><code>parse YAML [TEXT] as [NAME]</code></h3><p>Parse safe YAML text into the target-local structured data namespace.</p><p>Block type: COMMAND. Opcode: <code>parseYaml</code>. <a href="#block-parseYaml">Permanent link</a></p><div class="block-reference-table"><table><thead><tr><th>Argument</th><th>Type</th><th>Default value</th><th>Menu choices</th></tr></thead><tbody><tr><th scope="row"><code>TEXT</code></th><td>STRING</td><td><code>name: TurboWarp</code></td><td></td></tr><tr><th scope="row"><code>NAME</code></th><td>STRING</td><td><code>data</code></td><td></td></tr></tbody></table></div></article><article id="block-toJson" class="block-reference-entry"><h3><code>to JSON [NAME]</code></h3><p>Render named structured data as canonical JSON.</p><p>Block type: REPORTER. Opcode: <code>toJson</code>. <a href="#block-toJson">Permanent link</a></p><div class="block-reference-table"><table><thead><tr><th>Argument</th><th>Type</th><th>Default value</th><th>Menu choices</th></tr></thead><tbody><tr><th scope="row"><code>NAME</code></th><td>STRING</td><td><code>data</code></td><td></td></tr></tbody></table></div></article><article id="block-toYaml" class="block-reference-entry"><h3><code>to YAML [NAME]</code></h3><p>Render named structured data as deterministic YAML.</p><p>Block type: REPORTER. Opcode: <code>toYaml</code>. <a href="#block-toYaml">Permanent link</a></p><div class="block-reference-table"><table><thead><tr><th>Argument</th><th>Type</th><th>Default value</th><th>Menu choices</th></tr></thead><tbody><tr><th scope="row"><code>NAME</code></th><td>STRING</td><td><code>data</code></td><td></td></tr></tbody></table></div></article><article id="block-hasStructuredData" class="block-reference-entry"><h3><code>structured data [NAME] exists?</code></h3><p>Report whether the current target has named structured data.</p><p>Block type: BOOLEAN. Opcode: <code>hasStructuredData</code>. <a href="#block-hasStructuredData">Permanent link</a></p><div class="block-reference-table"><table><thead><tr><th>Argument</th><th>Type</th><th>Default value</th><th>Menu choices</th></tr></thead><tbody><tr><th scope="row"><code>NAME</code></th><td>STRING</td><td><code>data</code></td><td></td></tr></tbody></table></div></article><article id="block-deleteStructuredData" class="block-reference-entry"><h3><code>delete structured data [NAME]</code></h3><p>Delete named structured data from the current target.</p><p>Block type: COMMAND. Opcode: <code>deleteStructuredData</code>. <a href="#block-deleteStructuredData">Permanent link</a></p><div class="block-reference-table"><table><thead><tr><th>Argument</th><th>Type</th><th>Default value</th><th>Menu choices</th></tr></thead><tbody><tr><th scope="row"><code>NAME</code></th><td>STRING</td><td><code>data</code></td><td></td></tr></tbody></table></div></article><article id="block-getJsonAtPath" class="block-reference-entry"><h3><code>get JSON from [NAME] at path [PATH]</code></h3><p>Return a named value at a path as JSON.</p><p>Block type: REPORTER. Opcode: <code>getJsonAtPath</code>. <a href="#block-getJsonAtPath">Permanent link</a></p><div class="block-reference-table"><table><thead><tr><th>Argument</th><th>Type</th><th>Default value</th><th>Menu choices</th></tr></thead><tbody><tr><th scope="row"><code>NAME</code></th><td>STRING</td><td><code>data</code></td><td></td></tr><tr><th scope="row"><code>PATH</code></th><td>STRING</td><td><code>$.name</code></td><td></td></tr></tbody></table></div></article><article id="block-hasPath" class="block-reference-entry"><h3><code>structured data [NAME] has path [PATH]?</code></h3><p>Report whether a path exists in named structured data.</p><p>Block type: BOOLEAN. Opcode: <code>hasPath</code>. <a href="#block-hasPath">Permanent link</a></p><div class="block-reference-table"><table><thead><tr><th>Argument</th><th>Type</th><th>Default value</th><th>Menu choices</th></tr></thead><tbody><tr><th scope="row"><code>NAME</code></th><td>STRING</td><td><code>data</code></td><td></td></tr><tr><th scope="row"><code>PATH</code></th><td>STRING</td><td><code>$.name</code></td><td></td></tr></tbody></table></div></article><article id="block-setJsonAtPath" class="block-reference-entry"><h3><code>set [NAME] at path [PATH] to JSON [VALUE]</code></h3><p>Immutably update a named value and replace its binding.</p><p>Block type: COMMAND. Opcode: <code>setJsonAtPath</code>. <a href="#block-setJsonAtPath">Permanent link</a></p><div class="block-reference-table"><table><thead><tr><th>Argument</th><th>Type</th><th>Default value</th><th>Menu choices</th></tr></thead><tbody><tr><th scope="row"><code>NAME</code></th><td>STRING</td><td><code>data</code></td><td></td></tr><tr><th scope="row"><code>PATH</code></th><td>STRING</td><td><code>$.name</code></td><td></td></tr><tr><th scope="row"><code>VALUE</code></th><td>STRING</td><td><code>"Scratch"</code></td><td></td></tr></tbody></table></div></article><article id="block-deleteAtPath" class="block-reference-entry"><h3><code>delete path [PATH] from [NAME]</code></h3><p>Immutably delete a path and replace its named binding.</p><p>Block type: COMMAND. Opcode: <code>deleteAtPath</code>. <a href="#block-deleteAtPath">Permanent link</a></p><div class="block-reference-table"><table><thead><tr><th>Argument</th><th>Type</th><th>Default value</th><th>Menu choices</th></tr></thead><tbody><tr><th scope="row"><code>NAME</code></th><td>STRING</td><td><code>data</code></td><td></td></tr><tr><th scope="row"><code>PATH</code></th><td>STRING</td><td><code>$.name</code></td><td></td></tr></tbody></table></div></article><article id="block-keysAtPath" class="block-reference-entry"><h3><code>keys in [NAME] at path [PATH]</code></h3><p>Return sorted object keys as JSON.</p><p>Block type: REPORTER. Opcode: <code>keysAtPath</code>. <a href="#block-keysAtPath">Permanent link</a></p><div class="block-reference-table"><table><thead><tr><th>Argument</th><th>Type</th><th>Default value</th><th>Menu choices</th></tr></thead><tbody><tr><th scope="row"><code>NAME</code></th><td>STRING</td><td><code>data</code></td><td></td></tr><tr><th scope="row"><code>PATH</code></th><td>STRING</td><td><code>$</code></td><td></td></tr></tbody></table></div></article><article id="block-lengthAtPath" class="block-reference-entry"><h3><code>length of array in [NAME] at path [PATH]</code></h3><p>Return the array length.</p><p>Block type: REPORTER. Opcode: <code>lengthAtPath</code>. <a href="#block-lengthAtPath">Permanent link</a></p><div class="block-reference-table"><table><thead><tr><th>Argument</th><th>Type</th><th>Default value</th><th>Menu choices</th></tr></thead><tbody><tr><th scope="row"><code>NAME</code></th><td>STRING</td><td><code>data</code></td><td></td></tr><tr><th scope="row"><code>PATH</code></th><td>STRING</td><td><code>$</code></td><td></td></tr></tbody></table></div></article><article id="block-forEachAtPath" class="block-reference-entry"><h3><code>for each in [NAME] at path [PATH] max [MAX]</code></h3><p>Iterate named data deterministically with a static maximum.</p><p>Block type: LOOP. Opcode: <code>forEachAtPath</code>. <a href="#block-forEachAtPath">Permanent link</a></p><div class="block-reference-table"><table><thead><tr><th>Argument</th><th>Type</th><th>Default value</th><th>Menu choices</th></tr></thead><tbody><tr><th scope="row"><code>NAME</code></th><td>STRING</td><td><code>data</code></td><td></td></tr><tr><th scope="row"><code>PATH</code></th><td>STRING</td><td><code>$</code></td><td></td></tr><tr><th scope="row"><code>MAX</code></th><td>NUMBER</td><td><code>100</code></td><td></td></tr></tbody></table></div><!-- BEGIN FIXED INPUT HELP --><p id="fixed-input-forEachAtPath-MAX" class="fixed-input-editor">
|
|
611
|
+
<article id="block-parseJson" class="block-reference-entry"><h3><code>parse JSON [TEXT] as [NAME]</code></h3><p>Parse JSON text into the target-local structured data namespace.</p><p>Block type: COMMAND. Opcode: <code>parseJson</code>. <a href="#block-parseJson">Permanent link</a></p><div class="block-reference-table"><table><thead><tr><th>Argument</th><th>Type</th><th>Default value</th><th>Menu choices</th></tr></thead><tbody><tr><th scope="row"><code>TEXT</code></th><td>STRING</td><td><code>{"name":"TurboWarp"}</code></td><td></td></tr><tr><th scope="row"><code>NAME</code></th><td>STRING</td><td><code>data</code></td><td></td></tr></tbody></table></div></article><article id="block-parseYaml" class="block-reference-entry"><h3><code>parse YAML [TEXT] as [NAME]</code></h3><p>Parse safe YAML text into the target-local structured data namespace.</p><p>Block type: COMMAND. Opcode: <code>parseYaml</code>. <a href="#block-parseYaml">Permanent link</a></p><div class="block-reference-table"><table><thead><tr><th>Argument</th><th>Type</th><th>Default value</th><th>Menu choices</th></tr></thead><tbody><tr><th scope="row"><code>TEXT</code></th><td>STRING</td><td><code>name: TurboWarp</code></td><td></td></tr><tr><th scope="row"><code>NAME</code></th><td>STRING</td><td><code>data</code></td><td></td></tr></tbody></table></div></article><article id="block-toJson" class="block-reference-entry"><h3><code>to JSON [NAME]</code></h3><p>Render named structured data as canonical JSON.</p><p>Block type: REPORTER. Opcode: <code>toJson</code>. <a href="#block-toJson">Permanent link</a></p><div class="block-reference-table"><table><thead><tr><th>Argument</th><th>Type</th><th>Default value</th><th>Menu choices</th></tr></thead><tbody><tr><th scope="row"><code>NAME</code></th><td>STRING</td><td><code>data</code></td><td></td></tr></tbody></table></div></article><article id="block-toYaml" class="block-reference-entry"><h3><code>to YAML [NAME]</code></h3><p>Render named structured data as deterministic YAML.</p><p>Block type: REPORTER. Opcode: <code>toYaml</code>. <a href="#block-toYaml">Permanent link</a></p><div class="block-reference-table"><table><thead><tr><th>Argument</th><th>Type</th><th>Default value</th><th>Menu choices</th></tr></thead><tbody><tr><th scope="row"><code>NAME</code></th><td>STRING</td><td><code>data</code></td><td></td></tr></tbody></table></div></article><article id="block-hasStructuredData" class="block-reference-entry"><h3><code>structured data [NAME] exists?</code></h3><p>Report whether the current target has named structured data.</p><p>Block type: BOOLEAN. Opcode: <code>hasStructuredData</code>. <a href="#block-hasStructuredData">Permanent link</a></p><div class="block-reference-table"><table><thead><tr><th>Argument</th><th>Type</th><th>Default value</th><th>Menu choices</th></tr></thead><tbody><tr><th scope="row"><code>NAME</code></th><td>STRING</td><td><code>data</code></td><td></td></tr></tbody></table></div></article><article id="block-deleteStructuredData" class="block-reference-entry"><h3><code>delete structured data [NAME]</code></h3><p>Delete named structured data from the current target.</p><p>Block type: COMMAND. Opcode: <code>deleteStructuredData</code>. <a href="#block-deleteStructuredData">Permanent link</a></p><div class="block-reference-table"><table><thead><tr><th>Argument</th><th>Type</th><th>Default value</th><th>Menu choices</th></tr></thead><tbody><tr><th scope="row"><code>NAME</code></th><td>STRING</td><td><code>data</code></td><td></td></tr></tbody></table></div></article><article id="block-getJsonAtPath" class="block-reference-entry"><h3><code>get JSON from [NAME] at path [PATH]</code></h3><p>Return a named value at a path as JSON.</p><p>Block type: REPORTER. Opcode: <code>getJsonAtPath</code>. <a href="#block-getJsonAtPath">Permanent link</a></p><div class="block-reference-table"><table><thead><tr><th>Argument</th><th>Type</th><th>Default value</th><th>Menu choices</th></tr></thead><tbody><tr><th scope="row"><code>NAME</code></th><td>STRING</td><td><code>data</code></td><td></td></tr><tr><th scope="row"><code>PATH</code></th><td>STRING</td><td><code>$.name</code></td><td></td></tr></tbody></table></div></article><article id="block-hasPath" class="block-reference-entry"><h3><code>structured data [NAME] has path [PATH]?</code></h3><p>Report whether a path exists in named structured data.</p><p>Block type: BOOLEAN. Opcode: <code>hasPath</code>. <a href="#block-hasPath">Permanent link</a></p><div class="block-reference-table"><table><thead><tr><th>Argument</th><th>Type</th><th>Default value</th><th>Menu choices</th></tr></thead><tbody><tr><th scope="row"><code>NAME</code></th><td>STRING</td><td><code>data</code></td><td></td></tr><tr><th scope="row"><code>PATH</code></th><td>STRING</td><td><code>$.name</code></td><td></td></tr></tbody></table></div></article><article id="block-setJsonAtPath" class="block-reference-entry"><h3><code>set [NAME] at path [PATH] to JSON [VALUE]</code></h3><p>Immutably update a named value and replace its binding.</p><p>Block type: COMMAND. Opcode: <code>setJsonAtPath</code>. <a href="#block-setJsonAtPath">Permanent link</a></p><div class="block-reference-table"><table><thead><tr><th>Argument</th><th>Type</th><th>Default value</th><th>Menu choices</th></tr></thead><tbody><tr><th scope="row"><code>NAME</code></th><td>STRING</td><td><code>data</code></td><td></td></tr><tr><th scope="row"><code>PATH</code></th><td>STRING</td><td><code>$.name</code></td><td></td></tr><tr><th scope="row"><code>VALUE</code></th><td>STRING</td><td><code>"Scratch"</code></td><td></td></tr></tbody></table></div></article><article id="block-deleteAtPath" class="block-reference-entry"><h3><code>delete path [PATH] from [NAME]</code></h3><p>Immutably delete a path and replace its named binding.</p><p>Block type: COMMAND. Opcode: <code>deleteAtPath</code>. <a href="#block-deleteAtPath">Permanent link</a></p><div class="block-reference-table"><table><thead><tr><th>Argument</th><th>Type</th><th>Default value</th><th>Menu choices</th></tr></thead><tbody><tr><th scope="row"><code>NAME</code></th><td>STRING</td><td><code>data</code></td><td></td></tr><tr><th scope="row"><code>PATH</code></th><td>STRING</td><td><code>$.name</code></td><td></td></tr></tbody></table></div></article><article id="block-keysAtPath" class="block-reference-entry"><h3><code>keys in [NAME] at path [PATH]</code></h3><p>Return sorted object keys as JSON.</p><p>Block type: REPORTER. Opcode: <code>keysAtPath</code>. <a href="#block-keysAtPath">Permanent link</a></p><div class="block-reference-table"><table><thead><tr><th>Argument</th><th>Type</th><th>Default value</th><th>Menu choices</th></tr></thead><tbody><tr><th scope="row"><code>NAME</code></th><td>STRING</td><td><code>data</code></td><td></td></tr><tr><th scope="row"><code>PATH</code></th><td>STRING</td><td><code>$</code></td><td></td></tr></tbody></table></div></article><article id="block-lengthAtPath" class="block-reference-entry"><h3><code>length of array in [NAME] at path [PATH]</code></h3><p>Return the array length.</p><p>Block type: REPORTER. Opcode: <code>lengthAtPath</code>. <a href="#block-lengthAtPath">Permanent link</a></p><div class="block-reference-table"><table><thead><tr><th>Argument</th><th>Type</th><th>Default value</th><th>Menu choices</th></tr></thead><tbody><tr><th scope="row"><code>NAME</code></th><td>STRING</td><td><code>data</code></td><td></td></tr><tr><th scope="row"><code>PATH</code></th><td>STRING</td><td><code>$</code></td><td></td></tr></tbody></table></div></article><article id="block-forEachAtPath" class="block-reference-entry"><h3><code>for each in [NAME] at path [PATH] max [MAX]</code></h3><p>Iterate named data deterministically with a static maximum.</p><p>Block type: LOOP. Opcode: <code>forEachAtPath</code>. <a href="#block-forEachAtPath">Permanent link</a></p><div class="block-reference-table"><table><thead><tr><th>Argument</th><th>Type</th><th>Default value</th><th>Menu choices</th></tr></thead><tbody><tr><th scope="row"><code>NAME</code></th><td>STRING</td><td><code>data</code></td><td></td></tr><tr><th scope="row"><code>PATH</code></th><td>STRING</td><td><code>$</code></td><td></td></tr><tr><th scope="row"><code>MAX</code></th><td>NUMBER</td><td><code>100</code></td><td></td></tr></tbody></table></div><!-- BEGIN FIXED INPUT HELP --><p id="fixed-input-forEachAtPath-MAX" class="fixed-input-editor">When the fixed-input editor is enabled, MAX can be edited as a whole number from 1 to 1000. Partial, blank, or non-finite new values cannot be saved. NAME and PATH are not changed. The editor is off by default: enable both the <code>blockEditorDialogs</code> and <code>blockEditorFixedInputs</code> GUI startup options, then reload. Unchanged raw values are never rewritten, and connected reporters are never evaluated.</p><!-- END FIXED INPUT HELP --></article><article id="block-currentKey" class="block-reference-entry"><h3><code>current key</code></h3><p>Return the current object key or array index string.</p><p>Block type: REPORTER. Opcode: <code>currentKey</code>. <a href="#block-currentKey">Permanent link</a></p><p>This block has no arguments.</p></article><article id="block-currentIndex" class="block-reference-entry"><h3><code>current index</code></h3><p>Return the zero-based iteration number.</p><p>Block type: REPORTER. Opcode: <code>currentIndex</code>. <a href="#block-currentIndex">Permanent link</a></p><p>This block has no arguments.</p></article><article id="block-currentValueJson" class="block-reference-entry"><h3><code>current value JSON</code></h3><p>Return the current iteration value as JSON.</p><p>Block type: REPORTER. Opcode: <code>currentValueJson</code>. <a href="#block-currentValueJson">Permanent link</a></p><p>This block has no arguments.</p></article>
|
|
56
612
|
<p><a href="https://github.com/kubohiroya/turbowarp-structured-data/blob/main/README.md">Repository guide and examples</a></p>
|
|
57
613
|
</section>
|
|
58
614
|
<!-- END COMPLETE BLOCK REFERENCE -->
|
|
59
|
-
</body>
|
|
615
|
+
</body>
|
|
60
616
|
</html>
|