@classcad/client 3.0.0-beta.20261119090857 → 3.0.0-beta.20261120101705
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 +3 -3
- package/build/cjs/BuerliCadFacade.js +5 -5
- package/build/cjs/cclass/utils/index.js +1 -1
- package/build/cjs/classcadEngine.js +2 -2
- package/build/cjs/globals.js +9 -9
- package/build/cjs/index.js +2 -2
- package/build/cjs/io/AwvNodeClient.js +3 -3
- package/build/cjs/io/SocketIOClient.js +1 -1
- package/build/cjs/io/WSClient.js +1 -1
- package/build/cjs/session/selection.js +1 -1
- package/build/cjs/session/share.js +1 -1
- package/build/cjs/session/types.js +1 -1
- package/build/esm/BuerliCadFacade.js +5 -5
- package/build/esm/cclass/utils/index.js +1 -1
- package/build/esm/classcadEngine.js +2 -2
- package/build/esm/globals.js +9 -9
- package/build/esm/index.js +2 -2
- package/build/esm/io/AwvNodeClient.js +3 -3
- package/build/esm/io/SocketIOClient.js +1 -1
- package/build/esm/io/WSClient.js +1 -1
- package/build/esm/session/selection.js +1 -1
- package/build/esm/session/share.js +1 -1
- package/build/esm/session/types.js +1 -1
- package/build/types/BuerliCadFacade.d.ts +5 -5
- package/build/types/cclass/utils/index.d.ts +1 -1
- package/build/types/classcadEngine.d.ts +3 -3
- package/build/types/globals.d.ts +3 -3
- package/build/types/index.d.ts +2 -2
- package/build/types/io/AwvNodeClient.d.ts +4 -4
- package/build/types/io/SocketIOClient.d.ts +1 -1
- package/build/types/io/WSClient.d.ts +1 -1
- package/build/types/types/ComClient.d.ts +4 -4
- package/doc/api/advanced/connection.md +4 -4
- package/doc/api/clients.md +16 -16
- package/doc/api/engine-keys.md +1 -1
- package/doc/api/index.md +3 -3
- package/doc/api/modeling.md +7 -7
- package/doc/api/session-sharing.md +1 -1
- package/package.json +6 -5
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @classcad/client
|
|
2
2
|
|
|
3
|
-
Usage information and reference details can be found in the [
|
|
3
|
+
Usage information and reference details can be found in the [ClassCAD SDK documentation](https://sdkjs.classcad.ch/docs)
|
|
4
4
|
|
|
5
5
|
`@classcad/client` is completely implemented in Typescript and accordingly offers documented types for all interfaces.
|
|
6
6
|
|
|
@@ -15,7 +15,7 @@ Built against the ClassCAD engine 21.2.1-alpha.185 (alpha): the bundle at https:
|
|
|
15
15
|
|
|
16
16
|
### Links to our homepages and documentations
|
|
17
17
|
|
|
18
|
-
- [
|
|
19
|
-
- [
|
|
18
|
+
- [sdkjs.classcad.ch](https://sdkjs.classcad.ch)
|
|
19
|
+
- [modeler.classcad.ch](https://modeler.classcad.ch)
|
|
20
20
|
- [classcad.ch](https://classcad.ch)
|
|
21
21
|
- [awv-informatik.ch](https://awv-informatik.ch)
|
|
@@ -41,7 +41,7 @@ const assertFactory = () => {
|
|
|
41
41
|
/**
|
|
42
42
|
* A drawing connected to ClassCAD: its API, and helpers that turn the model into three.js objects.
|
|
43
43
|
*
|
|
44
|
-
* `connect()` creates a drawing in the
|
|
44
|
+
* `connect()` creates a drawing in the SDK's store and connects it with a client from the factory given to
|
|
45
45
|
* {@link init}. Then `api` is the drawing's ClassCAD API, unwrapped: `await api.v1.part.create(…)` resolves to the
|
|
46
46
|
* new part's id and rejects when the engine reports an error; warnings are logged. `createBufferGeometry` and
|
|
47
47
|
* `createScene` make three.js geometry of what was built, `tree` and `graphic` read the drawing as the store holds
|
|
@@ -89,7 +89,7 @@ class BuerliCadFacade {
|
|
|
89
89
|
return this._api;
|
|
90
90
|
}
|
|
91
91
|
/**
|
|
92
|
-
* Disconnects from ClassCAD and removes the drawing from the
|
|
92
|
+
* Disconnects from ClassCAD and removes the drawing from the SDK's store. The facade can `connect()` again.
|
|
93
93
|
*
|
|
94
94
|
* A failing disconnect does not keep the drawing from being removed.
|
|
95
95
|
*/
|
|
@@ -134,7 +134,7 @@ class BuerliCadFacade {
|
|
|
134
134
|
return drawing.id;
|
|
135
135
|
}
|
|
136
136
|
/**
|
|
137
|
-
* Disconnects from ClassCAD. The drawing stays in the
|
|
137
|
+
* Disconnects from ClassCAD. The drawing stays in the SDK's store, reset (without its model), and keeps its
|
|
138
138
|
* client; `api` is not available until {@link BuerliCadFacade.reconnect}.
|
|
139
139
|
*/
|
|
140
140
|
async disconnect() {
|
|
@@ -151,7 +151,7 @@ class BuerliCadFacade {
|
|
|
151
151
|
this._api = (0, createUnwrappedApi_1.createUnwrappedApi)(this.drawingId);
|
|
152
152
|
}
|
|
153
153
|
/**
|
|
154
|
-
* The structure tree (id -> node) of the drawing, as held by the
|
|
154
|
+
* The structure tree (id -> node) of the drawing, as held by the SDK's store.
|
|
155
155
|
* The tree is kept up to date by the regular structure broadcast; pass
|
|
156
156
|
* `refresh: true` to explicitly request it from ClassCAD first.
|
|
157
157
|
*
|
|
@@ -178,7 +178,7 @@ class BuerliCadFacade {
|
|
|
178
178
|
}
|
|
179
179
|
/**
|
|
180
180
|
* The current graphic (tessellation) of the drawing as `{ containers }`, as
|
|
181
|
-
* held by the
|
|
181
|
+
* held by the SDK's store. Pass `recalc: true` to recalculate first.
|
|
182
182
|
*
|
|
183
183
|
* Note that graphic element ids are payload-local - they rotate on every
|
|
184
184
|
* re-tessellation. The stable join between graphic and structure tree is
|
|
@@ -64,7 +64,7 @@ exports.getMessageTypeForErrors = getMessageTypeForErrors;
|
|
|
64
64
|
/**
|
|
65
65
|
* Helpers that look things up in a drawing's structure tree: classes, ancestors, work geometry, sketches, constraints.
|
|
66
66
|
*
|
|
67
|
-
* They read the tree in the
|
|
67
|
+
* They read the tree in the SDK's store; none of them calls the engine.
|
|
68
68
|
*
|
|
69
69
|
* @example
|
|
70
70
|
* ```ts
|
|
@@ -7,9 +7,9 @@ const url = `https://awvstatic.com/classcad/download/${api_js_1.CLASSCAD_VERSION
|
|
|
7
7
|
* The ClassCAD engine this package is built against: its version, its quality, and where its bundle is.
|
|
8
8
|
*
|
|
9
9
|
* `@classcad/api-js`, the ClassCAD API this package calls, is generated by the ClassCAD engine, and carries the
|
|
10
|
-
* version and the quality of the bundle it belongs to. That bundle is the engine this version of
|
|
10
|
+
* version and the quality of the bundle it belongs to. That bundle is the engine this version of the SDK is made
|
|
11
11
|
* for: {@link WASMClient} loads its WebAssembly from `wasmUrl`, and a host that runs the engine behind a server
|
|
12
|
-
* ({@link WSClient}, {@link SocketIOClient}) installs the same version, from `url`. A beta of
|
|
12
|
+
* ({@link WSClient}, {@link SocketIOClient}) installs the same version, from `url`. A beta of the SDK is built
|
|
13
13
|
* against an `alpha` build, a stable release against a `release`.
|
|
14
14
|
*
|
|
15
15
|
* `npx @classcad/client info` prints the same (`--json` for the object).
|
package/build/cjs/globals.js
CHANGED
|
@@ -8,16 +8,16 @@ class Globals {
|
|
|
8
8
|
exports.Globals = Globals;
|
|
9
9
|
Globals.clientCache = {};
|
|
10
10
|
/**
|
|
11
|
-
* Sets up
|
|
11
|
+
* Sets up the SDK: tells it how to reach ClassCAD, with a factory that makes the client for each drawing.
|
|
12
12
|
*
|
|
13
13
|
* Call it once, before the first drawing connects. Every drawing that connects afterwards
|
|
14
14
|
* ({@link BuerliCadFacade.connect}, `BuerliCadFacade.utils.connect`, react-cad, Buerligons) gets its client from
|
|
15
15
|
* `source`; the client connects right after it is made. Calling `init` again replaces the factory for the drawings
|
|
16
|
-
* that connect from then on. `options` go to the
|
|
16
|
+
* that connect from then on. `options` go to the SDK's store (`init` of `@classcad/sdkjs`).
|
|
17
17
|
*
|
|
18
18
|
* @param source - Makes the client for a drawing: called with the new drawing's id, returns a client that is not
|
|
19
19
|
* connected yet.
|
|
20
|
-
* @param options - Options of the
|
|
20
|
+
* @param options - Options of the SDK's store: theme colors, how geometry is shown (`config.geometry`), plugins.
|
|
21
21
|
* @example
|
|
22
22
|
* ```ts
|
|
23
23
|
* import { init, WASMClient } from '@classcad/client'
|
|
@@ -37,7 +37,7 @@ Globals.clientCache = {};
|
|
|
37
37
|
* @category Clients
|
|
38
38
|
*/
|
|
39
39
|
const init = (source, options) => {
|
|
40
|
-
// Make sure, the
|
|
40
|
+
// Make sure, the SDK core is initialized by calling initCore
|
|
41
41
|
(0, sdkjs_1.init)(options);
|
|
42
42
|
// Set the factory to the Globals object
|
|
43
43
|
Globals.factory = source;
|
|
@@ -92,9 +92,9 @@ const clientMade = (client, drawingId) => {
|
|
|
92
92
|
});
|
|
93
93
|
};
|
|
94
94
|
exports.clientMade = clientMade;
|
|
95
|
-
//#region
|
|
95
|
+
//#region SDK store subscription
|
|
96
96
|
/**
|
|
97
|
-
* Subscribe to the
|
|
97
|
+
* Subscribe to the SDK's store and observe the drawing id's.
|
|
98
98
|
*/
|
|
99
99
|
sdkjs_1.api.subscribe((state, prev) => {
|
|
100
100
|
if (state.drawing.ids !== prev.drawing.ids && state.drawing.ids) {
|
|
@@ -109,8 +109,8 @@ sdkjs_1.api.subscribe((state, prev) => {
|
|
|
109
109
|
});
|
|
110
110
|
const drawingSubscriptions = {};
|
|
111
111
|
/**
|
|
112
|
-
* Observe the drawing ids in the
|
|
113
|
-
* The callback will be called each time a drawing is added or removed from the
|
|
112
|
+
* Observe the drawing ids in the SDK's state.
|
|
113
|
+
* The callback will be called each time a drawing is added or removed from the SDK's state.
|
|
114
114
|
* Goal of this code is to call 'openFeature' and 'closeFeature' automatically if the active feature changes.
|
|
115
115
|
*/
|
|
116
116
|
sdkjs_1.api.subscribe((state, prev) => {
|
|
@@ -154,4 +154,4 @@ sdkjs_1.api.subscribe((state, prev) => {
|
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
156
|
});
|
|
157
|
-
//#endregion
|
|
157
|
+
//#endregion SDK store subscription
|
package/build/cjs/index.js
CHANGED
|
@@ -16,13 +16,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.onClient = exports.init = exports.getApiFacade = exports.createUnwrappedApi = exports.createApi = exports.SessionHost = void 0;
|
|
18
18
|
/**
|
|
19
|
-
* Connects an app to ClassCAD, the CAD engine, and runs the ClassCAD API on its drawings: the package every
|
|
19
|
+
* Connects an app to ClassCAD, the CAD engine, and runs the ClassCAD API on its drawings: the package every sdkjs
|
|
20
20
|
* app starts with. The engine runs in the browser as WebAssembly, or natively behind a server; a session can be
|
|
21
21
|
* shared with other apps and with AI agents.
|
|
22
22
|
*
|
|
23
23
|
* ## What it exposes
|
|
24
24
|
*
|
|
25
|
-
* - {@link init}: sets
|
|
25
|
+
* - {@link init}: sets the SDK up with a factory that makes the client of each drawing.
|
|
26
26
|
* - {@link WASMClient}: runs the engine in the browser, with a public access token (`ccpk_…`).
|
|
27
27
|
* - {@link WSClient}: connects to a native engine's own WebSocket server (`classcad-cli worker`).
|
|
28
28
|
* - {@link SocketIOClient}: connects to the ClassCAD server (`classcad-socketio`).
|
|
@@ -40,10 +40,10 @@ const unsupportedFromRejection = (e) => {
|
|
|
40
40
|
throw e;
|
|
41
41
|
};
|
|
42
42
|
/**
|
|
43
|
-
* The base of every client: what
|
|
43
|
+
* The base of every client: what the SDK asks of a connection to ClassCAD, and the session-sharing surface.
|
|
44
44
|
*
|
|
45
45
|
* An app makes a {@link WASMClient}, {@link WSClient} or {@link SocketIOClient} in the factory it gives {@link init};
|
|
46
|
-
*
|
|
46
|
+
* The SDK connects it and sends the drawing's API calls through it. A client that cannot share its session (the base
|
|
47
47
|
* class, {@link SocketIOClient}) has `shareKind` null and rejects `createInvite` with
|
|
48
48
|
* {@link SESSION_SHARING_UNSUPPORTED}.
|
|
49
49
|
*
|
|
@@ -273,7 +273,7 @@ class AwvNodeClient extends events_1.EventEmitter {
|
|
|
273
273
|
}
|
|
274
274
|
drawing.api.cad.setStates(frame.current ? Number.parseInt(frame.current, 10) : 0, frame.stack, captionMap);
|
|
275
275
|
}
|
|
276
|
-
/** Loads the drawing's structure tree from the engine and sets it in the
|
|
276
|
+
/** Loads the drawing's structure tree from the engine and sets it in the SDK's store. */
|
|
277
277
|
requestTree() {
|
|
278
278
|
return new Promise(async (resolve, reject) => {
|
|
279
279
|
try {
|
|
@@ -30,7 +30,7 @@ var SocketIOEvent;
|
|
|
30
30
|
SocketIOEvent["REDO"] = "redo";
|
|
31
31
|
})(SocketIOEvent || (exports.SocketIOEvent = SocketIOEvent = {}));
|
|
32
32
|
/**
|
|
33
|
-
* Connects
|
|
33
|
+
* Connects the SDK to a ClassCAD server (`classcad-socketio`) over Socket.IO.
|
|
34
34
|
*
|
|
35
35
|
* The server runs the engine and keeps the drawing's undo history, so `undo`, `redo` and `undoable` requests work
|
|
36
36
|
* with this client. It cannot share its session (`shareKind` is null). When the connection drops and comes back, the
|
package/build/cjs/io/WSClient.js
CHANGED
|
@@ -50,7 +50,7 @@ const DEFAULT_COMMAND_CONFIG = {
|
|
|
50
50
|
* - No Socket.IO envelopes, no BeginFrame/EndFrame wrapping
|
|
51
51
|
*/
|
|
52
52
|
/**
|
|
53
|
-
* Connects
|
|
53
|
+
* Connects the SDK to a native ClassCAD engine through the engine's own WebSocket server (`classcad-cli worker`).
|
|
54
54
|
*
|
|
55
55
|
* The server owns the session. Without an invite it creates one for this connection, which lasts as long as the
|
|
56
56
|
* connection; others join it with an invite from {@link WSClient.createInvite}, passed as `config.invite`. A URL
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
// the server keeps asks for nothing.
|
|
16
16
|
//
|
|
17
17
|
// `syncSelection(client)` does both for a drawing: it publishes the drawing's
|
|
18
|
-
// selection (interaction.selected in the
|
|
18
|
+
// selection (interaction.selected in the SDK's store) and selects what a peer
|
|
19
19
|
// asks for. Framework-free; the items carry the engine's own ids, so they mean
|
|
20
20
|
// the same in every app and in a script.
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -216,7 +216,7 @@ function subscribeSessionShare(drawingId, callback) {
|
|
|
216
216
|
};
|
|
217
217
|
attach();
|
|
218
218
|
// The client is created when the drawing connects (BuerliCadFacade.utils.connect)
|
|
219
|
-
// and dropped when the drawing goes away — both change the
|
|
219
|
+
// and dropped when the drawing goes away — both change the SDK's store, so a
|
|
220
220
|
// store subscription is enough to notice the client object changing.
|
|
221
221
|
const unsubStore = sdkjs_1.api.subscribe(() => attach());
|
|
222
222
|
return () => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// Session sharing — transport-independent types.
|
|
3
3
|
//
|
|
4
|
-
//
|
|
4
|
+
// An sdkjs app shares its CAD session by minting invite tokens; a guest —
|
|
5
5
|
// another app, or a ClassCAD MCP — joins with `?invite=<token>`. Who owns the
|
|
6
6
|
// session depends on where the engine runs:
|
|
7
7
|
// • a ClassCAD server (WSClient): the server does. Guests join on its URL.
|
|
@@ -38,7 +38,7 @@ const assertFactory = () => {
|
|
|
38
38
|
/**
|
|
39
39
|
* A drawing connected to ClassCAD: its API, and helpers that turn the model into three.js objects.
|
|
40
40
|
*
|
|
41
|
-
* `connect()` creates a drawing in the
|
|
41
|
+
* `connect()` creates a drawing in the SDK's store and connects it with a client from the factory given to
|
|
42
42
|
* {@link init}. Then `api` is the drawing's ClassCAD API, unwrapped: `await api.v1.part.create(…)` resolves to the
|
|
43
43
|
* new part's id and rejects when the engine reports an error; warnings are logged. `createBufferGeometry` and
|
|
44
44
|
* `createScene` make three.js geometry of what was built, `tree` and `graphic` read the drawing as the store holds
|
|
@@ -86,7 +86,7 @@ export class BuerliCadFacade {
|
|
|
86
86
|
return this._api;
|
|
87
87
|
}
|
|
88
88
|
/**
|
|
89
|
-
* Disconnects from ClassCAD and removes the drawing from the
|
|
89
|
+
* Disconnects from ClassCAD and removes the drawing from the SDK's store. The facade can `connect()` again.
|
|
90
90
|
*
|
|
91
91
|
* A failing disconnect does not keep the drawing from being removed.
|
|
92
92
|
*/
|
|
@@ -131,7 +131,7 @@ export class BuerliCadFacade {
|
|
|
131
131
|
return drawing.id;
|
|
132
132
|
}
|
|
133
133
|
/**
|
|
134
|
-
* Disconnects from ClassCAD. The drawing stays in the
|
|
134
|
+
* Disconnects from ClassCAD. The drawing stays in the SDK's store, reset (without its model), and keeps its
|
|
135
135
|
* client; `api` is not available until {@link BuerliCadFacade.reconnect}.
|
|
136
136
|
*/
|
|
137
137
|
async disconnect() {
|
|
@@ -148,7 +148,7 @@ export class BuerliCadFacade {
|
|
|
148
148
|
this._api = createUnwrappedApi(this.drawingId);
|
|
149
149
|
}
|
|
150
150
|
/**
|
|
151
|
-
* The structure tree (id -> node) of the drawing, as held by the
|
|
151
|
+
* The structure tree (id -> node) of the drawing, as held by the SDK's store.
|
|
152
152
|
* The tree is kept up to date by the regular structure broadcast; pass
|
|
153
153
|
* `refresh: true` to explicitly request it from ClassCAD first.
|
|
154
154
|
*
|
|
@@ -175,7 +175,7 @@ export class BuerliCadFacade {
|
|
|
175
175
|
}
|
|
176
176
|
/**
|
|
177
177
|
* The current graphic (tessellation) of the drawing as `{ containers }`, as
|
|
178
|
-
* held by the
|
|
178
|
+
* held by the SDK's store. Pass `recalc: true` to recalculate first.
|
|
179
179
|
*
|
|
180
180
|
* Note that graphic element ids are payload-local - they rotate on every
|
|
181
181
|
* re-tessellation. The stable join between graphic and structure tree is
|
|
@@ -27,7 +27,7 @@ export const getMessageTypeForErrors = (errors) => {
|
|
|
27
27
|
/**
|
|
28
28
|
* Helpers that look things up in a drawing's structure tree: classes, ancestors, work geometry, sketches, constraints.
|
|
29
29
|
*
|
|
30
|
-
* They read the tree in the
|
|
30
|
+
* They read the tree in the SDK's store; none of them calls the engine.
|
|
31
31
|
*
|
|
32
32
|
* @example
|
|
33
33
|
* ```ts
|
|
@@ -4,9 +4,9 @@ const url = `https://awvstatic.com/classcad/download/${CLASSCAD_VERSION_QUALITY}
|
|
|
4
4
|
* The ClassCAD engine this package is built against: its version, its quality, and where its bundle is.
|
|
5
5
|
*
|
|
6
6
|
* `@classcad/api-js`, the ClassCAD API this package calls, is generated by the ClassCAD engine, and carries the
|
|
7
|
-
* version and the quality of the bundle it belongs to. That bundle is the engine this version of
|
|
7
|
+
* version and the quality of the bundle it belongs to. That bundle is the engine this version of the SDK is made
|
|
8
8
|
* for: {@link WASMClient} loads its WebAssembly from `wasmUrl`, and a host that runs the engine behind a server
|
|
9
|
-
* ({@link WSClient}, {@link SocketIOClient}) installs the same version, from `url`. A beta of
|
|
9
|
+
* ({@link WSClient}, {@link SocketIOClient}) installs the same version, from `url`. A beta of the SDK is built
|
|
10
10
|
* against an `alpha` build, a stable release against a `release`.
|
|
11
11
|
*
|
|
12
12
|
* `npx @classcad/client info` prints the same (`--json` for the object).
|
package/build/esm/globals.js
CHANGED
|
@@ -4,16 +4,16 @@ export class Globals {
|
|
|
4
4
|
}
|
|
5
5
|
Globals.clientCache = {};
|
|
6
6
|
/**
|
|
7
|
-
* Sets up
|
|
7
|
+
* Sets up the SDK: tells it how to reach ClassCAD, with a factory that makes the client for each drawing.
|
|
8
8
|
*
|
|
9
9
|
* Call it once, before the first drawing connects. Every drawing that connects afterwards
|
|
10
10
|
* ({@link BuerliCadFacade.connect}, `BuerliCadFacade.utils.connect`, react-cad, Buerligons) gets its client from
|
|
11
11
|
* `source`; the client connects right after it is made. Calling `init` again replaces the factory for the drawings
|
|
12
|
-
* that connect from then on. `options` go to the
|
|
12
|
+
* that connect from then on. `options` go to the SDK's store (`init` of `@classcad/sdkjs`).
|
|
13
13
|
*
|
|
14
14
|
* @param source - Makes the client for a drawing: called with the new drawing's id, returns a client that is not
|
|
15
15
|
* connected yet.
|
|
16
|
-
* @param options - Options of the
|
|
16
|
+
* @param options - Options of the SDK's store: theme colors, how geometry is shown (`config.geometry`), plugins.
|
|
17
17
|
* @example
|
|
18
18
|
* ```ts
|
|
19
19
|
* import { init, WASMClient } from '@classcad/client'
|
|
@@ -33,7 +33,7 @@ Globals.clientCache = {};
|
|
|
33
33
|
* @category Clients
|
|
34
34
|
*/
|
|
35
35
|
export const init = (source, options) => {
|
|
36
|
-
// Make sure, the
|
|
36
|
+
// Make sure, the SDK core is initialized by calling initCore
|
|
37
37
|
initCore(options);
|
|
38
38
|
// Set the factory to the Globals object
|
|
39
39
|
Globals.factory = source;
|
|
@@ -85,9 +85,9 @@ export const clientMade = (client, drawingId) => {
|
|
|
85
85
|
}
|
|
86
86
|
});
|
|
87
87
|
};
|
|
88
|
-
//#region
|
|
88
|
+
//#region SDK store subscription
|
|
89
89
|
/**
|
|
90
|
-
* Subscribe to the
|
|
90
|
+
* Subscribe to the SDK's store and observe the drawing id's.
|
|
91
91
|
*/
|
|
92
92
|
buerliApi.subscribe((state, prev) => {
|
|
93
93
|
if (state.drawing.ids !== prev.drawing.ids && state.drawing.ids) {
|
|
@@ -102,8 +102,8 @@ buerliApi.subscribe((state, prev) => {
|
|
|
102
102
|
});
|
|
103
103
|
const drawingSubscriptions = {};
|
|
104
104
|
/**
|
|
105
|
-
* Observe the drawing ids in the
|
|
106
|
-
* The callback will be called each time a drawing is added or removed from the
|
|
105
|
+
* Observe the drawing ids in the SDK's state.
|
|
106
|
+
* The callback will be called each time a drawing is added or removed from the SDK's state.
|
|
107
107
|
* Goal of this code is to call 'openFeature' and 'closeFeature' automatically if the active feature changes.
|
|
108
108
|
*/
|
|
109
109
|
buerliApi.subscribe((state, prev) => {
|
|
@@ -147,4 +147,4 @@ buerliApi.subscribe((state, prev) => {
|
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
});
|
|
150
|
-
//#endregion
|
|
150
|
+
//#endregion SDK store subscription
|
package/build/esm/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Connects an app to ClassCAD, the CAD engine, and runs the ClassCAD API on its drawings: the package every
|
|
2
|
+
* Connects an app to ClassCAD, the CAD engine, and runs the ClassCAD API on its drawings: the package every sdkjs
|
|
3
3
|
* app starts with. The engine runs in the browser as WebAssembly, or natively behind a server; a session can be
|
|
4
4
|
* shared with other apps and with AI agents.
|
|
5
5
|
*
|
|
6
6
|
* ## What it exposes
|
|
7
7
|
*
|
|
8
|
-
* - {@link init}: sets
|
|
8
|
+
* - {@link init}: sets the SDK up with a factory that makes the client of each drawing.
|
|
9
9
|
* - {@link WASMClient}: runs the engine in the browser, with a public access token (`ccpk_…`).
|
|
10
10
|
* - {@link WSClient}: connects to a native engine's own WebSocket server (`classcad-cli worker`).
|
|
11
11
|
* - {@link SocketIOClient}: connects to the ClassCAD server (`classcad-socketio`).
|
|
@@ -37,10 +37,10 @@ const unsupportedFromRejection = (e) => {
|
|
|
37
37
|
throw e;
|
|
38
38
|
};
|
|
39
39
|
/**
|
|
40
|
-
* The base of every client: what
|
|
40
|
+
* The base of every client: what the SDK asks of a connection to ClassCAD, and the session-sharing surface.
|
|
41
41
|
*
|
|
42
42
|
* An app makes a {@link WASMClient}, {@link WSClient} or {@link SocketIOClient} in the factory it gives {@link init};
|
|
43
|
-
*
|
|
43
|
+
* The SDK connects it and sends the drawing's API calls through it. A client that cannot share its session (the base
|
|
44
44
|
* class, {@link SocketIOClient}) has `shareKind` null and rejects `createInvite` with
|
|
45
45
|
* {@link SESSION_SHARING_UNSUPPORTED}.
|
|
46
46
|
*
|
|
@@ -270,7 +270,7 @@ export class AwvNodeClient extends EventEmitter {
|
|
|
270
270
|
}
|
|
271
271
|
drawing.api.cad.setStates(frame.current ? Number.parseInt(frame.current, 10) : 0, frame.stack, captionMap);
|
|
272
272
|
}
|
|
273
|
-
/** Loads the drawing's structure tree from the engine and sets it in the
|
|
273
|
+
/** Loads the drawing's structure tree from the engine and sets it in the SDK's store. */
|
|
274
274
|
requestTree() {
|
|
275
275
|
return new Promise(async (resolve, reject) => {
|
|
276
276
|
try {
|
|
@@ -24,7 +24,7 @@ export var SocketIOEvent;
|
|
|
24
24
|
SocketIOEvent["REDO"] = "redo";
|
|
25
25
|
})(SocketIOEvent || (SocketIOEvent = {}));
|
|
26
26
|
/**
|
|
27
|
-
* Connects
|
|
27
|
+
* Connects the SDK to a ClassCAD server (`classcad-socketio`) over Socket.IO.
|
|
28
28
|
*
|
|
29
29
|
* The server runs the engine and keeps the drawing's undo history, so `undo`, `redo` and `undoable` requests work
|
|
30
30
|
* with this client. It cannot share its session (`shareKind` is null). When the connection drops and comes back, the
|
package/build/esm/io/WSClient.js
CHANGED
|
@@ -47,7 +47,7 @@ const DEFAULT_COMMAND_CONFIG = {
|
|
|
47
47
|
* - No Socket.IO envelopes, no BeginFrame/EndFrame wrapping
|
|
48
48
|
*/
|
|
49
49
|
/**
|
|
50
|
-
* Connects
|
|
50
|
+
* Connects the SDK to a native ClassCAD engine through the engine's own WebSocket server (`classcad-cli worker`).
|
|
51
51
|
*
|
|
52
52
|
* The server owns the session. Without an invite it creates one for this connection, which lasts as long as the
|
|
53
53
|
* connection; others join it with an invite from {@link WSClient.createInvite}, passed as `config.invite`. A URL
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
// the server keeps asks for nothing.
|
|
15
15
|
//
|
|
16
16
|
// `syncSelection(client)` does both for a drawing: it publishes the drawing's
|
|
17
|
-
// selection (interaction.selected in the
|
|
17
|
+
// selection (interaction.selected in the SDK's store) and selects what a peer
|
|
18
18
|
// asks for. Framework-free; the items carry the engine's own ids, so they mean
|
|
19
19
|
// the same in every app and in a script.
|
|
20
20
|
import { api as buerliApi, createInfo, getDrawing } from '@classcad/sdkjs';
|
|
@@ -208,7 +208,7 @@ export function subscribeSessionShare(drawingId, callback) {
|
|
|
208
208
|
};
|
|
209
209
|
attach();
|
|
210
210
|
// The client is created when the drawing connects (BuerliCadFacade.utils.connect)
|
|
211
|
-
// and dropped when the drawing goes away — both change the
|
|
211
|
+
// and dropped when the drawing goes away — both change the SDK's store, so a
|
|
212
212
|
// store subscription is enough to notice the client object changing.
|
|
213
213
|
const unsubStore = buerliApi.subscribe(() => attach());
|
|
214
214
|
return () => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Session sharing — transport-independent types.
|
|
2
2
|
//
|
|
3
|
-
//
|
|
3
|
+
// An sdkjs app shares its CAD session by minting invite tokens; a guest —
|
|
4
4
|
// another app, or a ClassCAD MCP — joins with `?invite=<token>`. Who owns the
|
|
5
5
|
// session depends on where the engine runs:
|
|
6
6
|
// • a ClassCAD server (WSClient): the server does. Guests join on its URL.
|
|
@@ -40,7 +40,7 @@ export type ClassCADApi = UnwrappedApiType;
|
|
|
40
40
|
/**
|
|
41
41
|
* A drawing connected to ClassCAD: its API, and helpers that turn the model into three.js objects.
|
|
42
42
|
*
|
|
43
|
-
* `connect()` creates a drawing in the
|
|
43
|
+
* `connect()` creates a drawing in the SDK's store and connects it with a client from the factory given to
|
|
44
44
|
* {@link init}. Then `api` is the drawing's ClassCAD API, unwrapped: `await api.v1.part.create(…)` resolves to the
|
|
45
45
|
* new part's id and rejects when the engine reports an error; warnings are logged. `createBufferGeometry` and
|
|
46
46
|
* `createScene` make three.js geometry of what was built, `tree` and `graphic` read the drawing as the store holds
|
|
@@ -175,7 +175,7 @@ export declare class BuerliCadFacade {
|
|
|
175
175
|
*/
|
|
176
176
|
get api(): ClassCADApi;
|
|
177
177
|
/**
|
|
178
|
-
* Disconnects from ClassCAD and removes the drawing from the
|
|
178
|
+
* Disconnects from ClassCAD and removes the drawing from the SDK's store. The facade can `connect()` again.
|
|
179
179
|
*
|
|
180
180
|
* A failing disconnect does not keep the drawing from being removed.
|
|
181
181
|
*/
|
|
@@ -193,7 +193,7 @@ export declare class BuerliCadFacade {
|
|
|
193
193
|
*/
|
|
194
194
|
connect(drawingName?: string): Promise<DrawingID>;
|
|
195
195
|
/**
|
|
196
|
-
* Disconnects from ClassCAD. The drawing stays in the
|
|
196
|
+
* Disconnects from ClassCAD. The drawing stays in the SDK's store, reset (without its model), and keeps its
|
|
197
197
|
* client; `api` is not available until {@link BuerliCadFacade.reconnect}.
|
|
198
198
|
*/
|
|
199
199
|
disconnect(): Promise<void>;
|
|
@@ -203,7 +203,7 @@ export declare class BuerliCadFacade {
|
|
|
203
203
|
*/
|
|
204
204
|
reconnect(): Promise<void>;
|
|
205
205
|
/**
|
|
206
|
-
* The structure tree (id -> node) of the drawing, as held by the
|
|
206
|
+
* The structure tree (id -> node) of the drawing, as held by the SDK's store.
|
|
207
207
|
* The tree is kept up to date by the regular structure broadcast; pass
|
|
208
208
|
* `refresh: true` to explicitly request it from ClassCAD first.
|
|
209
209
|
*
|
|
@@ -226,7 +226,7 @@ export declare class BuerliCadFacade {
|
|
|
226
226
|
}): Promise<ScgTree>;
|
|
227
227
|
/**
|
|
228
228
|
* The current graphic (tessellation) of the drawing as `{ containers }`, as
|
|
229
|
-
* held by the
|
|
229
|
+
* held by the SDK's store. Pass `recalc: true` to recalculate first.
|
|
230
230
|
*
|
|
231
231
|
* Note that graphic element ids are payload-local - they rotate on every
|
|
232
232
|
* re-tessellation. The stable join between graphic and structure tree is
|
|
@@ -11,7 +11,7 @@ export declare const getMessageTypeForErrors: (errors: ServerError[]) => "error"
|
|
|
11
11
|
/**
|
|
12
12
|
* Helpers that look things up in a drawing's structure tree: classes, ancestors, work geometry, sketches, constraints.
|
|
13
13
|
*
|
|
14
|
-
* They read the tree in the
|
|
14
|
+
* They read the tree in the SDK's store; none of them calls the engine.
|
|
15
15
|
*
|
|
16
16
|
* @example
|
|
17
17
|
* ```ts
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
export type ClassCadEngine = {
|
|
7
7
|
/** The ClassCAD version: `21.2.0`, or `21.2.1-alpha.169`. */
|
|
8
8
|
readonly version: string;
|
|
9
|
-
/** `release`, `alpha` (what a beta of
|
|
9
|
+
/** `release`, `alpha` (what a beta of the SDK is built against) or `dev` (a feature branch). */
|
|
10
10
|
readonly quality: string;
|
|
11
11
|
/** The bundle on awvstatic.com: the engine for every platform, the server, the API packages. */
|
|
12
12
|
readonly url: string;
|
|
@@ -21,9 +21,9 @@ export type ClassCadEngine = {
|
|
|
21
21
|
* The ClassCAD engine this package is built against: its version, its quality, and where its bundle is.
|
|
22
22
|
*
|
|
23
23
|
* `@classcad/api-js`, the ClassCAD API this package calls, is generated by the ClassCAD engine, and carries the
|
|
24
|
-
* version and the quality of the bundle it belongs to. That bundle is the engine this version of
|
|
24
|
+
* version and the quality of the bundle it belongs to. That bundle is the engine this version of the SDK is made
|
|
25
25
|
* for: {@link WASMClient} loads its WebAssembly from `wasmUrl`, and a host that runs the engine behind a server
|
|
26
|
-
* ({@link WSClient}, {@link SocketIOClient}) installs the same version, from `url`. A beta of
|
|
26
|
+
* ({@link WSClient}, {@link SocketIOClient}) installs the same version, from `url`. A beta of the SDK is built
|
|
27
27
|
* against an `alpha` build, a stable release against a `release`.
|
|
28
28
|
*
|
|
29
29
|
* `npx @classcad/client info` prints the same (`--json` for the object).
|
package/build/types/globals.d.ts
CHANGED
|
@@ -12,16 +12,16 @@ export declare class Globals {
|
|
|
12
12
|
static clientCache: Record<DrawingID, AwvNodeClient>;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
* Sets up
|
|
15
|
+
* Sets up the SDK: tells it how to reach ClassCAD, with a factory that makes the client for each drawing.
|
|
16
16
|
*
|
|
17
17
|
* Call it once, before the first drawing connects. Every drawing that connects afterwards
|
|
18
18
|
* ({@link BuerliCadFacade.connect}, `BuerliCadFacade.utils.connect`, react-cad, Buerligons) gets its client from
|
|
19
19
|
* `source`; the client connects right after it is made. Calling `init` again replaces the factory for the drawings
|
|
20
|
-
* that connect from then on. `options` go to the
|
|
20
|
+
* that connect from then on. `options` go to the SDK's store (`init` of `@classcad/sdkjs`).
|
|
21
21
|
*
|
|
22
22
|
* @param source - Makes the client for a drawing: called with the new drawing's id, returns a client that is not
|
|
23
23
|
* connected yet.
|
|
24
|
-
* @param options - Options of the
|
|
24
|
+
* @param options - Options of the SDK's store: theme colors, how geometry is shown (`config.geometry`), plugins.
|
|
25
25
|
* @example
|
|
26
26
|
* ```ts
|
|
27
27
|
* import { init, WASMClient } from '@classcad/client'
|
package/build/types/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Connects an app to ClassCAD, the CAD engine, and runs the ClassCAD API on its drawings: the package every
|
|
2
|
+
* Connects an app to ClassCAD, the CAD engine, and runs the ClassCAD API on its drawings: the package every sdkjs
|
|
3
3
|
* app starts with. The engine runs in the browser as WebAssembly, or natively behind a server; a session can be
|
|
4
4
|
* shared with other apps and with AI agents.
|
|
5
5
|
*
|
|
6
6
|
* ## What it exposes
|
|
7
7
|
*
|
|
8
|
-
* - {@link init}: sets
|
|
8
|
+
* - {@link init}: sets the SDK up with a factory that makes the client of each drawing.
|
|
9
9
|
* - {@link WASMClient}: runs the engine in the browser, with a public access token (`ccpk_…`).
|
|
10
10
|
* - {@link WSClient}: connects to a native engine's own WebSocket server (`classcad-cli worker`).
|
|
11
11
|
* - {@link SocketIOClient}: connects to the ClassCAD server (`classcad-socketio`).
|
|
@@ -4,10 +4,10 @@ import { EmissionConfig, IComClient, RedoOptions, RequestOptions, ServerRequest,
|
|
|
4
4
|
import { PresenceMessage, SessionInvite, SessionPeer, SessionRole, ShareKind } from '../session/types';
|
|
5
5
|
import { ClientIdentity } from '../session/identity';
|
|
6
6
|
/**
|
|
7
|
-
* The base of every client: what
|
|
7
|
+
* The base of every client: what the SDK asks of a connection to ClassCAD, and the session-sharing surface.
|
|
8
8
|
*
|
|
9
9
|
* An app makes a {@link WASMClient}, {@link WSClient} or {@link SocketIOClient} in the factory it gives {@link init};
|
|
10
|
-
*
|
|
10
|
+
* The SDK connects it and sends the drawing's API calls through it. A client that cannot share its session (the base
|
|
11
11
|
* class, {@link SocketIOClient}) has `shareKind` null and rejects `createInvite` with
|
|
12
12
|
* {@link SESSION_SHARING_UNSUPPORTED}.
|
|
13
13
|
*
|
|
@@ -106,7 +106,7 @@ export declare abstract class AwvNodeClient extends EventEmitter implements ICom
|
|
|
106
106
|
/** The drawing this client serves. */
|
|
107
107
|
get drawingId(): DrawingID;
|
|
108
108
|
/**
|
|
109
|
-
* Connects to the engine.
|
|
109
|
+
* Connects to the engine. The SDK calls it when the drawing connects; it resolves once the drawing's structure tree
|
|
110
110
|
* is loaded and API calls can be made.
|
|
111
111
|
*/
|
|
112
112
|
abstract connect(): Promise<AwvNodeClient>;
|
|
@@ -177,6 +177,6 @@ export declare abstract class AwvNodeClient extends EventEmitter implements ICom
|
|
|
177
177
|
* an undoable command, so every state is undoable.
|
|
178
178
|
*/
|
|
179
179
|
protected applyUndoStack(frame: UndoStackFrame): void;
|
|
180
|
-
/** Loads the drawing's structure tree from the engine and sets it in the
|
|
180
|
+
/** Loads the drawing's structure tree from the engine and sets it in the SDK's store. */
|
|
181
181
|
requestTree(): Promise<ServerResponse>;
|
|
182
182
|
}
|
|
@@ -19,7 +19,7 @@ export declare enum SocketIOEvent {
|
|
|
19
19
|
REDO = "redo"
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
|
-
* Connects
|
|
22
|
+
* Connects the SDK to a ClassCAD server (`classcad-socketio`) over Socket.IO.
|
|
23
23
|
*
|
|
24
24
|
* The server runs the engine and keeps the drawing's undo history, so `undo`, `redo` and `undoable` requests work
|
|
25
25
|
* with this client. It cannot share its session (`shareKind` is null). When the connection drops and comes back, the
|
|
@@ -52,7 +52,7 @@ export type WSClientConfig = {
|
|
|
52
52
|
commandConfig?: Partial<EmissionConfig>;
|
|
53
53
|
};
|
|
54
54
|
/**
|
|
55
|
-
* Connects
|
|
55
|
+
* Connects the SDK to a native ClassCAD engine through the engine's own WebSocket server (`classcad-cli worker`).
|
|
56
56
|
*
|
|
57
57
|
* The server owns the session. Without an invite it creates one for this connection, which lasts as long as the
|
|
58
58
|
* connection; others join it with an invite from {@link WSClient.createInvite}, passed as `config.invite`. A URL
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IStructureProtocol, Message } from '../re-export';
|
|
2
2
|
/**
|
|
3
|
-
* What a client does for
|
|
3
|
+
* What a client does for the SDK: connect a drawing to an engine, run commands on it and load its structure.
|
|
4
4
|
*
|
|
5
5
|
* {@link AwvNodeClient} implements it; the clients ({@link WASMClient}, {@link WSClient}, {@link SocketIOClient})
|
|
6
6
|
* extend that.
|
|
@@ -13,7 +13,7 @@ export interface IComClient {
|
|
|
13
13
|
connect(): Promise<IComClient>;
|
|
14
14
|
/** Closes the connection to the engine. */
|
|
15
15
|
disconnect(): Promise<IComClient>;
|
|
16
|
-
/** Loads the drawing's structure tree from the engine into the
|
|
16
|
+
/** Loads the drawing's structure tree from the engine into the SDK's store. */
|
|
17
17
|
requestTree(): Response;
|
|
18
18
|
/**
|
|
19
19
|
* Runs `task` (API calls) on the engine. Rejects with the reply when it carries an error.
|
|
@@ -113,9 +113,9 @@ export type EmissionConfig = {
|
|
|
113
113
|
sendGraphic_ImmediatelyBinary: boolean;
|
|
114
114
|
/** Send one graphic package per changed object instead of one for all of them. */
|
|
115
115
|
sendGraphic_Multipackage: boolean;
|
|
116
|
-
/** Compress meshes with Draco.
|
|
116
|
+
/** Compress meshes with Draco. the SDK's clients do not decode it. */
|
|
117
117
|
sendGraphic_UseDraco: boolean;
|
|
118
|
-
/** Compress meshes with Draco in its hybrid form.
|
|
118
|
+
/** Compress meshes with Draco in its hybrid form. the SDK's clients do not decode it. */
|
|
119
119
|
sendGraphic_UseDracoHybrid: boolean;
|
|
120
120
|
/** Also send graphic when objects were only moved or changed their material. */
|
|
121
121
|
sendGraphic_AdvancedNotifications: boolean;
|
|
@@ -81,8 +81,8 @@ await BuerliCadFacade.utils.fetchTree(facade.drawingId)
|
|
|
81
81
|
| <a id="property-sendgraphic_multipackage"></a> `sendGraphic_Multipackage` | `boolean` | Send one graphic package per changed object instead of one for all of them. |
|
|
82
82
|
| <a id="property-sendgraphic_sketch"></a> `sendGraphic_Sketch` | `boolean` | Send the graphic of sketches. |
|
|
83
83
|
| <a id="property-sendgraphic_structureobj"></a> `sendGraphic_StructureObj` | `boolean` | Send the graphic of model objects that are not bodies, such as work geometry. |
|
|
84
|
-
| <a id="property-sendgraphic_usedraco"></a> `sendGraphic_UseDraco` | `boolean` | Compress meshes with Draco.
|
|
85
|
-
| <a id="property-sendgraphic_usedracohybrid"></a> `sendGraphic_UseDracoHybrid` | `boolean` | Compress meshes with Draco in its hybrid form.
|
|
84
|
+
| <a id="property-sendgraphic_usedraco"></a> `sendGraphic_UseDraco` | `boolean` | Compress meshes with Draco. the SDK's clients do not decode it. |
|
|
85
|
+
| <a id="property-sendgraphic_usedracohybrid"></a> `sendGraphic_UseDracoHybrid` | `boolean` | Compress meshes with Draco in its hybrid form. the SDK's clients do not decode it. |
|
|
86
86
|
| <a id="property-sendmessages"></a> `sendMessages` | `boolean` | Send the messages (warnings, errors) of a command. |
|
|
87
87
|
| <a id="property-sendmessages_immediately"></a> `sendMessages_Immediately` | `boolean` | Send messages in frames of their own while the command runs, instead of on its Result. |
|
|
88
88
|
| <a id="property-sendmessages_minlevel"></a> `sendMessages_MinLevel` | `number` | The lowest level of message that is sent (a `MessageLevel`, 31 = info). |
|
|
@@ -97,7 +97,7 @@ await BuerliCadFacade.utils.fetchTree(facade.drawingId)
|
|
|
97
97
|
|
|
98
98
|
### IComClient {#icomclient}
|
|
99
99
|
|
|
100
|
-
What a client does for
|
|
100
|
+
What a client does for the SDK: connect a drawing to an engine, run commands on it and load its structure.
|
|
101
101
|
|
|
102
102
|
[AwvNodeClient](../clients.md#abstract-awvnodeclient) implements it; the clients ([WASMClient](../clients.md#wasmclient), [WSClient](../clients.md#wsclient), [SocketIOClient](../clients.md#socketioclient))
|
|
103
103
|
extend that.
|
|
@@ -224,7 +224,7 @@ requestTree(): {
|
|
|
224
224
|
};
|
|
225
225
|
```
|
|
226
226
|
|
|
227
|
-
Loads the drawing's structure tree from the engine into the
|
|
227
|
+
Loads the drawing's structure tree from the engine into the SDK's store.
|
|
228
228
|
|
|
229
229
|
###### Returns
|
|
230
230
|
|
package/doc/api/clients.md
CHANGED
|
@@ -11,19 +11,19 @@ in the page (`WASMClient`), a native engine (`WSClient`) or the ClassCAD server
|
|
|
11
11
|
function init(source, options?): void;
|
|
12
12
|
```
|
|
13
13
|
|
|
14
|
-
Sets up
|
|
14
|
+
Sets up the SDK: tells it how to reach ClassCAD, with a factory that makes the client for each drawing.
|
|
15
15
|
|
|
16
16
|
Call it once, before the first drawing connects. Every drawing that connects afterwards
|
|
17
17
|
([BuerliCadFacade.connect](modeling.md#connect), `BuerliCadFacade.utils.connect`, react-cad, Buerligons) gets its client from
|
|
18
18
|
`source`; the client connects right after it is made. Calling `init` again replaces the factory for the drawings
|
|
19
|
-
that connect from then on. `options` go to the
|
|
19
|
+
that connect from then on. `options` go to the SDK's store (`init` of `@classcad/sdkjs`).
|
|
20
20
|
|
|
21
21
|
#### Parameters
|
|
22
22
|
|
|
23
23
|
| Parameter | Type | Description |
|
|
24
24
|
| :------ | :------ | :------ |
|
|
25
25
|
| `source` | (`drawingId`) => [`AwvNodeClient`](#abstract-awvnodeclient) | Makes the client for a drawing: called with the new drawing's id, returns a client that is not connected yet. |
|
|
26
|
-
| `options?` | `Partial`<\{ `config`: \{ `geometry`: `GeometryConfig`; \}; `elements`: `any`; `globalPlugins`: (`Plugin` \| `Promise`<`Plugin`>)[]; `plugins`: `Record`<`string`, `PluginImpl`>; `theme`: \{ `dark`: `string`; `highlightedGeom`: `string`; `hoveredGeom`: `string`; `primary`: `string`; `secondary`: `string`; \}; \}> | Options of the
|
|
26
|
+
| `options?` | `Partial`<\{ `config`: \{ `geometry`: `GeometryConfig`; \}; `elements`: `any`; `globalPlugins`: (`Plugin` \| `Promise`<`Plugin`>)[]; `plugins`: `Record`<`string`, `PluginImpl`>; `theme`: \{ `dark`: `string`; `highlightedGeom`: `string`; `hoveredGeom`: `string`; `primary`: `string`; `secondary`: `string`; \}; \}> | Options of the SDK's store: theme colors, how geometry is shown (`config.geometry`), plugins. |
|
|
27
27
|
|
|
28
28
|
#### Returns
|
|
29
29
|
|
|
@@ -459,7 +459,7 @@ the drawing, and to the session's guests. Rejects with the reply when it carries
|
|
|
459
459
|
requestTree(): Promise<ServerResponse>;
|
|
460
460
|
```
|
|
461
461
|
|
|
462
|
-
Loads the drawing's structure tree from the engine and sets it in the
|
|
462
|
+
Loads the drawing's structure tree from the engine and sets it in the SDK's store.
|
|
463
463
|
|
|
464
464
|
###### Returns
|
|
465
465
|
|
|
@@ -588,7 +588,7 @@ UndoStack message, which updates `cad.states`. The result is the history afterwa
|
|
|
588
588
|
|
|
589
589
|
### WSClient {#wsclient}
|
|
590
590
|
|
|
591
|
-
Connects
|
|
591
|
+
Connects the SDK to a native ClassCAD engine through the engine's own WebSocket server (`classcad-cli worker`).
|
|
592
592
|
|
|
593
593
|
The server owns the session. Without an invite it creates one for this connection, which lasts as long as the
|
|
594
594
|
connection; others join it with an invite from [WSClient.createInvite](#createinvite-1), passed as `config.invite`. A URL
|
|
@@ -960,7 +960,7 @@ an error, and when the socket closes first.
|
|
|
960
960
|
requestTree(): Promise<ServerResponse>;
|
|
961
961
|
```
|
|
962
962
|
|
|
963
|
-
Loads the drawing's structure tree from the engine and sets it in the
|
|
963
|
+
Loads the drawing's structure tree from the engine and sets it in the SDK's store.
|
|
964
964
|
|
|
965
965
|
###### Returns
|
|
966
966
|
|
|
@@ -1099,7 +1099,7 @@ The result is the history afterwards: `{ stack, current }`.
|
|
|
1099
1099
|
|
|
1100
1100
|
### SocketIOClient {#socketioclient}
|
|
1101
1101
|
|
|
1102
|
-
Connects
|
|
1102
|
+
Connects the SDK to a ClassCAD server (`classcad-socketio`) over Socket.IO.
|
|
1103
1103
|
|
|
1104
1104
|
The server runs the engine and keeps the drawing's undo history, so `undo`, `redo` and `undoable` requests work
|
|
1105
1105
|
with this client. It cannot share its session (`shareKind` is null). When the connection drops and comes back, the
|
|
@@ -1405,7 +1405,7 @@ Structure patches and graphic go into the drawing on the way. Rejects with the r
|
|
|
1405
1405
|
requestTree(): Promise<ServerResponse>;
|
|
1406
1406
|
```
|
|
1407
1407
|
|
|
1408
|
-
Loads the drawing's structure tree from the engine and sets it in the
|
|
1408
|
+
Loads the drawing's structure tree from the engine and sets it in the SDK's store.
|
|
1409
1409
|
|
|
1410
1410
|
###### Returns
|
|
1411
1411
|
|
|
@@ -1537,9 +1537,9 @@ const classcadEngine: ClassCadEngine;
|
|
|
1537
1537
|
The ClassCAD engine this package is built against: its version, its quality, and where its bundle is.
|
|
1538
1538
|
|
|
1539
1539
|
`@classcad/api-js`, the ClassCAD API this package calls, is generated by the ClassCAD engine, and carries the
|
|
1540
|
-
version and the quality of the bundle it belongs to. That bundle is the engine this version of
|
|
1540
|
+
version and the quality of the bundle it belongs to. That bundle is the engine this version of the SDK is made
|
|
1541
1541
|
for: [WASMClient](#wasmclient) loads its WebAssembly from `wasmUrl`, and a host that runs the engine behind a server
|
|
1542
|
-
([WSClient](#wsclient), [SocketIOClient](#socketioclient)) installs the same version, from `url`. A beta of
|
|
1542
|
+
([WSClient](#wsclient), [SocketIOClient](#socketioclient)) installs the same version, from `url`. A beta of the SDK is built
|
|
1543
1543
|
against an `alpha` build, a stable release against a `release`.
|
|
1544
1544
|
|
|
1545
1545
|
`npx @classcad/client info` prints the same (`--json` for the object).
|
|
@@ -1575,7 +1575,7 @@ The ClassCAD engine a version of `@classcad/client` is built against: see [class
|
|
|
1575
1575
|
| :------ | :------ | :------ | :------ |
|
|
1576
1576
|
| <a id="property-apiurl"></a> `apiUrl` | `readonly` | `string` | The `@classcad/api-js` package this package is built with, as a tarball. |
|
|
1577
1577
|
| <a id="property-metadataurl"></a> `metadataUrl` | `readonly` | `string` | The bundle's `metadata.json`: its files, with their URLs and checksums. |
|
|
1578
|
-
| <a id="property-quality"></a> `quality` | `readonly` | `string` | `release`, `alpha` (what a beta of
|
|
1578
|
+
| <a id="property-quality"></a> `quality` | `readonly` | `string` | `release`, `alpha` (what a beta of the SDK is built against) or `dev` (a feature branch). |
|
|
1579
1579
|
| <a id="property-url"></a> `url` | `readonly` | `string` | The bundle on awvstatic.com: the engine for every platform, the server, the API packages. |
|
|
1580
1580
|
| <a id="property-version"></a> `version` | `readonly` | `string` | The ClassCAD version: `21.2.0`, or `21.2.1-alpha.169`. |
|
|
1581
1581
|
| <a id="property-wasmurl"></a> `wasmUrl` | `readonly` | `string` | The WebAssembly engine [WASMClient](#wasmclient) loads when it is given no `url`. |
|
|
@@ -1622,14 +1622,14 @@ init(drawingId => new WSClient('ws://localhost:9094', drawingId, config))
|
|
|
1622
1622
|
|
|
1623
1623
|
## Advanced
|
|
1624
1624
|
|
|
1625
|
-
Most apps do not need these directly: types they meet through the exports above, and what is there for special cases or for building on
|
|
1625
|
+
Most apps do not need these directly: types they meet through the exports above, and what is there for special cases or for building on the SDK itself.
|
|
1626
1626
|
|
|
1627
1627
|
### `abstract` AwvNodeClient {#abstract-awvnodeclient}
|
|
1628
1628
|
|
|
1629
|
-
The base of every client: what
|
|
1629
|
+
The base of every client: what the SDK asks of a connection to ClassCAD, and the session-sharing surface.
|
|
1630
1630
|
|
|
1631
1631
|
An app makes a [WASMClient](#wasmclient), [WSClient](#wsclient) or [SocketIOClient](#socketioclient) in the factory it gives [init](#init);
|
|
1632
|
-
|
|
1632
|
+
The SDK connects it and sends the drawing's API calls through it. A client that cannot share its session (the base
|
|
1633
1633
|
class, [SocketIOClient](#socketioclient)) has `shareKind` null and rejects `createInvite` with
|
|
1634
1634
|
[SESSION\_SHARING\_UNSUPPORTED](session-sharing.md#session_sharing_unsupported).
|
|
1635
1635
|
|
|
@@ -1763,7 +1763,7 @@ EventEmitter.constructor
|
|
|
1763
1763
|
abstract connect(): Promise<AwvNodeClient>;
|
|
1764
1764
|
```
|
|
1765
1765
|
|
|
1766
|
-
Connects to the engine.
|
|
1766
|
+
Connects to the engine. The SDK calls it when the drawing connects; it resolves once the drawing's structure tree
|
|
1767
1767
|
is loaded and API calls can be made.
|
|
1768
1768
|
|
|
1769
1769
|
###### Returns
|
|
@@ -1930,7 +1930,7 @@ Sends a raw request to the engine and resolves to its reply. Rejects with the re
|
|
|
1930
1930
|
requestTree(): Promise<ServerResponse>;
|
|
1931
1931
|
```
|
|
1932
1932
|
|
|
1933
|
-
Loads the drawing's structure tree from the engine and sets it in the
|
|
1933
|
+
Loads the drawing's structure tree from the engine and sets it in the SDK's store.
|
|
1934
1934
|
|
|
1935
1935
|
###### Returns
|
|
1936
1936
|
|
package/doc/api/engine-keys.md
CHANGED
|
@@ -182,7 +182,7 @@ const key = await resolveEngineKey(source)
|
|
|
182
182
|
|
|
183
183
|
## Advanced
|
|
184
184
|
|
|
185
|
-
Most apps do not need these directly: types they meet through the exports above, and what is there for special cases or for building on
|
|
185
|
+
Most apps do not need these directly: types they meet through the exports above, and what is there for special cases or for building on the SDK itself.
|
|
186
186
|
|
|
187
187
|
### DEFAULT\_KEY\_URL {#default_key_url}
|
|
188
188
|
|
package/doc/api/index.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# @classcad/client
|
|
2
2
|
|
|
3
|
-
Connects an app to ClassCAD, the CAD engine, and runs the ClassCAD API on its drawings: the package every
|
|
3
|
+
Connects an app to ClassCAD, the CAD engine, and runs the ClassCAD API on its drawings: the package every sdkjs
|
|
4
4
|
app starts with. The engine runs in the browser as WebAssembly, or natively behind a server; a session can be
|
|
5
5
|
shared with other apps and with AI agents.
|
|
6
6
|
|
|
7
7
|
## What it exposes
|
|
8
8
|
|
|
9
|
-
- [init](clients.md#init): sets
|
|
9
|
+
- [init](clients.md#init): sets the SDK up with a factory that makes the client of each drawing.
|
|
10
10
|
- [WASMClient](clients.md#wasmclient): runs the engine in the browser, with a public access token (`ccpk_…`).
|
|
11
11
|
- [WSClient](clients.md#wsclient): connects to a native engine's own WebSocket server (`classcad-cli worker`).
|
|
12
12
|
- [SocketIOClient](clients.md#socketioclient): connects to the ClassCAD server (`classcad-socketio`).
|
|
@@ -51,7 +51,7 @@ const meshes = geometries?.map(geometry => new THREE.Mesh(geometry, new THREE.Me
|
|
|
51
51
|
|
|
52
52
|
## Advanced
|
|
53
53
|
|
|
54
|
-
Most apps do not need these directly: types they meet through the exports above, and what is there for special cases or for building on
|
|
54
|
+
Most apps do not need these directly: types they meet through the exports above, and what is there for special cases or for building on the SDK itself.
|
|
55
55
|
|
|
56
56
|
| Name | Description |
|
|
57
57
|
| :------ | :------ |
|
package/doc/api/modeling.md
CHANGED
|
@@ -9,7 +9,7 @@ geometry.
|
|
|
9
9
|
|
|
10
10
|
A drawing connected to ClassCAD: its API, and helpers that turn the model into three.js objects.
|
|
11
11
|
|
|
12
|
-
`connect()` creates a drawing in the
|
|
12
|
+
`connect()` creates a drawing in the SDK's store and connects it with a client from the factory given to
|
|
13
13
|
[init](clients.md#init). Then `api` is the drawing's ClassCAD API, unwrapped: `await api.v1.part.create(…)` resolves to the
|
|
14
14
|
new part's id and rejects when the engine reports an error; warnings are logged. `createBufferGeometry` and
|
|
15
15
|
`createScene` make three.js geometry of what was built, `tree` and `graphic` read the drawing as the store holds
|
|
@@ -292,7 +292,7 @@ await facade.api.v1.solid.extrusion({ id: ei, curves: [curve], direction: [0, 0,
|
|
|
292
292
|
destroy(): Promise<void>;
|
|
293
293
|
```
|
|
294
294
|
|
|
295
|
-
Disconnects from ClassCAD and removes the drawing from the
|
|
295
|
+
Disconnects from ClassCAD and removes the drawing from the SDK's store. The facade can `connect()` again.
|
|
296
296
|
|
|
297
297
|
A failing disconnect does not keep the drawing from being removed.
|
|
298
298
|
|
|
@@ -306,7 +306,7 @@ A failing disconnect does not keep the drawing from being removed.
|
|
|
306
306
|
disconnect(): Promise<void>;
|
|
307
307
|
```
|
|
308
308
|
|
|
309
|
-
Disconnects from ClassCAD. The drawing stays in the
|
|
309
|
+
Disconnects from ClassCAD. The drawing stays in the SDK's store, reset (without its model), and keeps its
|
|
310
310
|
client; `api` is not available until [BuerliCadFacade.reconnect](#reconnect).
|
|
311
311
|
|
|
312
312
|
###### Returns
|
|
@@ -324,7 +324,7 @@ graphic(opts?): Promise<
|
|
|
324
324
|
```
|
|
325
325
|
|
|
326
326
|
The current graphic (tessellation) of the drawing as `{ containers }`, as
|
|
327
|
-
held by the
|
|
327
|
+
held by the SDK's store. Pass `recalc: true` to recalculate first.
|
|
328
328
|
|
|
329
329
|
Note that graphic element ids are payload-local - they rotate on every
|
|
330
330
|
re-tessellation. The stable join between graphic and structure tree is
|
|
@@ -432,7 +432,7 @@ const faces = await facade.selectGeometry([ScgGraphicType.PLANE, ScgGraphicType.
|
|
|
432
432
|
tree(opts?): Promise<ScgTree>;
|
|
433
433
|
```
|
|
434
434
|
|
|
435
|
-
The structure tree (id -\> node) of the drawing, as held by the
|
|
435
|
+
The structure tree (id -\> node) of the drawing, as held by the SDK's store.
|
|
436
436
|
The tree is kept up to date by the regular structure broadcast; pass
|
|
437
437
|
`refresh: true` to explicitly request it from ClassCAD first.
|
|
438
438
|
|
|
@@ -512,7 +512,7 @@ const part = await plateWithHole(facade.api, 100)
|
|
|
512
512
|
|
|
513
513
|
## Advanced
|
|
514
514
|
|
|
515
|
-
Most apps do not need these directly: types they meet through the exports above, and what is there for special cases or for building on
|
|
515
|
+
Most apps do not need these directly: types they meet through the exports above, and what is there for special cases or for building on the SDK itself.
|
|
516
516
|
|
|
517
517
|
### ccUtils {#ccutils}
|
|
518
518
|
|
|
@@ -526,7 +526,7 @@ const ccUtils: {
|
|
|
526
526
|
|
|
527
527
|
Helpers that look things up in a drawing's structure tree: classes, ancestors, work geometry, sketches, constraints.
|
|
528
528
|
|
|
529
|
-
They read the tree in the
|
|
529
|
+
They read the tree in the SDK's store; none of them calls the engine.
|
|
530
530
|
|
|
531
531
|
#### Type Declaration
|
|
532
532
|
|
|
@@ -405,7 +405,7 @@ purpose: `localhost` may be IPv6 in the browser and IPv4 in the MCP.
|
|
|
405
405
|
|
|
406
406
|
## Advanced
|
|
407
407
|
|
|
408
|
-
Most apps do not need these directly: types they meet through the exports above, and what is there for special cases or for building on
|
|
408
|
+
Most apps do not need these directly: types they meet through the exports above, and what is there for special cases or for building on the SDK itself.
|
|
409
409
|
|
|
410
410
|
### applySelection() {#applyselection}
|
|
411
411
|
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@classcad/client",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
4
|
-
"
|
|
3
|
+
"version": "3.0.0-beta.20261120101705",
|
|
4
|
+
"homepage": "https://sdkjs.classcad.ch",
|
|
5
|
+
"description": "Connects an app to ClassCAD, the CAD engine, and runs the ClassCAD API: the package every sdkjs app starts with",
|
|
5
6
|
"author": "AWV Informatik AG <info@awv-informatik.ch>",
|
|
6
7
|
"license": "ISC",
|
|
7
8
|
"repository": {
|
|
8
9
|
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/awv-informatik/
|
|
10
|
-
"directory": "packages/
|
|
10
|
+
"url": "git+https://github.com/awv-informatik/sdkjs.git",
|
|
11
|
+
"directory": "packages/client"
|
|
11
12
|
},
|
|
12
13
|
"main": "build/cjs/index.js",
|
|
13
14
|
"module": "build/esm/index.js",
|
|
@@ -37,7 +38,7 @@
|
|
|
37
38
|
"typescript": "~6.0.3"
|
|
38
39
|
},
|
|
39
40
|
"dependencies": {
|
|
40
|
-
"@classcad/sdkjs": "3.0.0-beta.
|
|
41
|
+
"@classcad/sdkjs": "3.0.0-beta.20261120101705",
|
|
41
42
|
"@classcad/api-js": "https://awvstatic.com/classcad/download/alpha/21.2.1-alpha.185/js/classcad-api-js-21.2.1-alpha.185.tgz",
|
|
42
43
|
"@types/events": "^3.0.3",
|
|
43
44
|
"base64-arraybuffer": "^1.0.2",
|