@graffiti-garden/wrapper-vue 0.7.2 → 1.0.4
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 +2 -3
- package/dist/browser/ajv-D_HICdxS.mjs +4447 -0
- package/dist/browser/ajv-D_HICdxS.mjs.map +1 -0
- package/dist/browser/plugin.mjs +1003 -943
- package/dist/browser/plugin.mjs.map +1 -1
- package/dist/node/components/ActorToHandle.vue.d.ts +23 -0
- package/dist/node/components/ActorToHandle.vue.d.ts.map +1 -0
- package/dist/node/{Discover.vue.d.ts → components/Discover.vue.d.ts} +4 -4
- package/dist/node/components/Discover.vue.d.ts.map +1 -0
- package/dist/node/{Get.vue.d.ts → components/Get.vue.d.ts} +2 -5
- package/dist/node/components/Get.vue.d.ts.map +1 -0
- package/dist/node/components/GetMedia.vue.d.ts +36 -0
- package/dist/node/components/GetMedia.vue.d.ts.map +1 -0
- package/dist/node/components/HandleToActor.vue.d.ts +23 -0
- package/dist/node/components/HandleToActor.vue.d.ts.map +1 -0
- package/dist/node/components/ObjectInfo.vue.d.ts +7 -0
- package/dist/node/components/ObjectInfo.vue.d.ts.map +1 -0
- package/dist/node/composables/actor-to-handle.d.ts +25 -0
- package/dist/node/composables/actor-to-handle.d.ts.map +1 -0
- package/dist/node/composables/discover.d.ts +38 -0
- package/dist/node/composables/discover.d.ts.map +1 -0
- package/dist/node/composables/get-media.d.ts +31 -0
- package/dist/node/composables/get-media.d.ts.map +1 -0
- package/dist/node/composables/get.d.ts +28 -0
- package/dist/node/composables/get.d.ts.map +1 -0
- package/dist/node/composables/handle-to-actor.d.ts +25 -0
- package/dist/node/composables/handle-to-actor.d.ts.map +1 -0
- package/dist/node/composables/resolve-string.d.ts +6 -0
- package/dist/node/composables/resolve-string.d.ts.map +1 -0
- package/dist/node/globals.d.ts +3 -5
- package/dist/node/globals.d.ts.map +1 -1
- package/dist/node/plugin.d.ts +174 -75
- package/dist/node/plugin.d.ts.map +1 -1
- package/dist/node/plugin.js +1 -1
- package/dist/node/plugin.js.map +1 -1
- package/dist/node/plugin.mjs +468 -333
- package/dist/node/plugin.mjs.map +1 -1
- package/package.json +15 -14
- package/src/components/ActorToHandle.vue +16 -0
- package/src/{Discover.vue → components/Discover.vue} +15 -9
- package/src/{Get.vue → components/Get.vue} +7 -11
- package/src/components/GetMedia.vue +75 -0
- package/src/components/HandleToActor.vue +16 -0
- package/src/components/ObjectInfo.vue +127 -0
- package/src/composables/actor-to-handle.ts +32 -0
- package/src/composables/discover.ts +202 -0
- package/src/composables/get-media.ts +116 -0
- package/src/composables/get.ts +109 -0
- package/src/composables/handle-to-actor.ts +32 -0
- package/src/composables/resolve-string.ts +46 -0
- package/src/globals.ts +24 -2
- package/src/plugin.ts +84 -29
- package/dist/browser/ajv-C30pimY5.mjs +0 -4400
- package/dist/browser/ajv-C30pimY5.mjs.map +0 -1
- package/dist/browser/index-CWfNKdDL.mjs +0 -424
- package/dist/browser/index-CWfNKdDL.mjs.map +0 -1
- package/dist/node/Discover.vue.d.ts.map +0 -1
- package/dist/node/Get.vue.d.ts.map +0 -1
- package/dist/node/RecoverOrphans.vue.d.ts +0 -31
- package/dist/node/RecoverOrphans.vue.d.ts.map +0 -1
- package/dist/node/composables.d.ts +0 -75
- package/dist/node/composables.d.ts.map +0 -1
- package/dist/node/pollers.d.ts +0 -28
- package/dist/node/pollers.d.ts.map +0 -1
- package/dist/node/reducers.d.ts +0 -37
- package/dist/node/reducers.d.ts.map +0 -1
- package/src/RecoverOrphans.vue +0 -37
- package/src/composables.ts +0 -347
- package/src/pollers.ts +0 -119
- package/src/reducers.ts +0 -124
package/dist/node/plugin.d.ts
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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
|
-
* | [
|
|
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
|
-
*
|
|
89
|
+
* getter functions.
|
|
86
90
|
*
|
|
87
|
-
* | Global variabale |
|
|
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.
|
|
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="{
|
|
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="
|
|
141
|
-
* :key="
|
|
150
|
+
* v-for="object in objects"
|
|
151
|
+
* :key="object.url"
|
|
142
152
|
* >
|
|
143
|
-
* {{
|
|
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
|
|
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
|
|
159
|
-
* the
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
209
|
-
* the
|
|
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.
|
|
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
|
|
259
|
-
* the
|
|
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
|
|
262
|
-
|
|
263
|
-
|
|
279
|
+
export declare const GraffitiGetMedia: {
|
|
280
|
+
new (...args: any[]): import('vue').CreateComponentPublicInstanceWithMixins<Readonly<{
|
|
281
|
+
url: string;
|
|
282
|
+
accept: import('@graffiti-garden/api').GraffitiMediaAccept;
|
|
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
|
+
accept: import('@graffiti-garden/api').GraffitiMediaAccept;
|
|
294
|
+
session?: GraffitiSession | null;
|
|
295
|
+
}> & Readonly<{}>, {}, {}, {}, {}, {}>;
|
|
296
|
+
__isFragment?: never;
|
|
297
|
+
__isTeleport?: never;
|
|
298
|
+
__isSuspense?: never;
|
|
299
|
+
} & import('vue').ComponentOptionsBase<Readonly<{
|
|
300
|
+
url: string;
|
|
301
|
+
accept: import('@graffiti-garden/api').GraffitiMediaAccept;
|
|
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
|
-
|
|
266
|
-
|
|
267
|
-
|
|
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
|
-
|
|
272
|
-
|
|
273
|
-
|
|
313
|
+
media: (import('@graffiti-garden/api').GraffitiMedia & {
|
|
314
|
+
dataUrl: string;
|
|
315
|
+
}) | null | undefined;
|
|
316
|
+
poll: () => Promise<void>;
|
|
274
317
|
}): any;
|
|
275
318
|
};
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
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
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
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
|
-
|
|
299
|
-
|
|
300
|
-
|
|
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","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAO,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE5C,OAAO,QAAQ,MAAM,
|
|
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,2BAA2B,CAAC;AACjD,OAAO,GAAG,MAAM,sBAAsB,CAAC;AACvC,OAAO,QAAQ,MAAM,2BAA2B,CAAC;AACjD,OAAO,aAAa,MAAM,gCAAgC,CAAC;AAC3D,OAAO,aAAa,MAAM,gCAAgC,CAAC;AAC3D,OAAO,UAAU,MAAM,6BAA6B,CAAC;AACrD,OAAO,KAAK,EACV,QAAQ,EACR,eAAe,EAIhB,MAAM,sBAAsB,CAAC;AAK9B,OAAO,QAAQ,KAAK,CAAC;IACnB,UAAiB,yBAAyB;QACxC;;;;;;;;;;WAUG;QACH,SAAS,EAAE,QAAQ,CAAC;QACpB;;;;;;;;;;;;;;WAcG;QACH,gBAAgB,EAAE,GAAG,CAAC,eAAe,GAAG,SAAS,GAAG,IAAI,CAAC,CAAC;KAC3D;IAED,UAAiB,gBAAgB;QAC/B,gBAAgB,EAAE,OAAO,QAAQ,CAAC;QAClC,WAAW,EAAE,OAAO,GAAG,CAAC;QACxB,gBAAgB,EAAE,OAAO,QAAQ,CAAC;QAClC,qBAAqB,EAAE,OAAO,aAAa,CAAC;QAC5C,qBAAqB,EAAE,OAAO,aAAa,CAAC;QAC5C,kBAAkB,EAAE,OAAO,UAAU,CAAC;KACvC;CACF;AACD,YAAY,EAAE,yBAAyB,EAAE,MAAM,KAAK,CAAC;AAErD;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;;;;;OAQG;IACH,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8FG;AACH,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,qBAAqB,CAiExD,CAAC;AAEF,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,EACL,WAAW,EACX,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,WAAW,CAAC;AAEnB;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SA9JpB,CAAC;CA8J8B,CAAC;AACzC;;;;;;;;;;GAUG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SArLb,CAAC;CAqLkB,CAAC;AAC/B;;;;;;;;;;GAUG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAW,CAAC;AACzC;;;;;;;;;;GAUG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;EAAgB,CAAC;AACnD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;EAAgB,CAAC;AACnD;;;GAGG;AACH,eAAO,MAAM,kBAAkB;;;;iGAAa,CAAC"}
|
package/dist/node/plugin.js
CHANGED
|
@@ -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 g=(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 P extends Error{constructor(t){super(t),this.name="GraffitiErrorNotFound",Object.setPrototypeOf(this,P.prototype)}};class C{constructor(t){g(this,"poll",async t=>{let o;const i=this.getter;try{o=await i()}catch{this.getter===i&&t(null);return}this.getter===i&&t({object:o})});this.getter=t}clear(){}}class S{constructor(t){g(this,"iterator");g(this,"continue");g(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,i=await o.next();if(o===this.iterator){if(i.done){this.iterator=void 0,i.value&&(this.continue=i.value.continue);break}if(i.value.error){console.error(i.value.error);continue}t(i.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(){g(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){g(this,"results",r.ref([]));g(this,"resultsRaw",new Map);g(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,i,a){let n;async function s(){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()}catch{await new Promise(m=>setTimeout(m,2e3))}finally{if(f!==c)return;u=!1,r.toValue(a)&&l()}},h=r.ref(!1);return r.watch(i,async(f,p)=>{if(JSON.stringify(f)===JSON.stringify(p))return;n==null||n.return(null),e.clear(),t.clear(),s(),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,i=!1){const a=v(),n=w(),s=()=>r.toValue(e),u=()=>r.toValue(t),c=F(n,o),l=[s,u,c],h=()=>a.synchronizeDiscover(...d(l)),f=()=>a.discover(...d(l)),p=new E(a),m=new S(f),{poll:y,isInitialPolling:b}=R(p,m,h,l,i);return{objects:p.results,poll:y,isInitialPolling:b}}function _(e,t,o,i=!1){const a=v(),n=w(),s=()=>r.toValue(e),u=()=>r.toValue(t),c=F(n,o),l=[s,u,c],h=()=>a.synchronizeGet(...d(l)),f=new L,p=()=>a.get(...d(l)),m=new C(p),{poll:y,isInitialPolling:b}=R(f,m,h,l,i);return{object:f.result,poll:y,isInitialPolling:b}}function z(e,t,o=!1){const i=v(),s=[()=>r.toValue(e),()=>r.toValue(t)],u=()=>i.synchronizeRecoverOrphans(...d(s)),c=new E(i),l=()=>i.recoverOrphans(...d(s)),h=new S(l),{poll:f,isInitialPolling:p}=R(c,h,u,s,o);return{objects:c.results,poll:f,isInitialPolling:p}}const T=r.defineComponent({__name:"Discover",props:{channels:{},schema:{},session:{},autopoll:{type:Boolean}},setup(e){const t=e,{objects:o,poll:i,isInitialPolling:a}=O(r.toRef(t,"channels"),r.toRef(t,"schema"),r.toRef(t,"session"),r.toRef(t,"autopoll"));return(n,s)=>r.renderSlot(n.$slots,"default",{objects:r.unref(o),poll:r.unref(i),isInitialPolling:r.unref(a)})}}),V=r.defineComponent({__name:"Get",props:{url:{},schema:{},session:{},autopoll:{type:Boolean}},setup(e){const t=e,{object:o,poll:i,isInitialPolling:a}=_(r.toRef(t,"url"),r.toRef(t,"schema"),r.toRef(t,"session"),r.toRef(t,"autopoll"));return(n,s)=>r.renderSlot(n.$slots,"default",{object:r.unref(o),poll:r.unref(i),isInitialPolling:r.unref(a)})}}),D=r.defineComponent({__name:"RecoverOrphans",props:{schema:{},session:{},autopoll:{type:Boolean}},setup(e){const t=e,{objects:o,poll:i,isInitialPolling:a}=z(r.toRef(t,"schema"),r.toRef(t,"session"),r.toRef(t,"autopoll"));return(n,s)=>r.renderSlot(n.$slots,"default",{objects:r.unref(o),poll:r.unref(i),isInitialPolling:r.unref(a)})}}),k={install(e,t){const o=t.graffiti,i=new M.GraffitiSynchronize(o),a=r.ref(void 0);i.sessionEvents.addEventListener("initialized",async n=>{const s=n.detail;if(s&&s.error&&console.error(s.error),s&&s.href){const u=e.config.globalProperties.$router;if(u){const c=u.options.history.base,l=new URL(s.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)}),i.sessionEvents.addEventListener("login",n=>{const s=n.detail;if(s.error){console.error("Error logging in:"),console.error(s.error);return}else a.value=s.session}),i.sessionEvents.addEventListener("logout",n=>{const s=n.detail;s.error?(console.error("Error logging out:"),console.error(s.error)):a.value=null}),G.graffitiSynchronize=i,G.graffitiSession=a,e.component("GraffitiDiscover",T),e.component("GraffitiGet",V),e.component("GraffitiRecoverOrphans",D),e.config.globalProperties.$graffiti=i,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 x(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 q(){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:{},accept:{},session:{}},setup(t){const a=t,{media:n,poll:i}=z(e.toRef(a,"url"),e.toRef(a,"accept"),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}),x(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=q;exports.useGraffitiSynchronize=b;
|
|
2
2
|
//# sourceMappingURL=plugin.js.map
|