bare-module 7.2.0 → 7.2.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/lib/loader.js +24 -15
- package/package.json +1 -1
- package/prebuilds/android-arm/bare-module.bare +0 -0
- package/prebuilds/android-arm64/bare-module.bare +0 -0
- package/prebuilds/android-ia32/bare-module.bare +0 -0
- package/prebuilds/android-x64/bare-module.bare +0 -0
- package/prebuilds/darwin-arm64/bare-module.bare +0 -0
- package/prebuilds/darwin-x64/bare-module.bare +0 -0
- package/prebuilds/ios-arm64/bare-module.bare +0 -0
- package/prebuilds/ios-arm64-simulator/bare-module.bare +0 -0
- package/prebuilds/ios-x64-simulator/bare-module.bare +0 -0
- package/prebuilds/linux-arm64/bare-module.bare +0 -0
- package/prebuilds/linux-x64/bare-module.bare +0 -0
- package/prebuilds/win32-arm64/bare-module.bare +0 -0
- package/prebuilds/win32-x64/bare-module.bare +0 -0
package/lib/loader.js
CHANGED
|
@@ -23,6 +23,8 @@ const engines = Bare.versions
|
|
|
23
23
|
|
|
24
24
|
const cacheOwners = new WeakMap()
|
|
25
25
|
|
|
26
|
+
const defaultProtocol = new ModuleProtocol()
|
|
27
|
+
|
|
26
28
|
function assertProtocol(protocol) {
|
|
27
29
|
if (ModuleProtocol.isProtocol(protocol)) return protocol
|
|
28
30
|
|
|
@@ -178,7 +180,7 @@ module.exports = class ModuleLoader {
|
|
|
178
180
|
concurrency
|
|
179
181
|
} = opts
|
|
180
182
|
|
|
181
|
-
this._protocol = protocol === null ?
|
|
183
|
+
this._protocol = protocol === null ? defaultProtocol : assertProtocol(protocol)
|
|
182
184
|
this._defaultType = defaultTypeFor(defaultType)
|
|
183
185
|
this._builtins = builtinsFor(builtins)
|
|
184
186
|
this._imports = importsFor(imports)
|
|
@@ -188,7 +190,6 @@ module.exports = class ModuleLoader {
|
|
|
188
190
|
this._resolutions = resolutionsFor(resolutions)
|
|
189
191
|
this._manifests = Object.create(null)
|
|
190
192
|
this._bundles = []
|
|
191
|
-
this._patches = null
|
|
192
193
|
this._visited = new Set()
|
|
193
194
|
this._packages = new Map()
|
|
194
195
|
this._prefixes = new Map()
|
|
@@ -202,7 +203,7 @@ module.exports = class ModuleLoader {
|
|
|
202
203
|
// other, protocol and builtins and all. The cache is therefore claimed
|
|
203
204
|
// before anything is read into it, and what it already holds is checked
|
|
204
205
|
// against the claim.
|
|
205
|
-
claimCache(this)
|
|
206
|
+
this._graph = claimCache(this)
|
|
206
207
|
|
|
207
208
|
for (const href in this._cache) {
|
|
208
209
|
const record = this._cache[href]
|
|
@@ -230,9 +231,11 @@ module.exports = class ModuleLoader {
|
|
|
230
231
|
}
|
|
231
232
|
|
|
232
233
|
patch(bundle) {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
234
|
+
const graph = this._graph
|
|
235
|
+
|
|
236
|
+
if (graph.patches === null) {
|
|
237
|
+
graph.patches = new Map()
|
|
238
|
+
graph.reader = patching(graph.protocol, graph.patches)
|
|
236
239
|
}
|
|
237
240
|
|
|
238
241
|
const patched = []
|
|
@@ -240,7 +243,7 @@ module.exports = class ModuleLoader {
|
|
|
240
243
|
for (const href of bundle.keys()) {
|
|
241
244
|
const url = new URL(href)
|
|
242
245
|
|
|
243
|
-
|
|
246
|
+
graph.patches.set(href, bundle)
|
|
244
247
|
|
|
245
248
|
this._forget(url)
|
|
246
249
|
|
|
@@ -384,15 +387,15 @@ module.exports = class ModuleLoader {
|
|
|
384
387
|
}
|
|
385
388
|
|
|
386
389
|
_answersFor(protocol) {
|
|
387
|
-
return protocol === this.
|
|
390
|
+
return protocol === this._graph.reader ? this._answers : null
|
|
388
391
|
}
|
|
389
392
|
|
|
390
393
|
_protocolFor(url) {
|
|
391
394
|
const bundle = this._bundleFor(url)
|
|
392
395
|
|
|
393
|
-
if (bundle === null) return this.
|
|
396
|
+
if (bundle === null) return this._graph.reader
|
|
394
397
|
|
|
395
|
-
return this.
|
|
398
|
+
return this._graph.reader.extend({
|
|
396
399
|
resolve(context, url) {
|
|
397
400
|
return bundleOwns(bundle, url) ? url : context.resolve(url)
|
|
398
401
|
},
|
|
@@ -658,7 +661,7 @@ module.exports = class ModuleLoader {
|
|
|
658
661
|
if (href in this._resolutions === false) this._resolutions[href] = bundle.resolutions[href]
|
|
659
662
|
}
|
|
660
663
|
|
|
661
|
-
const protocol = this.
|
|
664
|
+
const protocol = this._graph.reader.extend({
|
|
662
665
|
exists(context, url) {
|
|
663
666
|
if (bundleOwns(bundle, url)) return true
|
|
664
667
|
|
|
@@ -1145,12 +1148,16 @@ function claimCache(loader) {
|
|
|
1145
1148
|
const owner = cacheOwners.get(loader._cache)
|
|
1146
1149
|
|
|
1147
1150
|
if (owner === undefined) {
|
|
1148
|
-
|
|
1151
|
+
const graph = {
|
|
1149
1152
|
protocol: loader._protocol,
|
|
1150
|
-
builtins: loader._builtins
|
|
1151
|
-
|
|
1153
|
+
builtins: loader._builtins,
|
|
1154
|
+
patches: null,
|
|
1155
|
+
reader: loader._protocol
|
|
1156
|
+
}
|
|
1157
|
+
|
|
1158
|
+
cacheOwners.set(loader._cache, graph)
|
|
1152
1159
|
|
|
1153
|
-
return
|
|
1160
|
+
return graph
|
|
1154
1161
|
}
|
|
1155
1162
|
|
|
1156
1163
|
if (owner.protocol !== loader._protocol) {
|
|
@@ -1160,6 +1167,8 @@ function claimCache(loader) {
|
|
|
1160
1167
|
if (owner.builtins !== loader._builtins) {
|
|
1161
1168
|
throw errors.CACHE_INCOMPATIBLE('Cache is read with different builtins')
|
|
1162
1169
|
}
|
|
1170
|
+
|
|
1171
|
+
return owner
|
|
1163
1172
|
}
|
|
1164
1173
|
|
|
1165
1174
|
function assertCompatible(loader, href, record) {
|
package/package.json
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|