@nubjs/types 0.0.2

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