@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.
Files changed (83) hide show
  1. package/AGENTS.md +38 -46
  2. package/CHANGELOG.md +11 -0
  3. package/CLAUDE.md +1 -1
  4. package/dist/api/index.d.ts +12 -16
  5. package/dist/api/index.d.ts.map +1 -1
  6. package/dist/index.cjs +23 -655
  7. package/dist/index.cjs.map +1 -1
  8. package/dist/index.js +25 -648
  9. package/dist/index.js.map +1 -1
  10. package/dist/rpc-proxy.d.ts +28 -0
  11. package/dist/rpc-proxy.d.ts.map +1 -0
  12. package/package.json +2 -2
  13. package/src/api/index.ts +26 -22
  14. package/src/rpc-proxy.ts +56 -0
  15. package/dist/api/core/geom/arc.d.ts +0 -5
  16. package/dist/api/core/geom/arc.d.ts.map +0 -1
  17. package/dist/api/core/geom/curve.d.ts +0 -5
  18. package/dist/api/core/geom/curve.d.ts.map +0 -1
  19. package/dist/api/core/geom/index.d.ts +0 -17
  20. package/dist/api/core/geom/index.d.ts.map +0 -1
  21. package/dist/api/core/geom/line.d.ts +0 -5
  22. package/dist/api/core/geom/line.d.ts.map +0 -1
  23. package/dist/api/core/geom/profile.d.ts +0 -7
  24. package/dist/api/core/geom/profile.d.ts.map +0 -1
  25. package/dist/api/core/index.d.ts +0 -11
  26. package/dist/api/core/index.d.ts.map +0 -1
  27. package/dist/api/core/math/index.d.ts +0 -11
  28. package/dist/api/core/math/index.d.ts.map +0 -1
  29. package/dist/api/core/math/quat.d.ts +0 -5
  30. package/dist/api/core/math/quat.d.ts.map +0 -1
  31. package/dist/api/core/math/vec3.d.ts +0 -5
  32. package/dist/api/core/math/vec3.d.ts.map +0 -1
  33. package/dist/api/documentation/aiInspiration.d.ts +0 -24
  34. package/dist/api/documentation/aiInspiration.d.ts.map +0 -1
  35. package/dist/api/documentation/index.d.ts +0 -8
  36. package/dist/api/documentation/index.d.ts.map +0 -1
  37. package/dist/api/entity/buildableEnvelope.d.ts +0 -7
  38. package/dist/api/entity/buildableEnvelope.d.ts.map +0 -1
  39. package/dist/api/entity/department.d.ts +0 -7
  40. package/dist/api/entity/department.d.ts.map +0 -1
  41. package/dist/api/entity/index.d.ts +0 -20
  42. package/dist/api/entity/index.d.ts.map +0 -1
  43. package/dist/api/entity/referenceLine.d.ts +0 -9
  44. package/dist/api/entity/referenceLine.d.ts.map +0 -1
  45. package/dist/api/entity/space.d.ts +0 -15
  46. package/dist/api/entity/space.d.ts.map +0 -1
  47. package/dist/api/entity/story.d.ts +0 -9
  48. package/dist/api/entity/story.d.ts.map +0 -1
  49. package/dist/api/tools/copy.d.ts +0 -3
  50. package/dist/api/tools/copy.d.ts.map +0 -1
  51. package/dist/api/tools/index.d.ts +0 -14
  52. package/dist/api/tools/index.d.ts.map +0 -1
  53. package/dist/api/tools/offset.d.ts +0 -3
  54. package/dist/api/tools/offset.d.ts.map +0 -1
  55. package/dist/api/tools/selection.d.ts +0 -6
  56. package/dist/api/tools/selection.d.ts.map +0 -1
  57. package/dist/api/tools/transform.d.ts +0 -7
  58. package/dist/api/tools/transform.d.ts.map +0 -1
  59. package/dist/api/units/index.d.ts +0 -7
  60. package/dist/api/units/index.d.ts.map +0 -1
  61. package/src/api/core/geom/arc.ts +0 -7
  62. package/src/api/core/geom/curve.ts +0 -7
  63. package/src/api/core/geom/index.ts +0 -25
  64. package/src/api/core/geom/line.ts +0 -7
  65. package/src/api/core/geom/profile.ts +0 -17
  66. package/src/api/core/index.ts +0 -17
  67. package/src/api/core/math/index.ts +0 -17
  68. package/src/api/core/math/quat.ts +0 -7
  69. package/src/api/core/math/vec3.ts +0 -7
  70. package/src/api/documentation/aiInspiration.ts +0 -193
  71. package/src/api/documentation/index.ts +0 -13
  72. package/src/api/entity/buildableEnvelope.ts +0 -34
  73. package/src/api/entity/department.ts +0 -30
  74. package/src/api/entity/index.ts +0 -29
  75. package/src/api/entity/referenceLine.ts +0 -54
  76. package/src/api/entity/space.ts +0 -160
  77. package/src/api/entity/story.ts +0 -66
  78. package/src/api/tools/copy.ts +0 -10
  79. package/src/api/tools/index.ts +0 -33
  80. package/src/api/tools/offset.ts +0 -15
  81. package/src/api/tools/selection.ts +0 -15
  82. package/src/api/tools/transform.ts +0 -44
  83. 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 **extends** every abstract class defined in `@snaptrude/plugin-core`.
