@graffiti-garden/wrapper-vue 0.6.4 → 0.6.5

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.
@@ -4,20 +4,25 @@ declare const _default: <Schema extends JSONSchema>(__VLS_props: NonNullable<Awa
4
4
  channels: string[];
5
5
  schema: Schema;
6
6
  session?: GraffitiSession | null;
7
+ autopoll?: boolean;
7
8
  } & Partial<{}>> & import('vue').PublicProps;
8
9
  expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
9
10
  attrs: any;
10
11
  slots: Readonly<{
11
12
  default?(props: {
13
+ objects: GraffitiObject<Schema>[];
12
14
  results: GraffitiObject<Schema>[];
13
15
  poll: () => void;
14
16
  isPolling: boolean;
17
+ isInitialPolling: boolean;
15
18
  }): any;
16
19
  }> & {
17
20
  default?(props: {
21
+ objects: GraffitiObject<Schema>[];
18
22
  results: GraffitiObject<Schema>[];
19
23
  poll: () => void;
20
24
  isPolling: boolean;
25
+ isInitialPolling: boolean;
21
26
  }): any;
22
27
  };
23
28
  emit: {};
@@ -1 +1 @@
1
- {"version":3,"file":"Discover.vue.d.ts","sourceRoot":"","sources":["../../src/Discover.vue"],"names":[],"mappings":"AAoCA,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;WAmE1D,mBAAmB,CAAC;kBAhEd,MAAM,EAAE;gBACV,MAAM;kBACJ,eAAe,GAAG,IAAI;mBA8D0D,CAAC,4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,EAAE,gBAAgB,CAAC,EAAE,CAAC,GAAG,IAAI;WAClD,GAAG;;wBAnES;YACZ,OAAO,EAAE,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC;YAClC,OAAO,EAAE,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC;YAClC,IAAI,EAAE,MAAM,IAAI,CAAC;YACjB,SAAS,EAAE,OAAO,CAAC;YACnB,gBAAgB,EAAE,OAAO,CAAC;SAC7B,GAAG,GAAG;;wBANS;YACZ,OAAO,EAAE,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC;YAClC,OAAO,EAAE,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC;YAClC,IAAI,EAAE,MAAM,IAAI,CAAC;YACjB,SAAS,EAAE,OAAO,CAAC;YACnB,gBAAgB,EAAE,OAAO,CAAC;SAC7B,GAAG,GAAG;;UA+DJ,EAAE;OAGG,OAAO,KAAK,EAAE,KAAK,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC,OAAO,WAAW,CAAC,CAAA;CAAE;AAtFzE,wBAsF4E;AAC5E,KAAK,mBAAmB,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC"}
@@ -4,20 +4,25 @@ declare const _default: <Schema extends JSONSchema>(__VLS_props: NonNullable<Awa
4
4
  url: string | GraffitiObjectUrl;
5
5
  schema: Schema;
6
6
  session?: GraffitiSession | null;
7
+ autopoll?: boolean;
7
8
  } & Partial<{}>> & import('vue').PublicProps;
8
9
  expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
9
10
  attrs: any;
10
11
  slots: Readonly<{
11
12
  default?(props: {
13
+ object: GraffitiObject<Schema> | undefined | null;
12
14
  result: GraffitiObject<Schema> | undefined | null;
13
15
  poll: () => void;
14
16
  isPolling: boolean;
17
+ isInitialPolling: boolean;
15
18
  }): any;
16
19
  }> & {
17
20
  default?(props: {
21
+ object: GraffitiObject<Schema> | undefined | null;
18
22
  result: GraffitiObject<Schema> | undefined | null;
19
23
  poll: () => void;
20
24
  isPolling: boolean;
25
+ isInitialPolling: boolean;
21
26
  }): any;
22
27
  };
23
28
  emit: {};
