@workers-community/workers-types 4.20250911.0 → 4.20250912.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.
Files changed (3) hide show
  1. package/index.d.ts +120 -91
  2. package/index.ts +226 -86
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -388,10 +388,10 @@ declare const Cloudflare: Cloudflare;
388
388
  declare const origin: string;
389
389
  declare const navigator: Navigator;
390
390
  interface TestController {}
391
- interface ExecutionContext {
391
+ interface ExecutionContext<Props = unknown> {
392
392
  waitUntil(promise: Promise<any>): void;
393
393
  passThroughOnException(): void;
394
- props: any;
394
+ readonly props: Props;
395
395
  }
396
396
  type ExportedHandlerFetchHandler<Env = unknown, CfHostMetadata = unknown> = (
397
397
  request: Request<CfHostMetadata, IncomingRequestCfProperties<CfHostMetadata>>,
@@ -540,9 +540,12 @@ type DurableObjectLocationHint =
540
540
  interface DurableObjectNamespaceGetDurableObjectOptions {
541
541
  locationHint?: DurableObjectLocationHint;
542
542
  }
543
- interface DurableObjectState {
543
+ interface DurableObjectClass<
544
+ T extends Rpc.DurableObjectBranded | undefined = undefined,
545
+ > {}
546
+ interface DurableObjectState<Props = unknown> {
544
547
  waitUntil(promise: Promise<any>): void;
545
- props: any;
548
+ readonly props: Props;
546
549
  readonly id: DurableObjectId;
547
550
  readonly storage: DurableObjectStorage;
548
551
  container?: Container;
@@ -3080,6 +3083,30 @@ interface MessagePort extends EventTarget {
3080
3083
  interface MessagePortPostMessageOptions {
3081
3084
  transfer?: any[];
3082
3085
  }
3086
+ type LoopbackForExport<
3087
+ T extends
3088
+ | (new (...args: any[]) => Rpc.EntrypointBranded)
3089
+ | ExportedHandler<any, any, any>
3090
+ | undefined = undefined,
3091
+ > = T extends new (...args: any[]) => Rpc.WorkerEntrypointBranded
3092
+ ? LoopbackServiceStub<InstanceType<T>>
3093
+ : T extends new (...args: any[]) => Rpc.DurableObjectBranded
3094
+ ? LoopbackDurableObjectClass<InstanceType<T>>
3095
+ : T extends ExportedHandler<any, any, any>
3096
+ ? LoopbackServiceStub<undefined>
3097
+ : undefined;
3098
+ type LoopbackServiceStub<
3099
+ T extends Rpc.WorkerEntrypointBranded | undefined = undefined,
3100
+ > = Fetcher<T> &
3101
+ (T extends CloudflareWorkersModule.WorkerEntrypoint<any, infer Props>
3102
+ ? (opts: { props?: Props }) => Fetcher<T>
3103
+ : (opts: { props?: any }) => Fetcher<T>);
3104
+ type LoopbackDurableObjectClass<
3105
+ T extends Rpc.DurableObjectBranded | undefined = undefined,
3106
+ > = DurableObjectClass<T> &
3107
+ (T extends CloudflareWorkersModule.DurableObject<any, infer Props>
3108
+ ? (opts: { props?: Props }) => DurableObjectClass<T>
3109
+ : (opts: { props?: any }) => DurableObjectClass<T>);
3083
3110
  interface SyncKvStorage {
3084
3111
  get<T = unknown>(key: string): T | undefined;
3085
3112
  list<T = unknown>(options?: SyncKvListOptions): Iterable<[string, T]>;
@@ -3094,98 +3121,51 @@ interface SyncKvListOptions {
3094
3121
  reverse?: boolean;
3095
3122
  limit?: number;
3096
3123
  }
3124
+ interface WorkerStub {
3125
+ getEntrypoint<T extends Rpc.WorkerEntrypointBranded | undefined>(
3126
+ name?: string,
3127
+ options?: WorkerStubEntrypointOptions,
3128
+ ): Fetcher<T>;
3129
+ }
3130
+ interface WorkerStubEntrypointOptions {
3131
+ props?: any;
3132
+ }
3133
+ interface WorkerLoader {
3134
+ get(
3135
+ name: string,
3136
+ getCode: () => WorkerLoaderWorkerCode | Promise<WorkerLoaderWorkerCode>,
3137
+ ): WorkerStub;
3138
+ }
3139
+ interface WorkerLoaderModule {
3140
+ js?: string;
3141
+ cjs?: string;
3142
+ text?: string;
3143
+ data?: ArrayBuffer;
3144
+ json?: any;
3145
+ py?: string;
3146
+ }
3147
+ interface WorkerLoaderWorkerCode {
3148
+ compatibilityDate: string;
3149
+ compatibilityFlags?: string[];
3150
+ allowExperimental?: boolean;
3151
+ mainModule: string;
3152
+ modules: Record<string, WorkerLoaderModule | string>;
3153
+ env?: any;
3154
+ globalOutbound?: Fetcher | null;
3155
+ tails?: Fetcher[];
3156
+ streamingTails?: Fetcher[];
3157
+ }
3097
3158
  /**
3098
3159
  * The Workers runtime supports a subset of the Performance API, used to measure timing and performance,
3099
3160
  * as well as timing of subrequests and other operations.
3100
3161
  *
3101
3162
  * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/)
3102
3163
  */
3103
- declare abstract class Performance extends EventTarget {
3164
+ declare abstract class Performance {
3104
3165
  /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/#performancetimeorigin) */
3105
3166
  get timeOrigin(): number;
3106
3167
  /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/#performancenow) */
3107
3168
  now(): number;
3108
- get eventCounts(): EventCounts;
3109
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/clearMarks) */
3110
- clearMarks(name?: string): void;
3111
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/clearMeasures) */
3112
- clearMeasures(name?: string): void;
3113
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/clearResourceTimings) */
3114
- clearResourceTimings(): void;
3115
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/getEntries) */
3116
- getEntries(): PerformanceEntry[];
3117
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/getEntriesByName) */
3118
- getEntriesByName(name: string, type: string): PerformanceEntry[];
3119
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/getEntriesByType) */
3120
- getEntriesByType(type: string): PerformanceEntry[];
3121
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/mark) */
3122
- mark(name: string, options?: PerformanceMarkOptions): PerformanceMark;
3123
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/measure) */
3124
- measure(
3125
- measureName: string,
3126
- measureOptionsOrStartMark: PerformanceMeasureOptions | string,
3127
- maybeEndMark?: string,
3128
- ): PerformanceMeasure;
3129
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/setResourceTimingBufferSize) */
3130
- setResourceTimingBufferSize(size: number): void;
3131
- }
3132
- /**
3133
- * PerformanceMark is an abstract interface for PerformanceEntry objects with an entryType of "mark". Entries of this type are created by calling performance.mark() to add a named DOMHighResTimeStamp (the mark) to the browser's performance timeline.
3134
- *
3135
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceMark)
3136
- */
3137
- interface PerformanceMark extends PerformanceEntry {
3138
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceMark/detail) */
3139
- get detail(): any;
3140
- }
3141
- /**
3142
- * PerformanceMeasure is an abstract interface for PerformanceEntry objects with an entryType of "measure". Entries of this type are created by calling performance.measure() to add a named DOMHighResTimeStamp (the measure) between two marks to the browser's performance timeline.
3143
- *
3144
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceMeasure)
3145
- */
3146
- interface PerformanceMeasure extends PerformanceEntry {
3147
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceMeasure/detail) */
3148
- get detail(): any;
3149
- }
3150
- interface PerformanceMarkOptions {
3151
- detail?: any;
3152
- startTime?: number;
3153
- }
3154
- interface PerformanceMeasureOptions {
3155
- detail?: any;
3156
- start?: number;
3157
- duration?: number;
3158
- end?: number;
3159
- }
3160
- /**
3161
- * Encapsulates a single performance metric that is part of the performance timeline. A performance entry can be directly created by making a performance mark or measure (for example by calling the mark() method) at an explicit point in an application. Performance entries are also created in indirect ways such as loading a resource (such as an image).
3162
- *
3163
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceEntry)
3164
- */
3165
- declare abstract class PerformanceEntry {
3166
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceEntry/name) */
3167
- get name(): string;
3168
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceEntry/entryType) */
3169
- get entryType(): string;
3170
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceEntry/startTime) */
3171
- get startTime(): number;
3172
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceEntry/duration) */
3173
- get duration(): number;
3174
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceEntry/toJSON) */
3175
- toJSON(): any;
3176
- }
3177
- interface EventCounts {
3178
- get size(): number;
3179
- get(eventType: string): number | undefined;
3180
- has(eventType: string): boolean;
3181
- entries(): IterableIterator<string[]>;
3182
- keys(): IterableIterator<string>;
3183
- values(): IterableIterator<number>;
3184
- forEach(
3185
- param1: (param0: number, param1: string, param2: EventCounts) => void,
3186
- param2?: any,
3187
- ): void;
3188
- [Symbol.iterator](): IterableIterator<string[]>;
3189
3169
  }
