@bitblit/ratchet-common 5.0.111 → 5.0.112

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.
Files changed (38) hide show
  1. package/lib/lang/web-stream-ratchet.d.ts +1 -0
  2. package/lib/lang/web-stream-ratchet.js +14 -0
  3. package/lib/lang/web-stream-ratchet.js.map +1 -1
  4. package/lib/network/{remote-file-sync → remote-file-tracker}/backup-result.d.ts +2 -1
  5. package/lib/network/{remote-file-sync → remote-file-tracker}/backup-result.js +1 -0
  6. package/lib/network/remote-file-tracker/backup-result.js.map +1 -0
  7. package/lib/network/{remote-file-sync/file-transfer-result.d.ts → remote-file-tracker/file-transfer-result-type.d.ts} +1 -1
  8. package/lib/network/remote-file-tracker/file-transfer-result-type.js +7 -0
  9. package/lib/network/remote-file-tracker/file-transfer-result-type.js.map +1 -0
  10. package/lib/network/remote-file-tracker/file-transfer-result.d.ts +8 -0
  11. package/lib/network/remote-file-tracker/file-transfer-result.js +2 -0
  12. package/lib/network/remote-file-tracker/file-transfer-result.js.map +1 -0
  13. package/lib/network/remote-file-tracker/remote-file-tracker-options.d.ts +5 -0
  14. package/lib/network/remote-file-tracker/remote-file-tracker-options.js +2 -0
  15. package/lib/network/remote-file-tracker/remote-file-tracker-options.js.map +1 -0
  16. package/lib/network/remote-file-tracker/remote-file-tracker-push-options.d.ts +4 -0
  17. package/lib/network/remote-file-tracker/remote-file-tracker-push-options.js +2 -0
  18. package/lib/network/remote-file-tracker/remote-file-tracker-push-options.js.map +1 -0
  19. package/lib/network/remote-file-tracker/remote-file-tracker.d.ts +21 -0
  20. package/lib/network/remote-file-tracker/remote-file-tracker.js +88 -0
  21. package/lib/network/remote-file-tracker/remote-file-tracker.js.map +1 -0
  22. package/lib/network/remote-file-tracker/remote-file-tracking-provider.d.ts +9 -0
  23. package/lib/network/remote-file-tracker/remote-file-tracking-provider.js +2 -0
  24. package/lib/network/remote-file-tracker/remote-file-tracking-provider.js.map +1 -0
  25. package/lib/network/remote-file-tracker/remote-status-data-and-content.d.ts +5 -0
  26. package/lib/network/remote-file-tracker/remote-status-data-and-content.js +2 -0
  27. package/lib/network/remote-file-tracker/remote-status-data-and-content.js.map +1 -0
  28. package/lib/network/{remote-file-sync → remote-file-tracker}/remote-status-data.d.ts +3 -2
  29. package/lib/network/remote-file-tracker/remote-status-data.js.map +1 -0
  30. package/package.json +1 -1
  31. package/lib/network/remote-file-sync/backup-result.js.map +0 -1
  32. package/lib/network/remote-file-sync/file-transfer-result.js +0 -7
  33. package/lib/network/remote-file-sync/file-transfer-result.js.map +0 -1
  34. package/lib/network/remote-file-sync/remote-file-sync-like.d.ts +0 -16
  35. package/lib/network/remote-file-sync/remote-file-sync-like.js +0 -2
  36. package/lib/network/remote-file-sync/remote-file-sync-like.js.map +0 -1
  37. package/lib/network/remote-file-sync/remote-status-data.js.map +0 -1
  38. /package/lib/network/{remote-file-sync → remote-file-tracker}/remote-status-data.js +0 -0
@@ -3,4 +3,5 @@ export declare class WebStreamRatchet {
3
3
  static webReadableStreamToUint8Array(stream: ReadableStream): Promise<Uint8Array>;
4
4
  static webReadableStreamToString(stream: ReadableStream): Promise<string>;
5
5
  static stringToWebReadableStream(input: string): ReadableStream;
6
+ static uint8ArrayToWebReadableStream(input: Uint8Array): ReadableStream;
6
7
  }
@@ -43,5 +43,19 @@ export class WebStreamRatchet {
43
43
  });
44
44
  return rval;
45
45
  }
