@budibase/string-templates 2.17.8 → 2.18.1
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/dist/bundle.mjs +1 -1
- package/dist/errors.d.ts +4 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -1
- package/package.json +6 -4
- package/src/errors.js +11 -0
- package/src/helpers/javascript.js +1 -1
- package/src/helpers/list.js +23 -10
- package/src/index.cjs +5 -0
- package/src/index.js +5 -0
- package/src/index.mjs +2 -0
package/dist/errors.d.ts
ADDED
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
@@ -15,4 +15,4 @@ export function doesContainString(template: string, string: string): boolean;
|
|
15
15
|
export function convertToJS(hbs: any): string;
|
16
16
|
import { FIND_ANY_HBS_REGEX } from "./utilities";
|
17
17
|
import { helpersToRemoveForJs } from "./helpers/list";
|
18
|
-
export { setJSRunner, FIND_ANY_HBS_REGEX, helpersToRemoveForJs };
|
18
|
+
export { setJSRunner, FIND_ANY_HBS_REGEX, JsErrorTimeout, helpersToRemoveForJs };
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@budibase/string-templates",
|
3
|
-
"version": "2.
|
3
|
+
"version": "2.18.1",
|
4
4
|
"description": "Handlebars wrapper for Budibase templating.",
|
5
5
|
"main": "src/index.cjs",
|
6
6
|
"module": "dist/bundle.mjs",
|
@@ -11,7 +11,8 @@
|
|
11
11
|
"require": "./src/index.cjs",
|
12
12
|
"import": "./dist/bundle.mjs"
|
13
13
|
},
|
14
|
-
"./package.json": "./package.json"
|
14
|
+
"./package.json": "./package.json",
|
15
|
+
"./test/utils": "./test/utils.js"
|
15
16
|
},
|
16
17
|
"files": [
|
17
18
|
"dist",
|
@@ -20,7 +21,7 @@
|
|
20
21
|
],
|
21
22
|
"scripts": {
|
22
23
|
"build": "tsc && rollup -c",
|
23
|
-
"dev": "tsc
|
24
|
+
"dev": "concurrently \"tsc --watch\" \"rollup -cw\"",
|
24
25
|
"test": "jest",
|
25
26
|
"manifest": "node ./scripts/gen-collection-info.js"
|
26
27
|
},
|
@@ -34,6 +35,7 @@
|
|
34
35
|
"devDependencies": {
|
35
36
|
"@rollup/plugin-commonjs": "^17.1.0",
|
36
37
|
"@rollup/plugin-json": "^4.1.0",
|
38
|
+
"concurrently": "^8.2.2",
|
37
39
|
"doctrine": "^3.0.0",
|
38
40
|
"jest": "29.7.0",
|
39
41
|
"marked": "^4.0.10",
|
@@ -45,5 +47,5 @@
|
|
45
47
|
"rollup-plugin-terser": "^7.0.2",
|
46
48
|
"typescript": "5.2.2"
|
47
49
|
},
|
48
|
-
"gitHead": "
|
50
|
+
"gitHead": "bacb888b699e362e38c2be211a2a524e3172c347"
|
49
51
|
}
|
package/src/errors.js
ADDED
@@ -42,7 +42,7 @@ module.exports.processJS = (handlebars, context) => {
|
|
42
42
|
try {
|
43
43
|
// Wrap JS in a function and immediately invoke it.
|
44
44
|
// This is required to allow the final `return` statement to be valid.
|
45
|
-
const js = `function
|
45
|
+
const js = `(function(){${atob(handlebars)}})();`
|
46
46
|
|
47
47
|
// Our $ context function gets a value from context.
|
48
48
|
// We clone the context to avoid mutation in the binding affecting real
|
package/src/helpers/list.js
CHANGED
@@ -1,29 +1,42 @@
|
|
1
|
-
const
|
2
|
-
const helperList = require("@budibase/handlebars-helpers")
|
1
|
+
const { date, duration } = require("./date")
|
3
2
|
|
4
|
-
|
3
|
+
// https://github.com/evanw/esbuild/issues/56
|
4
|
+
const externalCollections = {
|
5
|
+
math: require("@budibase/handlebars-helpers/lib/math"),
|
6
|
+
array: require("@budibase/handlebars-helpers/lib/array"),
|
7
|
+
number: require("@budibase/handlebars-helpers/lib/number"),
|
8
|
+
url: require("@budibase/handlebars-helpers/lib/url"),
|
9
|
+
string: require("@budibase/handlebars-helpers/lib/string"),
|
10
|
+
comparison: require("@budibase/handlebars-helpers/lib/comparison"),
|
11
|
+
object: require("@budibase/handlebars-helpers/lib/object"),
|
12
|
+
regex: require("@budibase/handlebars-helpers/lib/regex"),
|
13
|
+
uuid: require("@budibase/handlebars-helpers/lib/uuid"),
|
14
|
+
}
|
5
15
|
|
6
16
|
const helpersToRemoveForJs = ["sortBy"]
|
7
17
|
module.exports.helpersToRemoveForJs = helpersToRemoveForJs
|
8
18
|
|
19
|
+
const addedHelpers = {
|
20
|
+
date: date,
|
21
|
+
duration: duration,
|
22
|
+
}
|
23
|
+
|
24
|
+
let helpers = undefined
|
25
|
+
|
9
26
|
module.exports.getJsHelperList = () => {
|
10
27
|
if (helpers) {
|
11
28
|
return helpers
|
12
29
|
}
|
13
30
|
|
14
31
|
helpers = {}
|
15
|
-
let
|
16
|
-
for (let collection of externalHandlebars.externalCollections) {
|
17
|
-
constructed.push(helperList[collection]())
|
18
|
-
}
|
19
|
-
for (let collection of constructed) {
|
32
|
+
for (let collection of Object.values(externalCollections)) {
|
20
33
|
for (let [key, func] of Object.entries(collection)) {
|
21
34
|
// Handlebars injects the hbs options to the helpers by default. We are adding an empty {} as a last parameter to simulate it
|
22
35
|
helpers[key] = (...props) => func(...props, {})
|
23
36
|
}
|
24
37
|
}
|
25
|
-
for (let key of Object.keys(
|
26
|
-
helpers[key] =
|
38
|
+
for (let key of Object.keys(addedHelpers)) {
|
39
|
+
helpers[key] = addedHelpers[key]
|
27
40
|
}
|
28
41
|
|
29
42
|
for (const toRemove of helpersToRemoveForJs) {
|
package/src/index.cjs
CHANGED
package/src/index.js
CHANGED
@@ -395,4 +395,9 @@ module.exports.convertToJS = hbs => {
|
|
395
395
|
}
|
396
396
|
|
397
397
|
module.exports.FIND_ANY_HBS_REGEX = FIND_ANY_HBS_REGEX
|
398
|
+
|
399
|
+
const errors = require("./errors")
|
400
|
+
// We cannot use dynamic exports, otherwise the typescript file will not be generating it
|
401
|
+
module.exports.JsErrorTimeout = errors.JsErrorTimeout
|
402
|
+
|
398
403
|
module.exports.helpersToRemoveForJs = helpersToRemoveForJs
|