3190
3170
  type AiImageClassificationInput = {
3191
3171
  image: number[];
@@ -8097,7 +8077,53 @@ declare namespace Rpc {
8097
8077
  };
8098
8078
  }
8099
8079
  declare namespace Cloudflare {
8080
+ // Type of `env`.
8081
+ //
8082
+ // The specific project can extend `Env` by redeclaring it in project-specific files. Typescript
8083
+ // will merge all declarations.
8084
+ //
8085
+ // You can use `wrangler types` to generate the `Env` type automatically.
8100
8086
  interface Env {}
8087
+ // Project-specific parameters used to inform types.
8088
+ //
8089
+ // This interface is, again, intended to be declared in project-specific files, and then that
8090
+ // declaration will be merged with this one.
8091
+ //
8092
+ // A project should have a declaration like this:
8093
+ //
8094
+ // interface GlobalProps {
8095
+ // // Declares the main module's exports. Used to populate Cloudflare.Exports aka the type
8096
+ // // of `ctx.exports`.
8097
+ // mainModule: typeof import("my-main-module");
8098
+ //
8099
+ // // Declares which of the main module's exports are configured with durable storage, and
8100
+ // // thus should behave as Durable Object namsepace bindings.
8101
+ // durableNamespaces: "MyDurableObject" | "AnotherDurableObject";
8102
+ // }
8103
+ //
8104
+ // You can use `wrangler types` to generate `GlobalProps` automatically.
8105
+ interface GlobalProps {}
8106
+ // Evaluates to the type of a property in GlobalProps, defaulting to `Default` if it is not
8107
+ // present.
8108
+ type GlobalProp<K extends string, Default> = K extends keyof GlobalProps
8109
+ ? GlobalProps[K]
8110
+ : Default;
8111
+ // The type of the program's main module exports, if known. Requires `GlobalProps` to declare the
8112
+ // `mainModule` property.
8113
+ type MainModule = GlobalProp<"mainModule", {}>;
8114
+ // The type of ctx.exports, which contains loopback bindings for all top-level exports.
8115
+ type Exports = {
8116
+ [K in keyof MainModule]: LoopbackForExport<MainModule[K]> &
8117
+ // If the export is listed in `durableNamespaces`, then it is also a
8118
+ // DurableObjectNamespace.
8119
+ (K extends GlobalProp<"durableNamespaces", never>
8120
+ ? MainModule[K] extends new (...args: any[]) => infer DoInstance
8121
+ ? DoInstance extends Rpc.DurableObjectBranded
8122
+ ? DurableObjectNamespace<DoInstance>
8123
+ : DurableObjectNamespace<undefined>
8124
+ : DurableObjectNamespace<undefined>
8125
+ : {});
8126
+ };
8101
8127
  }
