@graffiti-garden/wrapper-vue 0.7.0 → 0.7.1
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 +148 -148
- package/dist/browser/plugin.mjs.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 +97 -97
- package/dist/node/plugin.mjs.map +1 -1
- package/package.json +3 -3
- package/src/globals.ts +7 -8
- package/src/plugin.ts +3 -3
package/dist/node/plugin.mjs
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var p = (e, t, r) =>
|
|
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 p = (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
|
p(this, "poll", async (t) => {
|
|
34
34
|
let r;
|
|
@@ -46,7 +46,7 @@ class V {
|
|
|
46
46
|
clear() {
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
class
|
|
49
|
+
class O {
|
|
50
50
|
constructor(t) {
|
|
51
51
|
p(this, "iterator");
|
|
52
52
|
p(this, "continue");
|
|
@@ -56,7 +56,7 @@ class T {
|
|
|
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;
|
|
@@ -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
|
-
p(this, "entry",
|
|
99
|
+
p(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,12 +112,12 @@ 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
|
-
p(this, "results",
|
|
120
|
+
p(this, "results", G([]));
|
|
121
121
|
p(this, "resultsRaw", /* @__PURE__ */ new Map());
|
|
122
122
|
p(this, "batchFlattenTimer");
|
|
123
123
|
this.graffiti = t;
|
|
@@ -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,26 +152,26 @@ function S(e, t, r, o, n) {
|
|
|
152
152
|
e.onEntry(c);
|
|
153
153
|
}
|
|
154
154
|
}
|
|
155
|
-
let
|
|
155
|
+
let f = !1, a;
|
|
156
156
|
const l = async () => {
|
|
157
|
-
if (
|
|
157
|
+
if (f || !a) return;
|
|
158
158
|
const c = a;
|
|
159
|
-
|
|
159
|
+
f = !0;
|
|
160
160
|
try {
|
|
161
161
|
await c();
|
|
162
162
|
} finally {
|
|
163
163
|
if (c !== a) return;
|
|
164
|
-
|
|
164
|
+
f = !1, d(n) && l();
|
|
165
165
|
}
|
|
166
|
-
}, h =
|
|
167
|
-
return
|
|
166
|
+
}, h = G(!1);
|
|
167
|
+
return k(
|
|
168
168
|
o,
|
|
169
|
-
async (c,
|
|
170
|
-
if (JSON.stringify(c) === JSON.stringify(
|
|
169
|
+
async (c, m) => {
|
|
170
|
+
if (JSON.stringify(c) === JSON.stringify(m))
|
|
171
171
|
return;
|
|
172
172
|
i == null || i.return(null), e.clear(), t.clear(), s(), a = () => t.poll(e.onEntry.bind(e));
|
|
173
173
|
const y = a;
|
|
174
|
-
|
|
174
|
+
f = !1, h.value = !0;
|
|
175
175
|
try {
|
|
176
176
|
await l();
|
|
177
177
|
} finally {
|
|
@@ -182,11 +182,11 @@ function S(e, t, r, o, n) {
|
|
|
182
182
|
{
|
|
183
183
|
immediate: !0
|
|
184
184
|
}
|
|
185
|
-
),
|
|
185
|
+
), A(() => {
|
|
186
186
|
i == null || i.return(null), e.clear(), t.clear(), a = void 0;
|
|
187
187
|
}), { poll: l, isInitialPolling: h };
|
|
188
188
|
}
|
|
189
|
-
function
|
|
189
|
+
function $(e, t) {
|
|
190
190
|
return () => {
|
|
191
191
|
const r = d(t);
|
|
192
192
|
return r === void 0 ? e == null ? void 0 : e.value : r;
|
|
@@ -195,9 +195,9 @@ function D(e, t) {
|
|
|
195
195
|
function v(e) {
|
|
196
196
|
return e.map((t) => t());
|
|
197
197
|
}
|
|
198
|
-
function
|
|
199
|
-
const n =
|
|
200
|
-
|
|
198
|
+
function x(e, t, r, o = !1) {
|
|
199
|
+
const n = w(), i = F(), s = () => d(e), f = () => d(t), a = $(i, r), l = [s, f, a], h = () => n.synchronizeDiscover(...v(l)), c = () => n.discover(...v(l)), m = new T(n), y = new O(c), { poll: P, isInitialPolling: j } = E(
|
|
200
|
+
m,
|
|
201
201
|
y,
|
|
202
202
|
h,
|
|
203
203
|
l,
|
|
@@ -208,11 +208,11 @@ function W(e, t, r, o = !1) {
|
|
|
208
208
|
* A [ref](https://vuejs.org/api/reactivity-core.html#ref) that contains
|
|
209
209
|
* an array of Graffiti objects.
|
|
210
210
|
*/
|
|
211
|
-
objects:
|
|
211
|
+
objects: m.results,
|
|
212
212
|
/**
|
|
213
213
|
* A method to poll for new results.
|
|
214
214
|
*/
|
|
215
|
-
poll:
|
|
215
|
+
poll: P,
|
|
216
216
|
/**
|
|
217
217
|
* A boolean [ref](https://vuejs.org/api/reactivity-core.html#ref)
|
|
218
218
|
* that indicates if the *first* poll is currently running.
|
|
@@ -222,15 +222,15 @@ function W(e, t, r, o = !1) {
|
|
|
222
222
|
* but it does not track ongoing polls from either calling
|
|
223
223
|
* {@link poll} or using the `autopoll` argument.
|
|
224
224
|
*/
|
|
225
|
-
isInitialPolling:
|
|
225
|
+
isInitialPolling: j
|
|
226
226
|
};
|
|
227
227
|
}
|
|
228
|
-
function
|
|
229
|
-
const n =
|
|
228
|
+
function W(e, t, r, o = !1) {
|
|
229
|
+
const n = w(), i = F(), s = () => d(e), f = () => d(t), a = $(i, r), l = [
|
|
230
230
|
s,
|
|
231
|
-
|
|
231
|
+
f,
|
|
232
232
|
a
|
|
233
|
-
], h = () => n.synchronizeGet(...v(l)), c = new
|
|
233
|
+
], h = () => n.synchronizeGet(...v(l)), c = new V(), m = () => n.get(...v(l)), y = new U(m), { poll: P, isInitialPolling: j } = E(
|
|
234
234
|
c,
|
|
235
235
|
y,
|
|
236
236
|
h,
|
|
@@ -247,7 +247,7 @@ function q(e, t, r, o = !1) {
|
|
|
247
247
|
/**
|
|
248
248
|
* A method to poll for new results.
|
|
249
249
|
*/
|
|
250
|
-
poll:
|
|
250
|
+
poll: P,
|
|
251
251
|
/**
|
|
252
252
|
* A boolean [ref](https://vuejs.org/api/reactivity-core.html#ref)
|
|
253
253
|
* that indicates if the *first* poll is currently running.
|
|
@@ -257,14 +257,14 @@ function q(e, t, r, o = !1) {
|
|
|
257
257
|
* but it does not track ongoing polls from either calling
|
|
258
258
|
* {@link poll} or using the `autopoll` argument.
|
|
259
259
|
*/
|
|
260
|
-
isInitialPolling:
|
|
260
|
+
isInitialPolling: j
|
|
261
261
|
};
|
|
262
262
|
}
|
|
263
|
-
function
|
|
264
|
-
const o =
|
|
263
|
+
function q(e, t, r = !1) {
|
|
264
|
+
const o = w(), s = [() => d(e), () => d(t)], f = () => o.synchronizeRecoverOrphans(...v(s)), a = new T(o), l = () => o.recoverOrphans(...v(s)), h = new O(l), { poll: c, isInitialPolling: m } = E(
|
|
265
265
|
a,
|
|
266
266
|
h,
|
|
267
|
-
|
|
267
|
+
f,
|
|
268
268
|
s,
|
|
269
269
|
r
|
|
270
270
|
);
|
|
@@ -287,10 +287,10 @@ function H(e, t, r = !1) {
|
|
|
287
287
|
* but it does not track ongoing polls from either calling
|
|
288
288
|
* {@link poll} or using the `autopoll` argument.
|
|
289
289
|
*/
|
|
290
|
-
isInitialPolling:
|
|
290
|
+
isInitialPolling: m
|
|
291
291
|
};
|
|
292
292
|
}
|
|
293
|
-
const
|
|
293
|
+
const D = /* @__PURE__ */ S({
|
|
294
294
|
__name: "Discover",
|
|
295
295
|
props: {
|
|
296
296
|
channels: {},
|
|
@@ -299,19 +299,19 @@ const N = /* @__PURE__ */ j({
|
|
|
299
299
|
autopoll: { type: Boolean }
|
|
300
300
|
},
|
|
301
301
|
setup(e) {
|
|
302
|
-
const t = e, { objects: r, poll: o, isInitialPolling: n } =
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
302
|
+
const t = e, { objects: r, poll: o, isInitialPolling: n } = x(
|
|
303
|
+
u(t, "channels"),
|
|
304
|
+
u(t, "schema"),
|
|
305
|
+
u(t, "session"),
|
|
306
|
+
u(t, "autopoll")
|
|
307
307
|
);
|
|
308
308
|
return (i, s) => R(i.$slots, "default", {
|
|
309
|
-
objects:
|
|
310
|
-
poll:
|
|
311
|
-
isInitialPolling:
|
|
309
|
+
objects: g(r),
|
|
310
|
+
poll: g(o),
|
|
311
|
+
isInitialPolling: g(n)
|
|
312
312
|
});
|
|
313
313
|
}
|
|
314
|
-
}),
|
|
314
|
+
}), I = /* @__PURE__ */ S({
|
|
315
315
|
__name: "Get",
|
|
316
316
|
props: {
|
|
317
317
|
url: {},
|
|
@@ -320,19 +320,19 @@ const N = /* @__PURE__ */ j({
|
|
|
320
320
|
autopoll: { type: Boolean }
|
|
321
321
|
},
|
|
322
322
|
setup(e) {
|
|
323
|
-
const t = e, { object: r, poll: o, isInitialPolling: n } =
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
323
|
+
const t = e, { object: r, poll: o, isInitialPolling: n } = W(
|
|
324
|
+
u(t, "url"),
|
|
325
|
+
u(t, "schema"),
|
|
326
|
+
u(t, "session"),
|
|
327
|
+
u(t, "autopoll")
|
|
328
328
|
);
|
|
329
329
|
return (i, s) => R(i.$slots, "default", {
|
|
330
|
-
object:
|
|
331
|
-
poll:
|
|
332
|
-
isInitialPolling:
|
|
330
|
+
object: g(r),
|
|
331
|
+
poll: g(o),
|
|
332
|
+
isInitialPolling: g(n)
|
|
333
333
|
});
|
|
334
334
|
}
|
|
335
|
-
}),
|
|
335
|
+
}), N = /* @__PURE__ */ S({
|
|
336
336
|
__name: "RecoverOrphans",
|
|
337
337
|
props: {
|
|
338
338
|
schema: {},
|
|
@@ -340,27 +340,27 @@ const N = /* @__PURE__ */ j({
|
|
|
340
340
|
autopoll: { type: Boolean }
|
|
341
341
|
},
|
|
342
342
|
setup(e) {
|
|
343
|
-
const t = e, { objects: r, poll: o, isInitialPolling: n } =
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
343
|
+
const t = e, { objects: r, poll: o, isInitialPolling: n } = q(
|
|
344
|
+
u(t, "schema"),
|
|
345
|
+
u(t, "session"),
|
|
346
|
+
u(t, "autopoll")
|
|
347
347
|
);
|
|
348
348
|
return (i, s) => R(i.$slots, "default", {
|
|
349
|
-
objects:
|
|
350
|
-
poll:
|
|
351
|
-
isInitialPolling:
|
|
349
|
+
objects: g(r),
|
|
350
|
+
poll: g(o),
|
|
351
|
+
isInitialPolling: g(n)
|
|
352
352
|
});
|
|
353
353
|
}
|
|
354
|
-
}),
|
|
354
|
+
}), Y = {
|
|
355
355
|
install(e, t) {
|
|
356
|
-
const r = t.graffiti, o = new
|
|
356
|
+
const r = t.graffiti, o = new C(r), n = G(void 0);
|
|
357
357
|
o.sessionEvents.addEventListener("initialized", async (i) => {
|
|
358
358
|
const s = i.detail;
|
|
359
359
|
if (s && s.error && console.error(s.error), s && s.href) {
|
|
360
|
-
const
|
|
361
|
-
if (
|
|
362
|
-
const a =
|
|
363
|
-
l.pathname.startsWith(a) && (l.pathname = l.pathname.slice(a.length)), await
|
|
360
|
+
const f = e.config.globalProperties.$router;
|
|
361
|
+
if (f) {
|
|
362
|
+
const a = f.options.history.base, l = new URL(s.href);
|
|
363
|
+
l.pathname.startsWith(a) && (l.pathname = l.pathname.slice(a.length)), await f.replace(l.pathname + l.search + l.hash);
|
|
364
364
|
}
|
|
365
365
|
}
|
|
366
366
|
n.value || (n.value = null);
|
|
@@ -374,19 +374,19 @@ const N = /* @__PURE__ */ j({
|
|
|
374
374
|
}), o.sessionEvents.addEventListener("logout", (i) => {
|
|
375
375
|
const s = i.detail;
|
|
376
376
|
s.error ? (console.error("Error logging out:"), console.error(s.error)) : n.value = null;
|
|
377
|
-
}),
|
|
377
|
+
}), 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
378
|
}
|
|
379
|
-
},
|
|
379
|
+
}, Z = D, tt = I, et = N;
|
|
380
380
|
export {
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
381
|
+
Z as GraffitiDiscover,
|
|
382
|
+
tt as GraffitiGet,
|
|
383
|
+
Y as GraffitiPlugin,
|
|
384
|
+
et as GraffitiRecoverOrphans,
|
|
385
|
+
X as useGraffiti,
|
|
386
|
+
x as useGraffitiDiscover,
|
|
387
|
+
W as useGraffitiGet,
|
|
388
|
+
q as useGraffitiRecoverOrphans,
|
|
389
|
+
F as useGraffitiSession,
|
|
390
|
+
w as useGraffitiSynchronize
|
|
391
391
|
};
|
|
392
392
|
//# sourceMappingURL=plugin.mjs.map
|
package/dist/node/plugin.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.mjs","sources":["../../src/globals.ts","../../node_modules/@graffiti-garden/api/dist/index.mjs","../../src/pollers.ts","../../src/reducers.ts","../../src/composables.ts","../../src/Discover.vue","../../src/Get.vue","../../src/RecoverOrphans.vue","../../src/plugin.ts"],"sourcesContent":["import { inject } from \"vue\";\nimport type { InjectionKey, Ref } from \"vue\";\nimport type { Graffiti, GraffitiSession } from \"@graffiti-garden/api\";\nimport type { GraffitiSynchronize } from \"@graffiti-garden/wrapper-synchronize\";\n\nexport const graffitiInjectKey = Symbol() as InjectionKey<GraffitiSynchronize>;\nexport const graffitiSessionInjectKey = Symbol() as InjectionKey<\n Ref<GraffitiSession | undefined | null>\n>;\n\n/**\n * Returns the global [Graffiti](https://api.graffiti.garden/classes/Graffiti.html) instance\n * that has been wrapped by the {@link GraffitiPlugin} with the [GraffitiSynchronize](https://sync.graffiti.garden/classes/GraffitiSynchronize.html).\n * @throws If the {@link GraffitiPlugin} is not installed\n */\nexport function useGraffitiSynchronize() {\n const graffiti = inject(graffitiInjectKey);\n if (!graffiti) {\n throw new Error(\n \"No Graffiti instance provided, did you forget to install the plugin?\",\n );\n }\n return graffiti;\n}\n\n/**\n * Returns the global [Graffiti](https://api.graffiti.garden/classes/Graffiti.html) instance.\n *\n * In Vue templates and the [options API](https://vuejs.org/guide/introduction.html#options-api)\n * use the global variable {@link ComponentCustomProperties.$graffiti | $graffiti} instead.\n *\n * This is the same Graffiti registered with the {@link GraffitiPlugin}\n * via {@link GraffitiPluginOptions.graffiti}, only it has been wrapped\n * with [GraffitiSynchronize](https://sync.graffiti.garden/classes/GraffitiSynchronize.html).\n * Be sure to use the wrapped instance to enable reactivity.\n *\n * @throws If the {@link GraffitiPlugin} is not installed\n */\nexport function useGraffiti(): Graffiti {\n return useGraffitiSynchronize();\n}\n\n/**\n * Returns a global reactive [GraffitiSession](https://api.graffiti.garden/interfaces/GraffitiSession.html) instance\n * as a [Vue ref](https://vuejs.org/api/reactivity-core.html#ref).\n *\n * In Vue templates and the [options API](https://vuejs.org/guide/introduction.html#options-api)\n * use the global variable {@link ComponentCustomProperties.$graffitiSession | $graffitiSession} instead.\n *\n * While the application is loading and restoring any previous sessions,\n * the value will be `undefined`. If the user is not logged in,\n * the value will be `null`.\n *\n * This only keeps track of one session. If your app needs\n * to support multiple login sessions, you'll need to manage them\n * yourself using [`Graffiti.sessionEvents`](https://api.graffiti.garden/classes/Graffiti.html#sessionevents).\n * @throws If the {@link GraffitiPlugin} is not installed\n */\nexport function useGraffitiSession() {\n const session = inject(graffitiSessionInjectKey);\n if (!session) {\n throw new Error(\n \"No Graffiti session provided, did you forget to install the plugin?\",\n );\n }\n return session;\n}\n","var r=class{};var p={type:\"object\",properties:{value:{type:\"object\"},channels:{type:\"array\",items:{type:\"string\"}},allowed:{type:\"array\",items:{type:\"string\"},nullable:!0},url:{type:\"string\"},actor:{type:\"string\"},lastModified:{type:\"number\"}},additionalProperties:!1,required:[\"value\",\"channels\",\"actor\",\"url\",\"lastModified\"]},O={...p,required:[\"value\",\"channels\"]};var a=class t extends Error{constructor(e){super(e),this.name=\"GraffitiErrorUnauthorized\",Object.setPrototypeOf(this,t.prototype)}},i=class t extends Error{constructor(e){super(e),this.name=\"GraffitiErrorForbidden\",Object.setPrototypeOf(this,t.prototype)}},s=class t extends Error{constructor(e){super(e),this.name=\"GraffitiErrorNotFound\",Object.setPrototypeOf(this,t.prototype)}},o=class t extends Error{constructor(e){super(e),this.name=\"GraffitiErrorInvalidSchema\",Object.setPrototypeOf(this,t.prototype)}},n=class t extends Error{constructor(e){super(e),this.name=\"GraffitiErrorSchemaMismatch\",Object.setPrototypeOf(this,t.prototype)}},c=class t extends Error{constructor(e){super(e),this.name=\"GraffitiErrorPatchTestFailed\",Object.setPrototypeOf(this,t.prototype)}},f=class t extends Error{constructor(e){super(e),this.name=\"GraffitiErrorPatchError\",Object.setPrototypeOf(this,t.prototype)}},m=class t extends Error{constructor(e){super(e),this.name=\"GraffitiErrorInvalidUrl\",Object.setPrototypeOf(this,t.prototype)}},S=class t extends Error{constructor(e){super(e),this.name=\"GraffitiErrorUnrecognizedUriScheme\",Object.setPrototypeOf(this,t.prototype)}};export{r as Graffiti,i as GraffitiErrorForbidden,o as GraffitiErrorInvalidSchema,m as GraffitiErrorInvalidUrl,s as GraffitiErrorNotFound,f as GraffitiErrorPatchError,c as GraffitiErrorPatchTestFailed,n as GraffitiErrorSchemaMismatch,a as GraffitiErrorUnauthorized,S as GraffitiErrorUnrecognizedUrlScheme,p as GraffitiObjectJSONSchema,O as GraffitiPutObjectJSONSchema};\n//# sourceMappingURL=index.mjs.map\n","import {\n type Graffiti,\n type JSONSchema,\n type GraffitiObject,\n type GraffitiObjectStreamReturn,\n type GraffitiObjectStreamContinueEntry,\n type GraffitiObjectStream,\n type GraffitiObjectStreamContinue,\n GraffitiErrorNotFound,\n} from \"@graffiti-garden/api\";\n\nexport abstract class Poller<Schema extends JSONSchema> {\n abstract poll(\n onEntry: (\n entry: GraffitiObjectStreamContinueEntry<Schema> | null | \"clear\",\n ) => void,\n ): Promise<void>;\n abstract clear(): void;\n}\n\n/**\n * Polls for a single object and calls onValue with the result.\n */\nexport class GetPoller<Schema extends JSONSchema> implements Poller<Schema> {\n constructor(readonly getter: () => Promise<GraffitiObject<Schema>>) {}\n\n poll: Poller<Schema>[\"poll\"] = async (onEntry) => {\n let object: GraffitiObject<Schema>;\n const myGetter = this.getter;\n try {\n object = await myGetter();\n } catch (e) {\n if (this.getter === myGetter) {\n onEntry(null);\n }\n return;\n }\n if (this.getter === myGetter) {\n onEntry({ object });\n }\n };\n\n clear() {}\n}\n\n/**\n * Polls for multiple objects and calls `onObject` with the result.\n * If `poll` is called multiple times, it doesn't poll the results\n * entirely from scratch, but instead only polls the new results.\n */\nexport class StreamPoller<Schema extends JSONSchema> implements Poller<Schema> {\n iterator: GraffitiObjectStreamContinue<Schema> | undefined;\n continue: (() => GraffitiObjectStreamContinue<Schema>) | undefined;\n\n constructor(readonly streamFactory: () => GraffitiObjectStream<Schema>) {}\n\n clear() {\n if (this.iterator) {\n const iterator = this.iterator;\n this.iterator.return({\n continue: () => iterator,\n cursor: \"\",\n });\n }\n this.iterator = undefined;\n this.continue = undefined;\n }\n\n poll: Poller<Schema>[\"poll\"] = async (onEntry) => {\n if (!this.iterator) {\n if (this.continue) {\n try {\n this.iterator = this.continue();\n } catch (e) {\n // The cursor has expired, we need to start from scratch.\n if (e instanceof GraffitiErrorNotFound) {\n onEntry(\"clear\");\n this.iterator = this.streamFactory();\n } else {\n throw e;\n }\n }\n } else {\n this.iterator = this.streamFactory();\n }\n }\n\n while (true) {\n // Check if the iterator has been cancelled.\n if (!this.iterator) {\n break;\n }\n\n const myIterator: GraffitiObjectStreamContinue<Schema> = this.iterator;\n\n const result = await myIterator.next();\n\n // Check again if it was cancelled.\n if (myIterator !== this.iterator) {\n continue;\n }\n\n if (result.done) {\n if (result.value) {\n this.iterator = undefined;\n this.continue = result.value.continue;\n }\n break;\n }\n\n if (result.value.error) {\n console.error(result.value.error);\n continue;\n }\n\n onEntry(result.value);\n }\n };\n}\n","import { computed, ref } from \"vue\";\nimport type { Ref } from \"vue\";\nimport type {\n GraffitiObject,\n Graffiti,\n JSONSchema,\n GraffitiObjectStreamContinueEntry,\n} from \"@graffiti-garden/api\";\n\nexport abstract class Reducer<Schema extends JSONSchema> {\n abstract clear(): void;\n abstract onEntry(\n entry: GraffitiObjectStreamContinueEntry<Schema> | null | \"clear\",\n ): void;\n}\n\nfunction isEntryNewer<Schema extends JSONSchema>(\n entry: GraffitiObjectStreamContinueEntry<Schema>,\n existing: GraffitiObjectStreamContinueEntry<Schema> | null | undefined,\n): boolean {\n return (\n !existing ||\n entry.object.lastModified > existing.object.lastModified ||\n (entry.object.lastModified === existing.object.lastModified &&\n !entry.tombstone &&\n !!existing.tombstone)\n );\n}\n\n/**\n * Retrieves multiple Graffiti objects and retains\n * the most recent one as the `result` property (a Vue ref).\n * Before any objects have been received, the result\n * is `undefined`. If the object has been deleted,\n * the result is `null`.\n */\nexport class SingletonReducer<Schema extends JSONSchema>\n implements Reducer<Schema>\n{\n readonly entry: Ref<\n GraffitiObjectStreamContinueEntry<Schema> | null | undefined\n > = ref();\n\n get result(): Ref<GraffitiObject<Schema> | null | undefined> {\n return computed(() => {\n const value = this.entry.value;\n if (!value) return value;\n if (value.tombstone) return null;\n return value.object;\n });\n }\n\n clear() {\n this.entry.value = undefined;\n }\n\n onEntry(entry: GraffitiObjectStreamContinueEntry<Schema> | null | \"clear\") {\n if (entry === \"clear\") {\n this.clear();\n return;\n }\n if (!entry || isEntryNewer<Schema>(entry, this.entry.value)) {\n this.entry.value = entry;\n }\n }\n}\n\n/**\n * Retrieves multiple Graffiti objects and retains\n * the most recent one per URI as the `results` property (a Vue ref).\n * If multiple objects are received concurrently,\n * they are processed in batches every `REFRESH_RATE` milliseconds\n * to avoid freezing the interface.\n */\nexport class ArrayReducer<Schema extends JSONSchema>\n implements Reducer<Schema>\n{\n readonly results: Ref<GraffitiObject<Schema>[]> = ref([]);\n readonly resultsRaw: Map<string, GraffitiObjectStreamContinueEntry<Schema>> =\n new Map();\n batchFlattenTimer: ReturnType<typeof setTimeout> | undefined;\n\n constructor(readonly graffiti: Graffiti) {}\n\n clear() {\n this.resultsRaw.clear();\n this.results.value = [];\n clearTimeout(this.batchFlattenTimer);\n this.batchFlattenTimer = undefined;\n }\n\n flattenResults() {\n this.results.value = Array.from(this.resultsRaw.values()).reduce<\n GraffitiObject<Schema>[]\n >((acc, entry) => {\n if (!entry.tombstone) {\n acc.push(entry.object);\n }\n return acc;\n }, []);\n }\n\n onEntry(entry: GraffitiObjectStreamContinueEntry<Schema> | null | \"clear\") {\n if (!entry) return;\n if (entry === \"clear\") {\n this.clear();\n return;\n }\n const existing = this.resultsRaw.get(entry.object.url);\n if (!isEntryNewer<Schema>(entry, existing)) return;\n this.resultsRaw.set(entry.object.url, entry);\n\n // Don't flatten the results all at once,\n // because we may get a lot of results\n // and we don't want the interface to\n // freeze up\n if (!this.batchFlattenTimer) {\n this.batchFlattenTimer = setTimeout(() => {\n this.flattenResults();\n this.batchFlattenTimer = undefined;\n }, 0);\n }\n }\n}\n","import { onScopeDispose, ref, toValue, watch } from \"vue\";\nimport type { Ref, MaybeRefOrGetter } from \"vue\";\nimport type {\n GraffitiObjectUrl,\n GraffitiObject,\n GraffitiSession,\n JSONSchema,\n GraffitiObjectStreamContinueEntry,\n} from \"@graffiti-garden/api\";\nimport { useGraffitiSynchronize, useGraffitiSession } from \"./globals\";\nimport { GetPoller, Poller, StreamPoller } from \"./pollers\";\nimport { ArrayReducer, Reducer, SingletonReducer } from \"./reducers\";\n\nfunction makeComposable<Schema extends JSONSchema>(\n reducer: Reducer<Schema>,\n poller: Poller<Schema>,\n synchronizeFactory: () => AsyncGenerator<\n GraffitiObjectStreamContinueEntry<Schema>\n >,\n toWatch: readonly (() => any)[],\n autopoll: MaybeRefOrGetter<boolean>,\n) {\n let synchronizeIterator:\n | AsyncGenerator<GraffitiObjectStreamContinueEntry<Schema>>\n | undefined;\n async function pollSynchronize() {\n synchronizeIterator = synchronizeFactory();\n for await (const result of synchronizeIterator) {\n if (result.error) {\n console.error(result.error);\n continue;\n }\n reducer.onEntry(result);\n }\n }\n\n let isAlreadyPolling = false;\n let innerPoll: (() => Promise<void>) | undefined;\n const poll = async () => {\n if (isAlreadyPolling) return;\n if (!innerPoll) return;\n const myPoll = innerPoll;\n isAlreadyPolling = true;\n try {\n await myPoll();\n } finally {\n if (myPoll !== innerPoll) return;\n isAlreadyPolling = false;\n if (toValue(autopoll)) {\n poll();\n }\n }\n };\n\n const isInitialPolling = ref(false);\n watch(\n toWatch,\n async (newValue, oldValue) => {\n // Catch unnecessary updates\n if (JSON.stringify(newValue) === JSON.stringify(oldValue)) {\n return;\n }\n\n synchronizeIterator?.return(null);\n reducer.clear();\n poller.clear();\n\n pollSynchronize();\n\n innerPoll = () => poller.poll(reducer.onEntry.bind(reducer));\n const myPoll = innerPoll;\n\n isAlreadyPolling = false;\n\n isInitialPolling.value = true;\n try {\n await poll();\n } finally {\n if (myPoll !== innerPoll) return;\n isInitialPolling.value = false;\n }\n },\n {\n immediate: true,\n },\n );\n onScopeDispose(() => {\n synchronizeIterator?.return(null);\n reducer.clear();\n poller.clear();\n innerPoll = undefined;\n });\n\n return { poll, isInitialPolling };\n}\n\nfunction toSessionGetter(\n sessionInjected: ReturnType<typeof useGraffitiSession>,\n session?: MaybeRefOrGetter<GraffitiSession | undefined | null>,\n) {\n return () => {\n const sessionValue = toValue(session);\n if (sessionValue === undefined) {\n return sessionInjected?.value;\n } else {\n return sessionValue;\n }\n };\n}\n\nfunction callGetters<T extends readonly (() => any)[]>(\n getters: T,\n): {\n [K in keyof T]: ReturnType<T[K]>;\n} {\n return getters.map((fn) => fn()) as any;\n}\n\n/**\n * The [Graffiti.discover](https://api.graffiti.garden/classes/Graffiti.html#discover)\n * method as a reactive [composable](https://vuejs.org/guide/reusability/composables.html)\n * for use in the Vue [composition API](https://vuejs.org/guide/introduction.html#composition-api).\n *\n * Its corresponding renderless component is {@link GraffitiDiscover}.\n *\n * The arguments of this composable as the same as Graffiti.discover,\n * only they can also be [Refs](https://vuejs.org/api/reactivity-core.html#ref)\n * or [getters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get#description).\n * As they change the output will automatically update.\n * Reactivity only triggers when the root array or object changes,\n * not when the elements or properties change.\n * If you need deep reactivity, wrap your argument in a getter.\n */\nexport function useGraffitiDiscover<Schema extends JSONSchema>(\n channels: MaybeRefOrGetter<string[]>,\n schema: MaybeRefOrGetter<Schema>,\n /**\n * If the session is `undefined`, the global session,\n * {@link ComponentCustomProperties.$graffitiSession | $graffitiSession},\n * will be used. Otherwise, the provided value will be used.\n */\n session?: MaybeRefOrGetter<GraffitiSession | undefined | null>,\n autopoll: MaybeRefOrGetter<boolean> = false,\n): {\n objects: Ref<GraffitiObject<Schema>[]>;\n poll: () => Promise<void>;\n isInitialPolling: Ref<boolean>;\n} {\n const graffiti = useGraffitiSynchronize();\n const sessionInjected = useGraffitiSession();\n\n const channelsGetter = () => toValue(channels);\n const schemaGetter = () => toValue(schema);\n const sessionGetter = toSessionGetter(sessionInjected, session);\n const argGetters = [channelsGetter, schemaGetter, sessionGetter] as const;\n\n const synchronizeFactory = () =>\n graffiti.synchronizeDiscover(...callGetters(argGetters));\n const streamFactory = () => graffiti.discover(...callGetters(argGetters));\n\n const reducer = new ArrayReducer<Schema>(graffiti);\n const poller = new StreamPoller<Schema>(streamFactory);\n\n const { poll, isInitialPolling } = makeComposable<Schema>(\n reducer,\n poller,\n synchronizeFactory,\n argGetters,\n autopoll,\n );\n\n return {\n /**\n * A [ref](https://vuejs.org/api/reactivity-core.html#ref) that contains\n * an array of Graffiti objects.\n */\n objects: reducer.results,\n /**\n * A method to poll for new results.\n */\n poll,\n /**\n * A boolean [ref](https://vuejs.org/api/reactivity-core.html#ref)\n * that indicates if the *first* poll is currently running.\n * Useful to show a loading spinner or disable a button.\n *\n * This also tracks new polls when the arguments have changed,\n * but it does not track ongoing polls from either calling\n * {@link poll} or using the `autopoll` argument.\n */\n isInitialPolling,\n };\n}\n\n/**\n * The [Graffiti.get](https://api.graffiti.garden/classes/Graffiti.html#get)\n * method as a reactive [composable](https://vuejs.org/guide/reusability/composables.html)\n * for use in the Vue [composition API](https://vuejs.org/guide/introduction.html#composition-api).\n *\n * Its corresponding renderless component is {@link GraffitiGet}.\n *\n * The arguments of this composable as the same as Graffiti.get,\n * only they can also be [Refs](https://vuejs.org/api/reactivity-core.html#ref)\n * or [getters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get#description).\n * As they change the output will automatically update.\n * Reactivity only triggers when the root array or object changes,\n * not when the elements or properties change.\n * If you need deep reactivity, wrap your argument in a getter.\n */\nexport function useGraffitiGet<Schema extends JSONSchema>(\n locationOrUri: MaybeRefOrGetter<GraffitiObjectUrl | string>,\n schema: MaybeRefOrGetter<Schema>,\n /**\n * If the session is `undefined`, the global session,\n * {@link ComponentCustomProperties.$graffitiSession | $graffitiSession},\n * will be used. Otherwise, the provided value will be used.\n */\n session?: MaybeRefOrGetter<GraffitiSession | undefined | null>,\n autopoll: MaybeRefOrGetter<boolean> = false,\n): {\n object: Ref<GraffitiObject<Schema> | null | undefined>;\n poll: () => Promise<void>;\n isInitialPolling: Ref<boolean>;\n} {\n const graffiti = useGraffitiSynchronize();\n const sessionInjected = useGraffitiSession();\n\n const locationOrUriGetter = () => toValue(locationOrUri);\n const schemaGetter = () => toValue(schema);\n const sessionGetter = toSessionGetter(sessionInjected, session);\n const argGetters = [\n locationOrUriGetter,\n schemaGetter,\n sessionGetter,\n ] as const;\n\n const synchronizeFactory = () =>\n graffiti.synchronizeGet(...callGetters(argGetters));\n\n const reducer = new SingletonReducer<Schema>();\n const getter = () => graffiti.get<Schema>(...callGetters(argGetters));\n const poller = new GetPoller<Schema>(getter);\n\n const { poll, isInitialPolling } = makeComposable<Schema>(\n reducer,\n poller,\n synchronizeFactory,\n argGetters,\n autopoll,\n );\n\n return {\n /**\n * A [ref](https://vuejs.org/api/reactivity-core.html#ref) that contains\n * the retrieved Graffiti object, if it exists. If the object has been deleted,\n * the result is `null`. If the object is still being fetched, the result is `undefined`.\n */\n object: reducer.result,\n /**\n * A method to poll for new results.\n */\n poll,\n /**\n * A boolean [ref](https://vuejs.org/api/reactivity-core.html#ref)\n * that indicates if the *first* poll is currently running.\n * Useful to show a loading spinner or disable a button.\n *\n * This also tracks new polls when the arguments have changed,\n * but it does not track ongoing polls from either calling\n * {@link poll} or using the `autopoll` argument.\n */\n isInitialPolling,\n };\n}\n\n/**\n * The [Graffiti.recoverOrphans](https://api.graffiti.garden/classes/Graffiti.html#recoverorphans)\n * method as a reactive [composable](https://vuejs.org/guide/reusability/composables.html)\n * for use in the Vue [composition API](https://vuejs.org/guide/introduction.html#composition-api).\n *\n * Its corresponding renderless component is {@link GraffitiRecoverOrphans}.\n *\n * The arguments of this composable as the same as Graffiti.get,\n * only they can also be [Refs](https://vuejs.org/api/reactivity-core.html#ref)\n * or [getters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get#description).\n * As they change the output will automatically update.\n * Reactivity only triggers when the root array or object changes,\n * not when the elements or properties change.\n * If you need deep reactivity, wrap your argument in a getter.\n */\nexport function useGraffitiRecoverOrphans<Schema extends JSONSchema>(\n schema: MaybeRefOrGetter<Schema>,\n session: MaybeRefOrGetter<GraffitiSession>,\n autopoll: MaybeRefOrGetter<boolean> = false,\n): {\n objects: Ref<GraffitiObject<Schema>[]>;\n poll: () => Promise<void>;\n isInitialPolling: Ref<boolean>;\n} {\n const graffiti = useGraffitiSynchronize();\n\n const schemaGetter = () => toValue(schema);\n const sessionGetter = () => toValue(session);\n const argGetters = [schemaGetter, sessionGetter] as const;\n\n const synchronizeFactory = () =>\n graffiti.synchronizeRecoverOrphans(...callGetters(argGetters));\n\n const reducer = new ArrayReducer<Schema>(graffiti);\n const streamFactory = () =>\n graffiti.recoverOrphans<Schema>(...callGetters(argGetters));\n const poller = new StreamPoller<Schema>(streamFactory);\n\n const { poll, isInitialPolling } = makeComposable<Schema>(\n reducer,\n poller,\n synchronizeFactory,\n argGetters,\n autopoll,\n );\n\n return {\n /**\n * A [ref](https://vuejs.org/api/reactivity-core.html#ref) that contains\n * an array of Graffiti objects.\n */\n objects: reducer.results,\n /**\n * A method to poll for new results.\n */\n poll,\n /**\n * A boolean [ref](https://vuejs.org/api/reactivity-core.html#ref)\n * that indicates if the *first* poll is currently running.\n * Useful to show a loading spinner or disable a button.\n *\n * This also tracks new polls when the arguments have changed,\n * but it does not track ongoing polls from either calling\n * {@link poll} or using the `autopoll` argument.\n */\n isInitialPolling,\n };\n}\n","<script setup lang=\"ts\" generic=\"Schema extends JSONSchema\">\nimport { toRef } from \"vue\";\nimport type {\n GraffitiSession,\n JSONSchema,\n GraffitiObject,\n} from \"@graffiti-garden/api\";\nimport { useGraffitiDiscover } from \"./composables\";\n\nconst props = defineProps<{\n channels: string[];\n schema: Schema;\n session?: GraffitiSession | null;\n autopoll?: boolean;\n}>();\n\ndefineSlots<{\n default?(props: {\n objects: GraffitiObject<Schema>[];\n poll: () => void;\n isInitialPolling: boolean;\n }): any;\n}>();\n\nconst { objects, poll, isInitialPolling } = useGraffitiDiscover<Schema>(\n toRef(props, \"channels\"),\n toRef(props, \"schema\"),\n toRef(props, \"session\"),\n toRef(props, \"autopoll\"),\n);\n</script>\n\n<template>\n <slot\n :objects=\"objects\"\n :poll=\"poll\"\n :isInitialPolling=\"isInitialPolling\"\n ></slot>\n</template>\n","<script setup lang=\"ts\" generic=\"Schema extends JSONSchema\">\nimport { toRef } from \"vue\";\nimport type {\n GraffitiObjectUrl,\n GraffitiObject,\n GraffitiSession,\n JSONSchema,\n} from \"@graffiti-garden/api\";\nimport { useGraffitiGet } from \"./composables\";\n\nconst props = defineProps<{\n url: string | GraffitiObjectUrl;\n schema: Schema;\n session?: GraffitiSession | null;\n autopoll?: boolean;\n}>();\n\ndefineSlots<{\n default?(props: {\n object: GraffitiObject<Schema> | undefined | null;\n poll: () => void;\n isInitialPolling: boolean;\n }): any;\n}>();\n\nconst { object, poll, isInitialPolling } = useGraffitiGet<Schema>(\n toRef(props, \"url\"),\n toRef(props, \"schema\"),\n toRef(props, \"session\"),\n toRef(props, \"autopoll\"),\n);\n</script>\n\n<template>\n <slot\n :object=\"object\"\n :poll=\"poll\"\n :isInitialPolling=\"isInitialPolling\"\n ></slot>\n</template>\n","<script setup lang=\"ts\" generic=\"Schema extends JSONSchema\">\nimport { toRef } from \"vue\";\nimport type {\n GraffitiSession,\n JSONSchema,\n GraffitiObject,\n} from \"@graffiti-garden/api\";\nimport { useGraffitiRecoverOrphans } from \"./composables\";\n\nconst props = defineProps<{\n schema: Schema;\n session: GraffitiSession;\n autopoll?: boolean;\n}>();\n\ndefineSlots<{\n default?(props: {\n objects: GraffitiObject<Schema>[];\n poll: () => void;\n isInitialPolling: boolean;\n }): any;\n}>();\n\nconst { objects, poll, isInitialPolling } = useGraffitiRecoverOrphans<Schema>(\n toRef(props, \"schema\"),\n toRef(props, \"session\"),\n toRef(props, \"autopoll\"),\n);\n</script>\n\n<template>\n <slot\n :objects=\"objects\"\n :poll=\"poll\"\n :isInitialPolling=\"isInitialPolling\"\n ></slot>\n</template>\n","import type { App, Plugin, Ref } from \"vue\";\nimport { ref } from \"vue\";\nimport Discover from \"./Discover.vue\";\nimport Get from \"./Get.vue\";\nimport RecoverOrphans from \"./RecoverOrphans.vue\";\nimport type {\n Graffiti,\n GraffitiSession,\n GraffitiLoginEvent,\n GraffitiLogoutEvent,\n GraffitiSessionInitializedEvent,\n} from \"@graffiti-garden/api\";\nimport { graffitiInjectKey, graffitiSessionInjectKey } from \"./globals\";\nimport type { Router } from \"vue-router\";\nimport { GraffitiSynchronize } from \"@graffiti-garden/wrapper-synchronize\";\n\ndeclare module \"vue\" {\n export interface ComponentCustomProperties {\n /**\n * Global [Graffiti](https://api.graffiti.garden/classes/Graffiti.html) instance.\n *\n * In the [composition API](https://vuejs.org/guide/introduction.html#composition-api)\n * use {@link useGraffiti} instead.\n *\n * This is the same Graffiti registered with the {@link GraffitiPlugin}\n * via {@link GraffitiPluginOptions.graffiti}, only it has been wrapped\n * with [GraffitiSynchronize](https://sync.graffiti.garden/classes/GraffitiSynchronize.html).\n * Be sure to use the wrapped instance to enable reactivity.\n */\n $graffiti: Graffiti;\n /**\n * Global reactive [GraffitiSession](https://api.graffiti.garden/classes/GraffitiSession.html) instance\n * as a [Vue ref](https://vuejs.org/api/reactivity-core.html#ref).\n *\n * In the [composition API](https://vuejs.org/guide/introduction.html#composition-api)\n * use {@link useGraffitiSession} instead.\n *\n * While the application is loading and restoring any previous sessions,\n * the value will be `undefined`. If the user is not logged in,\n * the value will be `null`.\n *\n * This only keeps track of one session. If your app needs\n * to support multiple login sessions, you'll need to manage them\n * yourself using [`Graffiti.sessionEvents`](https://api.graffiti.garden/classes/Graffiti.html#sessionevents).\n */\n $graffitiSession: Ref<GraffitiSession | undefined | null>;\n }\n\n export interface GlobalComponents {\n GraffitiDiscover: typeof Discover;\n GraffitiGet: typeof Get;\n GraffitiRecoverOrphans: typeof RecoverOrphans;\n }\n}\nexport type { ComponentCustomProperties } from \"vue\";\n\n/**\n * Options for the {@link GraffitiPlugin}.\n */\nexport interface GraffitiPluginOptions {\n /**\n * An instance of the [Graffiti API](https://api.graffiti.garden/classes/Graffiti.html)\n * for the Vue.js plugin to use.\n * This instance, wrapped with [GraffitiSynchronize](https://sync.graffiti.garden/classes/GraffitiSynchronize.html),\n * will be exposed in Vue templates as {@link ComponentCustomProperties.$graffiti | $graffiti}\n * and in setup functions as {@link useGraffiti}.\n * You must interact with Graffiti through these wrapped instances\n * to enable reactivity.\n *\n * You'll likely want to use the [federated implementation](https://github.com/graffiti-garden/implementation-federated).\n * However, you could also use the [local implementation](https://github.com/graffiti-garden/implementation-local)\n * for testing. Other implementations may be available in the future.\n */\n graffiti: Graffiti;\n}\n\n/**\n * A [Vue.js](https://vuejs.org/) plugin that wraps around\n * the [Graffiti API](https://api.graffiti.garden/classes/Graffiti.html)\n * to provide [reactive](https://en.wikipedia.org/wiki/Reactive_programming) versions\n * of various Graffiti API methods.\n *\n * These reactive methods are available as both\n * [renderless components](https://vuejs.org/guide/components/slots#renderless-components),\n * which make it possible to create a whole Graffiti app in an HTML template,\n * and [composables](https://vuejs.org/guide/reusability/composables.html),\n * which can be used in the programmatic [composition API](https://vuejs.org/guide/introduction.html#composition-api).\n *\n * | [API](https://api.graffiti.garden/classes/Graffiti.html) method | [Composable](https://vuejs.org/guide/reusability/composables.html) | [Component](https://vuejs.org/guide/components/slots#renderless-components) |\n * | --- | --- | --- |\n * | [discover](https://api.graffiti.garden/classes/Graffiti.html#discover) | {@link useGraffitiDiscover} | {@link GraffitiDiscover} |\n * | [get](https://api.graffiti.garden/classes/Graffiti.html#get) | {@link useGraffitiGet} | {@link GraffitiGet} |\n * | [recoverOrphans](https://api.graffiti.garden/classes/Graffiti.html#recoverorphans) | {@link useGraffitiRecoverOrphans} | {@link GraffitiRecoverOrphans} |\n *\n * The plugin also exposes a global [Graffiti](https://api.graffiti.garden/classes/Graffiti.html) instance\n * and keeps track of the global [GraffitiSession](https://api.graffiti.garden/interfaces/GraffitiSession.html)\n * state as a reactive variable.\n * They are available in templates as global variables or in setup functions as\n * composable functions.\n *\n * | Global variabale | [Composable](https://vuejs.org/guide/reusability/composables.html) |\n * | --- | --- |\n * | {@link ComponentCustomProperties.$graffiti | $graffiti } | {@link useGraffiti} |\n * | {@link ComponentCustomProperties.$graffitiSession | $graffitiSession } | {@link useGraffitiSession} |\n *\n * [See the README for installation instructions](/).\n *\n * You can [try out live examples](/examples/), but basic usage looks like this:\n *\n * ```ts\n * import { createApp } from \"vue\";\n * import { GraffitiPlugin } from \"@graffiti-garden/vue\";\n * import { GraffitiLocal } from \"@graffiti-garden/implementation-local\";\n * import App from \"./App.vue\";\n *\n * createApp(App)\n * .use(GraffitiPlugin, {\n * graffiti: new GraffitiLocal(),\n * })\n * ```\n *\n * ```vue\n * <!-- App.vue -->\n * <template>\n * <button\n * v-if=\"$graffitiSession.value\"\n * @click=\"$graffiti.put({\n * value: { content: 'Hello, world!' },\n * channels: [ 'my-channel' ]\n * }, $graffitiSession.value)\"\n * >\n * Say Hello\n * </button>\n * <button v-else @click=\"$graffiti.login()\">\n * Log In to Say Hello\n * </button>\n *\n * <GraffitiDiscover\n * v-slot=\"{ results }\"\n * :channels=\"[ 'my-channel' ]\"\n * :schema=\"{\n * properties: {\n * value: {\n * required: ['content'],\n * properties: {\n * content: { type: 'string' }\n * }\n * }\n * }\n * }\"\n * >\n * <ul>\n * <li\n * v-for=\"result in results\"\n * :key=\"$graffiti.objectToUri(result)\"\n * >\n * {{ result.value.content }}\n * </li>\n * </ul>\n * </GraffitiDiscover>\n * </template>\n * ```\n */\nexport const GraffitiPlugin: Plugin<GraffitiPluginOptions> = {\n install(app: App, options: GraffitiPluginOptions) {\n const graffitiBase = options.graffiti;\n const graffiti = new GraffitiSynchronize(graffitiBase);\n\n const graffitiSession = ref<GraffitiSession | undefined | null>(undefined);\n graffiti.sessionEvents.addEventListener(\"initialized\", async (evt) => {\n const detail = (evt as GraffitiSessionInitializedEvent).detail;\n\n if (detail && detail.error) {\n console.error(detail.error);\n }\n\n if (detail && detail.href) {\n // If we're using Vue Router, redirect to the URL after login\n const router = app.config.globalProperties.$router as\n | Router\n | undefined;\n if (router) {\n const base = router.options.history.base;\n const url = new URL(detail.href);\n if (url.pathname.startsWith(base)) {\n url.pathname = url.pathname.slice(base.length);\n }\n await router.replace(url.pathname + url.search + url.hash);\n }\n }\n\n // Set the session to \"null\" if the user is not logged in\n if (!graffitiSession.value) {\n graffitiSession.value = null;\n }\n });\n graffiti.sessionEvents.addEventListener(\"login\", (evt) => {\n const detail = (evt as GraffitiLoginEvent).detail;\n if (detail.error) {\n console.error(\"Error logging in:\");\n console.error(detail.error);\n return;\n } else {\n graffitiSession.value = detail.session;\n }\n });\n graffiti.sessionEvents.addEventListener(\"logout\", (evt) => {\n const detail = (evt as GraffitiLogoutEvent).detail;\n if (detail.error) {\n console.error(\"Error logging out:\");\n console.error(detail.error);\n } else {\n graffitiSession.value = null;\n }\n });\n\n app.provide(graffitiInjectKey, graffiti);\n app.provide(graffitiSessionInjectKey, graffitiSession);\n\n app.component(\"GraffitiDiscover\", Discover);\n app.component(\"GraffitiGet\", Get);\n app.component(\"GraffitiRecoverOrphans\", RecoverOrphans);\n app.config.globalProperties.$graffiti = graffiti;\n app.config.globalProperties.$graffitiSession = graffitiSession;\n },\n};\n\nexport * from \"./composables\";\nexport {\n useGraffiti,\n useGraffitiSynchronize,\n useGraffitiSession,\n} from \"./globals\";\n\n/**\n * The [Graffiti.discover](https://api.graffiti.garden/classes/Graffiti.html#discover)\n * method as a reactive [renderless component](https://vuejs.org/guide/components/slots#renderless-components)\n * for use in Vue templates.\n *\n * Its props and slots are identical to the arguments and return values of\n * the composable {@link useGraffitiDiscover}.\n */\nexport const GraffitiDiscover = Discover;\n/**\n * The [Graffiti.get](https://api.graffiti.garden/classes/Graffiti.html#get)\n * method as a reactive [renderless component](https://vuejs.org/guide/components/slots#renderless-components)\n * for use in Vue templates.\n *\n * Its props and slots are identical to the arguments and return values of\n * the composable {@link useGraffitiGet}.\n */\nexport const GraffitiGet = Get;\n/**\n * The [Graffiti.recoverOrphans](https://api.graffiti.garden/classes/Graffiti.html#recoverorphans)\n * method as a reactive [renderless component](https://vuejs.org/guide/components/slots#renderless-components)\n * for use in Vue templates.\n *\n * Its props and slots are identical to the arguments and return values of\n * the composable {@link useGraffitiRecoverOrphans}.\n */\nexport const GraffitiRecoverOrphans = RecoverOrphans;\n"],"names":["graffitiInjectKey","graffitiSessionInjectKey","useGraffitiSynchronize","graffiti","inject","useGraffiti","useGraffitiSession","session","s","t","e","GetPoller","getter","__publicField","onEntry","object","myGetter","StreamPoller","streamFactory","GraffitiErrorNotFound","myIterator","result","iterator","isEntryNewer","entry","existing","SingletonReducer","ref","computed","value","ArrayReducer","acc","makeComposable","reducer","poller","synchronizeFactory","toWatch","autopoll","synchronizeIterator","pollSynchronize","isAlreadyPolling","innerPoll","poll","myPoll","toValue","isInitialPolling","watch","newValue","oldValue","onScopeDispose","toSessionGetter","sessionInjected","sessionValue","callGetters","getters","fn","useGraffitiDiscover","channels","schema","channelsGetter","schemaGetter","sessionGetter","argGetters","useGraffitiGet","locationOrUri","locationOrUriGetter","useGraffitiRecoverOrphans","props","__props","objects","toRef","GraffitiPlugin","app","options","graffitiBase","GraffitiSynchronize","graffitiSession","evt","detail","router","base","url","Discover","Get","RecoverOrphans","GraffitiDiscover","GraffitiGet","GraffitiRecoverOrphans"],"mappings":";;;;;AAKO,MAAMA,IAAoB,OAAO,GAC3BC,IAA2B,OAAO;AASxC,SAASC,IAAyB;AACjC,QAAAC,IAAWC,EAAOJ,CAAiB;AACzC,MAAI,CAACG;AACH,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAEK,SAAAA;AACT;AAeO,SAASE,IAAwB;AACtC,SAAOH,EAAuB;AAChC;AAkBO,SAASI,IAAqB;AAC7B,QAAAC,IAAUH,EAAOH,CAAwB;AAC/C,MAAI,CAACM;AACH,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAEK,SAAAA;AACT;AClEkX,IAA8PC,IAAE,MAAMC,UAAU,MAAK;AAAA,EAAC,YAAYC,GAAE;AAAC,UAAMA,CAAC,GAAE,KAAK,OAAK,yBAAwB,OAAO,eAAe,MAAKD,EAAE,SAAS;AAAA,EAAC;AAAC;ACuBnuB,MAAME,EAA+D;AAAA,EAC1E,YAAqBC,GAA+C;AAEpE,IAAAC,EAAA,cAA+B,OAAOC,MAAY;AAC5C,UAAAC;AACJ,YAAMC,IAAW,KAAK;AAClB,UAAA;AACF,QAAAD,IAAS,MAAMC,EAAS;AAAA,cACd;AACN,QAAA,KAAK,WAAWA,KAClBF,EAAQ,IAAI;AAEd;AAAA,MAAA;AAEE,MAAA,KAAK,WAAWE,KACVF,EAAA,EAAE,QAAAC,GAAQ;AAAA,IAEtB;AAhBqB,SAAA,SAAAH;AAAA,EAAA;AAAA,EAkBrB,QAAQ;AAAA,EAAA;AACV;AAOO,MAAMK,EAAkE;AAAA,EAI7E,YAAqBC,GAAmD;AAHxE,IAAAL,EAAA;AACA,IAAAA,EAAA;AAgBA,IAAAA,EAAA,cAA+B,OAAOC,MAAY;AAC5C,UAAA,CAAC,KAAK;AACR,YAAI,KAAK;AACH,cAAA;AACG,iBAAA,WAAW,KAA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AAI,SAASA,EAAI,IAAI;AAAA,QAAA;AAAA,MAC3D;AAIE,MAACL,EAAgB,UACnBA,EAAgB,QAAQ;AAAA,IAC1B,CACD,GACDzE,EAAS,cAAc,iBAAiB,SAAS,CAAC0E,MAAQ;AACxD,YAAMC,IAAUD,EAA2B;AAC3C,UAAIC,EAAO,OAAO;AAChB,gBAAQ,MAAM,mBAAmB,GACzB,QAAA,MAAMA,EAAO,KAAK;AAC1B;AAAA,MAAA;AAEA,QAAAF,EAAgB,QAAQE,EAAO;AAAA,IACjC,CACD,GACD3E,EAAS,cAAc,iBAAiB,UAAU,CAAC0E,MAAQ;AACzD,YAAMC,IAAUD,EAA4B;AAC5C,MAAIC,EAAO,SACT,QAAQ,MAAM,oBAAoB,GAC1B,QAAA,MAAMA,EAAO,KAAK,KAE1BF,EAAgB,QAAQ;AAAA,IAC1B,CACD,GAEGJ,EAAA,QAAQxE,GAAmBG,CAAQ,GACnCqE,EAAA,QAAQvE,GAA0B2E,CAAe,GAEjDJ,EAAA,UAAU,oBAAoBU,CAAQ,GACtCV,EAAA,UAAU,eAAeW,CAAG,GAC5BX,EAAA,UAAU,0BAA0BY,CAAc,GAClDZ,EAAA,OAAO,iBAAiB,YAAYrE,GACpCqE,EAAA,OAAO,iBAAiB,mBAAmBI;AAAA,EAAA;AAEnD,GAiBaS,KAAmBH,GASnBI,KAAcH,GASdI,KAAyBH;","x_google_ignoreList":[1]}
|
|
1
|
+
{"version":3,"file":"plugin.mjs","sources":["../../src/globals.ts","../../node_modules/@graffiti-garden/api/dist/index.mjs","../../src/pollers.ts","../../src/reducers.ts","../../src/composables.ts","../../src/Discover.vue","../../src/Get.vue","../../src/RecoverOrphans.vue","../../src/plugin.ts"],"sourcesContent":["import type { Ref } from \"vue\";\nimport type { Graffiti, GraffitiSession } from \"@graffiti-garden/api\";\nimport type { GraffitiSynchronize } from \"@graffiti-garden/wrapper-synchronize\";\n\nexport const globals: {\n graffitiSynchronize?: GraffitiSynchronize;\n graffitiSession?: Ref<GraffitiSession | undefined | null>;\n} = {};\n\n/**\n * Returns the global [Graffiti](https://api.graffiti.garden/classes/Graffiti.html) instance\n * that has been wrapped by the {@link GraffitiPlugin} with the [GraffitiSynchronize](https://sync.graffiti.garden/classes/GraffitiSynchronize.html).\n * @throws If the {@link GraffitiPlugin} is not installed\n */\nexport function useGraffitiSynchronize() {\n const graffiti = globals.graffitiSynchronize;\n if (!graffiti) {\n throw new Error(\n \"No Graffiti instance provided, did you forget to install the plugin?\",\n );\n }\n return graffiti;\n}\n\n/**\n * Returns the global [Graffiti](https://api.graffiti.garden/classes/Graffiti.html) instance.\n *\n * In Vue templates and the [options API](https://vuejs.org/guide/introduction.html#options-api)\n * use the global variable {@link ComponentCustomProperties.$graffiti | $graffiti} instead.\n *\n * This is the same Graffiti registered with the {@link GraffitiPlugin}\n * via {@link GraffitiPluginOptions.graffiti}, only it has been wrapped\n * with [GraffitiSynchronize](https://sync.graffiti.garden/classes/GraffitiSynchronize.html).\n * Be sure to use the wrapped instance to enable reactivity.\n *\n * @throws If the {@link GraffitiPlugin} is not installed\n */\nexport function useGraffiti(): Graffiti {\n return useGraffitiSynchronize();\n}\n\n/**\n * Returns a global reactive [GraffitiSession](https://api.graffiti.garden/interfaces/GraffitiSession.html) instance\n * as a [Vue ref](https://vuejs.org/api/reactivity-core.html#ref).\n *\n * In Vue templates and the [options API](https://vuejs.org/guide/introduction.html#options-api)\n * use the global variable {@link ComponentCustomProperties.$graffitiSession | $graffitiSession} instead.\n *\n * While the application is loading and restoring any previous sessions,\n * the value will be `undefined`. If the user is not logged in,\n * the value will be `null`.\n *\n * This only keeps track of one session. If your app needs\n * to support multiple login sessions, you'll need to manage them\n * yourself using [`Graffiti.sessionEvents`](https://api.graffiti.garden/classes/Graffiti.html#sessionevents).\n * @throws If the {@link GraffitiPlugin} is not installed\n */\nexport function useGraffitiSession() {\n const session = globals.graffitiSession;\n if (!session) {\n throw new Error(\n \"No Graffiti session provided, did you forget to install the plugin?\",\n );\n }\n return session;\n}\n","var r=class{};var p={type:\"object\",properties:{value:{type:\"object\"},channels:{type:\"array\",items:{type:\"string\"}},allowed:{type:\"array\",items:{type:\"string\"},nullable:!0},url:{type:\"string\"},actor:{type:\"string\"},lastModified:{type:\"number\"}},additionalProperties:!1,required:[\"value\",\"channels\",\"actor\",\"url\",\"lastModified\"]},O={...p,required:[\"value\",\"channels\"]};var a=class t extends Error{constructor(e){super(e),this.name=\"GraffitiErrorUnauthorized\",Object.setPrototypeOf(this,t.prototype)}},i=class t extends Error{constructor(e){super(e),this.name=\"GraffitiErrorForbidden\",Object.setPrototypeOf(this,t.prototype)}},s=class t extends Error{constructor(e){super(e),this.name=\"GraffitiErrorNotFound\",Object.setPrototypeOf(this,t.prototype)}},o=class t extends Error{constructor(e){super(e),this.name=\"GraffitiErrorInvalidSchema\",Object.setPrototypeOf(this,t.prototype)}},n=class t extends Error{constructor(e){super(e),this.name=\"GraffitiErrorSchemaMismatch\",Object.setPrototypeOf(this,t.prototype)}},c=class t extends Error{constructor(e){super(e),this.name=\"GraffitiErrorPatchTestFailed\",Object.setPrototypeOf(this,t.prototype)}},f=class t extends Error{constructor(e){super(e),this.name=\"GraffitiErrorPatchError\",Object.setPrototypeOf(this,t.prototype)}},m=class t extends Error{constructor(e){super(e),this.name=\"GraffitiErrorInvalidUrl\",Object.setPrototypeOf(this,t.prototype)}},S=class t extends Error{constructor(e){super(e),this.name=\"GraffitiErrorUnrecognizedUriScheme\",Object.setPrototypeOf(this,t.prototype)}};export{r as Graffiti,i as GraffitiErrorForbidden,o as GraffitiErrorInvalidSchema,m as GraffitiErrorInvalidUrl,s as GraffitiErrorNotFound,f as GraffitiErrorPatchError,c as GraffitiErrorPatchTestFailed,n as GraffitiErrorSchemaMismatch,a as GraffitiErrorUnauthorized,S as GraffitiErrorUnrecognizedUrlScheme,p as GraffitiObjectJSONSchema,O as GraffitiPutObjectJSONSchema};\n//# sourceMappingURL=index.mjs.map\n","import {\n type Graffiti,\n type JSONSchema,\n type GraffitiObject,\n type GraffitiObjectStreamReturn,\n type GraffitiObjectStreamContinueEntry,\n type GraffitiObjectStream,\n type GraffitiObjectStreamContinue,\n GraffitiErrorNotFound,\n} from \"@graffiti-garden/api\";\n\nexport abstract class Poller<Schema extends JSONSchema> {\n abstract poll(\n onEntry: (\n entry: GraffitiObjectStreamContinueEntry<Schema> | null | \"clear\",\n ) => void,\n ): Promise<void>;\n abstract clear(): void;\n}\n\n/**\n * Polls for a single object and calls onValue with the result.\n */\nexport class GetPoller<Schema extends JSONSchema> implements Poller<Schema> {\n constructor(readonly getter: () => Promise<GraffitiObject<Schema>>) {}\n\n poll: Poller<Schema>[\"poll\"] = async (onEntry) => {\n let object: GraffitiObject<Schema>;\n const myGetter = this.getter;\n try {\n object = await myGetter();\n } catch (e) {\n if (this.getter === myGetter) {\n onEntry(null);\n }\n return;\n }\n if (this.getter === myGetter) {\n onEntry({ object });\n }\n };\n\n clear() {}\n}\n\n/**\n * Polls for multiple objects and calls `onObject` with the result.\n * If `poll` is called multiple times, it doesn't poll the results\n * entirely from scratch, but instead only polls the new results.\n */\nexport class StreamPoller<Schema extends JSONSchema> implements Poller<Schema> {\n iterator: GraffitiObjectStreamContinue<Schema> | undefined;\n continue: (() => GraffitiObjectStreamContinue<Schema>) | undefined;\n\n constructor(readonly streamFactory: () => GraffitiObjectStream<Schema>) {}\n\n clear() {\n if (this.iterator) {\n const iterator = this.iterator;\n this.iterator.return({\n continue: () => iterator,\n cursor: \"\",\n });\n }\n this.iterator = undefined;\n this.continue = undefined;\n }\n\n poll: Poller<Schema>[\"poll\"] = async (onEntry) => {\n if (!this.iterator) {\n if (this.continue) {\n try {\n this.iterator = this.continue();\n } catch (e) {\n // The cursor has expired, we need to start from scratch.\n if (e instanceof GraffitiErrorNotFound) {\n onEntry(\"clear\");\n this.iterator = this.streamFactory();\n } else {\n throw e;\n }\n }\n } else {\n this.iterator = this.streamFactory();\n }\n }\n\n while (true) {\n // Check if the iterator has been cancelled.\n if (!this.iterator) {\n break;\n }\n\n const myIterator: GraffitiObjectStreamContinue<Schema> = this.iterator;\n\n const result = await myIterator.next();\n\n // Check again if it was cancelled.\n if (myIterator !== this.iterator) {\n continue;\n }\n\n if (result.done) {\n if (result.value) {\n this.iterator = undefined;\n this.continue = result.value.continue;\n }\n break;\n }\n\n if (result.value.error) {\n console.error(result.value.error);\n continue;\n }\n\n onEntry(result.value);\n }\n };\n}\n","import { computed, ref } from \"vue\";\nimport type { Ref } from \"vue\";\nimport type {\n GraffitiObject,\n Graffiti,\n JSONSchema,\n GraffitiObjectStreamContinueEntry,\n} from \"@graffiti-garden/api\";\n\nexport abstract class Reducer<Schema extends JSONSchema> {\n abstract clear(): void;\n abstract onEntry(\n entry: GraffitiObjectStreamContinueEntry<Schema> | null | \"clear\",\n ): void;\n}\n\nfunction isEntryNewer<Schema extends JSONSchema>(\n entry: GraffitiObjectStreamContinueEntry<Schema>,\n existing: GraffitiObjectStreamContinueEntry<Schema> | null | undefined,\n): boolean {\n return (\n !existing ||\n entry.object.lastModified > existing.object.lastModified ||\n (entry.object.lastModified === existing.object.lastModified &&\n !entry.tombstone &&\n !!existing.tombstone)\n );\n}\n\n/**\n * Retrieves multiple Graffiti objects and retains\n * the most recent one as the `result` property (a Vue ref).\n * Before any objects have been received, the result\n * is `undefined`. If the object has been deleted,\n * the result is `null`.\n */\nexport class SingletonReducer<Schema extends JSONSchema>\n implements Reducer<Schema>\n{\n readonly entry: Ref<\n GraffitiObjectStreamContinueEntry<Schema> | null | undefined\n > = ref();\n\n get result(): Ref<GraffitiObject<Schema> | null | undefined> {\n return computed(() => {\n const value = this.entry.value;\n if (!value) return value;\n if (value.tombstone) return null;\n return value.object;\n });\n }\n\n clear() {\n this.entry.value = undefined;\n }\n\n onEntry(entry: GraffitiObjectStreamContinueEntry<Schema> | null | \"clear\") {\n if (entry === \"clear\") {\n this.clear();\n return;\n }\n if (!entry || isEntryNewer<Schema>(entry, this.entry.value)) {\n this.entry.value = entry;\n }\n }\n}\n\n/**\n * Retrieves multiple Graffiti objects and retains\n * the most recent one per URI as the `results` property (a Vue ref).\n * If multiple objects are received concurrently,\n * they are processed in batches every `REFRESH_RATE` milliseconds\n * to avoid freezing the interface.\n */\nexport class ArrayReducer<Schema extends JSONSchema>\n implements Reducer<Schema>\n{\n readonly results: Ref<GraffitiObject<Schema>[]> = ref([]);\n readonly resultsRaw: Map<string, GraffitiObjectStreamContinueEntry<Schema>> =\n new Map();\n batchFlattenTimer: ReturnType<typeof setTimeout> | undefined;\n\n constructor(readonly graffiti: Graffiti) {}\n\n clear() {\n this.resultsRaw.clear();\n this.results.value = [];\n clearTimeout(this.batchFlattenTimer);\n this.batchFlattenTimer = undefined;\n }\n\n flattenResults() {\n this.results.value = Array.from(this.resultsRaw.values()).reduce<\n GraffitiObject<Schema>[]\n >((acc, entry) => {\n if (!entry.tombstone) {\n acc.push(entry.object);\n }\n return acc;\n }, []);\n }\n\n onEntry(entry: GraffitiObjectStreamContinueEntry<Schema> | null | \"clear\") {\n if (!entry) return;\n if (entry === \"clear\") {\n this.clear();\n return;\n }\n const existing = this.resultsRaw.get(entry.object.url);\n if (!isEntryNewer<Schema>(entry, existing)) return;\n this.resultsRaw.set(entry.object.url, entry);\n\n // Don't flatten the results all at once,\n // because we may get a lot of results\n // and we don't want the interface to\n // freeze up\n if (!this.batchFlattenTimer) {\n this.batchFlattenTimer = setTimeout(() => {\n this.flattenResults();\n this.batchFlattenTimer = undefined;\n }, 0);\n }\n }\n}\n","import { onScopeDispose, ref, toValue, watch } from \"vue\";\nimport type { Ref, MaybeRefOrGetter } from \"vue\";\nimport type {\n GraffitiObjectUrl,\n GraffitiObject,\n GraffitiSession,\n JSONSchema,\n GraffitiObjectStreamContinueEntry,\n} from \"@graffiti-garden/api\";\nimport { useGraffitiSynchronize, useGraffitiSession } from \"./globals\";\nimport { GetPoller, Poller, StreamPoller } from \"./pollers\";\nimport { ArrayReducer, Reducer, SingletonReducer } from \"./reducers\";\n\nfunction makeComposable<Schema extends JSONSchema>(\n reducer: Reducer<Schema>,\n poller: Poller<Schema>,\n synchronizeFactory: () => AsyncGenerator<\n GraffitiObjectStreamContinueEntry<Schema>\n >,\n toWatch: readonly (() => any)[],\n autopoll: MaybeRefOrGetter<boolean>,\n) {\n let synchronizeIterator:\n | AsyncGenerator<GraffitiObjectStreamContinueEntry<Schema>>\n | undefined;\n async function pollSynchronize() {\n synchronizeIterator = synchronizeFactory();\n for await (const result of synchronizeIterator) {\n if (result.error) {\n console.error(result.error);\n continue;\n }\n reducer.onEntry(result);\n }\n }\n\n let isAlreadyPolling = false;\n let innerPoll: (() => Promise<void>) | undefined;\n const poll = async () => {\n if (isAlreadyPolling) return;\n if (!innerPoll) return;\n const myPoll = innerPoll;\n isAlreadyPolling = true;\n try {\n await myPoll();\n } finally {\n if (myPoll !== innerPoll) return;\n isAlreadyPolling = false;\n if (toValue(autopoll)) {\n poll();\n }\n }\n };\n\n const isInitialPolling = ref(false);\n watch(\n toWatch,\n async (newValue, oldValue) => {\n // Catch unnecessary updates\n if (JSON.stringify(newValue) === JSON.stringify(oldValue)) {\n return;\n }\n\n synchronizeIterator?.return(null);\n reducer.clear();\n poller.clear();\n\n pollSynchronize();\n\n innerPoll = () => poller.poll(reducer.onEntry.bind(reducer));\n const myPoll = innerPoll;\n\n isAlreadyPolling = false;\n\n isInitialPolling.value = true;\n try {\n await poll();\n } finally {\n if (myPoll !== innerPoll) return;\n isInitialPolling.value = false;\n }\n },\n {\n immediate: true,\n },\n );\n onScopeDispose(() => {\n synchronizeIterator?.return(null);\n reducer.clear();\n poller.clear();\n innerPoll = undefined;\n });\n\n return { poll, isInitialPolling };\n}\n\nfunction toSessionGetter(\n sessionInjected: ReturnType<typeof useGraffitiSession>,\n session?: MaybeRefOrGetter<GraffitiSession | undefined | null>,\n) {\n return () => {\n const sessionValue = toValue(session);\n if (sessionValue === undefined) {\n return sessionInjected?.value;\n } else {\n return sessionValue;\n }\n };\n}\n\nfunction callGetters<T extends readonly (() => any)[]>(\n getters: T,\n): {\n [K in keyof T]: ReturnType<T[K]>;\n} {\n return getters.map((fn) => fn()) as any;\n}\n\n/**\n * The [Graffiti.discover](https://api.graffiti.garden/classes/Graffiti.html#discover)\n * method as a reactive [composable](https://vuejs.org/guide/reusability/composables.html)\n * for use in the Vue [composition API](https://vuejs.org/guide/introduction.html#composition-api).\n *\n * Its corresponding renderless component is {@link GraffitiDiscover}.\n *\n * The arguments of this composable as the same as Graffiti.discover,\n * only they can also be [Refs](https://vuejs.org/api/reactivity-core.html#ref)\n * or [getters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get#description).\n * As they change the output will automatically update.\n * Reactivity only triggers when the root array or object changes,\n * not when the elements or properties change.\n * If you need deep reactivity, wrap your argument in a getter.\n */\nexport function useGraffitiDiscover<Schema extends JSONSchema>(\n channels: MaybeRefOrGetter<string[]>,\n schema: MaybeRefOrGetter<Schema>,\n /**\n * If the session is `undefined`, the global session,\n * {@link ComponentCustomProperties.$graffitiSession | $graffitiSession},\n * will be used. Otherwise, the provided value will be used.\n */\n session?: MaybeRefOrGetter<GraffitiSession | undefined | null>,\n autopoll: MaybeRefOrGetter<boolean> = false,\n): {\n objects: Ref<GraffitiObject<Schema>[]>;\n poll: () => Promise<void>;\n isInitialPolling: Ref<boolean>;\n} {\n const graffiti = useGraffitiSynchronize();\n const sessionInjected = useGraffitiSession();\n\n const channelsGetter = () => toValue(channels);\n const schemaGetter = () => toValue(schema);\n const sessionGetter = toSessionGetter(sessionInjected, session);\n const argGetters = [channelsGetter, schemaGetter, sessionGetter] as const;\n\n const synchronizeFactory = () =>\n graffiti.synchronizeDiscover(...callGetters(argGetters));\n const streamFactory = () => graffiti.discover(...callGetters(argGetters));\n\n const reducer = new ArrayReducer<Schema>(graffiti);\n const poller = new StreamPoller<Schema>(streamFactory);\n\n const { poll, isInitialPolling } = makeComposable<Schema>(\n reducer,\n poller,\n synchronizeFactory,\n argGetters,\n autopoll,\n );\n\n return {\n /**\n * A [ref](https://vuejs.org/api/reactivity-core.html#ref) that contains\n * an array of Graffiti objects.\n */\n objects: reducer.results,\n /**\n * A method to poll for new results.\n */\n poll,\n /**\n * A boolean [ref](https://vuejs.org/api/reactivity-core.html#ref)\n * that indicates if the *first* poll is currently running.\n * Useful to show a loading spinner or disable a button.\n *\n * This also tracks new polls when the arguments have changed,\n * but it does not track ongoing polls from either calling\n * {@link poll} or using the `autopoll` argument.\n */\n isInitialPolling,\n };\n}\n\n/**\n * The [Graffiti.get](https://api.graffiti.garden/classes/Graffiti.html#get)\n * method as a reactive [composable](https://vuejs.org/guide/reusability/composables.html)\n * for use in the Vue [composition API](https://vuejs.org/guide/introduction.html#composition-api).\n *\n * Its corresponding renderless component is {@link GraffitiGet}.\n *\n * The arguments of this composable as the same as Graffiti.get,\n * only they can also be [Refs](https://vuejs.org/api/reactivity-core.html#ref)\n * or [getters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get#description).\n * As they change the output will automatically update.\n * Reactivity only triggers when the root array or object changes,\n * not when the elements or properties change.\n * If you need deep reactivity, wrap your argument in a getter.\n */\nexport function useGraffitiGet<Schema extends JSONSchema>(\n locationOrUri: MaybeRefOrGetter<GraffitiObjectUrl | string>,\n schema: MaybeRefOrGetter<Schema>,\n /**\n * If the session is `undefined`, the global session,\n * {@link ComponentCustomProperties.$graffitiSession | $graffitiSession},\n * will be used. Otherwise, the provided value will be used.\n */\n session?: MaybeRefOrGetter<GraffitiSession | undefined | null>,\n autopoll: MaybeRefOrGetter<boolean> = false,\n): {\n object: Ref<GraffitiObject<Schema> | null | undefined>;\n poll: () => Promise<void>;\n isInitialPolling: Ref<boolean>;\n} {\n const graffiti = useGraffitiSynchronize();\n const sessionInjected = useGraffitiSession();\n\n const locationOrUriGetter = () => toValue(locationOrUri);\n const schemaGetter = () => toValue(schema);\n const sessionGetter = toSessionGetter(sessionInjected, session);\n const argGetters = [\n locationOrUriGetter,\n schemaGetter,\n sessionGetter,\n ] as const;\n\n const synchronizeFactory = () =>\n graffiti.synchronizeGet(...callGetters(argGetters));\n\n const reducer = new SingletonReducer<Schema>();\n const getter = () => graffiti.get<Schema>(...callGetters(argGetters));\n const poller = new GetPoller<Schema>(getter);\n\n const { poll, isInitialPolling } = makeComposable<Schema>(\n reducer,\n poller,\n synchronizeFactory,\n argGetters,\n autopoll,\n );\n\n return {\n /**\n * A [ref](https://vuejs.org/api/reactivity-core.html#ref) that contains\n * the retrieved Graffiti object, if it exists. If the object has been deleted,\n * the result is `null`. If the object is still being fetched, the result is `undefined`.\n */\n object: reducer.result,\n /**\n * A method to poll for new results.\n */\n poll,\n /**\n * A boolean [ref](https://vuejs.org/api/reactivity-core.html#ref)\n * that indicates if the *first* poll is currently running.\n * Useful to show a loading spinner or disable a button.\n *\n * This also tracks new polls when the arguments have changed,\n * but it does not track ongoing polls from either calling\n * {@link poll} or using the `autopoll` argument.\n */\n isInitialPolling,\n };\n}\n\n/**\n * The [Graffiti.recoverOrphans](https://api.graffiti.garden/classes/Graffiti.html#recoverorphans)\n * method as a reactive [composable](https://vuejs.org/guide/reusability/composables.html)\n * for use in the Vue [composition API](https://vuejs.org/guide/introduction.html#composition-api).\n *\n * Its corresponding renderless component is {@link GraffitiRecoverOrphans}.\n *\n * The arguments of this composable as the same as Graffiti.get,\n * only they can also be [Refs](https://vuejs.org/api/reactivity-core.html#ref)\n * or [getters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get#description).\n * As they change the output will automatically update.\n * Reactivity only triggers when the root array or object changes,\n * not when the elements or properties change.\n * If you need deep reactivity, wrap your argument in a getter.\n */\nexport function useGraffitiRecoverOrphans<Schema extends JSONSchema>(\n schema: MaybeRefOrGetter<Schema>,\n session: MaybeRefOrGetter<GraffitiSession>,\n autopoll: MaybeRefOrGetter<boolean> = false,\n): {\n objects: Ref<GraffitiObject<Schema>[]>;\n poll: () => Promise<void>;\n isInitialPolling: Ref<boolean>;\n} {\n const graffiti = useGraffitiSynchronize();\n\n const schemaGetter = () => toValue(schema);\n const sessionGetter = () => toValue(session);\n const argGetters = [schemaGetter, sessionGetter] as const;\n\n const synchronizeFactory = () =>\n graffiti.synchronizeRecoverOrphans(...callGetters(argGetters));\n\n const reducer = new ArrayReducer<Schema>(graffiti);\n const streamFactory = () =>\n graffiti.recoverOrphans<Schema>(...callGetters(argGetters));\n const poller = new StreamPoller<Schema>(streamFactory);\n\n const { poll, isInitialPolling } = makeComposable<Schema>(\n reducer,\n poller,\n synchronizeFactory,\n argGetters,\n autopoll,\n );\n\n return {\n /**\n * A [ref](https://vuejs.org/api/reactivity-core.html#ref) that contains\n * an array of Graffiti objects.\n */\n objects: reducer.results,\n /**\n * A method to poll for new results.\n */\n poll,\n /**\n * A boolean [ref](https://vuejs.org/api/reactivity-core.html#ref)\n * that indicates if the *first* poll is currently running.\n * Useful to show a loading spinner or disable a button.\n *\n * This also tracks new polls when the arguments have changed,\n * but it does not track ongoing polls from either calling\n * {@link poll} or using the `autopoll` argument.\n */\n isInitialPolling,\n };\n}\n","<script setup lang=\"ts\" generic=\"Schema extends JSONSchema\">\nimport { toRef } from \"vue\";\nimport type {\n GraffitiSession,\n JSONSchema,\n GraffitiObject,\n} from \"@graffiti-garden/api\";\nimport { useGraffitiDiscover } from \"./composables\";\n\nconst props = defineProps<{\n channels: string[];\n schema: Schema;\n session?: GraffitiSession | null;\n autopoll?: boolean;\n}>();\n\ndefineSlots<{\n default?(props: {\n objects: GraffitiObject<Schema>[];\n poll: () => void;\n isInitialPolling: boolean;\n }): any;\n}>();\n\nconst { objects, poll, isInitialPolling } = useGraffitiDiscover<Schema>(\n toRef(props, \"channels\"),\n toRef(props, \"schema\"),\n toRef(props, \"session\"),\n toRef(props, \"autopoll\"),\n);\n</script>\n\n<template>\n <slot\n :objects=\"objects\"\n :poll=\"poll\"\n :isInitialPolling=\"isInitialPolling\"\n ></slot>\n</template>\n","<script setup lang=\"ts\" generic=\"Schema extends JSONSchema\">\nimport { toRef } from \"vue\";\nimport type {\n GraffitiObjectUrl,\n GraffitiObject,\n GraffitiSession,\n JSONSchema,\n} from \"@graffiti-garden/api\";\nimport { useGraffitiGet } from \"./composables\";\n\nconst props = defineProps<{\n url: string | GraffitiObjectUrl;\n schema: Schema;\n session?: GraffitiSession | null;\n autopoll?: boolean;\n}>();\n\ndefineSlots<{\n default?(props: {\n object: GraffitiObject<Schema> | undefined | null;\n poll: () => void;\n isInitialPolling: boolean;\n }): any;\n}>();\n\nconst { object, poll, isInitialPolling } = useGraffitiGet<Schema>(\n toRef(props, \"url\"),\n toRef(props, \"schema\"),\n toRef(props, \"session\"),\n toRef(props, \"autopoll\"),\n);\n</script>\n\n<template>\n <slot\n :object=\"object\"\n :poll=\"poll\"\n :isInitialPolling=\"isInitialPolling\"\n ></slot>\n</template>\n","<script setup lang=\"ts\" generic=\"Schema extends JSONSchema\">\nimport { toRef } from \"vue\";\nimport type {\n GraffitiSession,\n JSONSchema,\n GraffitiObject,\n} from \"@graffiti-garden/api\";\nimport { useGraffitiRecoverOrphans } from \"./composables\";\n\nconst props = defineProps<{\n schema: Schema;\n session: GraffitiSession;\n autopoll?: boolean;\n}>();\n\ndefineSlots<{\n default?(props: {\n objects: GraffitiObject<Schema>[];\n poll: () => void;\n isInitialPolling: boolean;\n }): any;\n}>();\n\nconst { objects, poll, isInitialPolling } = useGraffitiRecoverOrphans<Schema>(\n toRef(props, \"schema\"),\n toRef(props, \"session\"),\n toRef(props, \"autopoll\"),\n);\n</script>\n\n<template>\n <slot\n :objects=\"objects\"\n :poll=\"poll\"\n :isInitialPolling=\"isInitialPolling\"\n ></slot>\n</template>\n","import type { App, Plugin, Ref } from \"vue\";\nimport { ref } from \"vue\";\nimport Discover from \"./Discover.vue\";\nimport Get from \"./Get.vue\";\nimport RecoverOrphans from \"./RecoverOrphans.vue\";\nimport type {\n Graffiti,\n GraffitiSession,\n GraffitiLoginEvent,\n GraffitiLogoutEvent,\n GraffitiSessionInitializedEvent,\n} from \"@graffiti-garden/api\";\nimport { globals } from \"./globals\";\nimport type { Router } from \"vue-router\";\nimport { GraffitiSynchronize } from \"@graffiti-garden/wrapper-synchronize\";\n\ndeclare module \"vue\" {\n export interface ComponentCustomProperties {\n /**\n * Global [Graffiti](https://api.graffiti.garden/classes/Graffiti.html) instance.\n *\n * In the [composition API](https://vuejs.org/guide/introduction.html#composition-api)\n * use {@link useGraffiti} instead.\n *\n * This is the same Graffiti registered with the {@link GraffitiPlugin}\n * via {@link GraffitiPluginOptions.graffiti}, only it has been wrapped\n * with [GraffitiSynchronize](https://sync.graffiti.garden/classes/GraffitiSynchronize.html).\n * Be sure to use the wrapped instance to enable reactivity.\n */\n $graffiti: Graffiti;\n /**\n * Global reactive [GraffitiSession](https://api.graffiti.garden/classes/GraffitiSession.html) instance\n * as a [Vue ref](https://vuejs.org/api/reactivity-core.html#ref).\n *\n * In the [composition API](https://vuejs.org/guide/introduction.html#composition-api)\n * use {@link useGraffitiSession} instead.\n *\n * While the application is loading and restoring any previous sessions,\n * the value will be `undefined`. If the user is not logged in,\n * the value will be `null`.\n *\n * This only keeps track of one session. If your app needs\n * to support multiple login sessions, you'll need to manage them\n * yourself using [`Graffiti.sessionEvents`](https://api.graffiti.garden/classes/Graffiti.html#sessionevents).\n */\n $graffitiSession: Ref<GraffitiSession | undefined | null>;\n }\n\n export interface GlobalComponents {\n GraffitiDiscover: typeof Discover;\n GraffitiGet: typeof Get;\n GraffitiRecoverOrphans: typeof RecoverOrphans;\n }\n}\nexport type { ComponentCustomProperties } from \"vue\";\n\n/**\n * Options for the {@link GraffitiPlugin}.\n */\nexport interface GraffitiPluginOptions {\n /**\n * An instance of the [Graffiti API](https://api.graffiti.garden/classes/Graffiti.html)\n * for the Vue.js plugin to use.\n * This instance, wrapped with [GraffitiSynchronize](https://sync.graffiti.garden/classes/GraffitiSynchronize.html),\n * will be exposed in Vue templates as {@link ComponentCustomProperties.$graffiti | $graffiti}\n * and in setup functions as {@link useGraffiti}.\n * You must interact with Graffiti through these wrapped instances\n * to enable reactivity.\n *\n * You'll likely want to use the [federated implementation](https://github.com/graffiti-garden/implementation-federated).\n * However, you could also use the [local implementation](https://github.com/graffiti-garden/implementation-local)\n * for testing. Other implementations may be available in the future.\n */\n graffiti: Graffiti;\n}\n\n/**\n * A [Vue.js](https://vuejs.org/) plugin that wraps around\n * the [Graffiti API](https://api.graffiti.garden/classes/Graffiti.html)\n * to provide [reactive](https://en.wikipedia.org/wiki/Reactive_programming) versions\n * of various Graffiti API methods.\n *\n * These reactive methods are available as both\n * [renderless components](https://vuejs.org/guide/components/slots#renderless-components),\n * which make it possible to create a whole Graffiti app in an HTML template,\n * and [composables](https://vuejs.org/guide/reusability/composables.html),\n * which can be used in the programmatic [composition API](https://vuejs.org/guide/introduction.html#composition-api).\n *\n * | [API](https://api.graffiti.garden/classes/Graffiti.html) method | [Composable](https://vuejs.org/guide/reusability/composables.html) | [Component](https://vuejs.org/guide/components/slots#renderless-components) |\n * | --- | --- | --- |\n * | [discover](https://api.graffiti.garden/classes/Graffiti.html#discover) | {@link useGraffitiDiscover} | {@link GraffitiDiscover} |\n * | [get](https://api.graffiti.garden/classes/Graffiti.html#get) | {@link useGraffitiGet} | {@link GraffitiGet} |\n * | [recoverOrphans](https://api.graffiti.garden/classes/Graffiti.html#recoverorphans) | {@link useGraffitiRecoverOrphans} | {@link GraffitiRecoverOrphans} |\n *\n * The plugin also exposes a global [Graffiti](https://api.graffiti.garden/classes/Graffiti.html) instance\n * and keeps track of the global [GraffitiSession](https://api.graffiti.garden/interfaces/GraffitiSession.html)\n * state as a reactive variable.\n * They are available in templates as global variables or in setup functions as\n * composable functions.\n *\n * | Global variabale | [Composable](https://vuejs.org/guide/reusability/composables.html) |\n * | --- | --- |\n * | {@link ComponentCustomProperties.$graffiti | $graffiti } | {@link useGraffiti} |\n * | {@link ComponentCustomProperties.$graffitiSession | $graffitiSession } | {@link useGraffitiSession} |\n *\n * [See the README for installation instructions](/).\n *\n * You can [try out live examples](/examples/), but basic usage looks like this:\n *\n * ```ts\n * import { createApp } from \"vue\";\n * import { GraffitiPlugin } from \"@graffiti-garden/vue\";\n * import { GraffitiLocal } from \"@graffiti-garden/implementation-local\";\n * import App from \"./App.vue\";\n *\n * createApp(App)\n * .use(GraffitiPlugin, {\n * graffiti: new GraffitiLocal(),\n * })\n * ```\n *\n * ```vue\n * <!-- App.vue -->\n * <template>\n * <button\n * v-if=\"$graffitiSession.value\"\n * @click=\"$graffiti.put({\n * value: { content: 'Hello, world!' },\n * channels: [ 'my-channel' ]\n * }, $graffitiSession.value)\"\n * >\n * Say Hello\n * </button>\n * <button v-else @click=\"$graffiti.login()\">\n * Log In to Say Hello\n * </button>\n *\n * <GraffitiDiscover\n * v-slot=\"{ results }\"\n * :channels=\"[ 'my-channel' ]\"\n * :schema=\"{\n * properties: {\n * value: {\n * required: ['content'],\n * properties: {\n * content: { type: 'string' }\n * }\n * }\n * }\n * }\"\n * >\n * <ul>\n * <li\n * v-for=\"result in results\"\n * :key=\"$graffiti.objectToUri(result)\"\n * >\n * {{ result.value.content }}\n * </li>\n * </ul>\n * </GraffitiDiscover>\n * </template>\n * ```\n */\nexport const GraffitiPlugin: Plugin<GraffitiPluginOptions> = {\n install(app: App, options: GraffitiPluginOptions) {\n const graffitiBase = options.graffiti;\n const graffiti = new GraffitiSynchronize(graffitiBase);\n\n const graffitiSession = ref<GraffitiSession | undefined | null>(undefined);\n graffiti.sessionEvents.addEventListener(\"initialized\", async (evt) => {\n const detail = (evt as GraffitiSessionInitializedEvent).detail;\n\n if (detail && detail.error) {\n console.error(detail.error);\n }\n\n if (detail && detail.href) {\n // If we're using Vue Router, redirect to the URL after login\n const router = app.config.globalProperties.$router as\n | Router\n | undefined;\n if (router) {\n const base = router.options.history.base;\n const url = new URL(detail.href);\n if (url.pathname.startsWith(base)) {\n url.pathname = url.pathname.slice(base.length);\n }\n await router.replace(url.pathname + url.search + url.hash);\n }\n }\n\n // Set the session to \"null\" if the user is not logged in\n if (!graffitiSession.value) {\n graffitiSession.value = null;\n }\n });\n graffiti.sessionEvents.addEventListener(\"login\", (evt) => {\n const detail = (evt as GraffitiLoginEvent).detail;\n if (detail.error) {\n console.error(\"Error logging in:\");\n console.error(detail.error);\n return;\n } else {\n graffitiSession.value = detail.session;\n }\n });\n graffiti.sessionEvents.addEventListener(\"logout\", (evt) => {\n const detail = (evt as GraffitiLogoutEvent).detail;\n if (detail.error) {\n console.error(\"Error logging out:\");\n console.error(detail.error);\n } else {\n graffitiSession.value = null;\n }\n });\n\n globals.graffitiSynchronize = graffiti;\n globals.graffitiSession = graffitiSession;\n\n app.component(\"GraffitiDiscover\", Discover);\n app.component(\"GraffitiGet\", Get);\n app.component(\"GraffitiRecoverOrphans\", RecoverOrphans);\n app.config.globalProperties.$graffiti = graffiti;\n app.config.globalProperties.$graffitiSession = graffitiSession;\n },\n};\n\nexport * from \"./composables\";\nexport {\n useGraffiti,\n useGraffitiSynchronize,\n useGraffitiSession,\n} from \"./globals\";\n\n/**\n * The [Graffiti.discover](https://api.graffiti.garden/classes/Graffiti.html#discover)\n * method as a reactive [renderless component](https://vuejs.org/guide/components/slots#renderless-components)\n * for use in Vue templates.\n *\n * Its props and slots are identical to the arguments and return values of\n * the composable {@link useGraffitiDiscover}.\n */\nexport const GraffitiDiscover = Discover;\n/**\n * The [Graffiti.get](https://api.graffiti.garden/classes/Graffiti.html#get)\n * method as a reactive [renderless component](https://vuejs.org/guide/components/slots#renderless-components)\n * for use in Vue templates.\n *\n * Its props and slots are identical to the arguments and return values of\n * the composable {@link useGraffitiGet}.\n */\nexport const GraffitiGet = Get;\n/**\n * The [Graffiti.recoverOrphans](https://api.graffiti.garden/classes/Graffiti.html#recoverorphans)\n * method as a reactive [renderless component](https://vuejs.org/guide/components/slots#renderless-components)\n * for use in Vue templates.\n *\n * Its props and slots are identical to the arguments and return values of\n * the composable {@link useGraffitiRecoverOrphans}.\n */\nexport const GraffitiRecoverOrphans = RecoverOrphans;\n"],"names":["globals","useGraffitiSynchronize","graffiti","useGraffiti","useGraffitiSession","session","s","t","e","GetPoller","getter","__publicField","onEntry","object","myGetter","StreamPoller","streamFactory","GraffitiErrorNotFound","myIterator","result","iterator","isEntryNewer","entry","existing","SingletonReducer","ref","computed","value","ArrayReducer","acc","makeComposable","reducer","poller","synchronizeFactory","toWatch","autopoll","synchronizeIterator","pollSynchronize","isAlreadyPolling","innerPoll","poll","myPoll","toValue","isInitialPolling","watch","newValue","oldValue","onScopeDispose","toSessionGetter","sessionInjected","sessionValue","callGetters","getters","fn","useGraffitiDiscover","channels","schema","channelsGetter","schemaGetter","sessionGetter","argGetters","useGraffitiGet","locationOrUri","locationOrUriGetter","useGraffitiRecoverOrphans","props","__props","objects","toRef","GraffitiPlugin","app","options","graffitiBase","GraffitiSynchronize","graffitiSession","evt","detail","router","base","url","Discover","Get","RecoverOrphans","GraffitiDiscover","GraffitiGet","GraffitiRecoverOrphans"],"mappings":";;;;;AAIO,MAAMA,IAGT,CAAC;AAOE,SAASC,IAAyB;AACvC,QAAMC,IAAWF,EAAQ;AACzB,MAAI,CAACE;AACH,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAEK,SAAAA;AACT;AAeO,SAASC,IAAwB;AACtC,SAAOF,EAAuB;AAChC;AAkBO,SAASG,IAAqB;AACnC,QAAMC,IAAUL,EAAQ;AACxB,MAAI,CAACK;AACH,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAEK,SAAAA;AACT;ACjEkX,IAA8PC,IAAE,MAAMC,UAAU,MAAK;AAAA,EAAC,YAAYC,GAAE;AAAC,UAAMA,CAAC,GAAE,KAAK,OAAK,yBAAwB,OAAO,eAAe,MAAKD,EAAE,SAAS;AAAA,EAAC;AAAC;ACuBnuB,MAAME,EAA+D;AAAA,EAC1E,YAAqBC,GAA+C;AAEpE,IAAAC,EAAA,cAA+B,OAAOC,MAAY;AAC5C,UAAAC;AACJ,YAAMC,IAAW,KAAK;AAClB,UAAA;AACF,QAAAD,IAAS,MAAMC,EAAS;AAAA,cACd;AACN,QAAA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;","x_google_ignoreList":[1]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graffiti-garden/wrapper-vue",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "Vue.js wrapper for the Graffiti API",
|
|
5
5
|
"types": "./dist/node/plugin.d.ts",
|
|
6
6
|
"module": "./dist/node/plugin.mjs",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"README.md"
|
|
26
26
|
],
|
|
27
27
|
"scripts": {
|
|
28
|
-
"example": "cd examples/
|
|
29
|
-
"build:example": "cd examples/
|
|
28
|
+
"example": "cd examples/sfc && vite",
|
|
29
|
+
"build:example": "cd examples/sfc && vite build",
|
|
30
30
|
"build:js:node": "vite build --config vite.config.node.mts",
|
|
31
31
|
"build:js:browser": "vite build --config vite.config.browser.mts",
|
|
32
32
|
"build:js": "npm run build:js:node && npm run build:js:browser",
|