@graffiti-garden/wrapper-vue 0.7.2 → 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 -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/src/reducers.ts
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { computed, ref } from "vue";
|
|
2
|
-
import type { Ref } from "vue";
|
|
3
|
-
import type {
|
|
4
|
-
GraffitiObject,
|
|
5
|
-
Graffiti,
|
|
6
|
-
JSONSchema,
|
|
7
|
-
GraffitiObjectStreamContinueEntry,
|
|
8
|
-
} from "@graffiti-garden/api";
|
|
9
|
-
|
|
10
|
-
export abstract class Reducer<Schema extends JSONSchema> {
|
|
11
|
-
abstract clear(): void;
|
|
12
|
-
abstract onEntry(
|
|
13
|
-
entry: GraffitiObjectStreamContinueEntry<Schema> | null | "clear",
|
|
14
|
-
): void;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function isEntryNewer<Schema extends JSONSchema>(
|
|
18
|
-
entry: GraffitiObjectStreamContinueEntry<Schema>,
|
|
19
|
-
existing: GraffitiObjectStreamContinueEntry<Schema> | null | undefined,
|
|
20
|
-
): boolean {
|
|
21
|
-
return (
|
|
22
|
-
!existing ||
|
|
23
|
-
entry.object.lastModified > existing.object.lastModified ||
|
|
24
|
-
(entry.object.lastModified === existing.object.lastModified &&
|
|
25
|
-
!entry.tombstone &&
|
|
26
|
-
!!existing.tombstone)
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Retrieves multiple Graffiti objects and retains
|
|
32
|
-
* the most recent one as the `result` property (a Vue ref).
|
|
33
|
-
* Before any objects have been received, the result
|
|
34
|
-
* is `undefined`. If the object has been deleted,
|
|
35
|
-
* the result is `null`.
|
|
36
|
-
*/
|
|
37
|
-
export class SingletonReducer<Schema extends JSONSchema>
|
|
38
|
-
implements Reducer<Schema>
|
|
39
|
-
{
|
|
40
|
-
readonly entry: Ref<
|
|
41
|
-
GraffitiObjectStreamContinueEntry<Schema> | null | undefined
|
|
42
|
-
> = ref();
|
|
43
|
-
|
|
44
|
-
get result(): Ref<GraffitiObject<Schema> | null | undefined> {
|
|
45
|
-
return computed(() => {
|
|
46
|
-
const value = this.entry.value;
|
|
47
|
-
if (!value) return value;
|
|
48
|
-
if (value.tombstone) return null;
|
|
49
|
-
return value.object;
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
clear() {
|
|
54
|
-
this.entry.value = undefined;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
onEntry(entry: GraffitiObjectStreamContinueEntry<Schema> | null | "clear") {
|
|
58
|
-
if (entry === "clear") {
|
|
59
|
-
this.clear();
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
if (!entry || isEntryNewer<Schema>(entry, this.entry.value)) {
|
|
63
|
-
this.entry.value = entry;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Retrieves multiple Graffiti objects and retains
|
|
70
|
-
* the most recent one per URI as the `results` property (a Vue ref).
|
|
71
|
-
* If multiple objects are received concurrently,
|
|
72
|
-
* they are processed in batches every `REFRESH_RATE` milliseconds
|
|
73
|
-
* to avoid freezing the interface.
|
|
74
|
-
*/
|
|
75
|
-
export class ArrayReducer<Schema extends JSONSchema>
|
|
76
|
-
implements Reducer<Schema>
|
|
77
|
-
{
|
|
78
|
-
readonly results: Ref<GraffitiObject<Schema>[]> = ref([]);
|
|
79
|
-
readonly resultsRaw: Map<string, GraffitiObjectStreamContinueEntry<Schema>> =
|
|
80
|
-
new Map();
|
|
81
|
-
batchFlattenTimer: ReturnType<typeof setTimeout> | undefined;
|
|
82
|
-
|
|
83
|
-
constructor(readonly graffiti: Graffiti) {}
|
|
84
|
-
|
|
85
|
-
clear() {
|
|
86
|
-
this.resultsRaw.clear();
|
|
87
|
-
this.results.value = [];
|
|
88
|
-
clearTimeout(this.batchFlattenTimer);
|
|
89
|
-
this.batchFlattenTimer = undefined;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
flattenResults() {
|
|
93
|
-
this.results.value = Array.from(this.resultsRaw.values()).reduce<
|
|
94
|
-
GraffitiObject<Schema>[]
|
|
95
|
-
>((acc, entry) => {
|
|
96
|
-
if (!entry.tombstone) {
|
|
97
|
-
acc.push(entry.object);
|
|
98
|
-
}
|
|
99
|
-
return acc;
|
|
100
|
-
}, []);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
onEntry(entry: GraffitiObjectStreamContinueEntry<Schema> | null | "clear") {
|
|
104
|
-
if (!entry) return;
|
|
105
|
-
if (entry === "clear") {
|
|
106
|
-
this.clear();
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
const existing = this.resultsRaw.get(entry.object.url);
|
|
110
|
-
if (!isEntryNewer<Schema>(entry, existing)) return;
|
|
111
|
-
this.resultsRaw.set(entry.object.url, entry);
|
|
112
|
-
|
|
113
|
-
// Don't flatten the results all at once,
|
|
114
|
-
// because we may get a lot of results
|
|
115
|
-
// and we don't want the interface to
|
|
116
|
-
// freeze up
|
|
117
|
-
if (!this.batchFlattenTimer) {
|
|
118
|
-
this.batchFlattenTimer = setTimeout(() => {
|
|
119
|
-
this.flattenResults();
|
|
120
|
-
this.batchFlattenTimer = undefined;
|
|
121
|
-
}, 0);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
}
|