@@ -1 +1 @@
1
- {"version":3,"file":"Get.vue.d.ts","sourceRoot":"","sources":["../../src/Get.vue"],"names":[],"mappings":"AAqCA,OAAO,KAAK,EACR,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,UAAU,EACb,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;WAmE1D,mBAAmB,CAAC;aAhEnB,MAAM,GAAG,iBAAiB;gBACvB,MAAM;kBACJ,eAAe,GAAG,IAAI;mBA8D0D,CAAC,4BAA2B;oBACzG,OAAO,KAAK,EAAE,gBAAgB,CAAC,EAAE,CAAC,GAAG,IAAI;WAClD,GAAG;;wBA3DS;YACZ,MAAM,EAAE,cAAc,CAAC,MAAM,CAAC,GAAG,SAAS,GAAG,IAAI,CAAC;YAClD,IAAI,EAAE,MAAM,IAAI,CAAC;YACjB,SAAS,EAAE,OAAO,CAAC;SACtB,GAAG,GAAG;;wBAJS;YACZ,MAAM,EAAE,cAAc,CAAC,MAAM,CAAC,GAAG,SAAS,GAAG,IAAI,CAAC;YAClD,IAAI,EAAE,MAAM,IAAI,CAAC;YACjB,SAAS,EAAE,OAAO,CAAC;SACtB,GAAG,GAAG;;UAyDJ,EAAE;OAGG,OAAO,KAAK,EAAE,KAAK,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC,OAAO,WA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G,SAAS,GAAG,IAAI,CAAC;YAClD,IAAI,EAAE,MAAM,IAAI,CAAC;YACjB,SAAS,EAAE,OAAO,CAAC;YACnB,gBAAgB,EAAE,OAAO,CAAC;SAC7B,GAAG,GAAG;;UA+DJ,EAAE;OAGG,OAAO,KAAK,EAAE,KAAK,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC,OAAO,WAAW,CAAC,CAAA;CAAE;AAtFzE,wBAsF4E;AAC5E,KAAK,mBAAmB,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC"}
@@ -3,20 +3,25 @@ declare const _default: <Schema extends JSONSchema>(__VLS_props: NonNullable<Awa
3
3
  props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, never> & {
4
4
  schema: Schema;
5
5
  session: GraffitiSession;
6
+ autopoll?: boolean;
6
7
  } & Partial<{}>> & import('vue').PublicProps;
7
8
  expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
8
9
  attrs: any;
9
10
  slots: Readonly<{
10
11
  default?(props: {
12
+ objects: GraffitiObject<Schema>[];
11
13
  results: GraffitiObject<Schema>[];
12
14
  poll: () => void;
13
15
  isPolling: boolean;
16
+ isInitialPolling: boolean;
14
17
  }): any;
15
18
  }> & {
16
19
  default?(props: {
20
+ objects: GraffitiObject<Schema>[];
17
21
  results: GraffitiObject<Schema>[];
18
22
  poll: () => void;
19
23
  isPolling: boolean;
24
+ isInitialPolling: boolean;
20
25
  }): any;
21
26
  };
22
27
  emit: {};
@@ -1 +1 @@
1
- {"version":3,"file":"RecoverOrphans.vue.d.ts","sourceRoot":"","sources":["../../src/RecoverOrphans.vue"],"names":[],"mappings":"AAkCA,OAAO,KAAK,EACR,eAAe,EACf,UAAU,EACV,cAAc,EACjB,MAAM,sBAAsB,CAAC;yBAGb,MAAM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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,CAAC;YACjB,SAAS,EAAE,OAAO,CAAC;YACnB,gBAAgB,EAAE,OAAO,CAAC;SAC7B,GAAG,GAAG;;wBANS;YACZ,OAAO,EAAE,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC;YAClC,OAAO,EAAE,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC;YAClC,IAAI,EAAE,MAAM,IAAI,CAAC;YACjB,SAAS,EAAE,OAAO,CAAC;YACnB,gBAAgB,EAAE,OAAO,CAAC;SAC7B,GAAG,GAAG;;UA8DJ,EAAE;OAGG,OAAO,KAAK,EAAE,KAAK,GAAG;IAAE,KAAK,CAAC,EAAE,OAAO,CAAC,OAAO,WAAW,CAAC,CAAA;CAAE;AApFzE,wBAoF4E;AAC5E,KAAK,mBAAmB,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;CAAG,GAAG,EAAE,CAAC"}
@@ -21,10 +21,12 @@ export declare function useGraffitiDiscover<Schema extends JSONSchema>(channels:
21
21
  * {@link ComponentCustomProperties.$graffitiSession | $graffitiSession},
22
22
  * will be used. Otherwise, the provided value will be used.
23
23
  */
24
- session?: MaybeRefOrGetter<GraffitiSession | undefined | null>): {
24
+ session?: MaybeRefOrGetter<GraffitiSession | undefined | null>, autopoll?: MaybeRefOrGetter<boolean>): {
25
25
  results: Ref<GraffitiObject<Schema>[]>;
26
+ objects: Ref<GraffitiObject<Schema>[]>;
26
27
  poll: () => Promise<void>;
27
28
  isPolling: Ref<boolean>;
29
+ isInitialPolling: Ref<boolean>;
28
30
  };
29
31
  /**
30
32
  * The [Graffiti.get](https://api.graffiti.garden/classes/Graffiti.html#get)
@@ -47,10 +49,12 @@ export declare function useGraffitiGet<Schema extends JSONSchema>(locationOrUri:
47
49
  * {@link ComponentCustomProperties.$graffitiSession | $graffitiSession},
48
50
  * will be used. Otherwise, the provided value will be used.
49
51
  */
50
- session?: MaybeRefOrGetter<GraffitiSession | undefined | null>): {
52
+ session?: MaybeRefOrGetter<GraffitiSession | undefined | null>, autopoll?: MaybeRefOrGetter<boolean>): {
51
53
  result: Ref<GraffitiObject<Schema> | null | undefined>;
54
+ object: Ref<GraffitiObject<Schema> | null | undefined>;
52
55
  poll: () => Promise<void>;
53
56
  isPolling: Ref<boolean>;
57
+ isInitialPolling: Ref<boolean>;
54
58
  };
