pptx-svelte-viewer 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +83 -0
- package/README.md +57 -35
- package/dist/awareness-CkFlr7xx.js +166 -0
- package/dist/{component-DxQFSCeR.js → component-Bvs5zPMN.js} +17484 -14089
- package/dist/index.d.ts +304 -1
- package/dist/index.js +14 -11
- package/dist/viewer/index.d.ts +248 -1
- package/dist/viewer/index.js +1 -1
- package/dist/y-webrtc-BdH40MC6.js +3388 -0
- package/dist/y-websocket-C6aE1Dkp.js +115 -0
- package/dist/yjs-CE9F053g.js +3473 -0
- package/package.json +9 -3
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { a as V, c as W, d as L, i as H, l as w, n as $, o as _, r as f, s as E, t as N, u as O } from "./awareness-CkFlr7xx.js";
|
|
2
|
+
import { A as m, C as i, F as S, R as Q, S as p, T as c, V as j, _ as z, b as F, d as U, k as a, p as q, w as T, x as k, z as G } from "./yjs-CE9F053g.js";
|
|
3
|
+
var J = (s, t, e) => {
|
|
4
|
+
k(s) === 0 && e(t, F(s));
|
|
5
|
+
}, K = (s) => q(s, (t, e) => `${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join("&");
|
|
6
|
+
var y = [];
|
|
7
|
+
y[0] = (s, t, e, n, o) => {
|
|
8
|
+
a(s, 0);
|
|
9
|
+
const d = V(t, s, e.doc, e);
|
|
10
|
+
n && d === 1 && !e.synced && (e.synced = !0);
|
|
11
|
+
};
|
|
12
|
+
y[3] = (s, t, e, n, o) => {
|
|
13
|
+
a(s, 1), m(s, f(e.awareness, Array.from(e.awareness.getStates().keys())));
|
|
14
|
+
};
|
|
15
|
+
y[1] = (s, t, e, n, o) => {
|
|
16
|
+
$(e.awareness, p(t), e);
|
|
17
|
+
};
|
|
18
|
+
y[2] = (s, t, e, n, o) => {
|
|
19
|
+
J(t, e.doc, (d, r) => X(e, r));
|
|
20
|
+
};
|
|
21
|
+
var I = 3e4, X = (s, t) => console.warn(`Permission denied to access ${s.url}.
|
|
22
|
+
${t}`), R = (s, t, e) => {
|
|
23
|
+
const n = z(t), o = i(), d = k(n), r = s.messageHandlers[d];
|
|
24
|
+
return r ? r(o, n, s, e, d) : console.error("Unable to compute message"), o;
|
|
25
|
+
}, A = (s, t, e) => {
|
|
26
|
+
t === s.ws && (s.emit("connection-close", [e, s]), s.ws = null, t.close(), s.wsconnecting = !1, s.wsconnected ? (s.wsconnected = !1, s.synced = !1, H(s.awareness, Array.from(s.awareness.getStates().keys()).filter((n) => n !== s.doc.clientID), s), s.emit("status", [{ status: "disconnected" }])) : s.wsUnsuccessfulReconnects++, setTimeout(x, Q(G(2, s.wsUnsuccessfulReconnects) * 100, s.maxBackoffTime), s));
|
|
27
|
+
}, x = (s) => {
|
|
28
|
+
if (s.shouldConnect && s.ws === null) {
|
|
29
|
+
const t = new s._WS(s.url, s.protocols);
|
|
30
|
+
t.binaryType = "arraybuffer", s.ws = t, s.wsconnecting = !0, s.wsconnected = !1, s.synced = !1, t.onmessage = (e) => {
|
|
31
|
+
s.wsLastMessageReceived = S();
|
|
32
|
+
const n = R(s, new Uint8Array(e.data), !0);
|
|
33
|
+
T(n) > 1 && t.send(c(n));
|
|
34
|
+
}, t.onerror = (e) => {
|
|
35
|
+
s.emit("connection-error", [e, s]);
|
|
36
|
+
}, t.onclose = (e) => {
|
|
37
|
+
A(s, t, e);
|
|
38
|
+
}, t.onopen = () => {
|
|
39
|
+
s.wsLastMessageReceived = S(), s.wsconnecting = !1, s.wsconnected = !0, s.wsUnsuccessfulReconnects = 0, s.emit("status", [{ status: "connected" }]);
|
|
40
|
+
const e = i();
|
|
41
|
+
if (a(e, 0), _(e, s.doc), t.send(c(e)), s.awareness.getLocalState() !== null) {
|
|
42
|
+
const n = i();
|
|
43
|
+
a(n, 1), m(n, f(s.awareness, [s.doc.clientID])), t.send(c(n));
|
|
44
|
+
}
|
|
45
|
+
}, s.emit("status", [{ status: "connecting" }]);
|
|
46
|
+
}
|
|
47
|
+
}, b = (s, t) => {
|
|
48
|
+
const e = s.ws;
|
|
49
|
+
s.wsconnected && e && e.readyState === e.OPEN && e.send(t), s.bcconnected && w(s.bcChannel, t, s);
|
|
50
|
+
}, ss = class extends j {
|
|
51
|
+
constructor(s, t, e, { connect: n = !0, awareness: o = new N(e), params: d = {}, protocols: r = [], WebSocketPolyfill: M = WebSocket, resyncInterval: C = -1, maxBackoffTime: B = 2500, disableBc: D = !1 } = {}) {
|
|
52
|
+
for (super(); s[s.length - 1] === "/"; ) s = s.slice(0, s.length - 1);
|
|
53
|
+
this.serverUrl = s, this.bcChannel = s + "/" + t, this.maxBackoffTime = B, this.params = d, this.protocols = r, this.roomname = t, this.doc = e, this._WS = M, this.awareness = o, this.wsconnected = !1, this.wsconnecting = !1, this.bcconnected = !1, this.disableBc = D, this.wsUnsuccessfulReconnects = 0, this.messageHandlers = y.slice(), this._synced = !1, this.ws = null, this.wsLastMessageReceived = 0, this.shouldConnect = n, this._resyncInterval = 0, C > 0 && (this._resyncInterval = setInterval(() => {
|
|
54
|
+
if (this.ws && this.ws.readyState === WebSocket.OPEN) {
|
|
55
|
+
const h = i();
|
|
56
|
+
a(h, 0), _(h, e), this.ws.send(c(h));
|
|
57
|
+
}
|
|
58
|
+
}, C)), this._bcSubscriber = (h, u) => {
|
|
59
|
+
if (u !== this) {
|
|
60
|
+
const l = R(this, new Uint8Array(h), !1);
|
|
61
|
+
T(l) > 1 && w(this.bcChannel, c(l), this);
|
|
62
|
+
}
|
|
63
|
+
}, this._updateHandler = (h, u) => {
|
|
64
|
+
if (u !== this) {
|
|
65
|
+
const l = i();
|
|
66
|
+
a(l, 0), W(l, h), b(this, c(l));
|
|
67
|
+
}
|
|
68
|
+
}, this.doc.on("update", this._updateHandler), this._awarenessUpdateHandler = ({ added: h, updated: u, removed: l }, Y) => {
|
|
69
|
+
const P = h.concat(u).concat(l), g = i();
|
|
70
|
+
a(g, 1), m(g, f(o, P)), b(this, c(g));
|
|
71
|
+
}, this._exitHandler = () => {
|
|
72
|
+
H(this.awareness, [e.clientID], "app closed");
|
|
73
|
+
}, U && typeof process < "u" && process.on("exit", this._exitHandler), o.on("update", this._awarenessUpdateHandler), this._checkInterval = setInterval(() => {
|
|
74
|
+
this.wsconnected && I < S() - this.wsLastMessageReceived && A(this, this.ws, null);
|
|
75
|
+
}, I / 10), n && this.connect();
|
|
76
|
+
}
|
|
77
|
+
get url() {
|
|
78
|
+
const s = K(this.params);
|
|
79
|
+
return this.serverUrl + "/" + this.roomname + (s.length === 0 ? "" : "?" + s);
|
|
80
|
+
}
|
|
81
|
+
get synced() {
|
|
82
|
+
return this._synced;
|
|
83
|
+
}
|
|
84
|
+
set synced(s) {
|
|
85
|
+
this._synced !== s && (this._synced = s, this.emit("synced", [s]), this.emit("sync", [s]));
|
|
86
|
+
}
|
|
87
|
+
destroy() {
|
|
88
|
+
this._resyncInterval !== 0 && clearInterval(this._resyncInterval), clearInterval(this._checkInterval), this.disconnect(), U && typeof process < "u" && process.off("exit", this._exitHandler), this.awareness.off("update", this._awarenessUpdateHandler), this.doc.off("update", this._updateHandler), super.destroy();
|
|
89
|
+
}
|
|
90
|
+
connectBc() {
|
|
91
|
+
if (this.disableBc) return;
|
|
92
|
+
this.bcconnected || (O(this.bcChannel, this._bcSubscriber), this.bcconnected = !0);
|
|
93
|
+
const s = i();
|
|
94
|
+
a(s, 0), _(s, this.doc), w(this.bcChannel, c(s), this);
|
|
95
|
+
const t = i();
|
|
96
|
+
a(t, 0), E(t, this.doc), w(this.bcChannel, c(t), this);
|
|
97
|
+
const e = i();
|
|
98
|
+
a(e, 3), w(this.bcChannel, c(e), this);
|
|
99
|
+
const n = i();
|
|
100
|
+
a(n, 1), m(n, f(this.awareness, [this.doc.clientID])), w(this.bcChannel, c(n), this);
|
|
101
|
+
}
|
|
102
|
+
disconnectBc() {
|
|
103
|
+
const s = i();
|
|
104
|
+
a(s, 1), m(s, f(this.awareness, [this.doc.clientID], /* @__PURE__ */ new Map())), b(this, c(s)), this.bcconnected && (L(this.bcChannel, this._bcSubscriber), this.bcconnected = !1);
|
|
105
|
+
}
|
|
106
|
+
disconnect() {
|
|
107
|
+
this.shouldConnect = !1, this.disconnectBc(), this.ws !== null && A(this, this.ws, null);
|
|
108
|
+
}
|
|
109
|
+
connect() {
|
|
110
|
+
this.shouldConnect = !0, !this.wsconnected && this.ws === null && (x(this), this.connectBc());
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
export {
|
|
114
|
+
ss as WebsocketProvider
|
|
115
|
+
};
|