@graffiti-garden/wrapper-vue 0.6.2 → 0.6.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/dist/browser/plugin.mjs +506 -479
- package/dist/browser/plugin.mjs.map +1 -1
- package/dist/node/plugin.js +1 -1
- package/dist/node/plugin.js.map +1 -1
- package/dist/node/plugin.mjs +125 -97
- package/dist/node/plugin.mjs.map +1 -1
- package/dist/node/pollers.d.ts +1 -1
- package/dist/node/pollers.d.ts.map +1 -1
- package/dist/node/reducers.d.ts +3 -3
- package/dist/node/reducers.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/pollers.ts +39 -14
- package/src/reducers.ts +11 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pollers.d.ts","sourceRoot":"","sources":["../../src/pollers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"pollers.d.ts","sourceRoot":"","sources":["../../src/pollers.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,UAAU,EACf,KAAK,cAAc,EAEnB,KAAK,iCAAiC,EACtC,KAAK,oBAAoB,EACzB,KAAK,4BAA4B,EAElC,MAAM,sBAAsB,CAAC;AAE9B,8BAAsB,MAAM,CAAC,MAAM,SAAS,UAAU;IACpD,QAAQ,CAAC,IAAI,CACX,OAAO,EAAE,CACP,KAAK,EAAE,iCAAiC,CAAC,MAAM,CAAC,GAAG,IAAI,GAAG,OAAO,KAC9D,IAAI,GACR,OAAO,CAAC,IAAI,CAAC;IAChB,QAAQ,CAAC,KAAK,IAAI,IAAI;CACvB;AAED;;GAEG;AACH,qBAAa,SAAS,CAAC,MAAM,SAAS,UAAU,CAAE,YAAW,MAAM,CAAC,MAAM,CAAC;IAC7D,QAAQ,CAAC,MAAM,EAAE,MAAM,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;gBAA7C,MAAM,EAAE,MAAM,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IAElE,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAc1B;IAEF,KAAK;CACN;AAED;;;;GAIG;AACH,qBAAa,YAAY,CAAC,MAAM,SAAS,UAAU,CAAE,YAAW,MAAM,CAAC,MAAM,CAAC;IAIhE,QAAQ,CAAC,aAAa,EAAE,MAAM,oBAAoB,CAAC,MAAM,CAAC;IAHtE,QAAQ,EAAE,4BAA4B,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;IAC3D,QAAQ,EAAE,CAAC,MAAM,4BAA4B,CAAC,MAAM,CAAC,CAAC,GAAG,SAAS,CAAC;gBAE9C,aAAa,EAAE,MAAM,oBAAoB,CAAC,MAAM,CAAC;IAEtE,KAAK;IAYL,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAiD1B;CACH"}
|
package/dist/node/reducers.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Ref } from 'vue';
|
|
|
2
2
|
import { GraffitiObject, Graffiti, JSONSchema, GraffitiObjectStreamContinueEntry } from '@graffiti-garden/api';
|
|
3
3
|
export declare abstract class Reducer<Schema extends JSONSchema> {
|
|
4
4
|
abstract clear(): void;
|
|
5
|
-
abstract onEntry(entry: GraffitiObjectStreamContinueEntry<Schema> | null): void;
|
|
5
|
+
abstract onEntry(entry: GraffitiObjectStreamContinueEntry<Schema> | null | "clear"): void;
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
8
|
* Retrieves multiple Graffiti objects and retains
|
|
@@ -15,7 +15,7 @@ export declare class SingletonReducer<Schema extends JSONSchema> implements Redu
|
|
|
15
15
|
readonly entry: Ref<GraffitiObjectStreamContinueEntry<Schema> | null | undefined>;
|
|
16
16
|
get result(): Ref<GraffitiObject<Schema> | null | undefined>;
|
|
17
17
|
clear(): void;
|
|
18
|
-
onEntry(entry: GraffitiObjectStreamContinueEntry<Schema> | null): void;
|
|
18
|
+
onEntry(entry: GraffitiObjectStreamContinueEntry<Schema> | null | "clear"): void;
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
21
|
* Retrieves multiple Graffiti objects and retains
|
|
@@ -32,6 +32,6 @@ export declare class ArrayReducer<Schema extends JSONSchema> implements Reducer<
|
|
|
32
32
|
constructor(graffiti: Graffiti);
|
|
33
33
|
clear(): void;
|
|
34
34
|
flattenResults(): void;
|
|
35
|
-
onEntry(entry: GraffitiObjectStreamContinueEntry<Schema> | null): void;
|
|
35
|
+
onEntry(entry: GraffitiObjectStreamContinueEntry<Schema> | null | "clear"): void;
|
|
36
36
|
}
|
|
37
37
|
//# sourceMappingURL=reducers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reducers.d.ts","sourceRoot":"","sources":["../../src/reducers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC/B,OAAO,KAAK,EACV,cAAc,EACd,QAAQ,EACR,UAAU,EACV,iCAAiC,EAClC,MAAM,sBAAsB,CAAC;AAE9B,8BAAsB,OAAO,CAAC,MAAM,SAAS,UAAU;IACrD,QAAQ,CAAC,KAAK,IAAI,IAAI;IACtB,QAAQ,CAAC,OAAO,CACd,KAAK,EAAE,iCAAiC,CAAC,MAAM,CAAC,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"reducers.d.ts","sourceRoot":"","sources":["../../src/reducers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC/B,OAAO,KAAK,EACV,cAAc,EACd,QAAQ,EACR,UAAU,EACV,iCAAiC,EAClC,MAAM,sBAAsB,CAAC;AAE9B,8BAAsB,OAAO,CAAC,MAAM,SAAS,UAAU;IACrD,QAAQ,CAAC,KAAK,IAAI,IAAI;IACtB,QAAQ,CAAC,OAAO,CACd,KAAK,EAAE,iCAAiC,CAAC,MAAM,CAAC,GAAG,IAAI,GAAG,OAAO,GAChE,IAAI;CACR;AAeD;;;;;;GAMG;AACH,qBAAa,gBAAgB,CAAC,MAAM,SAAS,UAAU,CACrD,YAAW,OAAO,CAAC,MAAM,CAAC;IAE1B,QAAQ,CAAC,KAAK,EAAE,GAAG,CACjB,iCAAiC,CAAC,MAAM,CAAC,GAAG,IAAI,GAAG,SAAS,CAC7D,CAAS;IAEV,IAAI,MAAM,IAAI,GAAG,CAAC,cAAc,CAAC,MAAM,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC,CAO3D;IAED,KAAK;IAIL,OAAO,CAAC,KAAK,EAAE,iCAAiC,CAAC,MAAM,CAAC,GAAG,IAAI,GAAG,OAAO;CAS1E;AAED;;;;;;GAMG;AACH,qBAAa,YAAY,CAAC,MAAM,SAAS,UAAU,CACjD,YAAW,OAAO,CAAC,MAAM,CAAC;IAOd,QAAQ,CAAC,QAAQ,EAAE,QAAQ;IALvC,QAAQ,CAAC,OAAO,EAAE,GAAG,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC,CAAW;IAC1D,QAAQ,CAAC,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,iCAAiC,CAAC,MAAM,CAAC,CAAC,CAC/D;IACZ,iBAAiB,EAAE,UAAU,CAAC,OAAO,UAAU,CAAC,GAAG,SAAS,CAAC;gBAExC,QAAQ,EAAE,QAAQ;IAEvC,KAAK;IAOL,cAAc;IAWd,OAAO,CAAC,KAAK,EAAE,iCAAiC,CAAC,MAAM,CAAC,GAAG,IAAI,GAAG,OAAO;CAqB1E"}
|
package/package.json
CHANGED
package/src/pollers.ts
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
Graffiti,
|
|
3
|
-
JSONSchema,
|
|
4
|
-
GraffitiObject,
|
|
5
|
-
GraffitiObjectStreamReturn,
|
|
6
|
-
GraffitiObjectStreamContinueEntry,
|
|
7
|
-
GraffitiObjectStream,
|
|
8
|
-
GraffitiObjectStreamContinue,
|
|
1
|
+
import {
|
|
2
|
+
type Graffiti,
|
|
3
|
+
type JSONSchema,
|
|
4
|
+
type GraffitiObject,
|
|
5
|
+
type GraffitiObjectStreamReturn,
|
|
6
|
+
type GraffitiObjectStreamContinueEntry,
|
|
7
|
+
type GraffitiObjectStream,
|
|
8
|
+
type GraffitiObjectStreamContinue,
|
|
9
|
+
GraffitiErrorNotFound,
|
|
9
10
|
} from "@graffiti-garden/api";
|
|
10
11
|
|
|
11
12
|
export abstract class Poller<Schema extends JSONSchema> {
|
|
12
13
|
abstract poll(
|
|
13
|
-
onEntry: (
|
|
14
|
+
onEntry: (
|
|
15
|
+
entry: GraffitiObjectStreamContinueEntry<Schema> | null | "clear",
|
|
16
|
+
) => void,
|
|
14
17
|
): Promise<void>;
|
|
15
18
|
abstract clear(): void;
|
|
16
19
|
}
|
|
@@ -23,13 +26,18 @@ export class GetPoller<Schema extends JSONSchema> implements Poller<Schema> {
|
|
|
23
26
|
|
|
24
27
|
poll: Poller<Schema>["poll"] = async (onEntry) => {
|
|
25
28
|
let object: GraffitiObject<Schema>;
|
|
29
|
+
const myGetter = this.getter;
|
|
26
30
|
try {
|
|
27
|
-
object = await
|
|
31
|
+
object = await myGetter();
|
|
28
32
|
} catch (e) {
|
|
29
|
-
|
|
33
|
+
if (this.getter === myGetter) {
|
|
34
|
+
onEntry(null);
|
|
35
|
+
}
|
|
30
36
|
return;
|
|
31
37
|
}
|
|
32
|
-
|
|
38
|
+
if (this.getter === myGetter) {
|
|
39
|
+
onEntry({ object });
|
|
40
|
+
}
|
|
33
41
|
};
|
|
34
42
|
|
|
35
43
|
clear() {}
|
|
@@ -61,7 +69,17 @@ export class StreamPoller<Schema extends JSONSchema> implements Poller<Schema> {
|
|
|
61
69
|
poll: Poller<Schema>["poll"] = async (onEntry) => {
|
|
62
70
|
if (!this.iterator) {
|
|
63
71
|
if (this.continue) {
|
|
64
|
-
|
|
72
|
+
try {
|
|
73
|
+
this.iterator = this.continue();
|
|
74
|
+
} catch (e) {
|
|
75
|
+
// The cursor has expired, we need to start from scratch.
|
|
76
|
+
if (e instanceof GraffitiErrorNotFound) {
|
|
77
|
+
onEntry("clear");
|
|
78
|
+
this.iterator = this.streamFactory();
|
|
79
|
+
} else {
|
|
80
|
+
throw e;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
65
83
|
} else {
|
|
66
84
|
this.iterator = this.streamFactory();
|
|
67
85
|
}
|
|
@@ -73,7 +91,14 @@ export class StreamPoller<Schema extends JSONSchema> implements Poller<Schema> {
|
|
|
73
91
|
break;
|
|
74
92
|
}
|
|
75
93
|
|
|
76
|
-
const
|
|
94
|
+
const myIterator: GraffitiObjectStreamContinue<Schema> = this.iterator;
|
|
95
|
+
|
|
96
|
+
const result = await myIterator.next();
|
|
97
|
+
|
|
98
|
+
// Check again if it was cancelled.
|
|
99
|
+
if (myIterator !== this.iterator) {
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
77
102
|
|
|
78
103
|
if (result.done) {
|
|
79
104
|
if (result.value) {
|
package/src/reducers.ts
CHANGED
|
@@ -10,7 +10,7 @@ import type {
|
|
|
10
10
|
export abstract class Reducer<Schema extends JSONSchema> {
|
|
11
11
|
abstract clear(): void;
|
|
12
12
|
abstract onEntry(
|
|
13
|
-
entry: GraffitiObjectStreamContinueEntry<Schema> | null,
|
|
13
|
+
entry: GraffitiObjectStreamContinueEntry<Schema> | null | "clear",
|
|
14
14
|
): void;
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -54,7 +54,11 @@ export class SingletonReducer<Schema extends JSONSchema>
|
|
|
54
54
|
this.entry.value = undefined;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
onEntry(entry: GraffitiObjectStreamContinueEntry<Schema> | null) {
|
|
57
|
+
onEntry(entry: GraffitiObjectStreamContinueEntry<Schema> | null | "clear") {
|
|
58
|
+
if (entry === "clear") {
|
|
59
|
+
this.clear();
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
58
62
|
if (!entry || isEntryNewer<Schema>(entry, this.entry.value)) {
|
|
59
63
|
this.entry.value = entry;
|
|
60
64
|
}
|
|
@@ -96,8 +100,12 @@ export class ArrayReducer<Schema extends JSONSchema>
|
|
|
96
100
|
}, []);
|
|
97
101
|
}
|
|
98
102
|
|
|
99
|
-
onEntry(entry: GraffitiObjectStreamContinueEntry<Schema> | null) {
|
|
103
|
+
onEntry(entry: GraffitiObjectStreamContinueEntry<Schema> | null | "clear") {
|
|
100
104
|
if (!entry) return;
|
|
105
|
+
if (entry === "clear") {
|
|
106
|
+
this.clear();
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
101
109
|
const existing = this.resultsRaw.get(entry.object.url);
|
|
102
110
|
if (!isEntryNewer<Schema>(entry, existing)) return;
|
|
103
111
|
this.resultsRaw.set(entry.object.url, entry);
|