@dxos/client-services 0.6.14-main.2b6a0f3 → 0.6.14-main.f49f251
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/dist/lib/browser/{chunk-BBLK6AUB.mjs → chunk-Z3SSMM5X.mjs} +488 -174
- package/dist/lib/browser/chunk-Z3SSMM5X.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +43 -314
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +1 -2
- package/dist/lib/browser/testing/index.mjs.map +1 -1
- package/dist/lib/node/{chunk-SJEDBF7U.cjs → chunk-ZORMUE2S.cjs} +755 -433
- package/dist/lib/node/chunk-ZORMUE2S.cjs.map +7 -0
- package/dist/lib/node/index.cjs +95 -366
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +8 -8
- package/dist/lib/node-esm/{chunk-A6GS6OOD.mjs → chunk-4NBD4YSD.mjs} +488 -166
- package/dist/lib/node-esm/chunk-4NBD4YSD.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +43 -314
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/testing/index.mjs +1 -1
- package/dist/types/src/packlets/invitations/device-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitation-state.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/invitations-handler.d.ts.map +1 -1
- package/dist/types/src/packlets/invitations/space-invitation-protocol.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/package.json +43 -49
- package/src/packlets/invitations/device-invitation-protocol.ts +3 -1
- package/src/packlets/invitations/invitation-state.ts +13 -12
- package/src/packlets/invitations/invitations-handler.ts +34 -5
- package/src/packlets/invitations/space-invitation-protocol.ts +1 -0
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-BBLK6AUB.mjs.map +0 -7
- package/dist/lib/node/chunk-SJEDBF7U.cjs.map +0 -7
- package/dist/lib/node-esm/chunk-A6GS6OOD.mjs.map +0 -7
package/dist/lib/node/index.cjs
CHANGED
|
@@ -18,351 +18,80 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var node_exports = {};
|
|
20
20
|
__export(node_exports, {
|
|
21
|
-
ClientRpcServer: () => ClientRpcServer,
|
|
22
|
-
ClientServicesHost: () =>
|
|
23
|
-
DataSpace: () =>
|
|
24
|
-
DataSpaceManager: () =>
|
|
25
|
-
DeviceInvitationProtocol: () =>
|
|
26
|
-
DevtoolsHostEvents: () =>
|
|
27
|
-
DevtoolsServiceImpl: () =>
|
|
28
|
-
DiagnosticsCollector: () => DiagnosticsCollector,
|
|
29
|
-
EdgeAgentManager: () =>
|
|
30
|
-
EdgeAgentServiceImpl: () =>
|
|
31
|
-
EdgeFeedReplicator: () =>
|
|
32
|
-
Identity: () =>
|
|
33
|
-
IdentityManager: () =>
|
|
34
|
-
IdentityServiceImpl: () =>
|
|
35
|
-
InvitationsHandler: () =>
|
|
36
|
-
InvitationsManager: () =>
|
|
37
|
-
InvitationsServiceImpl: () =>
|
|
38
|
-
Lock: () =>
|
|
39
|
-
ServiceContext: () =>
|
|
40
|
-
ServiceRegistry: () =>
|
|
41
|
-
SpaceInvitationProtocol: () =>
|
|
42
|
-
SpacesServiceImpl: () =>
|
|
43
|
-
TrustedKeySetAuthVerifier: () =>
|
|
21
|
+
ClientRpcServer: () => import_chunk_ZORMUE2S.ClientRpcServer,
|
|
22
|
+
ClientServicesHost: () => import_chunk_ZORMUE2S.ClientServicesHost,
|
|
23
|
+
DataSpace: () => import_chunk_ZORMUE2S.DataSpace,
|
|
24
|
+
DataSpaceManager: () => import_chunk_ZORMUE2S.DataSpaceManager,
|
|
25
|
+
DeviceInvitationProtocol: () => import_chunk_ZORMUE2S.DeviceInvitationProtocol,
|
|
26
|
+
DevtoolsHostEvents: () => import_chunk_ZORMUE2S.DevtoolsHostEvents,
|
|
27
|
+
DevtoolsServiceImpl: () => import_chunk_ZORMUE2S.DevtoolsServiceImpl,
|
|
28
|
+
DiagnosticsCollector: () => import_chunk_ZORMUE2S.DiagnosticsCollector,
|
|
29
|
+
EdgeAgentManager: () => import_chunk_ZORMUE2S.EdgeAgentManager,
|
|
30
|
+
EdgeAgentServiceImpl: () => import_chunk_ZORMUE2S.EdgeAgentServiceImpl,
|
|
31
|
+
EdgeFeedReplicator: () => import_chunk_ZORMUE2S.EdgeFeedReplicator,
|
|
32
|
+
Identity: () => import_chunk_ZORMUE2S.Identity,
|
|
33
|
+
IdentityManager: () => import_chunk_ZORMUE2S.IdentityManager,
|
|
34
|
+
IdentityServiceImpl: () => import_chunk_ZORMUE2S.IdentityServiceImpl,
|
|
35
|
+
InvitationsHandler: () => import_chunk_ZORMUE2S.InvitationsHandler,
|
|
36
|
+
InvitationsManager: () => import_chunk_ZORMUE2S.InvitationsManager,
|
|
37
|
+
InvitationsServiceImpl: () => import_chunk_ZORMUE2S.InvitationsServiceImpl,
|
|
38
|
+
Lock: () => import_chunk_ZORMUE2S.Lock,
|
|
39
|
+
ServiceContext: () => import_chunk_ZORMUE2S.ServiceContext,
|
|
40
|
+
ServiceRegistry: () => import_chunk_ZORMUE2S.ServiceRegistry,
|
|
41
|
+
SpaceInvitationProtocol: () => import_chunk_ZORMUE2S.SpaceInvitationProtocol,
|
|
42
|
+
SpacesServiceImpl: () => import_chunk_ZORMUE2S.SpacesServiceImpl,
|
|
43
|
+
TrustedKeySetAuthVerifier: () => import_chunk_ZORMUE2S.TrustedKeySetAuthVerifier,
|
|
44
44
|
WorkerRuntime: () => WorkerRuntime,
|
|
45
45
|
WorkerSession: () => WorkerSession,
|
|
46
|
-
createAdmissionKeypair: () =>
|
|
47
|
-
createAuthProvider: () =>
|
|
48
|
-
createCollectDiagnosticsBroadcastHandler: () =>
|
|
49
|
-
createCollectDiagnosticsBroadcastSender: () =>
|
|
50
|
-
createDiagnostics: () =>
|
|
51
|
-
createLevel: () =>
|
|
52
|
-
createStorageObjects: () =>
|
|
53
|
-
decodeProfileArchive: () => decodeProfileArchive,
|
|
54
|
-
encodeProfileArchive: () => encodeProfileArchive,
|
|
55
|
-
exportProfileData: () => exportProfileData,
|
|
56
|
-
getNetworkPeers: () =>
|
|
57
|
-
importProfileData: () => importProfileData,
|
|
58
|
-
isLocked: () =>
|
|
59
|
-
subscribeToFeedBlocks: () =>
|
|
60
|
-
subscribeToFeeds: () =>
|
|
61
|
-
subscribeToNetworkStatus: () =>
|
|
62
|
-
subscribeToNetworkTopics: () =>
|
|
63
|
-
subscribeToSignal: () =>
|
|
64
|
-
subscribeToSpaces: () =>
|
|
65
|
-
subscribeToSwarmInfo: () =>
|
|
46
|
+
createAdmissionKeypair: () => import_chunk_ZORMUE2S.createAdmissionKeypair,
|
|
47
|
+
createAuthProvider: () => import_chunk_ZORMUE2S.createAuthProvider,
|
|
48
|
+
createCollectDiagnosticsBroadcastHandler: () => import_chunk_ZORMUE2S.createCollectDiagnosticsBroadcastHandler,
|
|
49
|
+
createCollectDiagnosticsBroadcastSender: () => import_chunk_ZORMUE2S.createCollectDiagnosticsBroadcastSender,
|
|
50
|
+
createDiagnostics: () => import_chunk_ZORMUE2S.createDiagnostics,
|
|
51
|
+
createLevel: () => import_chunk_ZORMUE2S.createLevel,
|
|
52
|
+
createStorageObjects: () => import_chunk_ZORMUE2S.createStorageObjects,
|
|
53
|
+
decodeProfileArchive: () => import_chunk_ZORMUE2S.decodeProfileArchive,
|
|
54
|
+
encodeProfileArchive: () => import_chunk_ZORMUE2S.encodeProfileArchive,
|
|
55
|
+
exportProfileData: () => import_chunk_ZORMUE2S.exportProfileData,
|
|
56
|
+
getNetworkPeers: () => import_chunk_ZORMUE2S.getNetworkPeers,
|
|
57
|
+
importProfileData: () => import_chunk_ZORMUE2S.importProfileData,
|
|
58
|
+
isLocked: () => import_chunk_ZORMUE2S.isLocked,
|
|
59
|
+
subscribeToFeedBlocks: () => import_chunk_ZORMUE2S.subscribeToFeedBlocks,
|
|
60
|
+
subscribeToFeeds: () => import_chunk_ZORMUE2S.subscribeToFeeds,
|
|
61
|
+
subscribeToNetworkStatus: () => import_chunk_ZORMUE2S.subscribeToNetworkStatus,
|
|
62
|
+
subscribeToNetworkTopics: () => import_chunk_ZORMUE2S.subscribeToNetworkTopics,
|
|
63
|
+
subscribeToSignal: () => import_chunk_ZORMUE2S.subscribeToSignal,
|
|
64
|
+
subscribeToSpaces: () => import_chunk_ZORMUE2S.subscribeToSpaces,
|
|
65
|
+
subscribeToSwarmInfo: () => import_chunk_ZORMUE2S.subscribeToSwarmInfo
|
|
66
66
|
});
|
|
67
67
|
module.exports = __toCommonJS(node_exports);
|
|
68
|
-
var
|
|
68
|
+
var import_chunk_ZORMUE2S = require("./chunk-ZORMUE2S.cjs");
|
|
69
|
+
var import_async = require("@dxos/async");
|
|
69
70
|
var import_client_protocol = require("@dxos/client-protocol");
|
|
70
|
-
var
|
|
71
|
-
var import_services = require("@dxos/protocols/proto/dxos/client/services");
|
|
72
|
-
var import_tracing = require("@dxos/tracing");
|
|
73
|
-
var import_util = require("@dxos/util");
|
|
74
|
-
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
75
|
-
var import_debug = require("@dxos/debug");
|
|
76
|
-
var import_rpc = require("@dxos/rpc");
|
|
77
|
-
var import_tracing2 = require("@dxos/tracing");
|
|
78
|
-
var import_automerge_repo = require("@dxos/automerge/automerge-repo");
|
|
71
|
+
var import_context = require("@dxos/context");
|
|
79
72
|
var import_invariant = require("@dxos/invariant");
|
|
80
73
|
var import_log = require("@dxos/log");
|
|
81
|
-
var import_protocols = require("@dxos/protocols");
|
|
82
|
-
var import_util2 = require("@dxos/util");
|
|
83
|
-
var import_async = require("@dxos/async");
|
|
84
|
-
var import_client_protocol2 = require("@dxos/client-protocol");
|
|
85
|
-
var import_context = require("@dxos/context");
|
|
86
|
-
var import_invariant2 = require("@dxos/invariant");
|
|
87
|
-
var import_log2 = require("@dxos/log");
|
|
88
74
|
var import_messaging = require("@dxos/messaging");
|
|
89
75
|
var import_network_manager = require("@dxos/network-manager");
|
|
90
76
|
var import_async2 = require("@dxos/async");
|
|
91
|
-
var
|
|
92
|
-
var
|
|
93
|
-
var
|
|
94
|
-
var
|
|
95
|
-
var
|
|
96
|
-
var GET_DIAGNOSTICS_RPC_TIMEOUT = 1e4;
|
|
97
|
-
var DiagnosticsCollector = class {
|
|
98
|
-
static {
|
|
99
|
-
this.broadcastSender = (0, import_chunk_SJEDBF7U.createCollectDiagnosticsBroadcastSender)();
|
|
100
|
-
}
|
|
101
|
-
static async collect(config = findConfigs(), services = findSystemServiceProvider(), options = {}) {
|
|
102
|
-
const serviceDiagnostics = await services?.services?.SystemService?.getDiagnostics({
|
|
103
|
-
keys: options.humanize ? import_services.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE : options.truncate ? import_services.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE : void 0
|
|
104
|
-
}, {
|
|
105
|
-
timeout: GET_DIAGNOSTICS_RPC_TIMEOUT
|
|
106
|
-
});
|
|
107
|
-
const clientDiagnostics = {
|
|
108
|
-
config,
|
|
109
|
-
trace: import_tracing.TRACE_PROCESSOR.getDiagnostics()
|
|
110
|
-
};
|
|
111
|
-
const diagnostics = serviceDiagnostics != null ? {
|
|
112
|
-
client: clientDiagnostics,
|
|
113
|
-
services: serviceDiagnostics
|
|
114
|
-
} : {
|
|
115
|
-
client: clientDiagnostics,
|
|
116
|
-
broadcast: await this.broadcastSender.broadcastDiagnosticsRequest()
|
|
117
|
-
};
|
|
118
|
-
return JSON.parse(JSON.stringify(diagnostics, (0, import_util.jsonKeyReplacer)(options)));
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
var findSystemServiceProvider = () => {
|
|
122
|
-
const serviceProviders = import_tracing.TRACE_PROCESSOR.findResourcesByAnnotation(import_client_protocol.ClientServicesProviderResource);
|
|
123
|
-
const providerResource = serviceProviders.find((r) => r.instance.deref()?.services?.SystemService != null);
|
|
124
|
-
return providerResource?.instance?.deref() ?? null;
|
|
125
|
-
};
|
|
126
|
-
var findConfigs = () => {
|
|
127
|
-
const configs = import_tracing.TRACE_PROCESSOR.findResourcesByAnnotation(import_config.ConfigResource);
|
|
128
|
-
return configs.map((r) => r.instance.deref()).filter(import_util.nonNullable);
|
|
129
|
-
};
|
|
77
|
+
var import_client_protocol2 = require("@dxos/client-protocol");
|
|
78
|
+
var import_invariant2 = require("@dxos/invariant");
|
|
79
|
+
var import_log2 = require("@dxos/log");
|
|
80
|
+
var import_rpc = require("@dxos/rpc");
|
|
81
|
+
var import_util = require("@dxos/util");
|
|
130
82
|
function _ts_decorate(decorators, target, key, desc) {
|
|
131
83
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
132
84
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
133
85
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
134
86
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
135
87
|
}
|
|
136
|
-
var
|
|
137
|
-
constructor(params) {
|
|
138
|
-
this._handlerCache = /* @__PURE__ */ new Map();
|
|
139
|
-
this._callMetrics = new import_tracing2.MapCounter();
|
|
140
|
-
const { serviceRegistry, handleCall, handleStream, ...rpcOptions } = params;
|
|
141
|
-
this._handleCall = handleCall;
|
|
142
|
-
this._handleStream = handleStream;
|
|
143
|
-
this._serviceRegistry = serviceRegistry;
|
|
144
|
-
this._rpcPeer = new import_rpc.RpcPeer({
|
|
145
|
-
...rpcOptions,
|
|
146
|
-
callHandler: (method, params2) => {
|
|
147
|
-
const [serviceName, methodName] = (0, import_rpc.parseMethodName)(method);
|
|
148
|
-
const handler = (method2, params3) => this._getServiceHandler(serviceName).call(method2, params3);
|
|
149
|
-
this._callMetrics.inc(`${serviceName}.${methodName} request`);
|
|
150
|
-
if (this._handleCall) {
|
|
151
|
-
return this._handleCall(methodName, params2, handler);
|
|
152
|
-
} else {
|
|
153
|
-
return handler(methodName, params2);
|
|
154
|
-
}
|
|
155
|
-
},
|
|
156
|
-
streamHandler: (method, params2) => {
|
|
157
|
-
const [serviceName, methodName] = (0, import_rpc.parseMethodName)(method);
|
|
158
|
-
const handler = (method2, params3) => this._getServiceHandler(serviceName).callStream(method2, params3);
|
|
159
|
-
this._callMetrics.inc(`${serviceName}.${methodName} request stream`);
|
|
160
|
-
if (this._handleStream) {
|
|
161
|
-
return import_codec_protobuf.Stream.map(import_codec_protobuf.Stream.unwrapPromise(this._handleStream(methodName, params2, handler)), (data) => {
|
|
162
|
-
this._callMetrics.inc(`${serviceName}.${methodName} response stream`);
|
|
163
|
-
return data;
|
|
164
|
-
});
|
|
165
|
-
} else {
|
|
166
|
-
return handler(methodName, params2);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
get _services() {
|
|
172
|
-
return Object.keys(this._serviceRegistry.services);
|
|
173
|
-
}
|
|
174
|
-
async open() {
|
|
175
|
-
await this._rpcPeer.open();
|
|
176
|
-
}
|
|
177
|
-
async close() {
|
|
178
|
-
await this._rpcPeer.close();
|
|
179
|
-
}
|
|
180
|
-
_getServiceHandler(serviceName) {
|
|
181
|
-
if (!this._handlerCache.has(serviceName)) {
|
|
182
|
-
const [key, descriptor] = Object.entries(this._serviceRegistry.descriptors).find(([key2, descriptor2]) => descriptor2.name === serviceName) ?? (0, import_debug.raise)(new Error(`Service not available: ${serviceName}`));
|
|
183
|
-
const service = this._serviceRegistry.services[key];
|
|
184
|
-
if (!service) {
|
|
185
|
-
throw new Error(`Service not available: ${serviceName}`);
|
|
186
|
-
}
|
|
187
|
-
this._handlerCache.set(serviceName, descriptor.createServer(service));
|
|
188
|
-
}
|
|
189
|
-
return this._handlerCache.get(serviceName);
|
|
190
|
-
}
|
|
191
|
-
};
|
|
192
|
-
_ts_decorate([
|
|
193
|
-
import_tracing2.trace.metricsCounter()
|
|
194
|
-
], ClientRpcServer.prototype, "_callMetrics", void 0);
|
|
195
|
-
_ts_decorate([
|
|
196
|
-
import_tracing2.trace.info()
|
|
197
|
-
], ClientRpcServer.prototype, "_services", null);
|
|
198
|
-
ClientRpcServer = _ts_decorate([
|
|
199
|
-
import_tracing2.trace.resource()
|
|
200
|
-
], ClientRpcServer);
|
|
201
|
-
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/storage/profile-archive.ts";
|
|
202
|
-
var encodeProfileArchive = (profile) => import_automerge_repo.cbor.encode(profile);
|
|
203
|
-
var decodeProfileArchive = (data) => import_automerge_repo.cbor.decode(data);
|
|
204
|
-
var exportProfileData = async ({ storage, level }) => {
|
|
205
|
-
const archive = {
|
|
206
|
-
storage: [],
|
|
207
|
-
meta: {
|
|
208
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
209
|
-
}
|
|
210
|
-
};
|
|
211
|
-
{
|
|
212
|
-
const directory = await storage.createDirectory();
|
|
213
|
-
const files = await directory.list();
|
|
214
|
-
import_log.log.info("begin exporting files", {
|
|
215
|
-
count: files.length
|
|
216
|
-
}, {
|
|
217
|
-
F: __dxlog_file,
|
|
218
|
-
L: 30,
|
|
219
|
-
S: void 0,
|
|
220
|
-
C: (f, a) => f(...a)
|
|
221
|
-
});
|
|
222
|
-
for (const filename of files) {
|
|
223
|
-
const file = await directory.getOrCreateFile(filename);
|
|
224
|
-
const { size } = await file.stat();
|
|
225
|
-
const data = await file.read(0, size);
|
|
226
|
-
archive.storage.push({
|
|
227
|
-
type: import_protocols.ProfileArchiveEntryType.FILE,
|
|
228
|
-
key: filename,
|
|
229
|
-
value: data
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
import_log.log.info("done exporting files", {
|
|
233
|
-
count: files.length
|
|
234
|
-
}, {
|
|
235
|
-
F: __dxlog_file,
|
|
236
|
-
L: 41,
|
|
237
|
-
S: void 0,
|
|
238
|
-
C: (f, a) => f(...a)
|
|
239
|
-
});
|
|
240
|
-
}
|
|
241
|
-
{
|
|
242
|
-
import_log.log.info("begin exporting kv pairs", void 0, {
|
|
243
|
-
F: __dxlog_file,
|
|
244
|
-
L: 45,
|
|
245
|
-
S: void 0,
|
|
246
|
-
C: (f, a) => f(...a)
|
|
247
|
-
});
|
|
248
|
-
const iter = await level.iterator({
|
|
249
|
-
keyEncoding: "binary",
|
|
250
|
-
valueEncoding: "binary"
|
|
251
|
-
});
|
|
252
|
-
let count = 0;
|
|
253
|
-
for await (const [key, value] of iter) {
|
|
254
|
-
archive.storage.push({
|
|
255
|
-
type: import_protocols.ProfileArchiveEntryType.KEY_VALUE,
|
|
256
|
-
key,
|
|
257
|
-
value
|
|
258
|
-
});
|
|
259
|
-
count++;
|
|
260
|
-
}
|
|
261
|
-
import_log.log.info("done exporting kv pairs", {
|
|
262
|
-
count
|
|
263
|
-
}, {
|
|
264
|
-
F: __dxlog_file,
|
|
265
|
-
L: 56,
|
|
266
|
-
S: void 0,
|
|
267
|
-
C: (f, a) => f(...a)
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
|
-
return archive;
|
|
271
|
-
};
|
|
272
|
-
var importProfileData = async ({ storage, level }, archive) => {
|
|
273
|
-
let batch = level.batch();
|
|
274
|
-
let count = 0;
|
|
275
|
-
for (const entry of archive.storage) {
|
|
276
|
-
switch (entry.type) {
|
|
277
|
-
case import_protocols.ProfileArchiveEntryType.FILE: {
|
|
278
|
-
const directory = await storage.createDirectory();
|
|
279
|
-
(0, import_invariant.invariant)(typeof entry.key === "string", "Invalid key type", {
|
|
280
|
-
F: __dxlog_file,
|
|
281
|
-
L: 79,
|
|
282
|
-
S: void 0,
|
|
283
|
-
A: [
|
|
284
|
-
"typeof entry.key === 'string'",
|
|
285
|
-
"'Invalid key type'"
|
|
286
|
-
]
|
|
287
|
-
});
|
|
288
|
-
const file = await directory.getOrCreateFile(entry.key);
|
|
289
|
-
(0, import_invariant.invariant)(entry.value instanceof Uint8Array, "Invalid value type", {
|
|
290
|
-
F: __dxlog_file,
|
|
291
|
-
L: 81,
|
|
292
|
-
S: void 0,
|
|
293
|
-
A: [
|
|
294
|
-
"entry.value instanceof Uint8Array",
|
|
295
|
-
"'Invalid value type'"
|
|
296
|
-
]
|
|
297
|
-
});
|
|
298
|
-
await file.write(0, (0, import_util2.arrayToBuffer)(entry.value));
|
|
299
|
-
await file.close();
|
|
300
|
-
break;
|
|
301
|
-
}
|
|
302
|
-
case import_protocols.ProfileArchiveEntryType.KEY_VALUE: {
|
|
303
|
-
(0, import_invariant.invariant)(entry.key instanceof Uint8Array, "Invalid key type", {
|
|
304
|
-
F: __dxlog_file,
|
|
305
|
-
L: 87,
|
|
306
|
-
S: void 0,
|
|
307
|
-
A: [
|
|
308
|
-
"entry.key instanceof Uint8Array",
|
|
309
|
-
"'Invalid key type'"
|
|
310
|
-
]
|
|
311
|
-
});
|
|
312
|
-
(0, import_invariant.invariant)(entry.value instanceof Uint8Array, "Invalid value type", {
|
|
313
|
-
F: __dxlog_file,
|
|
314
|
-
L: 88,
|
|
315
|
-
S: void 0,
|
|
316
|
-
A: [
|
|
317
|
-
"entry.value instanceof Uint8Array",
|
|
318
|
-
"'Invalid value type'"
|
|
319
|
-
]
|
|
320
|
-
});
|
|
321
|
-
batch.put(entry.key, entry.value, {
|
|
322
|
-
keyEncoding: "binary",
|
|
323
|
-
valueEncoding: "binary"
|
|
324
|
-
});
|
|
325
|
-
break;
|
|
326
|
-
}
|
|
327
|
-
default:
|
|
328
|
-
throw new Error(`Invalid entry type: ${entry.type}`);
|
|
329
|
-
}
|
|
330
|
-
if (++count % 1e3 === 0) {
|
|
331
|
-
await batch.write();
|
|
332
|
-
batch = level.batch();
|
|
333
|
-
import_log.log.info("importing", {
|
|
334
|
-
count,
|
|
335
|
-
total: archive.storage.length,
|
|
336
|
-
progress: `${(count / archive.storage.length * 100).toFixed()}%`
|
|
337
|
-
}, {
|
|
338
|
-
F: __dxlog_file,
|
|
339
|
-
L: 101,
|
|
340
|
-
S: void 0,
|
|
341
|
-
C: (f, a) => f(...a)
|
|
342
|
-
});
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
import_log.log.info("committing changes..", void 0, {
|
|
346
|
-
F: __dxlog_file,
|
|
347
|
-
L: 109,
|
|
348
|
-
S: void 0,
|
|
349
|
-
C: (f, a) => f(...a)
|
|
350
|
-
});
|
|
351
|
-
await batch.write();
|
|
352
|
-
};
|
|
353
|
-
function _ts_decorate2(decorators, target, key, desc) {
|
|
354
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
355
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
356
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
357
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
358
|
-
}
|
|
359
|
-
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/worker/worker-session.ts";
|
|
88
|
+
var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/worker/worker-session.ts";
|
|
360
89
|
var WorkerSession = class {
|
|
361
90
|
constructor({ serviceHost, systemPort, appPort, shellPort, readySignal }) {
|
|
362
91
|
this._startTrigger = new import_async2.Trigger();
|
|
363
|
-
this.onClose = new
|
|
364
|
-
(0,
|
|
365
|
-
F:
|
|
92
|
+
this.onClose = new import_util.Callback();
|
|
93
|
+
(0, import_invariant2.invariant)(serviceHost, void 0, {
|
|
94
|
+
F: __dxlog_file,
|
|
366
95
|
L: 54,
|
|
367
96
|
S: this,
|
|
368
97
|
A: [
|
|
@@ -374,7 +103,7 @@ var WorkerSession = class {
|
|
|
374
103
|
const middleware = {
|
|
375
104
|
handleCall: async (method, params, handler) => {
|
|
376
105
|
const error = await readySignal.wait({
|
|
377
|
-
timeout:
|
|
106
|
+
timeout: import_client_protocol2.PROXY_CONNECTION_TIMEOUT
|
|
378
107
|
});
|
|
379
108
|
if (error) {
|
|
380
109
|
throw error;
|
|
@@ -383,7 +112,7 @@ var WorkerSession = class {
|
|
|
383
112
|
},
|
|
384
113
|
handleStream: async (method, params, handler) => {
|
|
385
114
|
const error = await readySignal.wait({
|
|
386
|
-
timeout:
|
|
115
|
+
timeout: import_client_protocol2.PROXY_CONNECTION_TIMEOUT
|
|
387
116
|
});
|
|
388
117
|
if (error) {
|
|
389
118
|
throw error;
|
|
@@ -391,19 +120,19 @@ var WorkerSession = class {
|
|
|
391
120
|
return handler(method, params);
|
|
392
121
|
}
|
|
393
122
|
};
|
|
394
|
-
this._clientRpc = new ClientRpcServer({
|
|
123
|
+
this._clientRpc = new import_chunk_ZORMUE2S.ClientRpcServer({
|
|
395
124
|
serviceRegistry: this._serviceHost.serviceRegistry,
|
|
396
125
|
port: appPort,
|
|
397
126
|
...middleware
|
|
398
127
|
});
|
|
399
|
-
this._shellClientRpc = shellPort ? new ClientRpcServer({
|
|
128
|
+
this._shellClientRpc = shellPort ? new import_chunk_ZORMUE2S.ClientRpcServer({
|
|
400
129
|
serviceRegistry: this._serviceHost.serviceRegistry,
|
|
401
130
|
port: shellPort,
|
|
402
131
|
...middleware
|
|
403
132
|
}) : void 0;
|
|
404
|
-
this._iframeRpc = (0,
|
|
405
|
-
requested:
|
|
406
|
-
exposed:
|
|
133
|
+
this._iframeRpc = (0, import_rpc.createProtoRpcPeer)({
|
|
134
|
+
requested: import_client_protocol2.iframeServiceBundle,
|
|
135
|
+
exposed: import_client_protocol2.workerServiceBundle,
|
|
407
136
|
handlers: {
|
|
408
137
|
WorkerService: {
|
|
409
138
|
start: async (request) => {
|
|
@@ -418,8 +147,8 @@ var WorkerSession = class {
|
|
|
418
147
|
try {
|
|
419
148
|
await this.close();
|
|
420
149
|
} catch (err) {
|
|
421
|
-
|
|
422
|
-
F:
|
|
150
|
+
import_log2.log.catch(err, void 0, {
|
|
151
|
+
F: __dxlog_file,
|
|
423
152
|
L: 108,
|
|
424
153
|
S: this,
|
|
425
154
|
C: (f, a) => f(...a)
|
|
@@ -435,8 +164,8 @@ var WorkerSession = class {
|
|
|
435
164
|
this.bridgeService = this._iframeRpc.rpc.BridgeService;
|
|
436
165
|
}
|
|
437
166
|
async open() {
|
|
438
|
-
|
|
439
|
-
F:
|
|
167
|
+
import_log2.log.info("opening...", void 0, {
|
|
168
|
+
F: __dxlog_file,
|
|
440
169
|
L: 122,
|
|
441
170
|
S: this,
|
|
442
171
|
C: (f, a) => f(...a)
|
|
@@ -447,21 +176,21 @@ var WorkerSession = class {
|
|
|
447
176
|
this._maybeOpenShell()
|
|
448
177
|
]);
|
|
449
178
|
await this._startTrigger.wait({
|
|
450
|
-
timeout:
|
|
179
|
+
timeout: import_client_protocol2.PROXY_CONNECTION_TIMEOUT
|
|
451
180
|
});
|
|
452
181
|
if (this.lockKey) {
|
|
453
182
|
void this._afterLockReleases(this.lockKey, () => this.close());
|
|
454
183
|
}
|
|
455
|
-
|
|
456
|
-
F:
|
|
184
|
+
import_log2.log.info("opened", void 0, {
|
|
185
|
+
F: __dxlog_file,
|
|
457
186
|
L: 133,
|
|
458
187
|
S: this,
|
|
459
188
|
C: (f, a) => f(...a)
|
|
460
189
|
});
|
|
461
190
|
}
|
|
462
191
|
async close() {
|
|
463
|
-
|
|
464
|
-
F:
|
|
192
|
+
import_log2.log.info("closing...", void 0, {
|
|
193
|
+
F: __dxlog_file,
|
|
465
194
|
L: 137,
|
|
466
195
|
S: this,
|
|
467
196
|
C: (f, a) => f(...a)
|
|
@@ -469,8 +198,8 @@ var WorkerSession = class {
|
|
|
469
198
|
try {
|
|
470
199
|
await this.onClose.callIfSet();
|
|
471
200
|
} catch (err) {
|
|
472
|
-
|
|
473
|
-
F:
|
|
201
|
+
import_log2.log.catch(err, void 0, {
|
|
202
|
+
F: __dxlog_file,
|
|
474
203
|
L: 141,
|
|
475
204
|
S: this,
|
|
476
205
|
C: (f, a) => f(...a)
|
|
@@ -480,8 +209,8 @@ var WorkerSession = class {
|
|
|
480
209
|
this._clientRpc.close(),
|
|
481
210
|
this._iframeRpc.close()
|
|
482
211
|
]);
|
|
483
|
-
|
|
484
|
-
F:
|
|
212
|
+
import_log2.log.info("closed", void 0, {
|
|
213
|
+
F: __dxlog_file,
|
|
485
214
|
L: 145,
|
|
486
215
|
S: this,
|
|
487
216
|
C: (f, a) => f(...a)
|
|
@@ -491,8 +220,8 @@ var WorkerSession = class {
|
|
|
491
220
|
try {
|
|
492
221
|
this._shellClientRpc && await (0, import_async2.asyncTimeout)(this._shellClientRpc.open(), 1e3);
|
|
493
222
|
} catch {
|
|
494
|
-
|
|
495
|
-
F:
|
|
223
|
+
import_log2.log.info("No shell connected.", void 0, {
|
|
224
|
+
F: __dxlog_file,
|
|
496
225
|
L: 152,
|
|
497
226
|
S: this,
|
|
498
227
|
C: (f, a) => f(...a)
|
|
@@ -504,15 +233,15 @@ var WorkerSession = class {
|
|
|
504
233
|
}).then(callback);
|
|
505
234
|
}
|
|
506
235
|
};
|
|
507
|
-
|
|
508
|
-
|
|
236
|
+
_ts_decorate([
|
|
237
|
+
import_log2.logInfo
|
|
509
238
|
], WorkerSession.prototype, "origin", void 0);
|
|
510
|
-
|
|
511
|
-
|
|
239
|
+
_ts_decorate([
|
|
240
|
+
import_log2.logInfo
|
|
512
241
|
], WorkerSession.prototype, "lockKey", void 0);
|
|
513
|
-
var
|
|
242
|
+
var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/worker/worker-runtime.ts";
|
|
514
243
|
var WorkerRuntime = class {
|
|
515
|
-
constructor({ channel =
|
|
244
|
+
constructor({ channel = import_client_protocol.DEFAULT_WORKER_BROADCAST_CHANNEL, configProvider, acquireLock, releaseLock, onStop }) {
|
|
516
245
|
this._transportFactory = new import_network_manager.RtcTransportProxyFactory();
|
|
517
246
|
this._ready = new import_async.Trigger();
|
|
518
247
|
this._sessions = /* @__PURE__ */ new Set();
|
|
@@ -525,7 +254,7 @@ var WorkerRuntime = class {
|
|
|
525
254
|
this._releaseLock = releaseLock;
|
|
526
255
|
this._onStop = onStop;
|
|
527
256
|
this._channel = channel;
|
|
528
|
-
this._clientServices = new
|
|
257
|
+
this._clientServices = new import_chunk_ZORMUE2S.ClientServicesHost({
|
|
529
258
|
callbacks: {
|
|
530
259
|
onReset: async () => this.stop()
|
|
531
260
|
}
|
|
@@ -535,8 +264,8 @@ var WorkerRuntime = class {
|
|
|
535
264
|
return this._clientServices;
|
|
536
265
|
}
|
|
537
266
|
async start() {
|
|
538
|
-
(0,
|
|
539
|
-
F:
|
|
267
|
+
(0, import_log.log)("starting...", void 0, {
|
|
268
|
+
F: __dxlog_file2,
|
|
540
269
|
L: 84,
|
|
541
270
|
S: this,
|
|
542
271
|
C: (f, a) => f(...a)
|
|
@@ -560,12 +289,12 @@ var WorkerRuntime = class {
|
|
|
560
289
|
transportFactory: this._transportFactory
|
|
561
290
|
});
|
|
562
291
|
await this._clientServices.open(new import_context.Context(void 0, {
|
|
563
|
-
F:
|
|
292
|
+
F: __dxlog_file2,
|
|
564
293
|
L: 107
|
|
565
294
|
}));
|
|
566
295
|
this._ready.wake(void 0);
|
|
567
|
-
(0,
|
|
568
|
-
F:
|
|
296
|
+
(0, import_log.log)("started", void 0, {
|
|
297
|
+
F: __dxlog_file2,
|
|
569
298
|
L: 109,
|
|
570
299
|
S: this,
|
|
571
300
|
C: (f, a) => f(...a)
|
|
@@ -579,8 +308,8 @@ var WorkerRuntime = class {
|
|
|
579
308
|
});
|
|
580
309
|
} catch (err) {
|
|
581
310
|
this._ready.wake(err);
|
|
582
|
-
|
|
583
|
-
F:
|
|
311
|
+
import_log.log.error("starting", err, {
|
|
312
|
+
F: __dxlog_file2,
|
|
584
313
|
L: 119,
|
|
585
314
|
S: this,
|
|
586
315
|
C: (f, a) => f(...a)
|
|
@@ -614,8 +343,8 @@ var WorkerRuntime = class {
|
|
|
614
343
|
}
|
|
615
344
|
});
|
|
616
345
|
await session.open();
|
|
617
|
-
(0,
|
|
618
|
-
F:
|
|
346
|
+
(0, import_invariant.invariant)(!this._signalMetadataTags.origin || this._signalMetadataTags.origin === session.origin, `worker origin changed from ${this._signalMetadataTags.origin} to ${session.origin}?`, {
|
|
347
|
+
F: __dxlog_file2,
|
|
619
348
|
L: 157,
|
|
620
349
|
S: this,
|
|
621
350
|
A: [
|
|
@@ -635,8 +364,8 @@ var WorkerRuntime = class {
|
|
|
635
364
|
* Selects one of the existing session for WebRTC networking.
|
|
636
365
|
*/
|
|
637
366
|
_reconnectWebrtc() {
|
|
638
|
-
(0,
|
|
639
|
-
F:
|
|
367
|
+
(0, import_log.log)("reconnecting webrtc...", void 0, {
|
|
368
|
+
F: __dxlog_file2,
|
|
640
369
|
L: 175,
|
|
641
370
|
S: this,
|
|
642
371
|
C: (f, a) => f(...a)
|