@snaptrude/plugin-client 0.7.1 → 0.9.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/CHANGELOG.md +22 -0
- package/dist/api/index.d.ts +2 -1
- package/dist/api/index.d.ts.map +1 -1
- package/dist/events.d.ts +28 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/handle-runtime.d.ts +27 -0
- package/dist/handle-runtime.d.ts.map +1 -0
- package/dist/host-api.d.ts.map +1 -1
- package/dist/index.cjs +201 -27
- 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 +171 -3
- package/dist/index.js.map +1 -1
- package/dist/plugin-worker.d.ts +32 -0
- package/dist/plugin-worker.d.ts.map +1 -1
- package/dist/rpc-proxy.d.ts.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 +61 -0
- package/upgrade-notes/index.json +42 -0
- package/AGENTS.md +0 -86
- package/CLAUDE.md +0 -11
- package/src/api/index.ts +0 -45
- package/src/host-api.ts +0 -87
- package/src/index.ts +0 -38
- package/src/plugin-worker.ts +0 -99
- package/src/rpc-proxy.ts +0 -56
- package/test/host-api-errors.test.mjs +0 -101
- package/tsconfig.json +0 -17
- package/tsup.config.ts +0 -12
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
// Node built-in test runner suite for host-api error rehydration.
|
|
2
|
-
// Run: node --test test/host-api-errors.test.mjs
|
|
3
|
-
// Imports the BUILT package (dist) — run `pnpm build` first.
|
|
4
|
-
import test from "node:test"
|
|
5
|
-
import assert from "node:assert/strict"
|
|
6
|
-
import {
|
|
7
|
-
getHostApi,
|
|
8
|
-
__setHostApiInstance,
|
|
9
|
-
PluginError,
|
|
10
|
-
PluginQuotaError,
|
|
11
|
-
PluginTransportError,
|
|
12
|
-
PluginInternalError,
|
|
13
|
-
} from "../dist/index.js"
|
|
14
|
-
|
|
15
|
-
const PAYLOAD = { method: "design.boolean.union", args: [] }
|
|
16
|
-
|
|
17
|
-
/** Install a fake Comlink instance whose call() resolves/rejects as directed. */
|
|
18
|
-
function stubHost(behavior) {
|
|
19
|
-
__setHostApiInstance({ call: behavior })
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
test.afterEach(() => {
|
|
23
|
-
__setHostApiInstance(undefined)
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
test("success path returns data verbatim (handles are branded strings on the wire)", async () => {
|
|
27
|
-
const data = { value: 42, h: "mass_x" }
|
|
28
|
-
stubHost(async () => ({ success: true, data }))
|
|
29
|
-
const result = await getHostApi().call(PAYLOAD)
|
|
30
|
-
assert.equal(result, data) // pass-through: no cloning, no re-wrapping
|
|
31
|
-
assert.equal(result.value, 42)
|
|
32
|
-
assert.equal(result.h, "mass_x") // a handle IS its plain string id
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
test("errorInfo envelope rehydrates into the typed subclass with fields intact", async () => {
|
|
36
|
-
stubHost(async () => ({
|
|
37
|
-
success: false,
|
|
38
|
-
error: "Execution error: Rate limit exceeded",
|
|
39
|
-
errorInfo: {
|
|
40
|
-
envelopeVersion: 1,
|
|
41
|
-
code: "RATE_LIMITED",
|
|
42
|
-
message: "Rate limit exceeded",
|
|
43
|
-
errorId: "h-1",
|
|
44
|
-
details: { retryAfterMs: 250 },
|
|
45
|
-
methodPath: "design.boolean.union",
|
|
46
|
-
},
|
|
47
|
-
}))
|
|
48
|
-
await assert.rejects(getHostApi().call(PAYLOAD), (err) => {
|
|
49
|
-
assert.equal(PluginError.is(err), true)
|
|
50
|
-
assert.ok(err instanceof PluginQuotaError)
|
|
51
|
-
assert.equal(err.code, "RATE_LIMITED")
|
|
52
|
-
assert.equal(err.errorId, "h-1")
|
|
53
|
-
assert.deepEqual(err.details, { retryAfterMs: 250 })
|
|
54
|
-
assert.equal(err.methodPath, "design.boolean.union")
|
|
55
|
-
return true
|
|
56
|
-
})
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
test("unknown envelope code still rehydrates as a PluginError (forward compat)", async () => {
|
|
60
|
-
stubHost(async () => ({
|
|
61
|
-
success: false,
|
|
62
|
-
error: "Execution error: new thing",
|
|
63
|
-
errorInfo: {
|
|
64
|
-
envelopeVersion: 1,
|
|
65
|
-
code: "FUTURE_CODE",
|
|
66
|
-
message: "new thing",
|
|
67
|
-
errorId: "h-2",
|
|
68
|
-
},
|
|
69
|
-
}))
|
|
70
|
-
await assert.rejects(getHostApi().call(PAYLOAD), (err) => {
|
|
71
|
-
assert.equal(PluginError.is(err), true)
|
|
72
|
-
assert.equal(err.code, "FUTURE_CODE")
|
|
73
|
-
return true
|
|
74
|
-
})
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
test("legacy host (string error only) degrades to UNKNOWN with the message preserved", async () => {
|
|
78
|
-
stubHost(async () => ({ success: false, error: "Execution error: something broke" }))
|
|
79
|
-
await assert.rejects(getHostApi().call(PAYLOAD), (err) => {
|
|
80
|
-
assert.equal(PluginError.is(err), true)
|
|
81
|
-
assert.ok(err instanceof PluginInternalError)
|
|
82
|
-
assert.equal(err.code, "UNKNOWN")
|
|
83
|
-
assert.equal(err.message, "Execution error: something broke")
|
|
84
|
-
assert.ok(err.errorId.startsWith("c-"))
|
|
85
|
-
assert.equal(err.methodPath, "design.boolean.union")
|
|
86
|
-
return true
|
|
87
|
-
})
|
|
88
|
-
})
|
|
89
|
-
|
|
90
|
-
test("transport-level rejection normalizes to TRANSPORT_LOST", async () => {
|
|
91
|
-
stubHost(async () => {
|
|
92
|
-
throw new Error("port closed")
|
|
93
|
-
})
|
|
94
|
-
await assert.rejects(getHostApi().call(PAYLOAD), (err) => {
|
|
95
|
-
assert.ok(err instanceof PluginTransportError)
|
|
96
|
-
assert.equal(err.code, "TRANSPORT_LOST")
|
|
97
|
-
assert.equal(err.message, "port closed")
|
|
98
|
-
assert.ok(err.errorId.startsWith("c-"))
|
|
99
|
-
return true
|
|
100
|
-
})
|
|
101
|
-
})
|
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
|
-
})
|