@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.
@@ -1,36 +1,36 @@
1
- var L = Object.defineProperty;
2
- var k = (e, t, r) => t in e ? L(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var p = (e, t, r) => k(e, typeof t != "symbol" ? t + "" : t, r);
4
- import { inject as E, ref as b, computed as A, watch as C, onScopeDispose as J, toValue as d, defineComponent as j, toRef as f, renderSlot as R, unref as m } from "vue";
5
- import { GraffitiSynchronize as K } from "@graffiti-garden/wrapper-synchronize";
6
- const F = Symbol(), _ = Symbol();
7
- function G() {
8
- const e = E(F);
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 Z() {
16
- return G();
15
+ function X() {
16
+ return w();
17
17
  }
18
- function O() {
19
- const e = 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 U = class I extends Error {
26
+ var J = class _ extends Error {
27
27
  constructor(t) {
28
- super(t), this.name = "GraffitiErrorNotFound", Object.setPrototypeOf(this, I.prototype);
28
+ super(t), this.name = "GraffitiErrorNotFound", Object.setPrototypeOf(this, _.prototype);
29
29
  }
30
30
  };
31
- class V {
31
+ class U {
32
32
  constructor(t) {
33
- p(this, "poll", async (t) => {
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 T {
49
+ class O {
50
50
  constructor(t) {
51
- p(this, "iterator");
52
- p(this, "continue");
53
- p(this, "poll", async (t) => {
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 U)
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
- o.value && (this.iterator = void 0, this.continue = o.value.continue);
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 $(e, t) {
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 x {
97
+ class V {
98
98
  constructor() {
99
- p(this, "entry", b());
99
+ m(this, "entry", G());
100
100
  }
101
101
  get result() {
102
- return A(() => {
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 || $(t, this.entry.value)) && (this.entry.value = t);
115
+ (!t || z(t, this.entry.value)) && (this.entry.value = t);
116
116
  }
117
117
  }
118
- class z {
118
+ class T {
119
119
  constructor(t) {
120
- p(this, "results", b([]));
121
- p(this, "resultsRaw", /* @__PURE__ */ new Map());
122
- p(this, "batchFlattenTimer");
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
- $(t, r) && (this.resultsRaw.set(t.object.url, t), this.batchFlattenTimer || (this.batchFlattenTimer = setTimeout(() => {
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 S(e, t, r, o, n) {
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 u = !1, a;
156
- const l = async () => {
157
- if (u || !a) return;
158
- const c = a;
159
- u = !0;
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 !== a) return;
164
- u = !1, d(n) && l();
165
+ if (c !== l) return;
166
+ f = !1, d(n) && a();
165
167
  }
166
- }, h = b(!1);
167
- return C(
168
+ }, h = G(!1);
169
+ return k(
168
170
  o,
169
- async (c, g) => {
170
- if (JSON.stringify(c) === JSON.stringify(g))
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(), a = () => t.poll(e.onEntry.bind(e));
173
- const y = a;
174
- u = !1, h.value = !0;
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 l();
178
+ await a();
177
179
  } finally {
178
- if (y !== a) return;
180
+ if (v !== l) return;
179
181
  h.value = !1;
180
182
  }
181
183
  },
182
184
  {
183
185
  immediate: !0
184
186
  }
185
- ), J(() => {
186
- i == null || i.return(null), e.clear(), t.clear(), a = void 0;
187
- }), { poll: l, isInitialPolling: h };
187
+ ), A(() => {
188
+ i == null || i.return(null), e.clear(), t.clear(), l = void 0;
189
+ }), { poll: a, isInitialPolling: h };
188
190
  }
189
- function D(e, t) {
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 v(e) {
197
+ function y(e) {
196
198
  return e.map((t) => t());
197
199
  }
198
- function W(e, t, r, o = !1) {
199
- const n = G(), i = O(), s = () => d(e), u = () => d(t), a = D(i, r), l = [s, u, a], h = () => n.synchronizeDiscover(...v(l)), c = () => n.discover(...v(l)), g = new z(n), y = new T(c), { poll: w, isInitialPolling: P } = S(
200
- g,
201
- y,
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
- l,
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: g.results,
213
+ objects: p.results,
212
214
  /**
213
215
  * A method to poll for new results.
214
216
  */
215
- poll: w,
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: P
227
+ isInitialPolling: j
226
228
  };
227
229
  }
228
- function q(e, t, r, o = !1) {
229
- const n = G(), i = O(), s = () => d(e), u = () => d(t), a = D(i, r), l = [
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
- u,
232
- a
233
- ], h = () => n.synchronizeGet(...v(l)), c = new x(), g = () => n.get(...v(l)), y = new V(g), { poll: w, isInitialPolling: P } = S(
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
- y,
237
+ v,
236
238
  h,
237
- l,
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: w,
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: P
262
+ isInitialPolling: j
261
263
  };
262
264
  }
263
- function H(e, t, r = !1) {
264
- const o = G(), s = [() => d(e), () => d(t)], u = () => o.synchronizeRecoverOrphans(...v(s)), a = new z(o), l = () => o.recoverOrphans(...v(s)), h = new T(l), { poll: c, isInitialPolling: g } = S(
265
- a,
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
- u,
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: a.results,
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: g
292
+ isInitialPolling: p
291
293
  };
292
294
  }
293
- const N = /* @__PURE__ */ j({
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 } = W(
303
- f(t, "channels"),
304
- f(t, "schema"),
305
- f(t, "session"),
306
- f(t, "autopoll")
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: m(r),
310
- poll: m(o),
311
- isInitialPolling: m(n)
311
+ objects: g(r),
312
+ poll: g(o),
313
+ isInitialPolling: g(n)
312
314
  });
313
315
  }
314
- }), M = /* @__PURE__ */ j({
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 } = q(
324
- f(t, "url"),
325
- f(t, "schema"),
326
- f(t, "session"),
327
- f(t, "autopoll")
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: m(r),
331
- poll: m(o),
332
- isInitialPolling: m(n)
332
+ object: g(r),
333
+ poll: g(o),
334
+ isInitialPolling: g(n)
333
335
  });
334
336
  }
335
- }), B = /* @__PURE__ */ j({
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 } = H(
344
- f(t, "schema"),
345
- f(t, "session"),
346
- f(t, "autopoll")
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: m(r),
350
- poll: m(o),
351
- isInitialPolling: m(n)
351
+ objects: g(r),
352
+ poll: g(o),
353
+ isInitialPolling: g(n)
352
354
  });
353
355
  }
354
- }), tt = {
356
+ }), Y = {
355
357
  install(e, t) {
356
- const r = t.graffiti, o = new K(r), n = b(void 0);
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 u = e.config.globalProperties.$router;
361
- if (u) {
362
- const a = u.options.history.base, l = new URL(s.href);
363
- l.pathname.startsWith(a) && (l.pathname = l.pathname.slice(a.length)), await u.replace(l.pathname + l.search + l.hash);
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
- }), e.provide(F, o), e.provide(_, n), e.component("GraffitiDiscover", N), e.component("GraffitiGet", M), e.component("GraffitiRecoverOrphans", B), e.config.globalProperties.$graffiti = o, e.config.globalProperties.$graffitiSession = n;
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
- }, et = N, rt = M, ot = B;
381
+ }, Z = D, tt = I, et = N;
380
382
  export {
381
- et as GraffitiDiscover,
382
- rt as GraffitiGet,
383
- tt as GraffitiPlugin,
384
- ot as GraffitiRecoverOrphans,
385
- Z as useGraffiti,
386
- W as useGraffitiDiscover,
387
- q as useGraffitiGet,
388
- H as useGraffitiRecoverOrphans,
389
- O as useGraffitiSession,
390
- G as useGraffitiSynchronize
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