@lwrjs/app-service 0.24.2 → 0.24.3
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/identity.cjs
CHANGED
|
@@ -1,29 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
10
|
-
__defProp(target, name, {get: all[name], enumerable: true});
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
9
|
};
|
|
12
|
-
var
|
|
13
|
-
if (
|
|
14
|
-
for (let key of __getOwnPropNames(
|
|
15
|
-
if (!__hasOwnProp.call(
|
|
16
|
-
__defProp(
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
15
|
}
|
|
18
|
-
return
|
|
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);
|
|
16
|
+
return to;
|
|
22
17
|
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
19
|
|
|
24
20
|
// packages/@lwrjs/app-service/src/identity.ts
|
|
25
|
-
|
|
26
|
-
__export(
|
|
21
|
+
var identity_exports = {};
|
|
22
|
+
__export(identity_exports, {
|
|
27
23
|
APP_BOOTSTRAP_PACKAGE_NAME: () => APP_BOOTSTRAP_PACKAGE_NAME,
|
|
28
24
|
AppResourceEnum: () => AppResourceEnum,
|
|
29
25
|
ResourceIdentityTypes: () => ResourceIdentityTypes,
|
|
@@ -33,24 +29,25 @@ __export(exports, {
|
|
|
33
29
|
isWorkerSubResource: () => isWorkerSubResource,
|
|
34
30
|
parseAppIdentity: () => parseAppIdentity
|
|
35
31
|
});
|
|
36
|
-
|
|
32
|
+
module.exports = __toCommonJS(identity_exports);
|
|
33
|
+
var import_shared_utils = require("@lwrjs/shared-utils");
|
|
37
34
|
var APP_BOOTSTRAP_PACKAGE_NAME = "@lwrjs/app-service";
|
|
38
35
|
var SUPPORTED_MODULE_FORMATS = ["amd", "esm"];
|
|
39
|
-
var AppResourceEnum
|
|
40
|
-
(function(AppResourceEnum2) {
|
|
36
|
+
var AppResourceEnum = /* @__PURE__ */ ((AppResourceEnum2) => {
|
|
41
37
|
AppResourceEnum2["MODULE"] = "module";
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
(
|
|
38
|
+
return AppResourceEnum2;
|
|
39
|
+
})(AppResourceEnum || {});
|
|
40
|
+
var ResourceIdentityTypes = /* @__PURE__ */ ((ResourceIdentityTypes2) => {
|
|
45
41
|
ResourceIdentityTypes2["PATH"] = "path";
|
|
46
42
|
ResourceIdentityTypes2["WORKER"] = "worker";
|
|
47
|
-
|
|
43
|
+
return ResourceIdentityTypes2;
|
|
44
|
+
})(ResourceIdentityTypes || {});
|
|
48
45
|
function parseAppIdentity(specifier) {
|
|
49
|
-
const {packageName, subResource: packageSubResource} = (0, import_shared_utils.parsePackageSpecifier)(specifier);
|
|
46
|
+
const { packageName, subResource: packageSubResource } = (0, import_shared_utils.parsePackageSpecifier)(specifier);
|
|
50
47
|
if (packageSubResource === "") {
|
|
51
48
|
return;
|
|
52
49
|
}
|
|
53
|
-
const {appIdentity, appName, appResourceId} = parseAppResource(packageSubResource);
|
|
50
|
+
const { appIdentity, appName, appResourceId } = parseAppResource(packageSubResource);
|
|
54
51
|
const appResource = parseResourceId(appResourceId);
|
|
55
52
|
if (!appResource) {
|
|
56
53
|
return;
|
|
@@ -63,7 +60,7 @@ function parseAppIdentity(specifier) {
|
|
|
63
60
|
};
|
|
64
61
|
}
|
|
65
62
|
function isWorkerSubResource(subResource) {
|
|
66
|
-
return subResource.type ===
|
|
63
|
+
return subResource.type === "worker" /* WORKER */;
|
|
67
64
|
}
|
|
68
65
|
function getAppSpecifier(appIdentity) {
|
|
69
66
|
const appSubResourceIdentifier = appIdentity.subResource ? isWorkerSubResource(appIdentity.subResource) ? `/${appIdentity.subResource.type}/${appIdentity.subResource.workerId}` : `/${appIdentity.subResource.type}${appIdentity.subResource.requestPath}` : "";
|
|
@@ -76,7 +73,7 @@ function parseResourceId(resourceId) {
|
|
|
76
73
|
return;
|
|
77
74
|
}
|
|
78
75
|
switch (type) {
|
|
79
|
-
case
|
|
76
|
+
case "path" /* PATH */:
|
|
80
77
|
subResource = {
|
|
81
78
|
subResource: {
|
|
82
79
|
type,
|
|
@@ -84,7 +81,7 @@ function parseResourceId(resourceId) {
|
|
|
84
81
|
}
|
|
85
82
|
};
|
|
86
83
|
break;
|
|
87
|
-
case
|
|
84
|
+
case "worker" /* WORKER */: {
|
|
88
85
|
subResource = {
|
|
89
86
|
subResource: {
|
|
90
87
|
type,
|
|
@@ -1,41 +1,38 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
10
|
-
__defProp(target, name, {get: all[name], enumerable: true});
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
9
|
};
|
|
12
|
-
var
|
|
13
|
-
if (
|
|
14
|
-
for (let key of __getOwnPropNames(
|
|
15
|
-
if (!__hasOwnProp.call(
|
|
16
|
-
__defProp(
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
15
|
}
|
|
18
|
-
return
|
|
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);
|
|
16
|
+
return to;
|
|
22
17
|
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
19
|
|
|
24
20
|
// packages/@lwrjs/app-service/src/moduleProvider/index.ts
|
|
25
|
-
|
|
26
|
-
__export(
|
|
27
|
-
default: () =>
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
default: () => AppModuleProvider
|
|
28
24
|
});
|
|
29
|
-
|
|
30
|
-
var
|
|
31
|
-
var
|
|
32
|
-
var
|
|
25
|
+
module.exports = __toCommonJS(index_exports);
|
|
26
|
+
var import_diagnostics = require("@lwrjs/diagnostics");
|
|
27
|
+
var import_shared_utils = require("@lwrjs/shared-utils");
|
|
28
|
+
var import_utils = require("./utils.cjs");
|
|
29
|
+
var import_identity = require("../identity.cjs");
|
|
33
30
|
function validateSpecifier(specifier) {
|
|
34
31
|
const appIdentity = (0, import_identity.parseAppIdentity)(specifier);
|
|
35
32
|
return !!appIdentity && (0, import_identity.isValidResourceIdentity)(appIdentity, import_identity.AppResourceEnum.MODULE);
|
|
36
33
|
}
|
|
37
34
|
var AppModuleProvider = class {
|
|
38
|
-
constructor(appPluginConfig, {config, runtimeEnvironment: {hmrEnabled, lwrVersion}}) {
|
|
35
|
+
constructor(appPluginConfig, { config, runtimeEnvironment: { hmrEnabled, lwrVersion } }) {
|
|
39
36
|
this.name = "app-provider";
|
|
40
37
|
this.hmrEnabled = false;
|
|
41
38
|
this.config = config;
|
|
@@ -43,7 +40,7 @@ var AppModuleProvider = class {
|
|
|
43
40
|
this.version = lwrVersion;
|
|
44
41
|
this.lockerConfig = config.locker;
|
|
45
42
|
}
|
|
46
|
-
async getModuleEntry({specifier}) {
|
|
43
|
+
async getModuleEntry({ specifier }) {
|
|
47
44
|
if (validateSpecifier(specifier)) {
|
|
48
45
|
const normalizedSpecifier = specifier.endsWith("/") ? `${specifier}index` : specifier;
|
|
49
46
|
const virtualId = `<virtual>/${normalizedSpecifier}`;
|
|
@@ -65,12 +62,14 @@ var AppModuleProvider = class {
|
|
|
65
62
|
if (!appIdentity || !(0, import_identity.isValidResourceIdentity)(appIdentity, import_identity.AppResourceEnum.MODULE)) {
|
|
66
63
|
return;
|
|
67
64
|
}
|
|
68
|
-
const moduleEntry = await this.getModuleEntry({specifier});
|
|
69
|
-
const route = [...this.config.routes, ...this.config.errorRoutes].find(
|
|
65
|
+
const moduleEntry = await this.getModuleEntry({ specifier });
|
|
66
|
+
const route = [...this.config.routes, ...this.config.errorRoutes].find(
|
|
67
|
+
(r) => r.id === appIdentity.appName
|
|
68
|
+
);
|
|
70
69
|
if (!moduleEntry || !route) {
|
|
71
70
|
throw new import_diagnostics.LwrUnresolvableError(import_diagnostics.descriptions.UNRESOLVABLE.MODULE(specifier), "module");
|
|
72
71
|
}
|
|
73
|
-
const {format} = appIdentity;
|
|
72
|
+
const { format } = appIdentity;
|
|
74
73
|
const moduleLoader = format === "amd" ? this.config.amdLoader : this.config.esmLoader;
|
|
75
74
|
let originalSource;
|
|
76
75
|
if (appIdentity.subResource && (0, import_identity.isWorkerSubResource)(appIdentity.subResource)) {
|
|
@@ -85,11 +84,15 @@ var AppModuleProvider = class {
|
|
|
85
84
|
hmrEnabled: false
|
|
86
85
|
});
|
|
87
86
|
} else {
|
|
88
|
-
originalSource = (0, import_utils.createAppRouteViewBootstrapModule)(
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
87
|
+
originalSource = (0, import_utils.createAppRouteViewBootstrapModule)(
|
|
88
|
+
route,
|
|
89
|
+
{
|
|
90
|
+
format,
|
|
91
|
+
hmrEnabled: this.hmrEnabled,
|
|
92
|
+
moduleLoader
|
|
93
|
+
},
|
|
94
|
+
this.lockerConfig
|
|
95
|
+
);
|
|
93
96
|
}
|
|
94
97
|
return {
|
|
95
98
|
id: moduleEntry.id,
|
|
@@ -114,4 +117,3 @@ var AppModuleProvider = class {
|
|
|
114
117
|
};
|
|
115
118
|
}
|
|
116
119
|
};
|
|
117
|
-
var moduleProvider_default = AppModuleProvider;
|
|
@@ -1,33 +1,30 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
10
|
-
__defProp(target, name, {get: all[name], enumerable: true});
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
9
|
};
|
|
12
|
-
var
|
|
13
|
-
if (
|
|
14
|
-
for (let key of __getOwnPropNames(
|
|
15
|
-
if (!__hasOwnProp.call(
|
|
16
|
-
__defProp(
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
15
|
}
|
|
18
|
-
return
|
|
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);
|
|
16
|
+
return to;
|
|
22
17
|
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
19
|
|
|
24
20
|
// packages/@lwrjs/app-service/src/moduleProvider/utils.ts
|
|
25
|
-
|
|
26
|
-
__export(
|
|
21
|
+
var utils_exports = {};
|
|
22
|
+
__export(utils_exports, {
|
|
27
23
|
createAppRouteViewBootstrapModule: () => createAppRouteViewBootstrapModule,
|
|
28
24
|
createAppWorkerBootstrapModule: () => createAppWorkerBootstrapModule
|
|
29
25
|
});
|
|
30
|
-
|
|
26
|
+
module.exports = __toCommonJS(utils_exports);
|
|
27
|
+
var import_shared_utils = require("@lwrjs/shared-utils");
|
|
31
28
|
function getDefaultImportName(service) {
|
|
32
29
|
return (0, import_shared_utils.stringToVariableName)(`loaderService_${service}`);
|
|
33
30
|
}
|
|
@@ -46,16 +43,21 @@ function createServicesSource(services) {
|
|
|
46
43
|
}
|
|
47
44
|
function createAppWorkerBootstrapModule(workerSpecifier, route, options) {
|
|
48
45
|
const {
|
|
49
|
-
bootstrap: {services, syntheticShadow}
|
|
46
|
+
bootstrap: { services, syntheticShadow }
|
|
50
47
|
} = route;
|
|
51
48
|
const servicesSource = services && createServicesSource(services);
|
|
52
49
|
const serviceApiModule = getServiceApiModule(options.format, options.moduleLoader);
|
|
53
50
|
return [
|
|
54
51
|
"/* This module is generated */",
|
|
52
|
+
// conditional shadow
|
|
55
53
|
syntheticShadow && `import '@lwc/synthetic-shadow';`,
|
|
54
|
+
// Import loader services
|
|
56
55
|
services && services.length && `import { services } from '${serviceApiModule}';`,
|
|
56
|
+
// import and register the configured services
|
|
57
57
|
servicesSource,
|
|
58
|
+
// init module
|
|
58
59
|
`import { init, toKebabCase } from 'lwr/init';`,
|
|
60
|
+
// Import the worker ( no need to initialize the worker )
|
|
59
61
|
`import Worker from "${workerSpecifier}";`
|
|
60
62
|
].filter(Boolean).join("\n");
|
|
61
63
|
}
|
|
@@ -67,33 +69,47 @@ function getServiceApiModule(format, moduleLoader) {
|
|
|
67
69
|
}
|
|
68
70
|
}
|
|
69
71
|
function createAppRouteViewBootstrapModule(route, options, lockerConfig) {
|
|
70
|
-
const {bootstrap} = route;
|
|
71
|
-
const {services, syntheticShadow, ssr} = bootstrap;
|
|
72
|
+
const { bootstrap } = route;
|
|
73
|
+
const { services, syntheticShadow, ssr } = bootstrap;
|
|
72
74
|
const isAMD = options.format === "amd";
|
|
73
75
|
const isESM = options.format === "esm";
|
|
74
76
|
const servicesSource = bootstrap.services && createServicesSource(bootstrap.services);
|
|
75
77
|
const serviceApiModule = getServiceApiModule(options.format, options.moduleLoader);
|
|
76
78
|
return [
|
|
77
79
|
"/* This module is generated */",
|
|
80
|
+
// pre app initialization step
|
|
78
81
|
`import { getClientBootstrapConfig } from 'lwr/preInit';`,
|
|
82
|
+
// conditional shadow
|
|
79
83
|
syntheticShadow && `import '@lwc/synthetic-shadow';`,
|
|
84
|
+
// Declarative ShadowDOM polyfill
|
|
80
85
|
ssr && `import { polyfillDeclarativeShadowDom } from 'lwr/declarativeShadow';`,
|
|
86
|
+
// Import bootstrap services
|
|
87
|
+
// Note: in AMD, only part of the ServiceAPI contract is implemented by the AMD loader
|
|
81
88
|
services && services.length && `import { services } from '${serviceApiModule}';`,
|
|
82
89
|
services && services.length && `import { registerServerDataCallbacks, evaluateServerDataCallbacks } from 'lwr/serverDataCallback';`,
|
|
90
|
+
// import and register the configured services
|
|
83
91
|
servicesSource,
|
|
92
|
+
// HMR (ESM format only)
|
|
84
93
|
isESM && options.hmrEnabled && `import { initHMR } from 'lwr/hmr';`,
|
|
94
|
+
// Import the ESM module initializer
|
|
85
95
|
isESM && `import { init as esmLoaderInit } from 'lwr/esmLoader';`,
|
|
96
|
+
// init module
|
|
86
97
|
`import { init, toKebabCase } from 'lwr/init';`,
|
|
98
|
+
// locker
|
|
87
99
|
isAMD && lockerConfig && lockerConfig.enabled && `
|
|
88
100
|
import { registerLockerDefine } from 'lwr/lockerDefine';
|
|
89
101
|
registerLockerDefine(${JSON.stringify(lockerConfig.trustedComponents)});
|
|
90
102
|
`,
|
|
103
|
+
// grab client bootstrap config
|
|
91
104
|
`const clientBootstrapConfig = getClientBootstrapConfig();`,
|
|
92
105
|
`const { serverData, rootComponents } = clientBootstrapConfig;`,
|
|
106
|
+
// Initialize the ESM loader with the Client Bootstrap Config
|
|
93
107
|
isESM && `
|
|
94
108
|
const { imports, index, importMappings, endpoints } = clientBootstrapConfig;
|
|
95
109
|
esmLoaderInit({ imports, index, importMappings, endpoints });`,
|
|
110
|
+
// Invoke the Declarative ShadowDOM polyfill
|
|
96
111
|
ssr && `polyfillDeclarativeShadowDom();`,
|
|
112
|
+
// Invoke `serverDataCallback` bootstrap services
|
|
97
113
|
services && services.length && `evaluateServerDataCallbacks(serverData)`,
|
|
98
114
|
`
|
|
99
115
|
// initialize additional non-configured root components
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.24.
|
|
7
|
+
"version": "0.24.3",
|
|
8
8
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -36,14 +36,14 @@
|
|
|
36
36
|
"build": "tsc -b"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@lwrjs/diagnostics": "0.24.
|
|
40
|
-
"@lwrjs/shared-utils": "0.24.
|
|
39
|
+
"@lwrjs/diagnostics": "0.24.3",
|
|
40
|
+
"@lwrjs/shared-utils": "0.24.3"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@lwrjs/types": "0.24.
|
|
43
|
+
"@lwrjs/types": "0.24.3"
|
|
44
44
|
},
|
|
45
45
|
"engines": {
|
|
46
46
|
"node": ">=22.0.0"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "ed415a8f04d5558cac756fbc2a0e454a373e31c1"
|
|
49
49
|
}
|