temporal-fmt 0.9.81 → 0.9.82

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 (41) hide show
  1. package/dist/{chunk-GRBQ5FRO.js → chunk-4JMHI6E2.js} +2 -2
  2. package/dist/{chunk-6FPOCDZV.js → chunk-7XSIPXIR.js} +5 -5
  3. package/dist/{chunk-EXIJZ4JG.js → chunk-AF3LHBDQ.js} +2 -2
  4. package/dist/{chunk-TDQYKYVJ.js → chunk-IEQCJPB5.js} +2 -2
  5. package/dist/{chunk-DFWTCRS3.js → chunk-JCJW2VOV.js} +10 -7
  6. package/dist/chunk-JCJW2VOV.js.map +1 -0
  7. package/dist/{chunk-ACGCGXP5.js → chunk-KWOTFJNY.js} +3 -3
  8. package/dist/{chunk-YQGUTK4E.js → chunk-NHNUFNQ7.js} +2 -2
  9. package/dist/{chunk-E4DD23HH.js → chunk-TIMSK72I.js} +2 -2
  10. package/dist/{chunk-EEPLAE3H.js → chunk-W45J4E76.js} +4 -4
  11. package/dist/format.cjs +7 -4
  12. package/dist/format.cjs.map +1 -1
  13. package/dist/format.js +4 -4
  14. package/dist/index.cjs +9 -6
  15. package/dist/index.cjs.map +1 -1
  16. package/dist/index.js +9 -9
  17. package/dist/interval.cjs +7 -4
  18. package/dist/interval.cjs.map +1 -1
  19. package/dist/interval.js +5 -5
  20. package/dist/legacy.cjs +7 -4
  21. package/dist/legacy.cjs.map +1 -1
  22. package/dist/legacy.js +6 -6
  23. package/dist/parse.cjs +7 -4
  24. package/dist/parse.cjs.map +1 -1
  25. package/dist/parse.js +4 -4
  26. package/dist/relativeTime.cjs +6 -2
  27. package/dist/relativeTime.cjs.map +1 -1
  28. package/dist/relativeTime.js +3 -3
  29. package/dist/timezone.cjs +6 -2
  30. package/dist/timezone.cjs.map +1 -1
  31. package/dist/timezone.js +2 -2
  32. package/package.json +1 -1
  33. package/dist/chunk-DFWTCRS3.js.map +0 -1
  34. /package/dist/{chunk-GRBQ5FRO.js.map → chunk-4JMHI6E2.js.map} +0 -0
  35. /package/dist/{chunk-6FPOCDZV.js.map → chunk-7XSIPXIR.js.map} +0 -0
  36. /package/dist/{chunk-EXIJZ4JG.js.map → chunk-AF3LHBDQ.js.map} +0 -0
  37. /package/dist/{chunk-TDQYKYVJ.js.map → chunk-IEQCJPB5.js.map} +0 -0
  38. /package/dist/{chunk-ACGCGXP5.js.map → chunk-KWOTFJNY.js.map} +0 -0
  39. /package/dist/{chunk-YQGUTK4E.js.map → chunk-NHNUFNQ7.js.map} +0 -0
  40. /package/dist/{chunk-E4DD23HH.js.map → chunk-TIMSK72I.js.map} +0 -0
  41. /package/dist/{chunk-EEPLAE3H.js.map → chunk-W45J4E76.js.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  getTemporal,
3
3
  subscribeToTemporalChanges
4
- } from "./chunk-DFWTCRS3.js";
4
+ } from "./chunk-JCJW2VOV.js";
5
5
  import {
6
6
  dayOfYear,
7
7
  isoWeekYearAndWeek
@@ -364,4 +364,4 @@ export {
364
364
  DEFAULT_LOCALE,
365
365
  TOKENS
366
366
  };
367
- //# sourceMappingURL=chunk-GRBQ5FRO.js.map
367
+ //# sourceMappingURL=chunk-4JMHI6E2.js.map
@@ -2,7 +2,7 @@ import {
2
2
  compileFormat,
3
3
  format,
4
4
  formatToParts
5
- } from "./chunk-ACGCGXP5.js";
5
+ } from "./chunk-KWOTFJNY.js";
6
6
  import {
7
7
  buildCapturingPattern,
8
8
  compileParser,
@@ -11,13 +11,13 @@ import {
11
11
  parseToParts,
12
12
  safeParse,
13
13
  tryParse
14
- } from "./chunk-EEPLAE3H.js";
14
+ } from "./chunk-W45J4E76.js";
15
15
  import {
16
16
  tokenize
17
- } from "./chunk-EXIJZ4JG.js";
17
+ } from "./chunk-AF3LHBDQ.js";
18
18
  import {
19
19
  DEFAULT_LOCALE
20
- } from "./chunk-GRBQ5FRO.js";
20
+ } from "./chunk-4JMHI6E2.js";
21
21
  import {
22
22
  MAX_FORMAT_LENGTH
23
23
  } from "./chunk-SOPTTXUI.js";
