@nubjs/types 0.7.2 → 0.7.3

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/index.d.ts CHANGED
@@ -1,833 +1,9 @@
1
- // @nubjs/types — ambient declarations for code authored against the Nub runtime.
2
- //
3
- // Nub augments Node with surfaces TypeScript doesn't know about. This package
4
- // makes that nub-authored code typecheck so the parity bar holds: "if `tsc
5
- // --noEmit` accepts your code, nub runs it."
6
- //
7
- // Only declares surfaces that @types/node does NOT already cover. Everything Nub
8
- // merely flag-enables (URLPattern, WebSocket, EventSource, navigator.locks,
9
- // localStorage/sessionStorage, node:sqlite, Float16Array, RegExp.escape, …) is
10
- // already typed by @types/node + TypeScript's bundled libs and is intentionally
11
- // absent here. Add this package to a tsconfig with `types: ["node", "@nubjs/types"]`.
12
- //
13
- // MUST remain a global *script* file: NO top-level `import`/`export`. The wildcard
14
- // `declare module "*.yaml"` declarations are only visible project-wide from a
15
- // script file. (Adding `export {}` turns this into a module and silently breaks
16
- // the data-import wildcards.) Globals are declared bare (`declare function …`,
17
- // `declare var …`, `declare namespace …`) for the same reason.
18
-
19
- // ── Data-format module imports (Nub load hook; wiki/runtime/data-loaders.md) ──
20
- // Default export ONLY — data modules expose no named exports (a named import
21
- // like `import { host } from "./c.yaml"` is a load-time error on nub, the same
22
- // as Node's JSON modules). The object formats default to `Record<string,
23
- // unknown>` so the default can be destructured with sound `unknown` keys —
24
- // `import cfg from "./c.yaml"; const { host, port } = cfg;` gives `host`/`port:
25
- // unknown`. This is the sound, typeable equivalent of named imports.
26
- //
27
- // CAVEAT: a top-level array or scalar (e.g. a YAML document whose root is a list
28
- // or a bare string) is mistyped as a record by `Record<string, unknown>`; cast
29
- // the default in that case (`import data from "./list.yaml"; const items = data
30
- // as unknown as string[];`). `.txt` is always a `string`; `.json` is
31
- // intentionally NOT declared — it's Node-native (resolveJsonModule).
32
- declare module "*.yaml" {
33
- const data: Record<string, unknown>;
34
- export default data;
35
- }
36
- declare module "*.yml" {
37
- const data: Record<string, unknown>;
38
- export default data;
39
- }
40
- declare module "*.toml" {
41
- const data: Record<string, unknown>;
42
- export default data;
43
- }
44
- declare module "*.jsonc" {
45
- const data: Record<string, unknown>;
46
- export default data;
47
- }
48
- declare module "*.json5" {
49
- const data: Record<string, unknown>;
50
- export default data;
51
- }
52
- declare module "*.txt" {
53
- const data: string;
54
- export default data;
55
- }
56
-
57
- // ── reportError (WinterTC min-common-API; runtime/polyfills.cjs) ──
58
- // In no Node version, in no @types/node. Nub installs it on every supported version.
59
- declare function reportError(error: unknown): void;
60
-
61
- // ── lib.dom step-aside helpers (idiom from bun-types: packages/bun-types/bun.d.ts) ──
62
- // These two ambient *type* aliases let us declare DOM-overlapping globals (today
63
- // just `Worker`) WITHOUT colliding (TS2403/TS2430) when the consumer ALSO has them
64
- // globally — e.g. `lib: ["dom"]`, or any other lib that declares `Worker`. They
65
- // are pure type-level helpers: a global *script* may declare ambient `type`s
66
- // freely (only a top-level `import`/`export` would turn this into a module), so
67
- // this does NOT break the wildcard `declare module "*.yaml"` decls above.
68
- //
69
- // `__NubLibDomIsLoaded` — lib.dom defines the global `onabort`; its presence is the
70
- // signal that DOM is loaded, so the DOM owns these globals and we must step aside.
71
- // `__NubUseLibDomIfAvailable<K, T>` — when DOM is loaded, adopt whatever type
72
- // `globalThis` already has for key K; otherwise fall back to our own shape T. This
73
- // is exactly Bun's `Bun.__internal.{LibDomIsLoaded,UseLibDomIfAvailable}`, recast
74
- // as bare ambient globals (with a `__Nub` prefix) so the file stays a script.
75
- type __NubLibDomIsLoaded = typeof globalThis extends { onabort: any } ? true : false;
76
- type __NubUseLibDomIfAvailable<GlobalThisKeyName extends PropertyKey, Otherwise> =
77
- __NubLibDomIsLoaded extends true
78
- ? typeof globalThis extends { [K in GlobalThisKeyName]: infer T }
79
- ? T
80
- : Otherwise
81
- : Otherwise;
82
-
83
- // ── Browser-shape Worker global (runtime/worker-polyfill.mjs; wiki/runtime/web-worker.md) ──
84
- // Nub ships the WHATWG/browser subset of `Worker` over node:worker_threads.Worker.
85
- // @types/node has NO global `Worker` (only node:worker_threads' class), so this is
86
- // the genuine gap. `MessageEvent`, `ErrorEvent`, and `MessagePort` are ALREADY
87
- // global in @types/node>=25 (web-globals/fetch.d.ts + messaging.d.ts) — verified
88
- // empirically — so they are referenced from there and intentionally NOT redeclared
89
- // here (redeclaring them collides: TS2403).
90
- //
91
- // Step-aside: when `lib: ["dom"]` is in play, the DOM's own `Worker` wins — the
92
- // interface body resolves to `{}` (via `__NubLibWorkerOrNubWorker`) and our `var`
93
- // adopts the DOM type (via `__NubUseLibDomIfAvailable`), so the two coexist with
94
- // NO TS2403/TS2430 collision. When DOM is absent (the normal Node case), our full
95
- // browser-shape declaration applies unchanged.
96
- interface WorkerOptions {
97
- type?: "module" | "classic";
98
- name?: string;
99
- credentials?: "omit" | "same-origin" | "include";
100
- // `eval: true` runs the constructor's first argument as the worker's source
101
- // (Node's worker_threads inline form) instead of resolving it as a URL.
102
- eval?: true;
103
- }
104
- interface __NubWorker extends EventTarget {
105
- readonly name: string;
106
- postMessage(message: any, transfer?: readonly (ArrayBuffer | MessagePort)[]): void;
107
- // Returns the underlying worker_threads `Promise<exitCode>` (additive
108
- // void→value widening; spec code that ignores the return is unaffected).
109
- terminate(): Promise<number>;
110
- onmessage: ((this: Worker, ev: MessageEvent) => any) | null;
111
- onmessageerror: ((this: Worker, ev: MessageEvent) => any) | null;
112
- onerror: ((this: Worker, ev: ErrorEvent) => any) | null;
113
- // node:worker_threads EventEmitter surface, delegated to the underlying real
114
- // Worker. The node channel carries Node's shapes — `message` the RAW posted
115
- // value, `error` a bare `Error`, `exit` the numeric exit code, `online` no arg —
116
- // distinct from the web channel above (`MessageEvent`/`ErrorEvent`). The adders
117
- // return the handle for chaining.
118
- on(event: "message", listener: (value: any) => void): this;
119
- on(event: "messageerror", listener: (error: Error) => void): this;
120
- on(event: "error", listener: (err: Error) => void): this;
121
- on(event: "exit", listener: (exitCode: number) => void): this;
122
- on(event: "online", listener: () => void): this;
123
- on(event: string | symbol, listener: (...args: any[]) => void): this;
124
- once(event: "message", listener: (value: any) => void): this;
125
- once(event: "messageerror", listener: (error: Error) => void): this;
126
- once(event: "error", listener: (err: Error) => void): this;
127
- once(event: "exit", listener: (exitCode: number) => void): this;
128
- once(event: "online", listener: () => void): this;
129
- once(event: string | symbol, listener: (...args: any[]) => void): this;
130
- addListener(event: "message", listener: (value: any) => void): this;
131
- addListener(event: "messageerror", listener: (error: Error) => void): this;
132
- addListener(event: "error", listener: (err: Error) => void): this;
133
- addListener(event: "exit", listener: (exitCode: number) => void): this;
134
- addListener(event: "online", listener: () => void): this;
135
- addListener(event: string | symbol, listener: (...args: any[]) => void): this;
136
- off(event: string | symbol, listener: (...args: any[]) => void): this;
137
- removeListener(event: string | symbol, listener: (...args: any[]) => void): this;
138
- emit(event: string | symbol, ...args: any[]): boolean;
139
- }
140
- type __NubLibWorkerOrNubWorker = __NubLibDomIsLoaded extends true ? {} : __NubWorker;
141
- interface Worker extends __NubLibWorkerOrNubWorker {}
142
- declare var Worker: __NubUseLibDomIfAvailable<
143
- "Worker",
144
- {
145
- prototype: Worker;
146
- new (scriptURL: string | URL, options?: WorkerOptions): Worker;
147
- }
148
- >;
149
-
150
- // ── import.meta.hot (Vite-compatible; wiki/runtime/hot-mode.md — v0.x, shape committed v0.1) ──
151
- // Forward-compat commitment: ships now so framework authors can code against the
152
- // shape. `import.meta.hot` is `undefined` unless `nub watch --hot` is active.
153
- interface ImportMeta {
154
- readonly hot?: {
155
- readonly data: Record<string, any>;
156
- accept(): void;
157
- accept(cb: (mod: any) => void): void;
158
- accept(dep: string, cb: (mod: any) => void): void;
159
- accept(deps: readonly string[], cb: (mods: any[]) => void): void;
160
- dispose(cb: (data: Record<string, any>) => void): void;
161
- invalidate(): void;
162
- on(event: string, cb: (data: any) => void): void;
163
- send(event: string, data?: any): void;
164
- };
165
- }
166
-
167
- // ── Promise.allKeyed / Promise.allSettledKeyed (TC39 "await dictionary", Stage 3;
168
- // runtime/polyfills.cjs) ──
169
- // In no engine, in no @types/node, in no TypeScript lib. The mapped types mirror
170
- // the proposal README's own signatures: the key set is preserved and each value is
171
- // `Awaited`. Two runtime facts TypeScript cannot express — the result object has a
172
- // null prototype, and its keys are the argument's own ENUMERABLE keys (so a
173
- // non-enumerable or inherited property is absent at runtime while `keyof` still
174
- // includes it). Neither affects the destructuring this API exists for.
175
- interface PromiseConstructor {
176
- allKeyed<T extends object>(promises: T): Promise<{ -readonly [K in keyof T]: Awaited<T[K]> }>;
177
- allSettledKeyed<T extends object>(
178
- promises: T,
179
- ): Promise<{ -readonly [K in keyof T]: PromiseSettledResult<Awaited<T[K]>> }>;
180
- }
181
-
182
- // ── Date.prototype.toTemporalInstant (runtime/preload-common.cjs installs it) ──
183
- // Nub assigns the polyfill's `toTemporalInstant` onto Date.prototype on the floor
184
- // (matching native Node, which ships it once Temporal is native).
185
- interface Date {
186
- toTemporalInstant(): Temporal.Instant;
187
- }
188
-
189
- // ── Temporal (vendored @js-temporal/polyfill@0.5.1; runtime/preload-common.cjs) ──
190
- // In no Node version, in no @types/node. The namespace below is inlined verbatim
191
- // from @js-temporal/polyfill@0.5.1's index.d.ts (the version Nub bundles), with
192
- // `export` markers stripped so it is an ambient global rather than a module export.
193
- // Keep in sync with the bundled polyfill version on every bump.
194
- declare namespace Temporal {
195
- type ComparisonResult = -1 | 0 | 1;
196
- type RoundingMode =
197
- | "ceil"
198
- | "floor"
199
- | "expand"
200
- | "trunc"
201
- | "halfCeil"
202
- | "halfFloor"
203
- | "halfExpand"
204
- | "halfTrunc"
205
- | "halfEven";
206
-
207
- type AssignmentOptions = {
208
- overflow?: "constrain" | "reject";
209
- };
210
-
211
- type DurationOptions = {
212
- overflow?: "constrain" | "balance";
213
- };
214
-
215
- type ToInstantOptions = {
216
- disambiguation?: "compatible" | "earlier" | "later" | "reject";
217
- };
218
-
219
- type OffsetDisambiguationOptions = {
220
- offset?: "use" | "prefer" | "ignore" | "reject";
221
- };
222
-
223
- type ZonedDateTimeAssignmentOptions = Partial<
224
- AssignmentOptions & ToInstantOptions & OffsetDisambiguationOptions
225
- >;
226
-
227
- type ArithmeticOptions = {
228
- overflow?: "constrain" | "reject";
229
- };
230
-
231
- type DateUnit = "year" | "month" | "week" | "day";
232
- type TimeUnit = "hour" | "minute" | "second" | "millisecond" | "microsecond" | "nanosecond";
233
- type DateTimeUnit = DateUnit | TimeUnit;
234
-
235
- type PluralUnit<T extends DateTimeUnit> = {
236
- year: "years";
237
- month: "months";
238
- week: "weeks";
239
- day: "days";
240
- hour: "hours";
241
- minute: "minutes";
242
- second: "seconds";
243
- millisecond: "milliseconds";
244
- microsecond: "microseconds";
245
- nanosecond: "nanoseconds";
246
- }[T];
247
-
248
- type LargestUnit<T extends DateTimeUnit> = "auto" | T | PluralUnit<T>;
249
- type SmallestUnit<T extends DateTimeUnit> = T | PluralUnit<T>;
250
- type TotalUnit<T extends DateTimeUnit> = T | PluralUnit<T>;
251
-
252
- type ToStringPrecisionOptions = {
253
- fractionalSecondDigits?: "auto" | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
254
- smallestUnit?: SmallestUnit<"minute" | "second" | "millisecond" | "microsecond" | "nanosecond">;
255
- roundingMode?: RoundingMode;
256
- };
257
-
258
- type ShowCalendarOption = {
259
- calendarName?: "auto" | "always" | "never" | "critical";
260
- };
261
-
262
- type CalendarTypeToStringOptions = Partial<ToStringPrecisionOptions & ShowCalendarOption>;
263
-
264
- type ZonedDateTimeToStringOptions = Partial<
265
- CalendarTypeToStringOptions & {
266
- timeZoneName?: "auto" | "never" | "critical";
267
- offset?: "auto" | "never";
268
- }
269
- >;
270
-
271
- type InstantToStringOptions = Partial<
272
- ToStringPrecisionOptions & {
273
- timeZone: TimeZoneLike;
274
- }
275
- >;
276
-
277
- interface DifferenceOptions<T extends DateTimeUnit> {
278
- smallestUnit?: SmallestUnit<T>;
279
- largestUnit?: LargestUnit<T>;
280
- roundingIncrement?: number;
281
- roundingMode?: RoundingMode;
282
- }
283
-
284
- type RoundTo<T extends DateTimeUnit> =
285
- | SmallestUnit<T>
286
- | {
287
- smallestUnit: SmallestUnit<T>;
288
- roundingIncrement?: number;
289
- roundingMode?: RoundingMode;
290
- };
291
-
292
- type DurationRoundTo =
293
- | SmallestUnit<DateTimeUnit>
294
- | ((
295
- | {
296
- smallestUnit: SmallestUnit<DateTimeUnit>;
297
- largestUnit?: LargestUnit<DateTimeUnit>;
298
- }
299
- | {
300
- smallestUnit?: SmallestUnit<DateTimeUnit>;
301
- largestUnit: LargestUnit<DateTimeUnit>;
302
- }
303
- ) & {
304
- roundingIncrement?: number;
305
- roundingMode?: RoundingMode;
306
- relativeTo?:
307
- | Temporal.PlainDateTime
308
- | Temporal.ZonedDateTime
309
- | PlainDateTimeLike
310
- | ZonedDateTimeLike
311
- | string;
312
- });
313
-
314
- type DurationTotalOf =
315
- | TotalUnit<DateTimeUnit>
316
- | {
317
- unit: TotalUnit<DateTimeUnit>;
318
- relativeTo?:
319
- | Temporal.ZonedDateTime
320
- | Temporal.PlainDateTime
321
- | ZonedDateTimeLike
322
- | PlainDateTimeLike
323
- | string;
324
- };
325
-
326
- interface DurationArithmeticOptions {
327
- relativeTo?:
328
- | Temporal.ZonedDateTime
329
- | Temporal.PlainDateTime
330
- | ZonedDateTimeLike
331
- | PlainDateTimeLike
332
- | string;
333
- }
334
-
335
- type TransitionDirection = "next" | "previous" | { direction: "next" | "previous" };
336
-
337
- type LocalesArgument = ConstructorParameters<typeof Intl.DateTimeFormat>[0];
338
- type DurationFormatOptions = typeof Intl extends { DurationFormat: any }
339
- ? ConstructorParameters<(typeof Intl)["DurationFormat"]>[1]
340
- : Record<string, unknown>;
341
-
342
- type DurationLike = {
343
- years?: number;
344
- months?: number;
345
- weeks?: number;
346
- days?: number;
347
- hours?: number;
348
- minutes?: number;
349
- seconds?: number;
350
- milliseconds?: number;
351
- microseconds?: number;
352
- nanoseconds?: number;
353
- };
354
-
355
- class Duration {
356
- static from(item: Temporal.Duration | DurationLike | string): Temporal.Duration;
357
- static compare(
358
- one: Temporal.Duration | DurationLike | string,
359
- two: Temporal.Duration | DurationLike | string,
360
- options?: DurationArithmeticOptions
361
- ): ComparisonResult;
362
- constructor(
363
- years?: number,
364
- months?: number,
365
- weeks?: number,
366
- days?: number,
367
- hours?: number,
368
- minutes?: number,
369
- seconds?: number,
370
- milliseconds?: number,
371
- microseconds?: number,
372
- nanoseconds?: number
373
- );
374
- readonly sign: -1 | 0 | 1;
375
- readonly blank: boolean;
376
- readonly years: number;
377
- readonly months: number;
378
- readonly weeks: number;
379
- readonly days: number;
380
- readonly hours: number;
381
- readonly minutes: number;
382
- readonly seconds: number;
383
- readonly milliseconds: number;
384
- readonly microseconds: number;
385
- readonly nanoseconds: number;
386
- negated(): Temporal.Duration;
387
- abs(): Temporal.Duration;
388
- with(durationLike: DurationLike): Temporal.Duration;
389
- add(other: Temporal.Duration | DurationLike | string): Temporal.Duration;
390
- subtract(other: Temporal.Duration | DurationLike | string): Temporal.Duration;
391
- round(roundTo: DurationRoundTo): Temporal.Duration;
392
- total(totalOf: DurationTotalOf): number;
393
- toLocaleString(locales?: LocalesArgument, options?: DurationFormatOptions): string;
394
- toJSON(): string;
395
- toString(options?: ToStringPrecisionOptions): string;
396
- valueOf(): never;
397
- readonly [Symbol.toStringTag]: "Temporal.Duration";
398
- }
399
-
400
- class Instant {
401
- static fromEpochMilliseconds(epochMilliseconds: number): Temporal.Instant;
402
- static fromEpochNanoseconds(epochNanoseconds: bigint): Temporal.Instant;
403
- static from(item: Temporal.Instant | string): Temporal.Instant;
404
- static compare(one: Temporal.Instant | string, two: Temporal.Instant | string): ComparisonResult;
405
- constructor(epochNanoseconds: bigint);
406
- readonly epochMilliseconds: number;
407
- readonly epochNanoseconds: bigint;
408
- equals(other: Temporal.Instant | string): boolean;
409
- add(
410
- durationLike: Omit<Temporal.Duration | DurationLike, "years" | "months" | "weeks" | "days"> | string
411
- ): Temporal.Instant;
412
- subtract(
413
- durationLike: Omit<Temporal.Duration | DurationLike, "years" | "months" | "weeks" | "days"> | string
414
- ): Temporal.Instant;
415
- until(
416
- other: Temporal.Instant | string,
417
- options?: DifferenceOptions<"hour" | "minute" | "second" | "millisecond" | "microsecond" | "nanosecond">
418
- ): Temporal.Duration;
419
- since(
420
- other: Temporal.Instant | string,
421
- options?: DifferenceOptions<"hour" | "minute" | "second" | "millisecond" | "microsecond" | "nanosecond">
422
- ): Temporal.Duration;
423
- round(
424
- roundTo: RoundTo<"hour" | "minute" | "second" | "millisecond" | "microsecond" | "nanosecond">
425
- ): Temporal.Instant;
426
- toZonedDateTimeISO(tzLike: TimeZoneLike): Temporal.ZonedDateTime;
427
- toLocaleString(locales?: LocalesArgument, options?: globalThis.Intl.DateTimeFormatOptions): string;
428
- toJSON(): string;
429
- toString(options?: InstantToStringOptions): string;
430
- valueOf(): never;
431
- readonly [Symbol.toStringTag]: "Temporal.Instant";
432
- }
433
-
434
- type CalendarLike = string | ZonedDateTime | PlainDateTime | PlainDate | PlainYearMonth | PlainMonthDay;
435
-
436
- type PlainDateLike = {
437
- era?: string | undefined;
438
- eraYear?: number | undefined;
439
- year?: number;
440
- month?: number;
441
- monthCode?: string;
442
- day?: number;
443
- calendar?: CalendarLike;
444
- };
445
-
446
- class PlainDate {
447
- static from(item: Temporal.PlainDate | PlainDateLike | string, options?: AssignmentOptions): Temporal.PlainDate;
448
- static compare(
449
- one: Temporal.PlainDate | PlainDateLike | string,
450
- two: Temporal.PlainDate | PlainDateLike | string
451
- ): ComparisonResult;
452
- constructor(isoYear: number, isoMonth: number, isoDay: number, calendar?: string);
453
- readonly era: string | undefined;
454
- readonly eraYear: number | undefined;
455
- readonly year: number;
456
- readonly month: number;
457
- readonly monthCode: string;
458
- readonly day: number;
459
- readonly calendarId: string;
460
- readonly dayOfWeek: number;
461
- readonly dayOfYear: number;
462
- readonly weekOfYear: number | undefined;
463
- readonly yearOfWeek: number | undefined;
464
- readonly daysInWeek: number;
465
- readonly daysInYear: number;
466
- readonly daysInMonth: number;
467
- readonly monthsInYear: number;
468
- readonly inLeapYear: boolean;
469
- equals(other: Temporal.PlainDate | PlainDateLike | string): boolean;
470
- with(dateLike: PlainDateLike, options?: AssignmentOptions): Temporal.PlainDate;
471
- withCalendar(calendar: CalendarLike): Temporal.PlainDate;
472
- add(durationLike: Temporal.Duration | DurationLike | string, options?: ArithmeticOptions): Temporal.PlainDate;
473
- subtract(durationLike: Temporal.Duration | DurationLike | string, options?: ArithmeticOptions): Temporal.PlainDate;
474
- until(
475
- other: Temporal.PlainDate | PlainDateLike | string,
476
- options?: DifferenceOptions<"year" | "month" | "week" | "day">
477
- ): Temporal.Duration;
478
- since(
479
- other: Temporal.PlainDate | PlainDateLike | string,
480
- options?: DifferenceOptions<"year" | "month" | "week" | "day">
481
- ): Temporal.Duration;
482
- toPlainDateTime(temporalTime?: Temporal.PlainTime | PlainTimeLike | string): Temporal.PlainDateTime;
483
- toZonedDateTime(
484
- timeZoneAndTime:
485
- | string
486
- | {
487
- timeZone: TimeZoneLike;
488
- plainTime?: Temporal.PlainTime | PlainTimeLike | string;
489
- }
490
- ): Temporal.ZonedDateTime;
491
- toPlainYearMonth(): Temporal.PlainYearMonth;
492
- toPlainMonthDay(): Temporal.PlainMonthDay;
493
- toLocaleString(locales?: LocalesArgument, options?: globalThis.Intl.DateTimeFormatOptions): string;
494
- toJSON(): string;
495
- toString(options?: ShowCalendarOption): string;
496
- valueOf(): never;
497
- readonly [Symbol.toStringTag]: "Temporal.PlainDate";
498
- }
499
-
500
- type PlainDateTimeLike = {
501
- era?: string | undefined;
502
- eraYear?: number | undefined;
503
- year?: number;
504
- month?: number;
505
- monthCode?: string;
506
- day?: number;
507
- hour?: number;
508
- minute?: number;
509
- second?: number;
510
- millisecond?: number;
511
- microsecond?: number;
512
- nanosecond?: number;
513
- calendar?: CalendarLike;
514
- };
515
-
516
- class PlainDateTime {
517
- static from(
518
- item: Temporal.PlainDateTime | PlainDateTimeLike | string,
519
- options?: AssignmentOptions
520
- ): Temporal.PlainDateTime;
521
- static compare(
522
- one: Temporal.PlainDateTime | PlainDateTimeLike | string,
523
- two: Temporal.PlainDateTime | PlainDateTimeLike | string
524
- ): ComparisonResult;
525
- constructor(
526
- isoYear: number,
527
- isoMonth: number,
528
- isoDay: number,
529
- hour?: number,
530
- minute?: number,
531
- second?: number,
532
- millisecond?: number,
533
- microsecond?: number,
534
- nanosecond?: number,
535
- calendar?: string
536
- );
537
- readonly era: string | undefined;
538
- readonly eraYear: number | undefined;
539
- readonly year: number;
540
- readonly month: number;
541
- readonly monthCode: string;
542
- readonly day: number;
543
- readonly hour: number;
544
- readonly minute: number;
545
- readonly second: number;
546
- readonly millisecond: number;
547
- readonly microsecond: number;
548
- readonly nanosecond: number;
549
- readonly calendarId: string;
550
- readonly dayOfWeek: number;
551
- readonly dayOfYear: number;
552
- readonly weekOfYear: number | undefined;
553
- readonly yearOfWeek: number | undefined;
554
- readonly daysInWeek: number;
555
- readonly daysInYear: number;
556
- readonly daysInMonth: number;
557
- readonly monthsInYear: number;
558
- readonly inLeapYear: boolean;
559
- equals(other: Temporal.PlainDateTime | PlainDateTimeLike | string): boolean;
560
- with(dateTimeLike: PlainDateTimeLike, options?: AssignmentOptions): Temporal.PlainDateTime;
561
- withPlainTime(timeLike?: Temporal.PlainTime | PlainTimeLike | string): Temporal.PlainDateTime;
562
- withCalendar(calendar: CalendarLike): Temporal.PlainDateTime;
563
- add(durationLike: Temporal.Duration | DurationLike | string, options?: ArithmeticOptions): Temporal.PlainDateTime;
564
- subtract(
565
- durationLike: Temporal.Duration | DurationLike | string,
566
- options?: ArithmeticOptions
567
- ): Temporal.PlainDateTime;
568
- until(
569
- other: Temporal.PlainDateTime | PlainDateTimeLike | string,
570
- options?: DifferenceOptions<
571
- "year" | "month" | "week" | "day" | "hour" | "minute" | "second" | "millisecond" | "microsecond" | "nanosecond"
572
- >
573
- ): Temporal.Duration;
574
- since(
575
- other: Temporal.PlainDateTime | PlainDateTimeLike | string,
576
- options?: DifferenceOptions<
577
- "year" | "month" | "week" | "day" | "hour" | "minute" | "second" | "millisecond" | "microsecond" | "nanosecond"
578
- >
579
- ): Temporal.Duration;
580
- round(
581
- roundTo: RoundTo<"day" | "hour" | "minute" | "second" | "millisecond" | "microsecond" | "nanosecond">
582
- ): Temporal.PlainDateTime;
583
- toZonedDateTime(tzLike: TimeZoneLike, options?: ToInstantOptions): Temporal.ZonedDateTime;
584
- toPlainDate(): Temporal.PlainDate;
585
- toPlainTime(): Temporal.PlainTime;
586
- toLocaleString(locales?: LocalesArgument, options?: globalThis.Intl.DateTimeFormatOptions): string;
587
- toJSON(): string;
588
- toString(options?: CalendarTypeToStringOptions): string;
589
- valueOf(): never;
590
- readonly [Symbol.toStringTag]: "Temporal.PlainDateTime";
591
- }
592
-
593
- type PlainMonthDayLike = {
594
- era?: string | undefined;
595
- eraYear?: number | undefined;
596
- year?: number;
597
- month?: number;
598
- monthCode?: string;
599
- day?: number;
600
- calendar?: CalendarLike;
601
- };
602
-
603
- class PlainMonthDay {
604
- static from(
605
- item: Temporal.PlainMonthDay | PlainMonthDayLike | string,
606
- options?: AssignmentOptions
607
- ): Temporal.PlainMonthDay;
608
- constructor(isoMonth: number, isoDay: number, calendar?: string, referenceISOYear?: number);
609
- readonly monthCode: string;
610
- readonly day: number;
611
- readonly calendarId: string;
612
- equals(other: Temporal.PlainMonthDay | PlainMonthDayLike | string): boolean;
613
- with(monthDayLike: PlainMonthDayLike, options?: AssignmentOptions): Temporal.PlainMonthDay;
614
- toPlainDate(year: { year: number }): Temporal.PlainDate;
615
- toLocaleString(locales?: LocalesArgument, options?: globalThis.Intl.DateTimeFormatOptions): string;
616
- toJSON(): string;
617
- toString(options?: ShowCalendarOption): string;
618
- valueOf(): never;
619
- readonly [Symbol.toStringTag]: "Temporal.PlainMonthDay";
620
- }
621
-
622
- type PlainTimeLike = {
623
- hour?: number;
624
- minute?: number;
625
- second?: number;
626
- millisecond?: number;
627
- microsecond?: number;
628
- nanosecond?: number;
629
- };
630
-
631
- class PlainTime {
632
- static from(item: Temporal.PlainTime | PlainTimeLike | string, options?: AssignmentOptions): Temporal.PlainTime;
633
- static compare(
634
- one: Temporal.PlainTime | PlainTimeLike | string,
635
- two: Temporal.PlainTime | PlainTimeLike | string
636
- ): ComparisonResult;
637
- constructor(
638
- hour?: number,
639
- minute?: number,
640
- second?: number,
641
- millisecond?: number,
642
- microsecond?: number,
643
- nanosecond?: number
644
- );
645
- readonly hour: number;
646
- readonly minute: number;
647
- readonly second: number;
648
- readonly millisecond: number;
649
- readonly microsecond: number;
650
- readonly nanosecond: number;
651
- equals(other: Temporal.PlainTime | PlainTimeLike | string): boolean;
652
- with(timeLike: Temporal.PlainTime | PlainTimeLike, options?: AssignmentOptions): Temporal.PlainTime;
653
- add(durationLike: Temporal.Duration | DurationLike | string, options?: ArithmeticOptions): Temporal.PlainTime;
654
- subtract(durationLike: Temporal.Duration | DurationLike | string, options?: ArithmeticOptions): Temporal.PlainTime;
655
- until(
656
- other: Temporal.PlainTime | PlainTimeLike | string,
657
- options?: DifferenceOptions<"hour" | "minute" | "second" | "millisecond" | "microsecond" | "nanosecond">
658
- ): Temporal.Duration;
659
- since(
660
- other: Temporal.PlainTime | PlainTimeLike | string,
661
- options?: DifferenceOptions<"hour" | "minute" | "second" | "millisecond" | "microsecond" | "nanosecond">
662
- ): Temporal.Duration;
663
- round(
664
- roundTo: RoundTo<"hour" | "minute" | "second" | "millisecond" | "microsecond" | "nanosecond">
665
- ): Temporal.PlainTime;
666
- toLocaleString(locales?: LocalesArgument, options?: globalThis.Intl.DateTimeFormatOptions): string;
667
- toJSON(): string;
668
- toString(options?: ToStringPrecisionOptions): string;
669
- valueOf(): never;
670
- readonly [Symbol.toStringTag]: "Temporal.PlainTime";
671
- }
672
-
673
- type TimeZoneLike = string | ZonedDateTime;
674
-
675
- type PlainYearMonthLike = {
676
- era?: string | undefined;
677
- eraYear?: number | undefined;
678
- year?: number;
679
- month?: number;
680
- monthCode?: string;
681
- calendar?: CalendarLike;
682
- };
683
-
684
- class PlainYearMonth {
685
- static from(
686
- item: Temporal.PlainYearMonth | PlainYearMonthLike | string,
687
- options?: AssignmentOptions
688
- ): Temporal.PlainYearMonth;
689
- static compare(
690
- one: Temporal.PlainYearMonth | PlainYearMonthLike | string,
691
- two: Temporal.PlainYearMonth | PlainYearMonthLike | string
692
- ): ComparisonResult;
693
- constructor(isoYear: number, isoMonth: number, calendar?: string, referenceISODay?: number);
694
- readonly era: string | undefined;
695
- readonly eraYear: number | undefined;
696
- readonly year: number;
697
- readonly month: number;
698
- readonly monthCode: string;
699
- readonly calendarId: string;
700
- readonly daysInMonth: number;
701
- readonly daysInYear: number;
702
- readonly monthsInYear: number;
703
- readonly inLeapYear: boolean;
704
- equals(other: Temporal.PlainYearMonth | PlainYearMonthLike | string): boolean;
705
- with(yearMonthLike: PlainYearMonthLike, options?: AssignmentOptions): Temporal.PlainYearMonth;
706
- add(durationLike: Temporal.Duration | DurationLike | string, options?: ArithmeticOptions): Temporal.PlainYearMonth;
707
- subtract(
708
- durationLike: Temporal.Duration | DurationLike | string,
709
- options?: ArithmeticOptions
710
- ): Temporal.PlainYearMonth;
711
- until(
712
- other: Temporal.PlainYearMonth | PlainYearMonthLike | string,
713
- options?: DifferenceOptions<"year" | "month">
714
- ): Temporal.Duration;
715
- since(
716
- other: Temporal.PlainYearMonth | PlainYearMonthLike | string,
717
- options?: DifferenceOptions<"year" | "month">
718
- ): Temporal.Duration;
719
- toPlainDate(day: { day: number }): Temporal.PlainDate;
720
- toLocaleString(locales?: LocalesArgument, options?: globalThis.Intl.DateTimeFormatOptions): string;
721
- toJSON(): string;
722
- toString(options?: ShowCalendarOption): string;
723
- valueOf(): never;
724
- readonly [Symbol.toStringTag]: "Temporal.PlainYearMonth";
725
- }
726
-
727
- type ZonedDateTimeLike = {
728
- era?: string | undefined;
729
- eraYear?: number | undefined;
730
- year?: number;
731
- month?: number;
732
- monthCode?: string;
733
- day?: number;
734
- hour?: number;
735
- minute?: number;
736
- second?: number;
737
- millisecond?: number;
738
- microsecond?: number;
739
- nanosecond?: number;
740
- offset?: string;
741
- timeZone?: TimeZoneLike;
742
- calendar?: CalendarLike;
743
- };
744
-
745
- class ZonedDateTime {
746
- static from(
747
- item: Temporal.ZonedDateTime | ZonedDateTimeLike | string,
748
- options?: ZonedDateTimeAssignmentOptions
749
- ): ZonedDateTime;
750
- static compare(
751
- one: Temporal.ZonedDateTime | ZonedDateTimeLike | string,
752
- two: Temporal.ZonedDateTime | ZonedDateTimeLike | string
753
- ): ComparisonResult;
754
- constructor(epochNanoseconds: bigint, timeZone: string, calendar?: string);
755
- readonly era: string | undefined;
756
- readonly eraYear: number | undefined;
757
- readonly year: number;
758
- readonly month: number;
759
- readonly monthCode: string;
760
- readonly day: number;
761
- readonly hour: number;
762
- readonly minute: number;
763
- readonly second: number;
764
- readonly millisecond: number;
765
- readonly microsecond: number;
766
- readonly nanosecond: number;
767
- readonly timeZoneId: string;
768
- readonly calendarId: string;
769
- readonly dayOfWeek: number;
770
- readonly dayOfYear: number;
771
- readonly weekOfYear: number | undefined;
772
- readonly yearOfWeek: number | undefined;
773
- readonly hoursInDay: number;
774
- readonly daysInWeek: number;
775
- readonly daysInMonth: number;
776
- readonly daysInYear: number;
777
- readonly monthsInYear: number;
778
- readonly inLeapYear: boolean;
779
- readonly offsetNanoseconds: number;
780
- readonly offset: string;
781
- readonly epochMilliseconds: number;
782
- readonly epochNanoseconds: bigint;
783
- equals(other: Temporal.ZonedDateTime | ZonedDateTimeLike | string): boolean;
784
- with(zonedDateTimeLike: ZonedDateTimeLike, options?: ZonedDateTimeAssignmentOptions): Temporal.ZonedDateTime;
785
- withPlainTime(timeLike?: Temporal.PlainTime | PlainTimeLike | string): Temporal.ZonedDateTime;
786
- withCalendar(calendar: CalendarLike): Temporal.ZonedDateTime;
787
- withTimeZone(timeZone: TimeZoneLike): Temporal.ZonedDateTime;
788
- add(durationLike: Temporal.Duration | DurationLike | string, options?: ArithmeticOptions): Temporal.ZonedDateTime;
789
- subtract(
790
- durationLike: Temporal.Duration | DurationLike | string,
791
- options?: ArithmeticOptions
792
- ): Temporal.ZonedDateTime;
793
- until(
794
- other: Temporal.ZonedDateTime | ZonedDateTimeLike | string,
795
- options?: Temporal.DifferenceOptions<
796
- "year" | "month" | "week" | "day" | "hour" | "minute" | "second" | "millisecond" | "microsecond" | "nanosecond"
797
- >
798
- ): Temporal.Duration;
799
- since(
800
- other: Temporal.ZonedDateTime | ZonedDateTimeLike | string,
801
- options?: Temporal.DifferenceOptions<
802
- "year" | "month" | "week" | "day" | "hour" | "minute" | "second" | "millisecond" | "microsecond" | "nanosecond"
803
- >
804
- ): Temporal.Duration;
805
- round(
806
- roundTo: RoundTo<"day" | "hour" | "minute" | "second" | "millisecond" | "microsecond" | "nanosecond">
807
- ): Temporal.ZonedDateTime;
808
- startOfDay(): Temporal.ZonedDateTime;
809
- getTimeZoneTransition(direction: TransitionDirection): Temporal.ZonedDateTime | null;
810
- toInstant(): Temporal.Instant;
811
- toPlainDateTime(): Temporal.PlainDateTime;
812
- toPlainDate(): Temporal.PlainDate;
813
- toPlainTime(): Temporal.PlainTime;
814
- toLocaleString(locales?: LocalesArgument, options?: globalThis.Intl.DateTimeFormatOptions): string;
815
- toJSON(): string;
816
- toString(options?: ZonedDateTimeToStringOptions): string;
817
- valueOf(): never;
818
- readonly [Symbol.toStringTag]: "Temporal.ZonedDateTime";
819
- }
820
-
821
- const Now: {
822
- instant: () => Temporal.Instant;
823
- zonedDateTimeISO: (tzLike?: TimeZoneLike) => Temporal.ZonedDateTime;
824
- plainDateTimeISO: (tzLike?: TimeZoneLike) => Temporal.PlainDateTime;
825
- plainDateISO: (tzLike?: TimeZoneLike) => Temporal.PlainDate;
826
- plainTimeISO: (tzLike?: TimeZoneLike) => Temporal.PlainTime;
827
- timeZoneId: () => string;
828
- readonly [Symbol.toStringTag]: "Temporal.Now";
829
- };
830
- }
831
- // `Temporal` is exposed as an ambient global namespace. It is both a type namespace
832
- // and a value (its `class` and `const` members make it a runtime value), so no
833
- // separate `declare var Temporal` is needed — and adding one collides (TS2300).
1
+ // @nubjs/types — TypeScript 6+ entry point.
2
+ //
3
+ // TypeScript 6 ships the official Temporal declarations. Reference that focused
4
+ // library even when a consumer targets ES2024, then layer Nub's additive runtime
5
+ // augmentations from common.d.ts on top. Keeping this file a global script is
6
+ // intentional; see common.d.ts for the data-import wildcard invariant.
7
+ /// <reference lib="esnext.temporal" />
8
+ /// <reference lib="es2025.iterator" />
9
+ /// <reference path="./common.d.ts" />