@fedify/fedify 1.1.0-dev.433 → 1.1.0-dev.438

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/CHANGES.md CHANGED
@@ -56,6 +56,9 @@ To be released.
56
56
  - `Service.clone()` method now accepts `service` option.
57
57
  - `Service.clone()` method now accepts `services` option.
58
58
 
59
+ - In the `fedify inbox` command's web interface, the *Raw Activity* tab is
60
+ added to show the raw JSON object of the received activity.
61
+
59
62
  [FEP-c0e0]: https://w3id.org/fep/c0e0
60
63
  [FEP-9091]: https://w3id.org/fep/9091
61
64
  [#146]: https://github.com/dahlia/fedify/issues/146
@@ -0,0 +1,65 @@
1
+ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
2
+ // This module is browser compatible.
3
+ /** Options for {@linkcode delay}. */
4
+ import * as dntShim from "../../../../../_dnt.shims.js";
5
+ /**
6
+ * Resolve a {@linkcode Promise} after a given amount of milliseconds.
7
+ *
8
+ * @throws {DOMException} If the optional signal is aborted before the delay
9
+ * duration, and `signal.reason` is undefined.
10
+ * @param ms Duration in milliseconds for how long the delay should last.
11
+ * @param options Additional options.
12
+ *
13
+ * @example Basic usage
14
+ * ```ts no-assert
15
+ * import { delay } from "@std/async/delay";
16
+ *
17
+ * // ...
18
+ * const delayedPromise = delay(100);
19
+ * const result = await delayedPromise;
20
+ * // ...
21
+ * ```
22
+ *
23
+ * @example Disable persistence
24
+ *
25
+ * Setting `persistent` to `false` will allow the process to continue to run as
26
+ * long as the timer exists.
27
+ *
28
+ * ```ts no-assert ignore
29
+ * import { delay } from "@std/async/delay";
30
+ *
31
+ * // ...
32
+ * await delay(100, { persistent: false });
33
+ * // ...
34
+ * ```
35
+ */
36
+ export function delay(ms, options = {}) {
37
+ const { signal, persistent = true } = options;
38
+ if (signal?.aborted)
39
+ return Promise.reject(signal.reason);
40
+ return new Promise((resolve, reject) => {
41
+ const abort = () => {
42
+ clearTimeout(i);
43
+ reject(signal?.reason);
44
+ };
45
+ const done = () => {
46
+ signal?.removeEventListener("abort", abort);
47
+ resolve();
48
+ };
49
+ const i = setTimeout(done, ms);
50
+ signal?.addEventListener("abort", abort, { once: true });
51
+ if (persistent === false) {
52
+ try {
53
+ // @ts-ignore For browser compatibility
54
+ dntShim.Deno.unrefTimer(i);
55
+ }
56
+ catch (error) {
57
+ if (!(error instanceof ReferenceError)) {
58
+ throw error;
59
+ }
60
+ // deno-lint-ignore no-console
61
+ console.error("`persistent` option is only available in Deno");
62
+ }
63
+ }
64
+ });
65
+ }
@@ -1,4 +1,6 @@
1
+ import * as dntShim from "../_dnt.shims.js";
1
2
  import { getLogger } from "@logtape/logtape";
3
+ import { delay } from "../deps/jsr.io/@std/async/1.0.6/delay.js";
2
4
  import { fetchDocumentLoader, } from "../runtime/docloader.js";
3
5
  import { lookupWebFinger } from "../webfinger/lookup.js";
4
6
  import { Object } from "./vocab.js";
@@ -116,11 +118,15 @@ export async function* traverseCollection(collection, options = {}) {
116
118
  }
117
119
  }
