@graffiti-garden/wrapper-vue 0.7.1 → 1.0.3

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.
Files changed (70) hide show
  1. package/README.md +2 -3
  2. package/dist/browser/ajv-D_HICdxS.mjs +4447 -0
  3. package/dist/browser/ajv-D_HICdxS.mjs.map +1 -0
  4. package/dist/browser/plugin.mjs +999 -941
  5. package/dist/browser/plugin.mjs.map +1 -1
  6. package/dist/node/components/ActorToHandle.vue.d.ts +23 -0
  7. package/dist/node/components/ActorToHandle.vue.d.ts.map +1 -0
  8. package/dist/node/{Discover.vue.d.ts → components/Discover.vue.d.ts} +4 -4
  9. package/dist/node/components/Discover.vue.d.ts.map +1 -0
  10. package/dist/node/{Get.vue.d.ts → components/Get.vue.d.ts} +2 -5
  11. package/dist/node/components/Get.vue.d.ts.map +1 -0
  12. package/dist/node/components/GetMedia.vue.d.ts +36 -0
  13. package/dist/node/components/GetMedia.vue.d.ts.map +1 -0
  14. package/dist/node/components/HandleToActor.vue.d.ts +23 -0
  15. package/dist/node/components/HandleToActor.vue.d.ts.map +1 -0
  16. package/dist/node/components/ObjectInfo.vue.d.ts +7 -0
  17. package/dist/node/components/ObjectInfo.vue.d.ts.map +1 -0
  18. package/dist/node/composables/actor-to-handle.d.ts +25 -0
  19. package/dist/node/composables/actor-to-handle.d.ts.map +1 -0
  20. package/dist/node/composables/discover.d.ts +38 -0
  21. package/dist/node/composables/discover.d.ts.map +1 -0
  22. package/dist/node/composables/get-media.d.ts +31 -0
  23. package/dist/node/composables/get-media.d.ts.map +1 -0
  24. package/dist/node/composables/get.d.ts +28 -0
  25. package/dist/node/composables/get.d.ts.map +1 -0
  26. package/dist/node/composables/handle-to-actor.d.ts +25 -0
  27. package/dist/node/composables/handle-to-actor.d.ts.map +1 -0
  28. package/dist/node/composables/resolve-string.d.ts +6 -0
  29. package/dist/node/composables/resolve-string.d.ts.map +1 -0
  30. package/dist/node/globals.d.ts +3 -5
  31. package/dist/node/globals.d.ts.map +1 -1
  32. package/dist/node/plugin.d.ts +174 -75
  33. package/dist/node/plugin.d.ts.map +1 -1
  34. package/dist/node/plugin.js +1 -1
  35. package/dist/node/plugin.js.map +1 -1
  36. package/dist/node/plugin.mjs +468 -331
  37. package/dist/node/plugin.mjs.map +1 -1
  38. package/package.json +15 -14
  39. package/src/components/ActorToHandle.vue +16 -0
  40. package/src/{Discover.vue → components/Discover.vue} +15 -9
  41. package/src/{Get.vue → components/Get.vue} +7 -11
  42. package/src/components/GetMedia.vue +75 -0
  43. package/src/components/HandleToActor.vue +16 -0
  44. package/src/components/ObjectInfo.vue +127 -0
  45. package/src/composables/actor-to-handle.ts +32 -0
  46. package/src/composables/discover.ts +202 -0
  47. package/src/composables/get-media.ts +116 -0
  48. package/src/composables/get.ts +109 -0
  49. package/src/composables/handle-to-actor.ts +32 -0
  50. package/src/composables/resolve-string.ts +46 -0
  51. package/src/globals.ts +24 -2
  52. package/src/plugin.ts +84 -29
  53. package/dist/browser/ajv-C30pimY5.mjs +0 -4400
  54. package/dist/browser/ajv-C30pimY5.mjs.map +0 -1
  55. package/dist/browser/index-CWfNKdDL.mjs +0 -424
  56. package/dist/browser/index-CWfNKdDL.mjs.map +0 -1
  57. package/dist/node/Discover.vue.d.ts.map +0 -1
  58. package/dist/node/Get.vue.d.ts.map +0 -1
  59. package/dist/node/RecoverOrphans.vue.d.ts +0 -31
  60. package/dist/node/RecoverOrphans.vue.d.ts.map +0 -1
  61. package/dist/node/composables.d.ts +0 -75
  62. package/dist/node/composables.d.ts.map +0 -1
  63. package/dist/node/pollers.d.ts +0 -28
  64. package/dist/node/pollers.d.ts.map +0 -1
  65. package/dist/node/reducers.d.ts +0 -37
  66. package/dist/node/reducers.d.ts.map +0 -1
  67. package/src/RecoverOrphans.vue +0 -37
  68. package/src/composables.ts +0 -343
  69. package/src/pollers.ts +0 -119
  70. package/src/reducers.ts +0 -124
@@ -1,7 +1,10 @@
1
1
  import { Plugin, Ref } from 'vue';
2
- import { default as Discover } from './Discover.vue';
3
- import { default as Get } from './Get.vue';
4
- import { default as RecoverOrphans } from './RecoverOrphans.vue';
2
+ import { default as Discover } from './components/Discover.vue';
3
+ import { default as Get } from './components/Get.vue';
4
+ import { default as GetMedia } from './components/GetMedia.vue';
5
+ import { default as ActorToHandle } from './components/ActorToHandle.vue';
6
+ import { default as HandleToActor } from './components/HandleToActor.vue';
7
+ import { default as ObjectInfo } from './components/ObjectInfo.vue';
5
8
  import { Graffiti, GraffitiSession } from '@graffiti-garden/api';
