@squiz/render-runtime-lib 1.2.1-alpha.84 → 1.2.1-alpha.87
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.
|
@@ -8,7 +8,10 @@ export declare class ComponentFixture {
|
|
|
8
8
|
version: string;
|
|
9
9
|
componentName: string;
|
|
10
10
|
}>;
|
|
11
|
-
static new(returnObj: string | object
|
|
11
|
+
static new(returnObj: string | object, { raw, environment }?: {
|
|
12
|
+
raw?: boolean | undefined;
|
|
13
|
+
environment?: string[] | undefined;
|
|
14
|
+
}): Promise<ExecuteComponentTask>;
|
|
12
15
|
static updateComponent(component: ExecuteComponentTask, output: string | object): Promise<ExecuteComponentTask>;
|
|
13
16
|
private static createFixtureDirectory;
|
|
14
17
|
private static createVersionDirectory;
|
|
@@ -8072,7 +8072,7 @@ var require_v1 = __commonJS({
|
|
|
8072
8072
|
additionalProperties: false,
|
|
8073
8073
|
properties: {
|
|
8074
8074
|
$schema: { type: "string", description: "the manifest schema version" },
|
|
8075
|
-
name: { type: "string", description: "Name of the component" },
|
|
8075
|
+
name: { type: "string", description: "Name of the component", $ref: "#/$defs/name-pattern" },
|
|
8076
8076
|
"main-function": {
|
|
8077
8077
|
type: "string",
|
|
8078
8078
|
description: "Name of the main function to be executed at the root of the access url"
|
|
@@ -8103,10 +8103,16 @@ var require_v1 = __commonJS({
|
|
|
8103
8103
|
properties: {
|
|
8104
8104
|
name: {
|
|
8105
8105
|
type: "string",
|
|
8106
|
-
|
|
8106
|
+
$ref: "#/$defs/name-pattern",
|
|
8107
8107
|
description: "Function name, this will be used as part of the url to access this function. It must be a valid url"
|
|
8108
8108
|
},
|
|
8109
8109
|
entry: { type: "string" },
|
|
8110
|
+
environment: {
|
|
8111
|
+
type: "array",
|
|
8112
|
+
items: {
|
|
8113
|
+
type: "string"
|
|
8114
|
+
}
|
|
8115
|
+
},
|
|
8110
8116
|
input: {
|
|
8111
8117
|
type: "object"
|
|
8112
8118
|
},
|
|
@@ -8152,7 +8158,10 @@ var require_v1 = __commonJS({
|
|
|
8152
8158
|
}
|
|
8153
8159
|
}
|
|
8154
8160
|
},
|
|
8155
|
-
required: ["name", "version", "functions", "$schema", "main-function"]
|
|
8161
|
+
required: ["name", "version", "functions", "$schema", "main-function"],
|
|
8162
|
+
$defs: {
|
|
8163
|
+
"name-pattern": { pattern: "^[a-zA-Z0-9_\\-]+$" }
|
|
8164
|
+
}
|
|
8156
8165
|
};
|
|
8157
8166
|
}
|
|
8158
8167
|
});
|
|
@@ -40789,7 +40798,7 @@ var vm = new import_vm2.NodeVM({
|
|
|
40789
40798
|
var script = new import_vm2.VMScript(` const events = require('events');
|
|
40790
40799
|
const asyncHooks = require('async_hooks');
|
|
40791
40800
|
|
|
40792
|
-
module.exports = function(id, entry, input, info){
|
|
40801
|
+
module.exports = function(id, entry, input, info, environment = {}){
|
|
40793
40802
|
const emitter = new events.EventEmitter();
|
|
40794
40803
|
|
|
40795
40804
|
setImmediate(()=>{
|
|
@@ -40817,6 +40826,9 @@ var script = new import_vm2.VMScript(` const events = require('events');
|
|
|
40817
40826
|
return (activeResources);
|
|
40818
40827
|
}
|
|
40819
40828
|
|
|
40829
|
+
|
|
40830
|
+
// Should we override this or merge then unmerge?
|
|
40831
|
+
process.env = environment;
|
|
40820
40832
|
let script = require(entry);
|
|
40821
40833
|
|
|
40822
40834
|
if(typeof script === 'object') {
|
|
@@ -40876,7 +40888,7 @@ if (import_worker_threads.parentPort) {
|
|
|
40876
40888
|
});
|
|
40877
40889
|
import_worker_threads.parentPort.on("message", async (task) => {
|
|
40878
40890
|
var _a;
|
|
40879
|
-
const data = await executeComponent(task
|
|
40891
|
+
const data = await executeComponent(task);
|
|
40880
40892
|
(_a = import_worker_threads.parentPort) == null ? void 0 : _a.postMessage(data);
|
|
40881
40893
|
});
|
|
40882
40894
|
} else {
|
|
@@ -40886,14 +40898,14 @@ var executeComponentFunc = vm.run(script, {
|
|
|
40886
40898
|
strict: false,
|
|
40887
40899
|
wrapper: "commonjs"
|
|
40888
40900
|
});
|
|
40889
|
-
async function executeComponent(entry, id, input, info) {
|
|
40901
|
+
async function executeComponent({ path: entry, id, input, info, environment }) {
|
|
40890
40902
|
return new Promise((resolve, reject) => {
|
|
40891
40903
|
const componentContext = {
|
|
40892
40904
|
manifest: info.manifest,
|
|
40893
40905
|
set: info.set,
|
|
40894
40906
|
ctx: (0, import_component_lib.createComponentContext)(info.manifest.name, info.manifest.version, info.componentRoot, info.set)
|
|
40895
40907
|
};
|
|
40896
|
-
const componentExecutionWatcher = executeComponentFunc(id, entry, input, componentContext);
|
|
40908
|
+
const componentExecutionWatcher = executeComponentFunc(id, entry, input, componentContext, environment || {});
|
|
40897
40909
|
componentExecutionWatcher.on("console", (args) => {
|
|
40898
40910
|
var _a;
|
|
40899
40911
|
const message = JSON.parse(JSON.stringify(args.message));
|