@classcad/client 3.0.0-beta.20261120143517 → 3.0.0-beta.20261124144149

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
@@ -11,7 +11,7 @@ npm install @classcad/client
11
11
  yarn add @classcad/client
12
12
  ```
13
13
 
14
- Built against the ClassCAD engine 21.2.1-alpha.232 (alpha): the bundle at https://awvstatic.com/classcad/download/alpha/21.2.1-alpha.232. A server host installs that version, from the [Downloads](https://classcad.ch/account#downloads) of a classcad.ch account (channel Alpha); in WASM mode it is loaded from there by itself.
14
+ Built against the ClassCAD engine 21.2.1-alpha.242 (alpha): the bundle at https://awvstatic.com/classcad/download/alpha/21.2.1-alpha.242. A server host installs that version, from the [Downloads](https://classcad.ch/account#downloads) of a classcad.ch account (channel Alpha); in WASM mode it is loaded from there by itself.
15
15
 
16
16
  ### Links to our homepages and documentations
17
17
 
@@ -86,6 +86,51 @@ const errorResult = (req, message) => ({
86
86
  });
87
87
  /** A streaming connection (WSClient) takes patches and graphics as frames of their own. */
88
88
  const streams = (cfg) => cfg.sendStructure_Patch === true;
89
+ const MESH_ARRAYS = ['vertices', 'normals', 'indices'];
90
+ /**
91
+ * Mesh data may be typed arrays in this page (the worker of the WASM engine transfers them, see WASMClient), and
92
+ * JSON.stringify would write them as objects. Guests get plain number arrays, as from a server. What holds no typed
93
+ * array is returned as it is, so graphics without them cost nothing extra.
94
+ */
95
+ function plainMesh(mesh) {
96
+ if (!MESH_ARRAYS.some(key => ArrayBuffer.isView(mesh === null || mesh === void 0 ? void 0 : mesh[key])))
97
+ return mesh;
98
+ const copy = Object.assign({}, mesh);
99
+ for (const key of MESH_ARRAYS) {
100
+ const value = copy[key];
101
+ if (ArrayBuffer.isView(value))
102
+ copy[key] = Array.from(value);
103
+ }
104
+ return copy;
105
+ }
106
+ /** The containers with plain mesh arrays (see plainMesh); the same array when nothing had to change. */
107
+ function plainContainers(containers) {
108
+ let changed = false;
109
+ const plain = containers.map(container => {
110
+ const meshes = container === null || container === void 0 ? void 0 : container.meshes;
111
+ if (!Array.isArray(meshes))
112
+ return container;
113
+ const plainMeshes = meshes.map(plainMesh);
114
+ if (plainMeshes.every((mesh, i) => mesh === meshes[i]))
115
+ return container;
116
+ changed = true;
117
+ return Object.assign(Object.assign({}, container), { meshes: plainMeshes });
118
+ });
119
+ return changed ? plain : containers;
120
+ }
121
+ /** A graphic package with plain mesh arrays (see plainMesh), the same package when nothing had to change. */
122
+ function plainPackage(pkg) {
123
+ var _a;
124
+ if (Array.isArray(pkg === null || pkg === void 0 ? void 0 : pkg.containers)) {
125
+ const containers = plainContainers(pkg.containers);
126
+ return containers === pkg.containers ? pkg : Object.assign(Object.assign({}, pkg), { containers });
127
+ }
128
+ if (Array.isArray((_a = pkg === null || pkg === void 0 ? void 0 : pkg.graphic) === null || _a === void 0 ? void 0 : _a.containers)) {
129
+ const containers = plainContainers(pkg.graphic.containers);
130
+ return containers === pkg.graphic.containers ? pkg : Object.assign(Object.assign({}, pkg), { graphic: Object.assign(Object.assign({}, pkg.graphic), { containers }) });
131
+ }
132
+ return pkg;
133
+ }
89
134
  /** Translates one reply of the engine into what a server's frames are made of. */
90
135
  function pieces(req, res) {
91
136
  var _a, _b, _c, _d, _e, _f, _g, _h;
@@ -442,13 +487,15 @@ class SessionHost {
442
487
  const version = { version: 11 };
443
488
  let patchFrames = null;
444
489
  let graphicFrames = null;
490
+ let packages = null;
491
+ const plainPackages = () => (packages !== null && packages !== void 0 ? packages : (packages = p.packages.map(plainPackage)));
445
492
  for (const guest of recipients) {
446
493
  const cfg = guest.config;
447
494
  const result = Object.assign({}, p.result);
448
495
  if (read) {
449
496
  result.structure = p.structure;
450
497
  if (cfg.sendGraphic_Kernel !== false)
451
- result.graphic = { containers: this.opts.containers(), properties: version };
498
+ result.graphic = { containers: plainContainers(this.opts.containers()), properties: version };
452
499
  }
453
500
  else if (streams(cfg)) {
454
501
  if (cfg.sendStructure !== false) {
@@ -457,7 +504,7 @@ class SessionHost {
457
504
  this.raw(guest, frame);
458
505
  }
459
506
  if (cfg.sendGraphic_Kernel !== false && p.packages.length) {
460
- graphicFrames !== null && graphicFrames !== void 0 ? graphicFrames : (graphicFrames = p.packages.map(pkg => JSON.stringify(Object.assign(Object.assign({ command: 'Graphic' }, head), { graphic: pkg }))));
507
+ graphicFrames !== null && graphicFrames !== void 0 ? graphicFrames : (graphicFrames = plainPackages().map(pkg => JSON.stringify(Object.assign(Object.assign({ command: 'Graphic' }, head), { graphic: pkg }))));
461
508
  for (const frame of graphicFrames)
462
509
  this.raw(guest, frame);
463
510
  }
@@ -465,7 +512,7 @@ class SessionHost {
465
512
  else if (cfg.sendGraphic_Kernel !== false && p.packages.length) {
466
513
  // Bundled: what the command changed rides on its Result. The structure
467
514
  // does not (it would cost a pull per command): GetTree returns it.
468
- result.graphic = { containers: p.packages.flatMap(pkg => { var _a; return (_a = pkg === null || pkg === void 0 ? void 0 : pkg.containers) !== null && _a !== void 0 ? _a : []; }), properties: version };
515
+ result.graphic = { containers: plainPackages().flatMap(pkg => { var _a; return (_a = pkg === null || pkg === void 0 ? void 0 : pkg.containers) !== null && _a !== void 0 ? _a : []; }), properties: version };
469
516
  }
470
517
  if (cfg.sendMessages === false)
471
518
  delete result.messages;
@@ -82,6 +82,51 @@ const errorResult = (req, message) => ({
82
82
  });
83
83
  /** A streaming connection (WSClient) takes patches and graphics as frames of their own. */
84
84
  const streams = (cfg) => cfg.sendStructure_Patch === true;
85
+ const MESH_ARRAYS = ['vertices', 'normals', 'indices'];
86
+ /**
87
+ * Mesh data may be typed arrays in this page (the worker of the WASM engine transfers them, see WASMClient), and
88
+ * JSON.stringify would write them as objects. Guests get plain number arrays, as from a server. What holds no typed
89
+ * array is returned as it is, so graphics without them cost nothing extra.
90
+ */
91
+ function plainMesh(mesh) {
92
+ if (!MESH_ARRAYS.some(key => ArrayBuffer.isView(mesh === null || mesh === void 0 ? void 0 : mesh[key])))
93
+ return mesh;
94
+ const copy = Object.assign({}, mesh);
95
+ for (const key of MESH_ARRAYS) {
96
+ const value = copy[key];
97
+ if (ArrayBuffer.isView(value))
98
+ copy[key] = Array.from(value);
99
+ }
100
+ return copy;
101
+ }
102
+ /** The containers with plain mesh arrays (see plainMesh); the same array when nothing had to change. */
103
+ function plainContainers(containers) {
104
+ let changed = false;
105
+ const plain = containers.map(container => {
106
+ const meshes = container === null || container === void 0 ? void 0 : container.meshes;
107
+ if (!Array.isArray(meshes))
108
+ return container;
109
+ const plainMeshes = meshes.map(plainMesh);
110
+ if (plainMeshes.every((mesh, i) => mesh === meshes[i]))
111
+ return container;
112
+ changed = true;
113
+ return Object.assign(Object.assign({}, container), { meshes: plainMeshes });
114
+ });
115
+ return changed ? plain : containers;
116
+ }
117
+ /** A graphic package with plain mesh arrays (see plainMesh), the same package when nothing had to change. */
118
+ function plainPackage(pkg) {
119
+ var _a;
120
+ if (Array.isArray(pkg === null || pkg === void 0 ? void 0 : pkg.containers)) {
121
+ const containers = plainContainers(pkg.containers);
122
+ return containers === pkg.containers ? pkg : Object.assign(Object.assign({}, pkg), { containers });
123
+ }
124
+ if (Array.isArray((_a = pkg === null || pkg === void 0 ? void 0 : pkg.graphic) === null || _a === void 0 ? void 0 : _a.containers)) {
125
+ const containers = plainContainers(pkg.graphic.containers);
126
+ return containers === pkg.graphic.containers ? pkg : Object.assign(Object.assign({}, pkg), { graphic: Object.assign(Object.assign({}, pkg.graphic), { containers }) });
127
+ }
128
+ return pkg;
129
+ }
85
130
  /** Translates one reply of the engine into what a server's frames are made of. */
86
131
  export function pieces(req, res) {
87
132
  var _a, _b, _c, _d, _e, _f, _g, _h;
@@ -438,13 +483,15 @@ export class SessionHost {
438
483
  const version = { version: 11 };
439
484
  let patchFrames = null;
440
485
  let graphicFrames = null;
486
+ let packages = null;
487
+ const plainPackages = () => (packages !== null && packages !== void 0 ? packages : (packages = p.packages.map(plainPackage)));
441
488
  for (const guest of recipients) {
442
489
  const cfg = guest.config;
443
490
  const result = Object.assign({}, p.result);
444
491
  if (read) {
445
492
  result.structure = p.structure;
446
493
  if (cfg.sendGraphic_Kernel !== false)
447
- result.graphic = { containers: this.opts.containers(), properties: version };
494
+ result.graphic = { containers: plainContainers(this.opts.containers()), properties: version };
448
495
  }
449
496
  else if (streams(cfg)) {
450
497
  if (cfg.sendStructure !== false) {
@@ -453,7 +500,7 @@ export class SessionHost {
453
500
  this.raw(guest, frame);
454
501
  }
455
502
  if (cfg.sendGraphic_Kernel !== false && p.packages.length) {
456
- graphicFrames !== null && graphicFrames !== void 0 ? graphicFrames : (graphicFrames = p.packages.map(pkg => JSON.stringify(Object.assign(Object.assign({ command: 'Graphic' }, head), { graphic: pkg }))));
503
+ graphicFrames !== null && graphicFrames !== void 0 ? graphicFrames : (graphicFrames = plainPackages().map(pkg => JSON.stringify(Object.assign(Object.assign({ command: 'Graphic' }, head), { graphic: pkg }))));
457
504
  for (const frame of graphicFrames)
458
505
  this.raw(guest, frame);
459
506
  }
@@ -461,7 +508,7 @@ export class SessionHost {
461
508
  else if (cfg.sendGraphic_Kernel !== false && p.packages.length) {
462
509
  // Bundled: what the command changed rides on its Result. The structure
463
510
  // does not (it would cost a pull per command): GetTree returns it.
464
- result.graphic = { containers: p.packages.flatMap(pkg => { var _a; return (_a = pkg === null || pkg === void 0 ? void 0 : pkg.containers) !== null && _a !== void 0 ? _a : []; }), properties: version };
511
+ result.graphic = { containers: plainPackages().flatMap(pkg => { var _a; return (_a = pkg === null || pkg === void 0 ? void 0 : pkg.containers) !== null && _a !== void 0 ? _a : []; }), properties: version };
465
512
  }
466
513
  if (cfg.sendMessages === false)
467
514
  delete result.messages;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@classcad/client",
3
- "version": "3.0.0-beta.20261120143517",
3
+ "version": "3.0.0-beta.20261124144149",
4
4
  "homepage": "https://sdkjs.classcad.ch",
5
5
  "description": "Connects an app to ClassCAD, the CAD engine, and runs the ClassCAD API: the package every sdkjs app starts with",
6
6
  "author": "AWV Informatik AG <info@awv-informatik.ch>",
@@ -38,8 +38,8 @@
38
38
  "typescript": "~6.0.3"
39
39
  },
40
40
  "dependencies": {
41
- "@classcad/sdkjs": "3.0.0-beta.20261120143517",
42
- "@classcad/api-js": "https://awvstatic.com/classcad/download/alpha/21.2.1-alpha.232/js/classcad-api-js-21.2.1-alpha.232.tgz",
41
+ "@classcad/sdkjs": "3.0.0-beta.20261124144149",
42
+ "@classcad/api-js": "https://awvstatic.com/classcad/download/alpha/21.2.1-alpha.242/js/classcad-api-js-21.2.1-alpha.242.tgz",
43
43
  "@types/events": "^3.0.3",
44
44
  "base64-arraybuffer": "^1.0.2",
45
45
  "comlink": "^4.4.2",
@@ -55,8 +55,8 @@
55
55
  "three": ">=0.170"
56
56
  },
57
57
  "classcadEngine": {
58
- "version": "21.2.1-alpha.232",
58
+ "version": "21.2.1-alpha.242",
59
59
  "quality": "alpha",
60
- "url": "https://awvstatic.com/classcad/download/alpha/21.2.1-alpha.232"
60
+ "url": "https://awvstatic.com/classcad/download/alpha/21.2.1-alpha.242"
61
61
  }
62
62
  }