solve-engine 2.25.0 → 2.27.0
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/dist/CalendarBackend-MdS3Bb4P.d.cts +181 -0
- package/dist/CalendarBackend-MdS3Bb4P.d.ts +181 -0
- package/dist/{Configuration-DnzYPmoK.d.cts → Configuration-BxriK9Kw.d.cts} +63 -4
- package/dist/{Configuration-DnzYPmoK.d.ts → Configuration-BxriK9Kw.d.ts} +63 -4
- package/dist/DateCalendar-B85t6Vk6.d.ts +90 -0
- package/dist/DateCalendar-CUGI1fT4.d.cts +90 -0
- package/dist/{EngineError-fR1K1rvx.d.cts → EngineError-C-kBwYlN.d.cts} +31 -4
- package/dist/{EngineError-fR1K1rvx.d.ts → EngineError-C-kBwYlN.d.ts} +31 -4
- package/dist/{FormattingSettings-bRKjU7wI.d.ts → FormattingSettings-ByO-4wiM.d.cts} +14 -0
- package/dist/{FormattingSettings-bRKjU7wI.d.cts → FormattingSettings-CvCzAfsz.d.ts} +14 -0
- package/dist/{Lexer-aB95pjoX.d.cts → Lexer-DhGhoAa2.d.cts} +13 -3
- package/dist/{Lexer-Bmctxl0n.d.ts → Lexer-DqtnZMC5.d.ts} +13 -3
- package/dist/{PackageCompatibility-CUVg8tmt.d.cts → PackageCompatibility-CNiTtC6S.d.cts} +1 -1
- package/dist/{PackageCompatibility-BludTs7v.d.ts → PackageCompatibility-fj_f7uqC.d.ts} +1 -1
- package/dist/{PackageRegistry-Dvn4i2QK.d.cts → PackageRegistry-BHBCFswo.d.cts} +328 -14
- package/dist/{PackageRegistry-DT-x32OM.d.ts → PackageRegistry-CNZUwWHJ.d.ts} +328 -14
- package/dist/{Parselet-BawfGuTF.d.cts → Parselet-DF3864la.d.cts} +19 -3
- package/dist/{Parselet-DqTbbtWA.d.ts → Parselet-Dgymjxzd.d.ts} +19 -3
- package/dist/{Token-CbP_OutD.d.cts → Token-D8f7yaz1.d.cts} +17 -0
- package/dist/{Token-CbP_OutD.d.ts → Token-D8f7yaz1.d.ts} +17 -0
- package/dist/{TokenNormalizer-CLBtiE8M.d.ts → TokenNormalizer-IF7nPRMp.d.ts} +1 -1
- package/dist/{TokenNormalizer-CjTDmHgB.d.cts → TokenNormalizer-Pe3_390t.d.cts} +1 -1
- package/dist/{ScopeManager-B636am7Y.d.ts → VMBuiltins-CZiZRKn-.d.ts} +91 -9
- package/dist/{ScopeManager-CdwX0VTw.d.cts → VMBuiltins-kv4rr0y5.d.cts} +91 -9
- package/dist/{VMCheckpoints-DDlxNssY.d.ts → VMCheckpoints-DXze6ypg.d.ts} +2 -2
- package/dist/{VMCheckpoints-CYqeq8IV.d.cts → VMCheckpoints-yun4ocSv.d.cts} +2 -2
- package/dist/{Value-Ds3Gy07C.d.cts → Value-BYHw-x7q.d.cts} +57 -1
- package/dist/{Value-Ds3Gy07C.d.ts → Value-BYHw-x7q.d.ts} +57 -1
- package/dist/{WorkerError-B1dF3VYT.d.cts → WorkerError-BLZyNq6M.d.cts} +1 -1
- package/dist/{WorkerError-dneODN-u.d.ts → WorkerError-CfBJYueR.d.ts} +1 -1
- package/dist/chunk-2SYYKQ4Q.cjs +2 -0
- package/dist/chunk-2SYYKQ4Q.cjs.map +1 -0
- package/dist/chunk-6EYKVQT3.cjs +2 -0
- package/dist/chunk-6EYKVQT3.cjs.map +1 -0
- package/dist/chunk-7RC6RBS6.cjs +2 -0
- package/dist/chunk-7RC6RBS6.cjs.map +1 -0
- package/dist/chunk-AZX4NTYN.cjs +3 -0
- package/dist/chunk-AZX4NTYN.cjs.map +1 -0
- package/dist/{chunk-JFZ5SLF7.js → chunk-BCR53EIL.js} +2 -2
- package/dist/{chunk-JFZ5SLF7.js.map → chunk-BCR53EIL.js.map} +1 -1
- package/dist/chunk-BCY2WY5P.js +5 -0
- package/dist/chunk-BCY2WY5P.js.map +1 -0
- package/dist/chunk-BLJ6E577.js +2 -0
- package/dist/chunk-BLJ6E577.js.map +1 -0
- package/dist/chunk-CL7DM2FX.js +2 -0
- package/dist/chunk-CL7DM2FX.js.map +1 -0
- package/dist/{chunk-BMXYR5LI.cjs → chunk-CQLCTKMX.cjs} +2 -2
- package/dist/{chunk-BMXYR5LI.cjs.map → chunk-CQLCTKMX.cjs.map} +1 -1
- package/dist/chunk-D4VBWPWN.js +2 -0
- package/dist/chunk-D4VBWPWN.js.map +1 -0
- package/dist/chunk-DFMAZ6XM.cjs +3 -0
- package/dist/chunk-DFMAZ6XM.cjs.map +1 -0
- package/dist/chunk-E4HAKNBQ.cjs +2 -0
- package/dist/chunk-E4HAKNBQ.cjs.map +1 -0
- package/dist/{chunk-XHQYHXRE.js → chunk-ESZNJQ2C.js} +3 -3
- package/dist/{chunk-XHQYHXRE.js.map → chunk-ESZNJQ2C.js.map} +1 -1
- package/dist/{chunk-IJMNVBIS.js → chunk-FAO6DQ74.js} +2 -2
- package/dist/chunk-FAO6DQ74.js.map +1 -0
- package/dist/{chunk-WGP4UUO5.cjs → chunk-FDKTESBC.cjs} +2 -2
- package/dist/{chunk-WGP4UUO5.cjs.map → chunk-FDKTESBC.cjs.map} +1 -1
- package/dist/{chunk-NEGZZB7F.cjs → chunk-G2V33LFM.cjs} +2 -2
- package/dist/{chunk-NEGZZB7F.cjs.map → chunk-G2V33LFM.cjs.map} +1 -1
- package/dist/chunk-GJZIJK2Q.cjs +2 -0
- package/dist/chunk-GJZIJK2Q.cjs.map +1 -0
- package/dist/chunk-GVL3ZMS7.cjs +2 -0
- package/dist/chunk-GVL3ZMS7.cjs.map +1 -0
- package/dist/{chunk-YBQPEWT7.cjs → chunk-GXO7TSXQ.cjs} +3 -3
- package/dist/chunk-GXO7TSXQ.cjs.map +1 -0
- package/dist/{chunk-OONQ3V3I.js → chunk-HANGBVEE.js} +2 -2
- package/dist/{chunk-OONQ3V3I.js.map → chunk-HANGBVEE.js.map} +1 -1
- package/dist/chunk-J4K72CQN.js +2 -0
- package/dist/chunk-J4K72CQN.js.map +1 -0
- package/dist/{chunk-72PYPENZ.js → chunk-LE6WZLJ4.js} +2 -2
- package/dist/{chunk-72PYPENZ.js.map → chunk-LE6WZLJ4.js.map} +1 -1
- package/dist/chunk-LQIRBP4Q.js +2 -0
- package/dist/chunk-LQIRBP4Q.js.map +1 -0
- package/dist/{chunk-RDYXH7ML.js → chunk-LTUYWJGO.js} +2 -2
- package/dist/{chunk-RDYXH7ML.js.map → chunk-LTUYWJGO.js.map} +1 -1
- package/dist/chunk-O5PO4D2A.cjs +2 -0
- package/dist/chunk-O5PO4D2A.cjs.map +1 -0
- package/dist/chunk-PQFI55AC.js +3 -0
- package/dist/chunk-PQFI55AC.js.map +1 -0
- package/dist/chunk-QQHHZPEW.cjs +2 -0
- package/dist/chunk-QQHHZPEW.cjs.map +1 -0
- package/dist/chunk-REZQFPVX.js +2 -0
- package/dist/chunk-REZQFPVX.js.map +1 -0
- package/dist/chunk-RRUGQ6DM.js +2 -0
- package/dist/chunk-RRUGQ6DM.js.map +1 -0
- package/dist/chunk-S3ODNMJS.js +2 -0
- package/dist/chunk-S3ODNMJS.js.map +1 -0
- package/dist/{chunk-SAF3B3AX.cjs → chunk-SE6ZCGZ5.cjs} +2 -2
- package/dist/{chunk-SAF3B3AX.cjs.map → chunk-SE6ZCGZ5.cjs.map} +1 -1
- package/dist/chunk-TC23XEAV.js +2 -0
- package/dist/chunk-TC23XEAV.js.map +1 -0
- package/dist/{chunk-FYAMQFZZ.cjs → chunk-TMQ37JQY.cjs} +3 -3
- package/dist/{chunk-FYAMQFZZ.cjs.map → chunk-TMQ37JQY.cjs.map} +1 -1
- package/dist/chunk-TPPM4QSS.cjs +2 -0
- package/dist/chunk-TPPM4QSS.cjs.map +1 -0
- package/dist/chunk-UVHD7BBC.js +3 -0
- package/dist/{chunk-ZDCZ5IDD.js.map → chunk-UVHD7BBC.js.map} +1 -1
- package/dist/{chunk-57PSJQQW.js → chunk-VB6QMU2W.js} +3 -3
- package/dist/chunk-VB6QMU2W.js.map +1 -0
- package/dist/chunk-VQO54ZMA.js +2 -0
- package/dist/chunk-VQO54ZMA.js.map +1 -0
- package/dist/{chunk-7DP57BA7.js → chunk-Y7XRA2EV.js} +2 -2
- package/dist/{chunk-7DP57BA7.js.map → chunk-Y7XRA2EV.js.map} +1 -1
- package/dist/{chunk-5IJD5L3O.cjs → chunk-YBQOQTVL.cjs} +2 -2
- package/dist/chunk-YBQOQTVL.cjs.map +1 -0
- package/dist/{chunk-EL2XUOWX.js → chunk-YG7UWQFV.js} +2 -2
- package/dist/{chunk-EL2XUOWX.js.map → chunk-YG7UWQFV.js.map} +1 -1
- package/dist/chunk-YSHWNCDH.cjs +5 -0
- package/dist/chunk-YSHWNCDH.cjs.map +1 -0
- package/dist/chunk-ZC2NPRLO.js +3 -0
- package/dist/chunk-ZC2NPRLO.js.map +1 -0
- package/dist/{chunk-FYTB7SDP.cjs → chunk-ZDJTDFTR.cjs} +2 -2
- package/dist/{chunk-FYTB7SDP.cjs.map → chunk-ZDJTDFTR.cjs.map} +1 -1
- package/dist/chunk-ZE5KKMBV.cjs +2 -0
- package/dist/chunk-ZE5KKMBV.cjs.map +1 -0
- package/dist/{chunk-4BAUQE6A.cjs → chunk-ZPHUTCJ5.cjs} +3 -3
- package/dist/{chunk-4BAUQE6A.cjs.map → chunk-ZPHUTCJ5.cjs.map} +1 -1
- package/dist/{chunk-GBCN7FNV.cjs → chunk-ZSLVLMO5.cjs} +2 -2
- package/dist/{chunk-GBCN7FNV.cjs.map → chunk-ZSLVLMO5.cjs.map} +1 -1
- package/dist/constants.cjs +1 -1
- package/dist/constants.d.cts +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/engine.cjs +1 -1
- package/dist/engine.d.cts +14 -12
- package/dist/engine.d.ts +14 -12
- package/dist/engine.js +1 -1
- package/dist/errors.cjs +1 -1
- package/dist/errors.d.cts +3 -3
- package/dist/errors.d.ts +3 -3
- package/dist/errors.js +1 -1
- package/dist/format.cjs +1 -1
- package/dist/format.d.cts +4 -3
- package/dist/format.d.ts +4 -3
- package/dist/format.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -13
- package/dist/index.d.ts +15 -13
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/language.d.cts +12 -11
- package/dist/language.d.ts +12 -11
- package/dist/lexer.cjs +1 -1
- package/dist/lexer.d.cts +4 -4
- package/dist/lexer.d.ts +4 -4
- package/dist/lexer.js +1 -1
- package/dist/normalizer.cjs +1 -1
- package/dist/normalizer.d.cts +3 -3
- package/dist/normalizer.d.ts +3 -3
- package/dist/normalizer.js +1 -1
- package/dist/packages.cjs +1 -1
- package/dist/packages.d.cts +11 -10
- package/dist/packages.d.ts +11 -10
- package/dist/packages.js +1 -1
- package/dist/parser.cjs +1 -1
- package/dist/parser.d.cts +5 -4
- package/dist/parser.d.ts +5 -4
- package/dist/parser.js +1 -1
- package/dist/{pipeline-69q2tsLE.d.cts → pipeline-BYkKNpql.d.cts} +1 -1
- package/dist/{pipeline-DTqGLPsV.d.ts → pipeline-Cl7KW8CB.d.ts} +1 -1
- package/dist/resolvers.d.cts +2 -2
- package/dist/resolvers.d.ts +2 -2
- package/dist/temporal.cjs +2 -0
- package/dist/temporal.cjs.map +1 -0
- package/dist/temporal.d.cts +201 -0
- package/dist/temporal.d.ts +201 -0
- package/dist/temporal.js +2 -0
- package/dist/temporal.js.map +1 -0
- package/dist/testing.cjs +2 -2
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.cts +12 -11
- package/dist/testing.d.ts +12 -11
- package/dist/testing.js +1 -1
- package/dist/testing.js.map +1 -1
- package/dist/uom.cjs +1 -1
- package/dist/uom.d.cts +2 -2
- package/dist/uom.d.ts +2 -2
- package/dist/uom.js +1 -1
- package/dist/vm.cjs +1 -1
- package/dist/vm.cjs.map +1 -1
- package/dist/vm.d.cts +8 -56
- package/dist/vm.d.ts +8 -56
- package/dist/vm.js +1 -1
- package/dist/vm.js.map +1 -1
- package/dist/worker.cjs +2 -2
- package/dist/worker.cjs.map +1 -1
- package/dist/worker.d.cts +35 -13
- package/dist/worker.d.ts +35 -13
- package/dist/worker.js +2 -2
- package/dist/worker.js.map +1 -1
- package/package.json +12 -1
- package/dist/chunk-4BRTUFTH.js +0 -2
- package/dist/chunk-4BRTUFTH.js.map +0 -1
- package/dist/chunk-4NZXCHQL.cjs +0 -2
- package/dist/chunk-4NZXCHQL.cjs.map +0 -1
- package/dist/chunk-57PSJQQW.js.map +0 -1
- package/dist/chunk-5IJD5L3O.cjs.map +0 -1
- package/dist/chunk-634ILVMP.cjs +0 -2
- package/dist/chunk-634ILVMP.cjs.map +0 -1
- package/dist/chunk-63ZOOUOL.js +0 -2
- package/dist/chunk-63ZOOUOL.js.map +0 -1
- package/dist/chunk-77KI7AKJ.cjs +0 -2
- package/dist/chunk-77KI7AKJ.cjs.map +0 -1
- package/dist/chunk-7N3IJSWF.js +0 -5
- package/dist/chunk-7N3IJSWF.js.map +0 -1
- package/dist/chunk-DUYTXLO2.js +0 -2
- package/dist/chunk-DUYTXLO2.js.map +0 -1
- package/dist/chunk-IJMNVBIS.js.map +0 -1
- package/dist/chunk-JSM3O7EM.cjs +0 -2
- package/dist/chunk-JSM3O7EM.cjs.map +0 -1
- package/dist/chunk-MZMA32NE.js +0 -3
- package/dist/chunk-MZMA32NE.js.map +0 -1
- package/dist/chunk-N4SSR7Q6.js +0 -2
- package/dist/chunk-N4SSR7Q6.js.map +0 -1
- package/dist/chunk-NMU5E7W7.js +0 -2
- package/dist/chunk-NMU5E7W7.js.map +0 -1
- package/dist/chunk-OB2VX4IL.js +0 -2
- package/dist/chunk-OB2VX4IL.js.map +0 -1
- package/dist/chunk-RAPEZR5L.cjs +0 -2
- package/dist/chunk-RAPEZR5L.cjs.map +0 -1
- package/dist/chunk-SPOVFRZO.cjs +0 -5
- package/dist/chunk-SPOVFRZO.cjs.map +0 -1
- package/dist/chunk-SQHBOWES.cjs +0 -2
- package/dist/chunk-SQHBOWES.cjs.map +0 -1
- package/dist/chunk-UF5XMZTT.js +0 -2
- package/dist/chunk-UF5XMZTT.js.map +0 -1
- package/dist/chunk-UV3EUIBT.cjs +0 -3
- package/dist/chunk-UV3EUIBT.cjs.map +0 -1
- package/dist/chunk-VMSCRVNX.cjs +0 -2
- package/dist/chunk-VMSCRVNX.cjs.map +0 -1
- package/dist/chunk-XBGK3TTU.cjs +0 -3
- package/dist/chunk-XBGK3TTU.cjs.map +0 -1
- package/dist/chunk-XX55RR4Q.js +0 -3
- package/dist/chunk-XX55RR4Q.js.map +0 -1
- package/dist/chunk-YBQPEWT7.cjs.map +0 -1
- package/dist/chunk-ZDCZ5IDD.js +0 -3
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { C as CalendarBackend, a as CalendarFields, Z as ZonedFields } from './CalendarBackend-MdS3Bb4P.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The `Temporal` calendar backend: the engine's date questions answered
|
|
5
|
+
* through a `Temporal` implementation the host supplies, in a time zone the
|
|
6
|
+
* host chooses.
|
|
7
|
+
*
|
|
8
|
+
* `Temporal` is the JavaScript standard library's replacement for `Date`. It
|
|
9
|
+
* ships unflagged in Node 26 and in current Chrome, Firefox and Deno, but not
|
|
10
|
+
* in Safari nor in Node 22 and 24, and the smallest polyfill adds about twenty
|
|
11
|
+
* kilobytes gzipped to a bundle. The engine therefore imports no `Temporal`
|
|
12
|
+
* and no polyfill: this module is reached only through the
|
|
13
|
+
* `solve-engine/temporal` entry, and the host hands it the implementation to
|
|
14
|
+
* use, `globalThis.Temporal` on a runtime that has one or a polyfill's export.
|
|
15
|
+
* A host that never imports the entry pays nothing for it.
|
|
16
|
+
*
|
|
17
|
+
* The backend answers exactly what the `Date` backend answers. That is a
|
|
18
|
+
* design constraint rather than a hope: `Temporal` and `Date` differ in what
|
|
19
|
+
* they do with an out-of-range instant (`RangeError` against `NaN`), a
|
|
20
|
+
* fractional millisecond (a throw against truncation), a day past the end of
|
|
21
|
+
* a month (a clamp or a throw against a roll into the next month) and a year
|
|
22
|
+
* from 0 to 99 (read literally against read as the 1900s), and every one of
|
|
23
|
+
* those is reproduced here the way `Date` does it, because the engine's
|
|
24
|
+
* results are measured against `Date` and a host switching backends must see
|
|
25
|
+
* no result move. The differential suite under `__tests__/temporal/` is what
|
|
26
|
+
* holds that line.
|
|
27
|
+
*
|
|
28
|
+
* The one thing that does change is the zone. `Date` reads the process's own
|
|
29
|
+
* zone and nothing else; this backend reads the zone it was constructed with,
|
|
30
|
+
* so a document can be computed in Tokyo from a server in London, or in a
|
|
31
|
+
* zone the reader picks. That is the capability the backend adds, and the
|
|
32
|
+
* only observable difference.
|
|
33
|
+
*
|
|
34
|
+
* The named-zone display strings go through the same `Intl.DateTimeFormat`
|
|
35
|
+
* helpers the `Date` backend uses (`calendar/IntlZone.ts`), and the zone-free
|
|
36
|
+
* arithmetic through `calendar/Gregorian.ts`, so the two backends share one
|
|
37
|
+
* implementation wherever an answer does not depend on which backend is in
|
|
38
|
+
* use. The one piece of arithmetic `Date` keeps inside its own setters, the
|
|
39
|
+
* normalisation of overflowing fields, is written out in `CivilDays.ts`.
|
|
40
|
+
*
|
|
41
|
+
* @module TemporalCalendar
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The part of a `Temporal.Instant` the backend reads: its epoch milliseconds,
|
|
46
|
+
* and the zoned date-time it shows in a named zone.
|
|
47
|
+
*/
|
|
48
|
+
interface TemporalInstantLike {
|
|
49
|
+
readonly epochMilliseconds: number;
|
|
50
|
+
toZonedDateTimeISO(timeZone: string): TemporalZonedDateTimeLike;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The part of a `Temporal.ZonedDateTime` the backend reads: the calendar
|
|
54
|
+
* fields (a one-based month and an ISO weekday, Monday 1 to Sunday 7, both
|
|
55
|
+
* translated at the boundary), the offset, and the instant.
|
|
56
|
+
*/
|
|
57
|
+
interface TemporalZonedDateTimeLike {
|
|
58
|
+
readonly year: number;
|
|
59
|
+
/** One-based month, 1 is January, as `Temporal` counts. */
|
|
60
|
+
readonly month: number;
|
|
61
|
+
readonly day: number;
|
|
62
|
+
/** ISO weekday: Monday is 1, Sunday is 7. */
|
|
63
|
+
readonly dayOfWeek: number;
|
|
64
|
+
readonly hour: number;
|
|
65
|
+
readonly minute: number;
|
|
66
|
+
readonly second: number;
|
|
67
|
+
readonly millisecond: number;
|
|
68
|
+
/** The zone's offset from UTC at this instant, in nanoseconds, positive when ahead. */
|
|
69
|
+
readonly offsetNanoseconds: number;
|
|
70
|
+
readonly epochMilliseconds: number;
|
|
71
|
+
/** The zone's canonical IANA identifier. */
|
|
72
|
+
readonly timeZoneId: string;
|
|
73
|
+
}
|
|
74
|
+
/** The part of a `Temporal.PlainDateTime` the backend uses: resolving a wall-clock time to an instant in a zone. */
|
|
75
|
+
interface TemporalPlainDateTimeLike {
|
|
76
|
+
toZonedDateTime(timeZone: string, options?: {
|
|
77
|
+
disambiguation?: "compatible" | "earlier" | "later" | "reject";
|
|
78
|
+
}): TemporalZonedDateTimeLike;
|
|
79
|
+
}
|
|
80
|
+
/** The wall-clock fields a `Temporal.PlainDateTime` is built from, with a one-based month. */
|
|
81
|
+
interface TemporalDateTimeFields {
|
|
82
|
+
year: number;
|
|
83
|
+
/** One-based month, 1 is January. */
|
|
84
|
+
month: number;
|
|
85
|
+
day: number;
|
|
86
|
+
hour: number;
|
|
87
|
+
minute: number;
|
|
88
|
+
second: number;
|
|
89
|
+
millisecond: number;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* The subset of the `Temporal` namespace the backend uses, as a structural
|
|
93
|
+
* type, so the engine compiles and ships with no `Temporal` type installed
|
|
94
|
+
* and a host passes whichever implementation it has: `globalThis.Temporal`
|
|
95
|
+
* on Node 26 or a current browser, or the export of a polyfill such as
|
|
96
|
+
* `temporal-polyfill`. Both satisfy this shape as they are.
|
|
97
|
+
*/
|
|
98
|
+
interface TemporalLike {
|
|
99
|
+
readonly Now: {
|
|
100
|
+
instant(): TemporalInstantLike;
|
|
101
|
+
timeZoneId(): string;
|
|
102
|
+
};
|
|
103
|
+
readonly Instant: {
|
|
104
|
+
fromEpochMilliseconds(epochMilliseconds: number): TemporalInstantLike;
|
|
105
|
+
};
|
|
106
|
+
readonly PlainDateTime: {
|
|
107
|
+
from(fields: TemporalDateTimeFields, options?: {
|
|
108
|
+
overflow?: "constrain" | "reject";
|
|
109
|
+
}): TemporalPlainDateTimeLike;
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
/** What {@link createTemporalCalendar} takes beside the implementation. */
|
|
113
|
+
interface TemporalCalendarOptions {
|
|
114
|
+
/**
|
|
115
|
+
* The IANA time zone the engine computes dates in (`"Asia/Tokyo"`,
|
|
116
|
+
* `"UTC"`). Defaults to the runtime's own zone, `Temporal.Now.timeZoneId()`,
|
|
117
|
+
* which is what the `Date` backend reads. A zone the implementation does
|
|
118
|
+
* not know is refused at construction with `TEMPORAL_TIME_ZONE_UNKNOWN`.
|
|
119
|
+
*/
|
|
120
|
+
timeZone?: string;
|
|
121
|
+
/**
|
|
122
|
+
* The clock `now()` reads, in epoch milliseconds. Defaults to
|
|
123
|
+
* `Temporal.Now.instant()`. A test pins a date with this: a fake-timer
|
|
124
|
+
* library replaces `Date.now`, which the `Date` backend reads, but not
|
|
125
|
+
* `Temporal.Now`, so this backend needs telling separately.
|
|
126
|
+
*/
|
|
127
|
+
now?: () => number;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* A {@link CalendarBackend} over a `Temporal` implementation, computing in
|
|
131
|
+
* one named time zone. Build one with {@link createTemporalCalendar}.
|
|
132
|
+
*
|
|
133
|
+
* Every method answers what the `Date` backend answers for the same inputs
|
|
134
|
+
* when the zone is the process's own; see the module comment for the
|
|
135
|
+
* differences between `Temporal` and `Date` that are reproduced deliberately.
|
|
136
|
+
* The local methods answer `NaN` for an instant or a date the backend cannot
|
|
137
|
+
* represent and never throw; the four named-zone methods throw the runtime's
|
|
138
|
+
* `RangeError` for a zone it does not know or an instant it cannot represent,
|
|
139
|
+
* which is the contract the interface states.
|
|
140
|
+
*/
|
|
141
|
+
declare class TemporalCalendar implements CalendarBackend {
|
|
142
|
+
/** The IANA zone every local answer is computed in, in its canonical spelling. */
|
|
143
|
+
readonly timeZone: string;
|
|
144
|
+
private readonly temporal;
|
|
145
|
+
private readonly clock;
|
|
146
|
+
constructor(temporal: TemporalLike, options?: TemporalCalendarOptions);
|
|
147
|
+
now(): number;
|
|
148
|
+
fields(epochMs: number): CalendarFields;
|
|
149
|
+
localMidnight(year: number, month0: number, day: number): number;
|
|
150
|
+
localWallClock(year: number, month0: number, day: number, minutesPastMidnight: number): number;
|
|
151
|
+
addDays(epochMs: number, days: number): number;
|
|
152
|
+
addMonths(epochMs: number, months: number): number;
|
|
153
|
+
utcOffsetMinutes(epochMs: number): number;
|
|
154
|
+
parseIso8601(text: string): number;
|
|
155
|
+
formatLongDate(epochMs: number, locale: string): string;
|
|
156
|
+
formatTimeOfDay(epochMs: number, locale: string): string;
|
|
157
|
+
zoneOffsetMinutes(zone: string, epochMs: number): number;
|
|
158
|
+
fieldsInZone(zone: string, epochMs: number): ZonedFields;
|
|
159
|
+
/** The IANA zone this backend computes in, which is what `CalendarBackend.zone` documents. */
|
|
160
|
+
zone(): string;
|
|
161
|
+
formatTimeInZone(zone: string, epochMs: number): string;
|
|
162
|
+
formatDateInZone(zone: string, epochMs: number): string;
|
|
163
|
+
/** The zoned date-time of an instant, or `null` where `Date` would answer `NaN`. */
|
|
164
|
+
private zoned;
|
|
165
|
+
/**
|
|
166
|
+
* The instant a set of local wall-clock fields names, with the fields
|
|
167
|
+
* normalised the way `Date`'s constructor and setters normalise them
|
|
168
|
+
* (month 12 is next January, day 0 the last of the month before, a year
|
|
169
|
+
* from 0 to 99 the 1900s) before the zone is consulted.
|
|
170
|
+
*/
|
|
171
|
+
private wallClock;
|
|
172
|
+
/**
|
|
173
|
+
* Normalised wall-clock fields resolved to an instant in the backend's
|
|
174
|
+
* zone, clipped to the range `Date` represents only then, as `Date` clips
|
|
175
|
+
* last. `compatible` disambiguation is `Date`'s rule: a time in a
|
|
176
|
+
* spring-forward gap moves later by the gap, and a time that occurs twice
|
|
177
|
+
* on a fall-back day is its first occurrence.
|
|
178
|
+
*/
|
|
179
|
+
private resolve;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* A calendar backend over the host's `Temporal`, for the engine's `calendar`
|
|
183
|
+
* option.
|
|
184
|
+
*
|
|
185
|
+
* ```ts
|
|
186
|
+
* import { createEngine } from "solve-engine";
|
|
187
|
+
* import { createTemporalCalendar } from "solve-engine/temporal";
|
|
188
|
+
*
|
|
189
|
+
* const calendar = createTemporalCalendar(globalThis.Temporal, { timeZone: "Asia/Tokyo" });
|
|
190
|
+
* const engine = createEngine({ calendar });
|
|
191
|
+
* ```
|
|
192
|
+
*
|
|
193
|
+
* @param temporal - The `Temporal` implementation: `globalThis.Temporal` where the runtime ships one, or a polyfill's export.
|
|
194
|
+
* @param options - The zone to compute in and, for a test, the clock to read; see {@link TemporalCalendarOptions}.
|
|
195
|
+
* @returns A backend that computes every date in that zone and answers what the `Date` backend would in it.
|
|
196
|
+
* @throws `TEMPORAL_IMPLEMENTATION_INVALID` when `temporal` lacks the members the backend uses, and
|
|
197
|
+
* `TEMPORAL_TIME_ZONE_UNKNOWN` when the implementation does not know the zone asked for.
|
|
198
|
+
*/
|
|
199
|
+
declare function createTemporalCalendar(temporal: TemporalLike, options?: TemporalCalendarOptions): TemporalCalendar;
|
|
200
|
+
|
|
201
|
+
export { CalendarBackend, CalendarFields, TemporalCalendar, type TemporalCalendarOptions, type TemporalDateTimeFields, type TemporalInstantLike, type TemporalLike, type TemporalPlainDateTimeLike, type TemporalZonedDateTimeLike, ZonedFields, createTemporalCalendar };
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { C as CalendarBackend, a as CalendarFields, Z as ZonedFields } from './CalendarBackend-MdS3Bb4P.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The `Temporal` calendar backend: the engine's date questions answered
|
|
5
|
+
* through a `Temporal` implementation the host supplies, in a time zone the
|
|
6
|
+
* host chooses.
|
|
7
|
+
*
|
|
8
|
+
* `Temporal` is the JavaScript standard library's replacement for `Date`. It
|
|
9
|
+
* ships unflagged in Node 26 and in current Chrome, Firefox and Deno, but not
|
|
10
|
+
* in Safari nor in Node 22 and 24, and the smallest polyfill adds about twenty
|
|
11
|
+
* kilobytes gzipped to a bundle. The engine therefore imports no `Temporal`
|
|
12
|
+
* and no polyfill: this module is reached only through the
|
|
13
|
+
* `solve-engine/temporal` entry, and the host hands it the implementation to
|
|
14
|
+
* use, `globalThis.Temporal` on a runtime that has one or a polyfill's export.
|
|
15
|
+
* A host that never imports the entry pays nothing for it.
|
|
16
|
+
*
|
|
17
|
+
* The backend answers exactly what the `Date` backend answers. That is a
|
|
18
|
+
* design constraint rather than a hope: `Temporal` and `Date` differ in what
|
|
19
|
+
* they do with an out-of-range instant (`RangeError` against `NaN`), a
|
|
20
|
+
* fractional millisecond (a throw against truncation), a day past the end of
|
|
21
|
+
* a month (a clamp or a throw against a roll into the next month) and a year
|
|
22
|
+
* from 0 to 99 (read literally against read as the 1900s), and every one of
|
|
23
|
+
* those is reproduced here the way `Date` does it, because the engine's
|
|
24
|
+
* results are measured against `Date` and a host switching backends must see
|
|
25
|
+
* no result move. The differential suite under `__tests__/temporal/` is what
|
|
26
|
+
* holds that line.
|
|
27
|
+
*
|
|
28
|
+
* The one thing that does change is the zone. `Date` reads the process's own
|
|
29
|
+
* zone and nothing else; this backend reads the zone it was constructed with,
|
|
30
|
+
* so a document can be computed in Tokyo from a server in London, or in a
|
|
31
|
+
* zone the reader picks. That is the capability the backend adds, and the
|
|
32
|
+
* only observable difference.
|
|
33
|
+
*
|
|
34
|
+
* The named-zone display strings go through the same `Intl.DateTimeFormat`
|
|
35
|
+
* helpers the `Date` backend uses (`calendar/IntlZone.ts`), and the zone-free
|
|
36
|
+
* arithmetic through `calendar/Gregorian.ts`, so the two backends share one
|
|
37
|
+
* implementation wherever an answer does not depend on which backend is in
|
|
38
|
+
* use. The one piece of arithmetic `Date` keeps inside its own setters, the
|
|
39
|
+
* normalisation of overflowing fields, is written out in `CivilDays.ts`.
|
|
40
|
+
*
|
|
41
|
+
* @module TemporalCalendar
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The part of a `Temporal.Instant` the backend reads: its epoch milliseconds,
|
|
46
|
+
* and the zoned date-time it shows in a named zone.
|
|
47
|
+
*/
|
|
48
|
+
interface TemporalInstantLike {
|
|
49
|
+
readonly epochMilliseconds: number;
|
|
50
|
+
toZonedDateTimeISO(timeZone: string): TemporalZonedDateTimeLike;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The part of a `Temporal.ZonedDateTime` the backend reads: the calendar
|
|
54
|
+
* fields (a one-based month and an ISO weekday, Monday 1 to Sunday 7, both
|
|
55
|
+
* translated at the boundary), the offset, and the instant.
|
|
56
|
+
*/
|
|
57
|
+
interface TemporalZonedDateTimeLike {
|
|
58
|
+
readonly year: number;
|
|
59
|
+
/** One-based month, 1 is January, as `Temporal` counts. */
|
|
60
|
+
readonly month: number;
|
|
61
|
+
readonly day: number;
|
|
62
|
+
/** ISO weekday: Monday is 1, Sunday is 7. */
|
|
63
|
+
readonly dayOfWeek: number;
|
|
64
|
+
readonly hour: number;
|
|
65
|
+
readonly minute: number;
|
|
66
|
+
readonly second: number;
|
|
67
|
+
readonly millisecond: number;
|
|
68
|
+
/** The zone's offset from UTC at this instant, in nanoseconds, positive when ahead. */
|
|
69
|
+
readonly offsetNanoseconds: number;
|
|
70
|
+
readonly epochMilliseconds: number;
|
|
71
|
+
/** The zone's canonical IANA identifier. */
|
|
72
|
+
readonly timeZoneId: string;
|
|
73
|
+
}
|
|
74
|
+
/** The part of a `Temporal.PlainDateTime` the backend uses: resolving a wall-clock time to an instant in a zone. */
|
|
75
|
+
interface TemporalPlainDateTimeLike {
|
|
76
|
+
toZonedDateTime(timeZone: string, options?: {
|
|
77
|
+
disambiguation?: "compatible" | "earlier" | "later" | "reject";
|
|
78
|
+
}): TemporalZonedDateTimeLike;
|
|
79
|
+
}
|
|
80
|
+
/** The wall-clock fields a `Temporal.PlainDateTime` is built from, with a one-based month. */
|
|
81
|
+
interface TemporalDateTimeFields {
|
|
82
|
+
year: number;
|
|
83
|
+
/** One-based month, 1 is January. */
|
|
84
|
+
month: number;
|
|
85
|
+
day: number;
|
|
86
|
+
hour: number;
|
|
87
|
+
minute: number;
|
|
88
|
+
second: number;
|
|
89
|
+
millisecond: number;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* The subset of the `Temporal` namespace the backend uses, as a structural
|
|
93
|
+
* type, so the engine compiles and ships with no `Temporal` type installed
|
|
94
|
+
* and a host passes whichever implementation it has: `globalThis.Temporal`
|
|
95
|
+
* on Node 26 or a current browser, or the export of a polyfill such as
|
|
96
|
+
* `temporal-polyfill`. Both satisfy this shape as they are.
|
|
97
|
+
*/
|
|
98
|
+
interface TemporalLike {
|
|
99
|
+
readonly Now: {
|
|
100
|
+
instant(): TemporalInstantLike;
|
|
101
|
+
timeZoneId(): string;
|
|
102
|
+
};
|
|
103
|
+
readonly Instant: {
|
|
104
|
+
fromEpochMilliseconds(epochMilliseconds: number): TemporalInstantLike;
|
|
105
|
+
};
|
|
106
|
+
readonly PlainDateTime: {
|
|
107
|
+
from(fields: TemporalDateTimeFields, options?: {
|
|
108
|
+
overflow?: "constrain" | "reject";
|
|
109
|
+
}): TemporalPlainDateTimeLike;
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
/** What {@link createTemporalCalendar} takes beside the implementation. */
|
|
113
|
+
interface TemporalCalendarOptions {
|
|
114
|
+
/**
|
|
115
|
+
* The IANA time zone the engine computes dates in (`"Asia/Tokyo"`,
|
|
116
|
+
* `"UTC"`). Defaults to the runtime's own zone, `Temporal.Now.timeZoneId()`,
|
|
117
|
+
* which is what the `Date` backend reads. A zone the implementation does
|
|
118
|
+
* not know is refused at construction with `TEMPORAL_TIME_ZONE_UNKNOWN`.
|
|
119
|
+
*/
|
|
120
|
+
timeZone?: string;
|
|
121
|
+
/**
|
|
122
|
+
* The clock `now()` reads, in epoch milliseconds. Defaults to
|
|
123
|
+
* `Temporal.Now.instant()`. A test pins a date with this: a fake-timer
|
|
124
|
+
* library replaces `Date.now`, which the `Date` backend reads, but not
|
|
125
|
+
* `Temporal.Now`, so this backend needs telling separately.
|
|
126
|
+
*/
|
|
127
|
+
now?: () => number;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* A {@link CalendarBackend} over a `Temporal` implementation, computing in
|
|
131
|
+
* one named time zone. Build one with {@link createTemporalCalendar}.
|
|
132
|
+
*
|
|
133
|
+
* Every method answers what the `Date` backend answers for the same inputs
|
|
134
|
+
* when the zone is the process's own; see the module comment for the
|
|
135
|
+
* differences between `Temporal` and `Date` that are reproduced deliberately.
|
|
136
|
+
* The local methods answer `NaN` for an instant or a date the backend cannot
|
|
137
|
+
* represent and never throw; the four named-zone methods throw the runtime's
|
|
138
|
+
* `RangeError` for a zone it does not know or an instant it cannot represent,
|
|
139
|
+
* which is the contract the interface states.
|
|
140
|
+
*/
|
|
141
|
+
declare class TemporalCalendar implements CalendarBackend {
|
|
142
|
+
/** The IANA zone every local answer is computed in, in its canonical spelling. */
|
|
143
|
+
readonly timeZone: string;
|
|
144
|
+
private readonly temporal;
|
|
145
|
+
private readonly clock;
|
|
146
|
+
constructor(temporal: TemporalLike, options?: TemporalCalendarOptions);
|
|
147
|
+
now(): number;
|
|
148
|
+
fields(epochMs: number): CalendarFields;
|
|
149
|
+
localMidnight(year: number, month0: number, day: number): number;
|
|
150
|
+
localWallClock(year: number, month0: number, day: number, minutesPastMidnight: number): number;
|
|
151
|
+
addDays(epochMs: number, days: number): number;
|
|
152
|
+
addMonths(epochMs: number, months: number): number;
|
|
153
|
+
utcOffsetMinutes(epochMs: number): number;
|
|
154
|
+
parseIso8601(text: string): number;
|
|
155
|
+
formatLongDate(epochMs: number, locale: string): string;
|
|
156
|
+
formatTimeOfDay(epochMs: number, locale: string): string;
|
|
157
|
+
zoneOffsetMinutes(zone: string, epochMs: number): number;
|
|
158
|
+
fieldsInZone(zone: string, epochMs: number): ZonedFields;
|
|
159
|
+
/** The IANA zone this backend computes in, which is what `CalendarBackend.zone` documents. */
|
|
160
|
+
zone(): string;
|
|
161
|
+
formatTimeInZone(zone: string, epochMs: number): string;
|
|
162
|
+
formatDateInZone(zone: string, epochMs: number): string;
|
|
163
|
+
/** The zoned date-time of an instant, or `null` where `Date` would answer `NaN`. */
|
|
164
|
+
private zoned;
|
|
165
|
+
/**
|
|
166
|
+
* The instant a set of local wall-clock fields names, with the fields
|
|
167
|
+
* normalised the way `Date`'s constructor and setters normalise them
|
|
168
|
+
* (month 12 is next January, day 0 the last of the month before, a year
|
|
169
|
+
* from 0 to 99 the 1900s) before the zone is consulted.
|
|
170
|
+
*/
|
|
171
|
+
private wallClock;
|
|
172
|
+
/**
|
|
173
|
+
* Normalised wall-clock fields resolved to an instant in the backend's
|
|
174
|
+
* zone, clipped to the range `Date` represents only then, as `Date` clips
|
|
175
|
+
* last. `compatible` disambiguation is `Date`'s rule: a time in a
|
|
176
|
+
* spring-forward gap moves later by the gap, and a time that occurs twice
|
|
177
|
+
* on a fall-back day is its first occurrence.
|
|
178
|
+
*/
|
|
179
|
+
private resolve;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* A calendar backend over the host's `Temporal`, for the engine's `calendar`
|
|
183
|
+
* option.
|
|
184
|
+
*
|
|
185
|
+
* ```ts
|
|
186
|
+
* import { createEngine } from "solve-engine";
|
|
187
|
+
* import { createTemporalCalendar } from "solve-engine/temporal";
|
|
188
|
+
*
|
|
189
|
+
* const calendar = createTemporalCalendar(globalThis.Temporal, { timeZone: "Asia/Tokyo" });
|
|
190
|
+
* const engine = createEngine({ calendar });
|
|
191
|
+
* ```
|
|
192
|
+
*
|
|
193
|
+
* @param temporal - The `Temporal` implementation: `globalThis.Temporal` where the runtime ships one, or a polyfill's export.
|
|
194
|
+
* @param options - The zone to compute in and, for a test, the clock to read; see {@link TemporalCalendarOptions}.
|
|
195
|
+
* @returns A backend that computes every date in that zone and answers what the `Date` backend would in it.
|
|
196
|
+
* @throws `TEMPORAL_IMPLEMENTATION_INVALID` when `temporal` lacks the members the backend uses, and
|
|
197
|
+
* `TEMPORAL_TIME_ZONE_UNKNOWN` when the implementation does not know the zone asked for.
|
|
198
|
+
*/
|
|
199
|
+
declare function createTemporalCalendar(temporal: TemporalLike, options?: TemporalCalendarOptions): TemporalCalendar;
|
|
200
|
+
|
|
201
|
+
export { CalendarBackend, CalendarFields, TemporalCalendar, type TemporalCalendarOptions, type TemporalDateTimeFields, type TemporalInstantLike, type TemporalLike, type TemporalPlainDateTimeLike, type TemporalZonedDateTimeLike, ZonedFields, createTemporalCalendar };
|
package/dist/temporal.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"temporal.js"}
|
package/dist/testing.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict';var
|
|
1
|
+
'use strict';var chunkYSHWNCDH_cjs=require('./chunk-YSHWNCDH.cjs');require('./chunk-2SYYKQ4Q.cjs'),require('./chunk-NGBBNL4K.cjs'),require('./chunk-ZVPZQ66D.cjs'),require('./chunk-TTFO4YDP.cjs'),require('./chunk-GVL3ZMS7.cjs'),require('./chunk-HG4NPDN5.cjs'),require('./chunk-AZX4NTYN.cjs'),require('./chunk-R2SZFJTT.cjs');var chunkDFMAZ6XM_cjs=require('./chunk-DFMAZ6XM.cjs');require('./chunk-G2V33LFM.cjs'),require('./chunk-7RC6RBS6.cjs'),require('./chunk-ZDJTDFTR.cjs'),require('./chunk-ZSLVLMO5.cjs'),require('./chunk-UURM7P3P.cjs'),require('./chunk-ZLRJ7TDP.cjs'),require('./chunk-QQHHZPEW.cjs'),require('./chunk-ZE5KKMBV.cjs'),require('./chunk-TMQ37JQY.cjs'),require('./chunk-ABVDKMNF.cjs'),require('./chunk-TLG7VZRX.cjs'),require('./chunk-5TVI2UPZ.cjs'),require('./chunk-FDKTESBC.cjs'),require('./chunk-TPPM4QSS.cjs'),require('./chunk-E4HAKNBQ.cjs');var chunkGJZIJK2Q_cjs=require('./chunk-GJZIJK2Q.cjs');require('./chunk-ZKFCKAIX.cjs');var chunkO5PO4D2A_cjs=require('./chunk-O5PO4D2A.cjs');require('./chunk-CQLCTKMX.cjs'),require('./chunk-Y7O4D3BJ.cjs'),require('./chunk-6EYKVQT3.cjs'),require('./chunk-YBQOQTVL.cjs'),require('./chunk-S3DFU33X.cjs'),require('./chunk-J4LSAHCY.cjs'),require('./chunk-EZKR44MA.cjs');var chunkGXO7TSXQ_cjs=require('./chunk-GXO7TSXQ.cjs');var i=class o extends Error{constructor(t){super(t.message),this.name="ExpectationError",this.code=t.code,this.expected=t.expected,this.actual=t.actual,Object.setPrototypeOf(this,o.prototype);}};function V(o=[],t={}){let{locale:e="en",includeBuiltins:r=true}=t,s=new chunkYSHWNCDH_cjs.n({locale:e,packages:r?chunkDFMAZ6XM_cjs.z:[]});for(let a of o)s.registerPackage(a);return s}function v(o,t){try{let e=o.evaluateExpression(t);return e.isError()?{status:"error",code:e.errorCode??"",message:e.errorMessage??"",source:e}:e.isPending()?{status:"pending",value:e}:{status:"value",value:e}}catch(e){if(e instanceof chunkGXO7TSXQ_cjs.b)return {status:"error",code:e.code,message:e.message,source:e};let r=e instanceof Error?e.message:String(e);return {status:"error",code:"UNKNOWN_ERROR",message:r,source:new chunkGJZIJK2Q_cjs.m(13,"UNKNOWN_ERROR",r)}}}function x(o,t){if(Object.is(o,t))return true;if(!Number.isFinite(o)||!Number.isFinite(t))return false;let e=1e-9*Math.max(1,Math.abs(o),Math.abs(t));return Math.abs(o-t)<=e}function l(o){return o.type===3?JSON.stringify(o.value):o.type===6&&typeof o.unit=="string"?`${String(o.value)} ${o.unit}`:String(o.value)}function n(o){switch(o.status){case "value":return l(o.value);case "pending":return "a pending async value";case "error":return `an error (${o.code}: ${o.message})`}}var d=class{constructor(t,e){this.expression=t;this.outcome=e;}get value(){if(this.outcome.status==="error")throw new i({code:"EXPECTED_VALUE",message:`Expected "${this.expression}" to evaluate, but it failed with ${n(this.outcome)}.`,expected:"a resolved value",actual:n(this.outcome)});return this.outcome.value}toEvaluate(){if(this.outcome.status!=="value")throw new i({code:"EXPECTED_EVALUATE",message:`Expected "${this.expression}" to evaluate to a value, but got ${n(this.outcome)}.`,expected:"a resolved value",actual:n(this.outcome)});return this}toEqual(t,e){if(this.outcome.status!=="value")throw new i({code:"EXPECTED_EQUAL",message:`Expected "${this.expression}" to equal ${c(t,e)}, but got ${n(this.outcome)}.`,expected:c(t,e),actual:n(this.outcome)});let r=this.outcome.value,s;if(typeof t=="number"?s=x(r.toNumber(),t):typeof t=="boolean"?s=r.type===10&&r.value===t:s=C(r)===t,!s)throw new i({code:"EXPECTED_EQUAL",message:`Expected "${this.expression}" to equal ${c(t,e)}, but it was ${l(r)}.`,expected:c(t,e),actual:l(r)});if(e!==void 0&&r.unit!==e)throw new i({code:"EXPECTED_UNIT",message:`Expected "${this.expression}" to carry the unit "${e}", but it was ${r.unit===void 0?"unitless":`"${r.unit}"`}.`,expected:`unit "${e}"`,actual:r.unit===void 0?"no unit":`unit "${r.unit}"`});return this}toBeError(){if(this.outcome.status!=="error")throw new i({code:"EXPECTED_ERROR",message:`Expected "${this.expression}" to fail, but it produced ${n(this.outcome)}.`,expected:"an error",actual:n(this.outcome)});return this}toFailWith(t){if(this.outcome.status!=="error")throw new i({code:"EXPECTED_FAIL_WITH",message:`Expected "${this.expression}" to fail with "${t}", but it produced ${n(this.outcome)}.`,expected:`error code "${t}"`,actual:n(this.outcome)});if(this.outcome.code!==t)throw new i({code:"EXPECTED_FAIL_WITH",message:`Expected "${this.expression}" to fail with "${t}", but it failed with "${this.outcome.code}" (${this.outcome.message}).`,expected:`error code "${t}"`,actual:`error code "${this.outcome.code}"`});return this}toBePending(){if(this.outcome.status!=="pending")throw new i({code:"EXPECTED_PENDING",message:`Expected "${this.expression}" to be pending, but got ${n(this.outcome)}.`,expected:"a pending async value",actual:n(this.outcome)});return this}};function c(o,t){let e=typeof o=="string"?JSON.stringify(o):String(o);return t===void 0?e:`${e} ${t}`}function C(o){return String(o.value)}function D(o,t){return new d(t,v(o,t))}var O=["a","an","and","or","but","if","then","the","this","that","these","those","in","on","at","to","of","for","from","with","by","as","per","into","over","is","are","was","were","be","been","being","do","does","did","have","has","had","will","would","can","could","should","may","might","must","price","cost","value","total","sum","count","rate","amount","number","time","date","day","week","month","year","hour","minute","second","add","buy","sell","hold","make","take","give","get","set","run","up","down","out","off","all","some","any","no","not","more","less","one","two","three","first","last","next","each","every","here","there"],$=["error","warning","info"];function k(o){let t=[],e=o.lexerVocabulary;if(e?.keywords)for(let[r,s]of Object.entries(e.keywords))t.push({word:r,via:"keyword",tokenType:s});if(e?.units)for(let r of e.units)t.push({word:r,via:"unit"});if(e?.operators)for(let[r,s]of Object.entries(e.operators))t.push({word:r,via:"operator",tokenType:s});if(o.phrases)for(let[r,s]of Object.entries(o.phrases))r.includes(" ")||t.push({word:r,via:"phrase",tokenType:s});return t}var p=class{constructor(t){this.pkg=t;}notToShadow(t=O){let e=new Set(t.map(s=>s.toLowerCase())),r=k(this.pkg).filter(s=>e.has(s.word.toLowerCase()));if(r.length>0){let s=r.map(a=>`"${a.word}" (${a.via})`).join(", ");throw new i({code:"PACKAGE_SHADOWS_PROSE",message:`Package "${this.pkg.name}" claims prose word(s) as syntax: ${s}. A word that is also ordinary English turns prose into arithmetic; prefer a multi-word phrase or a form that requires a parenthesis.`,expected:"no prose words claimed as syntax",actual:s})}return r}notToCollideWith(t,e="error"){let r=chunkYSHWNCDH_cjs.a(this.pkg,t),s=$.indexOf(e),a=r.conflicts.filter(u=>$.indexOf(u.severity)<=s);if(a.length>0){let u=a.map(g=>`[${g.severity}] ${g.detail}`).join(`
|
|
2
2
|
`);throw new i({code:"PACKAGE_VOCABULARY_COLLISION",message:`Package "${this.pkg.name}" collides with another package:
|
|
3
|
-
${u}`,expected:`no conflicts at or above "${e}" severity`,actual:`${a.length} conflict(s)`})}return r}toDeclareCompatibleEngineVersion(t=
|
|
3
|
+
${u}`,expected:`no conflicts at or above "${e}" severity`,actual:`${a.length} conflict(s)`})}return r}toDeclareCompatibleEngineVersion(t=chunkO5PO4D2A_cjs.a){let e=chunkYSHWNCDH_cjs.b(this.pkg,t);if(!e.compatible){let r=e.reason==="invalid-range"?`its range "${e.declaredRange}" is not valid semver`:`its range "${e.declaredRange}" is not satisfied by engine version "${e.engineVersion}"`;throw new i({code:"PACKAGE_ENGINE_VERSION_INCOMPATIBLE",message:`Package "${this.pkg.name}" declares an engineVersion that will be rejected at registration: ${r}.`,expected:`an engineVersion satisfied by "${t}"`,actual:`"${e.declaredRange}"`})}return this}};function L(o){return new p(o)}exports.COMMON_PROSE_WORDS=O;exports.ExpectationError=i;exports.ExpressionAssertion=d;exports.PackageAssertion=p;exports.createTestEngine=V;exports.expectExpression=D;exports.expectPackage=L;//# sourceMappingURL=testing.cjs.map
|
|
4
4
|
//# sourceMappingURL=testing.cjs.map
|