y-mxgraph 0.3.0 → 0.3.2
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/README.md +4 -1
- package/README.zh-CN.md +4 -2
- package/binding/index.d.ts +19 -0
- package/binding/index.d.ts.map +1 -1
- package/iframe-bridge/provider.cjs.js +134 -0
- package/iframe-bridge/provider.cjs.js.map +1 -0
- package/iframe-bridge/provider.es.js +117 -0
- package/iframe-bridge/provider.es.js.map +1 -0
- package/iframe-bridge/server.cjs.js +111 -0
- package/iframe-bridge/server.cjs.js.map +1 -0
- package/iframe-bridge/server.es.js +94 -0
- package/iframe-bridge/server.es.js.map +1 -0
- package/index.d.ts +0 -2
- package/index.d.ts.map +1 -1
- package/package.json +11 -3
- package/types/drawio.d.ts +5 -0
- package/types/drawio.d.ts.map +1 -1
- package/y-mxgraph.cjs.js +94 -158
- package/y-mxgraph.cjs.js.map +1 -1
- package/y-mxgraph.es.js +95 -153
- package/y-mxgraph.es.js.map +1 -1
- package/y-mxgraph.iife.js +0 -1741
- package/y-mxgraph.iife.js.map +0 -1
- package/y-mxgraph.umd.js +0 -1742
- package/y-mxgraph.umd.js.map +0 -1
package/README.md
CHANGED
|
@@ -42,7 +42,10 @@ App.main((app) => {
|
|
|
42
42
|
// `file.setData(xml)` is intentionally NOT called so draw.io does not
|
|
43
43
|
// mark the file as modified and pop up the "Save diagrams to:" dialog.
|
|
44
44
|
// Override via `applyFileData` if you need to sync `file.data` too.
|
|
45
|
-
|
|
45
|
+
//
|
|
46
|
+
// `disableBeforeUnload` (default: true) disables draw.io's native
|
|
47
|
+
// "All changes will be lost" dialog since Yjs handles persistence.
|
|
48
|
+
const binding = new Binding(file, { doc });
|
|
46
49
|
|
|
47
50
|
window.addEventListener('beforeunload', () => binding.destroy());
|
|
48
51
|
});
|
package/README.zh-CN.md
CHANGED
|
@@ -36,6 +36,8 @@ App.main((app) => {
|
|
|
36
36
|
app.currentFile.data = Binding.generateFileTemplate('diagram-0');
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
// `disableBeforeUnload`(默认 true)禁用 draw.io 的 "All changes will be lost" 弹窗,
|
|
40
|
+
// 因为 Yjs 已接管持久化。如需保留原生行为(如使用 File System Access API),设为 false。
|
|
39
41
|
const binding = new Binding(app.currentFile, { doc });
|
|
40
42
|
|
|
41
43
|
window.addEventListener('beforeunload', () => binding.destroy());
|
|
@@ -80,7 +82,7 @@ App.main((app) => {
|
|
|
80
82
|
|
|
81
83
|
```ts
|
|
82
84
|
// Server(父页面)
|
|
83
|
-
import { createIframeBridgeServer } from '
|
|
85
|
+
import { createIframeBridgeServer } from 'y-mxgraph/iframe-bridge/server';
|
|
84
86
|
|
|
85
87
|
const doc = new Y.Doc();
|
|
86
88
|
const provider = new WebrtcProvider(roomName, doc, { signaling });
|
|
@@ -88,7 +90,7 @@ const bridge = createIframeBridgeServer(doc, provider.awareness);
|
|
|
88
90
|
bridge.addIframe(iframeElement, 'child-1');
|
|
89
91
|
|
|
90
92
|
// Provider(iframe 子页面)
|
|
91
|
-
import { createIframeBridgeProvider } from '
|
|
93
|
+
import { createIframeBridgeProvider } from 'y-mxgraph/iframe-bridge/provider';
|
|
92
94
|
|
|
93
95
|
const doc = new Y.Doc();
|
|
94
96
|
const awareness = new Awareness(doc);
|
package/binding/index.d.ts
CHANGED
|
@@ -31,6 +31,18 @@ export interface BindDrawioFileOptions {
|
|
|
31
31
|
* `file.save()`),可提供自定义实现。
|
|
32
32
|
*/
|
|
33
33
|
applyFileData?: (file: DrawioFile, xml: string) => void;
|
|
34
|
+
/**
|
|
35
|
+
* 是否禁用 draw.io 的 beforeUnload 弹窗,默认 `true`。
|
|
36
|
+
*
|
|
37
|
+
* Yjs 接管持久化后,draw.io 的原生保存状态不再有意义。
|
|
38
|
+
* 但 draw.io 内部会在特定条件下(如 LocalFile 无 fileHandle、
|
|
39
|
+
* 图表非空等)弹出 "All changes will be lost" 或
|
|
40
|
+
* "Ensure your data has been saved" 提示。
|
|
41
|
+
*
|
|
42
|
+
* 设为 `true` 可彻底禁用这些弹窗,适合纯 Yjs 协作场景。
|
|
43
|
+
* 若需要保留原生行为(如使用 File System Access API),设为 `false`。
|
|
44
|
+
*/
|
|
45
|
+
disableBeforeUnload?: boolean;
|
|
34
46
|
}
|
|
35
47
|
/**
|
|
36
48
|
* Y-MXGraph 绑定类,管理 draw.io 文件与 Y.Doc 的双向同步
|
|
@@ -59,9 +71,16 @@ export declare class Binding {
|
|
|
59
71
|
private cleanupUndoManager?;
|
|
60
72
|
/** 初始内容策略 */
|
|
61
73
|
private initialContentStrategy;
|
|
74
|
+
/** draw.io UI 引用,用于重置状态和获取 currentFile */
|
|
75
|
+
private ui;
|
|
62
76
|
/** replace 策略下,构造时 doc 为空,现在 doc 有数据时需要强制替换 */
|
|
63
77
|
private get shouldReplaceWhenDocHasData();
|
|
64
78
|
constructor(file: DrawioFile, options: BindDrawioFileOptions);
|
|
79
|
+
/**
|
|
80
|
+
* 重置 editor 和 file 的 modified 状态及状态栏。
|
|
81
|
+
* Yjs 接管持久化后,draw.io 的原生保存状态不再有意义。
|
|
82
|
+
*/
|
|
83
|
+
private resetEditorStatus;
|
|
65
84
|
/**
|
|
66
85
|
* 销毁绑定,解除所有监听器
|
|
67
86
|
* @param deep - 是否深度清理(包括 awareness/undoManager),默认 false
|
package/binding/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/binding/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAiBvD,OAAO,KAAK,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/binding/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,EAAE,KAAK,SAAS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AAE,CAAyB;IAEnC,+CAA+C;IAC/C,OAAO,KAAK,2BAA2B,GAEtC;gBAEW,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,qBAAqB;IAoJ5D;;;OAGG;IACH,OAAO,CAAC,iBAAiB;IAOzB;;;OAGG;IACH,OAAO,CAAC,IAAI,UAAQ,GAAG,IAAI;IAS3B;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,oBAAoB,CAAC,SAAS,SAAc,GAAG,MAAM;IAa5D;;;OAGG;IACH,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,qBAAqB,GAAG,OAAO;CAGzE"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const Y = require("yjs");
|
|
4
|
+
const awareness = require("y-protocols/awareness");
|
|
5
|
+
function _interopNamespaceDefault(e) {
|
|
6
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
7
|
+
if (e) {
|
|
8
|
+
for (const k in e) {
|
|
9
|
+
if (k !== "default") {
|
|
10
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
11
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: () => e[k]
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
n.default = e;
|
|
19
|
+
return Object.freeze(n);
|
|
20
|
+
}
|
|
21
|
+
const Y__namespace = /* @__PURE__ */ _interopNamespaceDefault(Y);
|
|
22
|
+
function readVarUint(data, pos) {
|
|
23
|
+
let result = 0;
|
|
24
|
+
let shift = 0;
|
|
25
|
+
let byte;
|
|
26
|
+
do {
|
|
27
|
+
byte = data[pos++];
|
|
28
|
+
result |= (byte & 127) << shift;
|
|
29
|
+
shift += 7;
|
|
30
|
+
} while (byte >= 128);
|
|
31
|
+
return [result >>> 0, pos];
|
|
32
|
+
}
|
|
33
|
+
function writeVarUint(value) {
|
|
34
|
+
const bytes = [];
|
|
35
|
+
while (value > 127) {
|
|
36
|
+
bytes.push(value & 127 | 128);
|
|
37
|
+
value >>>= 7;
|
|
38
|
+
}
|
|
39
|
+
bytes.push(value);
|
|
40
|
+
return bytes;
|
|
41
|
+
}
|
|
42
|
+
function readVarString(data, pos) {
|
|
43
|
+
const [len, pos2] = readVarUint(data, pos);
|
|
44
|
+
const str = new TextDecoder().decode(data.subarray(pos2, pos2 + len));
|
|
45
|
+
return [str, pos2 + len];
|
|
46
|
+
}
|
|
47
|
+
function writeVarString(str) {
|
|
48
|
+
const encoded = new TextEncoder().encode(str);
|
|
49
|
+
return [...writeVarUint(encoded.length), ...encoded];
|
|
50
|
+
}
|
|
51
|
+
function remapClientIdInUpdate(update, fromId, toId) {
|
|
52
|
+
const result = [];
|
|
53
|
+
let pos = 0;
|
|
54
|
+
const [count, pos2] = readVarUint(update, pos);
|
|
55
|
+
pos = pos2;
|
|
56
|
+
result.push(...writeVarUint(count));
|
|
57
|
+
for (let i = 0; i < count; i++) {
|
|
58
|
+
const [clientID, pos3] = readVarUint(update, pos);
|
|
59
|
+
pos = pos3;
|
|
60
|
+
const [clock, pos4] = readVarUint(update, pos);
|
|
61
|
+
pos = pos4;
|
|
62
|
+
const [state, pos5] = readVarString(update, pos);
|
|
63
|
+
pos = pos5;
|
|
64
|
+
const mappedId = clientID === fromId ? toId : clientID;
|
|
65
|
+
result.push(...writeVarUint(mappedId));
|
|
66
|
+
result.push(...writeVarUint(clock));
|
|
67
|
+
result.push(...writeVarString(state));
|
|
68
|
+
}
|
|
69
|
+
return new Uint8Array(result);
|
|
70
|
+
}
|
|
71
|
+
function createIframeBridgeProvider(ydoc, awareness$1) {
|
|
72
|
+
let applyingParentUpdate = false;
|
|
73
|
+
let serverClientId = null;
|
|
74
|
+
const onYdocUpdate = (update) => {
|
|
75
|
+
if (applyingParentUpdate) return;
|
|
76
|
+
window.parent.postMessage(
|
|
77
|
+
{ type: "ydoc-update", payload: Array.from(update) },
|
|
78
|
+
"*"
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
const onAwarenessUpdate = ({
|
|
82
|
+
added,
|
|
83
|
+
updated,
|
|
84
|
+
removed
|
|
85
|
+
}) => {
|
|
86
|
+
if (applyingParentUpdate) return;
|
|
87
|
+
const changes = [...added, ...updated, ...removed];
|
|
88
|
+
if (changes.length === 0) return;
|
|
89
|
+
const update = awareness.encodeAwarenessUpdate(awareness$1, changes);
|
|
90
|
+
const remapped = serverClientId != null ? remapClientIdInUpdate(update, awareness$1.clientID, serverClientId) : update;
|
|
91
|
+
window.parent.postMessage(
|
|
92
|
+
{ type: "awareness-update", payload: Array.from(remapped) },
|
|
93
|
+
"*"
|
|
94
|
+
);
|
|
95
|
+
};
|
|
96
|
+
const onMessage = (event) => {
|
|
97
|
+
if (event.source !== window.parent) return;
|
|
98
|
+
const { type, payload, serverClientId: receivedServerId } = event.data;
|
|
99
|
+
if (type === "pong" && receivedServerId != null) {
|
|
100
|
+
serverClientId = receivedServerId;
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (type === "ydoc-sync" || type === "ydoc-update") {
|
|
104
|
+
applyingParentUpdate = true;
|
|
105
|
+
Y__namespace.applyUpdate(ydoc, new Uint8Array(payload));
|
|
106
|
+
applyingParentUpdate = false;
|
|
107
|
+
} else if (type === "awareness-sync" || type === "awareness-update") {
|
|
108
|
+
if (receivedServerId != null) {
|
|
109
|
+
serverClientId = receivedServerId;
|
|
110
|
+
}
|
|
111
|
+
const raw = new Uint8Array(payload);
|
|
112
|
+
const remapped = serverClientId != null ? remapClientIdInUpdate(raw, serverClientId, awareness$1.clientID) : raw;
|
|
113
|
+
applyingParentUpdate = true;
|
|
114
|
+
awareness.applyAwarenessUpdate(awareness$1, remapped, null);
|
|
115
|
+
applyingParentUpdate = false;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
ydoc.on("update", onYdocUpdate);
|
|
119
|
+
awareness$1.on("update", onAwarenessUpdate);
|
|
120
|
+
window.addEventListener("message", onMessage);
|
|
121
|
+
window.parent.postMessage({ type: "init" }, "*");
|
|
122
|
+
return {
|
|
123
|
+
get serverClientId() {
|
|
124
|
+
return serverClientId;
|
|
125
|
+
},
|
|
126
|
+
dispose: () => {
|
|
127
|
+
ydoc.off("update", onYdocUpdate);
|
|
128
|
+
awareness$1.off("update", onAwarenessUpdate);
|
|
129
|
+
window.removeEventListener("message", onMessage);
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
exports.createIframeBridgeProvider = createIframeBridgeProvider;
|
|
134
|
+
//# sourceMappingURL=provider.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.cjs.js","sources":["../../../iframe-bridge/src/provider.ts"],"sourcesContent":["import * as Y from \"yjs\";\nimport {\n Awareness,\n applyAwarenessUpdate,\n encodeAwarenessUpdate,\n} from \"y-protocols/awareness\";\n\nexport interface IframeBridgeProvider {\n serverClientId: number | null;\n dispose: () => void;\n}\n\nfunction readVarUint(data: Uint8Array, pos: number): [number, number] {\n let result = 0;\n let shift = 0;\n let byte: number;\n do {\n byte = data[pos++];\n result |= (byte & 0x7f) << shift;\n shift += 7;\n } while (byte >= 0x80);\n return [result >>> 0, pos];\n}\n\nfunction writeVarUint(value: number): number[] {\n const bytes: number[] = [];\n while (value > 0x7f) {\n bytes.push((value & 0x7f) | 0x80);\n value >>>= 7;\n }\n bytes.push(value);\n return bytes;\n}\n\nfunction readVarString(data: Uint8Array, pos: number): [string, number] {\n const [len, pos2] = readVarUint(data, pos);\n const str = new TextDecoder().decode(data.subarray(pos2, pos2 + len));\n return [str, pos2 + len];\n}\n\nfunction writeVarString(str: string): number[] {\n const encoded = new TextEncoder().encode(str);\n return [...writeVarUint(encoded.length), ...encoded];\n}\n\nfunction remapClientIdInUpdate(\n update: Uint8Array,\n fromId: number,\n toId: number,\n): Uint8Array {\n const result: number[] = [];\n let pos = 0;\n\n const [count, pos2] = readVarUint(update, pos);\n pos = pos2;\n result.push(...writeVarUint(count));\n\n for (let i = 0; i < count; i++) {\n const [clientID, pos3] = readVarUint(update, pos);\n pos = pos3;\n const [clock, pos4] = readVarUint(update, pos);\n pos = pos4;\n const [state, pos5] = readVarString(update, pos);\n pos = pos5;\n\n const mappedId = clientID === fromId ? toId : clientID;\n result.push(...writeVarUint(mappedId));\n result.push(...writeVarUint(clock));\n result.push(...writeVarString(state));\n }\n\n return new Uint8Array(result);\n}\n\nexport function createIframeBridgeProvider(\n ydoc: Y.Doc,\n awareness: Awareness,\n): IframeBridgeProvider {\n let applyingParentUpdate = false;\n let serverClientId: number | null = null;\n\n const onYdocUpdate = (update: Uint8Array) => {\n if (applyingParentUpdate) return;\n window.parent.postMessage(\n { type: \"ydoc-update\", payload: Array.from(update) },\n \"*\",\n );\n };\n\n const onAwarenessUpdate = ({\n added,\n updated,\n removed,\n }: {\n added: number[];\n updated: number[];\n removed: number[];\n }) => {\n if (applyingParentUpdate) return;\n const changes = [...added, ...updated, ...removed];\n if (changes.length === 0) return;\n\n const update = encodeAwarenessUpdate(awareness, changes);\n const remapped =\n serverClientId != null\n ? remapClientIdInUpdate(update, awareness.clientID, serverClientId)\n : update;\n\n window.parent.postMessage(\n { type: \"awareness-update\", payload: Array.from(remapped) },\n \"*\",\n );\n };\n\n const onMessage = (event: MessageEvent) => {\n if (event.source !== window.parent) return;\n const { type, payload, serverClientId: receivedServerId } = event.data;\n\n if (type === \"pong\" && receivedServerId != null) {\n serverClientId = receivedServerId;\n return;\n }\n\n if (type === \"ydoc-sync\" || type === \"ydoc-update\") {\n applyingParentUpdate = true;\n Y.applyUpdate(ydoc, new Uint8Array(payload));\n applyingParentUpdate = false;\n } else if (type === \"awareness-sync\" || type === \"awareness-update\") {\n if (receivedServerId != null) {\n serverClientId = receivedServerId;\n }\n\n const raw = new Uint8Array(payload);\n const remapped =\n serverClientId != null\n ? remapClientIdInUpdate(raw, serverClientId, awareness.clientID)\n : raw;\n\n applyingParentUpdate = true;\n applyAwarenessUpdate(awareness, remapped, null);\n applyingParentUpdate = false;\n }\n };\n\n ydoc.on(\"update\", onYdocUpdate);\n awareness.on(\"update\", onAwarenessUpdate);\n window.addEventListener(\"message\", onMessage);\n\n window.parent.postMessage({ type: \"init\" }, \"*\");\n\n return {\n get serverClientId() {\n return serverClientId;\n },\n dispose: () => {\n ydoc.off(\"update\", onYdocUpdate);\n awareness.off(\"update\", onAwarenessUpdate);\n window.removeEventListener(\"message\", onMessage);\n },\n };\n}\n"],"names":["awareness","encodeAwarenessUpdate","Y","applyAwarenessUpdate"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAYA,SAAS,YAAY,MAAkB,KAA+B;AACpE,MAAI,SAAS;AACb,MAAI,QAAQ;AACZ,MAAI;AACJ,KAAG;AACD,WAAO,KAAK,KAAK;AACjB,eAAW,OAAO,QAAS;AAC3B,aAAS;AAAA,EACX,SAAS,QAAQ;AACjB,SAAO,CAAC,WAAW,GAAG,GAAG;AAC3B;AAEA,SAAS,aAAa,OAAyB;AAC7C,QAAM,QAAkB,CAAA;AACxB,SAAO,QAAQ,KAAM;AACnB,UAAM,KAAM,QAAQ,MAAQ,GAAI;AAChC,eAAW;AAAA,EACb;AACA,QAAM,KAAK,KAAK;AAChB,SAAO;AACT;AAEA,SAAS,cAAc,MAAkB,KAA+B;AACtE,QAAM,CAAC,KAAK,IAAI,IAAI,YAAY,MAAM,GAAG;AACzC,QAAM,MAAM,IAAI,YAAA,EAAc,OAAO,KAAK,SAAS,MAAM,OAAO,GAAG,CAAC;AACpE,SAAO,CAAC,KAAK,OAAO,GAAG;AACzB;AAEA,SAAS,eAAe,KAAuB;AAC7C,QAAM,UAAU,IAAI,cAAc,OAAO,GAAG;AAC5C,SAAO,CAAC,GAAG,aAAa,QAAQ,MAAM,GAAG,GAAG,OAAO;AACrD;AAEA,SAAS,sBACP,QACA,QACA,MACY;A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,QAAQ,EAAA;AAAA,MACxD;AAAA,IAAA;AAAA,EAEJ;AAEA,QAAM,YAAY,CAAC,UAAwB;AACzC,QAAI,MAAM,WAAW,OAAO,OAAQ;AACpC,UAAM,EAAE,MAAM,SAAS,gBAAgB,iBAAA,IAAqB,MAAM;AAElE,QAAI,SAAS,UAAU,oBAAoB,MAAM;AAC/C,uBAAiB;AACjB;AAAA,IACF;AAEA,QAAI,SAAS,eAAe,SAAS,eAAe;AAClD,6BAAuB;AACvBE,mBAAE,YAAY,MAAM,IAAI,WAAW,OAAO,CAAC;AAC3C,6BAAuB;AAAA,IACzB,WAAW,SAAS,oBAAoB,SAAS,oBAAoB;AACnE,UAAI,oBAAoB,MAAM;AAC5B,yBAAiB;AAAA,MACnB;AAEA,YAAM,MAAM,IAAI,WAAW,OAAO;AAClC,YAAM,WACJ,kBAAkB,OACd,sBAAsB,KAAK,gBAAgBF,YAAU,QAAQ,IAC7D;AAEN,6BAAuB;AACvBG,qCAAqBH,aAAW,UAAU,IAAI;AAC9C,6BAAuB;AAAA,IACzB;AAAA,EACF;AAEA,OAAK,GAAG,UAAU,YAAY;AAC9BA,cAAU,GAAG,UAAU,iBAAiB;AACxC,SAAO,iBAAiB,WAAW,SAAS;AAE5C,SAAO,OAAO,YAAY,EAAE,MAAM,OAAA,GAAU,GAAG;AAE/C,SAAO;AAAA,IACL,IAAI,iBAAiB;AACnB,aAAO;AAAA,IACT;AAAA,IACA,SAAS,MAAM;AACb,WAAK,IAAI,UAAU,YAAY;AAC/BA,kBAAU,IAAI,UAAU,iBAAiB;AACzC,aAAO,oBAAoB,WAAW,SAAS;AAAA,IACjD;AAAA,EAAA;AAEJ;;"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import * as Y from "yjs";
|
|
2
|
+
import { encodeAwarenessUpdate, applyAwarenessUpdate } from "y-protocols/awareness";
|
|
3
|
+
function readVarUint(data, pos) {
|
|
4
|
+
let result = 0;
|
|
5
|
+
let shift = 0;
|
|
6
|
+
let byte;
|
|
7
|
+
do {
|
|
8
|
+
byte = data[pos++];
|
|
9
|
+
result |= (byte & 127) << shift;
|
|
10
|
+
shift += 7;
|
|
11
|
+
} while (byte >= 128);
|
|
12
|
+
return [result >>> 0, pos];
|
|
13
|
+
}
|
|
14
|
+
function writeVarUint(value) {
|
|
15
|
+
const bytes = [];
|
|
16
|
+
while (value > 127) {
|
|
17
|
+
bytes.push(value & 127 | 128);
|
|
18
|
+
value >>>= 7;
|
|
19
|
+
}
|
|
20
|
+
bytes.push(value);
|
|
21
|
+
return bytes;
|
|
22
|
+
}
|
|
23
|
+
function readVarString(data, pos) {
|
|
24
|
+
const [len, pos2] = readVarUint(data, pos);
|
|
25
|
+
const str = new TextDecoder().decode(data.subarray(pos2, pos2 + len));
|
|
26
|
+
return [str, pos2 + len];
|
|
27
|
+
}
|
|
28
|
+
function writeVarString(str) {
|
|
29
|
+
const encoded = new TextEncoder().encode(str);
|
|
30
|
+
return [...writeVarUint(encoded.length), ...encoded];
|
|
31
|
+
}
|
|
32
|
+
function remapClientIdInUpdate(update, fromId, toId) {
|
|
33
|
+
const result = [];
|
|
34
|
+
let pos = 0;
|
|
35
|
+
const [count, pos2] = readVarUint(update, pos);
|
|
36
|
+
pos = pos2;
|
|
37
|
+
result.push(...writeVarUint(count));
|
|
38
|
+
for (let i = 0; i < count; i++) {
|
|
39
|
+
const [clientID, pos3] = readVarUint(update, pos);
|
|
40
|
+
pos = pos3;
|
|
41
|
+
const [clock, pos4] = readVarUint(update, pos);
|
|
42
|
+
pos = pos4;
|
|
43
|
+
const [state, pos5] = readVarString(update, pos);
|
|
44
|
+
pos = pos5;
|
|
45
|
+
const mappedId = clientID === fromId ? toId : clientID;
|
|
46
|
+
result.push(...writeVarUint(mappedId));
|
|
47
|
+
result.push(...writeVarUint(clock));
|
|
48
|
+
result.push(...writeVarString(state));
|
|
49
|
+
}
|
|
50
|
+
return new Uint8Array(result);
|
|
51
|
+
}
|
|
52
|
+
function createIframeBridgeProvider(ydoc, awareness) {
|
|
53
|
+
let applyingParentUpdate = false;
|
|
54
|
+
let serverClientId = null;
|
|
55
|
+
const onYdocUpdate = (update) => {
|
|
56
|
+
if (applyingParentUpdate) return;
|
|
57
|
+
window.parent.postMessage(
|
|
58
|
+
{ type: "ydoc-update", payload: Array.from(update) },
|
|
59
|
+
"*"
|
|
60
|
+
);
|
|
61
|
+
};
|
|
62
|
+
const onAwarenessUpdate = ({
|
|
63
|
+
added,
|
|
64
|
+
updated,
|
|
65
|
+
removed
|
|
66
|
+
}) => {
|
|
67
|
+
if (applyingParentUpdate) return;
|
|
68
|
+
const changes = [...added, ...updated, ...removed];
|
|
69
|
+
if (changes.length === 0) return;
|
|
70
|
+
const update = encodeAwarenessUpdate(awareness, changes);
|
|
71
|
+
const remapped = serverClientId != null ? remapClientIdInUpdate(update, awareness.clientID, serverClientId) : update;
|
|
72
|
+
window.parent.postMessage(
|
|
73
|
+
{ type: "awareness-update", payload: Array.from(remapped) },
|
|
74
|
+
"*"
|
|
75
|
+
);
|
|
76
|
+
};
|
|
77
|
+
const onMessage = (event) => {
|
|
78
|
+
if (event.source !== window.parent) return;
|
|
79
|
+
const { type, payload, serverClientId: receivedServerId } = event.data;
|
|
80
|
+
if (type === "pong" && receivedServerId != null) {
|
|
81
|
+
serverClientId = receivedServerId;
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
if (type === "ydoc-sync" || type === "ydoc-update") {
|
|
85
|
+
applyingParentUpdate = true;
|
|
86
|
+
Y.applyUpdate(ydoc, new Uint8Array(payload));
|
|
87
|
+
applyingParentUpdate = false;
|
|
88
|
+
} else if (type === "awareness-sync" || type === "awareness-update") {
|
|
89
|
+
if (receivedServerId != null) {
|
|
90
|
+
serverClientId = receivedServerId;
|
|
91
|
+
}
|
|
92
|
+
const raw = new Uint8Array(payload);
|
|
93
|
+
const remapped = serverClientId != null ? remapClientIdInUpdate(raw, serverClientId, awareness.clientID) : raw;
|
|
94
|
+
applyingParentUpdate = true;
|
|
95
|
+
applyAwarenessUpdate(awareness, remapped, null);
|
|
96
|
+
applyingParentUpdate = false;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
ydoc.on("update", onYdocUpdate);
|
|
100
|
+
awareness.on("update", onAwarenessUpdate);
|
|
101
|
+
window.addEventListener("message", onMessage);
|
|
102
|
+
window.parent.postMessage({ type: "init" }, "*");
|
|
103
|
+
return {
|
|
104
|
+
get serverClientId() {
|
|
105
|
+
return serverClientId;
|
|
106
|
+
},
|
|
107
|
+
dispose: () => {
|
|
108
|
+
ydoc.off("update", onYdocUpdate);
|
|
109
|
+
awareness.off("update", onAwarenessUpdate);
|
|
110
|
+
window.removeEventListener("message", onMessage);
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
export {
|
|
115
|
+
createIframeBridgeProvider
|
|
116
|
+
};
|
|
117
|
+
//# sourceMappingURL=provider.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.es.js","sources":["../../../iframe-bridge/src/provider.ts"],"sourcesContent":["import * as Y from \"yjs\";\nimport {\n Awareness,\n applyAwarenessUpdate,\n encodeAwarenessUpdate,\n} from \"y-protocols/awareness\";\n\nexport interface IframeBridgeProvider {\n serverClientId: number | null;\n dispose: () => void;\n}\n\nfunction readVarUint(data: Uint8Array, pos: number): [number, number] {\n let result = 0;\n let shift = 0;\n let byte: number;\n do {\n byte = data[pos++];\n result |= (byte & 0x7f) << shift;\n shift += 7;\n } while (byte >= 0x80);\n return [result >>> 0, pos];\n}\n\nfunction writeVarUint(value: number): number[] {\n const bytes: number[] = [];\n while (value > 0x7f) {\n bytes.push((value & 0x7f) | 0x80);\n value >>>= 7;\n }\n bytes.push(value);\n return bytes;\n}\n\nfunction readVarString(data: Uint8Array, pos: number): [string, number] {\n const [len, pos2] = readVarUint(data, pos);\n const str = new TextDecoder().decode(data.subarray(pos2, pos2 + len));\n return [str, pos2 + len];\n}\n\nfunction writeVarString(str: string): number[] {\n const encoded = new TextEncoder().encode(str);\n return [...writeVarUint(encoded.length), ...encoded];\n}\n\nfunction remapClientIdInUpdate(\n update: Uint8Array,\n fromId: number,\n toId: number,\n): Uint8Array {\n const result: number[] = [];\n let pos = 0;\n\n const [count, pos2] = readVarUint(update, pos);\n pos = pos2;\n result.push(...writeVarUint(count));\n\n for (let i = 0; i < count; i++) {\n const [clientID, pos3] = readVarUint(update, pos);\n pos = pos3;\n const [clock, pos4] = readVarUint(update, pos);\n pos = pos4;\n const [state, pos5] = readVarString(update, pos);\n pos = pos5;\n\n const mappedId = clientID === fromId ? toId : clientID;\n result.push(...writeVarUint(mappedId));\n result.push(...writeVarUint(clock));\n result.push(...writeVarString(state));\n }\n\n return new Uint8Array(result);\n}\n\nexport function createIframeBridgeProvider(\n ydoc: Y.Doc,\n awareness: Awareness,\n): IframeBridgeProvider {\n let applyingParentUpdate = false;\n let serverClientId: number | null = null;\n\n const onYdocUpdate = (update: Uint8Array) => {\n if (applyingParentUpdate) return;\n window.parent.postMessage(\n { type: \"ydoc-update\", payload: Array.from(update) },\n \"*\",\n );\n };\n\n const onAwarenessUpdate = ({\n added,\n updated,\n removed,\n }: {\n added: number[];\n updated: number[];\n removed: number[];\n }) => {\n if (applyingParentUpdate) return;\n const changes = [...added, ...updated, ...removed];\n if (changes.length === 0) return;\n\n const update = encodeAwarenessUpdate(awareness, changes);\n const remapped =\n serverClientId != null\n ? remapClientIdInUpdate(update, awareness.clientID, serverClientId)\n : update;\n\n window.parent.postMessage(\n { type: \"awareness-update\", payload: Array.from(remapped) },\n \"*\",\n );\n };\n\n const onMessage = (event: MessageEvent) => {\n if (event.source !== window.parent) return;\n const { type, payload, serverClientId: receivedServerId } = event.data;\n\n if (type === \"pong\" && receivedServerId != null) {\n serverClientId = receivedServerId;\n return;\n }\n\n if (type === \"ydoc-sync\" || type === \"ydoc-update\") {\n applyingParentUpdate = true;\n Y.applyUpdate(ydoc, new Uint8Array(payload));\n applyingParentUpdate = false;\n } else if (type === \"awareness-sync\" || type === \"awareness-update\") {\n if (receivedServerId != null) {\n serverClientId = receivedServerId;\n }\n\n const raw = new Uint8Array(payload);\n const remapped =\n serverClientId != null\n ? remapClientIdInUpdate(raw, serverClientId, awareness.clientID)\n : raw;\n\n applyingParentUpdate = true;\n applyAwarenessUpdate(awareness, remapped, null);\n applyingParentUpdate = false;\n }\n };\n\n ydoc.on(\"update\", onYdocUpdate);\n awareness.on(\"update\", onAwarenessUpdate);\n window.addEventListener(\"message\", onMessage);\n\n window.parent.postMessage({ type: \"init\" }, \"*\");\n\n return {\n get serverClientId() {\n return serverClientId;\n },\n dispose: () => {\n ydoc.off(\"update\", onYdocUpdate);\n awareness.off(\"update\", onAwarenessUpdate);\n window.removeEventListener(\"message\", onMessage);\n },\n };\n}\n"],"names":[],"mappings":";;AAYA,SAAS,YAAY,MAAkB,KAA+B;AACpE,MAAI,SAAS;AACb,MAAI,QAAQ;AACZ,MAAI;AACJ,KAAG;AACD,WAAO,KAAK,KAAK;AACjB,eAAW,OAAO,QAAS;AAC3B,aAAS;AAAA,EACX,SAAS,QAAQ;AACjB,SAAO,CAAC,WAAW,GAAG,GAAG;AAC3B;AAEA,SAAS,aAAa,OAAyB;AAC7C,QAAM,QAAkB,CAAA;AACxB,SAAO,QAAQ,KAAM;AACnB,UAAM,KAAM,QAAQ,MAAQ,GAAI;AAChC,eAAW;AAAA,EACb;AACA,QAAM,KAAK,KAAK;AAChB,SAAO;AACT;AAEA,SAAS,cAAc,MAAkB,KAA+B;AACtE,QAAM,CAAC,KAAK,IAAI,IAAI,YAAY,MAAM,GAAG;AACzC,QAAM,MAAM,IAAI,YAAA,EAAc,OAAO,KAAK,SAAS,MAAM,OAAO,GAAG,CAAC;AACpE,SAAO,CAAC,KAAK,OAAO,GAAG;AACzB;AAEA,SAAS,eAAe,KAAuB;AAC7C,QAAM,UAAU,IAAI,cAAc,OAAO,GAAG;AAC5C,SAAO,CAAC,GAAG,aAAa,QAAQ,MAAM,GAAG,G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Z,EAAE,MAAM,oBAAoB,SAAS,MAAM,KAAK,QAAQ,EAAA;AAAA,MACxD;AAAA,IAAA;AAAA,EAEJ;AAEA,QAAM,YAAY,CAAC,UAAwB;AACzC,QAAI,MAAM,WAAW,OAAO,OAAQ;AACpC,UAAM,EAAE,MAAM,SAAS,gBAAgB,iBAAA,IAAqB,MAAM;AAElE,QAAI,SAAS,UAAU,oBAAoB,MAAM;AAC/C,uBAAiB;AACjB;AAAA,IACF;AAEA,QAAI,SAAS,eAAe,SAAS,eAAe;AAClD,6BAAuB;AACvB,QAAE,YAAY,MAAM,IAAI,WAAW,OAAO,CAAC;AAC3C,6BAAuB;AAAA,IACzB,WAAW,SAAS,oBAAoB,SAAS,oBAAoB;AACnE,UAAI,oBAAoB,MAAM;AAC5B,yBAAiB;AAAA,MACnB;AAEA,YAAM,MAAM,IAAI,WAAW,OAAO;AAClC,YAAM,WACJ,kBAAkB,OACd,sBAAsB,KAAK,gBAAgB,UAAU,QAAQ,IAC7D;AAEN,6BAAuB;AACvB,2BAAqB,WAAW,UAAU,IAAI;AAC9C,6BAAuB;AAAA,IACzB;AAAA,EACF;AAEA,OAAK,GAAG,UAAU,YAAY;AAC9B,YAAU,GAAG,UAAU,iBAAiB;AACxC,SAAO,iBAAiB,WAAW,SAAS;AAE5C,SAAO,OAAO,YAAY,EAAE,MAAM,OAAA,GAAU,GAAG;AAE/C,SAAO;AAAA,IACL,IAAI,iBAAiB;AACnB,aAAO;AAAA,IACT;AAAA,IACA,SAAS,MAAM;AACb,WAAK,IAAI,UAAU,YAAY;AAC/B,gBAAU,IAAI,UAAU,iBAAiB;AACzC,aAAO,oBAAoB,WAAW,SAAS;AAAA,IACjD;AAAA,EAAA;AAEJ;"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const Y = require("yjs");
|
|
4
|
+
const awareness = require("y-protocols/awareness");
|
|
5
|
+
function _interopNamespaceDefault(e) {
|
|
6
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
7
|
+
if (e) {
|
|
8
|
+
for (const k in e) {
|
|
9
|
+
if (k !== "default") {
|
|
10
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
11
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: () => e[k]
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
n.default = e;
|
|
19
|
+
return Object.freeze(n);
|
|
20
|
+
}
|
|
21
|
+
const Y__namespace = /* @__PURE__ */ _interopNamespaceDefault(Y);
|
|
22
|
+
function createIframeBridgeServer(ydoc, awareness$1) {
|
|
23
|
+
const iframes = /* @__PURE__ */ new Map();
|
|
24
|
+
const iframeReady = /* @__PURE__ */ new Set();
|
|
25
|
+
const onYdocUpdate = (update) => {
|
|
26
|
+
broadcastToAll("ydoc-update", update);
|
|
27
|
+
};
|
|
28
|
+
const onAwarenessUpdate = ({
|
|
29
|
+
added,
|
|
30
|
+
updated,
|
|
31
|
+
removed
|
|
32
|
+
}) => {
|
|
33
|
+
const changes = [...added, ...updated, ...removed];
|
|
34
|
+
if (changes.length === 0) return;
|
|
35
|
+
const update = awareness.encodeAwarenessUpdate(awareness$1, changes);
|
|
36
|
+
broadcastToAll("awareness-update", update);
|
|
37
|
+
};
|
|
38
|
+
function broadcastToAll(type, payload) {
|
|
39
|
+
for (const iframe of iframes.values()) {
|
|
40
|
+
if (iframe.contentWindow) {
|
|
41
|
+
iframe.contentWindow.postMessage({ type, payload }, "*");
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const onMessage = (event) => {
|
|
46
|
+
let iframeId = null;
|
|
47
|
+
for (const [id, iframe] of iframes) {
|
|
48
|
+
if (event.source === iframe.contentWindow) {
|
|
49
|
+
iframeId = id;
|
|
50
|
+
break;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (!iframeId) return;
|
|
54
|
+
const { type: msgType, payload } = event.data;
|
|
55
|
+
const sourceWindow = event.source;
|
|
56
|
+
if (msgType === "init") {
|
|
57
|
+
if (!iframeReady.has(iframeId)) {
|
|
58
|
+
iframeReady.add(iframeId);
|
|
59
|
+
}
|
|
60
|
+
const docState = Y__namespace.encodeStateAsUpdate(ydoc);
|
|
61
|
+
const awarenessState = awareness.encodeAwarenessUpdate(
|
|
62
|
+
awareness$1,
|
|
63
|
+
Array.from(awareness$1.getStates().keys())
|
|
64
|
+
);
|
|
65
|
+
sourceWindow.postMessage(
|
|
66
|
+
{ type: "ydoc-sync", payload: Array.from(docState) },
|
|
67
|
+
"*"
|
|
68
|
+
);
|
|
69
|
+
sourceWindow.postMessage(
|
|
70
|
+
{
|
|
71
|
+
type: "awareness-sync",
|
|
72
|
+
payload: Array.from(awarenessState),
|
|
73
|
+
serverClientId: awareness$1.clientID
|
|
74
|
+
},
|
|
75
|
+
"*"
|
|
76
|
+
);
|
|
77
|
+
} else if (msgType === "ping") {
|
|
78
|
+
sourceWindow.postMessage(
|
|
79
|
+
{ type: "pong", serverClientId: awareness$1.clientID },
|
|
80
|
+
"*"
|
|
81
|
+
);
|
|
82
|
+
} else if (msgType === "ydoc-update") {
|
|
83
|
+
Y__namespace.applyUpdate(ydoc, new Uint8Array(payload));
|
|
84
|
+
} else if (msgType === "awareness-update") {
|
|
85
|
+
awareness.applyAwarenessUpdate(awareness$1, new Uint8Array(payload), null);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
function addIframe(iframe, iframeId) {
|
|
89
|
+
iframes.set(iframeId, iframe);
|
|
90
|
+
}
|
|
91
|
+
function removeIframe(iframeId) {
|
|
92
|
+
iframes.delete(iframeId);
|
|
93
|
+
iframeReady.delete(iframeId);
|
|
94
|
+
}
|
|
95
|
+
ydoc.on("update", onYdocUpdate);
|
|
96
|
+
awareness$1.on("update", onAwarenessUpdate);
|
|
97
|
+
window.addEventListener("message", onMessage);
|
|
98
|
+
return {
|
|
99
|
+
addIframe,
|
|
100
|
+
removeIframe,
|
|
101
|
+
dispose: () => {
|
|
102
|
+
ydoc.off("update", onYdocUpdate);
|
|
103
|
+
awareness$1.off("update", onAwarenessUpdate);
|
|
104
|
+
window.removeEventListener("message", onMessage);
|
|
105
|
+
iframes.clear();
|
|
106
|
+
iframeReady.clear();
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
exports.createIframeBridgeServer = createIframeBridgeServer;
|
|
111
|
+
//# sourceMappingURL=server.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.cjs.js","sources":["../../../iframe-bridge/src/server.ts"],"sourcesContent":["import * as Y from \"yjs\";\nimport {\n Awareness,\n applyAwarenessUpdate,\n encodeAwarenessUpdate,\n} from \"y-protocols/awareness\";\n\nexport interface IframeBridgeServer {\n addIframe: (iframe: HTMLIFrameElement, iframeId: string) => void;\n removeIframe: (iframeId: string) => void;\n dispose: () => void;\n}\n\nexport function createIframeBridgeServer(\n ydoc: Y.Doc,\n awareness: Awareness,\n): IframeBridgeServer {\n const iframes = new Map<string, HTMLIFrameElement>();\n const iframeReady = new Set<string>();\n\n const onYdocUpdate = (update: Uint8Array) => {\n broadcastToAll(\"ydoc-update\", update);\n };\n\n const onAwarenessUpdate = ({\n added,\n updated,\n removed,\n }: {\n added: number[];\n updated: number[];\n removed: number[];\n }) => {\n const changes = [...added, ...updated, ...removed];\n if (changes.length === 0) return;\n const update = encodeAwarenessUpdate(awareness, changes);\n broadcastToAll(\"awareness-update\", update);\n };\n\n function broadcastToAll(type: string, payload: Uint8Array) {\n for (const iframe of iframes.values()) {\n if (iframe.contentWindow) {\n iframe.contentWindow.postMessage({ type, payload }, \"*\");\n }\n }\n }\n\n const onMessage = (event: MessageEvent) => {\n let iframeId: string | null = null;\n for (const [id, iframe] of iframes) {\n if (event.source === iframe.contentWindow) {\n iframeId = id;\n break;\n }\n }\n if (!iframeId) return;\n\n const { type: msgType, payload } = event.data;\n const sourceWindow = event.source as Window;\n\n if (msgType === \"init\") {\n if (!iframeReady.has(iframeId)) {\n iframeReady.add(iframeId);\n }\n const docState = Y.encodeStateAsUpdate(ydoc);\n const awarenessState = encodeAwarenessUpdate(\n awareness,\n Array.from(awareness.getStates().keys()),\n );\n sourceWindow.postMessage(\n { type: \"ydoc-sync\", payload: Array.from(docState) },\n \"*\",\n );\n sourceWindow.postMessage(\n {\n type: \"awareness-sync\",\n payload: Array.from(awarenessState),\n serverClientId: awareness.clientID,\n },\n \"*\",\n );\n } else if (msgType === \"ping\") {\n sourceWindow.postMessage(\n { type: \"pong\", serverClientId: awareness.clientID },\n \"*\",\n );\n } else if (msgType === \"ydoc-update\") {\n Y.applyUpdate(ydoc, new Uint8Array(payload));\n } else if (msgType === \"awareness-update\") {\n applyAwarenessUpdate(awareness, new Uint8Array(payload), null);\n }\n };\n\n function addIframe(iframe: HTMLIFrameElement, iframeId: string) {\n iframes.set(iframeId, iframe);\n }\n\n function removeIframe(iframeId: string) {\n iframes.delete(iframeId);\n iframeReady.delete(iframeId);\n }\n\n ydoc.on(\"update\", onYdocUpdate);\n awareness.on(\"update\", onAwarenessUpdate);\n window.addEventListener(\"message\", onMessage);\n\n return {\n addIframe,\n removeIframe,\n dispose: () => {\n ydoc.off(\"update\", onYdocUpdate);\n awareness.off(\"update\", onAwarenessUpdate);\n window.removeEventListener(\"message\", onMessage);\n iframes.clear();\n iframeReady.clear();\n },\n };\n}\n"],"names":["awareness","encodeAwarenessUpdate","Y","applyAwarenessUpdate"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAaO,SAAS,yBACd,MACAA,aACoB;AACpB,QAAM,8BAAc,IAAA;AACpB,QAAM,kCAAkB,IAAA;AAExB,QAAM,eAAe,CAAC,WAAuB;AAC3C,mBAAe,eAAe,MAAM;AAAA,EACtC;AAEA,QAAM,oBAAoB,CAAC;AAAA,IACzB;AAAA,I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,YAAU,SAAA;AAAA,QAC1C;AAAA,MAAA;AAAA,IAEJ,WAAW,YAAY,eAAe;AACpCE,mBAAE,YAAY,MAAM,IAAI,WAAW,OAAO,CAAC;AAAA,IAC7C,WAAW,YAAY,oBAAoB;AACzCC,gBAAAA,qBAAqBH,aAAW,IAAI,WAAW,OAAO,GAAG,IAAI;AAAA,IAC/D;AAAA,EACF;AAEA,WAAS,UAAU,QAA2B,UAAkB;AAC9D,YAAQ,IAAI,UAAU,MAAM;AAAA,EAC9B;AAEA,WAAS,aAAa,UAAkB;AACtC,YAAQ,OAAO,QAAQ;AACvB,gBAAY,OAAO,QAAQ;AAAA,EAC7B;AAEA,OAAK,GAAG,UAAU,YAAY;AAC9BA,cAAU,GAAG,UAAU,iBAAiB;AACxC,SAAO,iBAAiB,WAAW,SAAS;AAE5C,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,SAAS,MAAM;AACb,WAAK,IAAI,UAAU,YAAY;AAC/BA,kBAAU,IAAI,UAAU,iBAAiB;AACzC,aAAO,oBAAoB,WAAW,SAAS;AAC/C,cAAQ,MAAA;AACR,kBAAY,MAAA;AAAA,IACd;AAAA,EAAA;AAEJ;;"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import * as Y from "yjs";
|
|
2
|
+
import { encodeAwarenessUpdate, applyAwarenessUpdate } from "y-protocols/awareness";
|
|
3
|
+
function createIframeBridgeServer(ydoc, awareness) {
|
|
4
|
+
const iframes = /* @__PURE__ */ new Map();
|
|
5
|
+
const iframeReady = /* @__PURE__ */ new Set();
|
|
6
|
+
const onYdocUpdate = (update) => {
|
|
7
|
+
broadcastToAll("ydoc-update", update);
|
|
8
|
+
};
|
|
9
|
+
const onAwarenessUpdate = ({
|
|
10
|
+
added,
|
|
11
|
+
updated,
|
|
12
|
+
removed
|
|
13
|
+
}) => {
|
|
14
|
+
const changes = [...added, ...updated, ...removed];
|
|
15
|
+
if (changes.length === 0) return;
|
|
16
|
+
const update = encodeAwarenessUpdate(awareness, changes);
|
|
17
|
+
broadcastToAll("awareness-update", update);
|
|
18
|
+
};
|
|
19
|
+
function broadcastToAll(type, payload) {
|
|
20
|
+
for (const iframe of iframes.values()) {
|
|
21
|
+
if (iframe.contentWindow) {
|
|
22
|
+
iframe.contentWindow.postMessage({ type, payload }, "*");
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const onMessage = (event) => {
|
|
27
|
+
let iframeId = null;
|
|
28
|
+
for (const [id, iframe] of iframes) {
|
|
29
|
+
if (event.source === iframe.contentWindow) {
|
|
30
|
+
iframeId = id;
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (!iframeId) return;
|
|
35
|
+
const { type: msgType, payload } = event.data;
|
|
36
|
+
const sourceWindow = event.source;
|
|
37
|
+
if (msgType === "init") {
|
|
38
|
+
if (!iframeReady.has(iframeId)) {
|
|
39
|
+
iframeReady.add(iframeId);
|
|
40
|
+
}
|
|
41
|
+
const docState = Y.encodeStateAsUpdate(ydoc);
|
|
42
|
+
const awarenessState = encodeAwarenessUpdate(
|
|
43
|
+
awareness,
|
|
44
|
+
Array.from(awareness.getStates().keys())
|
|
45
|
+
);
|
|
46
|
+
sourceWindow.postMessage(
|
|
47
|
+
{ type: "ydoc-sync", payload: Array.from(docState) },
|
|
48
|
+
"*"
|
|
49
|
+
);
|
|
50
|
+
sourceWindow.postMessage(
|
|
51
|
+
{
|
|
52
|
+
type: "awareness-sync",
|
|
53
|
+
payload: Array.from(awarenessState),
|
|
54
|
+
serverClientId: awareness.clientID
|
|
55
|
+
},
|
|
56
|
+
"*"
|
|
57
|
+
);
|
|
58
|
+
} else if (msgType === "ping") {
|
|
59
|
+
sourceWindow.postMessage(
|
|
60
|
+
{ type: "pong", serverClientId: awareness.clientID },
|
|
61
|
+
"*"
|
|
62
|
+
);
|
|
63
|
+
} else if (msgType === "ydoc-update") {
|
|
64
|
+
Y.applyUpdate(ydoc, new Uint8Array(payload));
|
|
65
|
+
} else if (msgType === "awareness-update") {
|
|
66
|
+
applyAwarenessUpdate(awareness, new Uint8Array(payload), null);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
function addIframe(iframe, iframeId) {
|
|
70
|
+
iframes.set(iframeId, iframe);
|
|
71
|
+
}
|
|
72
|
+
function removeIframe(iframeId) {
|
|
73
|
+
iframes.delete(iframeId);
|
|
74
|
+
iframeReady.delete(iframeId);
|
|
75
|
+
}
|
|
76
|
+
ydoc.on("update", onYdocUpdate);
|
|
77
|
+
awareness.on("update", onAwarenessUpdate);
|
|
78
|
+
window.addEventListener("message", onMessage);
|
|
79
|
+
return {
|
|
80
|
+
addIframe,
|
|
81
|
+
removeIframe,
|
|
82
|
+
dispose: () => {
|
|
83
|
+
ydoc.off("update", onYdocUpdate);
|
|
84
|
+
awareness.off("update", onAwarenessUpdate);
|
|
85
|
+
window.removeEventListener("message", onMessage);
|
|
86
|
+
iframes.clear();
|
|
87
|
+
iframeReady.clear();
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
export {
|
|
92
|
+
createIframeBridgeServer
|
|
93
|
+
};
|
|
94
|
+
//# sourceMappingURL=server.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.es.js","sources":["../../../iframe-bridge/src/server.ts"],"sourcesContent":["import * as Y from \"yjs\";\nimport {\n Awareness,\n applyAwarenessUpdate,\n encodeAwarenessUpdate,\n} from \"y-protocols/awareness\";\n\nexport interface IframeBridgeServer {\n addIframe: (iframe: HTMLIFrameElement, iframeId: string) => void;\n removeIframe: (iframeId: string) => void;\n dispose: () => void;\n}\n\nexport function createIframeBridgeServer(\n ydoc: Y.Doc,\n awareness: Awareness,\n): IframeBridgeServer {\n const iframes = new Map<string, HTMLIFrameElement>();\n const iframeReady = new Set<string>();\n\n const onYdocUpdate = (update: Uint8Array) => {\n broadcastToAll(\"ydoc-update\", update);\n };\n\n const onAwarenessUpdate = ({\n added,\n updated,\n removed,\n }: {\n added: number[];\n updated: number[];\n removed: number[];\n }) => {\n const changes = [...added, ...updated, ...removed];\n if (changes.length === 0) return;\n const update = encodeAwarenessUpdate(awareness, changes);\n broadcastToAll(\"awareness-update\", update);\n };\n\n function broadcastToAll(type: string, payload: Uint8Array) {\n for (const iframe of iframes.values()) {\n if (iframe.contentWindow) {\n iframe.contentWindow.postMessage({ type, payload }, \"*\");\n }\n }\n }\n\n const onMessage = (event: MessageEvent) => {\n let iframeId: string | null = null;\n for (const [id, iframe] of iframes) {\n if (event.source === iframe.contentWindow) {\n iframeId = id;\n break;\n }\n }\n if (!iframeId) return;\n\n const { type: msgType, payload } = event.data;\n const sourceWindow = event.source as Window;\n\n if (msgType === \"init\") {\n if (!iframeReady.has(iframeId)) {\n iframeReady.add(iframeId);\n }\n const docState = Y.encodeStateAsUpdate(ydoc);\n const awarenessState = encodeAwarenessUpdate(\n awareness,\n Array.from(awareness.getStates().keys()),\n );\n sourceWindow.postMessage(\n { type: \"ydoc-sync\", payload: Array.from(docState) },\n \"*\",\n );\n sourceWindow.postMessage(\n {\n type: \"awareness-sync\",\n payload: Array.from(awarenessState),\n serverClientId: awareness.clientID,\n },\n \"*\",\n );\n } else if (msgType === \"ping\") {\n sourceWindow.postMessage(\n { type: \"pong\", serverClientId: awareness.clientID },\n \"*\",\n );\n } else if (msgType === \"ydoc-update\") {\n Y.applyUpdate(ydoc, new Uint8Array(payload));\n } else if (msgType === \"awareness-update\") {\n applyAwarenessUpdate(awareness, new Uint8Array(payload), null);\n }\n };\n\n function addIframe(iframe: HTMLIFrameElement, iframeId: string) {\n iframes.set(iframeId, iframe);\n }\n\n function removeIframe(iframeId: string) {\n iframes.delete(iframeId);\n iframeReady.delete(iframeId);\n }\n\n ydoc.on(\"update\", onYdocUpdate);\n awareness.on(\"update\", onAwarenessUpdate);\n window.addEventListener(\"message\", onMessage);\n\n return {\n addIframe,\n removeIframe,\n dispose: () => {\n ydoc.off(\"update\", onYdocUpdate);\n awareness.off(\"update\", onAwarenessUpdate);\n window.removeEventListener(\"message\", onMessage);\n iframes.clear();\n iframeReady.clear();\n },\n };\n}\n"],"names":[],"mappings":";;AAaO,SAAS,yBACd,MACA,WACoB;AACpB,QAAM,8BAAc,IAAA;AACpB,QAAM,kCAAkB,IAAA;AAExB,QAAM,eAAe,CAAC,WAAuB;AAC3C,mBAAe,eAAe,MAAM;AAAA,EACtC;AAEA,QAAM,oBAAoB,CAAC;AAAA,IACzB;AAAA,IACA;AAAA,IACA;AAAA,EAAA,MAKI;AACJ,UAAM,UAAU,CAAC,GAAG,OAAO,GAAG,SAAS,GAAG,OAAO;AACjD,QAAI,QAAQ,WAAW,EAAG;AAC1B,UAAM,SAAS,sBAAsB,WAAW,OAAO;AACvD,mBAAe,oBAAoB,MAAM;AAAA,EAC3C;AAEA,WAAS,eAAe,MAAc,SAAqB;AACzD,eAAW,UAAU,QAAQ,UAAU;AACrC,UAAI,OAAO,eAAe;AACxB,eAAO,cAAc,YAAY,EAAE,MAAM,QAAA,GAAW,GAAG;AAAA,MACzD;AAAA,IACF;AAAA,EACF;AAEA,QAAM,YAAY,CAAC,UAAwB;AACzC,QAAI,WAA0B;AAC9B,eAAW,CAAC,IAAI,MAAM,KAAK,SAAS;AAClC,UAAI,MAAM,WAAW,OAAO,eAAe;AACzC,mBAAW;AACX;AAAA,MACF;AAAA,IACF;AACA,QAAI,CAAC,SAAU;AAEf,UAAM,EAAE,MAAM,SAAS,QAAA,IAAY,MAAM;AACzC,UAAM,eAAe,MAAM;AAE3B,QAAI,YAAY,QAAQ;AACtB,UAAI,CAAC,YAAY,IAAI,QAAQ,GAAG;AAC9B,oBAAY,IAAI,QAAQ;AAAA,MAC1B;AACA,YAAM,WAAW,EAAE,oBAAoB,IAAI;AAC3C,YAAM,iBAAiB;AAAA,QACrB;AAAA,QACA,MAAM,KAAK,UAAU,UAAA,EAAY,MAAM;AAAA,MAAA;AAEzC,mBAAa;AAAA,QACX,EAAE,MAAM,aAAa,SAAS,MAAM,KAAK,QAAQ,EAAA;AAAA,QACjD;AAAA,MAAA;AAEF,mBAAa;AAAA,QACX;AAAA,UACE,MAAM;AAAA,UACN,SAAS,MAAM,KAAK,cAAc;AAAA,UAClC,gBAAgB,UAAU;AAAA,QAAA;AAAA,QAE5B;AAAA,MAAA;AAAA,IAEJ,WAAW,YAAY,QAAQ;AAC7B,mBAAa;AAAA,QACX,EAAE,MAAM,QAAQ,gBAAgB,UAAU,SAAA;AAAA,QAC1C;AAAA,MAAA;AAAA,IAEJ,WAAW,YAAY,eAAe;AACpC,QAAE,YAAY,MAAM,IAAI,WAAW,OAAO,CAAC;AAAA,IAC7C,WAAW,YAAY,oBAAoB;AACzC,2BAAqB,WAAW,IAAI,WAAW,OAAO,GAAG,IAAI;AAAA,IAC/D;AAAA,EACF;AAEA,WAAS,UAAU,QAA2B,UAAkB;AAC9D,YAAQ,IAAI,UAAU,MAAM;AAAA,EAC9B;AAEA,WAAS,aAAa,UAAkB;AACtC,YAAQ,OAAO,QAAQ;AACvB,gBAAY,OAAO,QAAQ;AAAA,EAC7B;AAEA,OAAK,GAAG,UAAU,YAAY;AAC9B,YAAU,GAAG,UAAU,iBAAiB;AACxC,SAAO,iBAAiB,WAAW,SAAS;AAE5C,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,SAAS,MAAM;AACb,WAAK,IAAI,UAAU,YAAY;AAC/B,gBAAU,IAAI,UAAU,iBAAiB;AACzC,aAAO,oBAAoB,WAAW,SAAS;AAC/C,cAAQ,MAAA;AACR,kBAAY,MAAA;AAAA,IACd;AAAA,EAAA;AAEJ;"}
|
package/index.d.ts
CHANGED
|
@@ -3,6 +3,4 @@ export type { BindDrawioFileOptions, InitialContentStrategy } from "./binding";
|
|
|
3
3
|
export { xml2doc, doc2xml } from "./transformer";
|
|
4
4
|
export { LOCAL_ORIGIN } from "./helper/origin";
|
|
5
5
|
export { DEFAULT_USER_NAME_KEY, DEFAULT_USER_COLOR_KEY, } from "./binding/collaborator";
|
|
6
|
-
export { createIframeBridgeProvider, createIframeBridgeServer, } from "@y-mxgraph/iframe-bridge";
|
|
7
|
-
export type { IframeBridgeProvider, IframeBridgeServer, } from "@y-mxgraph/iframe-bridge";
|
|
8
6
|
//# sourceMappingURL=index.d.ts.map
|
package/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,YAAY,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAC/E,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,wBAAwB,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,YAAY,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAC/E,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,wBAAwB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "y-mxgraph",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "Yjs binding for draw.io (mxGraph) documents",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"yjs",
|
|
@@ -18,14 +18,22 @@
|
|
|
18
18
|
"type": "module",
|
|
19
19
|
"main": "./y-mxgraph.cjs.js",
|
|
20
20
|
"module": "./y-mxgraph.es.js",
|
|
21
|
-
"browser": "./y-mxgraph.umd.js",
|
|
22
21
|
"types": "./index.d.ts",
|
|
23
22
|
"exports": {
|
|
24
23
|
".": {
|
|
25
24
|
"import": "./y-mxgraph.es.js",
|
|
26
25
|
"require": "./y-mxgraph.cjs.js",
|
|
27
|
-
"browser": "./y-mxgraph.umd.js",
|
|
28
26
|
"types": "./index.d.ts"
|
|
27
|
+
},
|
|
28
|
+
"./iframe-bridge/server": {
|
|
29
|
+
"import": "./iframe-bridge/server.es.js",
|
|
30
|
+
"require": "./iframe-bridge/server.cjs.js",
|
|
31
|
+
"types": "./iframe-bridge/server.d.ts"
|
|
32
|
+
},
|
|
33
|
+
"./iframe-bridge/provider": {
|
|
34
|
+
"import": "./iframe-bridge/provider.es.js",
|
|
35
|
+
"require": "./iframe-bridge/provider.cjs.js",
|
|
36
|
+
"types": "./iframe-bridge/provider.d.ts"
|
|
29
37
|
}
|
|
30
38
|
},
|
|
31
39
|
"dependencies": {
|