@graffiti-garden/wrapper-vue 0.6.5 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,17 +11,13 @@ declare const _default: <Schema extends JSONSchema>(__VLS_props: NonNullable<Awa
11
11
  slots: Readonly<{
12
12
  default?(props: {
13
13
  objects: GraffitiObject<Schema>[];
14
- results: GraffitiObject<Schema>[];
15
14
  poll: () => void;
16
- isPolling: boolean;
17
15
  isInitialPolling: boolean;
18
16
  }): any;
19
17
  }> & {
20
18
  default?(props: {
21
19
  objects: GraffitiObject<Schema>[];
22
- results: GraffitiObject<Schema>[];
23
20
  poll: () => void;
24
- isPolling: boolean;
25
21
  isInitialPolling: boolean;
26
22
  }): any;
27
23
  };
@@ -1 +1 @@
1
- {"version":3,"file":"Discover.vue.d.ts","sourceRoot":"","sources":["../../src/Discover.vue"],"names":[],"mappings":"AA+CA,OAAO,KAAK,EACR,eAAe,EACf,UAAU,EACV,cAAc,EACjB,MAAM,sBAAsB,CAAC;yBAGb,MAAM,SAAS,UAAU,eAC5B,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,cAClD,mBAAmB,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,iBAC5F,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC;WA4E1D,mBAAmB,CAAC;kBAzEd,MAAM,EAAE;gBACV,MAAM;kBACJ,eAAe,GAAG,IAAI;mBACrB,OAAO;mBAsEwE,CAAC,4BAA2B;oBACzG,OAAO,KAAK,EAAE,gBAAgB,CAAC,EAAE,CAAC,GAAG,IAAI;WAClD,GAAG;;wBAnES;YACZ,OAAO,EAAE,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC;YAClC,OAAO,EAAE,cAA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,KAAK,EAAE,gBAAgB,CAAC,EAAE,CAAC,GAAG,IAAI;WAClD,GAAG;;wBA5DS;YACZ,OAAO,EAAE,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC;YAClC,IAAI,EAAE,MAAM,IAAI,CAAC;YACjB,gBAAgB,EAAE,OAAO,CAAC;SAC7B,GAAG,GAAG;;wBAJS;YACZ,OAAO,EAAE,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC;YAClC,IAAI,EAAE,MAAM,IAAI,CAAC;YACjB,gBAAgB,EAAE,OAAO,CAAC;SAC7B,GAAG,GAAG;;UA0DJ,EAAE;OAGG,OAAO,KAAK,EAAE,KAAK,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC,OAAO,WAAW,CAAC,CAAA;CAAE;AA/EzE,wBA+E4E;AAC5E,KAAK,mBAAmB,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC"}
@@ -11,17 +11,13 @@ declare const _default: <Schema extends JSONSchema>(__VLS_props: NonNullable<Awa
11
11
  slots: Readonly<{
12
12
  default?(props: {
13
13
  object: GraffitiObject<Schema> | undefined | null;
14
- result: GraffitiObject<Schema> | undefined | null;
15
14
  poll: () => void;
16
- isPolling: boolean;
17
15
  isInitialPolling: boolean;
18
16
  }): any;
19
17
  }> & {
20
18
  default?(props: {
21
19
  object: GraffitiObject<Schema> | undefined | null;
22
- result: GraffitiObject<Schema> | undefined | null;
23
20
  poll: () => void;
24
- isPolling: boolean;
25
21
  isInitialPolling: boolean;
26
22
  }): any;
27
23
  };
@@ -1 +1 @@
1
- {"version":3,"file":"Get.vue.d.ts","sourceRoot":"","sources":["../../src/Get.vue"],"names":[],"mappings":"AAgDA,OAAO,KAAK,EACR,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,UAAU,EACb,MAAM,sBAAsB,CAAC;yBAGb,MAAM,SAAS,UAAU,eAC5B,WAAW,CA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IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC"}
@@ -10,17 +10,13 @@ declare const _default: <Schema extends JSONSchema>(__VLS_props: NonNullable<Awa
10
10
  slots: Readonly<{
11
11
  default?(props: {
12
12
  objects: GraffitiObject<Schema>[];
13
- results: GraffitiObject<Schema>[];
14
13
  poll: () => void;
15
- isPolling: boolean;
16
14
  isInitialPolling: boolean;
17
15
  }): any;
18
16
  }> & {
19
17
  default?(props: {
20
18
  objects: GraffitiObject<Schema>[];
21
- results: GraffitiObject<Schema>[];
22
19
  poll: () => void;
23
- isPolling: boolean;
24
20
  isInitialPolling: boolean;
25
21
  }): any;
26
22
  };
@@ -1 +1 @@
1
- {"version":3,"file":"RecoverOrphans.vue.d.ts","sourceRoot":"","sources":["../../src/RecoverOrphans.vue"],"names":[],"mappings":"AA6CA,OAAO,KAAK,EACR,eAAe,EACf,UAAU,EACV,cAAc,EACjB,MAAM,sBAAsB,CAAC;yBAGb,MAAM,SAAS,UAAU,eAC5B,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,cAClD,mBAAmB,CAAC,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC,CAAC,iBAC5F,WAAW,CAAC,OAAO,CAAC,OAAO,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC;WA0E1D,mBAAmB,CAAC;gBAvEhB,MAAM;iBACL,eAAe;mBACb,OAAO;mBAqEwE,CAAC,4BAA2B;oBACzG,OAAO,KAAK,EAAE,gBAAgB,CAAC,EAAE,CAAC,GAAG,IAAI;WAClD,GAAG;;wBAlES;YACZ,OAAO,EAAE,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC;YAClC,OAAO,EAAE,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC;YAClC,IAAI,EAAE,MAAM,IAAI,CA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EAAE,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC;YAClC,IAAI,EAAE,MAAM,IAAI,CAAC;YACjB,gBAAgB,EAAE,OAAO,CAAC;SAC7B,GAAG,GAAG;;wBAJS;YACZ,OAAO,EAAE,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC;YAClC,IAAI,EAAE,MAAM,IAAI,CAAC;YACjB,gBAAgB,EAAE,OAAO,CAAC;SAC7B,GAAG,GAAG;;UAyDJ,EAAE;OAGG,OAAO,KAAK,EAAE,KAAK,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC,OAAO,WAAW,CAAC,CAAA;CAAE;AA7EzE,wBA6E4E;AAC5E,KAAK,mBAAmB,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC"}
@@ -22,10 +22,8 @@ export declare function useGraffitiDiscover<Schema extends JSONSchema>(channels:
22
22
  * will be used. Otherwise, the provided value will be used.
23
23
  */
24
24
  session?: MaybeRefOrGetter<GraffitiSession | undefined | null>, autopoll?: MaybeRefOrGetter<boolean>): {
25
- results: Ref<GraffitiObject<Schema>[]>;
26
25
  objects: Ref<GraffitiObject<Schema>[]>;
27
26
  poll: () => Promise<void>;
28
- isPolling: Ref<boolean>;
29
27
  isInitialPolling: Ref<boolean>;
30
28
  };
31
29
  /**
@@ -50,10 +48,8 @@ export declare function useGraffitiGet<Schema extends JSONSchema>(locationOrUri:
50
48
  * will be used. Otherwise, the provided value will be used.
51
49
  */
52
50
  session?: MaybeRefOrGetter<GraffitiSession | undefined | null>, autopoll?: MaybeRefOrGetter<boolean>): {
53
- result: Ref<GraffitiObject<Schema> | null | undefined>;
54
51
  object: Ref<GraffitiObject<Schema> | null | undefined>;
55
52
  poll: () => Promise<void>;
56
- isPolling: Ref<boolean>;
57
53
  isInitialPolling: Ref<boolean>;
58
54
  };
59
55
  /**
@@ -73,9 +69,7 @@ session?: MaybeRefOrGetter<GraffitiSession | undefined | null>, autopoll?: Maybe
73
69
  */
74
70
  export declare function useGraffitiRecoverOrphans<Schema extends JSONSchema>(schema: MaybeRefOrGetter<Schema>, session: MaybeRefOrGetter<GraffitiSession>, autopoll?: MaybeRefOrGetter<boolean>): {
75
71
  objects: Ref<GraffitiObject<Schema>[]>;
76
- results: Ref<GraffitiObject<Schema>[]>;
77
72
  poll: () => Promise<void>;
78
- isPolling: Ref<boolean>;
79
73
  isInitialPolling: Ref<boolean>;
80
74
  };
81
75
  //# sourceMappingURL=composables.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"composables.d.ts","sourceRoot":"","sources":["../../src/composables.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,gBAAgB,EAAE,MAAM,KAAK,CAAC;AACjD,OAAO,KAAK,EACV,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,UAAU,EAEX,MAAM,sBAAsB,CAAC;AA+F9B;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,SAAS,UAAU,EAC3D,QAAQ,EAAE,gBAAgB,CAAC,MAAM,EAAE,CAAC,EACpC,MAAM,EAAE,gBAAgB,CAAC,MAAM,CAAC;AAChC;;;;GAIG;AACH,OAAO,CAAC,EAAE,gBAAgB,CAAC,eAAe,GAAG,SAAS,GAAG,IAAI,CAAC,EAC9D,QAAQ,GAAE,gBAAgB,CAAC,OAAO,CAAS,GAC1C;IACD,OAAO,EAAE,GAAG,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACvC,OAAO,EAAE,GAAG,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACvC,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,SAAS,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;IACxB,gBAAgB,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;CAChC,CA+DA;AAED;;;;;;;;;;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ACH,wBAAgB,yBAAyB,CAAC,MAAM,SAAS,UAAU,EACjE,MAAM,EAAE,gBAAgB,CAAC,MAAM,CAAC,EAChC,OAAO,EAAE,gBAAgB,CAAC,eAAe,CAAC,EAC1C,QAAQ,GAAE,gBAAgB,CAAC,OAAO,CAAS,GAC1C;IACD,OAAO,EAAE,GAAG,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACvC,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,gBAAgB,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;CAChC,CA4CA"}
@@ -163,17 +163,13 @@ export declare const GraffitiDiscover: <Schema extends import('json-schema-to-ts
163
163
  slots: Readonly<{
164
164
  default?(props: {
165
165
  objects: import('@graffiti-garden/api').GraffitiObject<Schema>[];
166
- results: import('@graffiti-garden/api').GraffitiObject<Schema>[];
167
166
  poll: () => void;
168
- isPolling: boolean;
169
167
  isInitialPolling: boolean;
170
168
  }): any;
171
169
  }> & {
172
170
  default?(props: {
173
171
  objects: import('@graffiti-garden/api').GraffitiObject<Schema>[];
174
- results: import('@graffiti-garden/api').GraffitiObject<Schema>[];
175
172
  poll: () => void;
176
- isPolling: boolean;
177
173
  isInitialPolling: boolean;
178
174
  }): any;
179
175
  };
@@ -190,17 +186,13 @@ export declare const GraffitiDiscover: <Schema extends import('json-schema-to-ts
190
186
  slots: Readonly<{
191
187
  default?(props: {
192
188
  objects: import('@graffiti-garden/api').GraffitiObject<Schema>[];
193
- results: import('@graffiti-garden/api').GraffitiObject<Schema>[];
194
189
  poll: () => void;
195
- isPolling: boolean;
196
190
  isInitialPolling: boolean;
197
191
  }): any;
198
192
  }> & {
199
193
  default?(props: {
200
194
  objects: import('@graffiti-garden/api').GraffitiObject<Schema>[];
201
- results: import('@graffiti-garden/api').GraffitiObject<Schema>[];
202
195
  poll: () => void;
203
- isPolling: boolean;
204
196
  isInitialPolling: boolean;
205
197
  }): any;
206
198
  };
@@ -221,17 +213,13 @@ export declare const GraffitiGet: <Schema extends import('json-schema-to-ts').JS
221
213
  slots: Readonly<{
222
214
  default?(props: {
223
215
  object: import('@graffiti-garden/api').GraffitiObject<Schema> | undefined | null;
224
- result: import('@graffiti-garden/api').GraffitiObject<Schema> | undefined | null;
225
216
  poll: () => void;
226
- isPolling: boolean;
227
217
  isInitialPolling: boolean;
228
218
  }): any;
229
219
  }> & {
230
220
  default?(props: {
231
221
  object: import('@graffiti-garden/api').GraffitiObject<Schema> | undefined | null;
232
- result: import('@graffiti-garden/api').GraffitiObject<Schema> | undefined | null;
233
222
  poll: () => void;
234
- isPolling: boolean;
235
223
  isInitialPolling: boolean;
236
224
  }): any;
237
225
  };
@@ -248,17 +236,13 @@ export declare const GraffitiGet: <Schema extends import('json-schema-to-ts').JS
248
236
  slots: Readonly<{
249
237
  default?(props: {
250
238
  object: import('@graffiti-garden/api').GraffitiObject<Schema> | undefined | null;
251
- result: import('@graffiti-garden/api').GraffitiObject<Schema> | undefined | null;
252
239
  poll: () => void;
253
- isPolling: boolean;
254
240
  isInitialPolling: boolean;
255
241
  }): any;
256
242
  }> & {
257
243
  default?(props: {
258
244
  object: import('@graffiti-garden/api').GraffitiObject<Schema> | undefined | null;
259
- result: import('@graffiti-garden/api').GraffitiObject<Schema> | undefined | null;
260
245
  poll: () => void;
261
- isPolling: boolean;
262
246
  isInitialPolling: boolean;
263
247
  }): any;
264
248
  };
@@ -279,17 +263,13 @@ export declare const GraffitiRecoverOrphans: <Schema extends import('json-schema
279
263
  slots: Readonly<{
280
264
  default?(props: {
281
265
  objects: import('@graffiti-garden/api').GraffitiObject<Schema>[];
282
- results: import('@graffiti-garden/api').GraffitiObject<Schema>[];
283
266
  poll: () => void;
284
- isPolling: boolean;
285
267
  isInitialPolling: boolean;
286
268
  }): any;
287
269
  }> & {
288
270
  default?(props: {
289
271
  objects: import('@graffiti-garden/api').GraffitiObject<Schema>[];
290
- results: import('@graffiti-garden/api').GraffitiObject<Schema>[];
291
272
  poll: () => void;
292
- isPolling: boolean;
293
273
  isInitialPolling: boolean;
294
274
  }): any;
295
275
  };
@@ -305,17 +285,13 @@ export declare const GraffitiRecoverOrphans: <Schema extends import('json-schema
305
285
  slots: Readonly<{
306
286
  default?(props: {
307
287
  objects: import('@graffiti-garden/api').GraffitiObject<Schema>[];
308
- results: import('@graffiti-garden/api').GraffitiObject<Schema>[];
309
288
  poll: () => void;
310
- isPolling: boolean;
311
289
  isInitialPolling: boolean;
312
290
  }): any;
313
291
  }> & {
314
292
  default?(props: {
315
293
  objects: import('@graffiti-garden/api').GraffitiObject<Schema>[];
316
- results: import('@graffiti-garden/api').GraffitiObject<Schema>[];
317
294
  poll: () => void;
318
- isPolling: boolean;
319
295
  isInitialPolling: boolean;
320
296
  }): any;
321
297
  };
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAO,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE5C,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,GAAG,MAAM,WAAW,CAAC;AAC5B,OAAO,cAAc,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,EACV,QAAQ,EACR,eAAe,EAIhB,MAAM,sBAAsB,CAAC;AAK9B,OAAO,QAAQ,KAAK,CAAC;IACnB,UAAiB,yBAAyB;QACxC;;;;;;;;;;WAUG;QACH,SAAS,EAAE,QAAQ,CAAC;QACpB;;;;;;;;;;;;;;WAcG;QACH,gBAAgB,EAAE,GAAG,CAAC,eAAe,GAAG,SAAS,GAAG,IAAI,CAAC,CAAC;KAC3D;IAED,UAAiB,gBAAgB;QAC/B,gBAAgB,EAAE,OAAO,QAAQ,CAAC;QAClC,WAAW,EAAE,OAAO,GAAG,CAAC;QACxB,sBAAsB,EAAE,OAAO,cAAc,CAAC;KAC/C;CACF;AACD,YAAY,EAAE,yBAAyB,EAAE,MAAM,KAAK,CAA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umerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var h=(t,e,s)=>$(t,typeof e!="symbol"?e+"":e,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("vue"),M=require("@graffiti-garden/wrapper-synchronize"),w=Symbol(),j=Symbol();function m(){const t=r.inject(w);if(!t)throw new Error("No Graffiti instance provided, did you forget to install the plugin?");return t}function N(){return m()}function b(){const t=r.inject(j);if(!t)throw new Error("No Graffiti session provided, did you forget to install the plugin?");return t}var B=class R extends Error{constructor(e){super(e),this.name="GraffitiErrorNotFound",Object.setPrototypeOf(this,R.prototype)}};class C{constructor(e){h(this,"poll",async e=>{let s;const o=this.getter;try{s=await o()}catch{this.getter===o&&e(null);return}this.getter===o&&e({object:s})});this.getter=e}clear(){}}class S{constructor(e){h(this,"iterator");h(this,"continue");h(this,"poll",async e=>{if(!this.iterator)if(this.continue)try{this.iterator=this.continue()}catch(s){if(s instanceof B)e("clear"),this.iterator=this.streamFactory();else throw s}else this.iterator=this.streamFactory();for(;this.iterator;){const s=this.iterator,o=await s.next();if(s===this.iterator){if(o.done){o.value&&(this.iterator=void 0,this.continue=o.value.continue);break}if(o.value.error){console.error(o.value.error);continue}e(o.value)}}});this.streamFactory=e}clear(){if(this.iterator){const e=this.iterator;this.iterator.return({continue:()=>e,cursor:""})}this.iterator=void 0,this.continue=void 0}}function E(t,e){return!e||t.object.lastModified>e.object.lastModified||t.object.lastModified===e.object.lastModified&&!t.tombstone&&!!e.tombstone}class L{constructor(){h(this,"entry",r.ref())}get result(){return r.computed(()=>{const e=this.entry.value;return e&&(e.tombstone?null:e.object)})}clear(){this.entry.value=void 0}onEntry(e){if(e==="clear"){this.clear();return}(!e||E(e,this.entry.value))&&(this.entry.value=e)}}class F{constructor(e){h(this,"results",r.ref([]));h(this,"resultsRaw",new Map);h(this,"batchFlattenTimer");this.graffiti=e}clear(){this.resultsRaw.clear(),this.results.value=[],clearTimeout(this.batchFlattenTimer),this.batchFlattenTimer=void 0}flattenResults(){this.results.value=Array.from(this.resultsRaw.values()).reduce((e,s)=>(s.tombstone||e.push(s.object),e),[])}onEntry(e){if(!e)return;if(e==="clear"){this.clear();return}const s=this.resultsRaw.get(e.object.url);E(e,s)&&(this.resultsRaw.set(e.object.url,e),this.batchFlattenTimer||(this.batchFlattenTimer=setTimeout(()=>{this.flattenResults(),this.batchFlattenTimer=void 0},0)))}}function P(t,e,s,o,l){let n;async function i(){n=s();for await(const f of n){if(f.error){console.error(f.error);continue}t.onEntry(f)}}let c=!1;const u=async()=>{if(!c){c=!0;try{await e.poll(t.onEntry.bind(t))}finally{c=!1,r.toValue(l)&&u()}}},a=r.ref(!1);return r.watch(o,async(f,p)=>{if(JSON.stringify(f)!==JSON.stringify(p)){n==null||n.return(null),t.clear(),e.clear(),i(),a.value=!0;try{await u()}finally{a.value=!1}}},{immediate:!0}),r.onScopeDispose(()=>n==null?void 0:n.return(null)),{poll:u,isInitialPolling:a}}function T(t,e){return()=>{const s=r.toValue(e);return s===void 0?t==null?void 0:t.value:s}}function d(t){return t.map(e=>e())}function I(t,e,s,o=!1){const l=m(),n=b(),i=()=>r.toValue(t),c=()=>r.toValue(e),u=T(n,s),a=[i,c,u],f=()=>l.synchronizeDiscover(...d(a)),p=()=>l.discover(...d(a)),g=new F(l),v=new S(p),{poll:y,isInitialPolling:G}=P(g,v,f,a,o);return{objects:g.results,get results(){return console.warn("The `results` property is deprecated. Use `objects` instead."),this.objects},poll:y,isInitialPolling:G,get isPolling(){return console.warn("The `isPolling` property is deprecated. Use `isInitialPolling` instead."),this.isInitialPolling}}}function O(t,e,s,o=!1){const l=m(),n=b(),i=()=>r.toValue(t),c=()=>r.toValue(e),u=T(n,s),a=[i,c,u],f=()=>l.synchronizeGet(...d(a)),p=new L,g=()=>l.get(...d(a)),v=new C(g),{poll:y,isInitialPolling:G}=P(p,v,f,a,o);return{object:p.result,get result(){return console.warn("The `result` property is deprecated. Use `object` instead."),this.object},poll:y,isInitialPolling:G,get isPolling(){return console.warn("The `isPolling` property is deprecated. Use `isInitialPolling` instead."),this.isInitialPolling}}}function _(t,e,s=!1){const o=m(),i=[()=>r.toValue(t),()=>r.toValue(e)],c=()=>o.synchronizeRecoverOrphans(...d(i)),u=new F(o),a=()=>o.recoverOrphans(...d(i)),f=new S(a),{poll:p,isInitialPolling:g}=P(u,f,c,i,s);return{objects:u.results,get results(){return console.warn("The `result` property is deprecated. Use `object` instead."),this.objects},poll:p,isInitialPolling:g,get isPolling(){return console.warn("The `isPolling` property is deprecated. Use `isInitialPolling` instead."),this.isInitialPolling}}}const z=r.defineComponent({__name:"Discover",props:{channels:{},schema:{},session:{},autopoll:{type:Boolean}},setup(t){const e=t,{objects:s,results:o,poll:l,isPolling:n,isInitialPolling:i}=I(r.toRef(e,"channels"),r.toRef(e,"schema"),r.toRef(e,"session"),r.toRef(e,"autopoll"));return(c,u)=>r.renderSlot(c.$slots,"default",{objects:r.unref(s),results:r.unref(o),poll:r.unref(l),isPolling:r.unref(n),isInitialPolling:r.unref(i)})}}),V=r.defineComponent({__name:"Get",props:{url:{},schema:{},session:{},autopoll:{type:Boolean}},setup(t){const e=t,{object:s,result:o,poll:l,isPolling:n,isInitialPolling:i}=O(r.toRef(e,"url"),r.toRef(e,"schema"),r.toRef(e,"session"),r.toRef(e,"autopoll"));return(c,u)=>r.renderSlot(c.$slots,"default",{object:r.unref(s),result:r.unref(o),poll:r.unref(l),isPolling:r.unref(n),isInitialPolling:r.unref(i)})}}),D=r.defineComponent({__name:"RecoverOrphans",props:{schema:{},session:{},autopoll:{type:Boolean}},setup(t){const e=t,{objects:s,results:o,poll:l,isPolling:n,isInitialPolling:i}=_(r.toRef(e,"schema"),r.toRef(e,"session"),r.toRef(e,"autopoll"));return(c,u)=>r.renderSlot(c.$slots,"default",{objects:r.unref(s),results:r.unref(o),poll:r.unref(l),isPolling:r.unref(n),isInitialPolling:r.unref(i)})}}),k={install(t,e){const s=e.graffiti,o=new M.GraffitiSynchronize(s),l=r.ref(void 0);o.sessionEvents.addEventListener("initialized",async n=>{const i=n.detail;if(i&&i.error&&console.error(i.error),i&&i.href){const c=t.config.globalProperties.$router;if(c){const u=c.options.history.base,a=new URL(i.href);a.pathname.startsWith(u)&&(a.pathname=a.pathname.slice(u.length)),await c.replace(a.pathname+a.search+a.hash)}}l.value||(l.value=null)}),o.sessionEvents.addEventListener("login",n=>{const i=n.detail;if(i.error){console.error("Error logging in:"),console.error(i.error);return}else l.value=i.session}),o.sessionEvents.addEventListener("logout",n=>{const i=n.detail;i.error?(console.error("Error logging out:"),console.error(i.error)):l.value=null}),t.provide(w,o),t.provide(j,l),t.component("GraffitiDiscover",z),t.component("GraffitiGet",V),t.component("GraffitiRecoverOrphans",D),t.config.globalProperties.$graffiti=o,t.config.globalProperties.$graffitiSession=l}},A=z,q=V,J=D;exports.GraffitiDiscover=A;exports.GraffitiGet=q;exports.GraffitiPlugin=k;exports.GraffitiRecoverOrphans=J;exports.useGraffiti=N;exports.useGraffitiDiscover=I;exports.useGraffitiGet=O;exports.useGraffitiRecoverOrphans=_;exports.useGraffitiSession=b;exports.useGraffitiSynchronize=m;
1
+ "use strict";var $=Object.defineProperty;var M=(e,t,o)=>t in e?$(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o;var p=(e,t,o)=>M(e,typeof t!="symbol"?t+"":t,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("vue"),N=require("@graffiti-garden/wrapper-synchronize"),R=Symbol(),P=Symbol();function v(){const e=r.inject(R);if(!e)throw new Error("No Graffiti instance provided, did you forget to install the plugin?");return e}function B(){return v()}function b(){const e=r.inject(P);if(!e)throw new Error("No Graffiti session provided, did you forget to install the plugin?");return e}var C=class S extends Error{constructor(t){super(t),this.name="GraffitiErrorNotFound",Object.setPrototypeOf(this,S.prototype)}};class L{constructor(t){p(this,"poll",async t=>{let o;const s=this.getter;try{o=await s()}catch{this.getter===s&&t(null);return}this.getter===s&&t({object:o})});this.getter=t}clear(){}}class j{constructor(t){p(this,"iterator");p(this,"continue");p(this,"poll",async t=>{if(!this.iterator)if(this.continue)try{this.iterator=this.continue()}catch(o){if(o instanceof C)t("clear"),this.iterator=this.streamFactory();else throw o}else this.iterator=this.streamFactory();for(;this.iterator;){const o=this.iterator,s=await o.next();if(o===this.iterator){if(s.done){s.value&&(this.iterator=void 0,this.continue=s.value.continue);break}if(s.value.error){console.error(s.value.error);continue}t(s.value)}}});this.streamFactory=t}clear(){if(this.iterator){const t=this.iterator;this.iterator.return({continue:()=>t,cursor:""})}this.iterator=void 0,this.continue=void 0}}function E(e,t){return!t||e.object.lastModified>t.object.lastModified||e.object.lastModified===t.object.lastModified&&!e.tombstone&&!!t.tombstone}class k{constructor(){p(this,"entry",r.ref())}get result(){return r.computed(()=>{const t=this.entry.value;return t&&(t.tombstone?null:t.object)})}clear(){this.entry.value=void 0}onEntry(t){if(t==="clear"){this.clear();return}(!t||E(t,this.entry.value))&&(this.entry.value=t)}}class F{constructor(t){p(this,"results",r.ref([]));p(this,"resultsRaw",new Map);p(this,"batchFlattenTimer");this.graffiti=t}clear(){this.resultsRaw.clear(),this.results.value=[],clearTimeout(this.batchFlattenTimer),this.batchFlattenTimer=void 0}flattenResults(){this.results.value=Array.from(this.resultsRaw.values()).reduce((t,o)=>(o.tombstone||t.push(o.object),t),[])}onEntry(t){if(!t)return;if(t==="clear"){this.clear();return}const o=this.resultsRaw.get(t.object.url);E(t,o)&&(this.resultsRaw.set(t.object.url,t),this.batchFlattenTimer||(this.batchFlattenTimer=setTimeout(()=>{this.flattenResults(),this.batchFlattenTimer=void 0},0)))}}function w(e,t,o,s,a){let n;async function i(){n=o();for await(const f of n){if(f.error){console.error(f.error);continue}e.onEntry(f)}}let u=!1,c;const l=async()=>{if(u||!c)return;const f=c;u=!0;try{await f()}finally{if(f!==c)return;u=!1,r.toValue(a)&&l()}},h=r.ref(!1);return r.watch(s,async(f,d)=>{if(JSON.stringify(f)===JSON.stringify(d))return;n==null||n.return(null),e.clear(),t.clear(),i(),c=()=>t.poll(e.onEntry.bind(e));const m=c;u=!1,h.value=!0;try{await l()}finally{if(m!==c)return;h.value=!1}},{immediate:!0}),r.onScopeDispose(()=>{n==null||n.return(null),e.clear(),t.clear(),c=void 0}),{poll:l,isInitialPolling:h}}function O(e,t){return()=>{const o=r.toValue(t);return o===void 0?e==null?void 0:e.value:o}}function g(e){return e.map(t=>t())}function _(e,t,o,s=!1){const a=v(),n=b(),i=()=>r.toValue(e),u=()=>r.toValue(t),c=O(n,o),l=[i,u,c],h=()=>a.synchronizeDiscover(...g(l)),f=()=>a.discover(...g(l)),d=new F(a),m=new j(f),{poll:G,isInitialPolling:y}=w(d,m,h,l,s);return{objects:d.results,poll:G,isInitialPolling:y}}function z(e,t,o,s=!1){const a=v(),n=b(),i=()=>r.toValue(e),u=()=>r.toValue(t),c=O(n,o),l=[i,u,c],h=()=>a.synchronizeGet(...g(l)),f=new k,d=()=>a.get(...g(l)),m=new L(d),{poll:G,isInitialPolling:y}=w(f,m,h,l,s);return{object:f.result,poll:G,isInitialPolling:y}}function T(e,t,o=!1){const s=v(),i=[()=>r.toValue(e),()=>r.toValue(t)],u=()=>s.synchronizeRecoverOrphans(...g(i)),c=new F(s),l=()=>s.recoverOrphans(...g(i)),h=new j(l),{poll:f,isInitialPolling:d}=w(c,h,u,i,o);return{objects:c.results,poll:f,isInitialPolling:d}}const V=r.defineComponent({__name:"Discover",props:{channels:{},schema:{},session:{},autopoll:{type:Boolean}},setup(e){const t=e,{objects:o,poll:s,isInitialPolling:a}=_(r.toRef(t,"channels"),r.toRef(t,"schema"),r.toRef(t,"session"),r.toRef(t,"autopoll"));return(n,i)=>r.renderSlot(n.$slots,"default",{objects:r.unref(o),poll:r.unref(s),isInitialPolling:r.unref(a)})}}),D=r.defineComponent({__name:"Get",props:{url:{},schema:{},session:{},autopoll:{type:Boolean}},setup(e){const t=e,{object:o,poll:s,isInitialPolling:a}=z(r.toRef(t,"url"),r.toRef(t,"schema"),r.toRef(t,"session"),r.toRef(t,"autopoll"));return(n,i)=>r.renderSlot(n.$slots,"default",{object:r.unref(o),poll:r.unref(s),isInitialPolling:r.unref(a)})}}),I=r.defineComponent({__name:"RecoverOrphans",props:{schema:{},session:{},autopoll:{type:Boolean}},setup(e){const t=e,{objects:o,poll:s,isInitialPolling:a}=T(r.toRef(t,"schema"),r.toRef(t,"session"),r.toRef(t,"autopoll"));return(n,i)=>r.renderSlot(n.$slots,"default",{objects:r.unref(o),poll:r.unref(s),isInitialPolling:r.unref(a)})}}),A={install(e,t){const o=t.graffiti,s=new N.GraffitiSynchronize(o),a=r.ref(void 0);s.sessionEvents.addEventListener("initialized",async n=>{const i=n.detail;if(i&&i.error&&console.error(i.error),i&&i.href){const u=e.config.globalProperties.$router;if(u){const c=u.options.history.base,l=new URL(i.href);l.pathname.startsWith(c)&&(l.pathname=l.pathname.slice(c.length)),await u.replace(l.pathname+l.search+l.hash)}}a.value||(a.value=null)}),s.sessionEvents.addEventListener("login",n=>{const i=n.detail;if(i.error){console.error("Error logging in:"),console.error(i.error);return}else a.value=i.session}),s.sessionEvents.addEventListener("logout",n=>{const i=n.detail;i.error?(console.error("Error logging out:"),console.error(i.error)):a.value=null}),e.provide(R,s),e.provide(P,a),e.component("GraffitiDiscover",V),e.component("GraffitiGet",D),e.component("GraffitiRecoverOrphans",I),e.config.globalProperties.$graffiti=s,e.config.globalProperties.$graffitiSession=a}},q=V,J=D,K=I;exports.GraffitiDiscover=q;exports.GraffitiGet=J;exports.GraffitiPlugin=A;exports.GraffitiRecoverOrphans=K;exports.useGraffiti=B;exports.useGraffitiDiscover=_;exports.useGraffitiGet=z;exports.useGraffitiRecoverOrphans=T;exports.useGraffitiSession=b;exports.useGraffitiSynchronize=v;
2
2
  //# sourceMappingURL=plugin.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","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 const poll = async () => {\n if (isAlreadyPolling) return;\n isAlreadyPolling = true;\n try {\n await poller.poll(reducer.onEntry.bind(reducer));\n } finally {\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 isInitialPolling.value = true;\n try {\n await poll();\n } finally {\n isInitialPolling.value = false;\n }\n },\n {\n immediate: true,\n },\n );\n onScopeDispose(() => synchronizeIterator?.return(null));\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 results: Ref<GraffitiObject<Schema>[]>;\n objects: Ref<GraffitiObject<Schema>[]>;\n poll: () => Promise<void>;\n isPolling: Ref<boolean>;\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 * @deprecated Use {@link objects} instead.\n */\n get results() {\n console.warn(\n \"The `results` property is deprecated. Use `objects` instead.\",\n );\n return this.objects;\n },\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 * @deprecated Use {@link isInitialPolling} instead.\n */\n get isPolling() {\n console.warn(\n \"The `isPolling` property is deprecated. Use `isInitialPolling` instead.\",\n );\n return this.isInitialPolling;\n },\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 result: Ref<GraffitiObject<Schema> | null | undefined>;\n object: Ref<GraffitiObject<Schema> | null | undefined>;\n poll: () => Promise<void>;\n isPolling: Ref<boolean>;\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 * @deprecated Use {@link object} instead.\n */\n get result() {\n console.warn(\n \"The `result` property is deprecated. Use `object` instead.\",\n );\n return this.object;\n },\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 * @deprecated Use {@link isInitialPolling} instead.\n */\n get isPolling() {\n console.warn(\n \"The `isPolling` property is deprecated. Use `isInitialPolling` instead.\",\n );\n return this.isInitialPolling;\n },\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 results: Ref<GraffitiObject<Schema>[]>;\n poll: () => Promise<void>;\n isPolling: Ref<boolean>;\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 * @deprecated Use {@link objects} instead.\n */\n get results() {\n console.warn(\n \"The `result` property is deprecated. Use `object` instead.\",\n );\n return this.objects;\n },\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 * @deprecated Use {@link isInitialPolling} instead.\n */\n get isPolling() {\n console.warn(\n \"The `isPolling` property is deprecated. Use `isInitialPolling` instead.\",\n );\n return this.isInitialPolling;\n },\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 results: GraffitiObject<Schema>[];\n poll: () => void;\n isPolling: boolean;\n isInitialPolling: boolean;\n }): any;\n}>();\n\nconst { objects, results, poll, isPolling, isInitialPolling } =\n 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 :results=\"results\"\n :poll=\"poll\"\n :isPolling=\"isPolling\"\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 result: GraffitiObject<Schema> | undefined | null;\n poll: () => void;\n isPolling: boolean;\n isInitialPolling: boolean;\n }): any;\n}>();\n\nconst { object, result, poll, isPolling, isInitialPolling } =\n 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 :result=\"result\"\n :poll=\"poll\"\n :isPolling=\"isPolling\"\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 results: GraffitiObject<Schema>[];\n poll: () => void;\n isPolling: boolean;\n isInitialPolling: boolean;\n }): any;\n}>();\n\nconst { objects, results, poll, isPolling, isInitialPolling } =\n 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 :results=\"results\"\n :poll=\"poll\"\n :isPolling=\"isPolling\"\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","GetPoller","getter","__publicField","onEntry","object","myGetter","StreamPoller","streamFactory","e","GraffitiErrorNotFound","myIterator","result","iterator","isEntryNewer","entry","existing","SingletonReducer","ref","computed","value","ArrayReducer","acc","makeComposable","reducer","poller","synchronizeFactory","toWatch","autopoll","synchronizeIterator","pollSynchronize","isAlreadyPolling","poll","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","results","isPolling","toRef","GraffitiPlugin","app","options","graffitiBase","GraffitiSynchronize","graffitiSession","evt","detail","router","base","url","Discover","Get","RecoverOrphans","GraffitiDiscover","GraffitiGet","GraffitiRecoverOrphans"],"mappings":"6TAKaA,EAAoB,OAAO,EAC3BC,EAA2B,OAAO,EASxC,SAASC,GAAyB,CACjC,MAAAC,EAAWC,SAAOJ,CAAiB,EACzC,GAAI,CAACG,EACH,MAAM,IAAI,MACR,sEACF,EAEK,OAAAA,CACT,CAeO,SAASE,GAAwB,CACtC,OAAOH,EAAuB,CAChC,CAkBO,SAASI,GAAqB,CAC7B,MAAAC,EAAUH,SAAOH,CAAwB,EAC/C,GAAI,CAACM,EACH,MAAM,IAAI,MACR,qEACF,EAEK,OAAAA,CACT,CClEkX,IAA8PC,EAAE,MAAMC,UAAU,KAAK,CAAC,YAAY,EAAE,CAAC,MAAM,CAAC,EAAE,KAAK,KAAK,wBAAwB,OAAO,eAAe,KAAKA,EAAE,SAAS,CAAC,CAAC,ECuBnuB,MAAMC,CAA+D,CAC1E,YAAqBC,EAA+C,CAEpEC,EAAA,YAA+B,MAAOC,GAAY,CAC5C,IAAAC,EACJ,MAAMC,EAAW,KAAK,OAClB,GAAA,CACFD,EAAS,MAAMC,EAAS,OACd,CACN,KAAK,SAAWA,GAClBF,EAAQ,IAAI,EAEd,MAAA,CAEE,KAAK,SAAWE,GACVF,EAAA,CAAE,OAAAC,EAAQ,CA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AAQvE,EAA0B2E,CAAe,EAEjDJ,EAAA,UAAU,mBAAoBU,CAAQ,EACtCV,EAAA,UAAU,cAAeW,CAAG,EAC5BX,EAAA,UAAU,yBAA0BY,CAAc,EAClDZ,EAAA,OAAO,iBAAiB,UAAYrE,EACpCqE,EAAA,OAAO,iBAAiB,iBAAmBI,CAAA,CAEnD,EAiBaS,EAAmBH,EASnBI,EAAcH,EASdI,EAAyBH","x_google_ignoreList":[1]}
1
+ {"version":3,"file":"plugin.js","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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