@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 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. A page 800px
59
- wide or less stacks the panes, each at a height of its own (the script a few lines, the model
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.6",
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.6",
28
- "@kupcad/protocol": "0.1.6",
29
- "@kupcad/ui": "0.1.6",
30
- "@kupcad/wasm": "0.1.6"
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",
@@ -274,113 +274,121 @@
274
274
  }
275
275
  </script>
276
276
 
277
- <div
278
- class="kc-playground"
279
- bind:clientWidth={width}
280
- style:--editor-width="{editorWidth}px"
281
- style:--params-width="{paramsWidth}px"
282
- >
283
- <section class="code" aria-label="Script">
284
- {#key documents}
285
- <Editor
286
- bind:value
287
- bind:editor
288
- findings={marks}
289
- label={name}
290
- restore={restored}
291
- {language}
292
- onchange={edited}
293
- />
294
- {/key}
295
- {#if notice}<p class="notice" role="alert">{notice}</p>{/if}
296
- </section>
297
- <Splitter
298
- bind:size={editorWidth}
299
- min={240}
300
- max={width > 0 ? width - (paramsShown ? paramsWidth : 0) - MIN_VIEW : undefined}
301
- label="Resize the script"
302
- onchange={(size) => settings.set(KEYS.editor, size)}
303
- />
304
- <section class="view" aria-label="Model">
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
- </section>
356
- {#if header && parameters.length > 0}
357
- {#if paramsOpen}
358
- <Splitter
359
- pane="after"
360
- bind:size={paramsWidth}
361
- min={200}
362
- max={640}
363
- label="Resize the parameters"
364
- onchange={(size) => settings.set(KEYS.params, size)}
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
- {/if}
367
- <!-- Hidden, not gone: what its fields hold stays, and the toggle has it to control -->
368
- <aside class="params" id="{id}-params" aria-label="Parameters" hidden={!paramsOpen}>
369
- <!-- Made again for each script loaded: no field keeps what was typed in the last's -->
370
- {#key loads}
371
- <ParamsPanel
372
- schema={header.params.schema}
373
- values={header.params.values}
374
- error={header.error}
375
- bind:overrides
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
- {/key}
379
- </aside>
380
- {/if}
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 the playground scrolled: the
432
- script a few lines, the model 4:3 of its width (at most 32em), the console and the
433
- parameters as tall as their lines */
434
- @media (max-width: 800px) {
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;