46
+ static uint8ArrayToWebReadableStream(input) {
47
+ const rval = new ReadableStream({
48
+ start(controller) {
49
+ if (input) {
50
+ controller.enqueue(input);
51
+ }
52
+ controller.close();
53
+ return null;
54
+ },
55
+ }, {
56
+ highWaterMark: input ? input.length : null,
57
+ });
58
+ return rval;
59
+ }
46
60
  }
47
61
  //# sourceMappingURL=web-stream-ratchet.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"web-stream-ratchet.js","sourceRoot":"","sources":["../../src/lang/web-stream-ratchet.ts"],"names":[],"mappings":"AAAA,OAAO,EAA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Result {
2
2
  Success = "Success",
3
3
  Error = "Error",
4
- NotSupported = "NotSupported"
4
+ NotSupported = "NotSupported",
5
+ NotRequested = "NotRequested"
5
6
  }
@@ -3,5 +3,6 @@ export var BackupResult;
3
3
  BackupResult["Success"] = "Success";
4
4
  BackupResult["Error"] = "Error";
5
5
  BackupResult["NotSupported"] = "NotSupported";
6
+ BackupResult["NotRequested"] = "NotRequested";
6
7
  })(BackupResult || (BackupResult = {}));
7
8
  //# sourceMappingURL=backup-result.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backup-result.js","sourceRoot":"","sources":["../../../src/network/remote-file-tracker/backup-result.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,mCAAmB,CAAA;IACnB,+BAAe,CAAA;IACf,6CAA6B,CAAA;IAC7B,6CAA6B,CAAA;AAC/B,CAAC,EALW,YAAY,KAAZ,YAAY,QAKvB"}
