@fedify/vocab 2.0.16 → 2.0.17-dev.1093

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 { _ as Question, a as Create, b as vocab_exports, d as Note, f as Object$1, g as Place, h as Person, i as Collection, l as Hashtag, n as Announce, o as CryptographicKey, p as OrderedCollectionPage, s as Follow, t as Activity, u as Link, y as Source } from "./vocab-CbGDwxow.mjs";
3
+ import { _ as Question, a as Create, b as vocab_exports, d as Note, f as Object$1, g as Place, h as Person, i as Collection, l as Hashtag, n as Announce, o as CryptographicKey, p as OrderedCollectionPage, s as Follow, t as Activity, u as Link, y as Source } from "./vocab-BFNiYemZ.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";
@@ -25,6 +25,22 @@ test("new Object()", () => {
25
25
  throws(() => new Object$1({ names: "foo" }), TypeError);
26
26
  throws(() => new Object$1({ names: ["foo", 123] }), TypeError);
27
27
  });
28
+ test("new Object() accepts foreign Temporal.Instant (issue #767)", () => {
29
+ const foreignInstant = globalThis.Object.create(globalThis.Object.prototype, {
30
+ [Symbol.toStringTag]: { value: "Temporal.Instant" },
31
+ epochNanoseconds: { value: 0n },
32
+ toString: { value: () => "1970-01-01T00:00:00Z" }
33
+ });
34
+ ok(new Object$1({ published: foreignInstant }).published === foreignInstant);
35
+ });
36
+ test("Object.clone() accepts foreign Temporal.Instant (issue #767)", () => {
37
+ const foreignInstant = globalThis.Object.create(globalThis.Object.prototype, {
38
+ [Symbol.toStringTag]: { value: "Temporal.Instant" },
39
+ epochNanoseconds: { value: 0n },
40
+ toString: { value: () => "1970-01-01T00:00:00Z" }
41
+ });
42
+ ok(new Object$1({}).clone({ published: foreignInstant }).published === foreignInstant);
43
+ });
28
44
  test("Object.clone()", () => {
29
45
  const obj = new Object$1({
30
46
  id: new URL("https://example.com/"),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/vocab",
3
- "version": "2.0.16",
3
+ "version": "2.0.17-dev.1093+5ccc4865",
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.0.16",
50
- "@fedify/webfinger": "2.0.16",
51
- "@fedify/vocab-runtime": "2.0.16"
49
+ "@fedify/vocab-runtime": "2.0.17-dev.1093+5ccc4865",
50
+ "@fedify/webfinger": "2.0.17-dev.1093+5ccc4865",
51
+ "@fedify/vocab-tools": "2.0.17-dev.1093+5ccc4865"
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
@@ -69,6 +69,43 @@ test("new Object()", () => {
69
69
  );
70
70
  });
71
71
 
72
+ test(
73
+ // Regression test for
74
+ // https://github.com/fedify-dev/fedify/issues/767:
75
+ // values produced by a `Temporal` implementation other than the one bundled
76
+ // with Fedify (e.g. Node.js 26+ native `Temporal`) must be accepted as
77
+ // long as they conform to the spec-mandated `Symbol.toStringTag`.
78
+ "new Object() accepts foreign Temporal.Instant (issue #767)",
79
+ () => {
80
+ const foreignInstant = globalThis.Object.create(
81
+ globalThis.Object.prototype,
82
+ {
83
+ [Symbol.toStringTag]: { value: "Temporal.Instant" },
84
+ epochNanoseconds: { value: 0n },
85
+ toString: { value: () => "1970-01-01T00:00:00Z" },
86
+ },
87
+ ) as Temporal.Instant;
88
+ const obj = new Object({ published: foreignInstant });
89
+ ok(obj.published === foreignInstant);
90
+ },
91
+ );
92
+
93
+ test(
94
+ "Object.clone() accepts foreign Temporal.Instant (issue #767)",
95
+ () => {
96
+ const foreignInstant = globalThis.Object.create(
97
+ globalThis.Object.prototype,
98
+ {
99
+ [Symbol.toStringTag]: { value: "Temporal.Instant" },
100
+ epochNanoseconds: { value: 0n },
101
+ toString: { value: () => "1970-01-01T00:00:00Z" },
102
+ },
103
+ ) as Temporal.Instant;
104
+ const obj = new Object({}).clone({ published: foreignInstant });
105
+ ok(obj.published === foreignInstant);
106
+ },
107
+ );
108
+
72
109
  test("Object.clone()", () => {
73
110
  const obj = new Object({
74
111
  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({