@lwrjs/core 0.4.5 → 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/LICENSE ADDED
@@ -0,0 +1,10 @@
1
+ MIT LICENSE
2
+
3
+ Copyright (c) 2020, Salesforce.com, Inc.
4
+ All rights reserved.
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
7
+
8
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
9
+
10
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -55,8 +55,9 @@ function apiMiddleware(app, context) {
55
55
  res.status(400).send({error: `Environment "${targetEnvironment}" is not supported`});
56
56
  return;
57
57
  }
58
- const {moduleId, signature} = (0, import_shared_utils.getModuleIdentity)(req);
58
+ let moduleId, signature;
59
59
  try {
60
+ ({moduleId, signature} = (0, import_shared_utils.getModuleIdentity)(req));
60
61
  const sourceMapUrl = req.path.replace("/bundle/", "/sourcemaps/bundle/");
61
62
  const sourceMapRuntimeContext = {...runtimeEnvironment, sourceMapUrl};
62
63
  const importerSpecifier = req.query.importer;
@@ -101,7 +102,7 @@ function apiMiddleware(app, context) {
101
102
  res.type("application/javascript").send(bundleDef.code);
102
103
  } catch (e) {
103
104
  console.log(e);
104
- const error = (0, import_utils.createReturnStatus)(`bundle for "${moduleId.specifier}"`, e);
105
+ const error = (0, import_utils.createReturnStatus)(`bundle for "${moduleId?.specifier}"`, e);
105
106
  res.status(error.status).send(error.message);
106
107
  }
107
108
  });
@@ -117,9 +118,9 @@ function apiMiddleware(app, context) {
117
118
  res.status(400).send({error: `Environment "${targetEnvironment}" is not supported`});
118
119
  return;
119
120
  }
120
- const id = (0, import_shared_utils.getModuleIdentity)(req);
121
- let moduleId = id.moduleId;
121
+ let moduleId;
122
122
  try {
123
+ ({moduleId} = (0, import_shared_utils.getModuleIdentity)(req));
123
124
  const importerSpecifier = req.query.importer;
124
125
  if (importerSpecifier) {
125
126
  const importerModuleId = (0, import_shared_utils.explodeSpecifier)(importerSpecifier);
@@ -142,7 +143,7 @@ function apiMiddleware(app, context) {
142
143
  }
143
144
  } catch (e) {
144
145
  console.log(e);
145
- const error = (0, import_utils.createReturnStatus)(`bundle for "${moduleId.specifier}"`, e);
146
+ const error = (0, import_utils.createReturnStatus)(`bundle for "${moduleId?.specifier}"`, e);
146
147
  res.status(error.status).send(error.message);
147
148
  }
148
149
  });
@@ -163,8 +164,9 @@ function apiMiddleware(app, context) {
163
164
  res.status(400).send({error: `Environment "${targetEnvironment}" is not supported`});
164
165
  return;
165
166
  }
166
- const {moduleId, signature} = (0, import_shared_utils.getModuleIdentity)(req);
167
+ let moduleId, signature;
167
168
  try {
169
+ ({moduleId, signature} = (0, import_shared_utils.getModuleIdentity)(req));
168
170
  const bundleDef = await moduleBundler.getModuleBundle(moduleId, runtimeEnvironment);
169
171
  if (signature !== import_shared_utils.LATEST_SIGNATURE) {
170
172
  res.setHeader("Cache-control", "public, max-age=31536000, immutable");
@@ -172,7 +174,7 @@ function apiMiddleware(app, context) {
172
174
  res.type("application/json").send(bundleDef.map);
173
175
  } catch (e) {
174
176
  console.log(e);
175
- const error = (0, import_utils.createReturnStatus)(`bundle sourcemap for "${moduleId.specifier}"`, e);
177
+ const error = (0, import_utils.createReturnStatus)(`bundle sourcemap for "${moduleId?.specifier}"`, e);
176
178
  res.status(error.status).send(error.message);
177
179
  }
178
180
  });
@@ -192,8 +194,9 @@ function apiMiddleware(app, context) {
192
194
  res.status(400).send({error: `Environment "${targetEnvironment}" is not supported`});
193
195
  return;
194
196
  }
195
- const {moduleId, signature} = (0, import_shared_utils.getModuleIdentity)(req);
197
+ let moduleId, signature;
196
198
  try {
199
+ ({moduleId, signature} = (0, import_shared_utils.getModuleIdentity)(req));
197
200
  if (!req.validateJsonRequest()) {
198
201
  throw (0, import_diagnostics.createSingleDiagnosticError)({description: errors.INVALID_JSON()}, import_diagnostics.LwrUnresolvableError);
199
202
  }
@@ -213,7 +216,7 @@ function apiMiddleware(app, context) {
213
216
  }
214
217
  } catch (e) {
215
218
  console.log(e);
216
- const error = (0, import_utils.createReturnStatus)(`module "${moduleId.specifier}"`, e);
219
+ const error = (0, import_utils.createReturnStatus)(`module "${moduleId?.specifier}"`, e);
217
220
  res.status(error.status).send(error.message);
218
221
  }
