@bedrock-apis/env-types 1.0.0-beta.5 → 1.0.0-rc.1

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 +28 -7
  2. package/lib.d.ts +224 -0
  3. package/package.json +2 -1
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # env-types
2
2
 
3
+ [![npm version](https://badge.fury.io/js/@bedrock-apis%2Fenv-types.svg)](https://www.npmjs.com/package/@bedrock-apis/env-types)
4
+
3
5
  TypeScript type definitions for environment-specific QuickJS engine that doesn't strictly follow standard ES versioning. This package provides a curated set of global types and methods tailored for non-standard runtimes, ensuring better development experience and type safety for your projects.
4
6
 
5
7
  > **Note:** This package is currently in **beta**. Contributions, bug reports, and suggestions are highly appreciated! Check out our [GitHub repository](https://github.com/bedrock-apis/env-types) for more information.
@@ -12,23 +14,42 @@ TypeScript type definitions for environment-specific QuickJS engine that doesn't
12
14
  - Helps catch runtime errors early by providing accurate type safety.
13
15
  - Designed to supplement and compare against TypeScript's global types.
14
16
 
15
- # Installation
16
- Install the package as a development dependency, and add it to the known types in your `tsconfig.json`:
17
+ ## Installation
18
+
19
+ Install the package as a development dependency using your preferred package manager:
20
+
21
+ ### npm
22
+ ```bash
23
+ npm install --save-dev @bedrock-apis/env-types
24
+ ```
25
+
26
+ ### pnpm
27
+ ```bash
28
+ pnpm add -D @bedrock-apis/env-types
29
+ ```
30
+
31
+ ### yarn
32
+ ```bash
33
+ yarn add --dev @bedrock-apis/env-types
34
+ ```
35
+
36
+ ### Configuration
37
+
38
+ Add the package to the `types` field in your `tsconfig.json`:
39
+
17
40
  ```json
18
41
  {
19
42
  "compilerOptions": {
20
43
  "noLib": true,
21
- "types": ["@bedrock-apis/env-types"],
22
- // ...
44
+ "types": ["@bedrock-apis/env-types"]
23
45
  }
24
- // ...
25
46
  }
26
47
  ```
27
48
 
28
- ## Plan
49
+ ## Development Plan
29
50
 
30
51
  - Generate a basic set of methods and properties for each global class.
31
- - Compare and extend these definitions against TypeScripts standard global types.
52
+ - Compare and extend these definitions against TypeScript's standard global types.
32
53
  - Continuously update with help of contributions.
33
54
 
34
55
  ## Contributing
package/lib.d.ts CHANGED
@@ -2969,6 +2969,230 @@ interface String {
2969
2969
  replaceAll(searchValue: string | RegExp, replacer: (substring: string, ...args: any[]) => string): string;
2970
2970
  }
2971
2971
 
2972
+ interface WeakRef<T extends WeakKey> {
2973
+ readonly [Symbol.toStringTag]: "WeakRef";
2974
+ /**
2975
+ * Returns the WeakRef instance's target value, or undefined if the target value has been
2976
+ * reclaimed.
2977
+ * In es2023 the value can be either a symbol or an object, in previous versions only object is permissible.
2978
+ */
2979
+ deref(): T | undefined;
2980
+ }
2981
+ interface WeakRefConstructor {
2982
+ readonly prototype: WeakRef<any>;
2983
+ /**
2984
+ * Creates a WeakRef instance for the given target value.
2985
+ * In es2023 the value can be either a symbol or an object, in previous versions only object is permissible.
2986
+ * @param target The target value for the WeakRef instance.
2987
+ */
2988
+ new <T extends WeakKey>(target: T): WeakRef<T>;
2989
+ }
2990
+ declare var WeakRef: WeakRefConstructor;
2991
+ interface FinalizationRegistry<T> {
2992
+ readonly [Symbol.toStringTag]: "FinalizationRegistry";
2993
+ /**
2994
+ * Registers a value with the registry.
2995
+ * In es2023 the value can be either a symbol or an object, in previous versions only object is permissible.
2996
+ * @param target The target value to register.
2997
+ * @param heldValue The value to pass to the finalizer for this value. This cannot be the
2998
+ * target value.
2999
+ * @param unregisterToken The token to pass to the unregister method to unregister the target
3000
+ * value. If not provided, the target cannot be unregistered.
3001
+ */
3002
+ register(target: WeakKey, heldValue: T, unregisterToken?: WeakKey): void;
3003
+ /**
3004
+ * Unregisters a value from the registry.
3005
+ * In es2023 the value can be either a symbol or an object, in previous versions only object is permissible.
3006
+ * @param unregisterToken The token that was used as the unregisterToken argument when calling
3007
+ * register to register the target value.
3008
+ */
3009
+ unregister(unregisterToken: WeakKey): boolean;
3010
+ }
3011
+ interface FinalizationRegistryConstructor {
3012
+ readonly prototype: FinalizationRegistry<any>;
3013
+ /**
3014
+ * Creates a finalization registry with an associated cleanup callback
3015
+ * @param cleanupCallback The callback to call after a value in the registry has been reclaimed.
3016
+ */
3017
+ new <T>(cleanupCallback: (heldValue: T) => void): FinalizationRegistry<T>;
3018
+ }
3019
+ declare var FinalizationRegistry: FinalizationRegistryConstructor;
3020
+
3021
+ interface Array<T> {
3022
+ /**
3023
+ * Returns the item located at the specified index.
3024
+ * @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
3025
+ */
3026
+ at(index: number): T | undefined;
3027
+ }
3028
+ interface ReadonlyArray<T> {
3029
+ /**
3030
+ * Returns the item located at the specified index.
3031
+ * @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
3032
+ */
3033
+ at(index: number): T | undefined;
3034
+ }
3035
+ interface Int8Array<TArrayBuffer extends ArrayBufferLike> {
3036
+ /**
3037
+ * Returns the item located at the specified index.
3038
+ * @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
3039
+ */
3040
+ at(index: number): number | undefined;
3041
+ }
3042
+ interface Uint8Array<TArrayBuffer extends ArrayBufferLike> {
3043
+ /**
3044
+ * Returns the item located at the specified index.
3045
+ * @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
3046
+ */
3047
+ at(index: number): number | undefined;
3048
+ }
3049
+ interface Uint8ClampedArray<TArrayBuffer extends ArrayBufferLike> {
3050
+ /**
3051
+ * Returns the item located at the specified index.
3052
+ * @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
3053
+ */
3054
+ at(index: number): number | undefined;
3055
+ }
3056
+ interface Int16Array<TArrayBuffer extends ArrayBufferLike> {
3057
+ /**
3058
+ * Returns the item located at the specified index.
3059
+ * @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
3060
+ */
3061
+ at(index: number): number | undefined;
3062
+ }
3063
+ interface Uint16Array<TArrayBuffer extends ArrayBufferLike> {
3064
+ /**
3065
+ * Returns the item located at the specified index.
3066
+ * @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
3067
+ */
3068
+ at(index: number): number | undefined;
3069
+ }
3070
+ interface Int32Array<TArrayBuffer extends ArrayBufferLike> {
3071
+ /**
3072
+ * Returns the item located at the specified index.
3073
+ * @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
3074
+ */
3075
+ at(index: number): number | undefined;
3076
+ }
3077
+ interface Uint32Array<TArrayBuffer extends ArrayBufferLike> {
3078
+ /**
3079
+ * Returns the item located at the specified index.
3080
+ * @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
3081
+ */
3082
+ at(index: number): number | undefined;
3083
+ }
3084
+ interface Float32Array<TArrayBuffer extends ArrayBufferLike> {
3085
+ /**
3086
+ * Returns the item located at the specified index.
3087
+ * @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
3088
+ */
3089
+ at(index: number): number | undefined;
3090
+ }
3091
+ interface Float64Array<TArrayBuffer extends ArrayBufferLike> {
3092
+ /**
3093
+ * Returns the item located at the specified index.
3094
+ * @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
3095
+ */
3096
+ at(index: number): number | undefined;
3097
+ }
3098
+ interface BigInt64Array<TArrayBuffer extends ArrayBufferLike> {
3099
+ /**
3100
+ * Returns the item located at the specified index.
3101
+ * @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
3102
+ */
3103
+ at(index: number): bigint | undefined;
3104
+ }
3105
+ interface BigUint64Array<TArrayBuffer extends ArrayBufferLike> {
3106
+ /**
3107
+ * Returns the item located at the specified index.
3108
+ * @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
3109
+ */
3110
+ at(index: number): bigint | undefined;
3111
+ }
3112
+
3113
+ interface ErrorOptions {
3114
+ cause?: unknown;
3115
+ }
3116
+ interface Error {
3117
+ cause?: unknown;
3118
+ }
3119
+ interface ErrorConstructor {
3120
+ new (message?: string, options?: ErrorOptions): Error;
3121
+ (message?: string, options?: ErrorOptions): Error;
3122
+ }
3123
+ interface EvalErrorConstructor {
3124
+ new (message?: string, options?: ErrorOptions): EvalError;
3125
+ (message?: string, options?: ErrorOptions): EvalError;
3126
+ }
3127
+ interface RangeErrorConstructor {
3128
+ new (message?: string, options?: ErrorOptions): RangeError;
3129
+ (message?: string, options?: ErrorOptions): RangeError;
3130
+ }
3131
+ interface ReferenceErrorConstructor {
3132
+ new (message?: string, options?: ErrorOptions): ReferenceError;
3133
+ (message?: string, options?: ErrorOptions): ReferenceError;
3134
+ }
3135
+ interface SyntaxErrorConstructor {
3136
+ new (message?: string, options?: ErrorOptions): SyntaxError;
3137
+ (message?: string, options?: ErrorOptions): SyntaxError;
3138
+ }
3139
+ interface TypeErrorConstructor {
3140
+ new (message?: string, options?: ErrorOptions): TypeError;
3141
+ (message?: string, options?: ErrorOptions): TypeError;
3142
+ }
3143
+ interface URIErrorConstructor {
3144
+ new (message?: string, options?: ErrorOptions): URIError;
3145
+ (message?: string, options?: ErrorOptions): URIError;
3146
+ }
3147
+ interface AggregateErrorConstructor {
3148
+ new (
3149
+ errors: Iterable<any>,
3150
+ message?: string,
3151
+ options?: ErrorOptions,
3152
+ ): AggregateError;
3153
+ (
3154
+ errors: Iterable<any>,
3155
+ message?: string,
3156
+ options?: ErrorOptions,
3157
+ ): AggregateError;
3158
+ }
3159
+
3160
+ interface ObjectConstructor {
3161
+ /**
3162
+ * Determines whether an object has a property with the specified name.
3163
+ * @param o An object.
3164
+ * @param v A property name.
3165
+ */
3166
+ hasOwn(o: object, v: PropertyKey): boolean;
3167
+ }
3168
+
3169
+ interface RegExpMatchArray {
3170
+ indices?: RegExpIndicesArray;
3171
+ }
3172
+ interface RegExpExecArray {
3173
+ indices?: RegExpIndicesArray;
3174
+ }
3175
+ interface RegExpIndicesArray extends Array<[number, number]> {
3176
+ groups?: {
3177
+ [key: string]: [number, number];
3178
+ };
3179
+ }
3180
+ interface RegExp {
3181
+ /**
3182
+ * Returns a Boolean value indicating the state of the hasIndices flag (d) used with a regular expression.
3183
+ * Default is false. Read-only.
3184
+ */
3185
+ readonly hasIndices: boolean;
3186
+ }
3187
+
3188
+ interface String {
3189
+ /**
3190
+ * Returns a new String consisting of the single UTF-16 code unit located at the specified index.
3191
+ * @param index The zero-based index of the desired code unit. A negative index will count back from the last item.
3192
+ */
3193
+ at(index: number): string | undefined;
3194
+ }
3195
+
2972
3196
  interface Array<T> {
2973
3197
  /**
2974
3198
  * Returns the value of the last element in the array where predicate is true, and undefined
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@bedrock-apis/env-types",
3
- "version": "1.0.0-beta.5",
3
+ "version": "1.0.0-rc.1",
4
4
  "description": "A collection of environment-specific TypeScript type definitions for engines with non-standard versioning and selective feature support across versions.",
5
5
  "main": "",
6
6
  "types": "lib.d.ts",
7
+ "type": "module",
7
8
  "keywords": [
8
9
  "typescript",
9
10
  "api-types",