Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,58 @@ To be released.
fetches are retried once, and remaining transport failures are reported as
`FetchError` with the original error as the cause. [[#762], [#763]]

- Fixed a `TypeError` thrown when Activity Vocabulary constructors received
a `Temporal.Instant` or `Temporal.Duration` produced by an implementation
other than the bundled `@js-temporal/polyfill` (for example, the native
`Temporal` shipped with Node.js 26+). Internal `instanceof` checks have
been replaced with `Symbol.toStringTag`-based guards so any spec-conformant
Temporal value is accepted. Generated _\*.d.ts_ declarations no longer
import from `@js-temporal/polyfill`; they reference the ambient `Temporal`
namespace through the `esnext.temporal` lib instead, which removes the
nominal mismatch with native Temporal types. TypeScript 6.0 or later is
required to consume the type declarations. [[#767], [#768]]

[#762]: https://github.com/fedify-dev/fedify/issues/762
[#763]: https://github.com/fedify-dev/fedify/pull/763
[#767]: https://github.com/fedify-dev/fedify/issues/767
[#768]: https://github.com/fedify-dev/fedify/pull/768

### @fedify/vocab-runtime

- Added `isTemporalInstant()` and `isTemporalDuration()` type guards that
accept both polyfill and native `Temporal` values via `Symbol.toStringTag`.
[[#767], [#768]]

- Added the `@fedify/vocab-runtime/temporal` subpath export so consumers
can import the new `Temporal` type guards without pulling in the rest of
the runtime. [[#767], [#768]]

### @fedify/postgres

- Generated _\*.d.ts_ declarations no longer import from
`@js-temporal/polyfill`; they reference the ambient `Temporal` namespace
through the `esnext.temporal` lib instead, so `pollInterval` and
`handlerTimeout` accept native `Temporal.Duration` values from Node.js
26+ without a nominal type mismatch. TypeScript 6.0 or later is
required to consume the type declarations. [[#767], [#768]]

### @fedify/redis

- Generated _\*.d.ts_ declarations no longer import from
`@js-temporal/polyfill`; they reference the ambient `Temporal` namespace
through the `esnext.temporal` lib instead, so `pollInterval` accepts
native `Temporal.Duration` values from Node.js 26+ without a nominal type
mismatch. TypeScript 6.0 or later is required to consume the type
declarations. [[#767], [#768]]

### @fedify/sqlite

- Generated _\*.d.ts_ declarations no longer import from
`@js-temporal/polyfill`; they reference the ambient `Temporal` namespace
through the `esnext.temporal` lib instead, so `pollInterval` accepts
native `Temporal.Duration` values from Node.js 26+ without a nominal type
mismatch. TypeScript 6.0 or later is required to consume the type
declarations. [[#767], [#768]]


Version 2.0.16
Expand Down
4 changes: 3 additions & 1 deletion deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@ export default withMermaid(defineConfig({
target: ScriptTarget.ESNext,
experimentalDecorators: true, // For @fedify/nestjs
emitDecoratorMetadata: true, // For @fedify/nestjs
// Silences TS5101 about the `baseUrl` injected by @typescript/vfs
// when Twoslash spins up its virtual TS environment; the option
// is deprecated in TypeScript 6.0 and removed in 7.0.
ignoreDeprecations: "6.0",
lib: ["dom", "dom.iterable", "esnext"],
types: [
"dom",
Expand Down
4 changes: 2 additions & 2 deletions docs/manual/federation.md
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ Deno.serve(
~~~~

~~~~ typescript twoslash [Bun]
import "@types/bun";
import "bun";
import { type Federation } from "@fedify/fedify";
const federation = null as unknown as Federation<void>;
const request = new Request("");
Expand Down Expand Up @@ -665,7 +665,7 @@ serve({
~~~~

~~~~ typescript{1,4} twoslash [Bun]
import "@types/bun";
import "bun";
import { type Federation } from "@fedify/fedify";
const federation = null as unknown as Federation<void>;
// ---cut-before---
Expand Down
1 change: 0 additions & 1 deletion docs/manual/pragmatics.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ The date joined is displayed in the profile page of the actor.

~~~~ typescript twoslash
import { Person } from "@fedify/vocab";
import { Temporal } from "@js-temporal/polyfill";
// ---cut-before---
new Person({
name: "Fedify Demo",
Expand Down
2 changes: 1 addition & 1 deletion docs/manual/relay.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Deno.serve((request) => relay.fetch(request));
~~~~

~~~~ typescript twoslash [Bun]
import "@types/bun";
import "bun";
// ---cut-before---
import { createRelay } from "@fedify/relay";
import { MemoryKvStore } from "@fedify/fedify";
Expand Down
5 changes: 0 additions & 5 deletions docs/manual/vocab.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ that contains the properties of the object. The following shows an example of
instantiating a `Create` object:

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

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

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

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

Expand Down
10 changes: 5 additions & 5 deletions docs/tutorial/basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ Deno.serve(request =>
~~~~

~~~~ typescript twoslash [Bun]
import "@types/bun";
import "bun";
// ---cut-before---
Bun.serve({
port: 8000,
Expand Down Expand Up @@ -277,7 +277,7 @@ Deno.serve(
~~~~

~~~~ typescript{4} twoslash [Bun]
import "@types/bun";
import "bun";
import type { Federation } from "@fedify/fedify";
const federation = null as unknown as Federation<void>;
// ---cut-before---
Expand Down Expand Up @@ -407,7 +407,7 @@ Deno.serve(
~~~~

~~~~ typescript{7-16} twoslash [Bun]
import "@types/bun";
import "bun";
// ---cut-before---
import { createFederation, MemoryKvStore } from "@fedify/fedify";
import { Person } from "@fedify/vocab";
Expand Down Expand Up @@ -654,7 +654,7 @@ Deno.serve(
~~~~

~~~~ typescript{1,5} twoslash [Bun]
import "@types/bun";
import "bun";
import type { Federation } from "@fedify/fedify";
const federation = null as unknown as Federation<void>;
// ---cut-before---
Expand Down Expand Up @@ -1202,7 +1202,7 @@ Deno.serve(async (request) => {
~~~~

~~~~ typescript{4-18} twoslash [Bun]
import "@types/bun";
import "bun";
import type { Federation } from "@fedify/fedify";
import { openKv } from "@deno/kv";
const federation = null as unknown as Federation<void>;
Expand Down
3 changes: 1 addition & 2 deletions docs/tutorial/microblog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3144,7 +3144,7 @@ npm add @js-temporal/polyfill

Open the *src/federation.ts* file and `import` the installed package:

~~~~ typescript twoslash [src/federation.ts]
~~~~ typescript [src/federation.ts]
import { Temporal } from "@js-temporal/polyfill";
~~~~

Expand Down Expand Up @@ -3199,7 +3199,6 @@ federation.setObjectDispatcher(
Let's modify this as follows:

~~~~ typescript twoslash [src/federation.ts]
import { Temporal } from "@js-temporal/polyfill";
import { type Federation } from "@fedify/fedify";
import { Note, PUBLIC_COLLECTION } from "@fedify/vocab";
const federation = null as unknown as Federation<void>;
Expand Down
19 changes: 8 additions & 11 deletions packages/debugger/tsdown.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,13 @@ export default defineConfig({
/^hono\//,
],
},
outputOptions(outputOptions, format) {
if (format === "cjs") {
outputOptions.intro = `
const { Temporal } = require("@js-temporal/polyfill");
`;
} else {
outputOptions.intro = `
import { Temporal } from "@js-temporal/polyfill";
`;
}
return outputOptions;
banner({ format }) {
const js = format === "cjs"
? `const { Temporal } = require("@js-temporal/polyfill");`
: `import { Temporal } from "@js-temporal/polyfill";`;
return {
js,
dts: `/// <reference lib="esnext.temporal" />`,
};
},
});
4 changes: 1 addition & 3 deletions packages/fedify/src/utils/kv-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,7 @@ function matchRule(
][],
): Temporal.Duration | null {
for (const [pattern, d] of rules!) {
const duration = d instanceof Temporal.Duration
? d
: Temporal.Duration.from(d);
const duration = Temporal.Duration.from(d);
if (typeof pattern === "string") {
if (url === pattern) return duration;
continue;
Expand Down
27 changes: 14 additions & 13 deletions packages/fedify/tsdown.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,20 @@ export default [
format: ["esm", "cjs"],
platform: "neutral",
deps: { neverBundle: [/^node:/] },
outputOptions(outputOptions, format) {
if (format === "cjs") {
outputOptions.intro = `
const { Temporal } = require("@js-temporal/polyfill");
const { URLPattern } = require("urlpattern-polyfill");
`;
} else {
outputOptions.intro = `
import { Temporal } from "@js-temporal/polyfill";
import { URLPattern } from "urlpattern-polyfill";
`;
}
return outputOptions;
banner({ format }) {
const js = format === "cjs"
? [
`const { Temporal } = require("@js-temporal/polyfill");`,
`const { URLPattern } = require("urlpattern-polyfill");`,
].join("\n")
: [
`import { Temporal } from "@js-temporal/polyfill";`,
`import { URLPattern } from "urlpattern-polyfill";`,
].join("\n");
return {
js,
dts: `/// <reference lib="esnext.temporal" />`,
};
},
}),
defineConfig({
Expand Down
19 changes: 8 additions & 11 deletions packages/postgres/tsdown.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,13 @@ export default defineConfig({
dts: format === "cjs" ? ".d.cts" : ".d.ts",
};
},
outputOptions(outputOptions, format) {
if (format === "cjs") {
outputOptions.intro = `
const { Temporal } = require("@js-temporal/polyfill");
`;
} else {
outputOptions.intro = `
import { Temporal } from "@js-temporal/polyfill";
`;
}
return outputOptions;
banner({ format }) {
const js = format === "cjs"
? `const { Temporal } = require("@js-temporal/polyfill");`
: `import { Temporal } from "@js-temporal/polyfill";`;
return {
js,
dts: `/// <reference lib="esnext.temporal" />`,
};
},
});
19 changes: 8 additions & 11 deletions packages/redis/tsdown.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,13 @@ export default defineConfig({
dts: format === "cjs" ? ".d.cts" : ".d.ts",
};
},
outputOptions(outputOptions, format) {
if (format === "cjs") {
outputOptions.intro = `
const { Temporal } = require("@js-temporal/polyfill");
`;
} else {
outputOptions.intro = `
import { Temporal } from "@js-temporal/polyfill";
`;
}
return outputOptions;
banner({ format }) {
const js = format === "cjs"
? `const { Temporal } = require("@js-temporal/polyfill");`
: `import { Temporal } from "@js-temporal/polyfill";`;
return {
js,
dts: `/// <reference lib="esnext.temporal" />`,
};
},
});
19 changes: 8 additions & 11 deletions packages/relay/tsdown.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,14 @@ export default [
dts: format === "cjs" ? ".d.cts" : ".d.ts",
};
},
outputOptions(outputOptions, format) {
if (format === "cjs") {
outputOptions.intro = `
const { Temporal } = require("@js-temporal/polyfill");
`;
} else {
outputOptions.intro = `
import { Temporal } from "@js-temporal/polyfill";
`;
}
return outputOptions;
banner({ format }) {
const js = format === "cjs"
? `const { Temporal } = require("@js-temporal/polyfill");`
: `import { Temporal } from "@js-temporal/polyfill";`;
return {
js,
dts: `/// <reference lib="esnext.temporal" />`,
};
},
}),
defineConfig({
Expand Down
19 changes: 8 additions & 11 deletions packages/sqlite/tsdown.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,13 @@ export default defineConfig({
defaultHandler(warning);
},
},
outputOptions(outputOptions, format) {
if (format === "cjs") {
outputOptions.intro = `
const { Temporal } = require("@js-temporal/polyfill");
`;
} else {
outputOptions.intro = `
import { Temporal } from "@js-temporal/polyfill";
`;
}
return outputOptions;
banner({ format }) {
const js = format === "cjs"
? `const { Temporal } = require("@js-temporal/polyfill");`
: `import { Temporal } from "@js-temporal/polyfill";`;
return {
js,
dts: `/// <reference lib="esnext.temporal" />`,
};
},
});
Loading
Loading