@kupcad/playground 0.1.6 → 0.1.7
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 +2 -2
- package/package.json +5 -5
- package/src/Playground.svelte +113 -105
package/README.md
CHANGED
|
@@ -55,8 +55,8 @@ browser IDE embed; it keeps nothing of the page's.
|
|
|
55
55
|
resize them (`@kupcad/ui`'s `Splitter`), and the toolbar's Parameters button hides the
|
|
56
56
|
parameters for the model's width; the sizes, and what is hidden or folded, are kept in
|
|
57
57
|
`settings`, by default the page's localStorage (`localSettings`, the `playground.*` keys), and
|
|
58
|
-
how the view looks too (the pane's `view.*` keys), all followed as they are set.
|
|
59
|
-
|
|
58
|
+
how the view looks too (the pane's `view.*` keys), all followed as they are set. Given 800px
|
|
59
|
+
or less (a phone, or a column of a page: it goes by its own width) it stacks the panes, each at a height of its own (the script a few lines, the model
|
|
60
60
|
4:3 of its width, at most 32em, the console and the parameters as tall as their lines), and
|
|
61
61
|
the playground scrolls; on a phone the view's panel is under the model (`ViewerPane`'s).
|
|
62
62
|
* **The console** (`@kupcad/ui`'s `ConsolePanel`, under the model): each run, what it printed
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kupcad/playground",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "KupCAD in the browser: a script's editor, its model and its parameters, running on the core compiled to WebAssembly in a worker. One Svelte component a page embeds.",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"repository": {
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
"access": "public"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@kupcad/editor": "0.1.
|
|
28
|
-
"@kupcad/protocol": "0.1.
|
|
29
|
-
"@kupcad/ui": "0.1.
|
|
30
|
-
"@kupcad/wasm": "0.1.
|
|
27
|
+
"@kupcad/editor": "0.1.7",
|
|
28
|
+
"@kupcad/protocol": "0.1.7",
|
|
29
|
+
"@kupcad/ui": "0.1.7",
|
|
30
|
+
"@kupcad/wasm": "0.1.7"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@codemirror/language": "^6.13.1",
|
package/src/Playground.svelte
CHANGED
|
@@ -274,113 +274,121 @@
|
|
|
274
274
|
}
|
|
275
275
|
</script>
|
|
276
276
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
<div class="model">
|
|
306
|
-
<ViewerPane
|
|
307
|
-
model={ran?.preview.model ?? null}
|
|
308
|
-
subject="script {loads}"
|
|
309
|
-
options={viewerOptions}
|
|
310
|
-
bind:panel={() => panelOpen, (open) => settings.set(KEYS.panelOpen, open)}
|
|
311
|
-
{status}
|
|
312
|
-
{problems}
|
|
313
|
-
onproblem={reveal}
|
|
314
|
-
onscreenshot={screenshot}
|
|
315
|
-
{settings}
|
|
316
|
-
{shortcuts}
|
|
317
|
-
bind:shortcutsOpen
|
|
318
|
-
>
|
|
319
|
-
{#snippet actions()}
|
|
320
|
-
<ExportMenu kind={ran?.preview.model.kind ?? 'none'} onexport={exportChosen} />
|
|
321
|
-
{@render hostActions?.()}
|
|
322
|
-
{/snippet}
|
|
323
|
-
{#snippet toggles()}
|
|
324
|
-
{#if header && parameters.length > 0}
|
|
325
|
-
<button
|
|
326
|
-
type="button"
|
|
327
|
-
class="kc-control"
|
|
328
|
-
aria-controls="{id}-params"
|
|
329
|
-
aria-expanded={paramsOpen}
|
|
330
|
-
onclick={() => settings.set(KEYS.paramsOpen, !paramsOpen)}
|
|
331
|
-
>
|
|
332
|
-
Parameters
|
|
333
|
-
</button>
|
|
334
|
-
{/if}
|
|
335
|
-
{/snippet}
|
|
336
|
-
</ViewerPane>
|
|
337
|
-
</div>
|
|
338
|
-
{#if consoleOpen}
|
|
339
|
-
<Splitter
|
|
340
|
-
between="rows"
|
|
341
|
-
pane="after"
|
|
342
|
-
bind:size={consoleHeight}
|
|
343
|
-
min={48}
|
|
344
|
-
label="Resize the console"
|
|
345
|
-
onchange={(size) => settings.set(KEYS.console, size)}
|
|
346
|
-
/>
|
|
347
|
-
{/if}
|
|
348
|
-
<ConsolePanel
|
|
349
|
-
lines={consoleLines}
|
|
350
|
-
height={consoleHeight}
|
|
351
|
-
bind:open={() => consoleOpen, (open) => settings.set(KEYS.open, open)}
|
|
352
|
-
onreveal={reveal}
|
|
353
|
-
onclear={() => (consoleLines = [])}
|
|
277
|
+
<!-- The box the playground is laid out by: its own width, wide or a column of a page -->
|
|
278
|
+
<div class="kc-playground-box">
|
|
279
|
+
<div
|
|
280
|
+
class="kc-playground"
|
|
281
|
+
bind:clientWidth={width}
|
|
282
|
+
style:--editor-width="{editorWidth}px"
|
|
283
|
+
style:--params-width="{paramsWidth}px"
|
|
284
|
+
>
|
|
285
|
+
<section class="code" aria-label="Script">
|
|
286
|
+
{#key documents}
|
|
287
|
+
<Editor
|
|
288
|
+
bind:value
|
|
289
|
+
bind:editor
|
|
290
|
+
findings={marks}
|
|
291
|
+
label={name}
|
|
292
|
+
restore={restored}
|
|
293
|
+
{language}
|
|
294
|
+
onchange={edited}
|
|
295
|
+
/>
|
|
296
|
+
{/key}
|
|
297
|
+
{#if notice}<p class="notice" role="alert">{notice}</p>{/if}
|
|
298
|
+
</section>
|
|
299
|
+
<Splitter
|
|
300
|
+
bind:size={editorWidth}
|
|
301
|
+
min={240}
|
|
302
|
+
max={width > 0 ? width - (paramsShown ? paramsWidth : 0) - MIN_VIEW : undefined}
|
|
303
|
+
label="Resize the script"
|
|
304
|
+
onchange={(size) => settings.set(KEYS.editor, size)}
|
|
354
305
|
/>
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
306
|
+
<section class="view" aria-label="Model">
|
|
307
|
+
<div class="model">
|
|
308
|
+
<ViewerPane
|
|
309
|
+
model={ran?.preview.model ?? null}
|
|
310
|
+
subject="script {loads}"
|
|
311
|
+
options={viewerOptions}
|
|
312
|
+
bind:panel={() => panelOpen, (open) => settings.set(KEYS.panelOpen, open)}
|
|
313
|
+
{status}
|
|
314
|
+
{problems}
|
|
315
|
+
onproblem={reveal}
|
|
316
|
+
onscreenshot={screenshot}
|
|
317
|
+
{settings}
|
|
318
|
+
{shortcuts}
|
|
319
|
+
bind:shortcutsOpen
|
|
320
|
+
>
|
|
321
|
+
{#snippet actions()}
|
|
322
|
+
<ExportMenu kind={ran?.preview.model.kind ?? 'none'} onexport={exportChosen} />
|
|
323
|
+
{@render hostActions?.()}
|
|
324
|
+
{/snippet}
|
|
325
|
+
{#snippet toggles()}
|
|
326
|
+
{#if header && parameters.length > 0}
|
|
327
|
+
<button
|
|
328
|
+
type="button"
|
|
329
|
+
class="kc-control"
|
|
330
|
+
aria-controls="{id}-params"
|
|
331
|
+
aria-expanded={paramsOpen}
|
|
332
|
+
onclick={() => settings.set(KEYS.paramsOpen, !paramsOpen)}
|
|
333
|
+
>
|
|
334
|
+
Parameters
|
|
335
|
+
</button>
|
|
336
|
+
{/if}
|
|
337
|
+
{/snippet}
|
|
338
|
+
</ViewerPane>
|
|
339
|
+
</div>
|
|
340
|
+
{#if consoleOpen}
|
|
341
|
+
<Splitter
|
|
342
|
+
between="rows"
|
|
343
|
+
pane="after"
|
|
344
|
+
bind:size={consoleHeight}
|
|
345
|
+
min={48}
|
|
346
|
+
label="Resize the console"
|
|
347
|
+
onchange={(size) => settings.set(KEYS.console, size)}
|
|
348
|
+
/>
|
|
349
|
+
{/if}
|
|
350
|
+
<ConsolePanel
|
|
351
|
+
lines={consoleLines}
|
|
352
|
+
height={consoleHeight}
|
|
353
|
+
bind:open={() => consoleOpen, (open) => settings.set(KEYS.open, open)}
|
|
354
|
+
onreveal={reveal}
|
|
355
|
+
onclear={() => (consoleLines = [])}
|
|
365
356
|
/>
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
onchange={valuesChanged}
|
|
357
|
+
</section>
|
|
358
|
+
{#if header && parameters.length > 0}
|
|
359
|
+
{#if paramsOpen}
|
|
360
|
+
<Splitter
|
|
361
|
+
pane="after"
|
|
362
|
+
bind:size={paramsWidth}
|
|
363
|
+
min={200}
|
|
364
|
+
max={640}
|
|
365
|
+
label="Resize the parameters"
|
|
366
|
+
onchange={(size) => settings.set(KEYS.params, size)}
|
|
377
367
|
/>
|
|
378
|
-
{/
|
|
379
|
-
|
|
380
|
-
|
|
368
|
+
{/if}
|
|
369
|
+
<!-- Hidden, not gone: what its fields hold stays, and the toggle has it to control -->
|
|
370
|
+
<aside class="params" id="{id}-params" aria-label="Parameters" hidden={!paramsOpen}>
|
|
371
|
+
<!-- Made again for each script loaded: no field keeps what was typed in the last's -->
|
|
372
|
+
{#key loads}
|
|
373
|
+
<ParamsPanel
|
|
374
|
+
schema={header.params.schema}
|
|
375
|
+
values={header.params.values}
|
|
376
|
+
error={header.error}
|
|
377
|
+
bind:overrides
|
|
378
|
+
onchange={valuesChanged}
|
|
379
|
+
/>
|
|
380
|
+
{/key}
|
|
381
|
+
</aside>
|
|
382
|
+
{/if}
|
|
383
|
+
</div>
|
|
381
384
|
</div>
|
|
382
385
|
|
|
383
386
|
<style>
|
|
387
|
+
.kc-playground-box {
|
|
388
|
+
height: 100%;
|
|
389
|
+
min-height: 0;
|
|
390
|
+
container-type: inline-size;
|
|
391
|
+
}
|
|
384
392
|
.kc-playground {
|
|
385
393
|
display: flex;
|
|
386
394
|
height: 100%;
|
|
@@ -428,10 +436,10 @@
|
|
|
428
436
|
border-radius: var(--kc-radius);
|
|
429
437
|
background: var(--kc-bg);
|
|
430
438
|
}
|
|
431
|
-
/* Narrow, the panes stacked, each at a height of its own, and
|
|
432
|
-
script a few lines, the model 4:3 of its width (at most 32em),
|
|
433
|
-
parameters as tall as their lines */
|
|
434
|
-
@
|
|
439
|
+
/* Narrow (a phone, a column of a page), the panes stacked, each at a height of its own, and
|
|
440
|
+
the playground scrolled: the script a few lines, the model 4:3 of its width (at most 32em),
|
|
441
|
+
the console and the parameters as tall as their lines */
|
|
442
|
+
@container (max-width: 800px) {
|
|
435
443
|
.kc-playground {
|
|
436
444
|
flex-direction: column;
|
|
437
445
|
overflow-y: auto;
|