118
120
  else {
121
+ const interval = dntShim.Temporal.Duration.from(options.interval ?? { seconds: 0 })
122
+ .total("millisecond");
119
123
  let page = await collection.getFirst(options);
120
124
  while (page != null) {
121
125
  for await (const item of page.getItems(options)) {
122
126
  yield item;
123
127
  }
128
+ if (interval > 0)
129
+ await delay(interval);
124
130
  page = await page.getNext(options);
125
131
  }
126
132
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/fedify",
3
- "version": "1.1.0-dev.433+43f17a56",
3
+ "version": "1.1.0-dev.438+040af46e",
4
4
  "description": "An ActivityPub server framework",
5
5
  "keywords": [
6
6
  "ActivityPub",
@@ -0,0 +1,43 @@
1
+ /// <reference types="node" />
2
+ export interface DelayOptions {
3
+ /** Signal used to abort the delay. */
4
+ signal?: AbortSignal;
5
+ /** Indicates whether the process should continue to run as long as the timer exists.
6
+ *
7
+ * @default {true}
8
+ */
9
+ persistent?: boolean;
10
+ }
11
+ /**
12
+ * Resolve a {@linkcode Promise} after a given amount of milliseconds.
13
+ *
14
+ * @throws {DOMException} If the optional signal is aborted before the delay
15
+ * duration, and `signal.reason` is undefined.
16
+ * @param ms Duration in milliseconds for how long the delay should last.
17
+ * @param options Additional options.
18
+ *
19
+ * @example Basic usage
20
+ * ```ts no-assert
21
+ * import { delay } from "@std/async/delay";
22
+ *
23
+ * // ...
24
+ * const delayedPromise = delay(100);
25
+ * const result = await delayedPromise;
26
+ * // ...
27
+ * ```
28
+ *
29
+ * @example Disable persistence
30
+ *
31
+ * Setting `persistent` to `false` will allow the process to continue to run as
32
+ * long as the timer exists.
33
+ *
34
+ * ```ts no-assert ignore
35
+ * import { delay } from "@std/async/delay";
36
+ *
37
+ * // ...
38
+ * await delay(100, { persistent: false });
39
+ * // ...
40
+ * ```
41
+ */
42
+ export declare function delay(ms: number, options?: DelayOptions): Promise<void>;
43
+ //# sourceMappingURL=delay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delay.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/async/1.0.6/delay.ts"],"names":[],"mappings":";AAMA,MAAM,WAAW,YAAY;IAC3B,sCAAsC;IACtC,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB;;;OAGG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CA2B3E"}
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" />
2
+ import * as dntShim from "../_dnt.shims.js";
2
3
  import { type DocumentLoader } from "../runtime/docloader.js";
3
4
  import { type Collection, type Link, Object } from "./vocab.js";
4
5
  /**
@@ -63,6 +64,13 @@ export interface TraverseCollectionOptions {
63
64
  * The context loader for loading remote JSON-LD contexts.
64
65
  */
65
66
  contextLoader?: DocumentLoader;
67
+ /**
68
+ * The interval to wait between fetching pages. Zero or negative
69
+ * values will disable the interval. Disabled by default.
70
+ *
71
+ * @default `{ seconds: 0 }`
72
+ */
73
+ interval?: dntShim.Temporal.Duration | dntShim.Temporal.DurationLike;
66
74
  }
67
75
  /**
68
76
  * Traverses a collection, yielding each item in the collection.
@@ -1 +1 @@
1
- {"version":3,"file":"lookup.d.ts","sourceRoot":"","sources":["../../src/vocab/lookup.ts"],"names":[],"mappings":";AACA,OAAO,EACL,KAAK,cAAc,EAEpB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,IAAI,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAIhE;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC;IAEhC;;;OAGG;IACH,aAAa,CAAC,EAAE,cAAc,CAAC;CAChC;AAKD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAsB,YAAY,CAChC,UAAU,EAAE,MAAM,GAAG,GAAG,EACxB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAiDxB;AAED;;;GAGG;AACH,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC;IAEhC;;OAEG;IACH,aAAa,CAAC,EAAE,cAAc,CAAC;CAChC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAuB,kBAAkB,CACvC,UAAU,EAAE,UAAU,EACtB,OAAO,GAAE,yBAA8B,GACtC,aAAa,CAAC,MAAM,GAAG,IAAI,CAAC,CAc9B"}
1
+ {"version":3,"file":"lookup.d.ts","sourceRoot":"","sources":["../../src/vocab/lookup.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAG5C,OAAO,EACL,KAAK,cAAc,EAEpB,MAAM,yBAAyB,CAAC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