@@ -126,4 +126,4 @@ export {
126
126
  parseToParts2 as parseToParts,
127
127
  compileParser2 as compileParser
128
128
  };
129
- //# sourceMappingURL=chunk-6FPOCDZV.js.map
129
+ //# sourceMappingURL=chunk-7XSIPXIR.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  DEFAULT_LOCALE,
3
3
  TOKENS
4
- } from "./chunk-GRBQ5FRO.js";
4
+ } from "./chunk-4JMHI6E2.js";
5
5
  import {
6
6
  FormatSyntaxError,
7
7
  InvalidLocaleError,
@@ -199,4 +199,4 @@ export {
199
199
  applyNumbering,
200
200
  applyParseNumbering
201
201
  };
202
- //# sourceMappingURL=chunk-EXIJZ4JG.js.map
202
+ //# sourceMappingURL=chunk-AF3LHBDQ.js.map
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-SC6ENLEB.js";
4
4
  import {
5
5
  DEFAULT_LOCALE
6
- } from "./chunk-GRBQ5FRO.js";
6
+ } from "./chunk-4JMHI6E2.js";
7
7
  import {
8
8
  InvalidLocaleError,
9
9
  normalizeLocaleTag
@@ -62,4 +62,4 @@ export {
62
62
  formatRelative,
63
63
  formatRelativeToNow
64
64
  };
65
- //# sourceMappingURL=chunk-TDQYKYVJ.js.map
65
+ //# sourceMappingURL=chunk-IEQCJPB5.js.map
@@ -1,15 +1,18 @@
1
1
  // src/temporalProvider.ts
2
- var injectedTemporal;
3
- var onTemporalChanged = [];
2
+ var TEMPORAL_PROVIDER_STATE = /* @__PURE__ */ Symbol.for("temporal-fmt.temporal-provider");
3
+ var globalState = globalThis;
4
+ var providerState = globalState[TEMPORAL_PROVIDER_STATE] ??= {
5
+ onTemporalChanged: []
6
+ };
4
7
  function subscribeToTemporalChanges(listener) {
5
- onTemporalChanged.push(listener);
8
+ providerState.onTemporalChanged.push(listener);
6
9
  }
7
10
  function setTemporal(temporal) {
8
- injectedTemporal = temporal;
9
- for (const listener of onTemporalChanged) listener();
11
+ providerState.injectedTemporal = temporal;
12
+ for (const listener of providerState.onTemporalChanged) listener();
10
13
  }
11
14
  function resolveTemporal() {
12
- return injectedTemporal ?? globalThis.Temporal;
15
+ return providerState.injectedTemporal ?? globalThis.Temporal;
13
16
  }
14
17
  function getTemporal() {
15
18
  const temporal = resolveTemporal();
@@ -26,4 +29,4 @@ export {
26
29
  setTemporal,
27
30
  getTemporal
28
31
  };
29
- //# sourceMappingURL=chunk-DFWTCRS3.js.map
32
+ //# sourceMappingURL=chunk-JCJW2VOV.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/temporalProvider.ts"],"sourcesContent":["/*\n * Copyright 2026 DirazCoder\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// tsconfig here is lib: [\"ESNext\"] only, so there's no ambient Temporal\n// namespace type to lean on. everywhere else in the codebase we just read\n// fields off whatever Temporal-like object gets passed in (see TemporalLike\n// in tokens.ts) but this file is the one place that actually touches the\n// Temporal namespace itself — PlainDate.from and friends. parse() uses it\n// to build results, tokens.ts uses it to check native Intl<->Temporal\n// support. you can hand us your own implementation via setTemporal(), or\n// we just grab globalThis.Temporal if there is one\ninterface TemporalFactory {\n from(fields: Record<string, number | string | undefined>, options?: { overflow?: 'constrain' | 'reject'; disambiguation?: 'compatible' | 'earlier' | 'later' | 'reject'; offset?: 'use' | 'ignore' | 'prefer' | 'reject' }): unknown;\n // compare() is on the namespace, not instances (Temporal.PlainDate.compare).\n // made optional since someone might hand us a stripped-down shim that\n // doesn't bother implementing it\n compare?(one: unknown, two: unknown): number;\n}\n\n// Instant doesn't use from(fields) like the others, it's\n// fromEpochMilliseconds / fromEpochNanoseconds. needs its own shape.\ninterface InstantFactory {\n from(iso: string): unknown;\n fromEpochMilliseconds(ms: number): unknown;\n fromEpochMicroseconds(µs: number): unknown;\n fromEpochNanoseconds(ns: bigint): unknown;\n}\n\n// Duration uses from(fields) too, but also has round() and compare()\ninterface DurationFactory extends TemporalFactory {\n compare?(one: unknown, two: unknown): number;\n prototype?: { round(options: unknown): unknown };\n}\n\n// PlainYearMonth / PlainMonthDay also just use from(fields) — same shape\n// as TemporalFactory really, kept as its own type so callers can narrow\nexport interface TemporalNamespace {\n PlainDate: TemporalFactory;\n PlainTime: TemporalFactory;\n PlainDateTime: TemporalFactory;\n ZonedDateTime: TemporalFactory;\n Instant?: InstantFactory;\n Duration?: DurationFactory;\n PlainYearMonth?: TemporalFactory;\n PlainMonthDay?: TemporalFactory;\n}\n\ninterface TemporalProviderState {\n injectedTemporal?: TemporalNamespace;\n onTemporalChanged: Array<() => void>;\n}\n\nconst TEMPORAL_PROVIDER_STATE = Symbol.for('temporal-fmt.temporal-provider');\nconst globalState = globalThis as unknown as Record<symbol, unknown>;\nconst providerState = (globalState[TEMPORAL_PROVIDER_STATE] ??= {\n onTemporalChanged: [],\n}) as TemporalProviderState;\n\n// anything caching something tied to WHICH Temporal impl is active\n// (right now just tokens.ts's native-Intl probe) registers a listener\n// here so it knows to invalidate when setTemporal() swaps things out —\n// see setTemporal() below for why that matters. kept this as a plain\n// array instead of a full event emitter since all we need is \"call\n// everyone back, in order, no payload\" — didn't need unsubscribe either\nexport function subscribeToTemporalChanges(listener: () => void): void {\n providerState.onTemporalChanged.push(listener);\n}\n\n/**\n * Explicitly hand temporal-fmt the Temporal implementation to use, instead\n * of relying on a global `Temporal`. Call this once, before your first\n * `format()`/`parse()`/`parseISO()`/etc.\n *\n * Call with no argument (or `undefined`) to clear the override and fall\n * back to `globalThis.Temporal` again.\n *\n * @example\n * import { Temporal } from 'temporal-polyfill';\n * import { setTemporal } from 'temporal-fmt';\n * setTemporal(Temporal);\n */\nexport function setTemporal(temporal?: TemporalNamespace): void {\n providerState.injectedTemporal = temporal;\n // tokens.ts caches its native-Intl probe result based on whatever\n // Temporal was active the first time it ran. if that changes later\n // (native -> polyfill, say) the cached result goes stale. so just reset\n // everyone on any setTemporal() call — costs one extra probe re-run,\n // worth it to not silently use a stale answer\n for (const listener of providerState.onTemporalChanged) listener();\n}\n\nfunction resolveTemporal(): TemporalNamespace | undefined {\n return providerState.injectedTemporal ?? (globalThis as unknown as { Temporal?: TemporalNamespace }).Temporal;\n}\n\nexport function getTemporal(): TemporalNamespace {\n const temporal = resolveTemporal();\n if (!temporal) {\n throw new Error(\n 'temporal-fmt: parse() needs a Temporal implementation to construct its result. ' +\n 'Call setTemporal(Temporal) once at startup, or assign one to globalThis.Temporal ' +\n '(native on Node 26+, or a polyfill like temporal-polyfill).'\n );\n }\n return temporal;\n}\n"],"mappings":";AAiEA,IAAM,0BAA0B,uBAAO,IAAI,gCAAgC;AAC3E,IAAM,cAAc;AACpB,IAAM,gBAAiB,YAAY,uBAAuB,MAAM;AAAA,EAC9D,mBAAmB,CAAC;AACtB;AAQO,SAAS,2BAA2B,UAA4B;AACrE,gBAAc,kBAAkB,KAAK,QAAQ;AAC/C;AAeO,SAAS,YAAY,UAAoC;AAC9D,gBAAc,mBAAmB;AAMjC,aAAW,YAAY,cAAc,kBAAmB,UAAS;AACnE;AAEA,SAAS,kBAAiD;AACxD,SAAO,cAAc,oBAAqB,WAA2D;AACvG;AAEO,SAAS,cAAiC;AAC/C,QAAM,WAAW,gBAAgB;AACjC,MAAI,CAAC,UAAU;AACb,UAAM,IAAI;AAAA,MACR;AAAA,IAGF;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
@@ -1,11 +1,11 @@
1
1
  import {
2
2
  applyNumbering,
3
3
  tokenize
4
- } from "./chunk-EXIJZ4JG.js";
4
+ } from "./chunk-AF3LHBDQ.js";
5
5
  import {
6
6
  DEFAULT_LOCALE,
7
7
  TOKENS
8
- } from "./chunk-GRBQ5FRO.js";
8
+ } from "./chunk-4JMHI6E2.js";
9
9
  import {
10
10
  MAX_FORMAT_LENGTH
11
11
  } from "./chunk-SOPTTXUI.js";
