diff --git a/lib/FormioUtils.d.ts b/lib/FormioUtils.d.ts index 8229d26..003525d 100644 --- a/lib/FormioUtils.d.ts +++ b/lib/FormioUtils.d.ts @@ -1,2 +1,2 @@ -import { Utils as FormioUtils } from 'formiojs'; +import { Utils as FormioUtils } from '@formio/js'; export default FormioUtils; diff --git a/package.json b/package.json index dd61422..ca22e2f 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "@formio/js": "^5.0.0-rc.54" }, "dependencies": { + "@formio/core": "^1.2.0", "js-interpreter": "https://github.com/formio/JS-Interpreter#v1.1.0-formio.3", "lodash": "^4.17.21", "vm-browserify": "^1.1.2" diff --git a/src/FormioUtils.ts b/src/FormioUtils.ts index aae8dd2..548d62f 100644 --- a/src/FormioUtils.ts +++ b/src/FormioUtils.ts @@ -1,9 +1,9 @@ -import {Utils as FormioUtils} from 'formiojs'; +import { JSONLogicEvaluator } from '@formio/core/lib/modules/jsonlogic'; import {lodash as _} from './utils/lodash'; -const baseEvaluate = FormioUtils.evaluate; -FormioUtils.evaluate = function evaluate(func, args, ret, tokenize, ...rest) { +const baseEvaluate = JSONLogicEvaluator.evaluate; +JSONLogicEvaluator.evaluate = function evaluate(func, args, ret, tokenize, ...rest) { if (!FormioUtils.Evaluator.protectedEval || typeof func !== 'string') { return baseEvaluate(func, args, ret, tokenize, ...rest); } diff --git a/src/ProtectedEvaluator.ts b/src/ProtectedEvaluator.ts index d69a76f..4c9e0e1 100644 --- a/src/ProtectedEvaluator.ts +++ b/src/ProtectedEvaluator.ts @@ -1,9 +1,7 @@ -import {Utils as FormioUtils} from 'formiojs'; +import { JSONLogicEvaluator } from '@formio/core/lib/modules/jsonlogic'; import Interpreter from 'js-interpreter'; -const baseEvaluator = FormioUtils.Evaluator.evaluator; -const baseEvaluate = FormioUtils.Evaluator.evaluate; - +const baseEvaluator = (JSONLogicEvaluator as any).evaluator; export interface IEvaluator { noeval?: boolean; protectedEval?: boolean; @@ -26,7 +24,7 @@ const Evaluator: IEvaluator = { }, evaluate: (func: string | any, args: any, ...rest: any[]): any => { if (!Evaluator.protectedEval || typeof func !== 'string') { - return baseEvaluate(func, args, ...rest); + return JSONLogicEvaluator.evaluate(func, args, ...rest); } func = `result = (function() {${func}})()`; diff --git a/src/utils/lodash.ts b/src/utils/lodash.ts index da139f9..2c6be8a 100644 --- a/src/utils/lodash.ts +++ b/src/utils/lodash.ts @@ -1,5 +1,5 @@ import _ from 'lodash'; -import {lodashOperators} from 'formiojs/utils/jsonlogic/operators'; +import {lodashOperators} from '@formio/js/lib/cjs/utils/jsonlogic/operators'; export const lodash = lodashOperators.reduce((obj, operator) => _.set(obj, operator, _[operator]), {}); diff --git a/webpack.config.js b/webpack.config.js index 87875e3..e9f9bcb 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -24,6 +24,6 @@ module.exports = { } }, externals: { - formiojs: 'Formio', + '@formio/js': 'Formio', }, }; diff --git a/yarn.lock b/yarn.lock index 9ceed70..4cf2734 100644 --- a/yarn.lock +++ b/yarn.lock @@ -60,6 +60,19 @@ fuse.js "^6.6.2" redux "^4.2.0" +"@formio/core@^1.2.0": + version "1.2.0" + resolved "https://registry.npmjs.org/@formio/core/-/core-1.2.0.tgz#5f046bc5d536f2ece321b0785f5c423dc6d447f2" + integrity sha512-Emt64RzWnCg+HCcC8LNzLaTf96fOYjz4xVE6CPkhCcIcpMOVsZrUlIsTaxnaQn3lNPvt7bCp1uCcyy5dRJUK9Q== + dependencies: + "@formio/lodash" "0.0.9" + core-js "^3.21.1" + dayjs "^1.10.8" + dompurify "^2.3.6" + eventemitter3 "^4.0.7" + fetch-ponyfill "^7.1.0" + json-logic-js "^2.0.2" + "@formio/core@^2.1.0-dev.tt.8": version "2.1.0-rc.2" resolved "https://registry.npmjs.org/@formio/core/-/core-2.1.0-rc.2.tgz#885e379aeb3103a1ca190f58226e1509f5d668df" @@ -120,6 +133,11 @@ uuid "^9.0.0" vanilla-picker "^2.12.3" +"@formio/lodash@0.0.9": + version "0.0.9" + resolved "https://registry.npmjs.org/@formio/lodash/-/lodash-0.0.9.tgz#60c57131e960aeb87194e3420c642c9d4ee07fae" + integrity sha512-g/mcs0WOjcivqXFtc148jrfuSdZiwbX/CWHSTzPDwMCJzJIy7iftO9G6jyewELsKG2DGzqLRHxbDW/jnr4WjPw== + "@formio/text-mask-addons@^3.8.0-formio.2": version "3.8.0-formio.2" resolved "https://registry.npmjs.org/@formio/text-mask-addons/-/text-mask-addons-3.8.0-formio.2.tgz#b9489e68911c70a31997b97dd846d8a7cca6abdb" @@ -703,7 +721,7 @@ contra@1.9.4: atoa "1.0.0" ticky "1.0.1" -core-js@^3.33.2, core-js@^3.37.1: +core-js@^3.21.1, core-js@^3.33.2, core-js@^3.37.1: version "3.37.1" resolved "https://registry.npmjs.org/core-js/-/core-js-3.37.1.tgz#d21751ddb756518ac5a00e4d66499df981a62db9" integrity sha512-Xn6qmxrQZyB0FFY8E3bgRXei3lWDJHhvI+u0q9TKIYM49G8pAr0FgnnrFRAmsbptZL1yxRADVXn+x5AGsbBfyw== @@ -736,7 +754,7 @@ custom-event@^1.0.0: resolved "https://registry.npmjs.org/custom-event/-/custom-event-1.0.1.tgz#5d02a46850adf1b4a317946a3928fccb5bfd0425" integrity sha512-GAj5FOq0Hd+RsCGVJxZuKaIDXDf3h6GQoNEjFgbLLI/trgtavwUbSnZ5pVfg27DVCaWjIohryS0JFwIJyT2cMg== -dayjs@^1.11.10: +dayjs@^1.10.8, dayjs@^1.11.10: version "1.11.11" resolved "https://registry.npmjs.org/dayjs/-/dayjs-1.11.11.tgz#dfe0e9d54c5f8b68ccf8ca5f72ac603e7e5ed59e" integrity sha512-okzr3f11N6WuqYtZSvm+F776mB41wRZMhKP+hc34YdW+KmtYYK9iqvHSwo2k9FEH3fhGXvOPV6yz2IcSrfRUDg== @@ -803,6 +821,11 @@ dom-set@^1.0.1: is-array "^1.0.1" iselement "^1.1.4" +dompurify@^2.3.6: + version "2.5.5" + resolved "https://registry.npmjs.org/dompurify/-/dompurify-2.5.5.tgz#0540a05b8020d4691ee9c6083fb23b2c919276fc" + integrity sha512-FgbqnEPiv5Vdtwt6Mxl7XSylttCC03cqP5ldNT2z+Kj0nLxPHJH4+1Cyf5Jasxhw93Rl4Oo11qRoUV72fmya2Q== + dompurify@^3.0.6, dompurify@^3.1.3: version "3.1.4" resolved "https://registry.npmjs.org/dompurify/-/dompurify-3.1.4.tgz#42121304b2b3a6bae22f80131ff8a8f3f3c56be2" @@ -958,6 +981,11 @@ esutils@^2.0.2: resolved "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== +eventemitter3@^4.0.7: + version "4.0.7" + resolved "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz#2de9b68f6528d5644ef5c59526a1b4a07306169f" + integrity sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw== + eventemitter3@^5.0.0, eventemitter3@^5.0.1: version "5.0.1" resolved "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.1.tgz#53f5ffd0a492ac800721bb42c66b841de96423c4"