@snaptrude/plugin-client 0.0.0-dev-20260708130115 → 0.0.0-dev-20260921132444

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/src/rpc-proxy.ts DELETED
@@ -1,56 +0,0 @@
1
- import type {
2
- PluginApiCallPayload,
3
- PluginApiMethod,
4
- } from "@snaptrude/plugin-core"
5
- import { getHostApi } from "./host-api"
6
-
7
- /**
8
- * Build a namespace object whose nested property access maps to a
9
- * dot-separated host RPC method path, and whose every call dispatches that
10
- * path through the host bridge.
11
- *
12
- * The host exposes the entire plugin API behind a single generic `call()`
13
- * (see the host `bridge.ts`), and the method string is exactly the property
14
- * path — so one Proxy replaces every hand-written per-method RPC wrapper for
15
- * every namespace (`core.*`, `design.*`, `entity.*`):
16
- *
17
- * The POSITIONAL transport forwards the whole argument tuple; the host router
18
- * spreads it back into the resolved method (`fn(...args)`):
19
- *
20
- * ```ts
21
- * snaptrude.core.math.vec3.new(1, 2, 3)
22
- * // → getHostApi().call({ method: "core.math.vec3.new", args: [1, 2, 3] })
23
- * ```
24
- *
25
- * Typed at the call site, e.g. `createRpcNamespace<PluginEntityApi>("entity")`.
26
- * The Proxy is structurally cast to the abstract API type — argument and
27
- * return types are enforced by that type, while dispatch is dynamic.
28
- *
29
- * Every namespace uses this — including `core.math.*` and `core.geom.*`: under
30
- * the all-handle model there is no in-worker compute; math and geometry are
31
- * host calls like everything else.
32
- */
33
- export function createRpcNamespace<T extends object>(basePath: string): T {
34
- const build = (path: string): unknown =>
35
- new Proxy(NOOP, {
36
- get(_target, prop) {
37
- // Symbols and `then` must not resolve to a callable proxy, otherwise
38
- // the namespace would look thenable and break Promise resolution if it
39
- // ever reached an `await`.
40
- if (typeof prop !== "string" || prop === "then") return undefined
41
- return build(`${path}.${prop}`)
42
- },
43
- apply(_target, _thisArg, argArray: unknown[]) {
44
- const payload = {
45
- method: path,
46
- args: argArray,
47
- } as unknown as PluginApiCallPayload<PluginApiMethod>
48
- return getHostApi().call(payload)
49
- },
50
- })
51
-
52
- return build(basePath) as T
53
- }
54
-
55
- /** Proxy target must be callable for the `apply` trap; identity is irrelevant. */
56
- const NOOP = (): void => {}
package/tsconfig.json DELETED
@@ -1,17 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2020",
4
- "module": "ES2020",
5
- "moduleResolution": "bundler",
6
- "lib": ["ES2020", "WebWorker"],
7
- "strict": true,
8
- "esModuleInterop": true,
9
- "skipLibCheck": true,
10
- "emitDeclarationOnly": true,
11
- "typeRoots": [],
12
- "declaration": true,
13
- "declarationMap": true,
14
- "outDir": "dist"
15
- },
16
- "include": ["src/**/*.ts"]
17
- }
package/tsup.config.ts DELETED
@@ -1,12 +0,0 @@
1
- import { defineConfig } from "tsup"
2
-
3
- export default defineConfig( (options) => {
4
- return {
5
- entry: ["src/index.ts"],
6
- format: ["cjs", "esm"],
7
- dts: false,
8
- sourcemap: true,
9
- onSuccess: "tsc", // Run tsc to generate d.ts and d.ts.map
10
- watch: options.watch,
11
- }
12
- })