@syncbridge/common 0.5.7 → 0.5.8

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/constants.js CHANGED
@@ -1,4 +1,4 @@
1
- export const version = '0.5.7';
1
+ export const version = '0.5.8';
2
2
  export const OWN_ELEMENT_METADATA = Symbol.for('OWN_ELEMENT_METADATA');
3
3
  export const COMPONENT_OPTIONS = Symbol.for('COMPONENT_OPTIONS');
4
4
  export const PROCESSOR_OPTIONS = Symbol.for('PROCESSOR_OPTIONS');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@syncbridge/common",
3
- "version": "0.5.7",
3
+ "version": "0.5.8",
4
4
  "description": "SyncBridge Common utilities",
5
5
  "author": "Panates Inc",
6
6
  "license": "MIT",
@@ -3,6 +3,7 @@ import { Type } from 'ts-gems';
3
3
  import { ComponentBase } from '../classes/component-base.js';
4
4
  import { ProcessorBase } from '../classes/processor-base.js';
5
5
  import { ComponentMetadata, ProcessorMetadata } from '../models/index.js';
6
+ import type { ExtensionRegistry } from './extension-registry.js';
6
7
  /**
7
8
  *
8
9
  */
@@ -21,7 +22,7 @@ export declare class ExtensionPackage {
21
22
  * @static
22
23
  */
23
24
  static fromDirectory(directory: string): Promise<ExtensionPackage>;
24
- static fromNodePackage(specifier: string, parentPath?: string | URL): Promise<ExtensionPackage>;
25
+ static fromNodePackage(specifier: string, resolver: ExtensionRegistry.Resolver | undefined): Promise<ExtensionPackage>;
25
26
  }
26
27
  /**
27
28
  *
@@ -1,6 +1,5 @@
1
1
  import 'reflect-metadata';
2
2
  import fs from 'node:fs';
3
- import { createRequire } from 'node:module';
4
3
  import path from 'node:path';
5
4
  import process from 'node:process';
6
5
  import { fileURLToPath, pathToFileURL } from 'node:url';
@@ -119,11 +118,11 @@ export class ExtensionPackage {
119
118
  out.sortVersions();
120
119
  return out;
121
120
  }
122
- static async fromNodePackage(specifier, parentPath) {
121
+ static async fromNodePackage(specifier, resolver) {
123
122
  const compMetadataTypeDecoder = await getCompMetadataTypeDecoder();
124
123
  const procMetadataTypeDecoder = await getProcMetadataTypeDecoder();
125
- const resolver = createRequire(parentPath || import.meta.url).resolve;
126
- let entryPoint = resolver(specifier);
124
+ // const resolver = createRequire(parentPath || import.meta.url).resolve;
125
+ let entryPoint = (resolver || import.meta.resolve)(specifier);
127
126
  const pkgJson = locatePkgJson(path.dirname(entryPoint));
128
127
  if (!pkgJson) {
129
128
  throw new TypeError(`Can't locate package.json file for "${specifier}"`);
@@ -1,6 +1,8 @@
1
+ import { URL } from 'node:url';
1
2
  import { Type } from 'ts-gems';
2
3
  import { ExtensionPackage, ExtensionPackageComponent, ExtensionPackageProcessor } from './extension-package.js';
3
4
  export declare namespace ExtensionRegistry {
5
+ type Resolver = (specifier: string, parent?: string | URL) => string;
4
6
  const packages: Map<string, ExtensionPackage[]>;
5
7
  const components: Map<string, ExtensionPackageComponent[]>;
6
8
  const processors: Map<string, ExtensionPackageProcessor[]>;
@@ -23,7 +25,7 @@ export declare namespace ExtensionRegistry {
23
25
  /**
24
26
  *
25
27
  */
26
- function setParentPath(value: string | URL): void;
28
+ function setResolver(fn: Resolver | undefined): void;
27
29
  /**
28
30
  *
29
31
  */
@@ -5,7 +5,7 @@ import { resolvePromisesDeep } from '../utils/resolve-promises.js';
5
5
  import { ExtensionPackage, ExtensionPackageComponent, ExtensionPackageProcessor, } from './extension-package.js';
6
6
  export var ExtensionRegistry;
7
7
  (function (ExtensionRegistry) {
8
- let _parentPath = import.meta.url;
8
+ let _resolver;
9
9
  ExtensionRegistry.packages = new Map();
10
10
  ExtensionRegistry.components = new Map();
11
11
  ExtensionRegistry.processors = new Map();
@@ -51,10 +51,10 @@ export var ExtensionRegistry;
51
51
  /**
52
52
  *
53
53
  */
54
- function setParentPath(value) {
55
- _parentPath = value;
54
+ function setResolver(fn) {
55
+ _resolver = fn;
56
56
  }
57
- ExtensionRegistry.setParentPath = setParentPath;
57
+ ExtensionRegistry.setResolver = setResolver;
58
58
  /**
59
59
  *
60
60
  */
@@ -68,7 +68,7 @@ export var ExtensionRegistry;
68
68
  *
69
69
  */
70
70
  async function registerNodePackage(specifier) {
71
- const pkg = await ExtensionPackage.fromNodePackage(specifier, _parentPath);
71
+ const pkg = await ExtensionPackage.fromNodePackage(specifier, _resolver);
72
72
  storePackage(pkg);
73
73
  return pkg;
74
74
  }