@fedify/fedify 1.6.1-dev.856 → 1.6.1-dev.869

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/deno.js CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  //#region deno.json
6
6
  var name = "@fedify/fedify";
7
- var version = "1.6.1-dev.856+77c62d3e";
7
+ var version = "1.6.1-dev.869+94f077ee";
8
8
  var license = "MIT";
9
9
  var exports = {
10
10
  ".": "./mod.ts",
@@ -36,22 +36,22 @@ var FederationBuilderImpl = class {
36
36
  const { FederationImpl } = await import("./middleware.js");
37
37
  const f = new FederationImpl(options);
38
38
  const trailingSlashInsensitiveValue = f.router.trailingSlashInsensitive;
39
- f.router = this.router;
39
+ f.router = this.router.clone();
40
40
  f.router.trailingSlashInsensitive = trailingSlashInsensitiveValue;
41
41
  f._initializeRouter();
42
- f.actorCallbacks = this.actorCallbacks;
42
+ f.actorCallbacks = this.actorCallbacks == null ? void 0 : { ...this.actorCallbacks };
43
43
  f.nodeInfoDispatcher = this.nodeInfoDispatcher;
44
- f.objectCallbacks = this.objectCallbacks;
45
- f.objectTypeIds = this.objectTypeIds;
44
+ f.objectCallbacks = { ...this.objectCallbacks };
45
+ f.objectTypeIds = { ...this.objectTypeIds };
46
46
  f.inboxPath = this.inboxPath;
47
- f.inboxCallbacks = this.inboxCallbacks;
48
- f.outboxCallbacks = this.outboxCallbacks;
49
- f.followingCallbacks = this.followingCallbacks;
50
- f.followersCallbacks = this.followersCallbacks;
51
- f.likedCallbacks = this.likedCallbacks;
52
- f.featuredCallbacks = this.featuredCallbacks;
53
- f.featuredTagsCallbacks = this.featuredTagsCallbacks;
54
- f.inboxListeners = this.inboxListeners;
47
+ f.inboxCallbacks = this.inboxCallbacks == null ? void 0 : { ...this.inboxCallbacks };
48
+ f.outboxCallbacks = this.outboxCallbacks == null ? void 0 : { ...this.outboxCallbacks };
49
+ f.followingCallbacks = this.followingCallbacks == null ? void 0 : { ...this.followingCallbacks };
50
+ f.followersCallbacks = this.followersCallbacks == null ? void 0 : { ...this.followersCallbacks };
51
+ f.likedCallbacks = this.likedCallbacks == null ? void 0 : { ...this.likedCallbacks };
52
+ f.featuredCallbacks = this.featuredCallbacks == null ? void 0 : { ...this.featuredCallbacks };
53
+ f.featuredTagsCallbacks = this.featuredTagsCallbacks == null ? void 0 : { ...this.featuredTagsCallbacks };
54
+ f.inboxListeners = this.inboxListeners?.clone();
55
55
  f.inboxErrorHandler = this.inboxErrorHandler;
56
56
  f.sharedInboxKeyDispatcher = this.sharedInboxKeyDispatcher;
57
57
  return f;
@@ -65,6 +65,7 @@ test("FederationBuilder", async (t) => {
65
65
  assertEquals(notePaths, "/notes/123");
66
66
  assertEquals(impl.router.build("actor", { identifier: "user1" }), "/users/user1");
67
67
  assertEquals(impl.router.build("inbox", { identifier: "user1" }), "/users/user1/inbox");
68
+ await builder.build({ kv });
68
69
  });
69
70
  await t.step("should build with default options", async () => {
70
71
  const builder = createFederationBuilder();
@@ -9,11 +9,16 @@ import { getLogger } from "@logtape/logtape";
9
9
  import { SpanKind, SpanStatusCode, context, propagation, trace } from "@opentelemetry/api";
10
10
 
11
11
  //#region federation/inbox.ts
12
- var InboxListenerSet = class {
12
+ var InboxListenerSet = class InboxListenerSet {
13
13
  #listeners;
14
14
  constructor() {
15
15
  this.#listeners = new Map();
16
16
  }
17
+ clone() {
18
+ const clone = new InboxListenerSet();
19
+ clone.#listeners = new Map(this.#listeners);
20
+ return clone;
21
+ }
17
22
  add(type, listener) {
18
23
  if (this.#listeners.has(type)) throw new TypeError("Listener already set for this type.");
19
24
  this.#listeners.set(type, listener);
@@ -50,6 +50,7 @@ declare class Router {
50
50
  * @param options Options for the router.
51
51
  */
52
52
  constructor(options?: RouterOptions);
53
+ clone(): Router;
53
54
  /**
54
55
  * Checks if a path name exists in the router.
55
56
  * @param name The name of the path.
@@ -2,15 +2,26 @@
2
2
  import { Temporal } from "@js-temporal/polyfill";
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
 
5
+ import { cloneDeep } from "@es-toolkit/es-toolkit";
5
6
  import { Router } from "uri-template-router";
6
7
  import { parseTemplate } from "url-template";
7
8
 
8
9
  //#region federation/router.ts
10
+ function cloneInnerRouter(router) {
11
+ const clone = new Router();
12
+ clone.nid = router.nid;
13
+ clone.fsm = cloneDeep(router.fsm);
14
+ clone.routeSet = new Set(router.routeSet);
15
+ clone.templateRouteMap = new Map(router.templateRouteMap);
16
+ clone.valueRouteMap = new Map(router.valueRouteMap);
17
+ clone.hierarchy = cloneDeep(router.hierarchy);
18
+ return clone;
19
+ }
9
20
  /**
10
21
  * URL router and constructor based on URI Template
11
22
  * ([RFC 6570](https://tools.ietf.org/html/rfc6570)).
12
23
  */
13
- var Router$1 = class {
24
+ var Router$1 = class Router$1 {
14
25
  #router;
15
26
  #templates;
16
27
  #templateStrings;
@@ -29,6 +40,13 @@ var Router$1 = class {
29
40
  this.#templateStrings = {};
30
41
  this.trailingSlashInsensitive = options.trailingSlashInsensitive ?? false;
31
42
  }
43
+ clone() {
44
+ const clone = new Router$1({ trailingSlashInsensitive: this.trailingSlashInsensitive });
45
+ clone.#router = cloneInnerRouter(this.#router);
46
+ clone.#templates = { ...this.#templates };
47
+ clone.#templateStrings = { ...this.#templateStrings };
48
+ return clone;
49
+ }
32
50
  /**
33
51
  * Checks if a path name exists in the router.
34
52
  * @param name The name of the path.
@@ -3,8 +3,10 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
 
5
5
  import { Router, RouterError } from "./router.js";
6
+ import { assert } from "../node_modules/.pnpm/@jsr_std__assert@0.226.0/node_modules/@jsr/std__assert/assert.js";
6
7
  import { assertEquals } from "../node_modules/.pnpm/@jsr_std__assert@0.226.0/node_modules/@jsr/std__assert/assert_equals.js";
7
8
  import { test } from "../testing/mod.js";
9
+ import { assertFalse } from "../node_modules/.pnpm/@jsr_std__assert@0.226.0/node_modules/@jsr/std__assert/assert_false.js";
8
10
  import { assertThrows } from "../node_modules/.pnpm/@jsr_std__assert@0.226.0/node_modules/@jsr/std__assert/assert_throws.js";
9
11
 
10
12
  //#region federation/router.test.ts
@@ -14,6 +16,19 @@ function setUp(options = {}) {
14
16
  router.add("/users/{name}/posts/{postId}" + (options.trailingSlashInsensitive ? "/" : ""), "post");
15
17
  return router;
16
18
  }
19
+ test("Router.clone()", () => {
20
+ const original = setUp();
21
+ const clone = original.clone();
22
+ clone.add("/users/{name}/friends", "friends");
23
+ assert(clone.has("friends"));
24
+ assertEquals(clone.route("/users/alice/friends"), {
25
+ name: "friends",
26
+ template: "/users/{name}/friends",
27
+ values: { name: "alice" }
28
+ });
29
+ assertFalse(original.has("friends"));
30
+ assertEquals(original.route("/users/alice/friends"), null);
31
+ });
17
32
  test("Router.add()", () => {
18
33
  const router = new Router();
19
34
  assertEquals(router.add("/users", "users"), new Set());
@@ -11,4 +11,4 @@ function assertArg(path) {
11
11
  }
12
12
 
13
13
  //#endregion
14
- export { assertArg as assertArg$2 };
14
+ export { assertArg };
@@ -10,4 +10,4 @@ function assertArg(url) {
10
10
  }
11
11
 
12
12
  //#endregion
13
- export { assertArg };
13
+ export { assertArg as assertArg$2 };
@@ -4,7 +4,7 @@
4
4
 
5
5
  import { stripTrailingSeparators } from "../_common/strip_trailing_separators.js";
6
6
  import { isPosixPathSeparator } from "./_util.js";
7
- import { assertArg$2 as assertArg } from "../_common/dirname.js";
7
+ import { assertArg } from "../_common/dirname.js";
8
8
 
9
9
  //#region node_modules/.pnpm/@jsr+std__path@1.0.9/node_modules/@jsr/std__path/posix/dirname.js
10
10
  /**
@@ -2,7 +2,7 @@
2
2
  import { Temporal } from "@js-temporal/polyfill";
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
 
5
- import { assertArg } from "../_common/from_file_url.js";
5
+ import { assertArg$2 as assertArg } from "../_common/from_file_url.js";
6
6
 
7
7
  //#region node_modules/.pnpm/@jsr+std__path@1.0.9/node_modules/@jsr/std__path/posix/from_file_url.js
8
8
  /**
@@ -2,7 +2,7 @@
2
2
  import { Temporal } from "@js-temporal/polyfill";
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
 
5
- import { assertArg } from "../_common/from_file_url.js";
5
+ import { assertArg$2 as assertArg } from "../_common/from_file_url.js";
6
6
 
7
7
  //#region node_modules/.pnpm/@jsr+std__path@1.0.9/node_modules/@jsr/std__path/windows/from_file_url.js
8
8
  /**