11
- When plugin-core changes, this package must be updated to match.
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/`Concrete implementations of all plugin-core abstract APIs
16
- - `src/host-api.ts` — Comlink RPC wrapper (`HostApi.call()`) for host API calls
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
- ### Pure math/geometry (sync, local)
33
+ ### Everything is a generic RPC proxy (async, remote)
31
34
 
32
- Methods on `core.math.*` and `core.geom.*` are implemented directly they inherit
33
- the base class implementation or override with equivalent logic. No RPC involved.
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
- // Example: ClientVec3Api inherits PluginVec3Api directly
37
- export class ClientVec3Api extends PluginVec3Api {}
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
- ```typescript
45
- public async createRectangular(args: PluginSpaceCreateRectangularArgs) {
46
- const hostApi = getHostApi()
47
- return hostApi.call({
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 `method` string must match the dot-separated path from `PluginApiMethod` (auto-inferred
55
- from the class hierarchy in `plugin-core/src/host-utils.ts`).
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 new abstract method**: Add the concrete implementation here
60
- - **plugin-core removes a method**: Remove the implementation here
61
- - **plugin-core changes a signature**: Update the method signature + call args here
62
- - **plugin-core adds a new API module**: Create a matching file under `src/api/`, wire
63
- into the parent barrel (`index.ts`), and add to `ClientPluginApi`
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
- | plugin-core | plugin-client |
70
- | ------------------------------------- | -------------------------------------- |
71
- | `src/api/core/math/vec3.ts` | `src/api/core/math/vec3.ts` |
72
- | `src/api/core/math/quat.ts` | `src/api/core/math/quat.ts` |
73
- | `src/api/core/geom/line.ts` | `src/api/core/geom/line.ts` |
74
- | `src/api/core/geom/arc.ts` | `src/api/core/geom/arc.ts` |
75
- | `src/api/core/geom/curve.ts` | `src/api/core/geom/curve.ts` |
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
@@ -1,5 +1,16 @@
1
1
  # @snaptrude/plugin-client
2
2
 
3
+ ## 0.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 7750aa3: Exposed more snaptrude APIs
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [7750aa3]
12
+ - @snaptrude/plugin-core@0.5.0
13
+
3
14
  ## 0.2.9
4
15
 
5
16
  ### Patch Changes
package/CLAUDE.md CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  See [AGENTS.md](AGENTS.md) for:
7
7
 
8
- - Implementation patterns (sync math vs async RPC)
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
@@ -1,22 +1,18 @@
1
- import { ClientCoreApi } from "./core";
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
- core: ClientCoreApi;
10
- tools: ClientToolsApi;
11
- entity: ClientEntityApi;
12
- units: ClientUnitsApi;
13
- documentation: ClientDocumentationApi;
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
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AACxC,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAA;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAElD,qBAAa,eAAgB,SAAQ,SAAS;IAC5C,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAiB;IAEjC,IAAI,EAAE,aAAa,CAAA;IACnB,KAAK,EAAE,cAAc,CAAA;IACrB,MAAM,EAAE,eAAe,CAAA;IACvB,KAAK,EAAE,cAAc,CAAA;IACrB,aAAa,EAAE,sBAAsB,CAAA;IAE5C,OAAO;IASP,MAAM,CAAC,WAAW,IAAI,eAAe;CAMtC;AAED,cAAc,QAAQ,CAAA;AACtB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,SAAS,CAAA"}
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"}