@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.
Files changed (48) hide show
  1. package/deno.json +4 -3
  2. package/dist/{chunk-CKQMccvm.cjs → chunk-M78iaK0I.cjs} +1 -0
  3. package/dist/jsonld.cjs +3 -2
  4. package/dist/jsonld.d.cts +1 -0
  5. package/dist/jsonld.d.ts +1 -0
  6. package/dist/jsonld.js +1 -0
  7. package/dist/mod.cjs +4325 -4359
  8. package/dist/mod.d.cts +1 -0
  9. package/dist/mod.d.ts +1 -0
  10. package/dist/mod.js +4322 -4356
  11. package/dist/temporal.cjs +60 -0
  12. package/dist/temporal.d.cts +54 -0
  13. package/dist/temporal.d.ts +54 -0
  14. package/dist/temporal.js +58 -0
  15. package/dist/tests/{chunk-Do9eywBl.cjs → chunk-C2EiDwsr.cjs} +1 -1
  16. package/dist/tests/decimal.test.cjs +4 -4
  17. package/dist/tests/decimal.test.mjs +3 -3
  18. package/dist/tests/docloader-CjraMMLV.cjs +4543 -0
  19. package/dist/tests/docloader-svYZTdwU.mjs +4531 -0
  20. package/dist/tests/docloader.test.cjs +4 -4
  21. package/dist/tests/docloader.test.mjs +3 -3
  22. package/dist/tests/internal/multicodec.test.cjs +1 -1
  23. package/dist/tests/{key-BeTHFQJK.mjs → key-CrrK9mYh.mjs} +1 -1
  24. package/dist/tests/{key-DTTIntwb.cjs → key-pMmqUKuo.cjs} +2 -2
  25. package/dist/tests/key.test.cjs +3 -3
  26. package/dist/tests/key.test.mjs +2 -2
  27. package/dist/tests/langstr.test.cjs +2 -2
  28. package/dist/tests/link.test.cjs +1 -1
  29. package/dist/tests/multibase/multibase.test.cjs +2 -2
  30. package/dist/tests/multibase/multibase.test.mjs +1 -1
  31. package/dist/tests/{multibase-BgU9XRf7.mjs → multibase-B4bvakyA.mjs} +3 -0
  32. package/dist/tests/{multibase-F7LtMMsK.cjs → multibase-Bz_UUDtL.cjs} +5 -2
  33. package/dist/tests/{request-CARANH2d.mjs → request-Bpm2JArn.mjs} +1 -1
  34. package/dist/tests/{request-D3V3yzXZ.cjs → request-DzaqEN3w.cjs} +3 -3
  35. package/dist/tests/request.test.cjs +3 -3
  36. package/dist/tests/request.test.mjs +1 -1
  37. package/dist/tests/temporal.test.cjs +134 -0
  38. package/dist/tests/temporal.test.d.cts +1 -0
  39. package/dist/tests/temporal.test.d.mts +1 -0
  40. package/dist/tests/temporal.test.mjs +134 -0
  41. package/dist/tests/{url-Cj9-Ycue.cjs → url-CEmGms8t.cjs} +1 -1
  42. package/dist/tests/url.test.cjs +2 -2
  43. package/package.json +17 -6
  44. package/src/temporal.test.ts +121 -0
  45. package/src/temporal.ts +74 -0
  46. package/tsdown.config.ts +6 -3
  47. package/dist/tests/docloader-CJ2-f1JD.cjs +0 -4581
  48. package/dist/tests/docloader-CYy6F-CT.mjs +0 -4569
@@ -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
- external: [/^node:/],
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
- external: [/^node:/, "@fedify/fixture"],
22
+ deps: { neverBundle: [/^node:/, "@fedify/fixture"] },
20
23
  }),
21
24
  ];