@graffiti-garden/wrapper-vue 0.0.4 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -19,13 +19,13 @@ or the `useGraffitiSession` composable in the Composition API.
19
19
  ## Installation
20
20
 
21
21
  You must install this package along with Vue.js and an implementation of the Graffiti API.
22
- In this example, we will use the [PouchDB implementation](https://github.com/graffiti-garden/implementation-pouchdb)
22
+ In this example, we will use the [PouchDB implementation](https://github.com/graffiti-garden/implementation-local)
23
23
  of the Graffiti API, but any other would be similar.
24
24
  In node.js, simply install them with npm:
25
25
 
26
26
  ```bash
27
27
  npm install vue
28
- npm install @graffiti-garden/implementation-pouchdb
28
+ npm install @graffiti-garden/implementation-local
29
29
  npm install @graffiti-garden/wrapper-vue
30
30
  ```
31
31
 
@@ -39,7 +39,7 @@ Add an import map the the `<head>` of your HTML file:
39
39
  {
40
40
  "imports": {
41
41
  "vue": "https://cdn.jsdelivr.net/npm/vue/dist/vue.esm-browser.js",
42
- "@graffiti-garden/implementation-pouchdb": "https://cdn.jsdelivr.net/npm/@graffiti-garden/implementation-pouchdb/dist/index.js",
42
+ "@graffiti-garden/implementation-local": "https://cdn.jsdelivr.net/npm/@graffiti-garden/implementation-local/dist/index.browser.js",
43
43
  "@graffiti-garden/wrapper-vue": "https://cdn.jsdelivr.net/npm/@graffiti-garden/wrapper-vue/dist/plugin.js"
44
44
  }
45
45
  }
@@ -51,12 +51,12 @@ In ether case install the plugin in your Vue app as follows:
51
51
 
52
52
  ```typescript
53
53
  import { createApp } from "vue";
54
- import { GraffitiPouchDB } from "@graffiti-garden/implementation-pouchdb";
54
+ import { GraffitiLocal } from "@graffiti-garden/implementation-local";
55
55
  import { GraffitiPlugin } from "@graffiti-garden/wrapper-vue";
56
56
 
57
57
  createApp({})
58
58
  .use(GraffitiPlugin, {
59
- useGraffiti: () => new GraffitiPouchDB(),
59
+ useGraffiti: () => new GraffitiLocal(),
60
60
  });
61
61
  .mount("#app");
62
62
  ```
@@ -0,0 +1,26 @@
1
+ import { GraffitiSession, JSONSchema4 } from '@graffiti-garden/api';
2
+ declare const _default: <Schema extends JSONSchema4>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
3
+ props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, never> & {
4
+ channels: string[];
5
+ schema: Schema;
6
+ session?: GraffitiSession | null;
7
+ } & Partial<{}>> & import('vue').PublicProps;
8
+ expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
9
+ attrs: any;
10
+ slots: {
11
+ default?(_: {
12
+ results: import('@vue/reactivity').UnwrapRefSimple<import('@graffiti-garden/api').GraffitiObjectBase & import('ajv/dist/core').JTDDataType<Schema> & {
13
+ tombstone: false;
14
+ }>[];
15
+ poll: () => Promise<void>;
16
+ isPolling: boolean;
17
+ }): any;
18
+ };
19
+ emit: {};
20
+ }>) => import('vue').VNode & {
21
+ __ctx?: Awaited<typeof __VLS_setup>;
22
+ };
23
+ export default _default;
24
+ type __VLS_PrettifyLocal<T> = {
25
+ [K in keyof T]: T[K];
26
+ } & {};
@@ -0,0 +1,40 @@
1
+ import { GraffitiLocation, GraffitiSession, JSONSchema4 } from '@graffiti-garden/api';
2
+ declare const _default: <Schema extends JSONSchema4>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
3
+ props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, never> & {
4
+ locationOrUri: string | GraffitiLocation;
5
+ schema: Schema;
6
+ session?: GraffitiSession | null;
7
+ } & Partial<{}>> & import('vue').PublicProps;
8
+ expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
9
+ attrs: any;
10
+ slots: {
11
+ default?(_: {
12
+ result: import('@vue/reactivity').DistributeRef<[(import('@graffiti-garden/api').GraffitiObjectBase & import('ajv/dist/core').JTDDataType<Schema> & {
13
+ tombstone: false;
14
+ }) | null | undefined] extends [import('vue').Ref<any, any>] ? import('@vue/shared').IfAny<import('vue').Ref<any, any> & import('@graffiti-garden/api').GraffitiObjectBase & import('ajv/dist/core').JTDDataType<Schema> & {
15
+ tombstone: false;
16
+ }, import('vue').Ref<import('vue').Ref<any, any> & import('@graffiti-garden/api').GraffitiObjectBase & import('ajv/dist/core').JTDDataType<Schema> & {
17
+ tombstone: false;
18
+ }, import('vue').Ref<any, any> & import('@graffiti-garden/api').GraffitiObjectBase & import('ajv/dist/core').JTDDataType<Schema> & {
19
+ tombstone: false;
20
+ }>, import('vue').Ref<any, any> & import('@graffiti-garden/api').GraffitiObjectBase & import('ajv/dist/core').JTDDataType<Schema> & {
21
+ tombstone: false;
22
+ }> : import('vue').Ref<import('vue').UnwrapRef<import('@graffiti-garden/api').GraffitiObjectBase & import('ajv/dist/core').JTDDataType<Schema> & {
23
+ tombstone: false;
24
+ }> | null | undefined, (import('@graffiti-garden/api').GraffitiObjectBase & import('ajv/dist/core').JTDDataType<Schema> & {
25
+ tombstone: false;
26
+ }) | import('vue').UnwrapRef<import('@graffiti-garden/api').GraffitiObjectBase & import('ajv/dist/core').JTDDataType<Schema> & {
27
+ tombstone: false;
28
+ }> | null | undefined>>;
29
+ poll: () => Promise<void>;
30
+ isPolling: boolean;
31
+ }): any;
32
+ };
33
+ emit: {};
34
+ }>) => import('vue').VNode & {
35
+ __ctx?: Awaited<typeof __VLS_setup>;
36
+ };
37
+ export default _default;
38
+ type __VLS_PrettifyLocal<T> = {
39
+ [K in keyof T]: T[K];
40
+ } & {};
@@ -0,0 +1,25 @@
1
+ import { GraffitiSession, JSONSchema4 } from '@graffiti-garden/api';
2
+ declare const _default: <Schema extends JSONSchema4>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
3
+ props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, never> & {
4
+ schema: Schema;
5
+ session: GraffitiSession;
6
+ } & Partial<{}>> & import('vue').PublicProps;
7
+ expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
8
+ attrs: any;
9
+ slots: {
10
+ default?(_: {
11
+ results: import('@vue/reactivity').UnwrapRefSimple<import('@graffiti-garden/api').GraffitiObjectBase & import('ajv/dist/core').JTDDataType<Schema> & {
12
+ tombstone: false;
13
+ }>[];
14
+ poll: () => Promise<void>;
15
+ isPolling: boolean;
16
+ }): any;
17
+ };
18
+ emit: {};
19
+ }>) => import('vue').VNode & {
20
+ __ctx?: Awaited<typeof __VLS_setup>;
21
+ };
22
+ export default _default;
23
+ type __VLS_PrettifyLocal<T> = {
24
+ [K in keyof T]: T[K];
25
+ } & {};
@@ -0,0 +1,124 @@
1
+ import { MaybeRefOrGetter } from 'vue';
2
+ import { GraffitiLocation, GraffitiSession, JSONSchema4 } from '@graffiti-garden/api';
3
+ /**
4
+ * A reactive version of the [`Graffiti.discover`](https://api.graffiti.garden/classes/Graffiti.html#discover)
5
+ * method. Its arguments are the same, but now they can be
6
+ * reactive Vue refs or getters. As they change the output will
7
+ * automatically update.
8
+ *
9
+ * Rather than returning a stream of Graffiti objects, this
10
+ * function returns a reactive array of objects. It also
11
+ * provides a method to poll for new results and a boolean
12
+ * ref indicating if the poll is currently running.
13
+ *
14
+ * All [`tombstone`](https://api.graffiti.garden/interfaces/GraffitiObjectBase.html#tombstone)d
15
+ * objects are filtered out.
16
+ *
17
+ * @returns An object containing
18
+ * - `results`: a reactive array of Graffiti objects
19
+ * - `poll`: a method to poll for new results
20
+ * - `isPolling`: a boolean ref indicating if the poll is currently running
21
+ */
22
+ export declare function useGraffitiDiscover<Schema extends JSONSchema4>(
23
+ /**
24
+ * A list of channels to discover objects from.
25
+ * Reactivity will only trigger
26
+ * when the root array changes, not when the elements
27
+ * change. If you need reactivity on the elements,
28
+ * create a getter, e.g. `() => [toValue(myReactiveChannel)]`.
29
+ */
30
+ channels: MaybeRefOrGetter<string[]>,
31
+ /**
32
+ * A [JSON Schema](https://json-schema.org/) object describing the schema
33
+ * of the objects to discover. All other objects will be filtered out
34
+ * and the output will be typed as `GraffitiObject<Schema>`.
35
+ * Reactivity only triggers when the root object changes, not when
36
+ * the root object changes, not when the properties change.
37
+ * Create a getter if you need reactivity on the properties.
38
+ */
39
+ schema: MaybeRefOrGetter<Schema>,
40
+ /**
41
+ * A Graffiti session object. If not provided, the
42
+ * global plugin session will be used.
43
+ */
44
+ session?: MaybeRefOrGetter<GraffitiSession | undefined | null>): {
45
+ results: import('vue').Ref<import('@vue/reactivity').UnwrapRefSimple<import('@graffiti-garden/api').GraffitiObjectBase & import('ajv/dist/core').JTDDataType<Schema> & {
46
+ tombstone: false;
47
+ }>[], import('@vue/reactivity').UnwrapRefSimple<import('@graffiti-garden/api').GraffitiObjectBase & import('ajv/dist/core').JTDDataType<Schema> & {
48
+ tombstone: false;
49
+ }>[] | (import('@graffiti-garden/api').GraffitiObjectBase & import('ajv/dist/core').JTDDataType<Schema> & {
50
+ tombstone: false;
51
+ })[]>;
52
+ poll: () => Promise<void>;
53
+ isPolling: import('vue').Ref<boolean, boolean>;
54
+ };
55
+ /**
56
+ * A reactive version of the [`Graffiti.get`](https://api.graffiti.garden/classes/Graffiti.html#get)
57
+ * method. Its arguments are the same, but now they can be
58
+ * reactive Vue refs or getters. As they change the output will
59
+ * automatically update.
60
+ *
61
+ * Rather than returning a single Graffiti object, this
62
+ * function returns a reactive object. It also
63
+ * provides a method to poll for new results and a boolean
64
+ * ref indicating if the poll is currently running.
65
+ *
66
+ * While the object is first being fetched, the result
67
+ * is `undefined`. If the object has been deleted,
68
+ * the result is `null`. Otherwise, the result is the
69
+ * most recent object fetched. All [`tombstone`](https://api.graffiti.garden/interfaces/GraffitiObjectBase.html#tombstone)d
70
+ * objects are filtered out.
71
+ *
72
+ * @returns An object containing
73
+ * - `results`: a reactive array of Graffiti objects
74
+ * - `poll`: a method to poll for new results
75
+ * - `isPolling`: a boolean ref indicating if the poll is currently running
76
+ */
77
+ export declare function useGraffitiGet<Schema extends JSONSchema4>(
78
+ /**
79
+ * A Graffiti location or URI to fetch the object from.
80
+ */
81
+ locationOrUri: MaybeRefOrGetter<GraffitiLocation | string>,
82
+ /**
83
+ * A [JSON Schema](https://json-schema.org/) object describing the schema
84
+ * of the objects to discover. All other objects will be filtered out
85
+ * and the output will be typed as `GraffitiObject<Schema>`.
86
+ * Like the `channels` argument, reactivity only triggers when
87
+ */
88
+ schema: MaybeRefOrGetter<Schema>,
89
+ /**
90
+ * A Graffiti session object. If not provided, the
91
+ * global plugin session will be used.
92
+ */
93
+ session?: MaybeRefOrGetter<GraffitiSession | undefined | null>): {
94
+ result: [(import('@graffiti-garden/api').GraffitiObjectBase & import('ajv/dist/core').JTDDataType<Schema> & {
95
+ tombstone: false;
96
+ }) | null | undefined] extends [import('vue').Ref<any, any>] ? import('@vue/shared').IfAny<import('vue').Ref<any, any> & import('@graffiti-garden/api').GraffitiObjectBase & import('ajv/dist/core').JTDDataType<Schema> & {
97
+ tombstone: false;
98
+ }, import('vue').Ref<import('vue').Ref<any, any> & import('@graffiti-garden/api').GraffitiObjectBase & import('ajv/dist/core').JTDDataType<Schema> & {
99
+ tombstone: false;
100
+ }, import('vue').Ref<any, any> & import('@graffiti-garden/api').GraffitiObjectBase & import('ajv/dist/core').JTDDataType<Schema> & {
101
+ tombstone: false;
102
+ }>, import('vue').Ref<any, any> & import('@graffiti-garden/api').GraffitiObjectBase & import('ajv/dist/core').JTDDataType<Schema> & {
103
+ tombstone: false;
104
+ }> : import('vue').Ref<import('vue').UnwrapRef<import('@graffiti-garden/api').GraffitiObjectBase & import('ajv/dist/core').JTDDataType<Schema> & {
105
+ tombstone: false;
106
+ }> | null | undefined, (import('@graffiti-garden/api').GraffitiObjectBase & import('ajv/dist/core').JTDDataType<Schema> & {
107
+ tombstone: false;
108
+ }) | import('vue').UnwrapRef<import('@graffiti-garden/api').GraffitiObjectBase & import('ajv/dist/core').JTDDataType<Schema> & {
109
+ tombstone: false;
110
+ }> | null | undefined>;
111
+ poll: () => Promise<void>;
112
+ isPolling: import('vue').Ref<boolean, boolean>;
113
+ };
114
+ export declare function useGraffitiRecoverOrphans<Schema extends JSONSchema4>(schema: MaybeRefOrGetter<Schema>, session: MaybeRefOrGetter<GraffitiSession>): {
115
+ results: import('vue').Ref<import('@vue/reactivity').UnwrapRefSimple<import('@graffiti-garden/api').GraffitiObjectBase & import('ajv/dist/core').JTDDataType<Schema> & {
116
+ tombstone: false;
117
+ }>[], import('@vue/reactivity').UnwrapRefSimple<import('@graffiti-garden/api').GraffitiObjectBase & import('ajv/dist/core').JTDDataType<Schema> & {
118
+ tombstone: false;
119
+ }>[] | (import('@graffiti-garden/api').GraffitiObjectBase & import('ajv/dist/core').JTDDataType<Schema> & {
120
+ tombstone: false;
121
+ })[]>;
122
+ poll: () => Promise<void>;
123
+ isPolling: import('vue').Ref<boolean, boolean>;
124
+ };
@@ -0,0 +1,6 @@
1
+ import { InjectionKey, Ref } from 'vue';
2
+ import { Graffiti, GraffitiSession } from '@graffiti-garden/api';
3
+ export declare const graffitiInjectKey: InjectionKey<Graffiti>;
4
+ export declare const graffitiSessionInjectKey: InjectionKey<Ref<GraffitiSession | undefined | null>>;
5
+ export declare function useGraffiti(): Graffiti;
6
+ export declare function useGraffitiSession(): Ref<GraffitiSession | null | undefined, GraffitiSession | null | undefined>;
@@ -0,0 +1,2 @@
1
+ "use strict";var T=Object.defineProperty;var D=(t,e,r)=>e in t?T(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var u=(t,e,r)=>D(t,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("vue"),G=Symbol(),R=Symbol();function p(){const t=s.inject(G);if(!t)throw new Error("No Graffiti instance provided");return t}function y(){const t=s.inject(R);if(!t)throw new Error("No Graffiti session provided");return t}class V{constructor(e){u(this,"poll",async e=>{let r;try{r=await this.getter()}catch{e(null);return}e(r)});this.getter=e}clear(){}}class b{constructor(e,r){u(this,"bookmark");u(this,"iterator");u(this,"poll",async e=>{var c,h,d;const r=new Date().getTime(),o={...this.schemaGetter()};this.bookmark&&this.bookmark.fullRepollBy>r&&(o.properties={...o.properties,lastModified:{minimum:this.bookmark.lastModified,...(c=o.properties)==null?void 0:c.lastModified}});let i;try{i=this.streamFactory()}catch(f){console.error(f);return}(h=this.iterator)==null||h.return({tombstoneRetention:0}),this.iterator=i;let n=(d=this.bookmark)==null?void 0:d.lastModified,l=await i.next();for(;!l.done;){if(l.value.error){console.error(l.value.error),l=await i.next();continue}const f=l.value.value;(!n||f.lastModified>n)&&(n=f.lastModified),e(f),l=await i.next()}if(this.iterator!==i)return;this.iterator=void 0;const{tombstoneRetention:a}=l.value;n&&(this.bookmark={lastModified:n,fullRepollBy:r+a})});this.schemaGetter=e,this.streamFactory=r}clear(){this.bookmark=void 0}}function S(t,e){return t.lastModified>e.lastModified||t.lastModified===e.lastModified&&!t.tombstone&&e.tombstone}class ${constructor(){u(this,"result",s.ref(void 0))}clear(){this.result.value=void 0}onObject(e){(!e||!this.result.value||S(e,this.result.value))&&(!e||e.tombstone?this.result.value=null:this.result.value=e)}}class P{constructor(e){u(this,"REFRESH_RATE",100);u(this,"results",s.ref([]));u(this,"resultsRaw",new Map);u(this,"batchFlattenTimer");this.graffiti=e}clear(){this.resultsRaw.clear(),this.results.value=[],clearTimeout(this.batchFlattenTimer)}flattenResults(){this.results.value=Array.from(this.resultsRaw.values()).reduce((e,r)=>{const{tombstone:o}=r;return o||e.push({...r,tombstone:o}),e},[])}onObject(e){if(!e)return;const r=this.graffiti.objectToUri(e),o=this.resultsRaw.get(r);o&&!S(e,o)||(this.resultsRaw.set(r,e),this.batchFlattenTimer||(this.batchFlattenTimer=setTimeout(()=>{this.flattenResults(),this.batchFlattenTimer=void 0},this.REFRESH_RATE)))}}function w(t,e,r,o){let i;async function n(){i=r();for await(const c of i){if(c.error){console.error(c.error);continue}t.onObject(c.value)}}const l=()=>e.poll(t.onObject.bind(t)),a=s.ref(!1);return s.watch(o,async()=>{i==null||i.return(),t.clear(),e.clear(),n(),a.value=!0;try{await l()}finally{a.value=!1}},{immediate:!0}),s.onScopeDispose(()=>i==null?void 0:i.return()),{poll:l,isPolling:a}}function _(t,e){return()=>{const r=s.toValue(e);return r===void 0?t==null?void 0:t.value:r}}function m(t){return t.map(e=>e())}function E(t,e,r){const o=p(),i=y(),n=()=>s.toValue(t),l=()=>s.toValue(e),a=_(i,r),c=[n,l,a],h=()=>o.synchronizeDiscover(...m(c)),d=()=>o.discover(...m(c)),f=new P(o),g=new b(l,d),{poll:v,isPolling:F}=w(f,g,h,c);return{results:f.results,poll:v,isPolling:F}}function k(t,e,r){const o=p(),i=y(),n=()=>s.toValue(t),l=()=>s.toValue(e),a=_(i,r),c=[n,l,a],h=()=>o.synchronizeGet(...m(c)),d=new $,f=new V(()=>o.get(...m(c))),{poll:g,isPolling:v}=w(d,f,h,c);return{result:d.result,poll:g,isPolling:v}}function M(t,e){const r=p(),o=()=>s.toValue(t),n=[o,()=>s.toValue(e)],l=()=>r.synchronizeRecoverOrphans(...m(n)),a=new P(r),c=new b(o,()=>r.recoverOrphans(...m(n))),{poll:h,isPolling:d}=w(a,c,l,n);return{results:a.results,poll:h,isPolling:d}}const O=s.defineComponent({__name:"Discover",props:{channels:{},schema:{},session:{}},setup(t){const e=t,{results:r,poll:o,isPolling:i}=E(s.toRef(e,"channels"),s.toRef(e,"schema"),s.toRef(e,"session"));return(n,l)=>s.renderSlot(n.$slots,"default",{results:s.unref(r),poll:s.unref(o),isPolling:s.unref(i)})}}),z=s.defineComponent({__name:"Get",props:{locationOrUri:{},schema:{},session:{}},setup(t){const e=t,{result:r,poll:o,isPolling:i}=k(s.toRef(e,"locationOrUri"),s.toRef(e,"schema"),s.toRef(e,"session"));return(n,l)=>s.renderSlot(n.$slots,"default",{result:s.unref(r),poll:s.unref(o),isPolling:s.unref(i)})}}),L=s.defineComponent({__name:"RecoverOrphans",props:{schema:{},session:{}},setup(t){const e=t,{results:r,poll:o,isPolling:i}=M(s.toRef(e,"schema"),s.toRef(e,"session"));return(n,l)=>s.renderSlot(n.$slots,"default",{results:s.unref(r),poll:s.unref(o),isPolling:s.unref(i)})}}),U={install(t,e){const r=e.useGraffiti(),o=s.ref(void 0);r.sessionEvents.addEventListener("initialized",i=>{const n=i.detail;if(o.value||(o.value=null),n&&n.error&&console.error(n.error),n&&n.href){const l=t.config.globalProperties.$router;if(l){const a=new URL(n.href);l.replace(a.pathname+a.search+a.hash)}}}),r.sessionEvents.addEventListener("login",i=>{const n=i.detail;if(n.error){console.error("Error logging in:"),console.error(n.error);return}else o.value=n.session}),r.sessionEvents.addEventListener("logout",i=>{const n=i.detail;n.error?(console.error("Error logging out:"),console.error(n.error)):o.value=null}),t.provide(G,r),t.provide(R,o),t.component("GraffitiDiscover",O),t.config.globalProperties.$graffiti=r,t.config.globalProperties.$graffitiSession=o}};exports.GraffitiDiscover=O;exports.GraffitiGet=z;exports.GraffitiPlugin=U;exports.GraffitiRecoverOrphans=L;exports.graffitiInjectKey=G;exports.graffitiSessionInjectKey=R;exports.useGraffiti=p;exports.useGraffitiDiscover=E;exports.useGraffitiGet=k;exports.useGraffitiRecoverOrphans=M;exports.useGraffitiSession=y;
2
+ //# sourceMappingURL=plugin.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.cjs","sources":["../src/injections.ts","../src/pollers.ts","../node_modules/@graffiti-garden/implementation-local/dist/esm/utilities.js","../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\";\n\nexport const graffitiInjectKey = Symbol() as InjectionKey<Graffiti>;\nexport const graffitiSessionInjectKey = Symbol() as InjectionKey<\n Ref<GraffitiSession | undefined | null>\n>;\n\nexport function useGraffiti() {\n const graffiti = inject(graffitiInjectKey);\n if (!graffiti) {\n throw new Error(\"No Graffiti instance provided\");\n }\n return graffiti;\n}\n\nexport function useGraffitiSession() {\n const session = inject(graffitiSessionInjectKey);\n if (!session) {\n throw new Error(\"No Graffiti session provided\");\n }\n return session;\n}\n","import type {\n Graffiti,\n JSONSchema4,\n GraffitiObject,\n} from \"@graffiti-garden/api\";\n\nexport abstract class Poller<Schema extends JSONSchema4> {\n abstract poll(\n onObject: (object: GraffitiObject<Schema> | null) => 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 JSONSchema4> implements Poller<Schema> {\n constructor(readonly getter: () => Promise<GraffitiObject<Schema>>) {}\n\n poll: Poller<Schema>[\"poll\"] = async (onObject) => {\n let object: GraffitiObject<Schema>;\n try {\n object = await this.getter();\n } catch (e) {\n onObject(null);\n return;\n }\n onObject(object);\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 JSONSchema4>\n implements Poller<Schema>\n{\n bookmark:\n | {\n lastModified: number;\n fullRepollBy: number;\n }\n | undefined = undefined;\n iterator: ReturnType<typeof Graffiti.prototype.discover<Schema>> | undefined =\n undefined;\n\n constructor(\n readonly schemaGetter: () => Schema,\n readonly streamFactory: () => ReturnType<\n typeof Graffiti.prototype.discover<Schema>\n >,\n ) {}\n\n clear() {\n this.bookmark = undefined;\n }\n\n poll: Poller<Schema>[\"poll\"] = async (onObject) => {\n const startOfPoll = new Date().getTime();\n\n // Add a query for lastModified if it's not in the schema\n const schema = { ...this.schemaGetter() };\n if (this.bookmark && this.bookmark.fullRepollBy > startOfPoll) {\n schema.properties = {\n ...schema.properties,\n lastModified: {\n minimum: this.bookmark.lastModified,\n // if the schema already has a minimum\n // it won't be overridden because\n // the schema below takes precedence\n ...schema.properties?.lastModified,\n },\n };\n }\n\n let myIterator: ReturnType<typeof Graffiti.prototype.discover<Schema>>;\n try {\n myIterator = this.streamFactory();\n } catch (e) {\n console.error(e);\n return;\n }\n\n // Kill the previous iterator if its\n // still running and claim its spot\n this.iterator?.return({ tombstoneRetention: 0 });\n this.iterator = myIterator;\n\n // Keep track of the latest lastModified value\n // while streaming results\n let myLastModified = this.bookmark?.lastModified;\n let result = await myIterator.next();\n while (!result.done) {\n if (result.value.error) {\n console.error(result.value.error);\n result = await myIterator.next();\n continue;\n }\n\n const object = result.value.value;\n if (!myLastModified || object.lastModified > myLastModified) {\n myLastModified = object.lastModified;\n }\n\n onObject(object);\n\n result = await myIterator.next();\n }\n\n // Make sure we're still the current iterator\n if (this.iterator !== myIterator) return;\n\n // We've successfully polled all results\n // without getting overridden\n this.iterator = undefined;\n\n // Only now do we update the cache parameters\n // because the results may have appeared out\n // of order\n const { tombstoneRetention } = result.value;\n if (myLastModified) {\n this.bookmark = {\n lastModified: myLastModified,\n fullRepollBy: startOfPoll + tombstoneRetention,\n };\n }\n };\n}\n","import{GraffitiErrorInvalidSchema as n,GraffitiErrorInvalidUri as f,GraffitiErrorPatchError as c,GraffitiErrorPatchTestFailed as s}from\"@graffiti-garden/api\";const p=e=>`${e.source}/${encodeURIComponent(e.actor)}/${encodeURIComponent(e.name)}`,d=e=>{const t=e.split(\"/\"),r=t.pop(),o=t.pop();if(!r||!o||!t.length)throw new f;return{name:decodeURIComponent(r),actor:decodeURIComponent(o),source:t.join(\"/\")}};function l(e=16){const t=new Uint8Array(e);return crypto.getRandomValues(t),btoa(String.fromCodePoint(...t)).replace(/\\+/g,\"-\").replace(/\\//g,\"_\").replace(/\\=+$/,\"\")}function u(e){return typeof e==\"string\"?{location:d(e),uri:e}:{location:{name:e.name,actor:e.actor,source:e.source},uri:p(e)}}function G(e,t){return e.lastModified>t.lastModified||e.lastModified===t.lastModified&&!e.tombstone&&t.tombstone}function h(e,t,r,o){const i=r[t];if(!(!i||!i.length))try{o[t]=e(o[t],i,!0,!1).newDocument}catch(a){throw typeof a==\"object\"&&a&&\"name\"in a&&typeof a.name==\"string\"&&\"message\"in a&&typeof a.message==\"string\"?a.name===\"TEST_OPERATION_FAILED\"?new s(a.message):new c(a.name+\": \"+a.message):a}}function w(e,t){try{return e.compile(t)}catch(r){throw new n(r instanceof Error?r.message:void 0)}}function y(e,t,r){e.actor!==r?.actor&&(e.allowed=e.allowed&&r?[r.actor]:void 0,e.channels=e.channels.filter(o=>t.includes(o)))}function g(e,t){return e.allowed===void 0||e.allowed===null||!!t?.actor&&(e.actor===t.actor||e.allowed.includes(t.actor))}export{h as applyGraffitiPatch,w as attemptAjvCompile,g as isActorAllowedGraffitiObject,G as isObjectNewer,p as locationToUri,y as maskGraffitiObject,l as randomBase64,u as unpackLocationOrUri,d as uriToLocation};\n//# sourceMappingURL=utilities.js.map\n","import { ref } from \"vue\";\nimport type { JSONSchema4 } from \"@graffiti-garden/api\";\nimport type { GraffitiObject, Graffiti } from \"@graffiti-garden/api\";\nimport { isObjectNewer } from \"@graffiti-garden/implementation-local/utilities\";\n\nexport abstract class Reducer<Schema extends JSONSchema4> {\n abstract clear(): void;\n abstract onObject(object: GraffitiObject<Schema> | null): void;\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 JSONSchema4>\n implements Reducer<Schema>\n{\n readonly result = ref<\n (GraffitiObject<Schema> & { tombstone: false }) | null | undefined\n >(undefined);\n\n clear() {\n this.result.value = undefined;\n }\n\n onObject(object: GraffitiObject<Schema> | null) {\n if (\n !object ||\n !this.result.value ||\n isObjectNewer(object, this.result.value)\n ) {\n if (!object || object.tombstone) {\n this.result.value = null;\n } else {\n this.result.value = object;\n }\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 JSONSchema4>\n implements Reducer<Schema>\n{\n REFRESH_RATE = 100; // milliseconds\n readonly results = ref<(GraffitiObject<Schema> & { tombstone: false })[]>([]);\n readonly resultsRaw = new Map<string, GraffitiObject<Schema>>();\n batchFlattenTimer: ReturnType<typeof setTimeout> | undefined = undefined;\n\n constructor(readonly graffiti: Graffiti) {}\n\n clear() {\n this.resultsRaw.clear();\n this.results.value = [];\n clearTimeout(this.batchFlattenTimer);\n }\n\n flattenResults() {\n this.results.value = Array.from(this.resultsRaw.values()).reduce<\n (GraffitiObject<Schema> & { tombstone: false })[]\n >((acc, object) => {\n const { tombstone } = object;\n if (!tombstone) {\n acc.push({ ...object, tombstone });\n }\n return acc;\n }, []);\n }\n\n onObject(object: GraffitiObject<Schema> | null) {\n if (!object) return;\n const url = this.graffiti.objectToUri(object);\n const existing = this.resultsRaw.get(url);\n if (existing && !isObjectNewer(object, existing)) return;\n this.resultsRaw.set(url, object);\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 }, this.REFRESH_RATE);\n }\n }\n}\n","import {\n onScopeDispose,\n ref,\n toValue,\n watch,\n type MaybeRefOrGetter,\n} from \"vue\";\nimport type {\n GraffitiLocation,\n GraffitiObject,\n GraffitiSession,\n JSONSchema4,\n} from \"@graffiti-garden/api\";\nimport { useGraffiti, useGraffitiSession } from \"./injections\";\nimport type { GraffitiStream } from \"@graffiti-garden/api\";\nimport { GetPoller, Poller, StreamPoller } from \"./pollers\";\nimport { ArrayReducer, Reducer, SingletonReducer } from \"./reducers\";\n\nfunction makeComposable<Schema extends JSONSchema4>(\n reducer: Reducer<Schema>,\n poller: Poller<Schema>,\n synchronizeFactory: () => GraffitiStream<GraffitiObject<Schema>>,\n toWatch: readonly (() => any)[],\n) {\n let synchronizeIterator: GraffitiStream<GraffitiObject<Schema>> | undefined =\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.onObject(result.value);\n }\n }\n\n const poll = () => poller.poll(reducer.onObject.bind(reducer));\n\n const isPolling = ref(false);\n watch(\n toWatch,\n async () => {\n synchronizeIterator?.return();\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());\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 * A reactive version of the [`Graffiti.discover`](https://api.graffiti.garden/classes/Graffiti.html#discover)\n * method. Its arguments are the same, but now they can be\n * reactive Vue refs or getters. As they change the output will\n * automatically update.\n *\n * Rather than returning a stream of Graffiti objects, this\n * function returns a reactive array of objects. It also\n * provides a method to poll for new results and a boolean\n * ref indicating if the poll is currently running.\n *\n * All [`tombstone`](https://api.graffiti.garden/interfaces/GraffitiObjectBase.html#tombstone)d\n * objects are filtered out.\n *\n * @returns An object containing\n * - `results`: a reactive array of Graffiti objects\n * - `poll`: a method to poll for new results\n * - `isPolling`: a boolean ref indicating if the poll is currently running\n */\nexport function useGraffitiDiscover<Schema extends JSONSchema4>(\n /**\n * A list of channels to discover objects from.\n * Reactivity will only trigger\n * when the root array changes, not when the elements\n * change. If you need reactivity on the elements,\n * create a getter, e.g. `() => [toValue(myReactiveChannel)]`.\n */\n channels: MaybeRefOrGetter<string[]>,\n /**\n * A [JSON Schema](https://json-schema.org/) object describing the schema\n * of the objects to discover. All other objects will be filtered out\n * and the output will be typed as `GraffitiObject<Schema>`.\n * Reactivity only triggers when the root object changes, not when\n * the root object changes, not when the properties change.\n * Create a getter if you need reactivity on the properties.\n */\n schema: MaybeRefOrGetter<Schema>,\n /**\n * A Graffiti session object. If not provided, the\n * global plugin session will be used.\n */\n session?: MaybeRefOrGetter<GraffitiSession | undefined | null>,\n) {\n const graffiti = useGraffiti();\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(schemaGetter, streamFactory);\n\n const { poll, isPolling } = makeComposable(\n reducer,\n poller,\n synchronizeFactory,\n argGetters,\n );\n\n return {\n results: reducer.results,\n poll,\n isPolling,\n };\n}\n\n/**\n * A reactive version of the [`Graffiti.get`](https://api.graffiti.garden/classes/Graffiti.html#get)\n * method. Its arguments are the same, but now they can be\n * reactive Vue refs or getters. As they change the output will\n * automatically update.\n *\n * Rather than returning a single Graffiti object, this\n * function returns a reactive object. It also\n * provides a method to poll for new results and a boolean\n * ref indicating if the poll is currently running.\n *\n * While the object is first being fetched, the result\n * is `undefined`. If the object has been deleted,\n * the result is `null`. Otherwise, the result is the\n * most recent object fetched. All [`tombstone`](https://api.graffiti.garden/interfaces/GraffitiObjectBase.html#tombstone)d\n * objects are filtered out.\n *\n * @returns An object containing\n * - `results`: a reactive array of Graffiti objects\n * - `poll`: a method to poll for new results\n * - `isPolling`: a boolean ref indicating if the poll is currently running\n */\nexport function useGraffitiGet<Schema extends JSONSchema4>(\n /**\n * A Graffiti location or URI to fetch the object from.\n */\n locationOrUri: MaybeRefOrGetter<GraffitiLocation | string>,\n /**\n * A [JSON Schema](https://json-schema.org/) object describing the schema\n * of the objects to discover. All other objects will be filtered out\n * and the output will be typed as `GraffitiObject<Schema>`.\n * Like the `channels` argument, reactivity only triggers when\n */\n schema: MaybeRefOrGetter<Schema>,\n /**\n * A Graffiti session object. If not provided, the\n * global plugin session will be used.\n */\n session?: MaybeRefOrGetter<GraffitiSession | undefined | null>,\n) {\n const graffiti = useGraffiti();\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 poller = new GetPoller(() => graffiti.get(...callGetters(argGetters)));\n\n const { poll, isPolling } = makeComposable(\n reducer,\n poller,\n synchronizeFactory,\n argGetters,\n );\n\n return {\n result: reducer.result,\n poll,\n isPolling,\n };\n}\n\nexport function useGraffitiRecoverOrphans<Schema extends JSONSchema4>(\n schema: MaybeRefOrGetter<Schema>,\n session: MaybeRefOrGetter<GraffitiSession>,\n) {\n const graffiti = useGraffiti();\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 poller = new StreamPoller(schemaGetter, () =>\n graffiti.recoverOrphans(...callGetters(argGetters)),\n );\n\n const { poll, isPolling } = makeComposable(\n reducer,\n poller,\n synchronizeFactory,\n argGetters,\n );\n\n return {\n results: reducer.results,\n poll,\n isPolling,\n };\n}\n","<script setup lang=\"ts\" generic=\"Schema extends JSONSchema4\">\nimport { toRef } from \"vue\";\nimport type { GraffitiSession, JSONSchema4 } from \"@graffiti-garden/api\";\nimport { useGraffitiDiscover } from \"./composables\";\n\nconst props = defineProps<{\n channels: string[];\n schema: Schema;\n session?: GraffitiSession | null;\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 JSONSchema4\">\nimport { toRef } from \"vue\";\nimport type {\n GraffitiLocation,\n GraffitiSession,\n JSONSchema4,\n} from \"@graffiti-garden/api\";\nimport { useGraffitiGet } from \"./composables\";\n\nconst props = defineProps<{\n locationOrUri: string | GraffitiLocation;\n schema: Schema;\n session?: GraffitiSession | null;\n}>();\n\nconst { result, poll, isPolling } = useGraffitiGet<Schema>(\n toRef(props, \"locationOrUri\"),\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 JSONSchema4\">\nimport { toRef } from \"vue\";\nimport type { GraffitiSession, JSONSchema4 } from \"@graffiti-garden/api\";\nimport { useGraffitiRecoverOrphans } from \"./composables\";\n\nconst props = defineProps<{\n schema: Schema;\n session: GraffitiSession;\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 GraffitiFactory,\n Graffiti,\n GraffitiSession,\n GraffitiLoginEvent,\n GraffitiLogoutEvent,\n GraffitiSessionInitializedEvent,\n} from \"@graffiti-garden/api\";\nimport { graffitiInjectKey, graffitiSessionInjectKey } from \"./injections\";\nimport type { Router } from \"vue-router\";\n\ndeclare module \"vue\" {\n export interface ComponentCustomProperties {\n $graffiti: Graffiti;\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}\n\nexport interface GraffitiPluginOptions {\n useGraffiti: GraffitiFactory;\n}\n\nexport const GraffitiPlugin: Plugin<GraffitiPluginOptions> = {\n install(app: App, options: GraffitiPluginOptions) {\n const graffiti = options.useGraffiti();\n const graffitiSession = ref<GraffitiSession | undefined | null>(undefined);\n graffiti.sessionEvents.addEventListener(\"initialized\", (evt) => {\n const detail = (evt as GraffitiSessionInitializedEvent).detail;\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 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 url = new URL(detail.href);\n router.replace(url.pathname + url.search + url.hash);\n }\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.config.globalProperties.$graffiti = graffiti;\n app.config.globalProperties.$graffitiSession = graffitiSession;\n },\n};\n\nexport * from \"./composables\";\nexport * from \"./injections\";\nexport { Discover as GraffitiDiscover };\nexport { Get as GraffitiGet };\nexport { RecoverOrphans as GraffitiRecoverOrphans };\n"],"names":["graffitiInjectKey","graffitiSessionInjectKey","useGraffiti","graffiti","inject","useGraffitiSession","session","GetPoller","getter","__publicField","onObject","object","StreamPoller","schemaGetter","streamFactory","startOfPoll","schema","_a","myIterator","e","_b","myLastModified","_c","result","tombstoneRetention","G","t","SingletonReducer","ref","isObjectNewer","ArrayReducer","acc","tombstone","url","existing","makeComposable","reducer","poller","synchronizeFactory","toWatch","synchronizeIterator","pollSynchronize","poll","isPolling","watch","onScopeDispose","toSessionGetter","sessionInjected","sessionValue","toValue","callGetters","getters","fn","useGraffitiDiscover","channels","channelsGetter","sessionGetter","argGetters","useGraffitiGet","locationOrUri","locationOrUriGetter","useGraffitiRecoverOrphans","props","__props","results","toRef","GraffitiPlugin","app","options","graffitiSession","evt","detail","router","Discover"],"mappings":"2QAIaA,EAAoB,OAAO,EAC3BC,EAA2B,OAAO,EAIxC,SA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kBzC,MAAwC,MAAS,EACzEzB,EAAS,cAAc,iBAAiB,cAAgBmE,GAAQ,CAC9D,MAAMC,EAAUD,EAAwC,OAWpD,GARCD,EAAgB,QACnBA,EAAgB,MAAQ,MAGtBE,GAAUA,EAAO,OACX,QAAA,MAAMA,EAAO,KAAK,EAGxBA,GAAUA,EAAO,KAAM,CAEnB,MAAAC,EAASL,EAAI,OAAO,iBAAiB,QAG3C,GAAIK,EAAQ,CACV,MAAMvC,EAAM,IAAI,IAAIsC,EAAO,IAAI,EAC/BC,EAAO,QAAQvC,EAAI,SAAWA,EAAI,OAASA,EAAI,IAAI,CAAA,CACrD,CACF,CACD,EACD9B,EAAS,cAAc,iBAAiB,QAAUmE,GAAQ,CACxD,MAAMC,EAAUD,EAA2B,OAC3C,GAAIC,EAAO,MAAO,CAChB,QAAQ,MAAM,mBAAmB,EACzB,QAAA,MAAMA,EAAO,KAAK,EAC1B,MAAA,MAEAF,EAAgB,MAAQE,EAAO,OACjC,CACD,EACDpE,EAAS,cAAc,iBAAiB,SAAWmE,GAAQ,CACzD,MAAMC,EAAUD,EAA4B,OACxCC,EAAO,OACT,QAAQ,MAAM,oBAAoB,EAC1B,QAAA,MAAMA,EAAO,KAAK,GAE1BF,EAAgB,MAAQ,IAC1B,CACD,EAEGF,EAAA,QAAQnE,EAAmBG,CAAQ,EACnCgE,EAAA,QAAQlE,EAA0BoE,CAAe,EAEjDF,EAAA,UAAU,mBAAoBM,CAAQ,EACtCN,EAAA,OAAO,iBAAiB,UAAYhE,EACpCgE,EAAA,OAAO,iBAAiB,iBAAmBE,CAAA,CAEnD","x_google_ignoreList":[2]}
@@ -0,0 +1,25 @@
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';
5
+ import { GraffitiFactory, Graffiti, GraffitiSession } from '@graffiti-garden/api';
6
+ declare module "vue" {
7
+ interface ComponentCustomProperties {
8
+ $graffiti: Graffiti;
9
+ $graffitiSession: Ref<GraffitiSession | undefined | null>;
10
+ }
11
+ interface GlobalComponents {
12
+ GraffitiDiscover: typeof Discover;
13
+ GraffitiGet: typeof Get;
14
+ GraffitiRecoverOrphans: typeof RecoverOrphans;
15
+ }
16
+ }
17
+ export interface GraffitiPluginOptions {
18
+ useGraffiti: GraffitiFactory;
19
+ }
20
+ export declare const GraffitiPlugin: Plugin<GraffitiPluginOptions>;
21
+ export * from './composables';
22
+ export * from './injections';
23
+ export { Discover as GraffitiDiscover };
24
+ export { Get as GraffitiGet };
25
+ export { RecoverOrphans as GraffitiRecoverOrphans };