8102
8128
  declare module "cloudflare:node" {
8103
8129
  export interface DefaultHandler {
@@ -8115,7 +8141,7 @@ declare module "cloudflare:node" {
8115
8141
  handlers?: Omit<DefaultHandler, "fetch">,
8116
8142
  ): DefaultHandler;
8117
8143
  }
8118
- declare module "cloudflare:workers" {
8144
+ declare namespace CloudflareWorkersModule {
8119
8145
  export type RpcStub<T extends Rpc.Stubable> = Rpc.Stub<T>;
8120
8146
  export const RpcStub: {
8121
8147
  new <T extends Rpc.Stubable>(value: T): Rpc.Stub<T>;
@@ -8124,11 +8150,11 @@ declare module "cloudflare:workers" {
8124
8150
  [Rpc.__RPC_TARGET_BRAND]: never;
8125
8151
  }
8126
8152
  // `protected` fields don't appear in `keyof`s, so can't be accessed over RPC
8127
- export abstract class WorkerEntrypoint<Env = unknown>
8153
+ export abstract class WorkerEntrypoint<Env = Cloudflare.Env, Props = {}>
8128
8154
  implements Rpc.WorkerEntrypointBranded
8129
8155
  {
8130
8156
  [Rpc.__WORKER_ENTRYPOINT_BRAND]: never;
8131
- protected ctx: ExecutionContext;
8157
+ protected ctx: ExecutionContext<Props>;
8132
8158
  protected env: Env;
8133
8159
  constructor(ctx: ExecutionContext, env: Env);
8134
8160
  fetch?(request: Request): Response | Promise<Response>;
@@ -8138,11 +8164,11 @@ declare module "cloudflare:workers" {
8138
8164
  queue?(batch: MessageBatch<unknown>): void | Promise<void>;
8139
8165
  test?(controller: TestController): void | Promise<void>;
8140
8166
  }
8141
- export abstract class DurableObject<Env = unknown>
8167
+ export abstract class DurableObject<Env = Cloudflare.Env, Props = {}>
8142
8168
  implements Rpc.DurableObjectBranded
8143
8169
  {
8144
8170
  [Rpc.__DURABLE_OBJECT_BRAND]: never;
8145
- protected ctx: DurableObjectState;
8171
+ protected ctx: DurableObjectState<Props>;
8146
8172
  protected env: Env;
8147
8173
  constructor(ctx: DurableObjectState, env: Env);
8148
8174
  fetch?(request: Request): Response | Promise<Response>;
@@ -8229,6 +8255,9 @@ declare module "cloudflare:workers" {
8229
8255
  export function waitUntil(promise: Promise<unknown>): void;
8230
8256
  export const env: Cloudflare.Env;
8231
8257
  }
8258
+ declare module "cloudflare:workers" {
8259
+ export = CloudflareWorkersModule;
8260
+ }
8232
8261
  interface SecretsStoreSecret {
8233
8262
  /**
8234
8263
  * Get a secret from the Secrets Store, returning a string of the secret value
package/index.ts CHANGED
@@ -390,10 +390,10 @@ export declare const Cloudflare: Cloudflare;
390
390
  export declare const origin: string;
391
391
  export declare const navigator: Navigator;
392
392
  export interface TestController {}
393
- export interface ExecutionContext {
393
+ export interface ExecutionContext<Props = unknown> {
394
394
  waitUntil(promise: Promise<any>): void;
395
395
  passThroughOnException(): void;
396
- props: any;
396
+ readonly props: Props;
397
397
  }
398
398
  export type ExportedHandlerFetchHandler<
399
399
  Env = unknown,
@@ -545,9 +545,12 @@ export type DurableObjectLocationHint =
545
545
  export interface DurableObjectNamespaceGetDurableObjectOptions {
546
546
  locationHint?: DurableObjectLocationHint;
547
547
  }
548
- export interface DurableObjectState {
548
+ export interface DurableObjectClass<
549
+ T extends Rpc.DurableObjectBranded | undefined = undefined,
550
+ > {}
551
+ export interface DurableObjectState<Props = unknown> {
549
552
  waitUntil(promise: Promise<any>): void;
550
- props: any;
553
+ readonly props: Props;
551
554
  readonly id: DurableObjectId;
552
555
  readonly storage: DurableObjectStorage;
553
556
  container?: Container;
@@ -3091,6 +3094,30 @@ export interface MessagePort extends EventTarget {
3091
3094
  export interface MessagePortPostMessageOptions {
3092
3095
  transfer?: any[];
3093
3096
  }
3097
+ export type LoopbackForExport<
3098
+ T extends
3099
+ | (new (...args: any[]) => Rpc.EntrypointBranded)
3100
+ | ExportedHandler<any, any, any>
3101
+ | undefined = undefined,
3102
+ > = T extends new (...args: any[]) => Rpc.WorkerEntrypointBranded
3103
+ ? LoopbackServiceStub<InstanceType<T>>
3104
+ : T extends new (...args: any[]) => Rpc.DurableObjectBranded
3105
+ ? LoopbackDurableObjectClass<InstanceType<T>>
3106
+ : T extends ExportedHandler<any, any, any>
3107
+ ? LoopbackServiceStub<undefined>
3108
+ : undefined;
3109
+ export type LoopbackServiceStub<
3110
+ T extends Rpc.WorkerEntrypointBranded | undefined = undefined,
3111
+ > = Fetcher<T> &
3112
+ (T extends CloudflareWorkersModule.WorkerEntrypoint<any, infer Props>
3113
+ ? (opts: { props?: Props }) => Fetcher<T>
3114
+ : (opts: { props?: any }) => Fetcher<T>);
3115
+ export type LoopbackDurableObjectClass<
3116
+ T extends Rpc.DurableObjectBranded | undefined = undefined,
3117
+ > = DurableObjectClass<T> &
3118
+ (T extends CloudflareWorkersModule.DurableObject<any, infer Props>
3119
+ ? (opts: { props?: Props }) => DurableObjectClass<T>
3120
+ : (opts: { props?: any }) => DurableObjectClass<T>);
3094
3121
  export interface SyncKvStorage {
3095
3122
  get<T = unknown>(key: string): T | undefined;
3096
3123
  list<T = unknown>(options?: SyncKvListOptions): Iterable<[string, T]>;
@@ -3105,98 +3132,51 @@ export interface SyncKvListOptions {
3105
3132
  reverse?: boolean;
3106
3133
  limit?: number;
3107
3134
  }
3135
+ export interface WorkerStub {
3136
+ getEntrypoint<T extends Rpc.WorkerEntrypointBranded | undefined>(
3137
+ name?: string,
3138
+ options?: WorkerStubEntrypointOptions,
3139
+ ): Fetcher<T>;
3140
+ }
3141
+ export interface WorkerStubEntrypointOptions {
3142
+ props?: any;
3143
+ }
3144
+ export interface WorkerLoader {
3145
+ get(
3146
+ name: string,
3147
+ getCode: () => WorkerLoaderWorkerCode | Promise<WorkerLoaderWorkerCode>,
3148
+ ): WorkerStub;
3149
+ }
3150
+ export interface WorkerLoaderModule {
3151
+ js?: string;
3152
+ cjs?: string;
3153
+ text?: string;
3154
+ data?: ArrayBuffer;
3155
+ json?: any;
3156
+ py?: string;
3157
+ }
3158
+ export interface WorkerLoaderWorkerCode {
3159
+ compatibilityDate: string;
3160
+ compatibilityFlags?: string[];
3161
+ allowExperimental?: boolean;
3162
+ mainModule: string;
3163
+ modules: Record<string, WorkerLoaderModule | string>;
3164
+ env?: any;
3165
+ globalOutbound?: Fetcher | null;
3166
+ tails?: Fetcher[];
3167
+ streamingTails?: Fetcher[];
3168
+ }
3108
3169
  /**
3109
3170
  * The Workers runtime supports a subset of the Performance API, used to measure timing and performance,
3110
3171
  * as well as timing of subrequests and other operations.
3111
3172
  *
3112
3173
  * [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/)
3113
3174
  */
3114
- export declare abstract class Performance extends EventTarget {
3175
+ export declare abstract class Performance {
3115
3176
  /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/#performancetimeorigin) */
3116
3177
  get timeOrigin(): number;
3117
3178
  /* [Cloudflare Docs Reference](https://developers.cloudflare.com/workers/runtime-apis/performance/#performancenow) */
3118
3179
  now(): number;
3119
- get eventCounts(): EventCounts;
3120
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/clearMarks) */
3121
- clearMarks(name?: string): void;
3122
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/clearMeasures) */
3123
- clearMeasures(name?: string): void;
3124
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/clearResourceTimings) */
3125
- clearResourceTimings(): void;
3126
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/getEntries) */
3127
- getEntries(): PerformanceEntry[];
3128
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/getEntriesByName) */
3129
- getEntriesByName(name: string, type: string): PerformanceEntry[];
3130
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/getEntriesByType) */
3131
- getEntriesByType(type: string): PerformanceEntry[];
3132
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/mark) */
3133
- mark(name: string, options?: PerformanceMarkOptions): PerformanceMark;
3134
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/measure) */
3135
- measure(
3136
- measureName: string,
3137
- measureOptionsOrStartMark: PerformanceMeasureOptions | string,
3138
- maybeEndMark?: string,
3139
- ): PerformanceMeasure;
3140
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/Performance/setResourceTimingBufferSize) */
3141
- setResourceTimingBufferSize(size: number): void;
3142
- }
3143
- /**
3144
- * PerformanceMark is an abstract interface for PerformanceEntry objects with an entryType of "mark". Entries of this type are created by calling performance.mark() to add a named DOMHighResTimeStamp (the mark) to the browser's performance timeline.
3145
- *
3146
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceMark)
3147
- */
3148
- export interface PerformanceMark extends PerformanceEntry {
3149
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceMark/detail) */
3150
- get detail(): any;
3151
- }
3152
- /**
3153
- * PerformanceMeasure is an abstract interface for PerformanceEntry objects with an entryType of "measure". Entries of this type are created by calling performance.measure() to add a named DOMHighResTimeStamp (the measure) between two marks to the browser's performance timeline.
3154
- *
3155
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceMeasure)
3156
- */
3157
- export interface PerformanceMeasure extends PerformanceEntry {
3158
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceMeasure/detail) */
3159
- get detail(): any;
3160
- }
3161
- export interface PerformanceMarkOptions {
3162
- detail?: any;
3163
- startTime?: number;
3164
- }
3165
- export interface PerformanceMeasureOptions {
3166
- detail?: any;
3167
- start?: number;
3168
- duration?: number;
3169
- end?: number;
3170
- }
3171
- /**
3172
- * Encapsulates a single performance metric that is part of the performance timeline. A performance entry can be directly created by making a performance mark or measure (for example by calling the mark() method) at an explicit point in an application. Performance entries are also created in indirect ways such as loading a resource (such as an image).
3173
- *
3174
- * [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceEntry)
3175
- */
3176
- export declare abstract class PerformanceEntry {
3177
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceEntry/name) */
3178
- get name(): string;
3179
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceEntry/entryType) */
3180
- get entryType(): string;
3181
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceEntry/startTime) */
3182
- get startTime(): number;
3183
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceEntry/duration) */
3184
- get duration(): number;
3185
- /* [MDN Reference](https://developer.mozilla.org/docs/Web/API/PerformanceEntry/toJSON) */
3186
- toJSON(): any;
3187
- }
3188
- export interface EventCounts {
3189
- get size(): number;
3190
- get(eventType: string): number | undefined;
3191
- has(eventType: string): boolean;
3192
- entries(): IterableIterator<string[]>;
3193
- keys(): IterableIterator<string>;
3194
- values(): IterableIterator<number>;
3195
- forEach(
3196
- param1: (param0: number, param1: string, param2: EventCounts) => void,
3197
- param2?: any,
3198
- ): void;
3199
- [Symbol.iterator](): IterableIterator<string[]>;
3200
3180
  }
