@snaptrude/plugin-client 0.2.9 → 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 +38 -46
- package/CHANGELOG.md +11 -0
- package/CLAUDE.md +1 -1
- package/dist/api/index.d.ts +12 -16
- package/dist/api/index.d.ts.map +1 -1
- package/dist/index.cjs +23 -655
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +25 -648
- 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 -22
- 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/documentation/aiInspiration.d.ts +0 -24
- package/dist/api/documentation/aiInspiration.d.ts.map +0 -1
- package/dist/api/documentation/index.d.ts +0 -8
- package/dist/api/documentation/index.d.ts.map +0 -1
- package/dist/api/entity/buildableEnvelope.d.ts +0 -7
- package/dist/api/entity/buildableEnvelope.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 -20
- 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 -15
- 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 -14
- package/dist/api/tools/index.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/documentation/aiInspiration.ts +0 -193
- package/src/api/documentation/index.ts +0 -13
- package/src/api/entity/buildableEnvelope.ts +0 -34
- package/src/api/entity/department.ts +0 -30
- package/src/api/entity/index.ts +0 -29
- package/src/api/entity/referenceLine.ts +0 -54
- package/src/api/entity/space.ts +0 -160
- package/src/api/entity/story.ts +0 -66
- package/src/api/tools/copy.ts +0 -10
- package/src/api/tools/index.ts +0 -33
- 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/AGENTS.md
CHANGED
|
@@ -7,13 +7,16 @@ Plugins import `snaptrude` from this package to interact with the Snaptrude host
|
|
|
7
7
|
|
|
8
8
|
> Source of truth: [`packages/plugin-core/AGENTS.md`](../plugin-core/AGENTS.md)
|
|
9
9
|
|
|
10
|
-
This package
|
|
11
|
-
|
|
10
|
+
This package implements the API surface defined in `@snaptrude/plugin-core`. Only the
|
|
11
|
+
root `PluginApi` class is extended; every namespace under it is satisfied structurally
|
|
12
|
+
by a generic RPC proxy (see below). When plugin-core changes its top-level shape,
|
|
13
|
+
this package must be updated to match.
|
|
12
14
|
|
|
13
15
|
## What this package contains
|
|
14
16
|
|
|
15
|
-
- `src/api
|
|
16
|
-
- `src/
|
|
17
|
+
- `src/api/index.ts` — `ClientPluginApi`: wires one generic RPC proxy per top-level namespace
|
|
18
|
+
- `src/rpc-proxy.ts` — `createRpcNamespace()`: Proxy mapping dotted property paths to host RPC calls
|
|
19
|
+
- `src/host-api.ts` — Comlink RPC wrapper (`HostApi.call()`); unwraps success/error results
|
|
17
20
|
- `src/plugin-worker.ts` — `PluginWorker` base class (lifecycle, UI messaging, Comlink exposure)
|
|
18
21
|
- `src/index.ts` — Exports the `snaptrude` singleton (`ClientPluginApi` instance)
|
|
19
22
|
|
|
@@ -27,62 +30,51 @@ pnpm dev # tsup watch mode
|
|
|
27
30
|
|
|
28
31
|
## Implementation patterns
|
|
29
32
|
|
|
30
|
-
###
|
|
33
|
+
### Everything is a generic RPC proxy (async, remote)
|
|
31
34
|
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
Under the all-handle model there is no in-worker compute: `core.math.*` and
|
|
36
|
+
`core.geom.*` values are opaque handles, so **every** namespace — `core.*`
|
|
37
|
+
(including `core.units`), `design.*`, `entity.*`, `tools.*` — is a
|
|
38
|
+
`createRpcNamespace<PluginXApi>("x")` Proxy. There are no hand-written
|
|
39
|
+
per-method wrappers. Nested property access builds the dot-separated method
|
|
40
|
+
path; the call marshals `{ method, args }` to the host via Comlink
|
|
41
|
+
(`getHostApi().call()`):
|
|
34
42
|
|
|
35
43
|
```typescript
|
|
36
|
-
//
|
|
37
|
-
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
### Host API calls (async, RPC)
|
|
41
|
-
|
|
42
|
-
Methods on `entity.*`, `tools.*`, and `units.*` marshal calls to the host via Comlink:
|
|
44
|
+
// src/api/index.ts — one proxy per top-level namespace
|
|
45
|
+
this.core = createRpcNamespace<PluginCoreApi>("core")
|
|
43
46
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
method: "entity.space.createRectangular",
|
|
49
|
-
args,
|
|
50
|
-
})
|
|
51
|
-
}
|
|
47
|
+
// Plugin code — positional args (whole tuple crosses the wire), values are handles:
|
|
48
|
+
const v = await snaptrude.core.math.vec3.new(1, 2, 3)
|
|
49
|
+
await snaptrude.entity.space.createRectangular(position, dimensions)
|
|
50
|
+
// → getHostApi().call({ method: "entity.space.createRectangular", args: [position, dimensions] })
|
|
52
51
|
```
|
|
53
52
|
|
|
54
|
-
The
|
|
55
|
-
|
|
53
|
+
The proxy is structurally cast to the abstract API type, so argument and return
|
|
54
|
+
types are enforced by plugin-core while dispatch stays dynamic. The `method`
|
|
55
|
+
string is exactly the property path and must match `PluginApiMethod`
|
|
56
|
+
(auto-inferred from the class hierarchy in `plugin-core/src/host-utils.ts`).
|
|
56
57
|
|
|
57
58
|
## When to update this package
|
|
58
59
|
|
|
59
|
-
- **plugin-core adds a
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
- **plugin-core adds a new
|
|
63
|
-
|
|
60
|
+
- **plugin-core adds/removes/changes a method**: Usually nothing to do here — the
|
|
61
|
+
proxy dispatches dynamically and types flow from plugin-core. Rebuild plugin-core,
|
|
62
|
+
then run `pnpm check-types` here.
|
|
63
|
+
- **plugin-core adds a new top-level namespace on `PluginApi`**: Add a matching
|
|
64
|
+
`createRpcNamespace<PluginNewApi>("new")` property in `ClientPluginApi`
|
|
65
|
+
(`src/api/index.ts`). Nested modules under an existing namespace need no wiring.
|
|
64
66
|
|
|
65
67
|
After making changes, always run `pnpm check-types` to verify everything compiles.
|
|
66
68
|
|
|
67
69
|
## File mapping (plugin-core -> plugin-client)
|
|
68
70
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
|
73
|
-
|
|
|
74
|
-
| `src/api
|
|
75
|
-
| `src/
|
|
76
|
-
| `src/api/core/geom/profile.ts` | `src/api/core/geom/profile.ts` |
|
|
77
|
-
| `src/api/entity/space.ts` | `src/api/entity/space.ts` |
|
|
78
|
-
| `src/api/entity/story.ts` | `src/api/entity/story.ts` |
|
|
79
|
-
| `src/api/entity/referenceLine.ts` | `src/api/entity/referenceLine.ts` |
|
|
80
|
-
| `src/api/entity/department.ts` | `src/api/entity/department.ts` |
|
|
81
|
-
| `src/api/entity/buildableEnvelope.ts` | `src/api/entity/buildableEnvelope.ts` |
|
|
82
|
-
| `src/api/tools/selection.ts` | `src/api/tools/selection.ts` |
|
|
83
|
-
| `src/api/tools/transform.ts` | `src/api/tools/transform.ts` |
|
|
84
|
-
| `src/api/units/index.ts` | `src/api/units/index.ts` |
|
|
85
|
-
| `src/api/index.ts` (`PluginApi`) | `src/api/index.ts` (`ClientPluginApi`) |
|
|
71
|
+
There are no per-namespace files here anymore — the whole plugin-core API tree is
|
|
72
|
+
served by two files:
|
|
73
|
+
|
|
74
|
+
| plugin-core | plugin-client |
|
|
75
|
+
| --------------------------------------------- | -------------------------------------------------------------------- |
|
|
76
|
+
| `src/api/**` (all namespaces, e.g. `core.math.vec3`) | `src/api/index.ts` (`ClientPluginApi`, one `createRpcNamespace` each) |
|
|
77
|
+
| `src/host-utils.ts` (`PluginApiMethod` types) | `src/rpc-proxy.ts` + `src/host-api.ts` (dispatch + Comlink transport) |
|
|
86
78
|
|
|
87
79
|
## Downstream consumers
|
|
88
80
|
|
package/CHANGELOG.md
CHANGED
package/CLAUDE.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
See [AGENTS.md](AGENTS.md) for:
|
|
7
7
|
|
|
8
|
-
- Implementation
|
|
8
|
+
- Implementation pattern (generic RPC proxy — every namespace is async host RPC)
|
|
9
9
|
- File mapping from plugin-core to plugin-client
|
|
10
10
|
- When and how to update this package in response to plugin-core changes
|
|
11
11
|
- Downstream consumer notes
|
package/dist/api/index.d.ts
CHANGED
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ClientEntityApi } from "./entity";
|
|
3
|
-
import { ClientToolsApi } from "./tools";
|
|
4
|
-
import { ClientUnitsApi } from "./units";
|
|
5
|
-
import { ClientDocumentationApi } from "./documentation";
|
|
6
|
-
import { PluginApi } from "@snaptrude/plugin-core";
|
|
1
|
+
import { PluginApi, PluginCoreApi, PluginDesignApi, PluginEntityApi, PluginProgramApi, PluginPresentationApi } from "@snaptrude/plugin-core";
|
|
7
2
|
export declare class ClientPluginApi extends PluginApi {
|
|
8
3
|
private static instance;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Every namespace is fully remote under the all-handle model: math/geom now
|
|
6
|
+
* cross to the host (values are opaque handles), so there is no in-worker
|
|
7
|
+
* compute left. All dispatch through a single generic RPC Proxy. Units live
|
|
8
|
+
* under `core.units`, so they ride the `core` proxy.
|
|
9
|
+
*/
|
|
10
|
+
core: PluginCoreApi;
|
|
11
|
+
design: PluginDesignApi;
|
|
12
|
+
entity: PluginEntityApi;
|
|
13
|
+
program: PluginProgramApi;
|
|
14
|
+
presentation: PluginPresentationApi;
|
|
14
15
|
private constructor();
|
|
15
16
|
static getInstance(): ClientPluginApi;
|
|
16
17
|
}
|
|
17
|
-
export * from "./core";
|
|
18
|
-
export * from "./documentation";
|
|
19
|
-
export * from "./entity";
|
|
20
|
-
export * from "./tools";
|
|
21
|
-
export * from "./units";
|
|
22
18
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/api/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,aAAa,EACb,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,qBAAqB,EACtB,MAAM,wBAAwB,CAAA;AAG/B,qBAAa,eAAgB,SAAQ,SAAS;IAC5C,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAiB;IAExC;;;;;OAKG;IACI,IAAI,EAAE,aAAa,CAAA;IACnB,MAAM,EAAE,eAAe,CAAA;IACvB,MAAM,EAAE,eAAe,CAAA;IACvB,OAAO,EAAE,gBAAgB,CAAA;IACzB,YAAY,EAAE,qBAAqB,CAAA;IAE1C,OAAO;IAUP,MAAM,CAAC,WAAW,IAAI,eAAe;CAMtC"}
|