219
222
  });
@@ -229,9 +232,9 @@ function apiMiddleware(app, context) {
229
232
  res.status(400).send({error: `Environment "${targetEnvironment}" is not supported`});
230
233
  return;
231
234
  }
232
- const id = (0, import_shared_utils.getModuleIdentity)(req);
233
- let moduleId = id.moduleId;
235
+ let moduleId;
234
236
  try {
237
+ ({moduleId} = (0, import_shared_utils.getModuleIdentity)(req));
235
238
  const importerSpecifier = req.query.importer;
236
239
  if (importerSpecifier) {
237
240
  const importerModuleId = (0, import_shared_utils.explodeSpecifier)(importerSpecifier);
@@ -254,7 +257,7 @@ function apiMiddleware(app, context) {
254
257
  }
255
258
  } catch (e) {
256
259
  console.log(e);
257
- const error = (0, import_utils.createReturnStatus)(`module "${moduleId.specifier}"`, e);
260
+ const error = (0, import_utils.createReturnStatus)(`module "${moduleId?.specifier}"`, e);
258
261
  res.status(error.status).send(error.message);
259
262
  }
260
263
  });
@@ -270,8 +273,9 @@ function apiMiddleware(app, context) {
270
273
  res.status(400).send({error: `Environment "${targetEnvironment}" is not supported`});
271
274
  return;
272
275
  }
273
- const {moduleIds} = (0, import_shared_utils.getMappingIdentity)(req);
276
+ let moduleIds;
274
277
  try {
278
+ ({moduleIds} = (0, import_shared_utils.getMappingIdentity)(req));
275
279
  const {runtimeEnvironment, runtimeParams} = requestContext;
276
280
  const importMetadata = await (0, import_shared_utils.getImportMetadataMappings)(moduleIds, runtimeEnvironment, runtimeParams, moduleRegistry, moduleBundler);
277
281
  res.type("application/json").send(importMetadata);
@@ -293,8 +297,9 @@ function apiMiddleware(app, context) {
293
297
  res.status(400).send({error: `Environment "${targetEnvironment}" is not supported`});
294
298
  return;
295
299
  }
296
- const {resourceId} = (0, import_shared_utils.getResourceIdentity)(req);
300
+ let resourceId;
297
301
  try {
302
+ ({resourceId} = (0, import_shared_utils.getResourceIdentity)(req));
298
303
  const resource = await resourceRegistry.getResource(resourceId, runtimeEnvironment, runtimeParams);
299
304
  if (resource && resource.content) {
300
305
  const type = resource.type === "text/css" ? resource.type : "application/javascript";
@@ -307,7 +312,7 @@ function apiMiddleware(app, context) {
307
312
  res.setMetadata({resource});
308
313
  } catch (e) {
309
314
  console.log(e);
310
- const error = (0, import_utils.createReturnStatus)(`resource "${resourceId.specifier}"`, e);
315
+ const error = (0, import_utils.createReturnStatus)(`resource "${resourceId?.specifier}"`, e);
311
316
  res.status(error.status).send(error.message);
312
317
  }
313
318
  });
@@ -27,8 +27,9 @@ export default function apiMiddleware(app, context) {
27
27
  res.status(400).send({ error: `Environment "${targetEnvironment}" is not supported` });
28
28
  return;
29
29
  }
30
- const { moduleId, signature } = getModuleIdentity(req);
30
+ let moduleId, signature;
31
31
  try {
32
+ ({ moduleId, signature } = getModuleIdentity(req));
32
33
  const sourceMapUrl = req.path.replace('/bundle/', '/sourcemaps/bundle/');
33
34
  const sourceMapRuntimeContext = { ...runtimeEnvironment, sourceMapUrl };
34
35
  // Redirect module requests to the concrete URL when requested with an importer
@@ -81,7 +82,7 @@ export default function apiMiddleware(app, context) {
81
82
  }
82
83
  catch (e) {
83
84
  console.log(e);
84
- const error = createReturnStatus(`bundle for "${moduleId.specifier}"`, e);
85
+ const error = createReturnStatus(`bundle for "${moduleId?.specifier}"`, e);
85
86
  res.status(error.status).send(error.message);
86
87
  }
87
88
  });
@@ -102,9 +103,9 @@ export default function apiMiddleware(app, context) {
102
103
  res.status(400).send({ error: `Environment "${targetEnvironment}" is not supported` });
103
104
  return;
104
105
  }
