bundlebee 1.0.5 → 1.0.7
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/README.md +9 -0
- package/index.d.ts +44 -4
- package/index.js +9 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -40,6 +40,15 @@ const mod = await b.load(new URL('file:///path/to/project/'), '/index.js')
|
|
|
40
40
|
const { source, resolutions } = await b1.get('/entrypoint.js', 1)
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
+
### Checkout a specific version on init
|
|
44
|
+
|
|
45
|
+
```js
|
|
46
|
+
const b = new Bundlebee(store, { key, length })
|
|
47
|
+
|
|
48
|
+
// get remote bundle
|
|
49
|
+
const mod = await b.load(new URL('file:///path/to/project/'), '/index.js')
|
|
50
|
+
```
|
|
51
|
+
|
|
43
52
|
## API
|
|
44
53
|
|
|
45
54
|
#### `const b = new Bundlebee(store, [opts])`
|
package/index.d.ts
CHANGED
|
@@ -2,18 +2,30 @@ declare module 'bundlebee' {
|
|
|
2
2
|
import ReadyResource from 'ready-resource'
|
|
3
3
|
import Bundle from 'bare-bundle'
|
|
4
4
|
import Bee from 'hyperbee2'
|
|
5
|
+
import Hypercore from 'hypercore'
|
|
5
6
|
|
|
6
7
|
interface BundlebeeOptions {
|
|
8
|
+
autoUpdate?: boolean
|
|
9
|
+
skipExistingABIs?: boolean
|
|
10
|
+
peerDependencies?: string[]
|
|
7
11
|
[key: string]: any
|
|
8
12
|
}
|
|
9
13
|
|
|
10
14
|
interface Entry {
|
|
15
|
+
id: string
|
|
11
16
|
source: Buffer
|
|
12
17
|
resolutions: Record<string, string>
|
|
13
18
|
}
|
|
14
19
|
|
|
20
|
+
interface Manifest {
|
|
21
|
+
abi: number
|
|
22
|
+
}
|
|
23
|
+
|
|
15
24
|
interface AddOptions {
|
|
16
25
|
skipModules?: boolean
|
|
26
|
+
peerDependencies?: string[]
|
|
27
|
+
abi?: number
|
|
28
|
+
dryRun?: boolean
|
|
17
29
|
}
|
|
18
30
|
|
|
19
31
|
interface LoadOptions {
|
|
@@ -21,22 +33,50 @@ declare module 'bundlebee' {
|
|
|
21
33
|
skipModules?: boolean
|
|
22
34
|
}
|
|
23
35
|
|
|
36
|
+
interface BundleInput {
|
|
37
|
+
bundle: string | Bundle
|
|
38
|
+
abi?: number
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
interface ABIRecord {
|
|
42
|
+
checkout: number
|
|
43
|
+
manifest: Manifest
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
interface HeadInfo {
|
|
47
|
+
key: Buffer
|
|
48
|
+
length: number
|
|
49
|
+
}
|
|
50
|
+
|
|
24
51
|
class Bundlebee extends ReadyResource {
|
|
25
52
|
constructor(store: any, opts?: BundlebeeOptions) // lunte-disable-line
|
|
26
53
|
|
|
27
54
|
static require(
|
|
28
55
|
store: any,
|
|
29
|
-
...args: [...files: string[], opts: BundlebeeOptions]
|
|
56
|
+
...args: [...files: (string | BundleInput)[], opts: BundlebeeOptions]
|
|
30
57
|
): Promise<Bundlebee>
|
|
31
|
-
static require(store: any, ...files: string[]): Promise<Bundlebee>
|
|
58
|
+
static require(store: any, ...files: (string | BundleInput)[]): Promise<Bundlebee>
|
|
59
|
+
static bundleFrom(f: string): Bundle
|
|
60
|
+
|
|
61
|
+
get core(): Hypercore
|
|
62
|
+
get key(): Buffer
|
|
63
|
+
get discoveryKey(): Buffer
|
|
64
|
+
|
|
65
|
+
head(): HeadInfo
|
|
32
66
|
|
|
33
67
|
get(key: string, checkout?: number): Promise<Entry | null>
|
|
68
|
+
checkout(checkout?: number): Promise<Bee>
|
|
69
|
+
manifest(checkout?: number): Promise<Manifest | null>
|
|
70
|
+
peerDependencies(checkout?: number): Promise<Set<string> | null>
|
|
34
71
|
|
|
35
|
-
|
|
72
|
+
findABI(abi: number): Promise<number | undefined>
|
|
73
|
+
allABIs(): AsyncIterable<ABIRecord>
|
|
74
|
+
createEntryStream(checkout?: number): AsyncIterable<Entry>
|
|
36
75
|
|
|
37
76
|
add(root: URL, entrypoint: string, opts?: AddOptions): Promise<Bundle>
|
|
38
|
-
|
|
39
77
|
load(root: URL, entrypoint: string, checkout?: number, opts?: LoadOptions): Promise<any>
|
|
78
|
+
|
|
79
|
+
close(): Promise<void>
|
|
40
80
|
}
|
|
41
81
|
|
|
42
82
|
export = Bundlebee
|
package/index.js
CHANGED
|
@@ -24,7 +24,15 @@ const PEERDEPS_KEY = b4a.from(PEERDEPS_KEY_VALUE)
|
|
|
24
24
|
module.exports = class Bundlebee extends ReadyResource {
|
|
25
25
|
constructor(store, opts = {}) {
|
|
26
26
|
super()
|
|
27
|
-
|
|
27
|
+
|
|
28
|
+
const { key, length = -1 } = opts
|
|
29
|
+
const autoUpdate = !key || length === -1
|
|
30
|
+
|
|
31
|
+
this._bee = new Bee(store, { autoUpdate, ...opts })
|
|
32
|
+
|
|
33
|
+
if (key && length !== -1) {
|
|
34
|
+
this._bee.move({ key, length })
|
|
35
|
+
}
|
|
28
36
|
|
|
29
37
|
this.ready().catch(noop)
|
|
30
38
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bundlebee",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "bundlebee",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"imports": {
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
36
36
|
"format": "prettier . --write",
|
|
37
|
-
"test": "
|
|
38
|
-
"lint": "lunte"
|
|
37
|
+
"test": "brittle-bare test/index.js",
|
|
38
|
+
"lint": "prettier . --check && lunte"
|
|
39
39
|
},
|
|
40
40
|
"repository": {
|
|
41
41
|
"type": "git",
|