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

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 +49 -0
  3. package/package.json +1 -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,55 @@ 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
+
2972
3021
  interface Array<T> {
2973
3022
  /**
2974
3023
  * Returns the value of the last element in the array where predicate is true, and undefined
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bedrock-apis/env-types",
3
- "version": "1.0.0-beta.5",
3
+ "version": "1.0.0-beta.6",
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",