@@ -1,4 +1,4 @@
1
- export declare enum FileTransferResult {
1
+ export declare enum FileTransferResultType {
2
2
  Updated = "Updated",
3
3
  Skipped = "Skipped",
4
4
  Error = "Error"
@@ -0,0 +1,7 @@
1
+ export var FileTransferResultType;
2
+ (function (FileTransferResultType) {
3
+ FileTransferResultType["Updated"] = "Updated";
4
+ FileTransferResultType["Skipped"] = "Skipped";
5
+ FileTransferResultType["Error"] = "Error";
6
+ })(FileTransferResultType || (FileTransferResultType = {}));
7
+ //# sourceMappingURL=file-transfer-result-type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-transfer-result-type.js","sourceRoot":"","sources":["../../../src/network/remote-file-tracker/file-transfer-result-type.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,sBAIX;AAJD,WAAY,sBAAsB;IAChC,6CAAmB,CAAA;IACnB,6CAAmB,CAAA;IACnB,yCAAe,CAAA;AACjB,CAAC,EAJW,sBAAsB,KAAtB,sBAAsB,QAIjC"}
@@ -0,0 +1,8 @@
1
+ import { FileTransferResultType } from "./file-transfer-result-type.js";
2
+ import { BackupResult } from "./backup-result.js";
3
+ export interface FileTransferResult {
4
+ type: FileTransferResultType;
5
+ error?: string;
6
+ bytesTransferred?: number;
7
+ backupResult: BackupResult;
8
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=file-transfer-result.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"file-transfer-result.js","sourceRoot":"","sources":["../../../src/network/remote-file-tracker/file-transfer-result.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ import { RemoteFileTrackingProvider } from "./remote-file-tracking-provider.js";
2
+ export interface RemoteFileTrackerOptions<KeyType> {
3
+ key: KeyType;
4
+ provider: RemoteFileTrackingProvider<KeyType>;
5
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=remote-file-tracker-options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote-file-tracker-options.js","sourceRoot":"","sources":["../../../src/network/remote-file-tracker/remote-file-tracker-options.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ export interface RemoteFileTrackerPushOptions {
2
+ force?: boolean;
3
+ backup?: boolean;
4
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=remote-file-tracker-push-options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote-file-tracker-push-options.js","sourceRoot":"","sources":["../../../src/network/remote-file-tracker/remote-file-tracker-push-options.ts"],"names":[],"mappings":""}
@@ -0,0 +1,21 @@
1
+ import { RemoteStatusData } from "./remote-status-data.js";
2
+ import { RemoteStatusDataAndContent } from "./remote-status-data-and-content.js";
3
+ import { RemoteFileTrackerOptions } from "./remote-file-tracker-options.js";
4
+ import { RemoteFileTrackerPushOptions } from "./remote-file-tracker-push-options.js";
5
+ export declare class RemoteFileTracker<KeyType> {
6
+ private opts;
7
+ private _remoteStatusData;
8
+ constructor(opts: RemoteFileTrackerOptions<KeyType>);
9
+ get remoteStatusData(): RemoteStatusData<KeyType>;
10
+ sync(): Promise<RemoteStatusData<KeyType>>;
11
+ pullRemoteData(ifNewerThan?: RemoteStatusData<KeyType>): Promise<RemoteStatusDataAndContent<KeyType>>;
12
+ static dataAsString(data: RemoteStatusDataAndContent<any>): Promise<string>;
13
+ static dataAsUint8Array(data: RemoteStatusDataAndContent<any>): Promise<Uint8Array>;
14
+ static dataAsObject<T>(data: RemoteStatusDataAndContent<any>): Promise<T>;
15
+ pushStreamToRemote(src: ReadableStream, inPushOpts?: RemoteFileTrackerPushOptions): Promise<RemoteStatusData<KeyType>>;
16
+ pushStringToRemote(src: string, inPushOpts?: RemoteFileTrackerPushOptions): Promise<RemoteStatusData<KeyType>>;
17
+ pushUint8ArrayToRemote(src: Uint8Array, inPushOpts?: RemoteFileTrackerPushOptions): Promise<RemoteStatusData<KeyType>>;
18
+ pushObjectJsonToRemote(src: any, inPushOpts?: RemoteFileTrackerPushOptions): Promise<RemoteStatusData<KeyType>>;
19
+ modifiedSinceLastSync(skipUpdateLocal?: boolean): Promise<boolean>;
20
+ static statusMatch(rsd1: RemoteStatusData<any>, rsd2: RemoteStatusData<any>): boolean;
21
+ }
@@ -0,0 +1,88 @@
1
+ import { FileTransferResultType } from "./file-transfer-result-type.js";
2
+ import { Logger } from "../../logger/logger.js";
3
+ import { RequireRatchet } from "../../lang/require-ratchet.js";
4
+ import { WebStreamRatchet } from "../../lang/web-stream-ratchet.js";
5
+ export class RemoteFileTracker {
6
+ opts;
7
+ _remoteStatusData;
8
+ constructor(opts) {
9
+ this.opts = opts;
10
+ RequireRatchet.notNullOrUndefined(opts, 'opts');
11
+ RequireRatchet.notNullOrUndefined(opts.provider, 'opts.provider');
12
+ RequireRatchet.notNullOrUndefined(opts.key, 'opts.key');
13
+ }
14
+ get remoteStatusData() {
15
+ return Object.assign({}, this._remoteStatusData);
16
+ }
17
+ async sync() {
18
+ this._remoteStatusData = await this.opts.provider.readRemoteStatus(this.opts.key);
19
+ return this._remoteStatusData;
20
+ }
21
+ async pullRemoteData(ifNewerThan) {
22
+ const rval = await this.opts.provider.pullRemoteData(this.opts.key, ifNewerThan);
23
+ if (rval) {
24
+ this._remoteStatusData = rval.status;
25
+ }
26
+ return rval;
27
+ }
28
+ static async dataAsString(data) {
29
+ let rval = null;
30
+ if (data?.content) {
31
+ rval = await WebStreamRatchet.webReadableStreamToString(data.content);
32
+ }
33
+ return rval;
34
+ }
35
+ static async dataAsUint8Array(data) {
36
+ let rval = null;
37
+ if (data?.content) {
38
+ rval = await WebStreamRatchet.webReadableStreamToUint8Array(data.content);
39
+ }
40
+ return rval;
41
+ }
42
+ static async dataAsObject(data) {
43
+ let rval = null;
44
+ if (data?.content) {
45
+ const txt = await this.dataAsString(data);
46
+ rval = JSON.parse(txt);
47
+ }
48
+ return rval;
49
+ }
50
+ async pushStreamToRemote(src, inPushOpts) {
51
+ RequireRatchet.notNullOrUndefined(src, 'src');
52
+ const pushOpts = Object.assign({ force: false, backup: false }, inPushOpts);
53
+ const result = await this.opts.provider.sendDataToRemote(src, this.opts.key, pushOpts, this._remoteStatusData);
54
+ if (result.type === FileTransferResultType.Updated) {
55
+ Logger.info('Sent %d bytes to remote, re-reading sync');
56
+ await this.sync();
57
+ }
58
+ return this._remoteStatusData;
59
+ }
60
+ async pushStringToRemote(src, inPushOpts) {
61
+ RequireRatchet.notNullOrUndefined(src, 'src');
62
+ const asString = WebStreamRatchet.stringToWebReadableStream(src);
63
+ return this.pushStreamToRemote(asString);
64
+ }
65
+ async pushUint8ArrayToRemote(src, inPushOpts) {
66
+ RequireRatchet.notNullOrUndefined(src, 'src');
67
+ const asString = WebStreamRatchet.uint8ArrayToWebReadableStream(src);
68
+ return this.pushStreamToRemote(asString);
69
+ }
70
+ async pushObjectJsonToRemote(src, inPushOpts) {
71
+ RequireRatchet.notNullOrUndefined(src, 'src');
72
+ const asString = JSON.stringify(src);
73
+ return this.pushStringToRemote(asString);
74
+ }
75
+ async modifiedSinceLastSync(skipUpdateLocal) {
76
+ const newData = await this.opts.provider.readRemoteStatus(this.opts.key);
77
+ const rval = !RemoteFileTracker.statusMatch(newData, this._remoteStatusData);
78
+ if (!skipUpdateLocal) {
79
+ this._remoteStatusData = newData;
80
+ }
81
+ return rval;
82
+ }
83
+ static statusMatch(rsd1, rsd2) {
84
+ return rsd1 && rsd2 && rsd1.remoteHash === rsd2.remoteHash && rsd1.remoteSizeInBytes === rsd2.remoteSizeInBytes
85
+ && rsd1.remoteLastUpdatedEpochMs === rsd2.remoteLastUpdatedEpochMs;
86
+ }
87
+ }
88
+ //# sourceMappingURL=remote-file-tracker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote-file-tracker.js","sourceRoot":"","sources":["../../../src/network/remote-file-tracker/remote-file-tracker.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAExE,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAEhD,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEpE,MAAM,OAAO,iBAAiB;IAIR;IAFZ,iBAAiB,CAA4B;IAErD,YAAoB,IAAuC;QAAvC,SAAI,GAAJ,IAAI,CAAmC;QACzD,cAAc,CAAC,kBAAkB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAChD,cAAc,CAAC,kBAAkB,CAAC,IAAI,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;QAClE,cAAc,CAAC,kBAAkB,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IAC1D,CAAC;IAED,IAAW,gBAAgB;QAEzB,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IAClD,CAAC;IAGM,KAAK,CAAC,IAAI;QACf,IAAI,CAAC,iBAAiB,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC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yC;QACrF,cAAc,CAAC,kBAAkB,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC9C,MAAM,QAAQ,GAAW,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;QAC7C,OAAO,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;IAC3C,CAAC;IAIM,KAAK,CAAC,qBAAqB,CAAC,eAAyB;QAC1D,MAAM,OAAO,GAA8B,MAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACpG,MAAM,IAAI,GAAY,CAAC,iBAAiB,CAAC,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;QACtF,IAAI,CAAC,eAAe,EAAE,CAAC;YACrB,IAAI,CAAC,iBAAiB,GAAG,OAAO,CAAC;QACnC,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,MAAM,CAAC,WAAW,CAAC,IAA2B,EAAE,IAA2B;QAChF,OAAO,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC,UAAU,KAAG,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,iBAAiB,KAAK,IAAI,CAAC,iBAAiB;eAC1G,IAAI,CAAC,wBAAwB,KAAK,IAAI,CAAC,wBAAwB,CAAC;IACrE,CAAC;CAEF"}
@@ -0,0 +1,9 @@
1
+ import { RemoteStatusData } from "./remote-status-data.js";
2
+ import { RemoteStatusDataAndContent } from "./remote-status-data-and-content.js";
3
+ import { FileTransferResult } from "./file-transfer-result.js";
4
+ import { RemoteFileTrackerPushOptions } from "./remote-file-tracker-push-options.js";
5
+ export interface RemoteFileTrackingProvider<KeyType> {
6
+ readRemoteStatus(key: KeyType): Promise<RemoteStatusData<KeyType>>;
7
+ pullRemoteData(key: KeyType, ifNewerThan?: RemoteStatusData<KeyType>): Promise<RemoteStatusDataAndContent<KeyType>>;
8
+ sendDataToRemote(src: ReadableStream, key: KeyType, opts: RemoteFileTrackerPushOptions, checkStatus: RemoteStatusData<KeyType>): Promise<FileTransferResult>;
9
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=remote-file-tracking-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote-file-tracking-provider.js","sourceRoot":"","sources":["../../../src/network/remote-file-tracker/remote-file-tracking-provider.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ import { RemoteStatusData } from "./remote-status-data.js";
2
+ export interface RemoteStatusDataAndContent<KeyType> {
3
+ status: RemoteStatusData<KeyType>;
4
+ content: ReadableStream;
5
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=remote-status-data-and-content.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote-status-data-and-content.js","sourceRoot":"","sources":["../../../src/network/remote-file-tracker/remote-status-data-and-content.ts"],"names":[],"mappings":""}
@@ -1,5 +1,6 @@
1
- export interface RemoteStatusData {
2
- updatedEpochMs: number;
1
+ export interface RemoteStatusData<KeyType> {
2
+ key: KeyType;
3
+ statusTakenEpochMs: number;
3
4
  remoteSizeInBytes: number;
4
5
  remoteLastUpdatedEpochMs: number;
5
6
  remoteHash: string;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote-status-data.js","sourceRoot":"","sources":["../../../src/network/remote-file-tracker/remote-status-data.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bitblit/ratchet-common",
3
- "version": "5.0.111",
3
+ "version": "5.0.112",
4
4
  "description": "Common tools for general use",
5
5
  "type": "module",
6
6
  "files": [
@@ -1 +0,0 @@
1
- {"version":3,"file":"backup-result.js","sourceRoot":"","sources":["../../../src/network/remote-file-sync/backup-result.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,YAIX;AAJD,WAAY,YAAY;IACtB,mCAAmB,CAAA;IACnB,+BAAe,CAAA;IACf,6CAA6B,CAAA;AAC/B,CAAC,EAJW,YAAY,KAAZ,YAAY,QAIvB"}
@@ -1,7 +0,0 @@
1
- export var FileTransferResult;
2
- (function (FileTransferResult) {
3
- FileTransferResult["Updated"] = "Updated";
4
- FileTransferResult["Skipped"] = "Skipped";
5
- FileTransferResult["Error"] = "Error";
6
- })(FileTransferResult || (FileTransferResult = {}));
7
- //# sourceMappingURL=file-transfer-result.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"file-transfer-result.js","sourceRoot":"","sources":["../../../src/network/remote-file-sync/file-transfer-result.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,kBAIX;AAJD,WAAY,kBAAkB;IAC5B,yCAAmB,CAAA;IACnB,yCAAmB,CAAA;IACnB,qCAAe,CAAA;AACjB,CAAC,EAJW,kBAAkB,KAAlB,kBAAkB,QAI7B"}
@@ -1,16 +0,0 @@
1
- import { FileTransferResult } from './file-transfer-result.js';
2
- import { BackupResult } from './backup-result.js';
3
- import { RemoteStatusData } from './remote-status-data.js';
4
- export interface RemoteFileSyncLike {
5
- get lastSyncEpochMS(): number;
6
- get localFileName(): string;
7
- get localFileBytes(): number;
8
- get localFileUpdatedEpochMS(): number;
9
- get remoteStatusData(): Promise<RemoteStatusData>;
10
- get wouldFetch(): Promise<boolean>;
11
- get wouldPush(): Promise<boolean>;
12
- backupRemote(): Promise<BackupResult>;
13
- sendLocalToRemote(): Promise<FileTransferResult>;
14
- fetchRemoteToLocal(): Promise<FileTransferResult>;
15
- fetchRemoteToLocalIfNewerThan?(epochMS: number): Promise<FileTransferResult>;
16
- }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=remote-file-sync-like.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"remote-file-sync-like.js","sourceRoot":"","sources":["../../../src/network/remote-file-sync/remote-file-sync-like.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"remote-status-data.js","sourceRoot":"","sources":["../../../src/network/remote-file-sync/remote-status-data.ts"],"names":[],"mappings":""}