@comapeo/core 5.2.1 → 5.4.0
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/core-manager/index.d.ts +9 -0
- package/dist/core-manager/index.d.ts.map +1 -1
- package/dist/errors.d.ts +4 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/generated/extensions.d.ts +30 -0
- package/dist/generated/extensions.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/mapeo-manager.d.ts +11 -0
- package/dist/mapeo-manager.d.ts.map +1 -1
- package/dist/mapeo-project.d.ts +55 -0
- package/dist/mapeo-project.d.ts.map +1 -1
- package/dist/roles.d.ts +1 -0
- package/dist/roles.d.ts.map +1 -1
- package/dist/utils.d.ts +10 -0
- package/dist/utils.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/core-manager/index.js +49 -0
- package/src/errors.js +8 -0
- package/src/generated/extensions.d.ts +30 -0
- package/src/generated/extensions.js +165 -0
- package/src/generated/extensions.ts +204 -0
- package/src/index.js +1 -0
- package/src/mapeo-manager.js +32 -8
- package/src/mapeo-project.js +76 -1
- package/src/roles.js +6 -0
- package/src/utils.js +74 -0
|
@@ -6,6 +6,7 @@ export const kCoreManagerReplicate: unique symbol;
|
|
|
6
6
|
* @property {(coreRecord: CoreRecord) => void} add-core
|
|
7
7
|
* @property {(namespace: Namespace, msg: { coreDiscoveryId: string, peerId: string, start: number, bitfield: Uint32Array }) => void} peer-have
|
|
8
8
|
* @property {(blobFilter: GenericBlobFilter | null, peerId: string) => void} peer-download-intent
|
|
9
|
+
* @property {(mapShare: MapShareExtension, deviceId: string) => void} map-share
|
|
9
10
|
*/
|
|
10
11
|
/**
|
|
11
12
|
* @extends {TypedEmitter<Events>}
|
|
@@ -86,6 +87,12 @@ export class CoreManager extends TypedEmitter<Events> {
|
|
|
86
87
|
* @param {HypercorePeer} peer
|
|
87
88
|
*/
|
|
88
89
|
sendDownloadIntents(blobFilter: BlobFilter | null, peer: HypercorePeer): void;
|
|
90
|
+
/**
|
|
91
|
+
* Send a map share to a peer
|
|
92
|
+
* @param {MapShareExtension} mapShare
|
|
93
|
+
* @param {HypercorePeer['remotePublicKey']} peerId
|
|
94
|
+
*/
|
|
95
|
+
sendMapShare(mapShare: MapShareExtension, peerId: HypercorePeer["remotePublicKey"]): Promise<void>;
|
|
89
96
|
/**
|
|
90
97
|
* @param {Exclude<Namespace, 'auth'>} namespace
|
|
91
98
|
* @returns {Promise<void>}
|
|
@@ -118,6 +125,7 @@ export type Events = {
|
|
|
118
125
|
bitfield: Uint32Array;
|
|
119
126
|
}) => void;
|
|
120
127
|
"peer-download-intent": (blobFilter: GenericBlobFilter | null, peerId: string) => void;
|
|
128
|
+
"map-share": (mapShare: MapShareExtension, deviceId: string) => void;
|
|
121
129
|
};
|
|
122
130
|
export type HaveMsg = {
|
|
123
131
|
discoveryKey: Buffer;
|
|
@@ -129,6 +137,7 @@ import { TypedEmitter } from 'tiny-typed-emitter';
|
|
|
129
137
|
import type { Namespace } from '../types.js';
|
|
130
138
|
import type { BlobFilter } from '../types.js';
|
|
131
139
|
import type { HypercorePeer } from '../types.js';
|
|
140
|
+
import { MapShareExtension } from '../generated/extensions.js';
|
|
132
141
|
import Corestore from 'corestore';
|
|
133
142
|
import { Logger } from '../logger.js';
|
|
134
143
|
import type Hypercore from 'hypercore';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core-manager/index.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core-manager/index.js"],"names":[],"mappings":"AA0BA,kDAAqE;AAErE,kDAAkD;AAClD,8EAA8E;AAC9E;;;;;;GAMG;AAEH;;GAEG;AACH;IAkBE,kFAEC;IAED;;;;;;;;;;OAUG;IACH,8GATG;QAA4E,EAAE,EAAtE,OAAO,4BAA4B,EAAE,qBAAqB;QACd,U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AQ,EAAE,WAAW,CAAA;KAAE,KAAK,IAAI;4BACtH,CAAC,UAAU,EAAE,iBAAiB,GAAG,IAAI,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI;iBAC9D,CAAC,QAAQ,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI;;;kBA4fvD,MAAM;WACN,MAAM;cACN,WAAW;eACX,SAAS;;6BAliBM,oBAAoB;+BAsB4B,aAAa;gCAAb,aAAa;mCAAb,aAAa;kCAXnF,4BAA4B;sBAVb,WAAW;uBAWV,cAAc;2BASV,WAAW;uCACuC,aAAa"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -34,4 +34,8 @@ export class TimeoutError extends Error {
|
|
|
34
34
|
/** @param {string} [message] */
|
|
35
35
|
constructor(message?: string | undefined);
|
|
36
36
|
}
|
|
37
|
+
export class PeerNotFoundError extends Error {
|
|
38
|
+
/** @param {string} [message] */
|
|
39
|
+
constructor(message?: string | undefined);
|
|
40
|
+
}
|
|
37
41
|
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.js"],"names":[],"mappings":"AAuEA;;;GAGG;AACH,oCAHW,OAAO,GACL,IAAI,CAKhB;AA9ED;IACE,8BAGC;CACF;AAED;IACE,gCAAgC;IAChC,0CAGC;CACF;AAED;IACE,gCAAgC;IAChC,0CAGC;CACF;AAED;IACE,gCAAgC;IAChC,0CAGC;CACF;AAED;IACE,gCAAgC;IAChC,0CAGC;CACF;AAED;IACE,gCAAgC;IAChC,0CAGC;CACF;AAED;IACE,gCAAgC;IAChC,0CAGC;CACF;AAED;IACE,gCAAgC;IAChC,0CAGC;CACF;AAED;IACE,gCAAgC;IAChC,0CAGC;CACF"}
|
|
@@ -39,6 +39,30 @@ export interface DownloadIntentExtension_DownloadIntentsEntry {
|
|
|
39
39
|
key: string;
|
|
40
40
|
value: DownloadIntentExtension_DownloadIntent | undefined;
|
|
41
41
|
}
|
|
42
|
+
export interface MapShareExtension {
|
|
43
|
+
/** URLs to map share */
|
|
44
|
+
mapShareUrls: string[];
|
|
45
|
+
/** ID of peer that can receive the map share (each map share is linked to a specific device ID) */
|
|
46
|
+
receiverDeviceId: string;
|
|
47
|
+
/** The ID of the map share */
|
|
48
|
+
shareId: string;
|
|
49
|
+
/** The name of the map being shared */
|
|
50
|
+
mapName: string;
|
|
51
|
+
/** The ID of the map being shared */
|
|
52
|
+
mapId: string;
|
|
53
|
+
/** When ths share was created */
|
|
54
|
+
mapShareCreatedAt: number;
|
|
55
|
+
/** When the map was created */
|
|
56
|
+
mapCreatedAt: number;
|
|
57
|
+
/** The bounding box of the map data being shared */
|
|
58
|
+
bounds: number[];
|
|
59
|
+
/** The minimum zoom level of the map data being shared */
|
|
60
|
+
minzoom: number;
|
|
61
|
+
/** The maximum zoom level of the map data being shared */
|
|
62
|
+
maxzoom: number;
|
|
63
|
+
/** Estimated size of the map data being shared in bytes */
|
|
64
|
+
estimatedSizeBytes: number;
|
|
65
|
+
}
|
|
42
66
|
export declare const ProjectExtension: {
|
|
43
67
|
encode(message: ProjectExtension, writer?: _m0.Writer): _m0.Writer;
|
|
44
68
|
decode(input: _m0.Reader | Uint8Array, length?: number): ProjectExtension;
|
|
@@ -69,6 +93,12 @@ export declare const DownloadIntentExtension_DownloadIntentsEntry: {
|
|
|
69
93
|
create<I extends Exact<DeepPartial<DownloadIntentExtension_DownloadIntentsEntry>, I>>(base?: I): DownloadIntentExtension_DownloadIntentsEntry;
|
|
70
94
|
fromPartial<I extends Exact<DeepPartial<DownloadIntentExtension_DownloadIntentsEntry>, I>>(object: I): DownloadIntentExtension_DownloadIntentsEntry;
|
|
71
95
|
};
|
|
96
|
+
export declare const MapShareExtension: {
|
|
97
|
+
encode(message: MapShareExtension, writer?: _m0.Writer): _m0.Writer;
|
|
98
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): MapShareExtension;
|
|
99
|
+
create<I extends Exact<DeepPartial<MapShareExtension>, I>>(base?: I): MapShareExtension;
|
|
100
|
+
fromPartial<I extends Exact<DeepPartial<MapShareExtension>, I>>(object: I): MapShareExtension;
|
|
101
|
+
};
|
|
72
102
|
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
73
103
|
type DeepPartial<T> = T extends Builtin ? T : T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
|
|
74
104
|
[K in keyof T]?: DeepPartial<T[K]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extensions.d.ts","sourceRoot":"","sources":["../../src/generated/extensions.ts"],"names":[],"mappings":"AAEA,OAAO,GAAG,MAAM,uBAAuB,CAAC;AAExC,MAAM,WAAW,gBAAgB;IAC/B,YAAY,EAAE,MAAM,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,aAAa;IAC5B,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,uBAAuB,CAAC;CACpC;AAED,eAAO,MAAM,uBAAuB;;;;;;;CAO1B,CAAC;AAEX,MAAM,MAAM,uBAAuB,GAAG,OAAO,uBAAuB,CAAC,MAAM,OAAO,uBAAuB,CAAC,CAAC;AAE3G,wBAAgB,+BAA+B,CAAC,MAAM,EAAE,GAAG,GAAG,uBAAuB,CAsBpF;AAED,wBAAgB,+BAA+B,CAAC,MAAM,EAAE,uBAAuB,GAAG,MAAM,CAgBvF;AAED,uEAAuE;AACvE,MAAM,WAAW,uBAAuB;IACtC,eAAe,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,sCAAsC,CAAA;KAAE,CAAC;IAC3E;;;;;OAKG;IACH,UAAU,EAAE,OA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,KAAK,KAAK,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,OAAO,GAAG,CAAC,GAC9C,CAAC,GAAG;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GAAG;KAAG,CAAC,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,KAAK;CAAE,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export namespace roles {
|
|
|
7
7
|
export { COORDINATOR_ROLE_ID };
|
|
8
8
|
export { MEMBER_ROLE_ID };
|
|
9
9
|
}
|
|
10
|
+
export type MapShare = import("./mapeo-project.js").MapShare;
|
|
10
11
|
export type MapeoProject = import("./mapeo-project.js").MapeoProject;
|
|
11
12
|
export type EditableProjectSettings = import("./mapeo-project.js").EditableProjectSettings;
|
|
12
13
|
export namespace IconApi {
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":";;;AAiDO,0CARI,YAAY,uBACZ,CACV,OAAW,GACX,OAAW,QAAQ,EAAE,MAAM,GAC3B,OAAW,SAAS,EAAE,MAAM,CACzB,GACS,OAAO,YAAY,EAAE,iBAAiB,CAGF;;;;;;uBAvCnC,OAAO,oBAAoB,EAAE,QAAQ;2BACrC,OAAO,oBAAoB,EAAE,YAAY;sCACzC,OAAO,oBAAoB,EAAE,uBAAuB;;sBAGrD,OAAO,eAAe,EAAE,UAAU;mBAClC,OAAO,eAAe,EAAE,OAAO;;;kBAI/B,OAAO,YAAY,EAAE,MAAM;oBAC3B,OAAO,eAAe,EAAE,QAAQ;qBAIA,SAAS,SAAzC,OAAQ,YAAY,EAAE,QAAS,IAC/B,OAAO,YAAY,EAAE,WAAW,CAAC,SAAS,CAAC;;;kBAI3C,OAAO,wBAAwB,EAAE,MAAM;;;sBAIvC,OAAO,iBAAiB,EAAE,UAAU;kBACpC,OAAO,YAAY,EAAE,MAAM;8BAC3B,OAAO,YAAY,EAAE,kBAAkB;oCACvC,OAAO,YAAY,EAAE,wBAAwB;;gCAlCnD,YAAY;oCAAZ,YAAY;+BAAZ,YAAY"}
|
package/dist/mapeo-manager.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ export const DEFAULT_IS_ARCHIVE_DEVICE: true;
|
|
|
7
7
|
/**
|
|
8
8
|
* @typedef {object} MapeoManagerEvents
|
|
9
9
|
* @property {(peers: PublicPeerInfo[]) => void} local-peers Emitted when the list of connected peers changes (new ones added, or connection status changes)
|
|
10
|
+
* @property {(mapShare: import('./mapeo-project.js').MapShare) => void} map-share Emitted when a project has recieved a map share request
|
|
11
|
+
* @property {(e: Error, mapShare: MapShareExtension) => void} map-share-error - Emitted when an incoming map share fails to be recieved due to formatting issues
|
|
10
12
|
*/
|
|
11
13
|
/**
|
|
12
14
|
* @extends {TypedEmitter<MapeoManagerEvents>}
|
|
@@ -189,6 +191,14 @@ export type MapeoManagerEvents = {
|
|
|
189
191
|
* Emitted when the list of connected peers changes (new ones added, or connection status changes)
|
|
190
192
|
*/
|
|
191
193
|
"local-peers": (peers: PublicPeerInfo[]) => void;
|
|
194
|
+
/**
|
|
195
|
+
* Emitted when a project has recieved a map share request
|
|
196
|
+
*/
|
|
197
|
+
"map-share": (mapShare: import("./mapeo-project.js").MapShare) => void;
|
|
198
|
+
/**
|
|
199
|
+
* - Emitted when an incoming map share fails to be recieved due to formatting issues
|
|
200
|
+
*/
|
|
201
|
+
"map-share-error": (e: Error, mapShare: MapShareExtension) => void;
|
|
192
202
|
};
|
|
193
203
|
import { TypedEmitter } from 'tiny-typed-emitter';
|
|
194
204
|
import { MapeoProject } from './mapeo-project.js';
|
|
@@ -201,4 +211,5 @@ import type { SetNonNullable } from 'type-fest';
|
|
|
201
211
|
import type { ProjectJoinDetails } from './generated/rpc.js';
|
|
202
212
|
import type { ProjectSettings } from '@comapeo/schema';
|
|
203
213
|
import type { ProjectInfo } from './schema/client.js';
|
|
214
|
+
import type { MapShareExtension } from './generated/extensions.js';
|
|
204
215
|
//# sourceMappingURL=mapeo-manager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapeo-manager.d.ts","sourceRoot":"","sources":["../src/mapeo-manager.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mapeo-manager.d.ts","sourceRoot":"","sources":["../src/mapeo-manager.js"],"names":[],"mappings":"AAsFA,oDAEC;AAED,mFAC6C;AAE7C,6CAA6C;AAE7C;;GAEG;AAEH;;;;;GAKG;AAEH;;GAEG;AACH;IAwBE;;;;;;;;;;;;;;OAcG;IACH,4NAbG;QAAqB,OAAO,EAApB,MAAM;QACO,QAAQ,EAArB,MAAM;QACO,uBAAuB,EAApC,MAAM;QACO,sBAAsB,EAAnC,MAAM;QACqB,WAAW,EAAtC,MAAM,GAAG,WAAW;QACoB,OAAO,EAA/C,OAAO,SAAS,EAAE,eAAe;QACnB,iBAAiB;QACjB,aAAa;QACb,eAAe;QACf,qBAAqB;QACpB,sBAAsB;QACH,aAAa,UAAzC,MAAM,KAAK,SAAS;KAAsB,EAyG1D;IAED,uBAEC;IAoKD;;;;;OAKG;IACH;eAHoB,MAAM;qBAAe,MAAM;uBAAiB,MAAM;6BAAuB,MAAM;oBACtF,OAAO,CAAC,MAAM,CAAC,CAgF3B;IAED;;;OAGG;IACH,4BAHW,MAAM,GACJ,OAAO,CAAC,YAAY,CAAC,CA2CjC;IA2DD;;;OAGG;IACH;sBAH2B,OAAO;oBACrB,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAoEzC;IAED;;;;;;;;OAQG;IACH,wGAJW,mBAAmB;sBACH,OAAO;sBACrB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AoB,GAAG,WAAW,CAAC;4BAC/G,CAAA,qBAAqB,GAAG;IAAE,MAAM,EAAE,QAAQ,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,KAAG,WAAW,GAAG;IAAE,MAAM,EAAE,SAAS,GAAG,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,CAAA;6BA6BlI,IAAI,CAAC,OAAO,kBAAkB,EAAE,QAAQ,EAAE,UAAU,CAAC;;;;;mBAKpD,CAAC,KAAK,EAAE,cAAc,EAAE,KAAK,IAAI;;;;iBACjC,CAAC,QAAQ,EAAE,OAAO,oBAAoB,EAAE,QAAQ,KAAK,IAAI;;;;uBACzD,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,iBAAiB,KAAK,IAAI;;6BAhGhC,oBAAoB;6BAY1C,oBAAoB;qCA0CuB,oBAAoB;0BAd5C,wBAAwB;iCAaN,YAAY;0BAR9B,IAAI;4BA3BF,qBAAqB;oCAiCb,WAAW;wCACN,oBAAoB;qCAGF,iBAAiB;iCAD1B,oBAAoB;uCAL/B,2BAA2B"}
|
package/dist/mapeo-project.d.ts
CHANGED
|
@@ -20,10 +20,23 @@ export const kGeoJSONFileName: unique symbol;
|
|
|
20
20
|
* @typedef RoleChangeEvent
|
|
21
21
|
* @property {Role & {reason: string | undefined}} role
|
|
22
22
|
*/
|
|
23
|
+
/**
|
|
24
|
+
* @typedef {object} AugmentedMapShareProperties
|
|
25
|
+
* @property {readonly [number, number, number, number]} bounds - Bounding box of the shared map [W, S, E, N].
|
|
26
|
+
* @property {readonly [string, ...string[]]} mapShareUrls - URLs associated with the map share.
|
|
27
|
+
* @property {number} mapShareReceivedAt - Timestamp when the map share was received.
|
|
28
|
+
* @property {string} senderDeviceId - The ID of the device that sent the map share.
|
|
29
|
+
* @property {string} [senderDeviceName] - The name of the device that sent the map share.
|
|
30
|
+
*/
|
|
31
|
+
/**
|
|
32
|
+
* @typedef {Omit<MapShareExtension, 'bounds' | 'mapShareUrls'> & AugmentedMapShareProperties} MapShare
|
|
33
|
+
*/
|
|
23
34
|
/**
|
|
24
35
|
* @typedef {object} ProjectEvents
|
|
25
36
|
* @property {() => void} close Project resources have been cleared up
|
|
26
37
|
* @property {(changeEvent: RoleChangeEvent) => void} own-role-change
|
|
38
|
+
* @property {(e: Error, mapShare: MapShareExtension) => void} map-share-error - Emitted when an incoming map share fails to be recieved due to formatting issues
|
|
39
|
+
* @property {(mapShare: MapShare) => void} map-share - Emitted when a map share is recieved from someone on the project
|
|
27
40
|
*/
|
|
28
41
|
/**
|
|
29
42
|
* @extends {TypedEmitter<ProjectEvents>}
|
|
@@ -2508,6 +2521,16 @@ export class MapeoProject extends TypedEmitter<ProjectEvents> {
|
|
|
2508
2521
|
$importCategories({ filePath }: {
|
|
2509
2522
|
filePath: string;
|
|
2510
2523
|
}): Promise<void>;
|
|
2524
|
+
/**
|
|
2525
|
+
* Send a map share offer to the peer with device ID `mapShare.receiverDeviceId`
|
|
2526
|
+
*
|
|
2527
|
+
* @param {MapShareExtension} mapShare
|
|
2528
|
+
* @param {object} [options]
|
|
2529
|
+
* @param {boolean} [options.__testOnlyBypassValidation=false] Warning: Do not use!
|
|
2530
|
+
*/
|
|
2531
|
+
$sendMapShare(mapShare: MapShareExtension, { __testOnlyBypassValidation }?: {
|
|
2532
|
+
__testOnlyBypassValidation?: boolean | undefined;
|
|
2533
|
+
} | undefined): Promise<void>;
|
|
2511
2534
|
/**
|
|
2512
2535
|
* CoreManager instance, used for tests
|
|
2513
2536
|
*/
|
|
@@ -5736,12 +5759,43 @@ export type RoleChangeEvent = {
|
|
|
5736
5759
|
reason: string | undefined;
|
|
5737
5760
|
};
|
|
5738
5761
|
};
|
|
5762
|
+
export type AugmentedMapShareProperties = {
|
|
5763
|
+
/**
|
|
5764
|
+
* - Bounding box of the shared map [W, S, E, N].
|
|
5765
|
+
*/
|
|
5766
|
+
bounds: readonly [number, number, number, number];
|
|
5767
|
+
/**
|
|
5768
|
+
* - URLs associated with the map share.
|
|
5769
|
+
*/
|
|
5770
|
+
mapShareUrls: readonly [string, ...string[]];
|
|
5771
|
+
/**
|
|
5772
|
+
* - Timestamp when the map share was received.
|
|
5773
|
+
*/
|
|
5774
|
+
mapShareReceivedAt: number;
|
|
5775
|
+
/**
|
|
5776
|
+
* - The ID of the device that sent the map share.
|
|
5777
|
+
*/
|
|
5778
|
+
senderDeviceId: string;
|
|
5779
|
+
/**
|
|
5780
|
+
* - The name of the device that sent the map share.
|
|
5781
|
+
*/
|
|
5782
|
+
senderDeviceName?: string | undefined;
|
|
5783
|
+
};
|
|
5784
|
+
export type MapShare = Omit<MapShareExtension, "bounds" | "mapShareUrls"> & AugmentedMapShareProperties;
|
|
5739
5785
|
export type ProjectEvents = {
|
|
5740
5786
|
/**
|
|
5741
5787
|
* Project resources have been cleared up
|
|
5742
5788
|
*/
|
|
5743
5789
|
close: () => void;
|
|
5744
5790
|
"own-role-change": (changeEvent: RoleChangeEvent) => void;
|
|
5791
|
+
/**
|
|
5792
|
+
* - Emitted when an incoming map share fails to be recieved due to formatting issues
|
|
5793
|
+
*/
|
|
5794
|
+
"map-share-error": (e: Error, mapShare: MapShareExtension) => void;
|
|
5795
|
+
/**
|
|
5796
|
+
* - Emitted when a map share is recieved from someone on the project
|
|
5797
|
+
*/
|
|
5798
|
+
"map-share": (mapShare: MapShare) => void;
|
|
5745
5799
|
};
|
|
5746
5800
|
import { TypedEmitter } from 'tiny-typed-emitter';
|
|
5747
5801
|
import { BlobApi } from './blob-api.js';
|
|
@@ -5752,6 +5806,7 @@ import { SyncApi } from './sync/sync-api.js';
|
|
|
5752
5806
|
import TranslationApi from './translation-api.js';
|
|
5753
5807
|
import type { Role } from './roles.js';
|
|
5754
5808
|
import { IconApi } from './icon-api.js';
|
|
5809
|
+
import type { MapShareExtension } from './generated/extensions.js';
|
|
5755
5810
|
import { CoreManager } from './core-manager/index.js';
|
|
5756
5811
|
import { CoreOwnership } from './core-ownership.js';
|
|
5757
5812
|
import { BlobStore } from './blob-store/index.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapeo-project.d.ts","sourceRoot":"","sources":["../src/mapeo-project.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mapeo-project.d.ts","sourceRoot":"","sources":["../src/mapeo-project.js"],"names":[],"mappings":"AAi/CA;;;;;GAKG;AACH,qCAJW,MAAM,mBACN,MAAM,GACJ,MAAM,CAOlB;AA55CD,yCAAiD;AACjD,2CAAqD;AACrD,8CAA4D;AAC5D,uCAA6C;AAC7C,8CAA4D;AAC5D,uCAA6C;AAC7C,0CAAoD;AACpD,uCAAsD;AACtD,gDAAgE;AAChE,6CAA4E;AAC5E,6CAAyD;AAOzD;;;GAGG;AAEH;;;;;;;GAOG;AAEH;;GAEG;AAEH;;;;;;GAMG;AAEH;;GAEG;AACH;IAsBE;;OAAsD;IAGtD;;;;;;;;;;;;;;;;;;OAkBG;IACH,mPAjBG;QAAqB,MAAM,EAAnB,MAAM;QACO,uBAAuB,EAApC,MAAM;QACmC,UAAU,EAAnD,2CAAkC;QACrB,UAAU,EAAvB,MAAM;QACQ,gBAAgB;QACqB,cAAc,EAAjE,OAAO,qBAAqB,EAAE,cAAc;QACqB,QAAQ,EAAzE,OAAO,4BAA4B,EAAE,qBAAqB;QACxC,iBAAiB,EAAnC,WAAW;QACO,WAAW,EAA7B,WAAW;QAC6C,eAAe,EAAvE,CAAC,SAAS,EAAE,OAAO,GAAG,OAAO,KAAK,OAAO,CAAC,MAAM,CAAC;QACf,aAAa,UAAzC,MAAM,KAAK,SAAS;QACkB,UAAU,EAAtD,OAAO,kBAAkB,EAAE,UAAU;QACvB,eAAe,EAA7B,OAAO;QAC0D,sBAAsB,EAAvF,MAAM,OAAO,oBAAoB,EAAE,WAAW,GAAG,SAAS;QAC5C,MAAM;KAE9B,EA4XA;IA/GC,gBASE;IAiIJ,uBAEC;IAUD;;;;OAIG;IACH,SAFa,OAAO,CAAC,IAAI,CAAC,CA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;gCACgG,YAAY;4BAAZ,YAAY"}
|
package/dist/roles.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export const MEMBER_ROLE_ID: "012fd2d431c0bf60";
|
|
|
5
5
|
export const BLOCKED_ROLE_ID: "9e6d29263cba36c9";
|
|
6
6
|
export const LEFT_ROLE_ID: "8ced989b1904606b";
|
|
7
7
|
export const NO_ROLE_ID: "08e4251e36f6e7ed";
|
|
8
|
+
export const INACTIVE_MEMBER_ROLE_IDS: string[];
|
|
8
9
|
export const isRoleIdForNewInvite: (value: unknown) => value is "f7c150f5a3a9a855" | "012fd2d431c0bf60" | "9e6d29263cba36c9";
|
|
9
10
|
export const isRoleIdAssignableToOthers: (value: unknown) => value is "f7c150f5a3a9a855" | "012fd2d431c0bf60" | "9e6d29263cba36c9";
|
|
10
11
|
/**
|
package/dist/roles.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"roles.d.ts","sourceRoot":"","sources":["../src/roles.js"],"names":[],"mappings":"AAMA,8CAA8C;AAG9C,iDAAiD;AACjD,qDAAqD;AACrD,gDAAgD;AAChD,iDAAiD;AACjD,8CAA8C;AAC9C,4CAA4C;
|
|
1
|
+
{"version":3,"file":"roles.d.ts","sourceRoot":"","sources":["../src/roles.js"],"names":[],"mappings":"AAMA,8CAA8C;AAG9C,iDAAiD;AACjD,qDAAqD;AACrD,gDAAgD;AAChD,iDAAiD;AACjD,8CAA8C;AAC9C,4CAA4C;AAE5C,gDAIC;AAwBD,6HAAmE;AAMnE,mIAA+E;AAa/E;;;;;;GAMG;AAEH;;;;;;;;GAQG;AAEH;;;;;;GAMG;AACH,2BAFU,IAAI,CAAC,OAAO,eAAe,CAAC,CAmBrC;AA6BD;;;;;;;;;GASG;AACH,sBAFU,IAAI,CAAC,OAAO,UAAU,CAAC,CAmBhC;AAED,yCAAyC;AACzC,oBADW,GAAG,CAAW,IAAN,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,GAAE,CAgEpC;AA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,EAAE;UAC1B,MAAM,CAAC,SAAS,EAAE,SAAS,GAAG,SAAS,CAAC;;;;;;YAyJxC,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,KAAK,IAAI;;6BAlOd,oBAAoB;AAiBjD;;;GAGG;AAEH,mDAAmD;AACnD,yJASC;AAGD,8EAA8E;AAC9E,yGAEC;AAGD,0FAA0F;AAC1F,+GAEC;AAGD,0FAA0F;AAC1F,oIAOC;+BAtD8B,YAAY"}
|
package/dist/utils.d.ts
CHANGED
|
@@ -124,10 +124,20 @@ export function buildBlobId(attachment: Attachment, requestedVariant: "original"
|
|
|
124
124
|
* @returns {import('type-fest').Entries<T>}
|
|
125
125
|
*/
|
|
126
126
|
export function typedEntries<T extends Record<string, unknown>>(obj: T): import("type-fest").Entries<T>;
|
|
127
|
+
/**
|
|
128
|
+
* Validate map share extension messages to check that all their parameters make sense
|
|
129
|
+
* Does not validate device ID or device name
|
|
130
|
+
*
|
|
131
|
+
* @param {MapShareExtension} mapShare
|
|
132
|
+
* @returns {asserts mapShare is { [K in keyof MapShareExtension]: import('./mapeo-project.js').MapShare[K] }} - this validates the properties that MapShareExtension and MapShare have in common - bounds tuple and mapShareUrls
|
|
133
|
+
*/
|
|
134
|
+
export function validateMapShareExtension(mapShare: MapShareExtension): asserts mapShare is { [K in keyof MapShareExtension]: import("./mapeo-project.js").MapShare[K]; };
|
|
135
|
+
export const MAX_BOUNDS: number[];
|
|
127
136
|
export class ExhaustivenessError extends Error {
|
|
128
137
|
/** @param {never} value */
|
|
129
138
|
constructor(value: never);
|
|
130
139
|
}
|
|
131
140
|
import type { Attachment } from "./types.js";
|
|
132
141
|
import type { BlobId } from "./types.js";
|
|
142
|
+
import type { MapShareExtension } from './generated/extensions.js';
|
|
133
143
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.js"],"names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AM,CAMlB;AAED;;;GAGG;AACH,4CAHW,MAAM,GACJ,MAAM,CAIlB;AAED;;;GAGG;AACH,wCAHW,2CAAkC,GAChC,MAAM,CAIlB;AAED;;;;;;;2DAO2D;AAC3D,0BALsB,CAAC,SAAV,MAAQ,EACF,CAAC,wBACT,aAAa,CAAC,CAAC,CAAC,SAChB,CAAC,GACC,MAAM,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAOtD;AAED;;;;GAIG;AACH,gCAHW,MAAM,UAQhB;AAED;;;;;GAKG;AACH,wCAJW,UAAU,oBACV,UAAU,GAAG,WAAW,GAAG,SAAS,GAClC,MAAM,CA0BlB;AAED;;;;;;;;GAQG;AACH,6BAJuC,CAAC,SAA1B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAE,OAC3B,CAAC,GACC,OAAO,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC,CAI1C;AAED;;;;;;GAMG;AACH,oDAHW,iBAAiB,GACf,QAAQ,QAAQ,IAAI,GAAG,CAA4B,IAAvB,MAAM,iBAAiB,GAAG,OAAO,oBAAoB,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAE,CAgE5G;AA7TD,kCAA4D;AAe5D;IACE,2BAA2B;IAC3B,mBADY,KAAK,EAIhB;CACF;gCAzBqC,YAAY;4BAAZ,YAAY;uCADX,2BAA2B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@comapeo/core",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.4.0",
|
|
4
4
|
"description": "Offline p2p mapping library",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -185,7 +185,7 @@
|
|
|
185
185
|
"debug": "^4.3.4",
|
|
186
186
|
"dot-prop": "^9.0.0",
|
|
187
187
|
"dot-prop-extra": "^10.2.0",
|
|
188
|
-
"drizzle-orm": "
|
|
188
|
+
"drizzle-orm": "1.0.0-beta.1-fd8bfcc",
|
|
189
189
|
"ensure-error": "^4.0.0",
|
|
190
190
|
"fastify": "^4.0.0",
|
|
191
191
|
"fastify-plugin": "^4.5.1",
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
HaveExtension,
|
|
9
9
|
ProjectExtension,
|
|
10
10
|
DownloadIntentExtension,
|
|
11
|
+
MapShareExtension,
|
|
11
12
|
} from '../generated/extensions.js'
|
|
12
13
|
import { Logger } from '../logger.js'
|
|
13
14
|
import { NAMESPACES } from '../constants.js'
|
|
@@ -16,6 +17,7 @@ import { coresTable } from '../schema/project.js'
|
|
|
16
17
|
import * as rle from './bitfield-rle.js'
|
|
17
18
|
import { CoreIndex } from './core-index.js'
|
|
18
19
|
import mapObject from 'map-obj'
|
|
20
|
+
import { PeerNotFoundError } from '../errors.js'
|
|
19
21
|
|
|
20
22
|
/** @import Hypercore from 'hypercore' */
|
|
21
23
|
/** @import { BlobFilter, GenericBlobFilter, HypercorePeer, Namespace } from '../types.js' */
|
|
@@ -31,6 +33,7 @@ export const kCoreManagerReplicate = Symbol('replicate core manager')
|
|
|
31
33
|
* @property {(coreRecord: CoreRecord) => void} add-core
|
|
32
34
|
* @property {(namespace: Namespace, msg: { coreDiscoveryId: string, peerId: string, start: number, bitfield: Uint32Array }) => void} peer-have
|
|
33
35
|
* @property {(blobFilter: GenericBlobFilter | null, peerId: string) => void} peer-download-intent
|
|
36
|
+
* @property {(mapShare: MapShareExtension, deviceId: string) => void} map-share
|
|
34
37
|
*/
|
|
35
38
|
|
|
36
39
|
/**
|
|
@@ -52,6 +55,7 @@ export class CoreManager extends TypedEmitter {
|
|
|
52
55
|
#l
|
|
53
56
|
#autoDownload
|
|
54
57
|
#downloadIntentExtension
|
|
58
|
+
#mapShareExtension
|
|
55
59
|
|
|
56
60
|
static get namespaces() {
|
|
57
61
|
return NAMESPACES
|
|
@@ -173,6 +177,16 @@ export class CoreManager extends TypedEmitter {
|
|
|
173
177
|
}
|
|
174
178
|
)
|
|
175
179
|
|
|
180
|
+
this.#mapShareExtension = this.creatorCore.registerExtension(
|
|
181
|
+
'mapeo/map-share',
|
|
182
|
+
{
|
|
183
|
+
encoding: MapShareCodec,
|
|
184
|
+
onmessage: (msg, peer) => {
|
|
185
|
+
this.#handleMapShareMessage(msg, peer)
|
|
186
|
+
},
|
|
187
|
+
}
|
|
188
|
+
)
|
|
189
|
+
|
|
176
190
|
this.creatorCore.on('peer-add', (peer) => {
|
|
177
191
|
this.#sendHaves(peer, this.#coreIndex).catch(() => {
|
|
178
192
|
this.#l.log('Failed to send pre-haves to newly-connected peer')
|
|
@@ -384,6 +398,15 @@ export class CoreManager extends TypedEmitter {
|
|
|
384
398
|
}
|
|
385
399
|
}
|
|
386
400
|
|
|
401
|
+
/**
|
|
402
|
+
* @param {MapShareExtension} mapShare
|
|
403
|
+
* @param {HypercorePeer} peer
|
|
404
|
+
*/
|
|
405
|
+
#handleMapShareMessage(mapShare, peer) {
|
|
406
|
+
// TODO: Fetch device name or device ID for peer?
|
|
407
|
+
this.emit('map-share', mapShare, peer.remotePublicKey.toString('hex'))
|
|
408
|
+
}
|
|
409
|
+
|
|
387
410
|
/**
|
|
388
411
|
* Sends auth core keys to the given peer, skipping any keys that we know the
|
|
389
412
|
* peer has already (depends on the peer having already replicated the auth
|
|
@@ -466,6 +489,21 @@ export class CoreManager extends TypedEmitter {
|
|
|
466
489
|
peer.protomux.uncork()
|
|
467
490
|
}
|
|
468
491
|
|
|
492
|
+
/**
|
|
493
|
+
* Send a map share to a peer
|
|
494
|
+
* @param {MapShareExtension} mapShare
|
|
495
|
+
* @param {HypercorePeer['remotePublicKey']} peerId
|
|
496
|
+
*/
|
|
497
|
+
async sendMapShare(mapShare, peerId) {
|
|
498
|
+
for (const peer of this.creatorCore.peers) {
|
|
499
|
+
if (peer.remotePublicKey.equals(peerId)) {
|
|
500
|
+
this.#mapShareExtension.send(mapShare, peer)
|
|
501
|
+
return
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
throw new PeerNotFoundError()
|
|
505
|
+
}
|
|
506
|
+
|
|
469
507
|
/**
|
|
470
508
|
* ONLY FOR TESTING
|
|
471
509
|
* Replicate all cores in core manager
|
|
@@ -573,3 +611,14 @@ const DownloadIntentCodec = {
|
|
|
573
611
|
])
|
|
574
612
|
},
|
|
575
613
|
}
|
|
614
|
+
|
|
615
|
+
const MapShareCodec = {
|
|
616
|
+
/** @param {Parameters<typeof MapShareExtension.encode>[0]} msg */
|
|
617
|
+
encode(msg) {
|
|
618
|
+
return MapShareExtension.encode(msg).finish()
|
|
619
|
+
},
|
|
620
|
+
/** @param {Buffer | Uint8Array} buf */
|
|
621
|
+
decode(buf) {
|
|
622
|
+
return MapShareExtension.decode(buf)
|
|
623
|
+
},
|
|
624
|
+
}
|
package/src/errors.js
CHANGED
|
@@ -61,6 +61,14 @@ export class TimeoutError extends Error {
|
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
export class PeerNotFoundError extends Error {
|
|
65
|
+
/** @param {string} [message] */
|
|
66
|
+
constructor(message = 'PeerNotFoundError: Peer not found') {
|
|
67
|
+
super(message)
|
|
68
|
+
this.name = 'PeerNotFoundError'
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
64
72
|
/**
|
|
65
73
|
* @param {unknown} err
|
|
66
74
|
* @returns {null}
|
|
@@ -39,6 +39,30 @@ export interface DownloadIntentExtension_DownloadIntentsEntry {
|
|
|
39
39
|
key: string;
|
|
40
40
|
value: DownloadIntentExtension_DownloadIntent | undefined;
|
|
41
41
|
}
|
|
42
|
+
export interface MapShareExtension {
|
|
43
|
+
/** URLs to map share */
|
|
44
|
+
mapShareUrls: string[];
|
|
45
|
+
/** ID of peer that can receive the map share (each map share is linked to a specific device ID) */
|
|
46
|
+
receiverDeviceId: string;
|
|
47
|
+
/** The ID of the map share */
|
|
48
|
+
shareId: string;
|
|
49
|
+
/** The name of the map being shared */
|
|
50
|
+
mapName: string;
|
|
51
|
+
/** The ID of the map being shared */
|
|
52
|
+
mapId: string;
|
|
53
|
+
/** When ths share was created */
|
|
54
|
+
mapShareCreatedAt: number;
|
|
55
|
+
/** When the map was created */
|
|
56
|
+
mapCreatedAt: number;
|
|
57
|
+
/** The bounding box of the map data being shared */
|
|
58
|
+
bounds: number[];
|
|
59
|
+
/** The minimum zoom level of the map data being shared */
|
|
60
|
+
minzoom: number;
|
|
61
|
+
/** The maximum zoom level of the map data being shared */
|
|
62
|
+
maxzoom: number;
|
|
63
|
+
/** Estimated size of the map data being shared in bytes */
|
|
64
|
+
estimatedSizeBytes: number;
|
|
65
|
+
}
|
|
42
66
|
export declare const ProjectExtension: {
|
|
43
67
|
encode(message: ProjectExtension, writer?: _m0.Writer): _m0.Writer;
|
|
44
68
|
decode(input: _m0.Reader | Uint8Array, length?: number): ProjectExtension;
|
|
@@ -69,6 +93,12 @@ export declare const DownloadIntentExtension_DownloadIntentsEntry: {
|
|
|
69
93
|
create<I extends Exact<DeepPartial<DownloadIntentExtension_DownloadIntentsEntry>, I>>(base?: I): DownloadIntentExtension_DownloadIntentsEntry;
|
|
70
94
|
fromPartial<I extends Exact<DeepPartial<DownloadIntentExtension_DownloadIntentsEntry>, I>>(object: I): DownloadIntentExtension_DownloadIntentsEntry;
|
|
71
95
|
};
|
|
96
|
+
export declare const MapShareExtension: {
|
|
97
|
+
encode(message: MapShareExtension, writer?: _m0.Writer): _m0.Writer;
|
|
98
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): MapShareExtension;
|
|
99
|
+
create<I extends Exact<DeepPartial<MapShareExtension>, I>>(base?: I): MapShareExtension;
|
|
100
|
+
fromPartial<I extends Exact<DeepPartial<MapShareExtension>, I>>(object: I): MapShareExtension;
|
|
101
|
+
};
|
|
72
102
|
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
73
103
|
type DeepPartial<T> = T extends Builtin ? T : T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
|
|
74
104
|
[K in keyof T]?: DeepPartial<T[K]>;
|
|
@@ -329,6 +329,171 @@ export var DownloadIntentExtension_DownloadIntentsEntry = {
|
|
|
329
329
|
return message;
|
|
330
330
|
},
|
|
331
331
|
};
|
|
332
|
+
function createBaseMapShareExtension() {
|
|
333
|
+
return {
|
|
334
|
+
mapShareUrls: [],
|
|
335
|
+
receiverDeviceId: "",
|
|
336
|
+
shareId: "",
|
|
337
|
+
mapName: "",
|
|
338
|
+
mapId: "",
|
|
339
|
+
mapShareCreatedAt: 0,
|
|
340
|
+
mapCreatedAt: 0,
|
|
341
|
+
bounds: [],
|
|
342
|
+
minzoom: 0,
|
|
343
|
+
maxzoom: 0,
|
|
344
|
+
estimatedSizeBytes: 0,
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
export var MapShareExtension = {
|
|
348
|
+
encode: function (message, writer) {
|
|
349
|
+
if (writer === void 0) { writer = _m0.Writer.create(); }
|
|
350
|
+
for (var _i = 0, _a = message.mapShareUrls; _i < _a.length; _i++) {
|
|
351
|
+
var v = _a[_i];
|
|
352
|
+
writer.uint32(10).string(v);
|
|
353
|
+
}
|
|
354
|
+
if (message.receiverDeviceId !== "") {
|
|
355
|
+
writer.uint32(18).string(message.receiverDeviceId);
|
|
356
|
+
}
|
|
357
|
+
if (message.shareId !== "") {
|
|
358
|
+
writer.uint32(26).string(message.shareId);
|
|
359
|
+
}
|
|
360
|
+
if (message.mapName !== "") {
|
|
361
|
+
writer.uint32(34).string(message.mapName);
|
|
362
|
+
}
|
|
363
|
+
if (message.mapId !== "") {
|
|
364
|
+
writer.uint32(42).string(message.mapId);
|
|
365
|
+
}
|
|
366
|
+
if (message.mapShareCreatedAt !== 0) {
|
|
367
|
+
writer.uint32(48).uint64(message.mapShareCreatedAt);
|
|
368
|
+
}
|
|
369
|
+
if (message.mapCreatedAt !== 0) {
|
|
370
|
+
writer.uint32(56).uint64(message.mapCreatedAt);
|
|
371
|
+
}
|
|
372
|
+
writer.uint32(66).fork();
|
|
373
|
+
for (var _b = 0, _c = message.bounds; _b < _c.length; _b++) {
|
|
374
|
+
var v = _c[_b];
|
|
375
|
+
writer.double(v);
|
|
376
|
+
}
|
|
377
|
+
writer.ldelim();
|
|
378
|
+
if (message.minzoom !== 0) {
|
|
379
|
+
writer.uint32(72).int32(message.minzoom);
|
|
380
|
+
}
|
|
381
|
+
if (message.maxzoom !== 0) {
|
|
382
|
+
writer.uint32(80).int32(message.maxzoom);
|
|
383
|
+
}
|
|
384
|
+
if (message.estimatedSizeBytes !== 0) {
|
|
385
|
+
writer.uint32(88).uint64(message.estimatedSizeBytes);
|
|
386
|
+
}
|
|
387
|
+
return writer;
|
|
388
|
+
},
|
|
389
|
+
decode: function (input, length) {
|
|
390
|
+
var reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
|
|
391
|
+
var end = length === undefined ? reader.len : reader.pos + length;
|
|
392
|
+
var message = createBaseMapShareExtension();
|
|
393
|
+
while (reader.pos < end) {
|
|
394
|
+
var tag = reader.uint32();
|
|
395
|
+
switch (tag >>> 3) {
|
|
396
|
+
case 1:
|
|
397
|
+
if (tag !== 10) {
|
|
398
|
+
break;
|
|
399
|
+
}
|
|
400
|
+
message.mapShareUrls.push(reader.string());
|
|
401
|
+
continue;
|
|
402
|
+
case 2:
|
|
403
|
+
if (tag !== 18) {
|
|
404
|
+
break;
|
|
405
|
+
}
|
|
406
|
+
message.receiverDeviceId = reader.string();
|
|
407
|
+
continue;
|
|
408
|
+
case 3:
|
|
409
|
+
if (tag !== 26) {
|
|
410
|
+
break;
|
|
411
|
+
}
|
|
412
|
+
message.shareId = reader.string();
|
|
413
|
+
continue;
|
|
414
|
+
case 4:
|
|
415
|
+
if (tag !== 34) {
|
|
416
|
+
break;
|
|
417
|
+
}
|
|
418
|
+
message.mapName = reader.string();
|
|
419
|
+
continue;
|
|
420
|
+
case 5:
|
|
421
|
+
if (tag !== 42) {
|
|
422
|
+
break;
|
|
423
|
+
}
|
|
424
|
+
message.mapId = reader.string();
|
|
425
|
+
continue;
|
|
426
|
+
case 6:
|
|
427
|
+
if (tag !== 48) {
|
|
428
|
+
break;
|
|
429
|
+
}
|
|
430
|
+
message.mapShareCreatedAt = longToNumber(reader.uint64());
|
|
431
|
+
continue;
|
|
432
|
+
case 7:
|
|
433
|
+
if (tag !== 56) {
|
|
434
|
+
break;
|
|
435
|
+
}
|
|
436
|
+
message.mapCreatedAt = longToNumber(reader.uint64());
|
|
437
|
+
continue;
|
|
438
|
+
case 8:
|
|
439
|
+
if (tag === 65) {
|
|
440
|
+
message.bounds.push(reader.double());
|
|
441
|
+
continue;
|
|
442
|
+
}
|
|
443
|
+
if (tag === 66) {
|
|
444
|
+
var end2 = reader.uint32() + reader.pos;
|
|
445
|
+
while (reader.pos < end2) {
|
|
446
|
+
message.bounds.push(reader.double());
|
|
447
|
+
}
|
|
448
|
+
continue;
|
|
449
|
+
}
|
|
450
|
+
break;
|
|
451
|
+
case 9:
|
|
452
|
+
if (tag !== 72) {
|
|
453
|
+
break;
|
|
454
|
+
}
|
|
455
|
+
message.minzoom = reader.int32();
|
|
456
|
+
continue;
|
|
457
|
+
case 10:
|
|
458
|
+
if (tag !== 80) {
|
|
459
|
+
break;
|
|
460
|
+
}
|
|
461
|
+
message.maxzoom = reader.int32();
|
|
462
|
+
continue;
|
|
463
|
+
case 11:
|
|
464
|
+
if (tag !== 88) {
|
|
465
|
+
break;
|
|
466
|
+
}
|
|
467
|
+
message.estimatedSizeBytes = longToNumber(reader.uint64());
|
|
468
|
+
continue;
|
|
469
|
+
}
|
|
470
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
471
|
+
break;
|
|
472
|
+
}
|
|
473
|
+
reader.skipType(tag & 7);
|
|
474
|
+
}
|
|
475
|
+
return message;
|
|
476
|
+
},
|
|
477
|
+
create: function (base) {
|
|
478
|
+
return MapShareExtension.fromPartial(base !== null && base !== void 0 ? base : {});
|
|
479
|
+
},
|
|
480
|
+
fromPartial: function (object) {
|
|
481
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
482
|
+
var message = createBaseMapShareExtension();
|
|
483
|
+
message.mapShareUrls = ((_a = object.mapShareUrls) === null || _a === void 0 ? void 0 : _a.map(function (e) { return e; })) || [];
|
|
484
|
+
message.receiverDeviceId = (_b = object.receiverDeviceId) !== null && _b !== void 0 ? _b : "";
|
|
485
|
+
message.shareId = (_c = object.shareId) !== null && _c !== void 0 ? _c : "";
|
|
486
|
+
message.mapName = (_d = object.mapName) !== null && _d !== void 0 ? _d : "";
|
|
487
|
+
message.mapId = (_e = object.mapId) !== null && _e !== void 0 ? _e : "";
|
|
488
|
+
message.mapShareCreatedAt = (_f = object.mapShareCreatedAt) !== null && _f !== void 0 ? _f : 0;
|
|
489
|
+
message.mapCreatedAt = (_g = object.mapCreatedAt) !== null && _g !== void 0 ? _g : 0;
|
|
490
|
+
message.bounds = ((_h = object.bounds) === null || _h === void 0 ? void 0 : _h.map(function (e) { return e; })) || [];
|
|
491
|
+
message.minzoom = (_j = object.minzoom) !== null && _j !== void 0 ? _j : 0;
|
|
492
|
+
message.maxzoom = (_k = object.maxzoom) !== null && _k !== void 0 ? _k : 0;
|
|
493
|
+
message.estimatedSizeBytes = (_l = object.estimatedSizeBytes) !== null && _l !== void 0 ? _l : 0;
|
|
494
|
+
return message;
|
|
495
|
+
},
|
|
496
|
+
};
|
|
332
497
|
var tsProtoGlobalThis = (function () {
|
|
333
498
|
if (typeof globalThis !== "undefined") {
|
|
334
499
|
return globalThis;
|
|
@@ -87,6 +87,31 @@ export interface DownloadIntentExtension_DownloadIntentsEntry {
|
|
|
87
87
|
value: DownloadIntentExtension_DownloadIntent | undefined;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
export interface MapShareExtension {
|
|
91
|
+
/** URLs to map share */
|
|
92
|
+
mapShareUrls: string[];
|
|
93
|
+
/** ID of peer that can receive the map share (each map share is linked to a specific device ID) */
|
|
94
|
+
receiverDeviceId: string;
|
|
95
|
+
/** The ID of the map share */
|
|
96
|
+
shareId: string;
|
|
97
|
+
/** The name of the map being shared */
|
|
98
|
+
mapName: string;
|
|
99
|
+
/** The ID of the map being shared */
|
|
100
|
+
mapId: string;
|
|
101
|
+
/** When ths share was created */
|
|
102
|
+
mapShareCreatedAt: number;
|
|
103
|
+
/** When the map was created */
|
|
104
|
+
mapCreatedAt: number;
|
|
105
|
+
/** The bounding box of the map data being shared */
|
|
106
|
+
bounds: number[];
|
|
107
|
+
/** The minimum zoom level of the map data being shared */
|
|
108
|
+
minzoom: number;
|
|
109
|
+
/** The maximum zoom level of the map data being shared */
|
|
110
|
+
maxzoom: number;
|
|
111
|
+
/** Estimated size of the map data being shared in bytes */
|
|
112
|
+
estimatedSizeBytes: number;
|
|
113
|
+
}
|
|
114
|
+
|
|
90
115
|
function createBaseProjectExtension(): ProjectExtension {
|
|
91
116
|
return { authCoreKeys: [] };
|
|
92
117
|
}
|
|
@@ -393,6 +418,185 @@ export const DownloadIntentExtension_DownloadIntentsEntry = {
|
|
|
393
418
|
},
|
|
394
419
|
};
|
|
395
420
|
|
|
421
|
+
function createBaseMapShareExtension(): MapShareExtension {
|
|
422
|
+
return {
|
|
423
|
+
mapShareUrls: [],
|
|
424
|
+
receiverDeviceId: "",
|
|
425
|
+
shareId: "",
|
|
426
|
+
mapName: "",
|
|
427
|
+
mapId: "",
|
|
428
|
+
mapShareCreatedAt: 0,
|
|
429
|
+
mapCreatedAt: 0,
|
|
430
|
+
bounds: [],
|
|
431
|
+
minzoom: 0,
|
|
432
|
+
maxzoom: 0,
|
|
433
|
+
estimatedSizeBytes: 0,
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
export const MapShareExtension = {
|
|
438
|
+
encode(message: MapShareExtension, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
|
439
|
+
for (const v of message.mapShareUrls) {
|
|
440
|
+
writer.uint32(10).string(v!);
|
|
441
|
+
}
|
|
442
|
+
if (message.receiverDeviceId !== "") {
|
|
443
|
+
writer.uint32(18).string(message.receiverDeviceId);
|
|
444
|
+
}
|
|
445
|
+
if (message.shareId !== "") {
|
|
446
|
+
writer.uint32(26).string(message.shareId);
|
|
447
|
+
}
|
|
448
|
+
if (message.mapName !== "") {
|
|
449
|
+
writer.uint32(34).string(message.mapName);
|
|
450
|
+
}
|
|
451
|
+
if (message.mapId !== "") {
|
|
452
|
+
writer.uint32(42).string(message.mapId);
|
|
453
|
+
}
|
|
454
|
+
if (message.mapShareCreatedAt !== 0) {
|
|
455
|
+
writer.uint32(48).uint64(message.mapShareCreatedAt);
|
|
456
|
+
}
|
|
457
|
+
if (message.mapCreatedAt !== 0) {
|
|
458
|
+
writer.uint32(56).uint64(message.mapCreatedAt);
|
|
459
|
+
}
|
|
460
|
+
writer.uint32(66).fork();
|
|
461
|
+
for (const v of message.bounds) {
|
|
462
|
+
writer.double(v);
|
|
463
|
+
}
|
|
464
|
+
writer.ldelim();
|
|
465
|
+
if (message.minzoom !== 0) {
|
|
466
|
+
writer.uint32(72).int32(message.minzoom);
|
|
467
|
+
}
|
|
468
|
+
if (message.maxzoom !== 0) {
|
|
469
|
+
writer.uint32(80).int32(message.maxzoom);
|
|
470
|
+
}
|
|
471
|
+
if (message.estimatedSizeBytes !== 0) {
|
|
472
|
+
writer.uint32(88).uint64(message.estimatedSizeBytes);
|
|
473
|
+
}
|
|
474
|
+
return writer;
|
|
475
|
+
},
|
|
476
|
+
|
|
477
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): MapShareExtension {
|
|
478
|
+
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
|
|
479
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
|
480
|
+
const message = createBaseMapShareExtension();
|
|
481
|
+
while (reader.pos < end) {
|
|
482
|
+
const tag = reader.uint32();
|
|
483
|
+
switch (tag >>> 3) {
|
|
484
|
+
case 1:
|
|
485
|
+
if (tag !== 10) {
|
|
486
|
+
break;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
message.mapShareUrls.push(reader.string());
|
|
490
|
+
continue;
|
|
491
|
+
case 2:
|
|
492
|
+
if (tag !== 18) {
|
|
493
|
+
break;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
message.receiverDeviceId = reader.string();
|
|
497
|
+
continue;
|
|
498
|
+
case 3:
|
|
499
|
+
if (tag !== 26) {
|
|
500
|
+
break;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
message.shareId = reader.string();
|
|
504
|
+
continue;
|
|
505
|
+
case 4:
|
|
506
|
+
if (tag !== 34) {
|
|
507
|
+
break;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
message.mapName = reader.string();
|
|
511
|
+
continue;
|
|
512
|
+
case 5:
|
|
513
|
+
if (tag !== 42) {
|
|
514
|
+
break;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
message.mapId = reader.string();
|
|
518
|
+
continue;
|
|
519
|
+
case 6:
|
|
520
|
+
if (tag !== 48) {
|
|
521
|
+
break;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
message.mapShareCreatedAt = longToNumber(reader.uint64() as Long);
|
|
525
|
+
continue;
|
|
526
|
+
case 7:
|
|
527
|
+
if (tag !== 56) {
|
|
528
|
+
break;
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
message.mapCreatedAt = longToNumber(reader.uint64() as Long);
|
|
532
|
+
continue;
|
|
533
|
+
case 8:
|
|
534
|
+
if (tag === 65) {
|
|
535
|
+
message.bounds.push(reader.double());
|
|
536
|
+
|
|
537
|
+
continue;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
if (tag === 66) {
|
|
541
|
+
const end2 = reader.uint32() + reader.pos;
|
|
542
|
+
while (reader.pos < end2) {
|
|
543
|
+
message.bounds.push(reader.double());
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
continue;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
break;
|
|
550
|
+
case 9:
|
|
551
|
+
if (tag !== 72) {
|
|
552
|
+
break;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
message.minzoom = reader.int32();
|
|
556
|
+
continue;
|
|
557
|
+
case 10:
|
|
558
|
+
if (tag !== 80) {
|
|
559
|
+
break;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
message.maxzoom = reader.int32();
|
|
563
|
+
continue;
|
|
564
|
+
case 11:
|
|
565
|
+
if (tag !== 88) {
|
|
566
|
+
break;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
message.estimatedSizeBytes = longToNumber(reader.uint64() as Long);
|
|
570
|
+
continue;
|
|
571
|
+
}
|
|
572
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
573
|
+
break;
|
|
574
|
+
}
|
|
575
|
+
reader.skipType(tag & 7);
|
|
576
|
+
}
|
|
577
|
+
return message;
|
|
578
|
+
},
|
|
579
|
+
|
|
580
|
+
create<I extends Exact<DeepPartial<MapShareExtension>, I>>(base?: I): MapShareExtension {
|
|
581
|
+
return MapShareExtension.fromPartial(base ?? ({} as any));
|
|
582
|
+
},
|
|
583
|
+
fromPartial<I extends Exact<DeepPartial<MapShareExtension>, I>>(object: I): MapShareExtension {
|
|
584
|
+
const message = createBaseMapShareExtension();
|
|
585
|
+
message.mapShareUrls = object.mapShareUrls?.map((e) => e) || [];
|
|
586
|
+
message.receiverDeviceId = object.receiverDeviceId ?? "";
|
|
587
|
+
message.shareId = object.shareId ?? "";
|
|
588
|
+
message.mapName = object.mapName ?? "";
|
|
589
|
+
message.mapId = object.mapId ?? "";
|
|
590
|
+
message.mapShareCreatedAt = object.mapShareCreatedAt ?? 0;
|
|
591
|
+
message.mapCreatedAt = object.mapCreatedAt ?? 0;
|
|
592
|
+
message.bounds = object.bounds?.map((e) => e) || [];
|
|
593
|
+
message.minzoom = object.minzoom ?? 0;
|
|
594
|
+
message.maxzoom = object.maxzoom ?? 0;
|
|
595
|
+
message.estimatedSizeBytes = object.estimatedSizeBytes ?? 0;
|
|
596
|
+
return message;
|
|
597
|
+
},
|
|
598
|
+
};
|
|
599
|
+
|
|
396
600
|
declare const self: any | undefined;
|
|
397
601
|
declare const window: any | undefined;
|
|
398
602
|
declare const global: any | undefined;
|
package/src/index.js
CHANGED
|
@@ -9,6 +9,7 @@ export { FastifyController } from './fastify-controller.js'
|
|
|
9
9
|
export { MapeoManager } from './mapeo-manager.js'
|
|
10
10
|
|
|
11
11
|
// Type exports
|
|
12
|
+
/** @typedef {import('./mapeo-project.js').MapShare} MapShare */
|
|
12
13
|
/** @typedef {import('./mapeo-project.js').MapeoProject} MapeoProject */
|
|
13
14
|
/** @typedef {import('./mapeo-project.js').EditableProjectSettings} EditableProjectSettings */
|
|
14
15
|
/**
|
package/src/mapeo-manager.js
CHANGED
|
@@ -54,6 +54,7 @@ import { WebSocket } from 'ws'
|
|
|
54
54
|
import { excludeKeys } from 'filter-obj'
|
|
55
55
|
import { migrate } from './lib/drizzle-helpers.js'
|
|
56
56
|
|
|
57
|
+
/** @import { MapShareExtension } from './generated/extensions.js' */
|
|
57
58
|
/** @import NoiseSecretStream from '@hyperswarm/secret-stream' */
|
|
58
59
|
/** @import { SetNonNullable } from 'type-fest' */
|
|
59
60
|
/** @import { ProjectJoinDetails, } from './generated/rpc.js' */
|
|
@@ -99,6 +100,8 @@ export const DEFAULT_IS_ARCHIVE_DEVICE = true
|
|
|
99
100
|
/**
|
|
100
101
|
* @typedef {object} MapeoManagerEvents
|
|
101
102
|
* @property {(peers: PublicPeerInfo[]) => void} local-peers Emitted when the list of connected peers changes (new ones added, or connection status changes)
|
|
103
|
+
* @property {(mapShare: import('./mapeo-project.js').MapShare) => void} map-share Emitted when a project has recieved a map share request
|
|
104
|
+
* @property {(e: Error, mapShare: MapShareExtension) => void} map-share-error - Emitted when an incoming map share fails to be recieved due to formatting issues
|
|
102
105
|
*/
|
|
103
106
|
|
|
104
107
|
/**
|
|
@@ -465,10 +468,6 @@ export class MapeoManager extends TypedEmitter {
|
|
|
465
468
|
projectSecretKey: projectKeypair.secretKey,
|
|
466
469
|
})
|
|
467
470
|
|
|
468
|
-
project.once('close', () => {
|
|
469
|
-
this.#activeProjects.delete(projectPublicId)
|
|
470
|
-
})
|
|
471
|
-
|
|
472
471
|
// 5. Write project settings to project instance
|
|
473
472
|
await project.$setProjectSettings({
|
|
474
473
|
name,
|
|
@@ -545,10 +544,6 @@ export class MapeoManager extends TypedEmitter {
|
|
|
545
544
|
await project[kClearData]()
|
|
546
545
|
}
|
|
547
546
|
|
|
548
|
-
project.once('close', () => {
|
|
549
|
-
this.#activeProjects.delete(projectPublicId)
|
|
550
|
-
})
|
|
551
|
-
|
|
552
547
|
// 3. Keep track of project instance as we know it's a properly existing project
|
|
553
548
|
this.#activeProjects.set(projectPublicId, project)
|
|
554
549
|
|
|
@@ -580,6 +575,35 @@ export class MapeoManager extends TypedEmitter {
|
|
|
580
575
|
.get()?.projectInfo
|
|
581
576
|
},
|
|
582
577
|
})
|
|
578
|
+
|
|
579
|
+
const projectPublicId = projectKeyToPublicId(projectKeys.projectKey)
|
|
580
|
+
|
|
581
|
+
/**
|
|
582
|
+
* @param {import('./mapeo-project.js').MapShare} mapShare
|
|
583
|
+
*/
|
|
584
|
+
const onMapShare = (mapShare) => {
|
|
585
|
+
this.emit('map-share', mapShare)
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
/**
|
|
589
|
+
*
|
|
590
|
+
* @param {Error} err
|
|
591
|
+
* @param {MapShareExtension} mapShareExtension
|
|
592
|
+
*/
|
|
593
|
+
const onMapShareError = (err, mapShareExtension) => {
|
|
594
|
+
this.emit('map-share-error', err, mapShareExtension)
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
project.once('close', () => {
|
|
598
|
+
this.#activeProjects.delete(projectPublicId)
|
|
599
|
+
project.removeListener('map-share', onMapShare)
|
|
600
|
+
project.removeListener('map-share-error', onMapShareError)
|
|
601
|
+
})
|
|
602
|
+
|
|
603
|
+
project.on('map-share', onMapShare)
|
|
604
|
+
|
|
605
|
+
project.on('map-share-error', onMapShareError)
|
|
606
|
+
|
|
583
607
|
return project
|
|
584
608
|
}
|
|
585
609
|
|
package/src/mapeo-project.js
CHANGED
|
@@ -36,7 +36,12 @@ import {
|
|
|
36
36
|
getWinner,
|
|
37
37
|
mapAndValidateCoreOwnership,
|
|
38
38
|
} from './core-ownership.js'
|
|
39
|
-
import {
|
|
39
|
+
import {
|
|
40
|
+
BLOCKED_ROLE_ID,
|
|
41
|
+
Roles,
|
|
42
|
+
LEFT_ROLE_ID,
|
|
43
|
+
INACTIVE_MEMBER_ROLE_IDS,
|
|
44
|
+
} from './roles.js'
|
|
40
45
|
import {
|
|
41
46
|
assert,
|
|
42
47
|
buildBlobId,
|
|
@@ -44,6 +49,7 @@ import {
|
|
|
44
49
|
getDeviceId,
|
|
45
50
|
projectKeyToId,
|
|
46
51
|
projectKeyToPublicId,
|
|
52
|
+
validateMapShareExtension,
|
|
47
53
|
valueOf,
|
|
48
54
|
} from './utils.js'
|
|
49
55
|
import { migrate } from './lib/drizzle-helpers.js'
|
|
@@ -62,6 +68,7 @@ import { NotFoundError, nullIfNotFound } from './errors.js'
|
|
|
62
68
|
import { WebSocket } from 'ws'
|
|
63
69
|
import { createWriteStream } from 'fs'
|
|
64
70
|
import ensureError from 'ensure-error'
|
|
71
|
+
/** @import { MapShareExtension } from './generated/extensions.js' */
|
|
65
72
|
/** @import { ProjectSettingsValue, Observation, Track } from '@comapeo/schema' */
|
|
66
73
|
/** @import { Attachment, CoreStorage, BlobFilter, BlobId, BlobStoreEntriesStream, KeyPair, Namespace, ReplicationStream, GenericBlobFilter, MapeoValueMap, MapeoDocMap } from './types.js' */
|
|
67
74
|
/** @import {Role} from './roles.js' */
|
|
@@ -109,10 +116,25 @@ const VARIANT_EXPORT_ORDER = ['original', 'preview', 'thumbnail']
|
|
|
109
116
|
* @property {Role & {reason: string | undefined}} role
|
|
110
117
|
*/
|
|
111
118
|
|
|
119
|
+
/**
|
|
120
|
+
* @typedef {object} AugmentedMapShareProperties
|
|
121
|
+
* @property {readonly [number, number, number, number]} bounds - Bounding box of the shared map [W, S, E, N].
|
|
122
|
+
* @property {readonly [string, ...string[]]} mapShareUrls - URLs associated with the map share.
|
|
123
|
+
* @property {number} mapShareReceivedAt - Timestamp when the map share was received.
|
|
124
|
+
* @property {string} senderDeviceId - The ID of the device that sent the map share.
|
|
125
|
+
* @property {string} [senderDeviceName] - The name of the device that sent the map share.
|
|
126
|
+
*/
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* @typedef {Omit<MapShareExtension, 'bounds' | 'mapShareUrls'> & AugmentedMapShareProperties} MapShare
|
|
130
|
+
*/
|
|
131
|
+
|
|
112
132
|
/**
|
|
113
133
|
* @typedef {object} ProjectEvents
|
|
114
134
|
* @property {() => void} close Project resources have been cleared up
|
|
115
135
|
* @property {(changeEvent: RoleChangeEvent) => void} own-role-change
|
|
136
|
+
* @property {(e: Error, mapShare: MapShareExtension) => void} map-share-error - Emitted when an incoming map share fails to be recieved due to formatting issues
|
|
137
|
+
* @property {(mapShare: MapShare) => void} map-share - Emitted when a map share is recieved from someone on the project
|
|
116
138
|
*/
|
|
117
139
|
|
|
118
140
|
/**
|
|
@@ -525,6 +547,16 @@ export class MapeoProject extends TypedEmitter {
|
|
|
525
547
|
}
|
|
526
548
|
})
|
|
527
549
|
|
|
550
|
+
this.#coreManager.on('map-share', (mapShareBase, senderDeviceId) =>
|
|
551
|
+
this.#handleMapShare(mapShareBase, senderDeviceId).catch((e) => {
|
|
552
|
+
this.emit('map-share-error', e, mapShareBase)
|
|
553
|
+
this.#l.log(
|
|
554
|
+
'Error: Unable to handle incoming Map Share',
|
|
555
|
+
ensureError(e)
|
|
556
|
+
)
|
|
557
|
+
})
|
|
558
|
+
)
|
|
559
|
+
|
|
528
560
|
this.once('close', () => {
|
|
529
561
|
localPeers.off('peer-add', onPeerAdd)
|
|
530
562
|
localPeers.off('discovery-key', onDiscoverykey)
|
|
@@ -751,6 +783,34 @@ export class MapeoProject extends TypedEmitter {
|
|
|
751
783
|
this.emit('own-role-change', { role })
|
|
752
784
|
}
|
|
753
785
|
|
|
786
|
+
/**
|
|
787
|
+
* @param {MapShareExtension} mapShareBase
|
|
788
|
+
* @param {string} senderDeviceId
|
|
789
|
+
*/
|
|
790
|
+
async #handleMapShare(mapShareBase, senderDeviceId) {
|
|
791
|
+
const mapShareReceivedAt = Date.now()
|
|
792
|
+
|
|
793
|
+
validateMapShareExtension(mapShareBase)
|
|
794
|
+
|
|
795
|
+
const sender = await this.$member.getById(senderDeviceId)
|
|
796
|
+
|
|
797
|
+
if (INACTIVE_MEMBER_ROLE_IDS.includes(sender.role.roleId)) {
|
|
798
|
+
throw new Error(
|
|
799
|
+
`Map Share Sender is not an active member of the project (role: ${sender.role.name})`
|
|
800
|
+
)
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
/** @type {MapShare} */
|
|
804
|
+
const mapShare = {
|
|
805
|
+
...mapShareBase,
|
|
806
|
+
senderDeviceId,
|
|
807
|
+
senderDeviceName: sender.name,
|
|
808
|
+
mapShareReceivedAt,
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
this.emit('map-share', mapShare)
|
|
812
|
+
}
|
|
813
|
+
|
|
754
814
|
/**
|
|
755
815
|
* @deprecated
|
|
756
816
|
* @param {string} originalVersionId The `originalVersionId` from a document.
|
|
@@ -1391,6 +1451,21 @@ export class MapeoProject extends TypedEmitter {
|
|
|
1391
1451
|
this.#importingCategories = false
|
|
1392
1452
|
}
|
|
1393
1453
|
}
|
|
1454
|
+
|
|
1455
|
+
/**
|
|
1456
|
+
* Send a map share offer to the peer with device ID `mapShare.receiverDeviceId`
|
|
1457
|
+
*
|
|
1458
|
+
* @param {MapShareExtension} mapShare
|
|
1459
|
+
* @param {object} [options]
|
|
1460
|
+
* @param {boolean} [options.__testOnlyBypassValidation=false] Warning: Do not use!
|
|
1461
|
+
*/
|
|
1462
|
+
async $sendMapShare(mapShare, { __testOnlyBypassValidation = false } = {}) {
|
|
1463
|
+
if (!__testOnlyBypassValidation) {
|
|
1464
|
+
validateMapShareExtension(mapShare)
|
|
1465
|
+
}
|
|
1466
|
+
const peerId = Buffer.from(mapShare.receiverDeviceId, 'hex')
|
|
1467
|
+
await this.#coreManager.sendMapShare(mapShare, peerId)
|
|
1468
|
+
}
|
|
1394
1469
|
}
|
|
1395
1470
|
|
|
1396
1471
|
/**
|
package/src/roles.js
CHANGED
|
@@ -14,6 +14,12 @@ export const BLOCKED_ROLE_ID = '9e6d29263cba36c9'
|
|
|
14
14
|
export const LEFT_ROLE_ID = '8ced989b1904606b'
|
|
15
15
|
export const NO_ROLE_ID = '08e4251e36f6e7ed'
|
|
16
16
|
|
|
17
|
+
export const INACTIVE_MEMBER_ROLE_IDS = [
|
|
18
|
+
BLOCKED_ROLE_ID,
|
|
19
|
+
LEFT_ROLE_ID,
|
|
20
|
+
NO_ROLE_ID,
|
|
21
|
+
]
|
|
22
|
+
|
|
17
23
|
/**
|
|
18
24
|
* @typedef {T extends Iterable<infer U> ? U : never} ElementOf
|
|
19
25
|
* @template T
|
package/src/utils.js
CHANGED
|
@@ -4,10 +4,13 @@ import { createHash } from 'node:crypto'
|
|
|
4
4
|
import stableStringify from 'json-stable-stringify'
|
|
5
5
|
import { omit } from './lib/omit.js'
|
|
6
6
|
|
|
7
|
+
/** @import { MapShareExtension } from './generated/extensions.js' */
|
|
7
8
|
/** @import {Attachment, BlobId} from "./types.js" */
|
|
8
9
|
|
|
9
10
|
const PROJECT_INVITE_ID_SALT = Buffer.from('mapeo project invite id', 'ascii')
|
|
10
11
|
|
|
12
|
+
export const MAX_BOUNDS = [-180, -85.051129, 180, 85.051129]
|
|
13
|
+
|
|
11
14
|
/**
|
|
12
15
|
*
|
|
13
16
|
* @param {Buffer|String} key
|
|
@@ -253,3 +256,74 @@ export function buildBlobId(attachment, requestedVariant) {
|
|
|
253
256
|
export function typedEntries(obj) {
|
|
254
257
|
return /** @type {import('type-fest').Entries<T>} */ (Object.entries(obj))
|
|
255
258
|
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Validate map share extension messages to check that all their parameters make sense
|
|
262
|
+
* Does not validate device ID or device name
|
|
263
|
+
*
|
|
264
|
+
* @param {MapShareExtension} mapShare
|
|
265
|
+
* @returns {asserts mapShare is { [K in keyof MapShareExtension]: import('./mapeo-project.js').MapShare[K] }} - this validates the properties that MapShareExtension and MapShare have in common - bounds tuple and mapShareUrls
|
|
266
|
+
*/
|
|
267
|
+
export function validateMapShareExtension(mapShare) {
|
|
268
|
+
const {
|
|
269
|
+
mapShareUrls,
|
|
270
|
+
receiverDeviceId,
|
|
271
|
+
mapId,
|
|
272
|
+
mapName,
|
|
273
|
+
shareId,
|
|
274
|
+
bounds,
|
|
275
|
+
minzoom,
|
|
276
|
+
maxzoom,
|
|
277
|
+
estimatedSizeBytes,
|
|
278
|
+
mapCreatedAt,
|
|
279
|
+
mapShareCreatedAt,
|
|
280
|
+
} = mapShare
|
|
281
|
+
|
|
282
|
+
if (!receiverDeviceId.length) {
|
|
283
|
+
throw new Error('Receiver Device ID must not be empty')
|
|
284
|
+
}
|
|
285
|
+
if (!mapId.length) throw new Error('Map ID must not be empty')
|
|
286
|
+
if (!shareId.length) throw new Error('Share ID must not be empty')
|
|
287
|
+
if (!mapName.length) throw new Error('Map Name must not be empty')
|
|
288
|
+
if (!mapShareUrls.length) throw new Error('Map share URLs must not be empty')
|
|
289
|
+
if (!mapShareUrls.every((url) => URL.canParse(url))) {
|
|
290
|
+
throw new Error('Map share URLs must be valid URLs')
|
|
291
|
+
}
|
|
292
|
+
if (!mapCreatedAt) throw new Error('mapCreatedAt must be set')
|
|
293
|
+
if (!mapShareCreatedAt) throw new Error('mapShareCreatedAt must be set')
|
|
294
|
+
if (bounds.length !== 4) {
|
|
295
|
+
throw new Error('Bounds must be bounding box with 4 values')
|
|
296
|
+
}
|
|
297
|
+
if (bounds[0] < MAX_BOUNDS[0]) {
|
|
298
|
+
throw new Error(
|
|
299
|
+
`Bounds at ${0} must be within max of spherical mercator projection ${MAX_BOUNDS}`
|
|
300
|
+
)
|
|
301
|
+
}
|
|
302
|
+
if (bounds[1] < MAX_BOUNDS[1]) {
|
|
303
|
+
throw new Error(
|
|
304
|
+
`Bounds at ${1} must be within max of spherical mercator projection ${MAX_BOUNDS}`
|
|
305
|
+
)
|
|
306
|
+
}
|
|
307
|
+
if (bounds[2] > MAX_BOUNDS[2]) {
|
|
308
|
+
throw new Error(
|
|
309
|
+
`Bounds at ${2} must be within max of spherical mercator projection ${MAX_BOUNDS}`
|
|
310
|
+
)
|
|
311
|
+
}
|
|
312
|
+
if (bounds[3] > MAX_BOUNDS[3]) {
|
|
313
|
+
throw new Error(
|
|
314
|
+
`Bounds at ${3} must be within max of spherical mercator projection ${MAX_BOUNDS}`
|
|
315
|
+
)
|
|
316
|
+
}
|
|
317
|
+
if (maxzoom < minzoom) {
|
|
318
|
+
throw new Error('Max zoom must be greater than or equal to min zoom')
|
|
319
|
+
}
|
|
320
|
+
if (maxzoom < 0 || maxzoom > 22) {
|
|
321
|
+
throw new Error('Max zoom must be between 0 and 22')
|
|
322
|
+
}
|
|
323
|
+
if (minzoom < 0 || minzoom > 22) {
|
|
324
|
+
throw new Error('Min zoom must be between 0 and 22')
|
|
325
|
+
}
|
|
326
|
+
if (estimatedSizeBytes <= 0) {
|
|
327
|
+
throw new Error('Map size bytes must greater than zero')
|
|
328
|
+
}
|
|
329
|
+
}
|