@squiz/render-runtime-lib 1.2.1-alpha.90 → 1.2.1-alpha.92

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: [
@@ -59310,7 +59311,7 @@ var require_lib7 = __commonJS({
59310
59311
  __createBinding(exports3, m, p);
59311
59312
  };
59312
59313
  Object.defineProperty(exports2, "__esModule", { value: true });
59313
- exports2.test = exports2.ComponentSetService = exports2.ComponentService = exports2.transformResponseForLogging = exports2.transformRequestForLogging = exports2.errorMiddleware = exports2.schemaVersions = void 0;
59314
+ exports2.ComponentSetService = exports2.ComponentService = exports2.transformResponseForLogging = exports2.transformRequestForLogging = exports2.errorMiddleware = exports2.schemaVersions = void 0;
59314
59315
  __exportStar(require_validateManifest(), exports2);
59315
59316
  var schemas_1 = require_schemas();
59316
59317
  Object.defineProperty(exports2, "schemaVersions", { enumerable: true, get: function() {
@@ -59350,10 +59351,6 @@ var require_lib7 = __commonJS({
59350
59351
  Object.defineProperty(exports2, "ComponentSetService", { enumerable: true, get: function() {
59351
59352
  return services_1.ComponentSetService;
59352
59353
  } });
59353
- function test() {
59354
- console.log("a");
59355
- }
59356
- exports2.test = test;
59357
59354
  }
59358
59355
  });
59359
59356
 
@@ -94587,8 +94584,7 @@ function validateComponentVariables(functionVariables, environment) {
94587
94584
  }
94588
94585
  async function loadEnvironment(info, environmentLoader) {
94589
94586
  const variables = await environmentLoader.getEnvironmentVariables(info.set.name);
94590
- const functionDef = info.manifest.functions.find((f) => f.name === info.functionName);
94591
- const variableValidation = validateComponentVariables(functionDef.environment || [], variables);
94587
+ const variableValidation = validateComponentVariables(info.manifest.environment || [], variables);
94592
94588
  return variableValidation;
94593
94589
  }
94594
94590
  function getProcessEnvironmentLoader() {
@@ -95188,10 +95184,10 @@ function isInProductionMode() {
95188
95184
 
95189
95185
  // src/utils/getPreviewFilePath.ts
95190
95186
  var import_path3 = __toESM(require("path"));
95191
- function getPreviewFilePath(componentName, version) {
95187
+ function getPreviewFilePath(manifestPath) {
95192
95188
  const config = ComponentRunner.getConfig();
95193
95189
  const previewFile = config.previewFile ?? "preview.html";
95194
- return import_path3.default.join(config.dataMountPoint, componentName, version, previewFile);
95190
+ return import_path3.default.join(manifestPath, "../", previewFile);
95195
95191
  }
95196
95192
 
95197
95193
  // src/utils/resolvePreviewOutput.ts
@@ -95225,6 +95221,9 @@ function jsIncludeTagHtml(file) {
95225
95221
  if (file.defer) {
95226
95222
  tagParts.push(`defer`);
95227
95223
  }
95224
+ if (file.integrity !== void 0) {
95225
+ tagParts.push(`integrity="${file.integrity}"`);
95226
+ }
95228
95227
  if (file.referrerpolicy !== void 0) {
95229
95228
  tagParts.push(`referrerpolicy="${file.referrerpolicy}"`);
95230
95229
  }
@@ -95280,11 +95279,13 @@ router.get("/:componentSet/:componentName/:version/preview", async (req, res) =>
95280
95279
  if (!config.localDevMode) {
95281
95280
  throw new import_component_lib5.ResourceNotFoundError("Not available in non-development mode");
95282
95281
  }
95283
- const previewFile = getPreviewFilePath(req.params.componentName, req.params.version);
95282
+ const prodMode = isInProductionMode();
95283
+ const manifestPath = await getManifestPath(req.params.componentName, req.params.version, prodMode);
95284
+ const previewFile = getPreviewFilePath(manifestPath);
95284
95285
  if (!await import_fs_extra.default.pathExists(previewFile)) {
95285
95286
  throw new import_component_lib5.ResourceNotFoundError(`Preview file ${previewFile} not found`);
95286
95287
  }
95287
- 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);
95288
95289
  if (typeof hr.output === "string") {
95289
95290
  const html = await import_promises.default.readFile(previewFile);
95290
95291
  res.send(resolvePreviewOutput(html.toString(), hr.output, hr.files));
@@ -95293,18 +95294,20 @@ router.get("/:componentSet/:componentName/:version/preview", async (req, res) =>
95293
95294
  res.send(hr.output);
95294
95295
  });
95295
95296
  router.get("/:componentSet/:componentName/:version", async (req, res) => {
95296
- const result = await handleRendering(req.params.componentSet, req.params.componentName, req.params.version, void 0, req.query, req.id);
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);
95297
95300
  res.send(result.output);
95298
95301
  });
95299
95302
  router.get("/:componentSet/:componentName/:version/:functionName", async (req, res) => {
95300
- const result = await handleRendering(req.params.componentSet, req.params.componentName, req.params.version, req.params.functionName, req.query, req.id);
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);
95301
95306
  res.send(result.output);
95302
95307
  });
95303
- 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) {
95304
95309
  var _a;
95305
- const prodMode = isInProductionMode();
95306
95310
  const set = await (0, import_component_lib5.loadComponentSet)(setName);
95307
- const manifestPath = await getManifestPath(componentName, version, prodMode);
95308
95311
  const component = await (0, import_component_lib5.loadComponent)(manifestPath, componentName, version, Webserver.getConfig().rootUrl, ComponentRunner.get(), prodMode);
95309
95312
  if (functionName === void 0) {
95310
95313
  functionName = component.mainFunction;
@@ -95500,8 +95503,10 @@ function setupApp(db) {
95500
95503
  crossOriginEmbedderPolicy: false,
95501
95504
  contentSecurityPolicy: {
95502
95505
  directives: {
95503
- defaultSrc: ["*"],
95504
- scriptSrc: ["*"],
95506
+ defaultSrc: ["*", "'unsafe-inline'"],
95507
+ scriptSrc: ["*", "'unsafe-inline'"],
95508
+ scriptSrcElem: ["*", "'unsafe-inline'"],
95509
+ styleSrc: ["*", "'unsafe-inline'"],
95505
95510
  imgSrc: ["*"],
95506
95511
  upgradeInsecureRequests: null
95507
95512
  }
@@ -95656,11 +95661,11 @@ var _ComponentFixture = class {
95656
95661
  version: "1.0.0",
95657
95662
  $schema: "",
95658
95663
  "main-function": "main.js",
95664
+ environment,
95659
95665
  functions: [
95660
95666
  {
95661
95667
  entry: "main.js",
95662
95668
  name: "main",
95663
- environment,
95664
95669
  input: {},
95665
95670
  output: {
95666
95671
  "response-type": "html"