bare-module-traverse 1.4.0 → 1.4.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.
- package/index.d.ts +111 -0
- package/index.js +3 -1
- package/lib/resolve/bare.d.ts +21 -0
- package/lib/resolve/bare.js +2 -3
- package/lib/resolve/default.d.ts +10 -0
- package/lib/resolve/node.d.ts +21 -0
- package/lib/resolve/node.js +2 -3
- package/lib/resolve.d.ts +8 -0
- package/lib/runtime/bare.js +1 -1
- package/lib/runtime/node.js +1 -0
- package/lib/runtime.js +1 -0
- package/package.json +37 -7
package/index.d.ts
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import URL from 'bare-url'
|
|
2
|
+
import Buffer from 'bare-buffer'
|
|
3
|
+
import {
|
|
4
|
+
type ConditionalSpecifier,
|
|
5
|
+
type ImportsMap,
|
|
6
|
+
type ResolutionsMap
|
|
7
|
+
} from 'bare-module-resolve'
|
|
8
|
+
import { type ResolveOptions, type Resolver } from 'bare-addon-resolve'
|
|
9
|
+
import { type Import } from 'bare-module-lexer'
|
|
10
|
+
|
|
11
|
+
interface Dependency {
|
|
12
|
+
url: URL
|
|
13
|
+
source: string | Buffer
|
|
14
|
+
imports: ImportsMap
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface TraverseOptions extends ResolveOptions {
|
|
18
|
+
resolve?: (entry: Import, parentURL: URL, opts?: ResolveOptions) => Resolver
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
declare function traverse(
|
|
22
|
+
entry: URL,
|
|
23
|
+
readModule: (url: URL) => Buffer | string | null,
|
|
24
|
+
listPrefix?: (url: URL) => Iterable<URL>
|
|
25
|
+
): Iterable<Dependency>
|
|
26
|
+
|
|
27
|
+
declare function traverse(
|
|
28
|
+
entry: URL,
|
|
29
|
+
readModule: (url: URL) => Promise<Buffer | string | null>,
|
|
30
|
+
listPrefix?: (url: URL) => AsyncIterable<URL>
|
|
31
|
+
): AsyncIterable<Dependency>
|
|
32
|
+
|
|
33
|
+
declare function traverse(
|
|
34
|
+
entry: URL,
|
|
35
|
+
opts: TraverseOptions,
|
|
36
|
+
readModule: (url: URL) => Buffer | string | null,
|
|
37
|
+
listPrefix?: (url: URL) => Iterable<URL>
|
|
38
|
+
): Iterable<Dependency>
|
|
39
|
+
|
|
40
|
+
declare function traverse(
|
|
41
|
+
entry: URL,
|
|
42
|
+
opts: TraverseOptions,
|
|
43
|
+
readModule: (url: URL) => Promise<Buffer | string | null>,
|
|
44
|
+
listPrefix?: (url: URL) => AsyncIterable<URL>
|
|
45
|
+
): AsyncIterable<Dependency>
|
|
46
|
+
|
|
47
|
+
declare namespace traverse {
|
|
48
|
+
export { type TraverseOptions }
|
|
49
|
+
|
|
50
|
+
export type Traversal = Generator<
|
|
51
|
+
{ module: URL } | { prefix: URL } | { children: URL } | { dependency: URL },
|
|
52
|
+
boolean,
|
|
53
|
+
void | URL[] | Buffer | string | null
|
|
54
|
+
>
|
|
55
|
+
|
|
56
|
+
export interface Artifacts {
|
|
57
|
+
addons: URL[]
|
|
58
|
+
assets: URL[]
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function module(
|
|
62
|
+
url: URL,
|
|
63
|
+
source: string | Buffer,
|
|
64
|
+
artifacts: Artifacts,
|
|
65
|
+
visited: Set<string>,
|
|
66
|
+
opts?: TraverseOptions
|
|
67
|
+
): Traversal
|
|
68
|
+
|
|
69
|
+
export function package(
|
|
70
|
+
url: URL,
|
|
71
|
+
source: string | Buffer,
|
|
72
|
+
artifacts: Artifacts,
|
|
73
|
+
visited: Set<string>,
|
|
74
|
+
opts?: TraverseOptions
|
|
75
|
+
): Traversal
|
|
76
|
+
|
|
77
|
+
export function preresolved(
|
|
78
|
+
url: URL,
|
|
79
|
+
source: string | Buffer,
|
|
80
|
+
resolution: ResolutionsMap,
|
|
81
|
+
artifacts: Artifacts,
|
|
82
|
+
visited: Set<string>,
|
|
83
|
+
opts?: TraverseOptions
|
|
84
|
+
): Traversal
|
|
85
|
+
|
|
86
|
+
export function imports(
|
|
87
|
+
parentURL: URL,
|
|
88
|
+
source: string | Buffer,
|
|
89
|
+
imports: ImportsMap,
|
|
90
|
+
artifacts: Artifacts,
|
|
91
|
+
visited: Set<string>,
|
|
92
|
+
opts?: TraverseOptions
|
|
93
|
+
): Traversal
|
|
94
|
+
|
|
95
|
+
export function prebuilds(
|
|
96
|
+
packageURL: URL,
|
|
97
|
+
artifacts: Artifacts,
|
|
98
|
+
visited: Set<string>,
|
|
99
|
+
opts?: TraverseOptions
|
|
100
|
+
): Traversal
|
|
101
|
+
|
|
102
|
+
export function assets(
|
|
103
|
+
patterns: ConditionalSpecifier,
|
|
104
|
+
packageURL: URL,
|
|
105
|
+
artifacts: Artifacts,
|
|
106
|
+
visited: Set<string>,
|
|
107
|
+
opts?: TraverseOptions
|
|
108
|
+
): Traversal
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export = traverse
|
package/index.js
CHANGED
|
@@ -235,6 +235,7 @@ exports.imports = function* (
|
|
|
235
235
|
resolve = exports.resolve.default,
|
|
236
236
|
builtinProtocol = 'builtin:',
|
|
237
237
|
linkedProtocol = 'linked:',
|
|
238
|
+
deferredProtocol = 'deferred:',
|
|
238
239
|
matchedConditions = []
|
|
239
240
|
} = opts
|
|
240
241
|
|
|
@@ -270,7 +271,8 @@ exports.imports = function* (
|
|
|
270
271
|
|
|
271
272
|
if (
|
|
272
273
|
url.protocol === builtinProtocol ||
|
|
273
|
-
url.protocol === linkedProtocol
|
|
274
|
+
url.protocol === linkedProtocol ||
|
|
275
|
+
url.protocol === deferredProtocol
|
|
274
276
|
) {
|
|
275
277
|
addResolution(imports, specifier, matchedConditions, url)
|
|
276
278
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type Import } from 'bare-module-lexer'
|
|
2
|
+
import { type ResolveOptions, type Resolver } from 'bare-addon-resolve'
|
|
3
|
+
|
|
4
|
+
interface BareResolveOptions extends ResolveOptions {
|
|
5
|
+
platform?: string
|
|
6
|
+
arch?: string
|
|
7
|
+
simulator?: boolean
|
|
8
|
+
target?: string[]
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
declare function resolve(
|
|
12
|
+
entry: Import,
|
|
13
|
+
parentURL: URL,
|
|
14
|
+
opts?: BareResolveOptions
|
|
15
|
+
): Resolver
|
|
16
|
+
|
|
17
|
+
declare namespace resolve {
|
|
18
|
+
export { type BareResolveOptions }
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export = resolve
|
package/lib/resolve/bare.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
const lex = require('bare-module-lexer')
|
|
2
2
|
const resolve = require('../resolve')
|
|
3
|
+
const runtime = require('../runtime')
|
|
3
4
|
|
|
4
5
|
module.exports = function (entry, parentURL, opts = {}) {
|
|
5
|
-
const runtime = require('#runtime')
|
|
6
|
-
|
|
7
6
|
const {
|
|
8
7
|
linked = false,
|
|
9
8
|
platform = runtime.platform,
|
|
10
9
|
arch = runtime.arch,
|
|
11
|
-
simulator =
|
|
10
|
+
simulator = runtime.simulator,
|
|
12
11
|
host = `${platform}-${arch}${simulator ? '-simulator' : ''}`,
|
|
13
12
|
target = [host]
|
|
14
13
|
} = opts
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type Import } from 'bare-module-lexer'
|
|
2
|
+
import { type ResolveOptions, type Resolver } from 'bare-addon-resolve'
|
|
3
|
+
|
|
4
|
+
interface NodeResolveOptions extends ResolveOptions {
|
|
5
|
+
platform?: string
|
|
6
|
+
arch?: string
|
|
7
|
+
simulator?: boolean
|
|
8
|
+
target?: string[]
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
declare function resolve(
|
|
12
|
+
entry: Import,
|
|
13
|
+
parentURL: URL,
|
|
14
|
+
opts?: NodeResolveOptions
|
|
15
|
+
): Resolver
|
|
16
|
+
|
|
17
|
+
declare namespace resolve {
|
|
18
|
+
export { type NodeResolveOptions }
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export = resolve
|
package/lib/resolve/node.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
const lex = require('bare-module-lexer')
|
|
2
2
|
const resolve = require('../resolve')
|
|
3
|
+
const runtime = require('../runtime')
|
|
3
4
|
|
|
4
5
|
module.exports = function (entry, parentURL, opts = {}) {
|
|
5
|
-
const runtime = require('#runtime')
|
|
6
|
-
|
|
7
6
|
const {
|
|
8
7
|
platform = runtime.platform,
|
|
9
8
|
arch = runtime.arch,
|
|
10
|
-
simulator =
|
|
9
|
+
simulator = runtime.simulator,
|
|
11
10
|
host = `${platform}-${arch}${simulator ? '-simulator' : ''}`,
|
|
12
11
|
target = [host]
|
|
13
12
|
} = opts
|
package/lib/resolve.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { module } from 'bare-module-resolve'
|
|
2
|
+
import { addon } from 'bare-addon-resolve'
|
|
3
|
+
|
|
4
|
+
import defaultResolve from './resolve/default'
|
|
5
|
+
import bare from './resolve/bare'
|
|
6
|
+
import node from './resolve/node'
|
|
7
|
+
|
|
8
|
+
export { module, addon, defaultResolve as default, bare, node }
|
package/lib/runtime/bare.js
CHANGED
package/lib/runtime/node.js
CHANGED
package/lib/runtime.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('#runtime')
|
package/package.json
CHANGED
|
@@ -1,17 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bare-module-traverse",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "Low-level module graph traversal for Bare",
|
|
5
5
|
"exports": {
|
|
6
|
-
".":
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
"./resolve
|
|
11
|
-
|
|
6
|
+
".": {
|
|
7
|
+
"types": "./index.d.ts",
|
|
8
|
+
"default": "./index.js"
|
|
9
|
+
},
|
|
10
|
+
"./resolve": {
|
|
11
|
+
"types": "./lib/resolve.d.ts",
|
|
12
|
+
"default": "./lib/resolve.js"
|
|
13
|
+
},
|
|
14
|
+
"./resolve/default": {
|
|
15
|
+
"types": "./lib/resolve/default.d.ts",
|
|
16
|
+
"default": "./lib/resolve/default.js"
|
|
17
|
+
},
|
|
18
|
+
"./resolve/bare": {
|
|
19
|
+
"types": "./lib/resolve/bare.d.ts",
|
|
20
|
+
"default": "./lib/resolve/bare.js"
|
|
21
|
+
},
|
|
22
|
+
"./resolve/node": {
|
|
23
|
+
"types": "./lib/resolve/node.d.ts",
|
|
24
|
+
"default": "./lib/resolve/node.js"
|
|
25
|
+
},
|
|
26
|
+
"./package": "./package.json"
|
|
12
27
|
},
|
|
13
28
|
"files": [
|
|
14
29
|
"index.js",
|
|
30
|
+
"index.d.ts",
|
|
15
31
|
"lib"
|
|
16
32
|
],
|
|
17
33
|
"imports": {
|
|
@@ -42,8 +58,22 @@
|
|
|
42
58
|
"bare-module-resolve": "^1.7.0"
|
|
43
59
|
},
|
|
44
60
|
"devDependencies": {
|
|
61
|
+
"bare-buffer": "^3.0.2",
|
|
62
|
+
"bare-url": "^2.1.3",
|
|
45
63
|
"brittle": "^3.2.1",
|
|
46
64
|
"prettier": "^3.4.2",
|
|
47
65
|
"prettier-config-standard": "^7.0.0"
|
|
66
|
+
},
|
|
67
|
+
"peerDependencies": {
|
|
68
|
+
"bare-buffer": "*",
|
|
69
|
+
"bare-url": "*"
|
|
70
|
+
},
|
|
71
|
+
"peerDependenciesMeta": {
|
|
72
|
+
"bare-buffer": {
|
|
73
|
+
"optional": true
|
|
74
|
+
},
|
|
75
|
+
"bare-url": {
|
|
76
|
+
"optional": true
|
|
77
|
+
}
|
|
48
78
|
}
|
|
49
79
|
}
|