@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/CHANGELOG.md +163 -2
- package/dist/api/index.d.ts +2 -1
- package/dist/api/index.d.ts.map +1 -1
- package/dist/host-api.d.ts +2 -0
- package/dist/host-api.d.ts.map +1 -1
- package/dist/index.cjs +68 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +66 -7
- package/dist/index.js.map +1 -1
- package/package.json +10 -3
- package/upgrade-notes/0.4.0-to-0.5.0.md +53 -0
- package/upgrade-notes/0.5.0-to-0.6.0.md +38 -0
- package/upgrade-notes/0.6.0-to-0.7.0.md +38 -0
- package/upgrade-notes/0.7.0-to-0.7.1.md +28 -0
- package/upgrade-notes/0.7.1-to-0.8.0.md +44 -0
- package/upgrade-notes/0.8.0-to-0.9.0.md +67 -0
- package/upgrade-notes/index.json +42 -0
- package/AGENTS.md +0 -86
- package/CLAUDE.md +0 -11
- package/src/api/index.ts +0 -42
- package/src/host-api.ts +0 -47
- package/src/index.ts +0 -12
- package/src/plugin-worker.ts +0 -99
- package/src/rpc-proxy.ts +0 -56
- package/tsconfig.json +0 -17
- package/tsup.config.ts +0 -12
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
|
-
})
|