@graffiti-garden/wrapper-vue 1.0.3 → 1.0.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graffiti-garden/wrapper-vue",
3
- "version": "1.0.3",
3
+ "version": "1.0.8",
4
4
  "description": "Vue.js wrapper for the Graffiti API",
5
5
  "types": "./dist/node/plugin.d.ts",
6
6
  "module": "./dist/node/plugin.mjs",
@@ -44,19 +44,19 @@
44
44
  "url": "https://github.com/graffiti-garden/wrapper-vue/issues"
45
45
  },
46
46
  "dependencies": {
47
- "@graffiti-garden/api": "^1.0.3",
48
- "@graffiti-garden/wrapper-synchronize": "^1.0.3"
47
+ "@graffiti-garden/api": "^1.0.8",
48
+ "@graffiti-garden/wrapper-synchronize": "^1.0.8"
49
49
  },
50
50
  "devDependencies": {
51
- "@graffiti-garden/implementation-local": "^1.0.3",
52
- "@types/node": "^25.0.3",
51
+ "@graffiti-garden/implementation-local": "^1.0.8",
52
+ "@types/node": "^25.0.6",
53
53
  "@vitejs/plugin-vue": "^6.0.3",
54
- "@vue/typescript-plugin": "^3.2.0",
55
- "typedoc": "^0.28.15",
54
+ "@vue/typescript-plugin": "^3.2.2",
55
+ "typedoc": "^0.28.16",
56
56
  "typedoc-plugin-vue": "^1.5.1",
57
- "vite": "^7.3.0",
57
+ "vite": "^7.3.1",
58
58
  "vite-plugin-dts": "^4.5.4",
59
- "vite-plugin-node-polyfills": "^0.24.0",
59
+ "vite-plugin-node-polyfills": "^0.25.0",
60
60
  "vue": "^3.5.26",
61
61
  "vue-router": "^4.6.4"
62
62
  },
