@lwrjs/core 0.4.2 → 0.4.6
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/context/global-data.cjs +2 -5
- package/build/cjs/context/hooks.cjs +3 -6
- package/build/cjs/context/services.cjs +4 -7
- package/build/cjs/env-config.cjs +21 -24
- package/build/cjs/index.cjs +19 -22
- package/build/cjs/lwr-app-observer.cjs +2 -5
- package/build/cjs/middlewares/api-middleware.cjs +47 -45
- package/build/cjs/middlewares/base-middleware.cjs +1 -1
- package/build/cjs/middlewares/hmr-middleware.cjs +5 -8
- package/build/cjs/middlewares/locale-middleware.cjs +1 -1
- package/build/cjs/middlewares/ui-middleware.cjs +5 -8
- package/build/cjs/middlewares/utils.cjs +4 -7
- package/build/cjs/tools/server-warmup.cjs +2 -5
- package/build/cjs/tools/static-generation.cjs +20 -23
- package/build/cjs/tools/types.cjs +5 -0
- package/build/cjs/tools/utils/dir.cjs +3 -6
- package/build/cjs/tools/utils/network-dispatcher.cjs +2 -5
- package/build/cjs/tools/utils/stream.cjs +2 -5
- package/build/cjs/validation/app-config-context.cjs +7 -10
- package/build/cjs/validation/app-config.cjs +52 -55
- package/build/cjs/validation/helpers.cjs +1 -1
- package/build/es/index.js +3 -3
- package/build/es/middlewares/api-middleware.js +20 -15
- package/package.json +24 -25
|
@@ -6,12 +6,10 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
6
6
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
7
|
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
8
8
|
var __export = (target, all) => {
|
|
9
|
-
__markAsModule(target);
|
|
10
9
|
for (var name in all)
|
|
11
10
|
__defProp(target, name, {get: all[name], enumerable: true});
|
|
12
11
|
};
|
|
13
12
|
var __exportStar = (target, module2, desc) => {
|
|
14
|
-
__markAsModule(target);
|
|
15
13
|
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
16
14
|
for (let key of __getOwnPropNames(module2))
|
|
17
15
|
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
@@ -20,12 +18,11 @@ var __exportStar = (target, module2, desc) => {
|
|
|
20
18
|
return target;
|
|
21
19
|
};
|
|
22
20
|
var __toModule = (module2) => {
|
|
23
|
-
|
|
24
|
-
return module2;
|
|
25
|
-
return __exportStar(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", {value: module2, enumerable: true}), 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);
|
|
26
22
|
};
|
|
27
23
|
|
|
28
24
|
// packages/@lwrjs/core/src/context/global-data.ts
|
|
25
|
+
__markAsModule(exports);
|
|
29
26
|
__export(exports, {
|
|
30
27
|
getGlobalData: () => getGlobalData
|
|
31
28
|
});
|
|
@@ -6,12 +6,10 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
6
6
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
7
|
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
8
8
|
var __export = (target, all) => {
|
|
9
|
-
__markAsModule(target);
|
|
10
9
|
for (var name in all)
|
|
11
10
|
__defProp(target, name, {get: all[name], enumerable: true});
|
|
12
11
|
};
|
|
13
12
|
var __exportStar = (target, module2, desc) => {
|
|
14
|
-
__markAsModule(target);
|
|
15
13
|
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
16
14
|
for (let key of __getOwnPropNames(module2))
|
|
17
15
|
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
@@ -20,12 +18,11 @@ var __exportStar = (target, module2, desc) => {
|
|
|
20
18
|
return target;
|
|
21
19
|
};
|
|
22
20
|
var __toModule = (module2) => {
|
|
23
|
-
|
|
24
|
-
return module2;
|
|
25
|
-
return __exportStar(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", {value: module2, enumerable: true}), 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);
|
|
26
22
|
};
|
|
27
23
|
|
|
28
24
|
// packages/@lwrjs/core/src/context/hooks.ts
|
|
25
|
+
__markAsModule(exports);
|
|
29
26
|
__export(exports, {
|
|
30
27
|
runConfigurationsHook: () => runConfigurationsHook
|
|
31
28
|
});
|
|
@@ -42,7 +39,7 @@ async function runConfigurationsHook(hookPlugins, lwrConfig, dataConfig, runtime
|
|
|
42
39
|
for (const hookPlugin of hookPlugins) {
|
|
43
40
|
await hookPlugin.initConfigs(lwrConfig, dataConfig, runtimeConfig);
|
|
44
41
|
}
|
|
45
|
-
import_app_config.validateLwrAppConfig(JSON.stringify(lwrConfig), "post");
|
|
42
|
+
(0, import_app_config.validateLwrAppConfig)(JSON.stringify(lwrConfig), "post");
|
|
46
43
|
normalizeRoutesBootstrap(lwrConfig);
|
|
47
44
|
return {
|
|
48
45
|
lwrConfig,
|
|
@@ -6,12 +6,10 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
6
6
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
7
|
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
8
8
|
var __export = (target, all) => {
|
|
9
|
-
__markAsModule(target);
|
|
10
9
|
for (var name in all)
|
|
11
10
|
__defProp(target, name, {get: all[name], enumerable: true});
|
|
12
11
|
};
|
|
13
12
|
var __exportStar = (target, module2, desc) => {
|
|
14
|
-
__markAsModule(target);
|
|
15
13
|
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
16
14
|
for (let key of __getOwnPropNames(module2))
|
|
17
15
|
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
@@ -20,12 +18,11 @@ var __exportStar = (target, module2, desc) => {
|
|
|
20
18
|
return target;
|
|
21
19
|
};
|
|
22
20
|
var __toModule = (module2) => {
|
|
23
|
-
|
|
24
|
-
return module2;
|
|
25
|
-
return __exportStar(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", {value: module2, enumerable: true}), 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);
|
|
26
22
|
};
|
|
27
23
|
|
|
28
24
|
// packages/@lwrjs/core/src/context/services.ts
|
|
25
|
+
__markAsModule(exports);
|
|
29
26
|
__export(exports, {
|
|
30
27
|
getServiceModule: () => getServiceModule
|
|
31
28
|
});
|
|
@@ -34,8 +31,8 @@ var import_shared_utils = __toModule(require("@lwrjs/shared-utils"));
|
|
|
34
31
|
async function getServiceModule(path, {cacheDir, rootDir}) {
|
|
35
32
|
try {
|
|
36
33
|
if (path.endsWith(".ts")) {
|
|
37
|
-
const fullPath = import_shared_utils.resolveFileExtension(path);
|
|
38
|
-
path = await import_shared_utils.transpileTs(fullPath, {rootDir, cacheDir: import_path.default.join(cacheDir, "services")});
|
|
34
|
+
const fullPath = (0, import_shared_utils.resolveFileExtension)(path);
|
|
35
|
+
path = await (0, import_shared_utils.transpileTs)(fullPath, {rootDir, cacheDir: import_path.default.join(cacheDir, "services")});
|
|
39
36
|
}
|
|
40
37
|
const moduleEntry = await Promise.resolve().then(() => __toModule(require(path)));
|
|
41
38
|
return moduleEntry.default || moduleEntry;
|
package/build/cjs/env-config.cjs
CHANGED
|
@@ -6,12 +6,10 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
6
6
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
7
|
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
8
8
|
var __export = (target, all) => {
|
|
9
|
-
__markAsModule(target);
|
|
10
9
|
for (var name in all)
|
|
11
10
|
__defProp(target, name, {get: all[name], enumerable: true});
|
|
12
11
|
};
|
|
13
12
|
var __exportStar = (target, module2, desc) => {
|
|
14
|
-
__markAsModule(target);
|
|
15
13
|
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
16
14
|
for (let key of __getOwnPropNames(module2))
|
|
17
15
|
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
@@ -20,12 +18,11 @@ var __exportStar = (target, module2, desc) => {
|
|
|
20
18
|
return target;
|
|
21
19
|
};
|
|
22
20
|
var __toModule = (module2) => {
|
|
23
|
-
|
|
24
|
-
return module2;
|
|
25
|
-
return __exportStar(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", {value: module2, enumerable: true}), 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);
|
|
26
22
|
};
|
|
27
23
|
|
|
28
24
|
// packages/@lwrjs/core/src/env-config.ts
|
|
25
|
+
__markAsModule(exports);
|
|
29
26
|
__export(exports, {
|
|
30
27
|
explodeMode: () => explodeMode,
|
|
31
28
|
getExperimentalFeatures: () => getExperimentalFeatures,
|
|
@@ -108,16 +105,16 @@ var DEFAULT_LWR_CONFIG = {
|
|
|
108
105
|
locker: import_shared_utils.DEFAULT_LWR_LOCKER_CONFIG
|
|
109
106
|
};
|
|
110
107
|
function createCacheFolder(cache, rootDir) {
|
|
111
|
-
const cacheDir = import_shared_utils.normalizeDirectory(cache, rootDir);
|
|
108
|
+
const cacheDir = (0, import_shared_utils.normalizeDirectory)(cache, rootDir);
|
|
112
109
|
const absPath = import_path.default.resolve(cacheDir);
|
|
113
110
|
import_fs.default.mkdirSync(import_path.default.join(absPath, import_shared_utils.ASSETS_CACHE_DIR), {recursive: true});
|
|
114
111
|
return absPath;
|
|
115
112
|
}
|
|
116
113
|
function getLwrConfigFromFile(rootDir, customDir = DEFAULT_LWR_CONFIG_JSON) {
|
|
117
|
-
const lwrConfigPath = import_path.default.resolve(import_shared_utils.normalizeDirectory(customDir, rootDir));
|
|
114
|
+
const lwrConfigPath = import_path.default.resolve((0, import_shared_utils.normalizeDirectory)(customDir, rootDir));
|
|
118
115
|
if (import_fs.default.existsSync(lwrConfigPath)) {
|
|
119
116
|
try {
|
|
120
|
-
return import_app_config.validateLwrAppConfig(import_shared_utils.readFile(lwrConfigPath), "file");
|
|
117
|
+
return (0, import_app_config.validateLwrAppConfig)((0, import_shared_utils.readFile)(lwrConfigPath), "file");
|
|
121
118
|
} catch (e) {
|
|
122
119
|
if (e instanceof import_diagnostics.LwrConfigValidationError) {
|
|
123
120
|
throw e;
|
|
@@ -134,13 +131,13 @@ function explodeMode(mode) {
|
|
|
134
131
|
if (!import_fs.default.existsSync(modeConfigFile)) {
|
|
135
132
|
throw new Error(`No configuration found for server mode - ${mode}`);
|
|
136
133
|
}
|
|
137
|
-
const modeConfig = JSON.parse(import_shared_utils.readFile(modeConfigFile));
|
|
134
|
+
const modeConfig = JSON.parse((0, import_shared_utils.readFile)(modeConfigFile));
|
|
138
135
|
return modeConfig;
|
|
139
136
|
}
|
|
140
137
|
function normalizeServices(services, rootDir) {
|
|
141
138
|
return services.map((service) => {
|
|
142
139
|
const [serviceName, serviceConfig = void 0] = Array.isArray(service) ? service : [service];
|
|
143
|
-
let rawServiceName = import_shared_utils.normalizeDirectory(serviceName, rootDir);
|
|
140
|
+
let rawServiceName = (0, import_shared_utils.normalizeDirectory)(serviceName, rootDir);
|
|
144
141
|
if (!rawServiceName.startsWith("@") && !DEFAULT_SERVICE_PACKAGE_NAME.test(rawServiceName)) {
|
|
145
142
|
rawServiceName = import_path.default.resolve(rawServiceName);
|
|
146
143
|
}
|
|
@@ -151,11 +148,11 @@ function normalizeModules(modules, rootDir) {
|
|
|
151
148
|
return modules.map((m) => {
|
|
152
149
|
const dirRecord = m;
|
|
153
150
|
if (dirRecord.dir) {
|
|
154
|
-
dirRecord.dir = import_path.default.resolve(import_shared_utils.normalizeDirectory(dirRecord.dir, rootDir));
|
|
151
|
+
dirRecord.dir = import_path.default.resolve((0, import_shared_utils.normalizeDirectory)(dirRecord.dir, rootDir));
|
|
155
152
|
}
|
|
156
153
|
const aliasRecord = m;
|
|
157
154
|
if (aliasRecord.path) {
|
|
158
|
-
aliasRecord.path = import_path.default.resolve(import_shared_utils.normalizeDirectory(aliasRecord.path, rootDir));
|
|
155
|
+
aliasRecord.path = import_path.default.resolve((0, import_shared_utils.normalizeDirectory)(aliasRecord.path, rootDir));
|
|
159
156
|
}
|
|
160
157
|
return m;
|
|
161
158
|
});
|
|
@@ -170,9 +167,9 @@ function normalizeRoutes(routes, resourcePaths) {
|
|
|
170
167
|
return {
|
|
171
168
|
...route,
|
|
172
169
|
bootstrap,
|
|
173
|
-
routeHandler: routeHandler && import_path.default.resolve(import_shared_utils.normalizeDirectory(routeHandler, resourcePaths.rootDir)),
|
|
174
|
-
contentTemplate: contentTemplate && import_path.default.resolve(import_shared_utils.normalizeResourcePath(contentTemplate, resourcePaths)),
|
|
175
|
-
layoutTemplate: layoutTemplate && import_path.default.resolve(import_shared_utils.normalizeResourcePath(layoutTemplate, resourcePaths))
|
|
170
|
+
routeHandler: routeHandler && import_path.default.resolve((0, import_shared_utils.normalizeDirectory)(routeHandler, resourcePaths.rootDir)),
|
|
171
|
+
contentTemplate: contentTemplate && import_path.default.resolve((0, import_shared_utils.normalizeResourcePath)(contentTemplate, resourcePaths)),
|
|
172
|
+
layoutTemplate: layoutTemplate && import_path.default.resolve((0, import_shared_utils.normalizeResourcePath)(layoutTemplate, resourcePaths))
|
|
176
173
|
};
|
|
177
174
|
});
|
|
178
175
|
}
|
|
@@ -181,7 +178,7 @@ function normalizeAssetsDir(assets, rootDir) {
|
|
|
181
178
|
return [
|
|
182
179
|
{
|
|
183
180
|
alias: "assetsDir",
|
|
184
|
-
dir: import_shared_utils.normalizeDirectory(assets, rootDir),
|
|
181
|
+
dir: (0, import_shared_utils.normalizeDirectory)(assets, rootDir),
|
|
185
182
|
urlPath: "/public/assets"
|
|
186
183
|
}
|
|
187
184
|
];
|
|
@@ -191,8 +188,8 @@ function normalizeAssetsDir(assets, rootDir) {
|
|
|
191
188
|
const assetFile = asset.file;
|
|
192
189
|
return {
|
|
193
190
|
...asset,
|
|
194
|
-
dir: assetDir && import_shared_utils.normalizeDirectory(assetDir, rootDir),
|
|
195
|
-
file: assetFile && import_shared_utils.normalizeDirectory(assetFile, rootDir)
|
|
191
|
+
dir: assetDir && (0, import_shared_utils.normalizeDirectory)(assetDir, rootDir),
|
|
192
|
+
file: assetFile && (0, import_shared_utils.normalizeDirectory)(assetFile, rootDir)
|
|
196
193
|
};
|
|
197
194
|
});
|
|
198
195
|
}
|
|
@@ -223,7 +220,7 @@ function mergeLockerConfig(jsonConfig, config) {
|
|
|
223
220
|
};
|
|
224
221
|
}
|
|
225
222
|
function getLWCEngineSpecifier() {
|
|
226
|
-
const require2 = import_module.createRequire(import_path.default.join(process.cwd(), "./env-config.js"));
|
|
223
|
+
const require2 = (0, import_module.createRequire)(import_path.default.join(process.cwd(), "./env-config.js"));
|
|
227
224
|
const {version: version2} = require2("lwc/package.json");
|
|
228
225
|
if (version2 && version2.startsWith("1")) {
|
|
229
226
|
return "@lwc/engine";
|
|
@@ -233,12 +230,12 @@ function getLWCEngineSpecifier() {
|
|
|
233
230
|
function normalizeLwcConfig(config) {
|
|
234
231
|
return {
|
|
235
232
|
...config,
|
|
236
|
-
interchangeableModulesMap: config.interchangeableModules ? import_shared_utils.normalizeInterchangeableModuleConfig(config.interchangeableModules) : void 0
|
|
233
|
+
interchangeableModulesMap: config.interchangeableModules ? (0, import_shared_utils.normalizeInterchangeableModuleConfig)(config.interchangeableModules) : void 0
|
|
237
234
|
};
|
|
238
235
|
}
|
|
239
236
|
function normalizeConfig(config) {
|
|
240
237
|
if (config) {
|
|
241
|
-
import_app_config.validateLwrAppConfig(JSON.stringify(config), "pre");
|
|
238
|
+
(0, import_app_config.validateLwrAppConfig)(JSON.stringify(config), "pre");
|
|
242
239
|
}
|
|
243
240
|
const rootDir = import_path.default.resolve(config?.rootDir || DEFAULT_ROOT_DIR);
|
|
244
241
|
const lwrJsonConfig = config?.ignoreLwrConfigFile === true ? void 0 : getLwrConfigFromFile(rootDir, config?.lwrConfigFile);
|
|
@@ -251,15 +248,15 @@ function normalizeConfig(config) {
|
|
|
251
248
|
rootDir
|
|
252
249
|
};
|
|
253
250
|
const assets = normalizeAssetsDir(mergedLwrGlobalConfig.assets, rootDir);
|
|
254
|
-
const contentDir = import_shared_utils.normalizeDirectory(mergedLwrGlobalConfig.contentDir, rootDir);
|
|
255
|
-
const layoutsDir = import_shared_utils.normalizeDirectory(mergedLwrGlobalConfig.layoutsDir, rootDir);
|
|
251
|
+
const contentDir = (0, import_shared_utils.normalizeDirectory)(mergedLwrGlobalConfig.contentDir, rootDir);
|
|
252
|
+
const layoutsDir = (0, import_shared_utils.normalizeDirectory)(mergedLwrGlobalConfig.layoutsDir, rootDir);
|
|
256
253
|
const amdLoader = getExperimentalFeatures().ENABLE_FINGERPRINTS ? DEFAULT_AMD_LOADER : DEFAULT_AMD_LOADER_LEGACY;
|
|
257
254
|
return {
|
|
258
255
|
...mergedLwrGlobalConfig,
|
|
259
256
|
assets,
|
|
260
257
|
contentDir,
|
|
261
258
|
layoutsDir,
|
|
262
|
-
globalDataDir: import_shared_utils.normalizeDirectory(mergedLwrGlobalConfig.globalDataDir, rootDir),
|
|
259
|
+
globalDataDir: (0, import_shared_utils.normalizeDirectory)(mergedLwrGlobalConfig.globalDataDir, rootDir),
|
|
263
260
|
hooks: normalizeServices(mergedLwrGlobalConfig.hooks, rootDir),
|
|
264
261
|
cacheDir: createCacheFolder(mergedLwrGlobalConfig.cacheDir, rootDir),
|
|
265
262
|
lwc: {
|
package/build/cjs/index.cjs
CHANGED
|
@@ -6,12 +6,10 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
6
6
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
7
|
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
8
8
|
var __export = (target, all) => {
|
|
9
|
-
__markAsModule(target);
|
|
10
9
|
for (var name in all)
|
|
11
10
|
__defProp(target, name, {get: all[name], enumerable: true});
|
|
12
11
|
};
|
|
13
12
|
var __exportStar = (target, module2, desc) => {
|
|
14
|
-
__markAsModule(target);
|
|
15
13
|
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
16
14
|
for (let key of __getOwnPropNames(module2))
|
|
17
15
|
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
@@ -20,12 +18,11 @@ var __exportStar = (target, module2, desc) => {
|
|
|
20
18
|
return target;
|
|
21
19
|
};
|
|
22
20
|
var __toModule = (module2) => {
|
|
23
|
-
|
|
24
|
-
return module2;
|
|
25
|
-
return __exportStar(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", {value: module2, enumerable: true}), 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);
|
|
26
22
|
};
|
|
27
23
|
|
|
28
24
|
// packages/@lwrjs/core/src/index.ts
|
|
25
|
+
__markAsModule(exports);
|
|
29
26
|
__export(exports, {
|
|
30
27
|
LwrApp: () => LwrApp,
|
|
31
28
|
createServer: () => createServer,
|
|
@@ -54,32 +51,32 @@ var import_server_warmup = __toModule(require("./tools/server-warmup.cjs"));
|
|
|
54
51
|
async function getServices(services, providerContext, lwrConfig) {
|
|
55
52
|
return Promise.all(services.map(async (serviceEntry) => {
|
|
56
53
|
const [serviceName, serviceConfig = {}] = Array.isArray(serviceEntry) ? serviceEntry : [serviceEntry];
|
|
57
|
-
const ServiceCtor = await import_services.getServiceModule(serviceName, lwrConfig);
|
|
54
|
+
const ServiceCtor = await (0, import_services.getServiceModule)(serviceName, lwrConfig);
|
|
58
55
|
return new ServiceCtor(serviceConfig, providerContext);
|
|
59
56
|
}));
|
|
60
57
|
}
|
|
61
58
|
function initMiddlewares(app, server, serverContext) {
|
|
62
|
-
import_base_middleware.default(app, serverContext);
|
|
63
|
-
import_locale_middleware.default(app, serverContext);
|
|
64
|
-
import_api_middleware.default(app, serverContext);
|
|
65
|
-
import_ui_middleware.default(app, serverContext);
|
|
59
|
+
(0, import_base_middleware.default)(app, serverContext);
|
|
60
|
+
(0, import_locale_middleware.default)(app, serverContext);
|
|
61
|
+
(0, import_api_middleware.default)(app, serverContext);
|
|
62
|
+
(0, import_ui_middleware.default)(app, serverContext);
|
|
66
63
|
if (serverContext.runtimeEnvironment.hmrEnabled) {
|
|
67
|
-
import_hmr_middleware.default(server, serverContext);
|
|
64
|
+
(0, import_hmr_middleware.default)(server, serverContext);
|
|
68
65
|
}
|
|
69
66
|
}
|
|
70
67
|
async function initContext(app, server, rawLwrConfig) {
|
|
71
68
|
const {apiVersion, lwrVersion, serverMode, globalDataDir, globalData} = rawLwrConfig;
|
|
72
|
-
const rawDataConfig = import_global_data.getGlobalData(globalDataDir, globalData);
|
|
69
|
+
const rawDataConfig = (0, import_global_data.getGlobalData)(globalDataDir, globalData);
|
|
73
70
|
const rawRuntimeEnvConfig = {
|
|
74
|
-
...import_env_config.explodeMode(serverMode),
|
|
71
|
+
...(0, import_env_config.explodeMode)(serverMode),
|
|
75
72
|
apiVersion,
|
|
76
73
|
lwrVersion,
|
|
77
74
|
debug: false,
|
|
78
75
|
serverMode,
|
|
79
|
-
experimental_features: import_env_config.getExperimentalFeatures()
|
|
76
|
+
experimental_features: (0, import_env_config.getExperimentalFeatures)()
|
|
80
77
|
};
|
|
81
78
|
const hookProviders = await getServices(rawLwrConfig.hooks, void 0, rawLwrConfig);
|
|
82
|
-
const {lwrConfig, dataConfig, runtimeConfig} = await import_hooks.runConfigurationsHook(hookProviders, rawLwrConfig, rawDataConfig, rawRuntimeEnvConfig);
|
|
79
|
+
const {lwrConfig, dataConfig, runtimeConfig} = await (0, import_hooks.runConfigurationsHook)(hookProviders, rawLwrConfig, rawDataConfig, rawRuntimeEnvConfig);
|
|
83
80
|
const appObserver = new import_lwr_app_observer.LwrApplicationObserver();
|
|
84
81
|
const appEmitter = appObserver.createLwrEmitter();
|
|
85
82
|
const compiler = new import_compiler.LwrCompiler();
|
|
@@ -139,7 +136,7 @@ async function initContext(app, server, rawLwrConfig) {
|
|
|
139
136
|
notifyViewSourceChanged,
|
|
140
137
|
notifyAssetSourceChanged
|
|
141
138
|
} = appEmitter;
|
|
142
|
-
const providerContext = import_shared_utils.deepFreeze({
|
|
139
|
+
const providerContext = (0, import_shared_utils.deepFreeze)({
|
|
143
140
|
compiler,
|
|
144
141
|
appObserver: {onModuleDefinitionChange, onModuleSourceChange},
|
|
145
142
|
appEmitter: {
|
|
@@ -181,12 +178,12 @@ async function initContext(app, server, rawLwrConfig) {
|
|
|
181
178
|
var LwrApp = class {
|
|
182
179
|
constructor(config) {
|
|
183
180
|
this.initialized = false;
|
|
184
|
-
this.config = import_env_config.normalizeConfig(config);
|
|
185
|
-
this.app = import_server.createInternalServer(this.config.serverType);
|
|
181
|
+
this.config = (0, import_env_config.normalizeConfig)(config);
|
|
182
|
+
this.app = (0, import_server.createInternalServer)(this.config.serverType);
|
|
186
183
|
this.server = this.app.createHttpServer();
|
|
187
184
|
}
|
|
188
185
|
setConfig(config) {
|
|
189
|
-
this.config = import_env_config.normalizeConfig(config);
|
|
186
|
+
this.config = (0, import_env_config.normalizeConfig)(config);
|
|
190
187
|
}
|
|
191
188
|
getConfig() {
|
|
192
189
|
return this.config;
|
|
@@ -202,11 +199,11 @@ var LwrApp = class {
|
|
|
202
199
|
await this.init();
|
|
203
200
|
const {server, config, app} = this;
|
|
204
201
|
const {serverMode, port} = config;
|
|
205
|
-
server.listen(port || config.port, () => {
|
|
206
|
-
callback?.({serverMode, port});
|
|
202
|
+
server.listen(port || config.port, async () => {
|
|
207
203
|
if (process.env.WARMUP?.toLowerCase() === "true") {
|
|
208
|
-
import_server_warmup.warmupServer(config, app.getInternalRequestKey());
|
|
204
|
+
await (0, import_server_warmup.warmupServer)(config, app.getInternalRequestKey());
|
|
209
205
|
}
|
|
206
|
+
callback?.({serverMode, port});
|
|
210
207
|
});
|
|
211
208
|
}
|
|
212
209
|
async close() {
|
|
@@ -6,12 +6,10 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
6
6
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
7
|
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
8
8
|
var __export = (target, all) => {
|
|
9
|
-
__markAsModule(target);
|
|
10
9
|
for (var name in all)
|
|
11
10
|
__defProp(target, name, {get: all[name], enumerable: true});
|
|
12
11
|
};
|
|
13
12
|
var __exportStar = (target, module2, desc) => {
|
|
14
|
-
__markAsModule(target);
|
|
15
13
|
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
16
14
|
for (let key of __getOwnPropNames(module2))
|
|
17
15
|
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
@@ -20,12 +18,11 @@ var __exportStar = (target, module2, desc) => {
|
|
|
20
18
|
return target;
|
|
21
19
|
};
|
|
22
20
|
var __toModule = (module2) => {
|
|
23
|
-
|
|
24
|
-
return module2;
|
|
25
|
-
return __exportStar(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", {value: module2, enumerable: true}), 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);
|
|
26
22
|
};
|
|
27
23
|
|
|
28
24
|
// packages/@lwrjs/core/src/lwr-app-observer.ts
|
|
25
|
+
__markAsModule(exports);
|
|
29
26
|
__export(exports, {
|
|
30
27
|
LwrApplicationObserver: () => LwrApplicationObserver
|
|
31
28
|
});
|
|
@@ -6,12 +6,10 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
6
6
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
7
|
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
8
8
|
var __export = (target, all) => {
|
|
9
|
-
__markAsModule(target);
|
|
10
9
|
for (var name in all)
|
|
11
10
|
__defProp(target, name, {get: all[name], enumerable: true});
|
|
12
11
|
};
|
|
13
12
|
var __exportStar = (target, module2, desc) => {
|
|
14
|
-
__markAsModule(target);
|
|
15
13
|
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
16
14
|
for (let key of __getOwnPropNames(module2))
|
|
17
15
|
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
@@ -20,12 +18,11 @@ var __exportStar = (target, module2, desc) => {
|
|
|
20
18
|
return target;
|
|
21
19
|
};
|
|
22
20
|
var __toModule = (module2) => {
|
|
23
|
-
|
|
24
|
-
return module2;
|
|
25
|
-
return __exportStar(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", {value: module2, enumerable: true}), 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);
|
|
26
22
|
};
|
|
27
23
|
|
|
28
24
|
// packages/@lwrjs/core/src/middlewares/api-middleware.ts
|
|
25
|
+
__markAsModule(exports);
|
|
29
26
|
__export(exports, {
|
|
30
27
|
default: () => apiMiddleware
|
|
31
28
|
});
|
|
@@ -54,17 +51,18 @@ function apiMiddleware(app, context) {
|
|
|
54
51
|
const runtimeContext = req.getRuntimeContext(defaultRuntimeEnvironment);
|
|
55
52
|
const {runtimeEnvironment, runtimeParams} = runtimeContext;
|
|
56
53
|
const targetEnvironment = runtimeParams.environment;
|
|
57
|
-
if (!import_utils.isSupportedEnvironment(environmentConfig, targetEnvironment)) {
|
|
54
|
+
if (!(0, import_utils.isSupportedEnvironment)(environmentConfig, targetEnvironment)) {
|
|
58
55
|
res.status(400).send({error: `Environment "${targetEnvironment}" is not supported`});
|
|
59
56
|
return;
|
|
60
57
|
}
|
|
61
|
-
|
|
58
|
+
let moduleId, signature;
|
|
62
59
|
try {
|
|
60
|
+
({moduleId, signature} = (0, import_shared_utils.getModuleIdentity)(req));
|
|
63
61
|
const sourceMapUrl = req.path.replace("/bundle/", "/sourcemaps/bundle/");
|
|
64
62
|
const sourceMapRuntimeContext = {...runtimeEnvironment, sourceMapUrl};
|
|
65
63
|
const importerSpecifier = req.query.importer;
|
|
66
64
|
if (importerSpecifier) {
|
|
67
|
-
const importerModuleId = import_shared_utils.explodeSpecifier(importerSpecifier);
|
|
65
|
+
const importerModuleId = (0, import_shared_utils.explodeSpecifier)(importerSpecifier);
|
|
68
66
|
const {entry} = await moduleRegistry.getModuleEntry(importerModuleId);
|
|
69
67
|
const versionedModuleEntry = await moduleRegistry.getModuleEntry({
|
|
70
68
|
...moduleId,
|
|
@@ -86,7 +84,7 @@ function apiMiddleware(app, context) {
|
|
|
86
84
|
if (bundleDef.bundleRecord.imports) {
|
|
87
85
|
for (let index = 0; index < bundleDef.bundleRecord.imports.length; index++) {
|
|
88
86
|
const theImport = bundleDef.bundleRecord.imports[index];
|
|
89
|
-
const id = await import_shared_utils.getVersionedModuleId(theImport.specifier, moduleRegistry);
|
|
87
|
+
const id = await (0, import_shared_utils.getVersionedModuleId)(theImport.specifier, moduleRegistry);
|
|
90
88
|
const uri = await moduleRegistry.resolveModuleUri(id, runtimeEnvironment, runtimeParams);
|
|
91
89
|
resolvedUris.push(uri);
|
|
92
90
|
}
|
|
@@ -94,7 +92,7 @@ function apiMiddleware(app, context) {
|
|
|
94
92
|
if (bundleDef.bundleRecord.dynamicImports) {
|
|
95
93
|
for (let index = 0; index < bundleDef.bundleRecord.dynamicImports.length; index++) {
|
|
96
94
|
const theImport = bundleDef.bundleRecord.dynamicImports[index];
|
|
97
|
-
const id = await import_shared_utils.getVersionedModuleId(theImport.specifier, moduleRegistry);
|
|
95
|
+
const id = await (0, import_shared_utils.getVersionedModuleId)(theImport.specifier, moduleRegistry);
|
|
98
96
|
const uri = await moduleRegistry.resolveModuleUri(id, runtimeEnvironment, runtimeParams);
|
|
99
97
|
resolvedUris.push(uri);
|
|
100
98
|
}
|
|
@@ -104,7 +102,7 @@ function apiMiddleware(app, context) {
|
|
|
104
102
|
res.type("application/javascript").send(bundleDef.code);
|
|
105
103
|
} catch (e) {
|
|
106
104
|
console.log(e);
|
|
107
|
-
const error = import_utils.createReturnStatus(`bundle for "${moduleId
|
|
105
|
+
const error = (0, import_utils.createReturnStatus)(`bundle for "${moduleId?.specifier}"`, e);
|
|
108
106
|
res.status(error.status).send(error.message);
|
|
109
107
|
}
|
|
110
108
|
});
|
|
@@ -116,16 +114,16 @@ function apiMiddleware(app, context) {
|
|
|
116
114
|
], async (req, res) => {
|
|
117
115
|
const ctx = req.getRuntimeContext(defaultRuntimeEnvironment);
|
|
118
116
|
const targetEnvironment = ctx.runtimeParams.environment;
|
|
119
|
-
if (!import_utils.isSupportedEnvironment(environmentConfig, targetEnvironment)) {
|
|
117
|
+
if (!(0, import_utils.isSupportedEnvironment)(environmentConfig, targetEnvironment)) {
|
|
120
118
|
res.status(400).send({error: `Environment "${targetEnvironment}" is not supported`});
|
|
121
119
|
return;
|
|
122
120
|
}
|
|
123
|
-
|
|
124
|
-
let moduleId = id.moduleId;
|
|
121
|
+
let moduleId;
|
|
125
122
|
try {
|
|
123
|
+
({moduleId} = (0, import_shared_utils.getModuleIdentity)(req));
|
|
126
124
|
const importerSpecifier = req.query.importer;
|
|
127
125
|
if (importerSpecifier) {
|
|
128
|
-
const importerModuleId = import_shared_utils.explodeSpecifier(importerSpecifier);
|
|
126
|
+
const importerModuleId = (0, import_shared_utils.explodeSpecifier)(importerSpecifier);
|
|
129
127
|
const {entry} = await moduleRegistry.getModuleEntry(importerModuleId);
|
|
130
128
|
moduleId = {...moduleId, importer: entry};
|
|
131
129
|
}
|
|
@@ -133,9 +131,9 @@ function apiMiddleware(app, context) {
|
|
|
133
131
|
const {ownHash, moduleEntry} = await moduleRegistry.getModule(moduleId, ctx.runtimeParams);
|
|
134
132
|
if (ownHash) {
|
|
135
133
|
const localeSegment = locale ? `/l/${locale}` : "";
|
|
136
|
-
const uriSpecifier = encodeURIComponent(import_shared_utils.getSpecifier({
|
|
134
|
+
const uriSpecifier = encodeURIComponent((0, import_shared_utils.getSpecifier)({
|
|
137
135
|
specifier: moduleEntry.specifier,
|
|
138
|
-
version: import_shared_utils.normalizeVersionToUri(moduleEntry.version)
|
|
136
|
+
version: (0, import_shared_utils.normalizeVersionToUri)(moduleEntry.version)
|
|
139
137
|
}));
|
|
140
138
|
const jsonQuery = req.isJsonRequest() ? "?json" : "";
|
|
141
139
|
res.set({
|
|
@@ -145,7 +143,7 @@ function apiMiddleware(app, context) {
|
|
|
145
143
|
}
|
|
146
144
|
} catch (e) {
|
|
147
145
|
console.log(e);
|
|
148
|
-
const error = import_utils.createReturnStatus(`bundle for "${moduleId
|
|
146
|
+
const error = (0, import_utils.createReturnStatus)(`bundle for "${moduleId?.specifier}"`, e);
|
|
149
147
|
res.status(error.status).send(error.message);
|
|
150
148
|
}
|
|
151
149
|
});
|
|
@@ -162,12 +160,13 @@ function apiMiddleware(app, context) {
|
|
|
162
160
|
const runtimeContext = req.getRuntimeContext(defaultRuntimeEnvironment);
|
|
163
161
|
const {runtimeParams, runtimeEnvironment} = runtimeContext;
|
|
164
162
|
const targetEnvironment = runtimeParams.environment;
|
|
165
|
-
if (!import_utils.isSupportedEnvironment(environmentConfig, targetEnvironment)) {
|
|
163
|
+
if (!(0, import_utils.isSupportedEnvironment)(environmentConfig, targetEnvironment)) {
|
|
166
164
|
res.status(400).send({error: `Environment "${targetEnvironment}" is not supported`});
|
|
167
165
|
return;
|
|
168
166
|
}
|
|
169
|
-
|
|
167
|
+
let moduleId, signature;
|
|
170
168
|
try {
|
|
169
|
+
({moduleId, signature} = (0, import_shared_utils.getModuleIdentity)(req));
|
|
171
170
|
const bundleDef = await moduleBundler.getModuleBundle(moduleId, runtimeEnvironment);
|
|
172
171
|
if (signature !== import_shared_utils.LATEST_SIGNATURE) {
|
|
173
172
|
res.setHeader("Cache-control", "public, max-age=31536000, immutable");
|
|
@@ -175,7 +174,7 @@ function apiMiddleware(app, context) {
|
|
|
175
174
|
res.type("application/json").send(bundleDef.map);
|
|
176
175
|
} catch (e) {
|
|
177
176
|
console.log(e);
|
|
178
|
-
const error = import_utils.createReturnStatus(`bundle sourcemap for "${moduleId
|
|
177
|
+
const error = (0, import_utils.createReturnStatus)(`bundle sourcemap for "${moduleId?.specifier}"`, e);
|
|
179
178
|
res.status(error.status).send(error.message);
|
|
180
179
|
}
|
|
181
180
|
});
|
|
@@ -191,14 +190,15 @@ function apiMiddleware(app, context) {
|
|
|
191
190
|
], async (req, res) => {
|
|
192
191
|
const {runtimeEnvironment, runtimeParams} = req.getRuntimeContext(defaultRuntimeEnvironment);
|
|
193
192
|
const targetEnvironment = runtimeParams.environment;
|
|
194
|
-
if (!import_utils.isSupportedEnvironment(environmentConfig, targetEnvironment)) {
|
|
193
|
+
if (!(0, import_utils.isSupportedEnvironment)(environmentConfig, targetEnvironment)) {
|
|
195
194
|
res.status(400).send({error: `Environment "${targetEnvironment}" is not supported`});
|
|
196
195
|
return;
|
|
197
196
|
}
|
|
198
|
-
|
|
197
|
+
let moduleId, signature;
|
|
199
198
|
try {
|
|
199
|
+
({moduleId, signature} = (0, import_shared_utils.getModuleIdentity)(req));
|
|
200
200
|
if (!req.validateJsonRequest()) {
|
|
201
|
-
throw import_diagnostics.createSingleDiagnosticError({description: errors.INVALID_JSON()}, import_diagnostics.LwrUnresolvableError);
|
|
201
|
+
throw (0, import_diagnostics.createSingleDiagnosticError)({description: errors.INVALID_JSON()}, import_diagnostics.LwrUnresolvableError);
|
|
202
202
|
}
|
|
203
203
|
const theModule = await moduleRegistry.getLinkedModule(moduleId, runtimeEnvironment, runtimeParams);
|
|
204
204
|
const {ownHash, linkedSource} = theModule;
|
|
@@ -206,17 +206,17 @@ function apiMiddleware(app, context) {
|
|
|
206
206
|
const code = linkedSource;
|
|
207
207
|
res.setMetadata({moduleDefinition: theModule});
|
|
208
208
|
if (req.isJsonRequest()) {
|
|
209
|
-
const json = await import_shared_utils.serializeModuleToJson(code, theModule, moduleRegistry, runtimeParams);
|
|
209
|
+
const json = await (0, import_shared_utils.serializeModuleToJson)(code, theModule, moduleRegistry, runtimeParams);
|
|
210
210
|
res.type("application/json").send(json);
|
|
211
211
|
} else {
|
|
212
212
|
res.type("application/javascript").send(code);
|
|
213
213
|
}
|
|
214
214
|
} else {
|
|
215
|
-
throw import_diagnostics.createSingleDiagnosticError({description: errors.SIGNED_MODULE(moduleId.specifier, signature)}, import_diagnostics.LwrUnresolvableError);
|
|
215
|
+
throw (0, import_diagnostics.createSingleDiagnosticError)({description: errors.SIGNED_MODULE(moduleId.specifier, signature)}, import_diagnostics.LwrUnresolvableError);
|
|
216
216
|
}
|
|
217
217
|
} catch (e) {
|
|
218
218
|
console.log(e);
|
|
219
|
-
const error = import_utils.createReturnStatus(`module "${moduleId
|
|
219
|
+
const error = (0, import_utils.createReturnStatus)(`module "${moduleId?.specifier}"`, e);
|
|
220
220
|
res.status(error.status).send(error.message);
|
|
221
221
|
}
|
|
222
222
|
});
|
|
@@ -228,16 +228,16 @@ function apiMiddleware(app, context) {
|
|
|
228
228
|
], async (req, res) => {
|
|
229
229
|
const ctx = req.getRuntimeContext(defaultRuntimeEnvironment);
|
|
230
230
|
const targetEnvironment = ctx.runtimeParams.environment;
|
|
231
|
-
if (!import_utils.isSupportedEnvironment(environmentConfig, targetEnvironment)) {
|
|
231
|
+
if (!(0, import_utils.isSupportedEnvironment)(environmentConfig, targetEnvironment)) {
|
|
232
232
|
res.status(400).send({error: `Environment "${targetEnvironment}" is not supported`});
|
|
233
233
|
return;
|
|
234
234
|
}
|
|
235
|
-
|
|
236
|
-
let moduleId = id.moduleId;
|
|
235
|
+
let moduleId;
|
|
237
236
|
try {
|
|
237
|
+
({moduleId} = (0, import_shared_utils.getModuleIdentity)(req));
|
|
238
238
|
const importerSpecifier = req.query.importer;
|
|
239
239
|
if (importerSpecifier) {
|
|
240
|
-
const importerModuleId = import_shared_utils.explodeSpecifier(importerSpecifier);
|
|
240
|
+
const importerModuleId = (0, import_shared_utils.explodeSpecifier)(importerSpecifier);
|
|
241
241
|
const {entry} = await moduleRegistry.getModuleEntry(importerModuleId);
|
|
242
242
|
moduleId = {...moduleId, importer: entry};
|
|
243
243
|
}
|
|
@@ -245,9 +245,9 @@ function apiMiddleware(app, context) {
|
|
|
245
245
|
const {ownHash, moduleEntry} = await moduleRegistry.getModule(moduleId, ctx.runtimeParams);
|
|
246
246
|
if (ownHash) {
|
|
247
247
|
const localeSegment = locale ? `/l/${locale}` : "";
|
|
248
|
-
const uriSpecifier = encodeURIComponent(import_shared_utils.getSpecifier({
|
|
248
|
+
const uriSpecifier = encodeURIComponent((0, import_shared_utils.getSpecifier)({
|
|
249
249
|
specifier: moduleEntry.specifier,
|
|
250
|
-
version: import_shared_utils.normalizeVersionToUri(moduleEntry.version)
|
|
250
|
+
version: (0, import_shared_utils.normalizeVersionToUri)(moduleEntry.version)
|
|
251
251
|
}));
|
|
252
252
|
const jsonQuery = req.isJsonRequest() ? "?json" : "";
|
|
253
253
|
res.set({
|
|
@@ -257,7 +257,7 @@ function apiMiddleware(app, context) {
|
|
|
257
257
|
}
|
|
258
258
|
} catch (e) {
|
|
259
259
|
console.log(e);
|
|
260
|
-
const error = import_utils.createReturnStatus(`module "${moduleId
|
|
260
|
+
const error = (0, import_utils.createReturnStatus)(`module "${moduleId?.specifier}"`, e);
|
|
261
261
|
res.status(error.status).send(error.message);
|
|
262
262
|
}
|
|
263
263
|
});
|
|
@@ -269,18 +269,19 @@ function apiMiddleware(app, context) {
|
|
|
269
269
|
], async (req, res) => {
|
|
270
270
|
const requestContext = req.getRuntimeContext(defaultRuntimeEnvironment);
|
|
271
271
|
const targetEnvironment = requestContext.runtimeParams.environment;
|
|
272
|
-
if (!import_utils.isSupportedEnvironment(environmentConfig, targetEnvironment)) {
|
|
272
|
+
if (!(0, import_utils.isSupportedEnvironment)(environmentConfig, targetEnvironment)) {
|
|
273
273
|
res.status(400).send({error: `Environment "${targetEnvironment}" is not supported`});
|
|
274
274
|
return;
|
|
275
275
|
}
|
|
276
|
-
|
|
276
|
+
let moduleIds;
|
|
277
277
|
try {
|
|
278
|
+
({moduleIds} = (0, import_shared_utils.getMappingIdentity)(req));
|
|
278
279
|
const {runtimeEnvironment, runtimeParams} = requestContext;
|
|
279
|
-
const importMetadata = await import_shared_utils.getImportMetadataMappings(moduleIds, runtimeEnvironment, runtimeParams, moduleRegistry, moduleBundler);
|
|
280
|
+
const importMetadata = await (0, import_shared_utils.getImportMetadataMappings)(moduleIds, runtimeEnvironment, runtimeParams, moduleRegistry, moduleBundler);
|
|
280
281
|
res.type("application/json").send(importMetadata);
|
|
281
282
|
} catch (e) {
|
|
282
283
|
console.log(e);
|
|
283
|
-
const error = import_utils.createReturnStatus(`mappings for "${JSON.stringify(moduleIds)}"`, e);
|
|
284
|
+
const error = (0, import_utils.createReturnStatus)(`mappings for "${JSON.stringify(moduleIds)}"`, e);
|
|
284
285
|
res.status(error.status).send(error.message);
|
|
285
286
|
}
|
|
286
287
|
});
|
|
@@ -292,12 +293,13 @@ function apiMiddleware(app, context) {
|
|
|
292
293
|
], async (req, res) => {
|
|
293
294
|
const {runtimeEnvironment, runtimeParams} = req.getRuntimeContext(defaultRuntimeEnvironment);
|
|
294
295
|
const targetEnvironment = runtimeParams.environment;
|
|
295
|
-
if (!import_utils.isSupportedEnvironment(environmentConfig, targetEnvironment)) {
|
|
296
|
+
if (!(0, import_utils.isSupportedEnvironment)(environmentConfig, targetEnvironment)) {
|
|
296
297
|
res.status(400).send({error: `Environment "${targetEnvironment}" is not supported`});
|
|
297
298
|
return;
|
|
298
299
|
}
|
|
299
|
-
|
|
300
|
+
let resourceId;
|
|
300
301
|
try {
|
|
302
|
+
({resourceId} = (0, import_shared_utils.getResourceIdentity)(req));
|
|
301
303
|
const resource = await resourceRegistry.getResource(resourceId, runtimeEnvironment, runtimeParams);
|
|
302
304
|
if (resource && resource.content) {
|
|
303
305
|
const type = resource.type === "text/css" ? resource.type : "application/javascript";
|
|
@@ -305,12 +307,12 @@ function apiMiddleware(app, context) {
|
|
|
305
307
|
} else if (resource && resource.stream) {
|
|
306
308
|
res.type(resource.type).stream(resource.stream);
|
|
307
309
|
} else {
|
|
308
|
-
throw import_diagnostics.createSingleDiagnosticError({description: errors.RESOURCE(resourceId.specifier)}, import_diagnostics.LwrUnresolvableError);
|
|
310
|
+
throw (0, import_diagnostics.createSingleDiagnosticError)({description: errors.RESOURCE(resourceId.specifier)}, import_diagnostics.LwrUnresolvableError);
|
|
309
311
|
}
|
|
310
312
|
res.setMetadata({resource});
|
|
311
313
|
} catch (e) {
|
|
312
314
|
console.log(e);
|
|
313
|
-
const error = import_utils.createReturnStatus(`resource "${resourceId
|
|
315
|
+
const error = (0, import_utils.createReturnStatus)(`resource "${resourceId?.specifier}"`, e);
|
|
314
316
|
res.status(error.status).send(error.message);
|
|
315
317
|
}
|
|
316
318
|
});
|
|
@@ -323,7 +325,7 @@ function apiMiddleware(app, context) {
|
|
|
323
325
|
const {
|
|
324
326
|
assetId: {specifier, type},
|
|
325
327
|
signature
|
|
326
|
-
} = import_shared_utils.getAssetIdentity(req);
|
|
328
|
+
} = (0, import_shared_utils.getAssetIdentity)(req);
|
|
327
329
|
try {
|
|
328
330
|
const assetObj = await context.assetRegistry.getAsset({specifier, signature, type}, runtimeEnvironment);
|
|
329
331
|
if (assetObj.mime) {
|
|
@@ -333,7 +335,7 @@ function apiMiddleware(app, context) {
|
|
|
333
335
|
res.stream(assetObj.stream());
|
|
334
336
|
} catch (e) {
|
|
335
337
|
console.log(e);
|
|
336
|
-
const error = import_utils.createReturnStatus(`asset at "${specifier}"`, e);
|
|
338
|
+
const error = (0, import_utils.createReturnStatus)(`asset at "${specifier}"`, e);
|
|
337
339
|
res.status(error.status).send(error.message);
|
|
338
340
|
}
|
|
339
341
|
});
|
|
@@ -353,7 +355,7 @@ function apiMiddleware(app, context) {
|
|
|
353
355
|
res.stream(assetObj.stream());
|
|
354
356
|
} catch (e) {
|
|
355
357
|
console.log(e);
|
|
356
|
-
const error = import_utils.createReturnStatus(`asset at "${specifier}"`, e);
|
|
358
|
+
const error = (0, import_utils.createReturnStatus)(`asset at "${specifier}"`, e);
|
|
357
359
|
res.status(error.status).send(error.message);
|
|
358
360
|
}
|
|
359
361
|
});
|