@lwrjs/shared-utils 0.13.6 → 0.15.0-alpha.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.
@@ -1,17 +1,36 @@
1
+ var __create = Object.create;
1
2
  var __defProp = Object.defineProperty;
3
+ var __getProtoOf = Object.getPrototypeOf;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
2
7
  var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
3
8
  var __export = (target, all) => {
4
9
  for (var name in all)
5
10
  __defProp(target, name, {get: all[name], enumerable: true});
6
11
  };
12
+ var __exportStar = (target, module2, desc) => {
13
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
14
+ for (let key of __getOwnPropNames(module2))
15
+ if (!__hasOwnProp.call(target, key) && key !== "default")
16
+ __defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable});
17
+ }
18
+ return target;
19
+ };
20
+ var __toModule = (module2) => {
21
+ return __exportStar(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2);
22
+ };
7
23
 
8
24
  // packages/@lwrjs/shared-utils/src/bundle.ts
9
25
  __markAsModule(exports);
10
26
  __export(exports, {
11
27
  createAmdAlias: () => createAmdAlias,
28
+ createBundleSigner: () => createBundleSigner,
12
29
  getGroupName: () => getGroupName,
13
- isGroupie: () => isGroupie
30
+ isGroupie: () => isGroupie,
31
+ signBundle: () => signBundle
14
32
  });
33
+ var import_identity = __toModule(require("./identity.cjs"));
15
34
  function getGroupName(rawSpecifier, groupsConfig) {
16
35
  for (const [groupName, groupies] of Object.entries(groupsConfig)) {
17
36
  if (groupies.indexOf(rawSpecifier) >= 0) {
@@ -38,3 +57,15 @@ function createAmdAlias(aliasSpecifier, originalSpecifier) {
38
57
  builder.push("});");
39
58
  return builder.join("");
40
59
  }
60
+ function createBundleSigner(moduleBundler) {
61
+ return {
62
+ getBundleSignature: async (moduleId, runtimeEnvironment, runtimeParams, exclude) => {
63
+ const def = await moduleBundler.getModuleBundle(moduleId, runtimeEnvironment, runtimeParams, exclude ? {exclude} : void 0);
64
+ return signBundle(def);
65
+ }
66
+ };
67
+ }
68
+ function signBundle(bundleDef) {
69
+ const integrityHash = bundleDef?.integrity ?? import_identity.LATEST_SIGNATURE;
70
+ return integrityHash.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
71
+ }
@@ -1,4 +1,4 @@
1
- import type { BundleGroups } from '@lwrjs/types';
1
+ import type { BundleDefinition, BundleGroups, BundleSigner, ModuleBundler } from '@lwrjs/types';
2
2
  export declare function getGroupName(rawSpecifier: string, groupsConfig: BundleGroups): string | undefined;
3
3
  export declare function isGroupie(rawSpecifier: string, groupsConfig: BundleGroups): boolean;
4
4
  /**
@@ -13,4 +13,9 @@ export declare function isGroupie(rawSpecifier: string, groupsConfig: BundleGrou
13
13
  *
14
14
  */
15
15
  export declare function createAmdAlias(aliasSpecifier: string, originalSpecifier: string): string;
16
+ /**
17
+ * Creates a BundleSigner to fetch bundle signatures. This creates a facade over the bundle registry.
18
+ */
19
+ export declare function createBundleSigner(moduleBundler: ModuleBundler): BundleSigner;
20
+ export declare function signBundle(bundleDef: BundleDefinition | undefined): string;
16
21
  //# sourceMappingURL=bundle.d.ts.map
@@ -1,3 +1,4 @@
1
+ import { LATEST_SIGNATURE } from './identity.js';
1
2
  export function getGroupName(rawSpecifier, groupsConfig) {
2
3
  for (const [groupName, groupies] of Object.entries(groupsConfig)) {
3
4
  if (groupies.indexOf(rawSpecifier) >= 0) {
@@ -40,4 +41,20 @@ export function createAmdAlias(aliasSpecifier, originalSpecifier) {
40
41
  builder.push('});');
41
42
  return builder.join('');
42
43
  }
44
+ /**
45
+ * Creates a BundleSigner to fetch bundle signatures. This creates a facade over the bundle registry.
46
+ */
47
+ export function createBundleSigner(moduleBundler) {
48
+ return {
49
+ getBundleSignature: async (moduleId, runtimeEnvironment, runtimeParams, exclude) => {
50
+ const def = await moduleBundler.getModuleBundle(moduleId, runtimeEnvironment, runtimeParams, exclude ? { exclude } : undefined);
51
+ return signBundle(def);
52
+ },
53
+ };
54
+ }
55
+ export function signBundle(bundleDef) {
56
+ const integrityHash = bundleDef?.integrity ?? LATEST_SIGNATURE;
57
+ // Replace URL-unsafe characters (+, /) with URL-safe ones (-, _)
58
+ return integrityHash.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
59
+ }
43
60
  //# sourceMappingURL=bundle.js.map
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.13.6",
7
+ "version": "0.15.0-alpha.1",
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.13.6",
40
+ "@lwrjs/diagnostics": "0.15.0-alpha.1",
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.13.6",
53
+ "@lwrjs/types": "0.15.0-alpha.1",
54
54
  "@types/mime-types": "2.1.4",
55
55
  "@types/path-to-regexp": "^1.7.0",
56
56
  "memfs": "^4.9.3"
@@ -58,5 +58,5 @@
58
58
  "engines": {
59
59
  "node": ">=18.0.0"
60
60
  },
61
- "gitHead": "b6558d6ff644c035b3191eea00dfd6c625dc5efa"
61
+ "gitHead": "4547b6c6a7c9e9f33f829d4fdf2082caf4c9c44b"
62
62
  }