55
59
  /**
56
60
  * The [Graffiti.recoverOrphans](https://api.graffiti.garden/classes/Graffiti.html#recoverorphans)
@@ -67,9 +71,11 @@ session?: MaybeRefOrGetter<GraffitiSession | undefined | null>): {
67
71
  * not when the elements or properties change.
68
72
  * If you need deep reactivity, wrap your argument in a getter.
69
73
  */
70
- export declare function useGraffitiRecoverOrphans<Schema extends JSONSchema>(schema: MaybeRefOrGetter<Schema>, session: MaybeRefOrGetter<GraffitiSession>): {
74
+ export declare function useGraffitiRecoverOrphans<Schema extends JSONSchema>(schema: MaybeRefOrGetter<Schema>, session: MaybeRefOrGetter<GraffitiSession>, autopoll?: MaybeRefOrGetter<boolean>): {
75
+ objects: Ref<GraffitiObject<Schema>[]>;
71
76
  results: Ref<GraffitiObject<Schema>[]>;
72
77
  poll: () => Promise<void>;
73
78
  isPolling: Ref<boolean>;
79
+ isInitialPolling: Ref<boolean>;
74
80
  };
75
81
  //# 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;AAkF9B;;;;;;;;;;;;;;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,GAC7D;IACD,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;CACzB,CAwCA;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,CAAC,MAAM,SAAS,UAAU,EACtD,aAAa,EAAE,gBAAgB,CAAC,iBAAiB,GAAG,MAAM,CAAC,EAC3D,MAAM,EAAE,gBAAgB,CAAC,MAAM,CAAC;AAChC;;;;GAIG;AACH,OAAO,CAAC,EAAE,gBAAgB,CAAC,eAAe,GAAG,SAAS,GAAG,IAAI,CAAC,GAC7D;IACD,MAAM,EAAE,GAAG,CAAC,cAAc,CAAC,MAAM,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;IACvD,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,C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ChC,CA8DA"}
@@ -162,15 +162,19 @@ export declare const GraffitiDiscover: <Schema extends import('json-schema-to-ts
162
162
  attrs: any;
163
163
  slots: Readonly<{
164
164
  default?(props: {
165
+ objects: import('@graffiti-garden/api').GraffitiObject<Schema>[];
165
166
  results: import('@graffiti-garden/api').GraffitiObject<Schema>[];
166
167
  poll: () => void;
167
168
  isPolling: boolean;
169
+ isInitialPolling: boolean;
168
170
  }): any;
169
171
  }> & {
170
172
  default?(props: {
173
+ objects: import('@graffiti-garden/api').GraffitiObject<Schema>[];
171
174
  results: import('@graffiti-garden/api').GraffitiObject<Schema>[];
172
175
  poll: () => void;
173
176
  isPolling: boolean;
177
+ isInitialPolling: boolean;
174
178
  }): any;
175
179
  };
176
180
  emit: {};
@@ -179,20 +183,25 @@ export declare const GraffitiDiscover: <Schema extends import('json-schema-to-ts
179
183
  channels: string[];
180
184
  schema: Schema;
181
185
  session?: (GraffitiSession | null) | undefined;
186
+ autopoll?: boolean | undefined;
182
187
  } & import('vue').PublicProps;
183
188
  expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
184
189
  attrs: any;
185
190
  slots: Readonly<{
186
191
  default?(props: {
192
+ objects: import('@graffiti-garden/api').GraffitiObject<Schema>[];
187
193
  results: import('@graffiti-garden/api').GraffitiObject<Schema>[];
188
194
  poll: () => void;
189
195
  isPolling: boolean;
196
+ isInitialPolling: boolean;
190
197
  }): any;
191
198
  }> & {
192
199
  default?(props: {
200
+ objects: import('@graffiti-garden/api').GraffitiObject<Schema>[];
193
201
  results: import('@graffiti-garden/api').GraffitiObject<Schema>[];
194
202
  poll: () => void;
195
203
  isPolling: boolean;
204
+ isInitialPolling: boolean;
196
205
  }): any;
197
206
  };
198
207
  emit: {};
@@ -211,15 +220,19 @@ export declare const GraffitiGet: <Schema extends import('json-schema-to-ts').JS
211
220
  attrs: any;
212
221
  slots: Readonly<{
213
222
  default?(props: {
223
+ object: import('@graffiti-garden/api').GraffitiObject<Schema> | undefined | null;
214
224
  result: import('@graffiti-garden/api').GraffitiObject<Schema> | undefined | null;
215
225
  poll: () => void;
216
226
  isPolling: boolean;
227
+ isInitialPolling: boolean;
217
228
  }): any;
218
229
  }> & {
219
230
  default?(props: {
231
+ object: import('@graffiti-garden/api').GraffitiObject<Schema> | undefined | null;
220
232
  result: import('@graffiti-garden/api').GraffitiObject<Schema> | undefined | null;
221
233
  poll: () => void;
222
234
  isPolling: boolean;
235
+ isInitialPolling: boolean;
223
236
  }): any;
224
237
  };
225
238
  emit: {};
@@ -228,20 +241,25 @@ export declare const GraffitiGet: <Schema extends import('json-schema-to-ts').JS
228
241
  url: string | import('@graffiti-garden/api').GraffitiObjectUrl;
229
242
  schema: Schema;
230
243
  session?: (GraffitiSession | null) | undefined;
244
+ autopoll?: boolean | undefined;
231
245
  } & import('vue').PublicProps;
232
246
  expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
233
247
  attrs: any;
234
248
  slots: Readonly<{
235
249
  default?(props: {
250
+ object: import('@graffiti-garden/api').GraffitiObject<Schema> | undefined | null;
236
251
  result: import('@graffiti-garden/api').GraffitiObject<Schema> | undefined | null;
237
252
  poll: () => void;
238
253
  isPolling: boolean;
254
+ isInitialPolling: boolean;
239
255
  }): any;
240
256
  }> & {
241
257
  default?(props: {
258
+ object: import('@graffiti-garden/api').GraffitiObject<Schema> | undefined | null;
242
259
  result: import('@graffiti-garden/api').GraffitiObject<Schema> | undefined | null;
243
260
  poll: () => void;
244
261
  isPolling: boolean;
262
+ isInitialPolling: boolean;
245
263
  }): any;
246
264
  };
247
265
  emit: {};
@@ -260,15 +278,19 @@ export declare const GraffitiRecoverOrphans: <Schema extends import('json-schema
260
278
  attrs: any;
261
279
  slots: Readonly<{
262
280
  default?(props: {
281
+ objects: import('@graffiti-garden/api').GraffitiObject<Schema>[];
263
282
  results: import('@graffiti-garden/api').GraffitiObject<Schema>[];
264
283
  poll: () => void;
265
284
  isPolling: boolean;
285
+ isInitialPolling: boolean;
266
286
  }): any;
267
287
  }> & {
268
288
  default?(props: {
289
+ objects: import('@graffiti-garden/api').GraffitiObject<Schema>[];
269
290
  results: import('@graffiti-garden/api').GraffitiObject<Schema>[];
270
291
  poll: () => void;
271
292
  isPolling: boolean;
293
+ isInitialPolling: boolean;
272
294
  }): any;
273
295
  };
274
296
  emit: {};
@@ -276,20 +298,25 @@ export declare const GraffitiRecoverOrphans: <Schema extends import('json-schema
276
298
  props: {
277
299
  schema: Schema;
278
300
  session: GraffitiSession;
301
+ autopoll?: boolean | undefined;
279
302
  } & import('vue').PublicProps;
280
303
  expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
281
304
  attrs: any;
282
305
  slots: Readonly<{
283
306
  default?(props: {
307
+ objects: import('@graffiti-garden/api').GraffitiObject<Schema>[];
284
308
  results: import('@graffiti-garden/api').GraffitiObject<Schema>[];
285
309
  poll: () => void;
286
310
  isPolling: boolean;
311
+ isInitialPolling: boolean;
287
312
  }): any;
288
313
  }> & {
289
314
  default?(props: {
315
+ objects: import('@graffiti-garden/api').GraffitiObject<Schema>[];
290
316
  results: import('@graffiti-garden/api').GraffitiObject<Schema>[];
291
317
  poll: () => void;
292
318
  isPolling: boolean;
319
+ isInitialPolling: boolean;
293
320
  }): any;
294
321
  };
295
322
  emit: {};
@@ -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;;;;;;;;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;;;;;;;;;;;;;;cAExC,KAAK;SAAiB,CAAC;CA6JtE,CAAC;AAC/B;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;2BAzKO,KAAK;;;;;;;;;;;;;;;;;;;;cACO,KAAK;SAAiB,CAAC;CAwKzB,CAAC"}
@@ -1,2 +1,2 @@
1
- "use strict";var $=Object.defineProperty;var M=(e,t,r)=>t in e?$(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var f=(e,t,r)=>M(e,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("vue"),N=require("@graffiti-garden/wrapper-synchronize"),w=Symbol(),R=Symbol();function g(){const e=s.inject(w);if(!e)throw new Error("No Graffiti instance provided, did you forget to install the plugin?");return e}function C(){return g()}function y(){const e=s.inject(R);if(!e)throw new Error("No Graffiti session provided, did you forget to install the plugin?");return e}var L=class S extends Error{constructor(t){super(t),this.name="GraffitiErrorNotFound",Object.setPrototypeOf(this,S.prototype)}};class k{constructor(t){f(this,"poll",async t=>{let r;const o=this.getter;try{r=await o()}catch{this.getter===o&&t(null);return}this.getter===o&&t({object:r})});this.getter=t}clear(){}}class P{constructor(t){f(this,"iterator");f(this,"continue");f(this,"poll",async t=>{if(!this.iterator)if(this.continue)try{this.iterator=this.continue()}catch(r){if(r instanceof L)t("clear"),this.iterator=this.streamFactory();else throw r}else this.iterator=this.streamFactory();for(;this.iterator;){const r=this.iterator,o=await r.next();if(r===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}t(o.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 q{constructor(){f(this,"entry",s.ref())}get result(){return s.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){f(this,"results",s.ref([]));f(this,"resultsRaw",new Map);f(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,r)=>(r.tombstone||t.push(r.object),t),[])}onEntry(t){if(!t)return;if(t==="clear"){this.clear();return}const r=this.resultsRaw.get(t.object.url);E(t,r)&&(this.resultsRaw.set(t.object.url,t),this.batchFlattenTimer||(this.batchFlattenTimer=setTimeout(()=>{this.flattenResults(),this.batchFlattenTimer=void 0},0)))}}function b(e,t,r,o){let i;async function a(){i=r();for await(const l of i){if(l.error){console.error(l.error);continue}e.onEntry(l)}}const n=()=>t.poll(e.onEntry.bind(e)),c=s.ref(!1);return s.watch(o,async(l,u)=>{if(JSON.stringify(l)!==JSON.stringify(u)){i==null||i.return(null),e.clear(),t.clear(),a(),c.value=!0;try{await n()}finally{c.value=!1}}},{immediate:!0}),s.onScopeDispose(()=>i==null?void 0:i.return(null)),{poll:n,isPolling:c}}function O(e,t){return()=>{const r=s.toValue(t);return r===void 0?e==null?void 0:e.value:r}}function d(e){return e.map(t=>t())}function _(e,t,r){const o=g(),i=y(),a=()=>s.toValue(e),n=()=>s.toValue(t),c=O(i,r),l=[a,n,c],u=()=>o.synchronizeDiscover(...d(l)),h=()=>o.discover(...d(l)),p=new F(o),m=new P(h),{poll:v,isPolling:G}=b(p,m,u,l);return{results:p.results,poll:v,isPolling:G}}function j(e,t,r){const o=g(),i=y(),a=()=>s.toValue(e),n=()=>s.toValue(t),c=O(i,r),l=[a,n,c],u=()=>o.synchronizeGet(...d(l)),h=new q,p=()=>o.get(...d(l)),m=new k(p),{poll:v,isPolling:G}=b(h,m,u,l);return{result:h.result,poll:v,isPolling:G}}function z(e,t){const r=g(),a=[()=>s.toValue(e),()=>s.toValue(t)],n=()=>r.synchronizeRecoverOrphans(...d(a)),c=new F(r),l=()=>r.recoverOrphans(...d(a)),u=new P(l),{poll:h,isPolling:p}=b(c,u,n,a);return{results:c.results,poll:h,isPolling:p}}const T=s.defineComponent({__name:"Discover",props:{channels:{},schema:{},session:{}},setup(e){const t=e,{results:r,poll:o,isPolling:i}=_(s.toRef(t,"channels"),s.toRef(t,"schema"),s.toRef(t,"session"));return(a,n)=>s.renderSlot(a.$slots,"default",{results:s.unref(r),poll:s.unref(o),isPolling:s.unref(i)})}}),D=s.defineComponent({__name:"Get",props:{url:{},schema:{},session:{}},setup(e){const t=e,{result:r,poll:o,isPolling:i}=j(s.toRef(t,"url"),s.toRef(t,"schema"),s.toRef(t,"session"));return(a,n)=>s.renderSlot(a.$slots,"default",{result:s.unref(r),poll:s.unref(o),isPolling:s.unref(i)})}}),V=s.defineComponent({__name:"RecoverOrphans",props:{schema:{},session:{}},setup(e){const t=e,{results:r,poll:o,isPolling:i}=z(s.toRef(t,"schema"),s.toRef(t,"session"));return(a,n)=>s.renderSlot(a.$slots,"default",{results:s.unref(r),poll:s.unref(o),isPolling:s.unref(i)})}}),A={install(e,t){const r=t.graffiti,o=new N.GraffitiSynchronize(r),i=s.ref(void 0);o.sessionEvents.addEventListener("initialized",async a=>{const n=a.detail;if(n&&n.error&&console.error(n.error),n&&n.href){const c=e.config.globalProperties.$router;if(c){const l=c.options.history.base,u=new URL(n.href);u.pathname.startsWith(l)&&(u.pathname=u.pathname.slice(l.length)),await c.replace(u.pathname+u.search+u.hash)}}i.value||(i.value=null)}),o.sessionEvents.addEventListener("login",a=>{const n=a.detail;if(n.error){console.error("Error logging in:"),console.error(n.error);return}else i.value=n.session}),o.sessionEvents.addEventListener("logout",a=>{const n=a.detail;n.error?(console.error("Error logging out:"),console.error(n.error)):i.value=null}),e.provide(w,o),e.provide(R,i),e.component("GraffitiDiscover",T),e.component("GraffitiGet",D),e.component("GraffitiRecoverOrphans",V),e.config.globalProperties.$graffiti=o,e.config.globalProperties.$graffitiSession=i}},J=T,K=D,U=V;exports.GraffitiDiscover=J;exports.GraffitiGet=K;exports.GraffitiPlugin=A;exports.GraffitiRecoverOrphans=U;exports.useGraffiti=C;exports.useGraffitiDiscover=_;exports.useGraffitiGet=j;exports.useGraffitiRecoverOrphans=z;exports.useGraffitiSession=y;exports.useGraffitiSynchronize=g;
1
+ "use strict";var U=Object.defineProperty;var $=(t,e,s)=>e in t?U(t,e,{enumerable:!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;
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) {\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 const poll = () => poller.poll(reducer.onEntry.bind(reducer));\n\n const isPolling = 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 isPolling.value = true;\n try {\n await poll();\n } finally {\n isPolling.value = false;\n }\n },\n {\n immediate: true,\n },\n );\n onScopeDispose(() => synchronizeIterator?.return(null));\n\n return { poll, isPolling };\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): {\n results: Ref<GraffitiObject<Schema>[]>;\n poll: () => Promise<void>;\n isPolling: 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, isPolling } = makeComposable<Schema>(\n reducer,\n poller,\n synchronizeFactory,\n argGetters,\n );\n\n return {\n /**\n * A [Ref](https://vuejs.org/api/reactivity-core.html#ref) that contains\n * an array of Graffiti objects. All tombstoned objects have been filtered out.\n */\n results: 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 poll is currently running.\n * Useful to show a loading spinner or disable a button.\n */\n isPolling,\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): {\n result: Ref<GraffitiObject<Schema> | null | undefined>;\n poll: () => Promise<void>;\n isPolling: 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, isPolling } = makeComposable<Schema>(\n reducer,\n poller,\n synchronizeFactory,\n argGetters,\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 result: 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 poll is currently running.\n * Useful to show a loading spinner or disable a button.\n */\n isPolling,\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): {\n results: Ref<GraffitiObject<Schema>[]>;\n poll: () => Promise<void>;\n isPolling: 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, isPolling } = makeComposable<Schema>(\n reducer,\n poller,\n synchronizeFactory,\n argGetters,\n );\n\n return {\n /**\n * A [Ref](https://vuejs.org/api/reactivity-core.html#ref) that contains\n * an array of Graffiti objects. All tombstoned objects have been filtered out.\n */\n results: 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 poll is currently running.\n * Useful to show a loading spinner or disable a button.\n */\n isPolling,\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}>();\n\ndefineSlots<{\n default?(props: {\n results: GraffitiObject<Schema>[];\n poll: () => void;\n isPolling: boolean;\n }): any;\n}>();\n\nconst { results, poll, isPolling } = useGraffitiDiscover<Schema>(\n toRef(props, \"channels\"),\n toRef(props, \"schema\"),\n toRef(props, \"session\"),\n);\n</script>\n\n<template>\n <slot :results=\"results\" :poll=\"poll\" :isPolling=\"isPolling\"></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}>();\n\ndefineSlots<{\n default?(props: {\n result: GraffitiObject<Schema> | undefined | null;\n poll: () => void;\n isPolling: boolean;\n }): any;\n}>();\n\nconst { result, poll, isPolling } = useGraffitiGet<Schema>(\n toRef(props, \"url\"),\n toRef(props, \"schema\"),\n toRef(props, \"session\"),\n);\n</script>\n\n<template>\n <slot :result=\"result\" :poll=\"poll\" :isPolling=\"isPolling\"></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}>();\n\ndefineSlots<{\n default?(props: {\n results: GraffitiObject<Schema>[];\n poll: () => void;\n isPolling: boolean;\n }): any;\n}>();\n\nconst { results, poll, isPolling } = useGraffitiRecoverOrphans<Schema>(\n toRef(props, \"schema\"),\n toRef(props, \"session\"),\n);\n</script>\n\n<template>\n <slot :results=\"results\" :poll=\"poll\" :isPolling=\"isPolling\"></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","synchronizeIterator","pollSynchronize","poll","isPolling","watch","newValue","oldValue","onScopeDispose","toSessionGetter","sessionInjected","sessionValue","toValue","callGetters","getters","fn","useGraffitiDiscover","channels","schema","channelsGetter","schemaGetter","sessionGetter","argGetters","useGraffitiGet","locationOrUri","locationOrUriGetter","useGraffitiRecoverOrphans","props","__props","results","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,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EAAA,UAAU,cAAeW,CAAG,EAC5BX,EAAA,UAAU,yBAA0BY,CAAc,EAClDZ,EAAA,OAAO,iBAAiB,UAAYjE,EACpCiE,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 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,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