@lwrjs/shared-utils 0.10.0-alpha.13 → 0.10.0-alpha.14
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/bundle.cjs +28 -0
- package/build/cjs/env.cjs +3 -2
- package/build/cjs/html-meta.cjs +6 -0
- package/build/cjs/identity.cjs +2 -2
- package/build/cjs/import-metadata.cjs +5 -1
- package/build/cjs/index.cjs +1 -0
- package/build/es/bundle.d.ts +4 -0
- package/build/es/bundle.js +16 -0
- package/build/es/env.js +13 -8
- package/build/es/html-meta.d.ts +2 -0
- package/build/es/html-meta.js +4 -0
- package/build/es/identity.d.ts +1 -1
- package/build/es/identity.js +2 -2
- package/build/es/import-metadata.d.ts +1 -1
- package/build/es/import-metadata.js +6 -1
- package/build/es/index.d.ts +1 -0
- package/build/es/index.js +1 -0
- package/package.json +5 -5
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
3
|
+
var __export = (target, all) => {
|
|
4
|
+
for (var name in all)
|
|
5
|
+
__defProp(target, name, {get: all[name], enumerable: true});
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
// packages/@lwrjs/shared-utils/src/bundle.ts
|
|
9
|
+
__markAsModule(exports);
|
|
10
|
+
__export(exports, {
|
|
11
|
+
getGroupName: () => getGroupName,
|
|
12
|
+
isGroupie: () => isGroupie
|
|
13
|
+
});
|
|
14
|
+
function getGroupName(rawSpecifier, groupsConfig) {
|
|
15
|
+
for (const [groupName, groupies] of Object.entries(groupsConfig)) {
|
|
16
|
+
if (groupies.indexOf(rawSpecifier) >= 0) {
|
|
17
|
+
return groupName;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function isGroupie(rawSpecifier, groupsConfig) {
|
|
22
|
+
for (const groupies of Object.values(groupsConfig)) {
|
|
23
|
+
if (groupies.indexOf(rawSpecifier) >= 0) {
|
|
24
|
+
return true;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return false;
|
|
28
|
+
}
|
package/build/cjs/env.cjs
CHANGED
|
@@ -12,9 +12,10 @@ __export(exports, {
|
|
|
12
12
|
});
|
|
13
13
|
function getFeatureFlags() {
|
|
14
14
|
return {
|
|
15
|
+
ASSETS_ON_LAMBDA: process.env.ASSETS_ON_LAMBDA !== void 0 && process.env.ASSETS_ON_LAMBDA.toLowerCase() === "true" ? true : false,
|
|
15
16
|
LEGACY_LOADER: process.env.LEGACY_LOADER !== void 0 && process.env.LEGACY_LOADER.toLowerCase() === "true" ? true : false,
|
|
16
|
-
SSR_STATIC_BUNDLES: process.env.SSR_STATIC_BUNDLES !== void 0 && process.env.SSR_STATIC_BUNDLES.toLowerCase() === "true" ? true : false,
|
|
17
17
|
SSR_SANDBOX_WORKER: process.env.SSR_SANDBOX_WORKER !== void 0 && process.env.SSR_SANDBOX_WORKER.toLowerCase() === "true" ? true : false,
|
|
18
|
-
|
|
18
|
+
SSR_STATIC_BUNDLES: process.env.SSR_STATIC_BUNDLES !== void 0 && process.env.SSR_STATIC_BUNDLES.toLowerCase() === "true" ? true : false,
|
|
19
|
+
UNVERSIONED_ALIASES: process.env.UNVERSIONED_ALIASES !== void 0 && process.env.UNVERSIONED_ALIASES.toLowerCase() === "true" ? true : false
|
|
19
20
|
};
|
|
20
21
|
}
|
package/build/cjs/html-meta.cjs
CHANGED
|
@@ -24,7 +24,9 @@ var __toModule = (module2) => {
|
|
|
24
24
|
// packages/@lwrjs/shared-utils/src/html-meta.ts
|
|
25
25
|
__markAsModule(exports);
|
|
26
26
|
__export(exports, {
|
|
27
|
+
HYDRATE_DIRECTIVE: () => HYDRATE_DIRECTIVE,
|
|
27
28
|
extractMetadataFromHtml: () => extractMetadataFromHtml,
|
|
29
|
+
hasHydrateDirective: () => hasHydrateDirective,
|
|
28
30
|
isRelative: () => isRelative,
|
|
29
31
|
isSelfUrl: () => isSelfUrl
|
|
30
32
|
});
|
|
@@ -117,3 +119,7 @@ async function extractMetadataFromHtml(htmlSource) {
|
|
|
117
119
|
inputStream.pipe(parser);
|
|
118
120
|
});
|
|
119
121
|
}
|
|
122
|
+
var HYDRATE_DIRECTIVE = "lwr:hydrate";
|
|
123
|
+
function hasHydrateDirective(props = {}) {
|
|
124
|
+
return Object.keys(props).filter((propName) => propName === HYDRATE_DIRECTIVE).length > 0;
|
|
125
|
+
}
|
package/build/cjs/identity.cjs
CHANGED
|
@@ -182,11 +182,11 @@ function slugify(name) {
|
|
|
182
182
|
function getPropFromAttrName(propName) {
|
|
183
183
|
return propName.replace(/-([a-z])/g, (g) => g[1].toUpperCase());
|
|
184
184
|
}
|
|
185
|
-
function getModuleUriPrefix({apiVersion, bundle, format, compat, basePath}, {locale, environment} = {}) {
|
|
185
|
+
function getModuleUriPrefix({apiVersion, bundle, format, compat, basePath}, {locale, environment} = {}, bundleId) {
|
|
186
186
|
const localePart = locale ? `/${LOCALE_SIGIL}/${locale}` : "";
|
|
187
187
|
const environmentPart = environment ? `/${ENVIRONMENT_SIGIL}/${environment}` : "";
|
|
188
188
|
if (bundle) {
|
|
189
|
-
return `${basePath}/${apiVersion}/bundle/${format}${localePart}${environmentPart}/${BUNDLE_SIGIL}
|
|
189
|
+
return `${basePath}/${apiVersion}/bundle/${format}${localePart}${environmentPart}/${BUNDLE_SIGIL}/${bundleId || "0"}/module/mi/`;
|
|
190
190
|
} else {
|
|
191
191
|
return `${basePath}/${apiVersion}/module/${format}/${compat}${localePart}${environmentPart}/mi/`;
|
|
192
192
|
}
|
|
@@ -28,6 +28,7 @@ __export(exports, {
|
|
|
28
28
|
getImportMetadata: () => getImportMetadata
|
|
29
29
|
});
|
|
30
30
|
var import_es_module_lexer = __toModule(require("es-module-lexer"));
|
|
31
|
+
var import_logger = __toModule(require("./logger.cjs"));
|
|
31
32
|
var ModuleNameType;
|
|
32
33
|
(function(ModuleNameType2) {
|
|
33
34
|
ModuleNameType2["string"] = "string";
|
|
@@ -49,12 +50,15 @@ async function getImportMetadata(compiledSource) {
|
|
|
49
50
|
const isStringLiteral = moduleSpecifier.startsWith("'") || moduleSpecifier.startsWith('"');
|
|
50
51
|
const moduleNameType = isStringLiteral ? ModuleNameType.string : ModuleNameType.unresolved;
|
|
51
52
|
moduleSpecifier = isStringLiteral ? moduleSpecifier.slice(1, -1) : moduleSpecifier;
|
|
53
|
+
if (import_logger.logger.currentLevel === import_logger.DEBUG || import_logger.logger.currentLevel === import_logger.VERBOSE) {
|
|
54
|
+
import_logger.logger.debug(`[import-metadata] Import from dynamic import ${compiledSource.slice(moduleImportLocation.ss, moduleImportLocation.se)} -> ${compiledSource.slice(moduleImportLocation.ss, moduleImportLocation.s)}`);
|
|
55
|
+
}
|
|
52
56
|
dynamicImports.push({
|
|
53
57
|
moduleSpecifier,
|
|
54
58
|
moduleNameType,
|
|
55
59
|
location,
|
|
56
60
|
importLocation: {
|
|
57
|
-
startColumn: moduleImportLocation.
|
|
61
|
+
startColumn: moduleImportLocation.ss,
|
|
58
62
|
endColumn: moduleImportLocation.s
|
|
59
63
|
}
|
|
60
64
|
});
|
package/build/cjs/index.cjs
CHANGED
|
@@ -34,3 +34,4 @@ __exportStar(exports, __toModule(require("./urls.cjs")));
|
|
|
34
34
|
__exportStar(exports, __toModule(require("./env.cjs")));
|
|
35
35
|
__exportStar(exports, __toModule(require("./logger.cjs")));
|
|
36
36
|
__exportStar(exports, __toModule(require("./lwr-app-observer.cjs")));
|
|
37
|
+
__exportStar(exports, __toModule(require("./bundle.cjs")));
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { BundleGroups } from '@lwrjs/types';
|
|
2
|
+
export declare function getGroupName(rawSpecifier: string, groupsConfig: BundleGroups): string | undefined;
|
|
3
|
+
export declare function isGroupie(rawSpecifier: string, groupsConfig: BundleGroups): boolean;
|
|
4
|
+
//# sourceMappingURL=bundle.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function getGroupName(rawSpecifier, groupsConfig) {
|
|
2
|
+
for (const [groupName, groupies] of Object.entries(groupsConfig)) {
|
|
3
|
+
if (groupies.indexOf(rawSpecifier) >= 0) {
|
|
4
|
+
return groupName;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export function isGroupie(rawSpecifier, groupsConfig) {
|
|
9
|
+
for (const groupies of Object.values(groupsConfig)) {
|
|
10
|
+
if (groupies.indexOf(rawSpecifier) >= 0) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=bundle.js.map
|
package/build/es/env.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
export function getFeatureFlags() {
|
|
2
2
|
// Add any new feature flags here to parse from environment variables
|
|
3
3
|
return {
|
|
4
|
-
//
|
|
5
|
-
|
|
4
|
+
// Should we load load the assets from the lambda on MRT
|
|
5
|
+
ASSETS_ON_LAMBDA: process.env.ASSETS_ON_LAMBDA !== undefined &&
|
|
6
|
+
process.env.ASSETS_ON_LAMBDA.toLowerCase() === 'true'
|
|
6
7
|
? true
|
|
7
8
|
: false,
|
|
8
|
-
//
|
|
9
|
-
|
|
10
|
-
process.env.SSR_STATIC_BUNDLES.toLowerCase() === 'true'
|
|
9
|
+
// DEFAULT LEGACY_LOADER = false;
|
|
10
|
+
LEGACY_LOADER: process.env.LEGACY_LOADER !== undefined && process.env.LEGACY_LOADER.toLowerCase() === 'true'
|
|
11
11
|
? true
|
|
12
12
|
: false,
|
|
13
13
|
// Should we use a js worker for SSR, sand-boxing = false (use locker for ssr sand-boxing)
|
|
@@ -15,9 +15,14 @@ export function getFeatureFlags() {
|
|
|
15
15
|
process.env.SSR_SANDBOX_WORKER.toLowerCase() === 'true'
|
|
16
16
|
? true
|
|
17
17
|
: false,
|
|
18
|
-
//
|
|
19
|
-
|
|
20
|
-
process.env.
|
|
18
|
+
// SSR should concatenate bundles, default = false
|
|
19
|
+
SSR_STATIC_BUNDLES: process.env.SSR_STATIC_BUNDLES !== undefined &&
|
|
20
|
+
process.env.SSR_STATIC_BUNDLES.toLowerCase() === 'true'
|
|
21
|
+
? true
|
|
22
|
+
: false,
|
|
23
|
+
// AMD Module Bundles include un-versioned aliases
|
|
24
|
+
UNVERSIONED_ALIASES: process.env.UNVERSIONED_ALIASES !== undefined &&
|
|
25
|
+
process.env.UNVERSIONED_ALIASES.toLowerCase() === 'true'
|
|
21
26
|
? true
|
|
22
27
|
: false,
|
|
23
28
|
};
|
package/build/es/html-meta.d.ts
CHANGED
|
@@ -6,4 +6,6 @@ export declare function isSelfUrl(url: string): boolean;
|
|
|
6
6
|
* @param htmlSource - An HTML string to parse
|
|
7
7
|
*/
|
|
8
8
|
export declare function extractMetadataFromHtml(htmlSource: string): Promise<RenderedViewMetadata>;
|
|
9
|
+
export declare const HYDRATE_DIRECTIVE = "lwr:hydrate";
|
|
10
|
+
export declare function hasHydrateDirective(props?: {}): boolean;
|
|
9
11
|
//# sourceMappingURL=html-meta.d.ts.map
|
package/build/es/html-meta.js
CHANGED
|
@@ -105,4 +105,8 @@ export async function extractMetadataFromHtml(htmlSource) {
|
|
|
105
105
|
inputStream.pipe(parser);
|
|
106
106
|
});
|
|
107
107
|
}
|
|
108
|
+
export const HYDRATE_DIRECTIVE = 'lwr:hydrate';
|
|
109
|
+
export function hasHydrateDirective(props = {}) {
|
|
110
|
+
return Object.keys(props).filter((propName) => propName === HYDRATE_DIRECTIVE).length > 0;
|
|
111
|
+
}
|
|
108
112
|
//# sourceMappingURL=html-meta.js.map
|
package/build/es/identity.d.ts
CHANGED
|
@@ -129,7 +129,7 @@ export declare function getPropFromAttrName(propName: string): string;
|
|
|
129
129
|
* @param param0 - URI props from the Runtime Environment
|
|
130
130
|
* @param param1 - URI props from the Runtime Params
|
|
131
131
|
*/
|
|
132
|
-
export declare function getModuleUriPrefix({ apiVersion, bundle, format, compat, basePath }: RuntimeEnvironment, { locale, environment }?: RuntimeParams): string;
|
|
132
|
+
export declare function getModuleUriPrefix({ apiVersion, bundle, format, compat, basePath }: RuntimeEnvironment, { locale, environment }?: RuntimeParams, bundleId?: string): string;
|
|
133
133
|
/**
|
|
134
134
|
* Create a URI Mapping API URI prefix, stopping where the specifiers would be (at "mp/")
|
|
135
135
|
* @param param0 - URI props from the Runtime Environment
|
package/build/es/identity.js
CHANGED
|
@@ -221,11 +221,11 @@ export function getPropFromAttrName(propName) {
|
|
|
221
221
|
* @param param0 - URI props from the Runtime Environment
|
|
222
222
|
* @param param1 - URI props from the Runtime Params
|
|
223
223
|
*/
|
|
224
|
-
export function getModuleUriPrefix({ apiVersion, bundle, format, compat, basePath }, { locale, environment } = {}) {
|
|
224
|
+
export function getModuleUriPrefix({ apiVersion, bundle, format, compat, basePath }, { locale, environment } = {}, bundleId) {
|
|
225
225
|
const localePart = locale ? `/${LOCALE_SIGIL}/${locale}` : '';
|
|
226
226
|
const environmentPart = environment ? `/${ENVIRONMENT_SIGIL}/${environment}` : '';
|
|
227
227
|
if (bundle) {
|
|
228
|
-
return `${basePath}/${apiVersion}/bundle/${format}${localePart}${environmentPart}/${BUNDLE_SIGIL}
|
|
228
|
+
return `${basePath}/${apiVersion}/bundle/${format}${localePart}${environmentPart}/${BUNDLE_SIGIL}/${bundleId || '0'}/module/mi/`;
|
|
229
229
|
}
|
|
230
230
|
else {
|
|
231
231
|
return `${basePath}/${apiVersion}/module/${format}/${compat}${localePart}${environmentPart}/mi/`;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { parse as parseImports } from 'es-module-lexer';
|
|
2
|
+
import { DEBUG, logger, VERBOSE } from './logger.js';
|
|
2
3
|
export var ModuleNameType;
|
|
3
4
|
(function (ModuleNameType) {
|
|
4
5
|
ModuleNameType["string"] = "string";
|
|
@@ -22,12 +23,16 @@ export async function getImportMetadata(compiledSource) {
|
|
|
22
23
|
const isStringLiteral = moduleSpecifier.startsWith("'") || moduleSpecifier.startsWith('"');
|
|
23
24
|
const moduleNameType = isStringLiteral ? ModuleNameType.string : ModuleNameType.unresolved;
|
|
24
25
|
moduleSpecifier = isStringLiteral ? moduleSpecifier.slice(1, -1) : moduleSpecifier; // remove quotes
|
|
26
|
+
// Expecting: import(rootSpecifier) -> import(
|
|
27
|
+
if (logger.currentLevel === DEBUG || logger.currentLevel === VERBOSE) {
|
|
28
|
+
logger.debug(`[import-metadata] Import from dynamic import ${compiledSource.slice(moduleImportLocation.ss, moduleImportLocation.se)} -> ${compiledSource.slice(moduleImportLocation.ss, moduleImportLocation.s)}`);
|
|
29
|
+
}
|
|
25
30
|
dynamicImports.push({
|
|
26
31
|
moduleSpecifier,
|
|
27
32
|
moduleNameType,
|
|
28
33
|
location,
|
|
29
34
|
importLocation: {
|
|
30
|
-
startColumn: moduleImportLocation.
|
|
35
|
+
startColumn: moduleImportLocation.ss,
|
|
31
36
|
endColumn: moduleImportLocation.s,
|
|
32
37
|
},
|
|
33
38
|
});
|
package/build/es/index.d.ts
CHANGED
package/build/es/index.js
CHANGED
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.10.0-alpha.
|
|
7
|
+
"version": "0.10.0-alpha.14",
|
|
8
8
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"build/**/*.d.ts"
|
|
46
46
|
],
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"es-module-lexer": "^
|
|
48
|
+
"es-module-lexer": "^1.2.1",
|
|
49
49
|
"fast-json-stable-stringify": "^2.1.0",
|
|
50
50
|
"magic-string": "^0.30.0",
|
|
51
51
|
"mime-types": "^2.1.33",
|
|
@@ -62,13 +62,13 @@
|
|
|
62
62
|
"rollup": "^2.78.0"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
|
-
"@lwrjs/diagnostics": "0.10.0-alpha.
|
|
66
|
-
"@lwrjs/types": "0.10.0-alpha.
|
|
65
|
+
"@lwrjs/diagnostics": "0.10.0-alpha.14",
|
|
66
|
+
"@lwrjs/types": "0.10.0-alpha.14",
|
|
67
67
|
"@types/mime-types": "2.1.1",
|
|
68
68
|
"@types/path-to-regexp": "^1.7.0"
|
|
69
69
|
},
|
|
70
70
|
"engines": {
|
|
71
71
|
"node": ">=16.0.0 <20"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "f80dc1c18719b77c183f339027313be11d69f9dc"
|
|
74
74
|
}
|