@squiz/render-runtime-lib 1.2.1-alpha.89 → 1.2.1-alpha.93
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/lib/index.js
CHANGED
|
@@ -26180,6 +26180,12 @@ var require_v1 = __commonJS({
|
|
|
26180
26180
|
maxLength: 14,
|
|
26181
26181
|
pattern: "^(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)$"
|
|
26182
26182
|
},
|
|
26183
|
+
environment: {
|
|
26184
|
+
type: "array",
|
|
26185
|
+
items: {
|
|
26186
|
+
type: "string"
|
|
26187
|
+
}
|
|
26188
|
+
},
|
|
26183
26189
|
"static-files": {
|
|
26184
26190
|
type: "object",
|
|
26185
26191
|
properties: {
|
|
@@ -26203,12 +26209,6 @@ var require_v1 = __commonJS({
|
|
|
26203
26209
|
description: "Function name, this will be used as part of the url to access this function. It must be a valid url"
|
|
26204
26210
|
},
|
|
26205
26211
|
entry: { type: "string" },
|
|
26206
|
-
environment: {
|
|
26207
|
-
type: "array",
|
|
26208
|
-
items: {
|
|
26209
|
-
type: "string"
|
|
26210
|
-
}
|
|
26211
|
-
},
|
|
26212
26212
|
input: {
|
|
26213
26213
|
type: "object"
|
|
26214
26214
|
},
|
|
@@ -26239,6 +26239,7 @@ var require_v1 = __commonJS({
|
|
|
26239
26239
|
filepath: { type: "string" },
|
|
26240
26240
|
defer: { type: "boolean" },
|
|
26241
26241
|
async: { type: "boolean" },
|
|
26242
|
+
integrity: { type: "string" },
|
|
26242
26243
|
crossorigin: { oneOf: [{ const: "anonymous" }, { const: "use-credentials" }] },
|
|
26243
26244
|
referrerpolicy: {
|
|
26244
26245
|
oneOf: [
|
|
@@ -94583,8 +94584,7 @@ function validateComponentVariables(functionVariables, environment) {
|
|
|
94583
94584
|
}
|
|
94584
94585
|
async function loadEnvironment(info, environmentLoader) {
|
|
94585
94586
|
const variables = await environmentLoader.getEnvironmentVariables(info.set.name);
|
|
94586
|
-
const
|
|
94587
|
-
const variableValidation = validateComponentVariables(functionDef.environment || [], variables);
|
|
94587
|
+
const variableValidation = validateComponentVariables(info.manifest.environment || [], variables);
|
|
94588
94588
|
return variableValidation;
|
|
94589
94589
|
}
|
|
94590
94590
|
function getProcessEnvironmentLoader() {
|
|
@@ -95184,10 +95184,10 @@ function isInProductionMode() {
|
|
|
95184
95184
|
|
|
95185
95185
|
// src/utils/getPreviewFilePath.ts
|
|
95186
95186
|
var import_path3 = __toESM(require("path"));
|
|
95187
|
-
function getPreviewFilePath(
|
|
95187
|
+
function getPreviewFilePath(manifestPath) {
|
|
95188
95188
|
const config = ComponentRunner.getConfig();
|
|
95189
95189
|
const previewFile = config.previewFile ?? "preview.html";
|
|
95190
|
-
return import_path3.default.join(
|
|
95190
|
+
return import_path3.default.join(manifestPath, "../", previewFile);
|
|
95191
95191
|
}
|
|
95192
95192
|
|
|
95193
95193
|
// src/utils/resolvePreviewOutput.ts
|
|
@@ -95221,6 +95221,9 @@ function jsIncludeTagHtml(file) {
|
|
|
95221
95221
|
if (file.defer) {
|
|
95222
95222
|
tagParts.push(`defer`);
|
|
95223
95223
|
}
|
|
95224
|
+
if (file.integrity !== void 0) {
|
|
95225
|
+
tagParts.push(`integrity="${file.integrity}"`);
|
|
95226
|
+
}
|
|
95224
95227
|
if (file.referrerpolicy !== void 0) {
|
|
95225
95228
|
tagParts.push(`referrerpolicy="${file.referrerpolicy}"`);
|
|
95226
95229
|
}
|
|
@@ -95276,11 +95279,13 @@ router.get("/:componentSet/:componentName/:version/preview", async (req, res) =>
|
|
|
95276
95279
|
if (!config.localDevMode) {
|
|
95277
95280
|
throw new import_component_lib5.ResourceNotFoundError("Not available in non-development mode");
|
|
95278
95281
|
}
|
|
95279
|
-
const
|
|
95282
|
+
const prodMode = isInProductionMode();
|
|
95283
|
+
const manifestPath = await getManifestPath(req.params.componentName, req.params.version, prodMode);
|
|
95284
|
+
const previewFile = getPreviewFilePath(manifestPath);
|
|
95280
95285
|
if (!await import_fs_extra.default.pathExists(previewFile)) {
|
|
95281
95286
|
throw new import_component_lib5.ResourceNotFoundError(`Preview file ${previewFile} not found`);
|
|
95282
95287
|
}
|
|
95283
|
-
const hr = await handleRendering(req.params.componentSet, req.params.componentName, req.params.version, void 0, req.query, req.id, true);
|
|
95288
|
+
const hr = await handleRendering(manifestPath, req.params.componentSet, req.params.componentName, req.params.version, void 0, req.query, req.id, prodMode, true);
|
|
95284
95289
|
if (typeof hr.output === "string") {
|
|
95285
95290
|
const html = await import_promises.default.readFile(previewFile);
|
|
95286
95291
|
res.send(resolvePreviewOutput(html.toString(), hr.output, hr.files));
|
|
@@ -95289,18 +95294,20 @@ router.get("/:componentSet/:componentName/:version/preview", async (req, res) =>
|
|
|
95289
95294
|
res.send(hr.output);
|
|
95290
95295
|
});
|
|
95291
95296
|
router.get("/:componentSet/:componentName/:version", async (req, res) => {
|
|
95292
|
-
const
|
|
95297
|
+
const prodMode = isInProductionMode();
|
|
95298
|
+
const manifestPath = await getManifestPath(req.params.componentName, req.params.version, prodMode);
|
|
95299
|
+
const result = await handleRendering(manifestPath, req.params.componentSet, req.params.componentName, req.params.version, void 0, req.query, req.id, prodMode);
|
|
95293
95300
|
res.send(result.output);
|
|
95294
95301
|
});
|
|
95295
95302
|
router.get("/:componentSet/:componentName/:version/:functionName", async (req, res) => {
|
|
95296
|
-
const
|
|
95303
|
+
const prodMode = isInProductionMode();
|
|
95304
|
+
const manifestPath = await getManifestPath(req.params.componentName, req.params.version, prodMode);
|
|
95305
|
+
const result = await handleRendering(manifestPath, req.params.componentSet, req.params.componentName, req.params.version, req.params.functionName, req.query, req.id, prodMode);
|
|
95297
95306
|
res.send(result.output);
|
|
95298
95307
|
});
|
|
95299
|
-
async function handleRendering(setName, componentName, version, functionName, input, requestId, returnStaticFiles = false) {
|
|
95308
|
+
async function handleRendering(manifestPath, setName, componentName, version, functionName, input, requestId, prodMode, returnStaticFiles = false) {
|
|
95300
95309
|
var _a;
|
|
95301
|
-
const prodMode = isInProductionMode();
|
|
95302
95310
|
const set = await (0, import_component_lib5.loadComponentSet)(setName);
|
|
95303
|
-
const manifestPath = await getManifestPath(componentName, version, prodMode);
|
|
95304
95311
|
const component = await (0, import_component_lib5.loadComponent)(manifestPath, componentName, version, Webserver.getConfig().rootUrl, ComponentRunner.get(), prodMode);
|
|
95305
95312
|
if (functionName === void 0) {
|
|
95306
95313
|
functionName = component.mainFunction;
|
|
@@ -95496,8 +95503,10 @@ function setupApp(db) {
|
|
|
95496
95503
|
crossOriginEmbedderPolicy: false,
|
|
95497
95504
|
contentSecurityPolicy: {
|
|
95498
95505
|
directives: {
|
|
95499
|
-
defaultSrc: ["*"],
|
|
95500
|
-
scriptSrc: ["*"],
|
|
95506
|
+
defaultSrc: ["*", "'unsafe-inline'"],
|
|
95507
|
+
scriptSrc: ["*", "'unsafe-inline'"],
|
|
95508
|
+
scriptSrcElem: ["*", "'unsafe-inline'"],
|
|
95509
|
+
styleSrc: ["*", "'unsafe-inline'"],
|
|
95501
95510
|
imgSrc: ["*"],
|
|
95502
95511
|
upgradeInsecureRequests: null
|
|
95503
95512
|
}
|
|
@@ -95652,11 +95661,11 @@ var _ComponentFixture = class {
|
|
|
95652
95661
|
version: "1.0.0",
|
|
95653
95662
|
$schema: "",
|
|
95654
95663
|
"main-function": "main.js",
|
|
95664
|
+
environment,
|
|
95655
95665
|
functions: [
|
|
95656
95666
|
{
|
|
95657
95667
|
entry: "main.js",
|
|
95658
95668
|
name: "main",
|
|
95659
|
-
environment,
|
|
95660
95669
|
input: {},
|
|
95661
95670
|
output: {
|
|
95662
95671
|
"response-type": "html"
|