@rybosome/tspice 0.0.7 → 0.0.8
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/README.md +140 -78
- package/backend-contract/dist/.tsbuildinfo +1 -1
- package/backend-contract/dist/domains/cells-windows.d.ts +94 -0
- package/backend-contract/dist/domains/cells-windows.js +10 -0
- package/backend-contract/dist/domains/coords-vectors.d.ts +50 -0
- package/backend-contract/dist/domains/dsk.d.ts +49 -0
- package/backend-contract/dist/domains/dsk.js +2 -0
- package/backend-contract/dist/domains/ek.d.ts +186 -0
- package/backend-contract/dist/domains/ek.js +8 -0
- package/backend-contract/dist/domains/ephemeris.d.ts +141 -3
- package/backend-contract/dist/domains/error.d.ts +42 -0
- package/backend-contract/dist/domains/error.js +33 -0
- package/backend-contract/dist/domains/file-io.d.ts +114 -0
- package/backend-contract/dist/domains/file-io.js +8 -0
- package/backend-contract/dist/domains/frames.d.ts +40 -0
- package/backend-contract/dist/domains/geometry-gf.d.ts +44 -0
- package/backend-contract/dist/domains/geometry-gf.js +14 -0
- package/backend-contract/dist/domains/geometry.d.ts +21 -1
- package/backend-contract/dist/domains/ids-names-normalize.d.ts +3 -0
- package/backend-contract/dist/domains/ids-names-normalize.js +74 -0
- package/backend-contract/dist/domains/ids-names.d.ts +37 -0
- package/backend-contract/dist/domains/kernel-pool.d.ts +134 -0
- package/backend-contract/dist/domains/kernel-pool.js +2 -0
- package/backend-contract/dist/domains/kernels-utils.d.ts +44 -0
- package/backend-contract/dist/domains/kernels-utils.js +265 -0
- package/backend-contract/dist/domains/kernels.d.ts +39 -3
- package/backend-contract/dist/domains/time.d.ts +102 -0
- package/backend-contract/dist/index.d.ts +31 -3
- package/backend-contract/dist/index.js +15 -1
- package/backend-contract/dist/shared/errors.d.ts +6 -0
- package/backend-contract/dist/shared/errors.js +8 -0
- package/backend-contract/dist/shared/mat3.d.ts +26 -14
- package/backend-contract/dist/shared/mat3.js +46 -17
- package/backend-contract/dist/shared/mat6.d.ts +34 -0
- package/backend-contract/dist/shared/mat6.js +116 -0
- package/backend-contract/dist/shared/spice-handles.d.ts +20 -0
- package/backend-contract/dist/shared/spice-handles.js +82 -0
- package/backend-contract/dist/shared/spice-int.d.ts +32 -0
- package/backend-contract/dist/shared/spice-int.js +41 -0
- package/backend-contract/dist/shared/types.d.ts +106 -1
- package/backend-contract/dist/shared/vec.d.ts +54 -0
- package/backend-contract/dist/shared/vec.js +162 -0
- package/backend-fake/dist/.tsbuildinfo +1 -1
- package/backend-fake/dist/index.d.ts +19 -1
- package/backend-fake/dist/index.js +1103 -18
- package/backend-node/dist/.tsbuildinfo +1 -1
- package/backend-node/dist/codec/arrays.d.ts +9 -0
- package/backend-node/dist/codec/arrays.js +36 -0
- package/backend-node/dist/codec/errors.d.ts +6 -6
- package/backend-node/dist/codec/errors.js +6 -6
- package/backend-node/dist/domains/cells-windows.d.ts +5 -0
- package/backend-node/dist/domains/cells-windows.js +112 -0
- package/backend-node/dist/domains/coords-vectors.d.ts +1 -0
- package/backend-node/dist/domains/coords-vectors.js +64 -1
- package/backend-node/dist/domains/dsk.d.ts +6 -0
- package/backend-node/dist/domains/dsk.js +108 -0
- package/backend-node/dist/domains/ek.d.ts +10 -0
- package/backend-node/dist/domains/ek.js +100 -0
- package/backend-node/dist/domains/ephemeris.d.ts +5 -1
- package/backend-node/dist/domains/ephemeris.js +150 -1
- package/backend-node/dist/domains/error.d.ts +5 -0
- package/backend-node/dist/domains/error.js +34 -0
- package/backend-node/dist/domains/file-io.d.ts +7 -0
- package/backend-node/dist/domains/file-io.js +105 -0
- package/backend-node/dist/domains/frames.d.ts +1 -0
- package/backend-node/dist/domains/frames.js +52 -0
- package/backend-node/dist/domains/geometry-gf.d.ts +5 -0
- package/backend-node/dist/domains/geometry-gf.js +74 -0
- package/backend-node/dist/domains/geometry.d.ts +1 -0
- package/backend-node/dist/domains/geometry.js +62 -0
- package/backend-node/dist/domains/ids-names.d.ts +2 -1
- package/backend-node/dist/domains/ids-names.js +30 -0
- package/backend-node/dist/domains/kernel-pool.d.ts +5 -0
- package/backend-node/dist/domains/kernel-pool.js +74 -0
- package/backend-node/dist/domains/kernels.d.ts +1 -0
- package/backend-node/dist/domains/kernels.js +100 -13
- package/backend-node/dist/domains/time.d.ts +1 -0
- package/backend-node/dist/domains/time.js +75 -1
- package/backend-node/dist/index.d.ts +2 -0
- package/backend-node/dist/index.js +62 -1
- package/backend-node/dist/lowlevel/binding.d.ts +3 -0
- package/backend-node/dist/lowlevel/binding.js +115 -0
- package/backend-node/dist/runtime/addon.d.ts +271 -0
- package/backend-node/dist/runtime/addon.js +3 -0
- package/backend-node/dist/runtime/kernel-staging.d.ts +17 -0
- package/backend-node/dist/runtime/kernel-staging.js +80 -7
- package/backend-node/dist/runtime/spice-handles.d.ts +3 -0
- package/backend-node/dist/runtime/spice-handles.js +2 -0
- package/backend-node/dist/runtime/virtual-output-staging.d.ts +16 -0
- package/backend-node/dist/runtime/virtual-output-staging.js +148 -0
- package/backend-wasm/dist/.tsbuildinfo +1 -1
- package/backend-wasm/dist/codec/alloc.d.ts +19 -0
- package/backend-wasm/dist/codec/alloc.js +64 -0
- package/backend-wasm/dist/codec/calls.d.ts +2 -0
- package/backend-wasm/dist/codec/calls.js +13 -24
- package/backend-wasm/dist/codec/errors.d.ts +6 -0
- package/backend-wasm/dist/codec/errors.js +34 -2
- package/backend-wasm/dist/codec/found.d.ts +2 -0
- package/backend-wasm/dist/codec/found.js +20 -43
- package/backend-wasm/dist/codec/strings.d.ts +31 -1
- package/backend-wasm/dist/codec/strings.js +93 -6
- package/backend-wasm/dist/domains/cells-windows.d.ts +9 -0
- package/backend-wasm/dist/domains/cells-windows.js +392 -0
- package/backend-wasm/dist/domains/coords-vectors.d.ts +1 -0
- package/backend-wasm/dist/domains/coords-vectors.js +377 -187
- package/backend-wasm/dist/domains/dsk.d.ts +6 -0
- package/backend-wasm/dist/domains/dsk.js +179 -0
- package/backend-wasm/dist/domains/ek.d.ts +6 -0
- package/backend-wasm/dist/domains/ek.js +543 -0
- package/backend-wasm/dist/domains/ephemeris.d.ts +4 -1
- package/backend-wasm/dist/domains/ephemeris.js +405 -46
- package/backend-wasm/dist/domains/error.d.ts +5 -0
- package/backend-wasm/dist/domains/error.js +109 -0
- package/backend-wasm/dist/domains/file-io.d.ts +7 -0
- package/backend-wasm/dist/domains/file-io.js +462 -0
- package/backend-wasm/dist/domains/frames.d.ts +1 -0
- package/backend-wasm/dist/domains/frames.js +136 -4
- package/backend-wasm/dist/domains/geometry-gf.d.ts +5 -0
- package/backend-wasm/dist/domains/geometry-gf.js +178 -0
- package/backend-wasm/dist/domains/geometry.d.ts +1 -0
- package/backend-wasm/dist/domains/geometry.js +210 -0
- package/backend-wasm/dist/domains/ids-names.d.ts +2 -1
- package/backend-wasm/dist/domains/ids-names.js +89 -0
- package/backend-wasm/dist/domains/kernel-pool.d.ts +5 -0
- package/backend-wasm/dist/domains/kernel-pool.js +357 -0
- package/backend-wasm/dist/domains/kernels.d.ts +1 -0
- package/backend-wasm/dist/domains/kernels.js +91 -2
- package/backend-wasm/dist/domains/time.d.ts +2 -0
- package/backend-wasm/dist/domains/time.js +235 -133
- package/backend-wasm/dist/lowlevel/exports.d.ts +215 -1
- package/backend-wasm/dist/lowlevel/exports.js +217 -38
- package/backend-wasm/dist/runtime/create-backend-options.d.ts +21 -0
- package/backend-wasm/dist/runtime/create-backend.node.d.ts +7 -0
- package/backend-wasm/dist/runtime/create-backend.node.js +283 -12
- package/backend-wasm/dist/runtime/create-backend.web.d.ts +1 -0
- package/backend-wasm/dist/runtime/create-backend.web.js +40 -4
- package/backend-wasm/dist/runtime/fs.d.ts +5 -0
- package/backend-wasm/dist/runtime/fs.js +5 -0
- package/backend-wasm/dist/runtime/spice-handles.d.ts +3 -0
- package/backend-wasm/dist/runtime/spice-handles.js +2 -0
- package/backend-wasm/dist/runtime/virtual-outputs.d.ts +16 -0
- package/backend-wasm/dist/runtime/virtual-outputs.js +35 -0
- package/backend-wasm/dist/tspice_backend_wasm.node.js +3 -3
- package/backend-wasm/dist/tspice_backend_wasm.wasm +0 -0
- package/backend-wasm/dist/tspice_backend_wasm.web.js +1 -1
- package/core/dist/.tsbuildinfo +1 -1
- package/core/dist/index.d.ts +19 -8
- package/core/dist/index.js +19 -8
- package/dist/.tsbuildinfo +1 -1
- package/dist/backend.d.ts +5 -0
- package/dist/clients/createSpiceAsyncFromTransport.d.ts +5 -0
- package/dist/clients/createSpiceAsyncFromTransport.js +90 -0
- package/dist/clients/createSpiceSyncFromTransport.d.ts +5 -0
- package/dist/clients/createSpiceSyncFromTransport.js +88 -0
- package/dist/clients/spiceClients.d.ts +59 -0
- package/dist/clients/spiceClients.js +292 -0
- package/dist/errors.d.ts +4 -0
- package/dist/errors.js +4 -0
- package/dist/index.d.ts +10 -7
- package/dist/index.js +4 -3
- package/dist/kernels/defaultKernelPathFromUrl.d.ts +8 -0
- package/dist/kernels/defaultKernelPathFromUrl.js +32 -0
- package/dist/kernels/kernelPack.d.ts +88 -0
- package/dist/kernels/kernelPack.js +122 -0
- package/dist/kernels/kernels.d.ts +98 -0
- package/dist/kernels/kernels.js +217 -0
- package/dist/kernels/naifKernelId.d.ts +2 -0
- package/dist/kernels/naifKernelId.js +2 -0
- package/dist/kit/math/mat3.d.ts +9 -1
- package/dist/kit/math/mat3.js +9 -1
- package/dist/kit/spice/create-kit.d.ts +1 -0
- package/dist/kit/spice/create-kit.js +1 -0
- package/dist/kit/spice/frames.d.ts +1 -0
- package/dist/kit/spice/frames.js +1 -0
- package/dist/kit/spice/kernels.d.ts +1 -0
- package/dist/kit/spice/kernels.js +1 -0
- package/dist/kit/spice/state.d.ts +2 -1
- package/dist/kit/spice/state.js +8 -4
- package/dist/kit/spice/time.d.ts +1 -0
- package/dist/kit/spice/time.js +1 -0
- package/dist/kit/types/spice-types.d.ts +18 -1
- package/dist/spice.d.ts +10 -1
- package/dist/spice.js +41 -0
- package/dist/transport/caching/policy.d.ts +16 -0
- package/dist/transport/caching/policy.js +77 -0
- package/dist/transport/caching/withCaching.d.ts +125 -0
- package/dist/transport/caching/withCaching.js +335 -0
- package/dist/transport/caching/withCachingSync.d.ts +24 -0
- package/dist/transport/caching/withCachingSync.js +161 -0
- package/dist/transport/rpc/protocol.d.ts +35 -0
- package/dist/transport/rpc/protocol.js +56 -0
- package/dist/transport/rpc/taskScheduling.d.ts +20 -0
- package/dist/transport/rpc/taskScheduling.js +98 -0
- package/dist/transport/rpc/valueCodec.d.ts +5 -0
- package/dist/transport/rpc/valueCodec.js +106 -0
- package/dist/transport/types.d.ts +7 -0
- package/dist/transport/types.js +2 -0
- package/dist/types.d.ts +8 -5
- package/dist/types.js +2 -1
- package/dist/worker/browser/createSpiceWorker.d.ts +22 -0
- package/dist/worker/browser/createSpiceWorker.js +41 -0
- package/dist/worker/browser/createSpiceWorkerClient.d.ts +40 -0
- package/dist/worker/browser/createSpiceWorkerClient.js +99 -0
- package/dist/worker/browser/spiceWorkerEntry.d.ts +2 -0
- package/dist/worker/browser/spiceWorkerEntry.js +129 -0
- package/dist/worker/browser/spiceWorkerInlineSource.d.ts +2 -0
- package/dist/worker/browser/spiceWorkerInlineSource.js +4 -0
- package/dist/worker/index.d.ts +10 -0
- package/dist/worker/index.js +7 -0
- package/dist/worker/transport/createWorkerTransport.d.ts +69 -0
- package/dist/worker/transport/createWorkerTransport.js +398 -0
- package/dist/worker/transport/exposeTransportToWorker.d.ts +51 -0
- package/dist/worker/transport/exposeTransportToWorker.js +196 -0
- package/package.json +4 -4
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { createCachePolicy } from "./policy.js";
|
|
2
|
+
import { defaultSpiceCacheKey, } from "./withCaching.js";
|
|
3
|
+
const cachingTransportBrand = new WeakSet();
|
|
4
|
+
const defaultOnWarning = (message) => {
|
|
5
|
+
if (typeof console !== "undefined" && typeof console.warn === "function") {
|
|
6
|
+
console.warn(message);
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Type guard for narrowing a transport returned by `withCachingSync()`.
|
|
11
|
+
*/
|
|
12
|
+
export function isCachingTransportSync(t) {
|
|
13
|
+
if (typeof t !== "object" || t === null)
|
|
14
|
+
return false;
|
|
15
|
+
if (!cachingTransportBrand.has(t))
|
|
16
|
+
return false;
|
|
17
|
+
const v = t;
|
|
18
|
+
return (typeof v.request === "function" &&
|
|
19
|
+
typeof v.clear === "function" &&
|
|
20
|
+
typeof v.dispose === "function");
|
|
21
|
+
}
|
|
22
|
+
function tryUnrefTimer(timer) {
|
|
23
|
+
let unref;
|
|
24
|
+
try {
|
|
25
|
+
unref = timer.unref;
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
if (typeof unref !== "function")
|
|
31
|
+
return;
|
|
32
|
+
try {
|
|
33
|
+
unref.call(timer);
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
// Ignore. Some runtimes / shims may throw for `unref` even when present.
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/** Wrap a sync transport with an in-memory response cache (LRU-ish + optional TTL). */
|
|
40
|
+
export function withCachingSync(base, opts) {
|
|
41
|
+
// Note: cached values are returned by reference. If a caller mutates the
|
|
42
|
+
// returned object/array, subsequent cache hits will observe that mutation.
|
|
43
|
+
// Treat results as immutable (or clone them yourself) when caching is enabled.
|
|
44
|
+
const rawMaxEntries = opts?.maxEntries;
|
|
45
|
+
const maxEntries = rawMaxEntries ?? 1000;
|
|
46
|
+
const maxEntriesLimit = maxEntries === Infinity
|
|
47
|
+
? undefined
|
|
48
|
+
: Number.isFinite(maxEntries)
|
|
49
|
+
? maxEntries
|
|
50
|
+
: 0;
|
|
51
|
+
const rawTtlMs = opts?.ttlMs;
|
|
52
|
+
const ttlMs = rawTtlMs == null ? undefined : rawTtlMs;
|
|
53
|
+
const cachingEnabled = (ttlMs === undefined || ttlMs > 0) &&
|
|
54
|
+
(maxEntriesLimit === undefined || maxEntriesLimit > 0);
|
|
55
|
+
// True no-op mode: preserve the input object identity and avoid allocating
|
|
56
|
+
// any wrapper state when caching is disabled.
|
|
57
|
+
if (!cachingEnabled)
|
|
58
|
+
return base;
|
|
59
|
+
// Only pick defaults after the no-op early return so disabled caching pays
|
|
60
|
+
// ~0 overhead.
|
|
61
|
+
const now = opts?.now ?? Date.now;
|
|
62
|
+
const onWarning = opts?.onWarning ?? defaultOnWarning;
|
|
63
|
+
const keyFn = opts?.key ?? defaultSpiceCacheKey;
|
|
64
|
+
const policyByOp = opts?.policy;
|
|
65
|
+
const allowUnsafePolicyOverrides = opts?.allowUnsafePolicyOverrides === true;
|
|
66
|
+
const allowBroadNoStorePrefixes = opts?.allowBroadNoStorePrefixes === true;
|
|
67
|
+
const getPolicy = createCachePolicy({
|
|
68
|
+
wrapperName: "withCachingSync()",
|
|
69
|
+
onWarning,
|
|
70
|
+
policyByOp,
|
|
71
|
+
noStorePrefixes: opts?.noStorePrefixes,
|
|
72
|
+
allowBroadNoStorePrefixes,
|
|
73
|
+
allowUnsafePolicyOverrides,
|
|
74
|
+
});
|
|
75
|
+
const cache = new Map();
|
|
76
|
+
let sweepTimer;
|
|
77
|
+
const isExpired = (entry, now) => entry.expiresAt !== undefined && entry.expiresAt <= now;
|
|
78
|
+
const cleanupExpired = (now) => {
|
|
79
|
+
// TTL eviction is optional. When ttlMs is undefined, the cache is “forever”
|
|
80
|
+
// (still LRU-bounded by maxEntries).
|
|
81
|
+
if (ttlMs === undefined || ttlMs <= 0)
|
|
82
|
+
return;
|
|
83
|
+
for (const [k, entry] of cache) {
|
|
84
|
+
if (isExpired(entry, now))
|
|
85
|
+
cache.delete(k);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
if (cachingEnabled && ttlMs !== undefined && ttlMs > 0) {
|
|
89
|
+
const sweepIntervalMs = opts?.sweepIntervalMs;
|
|
90
|
+
if (sweepIntervalMs !== undefined && sweepIntervalMs > 0) {
|
|
91
|
+
sweepTimer = setInterval(() => cleanupExpired(now()), sweepIntervalMs);
|
|
92
|
+
// In Node, interval timers keep the event loop alive by default. `unref()`
|
|
93
|
+
// prevents this from pinning test runners / CLIs. Browsers return a
|
|
94
|
+
// numeric id (no-op).
|
|
95
|
+
tryUnrefTimer(sweepTimer);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const clear = () => {
|
|
99
|
+
cache.clear();
|
|
100
|
+
};
|
|
101
|
+
const dispose = () => {
|
|
102
|
+
if (sweepTimer !== undefined) {
|
|
103
|
+
clearInterval(sweepTimer);
|
|
104
|
+
sweepTimer = undefined;
|
|
105
|
+
}
|
|
106
|
+
cache.clear();
|
|
107
|
+
};
|
|
108
|
+
const touch = (k, entry) => {
|
|
109
|
+
cache.delete(k);
|
|
110
|
+
cache.set(k, entry);
|
|
111
|
+
};
|
|
112
|
+
const enforceMaxEntries = () => {
|
|
113
|
+
if (maxEntriesLimit === undefined)
|
|
114
|
+
return;
|
|
115
|
+
while (cache.size > maxEntriesLimit) {
|
|
116
|
+
const oldestKey = cache.keys().next().value;
|
|
117
|
+
if (oldestKey === undefined)
|
|
118
|
+
return;
|
|
119
|
+
cache.delete(oldestKey);
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
const request = (op, args) => {
|
|
123
|
+
// Per-method cache policy. When bypassing, skip *all* cache work (no key
|
|
124
|
+
// computation, no reads/writes, no TTL sweeps).
|
|
125
|
+
if (getPolicy(op) === "no-store")
|
|
126
|
+
return base.request(op, args);
|
|
127
|
+
const k = keyFn(op, args);
|
|
128
|
+
if (k == null)
|
|
129
|
+
return base.request(op, args);
|
|
130
|
+
const nowMs = now();
|
|
131
|
+
cleanupExpired(nowMs);
|
|
132
|
+
const existing = cache.get(k);
|
|
133
|
+
if (existing && !isExpired(existing, nowMs)) {
|
|
134
|
+
// LRU touch on access. TTL remains absolute (does not refresh on access).
|
|
135
|
+
touch(k, existing);
|
|
136
|
+
return existing.value;
|
|
137
|
+
}
|
|
138
|
+
if (existing)
|
|
139
|
+
cache.delete(k);
|
|
140
|
+
// Only cache successful responses.
|
|
141
|
+
let value;
|
|
142
|
+
try {
|
|
143
|
+
value = base.request(op, args);
|
|
144
|
+
}
|
|
145
|
+
catch (err) {
|
|
146
|
+
cache.delete(k);
|
|
147
|
+
throw err;
|
|
148
|
+
}
|
|
149
|
+
const entry = { value };
|
|
150
|
+
if (ttlMs !== undefined && ttlMs > 0) {
|
|
151
|
+
entry.expiresAt = now() + ttlMs;
|
|
152
|
+
}
|
|
153
|
+
cache.set(k, entry);
|
|
154
|
+
enforceMaxEntries();
|
|
155
|
+
return value;
|
|
156
|
+
};
|
|
157
|
+
const transport = { request, clear, dispose };
|
|
158
|
+
cachingTransportBrand.add(transport);
|
|
159
|
+
return transport;
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=withCachingSync.js.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export declare const tspiceRpcRequestType: "tspice:request";
|
|
2
|
+
export declare const tspiceRpcResponseType: "tspice:response";
|
|
3
|
+
export declare const tspiceRpcDisposeType: "tspice:dispose";
|
|
4
|
+
export type RpcRequest = {
|
|
5
|
+
type: typeof tspiceRpcRequestType;
|
|
6
|
+
id: number;
|
|
7
|
+
op: string;
|
|
8
|
+
args: unknown[];
|
|
9
|
+
};
|
|
10
|
+
export type RpcDispose = {
|
|
11
|
+
type: typeof tspiceRpcDisposeType;
|
|
12
|
+
};
|
|
13
|
+
export type SerializedError = {
|
|
14
|
+
message: string;
|
|
15
|
+
name?: string;
|
|
16
|
+
stack?: string;
|
|
17
|
+
};
|
|
18
|
+
export type RpcResponse = {
|
|
19
|
+
type: typeof tspiceRpcResponseType;
|
|
20
|
+
id: number;
|
|
21
|
+
ok: true;
|
|
22
|
+
value: unknown;
|
|
23
|
+
} | {
|
|
24
|
+
type: typeof tspiceRpcResponseType;
|
|
25
|
+
id: number;
|
|
26
|
+
ok: false;
|
|
27
|
+
error: SerializedError;
|
|
28
|
+
};
|
|
29
|
+
export type RpcMessageFromMain = RpcRequest | RpcDispose;
|
|
30
|
+
export type RpcMessageFromWorker = RpcResponse;
|
|
31
|
+
/** Serialize an unknown error into a structured, transferable shape for RPC. */
|
|
32
|
+
export declare function serializeError(err: unknown): SerializedError;
|
|
33
|
+
/** Deserialize an RPC-transferred error shape back into an {@link Error}. */
|
|
34
|
+
export declare function deserializeError(err: unknown): Error;
|
|
35
|
+
//# sourceMappingURL=protocol.d.ts.map
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
export const tspiceRpcRequestType = "tspice:request";
|
|
2
|
+
export const tspiceRpcResponseType = "tspice:response";
|
|
3
|
+
export const tspiceRpcDisposeType = "tspice:dispose";
|
|
4
|
+
/** Serialize an unknown error into a structured, transferable shape for RPC. */
|
|
5
|
+
export function serializeError(err) {
|
|
6
|
+
const defaultMessage = "Worker request failed";
|
|
7
|
+
const readStringProp = (obj, key) => {
|
|
8
|
+
if (!obj || typeof obj !== "object")
|
|
9
|
+
return undefined;
|
|
10
|
+
const v = obj[key];
|
|
11
|
+
return typeof v === "string" ? v : undefined;
|
|
12
|
+
};
|
|
13
|
+
if (err instanceof Error) {
|
|
14
|
+
const out = { message: err.message || defaultMessage };
|
|
15
|
+
if (typeof err.name === "string" && err.name)
|
|
16
|
+
out.name = err.name;
|
|
17
|
+
if (typeof err.stack === "string")
|
|
18
|
+
out.stack = err.stack;
|
|
19
|
+
return out;
|
|
20
|
+
}
|
|
21
|
+
if (typeof err === "string") {
|
|
22
|
+
return { message: err };
|
|
23
|
+
}
|
|
24
|
+
if (err && typeof err === "object") {
|
|
25
|
+
const message = readStringProp(err, "message") ?? defaultMessage;
|
|
26
|
+
const name = readStringProp(err, "name");
|
|
27
|
+
const stack = readStringProp(err, "stack");
|
|
28
|
+
const out = { message };
|
|
29
|
+
if (typeof name === "string" && name)
|
|
30
|
+
out.name = name;
|
|
31
|
+
if (typeof stack === "string")
|
|
32
|
+
out.stack = stack;
|
|
33
|
+
return out;
|
|
34
|
+
}
|
|
35
|
+
// Only stringify primitives (avoid calling an arbitrary `.toString()` on objects).
|
|
36
|
+
if (typeof err === "number" ||
|
|
37
|
+
typeof err === "boolean" ||
|
|
38
|
+
typeof err === "bigint") {
|
|
39
|
+
return { message: String(err) };
|
|
40
|
+
}
|
|
41
|
+
return { message: defaultMessage };
|
|
42
|
+
}
|
|
43
|
+
/** Deserialize an RPC-transferred error shape back into an {@link Error}. */
|
|
44
|
+
export function deserializeError(err) {
|
|
45
|
+
if (err && typeof err === "object") {
|
|
46
|
+
const e = err;
|
|
47
|
+
const out = new Error(typeof e.message === "string" ? e.message : "Worker request failed");
|
|
48
|
+
if (typeof e.name === "string")
|
|
49
|
+
out.name = e.name;
|
|
50
|
+
if (typeof e.stack === "string")
|
|
51
|
+
out.stack = e.stack;
|
|
52
|
+
return out;
|
|
53
|
+
}
|
|
54
|
+
return new Error(typeof err === "string" ? err : "Worker request failed");
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=protocol.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type QueueMacrotaskOptions = {
|
|
2
|
+
/**
|
|
3
|
+
* When no macrotask scheduler exists (no `MessageChannel` and no `setTimeout`),
|
|
4
|
+
* there is no way to create a real task boundary.
|
|
5
|
+
*
|
|
6
|
+
* - `true` (default): invoke `fn()` synchronously as a best-effort fallback.
|
|
7
|
+
* - `false`: do not call `fn()` and return `false`.
|
|
8
|
+
*/
|
|
9
|
+
allowSyncFallback?: boolean;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Probe whether a true macrotask scheduler is available in the current runtime
|
|
13
|
+
* (without actually scheduling a task).
|
|
14
|
+
*/
|
|
15
|
+
export declare function canQueueMacrotask(): boolean;
|
|
16
|
+
/** Queue `fn` on the next macrotask (MessageChannel preferred; setTimeout fallback). */
|
|
17
|
+
export declare function queueMacrotask(fn: () => void, opts?: QueueMacrotaskOptions): boolean;
|
|
18
|
+
/** Return a promise that resolves on the next macrotask boundary (rejects if unavailable). */
|
|
19
|
+
export declare function nextMacrotask(): Promise<void>;
|
|
20
|
+
//# sourceMappingURL=taskScheduling.d.ts.map
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Probe whether a true macrotask scheduler is available in the current runtime
|
|
3
|
+
* (without actually scheduling a task).
|
|
4
|
+
*/
|
|
5
|
+
export function canQueueMacrotask() {
|
|
6
|
+
// Prefer MessageChannel when available.
|
|
7
|
+
//
|
|
8
|
+
// Important: if MessageChannel exists but is broken (e.g. constructible but
|
|
9
|
+
// `postMessage` throws), we fall through to `setTimeout` rather than failing
|
|
10
|
+
// closed. This matches `queueMacrotask()` behavior.
|
|
11
|
+
if (typeof MessageChannel !== "undefined") {
|
|
12
|
+
try {
|
|
13
|
+
const { port1, port2 } = new MessageChannel();
|
|
14
|
+
try {
|
|
15
|
+
// Probe that `postMessage` works (some polyfills allow construction but
|
|
16
|
+
// throw on `postMessage`, which would otherwise deadlock queueing).
|
|
17
|
+
port2.postMessage(undefined);
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
finally {
|
|
21
|
+
// Always close ports so they don't keep the event loop alive in Node.
|
|
22
|
+
// Be defensive: some polyfills/test environments may not implement `close()`.
|
|
23
|
+
try {
|
|
24
|
+
port1.close?.();
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
// ignore
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
port2.close?.();
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
// ignore
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
// Ignore and fall back to setTimeout.
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return typeof setTimeout === "function";
|
|
42
|
+
}
|
|
43
|
+
/** Queue `fn` on the next macrotask (MessageChannel preferred; setTimeout fallback). */
|
|
44
|
+
export function queueMacrotask(fn, opts) {
|
|
45
|
+
const allowSyncFallback = opts?.allowSyncFallback ?? true;
|
|
46
|
+
// Prefer MessageChannel when available. This schedules a real task boundary
|
|
47
|
+
// without relying on timers, which makes it friendlier to fake-timer test
|
|
48
|
+
// environments.
|
|
49
|
+
try {
|
|
50
|
+
if (typeof MessageChannel !== "undefined") {
|
|
51
|
+
const { port1, port2 } = new MessageChannel();
|
|
52
|
+
const port1WithOnMessage = port1;
|
|
53
|
+
port1WithOnMessage.onmessage = () => {
|
|
54
|
+
port1WithOnMessage.onmessage = null;
|
|
55
|
+
// Close ports so this doesn't keep the event loop alive in Node.
|
|
56
|
+
// Be defensive: some polyfills/test environments may not implement
|
|
57
|
+
// `close()`.
|
|
58
|
+
try {
|
|
59
|
+
port1.close?.();
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
// ignore
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
port2.close?.();
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
// ignore
|
|
69
|
+
}
|
|
70
|
+
fn();
|
|
71
|
+
};
|
|
72
|
+
port2.postMessage(undefined);
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
// Ignore and fall back to setTimeout.
|
|
78
|
+
}
|
|
79
|
+
// Next preference: a real macrotask via setTimeout.
|
|
80
|
+
if (typeof setTimeout === "function") {
|
|
81
|
+
setTimeout(fn, 0);
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
// No macrotask scheduler available in this runtime.
|
|
85
|
+
if (allowSyncFallback)
|
|
86
|
+
fn();
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
/** Return a promise that resolves on the next macrotask boundary (rejects if unavailable). */
|
|
90
|
+
export function nextMacrotask() {
|
|
91
|
+
return new Promise((resolve, reject) => {
|
|
92
|
+
const ok = queueMacrotask(resolve, { allowSyncFallback: false });
|
|
93
|
+
if (!ok) {
|
|
94
|
+
reject(new Error("nextMacrotask(): no macrotask scheduler available (MessageChannel/setTimeout missing)"));
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=taskScheduling.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Encode an arbitrary value into a structured-clone-safe shape. */
|
|
2
|
+
export declare function encodeRpcValue(value: unknown): unknown;
|
|
3
|
+
/** Decode a value that was encoded by {@link encodeRpcValue}. */
|
|
4
|
+
export declare function decodeRpcValue(value: unknown): unknown;
|
|
5
|
+
//# sourceMappingURL=valueCodec.d.ts.map
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { Mat3 } from "../../kit/math/mat3.js";
|
|
2
|
+
/**
|
|
3
|
+
* Values sent across the worker boundary must be structured-clone-safe.
|
|
4
|
+
*
|
|
5
|
+
* This codec provides a minimal, extensible tagged encoding for non-plain
|
|
6
|
+
* objects (e.g. `Mat3`) used by the tspice API.
|
|
7
|
+
*/
|
|
8
|
+
const tspiceRpcTagKey = "__tspiceRpcTag";
|
|
9
|
+
function isRecord(value) {
|
|
10
|
+
return value !== null && typeof value === "object";
|
|
11
|
+
}
|
|
12
|
+
function isTaggedRecord(value) {
|
|
13
|
+
return isRecord(value) && tspiceRpcTagKey in value;
|
|
14
|
+
}
|
|
15
|
+
function isFiniteNumber(value) {
|
|
16
|
+
return typeof value === "number" && Number.isFinite(value);
|
|
17
|
+
}
|
|
18
|
+
function isMat3RowMajorData(value) {
|
|
19
|
+
return (Array.isArray(value) && value.length === 9 && value.every(isFiniteNumber));
|
|
20
|
+
}
|
|
21
|
+
/** Encode an arbitrary value into a structured-clone-safe shape. */
|
|
22
|
+
export function encodeRpcValue(value) {
|
|
23
|
+
if (value instanceof Mat3) {
|
|
24
|
+
const data = Array.from(value.rowMajor);
|
|
25
|
+
return {
|
|
26
|
+
[tspiceRpcTagKey]: "Mat3",
|
|
27
|
+
layout: "rowMajor",
|
|
28
|
+
data,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
if (Array.isArray(value)) {
|
|
32
|
+
return value.map(encodeRpcValue);
|
|
33
|
+
}
|
|
34
|
+
// Fast-path: ArrayBuffer + views (TypedArrays/DataView) are structured-clone-
|
|
35
|
+
// safe and should pass through unchanged. This is important for transferring
|
|
36
|
+
// kernel bytes (e.g. Uint8Array) into a worker.
|
|
37
|
+
if (value instanceof ArrayBuffer)
|
|
38
|
+
return value;
|
|
39
|
+
if (ArrayBuffer.isView(value))
|
|
40
|
+
return value;
|
|
41
|
+
// SharedArrayBuffer exists in some environments (Node, some browsers) but is
|
|
42
|
+
// gated by cross-origin isolation in browsers. Allow it when present.
|
|
43
|
+
if (typeof SharedArrayBuffer !== "undefined" &&
|
|
44
|
+
value instanceof SharedArrayBuffer) {
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
47
|
+
if (isRecord(value)) {
|
|
48
|
+
// Allow byte buffers/typed arrays to cross the worker boundary.
|
|
49
|
+
// These are structured-clone-safe and commonly used for kernel outputs.
|
|
50
|
+
if (value instanceof ArrayBuffer)
|
|
51
|
+
return value;
|
|
52
|
+
if (ArrayBuffer.isView(value))
|
|
53
|
+
return value;
|
|
54
|
+
if (typeof SharedArrayBuffer !== "undefined" && value instanceof SharedArrayBuffer) {
|
|
55
|
+
return value;
|
|
56
|
+
}
|
|
57
|
+
// Preserve Date/Map/Set/etc as-is? No: those are not guaranteed to be
|
|
58
|
+
// structured-clone-safe across all targets. For now, we only support plain
|
|
59
|
+
// object literals.
|
|
60
|
+
const proto = Object.getPrototypeOf(value);
|
|
61
|
+
if (proto !== Object.prototype && proto !== null) {
|
|
62
|
+
const ctorName = value.constructor?.name ??
|
|
63
|
+
proto.constructor?.name;
|
|
64
|
+
throw new Error("encodeRpcValue(): unsupported non-plain object for worker RPC " +
|
|
65
|
+
`(constructor=${String(ctorName)}). ` +
|
|
66
|
+
"Pass plain objects/arrays/primitives or extend the codec.");
|
|
67
|
+
}
|
|
68
|
+
const out = {};
|
|
69
|
+
for (const [k, v] of Object.entries(value)) {
|
|
70
|
+
out[k] = encodeRpcValue(v);
|
|
71
|
+
}
|
|
72
|
+
return out;
|
|
73
|
+
}
|
|
74
|
+
return value;
|
|
75
|
+
}
|
|
76
|
+
/** Decode a value that was encoded by {@link encodeRpcValue}. */
|
|
77
|
+
export function decodeRpcValue(value) {
|
|
78
|
+
if (isTaggedRecord(value)) {
|
|
79
|
+
const tag = value[tspiceRpcTagKey];
|
|
80
|
+
if (tag === "Mat3") {
|
|
81
|
+
const layout = value.layout;
|
|
82
|
+
const data = value.data;
|
|
83
|
+
if (layout === "rowMajor" && isMat3RowMajorData(data)) {
|
|
84
|
+
// Mat3.fromRowMajor expects a branded Mat3RowMajor type. We validated
|
|
85
|
+
// the runtime shape here, so the cast is safe.
|
|
86
|
+
return Mat3.fromRowMajor(data);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (Array.isArray(value)) {
|
|
91
|
+
return value.map(decodeRpcValue);
|
|
92
|
+
}
|
|
93
|
+
if (isRecord(value)) {
|
|
94
|
+
// Preserve non-plain objects (e.g. TypedArrays) as-is.
|
|
95
|
+
const proto = Object.getPrototypeOf(value);
|
|
96
|
+
if (proto !== Object.prototype && proto !== null)
|
|
97
|
+
return value;
|
|
98
|
+
const out = {};
|
|
99
|
+
for (const [k, v] of Object.entries(value)) {
|
|
100
|
+
out[k] = decodeRpcValue(v);
|
|
101
|
+
}
|
|
102
|
+
return out;
|
|
103
|
+
}
|
|
104
|
+
return value;
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=valueCodec.js.map
|
package/dist/types.d.ts
CHANGED
|
@@ -11,11 +11,14 @@ export type Vec6 = readonly [
|
|
|
11
11
|
];
|
|
12
12
|
/** SPICE frame name (e.g. "J2000", "IAU_EARTH"). */
|
|
13
13
|
export type FrameName = string;
|
|
14
|
+
/** Canonical inertial reference frame. */
|
|
15
|
+
export declare const J2000: "J2000";
|
|
14
16
|
/** Aberration correction string accepted by `spkezr`. */
|
|
15
17
|
export type AberrationCorrection = "NONE" | "LT" | "LT+S" | "CN" | "CN+S" | "XLT" | "XLT+S" | "XCN" | "XCN+S";
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
/** Seconds past J2000 (ET). */
|
|
19
|
+
export type SpiceTime = number;
|
|
20
|
+
/** Body identifier accepted by kit APIs (name or NAIF id). */
|
|
21
|
+
export type BodyRef = string | number;
|
|
19
22
|
export type StateVector = {
|
|
20
23
|
/** Seconds past J2000 (ET). */
|
|
21
24
|
et: SpiceTime;
|
|
@@ -33,8 +36,8 @@ export type StateVector = {
|
|
|
33
36
|
lightTime: number;
|
|
34
37
|
};
|
|
35
38
|
export type GetStateArgs = {
|
|
36
|
-
target:
|
|
37
|
-
observer:
|
|
39
|
+
target: BodyRef;
|
|
40
|
+
observer: BodyRef;
|
|
38
41
|
at: SpiceTime;
|
|
39
42
|
frame?: FrameName;
|
|
40
43
|
aberration?: AberrationCorrection;
|
package/dist/types.js
CHANGED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { WorkerLike } from "../transport/createWorkerTransport.js";
|
|
2
|
+
export type CreateSpiceWorkerOptions = {
|
|
3
|
+
/** Override the worker entrypoint (advanced). */
|
|
4
|
+
url?: string | URL;
|
|
5
|
+
/**
|
|
6
|
+
* Override the WASM binary URL used by the default inline worker.
|
|
7
|
+
*
|
|
8
|
+
* When omitted, `createSpiceWorker()` will resolve the WASM binary URL
|
|
9
|
+
* relative to the published package layout.
|
|
10
|
+
*/
|
|
11
|
+
wasmUrl?: string | URL;
|
|
12
|
+
/**
|
|
13
|
+
* Options passed through to the `Worker` constructor.
|
|
14
|
+
*
|
|
15
|
+
* Typed loosely on purpose so this package doesn't require `lib.dom` types
|
|
16
|
+
* (and so it can be consumed in non-DOM TS configs).
|
|
17
|
+
*/
|
|
18
|
+
workerOptions?: Record<string, unknown>;
|
|
19
|
+
};
|
|
20
|
+
/** Create a Web Worker instance for the tspice worker entrypoint (inline by default). */
|
|
21
|
+
export declare function createSpiceWorker(opts?: CreateSpiceWorkerOptions): WorkerLike;
|
|
22
|
+
//# sourceMappingURL=createSpiceWorker.d.ts.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { SPICE_WORKER_INLINE_SOURCE } from "./spiceWorkerInlineSource.js";
|
|
2
|
+
/** Create a Web Worker instance for the tspice worker entrypoint (inline by default). */
|
|
3
|
+
export function createSpiceWorker(opts = {}) {
|
|
4
|
+
const WorkerCtor = globalThis.Worker;
|
|
5
|
+
if (typeof WorkerCtor !== "function") {
|
|
6
|
+
throw new Error("createSpiceWorker() requires Web Worker support in the current runtime");
|
|
7
|
+
}
|
|
8
|
+
// Default to module workers since this package is ESM and relies on
|
|
9
|
+
// ESM-only dependencies.
|
|
10
|
+
const workerOptions = {
|
|
11
|
+
type: "module",
|
|
12
|
+
...(opts.workerOptions ?? {}),
|
|
13
|
+
};
|
|
14
|
+
if (opts.url != null) {
|
|
15
|
+
return new WorkerCtor(opts.url, workerOptions);
|
|
16
|
+
}
|
|
17
|
+
// Inline (blob) worker by default.
|
|
18
|
+
//
|
|
19
|
+
// This avoids requiring consumers to separately bundle/host a worker JS asset
|
|
20
|
+
// URL. It also means the worker entry cannot use `import.meta.url` to locate
|
|
21
|
+
// assets, since the entrypoint URL will be `blob:`.
|
|
22
|
+
if (workerOptions.type !== "module") {
|
|
23
|
+
throw new Error('createSpiceWorker() inline worker requires a module worker (workerOptions.type="module")');
|
|
24
|
+
}
|
|
25
|
+
const wasmUrl = opts.wasmUrl?.toString() ??
|
|
26
|
+
// Published package layout (and what `build:dist-publish` produces):
|
|
27
|
+
// dist/worker/browser/createSpiceWorker.js
|
|
28
|
+
// backend-wasm/dist/tspice_backend_wasm.wasm
|
|
29
|
+
new URL("../../../backend-wasm/dist/tspice_backend_wasm.wasm", import.meta.url).href;
|
|
30
|
+
const workerSource = `globalThis.__TSPICE_WORKER_CONFIG__ = ${JSON.stringify({ wasmUrl })};\n` +
|
|
31
|
+
SPICE_WORKER_INLINE_SOURCE;
|
|
32
|
+
const blob = new Blob([workerSource], { type: "text/javascript" });
|
|
33
|
+
const blobUrl = URL.createObjectURL(blob);
|
|
34
|
+
try {
|
|
35
|
+
return new WorkerCtor(blobUrl, workerOptions);
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
URL.revokeObjectURL(blobUrl);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=createSpiceWorker.js.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { SpiceAsync } from "../../kit/types/spice-types.js";
|
|
2
|
+
import type { SpiceTransport } from "../../transport/types.js";
|
|
3
|
+
import { type WorkerLike, type WorkerTransport } from "../transport/createWorkerTransport.js";
|
|
4
|
+
export type SpiceWorkerClient<TTransport extends SpiceTransport = WorkerTransport> = {
|
|
5
|
+
worker: WorkerLike;
|
|
6
|
+
/** The underlying request/response RPC transport (always a WorkerTransport). */
|
|
7
|
+
baseTransport: WorkerTransport;
|
|
8
|
+
/** The transport after applying `wrapTransport` (e.g. `withCaching`). */
|
|
9
|
+
transport: TTransport;
|
|
10
|
+
/** A `SpiceAsync` client backed by `transport`. */
|
|
11
|
+
spice: SpiceAsync;
|
|
12
|
+
/** Dispose wrapper transport (if any) and the worker transport. */
|
|
13
|
+
dispose: () => void;
|
|
14
|
+
/**
|
|
15
|
+
* Async dispose variant that awaits wrapper transport cleanup (if any) before
|
|
16
|
+
* disposing the underlying worker transport.
|
|
17
|
+
*/
|
|
18
|
+
disposeAsync: () => Promise<void>;
|
|
19
|
+
};
|
|
20
|
+
export type CreateSpiceWorkerClientOptions<TTransport extends SpiceTransport = WorkerTransport> = {
|
|
21
|
+
/**
|
|
22
|
+
* Pass an existing Worker or a factory to create one.
|
|
23
|
+
*
|
|
24
|
+
* Defaults to `() => createSpiceWorker()`.
|
|
25
|
+
*/
|
|
26
|
+
worker?: WorkerLike | (() => WorkerLike);
|
|
27
|
+
/** Default request timeout forwarded to `createWorkerTransport`. */
|
|
28
|
+
timeoutMs?: number;
|
|
29
|
+
/** Forwarded to `createWorkerTransport`. Defaults to `true` when `worker` is a factory. */
|
|
30
|
+
terminateOnDispose?: boolean;
|
|
31
|
+
/** Forwarded to `createWorkerTransport`. Defaults to `terminateOnDispose`. */
|
|
32
|
+
signalDispose?: boolean;
|
|
33
|
+
/** Optional transport wrapper (e.g. `withCaching`). */
|
|
34
|
+
wrapTransport?: (t: WorkerTransport) => TTransport;
|
|
35
|
+
/** Called if `disposeAsync()` rejects when invoked via fire-and-forget `dispose()`. */
|
|
36
|
+
onDisposeError?: (err: unknown) => void;
|
|
37
|
+
};
|
|
38
|
+
/** Create a {@link SpiceWorkerClient} that communicates with a tspice Web Worker via RPC. */
|
|
39
|
+
export declare function createSpiceWorkerClient<TTransport extends SpiceTransport = WorkerTransport>(opts?: CreateSpiceWorkerClientOptions<TTransport>): SpiceWorkerClient<TTransport>;
|
|
40
|
+
//# sourceMappingURL=createSpiceWorkerClient.d.ts.map
|