105
- const id = getModuleIdentity(req);
106
- let moduleId = id.moduleId;
106
+ let moduleId;
107
107
  try {
108
+ ({ moduleId } = getModuleIdentity(req));
108
109
  // Get the importer's specifier via the "importer" query param
109
110
  const importerSpecifier = req.query.importer;
110
111
  if (importerSpecifier) {
@@ -133,7 +134,7 @@ export default function apiMiddleware(app, context) {
133
134
  }
134
135
  catch (e) {
135
136
  console.log(e);
136
- const error = createReturnStatus(`bundle for "${moduleId.specifier}"`, e);
137
+ const error = createReturnStatus(`bundle for "${moduleId?.specifier}"`, e);
137
138
  res.status(error.status).send(error.message);
138
139
  }
139
140
  });
@@ -159,8 +160,9 @@ export default function apiMiddleware(app, context) {
159
160
  res.status(400).send({ error: `Environment "${targetEnvironment}" is not supported` });
160
161
  return;
161
162
  }
162
- const { moduleId, signature } = getModuleIdentity(req);
163
+ let moduleId, signature;
163
164
  try {
165
+ ({ moduleId, signature } = getModuleIdentity(req));
164
166
  const bundleDef = await moduleBundler.getModuleBundle(moduleId, runtimeEnvironment);
165
167
  if (signature !== LATEST_SIGNATURE) {
166
168
  res.setHeader('Cache-control', 'public, max-age=31536000, immutable');
@@ -169,7 +171,7 @@ export default function apiMiddleware(app, context) {
169
171
  }
170
172
  catch (e) {
171
173
  console.log(e);
172
- const error = createReturnStatus(`bundle sourcemap for "${moduleId.specifier}"`, e);
174
+ const error = createReturnStatus(`bundle sourcemap for "${moduleId?.specifier}"`, e);
173
175
  res.status(error.status).send(error.message);
174
176
  }
175
177
  });
@@ -195,8 +197,9 @@ export default function apiMiddleware(app, context) {
195
197
  res.status(400).send({ error: `Environment "${targetEnvironment}" is not supported` });
196
198
  return;
197
199
  }
198
- const { moduleId, signature } = getModuleIdentity(req);
200
+ let moduleId, signature;
199
201
  try {
202
+ ({ moduleId, signature } = getModuleIdentity(req));
200
203
  if (!req.validateJsonRequest()) {
201
204
  throw createDiagnostic({ description: errors.INVALID_JSON() }, LwrUnresolvableError);
202
205
  }
@@ -221,7 +224,7 @@ export default function apiMiddleware(app, context) {
221
224
  }
222
225
  catch (e) {
223
226
  console.log(e);
224
- const error = createReturnStatus(`module "${moduleId.specifier}"`, e);
227
+ const error = createReturnStatus(`module "${moduleId?.specifier}"`, e);
225
228
  res.status(error.status).send(error.message);
226
229
  }
227
230
  });
@@ -242,9 +245,9 @@ export default function apiMiddleware(app, context) {
242
245
  res.status(400).send({ error: `Environment "${targetEnvironment}" is not supported` });
243
246
  return;
244
247
  }
245
- const id = getModuleIdentity(req);
246
- let moduleId = id.moduleId;
248
+ let moduleId;
247
249
  try {
250
+ ({ moduleId } = getModuleIdentity(req));
248
251
  // Get the importer's specifier via the "importer" query param
249
252
  const importerSpecifier = req.query.importer;
250
253
  if (importerSpecifier) {
@@ -273,7 +276,7 @@ export default function apiMiddleware(app, context) {
273
276
  }
274
277
  catch (e) {
275
278
  console.log(e);
276
- const error = createReturnStatus(`module "${moduleId.specifier}"`, e);
279
+ const error = createReturnStatus(`module "${moduleId?.specifier}"`, e);
277
280
  res.status(error.status).send(error.message);
278
281
  }
279
282
  });
@@ -295,8 +298,9 @@ export default function apiMiddleware(app, context) {
295
298
  res.status(400).send({ error: `Environment "${targetEnvironment}" is not supported` });
296
299
  return;
297
300
  }
