@nativescript/ios 9.1.0-rc.2 → 9.1.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.
@@ -505,7 +505,7 @@
505
505
  repositoryURL = "https://github.com/NativeScript/ios-spm.git";
506
506
  requirement = {
507
507
  kind = exactVersion;
508
- version = "9.1.0-rc.2";
508
+ version = "9.1.1";
509
509
  };
510
510
  };
511
511
  /* End XCRemoteSwiftPackageReference section */
@@ -3,6 +3,7 @@
3
3
  import os
4
4
  import shlex
5
5
  import subprocess
6
+ import filecmp
6
7
  import sys
7
8
 
8
9
  print("Python version: " + sys.version)
@@ -126,7 +127,7 @@ def save_stream_to_file(filename, stream):
126
127
  def generate_metadata(arch):
127
128
  # metadata generator arguments
128
129
  generator_call = ["./objc-metadata-generator", "-verbose",
129
- "-output-bin", "{}/metadata-{}.bin".format(conf_build_dir, arch),
130
+ "-output-bin", "{}/metadata-{}.bin.tmp".format(conf_build_dir, arch),
130
131
  "-output-umbrella", "{}/umbrella-{}.h".format(conf_build_dir, arch),
131
132
  "-docset-path", docset_path]
132
133
 
@@ -192,6 +193,14 @@ def generate_metadata(arch):
192
193
  print(error_stream_content)
193
194
  sys.exit(1)
194
195
 
196
+ # Generated during linking, but also an input of the link (-sectcreate):
197
+ # replacing unchanged metadata would make Xcode relink on every build.
198
+ output_bin = "{}/metadata-{}.bin".format(conf_build_dir, arch)
199
+ if os.path.exists(output_bin) and filecmp.cmp(output_bin + ".tmp", output_bin, shallow=False):
200
+ os.remove(output_bin + ".tmp")
201
+ else:
202
+ os.replace(output_bin + ".tmp", output_bin)
203
+
195
204
 
196
205
  for arch in env("ARCHS").split():
197
206
  # skip metadata generation for architectures different than the one specified in the command line
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/framework/internal/metadata-generator-arm64/bin/objc-metadata-generator
3
- size: 37154200 bytes
4
- sha256: 7682e1c285a8f4c619beceb16bcf906fa3fb7e6436b0fb53cea690d8188fb4c0
3
+ size: 35685080 bytes
4
+ sha256: 8e9e7e76b1e74e2fb7a9085f8a22bc37db18f34ab9371c4785956c681dd857ef
@@ -3,6 +3,7 @@
3
3
  import os
4
4
  import shlex
5
5
  import subprocess
6
+ import filecmp
6
7
  import sys
7
8
 
8
9
  print("Python version: " + sys.version)
@@ -126,7 +127,7 @@ def save_stream_to_file(filename, stream):
126
127
  def generate_metadata(arch):
127
128
  # metadata generator arguments
128
129
  generator_call = ["./objc-metadata-generator", "-verbose",
129
- "-output-bin", "{}/metadata-{}.bin".format(conf_build_dir, arch),
130
+ "-output-bin", "{}/metadata-{}.bin.tmp".format(conf_build_dir, arch),
130
131
  "-output-umbrella", "{}/umbrella-{}.h".format(conf_build_dir, arch),
131
132
  "-docset-path", docset_path]
132
133
 
@@ -192,6 +193,14 @@ def generate_metadata(arch):
192
193
  print(error_stream_content)
193
194
  sys.exit(1)
194
195
 
196
+ # Generated during linking, but also an input of the link (-sectcreate):
197
+ # replacing unchanged metadata would make Xcode relink on every build.
198
+ output_bin = "{}/metadata-{}.bin".format(conf_build_dir, arch)
199
+ if os.path.exists(output_bin) and filecmp.cmp(output_bin + ".tmp", output_bin, shallow=False):
200
+ os.remove(output_bin + ".tmp")
201
+ else:
202
+ os.replace(output_bin + ".tmp", output_bin)
203
+
195
204
 
196
205
  for arch in env("ARCHS").split():
197
206
  # skip metadata generation for architectures different than the one specified in the command line
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/framework/internal/metadata-generator-x86_64/bin/objc-metadata-generator
3
- size: 39555632 bytes
4
- sha256: 8fdf58d95c65ac13c65f121e004c016d97f9e90d4f89e85ebbdcc7cc217ad624
3
+ size: 37733816 bytes
4
+ sha256: f3336d137c661e07495e4d5beaab93bd2d79e9926ed89dcfbd3a11407857de16
@@ -1,10 +1,30 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
3
  # Ignore errors while inserting environment variables (some could be readonly)
