@snaptrude/plugin-client 0.3.0 → 0.5.0
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/AGENTS.md +39 -45
- package/CHANGELOG.md +99 -0
- package/CLAUDE.md +1 -1
- package/dist/api/index.d.ts +12 -13
- package/dist/api/index.d.ts.map +1 -1
- package/dist/index.cjs +23 -467
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +25 -460
- package/dist/index.js.map +1 -1
- package/dist/rpc-proxy.d.ts +28 -0
- package/dist/rpc-proxy.d.ts.map +1 -0
- package/package.json +2 -2
- package/src/api/index.ts +26 -18
- package/src/rpc-proxy.ts +56 -0
- package/dist/api/core/geom/arc.d.ts +0 -5
- package/dist/api/core/geom/arc.d.ts.map +0 -1
- package/dist/api/core/geom/curve.d.ts +0 -5
- package/dist/api/core/geom/curve.d.ts.map +0 -1
- package/dist/api/core/geom/index.d.ts +0 -17
- package/dist/api/core/geom/index.d.ts.map +0 -1
- package/dist/api/core/geom/line.d.ts +0 -5
- package/dist/api/core/geom/line.d.ts.map +0 -1
- package/dist/api/core/geom/profile.d.ts +0 -7
- package/dist/api/core/geom/profile.d.ts.map +0 -1
- package/dist/api/core/index.d.ts +0 -11
- package/dist/api/core/index.d.ts.map +0 -1
- package/dist/api/core/math/index.d.ts +0 -11
- package/dist/api/core/math/index.d.ts.map +0 -1
- package/dist/api/core/math/quat.d.ts +0 -5
- package/dist/api/core/math/quat.d.ts.map +0 -1
- package/dist/api/core/math/vec3.d.ts +0 -5
- package/dist/api/core/math/vec3.d.ts.map +0 -1
- package/dist/api/entity/department.d.ts +0 -7
- package/dist/api/entity/department.d.ts.map +0 -1
- package/dist/api/entity/index.d.ts +0 -17
- package/dist/api/entity/index.d.ts.map +0 -1
- package/dist/api/entity/referenceLine.d.ts +0 -9
- package/dist/api/entity/referenceLine.d.ts.map +0 -1
- package/dist/api/entity/space.d.ts +0 -11
- package/dist/api/entity/space.d.ts.map +0 -1
- package/dist/api/entity/story.d.ts +0 -9
- package/dist/api/entity/story.d.ts.map +0 -1
- package/dist/api/tools/copy.d.ts +0 -3
- package/dist/api/tools/copy.d.ts.map +0 -1
- package/dist/api/tools/index.d.ts +0 -17
- package/dist/api/tools/index.d.ts.map +0 -1
- package/dist/api/tools/material.d.ts +0 -6
- package/dist/api/tools/material.d.ts.map +0 -1
- package/dist/api/tools/offset.d.ts +0 -3
- package/dist/api/tools/offset.d.ts.map +0 -1
- package/dist/api/tools/selection.d.ts +0 -6
- package/dist/api/tools/selection.d.ts.map +0 -1
- package/dist/api/tools/transform.d.ts +0 -7
- package/dist/api/tools/transform.d.ts.map +0 -1
- package/dist/api/units/index.d.ts +0 -7
- package/dist/api/units/index.d.ts.map +0 -1
- package/src/api/core/geom/arc.ts +0 -7
- package/src/api/core/geom/curve.ts +0 -7
- package/src/api/core/geom/index.ts +0 -25
- package/src/api/core/geom/line.ts +0 -7
- package/src/api/core/geom/profile.ts +0 -17
- package/src/api/core/index.ts +0 -17
- package/src/api/core/math/index.ts +0 -17
- package/src/api/core/math/quat.ts +0 -7
- package/src/api/core/math/vec3.ts +0 -7
- package/src/api/entity/department.ts +0 -30
- package/src/api/entity/index.ts +0 -25
- package/src/api/entity/referenceLine.ts +0 -54
- package/src/api/entity/space.ts +0 -98
- package/src/api/entity/story.ts +0 -66
- package/src/api/tools/copy.ts +0 -10
- package/src/api/tools/index.ts +0 -36
- package/src/api/tools/material.ts +0 -22
- package/src/api/tools/offset.ts +0 -15
- package/src/api/tools/selection.ts +0 -15
- package/src/api/tools/transform.ts +0 -44
- package/src/api/units/index.ts +0 -34
package/dist/index.js
CHANGED
|
@@ -1,63 +1,7 @@
|
|
|
1
|
-
// src/api/
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { PluginMathApi } from "@snaptrude/plugin-core";
|
|
6
|
-
|
|
7
|
-
// src/api/core/math/vec3.ts
|
|
8
|
-
import { PluginVec3Api } from "@snaptrude/plugin-core";
|
|
9
|
-
var ClientVec3Api = class extends PluginVec3Api {
|
|
10
|
-
constructor() {
|
|
11
|
-
super();
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
// src/api/core/math/quat.ts
|
|
16
|
-
import { PluginQuatApi } from "@snaptrude/plugin-core";
|
|
17
|
-
var ClientQuatApi = class extends PluginQuatApi {
|
|
18
|
-
constructor() {
|
|
19
|
-
super();
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
// src/api/core/math/index.ts
|
|
24
|
-
var ClientMathApi = class extends PluginMathApi {
|
|
25
|
-
constructor() {
|
|
26
|
-
super();
|
|
27
|
-
this.vec3 = new ClientVec3Api();
|
|
28
|
-
this.quat = new ClientQuatApi();
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
// src/api/core/geom/index.ts
|
|
33
|
-
import { PluginGeomApi } from "@snaptrude/plugin-core";
|
|
34
|
-
|
|
35
|
-
// src/api/core/geom/line.ts
|
|
36
|
-
import { PluginLineApi } from "@snaptrude/plugin-core";
|
|
37
|
-
var ClientLineApi = class extends PluginLineApi {
|
|
38
|
-
constructor() {
|
|
39
|
-
super();
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
// src/api/core/geom/arc.ts
|
|
44
|
-
import { PluginArcApi } from "@snaptrude/plugin-core";
|
|
45
|
-
var ClientArcApi = class extends PluginArcApi {
|
|
46
|
-
constructor() {
|
|
47
|
-
super();
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
// src/api/core/geom/curve.ts
|
|
52
|
-
import { PluginCurveApi } from "@snaptrude/plugin-core";
|
|
53
|
-
var ClientCurveApi = class extends PluginCurveApi {
|
|
54
|
-
constructor() {
|
|
55
|
-
super();
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
// src/api/core/geom/profile.ts
|
|
60
|
-
import { PluginProfileApi } from "@snaptrude/plugin-core";
|
|
1
|
+
// src/api/index.ts
|
|
2
|
+
import {
|
|
3
|
+
PluginApi
|
|
4
|
+
} from "@snaptrude/plugin-core";
|
|
61
5
|
|
|
62
6
|
// src/host-api.ts
|
|
63
7
|
import * as Comlink from "comlink";
|
|
@@ -87,395 +31,35 @@ function getHostApi() {
|
|
|
87
31
|
};
|
|
88
32
|
}
|
|
89
33
|
|
|
90
|
-
// src/
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
// src/api/core/geom/index.ts
|
|
105
|
-
var ClientGeomApi = class extends PluginGeomApi {
|
|
106
|
-
constructor() {
|
|
107
|
-
super();
|
|
108
|
-
this.line = new ClientLineApi();
|
|
109
|
-
this.arc = new ClientArcApi();
|
|
110
|
-
this.curve = new ClientCurveApi();
|
|
111
|
-
this.profile = new ClientProfileApi();
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
// src/api/core/index.ts
|
|
116
|
-
var ClientCoreApi = class extends PluginCoreApi {
|
|
117
|
-
constructor() {
|
|
118
|
-
super();
|
|
119
|
-
this.math = new ClientMathApi();
|
|
120
|
-
this.geom = new ClientGeomApi();
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
// src/api/entity/index.ts
|
|
125
|
-
import { PluginEntityApi } from "@snaptrude/plugin-core";
|
|
126
|
-
|
|
127
|
-
// src/api/entity/department.ts
|
|
128
|
-
import {
|
|
129
|
-
PluginDepartmentApi
|
|
130
|
-
} from "@snaptrude/plugin-core";
|
|
131
|
-
var ClientDepartmentApi = class extends PluginDepartmentApi {
|
|
132
|
-
constructor() {
|
|
133
|
-
super();
|
|
134
|
-
}
|
|
135
|
-
async create(args) {
|
|
136
|
-
const hostApi = getHostApi();
|
|
137
|
-
return hostApi.call({
|
|
138
|
-
method: "entity.department.create",
|
|
139
|
-
args
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
async getAll() {
|
|
143
|
-
const hostApi = getHostApi();
|
|
144
|
-
return hostApi.call({
|
|
145
|
-
method: "entity.department.getAll"
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
// src/api/entity/referenceLine.ts
|
|
151
|
-
import {
|
|
152
|
-
PluginReferenceLineApi
|
|
153
|
-
} from "@snaptrude/plugin-core";
|
|
154
|
-
var ClientReferenceLineApi = class extends PluginReferenceLineApi {
|
|
155
|
-
constructor() {
|
|
156
|
-
super();
|
|
157
|
-
}
|
|
158
|
-
async createMulti(args) {
|
|
159
|
-
const hostApi = getHostApi();
|
|
160
|
-
return hostApi.call({
|
|
161
|
-
method: "entity.referenceLine.createMulti",
|
|
162
|
-
args
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
async get(args) {
|
|
166
|
-
const hostApi = getHostApi();
|
|
167
|
-
return hostApi.call({
|
|
168
|
-
method: "entity.referenceLine.get",
|
|
169
|
-
args
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
async getAll() {
|
|
173
|
-
const hostApi = getHostApi();
|
|
174
|
-
return hostApi.call({
|
|
175
|
-
method: "entity.referenceLine.getAll"
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
async delete(args) {
|
|
179
|
-
const hostApi = getHostApi();
|
|
180
|
-
return hostApi.call({
|
|
181
|
-
method: "entity.referenceLine.delete",
|
|
182
|
-
args
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
// src/api/entity/space.ts
|
|
188
|
-
import {
|
|
189
|
-
PluginSpaceApi
|
|
190
|
-
} from "@snaptrude/plugin-core";
|
|
191
|
-
var ClientSpaceApi = class extends PluginSpaceApi {
|
|
192
|
-
constructor() {
|
|
193
|
-
super();
|
|
194
|
-
}
|
|
195
|
-
async createRectangular({
|
|
196
|
-
position,
|
|
197
|
-
dimensions
|
|
198
|
-
}) {
|
|
199
|
-
const hostApi = getHostApi();
|
|
200
|
-
return hostApi.call({
|
|
201
|
-
method: "entity.space.createRectangular",
|
|
202
|
-
args: {
|
|
203
|
-
position,
|
|
204
|
-
dimensions
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
async createFromProfile({
|
|
209
|
-
profile,
|
|
210
|
-
extrudeHeight,
|
|
211
|
-
position
|
|
212
|
-
}) {
|
|
213
|
-
const hostApi = getHostApi();
|
|
214
|
-
return hostApi.call({
|
|
215
|
-
method: "entity.space.createFromProfile",
|
|
216
|
-
args: {
|
|
217
|
-
profile,
|
|
218
|
-
extrudeHeight,
|
|
219
|
-
position
|
|
220
|
-
}
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
async get({
|
|
224
|
-
spaceId,
|
|
225
|
-
properties
|
|
226
|
-
}) {
|
|
227
|
-
const hostApi = getHostApi();
|
|
228
|
-
return hostApi.call({
|
|
229
|
-
method: "entity.space.get",
|
|
230
|
-
args: {
|
|
231
|
-
spaceId,
|
|
232
|
-
properties
|
|
233
|
-
}
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
|
-
async getAll() {
|
|
237
|
-
const hostApi = getHostApi();
|
|
238
|
-
return hostApi.call({
|
|
239
|
-
method: "entity.space.getAll"
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
async delete({
|
|
243
|
-
spaceId
|
|
244
|
-
}) {
|
|
245
|
-
const hostApi = getHostApi();
|
|
246
|
-
return hostApi.call({
|
|
247
|
-
method: "entity.space.delete",
|
|
248
|
-
args: {
|
|
249
|
-
spaceId
|
|
250
|
-
}
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
async update({
|
|
254
|
-
spaceId,
|
|
255
|
-
properties
|
|
256
|
-
}) {
|
|
257
|
-
const hostApi = getHostApi();
|
|
258
|
-
return hostApi.call({
|
|
259
|
-
method: "entity.space.update",
|
|
260
|
-
args: {
|
|
261
|
-
spaceId,
|
|
262
|
-
properties
|
|
263
|
-
}
|
|
264
|
-
});
|
|
265
|
-
}
|
|
266
|
-
};
|
|
267
|
-
|
|
268
|
-
// src/api/entity/story.ts
|
|
269
|
-
import {
|
|
270
|
-
PluginStoryApi
|
|
271
|
-
} from "@snaptrude/plugin-core";
|
|
272
|
-
var ClientStoryApi = class extends PluginStoryApi {
|
|
273
|
-
constructor() {
|
|
274
|
-
super();
|
|
275
|
-
}
|
|
276
|
-
async get({
|
|
277
|
-
storyValue,
|
|
278
|
-
properties
|
|
279
|
-
}) {
|
|
280
|
-
const hostApi = getHostApi();
|
|
281
|
-
return hostApi.call({
|
|
282
|
-
method: "entity.story.get",
|
|
283
|
-
args: {
|
|
284
|
-
storyValue,
|
|
285
|
-
properties
|
|
286
|
-
}
|
|
287
|
-
});
|
|
288
|
-
}
|
|
289
|
-
async getAll() {
|
|
290
|
-
const hostApi = getHostApi();
|
|
291
|
-
return hostApi.call({
|
|
292
|
-
method: "entity.story.getAll"
|
|
293
|
-
});
|
|
294
|
-
}
|
|
295
|
-
async create({
|
|
296
|
-
storyValue,
|
|
297
|
-
height
|
|
298
|
-
}) {
|
|
299
|
-
const hostApi = getHostApi();
|
|
300
|
-
return hostApi.call({
|
|
301
|
-
method: "entity.story.create",
|
|
302
|
-
args: {
|
|
303
|
-
storyValue,
|
|
304
|
-
height
|
|
305
|
-
}
|
|
306
|
-
});
|
|
307
|
-
}
|
|
308
|
-
async update({
|
|
309
|
-
storyValue,
|
|
310
|
-
height
|
|
311
|
-
}) {
|
|
312
|
-
const hostApi = getHostApi();
|
|
313
|
-
return hostApi.call({
|
|
314
|
-
method: "entity.story.update",
|
|
315
|
-
args: {
|
|
316
|
-
storyValue,
|
|
317
|
-
height
|
|
318
|
-
}
|
|
319
|
-
});
|
|
320
|
-
}
|
|
321
|
-
};
|
|
322
|
-
|
|
323
|
-
// src/api/entity/index.ts
|
|
324
|
-
var ClientEntityApi = class extends PluginEntityApi {
|
|
325
|
-
constructor() {
|
|
326
|
-
super();
|
|
327
|
-
this.space = new ClientSpaceApi();
|
|
328
|
-
this.story = new ClientStoryApi();
|
|
329
|
-
this.referenceLine = new ClientReferenceLineApi();
|
|
330
|
-
this.department = new ClientDepartmentApi();
|
|
331
|
-
}
|
|
332
|
-
};
|
|
333
|
-
|
|
334
|
-
// src/api/tools/index.ts
|
|
335
|
-
import { PluginToolsApi } from "@snaptrude/plugin-core";
|
|
336
|
-
|
|
337
|
-
// src/api/tools/selection.ts
|
|
338
|
-
import { PluginSelectionApi } from "@snaptrude/plugin-core";
|
|
339
|
-
var ClientSelectionApi = class extends PluginSelectionApi {
|
|
340
|
-
constructor() {
|
|
341
|
-
super();
|
|
342
|
-
}
|
|
343
|
-
async get() {
|
|
344
|
-
const hostApi = getHostApi();
|
|
345
|
-
return hostApi.call({
|
|
346
|
-
method: "tools.selection.get"
|
|
347
|
-
});
|
|
348
|
-
}
|
|
349
|
-
};
|
|
350
|
-
|
|
351
|
-
// src/api/tools/transform.ts
|
|
352
|
-
import {
|
|
353
|
-
PluginTransformApi
|
|
354
|
-
} from "@snaptrude/plugin-core";
|
|
355
|
-
var ClientTransformApi = class extends PluginTransformApi {
|
|
356
|
-
constructor() {
|
|
357
|
-
super();
|
|
358
|
-
}
|
|
359
|
-
async move({
|
|
360
|
-
componentIds,
|
|
361
|
-
displacement
|
|
362
|
-
}) {
|
|
363
|
-
const hostApi = getHostApi();
|
|
364
|
-
return hostApi.call({
|
|
365
|
-
method: "tools.transform.move",
|
|
366
|
-
args: {
|
|
367
|
-
componentIds,
|
|
368
|
-
displacement
|
|
369
|
-
}
|
|
370
|
-
});
|
|
371
|
-
}
|
|
372
|
-
async rotate({
|
|
373
|
-
componentIds,
|
|
374
|
-
angle,
|
|
375
|
-
axis,
|
|
376
|
-
pivot
|
|
377
|
-
}) {
|
|
378
|
-
const hostApi = getHostApi();
|
|
379
|
-
return hostApi.call({
|
|
380
|
-
method: "tools.transform.rotate",
|
|
381
|
-
args: {
|
|
382
|
-
componentIds,
|
|
383
|
-
angle,
|
|
384
|
-
axis,
|
|
385
|
-
pivot
|
|
386
|
-
}
|
|
387
|
-
});
|
|
388
|
-
}
|
|
389
|
-
};
|
|
390
|
-
|
|
391
|
-
// src/api/tools/material.ts
|
|
392
|
-
import { PluginMaterialApi } from "@snaptrude/plugin-core";
|
|
393
|
-
var ClientMaterialApi = class extends PluginMaterialApi {
|
|
394
|
-
constructor() {
|
|
395
|
-
super();
|
|
396
|
-
}
|
|
397
|
-
async apply({
|
|
398
|
-
materialName,
|
|
399
|
-
componentIds
|
|
400
|
-
}) {
|
|
401
|
-
const hostApi = getHostApi();
|
|
402
|
-
return hostApi.call({
|
|
403
|
-
method: "tools.material.apply",
|
|
404
|
-
args: {
|
|
405
|
-
materialName,
|
|
406
|
-
componentIds
|
|
407
|
-
}
|
|
408
|
-
});
|
|
409
|
-
}
|
|
410
|
-
};
|
|
411
|
-
|
|
412
|
-
// src/api/tools/copy.ts
|
|
413
|
-
async function copy(args) {
|
|
414
|
-
const hostApi = getHostApi();
|
|
415
|
-
return hostApi.call({
|
|
416
|
-
method: "tools.copy",
|
|
417
|
-
args
|
|
418
|
-
});
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
// src/api/tools/offset.ts
|
|
422
|
-
async function offset(args) {
|
|
423
|
-
const hostApi = getHostApi();
|
|
424
|
-
return hostApi.call({
|
|
425
|
-
method: "tools.offset",
|
|
426
|
-
args
|
|
34
|
+
// src/rpc-proxy.ts
|
|
35
|
+
function createRpcNamespace(basePath) {
|
|
36
|
+
const build = (path) => new Proxy(NOOP, {
|
|
37
|
+
get(_target, prop) {
|
|
38
|
+
if (typeof prop !== "string" || prop === "then") return void 0;
|
|
39
|
+
return build(`${path}.${prop}`);
|
|
40
|
+
},
|
|
41
|
+
apply(_target, _thisArg, argArray) {
|
|
42
|
+
const payload = {
|
|
43
|
+
method: path,
|
|
44
|
+
args: argArray
|
|
45
|
+
};
|
|
46
|
+
return getHostApi().call(payload);
|
|
47
|
+
}
|
|
427
48
|
});
|
|
49
|
+
return build(basePath);
|
|
428
50
|
}
|
|
429
|
-
|
|
430
|
-
// src/api/tools/index.ts
|
|
431
|
-
var ClientToolsApi = class extends PluginToolsApi {
|
|
432
|
-
constructor() {
|
|
433
|
-
super();
|
|
434
|
-
this.selection = new ClientSelectionApi();
|
|
435
|
-
this.transform = new ClientTransformApi();
|
|
436
|
-
this.material = new ClientMaterialApi();
|
|
437
|
-
}
|
|
438
|
-
async copy(args) {
|
|
439
|
-
return copy(args);
|
|
440
|
-
}
|
|
441
|
-
async offset(args) {
|
|
442
|
-
return offset(args);
|
|
443
|
-
}
|
|
444
|
-
};
|
|
445
|
-
|
|
446
|
-
// src/api/units/index.ts
|
|
447
|
-
import {
|
|
448
|
-
PluginUnitsApi
|
|
449
|
-
} from "@snaptrude/plugin-core";
|
|
450
|
-
var ClientUnitsApi = class extends PluginUnitsApi {
|
|
451
|
-
constructor() {
|
|
452
|
-
super();
|
|
453
|
-
}
|
|
454
|
-
async convertFrom(args) {
|
|
455
|
-
const hostApi = getHostApi();
|
|
456
|
-
return hostApi.call({
|
|
457
|
-
method: "units.convertFrom",
|
|
458
|
-
args
|
|
459
|
-
});
|
|
460
|
-
}
|
|
461
|
-
async convertTo(args) {
|
|
462
|
-
const hostApi = getHostApi();
|
|
463
|
-
return hostApi.call({
|
|
464
|
-
method: "units.convertTo",
|
|
465
|
-
args
|
|
466
|
-
});
|
|
467
|
-
}
|
|
51
|
+
var NOOP = () => {
|
|
468
52
|
};
|
|
469
53
|
|
|
470
54
|
// src/api/index.ts
|
|
471
|
-
import { PluginApi } from "@snaptrude/plugin-core";
|
|
472
55
|
var ClientPluginApi = class _ClientPluginApi extends PluginApi {
|
|
473
56
|
constructor() {
|
|
474
57
|
super();
|
|
475
|
-
this.core =
|
|
476
|
-
this.
|
|
477
|
-
this.entity =
|
|
478
|
-
this.
|
|
58
|
+
this.core = createRpcNamespace("core");
|
|
59
|
+
this.design = createRpcNamespace("design");
|
|
60
|
+
this.entity = createRpcNamespace("entity");
|
|
61
|
+
this.program = createRpcNamespace("program");
|
|
62
|
+
this.presentation = createRpcNamespace("presentation");
|
|
479
63
|
}
|
|
480
64
|
static getInstance() {
|
|
481
65
|
if (!_ClientPluginApi.instance) {
|
|
@@ -546,26 +130,7 @@ var PluginWorker = class {
|
|
|
546
130
|
// src/index.ts
|
|
547
131
|
var snaptrude = ClientPluginApi.getInstance();
|
|
548
132
|
export {
|
|
549
|
-
ClientArcApi,
|
|
550
|
-
ClientCoreApi,
|
|
551
|
-
ClientCurveApi,
|
|
552
|
-
ClientDepartmentApi,
|
|
553
|
-
ClientEntityApi,
|
|
554
|
-
ClientGeomApi,
|
|
555
|
-
ClientLineApi,
|
|
556
|
-
ClientMaterialApi,
|
|
557
|
-
ClientMathApi,
|
|
558
133
|
ClientPluginApi,
|
|
559
|
-
ClientProfileApi,
|
|
560
|
-
ClientQuatApi,
|
|
561
|
-
ClientReferenceLineApi,
|
|
562
|
-
ClientSelectionApi,
|
|
563
|
-
ClientSpaceApi,
|
|
564
|
-
ClientStoryApi,
|
|
565
|
-
ClientToolsApi,
|
|
566
|
-
ClientTransformApi,
|
|
567
|
-
ClientUnitsApi,
|
|
568
|
-
ClientVec3Api,
|
|
569
134
|
PluginWorker,
|
|
570
135
|
createHostApi,
|
|
571
136
|
getHostApi,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/api/core/index.ts","../src/api/core/math/index.ts","../src/api/core/math/vec3.ts","../src/api/core/math/quat.ts","../src/api/core/geom/index.ts","../src/api/core/geom/line.ts","../src/api/core/geom/arc.ts","../src/api/core/geom/curve.ts","../src/api/core/geom/profile.ts","../src/host-api.ts","../src/api/entity/index.ts","../src/api/entity/department.ts","../src/api/entity/referenceLine.ts","../src/api/entity/space.ts","../src/api/entity/story.ts","../src/api/tools/index.ts","../src/api/tools/selection.ts","../src/api/tools/transform.ts","../src/api/tools/material.ts","../src/api/tools/copy.ts","../src/api/tools/offset.ts","../src/api/units/index.ts","../src/api/index.ts","../src/plugin-worker.ts","../src/index.ts"],"sourcesContent":["import { PluginCoreApi } from \"@snaptrude/plugin-core\"\nimport { ClientMathApi } from \"./math\"\nimport { ClientGeomApi } from \"./geom\"\n\nexport class ClientCoreApi extends PluginCoreApi {\n public math: ClientMathApi\n public geom: ClientGeomApi\n\n constructor() {\n super()\n this.math = new ClientMathApi()\n this.geom = new ClientGeomApi()\n }\n}\n\nexport * from \"./math\"\nexport * from \"./geom\"\n","import { PluginMathApi } from \"@snaptrude/plugin-core\"\nimport { ClientVec3Api } from \"./vec3\"\nimport { ClientQuatApi } from \"./quat\"\n\nexport class ClientMathApi extends PluginMathApi {\n public vec3: ClientVec3Api\n public quat: ClientQuatApi\n\n constructor() {\n super()\n this.vec3 = new ClientVec3Api()\n this.quat = new ClientQuatApi()\n }\n}\n\nexport * from \"./vec3\"\nexport * from \"./quat\"\n","import { PluginVec3Api } from \"@snaptrude/plugin-core\"\n\nexport class ClientVec3Api extends PluginVec3Api {\n constructor() {\n super()\n }\n}\n","import { PluginQuatApi } from \"@snaptrude/plugin-core\"\n\nexport class ClientQuatApi extends PluginQuatApi {\n constructor() {\n super()\n }\n}\n","import { PluginGeomApi } from \"@snaptrude/plugin-core\"\nimport { ClientLineApi } from \"./line\"\nimport { ClientArcApi } from \"./arc\"\nimport { ClientCurveApi } from \"./curve\"\nimport { ClientProfileApi } from \"./profile\"\n\nexport class ClientGeomApi extends PluginGeomApi {\n public line: ClientLineApi\n public arc: ClientArcApi\n public curve: ClientCurveApi\n public profile: ClientProfileApi\n\n constructor() {\n super()\n this.line = new ClientLineApi()\n this.arc = new ClientArcApi()\n this.curve = new ClientCurveApi()\n this.profile = new ClientProfileApi()\n }\n}\n\nexport * from \"./line\"\nexport * from \"./arc\"\nexport * from \"./curve\"\nexport * from \"./profile\"\n","import { PluginLineApi } from \"@snaptrude/plugin-core\"\n\nexport class ClientLineApi extends PluginLineApi {\n constructor() {\n super()\n }\n}\n","import { PluginArcApi } from \"@snaptrude/plugin-core\"\n\nexport class ClientArcApi extends PluginArcApi {\n constructor() {\n super()\n }\n}\n","import { PluginCurveApi } from \"@snaptrude/plugin-core\"\n\nexport class ClientCurveApi extends PluginCurveApi {\n constructor() {\n super()\n }\n}\n","import { PluginProfileApi } from \"@snaptrude/plugin-core\"\nimport type { PProfile, PluginProfileFromLinePointsArgs } from \"@snaptrude/plugin-core\"\nimport { getHostApi } from \"../../../host-api\"\n\nexport class ClientProfileApi extends PluginProfileApi {\n constructor() {\n super()\n }\n\n public async fromLinePoints(args: PluginProfileFromLinePointsArgs): Promise<PProfile> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"core.geom.profile.fromLinePoints\",\n args,\n })\n }\n}\n","import * as Comlink from \"comlink\"\nimport type {\n PluginApiMethod,\n PluginApiCallPayload,\n PluginApiCallWrappedResult,\n PluginApiCallResult,\n} from \"@snaptrude/plugin-core\"\n\nexport interface HostApi {\n call<M extends PluginApiMethod>(\n payload: PluginApiCallPayload<M>\n ): Promise<PluginApiCallWrappedResult<M>>\n}\n\nexport interface HostApiWrapped {\n call<M extends PluginApiMethod>(\n payload: PluginApiCallPayload<M>\n ): Promise<PluginApiCallResult<M>>\n}\n\nexport function createHostApi(endpoint?: Comlink.Endpoint): HostApi {\n return Comlink.wrap<HostApi>(\n endpoint ?? (globalThis as unknown as Comlink.Endpoint)\n ) as unknown as HostApi\n}\n\nlet _instance: HostApi | null = null\n\nexport function getHostApi(): HostApiWrapped {\n if (!_instance) {\n _instance = createHostApi()\n }\n return {\n call: async <M extends PluginApiMethod>(payload: PluginApiCallPayload<M>): Promise<PluginApiCallResult<M>> => {\n if (!_instance) {\n throw new Error(\"Host API not initialized\")\n }\n return _instance.call(payload).then(result => {\n if (result.success) {\n return result.data\n } else {\n throw new Error(result.error)\n }\n })\n }\n }\n}\n","import { PluginEntityApi } from \"@snaptrude/plugin-core\"\nimport { ClientDepartmentApi } from \"./department\"\nimport { ClientReferenceLineApi } from \"./referenceLine\"\nimport { ClientSpaceApi } from \"./space\"\nimport { ClientStoryApi } from \"./story\"\n\nexport class ClientEntityApi extends PluginEntityApi {\n public space: ClientSpaceApi\n public story: ClientStoryApi\n public referenceLine: ClientReferenceLineApi\n public department: ClientDepartmentApi\n\n constructor() {\n super()\n this.space = new ClientSpaceApi()\n this.story = new ClientStoryApi()\n this.referenceLine = new ClientReferenceLineApi()\n this.department = new ClientDepartmentApi()\n }\n}\n\nexport * from \"./department\"\nexport * from \"./referenceLine\"\nexport * from \"./space\"\nexport * from \"./story\"\n","import {\n PluginDepartmentApi,\n PluginDepartmentCreateArgs,\n PluginDepartmentCreateResult,\n PluginDepartmentGetAllResult,\n} from \"@snaptrude/plugin-core\"\nimport { getHostApi } from \"../../host-api\"\n\nexport class ClientDepartmentApi extends PluginDepartmentApi {\n constructor() {\n super()\n }\n\n public async create(\n args: PluginDepartmentCreateArgs\n ): Promise<PluginDepartmentCreateResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.department.create\",\n args,\n })\n }\n\n public async getAll(): Promise<PluginDepartmentGetAllResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.department.getAll\",\n })\n }\n}\n","import {\n PluginReferenceLineApi,\n PluginReferenceLineCreateMultiArgs,\n PluginReferenceLineCreateMultiResult,\n PluginReferenceLineGetArgs,\n PluginReferenceLineGetResult,\n PluginReferenceLineGetAllResult,\n PluginReferenceLineDeleteArgs,\n PluginReferenceLineDeleteResult,\n} from \"@snaptrude/plugin-core\"\nimport { getHostApi } from \"../../host-api\"\n\nexport class ClientReferenceLineApi extends PluginReferenceLineApi {\n constructor() {\n super()\n }\n\n public async createMulti(\n args: PluginReferenceLineCreateMultiArgs\n ): Promise<PluginReferenceLineCreateMultiResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.referenceLine.createMulti\",\n args,\n })\n }\n\n public async get(\n args: PluginReferenceLineGetArgs\n ): Promise<PluginReferenceLineGetResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.referenceLine.get\",\n args,\n })\n }\n\n public async getAll(): Promise<PluginReferenceLineGetAllResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.referenceLine.getAll\",\n })\n }\n\n public async delete(\n args: PluginReferenceLineDeleteArgs\n ): Promise<PluginReferenceLineDeleteResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.referenceLine.delete\",\n args,\n })\n }\n}\n","import {\n PluginSpaceApi,\n PluginSpaceCreateRectangularArgs,\n PluginSpaceCreateRectangularResult,\n PluginSpaceCreateFromProfileArgs,\n PluginSpaceCreateFromProfileResult,\n PluginSpaceDeleteArgs,\n PluginSpaceDeleteResult,\n PluginSpaceGetArgs,\n PluginSpaceGetResult,\n PluginSpaceGetAllResult,\n PluginSpaceUpdateArgs,\n PluginSpaceUpdateResult,\n} from \"@snaptrude/plugin-core\"\nimport { getHostApi } from \"../../host-api\"\n\nexport class ClientSpaceApi extends PluginSpaceApi {\n constructor() {\n super()\n }\n\n public async createRectangular({\n position,\n dimensions,\n }: PluginSpaceCreateRectangularArgs): Promise<PluginSpaceCreateRectangularResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.space.createRectangular\",\n args: {\n position,\n dimensions,\n },\n })\n }\n\n public async createFromProfile({\n profile,\n extrudeHeight,\n position,\n }: PluginSpaceCreateFromProfileArgs): Promise<PluginSpaceCreateFromProfileResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.space.createFromProfile\",\n args: {\n profile,\n extrudeHeight,\n position,\n },\n })\n }\n\n public async get({\n spaceId,\n properties,\n }: PluginSpaceGetArgs): Promise<PluginSpaceGetResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.space.get\",\n args: {\n spaceId,\n properties,\n },\n })\n }\n\n public async getAll(): Promise<PluginSpaceGetAllResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.space.getAll\",\n })\n }\n\n public async delete({\n spaceId,\n }: PluginSpaceDeleteArgs): Promise<PluginSpaceDeleteResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.space.delete\",\n args: {\n spaceId,\n },\n })\n }\n\n public async update({\n spaceId,\n properties,\n }: PluginSpaceUpdateArgs): Promise<PluginSpaceUpdateResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.space.update\",\n args: {\n spaceId,\n properties,\n },\n })\n }\n}\n","import {\n PluginStoryApi,\n PluginStoryGetArgs,\n PluginStoryGetResult,\n PluginStoryGetAllResult,\n PluginStoryCreateArgs,\n PluginStoryCreateResult,\n PluginStoryUpdateArgs,\n PluginStoryUpdateResult,\n} from \"@snaptrude/plugin-core\"\nimport { getHostApi } from \"../../host-api\"\n\nexport class ClientStoryApi extends PluginStoryApi {\n constructor() {\n super()\n }\n\n public async get({\n storyValue,\n properties,\n }: PluginStoryGetArgs): Promise<PluginStoryGetResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.story.get\",\n args: {\n storyValue,\n properties,\n },\n })\n }\n\n public async getAll(): Promise<PluginStoryGetAllResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.story.getAll\",\n })\n }\n\n public async create({\n storyValue,\n height,\n }: PluginStoryCreateArgs): Promise<PluginStoryCreateResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.story.create\",\n args: {\n storyValue,\n height,\n },\n })\n }\n\n public async update({\n storyValue,\n height,\n }: PluginStoryUpdateArgs): Promise<PluginStoryUpdateResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"entity.story.update\",\n args: {\n storyValue,\n height,\n },\n })\n }\n}\n","import { PluginToolsApi } from \"@snaptrude/plugin-core\"\nimport type {\n PluginCopyArgs,\n PluginCopyResult,\n PluginOffsetArgs,\n PluginOffsetResult,\n} from \"@snaptrude/plugin-core\"\nimport { ClientSelectionApi } from \"./selection\"\nimport { ClientTransformApi } from \"./transform\"\nimport { ClientMaterialApi } from \"./material\"\nimport { copy } from \"./copy\"\nimport { offset } from \"./offset\"\n\nexport class ClientToolsApi extends PluginToolsApi {\n public selection: ClientSelectionApi\n public transform: ClientTransformApi\n public material: ClientMaterialApi\n constructor() {\n super()\n this.selection = new ClientSelectionApi()\n this.transform = new ClientTransformApi()\n this.material = new ClientMaterialApi()\n }\n\n public async copy(args: PluginCopyArgs): Promise<PluginCopyResult> {\n return copy(args)\n }\n\n public async offset(args: PluginOffsetArgs): Promise<PluginOffsetResult> {\n return offset(args)\n }\n}\n\nexport * from \"./selection\"\nexport * from \"./transform\"\nexport * from \"./material\"","import { PluginSelectionApi, PluginSelectionGetResult } from \"@snaptrude/plugin-core\"\nimport { getHostApi } from \"../../host-api\"\n\nexport class ClientSelectionApi extends PluginSelectionApi {\n constructor() {\n super()\n }\n\n public async get(): Promise<PluginSelectionGetResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"tools.selection.get\",\n })\n }\n}\n","import {\n PluginTransformApi,\n PluginMoveArgs,\n PluginRotateArgs,\n} from \"@snaptrude/plugin-core\"\nimport { getHostApi } from \"../../host-api\"\n\nexport class ClientTransformApi extends PluginTransformApi {\n constructor() {\n super()\n }\n\n public async move({\n componentIds,\n displacement,\n }: PluginMoveArgs): Promise<void> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"tools.transform.move\",\n args: {\n componentIds,\n displacement,\n },\n })\n }\n\n public async rotate({\n componentIds,\n angle,\n axis,\n pivot,\n }: PluginRotateArgs): Promise<void> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"tools.transform.rotate\",\n args: {\n componentIds,\n angle,\n axis,\n pivot,\n },\n })\n }\n}\n","import { PluginMaterialApi, PluginMaterialArgs } from \"@snaptrude/plugin-core\"\nimport { getHostApi } from \"../../host-api\"\n\nexport class ClientMaterialApi extends PluginMaterialApi {\n constructor() {\n super()\n }\n\n public async apply({\n materialName,\n componentIds,\n }: PluginMaterialArgs): Promise<void> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"tools.material.apply\",\n args: {\n materialName,\n componentIds,\n },\n })\n }\n}\n","import type { PluginCopyArgs, PluginCopyResult } from \"@snaptrude/plugin-core\"\nimport { getHostApi } from \"../../host-api\"\n\nexport async function copy(args: PluginCopyArgs): Promise<PluginCopyResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"tools.copy\",\n args,\n })\n}\n","import type {\n PluginOffsetArgs,\n PluginOffsetResult,\n} from \"@snaptrude/plugin-core\"\nimport { getHostApi } from \"../../host-api\"\n\nexport async function offset(\n args: PluginOffsetArgs,\n): Promise<PluginOffsetResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"tools.offset\",\n args,\n })\n}\n","import {\n PluginUnitsApi,\n PluginUnitsConvertFromArgs,\n PluginUnitsConvertFromResult,\n PluginUnitsConvertToArgs,\n PluginUnitsConvertToResult,\n} from \"@snaptrude/plugin-core\"\nimport { getHostApi } from \"../../host-api\"\n\nexport class ClientUnitsApi extends PluginUnitsApi {\n constructor() {\n super()\n }\n\n public async convertFrom(\n args: PluginUnitsConvertFromArgs,\n ): Promise<PluginUnitsConvertFromResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"units.convertFrom\",\n args,\n })\n }\n\n public async convertTo(\n args: PluginUnitsConvertToArgs,\n ): Promise<PluginUnitsConvertToResult> {\n const hostApi = getHostApi()\n return hostApi.call({\n method: \"units.convertTo\",\n args,\n })\n }\n}\n","import { ClientCoreApi } from \"./core\"\nimport { ClientEntityApi } from \"./entity\"\nimport { ClientToolsApi } from \"./tools\"\nimport { ClientUnitsApi } from \"./units\"\nimport { PluginApi } from \"@snaptrude/plugin-core\"\n\nexport class ClientPluginApi extends PluginApi {\n private static instance: ClientPluginApi\n\n public core: ClientCoreApi\n public tools: ClientToolsApi\n public entity: ClientEntityApi\n public units: ClientUnitsApi\n\n private constructor() {\n super()\n this.core = new ClientCoreApi()\n this.tools = new ClientToolsApi()\n this.entity = new ClientEntityApi()\n this.units = new ClientUnitsApi()\n }\n\n static getInstance(): ClientPluginApi {\n if (!ClientPluginApi.instance) {\n ClientPluginApi.instance = new ClientPluginApi()\n }\n return ClientPluginApi.instance\n }\n}\n\nexport * from \"./core\"\nexport * from \"./entity\"\nexport * from \"./tools\"\nexport * from \"./units\"\n","import * as Comlink from \"comlink\"\n\nexport interface UIMessage {\n action: string\n payload: unknown\n}\n\ninterface PluginConfig {\n pluginId: string\n}\n\n/**\n * Base class for Snaptrude plugin workers.\n *\n * Handles Comlink wiring, host communication, and the standard lifecycle\n * methods (`init`, `destroy`, `ping`, `onUIMessage`). Subclass this and\n * override only the methods you need — then call `start()` to expose the\n * worker API.\n *\n * The plugin ID is received automatically from the host during\n * initialization — no need to pass it manually.\n *\n * @example\n * ```ts\n * import { PluginWorker } from \"@snaptrude/plugin-client\";\n *\n * class MyPlugin extends PluginWorker {\n * async onUIMessage(message: UIMessage) {\n * // handle messages from the UI panel\n * }\n * }\n *\n * new MyPlugin().start();\n * ```\n */\nexport abstract class PluginWorker {\n protected pluginId!: string\n private hostAPI: Comlink.Remote<Record<string, unknown>>\n\n constructor() {\n this.hostAPI = Comlink.wrap<Record<string, unknown>>(\n self as unknown as Comlink.Endpoint\n )\n }\n\n protected sendToUI(action: string, payload: unknown): void {\n ;(this.hostAPI as Record<string, any>).ui.sendToUI({ action, payload })\n }\n\n /**\n * Signal the host that this plugin has finished its work and should be\n * stopped. Use this in headless (UI-less) plugins that run a task and\n * self-terminate.\n */\n protected complete(): void {\n ;(this.hostAPI as Record<string, any>).lifecycle.complete()\n }\n\n async init(): Promise<void> {\n console.log(this.pluginId, \"init() called\")\n console.log(this.pluginId, \"Initialization complete\")\n }\n\n async destroy(): Promise<void> {\n console.log(this.pluginId, \"destroy() called — cleaning up\")\n }\n\n async ping(): Promise<string> {\n return \"pong\"\n }\n\n async onUIMessage(_message: UIMessage): Promise<void> {\n // Override in subclass to handle UI messages\n }\n\n /**\n * Expose the worker API via Comlink and start listening.\n * Call this once after constructing the plugin instance.\n *\n * The host calls `init(config)` with `{ pluginId }`,\n * which is captured here to set `this.pluginId` before the\n * subclass's `init()` runs.\n */\n start(): void {\n Comlink.expose(\n {\n init: (config: PluginConfig) => {\n this.pluginId = config.pluginId\n return this.init()\n },\n destroy: () => this.destroy(),\n ping: () => this.ping(),\n onUIMessage: (message: UIMessage) => this.onUIMessage(message),\n },\n self as unknown as Comlink.Endpoint\n )\n console.log(\"Worker loaded, API exposed via Comlink\")\n }\n}\n","import { ClientPluginApi } from \"./api\"\n\nexport * from \"./api\"\nexport * from \"./host-api\"\nexport * from \"./plugin-worker\"\n\n/**\n * The Snaptrude plugin client API.\n *\n * The main entry point for plugins to interact with the Snaptrude platform.\n */\nexport const snaptrude = ClientPluginApi.getInstance()\n"],"mappings":";AAAA,SAAS,qBAAqB;;;ACA9B,SAAS,qBAAqB;;;ACA9B,SAAS,qBAAqB;AAEvB,IAAM,gBAAN,cAA4B,cAAc;AAAA,EAC/C,cAAc;AACZ,UAAM;AAAA,EACR;AACF;;;ACNA,SAAS,qBAAqB;AAEvB,IAAM,gBAAN,cAA4B,cAAc;AAAA,EAC/C,cAAc;AACZ,UAAM;AAAA,EACR;AACF;;;AFFO,IAAM,gBAAN,cAA4B,cAAc;AAAA,EAI/C,cAAc;AACZ,UAAM;AACN,SAAK,OAAO,IAAI,cAAc;AAC9B,SAAK,OAAO,IAAI,cAAc;AAAA,EAChC;AACF;;;AGbA,SAAS,qBAAqB;;;ACA9B,SAAS,qBAAqB;AAEvB,IAAM,gBAAN,cAA4B,cAAc;AAAA,EAC/C,cAAc;AACZ,UAAM;AAAA,EACR;AACF;;;ACNA,SAAS,oBAAoB;AAEtB,IAAM,eAAN,cAA2B,aAAa;AAAA,EAC7C,cAAc;AACZ,UAAM;AAAA,EACR;AACF;;;ACNA,SAAS,sBAAsB;AAExB,IAAM,iBAAN,cAA6B,eAAe;AAAA,EACjD,cA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AAU,SAAS;AAAA,EAC5D;AAAA,EAEA,MAAM,OAAsB;AAC1B,YAAQ,IAAI,KAAK,UAAU,eAAe;AAC1C,YAAQ,IAAI,KAAK,UAAU,yBAAyB;AAAA,EACtD;AAAA,EAEA,MAAM,UAAyB;AAC7B,YAAQ,IAAI,KAAK,UAAU,qCAAgC;AAAA,EAC7D;AAAA,EAEA,MAAM,OAAwB;AAC5B,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,YAAY,UAAoC;AAAA,EAEtD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,QAAc;AACZ,IAAQ;AAAA,MACN;AAAA,QACE,MAAM,CAAC,WAAyB;AAC9B,eAAK,WAAW,OAAO;AACvB,iBAAO,KAAK,KAAK;AAAA,QACnB;AAAA,QACA,SAAS,MAAM,KAAK,QAAQ;AAAA,QAC5B,MAAM,MAAM,KAAK,KAAK;AAAA,QACtB,aAAa,CAAC,YAAuB,KAAK,YAAY,OAAO;AAAA,MAC/D;AAAA,MACA;AAAA,IACF;AACA,YAAQ,IAAI,wCAAwC;AAAA,EACtD;AACF;;;ACvFO,IAAM,YAAY,gBAAgB,YAAY;","names":["Comlink"]}
|
|
1
|
+
{"version":3,"sources":["../src/api/index.ts","../src/host-api.ts","../src/rpc-proxy.ts","../src/plugin-worker.ts","../src/index.ts"],"sourcesContent":["import {\n PluginApi,\n PluginCoreApi,\n PluginDesignApi,\n PluginEntityApi,\n PluginProgramApi,\n PluginPresentationApi,\n} from \"@snaptrude/plugin-core\"\nimport { createRpcNamespace } from \"../rpc-proxy\"\n\nexport class ClientPluginApi extends PluginApi {\n private static instance: ClientPluginApi\n\n /**\n * Every namespace is fully remote under the all-handle model: math/geom now\n * cross to the host (values are opaque handles), so there is no in-worker\n * compute left. All dispatch through a single generic RPC Proxy. Units live\n * under `core.units`, so they ride the `core` proxy.\n */\n public core: PluginCoreApi\n public design: PluginDesignApi\n public entity: PluginEntityApi\n public program: PluginProgramApi\n public presentation: PluginPresentationApi\n\n private constructor() {\n super()\n this.core = createRpcNamespace<PluginCoreApi>(\"core\")\n this.design = createRpcNamespace<PluginDesignApi>(\"design\")\n this.entity = createRpcNamespace<PluginEntityApi>(\"entity\")\n this.program = createRpcNamespace<PluginProgramApi>(\"program\")\n this.presentation =\n createRpcNamespace<PluginPresentationApi>(\"presentation\")\n }\n\n static getInstance(): ClientPluginApi {\n if (!ClientPluginApi.instance) {\n ClientPluginApi.instance = new ClientPluginApi()\n }\n return ClientPluginApi.instance\n }\n}\n","import * as Comlink from \"comlink\"\nimport type {\n PluginApiMethod,\n PluginApiCallPayload,\n PluginApiCallWrappedResult,\n PluginApiCallResult,\n} from \"@snaptrude/plugin-core\"\n\nexport interface HostApi {\n call<M extends PluginApiMethod>(\n payload: PluginApiCallPayload<M>\n ): Promise<PluginApiCallWrappedResult<M>>\n}\n\nexport interface HostApiWrapped {\n call<M extends PluginApiMethod>(\n payload: PluginApiCallPayload<M>\n ): Promise<PluginApiCallResult<M>>\n}\n\nexport function createHostApi(endpoint?: Comlink.Endpoint): HostApi {\n return Comlink.wrap<HostApi>(\n endpoint ?? (globalThis as unknown as Comlink.Endpoint)\n ) as unknown as HostApi\n}\n\nlet _instance: HostApi | null = null\n\nexport function getHostApi(): HostApiWrapped {\n if (!_instance) {\n _instance = createHostApi()\n }\n return {\n call: async <M extends PluginApiMethod>(payload: PluginApiCallPayload<M>): Promise<PluginApiCallResult<M>> => {\n if (!_instance) {\n throw new Error(\"Host API not initialized\")\n }\n return _instance.call(payload).then(result => {\n if (result.success) {\n return result.data\n } else {\n throw new Error(result.error)\n }\n })\n }\n }\n}\n","import type {\n PluginApiCallPayload,\n PluginApiMethod,\n} from \"@snaptrude/plugin-core\"\nimport { getHostApi } from \"./host-api\"\n\n/**\n * Build a namespace object whose nested property access maps to a\n * dot-separated host RPC method path, and whose every call dispatches that\n * path through the host bridge.\n *\n * The host exposes the entire plugin API behind a single generic `call()`\n * (see the host `bridge.ts`), and the method string is exactly the property\n * path — so one Proxy replaces every hand-written per-method RPC wrapper for\n * every namespace (`core.*`, `design.*`, `entity.*`):\n *\n * The POSITIONAL transport forwards the whole argument tuple; the host router\n * spreads it back into the resolved method (`fn(...args)`):\n *\n * ```ts\n * snaptrude.core.math.vec3.new(1, 2, 3)\n * // → getHostApi().call({ method: \"core.math.vec3.new\", args: [1, 2, 3] })\n * ```\n *\n * Typed at the call site, e.g. `createRpcNamespace<PluginEntityApi>(\"entity\")`.\n * The Proxy is structurally cast to the abstract API type — argument and\n * return types are enforced by that type, while dispatch is dynamic.\n *\n * Every namespace uses this — including `core.math.*` and `core.geom.*`: under\n * the all-handle model there is no in-worker compute; math and geometry are\n * host calls like everything else.\n */\nexport function createRpcNamespace<T extends object>(basePath: string): T {\n const build = (path: string): unknown =>\n new Proxy(NOOP, {\n get(_target, prop) {\n // Symbols and `then` must not resolve to a callable proxy, otherwise\n // the namespace would look thenable and break Promise resolution if it\n // ever reached an `await`.\n if (typeof prop !== \"string\" || prop === \"then\") return undefined\n return build(`${path}.${prop}`)\n },\n apply(_target, _thisArg, argArray: unknown[]) {\n const payload = {\n method: path,\n args: argArray,\n } as unknown as PluginApiCallPayload<PluginApiMethod>\n return getHostApi().call(payload)\n },\n })\n\n return build(basePath) as T\n}\n\n/** Proxy target must be callable for the `apply` trap; identity is irrelevant. */\nconst NOOP = (): void => {}\n","import * as Comlink from \"comlink\"\n\nexport interface UIMessage {\n action: string\n payload: unknown\n}\n\ninterface PluginConfig {\n pluginId: string\n}\n\n/**\n * Base class for Snaptrude plugin workers.\n *\n * Handles Comlink wiring, host communication, and the standard lifecycle\n * methods (`init`, `destroy`, `ping`, `onUIMessage`). Subclass this and\n * override only the methods you need — then call `start()` to expose the\n * worker API.\n *\n * The plugin ID is received automatically from the host during\n * initialization — no need to pass it manually.\n *\n * @example\n * ```ts\n * import { PluginWorker } from \"@snaptrude/plugin-client\";\n *\n * class MyPlugin extends PluginWorker {\n * async onUIMessage(message: UIMessage) {\n * // handle messages from the UI panel\n * }\n * }\n *\n * new MyPlugin().start();\n * ```\n */\nexport abstract class PluginWorker {\n protected pluginId!: string\n private hostAPI: Comlink.Remote<Record<string, unknown>>\n\n constructor() {\n this.hostAPI = Comlink.wrap<Record<string, unknown>>(\n self as unknown as Comlink.Endpoint\n )\n }\n\n protected sendToUI(action: string, payload: unknown): void {\n ;(this.hostAPI as Record<string, any>).ui.sendToUI({ action, payload })\n }\n\n /**\n * Signal the host that this plugin has finished its work and should be\n * stopped. Use this in headless (UI-less) plugins that run a task and\n * self-terminate.\n */\n protected complete(): void {\n ;(this.hostAPI as Record<string, any>).lifecycle.complete()\n }\n\n async init(): Promise<void> {\n console.log(this.pluginId, \"init() called\")\n console.log(this.pluginId, \"Initialization complete\")\n }\n\n async destroy(): Promise<void> {\n console.log(this.pluginId, \"destroy() called — cleaning up\")\n }\n\n async ping(): Promise<string> {\n return \"pong\"\n }\n\n async onUIMessage(_message: UIMessage): Promise<void> {\n // Override in subclass to handle UI messages\n }\n\n /**\n * Expose the worker API via Comlink and start listening.\n * Call this once after constructing the plugin instance.\n *\n * The host calls `init(config)` with `{ pluginId }`,\n * which is captured here to set `this.pluginId` before the\n * subclass's `init()` runs.\n */\n start(): void {\n Comlink.expose(\n {\n init: (config: PluginConfig) => {\n this.pluginId = config.pluginId\n return this.init()\n },\n destroy: () => this.destroy(),\n ping: () => this.ping(),\n onUIMessage: (message: UIMessage) => this.onUIMessage(message),\n },\n self as unknown as Comlink.Endpoint\n )\n console.log(\"Worker loaded, API exposed via Comlink\")\n }\n}\n","import { ClientPluginApi } from \"./api\"\n\nexport * from \"./api\"\nexport * from \"./host-api\"\nexport * from \"./plugin-worker\"\n\n/**\n * The Snaptrude plugin client API.\n *\n * The main entry point for plugins to interact with the Snaptrude platform.\n */\nexport const snaptrude = ClientPluginApi.getInstance()\n"],"mappings":";AAAA;AAAA,EACE;AAAA,OAMK;;;ACPP,YAAY,aAAa;AAoBlB,SAAS,cAAc,UAAsC;AAClE,S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BAAgB;AAAA,IACjD;AACA,WAAO,iBAAgB;AAAA,EACzB;AACF;;;AGzCA,YAAYA,cAAa;AAmClB,IAAe,eAAf,MAA4B;AAAA,EAIjC,cAAc;AACZ,SAAK,UAAkB;AAAA,MACrB;AAAA,IACF;AAAA,EACF;AAAA,EAEU,SAAS,QAAgB,SAAwB;AACzD;AAAC,IAAC,KAAK,QAAgC,GAAG,SAAS,EAAE,QAAQ,QAAQ,CAAC;AAAA,EACxE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOU,WAAiB;AACzB;AAAC,IAAC,KAAK,QAAgC,UAAU,SAAS;AAAA,EAC5D;AAAA,EAEA,MAAM,OAAsB;AAC1B,YAAQ,IAAI,KAAK,UAAU,eAAe;AAC1C,YAAQ,IAAI,KAAK,UAAU,yBAAyB;AAAA,EACtD;AAAA,EAEA,MAAM,UAAyB;AAC7B,YAAQ,IAAI,KAAK,UAAU,qCAAgC;AAAA,EAC7D;AAAA,EAEA,MAAM,OAAwB;AAC5B,WAAO;AAAA,EACT;AAAA,EAEA,MAAM,YAAY,UAAoC;AAAA,EAEtD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUA,QAAc;AACZ,IAAQ;AAAA,MACN;AAAA,QACE,MAAM,CAAC,WAAyB;AAC9B,eAAK,WAAW,OAAO;AACvB,iBAAO,KAAK,KAAK;AAAA,QACnB;AAAA,QACA,SAAS,MAAM,KAAK,QAAQ;AAAA,QAC5B,MAAM,MAAM,KAAK,KAAK;AAAA,QACtB,aAAa,CAAC,YAAuB,KAAK,YAAY,OAAO;AAAA,MAC/D;AAAA,MACA;AAAA,IACF;AACA,YAAQ,IAAI,wCAAwC;AAAA,EACtD;AACF;;;ACvFO,IAAM,YAAY,gBAAgB,YAAY;","names":["Comlink"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build a namespace object whose nested property access maps to a
|
|
3
|
+
* dot-separated host RPC method path, and whose every call dispatches that
|
|
4
|
+
* path through the host bridge.
|
|
5
|
+
*
|
|
6
|
+
* The host exposes the entire plugin API behind a single generic `call()`
|
|
7
|
+
* (see the host `bridge.ts`), and the method string is exactly the property
|
|
8
|
+
* path — so one Proxy replaces every hand-written per-method RPC wrapper for
|
|
9
|
+
* every namespace (`core.*`, `design.*`, `entity.*`):
|
|
10
|
+
*
|
|
11
|
+
* The POSITIONAL transport forwards the whole argument tuple; the host router
|
|
12
|
+
* spreads it back into the resolved method (`fn(...args)`):
|
|
13
|
+
*
|
|
14
|
+
* ```ts
|
|
15
|
+
* snaptrude.core.math.vec3.new(1, 2, 3)
|
|
16
|
+
* // → getHostApi().call({ method: "core.math.vec3.new", args: [1, 2, 3] })
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* Typed at the call site, e.g. `createRpcNamespace<PluginEntityApi>("entity")`.
|
|
20
|
+
* The Proxy is structurally cast to the abstract API type — argument and
|
|
21
|
+
* return types are enforced by that type, while dispatch is dynamic.
|
|
22
|
+
*
|
|
23
|
+
* Every namespace uses this — including `core.math.*` and `core.geom.*`: under
|
|
24
|
+
* the all-handle model there is no in-worker compute; math and geometry are
|
|
25
|
+
* host calls like everything else.
|
|
26
|
+
*/
|
|
27
|
+
export declare function createRpcNamespace<T extends object>(basePath: string): T;
|
|
28
|
+
//# sourceMappingURL=rpc-proxy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpc-proxy.d.ts","sourceRoot":"","sources":["../src/rpc-proxy.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,CAAC,CAoBxE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@snaptrude/plugin-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"comlink": "^4.4.2",
|
|
21
|
-
"@snaptrude/plugin-core": "0.
|
|
21
|
+
"@snaptrude/plugin-core": "0.5.0"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"tsup": "^8.5.1",
|