bare-module 7.5.2 → 7.5.4

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 CHANGED
@@ -1,9 +1,9 @@
1
- const Semaphore = require('promaphore')
2
1
  const traverse = require('bare-module-traverse')
3
2
  const { startsWithWindowsDriveLetter } = require('bare-module-resolve')
4
3
  const lex = require('bare-module-lexer')
5
4
  const hostParser = require('bare-host-parser')
6
5
  const { isURL, pathToFileURL } = require('bare-url')
6
+ const Semaphore = require('./semaphore')
7
7
  const { urlToPath } = require('./url')
8
8
  const ModuleProtocol = require('./protocol')
9
9
  const ModuleSource = require('./source')
@@ -482,6 +482,16 @@ module.exports = class ModuleLoader {
482
482
  return null
483
483
  }
484
484
 
485
+ _typeFor(url) {
486
+ const { patches } = this._graph
487
+
488
+ const bundle = (patches !== null && patches.get(url.href)) || this._bundleFor(url)
489
+
490
+ if (bundle === null) return undefined
491
+
492
+ return typeByAttribute[bundle.type(url.href)]
493
+ }
494
+
485
495
  _cached(href) {
486
496
  const record = this._cache[href]
487
497
 
@@ -584,7 +594,8 @@ module.exports = class ModuleLoader {
584
594
  contexts: this._contexts,
585
595
  addonContexts: this._addonContexts,
586
596
  resolve: traverse.resolve.bare,
587
- loadable: isLoadable
597
+ loadable: isLoadable,
598
+ typeFor: (url) => this._typeFor(url)
588
599
  }
589
600
 
590
601
  if (this._builtins !== null) opts.builtins = Object.keys(this._builtins)
@@ -0,0 +1,23 @@
1
+ module.exports = class Semaphore {
2
+ constructor(limit) {
3
+ this.limit = limit
4
+ this.active = 0
5
+ this.waiting = []
6
+ }
7
+
8
+ wait() {
9
+ if (this.active < this.limit) {
10
+ this.active++
11
+ return Promise.resolve()
12
+ }
13
+
14
+ return new Promise((resolve) => this.waiting.push(resolve))
15
+ }
16
+
17
+ signal() {
18
+ const next = this.waiting.shift()
19
+
20
+ if (next === undefined) this.active--
21
+ else next()
22
+ }
23
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bare-module",
3
- "version": "7.5.2",
3
+ "version": "7.5.4",
4
4
  "description": "The module system that powers Bare",
5
5
  "exports": {
6
6
  "./package": "./package.json",
@@ -52,16 +52,15 @@
52
52
  "bare": ">=1.35.0"
53
53
  },
54
54
  "dependencies": {
55
- "bare-bundle": "^1.11.0",
55
+ "bare-bundle": "^1.12.0",
56
56
  "bare-host-parser": "^1.0.0",
57
57
  "bare-module-lexer": "^1.7.0",
58
58
  "bare-module-resolve": "^1.12.6",
59
- "bare-module-traverse": "~2.7.0",
59
+ "bare-module-traverse": "^2.8.0",
60
60
  "bare-path": "^3.0.0",
61
61
  "bare-type-stripper": "^0.1.2",
62
62
  "bare-url": "^2.0.1",
63
- "bare-wasm-abi": "^0.1.0",
64
- "promaphore": "^1.0.0"
63
+ "bare-wasm-abi": "^0.1.0"
65
64
  },
66
65
  "devDependencies": {
67
66
  "bare-buffer": "^3.0.2",