6
9
  declare module "vue" {
7
10
  interface ComponentCustomProperties {
@@ -37,7 +40,10 @@ declare module "vue" {
37
40
  interface GlobalComponents {
38
41
  GraffitiDiscover: typeof Discover;
39
42
  GraffitiGet: typeof Get;
40
- GraffitiRecoverOrphans: typeof RecoverOrphans;
43
+ GraffitiGetMedia: typeof GetMedia;
44
+ GraffitiActorToHandle: typeof ActorToHandle;
45
+ GraffitiHandleToActor: typeof HandleToActor;
46
+ GraffitiObjectInfo: typeof ObjectInfo;
41
47
  }
42
48
  }
43
49
  export type { ComponentCustomProperties } from 'vue';
@@ -53,10 +59,6 @@ export interface GraffitiPluginOptions {
53
59
  * and in setup functions as {@link useGraffiti}.
54
60
  * You must interact with Graffiti through these wrapped instances
55
61
  * to enable reactivity.
56
- *
57
- * You'll likely want to use the [federated implementation](https://github.com/graffiti-garden/implementation-federated).
58
- * However, you could also use the [local implementation](https://github.com/graffiti-garden/implementation-local)
59
- * for testing. Other implementations may be available in the future.
60
62
  */
61
63
  graffiti: Graffiti;
62
64
  }
@@ -76,19 +78,27 @@ export interface GraffitiPluginOptions {
76
78
  * | --- | --- | --- |
77
79
  * | [discover](https://api.graffiti.garden/classes/Graffiti.html#discover) | {@link useGraffitiDiscover} | {@link GraffitiDiscover} |
78
80
  * | [get](https://api.graffiti.garden/classes/Graffiti.html#get) | {@link useGraffitiGet} | {@link GraffitiGet} |
79
- * | [recoverOrphans](https://api.graffiti.garden/classes/Graffiti.html#recoverorphans) | {@link useGraffitiRecoverOrphans} | {@link GraffitiRecoverOrphans} |
81
+ * | [getMedia](https://api.graffiti.garden/classes/Graffiti.html#getmedia) | {@link useGraffitiGetMedia} | {@link GraffitiGetMedia} |
82
+ * | [actorToHandle](https://api.graffiti.garden/classes/Graffiti.html#actortohandle) | {@link useGraffitiActorToHandle} | {@link GraffitiActorToHandle} |
83
+ * | [handleToActor](https://api.graffiti.garden/classes/Graffiti.html#handletoactor) | {@link useGraffitiHandleToActor} | {@link GraffitiHandleToActor} |
80
84
  *
81
85
  * The plugin also exposes a global [Graffiti](https://api.graffiti.garden/classes/Graffiti.html) instance
82
86
  * and keeps track of the global [GraffitiSession](https://api.graffiti.garden/interfaces/GraffitiSession.html)
83
87
  * state as a reactive variable.
84
88
  * They are available in templates as global variables or in setup functions as
85
- * composable functions.
89
+ * getter functions.
86
90
  *
87
- * | Global variabale | [Composable](https://vuejs.org/guide/reusability/composables.html) |
91
+ * | Global variabale | Getter |
88
92
  * | --- | --- |
89
93
  * | {@link ComponentCustomProperties.$graffiti | $graffiti } | {@link useGraffiti} |
90
94
  * | {@link ComponentCustomProperties.$graffitiSession | $graffitiSession } | {@link useGraffitiSession} |
91
95
  *
96
+ * Finally, the plugin exposes an additional component, {@link GraffitiObjectInfo}
97
+ * that can be use to generically display a Graffiti object for debugging purposes.
98
+ * {@link GraffitiDiscover} and {@link GraffitiGet} show this output as
99
+ * [fallback content](https://vuejs.org/guide/components/slots.html#fallback-content)
100
+ * if no template is provided
101
+ *
92
102
  * [See the README for installation instructions](/).
93
103
  *
94
104
  * You can [try out live examples](/examples/), but basic usage looks like this:
@@ -110,7 +120,7 @@ export interface GraffitiPluginOptions {
110
120
  * <template>
111
121
  * <button
112
122
  * v-if="$graffitiSession.value"
113
- * @click="$graffiti.put({
123
+ * @click="$graffiti.post({
114
124
  * value: { content: 'Hello, world!' },
115
125
  * channels: [ 'my-channel' ]
116
126
  * }, $graffitiSession.value)"
@@ -122,7 +132,7 @@ export interface GraffitiPluginOptions {
122
132
  * </button>
123
133
  *
124
134
  * <GraffitiDiscover
125
- * v-slot="{ results }"
135
+ * v-slot="{ objects }"
126
136
  * :channels="[ 'my-channel' ]"
127
137
  * :schema="{
128
138
  * properties: {
@@ -137,10 +147,10 @@ export interface GraffitiPluginOptions {
137
147
  * >
138
148
  * <ul>
139
149
  * <li
140
- * v-for="result in results"
141
- * :key="$graffiti.objectToUri(result)"
150
+ * v-for="object in objects"
151
+ * :key="object.url"
142
152
  * >
143
- * {{ result.value.content }}
153
+ * {{ object.value.content }}
144
154
  * </li>
145
155
  * </ul>
146
156
  * </GraffitiDiscover>
@@ -148,31 +158,38 @@ export interface GraffitiPluginOptions {
148
158
  * ```
149
159
  */
150
160
  export declare const GraffitiPlugin: Plugin<GraffitiPluginOptions>;
151
- export * from './composables';
161
+ export { useGraffitiActorToHandle } from './composables/actor-to-handle';
162
+ export { useGraffitiHandleToActor } from './composables/handle-to-actor';
163
+ export { useGraffitiDiscover } from './composables/discover';
164
+ export { useGraffitiGet } from './composables/get';
165
+ export { useGraffitiGetMedia } from './composables/get-media';
152
166
  export { useGraffiti, useGraffitiSynchronize, useGraffitiSession, } from './globals';
153
167
  /**
154
168
  * The [Graffiti.discover](https://api.graffiti.garden/classes/Graffiti.html#discover)
155
169
  * method as a reactive [renderless component](https://vuejs.org/guide/components/slots#renderless-components)
156
170
  * for use in Vue templates.
157
171
  *
158
- * Its props and slots are identical to the arguments and return values of
159
- * the composable {@link useGraffitiDiscover}.
172
+ * Its props and [slots props](https://vuejs.org/guide/components/slots.html#scoped-slots)
173
+ * are identical to the arguments and return values of
174
+ * the composable {@link useGraffitiDiscover}. If no template is provided to
175
+ * the default slot, [fallback content](https://vuejs.org/guide/components/slots.html#fallback-content)
176
+ * will display the objects using {@link GraffitiObjectInfo} for debugging.
160
177
  */
161
178
  export declare const GraffitiDiscover: <Schema extends import('json-schema-to-ts').JSONSchema>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: {
162
- attrs: any;
163
179
  slots: Readonly<{
164
180
  default?(props: {
165
181
  objects: import('@graffiti-garden/api').GraffitiObject<Schema>[];
166
- poll: () => void;
167
- isInitialPolling: boolean;
182
+ poll: () => Promise<void>;
183
+ isFirstPoll: boolean;
168
184
  }): any;
169
185
  }> & {
170
186
  default?(props: {
171
187
  objects: import('@graffiti-garden/api').GraffitiObject<Schema>[];
172
- poll: () => void;
173
- isInitialPolling: boolean;
188
+ poll: () => Promise<void>;
189
+ isFirstPoll: boolean;
174
190
  }): any;
175
191
  };
192
+ attrs: any;
176
193
  emit: {};
177
194
  }, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
178
195
  props: {
@@ -186,14 +203,14 @@ export declare const GraffitiDiscover: <Schema extends import('json-schema-to-ts
186
203
  slots: Readonly<{
187
204
  default?(props: {
188
205
  objects: import('@graffiti-garden/api').GraffitiObject<Schema>[];
189
- poll: () => void;
190
- isInitialPolling: boolean;
206
+ poll: () => Promise<void>;
207
+ isFirstPoll: boolean;
191
208
  }): any;
192
209
  }> & {
193
210
  default?(props: {
194
211
  objects: import('@graffiti-garden/api').GraffitiObject<Schema>[];
195
- poll: () => void;
196
- isInitialPolling: boolean;
212
+ poll: () => Promise<void>;
213
+ isFirstPoll: boolean;
197
214
  }): any;
198
215
  };
199
216
  emit: {};
@@ -205,45 +222,43 @@ export declare const GraffitiDiscover: <Schema extends import('json-schema-to-ts
205
222
  * method as a reactive [renderless component](https://vuejs.org/guide/components/slots#renderless-components)
206
223
  * for use in Vue templates.
207
224
  *
208
- * Its props and slots are identical to the arguments and return values of
209
- * the composable {@link useGraffitiGet}.
225
+ * Its props and [slots props](https://vuejs.org/guide/components/slots.html#scoped-slots)
226
+ * are identical to the arguments and return values of
227
+ * the composable {@link useGraffitiGet}. If no template is provided to
228
+ * the default slot, [fallback content](https://vuejs.org/guide/components/slots.html#fallback-content)
229
+ * will display the object using {@link GraffitiObjectInfo} for debugging.
210
230
  */
211
231
  export declare const GraffitiGet: <Schema extends import('json-schema-to-ts').JSONSchema>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: {
212
- attrs: any;
213
232
  slots: Readonly<{
214
233
  default?(props: {
215
234
  object: import('@graffiti-garden/api').GraffitiObject<Schema> | undefined | null;
216
- poll: () => void;
217
- isInitialPolling: boolean;
235
+ poll: () => Promise<void>;
218
236
  }): any;
219
237
  }> & {
220
238
  default?(props: {
221
239
  object: import('@graffiti-garden/api').GraffitiObject<Schema> | undefined | null;
222
- poll: () => void;
223
- isInitialPolling: boolean;
240
+ poll: () => Promise<void>;
224
241
  }): any;
225
242
  };
243
+ attrs: any;
226
244
  emit: {};
227
245
  }, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
228
246
  props: {
229
247
  url: string | import('@graffiti-garden/api').GraffitiObjectUrl;
230
248
  schema: Schema;
231
249
  session?: (GraffitiSession | null) | undefined;
232
- autopoll?: boolean | undefined;
233
250
  } & import('vue').PublicProps;
234
251
  expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
235
252
  attrs: any;
236
253
  slots: Readonly<{
237
254
  default?(props: {
238
255
  object: import('@graffiti-garden/api').GraffitiObject<Schema> | undefined | null;
239
- poll: () => void;
240
- isInitialPolling: boolean;
256
+ poll: () => Promise<void>;
241
257
  }): any;
242
258
  }> & {
243
259
  default?(props: {
244
260
  object: import('@graffiti-garden/api').GraffitiObject<Schema> | undefined | null;
245
- poll: () => void;
246
- isInitialPolling: boolean;
261
+ poll: () => Promise<void>;
247
262
  }): any;
248
263
  };
249
264
  emit: {};
@@ -251,52 +266,136 @@ export declare const GraffitiGet: <Schema extends import('json-schema-to-ts').JS
251
266
  __ctx?: Awaited<typeof __VLS_setup>;
252
267
  };
253
268
  /**
254
- * The [Graffiti.recoverOrphans](https://api.graffiti.garden/classes/Graffiti.html#recoverorphans)
269
+ * The [Graffiti.getMedia](https://api.graffiti.garden/classes/Graffiti.html#getmedia)
255
270
  * method as a reactive [renderless component](https://vuejs.org/guide/components/slots#renderless-components)
256
271
  * for use in Vue templates.
257
272
  *
258
- * Its props and slots are identical to the arguments and return values of
259
- * the composable {@link useGraffitiRecoverOrphans}.
273
+ * Its props and [slots props](https://vuejs.org/guide/components/slots.html#scoped-slots)
274
+ * are identical to the arguments and return values of
275
+ * the composable {@link useGraffitiGetMedia}. If no template is provided to
276
+ * the default slot, [fallback content](https://vuejs.org/guide/components/slots.html#fallback-content)
277
+ * will display the media in an appropriate container based on its media type.
260
278
  */
261
- export declare const GraffitiRecoverOrphans: <Schema extends import('json-schema-to-ts').JSONSchema>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: {
262
- attrs: any;
263
- slots: Readonly<{
279
+ export declare const GraffitiGetMedia: {
280
+ new (...args: any[]): import('vue').CreateComponentPublicInstanceWithMixins<Readonly<{
281
+ url: string;
282
+ requirements: import('@graffiti-garden/api').GraffitiMediaRequirements;
283
+ session?: GraffitiSession | null;
284
+ }> & Readonly<{}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, import('vue').PublicProps, {}, false, {}, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, {}, any, import('vue').ComponentProvideOptions, {
285
+ P: {};
286
+ B: {};
287
+ D: {};
288
+ C: {};
289
+ M: {};
290
+ Defaults: {};
291
+ }, Readonly<{
292
+ url: string;
293
+ requirements: import('@graffiti-garden/api').GraffitiMediaRequirements;
294
+ session?: GraffitiSession | null;
295
+ }> & Readonly<{}>, {}, {}, {}, {}, {}>;
296
+ __isFragment?: never;
297
+ __isTeleport?: never;
298
+ __isSuspense?: never;
299
+ } & import('vue').ComponentOptionsBase<Readonly<{
300
+ url: string;
301
+ requirements: import('@graffiti-garden/api').GraffitiMediaRequirements;
302
+ session?: GraffitiSession | null;
303
+ }> & Readonly<{}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, {}, {}, string, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, import('vue').ComponentProvideOptions> & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & (new () => {
304
+ $slots: Readonly<{
264
305
  default?(props: {
265
- objects: import('@graffiti-garden/api').GraffitiObject<Schema>[];
266
- poll: () => void;
267
- isInitialPolling: boolean;
306
+ media: (import('@graffiti-garden/api').GraffitiMedia & {
307
+ dataUrl: string;
308
+ }) | null | undefined;
309
+ poll: () => Promise<void>;
268
310
  }): any;
269
311
  }> & {
270
312
  default?(props: {
271
- objects: import('@graffiti-garden/api').GraffitiObject<Schema>[];
272
- poll: () => void;
273
- isInitialPolling: boolean;
313
+ media: (import('@graffiti-garden/api').GraffitiMedia & {
314
+ dataUrl: string;
315
+ }) | null | undefined;
316
+ poll: () => Promise<void>;
274
317
  }): any;
275
318
  };
276
- emit: {};
277
- }, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
278
- props: {
279
- schema: Schema;
280
- session: GraffitiSession;
281
- autopoll?: boolean | undefined;
282
- } & import('vue').PublicProps;
283
- expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
284
- attrs: any;
285
- slots: Readonly<{
286
- default?(props: {
287
- objects: import('@graffiti-garden/api').GraffitiObject<Schema>[];
288
- poll: () => void;
289
- isInitialPolling: boolean;
319
+ });
320
+ /**
321
+ * The [Graffiti.actorToHandle](https://api.graffiti.garden/classes/Graffiti.html#actortohandle)
322
+ * method as a reactive [renderless component](https://vuejs.org/guide/components/slots#renderless-components)
323
+ * for use in Vue templates.
324
+ *
325
+ * Its props and [slots props](https://vuejs.org/guide/components/slots.html#scoped-slots)
326
+ * are identical to the arguments and return values of
327
+ * the composable {@link useGraffitiActorToHandle}. If no template is provided to
328
+ * the default slot, [fallback content](https://vuejs.org/guide/components/slots.html#fallback-content)
329
+ * will display the actor's handle.
330
+ */
331
+ export declare const GraffitiActorToHandle: {
332
+ new (...args: any[]): import('vue').CreateComponentPublicInstanceWithMixins<Readonly<{
333
+ actor: string;
334
+ }> & Readonly<{}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, import('vue').PublicProps, {}, false, {}, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, {}, any, import('vue').ComponentProvideOptions, {
335
+ P: {};
336
+ B: {};
337
+ D: {};
338
+ C: {};
339
+ M: {};
340
+ Defaults: {};
341
+ }, Readonly<{
342
+ actor: string;
343
+ }> & Readonly<{}>, {}, {}, {}, {}, {}>;
344
+ __isFragment?: never;
345
+ __isTeleport?: never;
346
+ __isSuspense?: never;
347
+ } & import('vue').ComponentOptionsBase<Readonly<{
348
+ actor: string;
349
+ }> & Readonly<{}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, {}, {}, string, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, import('vue').ComponentProvideOptions> & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & (new () => {
350
+ $slots: {
351
+ default?(_: {
352
+ handle: string | null | undefined;
290
353
  }): any;
291
- }> & {
292
- default?(props: {
293
- objects: import('@graffiti-garden/api').GraffitiObject<Schema>[];
294
- poll: () => void;
295
- isInitialPolling: boolean;
354
+ };
355
+ });
356
+ /**
357
+ * The [Graffiti.handleToActor](https://api.graffiti.garden/classes/Graffiti.html#handletoactor)
358
+ * method as a reactive [renderless component](https://vuejs.org/guide/components/slots#renderless-components)
359
+ * for use in Vue templates.
360
+ *
361
+ * Its props and [slots props](https://vuejs.org/guide/components/slots.html#scoped-slots)
362
+ * are identical to the arguments and return values of
363
+ * the composable {@link useGraffitiHandleToActor}. If no template is provided to
364
+ * the default slot, [fallback content](https://vuejs.org/guide/components/slots.html#fallback-content)
365
+ * will display the actor DID.
366
+ */
367
+ export declare const GraffitiHandleToActor: {
368
+ new (...args: any[]): import('vue').CreateComponentPublicInstanceWithMixins<Readonly<{
369
+ handle: string;
370
+ }> & Readonly<{}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, import('vue').PublicProps, {}, false, {}, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, {}, any, import('vue').ComponentProvideOptions, {
371
+ P: {};
372
+ B: {};
373
+ D: {};
374
+ C: {};
375
+ M: {};
376
+ Defaults: {};
377
+ }, Readonly<{
378
+ handle: string;
379
+ }> & Readonly<{}>, {}, {}, {}, {}, {}>;
380
+ __isFragment?: never;
381
+ __isTeleport?: never;
382
+ __isSuspense?: never;
383
+ } & import('vue').ComponentOptionsBase<Readonly<{
384
+ handle: string;
385
+ }> & Readonly<{}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, {}, {}, string, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, import('vue').ComponentProvideOptions> & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & (new () => {
386
+ $slots: {
387
+ default?(_: {
388
+ actor: string | null | undefined;
296
389
  }): any;
297
390
  };
298
- emit: {};
299
- }>) => import('vue').VNode & {
300
- __ctx?: Awaited<typeof __VLS_setup>;
301
- };
391
+ });
392
+ /**
393
+ * Displays a Graffiti object and all of its properties for
394
+ * debugging purposes.
395
+ */
396
+ export declare const GraffitiObjectInfo: import('vue').DefineComponent<{
397
+ object: import('@graffiti-garden/api').GraffitiObjectBase | null | undefined;
398
+ }, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{
399
+ object: import('@graffiti-garden/api').GraffitiObjectBase | null | undefined;
400
+ }> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
302
401
  //# sourceMappingURL=plugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceR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@@ -1,2 +1,2 @@
1
- "use strict";var $=Object.defineProperty;var I=(e,t,o)=>t in e?$(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o;var p=(e,t,o)=>I(e,typeof t!="symbol"?t+"":t,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("vue"),M=require("@graffiti-garden/wrapper-synchronize"),G={};function v(){const e=G.graffitiSynchronize;if(!e)throw new Error("No Graffiti instance provided, did you forget to install the plugin?");return e}function N(){return v()}function w(){const e=G.graffitiSession;if(!e)throw new Error("No Graffiti session provided, did you forget to install the plugin?");return e}var B=class S extends Error{constructor(t){super(t),this.name="GraffitiErrorNotFound",Object.setPrototypeOf(this,S.prototype)}};class C{constructor(t){p(this,"poll",async t=>{let o;const s=this.getter;try{o=await s()}catch{this.getter===s&&t(null);return}this.getter===s&&t({object:o})});this.getter=t}clear(){}}class P{constructor(t){p(this,"iterator");p(this,"continue");p(this,"poll",async t=>{if(!this.iterator)if(this.continue)try{this.iterator=this.continue()}catch(o){if(o instanceof B)t("clear"),this.iterator=this.streamFactory();else throw o}else this.iterator=this.streamFactory();for(;this.iterator;){const o=this.iterator,s=await o.next();if(o===this.iterator){if(s.done){s.value&&(this.iterator=void 0,this.continue=s.value.continue);break}if(s.value.error){console.error(s.value.error);continue}t(s.value)}}});this.streamFactory=t}clear(){if(this.iterator){const t=this.iterator;this.iterator.return({continue:()=>t,cursor:""})}this.iterator=void 0,this.continue=void 0}}function j(e,t){return!t||e.object.lastModified>t.object.lastModified||e.object.lastModified===t.object.lastModified&&!e.tombstone&&!!t.tombstone}class L{constructor(){p(this,"entry",r.ref())}get result(){return r.computed(()=>{const t=this.entry.value;return t&&(t.tombstone?null:t.object)})}clear(){this.entry.value=void 0}onEntry(t){if(t==="clear"){this.clear();return}(!t||j(t,this.entry.value))&&(this.entry.value=t)}}class E{constructor(t){p(this,"results",r.ref([]));p(this,"resultsRaw",new Map);p(this,"batchFlattenTimer");this.graffiti=t}clear(){this.resultsRaw.clear(),this.results.value=[],clearTimeout(this.batchFlattenTimer),this.batchFlattenTimer=void 0}flattenResults(){this.results.value=Array.from(this.resultsRaw.values()).reduce((t,o)=>(o.tombstone||t.push(o.object),t),[])}onEntry(t){if(!t)return;if(t==="clear"){this.clear();return}const o=this.resultsRaw.get(t.object.url);j(t,o)&&(this.resultsRaw.set(t.object.url,t),this.batchFlattenTimer||(this.batchFlattenTimer=setTimeout(()=>{this.flattenResults(),this.batchFlattenTimer=void 0},0)))}}function R(e,t,o,s,a){let n;async function i(){n=o();for await(const f of n){if(f.error){console.error(f.error);continue}e.onEntry(f)}}let u=!1,c;const l=async()=>{if(u||!c)return;const f=c;u=!0;try{await f()}finally{if(f!==c)return;u=!1,r.toValue(a)&&l()}},h=r.ref(!1);return r.watch(s,async(f,g)=>{if(JSON.stringify(f)===JSON.stringify(g))return;n==null||n.return(null),e.clear(),t.clear(),i(),c=()=>t.poll(e.onEntry.bind(e));const m=c;u=!1,h.value=!0;try{await l()}finally{if(m!==c)return;h.value=!1}},{immediate:!0}),r.onScopeDispose(()=>{n==null||n.return(null),e.clear(),t.clear(),c=void 0}),{poll:l,isInitialPolling:h}}function F(e,t){return()=>{const o=r.toValue(t);return o===void 0?e==null?void 0:e.value:o}}function d(e){return e.map(t=>t())}function O(e,t,o,s=!1){const a=v(),n=w(),i=()=>r.toValue(e),u=()=>r.toValue(t),c=F(n,o),l=[i,u,c],h=()=>a.synchronizeDiscover(...d(l)),f=()=>a.discover(...d(l)),g=new E(a),m=new P(f),{poll:y,isInitialPolling:b}=R(g,m,h,l,s);return{objects:g.results,poll:y,isInitialPolling:b}}function _(e,t,o,s=!1){const a=v(),n=w(),i=()=>r.toValue(e),u=()=>r.toValue(t),c=F(n,o),l=[i,u,c],h=()=>a.synchronizeGet(...d(l)),f=new L,g=()=>a.get(...d(l)),m=new C(g),{poll:y,isInitialPolling:b}=R(f,m,h,l,s);return{object:f.result,poll:y,isInitialPolling:b}}function z(e,t,o=!1){const s=v(),i=[()=>r.toValue(e),()=>r.toValue(t)],u=()=>s.synchronizeRecoverOrphans(...d(i)),c=new E(s),l=()=>s.recoverOrphans(...d(i)),h=new P(l),{poll:f,isInitialPolling:g}=R(c,h,u,i,o);return{objects:c.results,poll:f,isInitialPolling:g}}const T=r.defineComponent({__name:"Discover",props:{channels:{},schema:{},session:{},autopoll:{type:Boolean}},setup(e){const t=e,{objects:o,poll:s,isInitialPolling:a}=O(r.toRef(t,"channels"),r.toRef(t,"schema"),r.toRef(t,"session"),r.toRef(t,"autopoll"));return(n,i)=>r.renderSlot(n.$slots,"default",{objects:r.unref(o),poll:r.unref(s),isInitialPolling:r.unref(a)})}}),V=r.defineComponent({__name:"Get",props:{url:{},schema:{},session:{},autopoll:{type:Boolean}},setup(e){const t=e,{object:o,poll:s,isInitialPolling:a}=_(r.toRef(t,"url"),r.toRef(t,"schema"),r.toRef(t,"session"),r.toRef(t,"autopoll"));return(n,i)=>r.renderSlot(n.$slots,"default",{object:r.unref(o),poll:r.unref(s),isInitialPolling:r.unref(a)})}}),D=r.defineComponent({__name:"RecoverOrphans",props:{schema:{},session:{},autopoll:{type:Boolean}},setup(e){const t=e,{objects:o,poll:s,isInitialPolling:a}=z(r.toRef(t,"schema"),r.toRef(t,"session"),r.toRef(t,"autopoll"));return(n,i)=>r.renderSlot(n.$slots,"default",{objects:r.unref(o),poll:r.unref(s),isInitialPolling:r.unref(a)})}}),k={install(e,t){const o=t.graffiti,s=new M.GraffitiSynchronize(o),a=r.ref(void 0);s.sessionEvents.addEventListener("initialized",async n=>{const i=n.detail;if(i&&i.error&&console.error(i.error),i&&i.href){const u=e.config.globalProperties.$router;if(u){const c=u.options.history.base,l=new URL(i.href);l.pathname.startsWith(c)&&(l.pathname=l.pathname.slice(c.length)),await u.replace(l.pathname+l.search+l.hash)}}a.value||(a.value=null)}),s.sessionEvents.addEventListener("login",n=>{const i=n.detail;if(i.error){console.error("Error logging in:"),console.error(i.error);return}else a.value=i.session}),s.sessionEvents.addEventListener("logout",n=>{const i=n.detail;i.error?(console.error("Error logging out:"),console.error(i.error)):a.value=null}),G.graffitiSynchronize=s,G.graffitiSession=a,e.component("GraffitiDiscover",T),e.component("GraffitiGet",V),e.component("GraffitiRecoverOrphans",D),e.config.globalProperties.$graffiti=s,e.config.globalProperties.$graffitiSession=a}},A=T,q=V,J=D;exports.GraffitiDiscover=A;exports.GraffitiGet=q;exports.GraffitiPlugin=k;exports.GraffitiRecoverOrphans=J;exports.useGraffiti=N;exports.useGraffitiDiscover=O;exports.useGraffitiGet=_;exports.useGraffitiRecoverOrphans=z;exports.useGraffitiSession=w;exports.useGraffitiSynchronize=v;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),_=require("@graffiti-garden/wrapper-synchronize");var G=class R extends Error{constructor(a){super(a),this.name="GraffitiErrorNotFound",Object.setPrototypeOf(this,R.prototype)}};const E={};function W(t){if(!E.graffitiSession)E.graffitiSession=t;else throw new Error("Graffiti session already set - plugin installed multiple times?")}function q(t){if(!E.graffitiSynchronize)E.graffitiSynchronize=t;else throw new Error("Graffiti synchronize already set - plugin installed multiple times?")}function b(){const t=E.graffitiSynchronize;if(!t)throw new Error("No Graffiti instance provided, did you forget to install the plugin?");return t}function N(){return b()}function x(){const t=E.graffitiSession;if(!t)throw new Error("No Graffiti session provided, did you forget to install the plugin?");return t}function T(t,a,n,i=!1){const l=b(),o=new Map,r=e.ref([]);let s=async()=>{};const m=async()=>s(),u=e.ref(!0);let k,p;e.onScopeDispose(()=>{k?.return(null),p?.return({continue:()=>p,cursor:""})});const y=e.ref(0);function f(c=0){setTimeout(()=>{y.value++},c)}return e.watch(()=>({args:[e.toValue(t),e.toValue(a),e.toValue(n)],refresh:y.value}),({args:c},A,w)=>{o.clear(),r.value=[],u.value=!0;const j=l.synchronizeDiscover(...c);k=j;let h,v=!0;w(()=>{v=!1,j.return(null),h?.return({continue:()=>p,cursor:""})});let g;(async()=>{for await(const d of j){if(!v)break;d.tombstone?o.delete(d.object.url):o.set(d.object.url,d.object),g||(g=new Promise($=>{setTimeout(()=>{v&&(r.value=Array.from(o.values())),g=void 0,$()},50)}))}})();let S=!1,D=()=>l.discover(...c);s=async()=>{if(!(S||!v)){S=!0;try{h=D(c[2])}catch{return f(5e3)}if(v){for(p=h;;){let d;try{d=await h.next()}catch($){return $ instanceof G?f():f(5e3)}if(!v)return;if(d.done){D=d.value.continue;break}else d.value.error&&console.error(d.value.error)}await new Promise(d=>setTimeout(d,0)),g&&await g,v&&(S=!1,u.value=!1,e.toValue(i)&&m())}}},m()},{immediate:!0}),e.watch(()=>e.toValue(i),c=>c&&m()),{objects:r,poll:m,isFirstPoll:u}}function P(t,a){const n=e.ref(void 0);return e.watch(()=>e.toValue(t),async(i,l,o)=>{let r=!0;o(()=>{r=!1}),n.value=void 0;try{const s=await a(i);r&&(n.value=s)}catch(s){if(!r)return;s instanceof G?n.value=null:console.error(s)}},{immediate:!0}),{output:n}}function L(t){return t===void 0?"Loading...":t===null?"Not found":t}function U(t){const a=N(),{output:n}=P(t,a.actorToHandle.bind(a));return{handle:n}}const V=e.defineComponent({__name:"ActorToHandle",props:{actor:{}},setup(t){const a=t,n=e.toRef(a,"actor"),{handle:i}=U(n);return(l,o)=>e.renderSlot(l.$slots,"default",{handle:e.unref(i)},()=>[e.createElementVNode("span",null,e.toDisplayString(e.unref(L)(e.unref(i))),1)])}}),J=["data-url"],K={key:0},Q={key:1},X={key:0},Y={key:1},Z={key:0},ee=["disabled"],te={key:1},oe={key:2},B=e.defineComponent({__name:"ObjectInfo",props:{object:{}},setup(t){const a=N(),n=e.ref(!1);async function i(l,o){n.value=!0,await new Promise(r=>setTimeout(r,0)),confirm("Are you sure you want to delete this object? It cannot be undone.")&&await a.delete(l,o),n.value=!1}return(l,o)=>t.object?(e.openBlock(),e.createElementBlock("article",{key:0,"data-url":t.object.url},[e.createElementVNode("header",null,[o[4]||(o[4]=e.createElementVNode("h2",null,"Graffiti Object",-1)),e.createElementVNode("dl",null,[o[1]||(o[1]=e.createElementVNode("dt",null,"Object URL",-1)),e.createElementVNode("dd",null,[e.createElementVNode("code",null,e.toDisplayString(t.object.url),1)]),o[2]||(o[2]=e.createElementVNode("dt",null,"Actor",-1)),e.createElementVNode("dd",null,[e.createElementVNode("code",null,e.toDisplayString(t.object.actor),1)]),o[3]||(o[3]=e.createElementVNode("dt",null,"Handle",-1)),e.createElementVNode("dd",null,[e.createVNode(V,{actor:t.object.actor},null,8,["actor"])])])]),e.createElementVNode("section",null,[o[5]||(o[5]=e.createElementVNode("h3",null,"Content",-1)),e.createElementVNode("pre",null,e.toDisplayString(t.object.value),1)]),e.createElementVNode("section",null,[o[10]||(o[10]=e.createElementVNode("h3",null,"Allowed Actors",-1)),Array.isArray(t.object.allowed)?t.object.allowed.length===0?(e.openBlock(),e.createElementBlock("p",Q,[...o[7]||(o[7]=[e.createElementVNode("em",null,"Noone",-1)])])):e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("p",K,[...o[6]||(o[6]=[e.createElementVNode("em",null,"Public",-1)])])),e.createElementVNode("ul",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.object.allowed,r=>(e.openBlock(),e.createElementBlock("li",{key:r},[e.createElementVNode("dl",null,[o[8]||(o[8]=e.createElementVNode("dt",null,"Actor",-1)),e.createElementVNode("dd",null,[e.createElementVNode("code",null,e.toDisplayString(r),1)]),o[9]||(o[9]=e.createElementVNode("dt",null,"Handle",-1)),e.createElementVNode("dd",null,[e.createVNode(V,{actor:r},null,8,["actor"])])])]))),128))])]),e.createElementVNode("section",null,[o[12]||(o[12]=e.createElementVNode("h3",null,"Channels",-1)),t.object.channels?.length?(e.openBlock(),e.createElementBlock("ul",X,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.object.channels,r=>(e.openBlock(),e.createElementBlock("li",{key:r},[e.createElementVNode("code",null,e.toDisplayString(r),1)]))),128))])):(e.openBlock(),e.createElementBlock("p",Y,[...o[11]||(o[11]=[e.createElementVNode("em",null,"No channels",-1)])]))]),e.createElementVNode("footer",null,[e.createElementVNode("nav",null,[e.createElementVNode("ul",null,[l.$graffitiSession.value?.actor===t.object.actor?(e.openBlock(),e.createElementBlock("li",Z,[e.createElementVNode("button",{disabled:n.value,onClick:o[0]||(o[0]=r=>i(t.object,l.$graffitiSession.value))},e.toDisplayString(n.value?"Deleting...":"Delete"),9,ee)])):e.createCommentVNode("",!0)])])])],8,J)):t.object===null?(e.openBlock(),e.createElementBlock("article",te,[...o[13]||(o[13]=[e.createElementVNode("header",null,[e.createElementVNode("h2",null,"Graffiti Object")],-1),e.createElementVNode("p",null,[e.createElementVNode("em",null,"Object not found")],-1)])])):(e.openBlock(),e.createElementBlock("article",oe,[...o[14]||(o[14]=[e.createElementVNode("header",null,[e.createElementVNode("h2",null,"Graffiti Object")],-1),e.createElementVNode("p",null,[e.createElementVNode("em",null,"Loading...")],-1)])]))}}),ne={key:0},re={key:1},O=e.defineComponent({__name:"Discover",props:{channels:{},schema:{},session:{},autopoll:{type:Boolean}},setup(t){const a=t,{objects:n,poll:i,isFirstPoll:l}=T(e.toRef(a,"channels"),e.toRef(a,"schema"),e.toRef(a,"session"),e.toRef(a,"autopoll"));return(o,r)=>e.renderSlot(o.$slots,"default",{objects:e.unref(n),poll:e.unref(i),isFirstPoll:e.unref(l)},()=>[e.unref(l)?(e.openBlock(),e.createElementBlock("p",re,[...r[0]||(r[0]=[e.createElementVNode("em",null," Loading... ",-1)])])):(e.openBlock(),e.createElementBlock("ul",ne,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(n),s=>(e.openBlock(),e.createElementBlock("li",{key:s.url},[e.createVNode(B,{object:s},null,8,["object"])]))),128))]))])}});function H(t,a,n){const i=b(),l=e.ref(void 0);let o=async()=>{};const r=async()=>o();let s;return e.onScopeDispose(()=>{s?.return(null)}),e.watch(()=>[e.toValue(t),e.toValue(a),e.toValue(n)],(m,u,k)=>{l.value=void 0;const p=i.synchronizeGet(...m);s=p;let y=!0;k(()=>{y=!1,p.return(null)}),(async()=>{for await(const c of p){if(!y)return;c.tombstone?l.value=null:l.value=c.object}})();let f=!1;o=async()=>{if(!(f||!y)){f=!0;try{await i.get(...m)}catch(c){c instanceof G||console.error(c)}await new Promise(c=>setTimeout(c,0)),f=!1}},r()},{immediate:!0}),{object:l,poll:r}}const C=e.defineComponent({__name:"Get",props:{url:{},schema:{},session:{}},setup(t){const a=t,{object:n,poll:i}=H(e.toRef(a,"url"),e.toRef(a,"schema"),e.toRef(a,"session"));return(l,o)=>e.renderSlot(l.$slots,"default",{object:e.unref(n),poll:e.unref(i)},()=>[e.createVNode(B,{object:e.unref(n)},null,8,["object"])])}});function z(t,a,n){const i=b(),l=e.ref(void 0),o=e.ref(0);let r=null,s=()=>{};function m(){return r||(o.value++,r=new Promise(u=>{s=()=>{r=null,u()}}),r)}return e.watch(()=>({args:[e.toValue(t),e.toValue(a),e.toValue(n)],pollCounter:o.value}),async({args:u},k,p)=>{l.value?.dataUrl&&URL.revokeObjectURL(l.value.dataUrl),l.value=void 0;let y=!0;p(()=>{y=!1});try{const{data:f,actor:c,allowed:A}=await i.getMedia(...u);if(!y)return;const w=URL.createObjectURL(f);l.value={data:f,dataUrl:w,actor:c,allowed:A}}catch(f){if(!y)return;f instanceof G?l.value=null:console.error(f)}finally{s()}},{immediate:!0}),e.onScopeDispose(()=>{s(),l.value?.dataUrl&&URL.revokeObjectURL(l.value.dataUrl)}),{media:l,poll:m}}const le=["src","alt"],ae=["src","alt"],ie=["src","alt"],se=["src","alt"],ce=["data","alt"],ue={key:6},fe={key:7},M=e.defineComponent({__name:"GetMedia",props:{url:{},requirements:{},session:{}},setup(t){const a=t,{media:n,poll:i}=z(e.toRef(a,"url"),e.toRef(a,"requirements"),e.toRef(a,"session"));function l(){n.value&&(window.location.href=n.value.dataUrl)}return(o,r)=>e.renderSlot(o.$slots,"default",{media:e.unref(n),poll:e.unref(i)},()=>[e.unref(n)?.data.type.startsWith("image/")?(e.openBlock(),e.createElementBlock("img",{key:0,src:e.unref(n).dataUrl,alt:`An image by ${e.unref(n).actor}`},null,8,le)):e.unref(n)?.data.type.startsWith("video/")?(e.openBlock(),e.createElementBlock("video",{key:1,controls:"",src:e.unref(n).dataUrl,alt:`A video by ${e.unref(n).actor}`},null,8,ae)):e.unref(n)?.data.type.startsWith("audio/")?(e.openBlock(),e.createElementBlock("audio",{key:2,controls:"",src:e.unref(n).dataUrl,alt:`Audio by ${e.unref(n).actor}`},null,8,ie)):e.unref(n)?.data.type==="text/html"?(e.openBlock(),e.createElementBlock("iframe",{key:3,src:e.unref(n).dataUrl,alt:`HTML by ${e.unref(n).actor}`,sandbox:""},null,8,se)):e.unref(n)?.data.type.startsWith("application/pdf")?(e.openBlock(),e.createElementBlock("object",{key:4,data:e.unref(n).dataUrl,type:"application/pdf",alt:`PDF by ${e.unref(n).actor}`},null,8,ce)):e.unref(n)?(e.openBlock(),e.createElementBlock("button",{key:5,onClick:l},"Download")):e.unref(n)===null?(e.openBlock(),e.createElementBlock("p",ue,[...r[0]||(r[0]=[e.createElementVNode("em",null,"Media not found",-1)])])):(e.openBlock(),e.createElementBlock("p",fe,[...r[1]||(r[1]=[e.createElementVNode("em",null," Loading... ",-1)])]))])}});function F(t){const a=N(),{output:n}=P(t,a.handleToActor.bind(a));return{actor:n}}const I=e.defineComponent({__name:"HandleToActor",props:{handle:{}},setup(t){const a=t,n=e.toRef(a,"handle"),{actor:i}=F(n);return(l,o)=>e.renderSlot(l.$slots,"default",{actor:e.unref(i)},()=>[e.createElementVNode("span",null,e.toDisplayString(e.unref(L)(e.unref(i))),1)])}}),de={install(t,a){const n=a.graffiti,i=new _.GraffitiSynchronize(n),l=e.ref(void 0);i.sessionEvents.addEventListener("initialized",async o=>{const r=o.detail;if(r&&r.error&&console.error(r.error),r&&r.href){const s=t.config.globalProperties.$router;if(s){const m=s.options.history.base,u=new URL(r.href);u.pathname.startsWith(m)&&(u.pathname=u.pathname.slice(m.length)),await s.replace(u.pathname+u.search+u.hash)}}l.value||(l.value=null)}),i.sessionEvents.addEventListener("login",o=>{const r=o.detail;if(r.error){console.error("Error logging in:"),console.error(r.error);return}else l.value=r.session}),i.sessionEvents.addEventListener("logout",o=>{const r=o.detail;r.error?(console.error("Error logging out:"),console.error(r.error)):l.value=null}),q(i),W(l),t.component("GraffitiDiscover",O),t.component("GraffitiGet",C),t.component("GraffitiGetMedia",M),t.component("GraffitiActorToHandle",V),t.component("GraffitiHandleToActor",I),t.component("GraffitiObjectInfo",B),t.config.globalProperties.$graffiti=i,t.config.globalProperties.$graffitiSession=l}},me=O,pe=C,ye=M,ve=V,Ee=I,ke=B;exports.GraffitiActorToHandle=ve;exports.GraffitiDiscover=me;exports.GraffitiGet=pe;exports.GraffitiGetMedia=ye;exports.GraffitiHandleToActor=Ee;exports.GraffitiObjectInfo=ke;exports.GraffitiPlugin=de;exports.useGraffiti=N;exports.useGraffitiActorToHandle=U;exports.useGraffitiDiscover=T;exports.useGraffitiGet=H;exports.useGraffitiGetMedia=z;exports.useGraffitiHandleToActor=F;exports.useGraffitiSession=x;exports.useGraffitiSynchronize=b;
2
2
  //# sourceMappingURL=plugin.js.map