3201
3181
  export type AiImageClassificationInput = {
3202
3182
  image: number[];
@@ -8079,7 +8059,167 @@ export declare namespace Rpc {
8079
8059
  };
8080
8060
  }
8081
8061
  export declare namespace Cloudflare {
8062
+ // Type of `env`.
8063
+ //
8064
+ // The specific project can extend `Env` by redeclaring it in project-specific files. Typescript
8065
+ // will merge all declarations.
8066
+ //
8067
+ // You can use `wrangler types` to generate the `Env` type automatically.
8082
8068
  interface Env {}
8069
+ // Project-specific parameters used to inform types.
8070
+ //
8071
+ // This interface is, again, intended to be declared in project-specific files, and then that
8072
+ // declaration will be merged with this one.
8073
+ //
8074
+ // A project should have a declaration like this:
8075
+ //
8076
+ // interface GlobalProps {
8077
+ // // Declares the main module's exports. Used to populate Cloudflare.Exports aka the type
8078
+ // // of `ctx.exports`.
8079
+ // mainModule: typeof import("my-main-module");
8080
+ //
8081
+ // // Declares which of the main module's exports are configured with durable storage, and
8082
+ // // thus should behave as Durable Object namsepace bindings.
8083
+ // durableNamespaces: "MyDurableObject" | "AnotherDurableObject";
8084
+ // }
8085
+ //
8086
+ // You can use `wrangler types` to generate `GlobalProps` automatically.
8087
+ interface GlobalProps {}
8088
+ // Evaluates to the type of a property in GlobalProps, defaulting to `Default` if it is not
8089
+ // present.
8090
+ type GlobalProp<K extends string, Default> = K extends keyof GlobalProps
8091
+ ? GlobalProps[K]
8092
+ : Default;
8093
+ // The type of the program's main module exports, if known. Requires `GlobalProps` to declare the
8094
+ // `mainModule` property.
8095
+ type MainModule = GlobalProp<"mainModule", {}>;
8096
+ // The type of ctx.exports, which contains loopback bindings for all top-level exports.
8097
+ type Exports = {
8098
+ [K in keyof MainModule]: LoopbackForExport<MainModule[K]> &
8099
+ // If the export is listed in `durableNamespaces`, then it is also a
8100
+ // DurableObjectNamespace.
8101
+ (K extends GlobalProp<"durableNamespaces", never>
8102
+ ? MainModule[K] extends new (...args: any[]) => infer DoInstance
8103
+ ? DoInstance extends Rpc.DurableObjectBranded
8104
+ ? DurableObjectNamespace<DoInstance>
8105
+ : DurableObjectNamespace<undefined>
8106
+ : DurableObjectNamespace<undefined>
8107
+ : {});
8108
+ };
8109
+ }
8110
+ export declare namespace CloudflareWorkersModule {
8111
+ export type RpcStub<T extends Rpc.Stubable> = Rpc.Stub<T>;
8112
+ export const RpcStub: {
8113
+ new <T extends Rpc.Stubable>(value: T): Rpc.Stub<T>;
8114
+ };
8115
+ export abstract class RpcTarget implements Rpc.RpcTargetBranded {
8116
+ [Rpc.__RPC_TARGET_BRAND]: never;
8117
+ }
8118
+ // `protected` fields don't appear in `keyof`s, so can't be accessed over RPC
8119
+ export abstract class WorkerEntrypoint<Env = Cloudflare.Env, Props = {}>
8120
+ implements Rpc.WorkerEntrypointBranded
8121
+ {
8122
+ [Rpc.__WORKER_ENTRYPOINT_BRAND]: never;
8123
+ protected ctx: ExecutionContext<Props>;
8124
+ protected env: Env;
8125
+ constructor(ctx: ExecutionContext, env: Env);
8126
+ fetch?(request: Request): Response | Promise<Response>;
8127
+ tail?(events: TraceItem[]): void | Promise<void>;
8128
+ trace?(traces: TraceItem[]): void | Promise<void>;
8129
+ scheduled?(controller: ScheduledController): void | Promise<void>;
8130
+ queue?(batch: MessageBatch<unknown>): void | Promise<void>;
8131
+ test?(controller: TestController): void | Promise<void>;
8132
+ }
8133
+ export abstract class DurableObject<Env = Cloudflare.Env, Props = {}>
8134
+ implements Rpc.DurableObjectBranded
8135
+ {
8136
+ [Rpc.__DURABLE_OBJECT_BRAND]: never;
8137
+ protected ctx: DurableObjectState<Props>;
8138
+ protected env: Env;
8139
+ constructor(ctx: DurableObjectState, env: Env);
8140
+ fetch?(request: Request): Response | Promise<Response>;
8141
+ alarm?(alarmInfo?: AlarmInvocationInfo): void | Promise<void>;
8142
+ webSocketMessage?(
8143
+ ws: WebSocket,
8144
+ message: string | ArrayBuffer,
8145
+ ): void | Promise<void>;
8146
+ webSocketClose?(
8147
+ ws: WebSocket,
8148
+ code: number,
8149
+ reason: string,
8150
+ wasClean: boolean,
8151
+ ): void | Promise<void>;
8152
+ webSocketError?(ws: WebSocket, error: unknown): void | Promise<void>;
8153
+ }
8154
+ export type WorkflowDurationLabel =
8155
+ | "second"
8156
+ | "minute"
8157
+ | "hour"
8158
+ | "day"
8159
+ | "week"
8160
+ | "month"
8161
+ | "year";
8162
+ export type WorkflowSleepDuration =
8163
+ | `${number} ${WorkflowDurationLabel}${"s" | ""}`
8164
+ | number;
8165
+ export type WorkflowDelayDuration = WorkflowSleepDuration;
8166
+ export type WorkflowTimeoutDuration = WorkflowSleepDuration;
8167
+ export type WorkflowRetentionDuration = WorkflowSleepDuration;
8168
+ export type WorkflowBackoff = "constant" | "linear" | "exponential";
8169
+ export type WorkflowStepConfig = {
8170
+ retries?: {
8171
+ limit: number;
8172
+ delay: WorkflowDelayDuration | number;
8173
+ backoff?: WorkflowBackoff;
8174
+ };
8175
+ timeout?: WorkflowTimeoutDuration | number;
8176
+ };
8177
+ export type WorkflowEvent<T> = {
8178
+ payload: Readonly<T>;
8179
+ timestamp: Date;
8180
+ instanceId: string;
8181
+ };
8182
+ export type WorkflowStepEvent<T> = {
8183
+ payload: Readonly<T>;
8184
+ timestamp: Date;
8185
+ type: string;
8186
+ };
8187
+ export abstract class WorkflowStep {
8188
+ do<T extends Rpc.Serializable<T>>(
8189
+ name: string,
8190
+ callback: () => Promise<T>,
8191
+ ): Promise<T>;
8192
+ do<T extends Rpc.Serializable<T>>(
8193
+ name: string,
8194
+ config: WorkflowStepConfig,
8195
+ callback: () => Promise<T>,
8196
+ ): Promise<T>;
8197
+ sleep: (name: string, duration: WorkflowSleepDuration) => Promise<void>;
8198
+ sleepUntil: (name: string, timestamp: Date | number) => Promise<void>;
8199
+ waitForEvent<T extends Rpc.Serializable<T>>(
8200
+ name: string,
8201
+ options: {
8202
+ type: string;
8203
+ timeout?: WorkflowTimeoutDuration | number;
8204
+ },
8205
+ ): Promise<WorkflowStepEvent<T>>;
8206
+ }
8207
+ export abstract class WorkflowEntrypoint<
8208
+ Env = unknown,
8209
+ T extends Rpc.Serializable<T> | unknown = unknown,
8210
+ > implements Rpc.WorkflowEntrypointBranded
8211
+ {
8212
+ [Rpc.__WORKFLOW_ENTRYPOINT_BRAND]: never;
8213
+ protected ctx: ExecutionContext;
8214
+ protected env: Env;
8215
+ constructor(ctx: ExecutionContext, env: Env);
8216
+ run(
8217
+ event: Readonly<WorkflowEvent<T>>,
8218
+ step: WorkflowStep,
8219
+ ): Promise<unknown>;
8220
+ }
8221
+ export function waitUntil(promise: Promise<unknown>): void;
8222
+ export const env: Cloudflare.Env;
8083
8223
  }
8084
8224
  export interface SecretsStoreSecret {
8085
8225
  /**
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  },
8
8
  "author": "Workers Community",
9
9
  "license": "MIT OR Apache-2.0",
10
- "version": "4.20250911.0",
10
+ "version": "4.20250912.0",
11
11
  "exports": {
12
12
  ".": {
13
13
  "types": "./index.d.ts",