@aemforms/af-core 0.22.57 → 0.22.59
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.
|
@@ -7,7 +7,10 @@ export declare type FunctionDefinition = {
|
|
|
7
7
|
_signature: Array<any>;
|
|
8
8
|
};
|
|
9
9
|
declare class FunctionRuntimeImpl {
|
|
10
|
+
private static instance;
|
|
10
11
|
private customFunctions;
|
|
12
|
+
private constructor();
|
|
13
|
+
static getInstance(): FunctionRuntimeImpl;
|
|
11
14
|
registerFunctions(functions: {
|
|
12
15
|
[key: string]: FunctionDefinition | CustomFunction;
|
|
13
16
|
}): void;
|
|
@@ -167,6 +167,12 @@ class FunctionRuntimeImpl {
|
|
|
167
167
|
constructor() {
|
|
168
168
|
this.customFunctions = {};
|
|
169
169
|
}
|
|
170
|
+
static getInstance() {
|
|
171
|
+
if (!FunctionRuntimeImpl.instance) {
|
|
172
|
+
FunctionRuntimeImpl.instance = new FunctionRuntimeImpl();
|
|
173
|
+
}
|
|
174
|
+
return FunctionRuntimeImpl.instance;
|
|
175
|
+
}
|
|
170
176
|
registerFunctions(functions) {
|
|
171
177
|
Object.entries(functions).forEach(([name, funcDef]) => {
|
|
172
178
|
let finalFunction = funcDef;
|
|
@@ -176,7 +182,7 @@ class FunctionRuntimeImpl {
|
|
|
176
182
|
const globals = {
|
|
177
183
|
form: interpreter.globals.form,
|
|
178
184
|
invoke: (funcName, ...args) => {
|
|
179
|
-
return
|
|
185
|
+
return FunctionRuntimeImpl.getInstance().customFunctions[funcName]._func.call(undefined, args, data, interpreter);
|
|
180
186
|
}
|
|
181
187
|
};
|
|
182
188
|
return funcDef(...args, globals);
|
|
@@ -188,13 +194,13 @@ class FunctionRuntimeImpl {
|
|
|
188
194
|
console.warn(`Unable to register function with name ${name}.`);
|
|
189
195
|
return;
|
|
190
196
|
}
|
|
191
|
-
|
|
197
|
+
FunctionRuntimeImpl.getInstance().customFunctions[name] = finalFunction;
|
|
192
198
|
});
|
|
193
199
|
}
|
|
194
200
|
unregisterFunctions(...names) {
|
|
195
201
|
names.forEach(name => {
|
|
196
|
-
if (name in
|
|
197
|
-
delete
|
|
202
|
+
if (name in FunctionRuntimeImpl.getInstance().customFunctions) {
|
|
203
|
+
FunctionRuntimeImpl === null || FunctionRuntimeImpl === void 0 ? true : delete FunctionRuntimeImpl.getInstance().customFunctions[name];
|
|
198
204
|
}
|
|
199
205
|
});
|
|
200
206
|
}
|
|
@@ -372,7 +378,8 @@ class FunctionRuntimeImpl {
|
|
|
372
378
|
_signature: []
|
|
373
379
|
}
|
|
374
380
|
};
|
|
375
|
-
return Object.assign(Object.assign({}, defaultFunctions),
|
|
381
|
+
return Object.assign(Object.assign({}, defaultFunctions), FunctionRuntimeImpl.getInstance().customFunctions);
|
|
376
382
|
}
|
|
377
383
|
}
|
|
378
|
-
|
|
384
|
+
FunctionRuntimeImpl.instance = null;
|
|
385
|
+
exports.FunctionRuntime = FunctionRuntimeImpl.getInstance();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aemforms/af-core",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.59",
|
|
4
4
|
"description": "Core Module for Forms Runtime",
|
|
5
5
|
"author": "Adobe Systems",
|
|
6
6
|
"license": "Adobe Proprietary",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@adobe/json-formula": "0.1.50",
|
|
38
|
-
"@aemforms/af-formatters": "^0.22.
|
|
38
|
+
"@aemforms/af-formatters": "^0.22.59"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@babel/preset-env": "^7.20.2",
|