@meshagent/meshagent 0.28.11 → 0.28.13
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/CHANGELOG.md +6 -0
- package/dist/browser/sync-client.js +18 -1
- package/dist/esm/sync-client.js +18 -1
- package/dist/node/sync-client.js +18 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,19 @@ const room_server_client_1 = require("./room-server-client");
|
|
|
8
8
|
const utils_1 = require("./utils");
|
|
9
9
|
const runtime_1 = require("./runtime");
|
|
10
10
|
const completer_1 = require("./completer");
|
|
11
|
+
function normalizeSyncPath(path) {
|
|
12
|
+
let normalized = path;
|
|
13
|
+
while (normalized.startsWith("./")) {
|
|
14
|
+
normalized = normalized.slice(2);
|
|
15
|
+
}
|
|
16
|
+
while (normalized.startsWith("/")) {
|
|
17
|
+
normalized = normalized.slice(1);
|
|
18
|
+
}
|
|
19
|
+
if (normalized === ".") {
|
|
20
|
+
return "";
|
|
21
|
+
}
|
|
22
|
+
return normalized;
|
|
23
|
+
}
|
|
11
24
|
;
|
|
12
25
|
class QueuedSync {
|
|
13
26
|
constructor({ path, base64 }) {
|
|
@@ -42,7 +55,7 @@ class SyncClient extends event_emitter_1.EventEmitter {
|
|
|
42
55
|
const headerStr = (0, utils_1.splitMessageHeader)(bytes || new Uint8Array());
|
|
43
56
|
const payload = (0, utils_1.splitMessagePayload)(bytes || new Uint8Array());
|
|
44
57
|
const header = JSON.parse(headerStr);
|
|
45
|
-
const path = header["path"];
|
|
58
|
+
const path = normalizeSyncPath(header["path"]);
|
|
46
59
|
const isConnecting = this._connectingDocuments[path];
|
|
47
60
|
if (isConnecting) {
|
|
48
61
|
await isConnecting;
|
|
@@ -67,9 +80,11 @@ class SyncClient extends event_emitter_1.EventEmitter {
|
|
|
67
80
|
this.emit("status", header.status);
|
|
68
81
|
}
|
|
69
82
|
async create(path, json) {
|
|
83
|
+
path = normalizeSyncPath(path);
|
|
70
84
|
await this.client.sendRequest("room.create", { path, json });
|
|
71
85
|
}
|
|
72
86
|
async open(path, { create = true } = {}) {
|
|
87
|
+
path = normalizeSyncPath(path);
|
|
73
88
|
const pending = this._connectingDocuments[path];
|
|
74
89
|
if (pending) {
|
|
75
90
|
await pending;
|
|
@@ -105,6 +120,7 @@ class SyncClient extends event_emitter_1.EventEmitter {
|
|
|
105
120
|
}
|
|
106
121
|
}
|
|
107
122
|
async close(path) {
|
|
123
|
+
path = normalizeSyncPath(path);
|
|
108
124
|
const pending = this._connectingDocuments[path];
|
|
109
125
|
if (pending) {
|
|
110
126
|
await pending;
|
|
@@ -124,6 +140,7 @@ class SyncClient extends event_emitter_1.EventEmitter {
|
|
|
124
140
|
this.emit("closed", { type: "close", doc });
|
|
125
141
|
}
|
|
126
142
|
async sync(path, data) {
|
|
143
|
+
path = normalizeSyncPath(path);
|
|
127
144
|
await this.client.sendRequest("room.sync", { path }, data);
|
|
128
145
|
}
|
|
129
146
|
}
|
package/dist/esm/sync-client.js
CHANGED
|
@@ -5,6 +5,19 @@ import { MeshDocument, RoomServerException } from "./room-server-client";
|
|
|
5
5
|
import { splitMessageHeader, splitMessagePayload, decoder, encoder, RefCount } from "./utils";
|
|
6
6
|
import { unregisterDocument, applyBackendChanges } from "./runtime";
|
|
7
7
|
import { Completer } from "./completer";
|
|
8
|
+
function normalizeSyncPath(path) {
|
|
9
|
+
let normalized = path;
|
|
10
|
+
while (normalized.startsWith("./")) {
|
|
11
|
+
normalized = normalized.slice(2);
|
|
12
|
+
}
|
|
13
|
+
while (normalized.startsWith("/")) {
|
|
14
|
+
normalized = normalized.slice(1);
|
|
15
|
+
}
|
|
16
|
+
if (normalized === ".") {
|
|
17
|
+
return "";
|
|
18
|
+
}
|
|
19
|
+
return normalized;
|
|
20
|
+
}
|
|
8
21
|
;
|
|
9
22
|
export class QueuedSync {
|
|
10
23
|
constructor({ path, base64 }) {
|
|
@@ -38,7 +51,7 @@ export class SyncClient extends EventEmitter {
|
|
|
38
51
|
const headerStr = splitMessageHeader(bytes || new Uint8Array());
|
|
39
52
|
const payload = splitMessagePayload(bytes || new Uint8Array());
|
|
40
53
|
const header = JSON.parse(headerStr);
|
|
41
|
-
const path = header["path"];
|
|
54
|
+
const path = normalizeSyncPath(header["path"]);
|
|
42
55
|
const isConnecting = this._connectingDocuments[path];
|
|
43
56
|
if (isConnecting) {
|
|
44
57
|
await isConnecting;
|
|
@@ -63,9 +76,11 @@ export class SyncClient extends EventEmitter {
|
|
|
63
76
|
this.emit("status", header.status);
|
|
64
77
|
}
|
|
65
78
|
async create(path, json) {
|
|
79
|
+
path = normalizeSyncPath(path);
|
|
66
80
|
await this.client.sendRequest("room.create", { path, json });
|
|
67
81
|
}
|
|
68
82
|
async open(path, { create = true } = {}) {
|
|
83
|
+
path = normalizeSyncPath(path);
|
|
69
84
|
const pending = this._connectingDocuments[path];
|
|
70
85
|
if (pending) {
|
|
71
86
|
await pending;
|
|
@@ -101,6 +116,7 @@ export class SyncClient extends EventEmitter {
|
|
|
101
116
|
}
|
|
102
117
|
}
|
|
103
118
|
async close(path) {
|
|
119
|
+
path = normalizeSyncPath(path);
|
|
104
120
|
const pending = this._connectingDocuments[path];
|
|
105
121
|
if (pending) {
|
|
106
122
|
await pending;
|
|
@@ -120,6 +136,7 @@ export class SyncClient extends EventEmitter {
|
|
|
120
136
|
this.emit("closed", { type: "close", doc });
|
|
121
137
|
}
|
|
122
138
|
async sync(path, data) {
|
|
139
|
+
path = normalizeSyncPath(path);
|
|
123
140
|
await this.client.sendRequest("room.sync", { path }, data);
|
|
124
141
|
}
|
|
125
142
|
}
|
package/dist/node/sync-client.js
CHANGED
|
@@ -8,6 +8,19 @@ const room_server_client_1 = require("./room-server-client");
|
|
|
8
8
|
const utils_1 = require("./utils");
|
|
9
9
|
const runtime_1 = require("./runtime");
|
|
10
10
|
const completer_1 = require("./completer");
|
|
11
|
+
function normalizeSyncPath(path) {
|
|
12
|
+
let normalized = path;
|
|
13
|
+
while (normalized.startsWith("./")) {
|
|
14
|
+
normalized = normalized.slice(2);
|
|
15
|
+
}
|
|
16
|
+
while (normalized.startsWith("/")) {
|
|
17
|
+
normalized = normalized.slice(1);
|
|
18
|
+
}
|
|
19
|
+
if (normalized === ".") {
|
|
20
|
+
return "";
|
|
21
|
+
}
|
|
22
|
+
return normalized;
|
|
23
|
+
}
|
|
11
24
|
;
|
|
12
25
|
class QueuedSync {
|
|
13
26
|
constructor({ path, base64 }) {
|
|
@@ -42,7 +55,7 @@ class SyncClient extends event_emitter_1.EventEmitter {
|
|
|
42
55
|
const headerStr = (0, utils_1.splitMessageHeader)(bytes || new Uint8Array());
|
|
43
56
|
const payload = (0, utils_1.splitMessagePayload)(bytes || new Uint8Array());
|
|
44
57
|
const header = JSON.parse(headerStr);
|
|
45
|
-
const path = header["path"];
|
|
58
|
+
const path = normalizeSyncPath(header["path"]);
|
|
46
59
|
const isConnecting = this._connectingDocuments[path];
|
|
47
60
|
if (isConnecting) {
|
|
48
61
|
await isConnecting;
|
|
@@ -67,9 +80,11 @@ class SyncClient extends event_emitter_1.EventEmitter {
|
|
|
67
80
|
this.emit("status", header.status);
|
|
68
81
|
}
|
|
69
82
|
async create(path, json) {
|
|
83
|
+
path = normalizeSyncPath(path);
|
|
70
84
|
await this.client.sendRequest("room.create", { path, json });
|
|
71
85
|
}
|
|
72
86
|
async open(path, { create = true } = {}) {
|
|
87
|
+
path = normalizeSyncPath(path);
|
|
73
88
|
const pending = this._connectingDocuments[path];
|
|
74
89
|
if (pending) {
|
|
75
90
|
await pending;
|
|
@@ -105,6 +120,7 @@ class SyncClient extends event_emitter_1.EventEmitter {
|
|
|
105
120
|
}
|
|
106
121
|
}
|
|
107
122
|
async close(path) {
|
|
123
|
+
path = normalizeSyncPath(path);
|
|
108
124
|
const pending = this._connectingDocuments[path];
|
|
109
125
|
if (pending) {
|
|
110
126
|
await pending;
|
|
@@ -124,6 +140,7 @@ class SyncClient extends event_emitter_1.EventEmitter {
|
|
|
124
140
|
this.emit("closed", { type: "close", doc });
|
|
125
141
|
}
|
|
126
142
|
async sync(path, data) {
|
|
143
|
+
path = normalizeSyncPath(path);
|
|
127
144
|
await this.client.sendRequest("room.sync", { path }, data);
|
|
128
145
|
}
|
|
129
146
|
}
|