@toa.io/boot 1.0.0-alpha.274 → 1.0.0-alpha.278

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.
Files changed (49) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/package.json +10 -10
  3. package/src/atom.js +3 -7
  4. package/src/atomicity.js +2 -6
  5. package/src/bindings/broadcast.js +3 -6
  6. package/src/bindings/constants.js +1 -3
  7. package/src/bindings/consume.js +5 -8
  8. package/src/bindings/emit.js +3 -6
  9. package/src/bindings/factory.js +5 -9
  10. package/src/bindings/index.js +5 -13
  11. package/src/bindings/produce.js +12 -14
  12. package/src/bindings/receive.js +3 -6
  13. package/src/bridge.js +16 -22
  14. package/src/call.js +4 -8
  15. package/src/cascade.js +3 -7
  16. package/src/component.js +8 -12
  17. package/src/composition.js +8 -12
  18. package/src/context.js +3 -7
  19. package/src/contract.js +5 -8
  20. package/src/discovery.js +6 -11
  21. package/src/emission.js +8 -12
  22. package/src/env.js +4 -5
  23. package/src/events.js +1 -5
  24. package/src/exposition.js +3 -7
  25. package/src/extensions/aspects.js +3 -7
  26. package/src/extensions/component.js +2 -6
  27. package/src/extensions/context.js +2 -6
  28. package/src/extensions/emitter.js +2 -6
  29. package/src/extensions/index.js +9 -21
  30. package/src/extensions/instances.js +1 -3
  31. package/src/extensions/load.js +4 -8
  32. package/src/extensions/manage.js +2 -6
  33. package/src/extensions/receiver.js +2 -6
  34. package/src/extensions/resolve.js +36 -11
  35. package/src/extensions/storage.js +2 -6
  36. package/src/extensions/tenants.js +4 -8
  37. package/src/guards.js +3 -7
  38. package/src/index.js +27 -44
  39. package/src/manifest.js +17 -13
  40. package/src/manifest.test.js +7 -7
  41. package/src/operation.js +3 -15
  42. package/src/outbox.js +3 -7
  43. package/src/rc.js +2 -6
  44. package/src/receivers.js +10 -13
  45. package/src/remote.js +15 -10
  46. package/src/span.js +2 -6
  47. package/src/storage.js +11 -10
  48. package/types/index.d.ts +2 -2
  49. package/types/manifest.d.ts +1 -1
package/src/storage.js CHANGED
@@ -1,17 +1,20 @@
1
- 'use strict'
1
+ import { createRequire } from 'node:module'
2
+ import { pathToFileURL } from 'node:url'
3
+ import * as extensions from './extensions/index.js'
2
4
 
3
- const { join } = require('node:path')
4
- const extensions = require('./extensions')
5
+ // import.meta.resolve takes no paths, and the connector is resolved against the
6
+ // component that names it
7
+ const require = createRequire(import.meta.url)
5
8
 
6
9
  /**
7
10
  * @param {toa.norm.Component} manifest
8
11
  * @param {boolean} outbox whether this component publishes anything, and so needs a place to
9
12
  * commit it with the entity
10
13
  */
11
- const storage = (manifest, outbox) => {
14
+ export const storage = async (manifest, outbox) => {
12
15
  if (manifest.entity === undefined) return
13
16
 
14
- const Factory = load(manifest)
17
+ const Factory = await load(manifest)
15
18
 
16
19
  /** @type {toa.core.storages.Factory} */
17
20
  const factory = new Factory()
@@ -20,12 +23,10 @@ const storage = (manifest, outbox) => {
20
23
  return extensions.storage(storage)
21
24
  }
22
25
 
23
- function load (component) {
26
+ async function load (component) {
24
27
  const reference = component.entity.storage
25
- const path = require.resolve(reference, { paths: [component.path, __dirname] })
26
- const { Factory } = require(path)
28
+ const path = require.resolve(reference, { paths: [component.path, import.meta.dirname] })
29
+ const { Factory } = await import(pathToFileURL(path).href)
27
30
 
28
31
  return Factory
29
32
  }
30
-
31
- exports.storage = storage
package/types/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as core from '@toa.io/core'
2
- import * as composition from './composition'
2
+ import * as composition from './composition.js'
3
3
 
4
- export * as bindings from './bindings'
4
+ export * as bindings from './bindings.js'
5
5
 
6
6
  export async function composition (paths: string[], options?: composition.Options): Promise<core.Connector>
7
7
 
@@ -1,5 +1,5 @@
1
1
  import * as _norm from '@toa.io/norm/types'
2
- import * as _composition from './composition'
2
+ import * as _composition from './composition.js'
3
3
 
4
4
  declare namespace toa.boot {
5
5