bundlebee 1.0.4 → 1.0.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.
- package/index.d.ts +45 -5
- package/index.js +17 -4
- package/package.json +1 -1
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
|
-
constructor(store: any, opts?: BundlebeeOptions)
|
|
52
|
+
constructor(store: any, opts?: BundlebeeOptions)
|
|
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
|
@@ -163,6 +163,23 @@ module.exports = class Bundlebee extends ReadyResource {
|
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
+
async *allABIs() {
|
|
167
|
+
for await (const d of this._bee.createChangesStream()) {
|
|
168
|
+
let record = null
|
|
169
|
+
for (const b of d.batch) {
|
|
170
|
+
if (!b.keys) continue
|
|
171
|
+
const r = b.keys.find((k) => k.key.toString() === MANIFEST_KEY_VALUE)
|
|
172
|
+
if (!r) continue
|
|
173
|
+
record = r
|
|
174
|
+
}
|
|
175
|
+
if (!record) continue
|
|
176
|
+
|
|
177
|
+
const manifest = c.decode(Manifest, record.value)
|
|
178
|
+
|
|
179
|
+
yield { checkout: d.head, manifest }
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
166
183
|
async checkout(checkout) {
|
|
167
184
|
if (!this.opened) await this.ready()
|
|
168
185
|
|
|
@@ -287,10 +304,6 @@ module.exports = class Bundlebee extends ReadyResource {
|
|
|
287
304
|
|
|
288
305
|
const w = this._bee.write()
|
|
289
306
|
|
|
290
|
-
// for await (const { key } of this._bee.createReadStream()) {
|
|
291
|
-
// w.tryDelete(key)
|
|
292
|
-
// }
|
|
293
|
-
|
|
294
307
|
for (const f in data.bundle.files) {
|
|
295
308
|
w.tryPut(
|
|
296
309
|
b4a.from(f),
|