@dxos/client-services 0.4.10-main.d3d33d7 → 0.4.10-main.d4766e5
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-F647VGTE.mjs → chunk-DXJJOAJI.mjs} +643 -499
- package/dist/lib/browser/chunk-DXJJOAJI.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +9 -1
- package/dist/lib/browser/index.mjs.map +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/packlets/testing/index.mjs +1 -1
- package/dist/lib/node/{chunk-LYFRWNBG.cjs → chunk-54K33CLU.cjs} +590 -528
- package/dist/lib/node/chunk-54K33CLU.cjs.map +7 -0
- package/dist/lib/node/index.cjs +46 -38
- package/dist/lib/node/index.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/packlets/testing/index.cjs +6 -6
- package/dist/types/src/index.d.ts +1 -0
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/packlets/diagnostics/browser-diagnostics-broadcast.d.ts +5 -0
- package/dist/types/src/packlets/diagnostics/browser-diagnostics-broadcast.d.ts.map +1 -0
- package/dist/types/src/packlets/diagnostics/diagnostics-broadcast.d.ts +5 -0
- package/dist/types/src/packlets/diagnostics/diagnostics-broadcast.d.ts.map +1 -0
- package/dist/types/src/packlets/diagnostics/diagnostics-collector.d.ts +15 -0
- package/dist/types/src/packlets/diagnostics/diagnostics-collector.d.ts.map +1 -0
- package/dist/types/src/packlets/{services → diagnostics}/diagnostics.d.ts +1 -1
- package/dist/types/src/packlets/diagnostics/diagnostics.d.ts.map +1 -0
- package/dist/types/src/packlets/diagnostics/index.d.ts +4 -0
- package/dist/types/src/packlets/diagnostics/index.d.ts.map +1 -0
- package/dist/types/src/packlets/services/index.d.ts +1 -1
- package/dist/types/src/packlets/services/index.d.ts.map +1 -1
- package/dist/types/src/packlets/services/service-host.d.ts +1 -0
- package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
- package/dist/types/src/packlets/services/util.d.ts +1 -0
- package/dist/types/src/packlets/services/util.d.ts.map +1 -1
- package/dist/types/src/packlets/system/system-service.d.ts +1 -1
- package/dist/types/src/packlets/system/system-service.d.ts.map +1 -1
- package/dist/types/src/version.d.ts +1 -1
- package/package.json +35 -34
- package/src/index.ts +1 -0
- package/src/packlets/diagnostics/browser-diagnostics-broadcast.ts +94 -0
- package/src/packlets/diagnostics/diagnostics-broadcast.ts +20 -0
- package/src/packlets/diagnostics/diagnostics-collector.ts +65 -0
- package/src/packlets/{services → diagnostics}/diagnostics.ts +2 -2
- package/src/packlets/diagnostics/index.ts +7 -0
- package/src/packlets/services/index.ts +1 -1
- package/src/packlets/services/service-host.ts +9 -1
- package/src/packlets/services/util.ts +2 -0
- package/src/packlets/system/system-service.ts +1 -1
- package/src/version.ts +1 -1
- package/dist/lib/browser/chunk-F647VGTE.mjs.map +0 -7
- package/dist/lib/node/chunk-LYFRWNBG.cjs.map +0 -7
- package/dist/types/src/packlets/services/diagnostics.d.ts.map +0 -1
|
@@ -26,15 +26,17 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
26
|
mod
|
|
27
27
|
));
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var
|
|
30
|
-
__export(
|
|
29
|
+
var chunk_54K33CLU_exports = {};
|
|
30
|
+
__export(chunk_54K33CLU_exports, {
|
|
31
31
|
ClientRpcServer: () => ClientRpcServer,
|
|
32
32
|
ClientServicesHost: () => ClientServicesHost,
|
|
33
|
+
ClientServicesProviderResource: () => ClientServicesProviderResource,
|
|
33
34
|
DataSpace: () => DataSpace,
|
|
34
35
|
DataSpaceManager: () => DataSpaceManager,
|
|
35
36
|
DeviceInvitationProtocol: () => DeviceInvitationProtocol,
|
|
36
37
|
DevtoolsHostEvents: () => DevtoolsHostEvents,
|
|
37
38
|
DevtoolsServiceImpl: () => DevtoolsServiceImpl,
|
|
39
|
+
DiagnosticsCollector: () => DiagnosticsCollector,
|
|
38
40
|
Identity: () => Identity,
|
|
39
41
|
IdentityManager: () => IdentityManager,
|
|
40
42
|
IdentityServiceImpl: () => IdentityServiceImpl,
|
|
@@ -47,6 +49,8 @@ __export(chunk_LYFRWNBG_exports, {
|
|
|
47
49
|
SpacesServiceImpl: () => SpacesServiceImpl,
|
|
48
50
|
TrustedKeySetAuthVerifier: () => TrustedKeySetAuthVerifier,
|
|
49
51
|
createAuthProvider: () => createAuthProvider,
|
|
52
|
+
createCollectDiagnosticsBroadcastHandler: () => createCollectDiagnosticsBroadcastHandler,
|
|
53
|
+
createCollectDiagnosticsBroadcastSender: () => createCollectDiagnosticsBroadcastSender,
|
|
50
54
|
createDiagnostics: () => createDiagnostics,
|
|
51
55
|
createLevel: () => createLevel,
|
|
52
56
|
createStorageObjects: () => createStorageObjects,
|
|
@@ -61,7 +65,7 @@ __export(chunk_LYFRWNBG_exports, {
|
|
|
61
65
|
subscribeToSpaces: () => subscribeToSpaces,
|
|
62
66
|
subscribeToSwarmInfo: () => subscribeToSwarmInfo
|
|
63
67
|
});
|
|
64
|
-
module.exports = __toCommonJS(
|
|
68
|
+
module.exports = __toCommonJS(chunk_54K33CLU_exports);
|
|
65
69
|
var import_async = require("@dxos/async");
|
|
66
70
|
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
67
71
|
var import_feed_store = require("@dxos/feed-store");
|
|
@@ -148,13 +152,6 @@ var import_codec_protobuf9 = require("@dxos/codec-protobuf");
|
|
|
148
152
|
var import_debug2 = require("@dxos/debug");
|
|
149
153
|
var import_rpc = require("@dxos/rpc");
|
|
150
154
|
var import_tracing3 = require("@dxos/tracing");
|
|
151
|
-
var import_codec_protobuf10 = require("@dxos/codec-protobuf");
|
|
152
|
-
var import_credentials9 = require("@dxos/credentials");
|
|
153
|
-
var import_invariant9 = require("@dxos/invariant");
|
|
154
|
-
var import_protocols7 = require("@dxos/protocols");
|
|
155
|
-
var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
|
|
156
|
-
var import_tracing4 = require("@dxos/tracing");
|
|
157
|
-
var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
|
|
158
155
|
var import_async10 = require("@dxos/async");
|
|
159
156
|
var import_client_protocol3 = require("@dxos/client-protocol");
|
|
160
157
|
var import_context7 = require("@dxos/context");
|
|
@@ -162,107 +159,120 @@ var import_debug3 = require("@dxos/debug");
|
|
|
162
159
|
var import_echo_db = require("@dxos/echo-db");
|
|
163
160
|
var import_echo_pipeline = require("@dxos/echo-pipeline");
|
|
164
161
|
var import_echo_pipeline2 = require("@dxos/echo-pipeline");
|
|
165
|
-
var
|
|
162
|
+
var import_invariant9 = require("@dxos/invariant");
|
|
166
163
|
var import_keys7 = require("@dxos/keys");
|
|
167
164
|
var import_log8 = require("@dxos/log");
|
|
168
|
-
var
|
|
169
|
-
var
|
|
170
|
-
var
|
|
165
|
+
var import_protocols7 = require("@dxos/protocols");
|
|
166
|
+
var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
|
|
167
|
+
var import_credentials9 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
171
168
|
var import_timeframe2 = require("@dxos/timeframe");
|
|
172
|
-
var
|
|
169
|
+
var import_tracing4 = require("@dxos/tracing");
|
|
173
170
|
var import_util4 = require("@dxos/util");
|
|
174
171
|
var import_async11 = require("@dxos/async");
|
|
175
|
-
var
|
|
172
|
+
var import_credentials10 = require("@dxos/credentials");
|
|
176
173
|
var import_async12 = require("@dxos/async");
|
|
177
174
|
var import_context8 = require("@dxos/context");
|
|
178
|
-
var
|
|
175
|
+
var import_invariant10 = require("@dxos/invariant");
|
|
179
176
|
var import_keys8 = require("@dxos/keys");
|
|
180
177
|
var import_log9 = require("@dxos/log");
|
|
181
|
-
var
|
|
178
|
+
var import_protocols8 = require("@dxos/protocols");
|
|
182
179
|
var import_teleport2 = require("@dxos/teleport");
|
|
183
180
|
var import_util5 = require("@dxos/util");
|
|
184
181
|
var import_async13 = require("@dxos/async");
|
|
185
182
|
var import_context9 = require("@dxos/context");
|
|
186
|
-
var
|
|
187
|
-
var
|
|
183
|
+
var import_credentials11 = require("@dxos/credentials");
|
|
184
|
+
var import_invariant11 = require("@dxos/invariant");
|
|
188
185
|
var import_keys9 = require("@dxos/keys");
|
|
189
186
|
var import_log10 = require("@dxos/log");
|
|
190
|
-
var
|
|
191
|
-
var
|
|
187
|
+
var import_protocols9 = require("@dxos/protocols");
|
|
188
|
+
var import_services8 = require("@dxos/protocols/proto/dxos/client/services");
|
|
192
189
|
var import_teleport_extension_gossip2 = require("@dxos/teleport-extension-gossip");
|
|
193
190
|
var import_util6 = require("@dxos/util");
|
|
194
|
-
var
|
|
191
|
+
var import_credentials12 = require("@dxos/credentials");
|
|
195
192
|
var import_debug4 = require("@dxos/debug");
|
|
196
|
-
var
|
|
193
|
+
var import_credentials13 = require("@dxos/protocols/proto/dxos/halo/credentials");
|
|
197
194
|
var import_timeframe3 = require("@dxos/timeframe");
|
|
198
195
|
var import_async14 = require("@dxos/async");
|
|
199
|
-
var
|
|
196
|
+
var import_codec_protobuf10 = require("@dxos/codec-protobuf");
|
|
200
197
|
var import_debug5 = require("@dxos/debug");
|
|
201
|
-
var
|
|
198
|
+
var import_invariant12 = require("@dxos/invariant");
|
|
202
199
|
var import_log11 = require("@dxos/log");
|
|
203
|
-
var
|
|
204
|
-
var
|
|
200
|
+
var import_protocols10 = require("@dxos/protocols");
|
|
201
|
+
var import_services9 = require("@dxos/protocols/proto/dxos/client/services");
|
|
205
202
|
var import_async15 = require("@dxos/async");
|
|
206
203
|
var import_context10 = require("@dxos/context");
|
|
207
|
-
var
|
|
204
|
+
var import_credentials14 = require("@dxos/credentials");
|
|
208
205
|
var import_debug6 = require("@dxos/debug");
|
|
209
206
|
var import_echo_pipeline3 = require("@dxos/echo-pipeline");
|
|
210
207
|
var import_feed_store4 = require("@dxos/feed-store");
|
|
211
208
|
var import_indexing = require("@dxos/indexing");
|
|
212
|
-
var
|
|
209
|
+
var import_invariant13 = require("@dxos/invariant");
|
|
213
210
|
var import_keyring = require("@dxos/keyring");
|
|
214
211
|
var import_keys10 = require("@dxos/keys");
|
|
215
212
|
var import_log12 = require("@dxos/log");
|
|
216
|
-
var
|
|
217
|
-
var
|
|
213
|
+
var import_protocols11 = require("@dxos/protocols");
|
|
214
|
+
var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
|
|
218
215
|
var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
|
|
219
|
-
var
|
|
216
|
+
var import_tracing5 = require("@dxos/tracing");
|
|
220
217
|
var import_util7 = require("@dxos/util");
|
|
221
218
|
var import_automerge = require("@dxos/automerge/automerge");
|
|
222
219
|
var import_debug7 = require("@dxos/debug");
|
|
220
|
+
var import_protocols12 = require("@dxos/protocols");
|
|
221
|
+
var import_codec_protobuf11 = require("@dxos/codec-protobuf");
|
|
222
|
+
var import_credentials15 = require("@dxos/credentials");
|
|
223
|
+
var import_invariant14 = require("@dxos/invariant");
|
|
223
224
|
var import_protocols13 = require("@dxos/protocols");
|
|
224
|
-
var
|
|
225
|
-
var
|
|
226
|
-
var
|
|
227
|
-
var
|
|
228
|
-
var
|
|
229
|
-
var
|
|
230
|
-
var import_client_protocol4 = require("@dxos/client-protocol");
|
|
231
|
-
var import_config2 = require("@dxos/protocols/proto/dxos/config");
|
|
225
|
+
var import_services11 = require("@dxos/protocols/proto/dxos/client/services");
|
|
226
|
+
var import_tracing6 = require("@dxos/tracing");
|
|
227
|
+
var import_services12 = require("@dxos/protocols/proto/dxos/client/services");
|
|
228
|
+
var import_config = require("@dxos/config");
|
|
229
|
+
var import_services13 = require("@dxos/protocols/proto/dxos/client/services");
|
|
230
|
+
var import_tracing7 = require("@dxos/tracing");
|
|
232
231
|
var import_util8 = require("@dxos/util");
|
|
233
|
-
var import_level = require("level");
|
|
234
|
-
var import_node_path = __toESM(require("node:path"));
|
|
235
|
-
var import_keys11 = require("@dxos/keys");
|
|
236
232
|
var import_async16 = require("@dxos/async");
|
|
237
|
-
var
|
|
233
|
+
var import_client_protocol4 = require("@dxos/client-protocol");
|
|
238
234
|
var import_context11 = require("@dxos/context");
|
|
239
235
|
var import_echo_pipeline4 = require("@dxos/echo-pipeline");
|
|
240
236
|
var E = __toESM(require("@dxos/echo-schema"));
|
|
241
237
|
var import_indexing2 = require("@dxos/indexing");
|
|
242
|
-
var
|
|
243
|
-
var
|
|
244
|
-
var
|
|
238
|
+
var import_invariant15 = require("@dxos/invariant");
|
|
239
|
+
var import_keys11 = require("@dxos/keys");
|
|
240
|
+
var import_log13 = require("@dxos/log");
|
|
245
241
|
var import_messaging = require("@dxos/messaging");
|
|
246
242
|
var import_network_manager2 = require("@dxos/network-manager");
|
|
247
|
-
var
|
|
248
|
-
var
|
|
249
|
-
var
|
|
243
|
+
var import_protocols14 = require("@dxos/protocols");
|
|
244
|
+
var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
|
|
245
|
+
var import_tracing8 = require("@dxos/tracing");
|
|
250
246
|
var import_util9 = require("@dxos/util");
|
|
251
247
|
var import_websocket_rpc = require("@dxos/websocket-rpc");
|
|
252
248
|
var import_async17 = require("@dxos/async");
|
|
253
249
|
var import_codec_protobuf12 = require("@dxos/codec-protobuf");
|
|
250
|
+
var import_invariant16 = require("@dxos/invariant");
|
|
251
|
+
var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
|
|
254
252
|
var import_invariant17 = require("@dxos/invariant");
|
|
255
|
-
var
|
|
253
|
+
var import_lock_file = require("@dxos/lock-file");
|
|
254
|
+
var import_log14 = require("@dxos/log");
|
|
256
255
|
var import_async18 = require("@dxos/async");
|
|
257
256
|
var import_codec_protobuf13 = require("@dxos/codec-protobuf");
|
|
258
|
-
var
|
|
257
|
+
var import_keys12 = require("@dxos/keys");
|
|
259
258
|
var import_log15 = require("@dxos/log");
|
|
260
|
-
var
|
|
259
|
+
var import_services16 = require("@dxos/protocols/proto/dxos/client/services");
|
|
261
260
|
var import_util10 = require("@dxos/util");
|
|
262
261
|
var import_codec_protobuf14 = require("@dxos/codec-protobuf");
|
|
263
|
-
var
|
|
264
|
-
var
|
|
262
|
+
var import_protocols15 = require("@dxos/protocols");
|
|
263
|
+
var import_config2 = require("@dxos/protocols/proto/dxos/config");
|
|
264
|
+
var import_random_access_storage = require("@dxos/random-access-storage");
|
|
265
|
+
var import_client_protocol5 = require("@dxos/client-protocol");
|
|
266
|
+
var import_config3 = require("@dxos/protocols/proto/dxos/config");
|
|
265
267
|
var import_util11 = require("@dxos/util");
|
|
268
|
+
var import_level = require("level");
|
|
269
|
+
var import_node_path = __toESM(require("node:path"));
|
|
270
|
+
var import_keys13 = require("@dxos/keys");
|
|
271
|
+
var import_codec_protobuf15 = require("@dxos/codec-protobuf");
|
|
272
|
+
var import_services17 = require("@dxos/protocols/proto/dxos/client/services");
|
|
273
|
+
var import_util12 = require("@dxos/util");
|
|
274
|
+
var import_keys14 = require("@dxos/keys");
|
|
275
|
+
var import_util13 = require("@dxos/util");
|
|
266
276
|
var subscribeToFeeds = ({ feedStore }, { feedKeys }) => {
|
|
267
277
|
return new import_codec_protobuf.Stream(({ next }) => {
|
|
268
278
|
const subscriptions = new import_async.EventSubscriptions();
|
|
@@ -2864,141 +2874,6 @@ _ts_decorate3([
|
|
|
2864
2874
|
ClientRpcServer = _ts_decorate3([
|
|
2865
2875
|
import_tracing3.trace.resource()
|
|
2866
2876
|
], ClientRpcServer);
|
|
2867
|
-
var getPlatform = () => {
|
|
2868
|
-
if (process.browser) {
|
|
2869
|
-
if (typeof window !== "undefined") {
|
|
2870
|
-
const { userAgent } = window.navigator;
|
|
2871
|
-
return {
|
|
2872
|
-
type: import_services8.Platform.PLATFORM_TYPE.BROWSER,
|
|
2873
|
-
userAgent,
|
|
2874
|
-
uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
|
|
2875
|
-
};
|
|
2876
|
-
} else {
|
|
2877
|
-
return {
|
|
2878
|
-
type: import_services8.Platform.PLATFORM_TYPE.SHARED_WORKER,
|
|
2879
|
-
uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
|
|
2880
|
-
};
|
|
2881
|
-
}
|
|
2882
|
-
} else {
|
|
2883
|
-
const { platform: platform2, version, arch } = process;
|
|
2884
|
-
return {
|
|
2885
|
-
type: import_services8.Platform.PLATFORM_TYPE.NODE,
|
|
2886
|
-
platform: platform2,
|
|
2887
|
-
arch,
|
|
2888
|
-
runtime: version,
|
|
2889
|
-
uptime: Math.floor(process.uptime()),
|
|
2890
|
-
memory: process.memoryUsage()
|
|
2891
|
-
};
|
|
2892
|
-
}
|
|
2893
|
-
};
|
|
2894
|
-
var DXOS_VERSION = "0.4.10-main.d3d33d7";
|
|
2895
|
-
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
|
|
2896
|
-
var DEFAULT_TIMEOUT = 1e3;
|
|
2897
|
-
var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
2898
|
-
const diagnostics = {
|
|
2899
|
-
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2900
|
-
platform: getPlatform(),
|
|
2901
|
-
client: {
|
|
2902
|
-
version: DXOS_VERSION,
|
|
2903
|
-
storage: {
|
|
2904
|
-
version: import_protocols7.STORAGE_VERSION
|
|
2905
|
-
}
|
|
2906
|
-
},
|
|
2907
|
-
trace: import_tracing4.TRACE_PROCESSOR.getDiagnostics()
|
|
2908
|
-
};
|
|
2909
|
-
{
|
|
2910
|
-
(0, import_invariant9.invariant)(clientServices.LoggingService, "SystemService is not available.", {
|
|
2911
|
-
F: __dxlog_file10,
|
|
2912
|
-
L: 108,
|
|
2913
|
-
S: void 0,
|
|
2914
|
-
A: [
|
|
2915
|
-
"clientServices.LoggingService",
|
|
2916
|
-
"'SystemService is not available.'"
|
|
2917
|
-
]
|
|
2918
|
-
});
|
|
2919
|
-
diagnostics.metrics = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.LoggingService.queryMetrics({}), {
|
|
2920
|
-
timeout: DEFAULT_TIMEOUT
|
|
2921
|
-
}).catch(() => void 0);
|
|
2922
|
-
}
|
|
2923
|
-
if (typeof navigator !== "undefined" && navigator.storage) {
|
|
2924
|
-
const map = /* @__PURE__ */ new Map();
|
|
2925
|
-
const dir = await navigator.storage.getDirectory();
|
|
2926
|
-
for await (const filename of dir?.keys()) {
|
|
2927
|
-
const idx = filename.indexOf("-", filename.indexOf("-") + 1);
|
|
2928
|
-
if (idx === -1) {
|
|
2929
|
-
continue;
|
|
2930
|
-
}
|
|
2931
|
-
map.set(filename.slice(0, idx), (map.get(filename.slice(0, idx)) ?? 0) + 1);
|
|
2932
|
-
}
|
|
2933
|
-
diagnostics.storage = Array.from(map.entries()).sort((a, b) => b[1] - a[1]).map(([file, count]) => ({
|
|
2934
|
-
file,
|
|
2935
|
-
count
|
|
2936
|
-
}));
|
|
2937
|
-
}
|
|
2938
|
-
const identity = serviceContext.identityManager.identity;
|
|
2939
|
-
if (identity) {
|
|
2940
|
-
diagnostics.identity = {
|
|
2941
|
-
identityKey: identity.identityKey,
|
|
2942
|
-
spaceKey: identity.space.key,
|
|
2943
|
-
profile: identity.profileDocument
|
|
2944
|
-
};
|
|
2945
|
-
const { devices } = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.DevicesService.queryDevices(), {
|
|
2946
|
-
timeout: DEFAULT_TIMEOUT
|
|
2947
|
-
}).catch(() => void 0) ?? {};
|
|
2948
|
-
diagnostics.devices = devices;
|
|
2949
|
-
if (serviceContext.dataSpaceManager) {
|
|
2950
|
-
diagnostics.spaces = await Promise.all(Array.from(serviceContext.dataSpaceManager.spaces.values()).map((space) => getSpaceStats(space)) ?? []);
|
|
2951
|
-
}
|
|
2952
|
-
const { feeds = [] } = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.DevtoolsHost.subscribeToFeeds({}), {
|
|
2953
|
-
timeout: DEFAULT_TIMEOUT
|
|
2954
|
-
}).catch(() => void 0) ?? {};
|
|
2955
|
-
diagnostics.feeds = feeds.map(({ feedKey, bytes, length }) => ({
|
|
2956
|
-
feedKey,
|
|
2957
|
-
bytes,
|
|
2958
|
-
length
|
|
2959
|
-
}));
|
|
2960
|
-
const status = await (0, import_codec_protobuf10.getFirstStreamValue)(clientServices.NetworkService.queryStatus(), {
|
|
2961
|
-
timeout: DEFAULT_TIMEOUT
|
|
2962
|
-
}).catch(() => void 0);
|
|
2963
|
-
diagnostics.networkStatus = status;
|
|
2964
|
-
diagnostics.swarms = serviceContext.networkManager.connectionLog?.swarms;
|
|
2965
|
-
}
|
|
2966
|
-
diagnostics.config = config.values;
|
|
2967
|
-
return diagnostics;
|
|
2968
|
-
};
|
|
2969
|
-
var getSpaceStats = async (space) => {
|
|
2970
|
-
const stats = {
|
|
2971
|
-
key: space.key,
|
|
2972
|
-
metrics: space.metrics,
|
|
2973
|
-
epochs: space.inner.spaceState.credentials.filter((0, import_credentials9.credentialTypeFilter)("dxos.halo.credentials.Epoch")).map((credential) => ({
|
|
2974
|
-
...credential.subject.assertion,
|
|
2975
|
-
id: credential.id
|
|
2976
|
-
})),
|
|
2977
|
-
members: Array.from(space.inner.spaceState.members.values()).map((member) => ({
|
|
2978
|
-
identity: {
|
|
2979
|
-
identityKey: member.key,
|
|
2980
|
-
profile: {
|
|
2981
|
-
displayName: member.assertion.profile?.displayName
|
|
2982
|
-
}
|
|
2983
|
-
},
|
|
2984
|
-
presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services7.SpaceMember.PresenceState.ONLINE : import_services7.SpaceMember.PresenceState.OFFLINE
|
|
2985
|
-
})),
|
|
2986
|
-
pipeline: {
|
|
2987
|
-
// TODO(burdon): Pick properties from credentials if needed.
|
|
2988
|
-
currentEpoch: space.automergeSpaceState.lastEpoch,
|
|
2989
|
-
appliedEpoch: space.automergeSpaceState.lastEpoch,
|
|
2990
|
-
controlFeeds: space.inner.controlPipeline.state.feeds.map((feed) => feed.key),
|
|
2991
|
-
currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
|
|
2992
|
-
targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
|
|
2993
|
-
totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe
|
|
2994
|
-
}
|
|
2995
|
-
};
|
|
2996
|
-
if (stats.metrics) {
|
|
2997
|
-
const { open, ready } = stats.metrics;
|
|
2998
|
-
stats.metrics.startupTime = open && ready && ready.getTime() - open.getTime();
|
|
2999
|
-
}
|
|
3000
|
-
return stats;
|
|
3001
|
-
};
|
|
3002
2877
|
var AutomergeSpaceState = class {
|
|
3003
2878
|
constructor(_onNewRoot) {
|
|
3004
2879
|
this._onNewRoot = _onNewRoot;
|
|
@@ -3008,7 +2883,7 @@ var AutomergeSpaceState = class {
|
|
|
3008
2883
|
this._isProcessingRootDocs = false;
|
|
3009
2884
|
}
|
|
3010
2885
|
async processCredential(credential) {
|
|
3011
|
-
if (!(0,
|
|
2886
|
+
if (!(0, import_credentials10.checkCredentialType)(credential, "dxos.halo.credentials.Epoch")) {
|
|
3012
2887
|
return;
|
|
3013
2888
|
}
|
|
3014
2889
|
this.lastEpoch = credential;
|
|
@@ -3033,7 +2908,7 @@ var AutomergeSpaceState = class {
|
|
|
3033
2908
|
await this.onNewEpoch.waitForCondition(() => !!this.lastEpoch);
|
|
3034
2909
|
}
|
|
3035
2910
|
};
|
|
3036
|
-
var
|
|
2911
|
+
var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts";
|
|
3037
2912
|
var DEFAULT_RETRY_TIMEOUT = 1e3;
|
|
3038
2913
|
var DEFAULT_SUCCESS_DELAY = 1e3;
|
|
3039
2914
|
var DEFAULT_NOTARIZE_TIMEOUT = 1e4;
|
|
@@ -3061,13 +2936,13 @@ var NotarizationPlugin = class {
|
|
|
3061
2936
|
(0, import_log9.log)("notarize", {
|
|
3062
2937
|
credentials
|
|
3063
2938
|
}, {
|
|
3064
|
-
F:
|
|
2939
|
+
F: __dxlog_file10,
|
|
3065
2940
|
L: 90,
|
|
3066
2941
|
S: this,
|
|
3067
2942
|
C: (f, a) => f(...a)
|
|
3068
2943
|
});
|
|
3069
|
-
(0,
|
|
3070
|
-
F:
|
|
2944
|
+
(0, import_invariant10.invariant)(credentials.every((credential) => credential.id), "Credentials must have an id", {
|
|
2945
|
+
F: __dxlog_file10,
|
|
3071
2946
|
L: 91,
|
|
3072
2947
|
S: this,
|
|
3073
2948
|
A: [
|
|
@@ -3081,7 +2956,7 @@ var NotarizationPlugin = class {
|
|
|
3081
2956
|
import_log9.log.warn("Notarization error", {
|
|
3082
2957
|
err
|
|
3083
2958
|
}, {
|
|
3084
|
-
F:
|
|
2959
|
+
F: __dxlog_file10,
|
|
3085
2960
|
L: 99,
|
|
3086
2961
|
S: this,
|
|
3087
2962
|
C: (f, a) => f(...a)
|
|
@@ -3097,7 +2972,7 @@ var NotarizationPlugin = class {
|
|
|
3097
2972
|
timeout,
|
|
3098
2973
|
peers: Array.from(this._extensions).map((extension) => extension.remotePeerId)
|
|
3099
2974
|
}, {
|
|
3100
|
-
F:
|
|
2975
|
+
F: __dxlog_file10,
|
|
3101
2976
|
L: 111,
|
|
3102
2977
|
S: this,
|
|
3103
2978
|
C: (f, a) => f(...a)
|
|
@@ -3120,7 +2995,7 @@ var NotarizationPlugin = class {
|
|
|
3120
2995
|
import_log9.log.info("Exhausted all peers to notarize with", {
|
|
3121
2996
|
retryIn: retryTimeout
|
|
3122
2997
|
}, {
|
|
3123
|
-
F:
|
|
2998
|
+
F: __dxlog_file10,
|
|
3124
2999
|
L: 136,
|
|
3125
3000
|
S: this,
|
|
3126
3001
|
C: (f, a) => f(...a)
|
|
@@ -3134,7 +3009,7 @@ var NotarizationPlugin = class {
|
|
|
3134
3009
|
peer: peer.localPeerId,
|
|
3135
3010
|
credentialId: credentials.map((credential) => credential.id)
|
|
3136
3011
|
}, {
|
|
3137
|
-
F:
|
|
3012
|
+
F: __dxlog_file10,
|
|
3138
3013
|
L: 143,
|
|
3139
3014
|
S: this,
|
|
3140
3015
|
C: (f, a) => f(...a)
|
|
@@ -3143,7 +3018,7 @@ var NotarizationPlugin = class {
|
|
|
3143
3018
|
credentials: credentials.filter((credential) => !this._processedCredentials.has(credential.id))
|
|
3144
3019
|
});
|
|
3145
3020
|
(0, import_log9.log)("success", void 0, {
|
|
3146
|
-
F:
|
|
3021
|
+
F: __dxlog_file10,
|
|
3147
3022
|
L: 147,
|
|
3148
3023
|
S: this,
|
|
3149
3024
|
C: (f, a) => f(...a)
|
|
@@ -3152,7 +3027,7 @@ var NotarizationPlugin = class {
|
|
|
3152
3027
|
} catch (err) {
|
|
3153
3028
|
if (!ctx.disposed && !err.message.includes(WRITER_NOT_SET_ERROR_CODE)) {
|
|
3154
3029
|
import_log9.log.info("error notarizing (recoverable)", err, {
|
|
3155
|
-
F:
|
|
3030
|
+
F: __dxlog_file10,
|
|
3156
3031
|
L: 151,
|
|
3157
3032
|
S: this,
|
|
3158
3033
|
C: (f, a) => f(...a)
|
|
@@ -3170,7 +3045,7 @@ var NotarizationPlugin = class {
|
|
|
3170
3045
|
errors.wait()
|
|
3171
3046
|
]);
|
|
3172
3047
|
(0, import_log9.log)("done", void 0, {
|
|
3173
|
-
F:
|
|
3048
|
+
F: __dxlog_file10,
|
|
3174
3049
|
L: 162,
|
|
3175
3050
|
S: this,
|
|
3176
3051
|
C: (f, a) => f(...a)
|
|
@@ -3191,8 +3066,8 @@ var NotarizationPlugin = class {
|
|
|
3191
3066
|
this._processCredentialsTriggers.delete(credential.id);
|
|
3192
3067
|
}
|
|
3193
3068
|
setWriter(writer) {
|
|
3194
|
-
(0,
|
|
3195
|
-
F:
|
|
3069
|
+
(0, import_invariant10.invariant)(!this._writer, "Writer already set.", {
|
|
3070
|
+
F: __dxlog_file10,
|
|
3196
3071
|
L: 181,
|
|
3197
3072
|
S: this,
|
|
3198
3073
|
A: [
|
|
@@ -3216,8 +3091,8 @@ var NotarizationPlugin = class {
|
|
|
3216
3091
|
throw new Error(WRITER_NOT_SET_ERROR_CODE);
|
|
3217
3092
|
}
|
|
3218
3093
|
for (const credential of request.credentials ?? []) {
|
|
3219
|
-
(0,
|
|
3220
|
-
F:
|
|
3094
|
+
(0, import_invariant10.invariant)(credential.id, "Credential must have an id", {
|
|
3095
|
+
F: __dxlog_file10,
|
|
3221
3096
|
L: 200,
|
|
3222
3097
|
S: this,
|
|
3223
3098
|
A: [
|
|
@@ -3237,7 +3112,7 @@ var NotarizationPlugin = class {
|
|
|
3237
3112
|
(0, import_log9.log)("extension opened", {
|
|
3238
3113
|
peer: extension.localPeerId
|
|
3239
3114
|
}, {
|
|
3240
|
-
F:
|
|
3115
|
+
F: __dxlog_file10,
|
|
3241
3116
|
L: 211,
|
|
3242
3117
|
S: this,
|
|
3243
3118
|
C: (f, a) => f(...a)
|
|
@@ -3249,7 +3124,7 @@ var NotarizationPlugin = class {
|
|
|
3249
3124
|
(0, import_log9.log)("extension closed", {
|
|
3250
3125
|
peer: extension.localPeerId
|
|
3251
3126
|
}, {
|
|
3252
|
-
F:
|
|
3127
|
+
F: __dxlog_file10,
|
|
3253
3128
|
L: 216,
|
|
3254
3129
|
S: this,
|
|
3255
3130
|
C: (f, a) => f(...a)
|
|
@@ -3265,10 +3140,10 @@ var NotarizationTeleportExtension = class extends import_teleport2.RpcExtension
|
|
|
3265
3140
|
constructor(_params) {
|
|
3266
3141
|
super({
|
|
3267
3142
|
requested: {
|
|
3268
|
-
NotarizationService:
|
|
3143
|
+
NotarizationService: import_protocols8.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
|
|
3269
3144
|
},
|
|
3270
3145
|
exposed: {
|
|
3271
|
-
NotarizationService:
|
|
3146
|
+
NotarizationService: import_protocols8.schema.getService("dxos.mesh.teleport.notarization.NotarizationService")
|
|
3272
3147
|
}
|
|
3273
3148
|
});
|
|
3274
3149
|
this._params = _params;
|
|
@@ -3301,14 +3176,14 @@ function _ts_decorate4(decorators, target, key, desc) {
|
|
|
3301
3176
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3302
3177
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3303
3178
|
}
|
|
3304
|
-
var
|
|
3179
|
+
var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space.ts";
|
|
3305
3180
|
var DataSpace = class {
|
|
3306
3181
|
constructor(params) {
|
|
3307
3182
|
this._ctx = new import_context7.Context();
|
|
3308
3183
|
this._notarizationPlugin = new NotarizationPlugin();
|
|
3309
3184
|
this._cache = void 0;
|
|
3310
3185
|
this._automergeSpaceState = new AutomergeSpaceState((rootUrl) => this._onNewAutomergeRoot(rootUrl));
|
|
3311
|
-
this._state =
|
|
3186
|
+
this._state = import_services7.SpaceState.CLOSED;
|
|
3312
3187
|
this.error = void 0;
|
|
3313
3188
|
this.stateUpdate = new import_async10.Event();
|
|
3314
3189
|
this.metrics = {};
|
|
@@ -3330,9 +3205,9 @@ var DataSpace = class {
|
|
|
3330
3205
|
this._cache = params.cache;
|
|
3331
3206
|
this._state = params.initialState;
|
|
3332
3207
|
(0, import_log8.log)("new state", {
|
|
3333
|
-
state:
|
|
3208
|
+
state: import_services7.SpaceState[this._state]
|
|
3334
3209
|
}, {
|
|
3335
|
-
F:
|
|
3210
|
+
F: __dxlog_file11,
|
|
3336
3211
|
L: 140,
|
|
3337
3212
|
S: this,
|
|
3338
3213
|
C: (f, a) => f(...a)
|
|
@@ -3378,11 +3253,11 @@ var DataSpace = class {
|
|
|
3378
3253
|
await this._inner.spaceState.addCredentialProcessor(this._notarizationPlugin);
|
|
3379
3254
|
await this._inner.spaceState.addCredentialProcessor(this._automergeSpaceState);
|
|
3380
3255
|
await this._inner.open(new import_context7.Context());
|
|
3381
|
-
this._state =
|
|
3256
|
+
this._state = import_services7.SpaceState.CONTROL_ONLY;
|
|
3382
3257
|
(0, import_log8.log)("new state", {
|
|
3383
|
-
state:
|
|
3258
|
+
state: import_services7.SpaceState[this._state]
|
|
3384
3259
|
}, {
|
|
3385
|
-
F:
|
|
3260
|
+
F: __dxlog_file11,
|
|
3386
3261
|
L: 198,
|
|
3387
3262
|
S: this,
|
|
3388
3263
|
C: (f, a) => f(...a)
|
|
@@ -3396,11 +3271,11 @@ var DataSpace = class {
|
|
|
3396
3271
|
}
|
|
3397
3272
|
async _close() {
|
|
3398
3273
|
await this._callbacks.beforeClose?.();
|
|
3399
|
-
this._state =
|
|
3274
|
+
this._state = import_services7.SpaceState.CLOSED;
|
|
3400
3275
|
(0, import_log8.log)("new state", {
|
|
3401
|
-
state:
|
|
3276
|
+
state: import_services7.SpaceState[this._state]
|
|
3402
3277
|
}, {
|
|
3403
|
-
F:
|
|
3278
|
+
F: __dxlog_file11,
|
|
3404
3279
|
L: 212,
|
|
3405
3280
|
S: this,
|
|
3406
3281
|
C: (f, a) => f(...a)
|
|
@@ -3430,9 +3305,9 @@ var DataSpace = class {
|
|
|
3430
3305
|
this.metrics.pipelineInitBegin = /* @__PURE__ */ new Date();
|
|
3431
3306
|
await this.initializeDataPipeline();
|
|
3432
3307
|
} catch (err) {
|
|
3433
|
-
if (err instanceof
|
|
3308
|
+
if (err instanceof import_protocols7.CancelledError || err instanceof import_context7.ContextDisposedError) {
|
|
3434
3309
|
(0, import_log8.log)("data pipeline initialization cancelled", err, {
|
|
3435
|
-
F:
|
|
3310
|
+
F: __dxlog_file11,
|
|
3436
3311
|
L: 245,
|
|
3437
3312
|
S: this,
|
|
3438
3313
|
C: (f, a) => f(...a)
|
|
@@ -3440,16 +3315,16 @@ var DataSpace = class {
|
|
|
3440
3315
|
return;
|
|
3441
3316
|
}
|
|
3442
3317
|
import_log8.log.error("Error initializing data pipeline", err, {
|
|
3443
|
-
F:
|
|
3318
|
+
F: __dxlog_file11,
|
|
3444
3319
|
L: 249,
|
|
3445
3320
|
S: this,
|
|
3446
3321
|
C: (f, a) => f(...a)
|
|
3447
3322
|
});
|
|
3448
|
-
this._state =
|
|
3323
|
+
this._state = import_services7.SpaceState.ERROR;
|
|
3449
3324
|
(0, import_log8.log)("new state", {
|
|
3450
|
-
state:
|
|
3325
|
+
state: import_services7.SpaceState[this._state]
|
|
3451
3326
|
}, {
|
|
3452
|
-
F:
|
|
3327
|
+
F: __dxlog_file11,
|
|
3453
3328
|
L: 251,
|
|
3454
3329
|
S: this,
|
|
3455
3330
|
C: (f, a) => f(...a)
|
|
@@ -3462,14 +3337,14 @@ var DataSpace = class {
|
|
|
3462
3337
|
});
|
|
3463
3338
|
}
|
|
3464
3339
|
async initializeDataPipeline() {
|
|
3465
|
-
if (this._state !==
|
|
3466
|
-
throw new
|
|
3340
|
+
if (this._state !== import_services7.SpaceState.CONTROL_ONLY) {
|
|
3341
|
+
throw new import_protocols7.SystemError("Invalid operation");
|
|
3467
3342
|
}
|
|
3468
|
-
this._state =
|
|
3343
|
+
this._state = import_services7.SpaceState.INITIALIZING;
|
|
3469
3344
|
(0, import_log8.log)("new state", {
|
|
3470
|
-
state:
|
|
3345
|
+
state: import_services7.SpaceState[this._state]
|
|
3471
3346
|
}, {
|
|
3472
|
-
F:
|
|
3347
|
+
F: __dxlog_file11,
|
|
3473
3348
|
L: 267,
|
|
3474
3349
|
S: this,
|
|
3475
3350
|
C: (f, a) => f(...a)
|
|
@@ -3479,17 +3354,17 @@ var DataSpace = class {
|
|
|
3479
3354
|
this._automergeSpaceState.startProcessingRootDocs();
|
|
3480
3355
|
await (0, import_context7.cancelWithContext)(this._ctx, this.automergeSpaceState.ensureEpochInitialized());
|
|
3481
3356
|
(0, import_log8.log)("data pipeline ready", void 0, {
|
|
3482
|
-
F:
|
|
3357
|
+
F: __dxlog_file11,
|
|
3483
3358
|
L: 279,
|
|
3484
3359
|
S: this,
|
|
3485
3360
|
C: (f, a) => f(...a)
|
|
3486
3361
|
});
|
|
3487
3362
|
await this._callbacks.beforeReady?.();
|
|
3488
|
-
this._state =
|
|
3363
|
+
this._state = import_services7.SpaceState.READY;
|
|
3489
3364
|
(0, import_log8.log)("new state", {
|
|
3490
|
-
state:
|
|
3365
|
+
state: import_services7.SpaceState[this._state]
|
|
3491
3366
|
}, {
|
|
3492
|
-
F:
|
|
3367
|
+
F: __dxlog_file11,
|
|
3493
3368
|
L: 283,
|
|
3494
3369
|
S: this,
|
|
3495
3370
|
C: (f, a) => f(...a)
|
|
@@ -3505,7 +3380,7 @@ var DataSpace = class {
|
|
|
3505
3380
|
this.metrics.controlPipelineReady = /* @__PURE__ */ new Date();
|
|
3506
3381
|
await this._createWritableFeeds();
|
|
3507
3382
|
(0, import_log8.log)("writable feeds created", void 0, {
|
|
3508
|
-
F:
|
|
3383
|
+
F: __dxlog_file11,
|
|
3509
3384
|
L: 299,
|
|
3510
3385
|
S: this,
|
|
3511
3386
|
C: (f, a) => f(...a)
|
|
@@ -3533,7 +3408,7 @@ var DataSpace = class {
|
|
|
3533
3408
|
spaceKey: this.key,
|
|
3534
3409
|
deviceKey: this._signingContext.deviceKey,
|
|
3535
3410
|
identityKey: this._signingContext.identityKey,
|
|
3536
|
-
designation:
|
|
3411
|
+
designation: import_credentials9.AdmittedFeed.Designation.CONTROL
|
|
3537
3412
|
}
|
|
3538
3413
|
}));
|
|
3539
3414
|
}
|
|
@@ -3550,7 +3425,7 @@ var DataSpace = class {
|
|
|
3550
3425
|
spaceKey: this.key,
|
|
3551
3426
|
deviceKey: this._signingContext.deviceKey,
|
|
3552
3427
|
identityKey: this._signingContext.identityKey,
|
|
3553
|
-
designation:
|
|
3428
|
+
designation: import_credentials9.AdmittedFeed.Designation.DATA
|
|
3554
3429
|
}
|
|
3555
3430
|
}));
|
|
3556
3431
|
}
|
|
@@ -3568,7 +3443,7 @@ var DataSpace = class {
|
|
|
3568
3443
|
space: this.key,
|
|
3569
3444
|
rootUrl
|
|
3570
3445
|
}, {
|
|
3571
|
-
F:
|
|
3446
|
+
F: __dxlog_file11,
|
|
3572
3447
|
L: 365,
|
|
3573
3448
|
S: this,
|
|
3574
3449
|
C: (f, a) => f(...a)
|
|
@@ -3583,7 +3458,7 @@ var DataSpace = class {
|
|
|
3583
3458
|
if (this._ctx.disposed) {
|
|
3584
3459
|
return;
|
|
3585
3460
|
}
|
|
3586
|
-
const doc = handle.docSync() ?? (0,
|
|
3461
|
+
const doc = handle.docSync() ?? (0, import_invariant9.failedInvariant)();
|
|
3587
3462
|
if (!doc.access?.spaceKey) {
|
|
3588
3463
|
handle.change((doc2) => {
|
|
3589
3464
|
doc2.access = {
|
|
@@ -3600,7 +3475,7 @@ var DataSpace = class {
|
|
|
3600
3475
|
rootUrl,
|
|
3601
3476
|
err
|
|
3602
3477
|
}, {
|
|
3603
|
-
F:
|
|
3478
|
+
F: __dxlog_file11,
|
|
3604
3479
|
L: 388,
|
|
3605
3480
|
S: this,
|
|
3606
3481
|
C: (f, a) => f(...a)
|
|
@@ -3627,7 +3502,7 @@ var DataSpace = class {
|
|
|
3627
3502
|
let epoch;
|
|
3628
3503
|
switch (options?.migration) {
|
|
3629
3504
|
case void 0:
|
|
3630
|
-
case
|
|
3505
|
+
case import_services7.CreateEpochRequest.Migration.NONE:
|
|
3631
3506
|
{
|
|
3632
3507
|
epoch = {
|
|
3633
3508
|
previousId: this._automergeSpaceState.lastEpoch?.id,
|
|
@@ -3637,7 +3512,7 @@ var DataSpace = class {
|
|
|
3637
3512
|
};
|
|
3638
3513
|
}
|
|
3639
3514
|
break;
|
|
3640
|
-
case
|
|
3515
|
+
case import_services7.CreateEpochRequest.Migration.INIT_AUTOMERGE:
|
|
3641
3516
|
{
|
|
3642
3517
|
const document = this._automergeHost.repo.create();
|
|
3643
3518
|
epoch = {
|
|
@@ -3648,14 +3523,14 @@ var DataSpace = class {
|
|
|
3648
3523
|
};
|
|
3649
3524
|
}
|
|
3650
3525
|
break;
|
|
3651
|
-
case
|
|
3526
|
+
case import_services7.CreateEpochRequest.Migration.PRUNE_AUTOMERGE_ROOT_HISTORY:
|
|
3652
3527
|
{
|
|
3653
3528
|
const currentRootUrl = this._automergeSpaceState.rootUrl;
|
|
3654
3529
|
const rootHandle = this._automergeHost.repo.find(currentRootUrl);
|
|
3655
3530
|
await (0, import_context7.cancelWithContext)(this._ctx, (0, import_async10.asyncTimeout)(rootHandle.whenReady(), 1e4));
|
|
3656
3531
|
const newRoot = this._automergeHost.repo.create(rootHandle.docSync());
|
|
3657
|
-
(0,
|
|
3658
|
-
F:
|
|
3532
|
+
(0, import_invariant9.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
3533
|
+
F: __dxlog_file11,
|
|
3659
3534
|
L: 438,
|
|
3660
3535
|
S: this,
|
|
3661
3536
|
A: [
|
|
@@ -3671,10 +3546,10 @@ var DataSpace = class {
|
|
|
3671
3546
|
};
|
|
3672
3547
|
}
|
|
3673
3548
|
break;
|
|
3674
|
-
case
|
|
3549
|
+
case import_services7.CreateEpochRequest.Migration.FRAGMENT_AUTOMERGE_ROOT:
|
|
3675
3550
|
{
|
|
3676
3551
|
import_log8.log.info("Fragmenting", void 0, {
|
|
3677
|
-
F:
|
|
3552
|
+
F: __dxlog_file11,
|
|
3678
3553
|
L: 450,
|
|
3679
3554
|
S: this,
|
|
3680
3555
|
C: (f, a) => f(...a)
|
|
@@ -3685,8 +3560,8 @@ var DataSpace = class {
|
|
|
3685
3560
|
const objects = Object.entries(rootHandle.docSync().objects);
|
|
3686
3561
|
const properties = objects.find(([_, value]) => value.system.type?.itemId === import_echo_db.TYPE_PROPERTIES);
|
|
3687
3562
|
const otherObjects = objects.filter(([key]) => key !== properties?.[0]);
|
|
3688
|
-
(0,
|
|
3689
|
-
F:
|
|
3563
|
+
(0, import_invariant9.invariant)(properties, "Properties not found", {
|
|
3564
|
+
F: __dxlog_file11,
|
|
3690
3565
|
L: 460,
|
|
3691
3566
|
S: this,
|
|
3692
3567
|
A: [
|
|
@@ -3701,8 +3576,8 @@ var DataSpace = class {
|
|
|
3701
3576
|
])
|
|
3702
3577
|
};
|
|
3703
3578
|
const newRoot = this._automergeHost.repo.create(newSpaceDoc);
|
|
3704
|
-
(0,
|
|
3705
|
-
F:
|
|
3579
|
+
(0, import_invariant9.invariant)(typeof newRoot.url === "string" && newRoot.url.length > 0, void 0, {
|
|
3580
|
+
F: __dxlog_file11,
|
|
3706
3581
|
L: 465,
|
|
3707
3582
|
S: this,
|
|
3708
3583
|
A: [
|
|
@@ -3754,24 +3629,24 @@ var DataSpace = class {
|
|
|
3754
3629
|
]));
|
|
3755
3630
|
}
|
|
3756
3631
|
async activate() {
|
|
3757
|
-
if (this._state !==
|
|
3632
|
+
if (this._state !== import_services7.SpaceState.INACTIVE) {
|
|
3758
3633
|
return;
|
|
3759
3634
|
}
|
|
3760
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
3635
|
+
await this._metadataStore.setSpaceState(this.key, import_services7.SpaceState.ACTIVE);
|
|
3761
3636
|
await this._open();
|
|
3762
3637
|
this.initializeDataPipelineAsync();
|
|
3763
3638
|
}
|
|
3764
3639
|
async deactivate() {
|
|
3765
|
-
if (this._state ===
|
|
3640
|
+
if (this._state === import_services7.SpaceState.INACTIVE) {
|
|
3766
3641
|
return;
|
|
3767
3642
|
}
|
|
3768
|
-
await this._metadataStore.setSpaceState(this.key,
|
|
3643
|
+
await this._metadataStore.setSpaceState(this.key, import_services7.SpaceState.INACTIVE);
|
|
3769
3644
|
await this._close();
|
|
3770
|
-
this._state =
|
|
3645
|
+
this._state = import_services7.SpaceState.INACTIVE;
|
|
3771
3646
|
(0, import_log8.log)("new state", {
|
|
3772
|
-
state:
|
|
3647
|
+
state: import_services7.SpaceState[this._state]
|
|
3773
3648
|
}, {
|
|
3774
|
-
F:
|
|
3649
|
+
F: __dxlog_file11,
|
|
3775
3650
|
L: 531,
|
|
3776
3651
|
S: this,
|
|
3777
3652
|
C: (f, a) => f(...a)
|
|
@@ -3780,18 +3655,18 @@ var DataSpace = class {
|
|
|
3780
3655
|
}
|
|
3781
3656
|
};
|
|
3782
3657
|
_ts_decorate4([
|
|
3783
|
-
|
|
3658
|
+
import_tracing4.trace.info()
|
|
3784
3659
|
], DataSpace.prototype, "_inner", void 0);
|
|
3785
3660
|
_ts_decorate4([
|
|
3786
|
-
|
|
3661
|
+
import_tracing4.trace.info()
|
|
3787
3662
|
], DataSpace.prototype, "key", null);
|
|
3788
3663
|
_ts_decorate4([
|
|
3789
|
-
|
|
3790
|
-
enum:
|
|
3664
|
+
import_tracing4.trace.info({
|
|
3665
|
+
enum: import_services7.SpaceState
|
|
3791
3666
|
})
|
|
3792
3667
|
], DataSpace.prototype, "state", null);
|
|
3793
3668
|
_ts_decorate4([
|
|
3794
|
-
|
|
3669
|
+
import_tracing4.trace.info({
|
|
3795
3670
|
depth: null
|
|
3796
3671
|
})
|
|
3797
3672
|
], DataSpace.prototype, "_automergeInfo", null);
|
|
@@ -3802,12 +3677,12 @@ _ts_decorate4([
|
|
|
3802
3677
|
import_async10.synchronized
|
|
3803
3678
|
], DataSpace.prototype, "close", null);
|
|
3804
3679
|
_ts_decorate4([
|
|
3805
|
-
|
|
3680
|
+
import_tracing4.trace.span({
|
|
3806
3681
|
showInBrowserTimeline: true
|
|
3807
3682
|
})
|
|
3808
3683
|
], DataSpace.prototype, "initializeDataPipeline", null);
|
|
3809
3684
|
_ts_decorate4([
|
|
3810
|
-
|
|
3685
|
+
import_tracing4.trace.span({
|
|
3811
3686
|
showInBrowserTimeline: true
|
|
3812
3687
|
})
|
|
3813
3688
|
], DataSpace.prototype, "_initializeAndReadControlPipeline", null);
|
|
@@ -3822,11 +3697,11 @@ _ts_decorate4([
|
|
|
3822
3697
|
], DataSpace.prototype, "deactivate", null);
|
|
3823
3698
|
DataSpace = _ts_decorate4([
|
|
3824
3699
|
(0, import_async10.trackLeaks)("open", "close"),
|
|
3825
|
-
|
|
3700
|
+
import_tracing4.trace.resource()
|
|
3826
3701
|
], DataSpace);
|
|
3827
3702
|
var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
3828
3703
|
const credentials = [
|
|
3829
|
-
await (0,
|
|
3704
|
+
await (0, import_credentials12.createCredential)({
|
|
3830
3705
|
signer: keyring,
|
|
3831
3706
|
issuer: space.key,
|
|
3832
3707
|
subject: space.key,
|
|
@@ -3835,14 +3710,14 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
3835
3710
|
spaceKey: space.key
|
|
3836
3711
|
}
|
|
3837
3712
|
}),
|
|
3838
|
-
await (0,
|
|
3713
|
+
await (0, import_credentials12.createCredential)({
|
|
3839
3714
|
signer: keyring,
|
|
3840
3715
|
issuer: space.key,
|
|
3841
3716
|
subject: signingContext.identityKey,
|
|
3842
3717
|
assertion: {
|
|
3843
3718
|
"@type": "dxos.halo.credentials.SpaceMember",
|
|
3844
3719
|
spaceKey: space.key,
|
|
3845
|
-
role:
|
|
3720
|
+
role: import_credentials13.SpaceMember.Role.ADMIN,
|
|
3846
3721
|
profile: signingContext.getProfile(),
|
|
3847
3722
|
genesisFeedKey: space.controlFeedKey ?? (0, import_debug4.failUndefined)()
|
|
3848
3723
|
}
|
|
@@ -3854,7 +3729,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
3854
3729
|
spaceKey: space.key,
|
|
3855
3730
|
identityKey: signingContext.identityKey,
|
|
3856
3731
|
deviceKey: signingContext.deviceKey,
|
|
3857
|
-
designation:
|
|
3732
|
+
designation: import_credentials13.AdmittedFeed.Designation.CONTROL
|
|
3858
3733
|
}
|
|
3859
3734
|
}),
|
|
3860
3735
|
await signingContext.credentialSigner.createCredential({
|
|
@@ -3864,7 +3739,7 @@ var spaceGenesis = async (keyring, signingContext, space, automergeRoot) => {
|
|
|
3864
3739
|
spaceKey: space.key,
|
|
3865
3740
|
identityKey: signingContext.identityKey,
|
|
3866
3741
|
deviceKey: signingContext.deviceKey,
|
|
3867
|
-
designation:
|
|
3742
|
+
designation: import_credentials13.AdmittedFeed.Designation.DATA
|
|
3868
3743
|
}
|
|
3869
3744
|
}),
|
|
3870
3745
|
await signingContext.credentialSigner.createCredential({
|
|
@@ -3898,7 +3773,7 @@ function _ts_decorate5(decorators, target, key, desc) {
|
|
|
3898
3773
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
3899
3774
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
3900
3775
|
}
|
|
3901
|
-
var
|
|
3776
|
+
var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts";
|
|
3902
3777
|
var PRESENCE_ANNOUNCE_INTERVAL = 1e4;
|
|
3903
3778
|
var PRESENCE_OFFLINE_TIMEOUT = 2e4;
|
|
3904
3779
|
var DataSpaceManager = class {
|
|
@@ -3924,15 +3799,15 @@ var DataSpaceManager = class {
|
|
|
3924
3799
|
}
|
|
3925
3800
|
async open() {
|
|
3926
3801
|
(0, import_log10.log)("open", void 0, {
|
|
3927
|
-
F:
|
|
3802
|
+
F: __dxlog_file12,
|
|
3928
3803
|
L: 98,
|
|
3929
3804
|
S: this,
|
|
3930
3805
|
C: (f, a) => f(...a)
|
|
3931
3806
|
});
|
|
3932
|
-
import_log10.log.trace("dxos.echo.data-space-manager.open",
|
|
3807
|
+
import_log10.log.trace("dxos.echo.data-space-manager.open", import_protocols9.trace.begin({
|
|
3933
3808
|
id: this._instanceId
|
|
3934
3809
|
}), {
|
|
3935
|
-
F:
|
|
3810
|
+
F: __dxlog_file12,
|
|
3936
3811
|
L: 99,
|
|
3937
3812
|
S: this,
|
|
3938
3813
|
C: (f, a) => f(...a)
|
|
@@ -3940,7 +3815,7 @@ var DataSpaceManager = class {
|
|
|
3940
3815
|
(0, import_log10.log)("metadata loaded", {
|
|
3941
3816
|
spaces: this._metadataStore.spaces.length
|
|
3942
3817
|
}, {
|
|
3943
|
-
F:
|
|
3818
|
+
F: __dxlog_file12,
|
|
3944
3819
|
L: 100,
|
|
3945
3820
|
S: this,
|
|
3946
3821
|
C: (f, a) => f(...a)
|
|
@@ -3950,7 +3825,7 @@ var DataSpaceManager = class {
|
|
|
3950
3825
|
(0, import_log10.log)("load space", {
|
|
3951
3826
|
spaceMetadata
|
|
3952
3827
|
}, {
|
|
3953
|
-
F:
|
|
3828
|
+
F: __dxlog_file12,
|
|
3954
3829
|
L: 104,
|
|
3955
3830
|
S: this,
|
|
3956
3831
|
C: (f, a) => f(...a)
|
|
@@ -3961,7 +3836,7 @@ var DataSpaceManager = class {
|
|
|
3961
3836
|
spaceMetadata,
|
|
3962
3837
|
err
|
|
3963
3838
|
}, {
|
|
3964
|
-
F:
|
|
3839
|
+
F: __dxlog_file12,
|
|
3965
3840
|
L: 107,
|
|
3966
3841
|
S: this,
|
|
3967
3842
|
C: (f, a) => f(...a)
|
|
@@ -3971,14 +3846,14 @@ var DataSpaceManager = class {
|
|
|
3971
3846
|
this._isOpen = true;
|
|
3972
3847
|
this.updated.emit();
|
|
3973
3848
|
for (const space of this._spaces.values()) {
|
|
3974
|
-
if (space.state !==
|
|
3849
|
+
if (space.state !== import_services8.SpaceState.INACTIVE) {
|
|
3975
3850
|
space.initializeDataPipelineAsync();
|
|
3976
3851
|
}
|
|
3977
3852
|
}
|
|
3978
|
-
import_log10.log.trace("dxos.echo.data-space-manager.open",
|
|
3853
|
+
import_log10.log.trace("dxos.echo.data-space-manager.open", import_protocols9.trace.end({
|
|
3979
3854
|
id: this._instanceId
|
|
3980
3855
|
}), {
|
|
3981
|
-
F:
|
|
3856
|
+
F: __dxlog_file12,
|
|
3982
3857
|
L: 120,
|
|
3983
3858
|
S: this,
|
|
3984
3859
|
C: (f, a) => f(...a)
|
|
@@ -3986,7 +3861,7 @@ var DataSpaceManager = class {
|
|
|
3986
3861
|
}
|
|
3987
3862
|
async close() {
|
|
3988
3863
|
(0, import_log10.log)("close", void 0, {
|
|
3989
|
-
F:
|
|
3864
|
+
F: __dxlog_file12,
|
|
3990
3865
|
L: 125,
|
|
3991
3866
|
S: this,
|
|
3992
3867
|
C: (f, a) => f(...a)
|
|
@@ -4001,8 +3876,8 @@ var DataSpaceManager = class {
|
|
|
4001
3876
|
* Creates a new space writing the genesis credentials to the control feed.
|
|
4002
3877
|
*/
|
|
4003
3878
|
async createSpace() {
|
|
4004
|
-
(0,
|
|
4005
|
-
F:
|
|
3879
|
+
(0, import_invariant11.invariant)(this._isOpen, "Not open.", {
|
|
3880
|
+
F: __dxlog_file12,
|
|
4006
3881
|
L: 138,
|
|
4007
3882
|
S: this,
|
|
4008
3883
|
A: [
|
|
@@ -4018,12 +3893,12 @@ var DataSpaceManager = class {
|
|
|
4018
3893
|
genesisFeedKey: controlFeedKey,
|
|
4019
3894
|
controlFeedKey,
|
|
4020
3895
|
dataFeedKey,
|
|
4021
|
-
state:
|
|
3896
|
+
state: import_services8.SpaceState.ACTIVE
|
|
4022
3897
|
};
|
|
4023
3898
|
(0, import_log10.log)("creating space...", {
|
|
4024
3899
|
spaceKey
|
|
4025
3900
|
}, {
|
|
4026
|
-
F:
|
|
3901
|
+
F: __dxlog_file12,
|
|
4027
3902
|
L: 150,
|
|
4028
3903
|
S: this,
|
|
4029
3904
|
C: (f, a) => f(...a)
|
|
@@ -4038,8 +3913,8 @@ var DataSpaceManager = class {
|
|
|
4038
3913
|
const credentials = await spaceGenesis(this._keyring, this._signingContext, space.inner, automergeRoot.url);
|
|
4039
3914
|
await this._metadataStore.addSpace(metadata);
|
|
4040
3915
|
const memberCredential = credentials[1];
|
|
4041
|
-
(0,
|
|
4042
|
-
F:
|
|
3916
|
+
(0, import_invariant11.invariant)((0, import_credentials11.getCredentialAssertion)(memberCredential)["@type"] === "dxos.halo.credentials.SpaceMember", void 0, {
|
|
3917
|
+
F: __dxlog_file12,
|
|
4043
3918
|
L: 163,
|
|
4044
3919
|
S: this,
|
|
4045
3920
|
A: [
|
|
@@ -4057,13 +3932,13 @@ var DataSpaceManager = class {
|
|
|
4057
3932
|
(0, import_log10.log)("accept space", {
|
|
4058
3933
|
opts
|
|
4059
3934
|
}, {
|
|
4060
|
-
F:
|
|
3935
|
+
F: __dxlog_file12,
|
|
4061
3936
|
L: 175,
|
|
4062
3937
|
S: this,
|
|
4063
3938
|
C: (f, a) => f(...a)
|
|
4064
3939
|
});
|
|
4065
|
-
(0,
|
|
4066
|
-
F:
|
|
3940
|
+
(0, import_invariant11.invariant)(this._isOpen, "Not open.", {
|
|
3941
|
+
F: __dxlog_file12,
|
|
4067
3942
|
L: 176,
|
|
4068
3943
|
S: this,
|
|
4069
3944
|
A: [
|
|
@@ -4071,8 +3946,8 @@ var DataSpaceManager = class {
|
|
|
4071
3946
|
"'Not open.'"
|
|
4072
3947
|
]
|
|
4073
3948
|
});
|
|
4074
|
-
(0,
|
|
4075
|
-
F:
|
|
3949
|
+
(0, import_invariant11.invariant)(!this._spaces.has(opts.spaceKey), "Space already exists.", {
|
|
3950
|
+
F: __dxlog_file12,
|
|
4076
3951
|
L: 177,
|
|
4077
3952
|
S: this,
|
|
4078
3953
|
A: [
|
|
@@ -4100,14 +3975,14 @@ var DataSpaceManager = class {
|
|
|
4100
3975
|
async waitUntilSpaceReady(spaceKey) {
|
|
4101
3976
|
await (0, import_context9.cancelWithContext)(this._ctx, this.updated.waitForCondition(() => {
|
|
4102
3977
|
const space = this._spaces.get(spaceKey);
|
|
4103
|
-
return !!space && space.state ===
|
|
3978
|
+
return !!space && space.state === import_services8.SpaceState.READY;
|
|
4104
3979
|
}));
|
|
4105
3980
|
}
|
|
4106
3981
|
async _constructSpace(metadata) {
|
|
4107
3982
|
(0, import_log10.log)("construct space", {
|
|
4108
3983
|
metadata
|
|
4109
3984
|
}, {
|
|
4110
|
-
F:
|
|
3985
|
+
F: __dxlog_file12,
|
|
4111
3986
|
L: 210,
|
|
4112
3987
|
S: this,
|
|
4113
3988
|
C: (f, a) => f(...a)
|
|
@@ -4145,7 +4020,7 @@ var DataSpaceManager = class {
|
|
|
4145
4020
|
},
|
|
4146
4021
|
onAuthFailure: () => {
|
|
4147
4022
|
import_log10.log.warn("auth failure", void 0, {
|
|
4148
|
-
F:
|
|
4023
|
+
F: __dxlog_file12,
|
|
4149
4024
|
L: 247,
|
|
4150
4025
|
S: this,
|
|
4151
4026
|
C: (f, a) => f(...a)
|
|
@@ -4157,7 +4032,7 @@ var DataSpaceManager = class {
|
|
|
4157
4032
|
dataFeed && await space.setDataFeed(dataFeed);
|
|
4158
4033
|
const dataSpace = new DataSpace({
|
|
4159
4034
|
inner: space,
|
|
4160
|
-
initialState: metadata.state ===
|
|
4035
|
+
initialState: metadata.state === import_services8.SpaceState.INACTIVE ? import_services8.SpaceState.INACTIVE : import_services8.SpaceState.CLOSED,
|
|
4161
4036
|
metadataStore: this._metadataStore,
|
|
4162
4037
|
gossip,
|
|
4163
4038
|
presence,
|
|
@@ -4169,7 +4044,7 @@ var DataSpaceManager = class {
|
|
|
4169
4044
|
(0, import_log10.log)("before space ready", {
|
|
4170
4045
|
space: space.key
|
|
4171
4046
|
}, {
|
|
4172
|
-
F:
|
|
4047
|
+
F: __dxlog_file12,
|
|
4173
4048
|
L: 265,
|
|
4174
4049
|
S: this,
|
|
4175
4050
|
C: (f, a) => f(...a)
|
|
@@ -4180,7 +4055,7 @@ var DataSpaceManager = class {
|
|
|
4180
4055
|
space: space.key,
|
|
4181
4056
|
open: this._isOpen
|
|
4182
4057
|
}, {
|
|
4183
|
-
F:
|
|
4058
|
+
F: __dxlog_file12,
|
|
4184
4059
|
L: 268,
|
|
4185
4060
|
S: this,
|
|
4186
4061
|
C: (f, a) => f(...a)
|
|
@@ -4193,7 +4068,7 @@ var DataSpaceManager = class {
|
|
|
4193
4068
|
(0, import_log10.log)("before space close", {
|
|
4194
4069
|
space: space.key
|
|
4195
4070
|
}, {
|
|
4196
|
-
F:
|
|
4071
|
+
F: __dxlog_file12,
|
|
4197
4072
|
L: 274,
|
|
4198
4073
|
S: this,
|
|
4199
4074
|
C: (f, a) => f(...a)
|
|
@@ -4203,7 +4078,7 @@ var DataSpaceManager = class {
|
|
|
4203
4078
|
cache: metadata.cache,
|
|
4204
4079
|
automergeHost: this._automergeHost
|
|
4205
4080
|
});
|
|
4206
|
-
if (metadata.state !==
|
|
4081
|
+
if (metadata.state !== import_services8.SpaceState.INACTIVE) {
|
|
4207
4082
|
await dataSpace.open();
|
|
4208
4083
|
}
|
|
4209
4084
|
if (metadata.controlTimeframe) {
|
|
@@ -4228,7 +4103,7 @@ _ts_decorate5([
|
|
|
4228
4103
|
DataSpaceManager = _ts_decorate5([
|
|
4229
4104
|
(0, import_async13.trackLeaks)("open", "close")
|
|
4230
4105
|
], DataSpaceManager);
|
|
4231
|
-
var
|
|
4106
|
+
var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/spaces/spaces-service.ts";
|
|
4232
4107
|
var SpacesServiceImpl = class {
|
|
4233
4108
|
constructor(_identityManager, _spaceManager, _getDataSpaceManager) {
|
|
4234
4109
|
this._identityManager = _identityManager;
|
|
@@ -4245,29 +4120,29 @@ var SpacesServiceImpl = class {
|
|
|
4245
4120
|
}
|
|
4246
4121
|
async updateSpace({ spaceKey, state }) {
|
|
4247
4122
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4248
|
-
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new
|
|
4123
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
|
|
4249
4124
|
if (state) {
|
|
4250
4125
|
switch (state) {
|
|
4251
|
-
case
|
|
4126
|
+
case import_services9.SpaceState.ACTIVE:
|
|
4252
4127
|
await space.activate();
|
|
4253
4128
|
break;
|
|
4254
|
-
case
|
|
4129
|
+
case import_services9.SpaceState.INACTIVE:
|
|
4255
4130
|
await space.deactivate();
|
|
4256
4131
|
break;
|
|
4257
4132
|
default:
|
|
4258
|
-
throw new
|
|
4133
|
+
throw new import_protocols10.ApiError("Invalid space state");
|
|
4259
4134
|
}
|
|
4260
4135
|
}
|
|
4261
4136
|
}
|
|
4262
4137
|
querySpaces() {
|
|
4263
|
-
return new
|
|
4138
|
+
return new import_codec_protobuf10.Stream(({ next, ctx }) => {
|
|
4264
4139
|
const scheduler = new import_async14.UpdateScheduler(ctx, async () => {
|
|
4265
4140
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4266
4141
|
const spaces = Array.from(dataSpaceManager.spaces.values()).map((space) => this._serializeSpace(space));
|
|
4267
4142
|
(0, import_log11.log)("update", {
|
|
4268
4143
|
spaces
|
|
4269
4144
|
}, {
|
|
4270
|
-
F:
|
|
4145
|
+
F: __dxlog_file13,
|
|
4271
4146
|
L: 77,
|
|
4272
4147
|
S: this,
|
|
4273
4148
|
C: (f, a) => f(...a)
|
|
@@ -4307,14 +4182,14 @@ var SpacesServiceImpl = class {
|
|
|
4307
4182
|
}
|
|
4308
4183
|
async postMessage({ spaceKey, channel, message }) {
|
|
4309
4184
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4310
|
-
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new
|
|
4185
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
|
|
4311
4186
|
await space.postMessage(getChannelId(channel), message);
|
|
4312
4187
|
}
|
|
4313
4188
|
subscribeMessages({ spaceKey, channel }) {
|
|
4314
|
-
return new
|
|
4189
|
+
return new import_codec_protobuf10.Stream(({ ctx, next }) => {
|
|
4315
4190
|
(0, import_async14.scheduleTask)(ctx, async () => {
|
|
4316
4191
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4317
|
-
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new
|
|
4192
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
|
|
4318
4193
|
const handle = space.listen(getChannelId(channel), (message) => {
|
|
4319
4194
|
next(message);
|
|
4320
4195
|
});
|
|
@@ -4323,8 +4198,8 @@ var SpacesServiceImpl = class {
|
|
|
4323
4198
|
});
|
|
4324
4199
|
}
|
|
4325
4200
|
queryCredentials({ spaceKey, noTail }) {
|
|
4326
|
-
return new
|
|
4327
|
-
const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new
|
|
4201
|
+
return new import_codec_protobuf10.Stream(({ ctx, next, close }) => {
|
|
4202
|
+
const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
|
|
4328
4203
|
const processor = {
|
|
4329
4204
|
processCredential: async (credential) => {
|
|
4330
4205
|
next(credential);
|
|
@@ -4340,7 +4215,7 @@ var SpacesServiceImpl = class {
|
|
|
4340
4215
|
});
|
|
4341
4216
|
}
|
|
4342
4217
|
async writeCredentials({ spaceKey, credentials }) {
|
|
4343
|
-
const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new
|
|
4218
|
+
const space = this._spaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
|
|
4344
4219
|
for (const credential of credentials ?? []) {
|
|
4345
4220
|
if (credential.proof) {
|
|
4346
4221
|
await space.controlPipeline.writer.write({
|
|
@@ -4349,8 +4224,8 @@ var SpacesServiceImpl = class {
|
|
|
4349
4224
|
}
|
|
4350
4225
|
});
|
|
4351
4226
|
} else {
|
|
4352
|
-
(0,
|
|
4353
|
-
F:
|
|
4227
|
+
(0, import_invariant12.invariant)(!credential.id, "Id on unsigned credentials is not allowed", {
|
|
4228
|
+
F: __dxlog_file13,
|
|
4354
4229
|
L: 164,
|
|
4355
4230
|
S: this,
|
|
4356
4231
|
A: [
|
|
@@ -4358,8 +4233,8 @@ var SpacesServiceImpl = class {
|
|
|
4358
4233
|
"'Id on unsigned credentials is not allowed'"
|
|
4359
4234
|
]
|
|
4360
4235
|
});
|
|
4361
|
-
(0,
|
|
4362
|
-
F:
|
|
4236
|
+
(0, import_invariant12.invariant)(this._identityManager.identity, "Identity is not available", {
|
|
4237
|
+
F: __dxlog_file13,
|
|
4363
4238
|
L: 165,
|
|
4364
4239
|
S: this,
|
|
4365
4240
|
A: [
|
|
@@ -4368,8 +4243,8 @@ var SpacesServiceImpl = class {
|
|
|
4368
4243
|
]
|
|
4369
4244
|
});
|
|
4370
4245
|
const signer = this._identityManager.identity.getIdentityCredentialSigner();
|
|
4371
|
-
(0,
|
|
4372
|
-
F:
|
|
4246
|
+
(0, import_invariant12.invariant)(credential.issuer.equals(signer.getIssuer()), void 0, {
|
|
4247
|
+
F: __dxlog_file13,
|
|
4373
4248
|
L: 167,
|
|
4374
4249
|
S: this,
|
|
4375
4250
|
A: [
|
|
@@ -4391,7 +4266,7 @@ var SpacesServiceImpl = class {
|
|
|
4391
4266
|
}
|
|
4392
4267
|
async createEpoch({ spaceKey, migration }) {
|
|
4393
4268
|
const dataSpaceManager = await this._getDataSpaceManager();
|
|
4394
|
-
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new
|
|
4269
|
+
const space = dataSpaceManager.spaces.get(spaceKey) ?? (0, import_debug5.raise)(new import_protocols10.SpaceNotFoundError(spaceKey));
|
|
4395
4270
|
await space.createEpoch({
|
|
4396
4271
|
migration
|
|
4397
4272
|
});
|
|
@@ -4400,7 +4275,7 @@ var SpacesServiceImpl = class {
|
|
|
4400
4275
|
return {
|
|
4401
4276
|
spaceKey: space.key,
|
|
4402
4277
|
state: space.state,
|
|
4403
|
-
error: space.error ? (0,
|
|
4278
|
+
error: space.error ? (0, import_protocols10.encodeError)(space.error) : void 0,
|
|
4404
4279
|
pipeline: {
|
|
4405
4280
|
currentEpoch: space.automergeSpaceState.lastEpoch,
|
|
4406
4281
|
appliedEpoch: space.automergeSpaceState.lastEpoch,
|
|
@@ -4425,7 +4300,7 @@ var SpacesServiceImpl = class {
|
|
|
4425
4300
|
identityKey: member.key,
|
|
4426
4301
|
profile: member.profile ?? {}
|
|
4427
4302
|
},
|
|
4428
|
-
presence: member.removed ?
|
|
4303
|
+
presence: member.removed ? import_services9.SpaceMember.PresenceState.REMOVED : isMe || peers.length > 0 ? import_services9.SpaceMember.PresenceState.ONLINE : import_services9.SpaceMember.PresenceState.OFFLINE,
|
|
4429
4304
|
peerStates: peers
|
|
4430
4305
|
};
|
|
4431
4306
|
}),
|
|
@@ -4444,7 +4319,7 @@ var createSelectedDocumentsIterator = (automergeHost) => (
|
|
|
4444
4319
|
// TODO(mykola): Unload automerge handles after usage.
|
|
4445
4320
|
async function* loadDocuments(ids) {
|
|
4446
4321
|
for (const id of ids) {
|
|
4447
|
-
const { documentId, objectId } =
|
|
4322
|
+
const { documentId, objectId } = import_protocols12.idCodec.decode(id);
|
|
4448
4323
|
const handle = automergeHost.repo.find(documentId);
|
|
4449
4324
|
await (0, import_debug7.warnAfterTimeout)(5e3, "to long to load doc", () => handle.whenReady());
|
|
4450
4325
|
const doc = handle.docSync();
|
|
@@ -4477,7 +4352,7 @@ var createDocumentsIterator = (automergeHost) => (
|
|
|
4477
4352
|
if (doc.objects) {
|
|
4478
4353
|
yield Object.entries(doc.objects).map(([objectId, object]) => {
|
|
4479
4354
|
return {
|
|
4480
|
-
id:
|
|
4355
|
+
id: import_protocols12.idCodec.encode({
|
|
4481
4356
|
documentId: handle.documentId,
|
|
4482
4357
|
objectId
|
|
4483
4358
|
}),
|
|
@@ -4520,7 +4395,7 @@ function _ts_decorate6(decorators, target, key, desc) {
|
|
|
4520
4395
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4521
4396
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4522
4397
|
}
|
|
4523
|
-
var
|
|
4398
|
+
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-context.ts";
|
|
4524
4399
|
var ServiceContext = class extends import_context10.Resource {
|
|
4525
4400
|
constructor(storage, level, networkManager, signalManager, _runtimeParams) {
|
|
4526
4401
|
super();
|
|
@@ -4570,20 +4445,20 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4570
4445
|
getAllDocuments: createDocumentsIterator(this.automergeHost)
|
|
4571
4446
|
});
|
|
4572
4447
|
this.invitations = new InvitationsHandler(this.networkManager);
|
|
4573
|
-
this._handlerFactories.set(
|
|
4448
|
+
this._handlerFactories.set(import_services10.Invitation.Kind.DEVICE, () => new DeviceInvitationProtocol(this.keyring, () => this.identityManager.identity ?? (0, import_debug6.failUndefined)(), this._acceptIdentity.bind(this)));
|
|
4574
4449
|
}
|
|
4575
4450
|
async _open(ctx) {
|
|
4576
4451
|
await this._checkStorageVersion();
|
|
4577
4452
|
(0, import_log12.log)("opening...", void 0, {
|
|
4578
|
-
F:
|
|
4453
|
+
F: __dxlog_file14,
|
|
4579
4454
|
L: 156,
|
|
4580
4455
|
S: this,
|
|
4581
4456
|
C: (f, a) => f(...a)
|
|
4582
4457
|
});
|
|
4583
|
-
import_log12.log.trace("dxos.sdk.service-context.open",
|
|
4458
|
+
import_log12.log.trace("dxos.sdk.service-context.open", import_protocols11.trace.begin({
|
|
4584
4459
|
id: this._instanceId
|
|
4585
4460
|
}), {
|
|
4586
|
-
F:
|
|
4461
|
+
F: __dxlog_file14,
|
|
4587
4462
|
L: 157,
|
|
4588
4463
|
S: this,
|
|
4589
4464
|
C: (f, a) => f(...a)
|
|
@@ -4596,16 +4471,16 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4596
4471
|
if (this.identityManager.identity) {
|
|
4597
4472
|
await this._initialize(ctx);
|
|
4598
4473
|
}
|
|
4599
|
-
import_log12.log.trace("dxos.sdk.service-context.open",
|
|
4474
|
+
import_log12.log.trace("dxos.sdk.service-context.open", import_protocols11.trace.end({
|
|
4600
4475
|
id: this._instanceId
|
|
4601
4476
|
}), {
|
|
4602
|
-
F:
|
|
4477
|
+
F: __dxlog_file14,
|
|
4603
4478
|
L: 167,
|
|
4604
4479
|
S: this,
|
|
4605
4480
|
C: (f, a) => f(...a)
|
|
4606
4481
|
});
|
|
4607
4482
|
(0, import_log12.log)("opened", void 0, {
|
|
4608
|
-
F:
|
|
4483
|
+
F: __dxlog_file14,
|
|
4609
4484
|
L: 168,
|
|
4610
4485
|
S: this,
|
|
4611
4486
|
C: (f, a) => f(...a)
|
|
@@ -4613,7 +4488,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4613
4488
|
}
|
|
4614
4489
|
async _close() {
|
|
4615
4490
|
(0, import_log12.log)("closing...", void 0, {
|
|
4616
|
-
F:
|
|
4491
|
+
F: __dxlog_file14,
|
|
4617
4492
|
L: 172,
|
|
4618
4493
|
S: this,
|
|
4619
4494
|
C: (f, a) => f(...a)
|
|
@@ -4631,7 +4506,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4631
4506
|
await this.metadataStore.close();
|
|
4632
4507
|
await this.indexer.destroy();
|
|
4633
4508
|
(0, import_log12.log)("closed", void 0, {
|
|
4634
|
-
F:
|
|
4509
|
+
F: __dxlog_file14,
|
|
4635
4510
|
L: 185,
|
|
4636
4511
|
S: this,
|
|
4637
4512
|
C: (f, a) => f(...a)
|
|
@@ -4644,8 +4519,8 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4644
4519
|
}
|
|
4645
4520
|
getInvitationHandler(invitation) {
|
|
4646
4521
|
const factory = this._handlerFactories.get(invitation.kind);
|
|
4647
|
-
(0,
|
|
4648
|
-
F:
|
|
4522
|
+
(0, import_invariant13.invariant)(factory, `Unknown invitation kind: ${invitation.kind}`, {
|
|
4523
|
+
F: __dxlog_file14,
|
|
4649
4524
|
L: 196,
|
|
4650
4525
|
S: this,
|
|
4651
4526
|
A: [
|
|
@@ -4670,14 +4545,14 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4670
4545
|
}
|
|
4671
4546
|
async _checkStorageVersion() {
|
|
4672
4547
|
await this.metadataStore.load();
|
|
4673
|
-
if (this.metadataStore.version !==
|
|
4674
|
-
throw new
|
|
4548
|
+
if (this.metadataStore.version !== import_protocols11.STORAGE_VERSION) {
|
|
4549
|
+
throw new import_protocols11.InvalidStorageVersionError(import_protocols11.STORAGE_VERSION, this.metadataStore.version);
|
|
4675
4550
|
}
|
|
4676
4551
|
}
|
|
4677
4552
|
// Called when identity is created.
|
|
4678
4553
|
async _initialize(ctx) {
|
|
4679
4554
|
(0, import_log12.log)("initializing spaces...", void 0, {
|
|
4680
|
-
F:
|
|
4555
|
+
F: __dxlog_file14,
|
|
4681
4556
|
L: 227,
|
|
4682
4557
|
S: this,
|
|
4683
4558
|
C: (f, a) => f(...a)
|
|
@@ -4698,9 +4573,9 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4698
4573
|
};
|
|
4699
4574
|
this.dataSpaceManager = new DataSpaceManager(this.spaceManager, this.metadataStore, this.keyring, signingContext, this.feedStore, this.automergeHost, this._runtimeParams);
|
|
4700
4575
|
await this.dataSpaceManager.open();
|
|
4701
|
-
this._handlerFactories.set(
|
|
4702
|
-
(0,
|
|
4703
|
-
F:
|
|
4576
|
+
this._handlerFactories.set(import_services10.Invitation.Kind.SPACE, (invitation) => {
|
|
4577
|
+
(0, import_invariant13.invariant)(this.dataSpaceManager, "dataSpaceManager not initialized yet", {
|
|
4578
|
+
F: __dxlog_file14,
|
|
4704
4579
|
L: 251,
|
|
4705
4580
|
S: this,
|
|
4706
4581
|
A: [
|
|
@@ -4713,7 +4588,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4713
4588
|
this.initialized.wake();
|
|
4714
4589
|
this._deviceSpaceSync = {
|
|
4715
4590
|
processCredential: async (credential) => {
|
|
4716
|
-
const assertion = (0,
|
|
4591
|
+
const assertion = (0, import_credentials14.getCredentialAssertion)(credential);
|
|
4717
4592
|
if (assertion["@type"] !== "dxos.halo.credentials.SpaceMember") {
|
|
4718
4593
|
return;
|
|
4719
4594
|
}
|
|
@@ -4724,7 +4599,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4724
4599
|
(0, import_log12.log)("dataSpaceManager not initialized yet, ignoring space admission", {
|
|
4725
4600
|
details: assertion
|
|
4726
4601
|
}, {
|
|
4727
|
-
F:
|
|
4602
|
+
F: __dxlog_file14,
|
|
4728
4603
|
L: 267,
|
|
4729
4604
|
S: this,
|
|
4730
4605
|
C: (f, a) => f(...a)
|
|
@@ -4735,7 +4610,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4735
4610
|
(0, import_log12.log)("space already exists, ignoring space admission", {
|
|
4736
4611
|
details: assertion
|
|
4737
4612
|
}, {
|
|
4738
|
-
F:
|
|
4613
|
+
F: __dxlog_file14,
|
|
4739
4614
|
L: 271,
|
|
4740
4615
|
S: this,
|
|
4741
4616
|
C: (f, a) => f(...a)
|
|
@@ -4746,7 +4621,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4746
4621
|
(0, import_log12.log)("accepting space recorded in halo", {
|
|
4747
4622
|
details: assertion
|
|
4748
4623
|
}, {
|
|
4749
|
-
F:
|
|
4624
|
+
F: __dxlog_file14,
|
|
4750
4625
|
L: 276,
|
|
4751
4626
|
S: this,
|
|
4752
4627
|
C: (f, a) => f(...a)
|
|
@@ -4757,7 +4632,7 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4757
4632
|
});
|
|
4758
4633
|
} catch (err) {
|
|
4759
4634
|
import_log12.log.catch(err, void 0, {
|
|
4760
|
-
F:
|
|
4635
|
+
F: __dxlog_file14,
|
|
4761
4636
|
L: 282,
|
|
4762
4637
|
S: this,
|
|
4763
4638
|
C: (f, a) => f(...a)
|
|
@@ -4769,14 +4644,14 @@ var ServiceContext = class extends import_context10.Resource {
|
|
|
4769
4644
|
}
|
|
4770
4645
|
};
|
|
4771
4646
|
_ts_decorate6([
|
|
4772
|
-
|
|
4647
|
+
import_tracing5.trace.span()
|
|
4773
4648
|
], ServiceContext.prototype, "_open", null);
|
|
4774
4649
|
_ts_decorate6([
|
|
4775
|
-
|
|
4650
|
+
import_tracing5.trace.span()
|
|
4776
4651
|
], ServiceContext.prototype, "_initialize", null);
|
|
4777
4652
|
ServiceContext = _ts_decorate6([
|
|
4778
4653
|
(0, import_util7.safeInstanceof)("dxos.client-services.ServiceContext"),
|
|
4779
|
-
|
|
4654
|
+
import_tracing5.trace.resource()
|
|
4780
4655
|
], ServiceContext);
|
|
4781
4656
|
var ServiceRegistry = class {
|
|
4782
4657
|
// prettier-ignore
|
|
@@ -4800,118 +4675,155 @@ var ServiceRegistry = class {
|
|
|
4800
4675
|
delete this._handlers[name];
|
|
4801
4676
|
}
|
|
4802
4677
|
};
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
if (
|
|
4806
|
-
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
4810
|
-
|
|
4811
|
-
|
|
4812
|
-
}
|
|
4813
|
-
|
|
4814
|
-
|
|
4815
|
-
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
}
|
|
4820
|
-
|
|
4821
|
-
return
|
|
4822
|
-
|
|
4823
|
-
|
|
4824
|
-
|
|
4825
|
-
|
|
4826
|
-
|
|
4827
|
-
|
|
4828
|
-
|
|
4829
|
-
});
|
|
4830
|
-
this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
|
|
4831
|
-
await this._onAcquire?.();
|
|
4832
|
-
(0, import_log13.log)("acquired lock", void 0, {
|
|
4833
|
-
F: __dxlog_file16,
|
|
4834
|
-
L: 37,
|
|
4835
|
-
S: this,
|
|
4836
|
-
C: (f, a) => f(...a)
|
|
4837
|
-
});
|
|
4678
|
+
var DXOS_VERSION = "0.4.10-main.d4766e5";
|
|
4679
|
+
var getPlatform = () => {
|
|
4680
|
+
if (process.browser) {
|
|
4681
|
+
if (typeof window !== "undefined") {
|
|
4682
|
+
const { userAgent } = window.navigator;
|
|
4683
|
+
return {
|
|
4684
|
+
type: import_services12.Platform.PLATFORM_TYPE.BROWSER,
|
|
4685
|
+
userAgent,
|
|
4686
|
+
uptime: Math.floor((Date.now() - window.performance.timeOrigin) / 1e3)
|
|
4687
|
+
};
|
|
4688
|
+
} else {
|
|
4689
|
+
return {
|
|
4690
|
+
type: import_services12.Platform.PLATFORM_TYPE.SHARED_WORKER,
|
|
4691
|
+
uptime: Math.floor((Date.now() - performance.timeOrigin) / 1e3)
|
|
4692
|
+
};
|
|
4693
|
+
}
|
|
4694
|
+
} else {
|
|
4695
|
+
const { platform: platform2, version, arch } = process;
|
|
4696
|
+
return {
|
|
4697
|
+
type: import_services12.Platform.PLATFORM_TYPE.NODE,
|
|
4698
|
+
platform: platform2,
|
|
4699
|
+
arch,
|
|
4700
|
+
runtime: version,
|
|
4701
|
+
uptime: Math.floor(process.uptime()),
|
|
4702
|
+
memory: process.memoryUsage()
|
|
4703
|
+
};
|
|
4838
4704
|
}
|
|
4839
|
-
|
|
4840
|
-
|
|
4841
|
-
|
|
4842
|
-
|
|
4843
|
-
|
|
4844
|
-
|
|
4705
|
+
};
|
|
4706
|
+
var __dxlog_file15 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/diagnostics/diagnostics.ts";
|
|
4707
|
+
var DEFAULT_TIMEOUT = 1e3;
|
|
4708
|
+
var createDiagnostics = async (clientServices, serviceContext, config) => {
|
|
4709
|
+
const diagnostics = {
|
|
4710
|
+
created: (/* @__PURE__ */ new Date()).toISOString(),
|
|
4711
|
+
platform: getPlatform(),
|
|
4712
|
+
client: {
|
|
4713
|
+
version: DXOS_VERSION,
|
|
4714
|
+
storage: {
|
|
4715
|
+
version: import_protocols13.STORAGE_VERSION
|
|
4716
|
+
}
|
|
4717
|
+
},
|
|
4718
|
+
trace: import_tracing6.TRACE_PROCESSOR.getDiagnostics()
|
|
4719
|
+
};
|
|
4720
|
+
{
|
|
4721
|
+
(0, import_invariant14.invariant)(clientServices.LoggingService, "SystemService is not available.", {
|
|
4722
|
+
F: __dxlog_file15,
|
|
4723
|
+
L: 108,
|
|
4724
|
+
S: void 0,
|
|
4845
4725
|
A: [
|
|
4846
|
-
"
|
|
4847
|
-
"'
|
|
4726
|
+
"clientServices.LoggingService",
|
|
4727
|
+
"'SystemService is not available.'"
|
|
4848
4728
|
]
|
|
4849
4729
|
});
|
|
4850
|
-
await
|
|
4851
|
-
|
|
4852
|
-
};
|
|
4853
|
-
_ts_decorate7([
|
|
4854
|
-
import_log13.logInfo
|
|
4855
|
-
], Lock.prototype, "lockKey", null);
|
|
4856
|
-
var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
|
|
4857
|
-
var getRootPath = (config) => {
|
|
4858
|
-
const { dataRoot = (0, import_util8.isNode)() ? import_client_protocol4.DX_DATA : "dxos/storage" } = config ?? {};
|
|
4859
|
-
return `${dataRoot}/`;
|
|
4860
|
-
};
|
|
4861
|
-
var isPersistent = (config) => {
|
|
4862
|
-
const { persistent = false } = config ?? {};
|
|
4863
|
-
return config.dataStore !== void 0 && config.dataStore !== import_config2.Runtime.Client.Storage.StorageDriver.RAM || persistent;
|
|
4864
|
-
};
|
|
4865
|
-
var StorageDriver = import_config.Runtime.Client.Storage.StorageDriver;
|
|
4866
|
-
var createStorageObjects = (config) => {
|
|
4867
|
-
const { persistent = false, keyStore, dataStore } = config ?? {};
|
|
4868
|
-
if (persistent && dataStore === StorageDriver.RAM) {
|
|
4869
|
-
throw new import_protocols14.InvalidConfigError("RAM storage cannot be used in persistent mode.");
|
|
4730
|
+
diagnostics.metrics = await (0, import_codec_protobuf11.getFirstStreamValue)(clientServices.LoggingService.queryMetrics({}), {
|
|
4731
|
+
timeout: DEFAULT_TIMEOUT
|
|
4732
|
+
}).catch(() => void 0);
|
|
4870
4733
|
}
|
|
4871
|
-
if (
|
|
4872
|
-
|
|
4734
|
+
if (typeof navigator !== "undefined" && navigator.storage) {
|
|
4735
|
+
const map = /* @__PURE__ */ new Map();
|
|
4736
|
+
const dir = await navigator.storage.getDirectory();
|
|
4737
|
+
for await (const filename of dir?.keys()) {
|
|
4738
|
+
const idx = filename.indexOf("-", filename.indexOf("-") + 1);
|
|
4739
|
+
if (idx === -1) {
|
|
4740
|
+
continue;
|
|
4741
|
+
}
|
|
4742
|
+
map.set(filename.slice(0, idx), (map.get(filename.slice(0, idx)) ?? 0) + 1);
|
|
4743
|
+
}
|
|
4744
|
+
diagnostics.storage = Array.from(map.entries()).sort((a, b) => b[1] - a[1]).map(([file, count]) => ({
|
|
4745
|
+
file,
|
|
4746
|
+
count
|
|
4747
|
+
}));
|
|
4873
4748
|
}
|
|
4874
|
-
|
|
4875
|
-
|
|
4749
|
+
const identity = serviceContext.identityManager.identity;
|
|
4750
|
+
if (identity) {
|
|
4751
|
+
diagnostics.identity = {
|
|
4752
|
+
identityKey: identity.identityKey,
|
|
4753
|
+
spaceKey: identity.space.key,
|
|
4754
|
+
profile: identity.profileDocument
|
|
4755
|
+
};
|
|
4756
|
+
const { devices } = await (0, import_codec_protobuf11.getFirstStreamValue)(clientServices.DevicesService.queryDevices(), {
|
|
4757
|
+
timeout: DEFAULT_TIMEOUT
|
|
4758
|
+
}).catch(() => void 0) ?? {};
|
|
4759
|
+
diagnostics.devices = devices;
|
|
4760
|
+
if (serviceContext.dataSpaceManager) {
|
|
4761
|
+
diagnostics.spaces = await Promise.all(Array.from(serviceContext.dataSpaceManager.spaces.values()).map((space) => getSpaceStats(space)) ?? []);
|
|
4762
|
+
}
|
|
4763
|
+
const { feeds = [] } = await (0, import_codec_protobuf11.getFirstStreamValue)(clientServices.DevtoolsHost.subscribeToFeeds({}), {
|
|
4764
|
+
timeout: DEFAULT_TIMEOUT
|
|
4765
|
+
}).catch(() => void 0) ?? {};
|
|
4766
|
+
diagnostics.feeds = feeds.map(({ feedKey, bytes, length }) => ({
|
|
4767
|
+
feedKey,
|
|
4768
|
+
bytes,
|
|
4769
|
+
length
|
|
4770
|
+
}));
|
|
4771
|
+
const status = await (0, import_codec_protobuf11.getFirstStreamValue)(clientServices.NetworkService.queryStatus(), {
|
|
4772
|
+
timeout: DEFAULT_TIMEOUT
|
|
4773
|
+
}).catch(() => void 0);
|
|
4774
|
+
diagnostics.networkStatus = status;
|
|
4775
|
+
diagnostics.swarms = serviceContext.networkManager.connectionLog?.swarms;
|
|
4876
4776
|
}
|
|
4877
|
-
|
|
4878
|
-
|
|
4777
|
+
diagnostics.config = config.values;
|
|
4778
|
+
return diagnostics;
|
|
4779
|
+
};
|
|
4780
|
+
var getSpaceStats = async (space) => {
|
|
4781
|
+
const stats = {
|
|
4782
|
+
key: space.key,
|
|
4783
|
+
metrics: space.metrics,
|
|
4784
|
+
epochs: space.inner.spaceState.credentials.filter((0, import_credentials15.credentialTypeFilter)("dxos.halo.credentials.Epoch")).map((credential) => ({
|
|
4785
|
+
...credential.subject.assertion,
|
|
4786
|
+
id: credential.id
|
|
4787
|
+
})),
|
|
4788
|
+
members: Array.from(space.inner.spaceState.members.values()).map((member) => ({
|
|
4789
|
+
identity: {
|
|
4790
|
+
identityKey: member.key,
|
|
4791
|
+
profile: {
|
|
4792
|
+
displayName: member.assertion.profile?.displayName
|
|
4793
|
+
}
|
|
4794
|
+
},
|
|
4795
|
+
presence: space.presence.getPeersOnline().filter(({ identityKey }) => identityKey.equals(member.key)).length > 0 ? import_services11.SpaceMember.PresenceState.ONLINE : import_services11.SpaceMember.PresenceState.OFFLINE
|
|
4796
|
+
})),
|
|
4797
|
+
pipeline: {
|
|
4798
|
+
// TODO(burdon): Pick properties from credentials if needed.
|
|
4799
|
+
currentEpoch: space.automergeSpaceState.lastEpoch,
|
|
4800
|
+
appliedEpoch: space.automergeSpaceState.lastEpoch,
|
|
4801
|
+
controlFeeds: space.inner.controlPipeline.state.feeds.map((feed) => feed.key),
|
|
4802
|
+
currentControlTimeframe: space.inner.controlPipeline.state.timeframe,
|
|
4803
|
+
targetControlTimeframe: space.inner.controlPipeline.state.targetTimeframe,
|
|
4804
|
+
totalControlTimeframe: space.inner.controlPipeline.state.endTimeframe
|
|
4805
|
+
}
|
|
4806
|
+
};
|
|
4807
|
+
if (stats.metrics) {
|
|
4808
|
+
const { open, ready } = stats.metrics;
|
|
4809
|
+
stats.metrics.startupTime = open && ready && ready.getTime() - open.getTime();
|
|
4879
4810
|
}
|
|
4811
|
+
return stats;
|
|
4812
|
+
};
|
|
4813
|
+
var createCollectDiagnosticsBroadcastSender = () => {
|
|
4880
4814
|
return {
|
|
4881
|
-
|
|
4882
|
-
type: persistent ? toStorageType(dataStore) : import_random_access_storage.StorageType.RAM,
|
|
4883
|
-
root: getRootPath(config)
|
|
4884
|
-
})
|
|
4815
|
+
broadcastDiagnosticsRequest: async () => void 0
|
|
4885
4816
|
};
|
|
4886
4817
|
};
|
|
4887
|
-
var
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
|
|
4894
|
-
return import_random_access_storage.StorageType.CHROME;
|
|
4895
|
-
case StorageDriver.FIREFOX:
|
|
4896
|
-
return import_random_access_storage.StorageType.FIREFOX;
|
|
4897
|
-
case StorageDriver.IDB:
|
|
4898
|
-
return import_random_access_storage.StorageType.IDB;
|
|
4899
|
-
case StorageDriver.NODE:
|
|
4900
|
-
return import_random_access_storage.StorageType.NODE;
|
|
4901
|
-
case StorageDriver.WEBFS:
|
|
4902
|
-
return import_random_access_storage.StorageType.WEBFS;
|
|
4903
|
-
default:
|
|
4904
|
-
throw new Error(`Invalid storage type: ${StorageDriver[type]}`);
|
|
4905
|
-
}
|
|
4906
|
-
};
|
|
4907
|
-
var createLevel = async (config) => {
|
|
4908
|
-
const persistent = isPersistent(config);
|
|
4909
|
-
const storagePath = persistent ? getRootPath(config) : import_node_path.default.join("tmp", "level", import_keys11.PublicKey.random().toHex());
|
|
4910
|
-
const level = new import_level.Level(storagePath);
|
|
4911
|
-
await level.open();
|
|
4912
|
-
return level;
|
|
4818
|
+
var createCollectDiagnosticsBroadcastHandler = (_) => {
|
|
4819
|
+
return {
|
|
4820
|
+
start: () => {
|
|
4821
|
+
},
|
|
4822
|
+
stop: () => {
|
|
4823
|
+
}
|
|
4824
|
+
};
|
|
4913
4825
|
};
|
|
4914
|
-
var
|
|
4826
|
+
var __dxlog_file16 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
|
|
4915
4827
|
var DevicesServiceImpl = class {
|
|
4916
4828
|
constructor(_identityManager) {
|
|
4917
4829
|
this._identityManager = _identityManager;
|
|
@@ -4928,8 +4840,8 @@ var DevicesServiceImpl = class {
|
|
|
4928
4840
|
devices: []
|
|
4929
4841
|
});
|
|
4930
4842
|
} else {
|
|
4931
|
-
(0,
|
|
4932
|
-
F:
|
|
4843
|
+
(0, import_invariant16.invariant)(this._identityManager.identity?.presence, "presence not present", {
|
|
4844
|
+
F: __dxlog_file16,
|
|
4933
4845
|
L: 32,
|
|
4934
4846
|
S: this,
|
|
4935
4847
|
A: [
|
|
@@ -4944,9 +4856,9 @@ var DevicesServiceImpl = class {
|
|
|
4944
4856
|
const peerState = peers.find((peer) => peer.identityKey.equals(key));
|
|
4945
4857
|
return {
|
|
4946
4858
|
deviceKey: key,
|
|
4947
|
-
kind: this._identityManager.identity?.deviceKey.equals(key) ?
|
|
4859
|
+
kind: this._identityManager.identity?.deviceKey.equals(key) ? import_services15.DeviceKind.CURRENT : import_services15.DeviceKind.TRUSTED,
|
|
4948
4860
|
profile,
|
|
4949
|
-
presence: isMe ?
|
|
4861
|
+
presence: isMe ? import_services15.Device.PresenceState.ONLINE : peerState ? import_services15.Device.PresenceState.ONLINE : import_services15.Device.PresenceState.OFFLINE
|
|
4950
4862
|
};
|
|
4951
4863
|
})
|
|
4952
4864
|
});
|
|
@@ -4987,11 +4899,65 @@ var DevicesServiceImpl = class {
|
|
|
4987
4899
|
});
|
|
4988
4900
|
}
|
|
4989
4901
|
};
|
|
4902
|
+
function _ts_decorate7(decorators, target, key, desc) {
|
|
4903
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4904
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
4905
|
+
r = Reflect.decorate(decorators, target, key, desc);
|
|
4906
|
+
else
|
|
4907
|
+
for (var i = decorators.length - 1; i >= 0; i--)
|
|
4908
|
+
if (d = decorators[i])
|
|
4909
|
+
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
4910
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
4911
|
+
}
|
|
4912
|
+
var __dxlog_file17 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/locks/node.ts";
|
|
4913
|
+
var Lock = class {
|
|
4914
|
+
constructor({ lockKey: lockPath, onAcquire, onRelease }) {
|
|
4915
|
+
this._lockPath = lockPath;
|
|
4916
|
+
this._onAcquire = onAcquire;
|
|
4917
|
+
this._onRelease = onRelease;
|
|
4918
|
+
}
|
|
4919
|
+
get lockKey() {
|
|
4920
|
+
return this._lockPath;
|
|
4921
|
+
}
|
|
4922
|
+
async acquire() {
|
|
4923
|
+
(0, import_log14.log)("acquiring lock...", void 0, {
|
|
4924
|
+
F: __dxlog_file17,
|
|
4925
|
+
L: 32,
|
|
4926
|
+
S: this,
|
|
4927
|
+
C: (f, a) => f(...a)
|
|
4928
|
+
});
|
|
4929
|
+
this._fileHandle = await import_lock_file.LockFile.acquire(this._lockPath);
|
|
4930
|
+
await this._onAcquire?.();
|
|
4931
|
+
(0, import_log14.log)("acquired lock", void 0, {
|
|
4932
|
+
F: __dxlog_file17,
|
|
4933
|
+
L: 37,
|
|
4934
|
+
S: this,
|
|
4935
|
+
C: (f, a) => f(...a)
|
|
4936
|
+
});
|
|
4937
|
+
}
|
|
4938
|
+
async release() {
|
|
4939
|
+
await this._onRelease?.();
|
|
4940
|
+
(0, import_invariant17.invariant)(this._fileHandle, "Lock is not acquired", {
|
|
4941
|
+
F: __dxlog_file17,
|
|
4942
|
+
L: 42,
|
|
4943
|
+
S: this,
|
|
4944
|
+
A: [
|
|
4945
|
+
"this._fileHandle",
|
|
4946
|
+
"'Lock is not acquired'"
|
|
4947
|
+
]
|
|
4948
|
+
});
|
|
4949
|
+
await import_lock_file.LockFile.release(this._fileHandle);
|
|
4950
|
+
}
|
|
4951
|
+
};
|
|
4952
|
+
_ts_decorate7([
|
|
4953
|
+
import_log14.logInfo
|
|
4954
|
+
], Lock.prototype, "lockKey", null);
|
|
4955
|
+
var isLocked = (lockPath) => import_lock_file.LockFile.isLocked(lockPath);
|
|
4990
4956
|
var LoggingServiceImpl = class {
|
|
4991
4957
|
constructor() {
|
|
4992
4958
|
this._logs = new import_async18.Event();
|
|
4993
4959
|
this._started = Date.now();
|
|
4994
|
-
this._sessionId =
|
|
4960
|
+
this._sessionId = import_keys12.PublicKey.random().toHex();
|
|
4995
4961
|
this._logProcessor = (_config, entry2) => {
|
|
4996
4962
|
this._logs.emit(entry2);
|
|
4997
4963
|
};
|
|
@@ -5088,16 +5054,16 @@ var LoggingServiceImpl = class {
|
|
|
5088
5054
|
};
|
|
5089
5055
|
var matchFilter = (filter, level, path2, options) => {
|
|
5090
5056
|
switch (options) {
|
|
5091
|
-
case
|
|
5057
|
+
case import_services16.QueryLogsRequest.MatchingOptions.INCLUSIVE:
|
|
5092
5058
|
return level >= filter.level && (!filter.pattern || path2.includes(filter.pattern));
|
|
5093
|
-
case
|
|
5059
|
+
case import_services16.QueryLogsRequest.MatchingOptions.EXPLICIT:
|
|
5094
5060
|
return level === filter.level && (!filter.pattern || path2.includes(filter.pattern));
|
|
5095
5061
|
}
|
|
5096
5062
|
};
|
|
5097
5063
|
var shouldLog = (entry2, request) => {
|
|
5098
|
-
const options = request.options ??
|
|
5064
|
+
const options = request.options ?? import_services16.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
5099
5065
|
if (request.filters === void 0) {
|
|
5100
|
-
return options ===
|
|
5066
|
+
return options === import_services16.QueryLogsRequest.MatchingOptions.INCLUSIVE;
|
|
5101
5067
|
} else {
|
|
5102
5068
|
return request.filters.some((filter) => matchFilter(filter, entry2.level, entry2.meta?.F ?? "", options));
|
|
5103
5069
|
}
|
|
@@ -5133,6 +5099,63 @@ var NetworkServiceImpl = class {
|
|
|
5133
5099
|
await this.networkManager.setConnectionState(request.swarm);
|
|
5134
5100
|
}
|
|
5135
5101
|
};
|
|
5102
|
+
var getRootPath = (config) => {
|
|
5103
|
+
const { dataRoot = (0, import_util11.isNode)() ? import_client_protocol5.DX_DATA : "dxos/storage" } = config ?? {};
|
|
5104
|
+
return `${dataRoot}/`;
|
|
5105
|
+
};
|
|
5106
|
+
var isPersistent = (config) => {
|
|
5107
|
+
const { persistent = false } = config ?? {};
|
|
5108
|
+
return config.dataStore !== void 0 && config.dataStore !== import_config3.Runtime.Client.Storage.StorageDriver.RAM || persistent;
|
|
5109
|
+
};
|
|
5110
|
+
var StorageDriver = import_config2.Runtime.Client.Storage.StorageDriver;
|
|
5111
|
+
var createStorageObjects = (config) => {
|
|
5112
|
+
const { persistent = false, keyStore, dataStore } = config ?? {};
|
|
5113
|
+
if (persistent && dataStore === StorageDriver.RAM) {
|
|
5114
|
+
throw new import_protocols15.InvalidConfigError("RAM storage cannot be used in persistent mode.");
|
|
5115
|
+
}
|
|
5116
|
+
if (!persistent && dataStore !== void 0 && dataStore !== StorageDriver.RAM) {
|
|
5117
|
+
throw new import_protocols15.InvalidConfigError("Cannot use a persistent storage in not persistent mode.");
|
|
5118
|
+
}
|
|
5119
|
+
if (persistent && keyStore === StorageDriver.RAM) {
|
|
5120
|
+
throw new import_protocols15.InvalidConfigError("RAM key storage cannot be used in persistent mode.");
|
|
5121
|
+
}
|
|
5122
|
+
if (!persistent && keyStore !== StorageDriver.RAM && keyStore !== void 0) {
|
|
5123
|
+
throw new import_protocols15.InvalidConfigError("Cannot use a persistent key storage in not persistent mode.");
|
|
5124
|
+
}
|
|
5125
|
+
return {
|
|
5126
|
+
storage: (0, import_random_access_storage.createStorage)({
|
|
5127
|
+
type: persistent ? toStorageType(dataStore) : import_random_access_storage.StorageType.RAM,
|
|
5128
|
+
root: getRootPath(config)
|
|
5129
|
+
})
|
|
5130
|
+
};
|
|
5131
|
+
};
|
|
5132
|
+
var toStorageType = (type) => {
|
|
5133
|
+
switch (type) {
|
|
5134
|
+
case void 0:
|
|
5135
|
+
return void 0;
|
|
5136
|
+
case StorageDriver.RAM:
|
|
5137
|
+
return import_random_access_storage.StorageType.RAM;
|
|
5138
|
+
case StorageDriver.CHROME:
|
|
5139
|
+
return import_random_access_storage.StorageType.CHROME;
|
|
5140
|
+
case StorageDriver.FIREFOX:
|
|
5141
|
+
return import_random_access_storage.StorageType.FIREFOX;
|
|
5142
|
+
case StorageDriver.IDB:
|
|
5143
|
+
return import_random_access_storage.StorageType.IDB;
|
|
5144
|
+
case StorageDriver.NODE:
|
|
5145
|
+
return import_random_access_storage.StorageType.NODE;
|
|
5146
|
+
case StorageDriver.WEBFS:
|
|
5147
|
+
return import_random_access_storage.StorageType.WEBFS;
|
|
5148
|
+
default:
|
|
5149
|
+
throw new Error(`Invalid storage type: ${StorageDriver[type]}`);
|
|
5150
|
+
}
|
|
5151
|
+
};
|
|
5152
|
+
var createLevel = async (config) => {
|
|
5153
|
+
const persistent = isPersistent(config);
|
|
5154
|
+
const storagePath = persistent ? getRootPath(config) : import_node_path.default.join("tmp", "level", import_keys13.PublicKey.random().toHex());
|
|
5155
|
+
const level = new import_level.Level(storagePath);
|
|
5156
|
+
await level.open();
|
|
5157
|
+
return level;
|
|
5158
|
+
};
|
|
5136
5159
|
var SystemServiceImpl = class {
|
|
5137
5160
|
constructor({ config, statusUpdate, getDiagnostics, onUpdateStatus, getCurrentStatus, onReset }) {
|
|
5138
5161
|
this._config = config;
|
|
@@ -5152,9 +5175,9 @@ var SystemServiceImpl = class {
|
|
|
5152
5175
|
const diagnostics = await this._getDiagnostics();
|
|
5153
5176
|
return {
|
|
5154
5177
|
timestamp: /* @__PURE__ */ new Date(),
|
|
5155
|
-
diagnostics: JSON.parse(JSON.stringify(diagnostics, (0,
|
|
5156
|
-
truncate: keys ===
|
|
5157
|
-
humanize: keys ===
|
|
5178
|
+
diagnostics: JSON.parse(JSON.stringify(diagnostics, (0, import_util12.jsonKeyReplacer)({
|
|
5179
|
+
truncate: keys === import_services17.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE,
|
|
5180
|
+
humanize: keys === import_services17.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE
|
|
5158
5181
|
})))
|
|
5159
5182
|
};
|
|
5160
5183
|
}
|
|
@@ -5207,7 +5230,7 @@ var ClientServicesHost = class {
|
|
|
5207
5230
|
callbacks,
|
|
5208
5231
|
runtimeParams
|
|
5209
5232
|
} = {}) {
|
|
5210
|
-
this._tracingService =
|
|
5233
|
+
this._tracingService = import_tracing8.TRACE_PROCESSOR.createTraceSender();
|
|
5211
5234
|
this._statusUpdate = new import_async16.Event();
|
|
5212
5235
|
this._opening = false;
|
|
5213
5236
|
this._open = false;
|
|
@@ -5235,14 +5258,14 @@ var ClientServicesHost = class {
|
|
|
5235
5258
|
this._systemService = new SystemServiceImpl({
|
|
5236
5259
|
config: () => this._config,
|
|
5237
5260
|
statusUpdate: this._statusUpdate,
|
|
5238
|
-
getCurrentStatus: () => this.isOpen ?
|
|
5261
|
+
getCurrentStatus: () => this.isOpen ? import_services14.SystemStatus.ACTIVE : import_services14.SystemStatus.INACTIVE,
|
|
5239
5262
|
getDiagnostics: () => {
|
|
5240
5263
|
return createDiagnostics(this._serviceRegistry.services, this._serviceContext, this._config);
|
|
5241
5264
|
},
|
|
5242
5265
|
onUpdateStatus: async (status) => {
|
|
5243
|
-
if (!this.isOpen && status ===
|
|
5266
|
+
if (!this.isOpen && status === import_services14.SystemStatus.ACTIVE) {
|
|
5244
5267
|
await this._resourceLock?.acquire();
|
|
5245
|
-
} else if (this.isOpen && status ===
|
|
5268
|
+
} else if (this.isOpen && status === import_services14.SystemStatus.INACTIVE) {
|
|
5246
5269
|
await this._resourceLock?.release();
|
|
5247
5270
|
}
|
|
5248
5271
|
},
|
|
@@ -5250,8 +5273,9 @@ var ClientServicesHost = class {
|
|
|
5250
5273
|
await this.reset();
|
|
5251
5274
|
}
|
|
5252
5275
|
});
|
|
5276
|
+
this.diagnosticsBroadcastHandler = createCollectDiagnosticsBroadcastHandler(this._systemService);
|
|
5253
5277
|
this._loggingService = new LoggingServiceImpl();
|
|
5254
|
-
this._serviceRegistry = new ServiceRegistry(
|
|
5278
|
+
this._serviceRegistry = new ServiceRegistry(import_client_protocol4.clientServiceBundle, {
|
|
5255
5279
|
SystemService: this._systemService,
|
|
5256
5280
|
TracingService: this._tracingService
|
|
5257
5281
|
});
|
|
@@ -5280,25 +5304,25 @@ var ClientServicesHost = class {
|
|
|
5280
5304
|
* Can only be called once.
|
|
5281
5305
|
*/
|
|
5282
5306
|
initialize({ config, ...options }) {
|
|
5283
|
-
(0,
|
|
5307
|
+
(0, import_invariant15.invariant)(!this._open, "service host is open", {
|
|
5284
5308
|
F: __dxlog_file18,
|
|
5285
|
-
L:
|
|
5309
|
+
L: 188,
|
|
5286
5310
|
S: this,
|
|
5287
5311
|
A: [
|
|
5288
5312
|
"!this._open",
|
|
5289
5313
|
"'service host is open'"
|
|
5290
5314
|
]
|
|
5291
5315
|
});
|
|
5292
|
-
(0,
|
|
5316
|
+
(0, import_log13.log)("initializing...", void 0, {
|
|
5293
5317
|
F: __dxlog_file18,
|
|
5294
|
-
L:
|
|
5318
|
+
L: 189,
|
|
5295
5319
|
S: this,
|
|
5296
5320
|
C: (f, a) => f(...a)
|
|
5297
5321
|
});
|
|
5298
5322
|
if (config) {
|
|
5299
|
-
(0,
|
|
5323
|
+
(0, import_invariant15.invariant)(!this._config, "config already set", {
|
|
5300
5324
|
F: __dxlog_file18,
|
|
5301
|
-
L:
|
|
5325
|
+
L: 192,
|
|
5302
5326
|
S: this,
|
|
5303
5327
|
A: [
|
|
5304
5328
|
"!this._config",
|
|
@@ -5311,9 +5335,9 @@ var ClientServicesHost = class {
|
|
|
5311
5335
|
}
|
|
5312
5336
|
}
|
|
5313
5337
|
if (!options.signalManager) {
|
|
5314
|
-
|
|
5338
|
+
import_log13.log.warn("running signaling without telemetry metadata.", void 0, {
|
|
5315
5339
|
F: __dxlog_file18,
|
|
5316
|
-
L:
|
|
5340
|
+
L: 200,
|
|
5317
5341
|
S: this,
|
|
5318
5342
|
C: (f, a) => f(...a)
|
|
5319
5343
|
});
|
|
@@ -5322,9 +5346,9 @@ var ClientServicesHost = class {
|
|
|
5322
5346
|
iceServers: this._config?.get("runtime.services.ice")
|
|
5323
5347
|
}), signalManager = new import_messaging.WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
|
|
5324
5348
|
this._signalManager = signalManager;
|
|
5325
|
-
(0,
|
|
5349
|
+
(0, import_invariant15.invariant)(!this._networkManager, "network manager already set", {
|
|
5326
5350
|
F: __dxlog_file18,
|
|
5327
|
-
L:
|
|
5351
|
+
L: 211,
|
|
5328
5352
|
S: this,
|
|
5329
5353
|
A: [
|
|
5330
5354
|
"!this._networkManager",
|
|
@@ -5336,9 +5360,9 @@ var ClientServicesHost = class {
|
|
|
5336
5360
|
transportFactory,
|
|
5337
5361
|
signalManager
|
|
5338
5362
|
});
|
|
5339
|
-
(0,
|
|
5363
|
+
(0, import_log13.log)("initialized", void 0, {
|
|
5340
5364
|
F: __dxlog_file18,
|
|
5341
|
-
L:
|
|
5365
|
+
L: 218,
|
|
5342
5366
|
S: this,
|
|
5343
5367
|
C: (f, a) => f(...a)
|
|
5344
5368
|
});
|
|
@@ -5347,45 +5371,45 @@ var ClientServicesHost = class {
|
|
|
5347
5371
|
if (this._open) {
|
|
5348
5372
|
return;
|
|
5349
5373
|
}
|
|
5350
|
-
const traceId =
|
|
5351
|
-
|
|
5374
|
+
const traceId = import_keys11.PublicKey.random().toHex();
|
|
5375
|
+
import_log13.log.trace("dxos.client-services.host.open", import_protocols14.trace.begin({
|
|
5352
5376
|
id: traceId
|
|
5353
5377
|
}), {
|
|
5354
5378
|
F: __dxlog_file18,
|
|
5355
|
-
L:
|
|
5379
|
+
L: 229,
|
|
5356
5380
|
S: this,
|
|
5357
5381
|
C: (f, a) => f(...a)
|
|
5358
5382
|
});
|
|
5359
|
-
(0,
|
|
5383
|
+
(0, import_invariant15.invariant)(this._config, "config not set", {
|
|
5360
5384
|
F: __dxlog_file18,
|
|
5361
|
-
L:
|
|
5385
|
+
L: 231,
|
|
5362
5386
|
S: this,
|
|
5363
5387
|
A: [
|
|
5364
5388
|
"this._config",
|
|
5365
5389
|
"'config not set'"
|
|
5366
5390
|
]
|
|
5367
5391
|
});
|
|
5368
|
-
(0,
|
|
5392
|
+
(0, import_invariant15.invariant)(this._storage, "storage not set", {
|
|
5369
5393
|
F: __dxlog_file18,
|
|
5370
|
-
L:
|
|
5394
|
+
L: 232,
|
|
5371
5395
|
S: this,
|
|
5372
5396
|
A: [
|
|
5373
5397
|
"this._storage",
|
|
5374
5398
|
"'storage not set'"
|
|
5375
5399
|
]
|
|
5376
5400
|
});
|
|
5377
|
-
(0,
|
|
5401
|
+
(0, import_invariant15.invariant)(this._signalManager, "signal manager not set", {
|
|
5378
5402
|
F: __dxlog_file18,
|
|
5379
|
-
L:
|
|
5403
|
+
L: 233,
|
|
5380
5404
|
S: this,
|
|
5381
5405
|
A: [
|
|
5382
5406
|
"this._signalManager",
|
|
5383
5407
|
"'signal manager not set'"
|
|
5384
5408
|
]
|
|
5385
5409
|
});
|
|
5386
|
-
(0,
|
|
5410
|
+
(0, import_invariant15.invariant)(this._networkManager, "network manager not set", {
|
|
5387
5411
|
F: __dxlog_file18,
|
|
5388
|
-
L:
|
|
5412
|
+
L: 234,
|
|
5389
5413
|
S: this,
|
|
5390
5414
|
A: [
|
|
5391
5415
|
"this._networkManager",
|
|
@@ -5393,11 +5417,11 @@ var ClientServicesHost = class {
|
|
|
5393
5417
|
]
|
|
5394
5418
|
});
|
|
5395
5419
|
this._opening = true;
|
|
5396
|
-
(0,
|
|
5420
|
+
(0, import_log13.log)("opening...", {
|
|
5397
5421
|
lockKey: this._resourceLock?.lockKey
|
|
5398
5422
|
}, {
|
|
5399
5423
|
F: __dxlog_file18,
|
|
5400
|
-
L:
|
|
5424
|
+
L: 237,
|
|
5401
5425
|
S: this,
|
|
5402
5426
|
C: (f, a) => f(...a)
|
|
5403
5427
|
});
|
|
@@ -5432,9 +5456,9 @@ var ClientServicesHost = class {
|
|
|
5432
5456
|
})
|
|
5433
5457
|
});
|
|
5434
5458
|
await this._serviceContext.open(ctx);
|
|
5435
|
-
(0,
|
|
5459
|
+
(0, import_invariant15.invariant)(this.serviceRegistry.services.InvitationsService, void 0, {
|
|
5436
5460
|
F: __dxlog_file18,
|
|
5437
|
-
L:
|
|
5461
|
+
L: 303,
|
|
5438
5462
|
S: this,
|
|
5439
5463
|
A: [
|
|
5440
5464
|
"this.serviceRegistry.services.InvitationsService",
|
|
@@ -5442,11 +5466,11 @@ var ClientServicesHost = class {
|
|
|
5442
5466
|
]
|
|
5443
5467
|
});
|
|
5444
5468
|
const loadedInvitations = await this.serviceRegistry.services.InvitationsService.loadPersistentInvitations();
|
|
5445
|
-
(0,
|
|
5469
|
+
(0, import_log13.log)("loaded persistent invitations", {
|
|
5446
5470
|
count: loadedInvitations.invitations?.length
|
|
5447
5471
|
}, {
|
|
5448
5472
|
F: __dxlog_file18,
|
|
5449
|
-
L:
|
|
5473
|
+
L: 306,
|
|
5450
5474
|
S: this,
|
|
5451
5475
|
C: (f, a) => f(...a)
|
|
5452
5476
|
});
|
|
@@ -5455,28 +5479,29 @@ var ClientServicesHost = class {
|
|
|
5455
5479
|
this._devtoolsProxy = new import_websocket_rpc.WebsocketRpcClient({
|
|
5456
5480
|
url: devtoolsProxy,
|
|
5457
5481
|
requested: {},
|
|
5458
|
-
exposed:
|
|
5482
|
+
exposed: import_client_protocol4.clientServiceBundle,
|
|
5459
5483
|
handlers: this.services
|
|
5460
5484
|
});
|
|
5461
5485
|
void this._devtoolsProxy.open();
|
|
5462
5486
|
}
|
|
5487
|
+
this.diagnosticsBroadcastHandler.start();
|
|
5463
5488
|
this._opening = false;
|
|
5464
5489
|
this._open = true;
|
|
5465
5490
|
this._statusUpdate.emit();
|
|
5466
5491
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
5467
|
-
(0,
|
|
5492
|
+
(0, import_log13.log)("opened", {
|
|
5468
5493
|
deviceKey
|
|
5469
5494
|
}, {
|
|
5470
5495
|
F: __dxlog_file18,
|
|
5471
|
-
L:
|
|
5496
|
+
L: 324,
|
|
5472
5497
|
S: this,
|
|
5473
5498
|
C: (f, a) => f(...a)
|
|
5474
5499
|
});
|
|
5475
|
-
|
|
5500
|
+
import_log13.log.trace("dxos.client-services.host.open", import_protocols14.trace.end({
|
|
5476
5501
|
id: traceId
|
|
5477
5502
|
}), {
|
|
5478
5503
|
F: __dxlog_file18,
|
|
5479
|
-
L:
|
|
5504
|
+
L: 325,
|
|
5480
5505
|
S: this,
|
|
5481
5506
|
C: (f, a) => f(...a)
|
|
5482
5507
|
});
|
|
@@ -5486,14 +5511,15 @@ var ClientServicesHost = class {
|
|
|
5486
5511
|
return;
|
|
5487
5512
|
}
|
|
5488
5513
|
const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
|
|
5489
|
-
(0,
|
|
5514
|
+
(0, import_log13.log)("closing...", {
|
|
5490
5515
|
deviceKey
|
|
5491
5516
|
}, {
|
|
5492
5517
|
F: __dxlog_file18,
|
|
5493
|
-
L:
|
|
5518
|
+
L: 336,
|
|
5494
5519
|
S: this,
|
|
5495
5520
|
C: (f, a) => f(...a)
|
|
5496
5521
|
});
|
|
5522
|
+
this.diagnosticsBroadcastHandler.stop();
|
|
5497
5523
|
await this._devtoolsProxy?.close();
|
|
5498
5524
|
this._serviceRegistry.setServices({
|
|
5499
5525
|
SystemService: this._systemService
|
|
@@ -5503,44 +5529,44 @@ var ClientServicesHost = class {
|
|
|
5503
5529
|
await this._level?.close();
|
|
5504
5530
|
this._open = false;
|
|
5505
5531
|
this._statusUpdate.emit();
|
|
5506
|
-
(0,
|
|
5532
|
+
(0, import_log13.log)("closed", {
|
|
5507
5533
|
deviceKey
|
|
5508
5534
|
}, {
|
|
5509
5535
|
F: __dxlog_file18,
|
|
5510
|
-
L:
|
|
5536
|
+
L: 345,
|
|
5511
5537
|
S: this,
|
|
5512
5538
|
C: (f, a) => f(...a)
|
|
5513
5539
|
});
|
|
5514
5540
|
}
|
|
5515
5541
|
async reset() {
|
|
5516
|
-
const traceId =
|
|
5517
|
-
|
|
5542
|
+
const traceId = import_keys11.PublicKey.random().toHex();
|
|
5543
|
+
import_log13.log.trace("dxos.sdk.client-services-host.reset", import_protocols14.trace.begin({
|
|
5518
5544
|
id: traceId
|
|
5519
5545
|
}), {
|
|
5520
5546
|
F: __dxlog_file18,
|
|
5521
|
-
L:
|
|
5547
|
+
L: 350,
|
|
5522
5548
|
S: this,
|
|
5523
5549
|
C: (f, a) => f(...a)
|
|
5524
5550
|
});
|
|
5525
|
-
(0,
|
|
5551
|
+
(0, import_log13.log)("resetting...", void 0, {
|
|
5526
5552
|
F: __dxlog_file18,
|
|
5527
|
-
L:
|
|
5553
|
+
L: 352,
|
|
5528
5554
|
S: this,
|
|
5529
5555
|
C: (f, a) => f(...a)
|
|
5530
5556
|
});
|
|
5531
5557
|
await this._serviceContext?.close();
|
|
5532
5558
|
await this._storage.reset();
|
|
5533
|
-
(0,
|
|
5559
|
+
(0, import_log13.log)("reset", void 0, {
|
|
5534
5560
|
F: __dxlog_file18,
|
|
5535
|
-
L:
|
|
5561
|
+
L: 355,
|
|
5536
5562
|
S: this,
|
|
5537
5563
|
C: (f, a) => f(...a)
|
|
5538
5564
|
});
|
|
5539
|
-
|
|
5565
|
+
import_log13.log.trace("dxos.sdk.client-services-host.reset", import_protocols14.trace.end({
|
|
5540
5566
|
id: traceId
|
|
5541
5567
|
}), {
|
|
5542
5568
|
F: __dxlog_file18,
|
|
5543
|
-
L:
|
|
5569
|
+
L: 356,
|
|
5544
5570
|
S: this,
|
|
5545
5571
|
C: (f, a) => f(...a)
|
|
5546
5572
|
});
|
|
@@ -5551,9 +5577,9 @@ var ClientServicesHost = class {
|
|
|
5551
5577
|
await this._serviceContext.initialized.wait();
|
|
5552
5578
|
const space = await this._serviceContext.dataSpaceManager.createSpace();
|
|
5553
5579
|
const automergeIndex = space.automergeSpaceState.rootUrl;
|
|
5554
|
-
(0,
|
|
5580
|
+
(0, import_invariant15.invariant)(automergeIndex, void 0, {
|
|
5555
5581
|
F: __dxlog_file18,
|
|
5556
|
-
L:
|
|
5582
|
+
L: 368,
|
|
5557
5583
|
S: this,
|
|
5558
5584
|
A: [
|
|
5559
5585
|
"automergeIndex",
|
|
@@ -5564,16 +5590,16 @@ var ClientServicesHost = class {
|
|
|
5564
5590
|
await document.whenReady();
|
|
5565
5591
|
const properties = {
|
|
5566
5592
|
system: {
|
|
5567
|
-
type: (0, import_echo_pipeline4.encodeReference)(E.getTypeReference(
|
|
5593
|
+
type: (0, import_echo_pipeline4.encodeReference)(E.getTypeReference(import_client_protocol4.Properties))
|
|
5568
5594
|
},
|
|
5569
5595
|
data: {
|
|
5570
|
-
[
|
|
5596
|
+
[import_client_protocol4.defaultKey]: identity.identityKey.toHex()
|
|
5571
5597
|
},
|
|
5572
5598
|
meta: {
|
|
5573
5599
|
keys: []
|
|
5574
5600
|
}
|
|
5575
5601
|
};
|
|
5576
|
-
const propertiesId =
|
|
5602
|
+
const propertiesId = import_keys11.PublicKey.random().toHex();
|
|
5577
5603
|
document.change((doc) => {
|
|
5578
5604
|
(0, import_util9.assignDeep)(doc, [
|
|
5579
5605
|
"objects",
|
|
@@ -5585,31 +5611,65 @@ var ClientServicesHost = class {
|
|
|
5585
5611
|
}
|
|
5586
5612
|
};
|
|
5587
5613
|
_ts_decorate8([
|
|
5588
|
-
|
|
5614
|
+
import_tracing8.trace.info()
|
|
5589
5615
|
], ClientServicesHost.prototype, "_opening", void 0);
|
|
5590
5616
|
_ts_decorate8([
|
|
5591
|
-
|
|
5617
|
+
import_tracing8.trace.info()
|
|
5592
5618
|
], ClientServicesHost.prototype, "_open", void 0);
|
|
5593
5619
|
_ts_decorate8([
|
|
5594
5620
|
import_async16.synchronized,
|
|
5595
|
-
|
|
5621
|
+
import_tracing8.trace.span()
|
|
5596
5622
|
], ClientServicesHost.prototype, "open", null);
|
|
5597
5623
|
_ts_decorate8([
|
|
5598
5624
|
import_async16.synchronized,
|
|
5599
|
-
|
|
5625
|
+
import_tracing8.trace.span()
|
|
5600
5626
|
], ClientServicesHost.prototype, "close", null);
|
|
5601
5627
|
ClientServicesHost = _ts_decorate8([
|
|
5602
|
-
|
|
5628
|
+
import_tracing8.trace.resource()
|
|
5603
5629
|
], ClientServicesHost);
|
|
5630
|
+
var ClientServicesProviderResource = Symbol.for("dxos.resource.ClientServices");
|
|
5631
|
+
var DiagnosticsCollector = class {
|
|
5632
|
+
static {
|
|
5633
|
+
this.broadcastSender = createCollectDiagnosticsBroadcastSender();
|
|
5634
|
+
}
|
|
5635
|
+
static async collect(config = findConfigs(), services = findSystemServiceProvider(), options = {}) {
|
|
5636
|
+
const serviceDiagnostics = await services?.services?.SystemService?.getDiagnostics({
|
|
5637
|
+
keys: options.humanize ? import_services13.GetDiagnosticsRequest.KEY_OPTION.HUMANIZE : options.truncate ? import_services13.GetDiagnosticsRequest.KEY_OPTION.TRUNCATE : void 0
|
|
5638
|
+
});
|
|
5639
|
+
const clientDiagnostics = {
|
|
5640
|
+
config,
|
|
5641
|
+
trace: import_tracing7.TRACE_PROCESSOR.getDiagnostics()
|
|
5642
|
+
};
|
|
5643
|
+
const diagnostics = serviceDiagnostics != null ? {
|
|
5644
|
+
client: clientDiagnostics,
|
|
5645
|
+
services: serviceDiagnostics
|
|
5646
|
+
} : {
|
|
5647
|
+
client: clientDiagnostics,
|
|
5648
|
+
broadcast: await this.broadcastSender.broadcastDiagnosticsRequest()
|
|
5649
|
+
};
|
|
5650
|
+
return JSON.parse(JSON.stringify(diagnostics, (0, import_util8.jsonKeyReplacer)(options)));
|
|
5651
|
+
}
|
|
5652
|
+
};
|
|
5653
|
+
var findSystemServiceProvider = () => {
|
|
5654
|
+
const serviceProviders = import_tracing7.TRACE_PROCESSOR.findByAnnotation(ClientServicesProviderResource);
|
|
5655
|
+
const providerResource = serviceProviders.find((r) => r.instance.deref()?.services?.SystemService != null);
|
|
5656
|
+
return providerResource?.instance?.deref() ?? null;
|
|
5657
|
+
};
|
|
5658
|
+
var findConfigs = () => {
|
|
5659
|
+
const configs = import_tracing7.TRACE_PROCESSOR.findByAnnotation(import_config.ConfigResource);
|
|
5660
|
+
return configs.map((r) => r.instance.deref()).filter(import_util8.nonNullable);
|
|
5661
|
+
};
|
|
5604
5662
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5605
5663
|
0 && (module.exports = {
|
|
5606
5664
|
ClientRpcServer,
|
|
5607
5665
|
ClientServicesHost,
|
|
5666
|
+
ClientServicesProviderResource,
|
|
5608
5667
|
DataSpace,
|
|
5609
5668
|
DataSpaceManager,
|
|
5610
5669
|
DeviceInvitationProtocol,
|
|
5611
5670
|
DevtoolsHostEvents,
|
|
5612
5671
|
DevtoolsServiceImpl,
|
|
5672
|
+
DiagnosticsCollector,
|
|
5613
5673
|
Identity,
|
|
5614
5674
|
IdentityManager,
|
|
5615
5675
|
IdentityServiceImpl,
|
|
@@ -5622,6 +5682,8 @@ ClientServicesHost = _ts_decorate8([
|
|
|
5622
5682
|
SpacesServiceImpl,
|
|
5623
5683
|
TrustedKeySetAuthVerifier,
|
|
5624
5684
|
createAuthProvider,
|
|
5685
|
+
createCollectDiagnosticsBroadcastHandler,
|
|
5686
|
+
createCollectDiagnosticsBroadcastSender,
|
|
5625
5687
|
createDiagnostics,
|
|
5626
5688
|
createLevel,
|
|
5627
5689
|
createStorageObjects,
|
|
@@ -5636,4 +5698,4 @@ ClientServicesHost = _ts_decorate8([
|
|
|
5636
5698
|
subscribeToSpaces,
|
|
5637
5699
|
subscribeToSwarmInfo
|
|
5638
5700
|
});
|
|
5639
|
-
//# sourceMappingURL=chunk-
|
|
5701
|
+
//# sourceMappingURL=chunk-54K33CLU.cjs.map
|