@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.
- 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 +999 -941
- 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 -331
- 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 -343
- package/src/pollers.ts +0 -119
- package/src/reducers.ts +0 -124
package/src/globals.ts
CHANGED
|
@@ -2,11 +2,33 @@ import type { Ref } from "vue";
|
|
|
2
2
|
import type { Graffiti, GraffitiSession } from "@graffiti-garden/api";
|
|
3
3
|
import type { GraffitiSynchronize } from "@graffiti-garden/wrapper-synchronize";
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
const globals: {
|
|
6
6
|
graffitiSynchronize?: GraffitiSynchronize;
|
|
7
7
|
graffitiSession?: Ref<GraffitiSession | undefined | null>;
|
|
8
8
|
} = {};
|
|
9
9
|
|
|
10
|
+
export function setGraffitiSession(
|
|
11
|
+
session: Ref<GraffitiSession | undefined | null>,
|
|
12
|
+
) {
|
|
13
|
+
if (!globals.graffitiSession) {
|
|
14
|
+
globals.graffitiSession = session;
|
|
15
|
+
} else {
|
|
16
|
+
throw new Error(
|
|
17
|
+
"Graffiti session already set - plugin installed multiple times?",
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function setGraffitiSynchronize(synchronize: GraffitiSynchronize) {
|
|
23
|
+
if (!globals.graffitiSynchronize) {
|
|
24
|
+
globals.graffitiSynchronize = synchronize;
|
|
25
|
+
} else {
|
|
26
|
+
throw new Error(
|
|
27
|
+
"Graffiti synchronize already set - plugin installed multiple times?",
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
10
32
|
/**
|
|
11
33
|
* Returns the global [Graffiti](https://api.graffiti.garden/classes/Graffiti.html) instance
|
|
12
34
|
* that has been wrapped by the {@link GraffitiPlugin} with the [GraffitiSynchronize](https://sync.graffiti.garden/classes/GraffitiSynchronize.html).
|
|
@@ -26,7 +48,7 @@ export function useGraffitiSynchronize() {
|
|
|
26
48
|
* Returns the global [Graffiti](https://api.graffiti.garden/classes/Graffiti.html) instance.
|
|
27
49
|
*
|
|
28
50
|
* In Vue templates and the [options API](https://vuejs.org/guide/introduction.html#options-api)
|
|
29
|
-
* use the global variable {@link ComponentCustomProperties.$graffiti | $graffiti} instead.
|
|
51
|
+
* use may use the global variable {@link ComponentCustomProperties.$graffiti | $graffiti} instead.
|
|
30
52
|
*
|
|
31
53
|
* This is the same Graffiti registered with the {@link GraffitiPlugin}
|
|
32
54
|
* via {@link GraffitiPluginOptions.graffiti}, only it has been wrapped
|
package/src/plugin.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type { App, Plugin, Ref } from "vue";
|
|
2
2
|
import { ref } from "vue";
|
|
3
|
-
import Discover from "./Discover.vue";
|
|
4
|
-
import Get from "./Get.vue";
|
|
5
|
-
import
|
|
3
|
+
import Discover from "./components/Discover.vue";
|
|
4
|
+
import Get from "./components/Get.vue";
|
|
5
|
+
import GetMedia from "./components/GetMedia.vue";
|
|
6
|
+
import ActorToHandle from "./components/ActorToHandle.vue";
|
|
7
|
+
import HandleToActor from "./components/HandleToActor.vue";
|
|
8
|
+
import ObjectInfo from "./components/ObjectInfo.vue";
|
|
6
9
|
import type {
|
|
7
10
|
Graffiti,
|
|
8
11
|
GraffitiSession,
|
|
@@ -10,7 +13,7 @@ import type {
|
|
|
10
13
|
GraffitiLogoutEvent,
|
|
11
14
|
GraffitiSessionInitializedEvent,
|
|
12
15
|
} from "@graffiti-garden/api";
|
|
13
|
-
import {
|
|
16
|
+
import { setGraffitiSession, setGraffitiSynchronize } from "./globals";
|
|
14
17
|
import type { Router } from "vue-router";
|
|
15
18
|
import { GraffitiSynchronize } from "@graffiti-garden/wrapper-synchronize";
|
|
16
19
|
|
|
@@ -49,7 +52,10 @@ declare module "vue" {
|
|
|
49
52
|
export interface GlobalComponents {
|
|
50
53
|
GraffitiDiscover: typeof Discover;
|
|
51
54
|
GraffitiGet: typeof Get;
|
|
52
|
-
|
|
55
|
+
GraffitiGetMedia: typeof GetMedia;
|
|
56
|
+
GraffitiActorToHandle: typeof ActorToHandle;
|
|
57
|
+
GraffitiHandleToActor: typeof HandleToActor;
|
|
58
|
+
GraffitiObjectInfo: typeof ObjectInfo;
|
|
53
59
|
}
|
|
54
60
|
}
|
|
55
61
|
export type { ComponentCustomProperties } from "vue";
|
|
@@ -66,10 +72,6 @@ export interface GraffitiPluginOptions {
|
|
|
66
72
|
* and in setup functions as {@link useGraffiti}.
|
|
67
73
|
* You must interact with Graffiti through these wrapped instances
|
|
68
74
|
* to enable reactivity.
|
|
69
|
-
*
|
|
70
|
-
* You'll likely want to use the [federated implementation](https://github.com/graffiti-garden/implementation-federated).
|
|
71
|
-
* However, you could also use the [local implementation](https://github.com/graffiti-garden/implementation-local)
|
|
72
|
-
* for testing. Other implementations may be available in the future.
|
|
73
75
|
*/
|
|
74
76
|
graffiti: Graffiti;
|
|
75
77
|
}
|
|
@@ -90,19 +92,27 @@ export interface GraffitiPluginOptions {
|
|
|
90
92
|
* | --- | --- | --- |
|
|
91
93
|
* | [discover](https://api.graffiti.garden/classes/Graffiti.html#discover) | {@link useGraffitiDiscover} | {@link GraffitiDiscover} |
|
|
92
94
|
* | [get](https://api.graffiti.garden/classes/Graffiti.html#get) | {@link useGraffitiGet} | {@link GraffitiGet} |
|
|
93
|
-
* | [
|
|
95
|
+
* | [getMedia](https://api.graffiti.garden/classes/Graffiti.html#getmedia) | {@link useGraffitiGetMedia} | {@link GraffitiGetMedia} |
|
|
96
|
+
* | [actorToHandle](https://api.graffiti.garden/classes/Graffiti.html#actortohandle) | {@link useGraffitiActorToHandle} | {@link GraffitiActorToHandle} |
|
|
97
|
+
* | [handleToActor](https://api.graffiti.garden/classes/Graffiti.html#handletoactor) | {@link useGraffitiHandleToActor} | {@link GraffitiHandleToActor} |
|
|
94
98
|
*
|
|
95
99
|
* The plugin also exposes a global [Graffiti](https://api.graffiti.garden/classes/Graffiti.html) instance
|
|
96
100
|
* and keeps track of the global [GraffitiSession](https://api.graffiti.garden/interfaces/GraffitiSession.html)
|
|
97
101
|
* state as a reactive variable.
|
|
98
102
|
* They are available in templates as global variables or in setup functions as
|
|
99
|
-
*
|
|
103
|
+
* getter functions.
|
|
100
104
|
*
|
|
101
|
-
* | Global variabale |
|
|
105
|
+
* | Global variabale | Getter |
|
|
102
106
|
* | --- | --- |
|
|
103
107
|
* | {@link ComponentCustomProperties.$graffiti | $graffiti } | {@link useGraffiti} |
|
|
104
108
|
* | {@link ComponentCustomProperties.$graffitiSession | $graffitiSession } | {@link useGraffitiSession} |
|
|
105
109
|
*
|
|
110
|
+
* Finally, the plugin exposes an additional component, {@link GraffitiObjectInfo}
|
|
111
|
+
* that can be use to generically display a Graffiti object for debugging purposes.
|
|
112
|
+
* {@link GraffitiDiscover} and {@link GraffitiGet} show this output as
|
|
113
|
+
* [fallback content](https://vuejs.org/guide/components/slots.html#fallback-content)
|
|
114
|
+
* if no template is provided
|
|
115
|
+
*
|
|
106
116
|
* [See the README for installation instructions](/).
|
|
107
117
|
*
|
|
108
118
|
* You can [try out live examples](/examples/), but basic usage looks like this:
|
|
@@ -124,7 +134,7 @@ export interface GraffitiPluginOptions {
|
|
|
124
134
|
* <template>
|
|
125
135
|
* <button
|
|
126
136
|
* v-if="$graffitiSession.value"
|
|
127
|
-
* @click="$graffiti.
|
|
137
|
+
* @click="$graffiti.post({
|
|
128
138
|
* value: { content: 'Hello, world!' },
|
|
129
139
|
* channels: [ 'my-channel' ]
|
|
130
140
|
* }, $graffitiSession.value)"
|
|
@@ -136,7 +146,7 @@ export interface GraffitiPluginOptions {
|
|
|
136
146
|
* </button>
|
|
137
147
|
*
|
|
138
148
|
* <GraffitiDiscover
|
|
139
|
-
* v-slot="{
|
|
149
|
+
* v-slot="{ objects }"
|
|
140
150
|
* :channels="[ 'my-channel' ]"
|
|
141
151
|
* :schema="{
|
|
142
152
|
* properties: {
|
|
@@ -151,10 +161,10 @@ export interface GraffitiPluginOptions {
|
|
|
151
161
|
* >
|
|
152
162
|
* <ul>
|
|
153
163
|
* <li
|
|
154
|
-
* v-for="
|
|
155
|
-
* :key="
|
|
164
|
+
* v-for="object in objects"
|
|
165
|
+
* :key="object.url"
|
|
156
166
|
* >
|
|
157
|
-
* {{
|
|
167
|
+
* {{ object.value.content }}
|
|
158
168
|
* </li>
|
|
159
169
|
* </ul>
|
|
160
170
|
* </GraffitiDiscover>
|
|
@@ -214,18 +224,25 @@ export const GraffitiPlugin: Plugin<GraffitiPluginOptions> = {
|
|
|
214
224
|
}
|
|
215
225
|
});
|
|
216
226
|
|
|
217
|
-
|
|
218
|
-
|
|
227
|
+
setGraffitiSynchronize(graffiti);
|
|
228
|
+
setGraffitiSession(graffitiSession);
|
|
219
229
|
|
|
220
230
|
app.component("GraffitiDiscover", Discover);
|
|
221
231
|
app.component("GraffitiGet", Get);
|
|
222
|
-
app.component("
|
|
232
|
+
app.component("GraffitiGetMedia", GetMedia);
|
|
233
|
+
app.component("GraffitiActorToHandle", ActorToHandle);
|
|
234
|
+
app.component("GraffitiHandleToActor", HandleToActor);
|
|
235
|
+
app.component("GraffitiObjectInfo", ObjectInfo);
|
|
223
236
|
app.config.globalProperties.$graffiti = graffiti;
|
|
224
237
|
app.config.globalProperties.$graffitiSession = graffitiSession;
|
|
225
238
|
},
|
|
226
239
|
};
|
|
227
240
|
|
|
228
|
-
export
|
|
241
|
+
export { useGraffitiActorToHandle } from "./composables/actor-to-handle";
|
|
242
|
+
export { useGraffitiHandleToActor } from "./composables/handle-to-actor";
|
|
243
|
+
export { useGraffitiDiscover } from "./composables/discover";
|
|
244
|
+
export { useGraffitiGet } from "./composables/get";
|
|
245
|
+
export { useGraffitiGetMedia } from "./composables/get-media";
|
|
229
246
|
export {
|
|
230
247
|
useGraffiti,
|
|
231
248
|
useGraffitiSynchronize,
|
|
@@ -237,8 +254,11 @@ export {
|
|
|
237
254
|
* method as a reactive [renderless component](https://vuejs.org/guide/components/slots#renderless-components)
|
|
238
255
|
* for use in Vue templates.
|
|
239
256
|
*
|
|
240
|
-
* Its props and slots
|
|
241
|
-
* the
|
|
257
|
+
* Its props and [slots props](https://vuejs.org/guide/components/slots.html#scoped-slots)
|
|
258
|
+
* are identical to the arguments and return values of
|
|
259
|
+
* the composable {@link useGraffitiDiscover}. If no template is provided to
|
|
260
|
+
* the default slot, [fallback content](https://vuejs.org/guide/components/slots.html#fallback-content)
|
|
261
|
+
* will display the objects using {@link GraffitiObjectInfo} for debugging.
|
|
242
262
|
*/
|
|
243
263
|
export const GraffitiDiscover = Discover;
|
|
244
264
|
/**
|
|
@@ -246,16 +266,51 @@ export const GraffitiDiscover = Discover;
|
|
|
246
266
|
* method as a reactive [renderless component](https://vuejs.org/guide/components/slots#renderless-components)
|
|
247
267
|
* for use in Vue templates.
|
|
248
268
|
*
|
|
249
|
-
* Its props and slots
|
|
250
|
-
* the
|
|
269
|
+
* Its props and [slots props](https://vuejs.org/guide/components/slots.html#scoped-slots)
|
|
270
|
+
* are identical to the arguments and return values of
|
|
271
|
+
* the composable {@link useGraffitiGet}. If no template is provided to
|
|
272
|
+
* the default slot, [fallback content](https://vuejs.org/guide/components/slots.html#fallback-content)
|
|
273
|
+
* will display the object using {@link GraffitiObjectInfo} for debugging.
|
|
251
274
|
*/
|
|
252
275
|
export const GraffitiGet = Get;
|
|
253
276
|
/**
|
|
254
|
-
* The [Graffiti.
|
|
277
|
+
* The [Graffiti.getMedia](https://api.graffiti.garden/classes/Graffiti.html#getmedia)
|
|
255
278
|
* method as a reactive [renderless component](https://vuejs.org/guide/components/slots#renderless-components)
|
|
256
279
|
* for use in Vue templates.
|
|
257
280
|
*
|
|
258
|
-
* Its props and slots
|
|
259
|
-
* the
|
|
281
|
+
* Its props and [slots props](https://vuejs.org/guide/components/slots.html#scoped-slots)
|
|
282
|
+
* are identical to the arguments and return values of
|
|
283
|
+
* the composable {@link useGraffitiGetMedia}. If no template is provided to
|
|
284
|
+
* the default slot, [fallback content](https://vuejs.org/guide/components/slots.html#fallback-content)
|
|
285
|
+
* will display the media in an appropriate container based on its media type.
|
|
286
|
+
*/
|
|
287
|
+
export const GraffitiGetMedia = GetMedia;
|
|
288
|
+
/**
|
|
289
|
+
* The [Graffiti.actorToHandle](https://api.graffiti.garden/classes/Graffiti.html#actortohandle)
|
|
290
|
+
* method as a reactive [renderless component](https://vuejs.org/guide/components/slots#renderless-components)
|
|
291
|
+
* for use in Vue templates.
|
|
292
|
+
*
|
|
293
|
+
* Its props and [slots props](https://vuejs.org/guide/components/slots.html#scoped-slots)
|
|
294
|
+
* are identical to the arguments and return values of
|
|
295
|
+
* the composable {@link useGraffitiActorToHandle}. If no template is provided to
|
|
296
|
+
* the default slot, [fallback content](https://vuejs.org/guide/components/slots.html#fallback-content)
|
|
297
|
+
* will display the actor's handle.
|
|
298
|
+
*/
|
|
299
|
+
export const GraffitiActorToHandle = ActorToHandle;
|
|
300
|
+
/**
|
|
301
|
+
* The [Graffiti.handleToActor](https://api.graffiti.garden/classes/Graffiti.html#handletoactor)
|
|
302
|
+
* method as a reactive [renderless component](https://vuejs.org/guide/components/slots#renderless-components)
|
|
303
|
+
* for use in Vue templates.
|
|
304
|
+
*
|
|
305
|
+
* Its props and [slots props](https://vuejs.org/guide/components/slots.html#scoped-slots)
|
|
306
|
+
* are identical to the arguments and return values of
|
|
307
|
+
* the composable {@link useGraffitiHandleToActor}. If no template is provided to
|
|
308
|
+
* the default slot, [fallback content](https://vuejs.org/guide/components/slots.html#fallback-content)
|
|
309
|
+
* will display the actor DID.
|
|
310
|
+
*/
|
|
311
|
+
export const GraffitiHandleToActor = HandleToActor;
|
|
312
|
+
/**
|
|
313
|
+
* Displays a Graffiti object and all of its properties for
|
|
314
|
+
* debugging purposes.
|
|
260
315
|
*/
|
|
261
|
-
export const
|
|
316
|
+
export const GraffitiObjectInfo = ObjectInfo;
|