@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
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { Ref, MaybeRefOrGetter } from 'vue';
|
|
2
|
-
import { GraffitiObjectUrl, GraffitiObject, GraffitiSession, JSONSchema } from '@graffiti-garden/api';
|
|
3
|
-
/**
|
|
4
|
-
* The [Graffiti.discover](https://api.graffiti.garden/classes/Graffiti.html#discover)
|
|
5
|
-
* method as a reactive [composable](https://vuejs.org/guide/reusability/composables.html)
|
|
6
|
-
* for use in the Vue [composition API](https://vuejs.org/guide/introduction.html#composition-api).
|
|
7
|
-
*
|
|
8
|
-
* Its corresponding renderless component is {@link GraffitiDiscover}.
|
|
9
|
-
*
|
|
10
|
-
* The arguments of this composable as the same as Graffiti.discover,
|
|
11
|
-
* only they can also be [Refs](https://vuejs.org/api/reactivity-core.html#ref)
|
|
12
|
-
* or [getters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get#description).
|
|
13
|
-
* As they change the output will automatically update.
|
|
14
|
-
* Reactivity only triggers when the root array or object changes,
|
|
15
|
-
* not when the elements or properties change.
|
|
16
|
-
* If you need deep reactivity, wrap your argument in a getter.
|
|
17
|
-
*/
|
|
18
|
-
export declare function useGraffitiDiscover<Schema extends JSONSchema>(channels: MaybeRefOrGetter<string[]>, schema: MaybeRefOrGetter<Schema>,
|
|
19
|
-
/**
|
|
20
|
-
* If the session is `undefined`, the global session,
|
|
21
|
-
* {@link ComponentCustomProperties.$graffitiSession | $graffitiSession},
|
|
22
|
-
* will be used. Otherwise, the provided value will be used.
|
|
23
|
-
*/
|
|
24
|
-
session?: MaybeRefOrGetter<GraffitiSession | undefined | null>, autopoll?: MaybeRefOrGetter<boolean>): {
|
|
25
|
-
objects: Ref<GraffitiObject<Schema>[]>;
|
|
26
|
-
poll: () => Promise<void>;
|
|
27
|
-
isInitialPolling: Ref<boolean>;
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* The [Graffiti.get](https://api.graffiti.garden/classes/Graffiti.html#get)
|
|
31
|
-
* method as a reactive [composable](https://vuejs.org/guide/reusability/composables.html)
|
|
32
|
-
* for use in the Vue [composition API](https://vuejs.org/guide/introduction.html#composition-api).
|
|
33
|
-
*
|
|
34
|
-
* Its corresponding renderless component is {@link GraffitiGet}.
|
|
35
|
-
*
|
|
36
|
-
* The arguments of this composable as the same as Graffiti.get,
|
|
37
|
-
* only they can also be [Refs](https://vuejs.org/api/reactivity-core.html#ref)
|
|
38
|
-
* or [getters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get#description).
|
|
39
|
-
* As they change the output will automatically update.
|
|
40
|
-
* Reactivity only triggers when the root array or object changes,
|
|
41
|
-
* not when the elements or properties change.
|
|
42
|
-
* If you need deep reactivity, wrap your argument in a getter.
|
|
43
|
-
*/
|
|
44
|
-
export declare function useGraffitiGet<Schema extends JSONSchema>(locationOrUri: MaybeRefOrGetter<GraffitiObjectUrl | string>, schema: MaybeRefOrGetter<Schema>,
|
|
45
|
-
/**
|
|
46
|
-
* If the session is `undefined`, the global session,
|
|
47
|
-
* {@link ComponentCustomProperties.$graffitiSession | $graffitiSession},
|
|
48
|
-
* will be used. Otherwise, the provided value will be used.
|
|
49
|
-
*/
|
|
50
|
-
session?: MaybeRefOrGetter<GraffitiSession | undefined | null>, autopoll?: MaybeRefOrGetter<boolean>): {
|
|
51
|
-
object: Ref<GraffitiObject<Schema> | null | undefined>;
|
|
52
|
-
poll: () => Promise<void>;
|
|
53
|
-
isInitialPolling: Ref<boolean>;
|
|
54
|
-
};
|
|
55
|
-
/**
|
|
56
|
-
* The [Graffiti.recoverOrphans](https://api.graffiti.garden/classes/Graffiti.html#recoverorphans)
|
|
57
|
-
* method as a reactive [composable](https://vuejs.org/guide/reusability/composables.html)
|
|
58
|
-
* for use in the Vue [composition API](https://vuejs.org/guide/introduction.html#composition-api).
|
|
59
|
-
*
|
|
60
|
-
* Its corresponding renderless component is {@link GraffitiRecoverOrphans}.
|
|
61
|
-
*
|
|
62
|
-
* The arguments of this composable as the same as Graffiti.get,
|
|
63
|
-
* only they can also be [Refs](https://vuejs.org/api/reactivity-core.html#ref)
|
|
64
|
-
* or [getters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get#description).
|
|
65
|
-
* As they change the output will automatically update.
|
|
66
|
-
* Reactivity only triggers when the root array or object changes,
|
|
67
|
-
* not when the elements or properties change.
|
|
68
|
-
* If you need deep reactivity, wrap your argument in a getter.
|
|
69
|
-
*/
|
|
70
|
-
export declare function useGraffitiRecoverOrphans<Schema extends JSONSchema>(schema: MaybeRefOrGetter<Schema>, session: MaybeRefOrGetter<GraffitiSession>, autopoll?: MaybeRefOrGetter<boolean>): {
|
|
71
|
-
objects: Ref<GraffitiObject<Schema>[]>;
|
|
72
|
-
poll: () => Promise<void>;
|
|
73
|
-
isInitialPolling: Ref<boolean>;
|
|
74
|
-
};
|
|
75
|
-
//# sourceMappingURL=composables.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"composables.d.ts","sourceRoot":"","sources":["../../src/composables.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,gBAAgB,EAAE,MAAM,KAAK,CAAC;AACjD,OAAO,KAAK,EACV,iBAAiB,EACjB,cAAc,EACd,eAAe,EACf,UAAU,EAEX,MAAM,sBAAsB,CAAC;AA8G9B;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,SAAS,UAAU,EAC3D,QAAQ,EAAE,gBAAgB,CAAC,MAAM,EAAE,CAAC,EACpC,MAAM,EAAE,gBAAgB,CAAC,MAAM,CAAC;AAChC;;;;GAIG;AACH,OAAO,CAAC,EAAE,gBAAgB,CAAC,eAAe,GAAG,SAAS,GAAG,IAAI,CAAC,EAC9D,QAAQ,GAAE,gBAAgB,CAAC,OAAO,CAAS,GAC1C;IACD,OAAO,EAAE,GAAG,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACvC,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,gBAAgB,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;CAChC,CA6CA;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,CAAC,MAAM,SAAS,UAAU,EACtD,aAAa,EAAE,gBAAgB,CAAC,iBAAiB,GAAG,MAAM,CAAC,EAC3D,MAAM,EAAE,gBAAgB,CAAC,MAAM,CAAC;AAChC;;;;GAIG;AACH,OAAO,CAAC,EAAE,gBAAgB,CAAC,eAAe,GAAG,SAAS,GAAG,IAAI,CAAC,EAC9D,QAAQ,GAAE,gBAAgB,CAAC,OAAO,CAAS,GAC1C;IACD,MAAM,EAAE,GAAG,CAAC,cAAc,CAAC,MAAM,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;IACvD,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,gBAAgB,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;CAChC,CAkDA;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,SAAS,UAAU,EACjE,MAAM,EAAE,gBAAgB,CAAC,MAAM,CAAC,EAChC,OAAO,EAAE,gBAAgB,CAAC,eAAe,CAAC,EAC1C,QAAQ,GAAE,gBAAgB,CAAC,OAAO,CAAS,GAC1C;IACD,OAAO,EAAE,GAAG,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACvC,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,gBAAgB,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;CAChC,CA4CA"}
|
package/dist/node/pollers.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { JSONSchema, GraffitiObject, GraffitiObjectStreamContinueEntry, GraffitiObjectStream, GraffitiObjectStreamContinue } from '@graffiti-garden/api';
|
|
2
|
-
export declare abstract class Poller<Schema extends JSONSchema> {
|
|
3
|
-
abstract poll(onEntry: (entry: GraffitiObjectStreamContinueEntry<Schema> | null | "clear") => void): Promise<void>;
|
|
4
|
-
abstract clear(): void;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Polls for a single object and calls onValue with the result.
|
|
8
|
-
*/
|
|
9
|
-
export declare class GetPoller<Schema extends JSONSchema> implements Poller<Schema> {
|
|
10
|
-
readonly getter: () => Promise<GraffitiObject<Schema>>;
|
|
11
|
-
constructor(getter: () => Promise<GraffitiObject<Schema>>);
|
|
12
|
-
poll: Poller<Schema>["poll"];
|
|
13
|
-
clear(): void;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Polls for multiple objects and calls `onObject` with the result.
|
|
17
|
-
* If `poll` is called multiple times, it doesn't poll the results
|
|
18
|
-
* entirely from scratch, but instead only polls the new results.
|
|
19
|
-
*/
|
|
20
|
-
export declare class StreamPoller<Schema extends JSONSchema> implements Poller<Schema> {
|
|
21
|
-
readonly streamFactory: () => GraffitiObjectStream<Schema>;
|
|
22
|
-
iterator: GraffitiObjectStreamContinue<Schema> | undefined;
|
|
23
|
-
continue: (() => GraffitiObjectStreamContinue<Schema>) | undefined;
|
|
24
|
-
constructor(streamFactory: () => GraffitiObjectStream<Schema>);
|
|
25
|
-
clear(): void;
|
|
26
|
-
poll: Poller<Schema>["poll"];
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=pollers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Ref } from 'vue';
|
|
2
|
-
import { GraffitiObject, Graffiti, JSONSchema, GraffitiObjectStreamContinueEntry } from '@graffiti-garden/api';
|
|
3
|
-
export declare abstract class Reducer<Schema extends JSONSchema> {
|
|
4
|
-
abstract clear(): void;
|
|
5
|
-
abstract onEntry(entry: GraffitiObjectStreamContinueEntry<Schema> | null | "clear"): void;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Retrieves multiple Graffiti objects and retains
|
|
9
|
-
* the most recent one as the `result` property (a Vue ref).
|
|
10
|
-
* Before any objects have been received, the result
|
|
11
|
-
* is `undefined`. If the object has been deleted,
|
|
12
|
-
* the result is `null`.
|
|
13
|
-
*/
|
|
14
|
-
export declare class SingletonReducer<Schema extends JSONSchema> implements Reducer<Schema> {
|
|
15
|
-
readonly entry: Ref<GraffitiObjectStreamContinueEntry<Schema> | null | undefined>;
|
|
16
|
-
get result(): Ref<GraffitiObject<Schema> | null | undefined>;
|
|
17
|
-
clear(): void;
|
|
18
|
-
onEntry(entry: GraffitiObjectStreamContinueEntry<Schema> | null | "clear"): void;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Retrieves multiple Graffiti objects and retains
|
|
22
|
-
* the most recent one per URI as the `results` property (a Vue ref).
|
|
23
|
-
* If multiple objects are received concurrently,
|
|
24
|
-
* they are processed in batches every `REFRESH_RATE` milliseconds
|
|
25
|
-
* to avoid freezing the interface.
|
|
26
|
-
*/
|
|
27
|
-
export declare class ArrayReducer<Schema extends JSONSchema> implements Reducer<Schema> {
|
|
28
|
-
readonly graffiti: Graffiti;
|
|
29
|
-
readonly results: Ref<GraffitiObject<Schema>[]>;
|
|
30
|
-
readonly resultsRaw: Map<string, GraffitiObjectStreamContinueEntry<Schema>>;
|
|
31
|
-
batchFlattenTimer: ReturnType<typeof setTimeout> | undefined;
|
|
32
|
-
constructor(graffiti: Graffiti);
|
|
33
|
-
clear(): void;
|
|
34
|
-
flattenResults(): void;
|
|
35
|
-
onEntry(entry: GraffitiObjectStreamContinueEntry<Schema> | null | "clear"): void;
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=reducers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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/src/RecoverOrphans.vue
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts" generic="Schema extends JSONSchema">
|
|
2
|
-
import { toRef } from "vue";
|
|
3
|
-
import type {
|
|
4
|
-
GraffitiSession,
|
|
5
|
-
JSONSchema,
|
|
6
|
-
GraffitiObject,
|
|
7
|
-
} from "@graffiti-garden/api";
|
|
8
|
-
import { useGraffitiRecoverOrphans } from "./composables";
|
|
9
|
-
|
|
10
|
-
const props = defineProps<{
|
|
11
|
-
schema: Schema;
|
|
12
|
-
session: GraffitiSession;
|
|
13
|
-
autopoll?: boolean;
|
|
14
|
-
}>();
|
|
15
|
-
|
|
16
|
-
defineSlots<{
|
|
17
|
-
default?(props: {
|
|
18
|
-
objects: GraffitiObject<Schema>[];
|
|
19
|
-
poll: () => void;
|
|
20
|
-
isInitialPolling: boolean;
|
|
21
|
-
}): any;
|
|
22
|
-
}>();
|
|
23
|
-
|
|
24
|
-
const { objects, poll, isInitialPolling } = useGraffitiRecoverOrphans<Schema>(
|
|
25
|
-
toRef(props, "schema"),
|
|
26
|
-
toRef(props, "session"),
|
|
27
|
-
toRef(props, "autopoll"),
|
|
28
|
-
);
|
|
29
|
-
</script>
|
|
30
|
-
|
|
31
|
-
<template>
|
|
32
|
-
<slot
|
|
33
|
-
:objects="objects"
|
|
34
|
-
:poll="poll"
|
|
35
|
-
:isInitialPolling="isInitialPolling"
|
|
36
|
-
></slot>
|
|
37
|
-
</template>
|
package/src/composables.ts
DELETED
|
@@ -1,343 +0,0 @@
|
|
|
1
|
-
import { onScopeDispose, ref, toValue, watch } from "vue";
|
|
2
|
-
import type { Ref, MaybeRefOrGetter } from "vue";
|
|
3
|
-
import type {
|
|
4
|
-
GraffitiObjectUrl,
|
|
5
|
-
GraffitiObject,
|
|
6
|
-
GraffitiSession,
|
|
7
|
-
JSONSchema,
|
|
8
|
-
GraffitiObjectStreamContinueEntry,
|
|
9
|
-
} from "@graffiti-garden/api";
|
|
10
|
-
import { useGraffitiSynchronize, useGraffitiSession } from "./globals";
|
|
11
|
-
import { GetPoller, Poller, StreamPoller } from "./pollers";
|
|
12
|
-
import { ArrayReducer, Reducer, SingletonReducer } from "./reducers";
|
|
13
|
-
|
|
14
|
-
function makeComposable<Schema extends JSONSchema>(
|
|
15
|
-
reducer: Reducer<Schema>,
|
|
16
|
-
poller: Poller<Schema>,
|
|
17
|
-
synchronizeFactory: () => AsyncGenerator<
|
|
18
|
-
GraffitiObjectStreamContinueEntry<Schema>
|
|
19
|
-
>,
|
|
20
|
-
toWatch: readonly (() => any)[],
|
|
21
|
-
autopoll: MaybeRefOrGetter<boolean>,
|
|
22
|
-
) {
|
|
23
|
-
let synchronizeIterator:
|
|
24
|
-
| AsyncGenerator<GraffitiObjectStreamContinueEntry<Schema>>
|
|
25
|
-
| undefined;
|
|
26
|
-
async function pollSynchronize() {
|
|
27
|
-
synchronizeIterator = synchronizeFactory();
|
|
28
|
-
for await (const result of synchronizeIterator) {
|
|
29
|
-
if (result.error) {
|
|
30
|
-
console.error(result.error);
|
|
31
|
-
continue;
|
|
32
|
-
}
|
|
33
|
-
reducer.onEntry(result);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
let isAlreadyPolling = false;
|
|
38
|
-
let innerPoll: (() => Promise<void>) | undefined;
|
|
39
|
-
const poll = async () => {
|
|
40
|
-
if (isAlreadyPolling) return;
|
|
41
|
-
if (!innerPoll) return;
|
|
42
|
-
const myPoll = innerPoll;
|
|
43
|
-
isAlreadyPolling = true;
|
|
44
|
-
try {
|
|
45
|
-
await myPoll();
|
|
46
|
-
} finally {
|
|
47
|
-
if (myPoll !== innerPoll) return;
|
|
48
|
-
isAlreadyPolling = false;
|
|
49
|
-
if (toValue(autopoll)) {
|
|
50
|
-
poll();
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
const isInitialPolling = ref(false);
|
|
56
|
-
watch(
|
|
57
|
-
toWatch,
|
|
58
|
-
async (newValue, oldValue) => {
|
|
59
|
-
// Catch unnecessary updates
|
|
60
|
-
if (JSON.stringify(newValue) === JSON.stringify(oldValue)) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
synchronizeIterator?.return(null);
|
|
65
|
-
reducer.clear();
|
|
66
|
-
poller.clear();
|
|
67
|
-
|
|
68
|
-
pollSynchronize();
|
|
69
|
-
|
|
70
|
-
innerPoll = () => poller.poll(reducer.onEntry.bind(reducer));
|
|
71
|
-
const myPoll = innerPoll;
|
|
72
|
-
|
|
73
|
-
isAlreadyPolling = false;
|
|
74
|
-
|
|
75
|
-
isInitialPolling.value = true;
|
|
76
|
-
try {
|
|
77
|
-
await poll();
|
|
78
|
-
} finally {
|
|
79
|
-
if (myPoll !== innerPoll) return;
|
|
80
|
-
isInitialPolling.value = false;
|
|
81
|
-
}
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
immediate: true,
|
|
85
|
-
},
|
|
86
|
-
);
|
|
87
|
-
onScopeDispose(() => {
|
|
88
|
-
synchronizeIterator?.return(null);
|
|
89
|
-
reducer.clear();
|
|
90
|
-
poller.clear();
|
|
91
|
-
innerPoll = undefined;
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
return { poll, isInitialPolling };
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
function toSessionGetter(
|
|
98
|
-
sessionInjected: ReturnType<typeof useGraffitiSession>,
|
|
99
|
-
session?: MaybeRefOrGetter<GraffitiSession | undefined | null>,
|
|
100
|
-
) {
|
|
101
|
-
return () => {
|
|
102
|
-
const sessionValue = toValue(session);
|
|
103
|
-
if (sessionValue === undefined) {
|
|
104
|
-
return sessionInjected?.value;
|
|
105
|
-
} else {
|
|
106
|
-
return sessionValue;
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function callGetters<T extends readonly (() => any)[]>(
|
|
112
|
-
getters: T,
|
|
113
|
-
): {
|
|
114
|
-
[K in keyof T]: ReturnType<T[K]>;
|
|
115
|
-
} {
|
|
116
|
-
return getters.map((fn) => fn()) as any;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* The [Graffiti.discover](https://api.graffiti.garden/classes/Graffiti.html#discover)
|
|
121
|
-
* method as a reactive [composable](https://vuejs.org/guide/reusability/composables.html)
|
|
122
|
-
* for use in the Vue [composition API](https://vuejs.org/guide/introduction.html#composition-api).
|
|
123
|
-
*
|
|
124
|
-
* Its corresponding renderless component is {@link GraffitiDiscover}.
|
|
125
|
-
*
|
|
126
|
-
* The arguments of this composable as the same as Graffiti.discover,
|
|
127
|
-
* only they can also be [Refs](https://vuejs.org/api/reactivity-core.html#ref)
|
|
128
|
-
* or [getters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get#description).
|
|
129
|
-
* As they change the output will automatically update.
|
|
130
|
-
* Reactivity only triggers when the root array or object changes,
|
|
131
|
-
* not when the elements or properties change.
|
|
132
|
-
* If you need deep reactivity, wrap your argument in a getter.
|
|
133
|
-
*/
|
|
134
|
-
export function useGraffitiDiscover<Schema extends JSONSchema>(
|
|
135
|
-
channels: MaybeRefOrGetter<string[]>,
|
|
136
|
-
schema: MaybeRefOrGetter<Schema>,
|
|
137
|
-
/**
|
|
138
|
-
* If the session is `undefined`, the global session,
|
|
139
|
-
* {@link ComponentCustomProperties.$graffitiSession | $graffitiSession},
|
|
140
|
-
* will be used. Otherwise, the provided value will be used.
|
|
141
|
-
*/
|
|
142
|
-
session?: MaybeRefOrGetter<GraffitiSession | undefined | null>,
|
|
143
|
-
autopoll: MaybeRefOrGetter<boolean> = false,
|
|
144
|
-
): {
|
|
145
|
-
objects: Ref<GraffitiObject<Schema>[]>;
|
|
146
|
-
poll: () => Promise<void>;
|
|
147
|
-
isInitialPolling: Ref<boolean>;
|
|
148
|
-
} {
|
|
149
|
-
const graffiti = useGraffitiSynchronize();
|
|
150
|
-
const sessionInjected = useGraffitiSession();
|
|
151
|
-
|
|
152
|
-
const channelsGetter = () => toValue(channels);
|
|
153
|
-
const schemaGetter = () => toValue(schema);
|
|
154
|
-
const sessionGetter = toSessionGetter(sessionInjected, session);
|
|
155
|
-
const argGetters = [channelsGetter, schemaGetter, sessionGetter] as const;
|
|
156
|
-
|
|
157
|
-
const synchronizeFactory = () =>
|
|
158
|
-
graffiti.synchronizeDiscover(...callGetters(argGetters));
|
|
159
|
-
const streamFactory = () => graffiti.discover(...callGetters(argGetters));
|
|
160
|
-
|
|
161
|
-
const reducer = new ArrayReducer<Schema>(graffiti);
|
|
162
|
-
const poller = new StreamPoller<Schema>(streamFactory);
|
|
163
|
-
|
|
164
|
-
const { poll, isInitialPolling } = makeComposable<Schema>(
|
|
165
|
-
reducer,
|
|
166
|
-
poller,
|
|
167
|
-
synchronizeFactory,
|
|
168
|
-
argGetters,
|
|
169
|
-
autopoll,
|
|
170
|
-
);
|
|
171
|
-
|
|
172
|
-
return {
|
|
173
|
-
/**
|
|
174
|
-
* A [ref](https://vuejs.org/api/reactivity-core.html#ref) that contains
|
|
175
|
-
* an array of Graffiti objects.
|
|
176
|
-
*/
|
|
177
|
-
objects: reducer.results,
|
|
178
|
-
/**
|
|
179
|
-
* A method to poll for new results.
|
|
180
|
-
*/
|
|
181
|
-
poll,
|
|
182
|
-
/**
|
|
183
|
-
* A boolean [ref](https://vuejs.org/api/reactivity-core.html#ref)
|
|
184
|
-
* that indicates if the *first* poll is currently running.
|
|
185
|
-
* Useful to show a loading spinner or disable a button.
|
|
186
|
-
*
|
|
187
|
-
* This also tracks new polls when the arguments have changed,
|
|
188
|
-
* but it does not track ongoing polls from either calling
|
|
189
|
-
* {@link poll} or using the `autopoll` argument.
|
|
190
|
-
*/
|
|
191
|
-
isInitialPolling,
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* The [Graffiti.get](https://api.graffiti.garden/classes/Graffiti.html#get)
|
|
197
|
-
* method as a reactive [composable](https://vuejs.org/guide/reusability/composables.html)
|
|
198
|
-
* for use in the Vue [composition API](https://vuejs.org/guide/introduction.html#composition-api).
|
|
199
|
-
*
|
|
200
|
-
* Its corresponding renderless component is {@link GraffitiGet}.
|
|
201
|
-
*
|
|
202
|
-
* The arguments of this composable as the same as Graffiti.get,
|
|
203
|
-
* only they can also be [Refs](https://vuejs.org/api/reactivity-core.html#ref)
|
|
204
|
-
* or [getters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get#description).
|
|
205
|
-
* As they change the output will automatically update.
|
|
206
|
-
* Reactivity only triggers when the root array or object changes,
|
|
207
|
-
* not when the elements or properties change.
|
|
208
|
-
* If you need deep reactivity, wrap your argument in a getter.
|
|
209
|
-
*/
|
|
210
|
-
export function useGraffitiGet<Schema extends JSONSchema>(
|
|
211
|
-
locationOrUri: MaybeRefOrGetter<GraffitiObjectUrl | string>,
|
|
212
|
-
schema: MaybeRefOrGetter<Schema>,
|
|
213
|
-
/**
|
|
214
|
-
* If the session is `undefined`, the global session,
|
|
215
|
-
* {@link ComponentCustomProperties.$graffitiSession | $graffitiSession},
|
|
216
|
-
* will be used. Otherwise, the provided value will be used.
|
|
217
|
-
*/
|
|
218
|
-
session?: MaybeRefOrGetter<GraffitiSession | undefined | null>,
|
|
219
|
-
autopoll: MaybeRefOrGetter<boolean> = false,
|
|
220
|
-
): {
|
|
221
|
-
object: Ref<GraffitiObject<Schema> | null | undefined>;
|
|
222
|
-
poll: () => Promise<void>;
|
|
223
|
-
isInitialPolling: Ref<boolean>;
|
|
224
|
-
} {
|
|
225
|
-
const graffiti = useGraffitiSynchronize();
|
|
226
|
-
const sessionInjected = useGraffitiSession();
|
|
227
|
-
|
|
228
|
-
const locationOrUriGetter = () => toValue(locationOrUri);
|
|
229
|
-
const schemaGetter = () => toValue(schema);
|
|
230
|
-
const sessionGetter = toSessionGetter(sessionInjected, session);
|
|
231
|
-
const argGetters = [
|
|
232
|
-
locationOrUriGetter,
|
|
233
|
-
schemaGetter,
|
|
234
|
-
sessionGetter,
|
|
235
|
-
] as const;
|
|
236
|
-
|
|
237
|
-
const synchronizeFactory = () =>
|
|
238
|
-
graffiti.synchronizeGet(...callGetters(argGetters));
|
|
239
|
-
|
|
240
|
-
const reducer = new SingletonReducer<Schema>();
|
|
241
|
-
const getter = () => graffiti.get<Schema>(...callGetters(argGetters));
|
|
242
|
-
const poller = new GetPoller<Schema>(getter);
|
|
243
|
-
|
|
244
|
-
const { poll, isInitialPolling } = makeComposable<Schema>(
|
|
245
|
-
reducer,
|
|
246
|
-
poller,
|
|
247
|
-
synchronizeFactory,
|
|
248
|
-
argGetters,
|
|
249
|
-
autopoll,
|
|
250
|
-
);
|
|
251
|
-
|
|
252
|
-
return {
|
|
253
|
-
/**
|
|
254
|
-
* A [ref](https://vuejs.org/api/reactivity-core.html#ref) that contains
|
|
255
|
-
* the retrieved Graffiti object, if it exists. If the object has been deleted,
|
|
256
|
-
* the result is `null`. If the object is still being fetched, the result is `undefined`.
|
|
257
|
-
*/
|
|
258
|
-
object: reducer.result,
|
|
259
|
-
/**
|
|
260
|
-
* A method to poll for new results.
|
|
261
|
-
*/
|
|
262
|
-
poll,
|
|
263
|
-
/**
|
|
264
|
-
* A boolean [ref](https://vuejs.org/api/reactivity-core.html#ref)
|
|
265
|
-
* that indicates if the *first* poll is currently running.
|
|
266
|
-
* Useful to show a loading spinner or disable a button.
|
|
267
|
-
*
|
|
268
|
-
* This also tracks new polls when the arguments have changed,
|
|
269
|
-
* but it does not track ongoing polls from either calling
|
|
270
|
-
* {@link poll} or using the `autopoll` argument.
|
|
271
|
-
*/
|
|
272
|
-
isInitialPolling,
|
|
273
|
-
};
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
/**
|
|
277
|
-
* The [Graffiti.recoverOrphans](https://api.graffiti.garden/classes/Graffiti.html#recoverorphans)
|
|
278
|
-
* method as a reactive [composable](https://vuejs.org/guide/reusability/composables.html)
|
|
279
|
-
* for use in the Vue [composition API](https://vuejs.org/guide/introduction.html#composition-api).
|
|
280
|
-
*
|
|
281
|
-
* Its corresponding renderless component is {@link GraffitiRecoverOrphans}.
|
|
282
|
-
*
|
|
283
|
-
* The arguments of this composable as the same as Graffiti.get,
|
|
284
|
-
* only they can also be [Refs](https://vuejs.org/api/reactivity-core.html#ref)
|
|
285
|
-
* or [getters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/get#description).
|
|
286
|
-
* As they change the output will automatically update.
|
|
287
|
-
* Reactivity only triggers when the root array or object changes,
|
|
288
|
-
* not when the elements or properties change.
|
|
289
|
-
* If you need deep reactivity, wrap your argument in a getter.
|
|
290
|
-
*/
|
|
291
|
-
export function useGraffitiRecoverOrphans<Schema extends JSONSchema>(
|
|
292
|
-
schema: MaybeRefOrGetter<Schema>,
|
|
293
|
-
session: MaybeRefOrGetter<GraffitiSession>,
|
|
294
|
-
autopoll: MaybeRefOrGetter<boolean> = false,
|
|
295
|
-
): {
|
|
296
|
-
objects: Ref<GraffitiObject<Schema>[]>;
|
|
297
|
-
poll: () => Promise<void>;
|
|
298
|
-
isInitialPolling: Ref<boolean>;
|
|
299
|
-
} {
|
|
300
|
-
const graffiti = useGraffitiSynchronize();
|
|
301
|
-
|
|
302
|
-
const schemaGetter = () => toValue(schema);
|
|
303
|
-
const sessionGetter = () => toValue(session);
|
|
304
|
-
const argGetters = [schemaGetter, sessionGetter] as const;
|
|
305
|
-
|
|
306
|
-
const synchronizeFactory = () =>
|
|
307
|
-
graffiti.synchronizeRecoverOrphans(...callGetters(argGetters));
|
|
308
|
-
|
|
309
|
-
const reducer = new ArrayReducer<Schema>(graffiti);
|
|
310
|
-
const streamFactory = () =>
|
|
311
|
-
graffiti.recoverOrphans<Schema>(...callGetters(argGetters));
|
|
312
|
-
const poller = new StreamPoller<Schema>(streamFactory);
|
|
313
|
-
|
|
314
|
-
const { poll, isInitialPolling } = makeComposable<Schema>(
|
|
315
|
-
reducer,
|
|
316
|
-
poller,
|
|
317
|
-
synchronizeFactory,
|
|
318
|
-
argGetters,
|
|
319
|
-
autopoll,
|
|
320
|
-
);
|
|
321
|
-
|
|
322
|
-
return {
|
|
323
|
-
/**
|
|
324
|
-
* A [ref](https://vuejs.org/api/reactivity-core.html#ref) that contains
|
|
325
|
-
* an array of Graffiti objects.
|
|
326
|
-
*/
|
|
327
|
-
objects: reducer.results,
|
|
328
|
-
/**
|
|
329
|
-
* A method to poll for new results.
|
|
330
|
-
*/
|
|
331
|
-
poll,
|
|
332
|
-
/**
|
|
333
|
-
* A boolean [ref](https://vuejs.org/api/reactivity-core.html#ref)
|
|
334
|
-
* that indicates if the *first* poll is currently running.
|
|
335
|
-
* Useful to show a loading spinner or disable a button.
|
|
336
|
-
*
|
|
337
|
-
* This also tracks new polls when the arguments have changed,
|
|
338
|
-
* but it does not track ongoing polls from either calling
|
|
339
|
-
* {@link poll} or using the `autopoll` argument.
|
|
340
|
-
*/
|
|
341
|
-
isInitialPolling,
|
|
342
|
-
};
|
|
343
|
-
}
|
package/src/pollers.ts
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
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,
|
|
10
|
-
} from "@graffiti-garden/api";
|
|
11
|
-
|
|
12
|
-
export abstract class Poller<Schema extends JSONSchema> {
|
|
13
|
-
abstract poll(
|
|
14
|
-
onEntry: (
|
|
15
|
-
entry: GraffitiObjectStreamContinueEntry<Schema> | null | "clear",
|
|
16
|
-
) => void,
|
|
17
|
-
): Promise<void>;
|
|
18
|
-
abstract clear(): void;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Polls for a single object and calls onValue with the result.
|
|
23
|
-
*/
|
|
24
|
-
export class GetPoller<Schema extends JSONSchema> implements Poller<Schema> {
|
|
25
|
-
constructor(readonly getter: () => Promise<GraffitiObject<Schema>>) {}
|
|
26
|
-
|
|
27
|
-
poll: Poller<Schema>["poll"] = async (onEntry) => {
|
|
28
|
-
let object: GraffitiObject<Schema>;
|
|
29
|
-
const myGetter = this.getter;
|
|
30
|
-
try {
|
|
31
|
-
object = await myGetter();
|
|
32
|
-
} catch (e) {
|
|
33
|
-
if (this.getter === myGetter) {
|
|
34
|
-
onEntry(null);
|
|
35
|
-
}
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
if (this.getter === myGetter) {
|
|
39
|
-
onEntry({ object });
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
clear() {}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Polls for multiple objects and calls `onObject` with the result.
|
|
48
|
-
* If `poll` is called multiple times, it doesn't poll the results
|
|
49
|
-
* entirely from scratch, but instead only polls the new results.
|
|
50
|
-
*/
|
|
51
|
-
export class StreamPoller<Schema extends JSONSchema> implements Poller<Schema> {
|
|
52
|
-
iterator: GraffitiObjectStreamContinue<Schema> | undefined;
|
|
53
|
-
continue: (() => GraffitiObjectStreamContinue<Schema>) | undefined;
|
|
54
|
-
|
|
55
|
-
constructor(readonly streamFactory: () => GraffitiObjectStream<Schema>) {}
|
|
56
|
-
|
|
57
|
-
clear() {
|
|
58
|
-
if (this.iterator) {
|
|
59
|
-
const iterator = this.iterator;
|
|
60
|
-
this.iterator.return({
|
|
61
|
-
continue: () => iterator,
|
|
62
|
-
cursor: "",
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
this.iterator = undefined;
|
|
66
|
-
this.continue = undefined;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
poll: Poller<Schema>["poll"] = async (onEntry) => {
|
|
70
|
-
if (!this.iterator) {
|
|
71
|
-
if (this.continue) {
|
|
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
|
-
}
|
|
83
|
-
} else {
|
|
84
|
-
this.iterator = this.streamFactory();
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
while (true) {
|
|
89
|
-
// Check if the iterator has been cancelled.
|
|
90
|
-
if (!this.iterator) {
|
|
91
|
-
break;
|
|
92
|
-
}
|
|
93
|
-
|
|
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
|
-
}
|
|
102
|
-
|
|
103
|
-
if (result.done) {
|
|
104
|
-
if (result.value) {
|
|
105
|
-
this.iterator = undefined;
|
|
106
|
-
this.continue = result.value.continue;
|
|
107
|
-
}
|
|
108
|
-
break;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
if (result.value.error) {
|
|
112
|
-
console.error(result.value.error);
|
|
113
|
-
continue;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
onEntry(result.value);
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
}
|