@fedify/vocab-runtime 2.3.0-dev.1069 → 2.3.0-dev.1099
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/deno.json +4 -3
- package/dist/{chunk-CKQMccvm.cjs → chunk-M78iaK0I.cjs} +1 -0
- package/dist/jsonld.cjs +3 -2
- package/dist/jsonld.d.cts +1 -0
- package/dist/jsonld.d.ts +1 -0
- package/dist/jsonld.js +1 -0
- package/dist/mod.cjs +4325 -4359
- package/dist/mod.d.cts +1 -0
- package/dist/mod.d.ts +1 -0
- package/dist/mod.js +4322 -4356
- package/dist/temporal.cjs +60 -0
- package/dist/temporal.d.cts +54 -0
- package/dist/temporal.d.ts +54 -0
- package/dist/temporal.js +58 -0
- package/dist/tests/{chunk-Do9eywBl.cjs → chunk-C2EiDwsr.cjs} +1 -1
- package/dist/tests/decimal.test.cjs +4 -4
- package/dist/tests/decimal.test.mjs +3 -3
- package/dist/tests/docloader-CjraMMLV.cjs +4543 -0
- package/dist/tests/docloader-svYZTdwU.mjs +4531 -0
- package/dist/tests/docloader.test.cjs +4 -4
- package/dist/tests/docloader.test.mjs +3 -3
- package/dist/tests/internal/multicodec.test.cjs +1 -1
- package/dist/tests/{key-BeTHFQJK.mjs → key-CrrK9mYh.mjs} +1 -1
- package/dist/tests/{key-DTTIntwb.cjs → key-pMmqUKuo.cjs} +2 -2
- package/dist/tests/key.test.cjs +3 -3
- package/dist/tests/key.test.mjs +2 -2
- package/dist/tests/langstr.test.cjs +2 -2
- package/dist/tests/link.test.cjs +1 -1
- package/dist/tests/multibase/multibase.test.cjs +2 -2
- package/dist/tests/multibase/multibase.test.mjs +1 -1
- package/dist/tests/{multibase-BgU9XRf7.mjs → multibase-B4bvakyA.mjs} +3 -0
- package/dist/tests/{multibase-F7LtMMsK.cjs → multibase-Bz_UUDtL.cjs} +5 -2
- package/dist/tests/{request-CARANH2d.mjs → request-Bpm2JArn.mjs} +1 -1
- package/dist/tests/{request-D3V3yzXZ.cjs → request-DzaqEN3w.cjs} +3 -3
- package/dist/tests/request.test.cjs +3 -3
- package/dist/tests/request.test.mjs +1 -1
- package/dist/tests/temporal.test.cjs +134 -0
- package/dist/tests/temporal.test.d.cts +1 -0
- package/dist/tests/temporal.test.d.mts +1 -0
- package/dist/tests/temporal.test.mjs +134 -0
- package/dist/tests/{url-Cj9-Ycue.cjs → url-CEmGms8t.cjs} +1 -1
- package/dist/tests/url.test.cjs +2 -2
- package/package.json +17 -6
- package/src/temporal.test.ts +121 -0
- package/src/temporal.ts +74 -0
- package/tsdown.config.ts +6 -3
- package/dist/tests/docloader-CJ2-f1JD.cjs +0 -4581
- package/dist/tests/docloader-CYy6F-CT.mjs +0 -4569
package/src/temporal.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type guards for `Temporal` namespace objects.
|
|
3
|
+
*
|
|
4
|
+
* Fedify accepts both runtime polyfills (e.g. `@js-temporal/polyfill`,
|
|
5
|
+
* `temporal-polyfill`) and the host's native `Temporal` implementation
|
|
6
|
+
* (Node.js 26+, Bun, Deno). The guards below rely on `Symbol.toStringTag`,
|
|
7
|
+
* which is mandated by the Temporal specification, so they accept any
|
|
8
|
+
* spec-conformant implementation regardless of which class produced the
|
|
9
|
+
* value.
|
|
10
|
+
*
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Checks whether the given value is a `Temporal.Instant` object, regardless
|
|
16
|
+
* of whether it came from a polyfill or the host's native implementation.
|
|
17
|
+
*
|
|
18
|
+
* The guard verifies the spec-mandated `Symbol.toStringTag`, that the
|
|
19
|
+
* `epochNanoseconds` accessor exposes a `bigint`, and that `toString` is
|
|
20
|
+
* not the default inherited from `Object.prototype`. Together they reject
|
|
21
|
+
* bare objects whose tag was set to `"Temporal.Instant"` without exposing
|
|
22
|
+
* the rest of the shape; the `toString` check in particular prevents a
|
|
23
|
+
* spoof from reaching the JSON-LD serializer (which calls `toString()`)
|
|
24
|
+
* and emitting `"[object Temporal.Instant]"` instead of an RFC 3339
|
|
25
|
+
* timestamp.
|
|
26
|
+
*
|
|
27
|
+
* @param value The value to test.
|
|
28
|
+
* @returns `true` if the value reports `Temporal.Instant` via
|
|
29
|
+
* `Symbol.toStringTag`, exposes a `bigint`-valued
|
|
30
|
+
* `epochNanoseconds`, and overrides `toString`; `false` otherwise.
|
|
31
|
+
*/
|
|
32
|
+
export function isTemporalInstant(value: unknown): value is Temporal.Instant {
|
|
33
|
+
return (
|
|
34
|
+
typeof value === "object" &&
|
|
35
|
+
value !== null &&
|
|
36
|
+
Object.prototype.toString.call(value) === "[object Temporal.Instant]" &&
|
|
37
|
+
"epochNanoseconds" in value &&
|
|
38
|
+
typeof value.epochNanoseconds === "bigint" &&
|
|
39
|
+
"toString" in value &&
|
|
40
|
+
typeof value.toString === "function" &&
|
|
41
|
+
value.toString !== Object.prototype.toString
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Checks whether the given value is a `Temporal.Duration` object, regardless
|
|
47
|
+
* of whether it came from a polyfill or the host's native implementation.
|
|
48
|
+
*
|
|
49
|
+
* The guard verifies the spec-mandated `Symbol.toStringTag`, that the
|
|
50
|
+
* `sign` accessor returns one of the three spec-valid values (`-1`, `0`,
|
|
51
|
+
* or `1`), and that `toString` is not the default inherited from
|
|
52
|
+
* `Object.prototype`. Together they reject bare objects whose tag was set
|
|
53
|
+
* to `"Temporal.Duration"` without exposing the rest of the shape; the
|
|
54
|
+
* `toString` check in particular prevents a spoof from reaching the
|
|
55
|
+
* JSON-LD serializer (which calls `toString()`) and emitting
|
|
56
|
+
* `"[object Temporal.Duration]"` instead of an ISO 8601 duration.
|
|
57
|
+
*
|
|
58
|
+
* @param value The value to test.
|
|
59
|
+
* @returns `true` if the value reports `Temporal.Duration` via
|
|
60
|
+
* `Symbol.toStringTag`, exposes a `sign` of `-1`, `0`, or `1`,
|
|
61
|
+
* and overrides `toString`; `false` otherwise.
|
|
62
|
+
*/
|
|
63
|
+
export function isTemporalDuration(value: unknown): value is Temporal.Duration {
|
|
64
|
+
return (
|
|
65
|
+
typeof value === "object" &&
|
|
66
|
+
value !== null &&
|
|
67
|
+
Object.prototype.toString.call(value) === "[object Temporal.Duration]" &&
|
|
68
|
+
"sign" in value &&
|
|
69
|
+
(value.sign === -1 || value.sign === 0 || value.sign === 1) &&
|
|
70
|
+
"toString" in value &&
|
|
71
|
+
typeof value.toString === "function" &&
|
|
72
|
+
value.toString !== Object.prototype.toString
|
|
73
|
+
);
|
|
74
|
+
}
|
package/tsdown.config.ts
CHANGED
|
@@ -4,11 +4,14 @@ import { defineConfig } from "tsdown";
|
|
|
4
4
|
|
|
5
5
|
export default [
|
|
6
6
|
defineConfig({
|
|
7
|
-
entry: ["src/mod.ts", "src/jsonld.ts"],
|
|
7
|
+
entry: ["src/mod.ts", "src/jsonld.ts", "src/temporal.ts"],
|
|
8
8
|
dts: { compilerOptions: { isolatedDeclarations: true, declaration: true } },
|
|
9
9
|
format: ["esm", "cjs"],
|
|
10
10
|
platform: "neutral",
|
|
11
|
-
|
|
11
|
+
deps: { neverBundle: [/^node:/] },
|
|
12
|
+
banner: {
|
|
13
|
+
dts: `/// <reference lib="esnext.temporal" />`,
|
|
14
|
+
},
|
|
12
15
|
}),
|
|
13
16
|
defineConfig({
|
|
14
17
|
outDir: "dist/tests",
|
|
@@ -16,6 +19,6 @@ export default [
|
|
|
16
19
|
.map((f) => f.replace(sep, "/")),
|
|
17
20
|
format: ["esm", "cjs"],
|
|
18
21
|
platform: "node",
|
|
19
|
-
|
|
22
|
+
deps: { neverBundle: [/^node:/, "@fedify/fixture"] },
|
|
20
23
|
}),
|
|
21
24
|
];
|