@fedify/vocab 2.2.0 → 2.2.2

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.
@@ -1,6 +1,6 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  globalThis.addEventListener = () => {};
3
- import { C as QuoteRequest, E as Tombstone, S as QuoteAuthorization, T as Source, _ as OrderedCollectionPage, a as Create, b as Place, c as Endpoints, d as Hashtag, f as InteractionPolicy, g as Object$1, h as Note, i as Collection, k as vocab_exports, l as Follow, m as Link, n as Announce, o as CryptographicKey, p as InteractionRule, s as Delete, t as Activity, x as Question, y as Person } from "./vocab-DKp-OcRQ.mjs";
3
+ import { C as QuoteRequest, E as Tombstone, S as QuoteAuthorization, T as Source, _ as OrderedCollectionPage, a as Create, b as Place, c as Endpoints, d as Hashtag, f as InteractionPolicy, g as Object$1, h as Note, i as Collection, k as vocab_exports, l as Follow, m as Link, n as Announce, o as CryptographicKey, p as InteractionRule, s as Delete, t as Activity, x as Question, y as Person } from "./vocab-Cp7kqLh1.mjs";
4
4
  import { t as assertInstanceOf } from "./utils-CE8Dk5hm.mjs";
5
5
  import { mockDocumentLoader, test } from "@fedify/fixture";
6
6
  import { deepStrictEqual, notDeepStrictEqual, ok, rejects, throws } from "node:assert/strict";
@@ -102,6 +102,22 @@ test("new Object()", () => {
102
102
  throws(() => new Object$1({ names: "foo" }), TypeError);
103
103
  throws(() => new Object$1({ names: ["foo", 123] }), TypeError);
104
104
  });
105
+ test("new Object() accepts foreign Temporal.Instant (issue #767)", () => {
106
+ const foreignInstant = globalThis.Object.create(globalThis.Object.prototype, {
107
+ [Symbol.toStringTag]: { value: "Temporal.Instant" },
108
+ epochNanoseconds: { value: 0n },
109
+ toString: { value: () => "1970-01-01T00:00:00Z" }
110
+ });
111
+ ok(new Object$1({ published: foreignInstant }).published === foreignInstant);
112
+ });
113
+ test("Object.clone() accepts foreign Temporal.Instant (issue #767)", () => {
114
+ const foreignInstant = globalThis.Object.create(globalThis.Object.prototype, {
115
+ [Symbol.toStringTag]: { value: "Temporal.Instant" },
116
+ epochNanoseconds: { value: 0n },
117
+ toString: { value: () => "1970-01-01T00:00:00Z" }
118
+ });
119
+ ok(new Object$1({}).clone({ published: foreignInstant }).published === foreignInstant);
120
+ });
105
121
  test("Object.clone()", () => {
106
122
  const obj = new Object$1({
107
123
  id: new URL("https://example.com/"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/vocab",
3
- "version": "2.2.0",
3
+ "version": "2.2.2",
4
4
  "homepage": "https://fedify.dev/",
5
5
  "repository": {
6
6
  "type": "git",
@@ -46,16 +46,16 @@
46
46
  "es-toolkit": "1.43.0",
47
47
  "jsonld": "^9.0.0",
48
48
  "pkijs": "^3.3.3",
49
- "@fedify/vocab-tools": "2.2.0",
50
- "@fedify/webfinger": "2.2.0",
51
- "@fedify/vocab-runtime": "2.2.0"
49
+ "@fedify/vocab-tools": "2.2.2",
50
+ "@fedify/vocab-runtime": "2.2.2",
51
+ "@fedify/webfinger": "2.2.2"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@types/node": "^22.17.0",
55
55
  "fast-check": "^3.22.0",
56
56
  "fetch-mock": "^12.5.4",
57
57
  "tsdown": "^0.21.6",
58
- "typescript": "^5.9.2",
58
+ "typescript": "^6.0.0",
59
59
  "@fedify/fixture": "2.0.0"
60
60
  },
61
61
  "keywords": [
package/src/vocab.test.ts CHANGED
@@ -160,6 +160,43 @@ test("new Object()", () => {
160
160
  );
161
161
  });
162
162
 
163
+ test(
164
+ // Regression test for
165
+ // https://github.com/fedify-dev/fedify/issues/767:
166
+ // values produced by a `Temporal` implementation other than the one bundled
167
+ // with Fedify (e.g. Node.js 26+ native `Temporal`) must be accepted as
168
+ // long as they conform to the spec-mandated `Symbol.toStringTag`.
169
+ "new Object() accepts foreign Temporal.Instant (issue #767)",
170
+ () => {
171
+ const foreignInstant = globalThis.Object.create(
172
+ globalThis.Object.prototype,
173
+ {
174
+ [Symbol.toStringTag]: { value: "Temporal.Instant" },
175
+ epochNanoseconds: { value: 0n },
176
+ toString: { value: () => "1970-01-01T00:00:00Z" },
177
+ },
178
+ ) as Temporal.Instant;
179
+ const obj = new Object({ published: foreignInstant });
180
+ ok(obj.published === foreignInstant);
181
+ },
182
+ );
183
+
184
+ test(
185
+ "Object.clone() accepts foreign Temporal.Instant (issue #767)",
186
+ () => {
187
+ const foreignInstant = globalThis.Object.create(
188
+ globalThis.Object.prototype,
189
+ {
190
+ [Symbol.toStringTag]: { value: "Temporal.Instant" },
191
+ epochNanoseconds: { value: 0n },
192
+ toString: { value: () => "1970-01-01T00:00:00Z" },
193
+ },
194
+ ) as Temporal.Instant;
195
+ const obj = new Object({}).clone({ published: foreignInstant });
196
+ ok(obj.published === foreignInstant);
197
+ },
198
+ );
199
+
163
200
  test("Object.clone()", () => {
164
201
  const obj = new Object({
165
202
  id: new URL("https://example.com/"),
package/tsdown.config.ts CHANGED
@@ -19,17 +19,14 @@ export default [
19
19
  format: ["esm", "cjs"],
20
20
  platform: "neutral",
21
21
  external: [/^node:/],
22
- outputOptions(outputOptions, format) {
23
- if (format === "cjs") {
24
- outputOptions.intro = `
25
- const { Temporal } = require("@js-temporal/polyfill");
26
- `;
27
- } else {
28
- outputOptions.intro = `
29
- import { Temporal } from "@js-temporal/polyfill";
30
- `;
31
- }
32
- return outputOptions;
22
+ banner({ format }) {
23
+ const js = format === "cjs"
24
+ ? `const { Temporal } = require("@js-temporal/polyfill");`
25
+ : `import { Temporal } from "@js-temporal/polyfill";`;
26
+ return {
27
+ js,
28
+ dts: `/// <reference lib="esnext.temporal" />`,
29
+ };
33
30
  },
34
31
  }),
35
32
  defineConfig({