@kupcad/ui 0.1.9 → 0.1.11

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
@@ -235,7 +235,7 @@ webview and the desktop app to the language server.
235
235
  presets, which the toolbar's Parameters button hides for the model's width. It talks to the
236
236
  host as a `ViewerHost` (`@kupcad/protocol`'s `HostMessage` and `ViewerMessage`): the panel's
237
237
  values, a preset, an export (in the format its toolbar's `ExportMenu` chose, those the model's
238
- kind can be written in), a screenshot (base64) or a problem's place go to the host, which
238
+ kind can be written in), a screenshot (base64, `@kupcad/protocol`'s `pngBase64`) or a problem's place go to the host, which
239
239
  gives them to the server or acts on them. Its console (`console`, by default shown) keeps each
240
240
  run of the document shown, a frame sent again once, and the lines the host's `log` messages
241
241
  give. A host that keeps no presets passes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kupcad/ui",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "description": "KupCAD's UI: a three.js viewer of a model the core made, for any host (@kupcad/ui/viewer), and the Svelte panels around it (the viewer's pane, parameters, console, a language server's preview), styled by --kc-* tokens.",
5
5
  "license": "AGPL-3.0-only",
6
6
  "repository": {
@@ -36,22 +36,22 @@
36
36
  "access": "public"
37
37
  },
38
38
  "dependencies": {
39
- "@kupcad/protocol": "0.1.9",
39
+ "@kupcad/protocol": "0.1.11",
40
40
  "three": "^0.187.0",
41
41
  "three-mesh-bvh": "^0.9.17"
42
42
  },
43
43
  "devDependencies": {
44
- "@kupcad/wasm": "0.1.9",
44
+ "@kupcad/wasm": "0.1.11",
45
45
  "@playwright/test": "^1.64.1",
46
46
  "@sveltejs/vite-plugin-svelte": "^7.3.1",
47
47
  "@testing-library/svelte": "^5.4.2",
48
- "@types/node": "^26.6.5",
49
- "@types/three": "~0.186.0",
48
+ "@types/node": "^26.6.6",
49
+ "@types/three": "~0.187.0",
50
50
  "jsdom": "^30.1.3",
51
51
  "svelte": "^5.57.3",
52
- "svelte-check": "^4.7.7",
52
+ "svelte-check": "^4.7.8",
53
53
  "vite": "^8.3.5",
54
- "vitest": "^5.0.5"
54
+ "vitest": "^5.1.0"
55
55
  },
56
56
  "peerDependencies": {
57
57
  "svelte": "^5.57.2"
@@ -16,7 +16,7 @@
16
16
  -->
17
17
  <script>
18
18
  import { onMount, untrack } from 'svelte';
19
- import { errorText } from '@kupcad/protocol';
19
+ import { errorText, pngBase64 } from '@kupcad/protocol';
20
20
  import ConsolePanel from './ConsolePanel.svelte';
21
21
  import ExportMenu from './ExportMenu.svelte';
22
22
  import { appendLines, linesOfLog, linesOfRun } from './console.js';
@@ -25,7 +25,6 @@
25
25
  import { memorySettings, paneKeys, sizeSetting } from './settings.js';
26
26
  import Splitter from './Splitter.svelte';
27
27
  import ViewerPane from './ViewerPane.svelte';
28
- import { toBase64 } from './base64.js';
29
28
  import { problemsOf, runStatusOf } from './run-status.js';
30
29
  import { connectViewport } from './viewport-socket.js';
31
30
 
@@ -218,7 +217,7 @@
218
217
 
219
218
  /** @param {Blob} image */
220
219
  async function screenshot(image) {
221
- host.post({ type: 'screenshot', png: toBase64(new Uint8Array(await image.arrayBuffer())) });
220
+ host.post({ type: 'screenshot', png: pngBase64(new Uint8Array(await image.arrayBuffer())) });
222
221
  }
223
222
 
224
223
  /** @param {unknown} error the viewer's: a model it can't show */
package/src/index.js CHANGED
@@ -23,7 +23,7 @@ export {
23
23
  settingsObject,
24
24
  sizeSetting,
25
25
  } from './settings.js';
26
- export { VIEWER_SHORTCUTS } from './shortcuts.js';
26
+ export { keyboardSystem, VIEWER_SHORTCUTS } from './shortcuts.js';
27
27
  export { watchTokens } from './theme.js';
28
28
  export { plainValues } from './values.svelte.js';
29
29
  export {
@@ -43,5 +43,6 @@ export { connectViewport } from './viewport-socket.js';
43
43
  /** @typedef {import('./run-status.js').RunStatus} RunStatus */
44
44
  /** @typedef {import('./settings.js').Settings} Settings */
45
45
  /** @typedef {import('./shortcuts.js').ShortcutGroup} ShortcutGroup */
46
+ /** @typedef {import('./shortcuts.js').KeyboardSystem} KeyboardSystem */
46
47
  /** @typedef {import('./view-settings.js').ViewChoices} ViewChoices */
47
48
  /** @typedef {import('./viewport-socket.js').ViewportEvents} ViewportEvents */
package/src/measures.js CHANGED
@@ -15,10 +15,10 @@ const MM3_PER_CM3 = 1000;
15
15
  const decimal = (n, digits) => n.toLocaleString('en', { maximumFractionDigits: digits });
16
16
 
17
17
  /** @param {number} mm */
18
- export const formatLength = (mm) => decimal(mm, 2);
18
+ const formatLength = (mm) => decimal(mm, 2);
19
19
 
20
20
  /** @param {number} mm2 */
21
- export const formatArea = (mm2) => `${decimal(mm2, 1)} mm²`;
21
+ const formatArea = (mm2) => `${decimal(mm2, 1)} mm²`;
22
22
 
23
23
  /** @param {number} mm3 */
24
24
  export const formatVolume = (mm3) =>
package/src/params.js CHANGED
@@ -329,7 +329,7 @@ function readScalar(rule, input, path) {
329
329
  * @param {Value | null} input
330
330
  * @returns {number | null}
331
331
  */
332
- export function numberOf(input) {
332
+ function numberOf(input) {
333
333
  if (typeof input === 'number') return Number.isFinite(input) ? input : null;
334
334
  if (typeof input !== 'string') return null;
335
335
  const hex = HEX_NUMBER.exec(input);
@@ -372,7 +372,7 @@ function hexNumber(match) {
372
372
  * @param {Value | null} input
373
373
  * @returns {boolean | null}
374
374
  */
375
- export function booleanOf(input) {
375
+ function booleanOf(input) {
376
376
  if (typeof input === 'boolean') return input;
377
377
  if (input === 1 || input === 'true' || input === '1') return true;
378
378
  if (input === 0 || input === 'false' || input === '0') return false;
package/src/theme.js CHANGED
@@ -60,7 +60,7 @@ export function themeFromTokens(element) {
60
60
  * `only light`), else the system's (`light dark`, or none said).
61
61
  * @param {CSSStyleDeclaration} style its computed style
62
62
  */
63
- export function isDark(style) {
63
+ function isDark(style) {
64
64
  const scheme = (style.colorScheme ?? '').split(/\s+/);
65
65
  const light = scheme.includes('light');
66
66
  if (scheme.includes('dark') !== light) return !light;
package/src/base64.js DELETED
@@ -1,16 +0,0 @@
1
- // Bytes as base64, which the page's messages carry a screenshot in.
2
-
3
- /** How many bytes go to String.fromCharCode at once: it takes only so many arguments. */
4
- const CHUNK_BYTES = 0x8000;
5
-
6
- /**
7
- * @param {Uint8Array} bytes
8
- * @returns {string}
9
- */
10
- export function toBase64(bytes) {
11
- let text = '';
12
- for (let at = 0; at < bytes.length; at += CHUNK_BYTES) {
13
- text += String.fromCharCode(...bytes.subarray(at, at + CHUNK_BYTES));
14
- }
15
- return btoa(text);
16
- }