@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,113 @@
|
|
|
1
|
+
import type { ClientIdentity } from './identity';
|
|
2
|
+
/**
|
|
3
|
+
* Role attached to an invite. Advisory: enforced by the client, not the server (yet).
|
|
4
|
+
*
|
|
5
|
+
* `'edit'` may change the model, `'view'` only look; an app suppresses changes for a `'view'` guest.
|
|
6
|
+
*
|
|
7
|
+
* @category Session Sharing
|
|
8
|
+
*/
|
|
9
|
+
export type SessionRole = 'edit' | 'view';
|
|
10
|
+
/**
|
|
11
|
+
* A guest currently sharing the session, keyed by peerId.
|
|
12
|
+
*
|
|
13
|
+
* Clients list them in `peers` and emit `peers_changed`; see the host example of {@link WSClient}.
|
|
14
|
+
*
|
|
15
|
+
* @category Session Sharing
|
|
16
|
+
*/
|
|
17
|
+
export type SessionPeer = {
|
|
18
|
+
/** Stable id of the guest's connection. */
|
|
19
|
+
peerId: string;
|
|
20
|
+
/** The invite token the guest joined with. */
|
|
21
|
+
invite: string;
|
|
22
|
+
/** Display name of that token ('' for unnamed tokens). */
|
|
23
|
+
inviteName: string;
|
|
24
|
+
/** The role of that token. */
|
|
25
|
+
role: SessionRole;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* An ephemeral presence message from a session sibling (e.g. its camera viewpoint).
|
|
29
|
+
*
|
|
30
|
+
* Clients emit it as `presence` (client, message); the guest example of {@link WSClient} follows a camera with it.
|
|
31
|
+
*
|
|
32
|
+
* @category Session Sharing
|
|
33
|
+
*/
|
|
34
|
+
export type PresenceMessage = {
|
|
35
|
+
/** Application-defined channel, e.g. 'view' for shared camera viewpoints, 'leave' when a peer disconnects. */
|
|
36
|
+
channel: string;
|
|
37
|
+
/** Stable id of the sending connection (matches PeerJoined/PeerLeft peerIds). */
|
|
38
|
+
peerId: string;
|
|
39
|
+
/** Channel-specific payload, verbatim from the sender. */
|
|
40
|
+
data: Record<string, any>;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* How a client's sessions are shared: by invite. `null` (on a client) = it cannot share.
|
|
44
|
+
*
|
|
45
|
+
* @advanced
|
|
46
|
+
* @category Session Sharing
|
|
47
|
+
*/
|
|
48
|
+
export type ShareKind = 'invite';
|
|
49
|
+
/**
|
|
50
|
+
* An invite this client minted (the server keeps no queryable list, so the client tracks it).
|
|
51
|
+
*
|
|
52
|
+
* {@link buildShareUrl} makes the link a guest opens.
|
|
53
|
+
*
|
|
54
|
+
* @category Session Sharing
|
|
55
|
+
*/
|
|
56
|
+
export type SessionInvite = {
|
|
57
|
+
/** The token guests join with (`?invite=<token>`). */
|
|
58
|
+
invite: string;
|
|
59
|
+
/** The name shown for the invite ('' for unnamed ones). */
|
|
60
|
+
name: string;
|
|
61
|
+
/** What guests with the invite may do. */
|
|
62
|
+
role: SessionRole;
|
|
63
|
+
/** How the invite is honoured. */
|
|
64
|
+
kind: ShareKind;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Why the share relay would not take a page's invite, for good: the code it closed the offer with, and its words.
|
|
68
|
+
*
|
|
69
|
+
* The code is 4000 + the HTTP status: 4401 the sign-in, 4403 the plan, 4409 another account offers the invite.
|
|
70
|
+
* A WASMClient emits it as 'invite_refused' (client, invite, refusal); {@link WASMClient.createInvite} has an
|
|
71
|
+
* example.
|
|
72
|
+
*
|
|
73
|
+
* @advanced
|
|
74
|
+
* @category Session Sharing
|
|
75
|
+
*/
|
|
76
|
+
export type OfferRefusal = {
|
|
77
|
+
/** The close code: 4401 the sign-in, 4403 the plan, 4409 another account offers the invite. */
|
|
78
|
+
code: number;
|
|
79
|
+
/** The relay's words. */
|
|
80
|
+
reason: string;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Snapshot of a drawing's sharing state, as served to UI.
|
|
84
|
+
*
|
|
85
|
+
* {@link getSessionShareState} returns it, {@link subscribeSessionShare} says when it changed.
|
|
86
|
+
*
|
|
87
|
+
* @category Session Sharing
|
|
88
|
+
*/
|
|
89
|
+
export type SessionShareState = {
|
|
90
|
+
/** A client exists for the drawing and can mint invites. */
|
|
91
|
+
supported: boolean;
|
|
92
|
+
/** How the client shares, or null when it cannot. */
|
|
93
|
+
kind: ShareKind | null;
|
|
94
|
+
/** This connection's own role ('edit' for hosts and non-sharing clients). */
|
|
95
|
+
role: SessionRole;
|
|
96
|
+
/** Name of the invite this page joined with ('' for the host). */
|
|
97
|
+
inviteName: string;
|
|
98
|
+
/** True when this page was opened with a share token (it is a guest, not the host). */
|
|
99
|
+
isGuest: boolean;
|
|
100
|
+
/** The guests in the session (host side). */
|
|
101
|
+
peers: SessionPeer[];
|
|
102
|
+
/** The invites this client minted and has not revoked. */
|
|
103
|
+
invites: SessionInvite[];
|
|
104
|
+
/** What the other participants said about themselves, by peer id (see {@link ClientIdentity}). */
|
|
105
|
+
identities: Record<string, ClientIdentity>;
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* `Error.name` of the rejection when a client cannot share (no `shareKind`).
|
|
109
|
+
*
|
|
110
|
+
* @advanced
|
|
111
|
+
* @category Session Sharing
|
|
112
|
+
*/
|
|
113
|
+
export declare const SESSION_SHARING_UNSUPPORTED = "SessionSharingUnsupported";
|
|
File without changes
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import { IStructureProtocol, Message } from '../re-export';
|
|
2
|
+
/**
|
|
3
|
+
* What a client does for the SDK: connect a drawing to an engine, run commands on it and load its structure.
|
|
4
|
+
*
|
|
5
|
+
* {@link AwvNodeClient} implements it; the clients ({@link WASMClient}, {@link WSClient}, {@link SocketIOClient})
|
|
6
|
+
* extend that.
|
|
7
|
+
*
|
|
8
|
+
* @advanced
|
|
9
|
+
* @category Connection
|
|
10
|
+
*/
|
|
11
|
+
export interface IComClient {
|
|
12
|
+
/** Connects to the engine; resolves once the drawing's structure tree is loaded and API calls can be made. */
|
|
13
|
+
connect(): Promise<IComClient>;
|
|
14
|
+
/** Closes the connection to the engine. */
|
|
15
|
+
disconnect(): Promise<IComClient>;
|
|
16
|
+
/** Loads the drawing's structure tree from the engine into the SDK's store. */
|
|
17
|
+
requestTree(): Response;
|
|
18
|
+
/**
|
|
19
|
+
* Runs `task` (API calls) on the engine. Rejects with the reply when it carries an error.
|
|
20
|
+
*
|
|
21
|
+
* @param task - The API calls to run, e.g. `[{ 'v1.part.create': [{ name: 'Part' }] }]`.
|
|
22
|
+
* @param streamMap - Data the calls read, by stream key (a file to import, for example).
|
|
23
|
+
* @param options - Options of the request, such as `undoable`.
|
|
24
|
+
*/
|
|
25
|
+
executeRequest(task: Task, streamMap?: StreamMap, options?: RequestOptions): Response;
|
|
26
|
+
/**
|
|
27
|
+
* Sends a command of the server's own (a middleware command) with `data`.
|
|
28
|
+
*
|
|
29
|
+
* @param command - The command's name.
|
|
30
|
+
* @param data - Fields sent with the command.
|
|
31
|
+
*/
|
|
32
|
+
executeMiddleware(command: string, data: any): Response;
|
|
33
|
+
/** Steps back in the drawing's undo history. */
|
|
34
|
+
undo(options?: UndoOptions): Response;
|
|
35
|
+
/** Steps forward in the drawing's undo history. */
|
|
36
|
+
redo(options?: RedoOptions): Response;
|
|
37
|
+
/**
|
|
38
|
+
* Per-connection emission config (what the engine pushes back: structure,
|
|
39
|
+
* graphic categories, messages, delivery form). `getEmissionConfig` returns the
|
|
40
|
+
* effective flags, `setEmissionConfig` merges a partial set and returns the result.
|
|
41
|
+
* Rejects with an Error named EMISSION_CONFIG_UNSUPPORTED on engines that
|
|
42
|
+
* predate the GetEmissionConfig/SetEmissionConfig commands (old WASM builds, old servers).
|
|
43
|
+
*/
|
|
44
|
+
getEmissionConfig(): Promise<EmissionConfig>;
|
|
45
|
+
/**
|
|
46
|
+
* Merges `partial` into the connection's emission config and resolves to the effective flags. Rejects with an
|
|
47
|
+
* Error named {@link EMISSION_CONFIG_UNSUPPORTED} on engines that predate the command.
|
|
48
|
+
*
|
|
49
|
+
* @param partial - The flags to change; the others stay as they are.
|
|
50
|
+
*/
|
|
51
|
+
setEmissionConfig(partial: Partial<EmissionConfig>): Promise<EmissionConfig>;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The engine's per-connection emission flags: what it sends back after a command, and in which form.
|
|
55
|
+
*
|
|
56
|
+
* Content flags decide WHAT comes back after a command (structure tree, the
|
|
57
|
+
* four graphic categories, messages); delivery flags decide HOW (patches vs
|
|
58
|
+
* snapshot, streamed immediately vs bundled on the Result, binary/compressed,
|
|
59
|
+
* multipackage). Two commands ignore the content flags on purpose:
|
|
60
|
+
* GetTree/Sync always deliver the structure, v1.common.requestVisualisation
|
|
61
|
+
* always delivers its graphic - they are explicit requests.
|
|
62
|
+
*
|
|
63
|
+
* Read and change them with `getEmissionConfig`/`setEmissionConfig` of a client, or for a stretch of commands
|
|
64
|
+
* with `BuerliCadFacade.utils.withEmissionConfig`. Not to be confused with `v1.common.setDatabaseSettings`, which
|
|
65
|
+
* decides what the engine tessellates.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```ts
|
|
69
|
+
* import { BuerliCadFacade } from '@classcad/client'
|
|
70
|
+
* import type { EmissionConfig } from '@classcad/client'
|
|
71
|
+
*
|
|
72
|
+
* // A study of twenty variants: no graphic after each change, only the volume
|
|
73
|
+
* const noGraphic: Partial<EmissionConfig> = { sendGraphic_Kernel: false, sendGraphic_Sketch: false }
|
|
74
|
+
* const volumes = await BuerliCadFacade.utils.withEmissionConfig(facade.drawingId, noGraphic, async () => {
|
|
75
|
+
* const result: number[] = []
|
|
76
|
+
* for (let length = 50; length < 250; length += 10) {
|
|
77
|
+
* await facade.api.v1.part.updateExpression({ id: part, toUpdate: [{ name: 'length', value: length }] })
|
|
78
|
+
* const mass = await facade.api.v1.part.calculateMassProperties({ id: part })
|
|
79
|
+
* if (mass) result.push(mass.volume)
|
|
80
|
+
* }
|
|
81
|
+
* return result
|
|
82
|
+
* })
|
|
83
|
+
* // The flags are back: the tree, and with it the graphic, once
|
|
84
|
+
* await BuerliCadFacade.utils.fetchTree(facade.drawingId)
|
|
85
|
+
* ```
|
|
86
|
+
* @advanced
|
|
87
|
+
* @category Connection
|
|
88
|
+
*/
|
|
89
|
+
export type EmissionConfig = {
|
|
90
|
+
/** Send the structure tree after a command that changed it. */
|
|
91
|
+
sendStructure: boolean;
|
|
92
|
+
/** Send structure changes as JSON patches instead of the whole tree. */
|
|
93
|
+
sendStructure_Patch: boolean;
|
|
94
|
+
/** Send the structure as a base64 string of deflated JSON. */
|
|
95
|
+
sendStructure_Compressed: boolean;
|
|
96
|
+
/** Send the structure in frames of its own while the command runs, instead of on its Result. */
|
|
97
|
+
sendStructure_Immediately: boolean;
|
|
98
|
+
/** Send the frames of `sendStructure_Immediately` as binary (deflated) WebSocket frames. */
|
|
99
|
+
sendStructure_ImmediatelyBinary: boolean;
|
|
100
|
+
/** Send the graphic of bodies: their faces, edges and vertices. */
|
|
101
|
+
sendGraphic_Kernel: boolean;
|
|
102
|
+
/** Send the graphic of model objects that are not bodies, such as work geometry. */
|
|
103
|
+
sendGraphic_StructureObj: boolean;
|
|
104
|
+
/** Send the graphic of sketches. */
|
|
105
|
+
sendGraphic_Sketch: boolean;
|
|
106
|
+
/** Send the graphic of hidden objects as well. */
|
|
107
|
+
sendGraphic_Invisible: boolean;
|
|
108
|
+
/** Send graphic as a base64 string of deflated JSON. */
|
|
109
|
+
sendGraphic_Compressed: boolean;
|
|
110
|
+
/** Send graphic in frames of its own while the command runs, instead of on its Result. */
|
|
111
|
+
sendGraphic_Immediately: boolean;
|
|
112
|
+
/** Send the frames of `sendGraphic_Immediately` as binary (deflated) WebSocket frames. */
|
|
113
|
+
sendGraphic_ImmediatelyBinary: boolean;
|
|
114
|
+
/** Send one graphic package per changed object instead of one for all of them. */
|
|
115
|
+
sendGraphic_Multipackage: boolean;
|
|
116
|
+
/** Compress meshes with Draco. the SDK's clients do not decode it. */
|
|
117
|
+
sendGraphic_UseDraco: boolean;
|
|
118
|
+
/** Compress meshes with Draco in its hybrid form. the SDK's clients do not decode it. */
|
|
119
|
+
sendGraphic_UseDracoHybrid: boolean;
|
|
120
|
+
/** Also send graphic when objects were only moved or changed their material. */
|
|
121
|
+
sendGraphic_AdvancedNotifications: boolean;
|
|
122
|
+
/** Send the messages (warnings, errors) of a command. */
|
|
123
|
+
sendMessages: boolean;
|
|
124
|
+
/** Send messages in frames of their own while the command runs, instead of on its Result. */
|
|
125
|
+
sendMessages_Immediately: boolean;
|
|
126
|
+
/** The lowest level of message that is sent (a `MessageLevel`, 31 = info). */
|
|
127
|
+
sendMessages_MinLevel: number;
|
|
128
|
+
/** Taken and echoed by the engine; it does not act on it. */
|
|
129
|
+
storeState: boolean;
|
|
130
|
+
/** Read-only instance property, echoed for completeness. */
|
|
131
|
+
safeApi?: boolean;
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* `Error.name` of the rejection when the engine does not support GetEmissionConfig/SetEmissionConfig.
|
|
135
|
+
*
|
|
136
|
+
* @advanced
|
|
137
|
+
* @category Connection
|
|
138
|
+
*/
|
|
139
|
+
export declare const EMISSION_CONFIG_UNSUPPORTED = "EmissionConfigUnsupported";
|
|
140
|
+
/**
|
|
141
|
+
* A message of the engine about a command: its text, `code` and `level` (a `MessageLevel`).
|
|
142
|
+
*
|
|
143
|
+
* @advanced
|
|
144
|
+
* @category Connection
|
|
145
|
+
*/
|
|
146
|
+
export type ServerMessage = Message;
|
|
147
|
+
/**
|
|
148
|
+
* An error in the form older engines report it, before `messages`; clients turn it into a {@link ServerMessage}.
|
|
149
|
+
*
|
|
150
|
+
* @advanced
|
|
151
|
+
* @category Connection
|
|
152
|
+
*/
|
|
153
|
+
export type ServerError = {
|
|
154
|
+
/** How bad it is: 0 no error, 1 warning, 2 error (the command went on), 3 error (the command stopped). */
|
|
155
|
+
errorState: number;
|
|
156
|
+
/** The error's code. */
|
|
157
|
+
errorCode: number;
|
|
158
|
+
/** The error's text. */
|
|
159
|
+
errorMessage: string;
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* The engine's reply to a request: the result, and the messages that came with it.
|
|
163
|
+
*
|
|
164
|
+
* A client rejects with the reply when `maxLevel` is an error or worse.
|
|
165
|
+
*
|
|
166
|
+
* @advanced
|
|
167
|
+
* @category Connection
|
|
168
|
+
*/
|
|
169
|
+
export type ServerResponse = {
|
|
170
|
+
/** The command's result, e.g. the id of a new object. */
|
|
171
|
+
result?: any;
|
|
172
|
+
/** The highest level among `messages` (a `MessageLevel`); undefined without messages. */
|
|
173
|
+
maxLevel?: number;
|
|
174
|
+
/** The warnings and errors of the command. */
|
|
175
|
+
messages?: Message[];
|
|
176
|
+
/** Data the command returned by stream key, such as the content of an export. */
|
|
177
|
+
streamData?: {
|
|
178
|
+
[key: string]: string;
|
|
179
|
+
};
|
|
180
|
+
/** Raw engine frames: the frame's kind (`Result`, `Patch`, `ErrorMessage`). @internal */
|
|
181
|
+
command?: string;
|
|
182
|
+
/** Raw engine frames: the command a `Result` answers. @internal */
|
|
183
|
+
from?: string;
|
|
184
|
+
/** Raw engine frames: the JSON patch operations of a `Patch`. @internal */
|
|
185
|
+
ops?: any;
|
|
186
|
+
/** Raw engine frames: the error of an `ErrorMessage`. @internal */
|
|
187
|
+
attributes?: ServerError;
|
|
188
|
+
};
|
|
189
|
+
/**
|
|
190
|
+
* A request to the engine: a command, and what it needs.
|
|
191
|
+
*
|
|
192
|
+
* @advanced
|
|
193
|
+
* @category Connection
|
|
194
|
+
*/
|
|
195
|
+
export type ServerRequest = {
|
|
196
|
+
/** The command: `Execute` runs `task`, `GetTree` returns the structure tree; the engine knows more. */
|
|
197
|
+
command: 'Execute' | 'GetTree' | 'GetEmissionConfig' | 'SetEmissionConfig' | string;
|
|
198
|
+
/** For `Execute`: the API calls to run. */
|
|
199
|
+
task?: Task;
|
|
200
|
+
/** For `Execute`: the data the calls read, by stream key. */
|
|
201
|
+
streamData?: StreamMap;
|
|
202
|
+
/** Options of the request. */
|
|
203
|
+
options?: RequestOptions;
|
|
204
|
+
/**
|
|
205
|
+
* Only for the SetEmissionConfig command: the partial EmissionConfig to merge. The
|
|
206
|
+
* engine ignores this field on every other command - emission flags are a
|
|
207
|
+
* per-CONNECTION setting (see {@link IComClient.setEmissionConfig}), not per request.
|
|
208
|
+
*/
|
|
209
|
+
config?: Partial<EmissionConfig>;
|
|
210
|
+
/** Only for the Undo / Redo commands: the state of the undo history to go to (see UndoStackFrame). */
|
|
211
|
+
state?: string;
|
|
212
|
+
};
|
|
213
|
+
/**
|
|
214
|
+
* The undo history of the engine's drawing, sent by the engine (a ClassCAD server, the WASM
|
|
215
|
+
* engine) after every undoable command and every undo / redo, and to a guest when it joins a
|
|
216
|
+
* shared session. `stack` and `current` are state ids (time stamps, oldest first); `id` is the
|
|
217
|
+
* transaction of the undoable command that recorded the newest state (null otherwise); `captions`
|
|
218
|
+
* names the api call behind every state.
|
|
219
|
+
*/
|
|
220
|
+
export type UndoStackFrame = {
|
|
221
|
+
command: 'UndoStack';
|
|
222
|
+
stack: string[];
|
|
223
|
+
current: string;
|
|
224
|
+
id?: string | null;
|
|
225
|
+
undoable?: boolean;
|
|
226
|
+
captions?: Record<string, string>;
|
|
227
|
+
};
|
|
228
|
+
/**
|
|
229
|
+
* Options of a request; keys other than `undoable` travel with it to the engine.
|
|
230
|
+
*
|
|
231
|
+
* @advanced
|
|
232
|
+
* @category Connection
|
|
233
|
+
*/
|
|
234
|
+
export type RequestOptions = {
|
|
235
|
+
[key: string]: any;
|
|
236
|
+
/** Makes the request a step of the drawing's undo history, named after its first API call. */
|
|
237
|
+
undoable?: boolean;
|
|
238
|
+
};
|
|
239
|
+
/**
|
|
240
|
+
* Options of an undo; keys other than `state` travel with it to the engine.
|
|
241
|
+
*
|
|
242
|
+
* @advanced
|
|
243
|
+
* @category Connection
|
|
244
|
+
*/
|
|
245
|
+
export type UndoOptions = {
|
|
246
|
+
[key: string]: any;
|
|
247
|
+
/** The state of the undo history to go back to, a name from the drawing's `cad.states.stack`. */
|
|
248
|
+
state?: string;
|
|
249
|
+
};
|
|
250
|
+
/**
|
|
251
|
+
* Options of a redo; keys other than `state` travel with it to the engine.
|
|
252
|
+
*
|
|
253
|
+
* @advanced
|
|
254
|
+
* @category Connection
|
|
255
|
+
*/
|
|
256
|
+
export type RedoOptions = {
|
|
257
|
+
[key: string]: any;
|
|
258
|
+
/** The state of the undo history to go forward to, a name from the drawing's `cad.states.stack`. */
|
|
259
|
+
state?: string;
|
|
260
|
+
};
|
|
261
|
+
/**
|
|
262
|
+
* A result as the ClassCAD server's frames carry it.
|
|
263
|
+
*
|
|
264
|
+
* @internal
|
|
265
|
+
*/
|
|
266
|
+
export type ServerResult = {
|
|
267
|
+
result: IStructureProtocol | string | number | Array<string | number> | null;
|
|
268
|
+
streamData?: StreamMap;
|
|
269
|
+
};
|
|
270
|
+
/**
|
|
271
|
+
* The data of one stream: the content of a file, for example.
|
|
272
|
+
*
|
|
273
|
+
* @advanced
|
|
274
|
+
* @category Connection
|
|
275
|
+
*/
|
|
276
|
+
export type StreamData = any;
|
|
277
|
+
/**
|
|
278
|
+
* Data sent with a request or returned by it, by stream key; API calls refer to it by that key.
|
|
279
|
+
*
|
|
280
|
+
* @advanced
|
|
281
|
+
* @category Connection
|
|
282
|
+
*/
|
|
283
|
+
export type StreamMap = Record<string, StreamData>;
|
|
284
|
+
/**
|
|
285
|
+
* What an `Execute` request runs: a list of API calls, or a command as a string.
|
|
286
|
+
*
|
|
287
|
+
* Each API call is `{ '<version>.<namespace>.<function>': [args] }`.
|
|
288
|
+
*
|
|
289
|
+
* @advanced
|
|
290
|
+
* @category Connection
|
|
291
|
+
*/
|
|
292
|
+
export type Task = TaskMap | string;
|
|
293
|
+
/**
|
|
294
|
+
* API calls, each `{ '<version>.<namespace>.<function>': [args] }`.
|
|
295
|
+
*
|
|
296
|
+
* @inline
|
|
297
|
+
*/
|
|
298
|
+
type TaskMap = Array<{
|
|
299
|
+
[apiCommand: string]: Array<string | number>;
|
|
300
|
+
}>;
|
|
301
|
+
/**
|
|
302
|
+
* The engine's reply.
|
|
303
|
+
*
|
|
304
|
+
* @inline
|
|
305
|
+
*/
|
|
306
|
+
type Response = Promise<ServerResponse>;
|
|
307
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { DrawingID, ScgObject } from '@classcad/sdkjs';
|
|
2
|
+
import { BufferGeometry } from 'three';
|
|
3
|
+
/**
|
|
4
|
+
* Helps to create the buffer geometry of the given object recursively.
|
|
5
|
+
* @param object object to create the buffergeometry from
|
|
6
|
+
* @param bufferGeomArray array to fill up with buffert geometries
|
|
7
|
+
*/
|
|
8
|
+
export declare const createRecursiveBufferGeometry: (object: ScgObject, drawingId: DrawingID, bufferGeomArray: BufferGeometry[]) => Promise<void>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { DrawingID, ScgObject } from '@classcad/sdkjs';
|
|
2
|
+
import { Material, Object3D } from 'three';
|
|
3
|
+
/**
|
|
4
|
+
* We traverse recursively over structure tree, starting with object and create THREE objects
|
|
5
|
+
* for the scene. Each part or assembly will be turned into groups and subgroups. Solids which are children of the
|
|
6
|
+
* parts will be turned into groups as well. Children of solids will be merged to meshes. Faces of a solid with different color
|
|
7
|
+
* or transparency will get its own mesh.
|
|
8
|
+
* @param object root object where we start building the three scene
|
|
9
|
+
* @param drawingId id of the drawing
|
|
10
|
+
* @param root the root of the scene
|
|
11
|
+
* @param result object containing all the current collected nodes, solids, meshes
|
|
12
|
+
* @param options e.g. meshPerGeometry controls if each geometry element gets a own mesh or if they will be combined/merged
|
|
13
|
+
*/
|
|
14
|
+
export declare const createRecursiveScene: (object: ScgObject, drawingId: DrawingID, root: Object3D, result: {
|
|
15
|
+
nodes: {
|
|
16
|
+
[key: string]: Object3D;
|
|
17
|
+
};
|
|
18
|
+
materials: {
|
|
19
|
+
[key: string]: Material;
|
|
20
|
+
};
|
|
21
|
+
}, options?: {
|
|
22
|
+
meshPerGeometry?: boolean;
|
|
23
|
+
structureOnly?: boolean;
|
|
24
|
+
}) => Promise<void>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ContainerGeometryT, MeshGeometry } from '@classcad/sdkjs';
|
|
2
|
+
import { Color } from 'three';
|
|
3
|
+
type ColorMeshMap = Record<string, {
|
|
4
|
+
meshes: MeshGeometry[];
|
|
5
|
+
color: Color | undefined;
|
|
6
|
+
opacity: number;
|
|
7
|
+
}>;
|
|
8
|
+
/**
|
|
9
|
+
* Get all meshes in a map, sorted by their color / opacity
|
|
10
|
+
* @param entity entity to look for the meshes
|
|
11
|
+
* @returns map (key = color/opacity as string, value = object containing the meshes, color and opacity)
|
|
12
|
+
*/
|
|
13
|
+
export declare const getDifferentColoredMeshesFromEntity: (entity: ContainerGeometryT) => ColorMeshMap;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type * as THREE from 'three';
|
|
2
|
+
type Vec = number[] | THREE.Vector3 | THREE.Euler;
|
|
3
|
+
/**
|
|
4
|
+
* Information about the fillet.
|
|
5
|
+
*/
|
|
6
|
+
export type FilletInfo = {
|
|
7
|
+
/** Contains both start points of adjacent lines of control point. Actually both start points are equal to control point. */
|
|
8
|
+
lineStarts: Vec[];
|
|
9
|
+
/** Contains both end points of adjacent lines of control point. */
|
|
10
|
+
lineEnds: Vec[];
|
|
11
|
+
/** Control point of fillet. It's the point where both lines intersect. */
|
|
12
|
+
control: Vec;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Point definition where the fillet will be added with a specified radius.
|
|
16
|
+
*/
|
|
17
|
+
export type FilletPoint = {
|
|
18
|
+
/** Point where the corner of the polyline will be. */
|
|
19
|
+
point: THREE.Vector3;
|
|
20
|
+
/** Radius of the fillet at the position of point. */
|
|
21
|
+
radius: number;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Polyline of points and bulges. Bulges define the arc between the current and the next point.
|
|
25
|
+
*/
|
|
26
|
+
export type Polyline = {
|
|
27
|
+
/** Points where the corners of the polyline will be. */
|
|
28
|
+
points: THREE.Vector3[];
|
|
29
|
+
/** Bulges which define the arcs. */
|
|
30
|
+
bulges: number[];
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Returns the adjacent points of the fillet arc. These are the points where fillet arc tangentially touches the lines.
|
|
34
|
+
* @param info contains all information for the fillet, like start- and endpoints of adjacent lines and control point
|
|
35
|
+
* @param radius radius of the fillet arc
|
|
36
|
+
*/
|
|
37
|
+
export declare const getTouchPoints: (info: FilletInfo, radius: number) => THREE.Vector3[] | null;
|
|
38
|
+
/**
|
|
39
|
+
* Calculates and returns the including angle between the touchpoints of the fillet. Attention: It is the angle of touchpoints and center of fillet arc and not the one between touchpoints and control point.
|
|
40
|
+
* @param info
|
|
41
|
+
*/
|
|
42
|
+
export declare const getIncludingBulgeAngle: (info: FilletInfo) => number;
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { DrawingID, SelectedItem } from '@classcad/sdkjs';
|
|
2
|
+
type CustomSelect<T> = (resolve: (result: T) => Promise<T>, newItems: SelectedItem[], diff: SelectedItem[]) => void;
|
|
3
|
+
export declare function waitForSelect<T>(drawingId: DrawingID, length: number, filter: any, onChange: CustomSelect<T>): Promise<SelectedItem[]>;
|
|
4
|
+
export {};
|