@classcad/client 0.0.0-stage → 3.0.0-beta.20261119100608
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 +20 -2
- package/bin/buerli-classcad.cjs +23 -0
- package/build/cjs/BuerliCadFacade.js +718 -0
- package/build/cjs/cclass/utils/assembly.js +687 -0
- package/build/cjs/cclass/utils/base.js +136 -0
- package/build/cjs/cclass/utils/index.js +99 -0
- package/build/cjs/cclass/utils/part.js +153 -0
- package/build/cjs/classcadEngine.js +33 -0
- package/build/cjs/createApi.js +71 -0
- package/build/cjs/createUnwrappedApi.js +43 -0
- package/build/cjs/facade.js +103 -0
- package/build/cjs/globals.js +157 -0
- package/build/cjs/index.js +102 -0
- package/build/cjs/io/AwvNodeClient.js +290 -0
- package/build/cjs/io/SocketIOClient.js +339 -0
- package/build/cjs/io/Transaction.js +134 -0
- package/build/cjs/io/WASMClient.js +433 -0
- package/build/cjs/io/WSClient.js +646 -0
- package/build/cjs/io/engineKey.js +202 -0
- package/build/cjs/re-export.js +35 -0
- package/build/cjs/session/host.js +479 -0
- package/build/cjs/session/identity.js +38 -0
- package/build/cjs/session/selection.js +283 -0
- package/build/cjs/session/share.js +229 -0
- package/build/cjs/session/types.js +23 -0
- package/build/cjs/test/SocketIOClient.spec.js +178 -0
- package/build/cjs/types/ComClient.js +10 -0
- package/build/cjs/utils/createRecursiveBufferGeometry.js +55 -0
- package/build/cjs/utils/createRecursiveScene.js +140 -0
- package/build/cjs/utils/getDifferentColoredMeshesFromEntity.js +24 -0
- package/build/cjs/utils/index.js +20 -0
- package/build/cjs/utils/polyline.js +65 -0
- package/build/cjs/utils/waitForSelect.js +29 -0
- package/build/esm/BuerliCadFacade.js +714 -0
- package/build/esm/cclass/utils/assembly.js +665 -0
- package/build/esm/cclass/utils/base.js +127 -0
- package/build/esm/cclass/utils/index.js +62 -0
- package/build/esm/cclass/utils/part.js +144 -0
- package/build/esm/classcadEngine.js +30 -0
- package/build/esm/createApi.js +66 -0
- package/build/esm/createUnwrappedApi.js +39 -0
- package/build/esm/facade.js +98 -0
- package/build/esm/globals.js +150 -0
- package/build/esm/index.js +80 -0
- package/build/esm/io/AwvNodeClient.js +286 -0
- package/build/esm/io/SocketIOClient.js +332 -0
- package/build/esm/io/Transaction.js +130 -0
- package/build/esm/io/WASMClient.js +429 -0
- package/build/esm/io/WSClient.js +642 -0
- package/build/esm/io/engineKey.js +196 -0
- package/build/esm/re-export.js +3 -0
- package/build/esm/session/host.js +474 -0
- package/build/esm/session/identity.js +34 -0
- package/build/esm/session/selection.js +277 -0
- package/build/esm/session/share.js +221 -0
- package/build/esm/session/types.js +20 -0
- package/build/esm/test/SocketIOClient.spec.js +178 -0
- package/build/esm/types/ComClient.js +7 -0
- package/build/esm/utils/createRecursiveBufferGeometry.js +51 -0
- package/build/esm/utils/createRecursiveScene.js +136 -0
- package/build/esm/utils/getDifferentColoredMeshesFromEntity.js +20 -0
- package/build/esm/utils/index.js +4 -0
- package/build/esm/utils/polyline.js +60 -0
- package/build/esm/utils/waitForSelect.js +23 -0
- package/build/types/BuerliCadFacade.d.ts +410 -0
- package/build/types/cclass/utils/assembly.d.ts +180 -0
- package/build/types/cclass/utils/base.d.ts +55 -0
- package/build/types/cclass/utils/index.d.ts +46 -0
- package/build/types/cclass/utils/part.d.ts +46 -0
- package/build/types/classcadEngine.d.ts +40 -0
- package/build/types/createApi.d.ts +65 -0
- package/build/types/createUnwrappedApi.d.ts +36 -0
- package/build/types/facade.d.ts +9 -0
- package/build/types/globals.d.ts +79 -0
- package/build/types/index.d.ts +82 -0
- package/build/types/io/AwvNodeClient.d.ts +182 -0
- package/build/types/io/SocketIOClient.d.ts +84 -0
- package/build/types/io/Transaction.d.ts +56 -0
- package/build/types/io/WASMClient.d.ts +239 -0
- package/build/types/io/WSClient.d.ts +242 -0
- package/build/types/io/engineKey.d.ts +137 -0
- package/build/types/re-export.d.ts +6 -0
- package/build/types/session/host.d.ts +108 -0
- package/build/types/session/identity.d.ts +46 -0
- package/build/types/session/selection.d.ts +164 -0
- package/build/types/session/share.d.ts +131 -0
- package/build/types/session/types.d.ts +113 -0
- package/build/types/test/SocketIOClient.spec.d.ts +0 -0
- package/build/types/types/ComClient.d.ts +307 -0
- package/build/types/utils/createRecursiveBufferGeometry.d.ts +8 -0
- package/build/types/utils/createRecursiveScene.d.ts +24 -0
- package/build/types/utils/getDifferentColoredMeshesFromEntity.d.ts +14 -0
- package/build/types/utils/index.d.ts +4 -0
- package/build/types/utils/polyline.d.ts +43 -0
- package/build/types/utils/waitForSelect.d.ts +4 -0
- package/doc/api/advanced/connection.md +488 -0
- package/doc/api/clients.md +2045 -0
- package/doc/api/engine-keys.md +230 -0
- package/doc/api/index.md +58 -0
- package/doc/api/modeling.md +682 -0
- package/doc/api/other.md +33 -0
- package/doc/api/session-sharing.md +706 -0
- package/package.json +60 -4
- package/test/classcadEngine.test.cjs +44 -0
- package/test/connect.test.cjs +81 -0
- package/test/engineKey.test.cjs +80 -0
- package/test/onClient.test.cjs +82 -0
- package/typedoc.json +8 -0
|
@@ -0,0 +1,714 @@
|
|
|
1
|
+
var _a;
|
|
2
|
+
import { Scene } from 'three';
|
|
3
|
+
import { api as buerliApi, getDrawing, showMessage, BuerliScope, createInfo, Measure, } from '@classcad/sdkjs';
|
|
4
|
+
import { createUnwrappedApi } from './createUnwrappedApi';
|
|
5
|
+
import { clientMade, Globals } from './globals';
|
|
6
|
+
import { EMISSION_CONFIG_UNSUPPORTED } from './types/ComClient';
|
|
7
|
+
import { createRecursiveBufferGeometry, createRecursiveScene, getIncludingBulgeAngle, getTouchPoints, waitForSelect, } from './utils';
|
|
8
|
+
/**
|
|
9
|
+
* Only for internal usage!
|
|
10
|
+
*
|
|
11
|
+
* Connects the drawing to ClassCAD
|
|
12
|
+
* This function is not part of the api itself, since it should only be used internally!
|
|
13
|
+
*/
|
|
14
|
+
const connect = async (drawingId) => {
|
|
15
|
+
const client = Globals.clientCache[drawingId];
|
|
16
|
+
if (!client) {
|
|
17
|
+
throw new Error("Client not ready. Did you create a valid cc drawing by calling 'createCCDrawing'?");
|
|
18
|
+
}
|
|
19
|
+
await client.connect();
|
|
20
|
+
showMessage({ type: 'success', text: `Connected to ClassCAD`, drawingId: drawingId });
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Only for internal usage!
|
|
24
|
+
*
|
|
25
|
+
* Makes the drawing's client with the factory given to init, hands it to the onClient callbacks and connects it.
|
|
26
|
+
* Rejects with what kept the client from connecting.
|
|
27
|
+
*/
|
|
28
|
+
const connectClient = async (drawingId) => {
|
|
29
|
+
Globals.clientCache[drawingId] = Globals.factory(drawingId);
|
|
30
|
+
clientMade(Globals.clientCache[drawingId], drawingId);
|
|
31
|
+
await connect(drawingId);
|
|
32
|
+
};
|
|
33
|
+
const assertFactory = () => {
|
|
34
|
+
if (!Globals.factory) {
|
|
35
|
+
throw new Error('Client factory not initialized. Did you init @classcad/client by calling the function init?');
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* A drawing connected to ClassCAD: its API, and helpers that turn the model into three.js objects.
|
|
40
|
+
*
|
|
41
|
+
* `connect()` creates a drawing in the SDK's store and connects it with a client from the factory given to
|
|
42
|
+
* {@link init}. Then `api` is the drawing's ClassCAD API, unwrapped: `await api.v1.part.create(…)` resolves to the
|
|
43
|
+
* new part's id and rejects when the engine reports an error; warnings are logged. `createBufferGeometry` and
|
|
44
|
+
* `createScene` make three.js geometry of what was built, `tree` and `graphic` read the drawing as the store holds
|
|
45
|
+
* it. The static `utils` do the facade's work for any drawing, by its id.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* import * as THREE from 'three'
|
|
50
|
+
* import { init, BuerliCadFacade, WASMClient } from '@classcad/client'
|
|
51
|
+
*
|
|
52
|
+
* init(drawingId => new WASMClient(drawingId, { token: 'ccpk_…' }))
|
|
53
|
+
*
|
|
54
|
+
* // A parametric flange: one facade per drawing
|
|
55
|
+
* export async function flange(diameter: number, thickness: number) {
|
|
56
|
+
* const facade = new BuerliCadFacade()
|
|
57
|
+
* await facade.connect('Flange')
|
|
58
|
+
* const { part } = facade.api.v1
|
|
59
|
+
* const flange = (await part.create({ name: 'Flange' }))!
|
|
60
|
+
* await part.cylinder({ id: flange, diameter, height: thickness })
|
|
61
|
+
* const geometries = (await facade.createBufferGeometry(flange)) ?? []
|
|
62
|
+
* const meshes = geometries.map(geometry => new THREE.Mesh(geometry, new THREE.MeshStandardMaterial()))
|
|
63
|
+
* // Done with it: the drawing leaves the store
|
|
64
|
+
* await facade.destroy()
|
|
65
|
+
* return meshes
|
|
66
|
+
* }
|
|
67
|
+
* ```
|
|
68
|
+
* @category Modeling
|
|
69
|
+
*/
|
|
70
|
+
export class BuerliCadFacade {
|
|
71
|
+
/** The id of the drawing the facade connected. Throws before `connect()`. */
|
|
72
|
+
get drawingId() {
|
|
73
|
+
if (!this._drawingId) {
|
|
74
|
+
throw new Error('Drawing ID not set. Did you call connect() first?');
|
|
75
|
+
}
|
|
76
|
+
return this._drawingId;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* The drawing's ClassCAD API ({@link ClassCADApi}): calls resolve to their result and reject on an error.
|
|
80
|
+
* Throws before `connect()` and after `disconnect()`.
|
|
81
|
+
*/
|
|
82
|
+
get api() {
|
|
83
|
+
if (!this._api) {
|
|
84
|
+
throw new Error('API not initialized. Did you call connect() first?');
|
|
85
|
+
}
|
|
86
|
+
return this._api;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Disconnects from ClassCAD and removes the drawing from the SDK's store. The facade can `connect()` again.
|
|
90
|
+
*
|
|
91
|
+
* A failing disconnect does not keep the drawing from being removed.
|
|
92
|
+
*/
|
|
93
|
+
async destroy() {
|
|
94
|
+
// Make sure disconnect does not prevent the drawing from being removed!
|
|
95
|
+
try {
|
|
96
|
+
await this.disconnect();
|
|
97
|
+
}
|
|
98
|
+
catch (error) { }
|
|
99
|
+
buerliApi.getState().api.removeDrawing(this.drawingId);
|
|
100
|
+
this._drawingId = undefined;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Creates a drawing, connects it to ClassCAD with a client from the factory given to {@link init}, and makes its
|
|
104
|
+
* `api` available.
|
|
105
|
+
*
|
|
106
|
+
* Rejects when the facade is connected already, when `init` has not been called, and when connecting fails: then
|
|
107
|
+
* with the error that kept the client from connecting (a token the key service refuses, an engine that cannot be
|
|
108
|
+
* reached), and the drawing it made is removed again.
|
|
109
|
+
*
|
|
110
|
+
* @param drawingName - The drawing's name in the store; by default `Drawing #<n>`.
|
|
111
|
+
* @returns The id of the new drawing.
|
|
112
|
+
*/
|
|
113
|
+
async connect(drawingName) {
|
|
114
|
+
if (this._drawingId) {
|
|
115
|
+
// Prefer throwing here since calling connect() twice should be considered a bug
|
|
116
|
+
throw new Error('Drawing already connected. Did you call connect() twice?');
|
|
117
|
+
}
|
|
118
|
+
assertFactory();
|
|
119
|
+
const drawing = await buerliApi.getState().api.createDrawing(drawingName);
|
|
120
|
+
try {
|
|
121
|
+
await connectClient(drawing.id);
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
// A drawing that did not connect leaves the store (its client is disconnected with it)
|
|
125
|
+
buerliApi.getState().api.removeDrawing(drawing.id);
|
|
126
|
+
throw error;
|
|
127
|
+
}
|
|
128
|
+
this._drawingId = drawing.id;
|
|
129
|
+
// Initialize the API with the drawingId, unwrap the API to get a more JS centric version
|
|
130
|
+
this._api = createUnwrappedApi(drawing.id);
|
|
131
|
+
return drawing.id;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Disconnects from ClassCAD. The drawing stays in the SDK's store, reset (without its model), and keeps its
|
|
135
|
+
* client; `api` is not available until {@link BuerliCadFacade.reconnect}.
|
|
136
|
+
*/
|
|
137
|
+
async disconnect() {
|
|
138
|
+
await _a.utils.disconnect(this.drawingId);
|
|
139
|
+
this._api = undefined;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Disconnects, connects the drawing's client again and recalculates the model (`v1.common.recalc`); then `api` is
|
|
143
|
+
* available again.
|
|
144
|
+
*/
|
|
145
|
+
async reconnect() {
|
|
146
|
+
await _a.utils.reconnect(this.drawingId);
|
|
147
|
+
// Initialize the API with the drawingId
|
|
148
|
+
this._api = createUnwrappedApi(this.drawingId);
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* The structure tree (id -> node) of the drawing, as held by the SDK's store.
|
|
152
|
+
* The tree is kept up to date by the regular structure broadcast; pass
|
|
153
|
+
* `refresh: true` to explicitly request it from ClassCAD first.
|
|
154
|
+
*
|
|
155
|
+
* @param opts - Options.
|
|
156
|
+
* @param opts.refresh - Loads the tree from ClassCAD before reading it.
|
|
157
|
+
* @returns The structure tree, keyed by object id.
|
|
158
|
+
* @example
|
|
159
|
+
* ```ts
|
|
160
|
+
* import { ccUtils, ScgClassType } from '@classcad/client'
|
|
161
|
+
*
|
|
162
|
+
* // The parts of a loaded model, by name
|
|
163
|
+
* const tree = await facade.tree({ refresh: true })
|
|
164
|
+
* const parts = Object.values(tree).filter(node => ccUtils.base.isA(node.class, ScgClassType.CCPart))
|
|
165
|
+
* const wheel = parts.find(node => node.name === 'Wheel')
|
|
166
|
+
* console.log(parts.map(node => node.name), wheel?.id)
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
169
|
+
async tree(opts) {
|
|
170
|
+
var _b, _c;
|
|
171
|
+
if (opts === null || opts === void 0 ? void 0 : opts.refresh) {
|
|
172
|
+
await _a.utils.fetchTree(this.drawingId);
|
|
173
|
+
}
|
|
174
|
+
return (_c = (_b = getDrawing(this.drawingId)) === null || _b === void 0 ? void 0 : _b.structure.tree) !== null && _c !== void 0 ? _c : {};
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* The current graphic (tessellation) of the drawing as `{ containers }`, as
|
|
178
|
+
* held by the SDK's store. Pass `recalc: true` to recalculate first.
|
|
179
|
+
*
|
|
180
|
+
* Note that graphic element ids are payload-local - they rotate on every
|
|
181
|
+
* re-tessellation. The stable join between graphic and structure tree is
|
|
182
|
+
* `container.owner === <CC_Solid id>`.
|
|
183
|
+
*
|
|
184
|
+
* @param opts - Options.
|
|
185
|
+
* @param opts.recalc - Recalculates the model before reading the graphic.
|
|
186
|
+
* @returns The graphic containers, or `null` if the drawing is not available.
|
|
187
|
+
* @example
|
|
188
|
+
* ```ts
|
|
189
|
+
* import * as THREE from 'three'
|
|
190
|
+
*
|
|
191
|
+
* // Frames the camera on the model: the bounds of every body
|
|
192
|
+
* const graphic = await facade.graphic()
|
|
193
|
+
* const bounds = new THREE.Box3()
|
|
194
|
+
* for (const container of graphic?.containers ?? []) {
|
|
195
|
+
* if (!container.meshes?.length) continue
|
|
196
|
+
* bounds.expandByPoint(new THREE.Vector3().fromArray(container.properties.min))
|
|
197
|
+
* bounds.expandByPoint(new THREE.Vector3().fromArray(container.properties.max))
|
|
198
|
+
* }
|
|
199
|
+
* const center = bounds.getCenter(new THREE.Vector3())
|
|
200
|
+
* const size = bounds.getSize(new THREE.Vector3()).length()
|
|
201
|
+
* camera.position.copy(center).add(new THREE.Vector3(0, -size, size))
|
|
202
|
+
* camera.lookAt(center)
|
|
203
|
+
* ```
|
|
204
|
+
*/
|
|
205
|
+
async graphic(opts) {
|
|
206
|
+
var _b;
|
|
207
|
+
if (opts === null || opts === void 0 ? void 0 : opts.recalc) {
|
|
208
|
+
await this.api.v1.common.recalc();
|
|
209
|
+
}
|
|
210
|
+
const containers = (_b = getDrawing(this.drawingId)) === null || _b === void 0 ? void 0 : _b.graphic.containers;
|
|
211
|
+
return containers ? { containers: Object.values(containers) } : null;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Creates the buffer geometry of any product (part or assembly).
|
|
215
|
+
*
|
|
216
|
+
* Each part, and each instance of a part in an assembly, becomes one geometry: its bodies merged, placed where it
|
|
217
|
+
* is in the model. Bodies the store has no graphic for yet are requested from ClassCAD first. Rejects when an id is
|
|
218
|
+
* not in the drawing's tree.
|
|
219
|
+
*
|
|
220
|
+
* @param objectId - The product, its instance or a solid; or several of them.
|
|
221
|
+
* @returns The geometries, or undefined when there is no id or nothing to show.
|
|
222
|
+
* @example
|
|
223
|
+
* ```ts
|
|
224
|
+
* import * as THREE from 'three'
|
|
225
|
+
*
|
|
226
|
+
* // A cylinder with diameter 20 and height 30, as a mesh of one's own
|
|
227
|
+
* const part = (await facade.api.v1.part.create({ name: 'Pin' }))!
|
|
228
|
+
* await facade.api.v1.part.cylinder({ id: part, diameter: 20, height: 30 })
|
|
229
|
+
* const [geometry] = (await facade.createBufferGeometry(part)) ?? []
|
|
230
|
+
* if (geometry) scene.add(new THREE.Mesh(geometry, new THREE.MeshStandardMaterial({ color: 'orange' })))
|
|
231
|
+
* ```
|
|
232
|
+
*/
|
|
233
|
+
async createBufferGeometry(objectId) {
|
|
234
|
+
if (!objectId)
|
|
235
|
+
return undefined;
|
|
236
|
+
const cDrawing = getDrawing(this.drawingId);
|
|
237
|
+
const structureTree = cDrawing.structure.tree;
|
|
238
|
+
const ids = Array.isArray(objectId) ? objectId : [objectId];
|
|
239
|
+
const bufferGeomArray = [];
|
|
240
|
+
for (const id of ids) {
|
|
241
|
+
const obj = structureTree[id];
|
|
242
|
+
if (obj) {
|
|
243
|
+
await createRecursiveBufferGeometry(obj, this.drawingId, bufferGeomArray);
|
|
244
|
+
}
|
|
245
|
+
else {
|
|
246
|
+
throw new Error('Object does not exist!');
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
if (bufferGeomArray.length > 0) {
|
|
250
|
+
return bufferGeomArray;
|
|
251
|
+
}
|
|
252
|
+
return undefined;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Creates the threeJS scene of any product (part or assembly).
|
|
256
|
+
*
|
|
257
|
+
* Assemblies and instances become groups placed as in the model, parts become groups of their bodies. A body is
|
|
258
|
+
* one mesh per color (`meshPerGeometry: false`, default) or one mesh per face. Bodies the store has no graphic
|
|
259
|
+
* for yet are requested from ClassCAD first. Rejects when an id is not in the drawing's tree.
|
|
260
|
+
*
|
|
261
|
+
* @param objectId - The product, its instance or a solid, or several of them; by default the drawing's root.
|
|
262
|
+
* @param options - Options.
|
|
263
|
+
* @param options.meshPerGeometry - Makes a mesh for each face (its `userData.id` is the face's graphic id) instead
|
|
264
|
+
* of merging a body's faces of one color into one mesh.
|
|
265
|
+
* @param options.structureOnly - Makes the nodes without geometry and materials.
|
|
266
|
+
* @returns The scene, its nodes and their materials.
|
|
267
|
+
* @example
|
|
268
|
+
* ```ts
|
|
269
|
+
* import * as THREE from 'three'
|
|
270
|
+
*
|
|
271
|
+
* // The whole assembly in a three.js scene, a node per instance
|
|
272
|
+
* const { scene: model, nodes } = await facade.createScene(assembly)
|
|
273
|
+
* scene.add(model)
|
|
274
|
+
* // The nodes by the id of the object they show, and by name
|
|
275
|
+
* nodes[`${wheel}`].rotation.z = Math.PI / 4
|
|
276
|
+
* ```
|
|
277
|
+
*/
|
|
278
|
+
async createScene(objectId, options) {
|
|
279
|
+
const cDrawing = getDrawing(this.drawingId);
|
|
280
|
+
const structureTree = cDrawing.structure.tree;
|
|
281
|
+
const ids = objectId ? (Array.isArray(objectId) ? objectId : [objectId]) : [cDrawing.structure.root];
|
|
282
|
+
const scene = new Scene();
|
|
283
|
+
const result = {
|
|
284
|
+
nodes: {},
|
|
285
|
+
materials: {},
|
|
286
|
+
};
|
|
287
|
+
for (const id of ids) {
|
|
288
|
+
const obj = structureTree[id];
|
|
289
|
+
if (obj) {
|
|
290
|
+
await createRecursiveScene(obj, this.drawingId, scene, result, options);
|
|
291
|
+
}
|
|
292
|
+
else {
|
|
293
|
+
throw new Error('Object does not exist!');
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
return Object.assign({ scene }, result);
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Adds the curves of a three.js `Shape` to a shape curve of the model, in one batch of API calls.
|
|
300
|
+
*
|
|
301
|
+
* Lines, arcs and ellipses, quadratic and cubic Bézier curves and splines (as interpolation curves) are added, in
|
|
302
|
+
* the XY plane; other curves and the shape's holes are not.
|
|
303
|
+
*
|
|
304
|
+
* @param owner - The shape curve, from `v1.curve.shape`.
|
|
305
|
+
* @param shape - The outline.
|
|
306
|
+
* @example
|
|
307
|
+
* ```ts
|
|
308
|
+
* import * as THREE from 'three'
|
|
309
|
+
*
|
|
310
|
+
* // A disc, extruded from a three.js outline
|
|
311
|
+
* const part = (await facade.api.v1.part.create({ name: 'Disc' }))!
|
|
312
|
+
* const ei = (await facade.api.v1.part.entityInjection({ id: part }))!
|
|
313
|
+
* const outline = new THREE.Shape()
|
|
314
|
+
* outline.absarc(0, 0, 40, 0, Math.PI * 2, false)
|
|
315
|
+
* const curve = (await facade.api.v1.curve.shape({ id: ei }))!
|
|
316
|
+
* await facade.createThreeShape(curve, outline)
|
|
317
|
+
* await facade.api.v1.solid.extrusion({ id: ei, curves: [curve], direction: [0, 0, 5] })
|
|
318
|
+
* ```
|
|
319
|
+
*/
|
|
320
|
+
async createThreeShape(owner, shape) {
|
|
321
|
+
const jobs = [];
|
|
322
|
+
for (const curve of shape.curves) {
|
|
323
|
+
switch (curve.type) {
|
|
324
|
+
case 'CubicBezierCurve':
|
|
325
|
+
const c1 = curve;
|
|
326
|
+
const p11 = [c1.v0.x, c1.v0.y, 0];
|
|
327
|
+
const p12 = [c1.v1.x, c1.v1.y, 0];
|
|
328
|
+
const p13 = [c1.v2.x, c1.v2.y, 0];
|
|
329
|
+
const p14 = [c1.v3.x, c1.v3.y, 0];
|
|
330
|
+
jobs.push({ api: 'v1/curve/bezierCurve', param: { id: owner, points: [p11, p12, p13, p14] } });
|
|
331
|
+
break;
|
|
332
|
+
case 'QuadraticBezierCurve':
|
|
333
|
+
const c2 = curve;
|
|
334
|
+
const p21 = [c2.v0.x, c2.v0.y, 0];
|
|
335
|
+
const p22 = [c2.v1.x, c2.v1.y, 0];
|
|
336
|
+
const p23 = [c2.v2.x, c2.v2.y, 0];
|
|
337
|
+
jobs.push({ api: 'v1/curve/bezierCurve', param: { id: owner, points: [p21, p22, p23] } });
|
|
338
|
+
break;
|
|
339
|
+
case 'LineCurve':
|
|
340
|
+
const c3 = curve;
|
|
341
|
+
const p31 = [c3.v1.x, c3.v1.y, 0];
|
|
342
|
+
const p32 = [c3.v2.x, c3.v2.y, 0];
|
|
343
|
+
jobs.push({ api: 'v1/curve/line', param: { id: owner, startPos: p31, endPos: p32 } });
|
|
344
|
+
break;
|
|
345
|
+
case 'SplineCurve':
|
|
346
|
+
const c4 = curve;
|
|
347
|
+
const p41 = c4.points.map((p) => [p.x, p.y, 0]);
|
|
348
|
+
jobs.push({ api: 'v1/curve/interpolationCurve', param: { id: owner, points: p41 } });
|
|
349
|
+
break;
|
|
350
|
+
case 'EllipseCurve':
|
|
351
|
+
case 'ArcCurve':
|
|
352
|
+
const c5 = curve;
|
|
353
|
+
jobs.push({
|
|
354
|
+
api: 'v1/curve/ellipticArc',
|
|
355
|
+
param: {
|
|
356
|
+
id: owner,
|
|
357
|
+
centerPos: [c5.aX, c5.aY, 0],
|
|
358
|
+
startAngle: c5.aStartAngle,
|
|
359
|
+
endAngle: c5.aEndAngle,
|
|
360
|
+
radius1: c5.xRadius,
|
|
361
|
+
radius2: c5.yRadius,
|
|
362
|
+
},
|
|
363
|
+
});
|
|
364
|
+
break;
|
|
365
|
+
default:
|
|
366
|
+
break;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
await this.api.common.batch({ jobs });
|
|
370
|
+
}
|
|
371
|
+
/**
|
|
372
|
+
* Adds a polyline through the given points to a shape curve of the model, its corners rounded where a radius is
|
|
373
|
+
* given (`v1.curve.polyline2d`).
|
|
374
|
+
*
|
|
375
|
+
* A corner with a radius above 0 becomes an arc of that radius. A corner whose arc does not fit between its
|
|
376
|
+
* neighbours is left out.
|
|
377
|
+
*
|
|
378
|
+
* @param owner - The shape curve, from `v1.curve.shape`.
|
|
379
|
+
* @param fPts - The corners, each with the radius to round it with (0 for a sharp corner).
|
|
380
|
+
* @param close - Closes the polyline. Default `true`.
|
|
381
|
+
* @example
|
|
382
|
+
* ```ts
|
|
383
|
+
* import * as THREE from 'three'
|
|
384
|
+
*
|
|
385
|
+
* // A plate with two rounded corners, extruded from a polyline
|
|
386
|
+
* const part = (await facade.api.v1.part.create({ name: 'Plate' }))!
|
|
387
|
+
* const ei = (await facade.api.v1.part.entityInjection({ id: part }))!
|
|
388
|
+
* const curve = (await facade.api.v1.curve.shape({ id: ei }))!
|
|
389
|
+
* await facade.createPolyline(curve, [
|
|
390
|
+
* { point: new THREE.Vector3(0, 0, 0), radius: 0 },
|
|
391
|
+
* { point: new THREE.Vector3(100, 0, 0), radius: 10 },
|
|
392
|
+
* { point: new THREE.Vector3(100, 50, 0), radius: 10 },
|
|
393
|
+
* { point: new THREE.Vector3(0, 50, 0), radius: 0 },
|
|
394
|
+
* ])
|
|
395
|
+
* await facade.api.v1.solid.extrusion({ id: ei, curves: [curve], direction: [0, 0, 8] })
|
|
396
|
+
* ```
|
|
397
|
+
*/
|
|
398
|
+
async createPolyline(owner, fPts, close = true) {
|
|
399
|
+
const newVertices = [];
|
|
400
|
+
const bulges = [];
|
|
401
|
+
for (let i = 0; i < fPts.length; i++) {
|
|
402
|
+
// if fillet point has radius, calculate fillet info, touchpoints and bulge
|
|
403
|
+
if (fPts[i].radius > 0) {
|
|
404
|
+
const j = i - 1 < 0 ? fPts.length - 1 : i - 1;
|
|
405
|
+
const k = i + 1 > fPts.length - 1 ? 0 : i + 1;
|
|
406
|
+
const filletInfo = {
|
|
407
|
+
control: fPts[i].point,
|
|
408
|
+
lineStarts: [fPts[i].point, fPts[i].point],
|
|
409
|
+
lineEnds: [fPts[j].point, fPts[k].point],
|
|
410
|
+
};
|
|
411
|
+
const touchPts = getTouchPoints(filletInfo, fPts[i].radius); // returns two points
|
|
412
|
+
if (touchPts != undefined && (touchPts === null || touchPts === void 0 ? void 0 : touchPts.length) > 0) {
|
|
413
|
+
const angle = getIncludingBulgeAngle(filletInfo);
|
|
414
|
+
const bulge = Math.tan(angle / 4);
|
|
415
|
+
newVertices.push(...touchPts);
|
|
416
|
+
bulges.push(bulge); // bulge for first point
|
|
417
|
+
bulges.push(0); // bulge for second point
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
else {
|
|
421
|
+
newVertices.push(fPts[i].point);
|
|
422
|
+
bulges.push(0);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
const points = newVertices.map(v => [v.x, v.y, v.z]);
|
|
426
|
+
await this.api.curve.polyline2d({ id: owner, points: points, bulges, close });
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Lets the user pick geometry of the given types in the 3D view, and resolves with what was picked.
|
|
430
|
+
*
|
|
431
|
+
* The drawing's geometry must be shown for selection, for example by `BuerliGeometry` of `@classcad/react` with
|
|
432
|
+
* `selection`. With a count it resolves once that many items are picked; with a function, that function is
|
|
433
|
+
* called at the first pick with one that ends the selection. Each item carries the picked element's ids, and in
|
|
434
|
+
* `userData` its geometry in world coordinates and its positions (`matchingPoints`).
|
|
435
|
+
*
|
|
436
|
+
* @param types - The kinds of geometry that can be picked.
|
|
437
|
+
* @param countOrResolver - How many items to pick (default 1), or a function that gets the function that ends the
|
|
438
|
+
* selection.
|
|
439
|
+
* @returns The picked items.
|
|
440
|
+
* @example
|
|
441
|
+
* ```ts
|
|
442
|
+
* import { ScgGraphicType } from '@classcad/client'
|
|
443
|
+
*
|
|
444
|
+
* // A box whose edges the user picks to round them; the drawing is shown with <BuerliGeometry selection />
|
|
445
|
+
* const part = (await facade.api.v1.part.create({ name: 'Block' }))!
|
|
446
|
+
* await facade.api.v1.part.box({ id: part, length: 60, width: 40, height: 20 })
|
|
447
|
+
* const edges = await facade.selectGeometry([ScgGraphicType.LINE, ScgGraphicType.ARC], 2)
|
|
448
|
+
* await facade.api.v1.part.fillet({ id: part, references: edges.map(edge => edge.graphicId!), radius: 4 })
|
|
449
|
+
* ```
|
|
450
|
+
* @example
|
|
451
|
+
* ```ts
|
|
452
|
+
* import { ScgGraphicType } from '@classcad/client'
|
|
453
|
+
*
|
|
454
|
+
* // As many faces as the user likes, until "Done"
|
|
455
|
+
* const faces = await facade.selectGeometry([ScgGraphicType.PLANE, ScgGraphicType.CYLINDER], finish => {
|
|
456
|
+
* doneButton.onclick = () => finish()
|
|
457
|
+
* })
|
|
458
|
+
* ```
|
|
459
|
+
*/
|
|
460
|
+
async selectGeometry(types, countOrResolver) {
|
|
461
|
+
const drId = this.drawingId;
|
|
462
|
+
const filter = (scope, data) => scope === BuerliScope && types.some(type => type === data);
|
|
463
|
+
let selections;
|
|
464
|
+
if (typeof countOrResolver === 'function') {
|
|
465
|
+
// Callback-based selection: user controls when to stop
|
|
466
|
+
let resolveSelectionFn = null;
|
|
467
|
+
let currentItems = [];
|
|
468
|
+
let isCallbackInvoked = false;
|
|
469
|
+
selections = (await waitForSelect(drId, Infinity, filter, (resolveSelection, items, diff) => {
|
|
470
|
+
// Store the resolve function and update current items on every change
|
|
471
|
+
resolveSelectionFn = resolveSelection;
|
|
472
|
+
currentItems = items;
|
|
473
|
+
// Invoke the user's resolver function only once, on the first call
|
|
474
|
+
if (!isCallbackInvoked) {
|
|
475
|
+
isCallbackInvoked = true;
|
|
476
|
+
countOrResolver(() => {
|
|
477
|
+
if (resolveSelectionFn) {
|
|
478
|
+
resolveSelectionFn(currentItems);
|
|
479
|
+
}
|
|
480
|
+
});
|
|
481
|
+
}
|
|
482
|
+
}));
|
|
483
|
+
}
|
|
484
|
+
else {
|
|
485
|
+
// Count-based selection: wait for exact count
|
|
486
|
+
const lCount = countOrResolver ? (countOrResolver < 1 ? 1 : countOrResolver) : 1;
|
|
487
|
+
selections = (await waitForSelect(drId, lCount, filter, (resolveSelection, items, diff) => {
|
|
488
|
+
if (items.length > lCount - 1) {
|
|
489
|
+
resolveSelection(items);
|
|
490
|
+
}
|
|
491
|
+
}));
|
|
492
|
+
}
|
|
493
|
+
const interactionInfos = [];
|
|
494
|
+
for (const selection of selections) {
|
|
495
|
+
// Get matching points from selected geometry and add to userData. TODO: Only if in part mode useful?
|
|
496
|
+
const points = (await this.api.part.getGeometryPositions({ elems: [selection.data.graphicId] }))[0].positions;
|
|
497
|
+
const matrix = getDrawing(drId).api.structure.calculateGlobalTransformation(selection.data.productId);
|
|
498
|
+
const clone = selection.data.geometry.clone().applyMatrix4(matrix);
|
|
499
|
+
// TODO: Should the transform code be moved to something else than Measure? It's helpful for more cases than just measuring.
|
|
500
|
+
const transformedData = Measure.transform([selection.data], drId)[0];
|
|
501
|
+
const interactionInfo = createInfo({
|
|
502
|
+
objectId: selection.data.container.ownerId,
|
|
503
|
+
prodRefId: selection.data.productId,
|
|
504
|
+
containerId: selection.data.container.id,
|
|
505
|
+
graphicId: selection.data.graphicId,
|
|
506
|
+
// objectPath: ?, TODO: Add path to the root in expanded tree, as soon as available
|
|
507
|
+
userData: Object.assign(Object.assign({}, transformedData), { geometry: clone, matchingPoints: points }),
|
|
508
|
+
});
|
|
509
|
+
interactionInfos.push(interactionInfo);
|
|
510
|
+
}
|
|
511
|
+
return interactionInfos;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
_a = BuerliCadFacade;
|
|
515
|
+
/**
|
|
516
|
+
* The facade's work for any drawing, by its id: connect, disconnect, undo, emission config, middleware commands.
|
|
517
|
+
*
|
|
518
|
+
* For drawings an app connects without a facade, and for the drawings of react-cad and Buerligons.
|
|
519
|
+
*/
|
|
520
|
+
BuerliCadFacade.utils = {
|
|
521
|
+
/**
|
|
522
|
+
* Creates a drawing and connects it: makes its client with the factory given to {@link init}, calls the
|
|
523
|
+
* {@link onClient} callbacks, connects the client.
|
|
524
|
+
*
|
|
525
|
+
* Rejects when `init` has not been called. When connecting fails, the error is logged and shown as a message,
|
|
526
|
+
* and it resolves to null.
|
|
527
|
+
*
|
|
528
|
+
* @param drawingName - The drawing's name in the store; by default `Drawing #<n>`.
|
|
529
|
+
* @returns The new drawing's id, or null when it could not connect.
|
|
530
|
+
*/
|
|
531
|
+
connect: async (drawingName) => {
|
|
532
|
+
assertFactory();
|
|
533
|
+
try {
|
|
534
|
+
const drawing = await buerliApi.getState().api.createDrawing(drawingName);
|
|
535
|
+
if (drawing) {
|
|
536
|
+
await connectClient(drawing.id);
|
|
537
|
+
return drawing.id;
|
|
538
|
+
}
|
|
539
|
+
return null;
|
|
540
|
+
}
|
|
541
|
+
catch (error) {
|
|
542
|
+
console.error(error);
|
|
543
|
+
showMessage({ type: 'error', text: `Connection to ClassCAD failed` });
|
|
544
|
+
return null;
|
|
545
|
+
}
|
|
546
|
+
},
|
|
547
|
+
/**
|
|
548
|
+
* Disconnects the drawing's client and resets the drawing: it stays in the store, without its model.
|
|
549
|
+
*
|
|
550
|
+
* Rejects when the drawing has no client.
|
|
551
|
+
*
|
|
552
|
+
* @param drawingId - The drawing.
|
|
553
|
+
*/
|
|
554
|
+
disconnect: async (drawingId) => {
|
|
555
|
+
const client = Globals.clientCache[drawingId];
|
|
556
|
+
if (!client) {
|
|
557
|
+
throw new Error("Client not ready. Did you create a valid cc drawing by calling 'createCCDrawing'?");
|
|
558
|
+
}
|
|
559
|
+
await client.disconnect();
|
|
560
|
+
getDrawing(drawingId).api.reset();
|
|
561
|
+
getDrawing(drawingId).api.cad.setConnected(false);
|
|
562
|
+
},
|
|
563
|
+
/**
|
|
564
|
+
* Disconnects the drawing, connects its client again and recalculates the model (`v1.common.recalc`).
|
|
565
|
+
*
|
|
566
|
+
* @param drawingId - The drawing.
|
|
567
|
+
*/
|
|
568
|
+
reconnect: async (drawingId) => {
|
|
569
|
+
await _a.utils.disconnect(drawingId);
|
|
570
|
+
await connect(drawingId);
|
|
571
|
+
await createUnwrappedApi(drawingId).v1.common.recalc();
|
|
572
|
+
},
|
|
573
|
+
/**
|
|
574
|
+
* Loads the drawing's structure tree from the engine into the store.
|
|
575
|
+
*
|
|
576
|
+
* @param drawingId - The drawing.
|
|
577
|
+
*/
|
|
578
|
+
fetchTree: async (drawingId) => {
|
|
579
|
+
const comClient = Globals.clientCache[drawingId];
|
|
580
|
+
await comClient.requestTree();
|
|
581
|
+
},
|
|
582
|
+
/**
|
|
583
|
+
* Effective per-connection emission config of the drawing's client (see {@link IComClient.getEmissionConfig}).
|
|
584
|
+
*
|
|
585
|
+
* @param drawingId - The drawing.
|
|
586
|
+
*/
|
|
587
|
+
getEmissionConfig: async (drawingId) => {
|
|
588
|
+
const comClient = Globals.clientCache[drawingId];
|
|
589
|
+
return comClient.getEmissionConfig();
|
|
590
|
+
},
|
|
591
|
+
/**
|
|
592
|
+
* Merges `partial` into the per-connection emission config and returns the effective flags.
|
|
593
|
+
*
|
|
594
|
+
* @param drawingId - The drawing.
|
|
595
|
+
* @param partial - The flags to change; the others stay as they are.
|
|
596
|
+
*/
|
|
597
|
+
setEmissionConfig: async (drawingId, partial) => {
|
|
598
|
+
const comClient = Globals.clientCache[drawingId];
|
|
599
|
+
return comClient.setEmissionConfig(partial);
|
|
600
|
+
},
|
|
601
|
+
/**
|
|
602
|
+
* Runs `fn` with a temporary emission config and restores the previous one
|
|
603
|
+
* afterwards (also when `fn` throws). This is the "own config for a
|
|
604
|
+
* script" pattern: e.g. switch every graphic category off while a script
|
|
605
|
+
* issues hundreds of commands, then restore the app's config and fetch
|
|
606
|
+
* tree + graphic once. On engines without GetEmissionConfig/SetEmissionConfig
|
|
607
|
+
* ({@link EMISSION_CONFIG_UNSUPPORTED}) `fn` simply runs with the fixed config.
|
|
608
|
+
*
|
|
609
|
+
* Only the flags in `partial` are restored. Resolves to what `fn` resolves to. {@link EmissionConfig} has an
|
|
610
|
+
* example.
|
|
611
|
+
*
|
|
612
|
+
* @param drawingId - The drawing.
|
|
613
|
+
* @param partial - The flags to change while `fn` runs, e.g. `{ sendGraphic_Kernel: false }`.
|
|
614
|
+
* @param fn - The work to do with them.
|
|
615
|
+
*/
|
|
616
|
+
withEmissionConfig: async (drawingId, partial, fn) => {
|
|
617
|
+
const comClient = Globals.clientCache[drawingId];
|
|
618
|
+
let previous = null;
|
|
619
|
+
try {
|
|
620
|
+
previous = await comClient.getEmissionConfig();
|
|
621
|
+
await comClient.setEmissionConfig(partial);
|
|
622
|
+
}
|
|
623
|
+
catch (e) {
|
|
624
|
+
if ((e === null || e === void 0 ? void 0 : e.name) !== EMISSION_CONFIG_UNSUPPORTED)
|
|
625
|
+
throw e;
|
|
626
|
+
previous = null;
|
|
627
|
+
}
|
|
628
|
+
try {
|
|
629
|
+
return await fn();
|
|
630
|
+
}
|
|
631
|
+
finally {
|
|
632
|
+
if (previous) {
|
|
633
|
+
// Restore only the flags we changed, taken from the previous snapshot.
|
|
634
|
+
const restore = {};
|
|
635
|
+
for (const key of Object.keys(partial)) {
|
|
636
|
+
;
|
|
637
|
+
restore[key] = previous[key];
|
|
638
|
+
}
|
|
639
|
+
await comClient.setEmissionConfig(restore);
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
},
|
|
643
|
+
/**
|
|
644
|
+
* Steps back in the drawing's undo history, to `state` when given ({@link AwvNodeClient.undo}).
|
|
645
|
+
*
|
|
646
|
+
* Messages of the engine are logged as warnings; an error is logged, not thrown.
|
|
647
|
+
*
|
|
648
|
+
* @param drawingId - The drawing.
|
|
649
|
+
* @param state - The state to go back to, a name from the drawing's `cad.states.stack`.
|
|
650
|
+
*/
|
|
651
|
+
undo: async (drawingId, state) => {
|
|
652
|
+
const comClient = Globals.clientCache[drawingId];
|
|
653
|
+
try {
|
|
654
|
+
const res = await comClient.undo({ state });
|
|
655
|
+
const errStr = (res.messages || [])
|
|
656
|
+
.map(e => `undo > State: ${e.level}, Code: ${e.code}, Message: ${e.message}`)
|
|
657
|
+
.join('\n');
|
|
658
|
+
if (errStr) {
|
|
659
|
+
console.warn(errStr);
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
catch (error) {
|
|
663
|
+
console.error(error);
|
|
664
|
+
}
|
|
665
|
+
},
|
|
666
|
+
/**
|
|
667
|
+
* Steps forward in the drawing's undo history, to `state` when given ({@link AwvNodeClient.redo}).
|
|
668
|
+
*
|
|
669
|
+
* Messages of the engine are logged as warnings; an error is logged, not thrown.
|
|
670
|
+
*
|
|
671
|
+
* @param drawingId - The drawing.
|
|
672
|
+
* @param state - The state to go forward to, a name from the drawing's `cad.states.stack`.
|
|
673
|
+
*/
|
|
674
|
+
redo: async (drawingId, state) => {
|
|
675
|
+
const comClient = Globals.clientCache[drawingId];
|
|
676
|
+
try {
|
|
677
|
+
const res = await comClient.redo({ state });
|
|
678
|
+
const errStr = (res.messages || [])
|
|
679
|
+
.map(e => `redo > State: ${e.level}, Code: ${e.code}, Message: ${e.message}`)
|
|
680
|
+
.join('\n');
|
|
681
|
+
if (errStr) {
|
|
682
|
+
console.warn(errStr);
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
catch (error) {
|
|
686
|
+
console.error(error);
|
|
687
|
+
}
|
|
688
|
+
},
|
|
689
|
+
/**
|
|
690
|
+
* Sends a command of the server's own ({@link AwvNodeClient.executeMiddleware}) and resolves to the reply.
|
|
691
|
+
*
|
|
692
|
+
* Messages of the reply are logged as warnings; on an error it is logged and the call resolves to undefined.
|
|
693
|
+
*
|
|
694
|
+
* @param drawingId - The drawing.
|
|
695
|
+
* @param middlewareCommand - The command's name.
|
|
696
|
+
* @param data - Fields sent along with the command.
|
|
697
|
+
*/
|
|
698
|
+
callMiddleware: async (drawingId, middlewareCommand, data) => {
|
|
699
|
+
const comClient = Globals.clientCache[drawingId];
|
|
700
|
+
try {
|
|
701
|
+
const res = await comClient.executeMiddleware(middlewareCommand, data);
|
|
702
|
+
const errStr = (res.messages || [])
|
|
703
|
+
.map(e => `${middlewareCommand} > Level: ${e.level}, Code: ${e.code}, Message: ${e.message}`)
|
|
704
|
+
.join('\n');
|
|
705
|
+
if (errStr) {
|
|
706
|
+
console.warn(errStr);
|
|
707
|
+
}
|
|
708
|
+
return res;
|
|
709
|
+
}
|
|
710
|
+
catch (error) {
|
|
711
|
+
console.error(error);
|
|
712
|
+
}
|
|
713
|
+
},
|
|
714
|
+
};
|