4
- (echo "set +e"; echo "set +o posix"; export; echo "set -o posix"; echo "set -e";) > ./.build_env_vars.sh
4
+ ENV_FILE=./.build_env_vars.sh
5
+ (echo "set +e"; echo "set +o posix"; export; echo "set -o posix"; echo "set -e";) > "$ENV_FILE.tmp"
6
+ if cmp -s "$ENV_FILE.tmp" "$ENV_FILE"; then
7
+ rm "$ENV_FILE.tmp"
8
+ else
9
+ mv "$ENV_FILE.tmp" "$ENV_FILE"
10
+ fi
5
11
 
6
- # create temporary empty metadata files for XCode LD/LDPLUSPLUS flag analysis
12
+ # create temporary empty metadata files for XCode LD/LDPLUSPLUS flag analysis.
13
+ # Never touch existing ones: the link step reads them, so a newer timestamp
14
+ # would make Xcode relink on every build.
7
15
  for arch in $VALID_ARCHS
8
16
  do :
9
- touch "$CONFIGURATION_BUILD_DIR/metadata-$arch.bin"
17
+ [ -e "$CONFIGURATION_BUILD_DIR/metadata-$arch.bin" ] || touch "$CONFIGURATION_BUILD_DIR/metadata-$arch.bin"
10
18
  done
19
+
20
+ # The metadata generator reads these during linking, which Xcode would skip when
21
+ # only they changed.
22
+ FILTERS_STAMP="$CONFIGURATION_BUILD_DIR/metadata-filters.stamp"
23
+ FILTERS_HASH=$(cd "$SRCROOT" && shasum whitelist.mdg blacklist.mdg 2>/dev/null || true)
24
+ if [ ! -e "$FILTERS_STAMP" ] || [ "$FILTERS_HASH" != "$(cat "$FILTERS_STAMP")" ]; then
25
+ for arch in $VALID_ARCHS
26
+ do :
27
+ touch "$CONFIGURATION_BUILD_DIR/metadata-$arch.bin"
28
+ done
29
+ printf '%s' "$FILTERS_HASH" > "$FILTERS_STAMP"
30
+ fi
@@ -41,16 +41,26 @@ if [ ! -e "${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}" ]; then
41
41
  exit 0
42
42
  fi
43
43
 
44
- echo "Stripping frameworks"
44
+ # Simulator builds never ship, so extra architectures in them are harmless.
45
+ if [[ "${PLATFORM_NAME}" == *simulator ]]; then
46
+ exit 0
47
+ fi
48
+
45
49
  cd "${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}"
46
50
 
