@ztimson/momentum 1.4.1 → 1.4.3
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/actions.d.ts +5 -1
- package/dist/actions.d.ts.map +1 -1
- package/dist/asset-controller.d.ts.map +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.d.ts.map +1 -1
- package/dist/data.d.ts +50 -29
- package/dist/data.d.ts.map +1 -1
- package/dist/index.js +100 -95
- package/dist/index.mjs +100 -95
- package/dist/sockets.d.ts +4 -4
- package/dist/sockets.d.ts.map +1 -1
- package/dist/storage.d.ts +7 -8
- package/dist/storage.d.ts.map +1 -1
- package/dist/webRtc.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/actions.d.ts
CHANGED
|
@@ -72,6 +72,10 @@ export type ActionResult = {
|
|
|
72
72
|
readonly response?: any;
|
|
73
73
|
/** Action return value */
|
|
74
74
|
readonly return?: any;
|
|
75
|
+
/** Captured HTTP headers (REST actions only) */
|
|
76
|
+
readonly headers?: Record<string, any>;
|
|
77
|
+
/** HTTP status code (REST actions only) */
|
|
78
|
+
readonly statusCode?: number;
|
|
75
79
|
};
|
|
76
80
|
/** Action triggers - Ordered to optimize filtering */
|
|
77
81
|
export declare enum ActionType {
|
|
@@ -99,7 +103,7 @@ export declare class Actions extends AssetController<Action> {
|
|
|
99
103
|
/**
|
|
100
104
|
* Manually trigger an actions execution with real-time updates
|
|
101
105
|
* @param {string} id Action ID
|
|
102
|
-
* @param {(payload:
|
|
106
|
+
* @param {(payload: ActionResult) => any} callback Get updates in real time
|
|
103
107
|
* @param {HttpRequestOptions} opts Additional arguments
|
|
104
108
|
* @return {Promise<string>} Run UID for socket subscription
|
|
105
109
|
*/
|
package/dist/actions.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAY,M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CACxB,CAAC;AAEF,OAAO,EAAC,KAAK,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAEhD,wBAAgB,WAAW,CAAC,CAAC,SAAS;IAAC,IAAI,EAAE,MAAM,CAAA;CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC,EAAE,CA0CjF;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,WAMvC"}
|
package/dist/data.d.ts
CHANGED
|
@@ -13,6 +13,24 @@ export type Filter<T = any> = {
|
|
|
13
13
|
};
|
|
14
14
|
/** Generic MongoDB document */
|
|
15
15
|
export type Document<T> = Meta & T;
|
|
16
|
+
/** Read query options */
|
|
17
|
+
export type ReadOptions = {
|
|
18
|
+
limit?: number;
|
|
19
|
+
page?: number;
|
|
20
|
+
sortBy?: string;
|
|
21
|
+
sortDir?: 'asc' | 'desc';
|
|
22
|
+
};
|
|
23
|
+
/** Delete query options */
|
|
24
|
+
export type DeleteOptions = {
|
|
25
|
+
limit?: number;
|
|
26
|
+
};
|
|
27
|
+
/** Update query options */
|
|
28
|
+
export type UpdateOptions<T = any> = {
|
|
29
|
+
filter?: Filter<T>;
|
|
30
|
+
append?: boolean;
|
|
31
|
+
limit?: number;
|
|
32
|
+
upsert?: boolean;
|
|
33
|
+
};
|
|
16
34
|
/** Raw MongoDB query */
|
|
17
35
|
export type RawQuery = {
|
|
18
36
|
/** Query operation type */
|
|
@@ -33,53 +51,56 @@ export declare class Data extends PathEventEmitter {
|
|
|
33
51
|
[key: string]: Unsubscribe;
|
|
34
52
|
};
|
|
35
53
|
constructor(momentum: Momentum);
|
|
54
|
+
protected dataUrl(collection: string, pk?: number, filter?: any, options?: {
|
|
55
|
+
[key: string]: any;
|
|
56
|
+
}): string;
|
|
36
57
|
/**
|
|
37
|
-
* Create new document in collection
|
|
58
|
+
* Create new document(s) in collection
|
|
38
59
|
* @param {string} collection Target collection
|
|
39
|
-
* @param {Document<T>}
|
|
40
|
-
* @return {Promise<Document<T
|
|
60
|
+
* @param {Document<T> | Document<T>[]} documents New document(s)
|
|
61
|
+
* @return {Promise<Document<T> | Document<T>[]>} New saved document(s)
|
|
41
62
|
*/
|
|
42
|
-
create<T>(collection: string,
|
|
63
|
+
create<T>(collection: string, documents: Document<T> | Document<T>[]): Promise<Document<T> | Document<T>[]>;
|
|
43
64
|
/**
|
|
44
|
-
* Delete document from collection
|
|
65
|
+
* Delete document(s) from collection
|
|
45
66
|
* @param {string} collection Target collection
|
|
46
|
-
* @param {number}
|
|
47
|
-
* @
|
|
67
|
+
* @param {number | Filter<T>} filter Document ID or filter object
|
|
68
|
+
* @param {DeleteOptions} options Delete options
|
|
69
|
+
* @return {Promise<number[]>} Array of deleted document IDs
|
|
48
70
|
*/
|
|
49
|
-
delete(collection: string, id: number): Promise<number[]>;
|
|
50
|
-
delete<T>(collection: string, filter: Filter<T
|
|
71
|
+
delete(collection: string, id: number, options?: DeleteOptions): Promise<number[]>;
|
|
72
|
+
delete<T>(collection: string, filter: Filter<T>, options?: DeleteOptions): Promise<number[]>;
|
|
51
73
|
/**
|
|
52
|
-
* Read collection
|
|
53
|
-
* @param {string} collection
|
|
54
|
-
* @
|
|
74
|
+
* Read document(s) from collection
|
|
75
|
+
* @param {string} collection Target collection
|
|
76
|
+
* @param {number | Filter<T>} filter Document ID or filter object
|
|
77
|
+
* @param {ReadOptions} options Read options (limit, page, sortBy, sortDir)
|
|
78
|
+
* @return {Promise<T | T[]>} Single document if ID provided, array of documents if filter or no filter provided
|
|
55
79
|
*/
|
|
56
|
-
read<T extends Meta>(collection: string): Promise<T[]>;
|
|
57
|
-
read<T extends Meta>(collection: string,
|
|
58
|
-
read<T extends Meta>(collection: string, filter
|
|
80
|
+
read<T extends Meta>(collection: string, filter?: undefined, options?: ReadOptions): Promise<T[]>;
|
|
81
|
+
read<T extends Meta>(collection: string, filter?: number, options?: ReadOptions): Promise<T>;
|
|
82
|
+
read<T extends Meta>(collection: string, filter?: Filter<T>, options?: ReadOptions): Promise<T[]>;
|
|
59
83
|
/**
|
|
60
|
-
* Update document in collection
|
|
84
|
+
* Update document(s) in collection
|
|
61
85
|
* @param {string} collection Target collection
|
|
62
|
-
* @param {Document<T>}
|
|
63
|
-
* @param {
|
|
86
|
+
* @param {Document<T> | Document<T>[]} documents Document(s) to update
|
|
87
|
+
* @param {UpdateOptions<T>} options Update options (filter, append, limit, upsert)
|
|
64
88
|
* @return {Promise<Document<T> | Document<T>[]>} Updated document(s)
|
|
65
89
|
*/
|
|
66
|
-
update<T>(collection: string,
|
|
67
|
-
filter?: Filter<T>;
|
|
68
|
-
append?: boolean;
|
|
69
|
-
}): Promise<Document<T> | Document<T>[]>;
|
|
90
|
+
update<T>(collection: string, documents: Document<T> | Document<T>[], options?: UpdateOptions<T>): Promise<Document<T> | Document<T>[]>;
|
|
70
91
|
/**
|
|
71
|
-
*
|
|
92
|
+
* Execute raw MongoDB query
|
|
72
93
|
* @param {string} collection Target collection name
|
|
73
|
-
* @param {RawQuery} query Raw query
|
|
94
|
+
* @param {RawQuery} query Raw MongoDB query object
|
|
74
95
|
* @return {Promise<any>} Query response
|
|
75
96
|
*/
|
|
76
97
|
raw<T>(collection: string, query: RawQuery): Promise<any>;
|
|
77
98
|
/**
|
|
78
|
-
* Subscribe to live updates
|
|
79
|
-
* @param path
|
|
80
|
-
* @param {(value: T[]) => any
|
|
81
|
-
* @param opts
|
|
82
|
-
* @return {
|
|
99
|
+
* Subscribe to live data updates
|
|
100
|
+
* @param {string} path Data path to subscribe to
|
|
101
|
+
* @param {(value: T | T[]) => any} callback Function called with updated data
|
|
102
|
+
* @param {object} opts Options object with reload flag
|
|
103
|
+
* @return {Unsubscribe} Function to unsubscribe from updates
|
|
83
104
|
*/
|
|
84
105
|
sync<T>(path: string, callback: ((value: T | T[]) => any), opts?: {
|
|
85
106
|
reload?: boolean;
|
package/dist/data.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data.d.ts","sourceRo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AG,CAAC;IASzD;;;;;;OAMG;IACH,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,IAAI,GAAE;QAAC,MAAM,CAAC,EAAE,OAAO,CAAA;KAAM,GAAG,WAAW;CAmBtG"}
|
package/dist/index.js
CHANGED
|
@@ -1721,11 +1721,11 @@
|
|
|
1721
1721
|
this.opts.storage = { storage: momentum.database, key: "_" + this.opts.module };
|
|
1722
1722
|
this.cache = new Cache("_id", { persistentStorage: this.opts.storage });
|
|
1723
1723
|
this.momentum.auth.on("login:d", (e) => this.cache.clear());
|
|
1724
|
-
this.on(this.opts.module, (event, payload) => {
|
|
1725
|
-
if (Array.isArray(payload)) {
|
|
1724
|
+
this.on(this.opts.module + ":crud", (event, payload) => {
|
|
1725
|
+
if (!event.path && Array.isArray(payload)) {
|
|
1726
1726
|
this.cache.addAll(payload);
|
|
1727
1727
|
} else if ((event.create || event.update || event.read) && payload != null) {
|
|
1728
|
-
this.cache.add(
|
|
1728
|
+
makeArray(payload).forEach((p) => this.cache.add(p));
|
|
1729
1729
|
} else if (event.delete || payload == null) {
|
|
1730
1730
|
if (!event.path) return this.cache.clear();
|
|
1731
1731
|
const id = this.opts.key == "_id" ? event.name : this.cache.find({ [this.opts.key]: event.path })?._id;
|
|
@@ -1885,18 +1885,17 @@
|
|
|
1885
1885
|
/**
|
|
1886
1886
|
* Manually trigger an actions execution with real-time updates
|
|
1887
1887
|
* @param {string} id Action ID
|
|
1888
|
-
* @param {(payload:
|
|
1888
|
+
* @param {(payload: ActionResult) => any} callback Get updates in real time
|
|
1889
1889
|
* @param {HttpRequestOptions} opts Additional arguments
|
|
1890
1890
|
* @return {Promise<string>} Run UID for socket subscription
|
|
1891
1891
|
*/
|
|
1892
1892
|
async debug(id, callback, opts = {}) {
|
|
1893
1893
|
const uid = await this.momentum.api.request({ url: `api/actions/debug/${id}`, method: "POST", ...opts }).then((resp) => resp.uid);
|
|
1894
1894
|
if (!this.momentum.socket || !callback) return uid;
|
|
1895
|
-
const unsubscribe = this.momentum.socket.
|
|
1895
|
+
const unsubscribe = this.momentum.socket.subscribe(`actions/${id}/${uid}:x`, (event, payload) => {
|
|
1896
1896
|
if (payload.return) unsubscribe();
|
|
1897
1897
|
callback(payload);
|
|
1898
1898
|
});
|
|
1899
|
-
await this.momentum.socket.subscribe(`actions-debug/${uid}`);
|
|
1900
1899
|
return uid;
|
|
1901
1900
|
}
|
|
1902
1901
|
/**
|
|
@@ -1914,7 +1913,7 @@
|
|
|
1914
1913
|
* @return {Promise<T>} HTTP response
|
|
1915
1914
|
*/
|
|
1916
1915
|
run(path, opts = {}) {
|
|
1917
|
-
return this.momentum.api.request({ ...opts, url: `api/
|
|
1916
|
+
return this.momentum.api.request({ ...opts, url: `api${path.startsWith("/") ? "" : "/"}${path}` });
|
|
1918
1917
|
}
|
|
1919
1918
|
}
|
|
1920
1919
|
class Agents extends AssetController {
|
|
@@ -3197,42 +3196,51 @@ Must be either: call, email or sms`);
|
|
|
3197
3196
|
}
|
|
3198
3197
|
momentum;
|
|
3199
3198
|
subscribers = {};
|
|
3199
|
+
dataUrl(collection, pk, filter, options) {
|
|
3200
|
+
const params = new URLSearchParams();
|
|
3201
|
+
if (filter) params.set("q", JSON.stringify(filter));
|
|
3202
|
+
Object.entries(options ?? {}).forEach(([key, value]) => {
|
|
3203
|
+
if (value !== void 0 && value !== null) params.set(key, String(value));
|
|
3204
|
+
});
|
|
3205
|
+
const query = params.toString();
|
|
3206
|
+
return `api/data/${collection}${pk != null ? `/${pk}` : ""}${query ? `?${query}` : ""}`;
|
|
3207
|
+
}
|
|
3200
3208
|
/**
|
|
3201
|
-
* Create new document in collection
|
|
3209
|
+
* Create new document(s) in collection
|
|
3202
3210
|
* @param {string} collection Target collection
|
|
3203
|
-
* @param {Document<T>}
|
|
3204
|
-
* @return {Promise<Document<T
|
|
3211
|
+
* @param {Document<T> | Document<T>[]} documents New document(s)
|
|
3212
|
+
* @return {Promise<Document<T> | Document<T>[]>} New saved document(s)
|
|
3205
3213
|
*/
|
|
3206
|
-
create(collection,
|
|
3207
|
-
if (!collection || !
|
|
3214
|
+
create(collection, documents) {
|
|
3215
|
+
if (!collection || !documents) throw new Error("Cannot create document, missing collection or document");
|
|
3208
3216
|
return this.momentum.api.request({
|
|
3209
3217
|
url: `api/` + PES`data/${collection}`,
|
|
3210
3218
|
method: "POST",
|
|
3211
|
-
body:
|
|
3219
|
+
body: documents
|
|
3212
3220
|
}).then((resp) => {
|
|
3213
3221
|
if (!resp) return null;
|
|
3214
|
-
this.emit(PES`data/${collection}:c`,
|
|
3222
|
+
makeArray(resp).forEach((r) => this.emit(PES`data/${collection}/${r._id}:c`, r));
|
|
3215
3223
|
return resp;
|
|
3216
3224
|
});
|
|
3217
3225
|
}
|
|
3218
|
-
async delete(collection, filter) {
|
|
3219
|
-
if (!collection ||
|
|
3220
|
-
const pk = typeof filter == "object" ? filter?.
|
|
3221
|
-
const q = typeof filter == "object" ?
|
|
3222
|
-
const url =
|
|
3226
|
+
async delete(collection, filter, options) {
|
|
3227
|
+
if (!collection || filter == null) throw new Error("Cannot delete document, missing collection or filter");
|
|
3228
|
+
const pk = typeof filter == "object" ? filter?._id ?? null : filter;
|
|
3229
|
+
const q = typeof filter == "object" && pk == null ? filter : null;
|
|
3230
|
+
const url = this.dataUrl(collection, pk, q, options);
|
|
3223
3231
|
const ids = await this.momentum.api.request({ url, method: "DELETE" });
|
|
3224
3232
|
ids.forEach((id) => this.emit(PES`data/${collection}/${id}:d`, id));
|
|
3225
3233
|
return ids;
|
|
3226
3234
|
}
|
|
3227
|
-
read(collection, filter) {
|
|
3235
|
+
read(collection, filter, options) {
|
|
3228
3236
|
if (!collection) throw new Error("Cannot read documents, missing collection");
|
|
3229
3237
|
const pk = typeof filter == "object" ? filter?.["_id"] ?? null : filter;
|
|
3230
|
-
const q = typeof filter == "object"
|
|
3231
|
-
const url =
|
|
3238
|
+
const q = typeof filter == "object" && filter != null && Object.keys(filter).length && pk == null ? filter : null;
|
|
3239
|
+
const url = this.dataUrl(collection, pk, q, options);
|
|
3232
3240
|
return this.momentum.api.request({ url }).then((resp) => {
|
|
3233
3241
|
if (!resp) return null;
|
|
3234
3242
|
if (Array.isArray(resp)) {
|
|
3235
|
-
if (!q) this.emit(PES`data/${collection}:r`, collection, resp);
|
|
3243
|
+
if (!q && !options?.limit) this.emit(PES`data/${collection}:r`, collection, resp);
|
|
3236
3244
|
else resp.forEach((r) => this.emit(PES`data/${collection}/${r._id}:r`, collection, resp));
|
|
3237
3245
|
} else {
|
|
3238
3246
|
this.emit(PES`data/${collection}/${resp._id}:r`, collection, resp);
|
|
@@ -3241,32 +3249,34 @@ Must be either: call, email or sms`);
|
|
|
3241
3249
|
});
|
|
3242
3250
|
}
|
|
3243
3251
|
/**
|
|
3244
|
-
* Update document in collection
|
|
3252
|
+
* Update document(s) in collection
|
|
3245
3253
|
* @param {string} collection Target collection
|
|
3246
|
-
* @param {Document<T>}
|
|
3247
|
-
* @param {
|
|
3254
|
+
* @param {Document<T> | Document<T>[]} documents Document(s) to update
|
|
3255
|
+
* @param {UpdateOptions<T>} options Update options (filter, append, limit, upsert)
|
|
3248
3256
|
* @return {Promise<Document<T> | Document<T>[]>} Updated document(s)
|
|
3249
3257
|
*/
|
|
3250
|
-
update(collection,
|
|
3251
|
-
if (!collection || !
|
|
3252
|
-
const
|
|
3253
|
-
const
|
|
3254
|
-
const
|
|
3258
|
+
update(collection, documents, options = {}) {
|
|
3259
|
+
if (!collection || !documents) throw new Error("Cannot update document, missing collection or document");
|
|
3260
|
+
const { filter, append, ...queryOptions } = options;
|
|
3261
|
+
const isArray = Array.isArray(documents);
|
|
3262
|
+
const firstDoc = isArray ? documents[0] : documents;
|
|
3263
|
+
const pk = isArray ? null : filter ? filter?._id ?? firstDoc._id : firstDoc._id;
|
|
3264
|
+
const q = filter && filter?._id == null ? filter : null;
|
|
3265
|
+
const url = this.dataUrl(collection, pk, q, queryOptions);
|
|
3255
3266
|
return this.momentum.api.request({
|
|
3256
3267
|
url,
|
|
3257
|
-
method:
|
|
3258
|
-
body:
|
|
3268
|
+
method: append === false ? "PUT" : "PATCH",
|
|
3269
|
+
body: documents
|
|
3259
3270
|
}).then((resp) => {
|
|
3260
3271
|
if (!resp) return null;
|
|
3261
|
-
|
|
3262
|
-
else this.emit(PES`data/${collection}/${resp._id}:u`, resp);
|
|
3272
|
+
makeArray(resp).forEach((r) => this.emit(PES`data/${collection}/${r._id}:u`, r));
|
|
3263
3273
|
return resp;
|
|
3264
3274
|
});
|
|
3265
3275
|
}
|
|
3266
3276
|
/**
|
|
3267
|
-
*
|
|
3277
|
+
* Execute raw MongoDB query
|
|
3268
3278
|
* @param {string} collection Target collection name
|
|
3269
|
-
* @param {RawQuery} query Raw query
|
|
3279
|
+
* @param {RawQuery} query Raw MongoDB query object
|
|
3270
3280
|
* @return {Promise<any>} Query response
|
|
3271
3281
|
*/
|
|
3272
3282
|
raw(collection, query) {
|
|
@@ -3278,11 +3288,11 @@ Must be either: call, email or sms`);
|
|
|
3278
3288
|
});
|
|
3279
3289
|
}
|
|
3280
3290
|
/**
|
|
3281
|
-
* Subscribe to live updates
|
|
3282
|
-
* @param path
|
|
3283
|
-
* @param {(value: T[]) => any
|
|
3284
|
-
* @param opts
|
|
3285
|
-
* @return {
|
|
3291
|
+
* Subscribe to live data updates
|
|
3292
|
+
* @param {string} path Data path to subscribe to
|
|
3293
|
+
* @param {(value: T | T[]) => any} callback Function called with updated data
|
|
3294
|
+
* @param {object} opts Options object with reload flag
|
|
3295
|
+
* @return {Unsubscribe} Function to unsubscribe from updates
|
|
3286
3296
|
*/
|
|
3287
3297
|
sync(path, callback, opts = {}) {
|
|
3288
3298
|
const e = PES`data/${path}`;
|
|
@@ -3909,6 +3919,11 @@ ${log}`;
|
|
|
3909
3919
|
this.momentum.auth.on("login:cd", (event, user) => {
|
|
3910
3920
|
if (user !== void 0 && this.momentum.api.token != this.token) this.connect();
|
|
3911
3921
|
});
|
|
3922
|
+
if (typeof window !== "undefined") {
|
|
3923
|
+
window.addEventListener("online", () => {
|
|
3924
|
+
if (this.reconnect && !this.connected) this.connect();
|
|
3925
|
+
});
|
|
3926
|
+
}
|
|
3912
3927
|
}
|
|
3913
3928
|
momentum;
|
|
3914
3929
|
static pollingSpeed = 15e3;
|
|
@@ -3917,7 +3932,6 @@ ${log}`;
|
|
|
3917
3932
|
connectingResolver;
|
|
3918
3933
|
events = {};
|
|
3919
3934
|
reconnect = true;
|
|
3920
|
-
pending = [];
|
|
3921
3935
|
token;
|
|
3922
3936
|
reconnectTimeout;
|
|
3923
3937
|
connected = false;
|
|
@@ -3932,19 +3946,17 @@ ${log}`;
|
|
|
3932
3946
|
console.debug("Disconnected from Momentum");
|
|
3933
3947
|
this.connected = false;
|
|
3934
3948
|
this.connection?.close();
|
|
3935
|
-
this.connection = void 0;
|
|
3949
|
+
this.connection = this.connecting = this.connectingResolver = void 0;
|
|
3936
3950
|
this.reconnect = !!reconnect;
|
|
3951
|
+
clearTimeout(this.reconnectTimeout);
|
|
3937
3952
|
if (this.reconnect) {
|
|
3938
3953
|
this.scheduleReconnect();
|
|
3939
3954
|
} else {
|
|
3940
3955
|
this.events = {};
|
|
3941
|
-
clearTimeout(this.reconnectTimeout);
|
|
3942
3956
|
}
|
|
3943
3957
|
}
|
|
3944
3958
|
connect() {
|
|
3945
|
-
if (!this.connecting)
|
|
3946
|
-
this.connecting = new Promise((res) => this.connectingResolver = res);
|
|
3947
|
-
}
|
|
3959
|
+
if (!this.connecting) this.connecting = new Promise((res) => this.connectingResolver = res);
|
|
3948
3960
|
if (typeof navigator != "undefined" && !navigator.onLine || this.connected && this.token == this.momentum.api.token) return this.connecting;
|
|
3949
3961
|
if (this.connected) this.close();
|
|
3950
3962
|
clearTimeout(this.reconnectTimeout);
|
|
@@ -3952,18 +3964,8 @@ ${log}`;
|
|
|
3952
3964
|
const url = this.momentum.url.toString().replace("http", "ws");
|
|
3953
3965
|
this.connection = new WebSocket(url + (this.momentum.api.token ? `?token=${this.momentum.api.token}&url=${location?.href || ""}` : ""));
|
|
3954
3966
|
this.connection.onopen = () => {
|
|
3955
|
-
console.debug("Connected to Momentum");
|
|
3956
|
-
this.connected = true;
|
|
3957
3967
|
this.token = this.momentum.api.token;
|
|
3958
3968
|
clearTimeout(this.reconnectTimeout);
|
|
3959
|
-
Object.keys(this.events).forEach((e) => this.send("subscribe", e));
|
|
3960
|
-
this.pending = this.pending.filter((p) => {
|
|
3961
|
-
this.send(p.event, p.payload);
|
|
3962
|
-
return false;
|
|
3963
|
-
});
|
|
3964
|
-
this.connectingResolver?.();
|
|
3965
|
-
this.connecting = void 0;
|
|
3966
|
-
this.connectingResolver = void 0;
|
|
3967
3969
|
};
|
|
3968
3970
|
this.connection.onclose = () => {
|
|
3969
3971
|
if (!this.reconnect) return;
|
|
@@ -3971,7 +3973,12 @@ ${log}`;
|
|
|
3971
3973
|
};
|
|
3972
3974
|
this.connection.onmessage = (message) => {
|
|
3973
3975
|
const data = JSONAttemptParse(message.data);
|
|
3974
|
-
if (data.connected ===
|
|
3976
|
+
if (data.connected === true) {
|
|
3977
|
+
console.debug("Connected to Momentum");
|
|
3978
|
+
Object.keys(this.events).forEach((e) => this.send("subscribe", e));
|
|
3979
|
+
this.connectingResolver?.();
|
|
3980
|
+
this.connected = true;
|
|
3981
|
+
} else if (data.connected === false) this.close(true);
|
|
3975
3982
|
else this.emit(data.event, data.payload);
|
|
3976
3983
|
};
|
|
3977
3984
|
this.scheduleReconnect();
|
|
@@ -3986,25 +3993,24 @@ ${log}`;
|
|
|
3986
3993
|
this.send("ping");
|
|
3987
3994
|
});
|
|
3988
3995
|
}
|
|
3989
|
-
send(channel, payload = null) {
|
|
3996
|
+
async send(channel, payload = null) {
|
|
3997
|
+
if (!this.connecting) await sleepWhile(() => !this.connecting);
|
|
3998
|
+
if (this.connecting) await this.connecting;
|
|
3990
3999
|
if (!this.connection || this.connection.readyState !== WebSocket.OPEN) {
|
|
3991
|
-
|
|
3992
|
-
} else {
|
|
3993
|
-
this.connection.send(JSON.stringify({ event: channel, payload }));
|
|
4000
|
+
throw new Error("WebSocket is not connected");
|
|
3994
4001
|
}
|
|
4002
|
+
this.connection.send(JSON.stringify({ event: channel, payload }));
|
|
3995
4003
|
}
|
|
3996
|
-
subscribe(event) {
|
|
4004
|
+
subscribe(event, callback) {
|
|
3997
4005
|
const e = new PathEvent(event).toString();
|
|
4006
|
+
const unsubscribe = callback ? this.on(e, callback) : null;
|
|
3998
4007
|
if (!this.events[e]) this.events[e] = 1;
|
|
3999
4008
|
else this.events[e]++;
|
|
4000
|
-
if (this.events[e] == 1)
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
this.send("subscribe", e.toString());
|
|
4006
|
-
});
|
|
4007
|
-
} else return Promise.resolve(true);
|
|
4009
|
+
if (this.events[e] == 1 && this.connected) this.send("subscribe", e.toString());
|
|
4010
|
+
return () => {
|
|
4011
|
+
this.unsubscribe(e);
|
|
4012
|
+
unsubscribe?.();
|
|
4013
|
+
};
|
|
4008
4014
|
}
|
|
4009
4015
|
async subscriptions() {
|
|
4010
4016
|
if (!this.connected) await this.connect();
|
|
@@ -4015,16 +4021,12 @@ ${log}`;
|
|
|
4015
4021
|
}
|
|
4016
4022
|
unsubscribe(event) {
|
|
4017
4023
|
const e = new PathEvent(event).toString();
|
|
4024
|
+
if (!this.events[e]) return;
|
|
4018
4025
|
this.events[e]--;
|
|
4019
4026
|
if (this.events[e] <= 0) {
|
|
4020
4027
|
delete this.events[e];
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
if (payload.event == e) res(payload.success);
|
|
4024
|
-
});
|
|
4025
|
-
this.send("unsubscribe", e.toString());
|
|
4026
|
-
});
|
|
4027
|
-
} else return Promise.resolve(true);
|
|
4028
|
+
if (this.connected) this.send("unsubscribe", e.toString());
|
|
4029
|
+
}
|
|
4028
4030
|
}
|
|
4029
4031
|
}
|
|
4030
4032
|
class Storage extends PathEventEmitter {
|
|
@@ -4095,17 +4097,11 @@ ${log}`;
|
|
|
4095
4097
|
/**
|
|
4096
4098
|
* Download module
|
|
4097
4099
|
* @param {string} path Path to target
|
|
4098
|
-
* @param {
|
|
4100
|
+
* @param {rename?: string} rename Rename file on download
|
|
4099
4101
|
* @return {PromiseProgress<Blob>} File as blob with progress tracking
|
|
4100
4102
|
*/
|
|
4101
|
-
download(path,
|
|
4102
|
-
|
|
4103
|
-
return this.momentum.api.request({ url: `api/${this.module}/${path}?download=true`, decode: false }).then(async (response) => {
|
|
4104
|
-
const blob = await response.blob();
|
|
4105
|
-
const name = opts.downloadAs || path.split("/").pop();
|
|
4106
|
-
downloadFile(blob, name);
|
|
4107
|
-
return response;
|
|
4108
|
-
});
|
|
4103
|
+
download(path, rename) {
|
|
4104
|
+
return this.open(path, rename || "download");
|
|
4109
4105
|
}
|
|
4110
4106
|
/**
|
|
4111
4107
|
* Retrieve file/folder metadata
|
|
@@ -4145,11 +4141,19 @@ ${log}`;
|
|
|
4145
4141
|
return response;
|
|
4146
4142
|
});
|
|
4147
4143
|
}
|
|
4148
|
-
open(path, target = "_blank") {
|
|
4144
|
+
open(path, target = typeof window !== "undefined" ? "_blank" : "blob") {
|
|
4149
4145
|
if (!path) throw new Error("Cannot download file, missing module");
|
|
4150
4146
|
const link = `${this.momentum.url.toString()}api/${this.module}/${path}`.replaceAll(/([^:])\/+/g, "$1/") + (!this.momentum.api.sameOrigin && this.momentum.api.token ? `?token=${this.momentum.api.token}` : "");
|
|
4151
|
-
if (
|
|
4152
|
-
return window.open(link, target);
|
|
4147
|
+
if (target === "url" || target === false) return link;
|
|
4148
|
+
if (target === "_blank" || target == "_self") return window.open(link, target);
|
|
4149
|
+
return this.momentum.api.request({ url: `api/${this.module}/${path}?download=true`, decode: false }).then(async (response) => {
|
|
4150
|
+
const blob = await response.blob();
|
|
4151
|
+
if (target !== "blob") {
|
|
4152
|
+
const name = target === "download" ? path.split("/").pop() : target;
|
|
4153
|
+
downloadFile(blob, name);
|
|
4154
|
+
}
|
|
4155
|
+
return blob;
|
|
4156
|
+
});
|
|
4153
4157
|
}
|
|
4154
4158
|
text(path, set) {
|
|
4155
4159
|
if (!path) throw new Error("Missing path");
|
|
@@ -4194,7 +4198,7 @@ ${log}`;
|
|
|
4194
4198
|
sync(path, callback, opts = {}) {
|
|
4195
4199
|
const e = PE`${this.module}/${path}`;
|
|
4196
4200
|
const unsubscribe = callback ? this.on(e.toString(), (event) => callback(event, this.cache.get(path))) : null;
|
|
4197
|
-
if (
|
|
4201
|
+
if (opts.reload) this.meta(path);
|
|
4198
4202
|
if (!this.subscribers.length) this.momentum.socket?.subscribe(e.toString());
|
|
4199
4203
|
const key = Object.keys(this.subscribers).length.toString();
|
|
4200
4204
|
this.subscribers[key] = () => {
|
|
@@ -4328,7 +4332,7 @@ ${log}`;
|
|
|
4328
4332
|
}
|
|
4329
4333
|
momentum;
|
|
4330
4334
|
}
|
|
4331
|
-
const version = "1.4.
|
|
4335
|
+
const version = "1.4.3";
|
|
4332
4336
|
class WebRtc extends PathEventEmitter {
|
|
4333
4337
|
constructor(momentum) {
|
|
4334
4338
|
super("webrtc");
|
|
@@ -4381,6 +4385,7 @@ ${log}`;
|
|
|
4381
4385
|
session.open = false;
|
|
4382
4386
|
Object.values(session.peers).forEach((p) => p.connection.close());
|
|
4383
4387
|
session.stream.getTracks().forEach((track) => track.stop());
|
|
4388
|
+
unsubscribe();
|
|
4384
4389
|
this.momentum.socket?.send(`webrtc/${id}/${session.uid}:d`, {
|
|
4385
4390
|
uid: session.uid,
|
|
4386
4391
|
username: this.momentum.auth.user?._id || "Anonymous",
|
|
@@ -4388,8 +4393,7 @@ ${log}`;
|
|
|
4388
4393
|
});
|
|
4389
4394
|
}
|
|
4390
4395
|
};
|
|
4391
|
-
this.momentum.socket?.subscribe(`webrtc/${id}
|
|
4392
|
-
this.momentum.socket?.on(`webrtc/${id}`, async (event, payload) => {
|
|
4396
|
+
const unsubscribe = this.momentum.socket?.subscribe(`webrtc/${id}`, async (event, payload) => {
|
|
4393
4397
|
if (event.name != session.uid) {
|
|
4394
4398
|
if (payload.connected) {
|
|
4395
4399
|
session.peers[event.name] = {
|
|
@@ -4435,6 +4439,7 @@ ${log}`;
|
|
|
4435
4439
|
this.emit(id, session);
|
|
4436
4440
|
}
|
|
4437
4441
|
}
|
|
4442
|
+
}) || (() => {
|
|
4438
4443
|
});
|
|
4439
4444
|
this.momentum.socket?.send(`webrtc/${id}/${session.uid}`, {
|
|
4440
4445
|
uid: session.uid,
|
package/dist/index.mjs
CHANGED
|
@@ -1717,11 +1717,11 @@ class AssetController extends PathEventEmitter {
|
|
|
1717
1717
|
this.opts.storage = { storage: momentum.database, key: "_" + this.opts.module };
|
|
1718
1718
|
this.cache = new Cache("_id", { persistentStorage: this.opts.storage });
|
|
1719
1719
|
this.momentum.auth.on("login:d", (e) => this.cache.clear());
|
|
1720
|
-
this.on(this.opts.module, (event, payload) => {
|
|
1721
|
-
if (Array.isArray(payload)) {
|
|
1720
|
+
this.on(this.opts.module + ":crud", (event, payload) => {
|
|
1721
|
+
if (!event.path && Array.isArray(payload)) {
|
|
1722
1722
|
this.cache.addAll(payload);
|
|
1723
1723
|
} else if ((event.create || event.update || event.read) && payload != null) {
|
|
1724
|
-
this.cache.add(
|
|
1724
|
+
makeArray(payload).forEach((p) => this.cache.add(p));
|
|
1725
1725
|
} else if (event.delete || payload == null) {
|
|
1726
1726
|
if (!event.path) return this.cache.clear();
|
|
1727
1727
|
const id = this.opts.key == "_id" ? event.name : this.cache.find({ [this.opts.key]: event.path })?._id;
|
|
@@ -1881,18 +1881,17 @@ class Actions extends AssetController {
|
|
|
1881
1881
|
/**
|
|
1882
1882
|
* Manually trigger an actions execution with real-time updates
|
|
1883
1883
|
* @param {string} id Action ID
|
|
1884
|
-
* @param {(payload:
|
|
1884
|
+
* @param {(payload: ActionResult) => any} callback Get updates in real time
|
|
1885
1885
|
* @param {HttpRequestOptions} opts Additional arguments
|
|
1886
1886
|
* @return {Promise<string>} Run UID for socket subscription
|
|
1887
1887
|
*/
|
|
1888
1888
|
async debug(id, callback, opts = {}) {
|
|
1889
1889
|
const uid = await this.momentum.api.request({ url: `api/actions/debug/${id}`, method: "POST", ...opts }).then((resp) => resp.uid);
|
|
1890
1890
|
if (!this.momentum.socket || !callback) return uid;
|
|
1891
|
-
const unsubscribe = this.momentum.socket.
|
|
1891
|
+
const unsubscribe = this.momentum.socket.subscribe(`actions/${id}/${uid}:x`, (event, payload) => {
|
|
1892
1892
|
if (payload.return) unsubscribe();
|
|
1893
1893
|
callback(payload);
|
|
1894
1894
|
});
|
|
1895
|
-
await this.momentum.socket.subscribe(`actions-debug/${uid}`);
|
|
1896
1895
|
return uid;
|
|
1897
1896
|
}
|
|
1898
1897
|
/**
|
|
@@ -1910,7 +1909,7 @@ class Actions extends AssetController {
|
|
|
1910
1909
|
* @return {Promise<T>} HTTP response
|
|
1911
1910
|
*/
|
|
1912
1911
|
run(path, opts = {}) {
|
|
1913
|
-
return this.momentum.api.request({ ...opts, url: `api/
|
|
1912
|
+
return this.momentum.api.request({ ...opts, url: `api${path.startsWith("/") ? "" : "/"}${path}` });
|
|
1914
1913
|
}
|
|
1915
1914
|
}
|
|
1916
1915
|
class Agents extends AssetController {
|
|
@@ -3193,42 +3192,51 @@ class Data extends PathEventEmitter {
|
|
|
3193
3192
|
}
|
|
3194
3193
|
momentum;
|
|
3195
3194
|
subscribers = {};
|
|
3195
|
+
dataUrl(collection, pk, filter, options) {
|
|
3196
|
+
const params = new URLSearchParams();
|
|
3197
|
+
if (filter) params.set("q", JSON.stringify(filter));
|
|
3198
|
+
Object.entries(options ?? {}).forEach(([key, value]) => {
|
|
3199
|
+
if (value !== void 0 && value !== null) params.set(key, String(value));
|
|
3200
|
+
});
|
|
3201
|
+
const query = params.toString();
|
|
3202
|
+
return `api/data/${collection}${pk != null ? `/${pk}` : ""}${query ? `?${query}` : ""}`;
|
|
3203
|
+
}
|
|
3196
3204
|
/**
|
|
3197
|
-
* Create new document in collection
|
|
3205
|
+
* Create new document(s) in collection
|
|
3198
3206
|
* @param {string} collection Target collection
|
|
3199
|
-
* @param {Document<T>}
|
|
3200
|
-
* @return {Promise<Document<T
|
|
3207
|
+
* @param {Document<T> | Document<T>[]} documents New document(s)
|
|
3208
|
+
* @return {Promise<Document<T> | Document<T>[]>} New saved document(s)
|
|
3201
3209
|
*/
|
|
3202
|
-
create(collection,
|
|
3203
|
-
if (!collection || !
|
|
3210
|
+
create(collection, documents) {
|
|
3211
|
+
if (!collection || !documents) throw new Error("Cannot create document, missing collection or document");
|
|
3204
3212
|
return this.momentum.api.request({
|
|
3205
3213
|
url: `api/` + PES`data/${collection}`,
|
|
3206
3214
|
method: "POST",
|
|
3207
|
-
body:
|
|
3215
|
+
body: documents
|
|
3208
3216
|
}).then((resp) => {
|
|
3209
3217
|
if (!resp) return null;
|
|
3210
|
-
this.emit(PES`data/${collection}:c`,
|
|
3218
|
+
makeArray(resp).forEach((r) => this.emit(PES`data/${collection}/${r._id}:c`, r));
|
|
3211
3219
|
return resp;
|
|
3212
3220
|
});
|
|
3213
3221
|
}
|
|
3214
|
-
async delete(collection, filter) {
|
|
3215
|
-
if (!collection ||
|
|
3216
|
-
const pk = typeof filter == "object" ? filter?.
|
|
3217
|
-
const q = typeof filter == "object" ?
|
|
3218
|
-
const url =
|
|
3222
|
+
async delete(collection, filter, options) {
|
|
3223
|
+
if (!collection || filter == null) throw new Error("Cannot delete document, missing collection or filter");
|
|
3224
|
+
const pk = typeof filter == "object" ? filter?._id ?? null : filter;
|
|
3225
|
+
const q = typeof filter == "object" && pk == null ? filter : null;
|
|
3226
|
+
const url = this.dataUrl(collection, pk, q, options);
|
|
3219
3227
|
const ids = await this.momentum.api.request({ url, method: "DELETE" });
|
|
3220
3228
|
ids.forEach((id) => this.emit(PES`data/${collection}/${id}:d`, id));
|
|
3221
3229
|
return ids;
|
|
3222
3230
|
}
|
|
3223
|
-
read(collection, filter) {
|
|
3231
|
+
read(collection, filter, options) {
|
|
3224
3232
|
if (!collection) throw new Error("Cannot read documents, missing collection");
|
|
3225
3233
|
const pk = typeof filter == "object" ? filter?.["_id"] ?? null : filter;
|
|
3226
|
-
const q = typeof filter == "object"
|
|
3227
|
-
const url =
|
|
3234
|
+
const q = typeof filter == "object" && filter != null && Object.keys(filter).length && pk == null ? filter : null;
|
|
3235
|
+
const url = this.dataUrl(collection, pk, q, options);
|
|
3228
3236
|
return this.momentum.api.request({ url }).then((resp) => {
|
|
3229
3237
|
if (!resp) return null;
|
|
3230
3238
|
if (Array.isArray(resp)) {
|
|
3231
|
-
if (!q) this.emit(PES`data/${collection}:r`, collection, resp);
|
|
3239
|
+
if (!q && !options?.limit) this.emit(PES`data/${collection}:r`, collection, resp);
|
|
3232
3240
|
else resp.forEach((r) => this.emit(PES`data/${collection}/${r._id}:r`, collection, resp));
|
|
3233
3241
|
} else {
|
|
3234
3242
|
this.emit(PES`data/${collection}/${resp._id}:r`, collection, resp);
|
|
@@ -3237,32 +3245,34 @@ class Data extends PathEventEmitter {
|
|
|
3237
3245
|
});
|
|
3238
3246
|
}
|
|
3239
3247
|
/**
|
|
3240
|
-
* Update document in collection
|
|
3248
|
+
* Update document(s) in collection
|
|
3241
3249
|
* @param {string} collection Target collection
|
|
3242
|
-
* @param {Document<T>}
|
|
3243
|
-
* @param {
|
|
3250
|
+
* @param {Document<T> | Document<T>[]} documents Document(s) to update
|
|
3251
|
+
* @param {UpdateOptions<T>} options Update options (filter, append, limit, upsert)
|
|
3244
3252
|
* @return {Promise<Document<T> | Document<T>[]>} Updated document(s)
|
|
3245
3253
|
*/
|
|
3246
|
-
update(collection,
|
|
3247
|
-
if (!collection || !
|
|
3248
|
-
const
|
|
3249
|
-
const
|
|
3250
|
-
const
|
|
3254
|
+
update(collection, documents, options = {}) {
|
|
3255
|
+
if (!collection || !documents) throw new Error("Cannot update document, missing collection or document");
|
|
3256
|
+
const { filter, append, ...queryOptions } = options;
|
|
3257
|
+
const isArray = Array.isArray(documents);
|
|
3258
|
+
const firstDoc = isArray ? documents[0] : documents;
|
|
3259
|
+
const pk = isArray ? null : filter ? filter?._id ?? firstDoc._id : firstDoc._id;
|
|
3260
|
+
const q = filter && filter?._id == null ? filter : null;
|
|
3261
|
+
const url = this.dataUrl(collection, pk, q, queryOptions);
|
|
3251
3262
|
return this.momentum.api.request({
|
|
3252
3263
|
url,
|
|
3253
|
-
method:
|
|
3254
|
-
body:
|
|
3264
|
+
method: append === false ? "PUT" : "PATCH",
|
|
3265
|
+
body: documents
|
|
3255
3266
|
}).then((resp) => {
|
|
3256
3267
|
if (!resp) return null;
|
|
3257
|
-
|
|
3258
|
-
else this.emit(PES`data/${collection}/${resp._id}:u`, resp);
|
|
3268
|
+
makeArray(resp).forEach((r) => this.emit(PES`data/${collection}/${r._id}:u`, r));
|
|
3259
3269
|
return resp;
|
|
3260
3270
|
});
|
|
3261
3271
|
}
|
|
3262
3272
|
/**
|
|
3263
|
-
*
|
|
3273
|
+
* Execute raw MongoDB query
|
|
3264
3274
|
* @param {string} collection Target collection name
|
|
3265
|
-
* @param {RawQuery} query Raw query
|
|
3275
|
+
* @param {RawQuery} query Raw MongoDB query object
|
|
3266
3276
|
* @return {Promise<any>} Query response
|
|
3267
3277
|
*/
|
|
3268
3278
|
raw(collection, query) {
|
|
@@ -3274,11 +3284,11 @@ class Data extends PathEventEmitter {
|
|
|
3274
3284
|
});
|
|
3275
3285
|
}
|
|
3276
3286
|
/**
|
|
3277
|
-
* Subscribe to live updates
|
|
3278
|
-
* @param path
|
|
3279
|
-
* @param {(value: T[]) => any
|
|
3280
|
-
* @param opts
|
|
3281
|
-
* @return {
|
|
3287
|
+
* Subscribe to live data updates
|
|
3288
|
+
* @param {string} path Data path to subscribe to
|
|
3289
|
+
* @param {(value: T | T[]) => any} callback Function called with updated data
|
|
3290
|
+
* @param {object} opts Options object with reload flag
|
|
3291
|
+
* @return {Unsubscribe} Function to unsubscribe from updates
|
|
3282
3292
|
*/
|
|
3283
3293
|
sync(path, callback, opts = {}) {
|
|
3284
3294
|
const e = PES`data/${path}`;
|
|
@@ -3905,6 +3915,11 @@ class Socket extends PathEventEmitter {
|
|
|
3905
3915
|
this.momentum.auth.on("login:cd", (event, user) => {
|
|
3906
3916
|
if (user !== void 0 && this.momentum.api.token != this.token) this.connect();
|
|
3907
3917
|
});
|
|
3918
|
+
if (typeof window !== "undefined") {
|
|
3919
|
+
window.addEventListener("online", () => {
|
|
3920
|
+
if (this.reconnect && !this.connected) this.connect();
|
|
3921
|
+
});
|
|
3922
|
+
}
|
|
3908
3923
|
}
|
|
3909
3924
|
momentum;
|
|
3910
3925
|
static pollingSpeed = 15e3;
|
|
@@ -3913,7 +3928,6 @@ class Socket extends PathEventEmitter {
|
|
|
3913
3928
|
connectingResolver;
|
|
3914
3929
|
events = {};
|
|
3915
3930
|
reconnect = true;
|
|
3916
|
-
pending = [];
|
|
3917
3931
|
token;
|
|
3918
3932
|
reconnectTimeout;
|
|
3919
3933
|
connected = false;
|
|
@@ -3928,19 +3942,17 @@ class Socket extends PathEventEmitter {
|
|
|
3928
3942
|
console.debug("Disconnected from Momentum");
|
|
3929
3943
|
this.connected = false;
|
|
3930
3944
|
this.connection?.close();
|
|
3931
|
-
this.connection = void 0;
|
|
3945
|
+
this.connection = this.connecting = this.connectingResolver = void 0;
|
|
3932
3946
|
this.reconnect = !!reconnect;
|
|
3947
|
+
clearTimeout(this.reconnectTimeout);
|
|
3933
3948
|
if (this.reconnect) {
|
|
3934
3949
|
this.scheduleReconnect();
|
|
3935
3950
|
} else {
|
|
3936
3951
|
this.events = {};
|
|
3937
|
-
clearTimeout(this.reconnectTimeout);
|
|
3938
3952
|
}
|
|
3939
3953
|
}
|
|
3940
3954
|
connect() {
|
|
3941
|
-
if (!this.connecting)
|
|
3942
|
-
this.connecting = new Promise((res) => this.connectingResolver = res);
|
|
3943
|
-
}
|
|
3955
|
+
if (!this.connecting) this.connecting = new Promise((res) => this.connectingResolver = res);
|
|
3944
3956
|
if (typeof navigator != "undefined" && !navigator.onLine || this.connected && this.token == this.momentum.api.token) return this.connecting;
|
|
3945
3957
|
if (this.connected) this.close();
|
|
3946
3958
|
clearTimeout(this.reconnectTimeout);
|
|
@@ -3948,18 +3960,8 @@ class Socket extends PathEventEmitter {
|
|
|
3948
3960
|
const url = this.momentum.url.toString().replace("http", "ws");
|
|
3949
3961
|
this.connection = new WebSocket(url + (this.momentum.api.token ? `?token=${this.momentum.api.token}&url=${location?.href || ""}` : ""));
|
|
3950
3962
|
this.connection.onopen = () => {
|
|
3951
|
-
console.debug("Connected to Momentum");
|
|
3952
|
-
this.connected = true;
|
|
3953
3963
|
this.token = this.momentum.api.token;
|
|
3954
3964
|
clearTimeout(this.reconnectTimeout);
|
|
3955
|
-
Object.keys(this.events).forEach((e) => this.send("subscribe", e));
|
|
3956
|
-
this.pending = this.pending.filter((p) => {
|
|
3957
|
-
this.send(p.event, p.payload);
|
|
3958
|
-
return false;
|
|
3959
|
-
});
|
|
3960
|
-
this.connectingResolver?.();
|
|
3961
|
-
this.connecting = void 0;
|
|
3962
|
-
this.connectingResolver = void 0;
|
|
3963
3965
|
};
|
|
3964
3966
|
this.connection.onclose = () => {
|
|
3965
3967
|
if (!this.reconnect) return;
|
|
@@ -3967,7 +3969,12 @@ class Socket extends PathEventEmitter {
|
|
|
3967
3969
|
};
|
|
3968
3970
|
this.connection.onmessage = (message) => {
|
|
3969
3971
|
const data = JSONAttemptParse(message.data);
|
|
3970
|
-
if (data.connected ===
|
|
3972
|
+
if (data.connected === true) {
|
|
3973
|
+
console.debug("Connected to Momentum");
|
|
3974
|
+
Object.keys(this.events).forEach((e) => this.send("subscribe", e));
|
|
3975
|
+
this.connectingResolver?.();
|
|
3976
|
+
this.connected = true;
|
|
3977
|
+
} else if (data.connected === false) this.close(true);
|
|
3971
3978
|
else this.emit(data.event, data.payload);
|
|
3972
3979
|
};
|
|
3973
3980
|
this.scheduleReconnect();
|
|
@@ -3982,25 +3989,24 @@ class Socket extends PathEventEmitter {
|
|
|
3982
3989
|
this.send("ping");
|
|
3983
3990
|
});
|
|
3984
3991
|
}
|
|
3985
|
-
send(channel, payload = null) {
|
|
3992
|
+
async send(channel, payload = null) {
|
|
3993
|
+
if (!this.connecting) await sleepWhile(() => !this.connecting);
|
|
3994
|
+
if (this.connecting) await this.connecting;
|
|
3986
3995
|
if (!this.connection || this.connection.readyState !== WebSocket.OPEN) {
|
|
3987
|
-
|
|
3988
|
-
} else {
|
|
3989
|
-
this.connection.send(JSON.stringify({ event: channel, payload }));
|
|
3996
|
+
throw new Error("WebSocket is not connected");
|
|
3990
3997
|
}
|
|
3998
|
+
this.connection.send(JSON.stringify({ event: channel, payload }));
|
|
3991
3999
|
}
|
|
3992
|
-
subscribe(event) {
|
|
4000
|
+
subscribe(event, callback) {
|
|
3993
4001
|
const e = new PathEvent(event).toString();
|
|
4002
|
+
const unsubscribe = callback ? this.on(e, callback) : null;
|
|
3994
4003
|
if (!this.events[e]) this.events[e] = 1;
|
|
3995
4004
|
else this.events[e]++;
|
|
3996
|
-
if (this.events[e] == 1)
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
this.send("subscribe", e.toString());
|
|
4002
|
-
});
|
|
4003
|
-
} else return Promise.resolve(true);
|
|
4005
|
+
if (this.events[e] == 1 && this.connected) this.send("subscribe", e.toString());
|
|
4006
|
+
return () => {
|
|
4007
|
+
this.unsubscribe(e);
|
|
4008
|
+
unsubscribe?.();
|
|
4009
|
+
};
|
|
4004
4010
|
}
|
|
4005
4011
|
async subscriptions() {
|
|
4006
4012
|
if (!this.connected) await this.connect();
|
|
@@ -4011,16 +4017,12 @@ class Socket extends PathEventEmitter {
|
|
|
4011
4017
|
}
|
|
4012
4018
|
unsubscribe(event) {
|
|
4013
4019
|
const e = new PathEvent(event).toString();
|
|
4020
|
+
if (!this.events[e]) return;
|
|
4014
4021
|
this.events[e]--;
|
|
4015
4022
|
if (this.events[e] <= 0) {
|
|
4016
4023
|
delete this.events[e];
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
if (payload.event == e) res(payload.success);
|
|
4020
|
-
});
|
|
4021
|
-
this.send("unsubscribe", e.toString());
|
|
4022
|
-
});
|
|
4023
|
-
} else return Promise.resolve(true);
|
|
4024
|
+
if (this.connected) this.send("unsubscribe", e.toString());
|
|
4025
|
+
}
|
|
4024
4026
|
}
|
|
4025
4027
|
}
|
|
4026
4028
|
class Storage extends PathEventEmitter {
|
|
@@ -4091,17 +4093,11 @@ class Storage extends PathEventEmitter {
|
|
|
4091
4093
|
/**
|
|
4092
4094
|
* Download module
|
|
4093
4095
|
* @param {string} path Path to target
|
|
4094
|
-
* @param {
|
|
4096
|
+
* @param {rename?: string} rename Rename file on download
|
|
4095
4097
|
* @return {PromiseProgress<Blob>} File as blob with progress tracking
|
|
4096
4098
|
*/
|
|
4097
|
-
download(path,
|
|
4098
|
-
|
|
4099
|
-
return this.momentum.api.request({ url: `api/${this.module}/${path}?download=true`, decode: false }).then(async (response) => {
|
|
4100
|
-
const blob = await response.blob();
|
|
4101
|
-
const name = opts.downloadAs || path.split("/").pop();
|
|
4102
|
-
downloadFile(blob, name);
|
|
4103
|
-
return response;
|
|
4104
|
-
});
|
|
4099
|
+
download(path, rename) {
|
|
4100
|
+
return this.open(path, rename || "download");
|
|
4105
4101
|
}
|
|
4106
4102
|
/**
|
|
4107
4103
|
* Retrieve file/folder metadata
|
|
@@ -4141,11 +4137,19 @@ class Storage extends PathEventEmitter {
|
|
|
4141
4137
|
return response;
|
|
4142
4138
|
});
|
|
4143
4139
|
}
|
|
4144
|
-
open(path, target = "_blank") {
|
|
4140
|
+
open(path, target = typeof window !== "undefined" ? "_blank" : "blob") {
|
|
4145
4141
|
if (!path) throw new Error("Cannot download file, missing module");
|
|
4146
4142
|
const link = `${this.momentum.url.toString()}api/${this.module}/${path}`.replaceAll(/([^:])\/+/g, "$1/") + (!this.momentum.api.sameOrigin && this.momentum.api.token ? `?token=${this.momentum.api.token}` : "");
|
|
4147
|
-
if (
|
|
4148
|
-
return window.open(link, target);
|
|
4143
|
+
if (target === "url" || target === false) return link;
|
|
4144
|
+
if (target === "_blank" || target == "_self") return window.open(link, target);
|
|
4145
|
+
return this.momentum.api.request({ url: `api/${this.module}/${path}?download=true`, decode: false }).then(async (response) => {
|
|
4146
|
+
const blob = await response.blob();
|
|
4147
|
+
if (target !== "blob") {
|
|
4148
|
+
const name = target === "download" ? path.split("/").pop() : target;
|
|
4149
|
+
downloadFile(blob, name);
|
|
4150
|
+
}
|
|
4151
|
+
return blob;
|
|
4152
|
+
});
|
|
4149
4153
|
}
|
|
4150
4154
|
text(path, set) {
|
|
4151
4155
|
if (!path) throw new Error("Missing path");
|
|
@@ -4190,7 +4194,7 @@ class Storage extends PathEventEmitter {
|
|
|
4190
4194
|
sync(path, callback, opts = {}) {
|
|
4191
4195
|
const e = PE`${this.module}/${path}`;
|
|
4192
4196
|
const unsubscribe = callback ? this.on(e.toString(), (event) => callback(event, this.cache.get(path))) : null;
|
|
4193
|
-
if (
|
|
4197
|
+
if (opts.reload) this.meta(path);
|
|
4194
4198
|
if (!this.subscribers.length) this.momentum.socket?.subscribe(e.toString());
|
|
4195
4199
|
const key = Object.keys(this.subscribers).length.toString();
|
|
4196
4200
|
this.subscribers[key] = () => {
|
|
@@ -4324,7 +4328,7 @@ class Static extends Storage {
|
|
|
4324
4328
|
}
|
|
4325
4329
|
momentum;
|
|
4326
4330
|
}
|
|
4327
|
-
const version = "1.4.
|
|
4331
|
+
const version = "1.4.3";
|
|
4328
4332
|
class WebRtc extends PathEventEmitter {
|
|
4329
4333
|
constructor(momentum) {
|
|
4330
4334
|
super("webrtc");
|
|
@@ -4377,6 +4381,7 @@ class WebRtc extends PathEventEmitter {
|
|
|
4377
4381
|
session.open = false;
|
|
4378
4382
|
Object.values(session.peers).forEach((p) => p.connection.close());
|
|
4379
4383
|
session.stream.getTracks().forEach((track) => track.stop());
|
|
4384
|
+
unsubscribe();
|
|
4380
4385
|
this.momentum.socket?.send(`webrtc/${id}/${session.uid}:d`, {
|
|
4381
4386
|
uid: session.uid,
|
|
4382
4387
|
username: this.momentum.auth.user?._id || "Anonymous",
|
|
@@ -4384,8 +4389,7 @@ class WebRtc extends PathEventEmitter {
|
|
|
4384
4389
|
});
|
|
4385
4390
|
}
|
|
4386
4391
|
};
|
|
4387
|
-
this.momentum.socket?.subscribe(`webrtc/${id}
|
|
4388
|
-
this.momentum.socket?.on(`webrtc/${id}`, async (event, payload) => {
|
|
4392
|
+
const unsubscribe = this.momentum.socket?.subscribe(`webrtc/${id}`, async (event, payload) => {
|
|
4389
4393
|
if (event.name != session.uid) {
|
|
4390
4394
|
if (payload.connected) {
|
|
4391
4395
|
session.peers[event.name] = {
|
|
@@ -4431,6 +4435,7 @@ class WebRtc extends PathEventEmitter {
|
|
|
4431
4435
|
this.emit(id, session);
|
|
4432
4436
|
}
|
|
4433
4437
|
}
|
|
4438
|
+
}) || (() => {
|
|
4434
4439
|
});
|
|
4435
4440
|
this.momentum.socket?.send(`webrtc/${id}/${session.uid}`, {
|
|
4436
4441
|
uid: session.uid,
|
package/dist/sockets.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Unsubscribe } from '@ztimson/utils';
|
|
1
2
|
import { PathEvent, PathEventEmitter } from './core';
|
|
2
3
|
import { Momentum } from './momentum';
|
|
3
4
|
export declare class Socket extends PathEventEmitter {
|
|
@@ -8,7 +9,6 @@ export declare class Socket extends PathEventEmitter {
|
|
|
8
9
|
private connectingResolver?;
|
|
9
10
|
private events;
|
|
10
11
|
private reconnect;
|
|
11
|
-
private pending;
|
|
12
12
|
private token?;
|
|
13
13
|
private reconnectTimeout;
|
|
14
14
|
connected: boolean;
|
|
@@ -17,9 +17,9 @@ export declare class Socket extends PathEventEmitter {
|
|
|
17
17
|
close(reconnect?: boolean): void;
|
|
18
18
|
connect(): Promise<void>;
|
|
19
19
|
ping(): Promise<number>;
|
|
20
|
-
send(channel: string, payload?: any): void
|
|
21
|
-
subscribe(event: string | PathEvent):
|
|
20
|
+
send(channel: string, payload?: any): Promise<void>;
|
|
21
|
+
subscribe(event: string | PathEvent, callback?: (event: PathEvent, payload: any) => any): Unsubscribe;
|
|
22
22
|
subscriptions(): Promise<string[]>;
|
|
23
|
-
unsubscribe(event: string | PathEvent):
|
|
23
|
+
unsubscribe(event: string | PathEvent): void;
|
|
24
24
|
}
|
|
25
25
|
//# sourceMappingURL=sockets.d.ts.map
|
package/dist/sockets.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sockets.d.ts","sourceRoot":"","sources":["../src/sockets.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sockets.d.ts","sourceRoot":"","sources":["../src/sockets.ts"],"names":[],"mappings":"AAAA,OAAO,EAA+B,WAAW,EAAC,MAAM,gBAAgB,CAAC;AACzE,OAAO,EAAC,SAAS,EAAE,gBAAgB,EAAC,MAAM,QAAQ,CAAC;AACnD,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AAEpC,qBAAa,MAAO,SAAQ,gBAAgB;IAW/B,SAAS,CAAC,QAAQ,EAAE,QAAQ;IAVxC,MAAM,CAAC,QAAQ,CAAC,YAAY,SAAS;IACrC,OAAO,CAAC,UAAU,CAAC,CAAY;IAC/B,OAAO,CAAC,UAAU,CAAC,CAAgB;IACnC,OAAO,CAAC,kBAAkB,CAAC,CAAW;IACtC,OAAO,CAAC,MAAM,CAA+B;IAC7C,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,KAAK,CAAC,CAAgB;IAC9B,OAAO,CAAC,gBAAgB,CAAM;IAC9B,SAAS,UAAS;gBAEI,QAAQ,EAAE,QAAQ;IAaxC,OAAO,CAAC,iBAAiB;IAQzB,KAAK,CAAC,SAAS,CAAC,EAAE,OAAO;IAczB,OAAO;IAqCD,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC;IASvB,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,GAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAS/D,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,KAAK,GAAG,GAAG,WAAW;IAY/F,aAAa,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAQxC,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS;CASrC"}
|
package/dist/storage.d.ts
CHANGED
|
@@ -52,12 +52,10 @@ export declare class Storage extends PathEventEmitter {
|
|
|
52
52
|
/**
|
|
53
53
|
* Download module
|
|
54
54
|
* @param {string} path Path to target
|
|
55
|
-
* @param {
|
|
55
|
+
* @param {rename?: string} rename Rename file on download
|
|
56
56
|
* @return {PromiseProgress<Blob>} File as blob with progress tracking
|
|
57
57
|
*/
|
|
58
|
-
download(path: string,
|
|
59
|
-
'downloadAs'?: string;
|
|
60
|
-
}): PromiseProgress<Blob>;
|
|
58
|
+
download(path: string, rename?: string): PromiseProgress<Blob>;
|
|
61
59
|
/**
|
|
62
60
|
* Retrieve file/folder metadata
|
|
63
61
|
* @param {string} path Path to target
|
|
@@ -80,11 +78,12 @@ export declare class Storage extends PathEventEmitter {
|
|
|
80
78
|
/**
|
|
81
79
|
* Create file link & open
|
|
82
80
|
* @param {string} path Path to target
|
|
83
|
-
* @param {false} target
|
|
84
|
-
* @return {string} URL
|
|
81
|
+
* @param {'url' | 'blob' | 'download' | false | '_blank' | '_self' | string} target File destination: url/false - returns absolute URL, blob - returns blob object, download/string - downloads/renames file, _blank/_self - Redirects / opens in new tab
|
|
82
|
+
* @return {string | Blob | Window | null} URL, Blob, or Window depending on target
|
|
85
83
|
*/
|
|
86
|
-
open(path: string, target: false): string;
|
|
87
|
-
open(path: string, target
|
|
84
|
+
open(path: string, target: 'url' | false): string;
|
|
85
|
+
open(path: string, target: 'blob' | 'download' | string): PromiseProgress<Blob>;
|
|
86
|
+
open(path: string, target: '_blank' | '_self'): Window | null;
|
|
88
87
|
/**
|
|
89
88
|
* Read file as text via extraction or OCR
|
|
90
89
|
* @param {string} path Path to target
|
package/dist/storage.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,IAAI,EAAK,MAAM,QAAQ,CAAC;AACrC,OAAO,EACN,KAAK,EACL,eAAe,EAKf,gBAAgB,EAAO,WAAW,EAAE,SAAS,EAC7C,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAC;AAEpC,4BAA4B;AAC5B,MAAM,MAAM,OAAO,GAAG,QAAQ,GAAG;IAChC,sBAAsB;IACtB,QAAQ,CAAC,QAAQ,EAAE,CAAC,OAAO,GAAG,QAAQ,CAAC,EAAE,CAAC;IAC1C,kCAAkC;IAClC,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;CAC3B,CAAA;AAED,uBAAuB;AACvB,MAAM,MAAM,QAAQ,GAAG,IAAI,GAAG;IAC7B,oBAAoB;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,gBAAgB;IAChB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,oBAAoB;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,gBAAgB;IAChB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,+BAA+B;IAC/B,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,+BAA+B;IAC/B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACvB,CAAA;AAED,mBAAmB;AACnB,qBAAa,OAAQ,SAAQ,gBAAgB;IAKhC,SAA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