Skip to content

Commit 5ccc486

Browse files
authored
Merge pull request #768 from dahlia/bugfix/temporal
2 parents 6cfb9a3 + b14a2af commit 5ccc486

31 files changed

Lines changed: 691 additions & 397 deletions

CHANGES.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,58 @@ To be released.
1515
fetches are retried once, and remaining transport failures are reported as
1616
`FetchError` with the original error as the cause. [[#762], [#763]]
1717

18+
- Fixed a `TypeError` thrown when Activity Vocabulary constructors received
19+
a `Temporal.Instant` or `Temporal.Duration` produced by an implementation
20+
other than the bundled `@js-temporal/polyfill` (for example, the native
21+
`Temporal` shipped with Node.js 26+). Internal `instanceof` checks have
22+
been replaced with `Symbol.toStringTag`-based guards so any spec-conformant
23+
Temporal value is accepted. Generated _\*.d.ts_ declarations no longer
24+
import from `@js-temporal/polyfill`; they reference the ambient `Temporal`
25+
namespace through the `esnext.temporal` lib instead, which removes the
26+
nominal mismatch with native Temporal types. TypeScript 6.0 or later is
27+
required to consume the type declarations. [[#767], [#768]]
28+
1829
[#762]: https://github.com/fedify-dev/fedify/issues/762
1930
[#763]: https://github.com/fedify-dev/fedify/pull/763
31+
[#767]: https://github.com/fedify-dev/fedify/issues/767
32+
[#768]: https://github.com/fedify-dev/fedify/pull/768
33+
34+
### @fedify/vocab-runtime
35+
36+
- Added `isTemporalInstant()` and `isTemporalDuration()` type guards that
37+
accept both polyfill and native `Temporal` values via `Symbol.toStringTag`.
38+
[[#767], [#768]]
39+
40+
- Added the `@fedify/vocab-runtime/temporal` subpath export so consumers
41+
can import the new `Temporal` type guards without pulling in the rest of
42+
the runtime. [[#767], [#768]]
43+
44+
### @fedify/postgres
45+
46+
- Generated _\*.d.ts_ declarations no longer import from
47+
`@js-temporal/polyfill`; they reference the ambient `Temporal` namespace
48+
through the `esnext.temporal` lib instead, so `pollInterval` and
49+
`handlerTimeout` accept native `Temporal.Duration` values from Node.js
50+
26+ without a nominal type mismatch. TypeScript 6.0 or later is
51+
required to consume the type declarations. [[#767], [#768]]
52+
53+
### @fedify/redis
54+
55+
- Generated _\*.d.ts_ declarations no longer import from
56+
`@js-temporal/polyfill`; they reference the ambient `Temporal` namespace
57+
through the `esnext.temporal` lib instead, so `pollInterval` accepts
58+
native `Temporal.Duration` values from Node.js 26+ without a nominal type
59+
mismatch. TypeScript 6.0 or later is required to consume the type
60+
declarations. [[#767], [#768]]
61+
62+
### @fedify/sqlite
63+
64+
- Generated _\*.d.ts_ declarations no longer import from
65+
`@js-temporal/polyfill`; they reference the ambient `Temporal` namespace
66+
through the `esnext.temporal` lib instead, so `pollInterval` accepts
67+
native `Temporal.Duration` values from Node.js 26+ without a nominal type
68+
mismatch. TypeScript 6.0 or later is required to consume the type
69+
declarations. [[#767], [#768]]
2070

2171

2272
Version 2.0.16

deno.lock

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/.vitepress/config.mts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,10 @@ export default withMermaid(defineConfig({
249249
target: ScriptTarget.ESNext,
250250
experimentalDecorators: true, // For @fedify/nestjs
251251
emitDecoratorMetadata: true, // For @fedify/nestjs
252+
// Silences TS5101 about the `baseUrl` injected by @typescript/vfs
253+
// when Twoslash spins up its virtual TS environment; the option
254+
// is deprecated in TypeScript 6.0 and removed in 7.0.
255+
ignoreDeprecations: "6.0",
252256
lib: ["dom", "dom.iterable", "esnext"],
253257
types: [
254258
"dom",

docs/manual/federation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ Deno.serve(
540540
~~~~
541541

542542
~~~~ typescript twoslash [Bun]
543-
import "@types/bun";
543+
import "bun";
544544
import { type Federation } from "@fedify/fedify";
545545
const federation = null as unknown as Federation<void>;
546546
const request = new Request("");
@@ -665,7 +665,7 @@ serve({
665665
~~~~
666666

667667
~~~~ typescript{1,4} twoslash [Bun]
668-
import "@types/bun";
668+
import "bun";
669669
import { type Federation } from "@fedify/fedify";
670670
const federation = null as unknown as Federation<void>;
671671
// ---cut-before---

docs/manual/pragmatics.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ The date joined is displayed in the profile page of the actor.
158158
159159
~~~~ typescript twoslash
160160
import { Person } from "@fedify/vocab";
161-
import { Temporal } from "@js-temporal/polyfill";
162161
// ---cut-before---
163162
new Person({
164163
name: "Fedify Demo",

docs/manual/relay.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Deno.serve((request) => relay.fetch(request));
6767
~~~~
6868

6969
~~~~ typescript twoslash [Bun]
70-
import "@types/bun";
70+
import "bun";
7171
// ---cut-before---
7272
import { createRelay } from "@fedify/relay";
7373
import { MemoryKvStore } from "@fedify/fedify";

docs/manual/vocab.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,6 @@ that contains the properties of the object. The following shows an example of
9292
instantiating a `Create` object:
9393

9494
~~~~ typescript twoslash
95-
import { Temporal } from "@js-temporal/polyfill";
96-
// ---cut-before---
9795
import { Create, Note } from "@fedify/vocab";
9896

9997
const create = new Create({
@@ -199,7 +197,6 @@ For example, the following two objects are equivalent (where dereferencing URI
199197

200198
~~~~ typescript twoslash
201199
import { Create, Note } from "@fedify/vocab";
202-
import { Temporal } from "@js-temporal/polyfill";
203200
// ---cut-before---
204201
const a = new Create({
205202
id: new URL("https://example.com/activities/123"),
@@ -353,8 +350,6 @@ properties. The following shows an example of changing the `~Object.content`
353350
property of a `Note` object:
354351

355352
~~~~ typescript{8-10} twoslash
356-
import { Temporal } from "@js-temporal/polyfill";
357-
// ---cut-before---
358353
import { Note } from "@fedify/vocab";
359354
import { LanguageString } from "@fedify/vocab-runtime";
360355

docs/tutorial/basics.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ Deno.serve(request =>
168168
~~~~
169169

170170
~~~~ typescript twoslash [Bun]
171-
import "@types/bun";
171+
import "bun";
172172
// ---cut-before---
173173
Bun.serve({
174174
port: 8000,
@@ -277,7 +277,7 @@ Deno.serve(
277277
~~~~
278278

279279
~~~~ typescript{4} twoslash [Bun]
280-
import "@types/bun";
280+
import "bun";
281281
import type { Federation } from "@fedify/fedify";
282282
const federation = null as unknown as Federation<void>;
283283
// ---cut-before---
@@ -407,7 +407,7 @@ Deno.serve(
407407
~~~~
408408
409409
~~~~ typescript{7-16} twoslash [Bun]
410-
import "@types/bun";
410+
import "bun";
411411
// ---cut-before---
412412
import { createFederation, MemoryKvStore } from "@fedify/fedify";
413413
import { Person } from "@fedify/vocab";
@@ -654,7 +654,7 @@ Deno.serve(
654654
~~~~
655655
656656
~~~~ typescript{1,5} twoslash [Bun]
657-
import "@types/bun";
657+
import "bun";
658658
import type { Federation } from "@fedify/fedify";
659659
const federation = null as unknown as Federation<void>;
660660
// ---cut-before---
@@ -1202,7 +1202,7 @@ Deno.serve(async (request) => {
12021202
~~~~
12031203
12041204
~~~~ typescript{4-18} twoslash [Bun]
1205-
import "@types/bun";
1205+
import "bun";
12061206
import type { Federation } from "@fedify/fedify";
12071207
import { openKv } from "@deno/kv";
12081208
const federation = null as unknown as Federation<void>;

docs/tutorial/microblog.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3144,7 +3144,7 @@ npm add @js-temporal/polyfill
31443144
31453145
Open the *src/federation.ts* file and `import` the installed package:
31463146
3147-
~~~~ typescript twoslash [src/federation.ts]
3147+
~~~~ typescript [src/federation.ts]
31483148
import { Temporal } from "@js-temporal/polyfill";
31493149
~~~~
31503150
@@ -3199,7 +3199,6 @@ federation.setObjectDispatcher(
31993199
Let's modify this as follows:
32003200
32013201
~~~~ typescript twoslash [src/federation.ts]
3202-
import { Temporal } from "@js-temporal/polyfill";
32033202
import { type Federation } from "@fedify/fedify";
32043203
import { Note, PUBLIC_COLLECTION } from "@fedify/vocab";
32053204
const federation = null as unknown as Federation<void>;

packages/debugger/tsdown.config.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,13 @@ export default defineConfig({
2323
/^hono\//,
2424
],
2525
},
26-
outputOptions(outputOptions, format) {
27-
if (format === "cjs") {
28-
outputOptions.intro = `
29-
const { Temporal } = require("@js-temporal/polyfill");
30-
`;
31-
} else {
32-
outputOptions.intro = `
33-
import { Temporal } from "@js-temporal/polyfill";
34-
`;
35-
}
36-
return outputOptions;
26+
banner({ format }) {
27+
const js = format === "cjs"
28+
? `const { Temporal } = require("@js-temporal/polyfill");`
29+
: `import { Temporal } from "@js-temporal/polyfill";`;
30+
return {
31+
js,
32+
dts: `/// <reference lib="esnext.temporal" />`,
33+
};
3734
},
3835
});

0 commit comments

Comments
 (0)