@@ -189,4 +189,4 @@ export {
189
189
  _getPieces,
190
190
  _handlerFor
191
191
  };
192
- //# sourceMappingURL=chunk-ACGCGXP5.js.map
192
+ //# sourceMappingURL=chunk-KWOTFJNY.js.map
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-SC6ENLEB.js";
4
4
  import {
5
5
  getTemporal
6
- } from "./chunk-DFWTCRS3.js";
6
+ } from "./chunk-JCJW2VOV.js";
7
7
 
8
8
  // src/timezone.ts
9
9
  function resolveZoned(fields, timeZone, options = {}) {
@@ -232,4 +232,4 @@ export {
232
232
  getTransitions,
233
233
  possibleInstantsFor
234
234
  };
235
- //# sourceMappingURL=chunk-YQGUTK4E.js.map
235
+ //# sourceMappingURL=chunk-NHNUFNQ7.js.map
@@ -7,7 +7,7 @@ import {
7
7
  import {
8
8
  format,
9
9
  formatToParts
10
- } from "./chunk-ACGCGXP5.js";
10
+ } from "./chunk-KWOTFJNY.js";
11
11
  import {
12
12
  daysFromCivil
13
13
  } from "./chunk-BLZDBPSV.js";
@@ -238,4 +238,4 @@ export {
238
238
  formatRange,
239
239
  formatRangeToParts
240
240
  };
241
- //# sourceMappingURL=chunk-E4DD23HH.js.map
241
+ //# sourceMappingURL=chunk-TIMSK72I.js.map
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  applyParseNumbering,
3
3
  tokenize
4
- } from "./chunk-EXIJZ4JG.js";
4
+ } from "./chunk-AF3LHBDQ.js";
5
5
  import {
6
6
  DEFAULT_LOCALE
7
- } from "./chunk-GRBQ5FRO.js";
7
+ } from "./chunk-4JMHI6E2.js";
8
8
  import {
9
9
  getTemporal
10
- } from "./chunk-DFWTCRS3.js";
10
+ } from "./chunk-JCJW2VOV.js";
11
11
  import {
12
12
  MAX_FORMAT_LENGTH,
13
13
  MAX_INPUT_LENGTH
@@ -983,4 +983,4 @@ export {
983
983
  parseToParts,
984
984
  compileParser
985
985
  };
986
- //# sourceMappingURL=chunk-EEPLAE3H.js.map
986
+ //# sourceMappingURL=chunk-W45J4E76.js.map
package/dist/format.cjs CHANGED
@@ -29,13 +29,16 @@ __export(format_exports, {
29
29
  module.exports = __toCommonJS(format_exports);
30
30
 
31
31
  // src/temporalProvider.ts
32
- var injectedTemporal;
33
- var onTemporalChanged = [];
32
+ var TEMPORAL_PROVIDER_STATE = /* @__PURE__ */ Symbol.for("temporal-fmt.temporal-provider");
33
+ var globalState = globalThis;
34
+ var providerState = globalState[TEMPORAL_PROVIDER_STATE] ??= {
35
+ onTemporalChanged: []
36
+ };
34
37
  function subscribeToTemporalChanges(listener) {
35
- onTemporalChanged.push(listener);
38
+ providerState.onTemporalChanged.push(listener);
36
39
  }
37
40
  function resolveTemporal() {
38
- return injectedTemporal ?? globalThis.Temporal;
41
+ return providerState.injectedTemporal ?? globalThis.Temporal;
39
42
  }
40
43
  function getTemporal() {
41
44
  const temporal = resolveTemporal();