47
- for file in $(find . -type f); do
48
- # Skip non-dynamic libraries
49
- if ! [[ "$(file "$file")" == *"dynamically linked shared library"* ]]; then
51
+ shopt -s nullglob
52
+ for file in *.framework/* *.dylib; do
53
+ # Only a framework's main binary (named after it) and loose dylibs are Mach-O
54
+ if [[ "$file" == *.framework/* && "$(basename "$file")" != "$(basename "$(dirname "$file")" .framework)" ]]; then
50
55
  continue
51
56
  fi
52
- # Get architectures for current file
53
- archs="$(lipo -info "${file}" | rev | cut -d ':' -f1 | rev)"
57
+ # A versioned framework's binary (and a dylib's alias) is a symlink, which
58
+ # lipo -output would replace with a regular file; strip the real binary.
59
+ if [ -L "$file" ]; then
60
+ file="$(readlink -f "$file")"
61
+ fi
62
+
63
+ archs="$(lipo -archs "$file" 2>/dev/null)" || continue
54
64
  stripped=""
55
65
  for arch in $archs; do
56
66
  if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then
@@ -59,6 +69,7 @@ for file in $(find . -type f); do
59
69
  stripped="$stripped $arch"
60
70
  fi
61
71
  done
72
+
62
73
  if [[ "$stripped" != "" ]]; then
63
74
  echo "Stripped $file of architectures:$stripped"
64
75
  if [ "${CODE_SIGNING_ALLOWED}" == "YES" ]; then
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nativescript/ios",
3
3
  "description": "NativeScript Runtime for iOS",
4
- "version": "9.1.0-rc.2",
4
+ "version": "9.1.1",
5
5
  "keywords": [
6
6
  "NativeScript",
7
7
  "iOS",
@@ -28,18 +28,18 @@
28
28
  "build-ios": "node prepare-target ios && ./build_all_ios.sh",
29
29
  "build-vision": "node prepare-target visionos && ./build_all_vision.sh",
30
30
  "setup-ci": "./build_metadata_generator.sh",
31
- "update-version": "./update_version.sh",
32
- "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
31
+ "changelog": "node ./scripts/changelog.mjs --write CHANGELOG.md",
33
32
  "version": "npm run changelog && git add CHANGELOG.md"
34
33
  },
35
34
  "license": "Apache-2.0",
36
35
  "devDependencies": {
37
- "conventional-changelog-cli": "^2.1.1",
36
+ "conventional-changelog": "^3.1.25",
38
37
  "dayjs": "^1.11.7",
39
38
  "esbuild": "0.28.1",
40
39
  "eslint": "10.8.0",
41
40
  "globals": "17.8.0",
42
41
  "husky": "^9.0.11",
42
+ "jasmine-core": "7.0.2",
43
43
  "lint-staged": "^15.2.7",
44
44
  "semver": "^7.5.0"
45
45
  },
package/types/index.d.ts CHANGED
@@ -2,7 +2,8 @@
2
2
  // .d.ts per module, mirroring @types/node's layout and the "one module, one
3
3
  // source file" rule in docs/ns-builtin-modules.md. The declared surfaces must
4
4
  // stay in sync with that document (NsRuntimeTests.js / NsUtilTests.js /
5
- // HttpEsmLoaderTests.js assert the export sets at runtime).
5
+ // NsInteropTests.js / HttpEsmLoaderTests.js assert the export sets at
6
+ // runtime).
6
7
  //
7
8
  // `ns:` is not a resolvable package specifier, so these are ambient
8
9
  // declarations: they apply program-wide once this file is in the TypeScript
@@ -25,6 +26,10 @@
25
26
  // in docs/ns-builtin-modules.md, not something to restate in types that would
26
27
  // then conflict.
27
28
 
29
+ /// <reference path="./ns-interop.d.ts" />
30
+ /// <reference path="./ns-interop-ios.d.ts" />
28
31
  /// <reference path="./ns-module.d.ts" />
29
32
  /// <reference path="./ns-runtime.d.ts" />
33
+ /// <reference path="./ns-url.d.ts" />
30
34
  /// <reference path="./ns-util.d.ts" />
35
+ /// <reference path="./ns-worker-threads.d.ts" />
@@ -0,0 +1,39 @@
1
+ declare module "ns:interop/ios" {
2
+ import type { AdoptedPointer, Pointer, Type } from "ns:interop";
3
+
4
+ /**
5
+ * Makes `ptr` own the memory it points to, so it is freed when the pointer
6
+ * is collected. Returns `ptr` itself.
7
+ */
8
+ export function adopt(ptr: Pointer): AdoptedPointer;
9
+
10
+ /**
11
+ * An ArrayBuffer over the bytes of `data`, without copying them. The
12
+ * buffer keeps `data` alive for as long as it is reachable.
13
+ */
14
+ export function bufferFromData(data: NSData & object): ArrayBuffer;
15
+
16
+ /** The Objective-C types, frozen. */
17
+ export const types: Readonly<{
18
+ id: Type<any>;
19
+ class: Type<any>;
20
+ selector: Type<string>;
21
+ protocol: Type<any>;
22
+ unichar: Type<string>;
23
+ /** Pointer-sized, with `void`'s encoding. */
24
+ noop: Type<void>;
25
+ }>;
26
+ }
27
+
28
+ declare module "ns:interop/visionos" {
29
+ export * from "ns:interop/ios";
30
+ }
31
+
32
+ declare module "ns:interop/macos" {
33
+ export * from "ns:interop/ios";
34
+ }
35
+
36
+ // Merges into the class @nativescript/types-ios declares, so `bufferFromData`
37
+ // takes a real NSData there and any object in a program without those types.
38
+ // Declared empty on purpose: a member here would be added to that class.
39
+ interface NSData {}
@@ -0,0 +1,157 @@
1
+ declare module "ns:interop" {
2
+ /** A native `void*`. */
3
+ export interface Pointer {
4
+ /** A new pointer `offset` bytes past this one. */
5
+ add(offset: number): Pointer;
6
+ /** A new pointer `offset` bytes before this one. */
7
+ subtract(offset: number): Pointer;
8
+ /**
9
+ * The address as a number. Addresses wider than 53 bits lose precision;
10
+ * `toBigInt` does not.
11
+ */
12
+ toNumber(): number;
13
+ toBigInt(): bigint;
14
+ /** The address in hexadecimal, `0x`-prefixed. */
15
+ toHexString(): string;
16
+ /** The address in decimal. */
17
+ toDecimalString(): string;
18
+ toString(): string;
19
+ }
20
+
21
+ /**
22
+ * Pointers are interned per address: constructing one for an address that
23
+ * already has a live `Pointer` returns that object.
24
+ */
25
+ export const Pointer: {
26
+ readonly prototype: Pointer;
27
+ /** A pointer to `address`, or the null pointer when omitted. */
28
+ new (address?: number | bigint): Pointer;
29
+ };
30
+
31
+ /**
32
+ * A pointer that owns the memory it points to and frees it when it is
33
+ * garbage collected — what `alloc` returns and `adopt` produces.
34
+ */
35
+ export interface AdoptedPointer extends Pointer {}
36
+
37
+ /**
38
+ * A native type: the C primitives in `types`, a struct constructor, an
39
+ * Objective-C class or protocol. Calling one reads a value of that type at
40
+ * a pointer.
41
+ */
42
+ export interface Type<T> {
43
+ (ptr: Pointer): T;
44
+ }
45
+
46
+ /** The constructor of a C struct, which doubles as its `Type`. */
47
+ export interface StructType<T> extends Type<T> {
48
+ /** A zero-initialized struct. */
49
+ new (): T;
50
+ /** A struct initialized from the fields of `obj`. */
51
+ new (obj: T): T;
52
+ /** A struct copied from the memory at `obj`. */
53
+ new (obj: Pointer): T;
54
+ /** Whether two structs hold the same bytes. */
55
+ equals(left: T, right: T): boolean;
56
+ }
57
+
58
+ /**
59
+ * An object reference whose ownership the native side did not express (a
60
+ * Core Foundation function without an audited ownership convention). The
61
+ * caller decides whether the retain it carries is consumed.
62
+ */
63
+ export interface Unmanaged<T> {
64
+ /** The value, consuming an unbalanced retain of it. */
65
+ takeRetainedValue(): T;
66
+ /** The value, leaving its retain count alone. */
67
+ takeUnretainedValue(): T;
68
+ }
69
+
70
+ /**
71
+ * A typed slot in native memory, used for out parameters and pointer
72
+ * arithmetic. Indexing reads and writes the elements that follow it.
73
+ */
74
+ export interface Reference<T> {
75
+ value: T;
76
+ [index: number]: any;
77
+ }
78
+
79
+ export const Reference: {
80
+ readonly prototype: Reference<any>;
81
+ /**
82
+ * A reference holding `value`; its native type is fixed the first time
83
+ * it is marshalled.
84
+ */
85
+ new <T>(value?: T): Reference<T>;
86
+ /** A view of the memory at `data`, read and written as `type`. */
87
+ new <T>(type: Type<T>, data: Pointer): Reference<T>;
88
+ /** A reference of type `type` initialized with `value`. */
89
+ new <T>(type: Type<T>, value: any): Reference<T>;
90
+ };
91
+
92
+ /**
93
+ * A JS function marshalled as a native function pointer. The pointer stays
94
+ * valid only while this object is reachable from JS.
95
+ */
96
+ export interface FunctionReference<T> {
97
+ (...params: any[]): any;
98
+ }
99
+
100
+ export const FunctionReference: {
101
+ readonly prototype: FunctionReference<any>;
102
+ new <T>(func: T): FunctionReference<T>;
103
+ };
104
+
105
+ /**
106
+ * The size in bytes of a type or of the value behind an instance: a type
107
+ * from `types`, a struct type or instance, a class or protocol, a native
108
+ * object, reference, pointer, block or C function. Throws for anything else.
109
+ */
110
+ export function sizeof(type: any): number;
111
+
112
+ /** `size` bytes of zeroed memory, freed when the pointer is collected. */
113
+ export function alloc(size: number): AdoptedPointer;
114
+
115
+ /**
116
+ * Frees memory a pointer does not own. Does nothing for an adopted
117
+ * pointer, whose memory is freed when it is collected.
118
+ */
119
+ export function free(ptr: Pointer): void;
120
+
121
+ /**
122
+ * A pointer to the native counterpart of `instance`: a native object,
123
+ * class or protocol, a struct, reference, pointer, block, function
124
+ * reference, C function or ArrayBuffer view. `null` for `null`; throws for
125
+ * anything else.
126
+ */
127
+ export function handleof(instance: any): Pointer;
128
+
129
+ /**
130
+ * Decodes UTF-8 from `cString`: `lengthInBytes` bytes, or up to the first
131
+ * NUL when omitted.
132
+ */
133
+ export function stringFromCString(
134
+ cString: Pointer | Reference<any>,
135
+ lengthInBytes?: number
136
+ ): string;
137
+
138
+ /** The C primitive types, frozen. */
139
+ export const types: Readonly<{
140
+ void: Type<void>;
141
+ bool: Type<boolean>;
142
+ int8: Type<number>;
143
+ uint8: Type<number>;
144
+ int16: Type<number>;
145
+ uint16: Type<number>;
146
+ int32: Type<number>;
147
+ uint32: Type<number>;
148
+ int64: Type<number>;
149
+ uint64: Type<number>;
150
+ /** C `unsigned long`. */
151
+ ulong: Type<number>;
152
+ /** C `long`. */
153
+ slong: Type<number>;
154
+ float: Type<number>;
155
+ double: Type<number>;
156
+ }>;
157
+ }
@@ -55,4 +55,30 @@ declare module "ns:runtime" {
55
55
  export function getConfig<K extends keyof RuntimeConfig | (string & {})>(
56
56
  key: K
57
57
  ): K extends keyof RuntimeConfig ? RuntimeConfig[K] : unknown;
58
+
59
+ /**
60
+ * Marks `error` to cross the next JS-to-native boundary as a native
61
+ * exception instead of being reported in JS: `throw escapeException(e)`
62
+ * inside a native callback reaches the native caller's `@try/@catch`, with
63
+ * the original `NSException` when `e` carries one. Returns an `Error`
64
+ * (message and stack copied), so the throw also behaves normally in pure-JS
65
+ * paths. An already-escaped value is returned unchanged; calling with no
66
+ * argument throws `TypeError`.
67
+ */
68
+ export function escapeException(error: unknown): Error;
69
+
70
+ /**
71
+ * Reports `bytes` of native memory held by `target` (a native object,
72
+ * pointer, reference, block or function reference) to the garbage
73
+ * collector, replacing any earlier size; `0` clears it. The charge is
74
+ * returned when `target` is collected or released. Throws `TypeError` for
75
+ * any other value and `RangeError` for a byte count outside `0`–`2^34`.
76
+ */
77
+ export function setExternalSize(target: object, bytes: number): void;
78
+
79
+ /**
80
+ * The size last reported for `target` through `setExternalSize` or by the
81
+ * runtime itself, `0` when there is none.
82
+ */
83
+ export function getExternalSize(target: unknown): number;
58
84
  }