298
- const { moduleIds } = getMappingIdentity(req);
301
+ let moduleIds;
299
302
  try {
303
+ ({ moduleIds } = getMappingIdentity(req));
300
304
  const { runtimeEnvironment, runtimeParams } = requestContext;
301
305
  const importMetadata = await getImportMetadataMappings(moduleIds, runtimeEnvironment, runtimeParams, moduleRegistry, moduleBundler);
302
306
  res.type('application/json').send(importMetadata);
@@ -324,8 +328,9 @@ export default function apiMiddleware(app, context) {
324
328
  res.status(400).send({ error: `Environment "${targetEnvironment}" is not supported` });
325
329
  return;
326
330
  }
327
- const { resourceId } = getResourceIdentity(req);
331
+ let resourceId;
328
332
  try {
333
+ ({ resourceId } = getResourceIdentity(req));
329
334
  const resource = await resourceRegistry.getResource(resourceId, runtimeEnvironment, runtimeParams);
330
335
  if (resource && resource.content) {
331
336
  // Static resource
@@ -343,7 +348,7 @@ export default function apiMiddleware(app, context) {
343
348
  }
344
349
  catch (e) {
345
350
  console.log(e);
346
- const error = createReturnStatus(`resource "${resourceId.specifier}"`, e);
351
+ const error = createReturnStatus(`resource "${resourceId?.specifier}"`, e);
347
352
  res.status(error.status).send(error.message);
348
353
  }
349
354
  });
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.4.5",
7
+ "version": "0.4.6",
8
8
  "homepage": "https://lwr.dev/",
9
9
  "repository": {
10
10
  "type": "git",
@@ -33,27 +33,27 @@
33
33
  "package.cjs"
34
34
  ],
35
35
  "dependencies": {
36
- "@lwrjs/app-service": "0.4.5",
37
- "@lwrjs/asset-registry": "0.4.5",
38
- "@lwrjs/base-template-engine": "0.4.5",
39
- "@lwrjs/base-view-provider": "0.4.5",
40
- "@lwrjs/client-modules": "0.4.5",
41
- "@lwrjs/compiler": "0.4.5",
42
- "@lwrjs/diagnostics": "0.4.5",
43
- "@lwrjs/fs-asset-provider": "0.4.5",
44
- "@lwrjs/html-view-provider": "0.4.5",
45
- "@lwrjs/loader": "0.4.5",
46
- "@lwrjs/lwc-module-provider": "0.4.5",
47
- "@lwrjs/markdown-view-provider": "0.4.5",
48
- "@lwrjs/module-bundler": "0.4.5",
49
- "@lwrjs/module-registry": "0.4.5",
50
- "@lwrjs/npm-module-provider": "0.4.5",
51
- "@lwrjs/nunjucks-view-provider": "0.4.5",
52
- "@lwrjs/resource-registry": "0.4.5",
53
- "@lwrjs/router": "0.4.5",
54
- "@lwrjs/server": "0.4.5",
55
- "@lwrjs/shared-utils": "0.4.5",
56
- "@lwrjs/view-registry": "0.4.5",
36
+ "@lwrjs/app-service": "0.4.6",
37
+ "@lwrjs/asset-registry": "0.4.6",
38
+ "@lwrjs/base-template-engine": "0.4.6",
39
+ "@lwrjs/base-view-provider": "0.4.6",
40
+ "@lwrjs/client-modules": "0.4.6",
41
+ "@lwrjs/compiler": "0.4.6",
42
+ "@lwrjs/diagnostics": "0.4.6",
43
+ "@lwrjs/fs-asset-provider": "0.4.6",
44
+ "@lwrjs/html-view-provider": "0.4.6",
45
+ "@lwrjs/loader": "0.4.6",
46
+ "@lwrjs/lwc-module-provider": "0.4.6",
47
+ "@lwrjs/markdown-view-provider": "0.4.6",
48
+ "@lwrjs/module-bundler": "0.4.6",
49
+ "@lwrjs/module-registry": "0.4.6",
50
+ "@lwrjs/npm-module-provider": "0.4.6",
51
+ "@lwrjs/nunjucks-view-provider": "0.4.6",
52
+ "@lwrjs/resource-registry": "0.4.6",
53
+ "@lwrjs/router": "0.4.6",
54
+ "@lwrjs/server": "0.4.6",
55
+ "@lwrjs/shared-utils": "0.4.6",
56
+ "@lwrjs/view-registry": "0.4.6",
57
57
  "dompurify": "^2.3.0",
58
58
  "fs-extra": "^10.0.0",
59
59
  "jsdom": "^16.7.0",
@@ -63,12 +63,13 @@
63
63
  "qs": "^6.9.4"
64
64
  },
65
65
  "devDependencies": {
66
- "@lwrjs/types": "0.4.5"
66
+ "@lwrjs/types": "0.4.6"
67
67
  },
68
68
  "peerDependencies": {
69
69
  "lwc": ">= 1.x <= 2.x"
70
70
  },
71
71
  "engines": {
72
72
  "node": ">=14.15.4 <15"
73
- }
73
+ },
74
+ "gitHead": "71f599b20c35d612e55312e94804a97e7cc778e1"
74
75
  }