@@ -39,7 +39,7 @@ const { objects, poll, isFirstPoll } = useGraffitiDiscover<Schema>(
39
39
  </li>
40
40
  </ul>
41
41
  <p v-else>
42
- <em> Loading... </em>
42
+ <em> Graffiti discover loading... </em>
43
43
  </p>
44
44
  </slot>
45
45
  </template>
@@ -2,14 +2,14 @@
2
2
  import { toRef } from "vue";
3
3
  import type {
4
4
  GraffitiSession,
5
- GraffitiMediaRequirements,
5
+ GraffitiMediaAccept,
6
6
  GraffitiMedia,
7
7
  } from "@graffiti-garden/api";
8
8
  import { useGraffitiGetMedia } from "../composables/get-media";
9
9
 
10
10
  const props = defineProps<{
11
11
  url: string;
12
- requirements: GraffitiMediaRequirements;
12
+ accept: GraffitiMediaAccept;
13
13
  session?: GraffitiSession | null;
14
14
  }>();
15
15
 
@@ -22,7 +22,7 @@ defineSlots<{
22
22
 
23
23
  const { media, poll } = useGraffitiGetMedia(
24
24
  toRef(props, "url"),
25
- toRef(props, "requirements"),
25
+ toRef(props, "accept"),
26
26
  toRef(props, "session"),
27
27
  );
28
28
 
@@ -64,12 +64,12 @@ function downloadMedia() {
64
64
  type="application/pdf"
65
65
  :alt="`PDF by ${media.actor}`"
66
66
  />
67
- <button v-else-if="media" @click="downloadMedia">Download</button>
67
+ <button v-else-if="media" @click="downloadMedia">Download media</button>
68
68
  <p v-else-if="media === null">
69
69
  <em>Media not found</em>
70
70
  </p>
71
71
  <p v-else>
72
- <em> Loading... </em>
72
+ <em> Media loading... </em>
73
73
  </p>
74
74
  </slot>
75
75
  </template>
@@ -29,8 +29,10 @@ async function deleteObject(
29
29
 
30
30
  <template>
31
31
  <article v-if="object" :data-url="object.url">
32
- <header>
33
- <h2>Graffiti Object</h2>
32
+ <p>@<ActorToHandle :actor="object.actor" /> posted:</p>
33
+ <pre>{{ object.value }}</pre>
34
+ <details>
35
+ <summary>Show object properties</summary>
34
36
 
35
37
  <dl>
36
38
  <dt>Object URL</dt>
@@ -47,81 +49,63 @@ async function deleteObject(
47
49
  <dd>
48
50
  <ActorToHandle :actor="object.actor" />
49
51
  </dd>
50
- </dl>
51
- </header>
52
-
53
- <section>
54
- <h3>Content</h3>
55
- <pre>{{ object.value }}</pre>
56
- </section>
57
-
58
- <section>
59
- <h3>Allowed Actors</h3>
60
52
 
61
- <p v-if="!Array.isArray(object.allowed)">
62
- <em>Public</em>
63
- </p>
64
- <p v-else-if="object.allowed.length === 0">
65
- <em>Noone</em>
66
- </p>
67
- <ul>
68
- <li v-for="actor in object.allowed" :key="actor">
69
- <dl>
70
- <dt>Actor</dt>
71
- <dd>
72
- <code>{{ actor }}</code>
73
- </dd>
74
- <dt>Handle</dt>
75
- <dd>
76
- <ActorToHandle :actor="actor" />
77
- </dd>
78
- </dl>
79
- </li>
80
- </ul>
81
- </section>
82
-
83
- <section>
84
- <h3>Channels</h3>
53
+ <dt>Content</dt>
54
+ <dd>
55
+ <pre>{{ object.value }}</pre>
56
+ </dd>
85
57
 
86
- <ul v-if="object.channels?.length">
87
- <li v-for="channel in object.channels" :key="channel">
88
- <code>{{ channel }}</code>
89
- </li>
90
- </ul>
91
- <p v-else>
92
- <em>No channels</em>
93
- </p>
94
- </section>
58
+ <dt>Allowed actors</dt>
59
+ <dd>
60
+ <p v-if="!Array.isArray(object.allowed)">
61
+ <em>Public</em>
62
+ </p>
63
+ <p v-else-if="object.allowed.length === 0">
64
+ <em>No one is allowed (except you)</em>
65
+ </p>
66
+ <ul>
67
+ <li v-for="actor in object.allowed" :key="actor">
68
+ <dl>
69
+ <dt>Actor</dt>
70
+ <dd>
71
+ <code>{{ actor }}</code>
72
+ </dd>
73
+ <dt>Handle</dt>
74
+ <dd>
75
+ <ActorToHandle :actor="actor" />
76
+ </dd>
77
+ </dl>
78
+ </li>
79
+ </ul>
80
+ </dd>
95
81
 
96
- <footer>
97
- <nav>
98
- <ul>
99
- <li v-if="$graffitiSession.value?.actor === object.actor">
100
- <button
101
- :disabled="deleting"
102
- @click="
103
- deleteObject(object, $graffitiSession.value)
104
- "
105
- >
106
- {{ deleting ? "Deleting..." : "Delete" }}
107
- </button>
108
- </li>
109
- </ul>
110
- </nav>
111
- </footer>
82
+ <dt>Channels</dt>
83
+ <dd>
84
+ <ul v-if="object.channels?.length">
85
+ <li v-for="channel in object.channels" :key="channel">
86
+ <code>{{ channel }}</code>
87
+ </li>
88
+ </ul>
89
+ <p v-else>
90
+ <em>No channels</em>
91
+ </p>
92
+ </dd>
93
+ </dl>
94
+ </details>
95
+ <button
96
+ v-if="$graffitiSession.value?.actor === object.actor"
97
+ :disabled="deleting"
98
+ @click="deleteObject(object, $graffitiSession.value)"
99
+ >
100
+ {{ deleting ? "Deleting..." : "Delete" }}
101
+ </button>
112
102
  </article>
113
103
 
114
104
  <article v-else-if="object === null">
115
- <header>
116
- <h2>Graffiti Object</h2>
117
- </header>
118
- <p><em>Object not found</em></p>
105
+ <p><em>Graffiti object not found</em></p>
119
106
  </article>
120
107
 
121
108
  <article v-else>
122
- <header>
123
- <h2>Graffiti Object</h2>
124
- </header>
125
- <p><em>Loading...</em></p>
109
+ <p><em>Graffiti object loading...</em></p>
126
110
  </article>
127
111
  </template>
@@ -7,7 +7,7 @@ import type {
7
7
  GraffitiSession,
8
8
  JSONSchema,
9
9
  } from "@graffiti-garden/api";
10
- import { GraffitiErrorNotFound } from "@graffiti-garden/api";
10
+ import { GraffitiErrorCursorExpired } from "@graffiti-garden/api";
11
11
  import type { MaybeRefOrGetter, Ref } from "vue";
12
12
  import { ref, toValue, watch, onScopeDispose } from "vue";
13
13
  import { useGraffitiSynchronize } from "../globals";
@@ -155,11 +155,13 @@ export function useGraffitiDiscover<Schema extends JSONSchema>(
155
155
  try {
156
156
  result = await myDiscoverIterator.next();
157
157
  } catch (e) {
158
- if (e instanceof GraffitiErrorNotFound) {
158
+ if (e instanceof GraffitiErrorCursorExpired) {
159
159
  // The cursor has expired, we need to start from scratch.
160
160
  return restartWatch();
161
161
  } else {
162
162
  // If something else went wrong, wait a bit before retrying
163
+ console.error("Fatal error in discover");
164
+ console.error(e);
163
165
  return restartWatch(5000);
164
166
  }
165
167
  }
@@ -1,6 +1,6 @@
1
1
  import type {
2
2
  GraffitiMedia,
3
- GraffitiMediaRequirements,
3
+ GraffitiMediaAccept,
4
4
  GraffitiSession,
5
5
  } from "@graffiti-garden/api";
6
6
  import { GraffitiErrorNotFound } from "@graffiti-garden/api";
@@ -32,7 +32,7 @@ import { useGraffitiSynchronize } from "../globals";
32
32
  */
33
33
  export function useGraffitiGetMedia(
34
34
  url: MaybeRefOrGetter<string>,
35
- requirements: MaybeRefOrGetter<GraffitiMediaRequirements>,
35
+ accept: MaybeRefOrGetter<GraffitiMediaAccept>,
36
36
  session?: MaybeRefOrGetter<GraffitiSession | undefined | null>,
37
37
  ): {
38
38
  media: Ref<(GraffitiMedia & { dataUrl: string }) | null | undefined>;
@@ -63,7 +63,7 @@ export function useGraffitiGetMedia(
63
63
  }
64
64
  watch(
65
65
  () => ({
66
- args: [toValue(url), toValue(requirements), toValue(session)] as const,
66
+ args: [toValue(url), toValue(accept), toValue(session)] as const,
67
67
  pollCounter: pollCounter.value,
68
68
  }),
69
69
  async ({ args }, _prev, onInvalidate) => {
@@ -24,9 +24,8 @@ export function useResolveString(
24
24
  } catch (err) {
25
25
  if (!active) return;
26
26
 
27
- if (err instanceof GraffitiErrorNotFound) {
28
- output.value = null;
29
- } else {
27
+ output.value = null;
28
+ if (!(err instanceof GraffitiErrorNotFound)) {
30
29
  console.error(err);
31
30
  }
32
31
  }