@requence/service 0.8.5-edge.1206 → 0.8.5-edge.1212
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/build/{chunk-n7ayk1td.js → chunk-6dx6x31h.js} +15 -47
- package/build/{chunk-n7ayk1td.js.map → chunk-6dx6x31h.js.map} +2 -2
- package/build/cli.js +12 -12
- package/build/cli.js.map +2 -2
- package/build/index.js +146 -115
- package/build/index.js.map +2 -2
- package/build/types/service/src/surfaceUi.d.ts +1 -0
- package/build/types/service/src/surfaceUi.d.ts.map +1 -1
- package/package.json +2 -2
package/build/index.js
CHANGED
|
@@ -1,26 +1,57 @@
|
|
|
1
1
|
import {
|
|
2
|
-
CAPABILITY_HEADER_KEYS,
|
|
3
|
-
PayloadTooLargeError,
|
|
4
|
-
RequenceConnectionError,
|
|
5
|
-
RequenceUnreachableError,
|
|
6
|
-
UITooLargeError,
|
|
7
|
-
UnsupportedCapabilityError,
|
|
8
|
-
__commonJS,
|
|
9
|
-
__toESM,
|
|
10
|
-
assertReachable,
|
|
11
|
-
buildServiceClientProperties,
|
|
12
|
-
buildServiceIdentityHeaders,
|
|
13
|
-
deobfuscate,
|
|
14
|
-
isUnreachableStatus,
|
|
15
2
|
obfuscate,
|
|
16
|
-
|
|
17
|
-
readRequiredCapabilities,
|
|
3
|
+
deobfuscate,
|
|
18
4
|
simple_default,
|
|
19
|
-
|
|
20
|
-
|
|
5
|
+
buildServiceClientProperties,
|
|
6
|
+
CAPABILITY_HEADER_KEYS,
|
|
7
|
+
readRequiredCapabilities,
|
|
8
|
+
unsupportedCapabilities,
|
|
9
|
+
buildServiceIdentityHeaders,
|
|
10
|
+
RequenceConnectionError2,
|
|
11
|
+
RequenceUnreachableError2,
|
|
12
|
+
isUnreachableStatus2,
|
|
13
|
+
assertReachable2,
|
|
14
|
+
reachableFetch2,
|
|
15
|
+
UITooLargeError2,
|
|
16
|
+
UnsupportedCapabilityError2,
|
|
17
|
+
PayloadTooLargeError2
|
|
18
|
+
} from "./chunk-6dx6x31h.js";
|
|
19
|
+
var __create = Object.create;
|
|
20
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
21
|
+
var __defProp = Object.defineProperty;
|
|
22
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
23
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
24
|
+
function __accessProp(key) {
|
|
25
|
+
return this[key];
|
|
26
|
+
}
|
|
27
|
+
var __toESMCache_node;
|
|
28
|
+
var __toESMCache_esm;
|
|
29
|
+
var __toESM = (mod, isNodeMode, target) => {
|
|
30
|
+
var canCache = mod != null && typeof mod === "object";
|
|
31
|
+
if (canCache) {
|
|
32
|
+
var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
|
|
33
|
+
var cached = cache.get(mod);
|
|
34
|
+
if (cached)
|
|
35
|
+
return cached;
|
|
36
|
+
}
|
|
37
|
+
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
38
|
+
const to = isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
39
|
+
if (mod && typeof mod === "object" || typeof mod === "function") {
|
|
40
|
+
for (let key of __getOwnPropNames(mod))
|
|
41
|
+
if (!__hasOwnProp.call(to, key))
|
|
42
|
+
__defProp(to, key, {
|
|
43
|
+
get: __accessProp.bind(mod, key),
|
|
44
|
+
enumerable: true
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
if (canCache)
|
|
48
|
+
cache.set(mod, to);
|
|
49
|
+
return to;
|
|
50
|
+
};
|
|
51
|
+
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
21
52
|
|
|
22
53
|
// ../../node_modules/.bun/dlv@1.1.3/node_modules/dlv/dist/dlv.js
|
|
23
|
-
var require_dlv = __commonJS((exports, module)
|
|
54
|
+
var require_dlv = __commonJS(function(exports, module) {
|
|
24
55
|
module.exports = function(t, e, l, n, o) {
|
|
25
56
|
for (e = e.split ? e.split(".") : e, n = 0;n < e.length; n++)
|
|
26
57
|
t = t ? t[e[n]] : o;
|
|
@@ -54,45 +85,45 @@ class AbortMapData extends Error {
|
|
|
54
85
|
}
|
|
55
86
|
function mapData(data, visitors) {
|
|
56
87
|
let aborted = false;
|
|
57
|
-
const traverseData = (
|
|
88
|
+
const traverseData = (data, path) => {
|
|
58
89
|
if (aborted) {
|
|
59
|
-
return
|
|
90
|
+
return data;
|
|
60
91
|
}
|
|
61
92
|
try {
|
|
62
|
-
if (Array.isArray(
|
|
63
|
-
return resolve(visitors.Array?.(
|
|
93
|
+
if (Array.isArray(data)) {
|
|
94
|
+
return resolve(visitors.Array?.(data, path), (resolvedData) => {
|
|
64
95
|
if (resolvedData) {
|
|
65
96
|
return resolvedData;
|
|
66
97
|
}
|
|
67
|
-
const items =
|
|
98
|
+
const items = data.map((item, index) => traverseData(item, [...path, index]));
|
|
68
99
|
if (items.some((item) => item instanceof Promise)) {
|
|
69
100
|
return Promise.all(items);
|
|
70
101
|
}
|
|
71
102
|
return items;
|
|
72
103
|
});
|
|
73
104
|
}
|
|
74
|
-
if (
|
|
75
|
-
return notUndefined(visitors.Null?.(
|
|
105
|
+
if (data === null) {
|
|
106
|
+
return notUndefined(visitors.Null?.(data, path), data);
|
|
76
107
|
}
|
|
77
108
|
const runtimeBuffer = globalThis.Buffer;
|
|
78
|
-
if (runtimeBuffer?.isBuffer(
|
|
79
|
-
return notUndefined(visitors.Buffer?.(
|
|
109
|
+
if (runtimeBuffer?.isBuffer(data)) {
|
|
110
|
+
return notUndefined(visitors.Buffer?.(data, path), data);
|
|
80
111
|
}
|
|
81
|
-
if (typeof
|
|
82
|
-
return notUndefined(visitors.String?.(
|
|
112
|
+
if (typeof data === "string") {
|
|
113
|
+
return notUndefined(visitors.String?.(data, path), data);
|
|
83
114
|
}
|
|
84
|
-
if (typeof
|
|
85
|
-
return notUndefined(visitors.Number?.(
|
|
115
|
+
if (typeof data === "number") {
|
|
116
|
+
return notUndefined(visitors.Number?.(data, path), data);
|
|
86
117
|
}
|
|
87
|
-
if (typeof
|
|
88
|
-
return notUndefined(visitors.Symbol?.(
|
|
118
|
+
if (typeof data === "symbol") {
|
|
119
|
+
return notUndefined(visitors.Symbol?.(data, path), data);
|
|
89
120
|
}
|
|
90
|
-
if (typeof
|
|
91
|
-
return notUndefined(visitors.Function?.(
|
|
121
|
+
if (typeof data === "function") {
|
|
122
|
+
return notUndefined(visitors.Function?.(data, path), data);
|
|
92
123
|
}
|
|
93
|
-
if (isRecord(
|
|
94
|
-
return resolve(visitors.Object?.({ ...
|
|
95
|
-
const nextData = resolvedData ??
|
|
124
|
+
if (isRecord(data)) {
|
|
125
|
+
return resolve(visitors.Object?.({ ...data }, path), (resolvedData) => {
|
|
126
|
+
const nextData = resolvedData ?? data;
|
|
96
127
|
if (!isRecord(nextData)) {
|
|
97
128
|
return nextData;
|
|
98
129
|
}
|
|
@@ -101,19 +132,19 @@ function mapData(data, visitors) {
|
|
|
101
132
|
traverseData(value, [...path, key])
|
|
102
133
|
]);
|
|
103
134
|
if (entries.some(([, value]) => value instanceof Promise)) {
|
|
104
|
-
return Promise.all(entries.map(([key, value]) => Promise.resolve().then(() => value).then((resolvedValue) => [key, resolvedValue]))).then((
|
|
135
|
+
return Promise.all(entries.map(([key, value]) => Promise.resolve().then(() => value).then((resolvedValue) => [key, resolvedValue]))).then((entries) => Object.fromEntries(entries));
|
|
105
136
|
}
|
|
106
137
|
return Object.fromEntries(entries);
|
|
107
138
|
});
|
|
108
139
|
}
|
|
109
|
-
if (typeof
|
|
110
|
-
return notUndefined(visitors.Object?.(
|
|
140
|
+
if (typeof data === "object" && data) {
|
|
141
|
+
return notUndefined(visitors.Object?.(data, path), data);
|
|
111
142
|
}
|
|
112
|
-
return
|
|
143
|
+
return data;
|
|
113
144
|
} catch (error) {
|
|
114
145
|
if (error instanceof AbortMapData) {
|
|
115
146
|
aborted = true;
|
|
116
|
-
return
|
|
147
|
+
return data;
|
|
117
148
|
}
|
|
118
149
|
throw error;
|
|
119
150
|
}
|
|
@@ -203,10 +234,10 @@ function isCallbackObject(data) {
|
|
|
203
234
|
return callbackObjectSchema.safeParse(data).success;
|
|
204
235
|
}
|
|
205
236
|
function createCallback(callback) {
|
|
206
|
-
const { promise, resolve
|
|
237
|
+
const { promise, resolve } = Promise.withResolvers();
|
|
207
238
|
const executor = (arg) => {
|
|
208
239
|
const value = arg === undefined ? null : arg;
|
|
209
|
-
|
|
240
|
+
resolve(value);
|
|
210
241
|
callback?.(value);
|
|
211
242
|
};
|
|
212
243
|
return Object.assign(executor, {
|
|
@@ -1336,9 +1367,9 @@ function createOutboundBoundary(base) {
|
|
|
1336
1367
|
};
|
|
1337
1368
|
if (opts.bestEffort) {
|
|
1338
1369
|
try {
|
|
1339
|
-
const { value
|
|
1340
|
-
ledger.push(
|
|
1341
|
-
return
|
|
1370
|
+
const { value, done } = await withRequenceStreams(() => transformer.outbound(sanitizeLogData(data), ctx));
|
|
1371
|
+
ledger.push(done.then(() => {}, (error) => warn("log stream upload failed:", error)));
|
|
1372
|
+
return value;
|
|
1342
1373
|
} catch (error) {
|
|
1343
1374
|
warn("log offload errored:", error);
|
|
1344
1375
|
return;
|
|
@@ -2008,7 +2039,7 @@ function createConnection({
|
|
|
2008
2039
|
clientProperties: {
|
|
2009
2040
|
...connectionOptions?.clientProperties,
|
|
2010
2041
|
...buildServiceClientProperties({
|
|
2011
|
-
libVersion: "javascript@0.8.5-edge.
|
|
2042
|
+
libVersion: "javascript@0.8.5-edge.1212",
|
|
2012
2043
|
serviceVersion: version,
|
|
2013
2044
|
connectionId,
|
|
2014
2045
|
prefetch,
|
|
@@ -2033,7 +2064,7 @@ function createConnection({
|
|
|
2033
2064
|
hasConnected = true;
|
|
2034
2065
|
onConnectionStateChange?.({ connected: true });
|
|
2035
2066
|
});
|
|
2036
|
-
const connectedPromise = new Promise((
|
|
2067
|
+
const connectedPromise = new Promise((resolve, reject) => {
|
|
2037
2068
|
const unsubscribe = () => {
|
|
2038
2069
|
clearTimeout(timeout);
|
|
2039
2070
|
connection.removeListener("connect", handleConnect);
|
|
@@ -2041,17 +2072,17 @@ function createConnection({
|
|
|
2041
2072
|
};
|
|
2042
2073
|
const timeout = setTimeout(() => {
|
|
2043
2074
|
handleConnectFailed({
|
|
2044
|
-
err: new
|
|
2075
|
+
err: new RequenceConnectionError2("Requence connection timeout")
|
|
2045
2076
|
});
|
|
2046
2077
|
}, connectionTimeout);
|
|
2047
2078
|
const handleConnect = () => {
|
|
2048
2079
|
unsubscribe();
|
|
2049
|
-
|
|
2080
|
+
resolve();
|
|
2050
2081
|
};
|
|
2051
2082
|
const handleConnectFailed = ({ err }) => {
|
|
2052
2083
|
unsubscribe();
|
|
2053
2084
|
if (err.message.startsWith("Handshake terminated by server: 403 (ACCESS-REFUSED)")) {
|
|
2054
|
-
reject(new
|
|
2085
|
+
reject(new RequenceConnectionError2("Invalid service credentials"));
|
|
2055
2086
|
} else {
|
|
2056
2087
|
reject(err);
|
|
2057
2088
|
}
|
|
@@ -2099,7 +2130,7 @@ function createConnection({
|
|
|
2099
2130
|
case "callback": {
|
|
2100
2131
|
const { surface } = backchannelMessage.payload;
|
|
2101
2132
|
const { taskId } = backchannelMessage;
|
|
2102
|
-
const report = surface && taskId ? (
|
|
2133
|
+
const report = surface && taskId ? (message) => reportInteractionFailure({ taskId, surface, message }) : () => {};
|
|
2103
2134
|
const entry = callbacks.get(backchannelMessage.payload.callbackId);
|
|
2104
2135
|
if (!entry) {
|
|
2105
2136
|
simple_default.warn(`Requence: dropped an invocation of callback |${backchannelMessage.payload.callbackId}| — nothing is registered under it, so the message that registered it has settled`);
|
|
@@ -2156,10 +2187,10 @@ function createConnection({
|
|
|
2156
2187
|
simple_default.error("Requence: cannot report a failed durable callback — the invocation names no task and node");
|
|
2157
2188
|
return;
|
|
2158
2189
|
}
|
|
2159
|
-
const { taskId, nodeId, name
|
|
2190
|
+
const { taskId, nodeId, name } = parsed.data;
|
|
2160
2191
|
channelWrapper.publish(exchange, "", Buffer.from(JSON.stringify({
|
|
2161
2192
|
nodeId,
|
|
2162
|
-
name
|
|
2193
|
+
name,
|
|
2163
2194
|
message: (error instanceof Error ? error.message : String(error)).slice(0, MAX_DURABLE_CALLBACK_ERROR_CHARS)
|
|
2164
2195
|
})), {
|
|
2165
2196
|
contentType: "application/json",
|
|
@@ -2169,7 +2200,7 @@ function createConnection({
|
|
|
2169
2200
|
[DURABLE_CALLBACK_ERROR_HEADER]: true
|
|
2170
2201
|
}
|
|
2171
2202
|
}).catch((publishError) => {
|
|
2172
|
-
simple_default.error(`Requence: could not report the failed durable callback |${
|
|
2203
|
+
simple_default.error(`Requence: could not report the failed durable callback |${name}| of task |${taskId}|:`, publishError instanceof Error ? publishError.message : publishError);
|
|
2173
2204
|
});
|
|
2174
2205
|
};
|
|
2175
2206
|
const announceResume = (params) => {
|
|
@@ -2218,8 +2249,8 @@ function createConnection({
|
|
|
2218
2249
|
simple_default.error("Requence: dropped a malformed surface handler invocation:", parsed.error.message);
|
|
2219
2250
|
return;
|
|
2220
2251
|
}
|
|
2221
|
-
const { taskId, surface, uiId, path
|
|
2222
|
-
const where = `UI |${uiId}| prop |${
|
|
2252
|
+
const { taskId, surface, uiId, path, arg } = parsed.data;
|
|
2253
|
+
const where = `UI |${uiId}| prop |${path.join(".") || "<root>"}| (task |${taskId}|)`;
|
|
2223
2254
|
const report = (message) => reportInteractionFailure({ taskId, surface, message });
|
|
2224
2255
|
const ui = findUIById(uiId);
|
|
2225
2256
|
if (!ui) {
|
|
@@ -2227,10 +2258,10 @@ function createConnection({
|
|
|
2227
2258
|
report(`the service has no component registered as "${uiId}", so nothing ran the handler`);
|
|
2228
2259
|
return;
|
|
2229
2260
|
}
|
|
2230
|
-
const handler = getByPath(ui.defaults,
|
|
2261
|
+
const handler = getByPath(ui.defaults, path);
|
|
2231
2262
|
if (typeof handler !== "function") {
|
|
2232
2263
|
simple_default.error(`Requence: no handler at ${where} — the component's defaults have ${handler === undefined ? "nothing" : typeof handler} there`);
|
|
2233
|
-
report(`this component has no handler at "${
|
|
2264
|
+
report(`this component has no handler at "${path.join(".") || "<root>"}", so nothing ran`);
|
|
2234
2265
|
return;
|
|
2235
2266
|
}
|
|
2236
2267
|
try {
|
|
@@ -2265,12 +2296,12 @@ function createConnection({
|
|
|
2265
2296
|
simple_default.error("Requence: dropped a malformed durable callback invocation — it does not name a callback this build can run");
|
|
2266
2297
|
return;
|
|
2267
2298
|
}
|
|
2268
|
-
const { name
|
|
2269
|
-
const registration = findDurableCallback(
|
|
2299
|
+
const { name, bound, arg, configuration, taskId, nodeId } = parsed.data;
|
|
2300
|
+
const registration = findDurableCallback(name);
|
|
2270
2301
|
if (!registration) {
|
|
2271
|
-
throw new Error(`no durable callback registered as "${
|
|
2302
|
+
throw new Error(`no durable callback registered as "${name}" — a reference naming it was emitted by node ${nodeId} of task ${taskId}, and this version declares none`);
|
|
2272
2303
|
}
|
|
2273
|
-
await registration.handler(arg, durableCallbackContext(
|
|
2304
|
+
await registration.handler(arg, durableCallbackContext(name, bound, configuration));
|
|
2274
2305
|
}
|
|
2275
2306
|
const callbackQueue = serviceCallbackQueueName(queue);
|
|
2276
2307
|
const callbackChannelWrapper = connection.createChannel({
|
|
@@ -2313,7 +2344,7 @@ function createConnection({
|
|
|
2313
2344
|
}) => {
|
|
2314
2345
|
const { body, contentType } = encodeWireBody(data ?? null, messageCodecs.get(messageId) ?? "json");
|
|
2315
2346
|
if (body.byteLength > maxMessageSize) {
|
|
2316
|
-
return Promise.reject(new
|
|
2347
|
+
return Promise.reject(new PayloadTooLargeError2(body.byteLength, maxMessageSize));
|
|
2317
2348
|
}
|
|
2318
2349
|
return channelWrapper.publish(exchange, "", body, {
|
|
2319
2350
|
correlationId: messageId,
|
|
@@ -2368,13 +2399,13 @@ function createConnection({
|
|
|
2368
2399
|
};
|
|
2369
2400
|
const buildRender = (deps) => {
|
|
2370
2401
|
const registerSurfaceHandler = (ui, handler, payloadPath) => {
|
|
2371
|
-
const [layer, ...
|
|
2402
|
+
const [layer, ...path] = payloadPath;
|
|
2372
2403
|
if (layer === "defaults") {
|
|
2373
2404
|
return {
|
|
2374
2405
|
__REQUENCE_type: SURFACE_HANDLER_TAG,
|
|
2375
2406
|
lifetime: "durable",
|
|
2376
2407
|
uiId: ui.id,
|
|
2377
|
-
path
|
|
2408
|
+
path
|
|
2378
2409
|
};
|
|
2379
2410
|
}
|
|
2380
2411
|
if (layer !== "props") {
|
|
@@ -2385,7 +2416,7 @@ function createConnection({
|
|
|
2385
2416
|
__REQUENCE_type: SURFACE_HANDLER_TAG,
|
|
2386
2417
|
lifetime: "connection",
|
|
2387
2418
|
uiId: ui.id,
|
|
2388
|
-
path
|
|
2419
|
+
path,
|
|
2389
2420
|
connectionId: sourceId,
|
|
2390
2421
|
handlerId: callbackId
|
|
2391
2422
|
};
|
|
@@ -2410,7 +2441,7 @@ function createConnection({
|
|
|
2410
2441
|
}, {
|
|
2411
2442
|
outputName: null,
|
|
2412
2443
|
inlineKeys: ["component", "defaults"],
|
|
2413
|
-
onSurfaceHandler: (handler,
|
|
2444
|
+
onSurfaceHandler: (handler, path) => registerSurfaceHandler(params.ui, handler, path)
|
|
2414
2445
|
}).then((data) => publish({
|
|
2415
2446
|
index,
|
|
2416
2447
|
version,
|
|
@@ -2448,7 +2479,7 @@ function createConnection({
|
|
|
2448
2479
|
messageIdForCleanup = messageId;
|
|
2449
2480
|
const unsupported = unsupportedCapabilities(readRequiredCapabilities(message.properties.headers));
|
|
2450
2481
|
if (unsupported.length > 0) {
|
|
2451
|
-
throw new
|
|
2482
|
+
throw new UnsupportedCapabilityError2(unsupported);
|
|
2452
2483
|
}
|
|
2453
2484
|
const dispatchCodec = wireCodecFromContentType(message.properties.contentType);
|
|
2454
2485
|
messageCodecs.set(messageId, dispatchCodec);
|
|
@@ -2465,14 +2496,14 @@ function createConnection({
|
|
|
2465
2496
|
const payload = payloadSchema.parse(message);
|
|
2466
2497
|
const abortController = new AbortController;
|
|
2467
2498
|
const growth = callbackGrowth.forDelivery({ taskId });
|
|
2468
|
-
const registerCallback = (callback,
|
|
2499
|
+
const registerCallback = (callback, path) => {
|
|
2469
2500
|
const callbackId = crypto.randomUUID();
|
|
2470
2501
|
registeredCallbackIds.add(callbackId);
|
|
2471
2502
|
callbacks.set(callbackId, {
|
|
2472
2503
|
callback,
|
|
2473
2504
|
onCallbackInvoke: dispatchInvocation
|
|
2474
2505
|
});
|
|
2475
|
-
growth.record(
|
|
2506
|
+
growth.record(path);
|
|
2476
2507
|
return { sourceId: connectionId, callbackId };
|
|
2477
2508
|
};
|
|
2478
2509
|
const outbound = createOutboundBoundary({
|
|
@@ -2569,7 +2600,7 @@ function createConnection({
|
|
|
2569
2600
|
begin: true,
|
|
2570
2601
|
epoch,
|
|
2571
2602
|
...buildServiceIdentityHeaders({
|
|
2572
|
-
libVersion: "javascript@0.8.5-edge.
|
|
2603
|
+
libVersion: "javascript@0.8.5-edge.1212",
|
|
2573
2604
|
name,
|
|
2574
2605
|
holdsSlot: !(isGeneratorHandler && mode === "CONTINUOUS")
|
|
2575
2606
|
})
|
|
@@ -2660,7 +2691,7 @@ function createConnection({
|
|
|
2660
2691
|
});
|
|
2661
2692
|
}
|
|
2662
2693
|
}
|
|
2663
|
-
await new Promise((
|
|
2694
|
+
await new Promise((resolve, reject) => {
|
|
2664
2695
|
setImmediate(async () => {
|
|
2665
2696
|
try {
|
|
2666
2697
|
if (!deferred) {
|
|
@@ -2680,7 +2711,7 @@ function createConnection({
|
|
|
2680
2711
|
if (!acked) {
|
|
2681
2712
|
safeAck(channel, message);
|
|
2682
2713
|
}
|
|
2683
|
-
|
|
2714
|
+
resolve();
|
|
2684
2715
|
} catch (error) {
|
|
2685
2716
|
reject(error);
|
|
2686
2717
|
}
|
|
@@ -2708,7 +2739,7 @@ function createConnection({
|
|
|
2708
2739
|
});
|
|
2709
2740
|
return;
|
|
2710
2741
|
}
|
|
2711
|
-
if (error instanceof
|
|
2742
|
+
if (error instanceof UnsupportedCapabilityError2) {
|
|
2712
2743
|
if (!silent) {
|
|
2713
2744
|
simple_default.error(error.message);
|
|
2714
2745
|
}
|
|
@@ -2816,14 +2847,14 @@ function createConnection({
|
|
|
2816
2847
|
const registeredCallbackIds = new Set;
|
|
2817
2848
|
const outbound = createOutboundBoundary(options);
|
|
2818
2849
|
const growth = callbackGrowth.forDelivery({ taskId });
|
|
2819
|
-
const registerCallback = (callback,
|
|
2850
|
+
const registerCallback = (callback, path) => {
|
|
2820
2851
|
const callbackId = crypto.randomUUID();
|
|
2821
2852
|
registeredCallbackIds.add(callbackId);
|
|
2822
2853
|
callbacks.set(callbackId, {
|
|
2823
2854
|
callback,
|
|
2824
2855
|
onCallbackInvoke: dispatchInvocation
|
|
2825
2856
|
});
|
|
2826
|
-
growth.record(
|
|
2857
|
+
growth.record(path);
|
|
2827
2858
|
return { sourceId: connectionId, callbackId };
|
|
2828
2859
|
};
|
|
2829
2860
|
const dispatchInvocation = (invocation) => {
|
|
@@ -2888,7 +2919,7 @@ function createConnection({
|
|
|
2888
2919
|
} else if (result !== undefined) {
|
|
2889
2920
|
await sendApi.send(result);
|
|
2890
2921
|
}
|
|
2891
|
-
await new Promise((
|
|
2922
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
2892
2923
|
await activeMessage();
|
|
2893
2924
|
await outbound.settle();
|
|
2894
2925
|
} catch (error) {
|
|
@@ -2926,18 +2957,18 @@ function createUI(target, defaults) {
|
|
|
2926
2957
|
if (!(options?.url instanceof URL) || options.url.protocol !== "file:") {
|
|
2927
2958
|
throw new Error("createUI needs a file URL to the built component: new URL('./component.js', import.meta.url)");
|
|
2928
2959
|
}
|
|
2929
|
-
const
|
|
2930
|
-
const bundle = fs2.readFileSync(
|
|
2960
|
+
const path = fileURLToPath(options.url);
|
|
2961
|
+
const bundle = fs2.readFileSync(path);
|
|
2931
2962
|
if (bundle.byteLength > MAX_UI_SOURCE_BYTES) {
|
|
2932
|
-
throw new
|
|
2963
|
+
throw new UITooLargeError2(path, bundle.byteLength, MAX_UI_SOURCE_BYTES);
|
|
2933
2964
|
}
|
|
2934
2965
|
const ui = {
|
|
2935
|
-
id: options.id ?? basename(
|
|
2966
|
+
id: options.id ?? basename(path),
|
|
2936
2967
|
hash: createHash3("sha256").update(bundle).digest("hex"),
|
|
2937
2968
|
source: bundle.toString("utf-8"),
|
|
2938
2969
|
...defaults === undefined ? {} : { defaults: { ...defaults } }
|
|
2939
2970
|
};
|
|
2940
|
-
registerUI(ui,
|
|
2971
|
+
registerUI(ui, path);
|
|
2941
2972
|
return ui;
|
|
2942
2973
|
}
|
|
2943
2974
|
// src/utils.ts
|
|
@@ -2998,9 +3029,9 @@ function asyncEventEmitter(initial = []) {
|
|
|
2998
3029
|
return {
|
|
2999
3030
|
push: (value) => {
|
|
3000
3031
|
if (waiting) {
|
|
3001
|
-
const
|
|
3032
|
+
const resolve = waiting;
|
|
3002
3033
|
waiting = null;
|
|
3003
|
-
|
|
3034
|
+
resolve(value);
|
|
3004
3035
|
return;
|
|
3005
3036
|
}
|
|
3006
3037
|
queue.push(value);
|
|
@@ -3073,15 +3104,15 @@ function createService(optionsOrVersion, optionalMessageHandler) {
|
|
|
3073
3104
|
let token = options.accessToken ?? process.env.REQUENCE_SERVICE_ACCESS_TOKEN ?? process.env.REQUENCE_ACCESS_TOKEN;
|
|
3074
3105
|
if (!token) {
|
|
3075
3106
|
try {
|
|
3076
|
-
const
|
|
3077
|
-
token =
|
|
3107
|
+
const pkgJson = loadPkgJson();
|
|
3108
|
+
token = pkgJson.requence?.service?.accessToken ?? pkgJson.requence?.accessToken;
|
|
3078
3109
|
} catch {}
|
|
3079
3110
|
}
|
|
3080
3111
|
let devToken = options.devToken ?? process.env.REQUENCE_SERVICE_DEV_TOKEN ?? process.env.REQUENCE_DEV_TOKEN;
|
|
3081
3112
|
if (!devToken) {
|
|
3082
3113
|
try {
|
|
3083
|
-
const
|
|
3084
|
-
devToken =
|
|
3114
|
+
const pkgJson = loadPkgJson();
|
|
3115
|
+
devToken = pkgJson.requence?.service?.devToken ?? pkgJson.requence?.devToken;
|
|
3085
3116
|
} catch {}
|
|
3086
3117
|
}
|
|
3087
3118
|
if (!token) {
|
|
@@ -3120,31 +3151,31 @@ function createService(optionsOrVersion, optionalMessageHandler) {
|
|
|
3120
3151
|
}, messageHandler);
|
|
3121
3152
|
}
|
|
3122
3153
|
export {
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
isUnreachableStatus,
|
|
3126
|
-
createUI,
|
|
3127
|
-
createService,
|
|
3128
|
-
createDurableCallback,
|
|
3129
|
-
createCallback,
|
|
3130
|
-
asyncEventEmitter,
|
|
3131
|
-
assertReachable,
|
|
3132
|
-
UnsupportedCapabilityError,
|
|
3133
|
-
UITooLargeError,
|
|
3134
|
-
StoreValueTooLargeError,
|
|
3135
|
-
StoreValueNotStorableError,
|
|
3136
|
-
StoreUnavailableError,
|
|
3137
|
-
StoreUnauthorizedError,
|
|
3138
|
-
StoreTaskNotAllowedError,
|
|
3139
|
-
StoreRequestError,
|
|
3140
|
-
StoreError,
|
|
3141
|
-
StoreAddressFullError,
|
|
3142
|
-
RequenceUnreachableError,
|
|
3143
|
-
RequenceStream,
|
|
3154
|
+
PayloadTooLargeError2 as PayloadTooLargeError,
|
|
3155
|
+
RequenceConnectionError2 as RequenceConnectionError,
|
|
3144
3156
|
RequenceFile,
|
|
3145
|
-
|
|
3146
|
-
|
|
3157
|
+
RequenceStream,
|
|
3158
|
+
RequenceUnreachableError2 as RequenceUnreachableError,
|
|
3159
|
+
StoreAddressFullError,
|
|
3160
|
+
StoreError,
|
|
3161
|
+
StoreRequestError,
|
|
3162
|
+
StoreTaskNotAllowedError,
|
|
3163
|
+
StoreUnauthorizedError,
|
|
3164
|
+
StoreUnavailableError,
|
|
3165
|
+
StoreValueNotStorableError,
|
|
3166
|
+
StoreValueTooLargeError,
|
|
3167
|
+
UITooLargeError2 as UITooLargeError,
|
|
3168
|
+
UnsupportedCapabilityError2 as UnsupportedCapabilityError,
|
|
3169
|
+
assertReachable2 as assertReachable,
|
|
3170
|
+
asyncEventEmitter,
|
|
3171
|
+
createCallback,
|
|
3172
|
+
createDurableCallback,
|
|
3173
|
+
createService,
|
|
3174
|
+
createUI,
|
|
3175
|
+
isUnreachableStatus2 as isUnreachableStatus,
|
|
3176
|
+
reachableFetch2 as reachableFetch,
|
|
3177
|
+
wrapIterable
|
|
3147
3178
|
};
|
|
3148
3179
|
|
|
3149
|
-
//# debugId=
|
|
3180
|
+
//# debugId=A2BCC6DE93A6FAB664756E2164756E21
|
|
3150
3181
|
//# sourceMappingURL=index.js.map
|