@lwrjs/shared-utils 0.17.2-alpha.0 → 0.17.2-alpha.10

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/build/cjs/fs.cjs CHANGED
@@ -168,9 +168,7 @@ function normalizeResourcePath(rawPath, {rootDir, assets, contentDir, layoutsDir
168
168
  return rawPath.replace(RESOURCE_DIR_REGEX, function(fullMatch, m1, m2) {
169
169
  const alias = assetsMap[m1] || assetsMap[m2];
170
170
  if (!alias && !allowUnresolvedAlias) {
171
- throw (0, import_diagnostics.createSingleDiagnosticError)({
172
- description: import_diagnostics.descriptions.UNRESOLVABLE.DIR_ALIAS(fullMatch)
173
- }, import_diagnostics.LwrUnresolvableError);
171
+ throw new import_diagnostics.LwrUnresolvableError(import_diagnostics.descriptions.UNRESOLVABLE.DIR_ALIAS(fullMatch), "asset");
174
172
  }
175
173
  return alias;
176
174
  });
@@ -112,9 +112,7 @@ async function getModuleGraphs(specifier, options, moduleRegistry, defRegistry,
112
112
  };
113
113
  const moduleDef = isBundler(defRegistry) ? await defRegistry.getModuleBundle(versionedModuleId, runtimeEnvironment, runtimeParams) : await defRegistry.getModule(versionedModuleId, runtimeParams);
114
114
  if (!moduleDef) {
115
- throw (0, import_diagnostics.createSingleDiagnosticError)({
116
- description: import_diagnostics.descriptions.UNRESOLVABLE.MODULE_ENTRY(versionedModuleId.specifier)
117
- }, import_diagnostics.LwrUnresolvableError);
115
+ throw new import_diagnostics.LwrUnresolvableError(import_diagnostics.descriptions.UNRESOLVABLE.MODULE_ENTRY(versionedModuleId.specifier), "module");
118
116
  }
119
117
  const flattened = [];
120
118
  await traverse(moduleDef, depth, flattened, 0, acc, defRegistry, runtimeEnvironment, runtimeParams);
@@ -95,7 +95,7 @@ function explodeSpecifier(rawSpecifier) {
95
95
  const name = rawName ? [rawName, ...remaining].join("/") : rawNamespace;
96
96
  return {
97
97
  specifier: importee,
98
- namespace,
98
+ namespace: namespace || "",
99
99
  name,
100
100
  version: version ? normalizeVersionFromUri(version) : version
101
101
  };
@@ -33,7 +33,8 @@ __export(exports, {
33
33
  getViewUri: () => getViewUri,
34
34
  isModuleOrBundleUrl: () => isModuleOrBundleUrl,
35
35
  isURL: () => isURL,
36
- removeClientBootstrapConfigurationSuffix: () => removeClientBootstrapConfigurationSuffix
36
+ removeClientBootstrapConfigurationSuffix: () => removeClientBootstrapConfigurationSuffix,
37
+ toHostname: () => toHostname
37
38
  });
38
39
  var import_path_to_regexp = __toModule(require("path-to-regexp"));
39
40
  var import_path = __toModule(require("path"));
@@ -138,3 +139,6 @@ function crossEnvFileURL(url) {
138
139
  }
139
140
  return url;
140
141
  }
142
+ function toHostname(url) {
143
+ return url.replace(/^https?:\/\//, "").replace(/:(\d+)(?=[/.]|$)/, "");
144
+ }
package/build/es/fs.js CHANGED
@@ -3,7 +3,7 @@ import pathLib from 'path';
3
3
  import url from 'url';
4
4
  import crypto from 'crypto';
5
5
  import { slugify } from './identity.js';
6
- import { LwrUnresolvableError, createSingleDiagnosticError, descriptions } from '@lwrjs/diagnostics';
6
+ import { LwrUnresolvableError, descriptions } from '@lwrjs/diagnostics';
7
7
  import { lookup } from 'mime-types';
8
8
  import { Readable } from 'stream';
9
9
  import { logger } from '@lwrjs/diagnostics';
@@ -185,9 +185,7 @@ export function normalizeResourcePath(rawPath, { rootDir, assets, contentDir, la
185
185
  return rawPath.replace(RESOURCE_DIR_REGEX, function (fullMatch, m1, m2) {
186
186
  const alias = assetsMap[m1] || assetsMap[m2];
187
187
  if (!alias && !allowUnresolvedAlias) {
188
- throw createSingleDiagnosticError({
189
- description: descriptions.UNRESOLVABLE.DIR_ALIAS(fullMatch),
190
- }, LwrUnresolvableError);
188
+ throw new LwrUnresolvableError(descriptions.UNRESOLVABLE.DIR_ALIAS(fullMatch), 'asset');
191
189
  }
192
190
  return alias;
193
191
  });
package/build/es/graph.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { getSpecifier, getVersionedModuleId, isBundleDefinition } from './identity.js';
2
- import { LwrUnresolvableError, createSingleDiagnosticError, descriptions } from '@lwrjs/diagnostics';
2
+ import { LwrUnresolvableError, descriptions } from '@lwrjs/diagnostics';
3
3
  import { ModuleNameType } from './import-metadata.js';
4
4
  export var GraphDepth;
5
5
  (function (GraphDepth) {
@@ -117,9 +117,7 @@ options, moduleRegistry, defRegistry, runtimeEnvironment, runtimeParams, visited
117
117
  ? await defRegistry.getModuleBundle(versionedModuleId, runtimeEnvironment, runtimeParams)
118
118
  : await defRegistry.getModule(versionedModuleId, runtimeParams);
119
119
  if (!moduleDef) {
120
- throw createSingleDiagnosticError({
121
- description: descriptions.UNRESOLVABLE.MODULE_ENTRY(versionedModuleId.specifier),
122
- }, LwrUnresolvableError);
120
+ throw new LwrUnresolvableError(descriptions.UNRESOLVABLE.MODULE_ENTRY(versionedModuleId.specifier), 'module');
123
121
  }
124
122
  const flattened = [];
125
123
  await traverse(moduleDef, depth, flattened, 0, acc, defRegistry, runtimeEnvironment, runtimeParams);
@@ -43,6 +43,7 @@ export declare function prettyModuleUriSuffix(specifier: string): string;
43
43
  */
44
44
  interface PartialModuleId extends AbstractModuleId {
45
45
  name: string;
46
+ namespace: string;
46
47
  }
47
48
  export declare function explodeSpecifier(rawSpecifier: string): PartialModuleId;
48
49
  export declare function explodeSpecifiers(rawSpecifiers: string): PartialModuleId[];
@@ -55,7 +55,7 @@ export function explodeSpecifier(rawSpecifier) {
55
55
  // Return an abstract ModuleIdentifier
56
56
  return {
57
57
  specifier: importee,
58
- namespace,
58
+ namespace: namespace || '',
59
59
  name,
60
60
  version: version ? normalizeVersionFromUri(version) : version,
61
61
  };
@@ -38,4 +38,5 @@ export declare function getViewUri(routePath: string, basePath: string, locale:
38
38
  */
39
39
  export declare function isURL(uri: string): boolean;
40
40
  export declare function crossEnvFileURL(url: string): string;
41
+ export declare function toHostname(url: string): string;
41
42
  //# sourceMappingURL=urls.d.ts.map
package/build/es/urls.js CHANGED
@@ -139,4 +139,13 @@ export function crossEnvFileURL(url) {
139
139
  }
140
140
  return url;
141
141
  }
142
+ // Remove the protocol and port from a URL to create a hostname
143
+ // eg: url = https://developer.mozilla.org:4097/en-US/docs/Web/API/URL/hostname
144
+ // protocol = https
145
+ // port = 4097
146
+ // host = developer.mozilla.org:4097
147
+ // hostname = developer.mozilla.org
148
+ export function toHostname(url) {
149
+ return url.replace(/^https?:\/\//, '').replace(/:(\d+)(?=[/.]|$)/, '');
150
+ }
142
151
  //# sourceMappingURL=urls.js.map
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.17.2-alpha.0",
7
+ "version": "0.17.2-alpha.10",
8
8
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
9
9
  "repository": {
10
10
  "type": "git",
@@ -37,7 +37,7 @@
37
37
  "build/**/*.d.ts"
38
38
  ],
39
39
  "dependencies": {
40
- "@lwrjs/diagnostics": "0.17.2-alpha.0",
40
+ "@lwrjs/diagnostics": "0.17.2-alpha.10",
41
41
  "es-module-lexer": "^1.5.4",
42
42
  "fast-json-stable-stringify": "^2.1.0",
43
43
  "magic-string": "^0.30.9",
@@ -50,7 +50,7 @@
50
50
  "slugify": "^1.4.5"
51
51
  },
52
52
  "devDependencies": {
53
- "@lwrjs/types": "0.17.2-alpha.0",
53
+ "@lwrjs/types": "0.17.2-alpha.10",
54
54
  "@types/mime-types": "2.1.4",
55
55
  "@types/path-to-regexp": "^1.7.0",
56
56
  "memfs": "^4.13.0"
@@ -58,5 +58,5 @@
58
58
  "engines": {
59
59
  "node": ">=18.0.0"
60
60
  },
61
- "gitHead": "128e2d6e17d05fb780523b60c2717ef8ebfd9b57"
61
+ "gitHead": "3938f97f31973d7953bb61cff8388c71980c22c7"
62
62
  }