@@ -0,0 +1,135 @@
1
+ declare module "ns:url" {
2
+ /**
3
+ * The WHATWG `URL` surface the runtime implements. Every component setter
4
+ * stringifies its value.
5
+ */
6
+ export interface URL {
7
+ hash: string;
8
+ host: string;
9
+ hostname: string;
10
+ href: string;
11
+ readonly origin: string;
12
+ password: string;
13
+ pathname: string;
14
+ port: string;
15
+ protocol: string;
16
+ search: string;
17
+ /**
18
+ * The same object on every read, kept in step with `search` in both
19
+ * directions.
20
+ */
21
+ readonly searchParams: URLSearchParams;
22
+ username: string;
23
+ /** Returns `href`. */
24
+ toString(): string;
25
+ /** Returns `href`, so `JSON.stringify` serializes a URL as its href. */
26
+ toJSON(): string;
27
+ }
28
+
29
+ /** The WHATWG `URLSearchParams` surface the runtime implements. */
30
+ export interface URLSearchParams {
31
+ readonly size: number;
32
+ append(name: string, value: string): void;
33
+ /** With `value`, removes only the pairs matching both name and value. */
34
+ delete(name: string, value?: string): void;
35
+ get(name: string): string | null;
36
+ getAll(name: string): string[];
37
+ /** With `value`, matches only a pair with both that name and value. */
38
+ has(name: string, value?: string): boolean;
39
+ set(name: string, value: string): void;
40
+ sort(): void;
41
+ forEach<This = undefined>(
42
+ callback: (
43
+ this: This,
44
+ value: string,
45
+ name: string,
46
+ searchParams: URLSearchParams
47
+ ) => void,
48
+ thisArg?: This
49
+ ): void;
50
+ /** The iterators are live: pairs added while iterating are visited. */
51
+ entries(): IterableIterator<[string, string]>;
52
+ keys(): IterableIterator<string>;
53
+ values(): IterableIterator<string>;
54
+ [Symbol.iterator](): IterableIterator<[string, string]>;
55
+ toString(): string;
56
+ }
57
+
58
+ /**
59
+ * The runtime's `URL` constructor: the very function the global of that
60
+ * name was created with, however `globalThis.URL` has been reassigned
61
+ * since. A `url` or `base` that does not parse throws a `TypeError`.
62
+ */
63
+ export const URL: {
64
+ readonly prototype: URL;
65
+ new (url: string, base?: string | URL): URL;
66
+ canParse(url: string, base?: string): boolean;
67
+ /**
68
+ * Registers a `Blob` or `File` under a fresh `blob:nativescript/` URL;
69
+ * anything else yields `null`. `ext` records a file extension for the
70
+ * consumers that read the blob back by URL.
71
+ */
72
+ createObjectURL(
73
+ object: object,
74
+ options?: { ext?: string } | null
75
+ ): string | null;
76
+ revokeObjectURL(url: string): void;
77
+ };
78
+
79
+ /**
80
+ * The runtime's `URLSearchParams` constructor, the very function the global
81
+ * of that name was created with. `init` is a query string (one leading `?`
82
+ * is ignored), an iterable of name/value pairs (an element that is not
83
+ * exactly a pair throws a `TypeError`), or a record of names to values.
84
+ */
85
+ export const URLSearchParams: {
86
+ readonly prototype: URLSearchParams;
87
+ new (
88
+ init?: string | Iterable<readonly string[]> | Record<string, string>
89
+ ): URLSearchParams;
90
+ };
91
+
92
+ /**
93
+ * Converts a `file:` URL to an absolute path, percent-decoding it. Accepts
94
+ * a string or any object with a string `href` (so a `URL` from another
95
+ * realm works too). Throws a `TypeError` for a value that does not parse as
96
+ * a URL, a scheme other than `file:`, a host other than empty or
97
+ * `localhost`, or an encoded `/` in the path.
98
+ */
99
+ export function fileURLToPath(url: string | { readonly href: string }): string;
100
+
101
+ /**
102
+ * Converts an absolute path to a `file:` URL, percent-encoding the
103
+ * characters the URL parser would otherwise read as syntax. There is no
104
+ * working directory to resolve against, so a relative path throws a
105
+ * `TypeError`.
106
+ */
107
+ export function pathToFileURL(path: string): URL;
108
+
109
+ // An interface cannot extend an `import()` type, and inside `global` the
110
+ // bare names mean the globals, hence the self-import.
111
+ import {
112
+ URL as NsURL,
113
+ URLSearchParams as NsURLSearchParams,
114
+ } from "ns:url";
115
+ global {
116
+ // Merged into the DOM's interfaces when a DOM lib is present.
117
+ interface URL extends NsURL {}
118
+ interface URLSearchParams extends NsURLSearchParams {}
119
+ }
120
+ }
121
+
122
+ // Script-level declarations are global. The variables follow @types/node's
123
+ // rule for its own globals: when a DOM lib declares the global (detected
124
+ // through `onmessage`, which only the DOM libs put on `globalThis`), that
125
+ // declaration is reused verbatim so the two `declare var`s agree, and
126
+ // otherwise the module's constructor becomes the global.
127
+ declare var URL: typeof globalThis extends { onmessage: any; URL: infer T }
128
+ ? T
129
+ : typeof import("ns:url").URL;
130
+ declare var URLSearchParams: typeof globalThis extends {
131
+ onmessage: any;
132
+ URLSearchParams: infer T;
133
+ }
134
+ ? T
135
+ : typeof import("ns:url").URLSearchParams;