@symbo.ls/sync 3.1.2 → 3.2.7
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/Inspect.js +1 -1
- package/client.js +131 -0
- package/dist/cjs/Inspect.js +1 -1
- package/dist/cjs/client.js +130 -0
- package/dist/cjs/index.js +185 -51
- package/dist/cjs/server.js +115 -0
- package/dist/esm/Inspect.js +2 -17
- package/dist/esm/client.js +101 -0
- package/dist/esm/index.js +186 -51
- package/dist/esm/server.js +85 -0
- package/dist/iife/index.js +495 -0
- package/index.js +222 -53
- package/package.json +48 -22
- package/server.js +102 -0
- package/dist/cjs/package.json +0 -4
|
@@ -0,0 +1,495 @@
|
|
|
1
|
+
var SmblsSync = (() => {
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
9
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
10
|
+
}) : x)(function(x) {
|
|
11
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
12
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
13
|
+
});
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __copyProps = (to, from, except, desc) => {
|
|
19
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
20
|
+
for (let key of __getOwnPropNames(from))
|
|
21
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
22
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
23
|
+
}
|
|
24
|
+
return to;
|
|
25
|
+
};
|
|
26
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
27
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
28
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
29
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
30
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
31
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
32
|
+
mod
|
|
33
|
+
));
|
|
34
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
35
|
+
|
|
36
|
+
// index.js
|
|
37
|
+
var index_exports = {};
|
|
38
|
+
__export(index_exports, {
|
|
39
|
+
DefaultSyncApp: () => DefaultSyncApp,
|
|
40
|
+
Inspect: () => Inspect,
|
|
41
|
+
Notifications: () => Notifications,
|
|
42
|
+
SyncComponent: () => SyncComponent,
|
|
43
|
+
connectToSocket: () => connectToSocket
|
|
44
|
+
});
|
|
45
|
+
var import_router = __require("@domql/router");
|
|
46
|
+
var import_smbls = __require("smbls");
|
|
47
|
+
var import_socket2 = __require("socket.io-client");
|
|
48
|
+
var import_utils2 = __require("@domql/utils");
|
|
49
|
+
|
|
50
|
+
// SyncNotifications.js
|
|
51
|
+
var NOTIF_COLORS = {
|
|
52
|
+
success: "green",
|
|
53
|
+
error: "red",
|
|
54
|
+
warning: "yellow"
|
|
55
|
+
};
|
|
56
|
+
var connectedToSymbols = (clients, element, state) => {
|
|
57
|
+
if (clients.symbols) {
|
|
58
|
+
if (!state.connected) {
|
|
59
|
+
state.notifications.connected = {
|
|
60
|
+
title: "Connected",
|
|
61
|
+
message: "to the Symbols live server"
|
|
62
|
+
};
|
|
63
|
+
state.update({ connected: true });
|
|
64
|
+
const t = setTimeout(() => {
|
|
65
|
+
delete state.notifications.connected;
|
|
66
|
+
element.notifications.content.connected.setProps({ animation: "fadeOutDown" });
|
|
67
|
+
state.update({ connected: true });
|
|
68
|
+
clearTimeout(t);
|
|
69
|
+
}, 3e3);
|
|
70
|
+
}
|
|
71
|
+
} else {
|
|
72
|
+
if (state.connected) {
|
|
73
|
+
state.notifications.connected = {
|
|
74
|
+
title: "Disconnected",
|
|
75
|
+
type: "error"
|
|
76
|
+
};
|
|
77
|
+
state.update({ connected: false });
|
|
78
|
+
const t = setTimeout(() => {
|
|
79
|
+
delete state.notifications.connected;
|
|
80
|
+
if (element.notifications.content.connected) {
|
|
81
|
+
element.notifications.content.connected.setProps({ animation: "fadeOutDown" });
|
|
82
|
+
}
|
|
83
|
+
state.update({ connected: true });
|
|
84
|
+
clearTimeout(t);
|
|
85
|
+
}, 3e3);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
var Notifications = {
|
|
90
|
+
state: {
|
|
91
|
+
notifications: []
|
|
92
|
+
},
|
|
93
|
+
Notifications: {
|
|
94
|
+
position: "fixed",
|
|
95
|
+
left: "A2",
|
|
96
|
+
bottom: "Z2",
|
|
97
|
+
zIndex: "999",
|
|
98
|
+
childExtends: "Notification",
|
|
99
|
+
childProps: ({ state }) => ({
|
|
100
|
+
animationDuration: "C",
|
|
101
|
+
background: NOTIF_COLORS[state.type || "success"],
|
|
102
|
+
icon: null,
|
|
103
|
+
Flex: {
|
|
104
|
+
Title: {
|
|
105
|
+
text: "{{ title }}"
|
|
106
|
+
},
|
|
107
|
+
P: {
|
|
108
|
+
text: "{{ title }}"
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
onRender: (e, el, s) => {
|
|
112
|
+
el.setProps({ animation: "fadeInUp" });
|
|
113
|
+
},
|
|
114
|
+
onClick: (e, el, s) => {
|
|
115
|
+
delete s.notifications[el.key];
|
|
116
|
+
el.setProps({ animation: "fadeOutDown" });
|
|
117
|
+
if (s.onClose) s.onClose(e, el, s);
|
|
118
|
+
}
|
|
119
|
+
}),
|
|
120
|
+
IconText: null,
|
|
121
|
+
childrenAs: "state",
|
|
122
|
+
children: ({ state }) => state.notifications
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
// Inspect.js
|
|
127
|
+
var smblsUI = __toESM(__require("@symbo.ls/uikit"), 1);
|
|
128
|
+
var import_utils = __require("@domql/utils");
|
|
129
|
+
|
|
130
|
+
// client.js
|
|
131
|
+
var utils = __toESM(__require("@domql/utils"), 1);
|
|
132
|
+
var import_socket = __toESM(__require("socket.io-client"), 1);
|
|
133
|
+
var { window: window2, isFunction, isArray } = utils.default || utils;
|
|
134
|
+
var defautlOpts = {};
|
|
135
|
+
function send(event = "change", changes, options) {
|
|
136
|
+
this.emit(event, changes, { ...options, ...defautlOpts });
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Inspect.js
|
|
140
|
+
function returnStringExtend(_extends) {
|
|
141
|
+
return (0, import_utils.isString)(_extends) ? _extends : (0, import_utils.isArray)(_extends) ? _extends.find((extItem) => (0, import_utils.isString)(extItem)) : "";
|
|
142
|
+
}
|
|
143
|
+
function getComponentKey(el) {
|
|
144
|
+
if (!el) return;
|
|
145
|
+
const __componentKey = el.__ref.__componentKey;
|
|
146
|
+
const extendsStr = el.extends && returnStringExtend(el.extends);
|
|
147
|
+
const parentChildExtendStr = el.parent && el.parent.childExtends && returnStringExtend(el.parent.childExtends);
|
|
148
|
+
return (__componentKey || extendsStr || parentChildExtendStr || "").split("_")[0].split(".")[0].split("+")[0];
|
|
149
|
+
}
|
|
150
|
+
function findComponent(el) {
|
|
151
|
+
if (!el || !el.__ref) return;
|
|
152
|
+
const { components, pages, editor } = el.context;
|
|
153
|
+
const componentKey = getComponentKey(el);
|
|
154
|
+
if (editor && editor.onInitInspect) {
|
|
155
|
+
const initInspectReturns = editor.onInitInspect(componentKey, el, el.state);
|
|
156
|
+
if (!initInspectReturns) return findComponent(el.parent);
|
|
157
|
+
}
|
|
158
|
+
if (componentKey && (components[componentKey] || pages[componentKey])) {
|
|
159
|
+
return el;
|
|
160
|
+
}
|
|
161
|
+
return findComponent(el.parent);
|
|
162
|
+
}
|
|
163
|
+
var onInspect = (app, state, ctx) => {
|
|
164
|
+
const windowOpts = ctx.window || window;
|
|
165
|
+
windowOpts.onkeydown = (ev) => {
|
|
166
|
+
if (ev.altKey && ev.shiftKey) {
|
|
167
|
+
app.state.update({ debugging: true, preventSelect: true }, {
|
|
168
|
+
preventUpdate: true,
|
|
169
|
+
preventContentUpdate: true,
|
|
170
|
+
preventRecursive: true
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
windowOpts.onkeyup = (ev) => {
|
|
175
|
+
if (app.state.preventSelect && (!ev.altKey || !ev.shiftKey)) {
|
|
176
|
+
app.state.replace({ debugging: false, preventSelect: false }, {
|
|
177
|
+
preventUpdate: true,
|
|
178
|
+
preventContentUpdate: true,
|
|
179
|
+
preventRecursive: true
|
|
180
|
+
});
|
|
181
|
+
app.Inspector.state.update({ area: false });
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
};
|
|
185
|
+
var Inspect = {
|
|
186
|
+
".preventSelect": { userSelect: "none" },
|
|
187
|
+
"!preventSelect": { userSelect: "auto" },
|
|
188
|
+
onInspect,
|
|
189
|
+
onMousemove: (ev, e, state) => {
|
|
190
|
+
const el = ev.target.ref;
|
|
191
|
+
const component = findComponent(el);
|
|
192
|
+
const focusState = e.Inspector.state;
|
|
193
|
+
if (!component || !state.debugging || !component.__ref) return focusState.update({ area: false });
|
|
194
|
+
const componentKey = getComponentKey(component);
|
|
195
|
+
const updateValue = (area) => {
|
|
196
|
+
focusState.update({ area, focusKey: componentKey });
|
|
197
|
+
};
|
|
198
|
+
const update = () => {
|
|
199
|
+
if (ev.altKey && ev.shiftKey) {
|
|
200
|
+
const { x, y, width, height } = component.node.getBoundingClientRect();
|
|
201
|
+
const area = { x, y, width, height };
|
|
202
|
+
if (!focusState.area) return updateValue(area);
|
|
203
|
+
if (focusState.area.x !== area.x) updateValue(area);
|
|
204
|
+
} else if (focusState.area) {
|
|
205
|
+
focusState.update({ area: false });
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
window.requestAnimationFrame(() => {
|
|
209
|
+
update();
|
|
210
|
+
window.requestAnimationFrame(update);
|
|
211
|
+
});
|
|
212
|
+
},
|
|
213
|
+
onMousedown: (ev, elem, state) => {
|
|
214
|
+
if (!state.debugging) return;
|
|
215
|
+
const el = ev.target.ref;
|
|
216
|
+
const component = findComponent(el);
|
|
217
|
+
if (!component) return;
|
|
218
|
+
const componentKey = getComponentKey(component);
|
|
219
|
+
if (!componentKey) return;
|
|
220
|
+
const editor = el.context.editor;
|
|
221
|
+
if (editor && editor.onInspect) {
|
|
222
|
+
return editor.onInspect(componentKey, el, el.state, { allowRouterWhileInspect: true });
|
|
223
|
+
}
|
|
224
|
+
const data = JSON.stringify({
|
|
225
|
+
componentKey: `${componentKey}`
|
|
226
|
+
});
|
|
227
|
+
send.call(el.context.socket, "route", data);
|
|
228
|
+
ev.preventDefault();
|
|
229
|
+
ev.stopPropagation();
|
|
230
|
+
return false;
|
|
231
|
+
},
|
|
232
|
+
Inspector: {
|
|
233
|
+
state: {},
|
|
234
|
+
transition: "all, defaultBezier, X",
|
|
235
|
+
position: "fixed",
|
|
236
|
+
hide: (el, s) => !(s.area && s.parent.debugging),
|
|
237
|
+
style: {
|
|
238
|
+
boxShadow: "0 0 10px #3686F733, 0 0 0 3px #3686F766, 0 0 100vmax 100vmax #000A",
|
|
239
|
+
zIndex: "9999999",
|
|
240
|
+
borderRadius: "10px",
|
|
241
|
+
pointerEvents: "none"
|
|
242
|
+
},
|
|
243
|
+
Span: {
|
|
244
|
+
position: "absolute",
|
|
245
|
+
margin: "A2 0",
|
|
246
|
+
fontSize: "Z",
|
|
247
|
+
color: "text",
|
|
248
|
+
// color: 'blue',
|
|
249
|
+
zIndex: "99999999",
|
|
250
|
+
transition: "all, defaultBezier, X",
|
|
251
|
+
textDecoration: "underline",
|
|
252
|
+
fontWeight: "500",
|
|
253
|
+
top: "100%",
|
|
254
|
+
style: {
|
|
255
|
+
boxShadow: "0 25px 10px 35px black",
|
|
256
|
+
textShadow: "0 0 10px black"
|
|
257
|
+
},
|
|
258
|
+
text: "{{ focusKey }}"
|
|
259
|
+
},
|
|
260
|
+
onInit: ({ context }) => {
|
|
261
|
+
const { components } = context;
|
|
262
|
+
if ((0, import_utils.isObject)(components)) {
|
|
263
|
+
const { Content, ...rest } = components;
|
|
264
|
+
for (const key in rest) {
|
|
265
|
+
if (smblsUI[key]) continue;
|
|
266
|
+
if (!rest[key].__ref) rest[key].__ref = {};
|
|
267
|
+
if (!rest[key].__ref.__componentKey) {
|
|
268
|
+
rest[key].__ref.__componentKey = key;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
},
|
|
273
|
+
onBeforeUpdate: (ch, el, s) => {
|
|
274
|
+
const { area } = s;
|
|
275
|
+
const isDebugging = s.area && s.parent.debugging;
|
|
276
|
+
let style;
|
|
277
|
+
if (!isDebugging) {
|
|
278
|
+
style = "display: none !important";
|
|
279
|
+
} else if (area) {
|
|
280
|
+
const { x, y, width, height } = area;
|
|
281
|
+
style = `
|
|
282
|
+
display: block !important;
|
|
283
|
+
top: ${y - 6}px;
|
|
284
|
+
left: ${x - 6}px;
|
|
285
|
+
width: ${width + 12}px;
|
|
286
|
+
height: ${height + 12}px;
|
|
287
|
+
`;
|
|
288
|
+
}
|
|
289
|
+
el.node.style = style;
|
|
290
|
+
el.Span.node.innerText = s.focusKey;
|
|
291
|
+
return false;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
// index.js
|
|
297
|
+
var isLocal = process.env.NODE_ENV === "local";
|
|
298
|
+
var deletePath = (obj, path) => {
|
|
299
|
+
if (!obj || !Array.isArray(path)) {
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
path.reduce((acc, v, i, arr) => {
|
|
303
|
+
if (acc && v in acc) {
|
|
304
|
+
if (i !== arr.length - 1) {
|
|
305
|
+
return acc[v];
|
|
306
|
+
}
|
|
307
|
+
delete acc[v];
|
|
308
|
+
}
|
|
309
|
+
return void 0;
|
|
310
|
+
}, obj);
|
|
311
|
+
};
|
|
312
|
+
var setPath = (obj, path, value, createNestedObjects = false) => {
|
|
313
|
+
if (!obj || !Array.isArray(path)) {
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
path.reduce((acc, v, i, arr) => {
|
|
317
|
+
if (!acc) {
|
|
318
|
+
return void 0;
|
|
319
|
+
}
|
|
320
|
+
if (i !== arr.length - 1) {
|
|
321
|
+
if (!acc[v] && createNestedObjects) {
|
|
322
|
+
acc[v] = {};
|
|
323
|
+
}
|
|
324
|
+
return acc[v];
|
|
325
|
+
}
|
|
326
|
+
acc[v] = value;
|
|
327
|
+
return void 0;
|
|
328
|
+
}, obj);
|
|
329
|
+
};
|
|
330
|
+
var applyOpsToCtx = (ctx, changes) => {
|
|
331
|
+
const topLevelChanged = /* @__PURE__ */ new Set();
|
|
332
|
+
if (!Array.isArray(changes)) {
|
|
333
|
+
return topLevelChanged;
|
|
334
|
+
}
|
|
335
|
+
for (const [action, path, change] of changes) {
|
|
336
|
+
if (!Array.isArray(path) || !path.length) {
|
|
337
|
+
continue;
|
|
338
|
+
}
|
|
339
|
+
topLevelChanged.add(path[0]);
|
|
340
|
+
switch (action) {
|
|
341
|
+
case "delete":
|
|
342
|
+
deletePath(ctx, path);
|
|
343
|
+
break;
|
|
344
|
+
case "update":
|
|
345
|
+
case "set":
|
|
346
|
+
setPath(ctx, path, change, true);
|
|
347
|
+
break;
|
|
348
|
+
default:
|
|
349
|
+
break;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
return topLevelChanged;
|
|
353
|
+
};
|
|
354
|
+
var fetchServiceToken = async () => {
|
|
355
|
+
try {
|
|
356
|
+
const urlBase = isLocal ? "http://localhost:8080" : "https://api.symbols.app";
|
|
357
|
+
const res = await import_utils2.window.fetch(`${urlBase}/service-token`, {
|
|
358
|
+
method: "GET"
|
|
359
|
+
});
|
|
360
|
+
let txt;
|
|
361
|
+
try {
|
|
362
|
+
const json = await res.clone().json();
|
|
363
|
+
if (json && typeof json.token === "string") {
|
|
364
|
+
return json.token.trim();
|
|
365
|
+
}
|
|
366
|
+
txt = await res.text();
|
|
367
|
+
} catch {
|
|
368
|
+
txt = await res.text();
|
|
369
|
+
}
|
|
370
|
+
return (txt || "").replace(/\s+/gu, "") || void 0;
|
|
371
|
+
} catch (e) {
|
|
372
|
+
console.error("[sync] Failed to fetch service-token", e);
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
var onSnapshot = (el, s, ctx) => (payload = {}) => {
|
|
376
|
+
let { data } = payload;
|
|
377
|
+
const { schema } = payload;
|
|
378
|
+
if (!data) {
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
data = el.call(
|
|
382
|
+
"deepDestringifyFunctions",
|
|
383
|
+
data,
|
|
384
|
+
Array.isArray(data) ? [] : {}
|
|
385
|
+
);
|
|
386
|
+
Object.entries(data).forEach(([key, val]) => {
|
|
387
|
+
if (ctx[key] && typeof ctx[key] === "object") {
|
|
388
|
+
if (key === "designSystem") {
|
|
389
|
+
(0, import_smbls.init)(val);
|
|
390
|
+
} else {
|
|
391
|
+
(0, import_utils2.overwriteShallow)(ctx[key], val);
|
|
392
|
+
}
|
|
393
|
+
} else {
|
|
394
|
+
ctx[key] = val;
|
|
395
|
+
}
|
|
396
|
+
});
|
|
397
|
+
if (schema) {
|
|
398
|
+
ctx.schema = schema;
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
var onOps = (el, s, ctx) => (payload = {}) => {
|
|
402
|
+
let { changes } = payload;
|
|
403
|
+
if (!changes || !Array.isArray(changes) || !changes.length) {
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
changes = el.call(
|
|
407
|
+
"deepDestringifyFunctions",
|
|
408
|
+
changes,
|
|
409
|
+
Array.isArray(changes) ? [] : {}
|
|
410
|
+
);
|
|
411
|
+
const changed = applyOpsToCtx(ctx, changes);
|
|
412
|
+
if (changed.has("state")) {
|
|
413
|
+
const route = ctx.state?.route;
|
|
414
|
+
if (route) {
|
|
415
|
+
el.call(
|
|
416
|
+
"router",
|
|
417
|
+
route.replace("/state", "") || "/",
|
|
418
|
+
el.__ref.root,
|
|
419
|
+
{},
|
|
420
|
+
{ scrollToTop: false }
|
|
421
|
+
);
|
|
422
|
+
} else {
|
|
423
|
+
s.update(ctx.state);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
if (["pages", "components", "snippets", "functions"].some(
|
|
427
|
+
(k) => changed.has(k)
|
|
428
|
+
)) {
|
|
429
|
+
const { pathname, search, hash } = ctx.window.location;
|
|
430
|
+
el.call(
|
|
431
|
+
"router",
|
|
432
|
+
pathname + search + hash,
|
|
433
|
+
el.__ref.root,
|
|
434
|
+
{},
|
|
435
|
+
{ scrollToTop: false }
|
|
436
|
+
);
|
|
437
|
+
}
|
|
438
|
+
if (changed.has("designSystem")) {
|
|
439
|
+
(0, import_smbls.init)(ctx.designSystem);
|
|
440
|
+
}
|
|
441
|
+
};
|
|
442
|
+
var connectToSocket = async (el, s, ctx) => {
|
|
443
|
+
const token = await fetchServiceToken();
|
|
444
|
+
if (!token) {
|
|
445
|
+
console.warn("[sync] No service token \u2013 live collaboration disabled");
|
|
446
|
+
return null;
|
|
447
|
+
}
|
|
448
|
+
const projectKey = ctx.key;
|
|
449
|
+
if (!projectKey) {
|
|
450
|
+
console.warn(
|
|
451
|
+
"[sync] ctx.key missing \u2013 cannot establish collaborative connection"
|
|
452
|
+
);
|
|
453
|
+
return null;
|
|
454
|
+
}
|
|
455
|
+
const socketBaseUrl = isLocal ? "http://localhost:8080" : "https://api.symbols.app";
|
|
456
|
+
const socket = (0, import_socket2.io)(socketBaseUrl, {
|
|
457
|
+
path: "/collab-socket",
|
|
458
|
+
transports: ["websocket"],
|
|
459
|
+
auth: {
|
|
460
|
+
token,
|
|
461
|
+
projectKey,
|
|
462
|
+
branch: "main",
|
|
463
|
+
live: true,
|
|
464
|
+
clientType: "platform"
|
|
465
|
+
},
|
|
466
|
+
reconnectionAttempts: Infinity,
|
|
467
|
+
reconnectionDelayMax: 4e3
|
|
468
|
+
});
|
|
469
|
+
socket.on("connect", () => {
|
|
470
|
+
if (ctx.editor?.verbose) {
|
|
471
|
+
console.info("[sync] Connected to collab socket");
|
|
472
|
+
}
|
|
473
|
+
});
|
|
474
|
+
socket.on("snapshot", onSnapshot(el, s, ctx));
|
|
475
|
+
socket.on("ops", onOps(el, s, ctx));
|
|
476
|
+
socket.on("clients", (data) => {
|
|
477
|
+
if (ctx.editor?.verbose) {
|
|
478
|
+
connectedToSymbols(data, el, s);
|
|
479
|
+
}
|
|
480
|
+
});
|
|
481
|
+
socket.on("disconnect", (reason) => {
|
|
482
|
+
if (ctx.editor?.verbose) {
|
|
483
|
+
console.info("[sync] Disconnected from collab socket", reason);
|
|
484
|
+
}
|
|
485
|
+
});
|
|
486
|
+
return socket;
|
|
487
|
+
};
|
|
488
|
+
var SyncComponent = {
|
|
489
|
+
onInitSync: connectToSocket
|
|
490
|
+
};
|
|
491
|
+
var DefaultSyncApp = {
|
|
492
|
+
extends: [SyncComponent, Inspect, Notifications]
|
|
493
|
+
};
|
|
494
|
+
return __toCommonJS(index_exports);
|
|
495
|
+
})();
|