@graffiti-garden/wrapper-vue 0.7.0 → 0.7.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/dist/browser/plugin.mjs +151 -149
- package/dist/browser/plugin.mjs.map +1 -1
- package/dist/node/composables.d.ts.map +1 -1
- package/dist/node/globals.d.ts +5 -3
- package/dist/node/globals.d.ts.map +1 -1
- package/dist/node/plugin.d.ts.map +1 -1
- package/dist/node/plugin.js +1 -1
- package/dist/node/plugin.js.map +1 -1
- package/dist/node/plugin.mjs +123 -121
- package/dist/node/plugin.mjs.map +1 -1
- package/package.json +3 -3
- package/src/composables.ts +4 -0
- package/src/globals.ts +7 -8
- package/src/plugin.ts +3 -3
- package/src/pollers.ts +1 -1
package/dist/node/plugin.mjs
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import {
|
|
5
|
-
import { GraffitiSynchronize as
|
|
6
|
-
const
|
|
7
|
-
function
|
|
8
|
-
const e =
|
|
1
|
+
var M = Object.defineProperty;
|
|
2
|
+
var B = (e, t, r) => t in e ? M(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
+
var m = (e, t, r) => B(e, typeof t != "symbol" ? t + "" : t, r);
|
|
4
|
+
import { ref as G, computed as L, watch as k, onScopeDispose as A, toValue as d, defineComponent as S, toRef as u, renderSlot as R, unref as g } from "vue";
|
|
5
|
+
import { GraffitiSynchronize as C } from "@graffiti-garden/wrapper-synchronize";
|
|
6
|
+
const b = {};
|
|
7
|
+
function w() {
|
|
8
|
+
const e = b.graffitiSynchronize;
|
|
9
9
|
if (!e)
|
|
10
10
|
throw new Error(
|
|
11
11
|
"No Graffiti instance provided, did you forget to install the plugin?"
|
|
12
12
|
);
|
|
13
13
|
return e;
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
return
|
|
15
|
+
function X() {
|
|
16
|
+
return w();
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
const e =
|
|
18
|
+
function F() {
|
|
19
|
+
const e = b.graffitiSession;
|
|
20
20
|
if (!e)
|
|
21
21
|
throw new Error(
|
|
22
22
|
"No Graffiti session provided, did you forget to install the plugin?"
|
|
23
23
|
);
|
|
24
24
|
return e;
|
|
25
25
|
}
|
|
26
|
-
var
|
|
26
|
+
var J = class _ extends Error {
|
|
27
27
|
constructor(t) {
|
|
28
|
-
super(t), this.name = "GraffitiErrorNotFound", Object.setPrototypeOf(this,
|
|
28
|
+
super(t), this.name = "GraffitiErrorNotFound", Object.setPrototypeOf(this, _.prototype);
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
|
-
class
|
|
31
|
+
class U {
|
|
32
32
|
constructor(t) {
|
|
33
|
-
|
|
33
|
+
m(this, "poll", async (t) => {
|
|
34
34
|
let r;
|
|
35
35
|
const o = this.getter;
|
|
36
36
|
try {
|
|
@@ -46,17 +46,17 @@ class V {
|
|
|
46
46
|
clear() {
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
class
|
|
49
|
+
class O {
|
|
50
50
|
constructor(t) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
m(this, "iterator");
|
|
52
|
+
m(this, "continue");
|
|
53
|
+
m(this, "poll", async (t) => {
|
|
54
54
|
if (!this.iterator)
|
|
55
55
|
if (this.continue)
|
|
56
56
|
try {
|
|
57
57
|
this.iterator = this.continue();
|
|
58
58
|
} catch (r) {
|
|
59
|
-
if (r instanceof
|
|
59
|
+
if (r instanceof J)
|
|
60
60
|
t("clear"), this.iterator = this.streamFactory();
|
|
61
61
|
else
|
|
62
62
|
throw r;
|
|
@@ -67,7 +67,7 @@ class T {
|
|
|
67
67
|
const r = this.iterator, o = await r.next();
|
|
68
68
|
if (r === this.iterator) {
|
|
69
69
|
if (o.done) {
|
|
70
|
-
|
|
70
|
+
this.iterator = void 0, o.value && (this.continue = o.value.continue);
|
|
71
71
|
break;
|
|
72
72
|
}
|
|
73
73
|
if (o.value.error) {
|
|
@@ -91,15 +91,15 @@ class T {
|
|
|
91
91
|
this.iterator = void 0, this.continue = void 0;
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
|
-
function
|
|
94
|
+
function z(e, t) {
|
|
95
95
|
return !t || e.object.lastModified > t.object.lastModified || e.object.lastModified === t.object.lastModified && !e.tombstone && !!t.tombstone;
|
|
96
96
|
}
|
|
97
|
-
class
|
|
97
|
+
class V {
|
|
98
98
|
constructor() {
|
|
99
|
-
|
|
99
|
+
m(this, "entry", G());
|
|
100
100
|
}
|
|
101
101
|
get result() {
|
|
102
|
-
return
|
|
102
|
+
return L(() => {
|
|
103
103
|
const t = this.entry.value;
|
|
104
104
|
return t && (t.tombstone ? null : t.object);
|
|
105
105
|
});
|
|
@@ -112,14 +112,14 @@ class x {
|
|
|
112
112
|
this.clear();
|
|
113
113
|
return;
|
|
114
114
|
}
|
|
115
|
-
(!t ||
|
|
115
|
+
(!t || z(t, this.entry.value)) && (this.entry.value = t);
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
|
-
class
|
|
118
|
+
class T {
|
|
119
119
|
constructor(t) {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
120
|
+
m(this, "results", G([]));
|
|
121
|
+
m(this, "resultsRaw", /* @__PURE__ */ new Map());
|
|
122
|
+
m(this, "batchFlattenTimer");
|
|
123
123
|
this.graffiti = t;
|
|
124
124
|
}
|
|
125
125
|
clear() {
|
|
@@ -135,12 +135,12 @@ class z {
|
|
|
135
135
|
return;
|
|
136
136
|
}
|
|
137
137
|
const r = this.resultsRaw.get(t.object.url);
|
|
138
|
-
|
|
138
|
+
z(t, r) && (this.resultsRaw.set(t.object.url, t), this.batchFlattenTimer || (this.batchFlattenTimer = setTimeout(() => {
|
|
139
139
|
this.flattenResults(), this.batchFlattenTimer = void 0;
|
|
140
140
|
}, 0)));
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
|
-
function
|
|
143
|
+
function E(e, t, r, o, n) {
|
|
144
144
|
let i;
|
|
145
145
|
async function s() {
|
|
146
146
|
i = r();
|
|
@@ -152,55 +152,57 @@ function S(e, t, r, o, n) {
|
|
|
152
152
|
e.onEntry(c);
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
|
-
let
|
|
156
|
-
const
|
|
157
|
-
if (
|
|
158
|
-
const c =
|
|
159
|
-
|
|
155
|
+
let f = !1, l;
|
|
156
|
+
const a = async () => {
|
|
157
|
+
if (f || !l) return;
|
|
158
|
+
const c = l;
|
|
159
|
+
f = !0;
|
|
160
160
|
try {
|
|
161
161
|
await c();
|
|
162
|
+
} catch {
|
|
163
|
+
await new Promise((v) => setTimeout(v, 2e3));
|
|
162
164
|
} finally {
|
|
163
|
-
if (c !==
|
|
164
|
-
|
|
165
|
+
if (c !== l) return;
|
|
166
|
+
f = !1, d(n) && a();
|
|
165
167
|
}
|
|
166
|
-
}, h =
|
|
167
|
-
return
|
|
168
|
+
}, h = G(!1);
|
|
169
|
+
return k(
|
|
168
170
|
o,
|
|
169
|
-
async (c,
|
|
170
|
-
if (JSON.stringify(c) === JSON.stringify(
|
|
171
|
+
async (c, p) => {
|
|
172
|
+
if (JSON.stringify(c) === JSON.stringify(p))
|
|
171
173
|
return;
|
|
172
|
-
i == null || i.return(null), e.clear(), t.clear(), s(),
|
|
173
|
-
const
|
|
174
|
-
|
|
174
|
+
i == null || i.return(null), e.clear(), t.clear(), s(), l = () => t.poll(e.onEntry.bind(e));
|
|
175
|
+
const v = l;
|
|
176
|
+
f = !1, h.value = !0;
|
|
175
177
|
try {
|
|
176
|
-
await
|
|
178
|
+
await a();
|
|
177
179
|
} finally {
|
|
178
|
-
if (
|
|
180
|
+
if (v !== l) return;
|
|
179
181
|
h.value = !1;
|
|
180
182
|
}
|
|
181
183
|
},
|
|
182
184
|
{
|
|
183
185
|
immediate: !0
|
|
184
186
|
}
|
|
185
|
-
),
|
|
186
|
-
i == null || i.return(null), e.clear(), t.clear(),
|
|
187
|
-
}), { poll:
|
|
187
|
+
), A(() => {
|
|
188
|
+
i == null || i.return(null), e.clear(), t.clear(), l = void 0;
|
|
189
|
+
}), { poll: a, isInitialPolling: h };
|
|
188
190
|
}
|
|
189
|
-
function
|
|
191
|
+
function $(e, t) {
|
|
190
192
|
return () => {
|
|
191
193
|
const r = d(t);
|
|
192
194
|
return r === void 0 ? e == null ? void 0 : e.value : r;
|
|
193
195
|
};
|
|
194
196
|
}
|
|
195
|
-
function
|
|
197
|
+
function y(e) {
|
|
196
198
|
return e.map((t) => t());
|
|
197
199
|
}
|
|
198
|
-
function
|
|
199
|
-
const n =
|
|
200
|
-
|
|
201
|
-
|
|
200
|
+
function x(e, t, r, o = !1) {
|
|
201
|
+
const n = w(), i = F(), s = () => d(e), f = () => d(t), l = $(i, r), a = [s, f, l], h = () => n.synchronizeDiscover(...y(a)), c = () => n.discover(...y(a)), p = new T(n), v = new O(c), { poll: P, isInitialPolling: j } = E(
|
|
202
|
+
p,
|
|
203
|
+
v,
|
|
202
204
|
h,
|
|
203
|
-
|
|
205
|
+
a,
|
|
204
206
|
o
|
|
205
207
|
);
|
|
206
208
|
return {
|
|
@@ -208,11 +210,11 @@ function W(e, t, r, o = !1) {
|
|
|
208
210
|
* A [ref](https://vuejs.org/api/reactivity-core.html#ref) that contains
|
|
209
211
|
* an array of Graffiti objects.
|
|
210
212
|
*/
|
|
211
|
-
objects:
|
|
213
|
+
objects: p.results,
|
|
212
214
|
/**
|
|
213
215
|
* A method to poll for new results.
|
|
214
216
|
*/
|
|
215
|
-
poll:
|
|
217
|
+
poll: P,
|
|
216
218
|
/**
|
|
217
219
|
* A boolean [ref](https://vuejs.org/api/reactivity-core.html#ref)
|
|
218
220
|
* that indicates if the *first* poll is currently running.
|
|
@@ -222,19 +224,19 @@ function W(e, t, r, o = !1) {
|
|
|
222
224
|
* but it does not track ongoing polls from either calling
|
|
223
225
|
* {@link poll} or using the `autopoll` argument.
|
|
224
226
|
*/
|
|
225
|
-
isInitialPolling:
|
|
227
|
+
isInitialPolling: j
|
|
226
228
|
};
|
|
227
229
|
}
|
|
228
|
-
function
|
|
229
|
-
const n =
|
|
230
|
+
function W(e, t, r, o = !1) {
|
|
231
|
+
const n = w(), i = F(), s = () => d(e), f = () => d(t), l = $(i, r), a = [
|
|
230
232
|
s,
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
], h = () => n.synchronizeGet(...
|
|
233
|
+
f,
|
|
234
|
+
l
|
|
235
|
+
], h = () => n.synchronizeGet(...y(a)), c = new V(), p = () => n.get(...y(a)), v = new U(p), { poll: P, isInitialPolling: j } = E(
|
|
234
236
|
c,
|
|
235
|
-
|
|
237
|
+
v,
|
|
236
238
|
h,
|
|
237
|
-
|
|
239
|
+
a,
|
|
238
240
|
o
|
|
239
241
|
);
|
|
240
242
|
return {
|
|
@@ -247,7 +249,7 @@ function q(e, t, r, o = !1) {
|
|
|
247
249
|
/**
|
|
248
250
|
* A method to poll for new results.
|
|
249
251
|
*/
|
|
250
|
-
poll:
|
|
252
|
+
poll: P,
|
|
251
253
|
/**
|
|
252
254
|
* A boolean [ref](https://vuejs.org/api/reactivity-core.html#ref)
|
|
253
255
|
* that indicates if the *first* poll is currently running.
|
|
@@ -257,14 +259,14 @@ function q(e, t, r, o = !1) {
|
|
|
257
259
|
* but it does not track ongoing polls from either calling
|
|
258
260
|
* {@link poll} or using the `autopoll` argument.
|
|
259
261
|
*/
|
|
260
|
-
isInitialPolling:
|
|
262
|
+
isInitialPolling: j
|
|
261
263
|
};
|
|
262
264
|
}
|
|
263
|
-
function
|
|
264
|
-
const o =
|
|
265
|
-
|
|
265
|
+
function q(e, t, r = !1) {
|
|
266
|
+
const o = w(), s = [() => d(e), () => d(t)], f = () => o.synchronizeRecoverOrphans(...y(s)), l = new T(o), a = () => o.recoverOrphans(...y(s)), h = new O(a), { poll: c, isInitialPolling: p } = E(
|
|
267
|
+
l,
|
|
266
268
|
h,
|
|
267
|
-
|
|
269
|
+
f,
|
|
268
270
|
s,
|
|
269
271
|
r
|
|
270
272
|
);
|
|
@@ -273,7 +275,7 @@ function H(e, t, r = !1) {
|
|
|
273
275
|
* A [ref](https://vuejs.org/api/reactivity-core.html#ref) that contains
|
|
274
276
|
* an array of Graffiti objects.
|
|
275
277
|
*/
|
|
276
|
-
objects:
|
|
278
|
+
objects: l.results,
|
|
277
279
|
/**
|
|
278
280
|
* A method to poll for new results.
|
|
279
281
|
*/
|
|
@@ -287,10 +289,10 @@ function H(e, t, r = !1) {
|
|
|
287
289
|
* but it does not track ongoing polls from either calling
|
|
288
290
|
* {@link poll} or using the `autopoll` argument.
|
|
289
291
|
*/
|
|
290
|
-
isInitialPolling:
|
|
292
|
+
isInitialPolling: p
|
|
291
293
|
};
|
|
292
294
|
}
|
|
293
|
-
const
|
|
295
|
+
const D = /* @__PURE__ */ S({
|
|
294
296
|
__name: "Discover",
|
|
295
297
|
props: {
|
|
296
298
|
channels: {},
|
|
@@ -299,19 +301,19 @@ const N = /* @__PURE__ */ j({
|
|
|
299
301
|
autopoll: { type: Boolean }
|
|
300
302
|
},
|
|
301
303
|
setup(e) {
|
|
302
|
-
const t = e, { objects: r, poll: o, isInitialPolling: n } =
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
304
|
+
const t = e, { objects: r, poll: o, isInitialPolling: n } = x(
|
|
305
|
+
u(t, "channels"),
|
|
306
|
+
u(t, "schema"),
|
|
307
|
+
u(t, "session"),
|
|
308
|
+
u(t, "autopoll")
|
|
307
309
|
);
|
|
308
310
|
return (i, s) => R(i.$slots, "default", {
|
|
309
|
-
objects:
|
|
310
|
-
poll:
|
|
311
|
-
isInitialPolling:
|
|
311
|
+
objects: g(r),
|
|
312
|
+
poll: g(o),
|
|
313
|
+
isInitialPolling: g(n)
|
|
312
314
|
});
|
|
313
315
|
}
|
|
314
|
-
}),
|
|
316
|
+
}), I = /* @__PURE__ */ S({
|
|
315
317
|
__name: "Get",
|
|
316
318
|
props: {
|
|
317
319
|
url: {},
|
|
@@ -320,19 +322,19 @@ const N = /* @__PURE__ */ j({
|
|
|
320
322
|
autopoll: { type: Boolean }
|
|
321
323
|
},
|
|
322
324
|
setup(e) {
|
|
323
|
-
const t = e, { object: r, poll: o, isInitialPolling: n } =
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
325
|
+
const t = e, { object: r, poll: o, isInitialPolling: n } = W(
|
|
326
|
+
u(t, "url"),
|
|
327
|
+
u(t, "schema"),
|
|
328
|
+
u(t, "session"),
|
|
329
|
+
u(t, "autopoll")
|
|
328
330
|
);
|
|
329
331
|
return (i, s) => R(i.$slots, "default", {
|
|
330
|
-
object:
|
|
331
|
-
poll:
|
|
332
|
-
isInitialPolling:
|
|
332
|
+
object: g(r),
|
|
333
|
+
poll: g(o),
|
|
334
|
+
isInitialPolling: g(n)
|
|
333
335
|
});
|
|
334
336
|
}
|
|
335
|
-
}),
|
|
337
|
+
}), N = /* @__PURE__ */ S({
|
|
336
338
|
__name: "RecoverOrphans",
|
|
337
339
|
props: {
|
|
338
340
|
schema: {},
|
|
@@ -340,27 +342,27 @@ const N = /* @__PURE__ */ j({
|
|
|
340
342
|
autopoll: { type: Boolean }
|
|
341
343
|
},
|
|
342
344
|
setup(e) {
|
|
343
|
-
const t = e, { objects: r, poll: o, isInitialPolling: n } =
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
345
|
+
const t = e, { objects: r, poll: o, isInitialPolling: n } = q(
|
|
346
|
+
u(t, "schema"),
|
|
347
|
+
u(t, "session"),
|
|
348
|
+
u(t, "autopoll")
|
|
347
349
|
);
|
|
348
350
|
return (i, s) => R(i.$slots, "default", {
|
|
349
|
-
objects:
|
|
350
|
-
poll:
|
|
351
|
-
isInitialPolling:
|
|
351
|
+
objects: g(r),
|
|
352
|
+
poll: g(o),
|
|
353
|
+
isInitialPolling: g(n)
|
|
352
354
|
});
|
|
353
355
|
}
|
|
354
|
-
}),
|
|
356
|
+
}), Y = {
|
|
355
357
|
install(e, t) {
|
|
356
|
-
const r = t.graffiti, o = new
|
|
358
|
+
const r = t.graffiti, o = new C(r), n = G(void 0);
|
|
357
359
|
o.sessionEvents.addEventListener("initialized", async (i) => {
|
|
358
360
|
const s = i.detail;
|
|
359
361
|
if (s && s.error && console.error(s.error), s && s.href) {
|
|
360
|
-
const
|
|
361
|
-
if (
|
|
362
|
-
const
|
|
363
|
-
|
|
362
|
+
const f = e.config.globalProperties.$router;
|
|
363
|
+
if (f) {
|
|
364
|
+
const l = f.options.history.base, a = new URL(s.href);
|
|
365
|
+
a.pathname.startsWith(l) && (a.pathname = a.pathname.slice(l.length)), await f.replace(a.pathname + a.search + a.hash);
|
|
364
366
|
}
|
|
365
367
|
}
|
|
366
368
|
n.value || (n.value = null);
|
|
@@ -374,19 +376,19 @@ const N = /* @__PURE__ */ j({
|
|
|
374
376
|
}), o.sessionEvents.addEventListener("logout", (i) => {
|
|
375
377
|
const s = i.detail;
|
|
376
378
|
s.error ? (console.error("Error logging out:"), console.error(s.error)) : n.value = null;
|
|
377
|
-
}),
|
|
379
|
+
}), b.graffitiSynchronize = o, b.graffitiSession = n, e.component("GraffitiDiscover", D), e.component("GraffitiGet", I), e.component("GraffitiRecoverOrphans", N), e.config.globalProperties.$graffiti = o, e.config.globalProperties.$graffitiSession = n;
|
|
378
380
|
}
|
|
379
|
-
},
|
|
381
|
+
}, Z = D, tt = I, et = N;
|
|
380
382
|
export {
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
383
|
+
Z as GraffitiDiscover,
|
|
384
|
+
tt as GraffitiGet,
|
|
385
|
+
Y as GraffitiPlugin,
|
|
386
|
+
et as GraffitiRecoverOrphans,
|
|
387
|
+
X as useGraffiti,
|
|
388
|
+
x as useGraffitiDiscover,
|
|
389
|
+
W as useGraffitiGet,
|
|
390
|
+
q as useGraffitiRecoverOrphans,
|
|
391
|
+
F as useGraffitiSession,
|
|
392
|
+
w as useGraffitiSynchronize
|
|
391
393
|
};
|
|
392
394
|
//# sourceMappingURL=plugin.mjs.map
|