@nocobase/utils 0.20.0-alpha.9 → 0.21.0-alpha.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/lib/client.d.ts CHANGED
@@ -16,3 +16,4 @@ export * from './isPortalInBody';
16
16
  export * from './uid';
17
17
  export * from './url';
18
18
  export { dayjs, lodash };
19
+ export * from './parseHTML';
package/lib/client.js CHANGED
@@ -49,6 +49,7 @@ __reExport(client_exports, require("./registry"), module.exports);
49
49
  __reExport(client_exports, require("./isPortalInBody"), module.exports);
50
50
  __reExport(client_exports, require("./uid"), module.exports);
51
51
  __reExport(client_exports, require("./url"), module.exports);
52
+ __reExport(client_exports, require("./parseHTML"), module.exports);
52
53
  // Annotate the CommonJS export names for ESM import in node:
53
54
  0 && (module.exports = {
54
55
  dayjs,
@@ -67,5 +68,6 @@ __reExport(client_exports, require("./url"), module.exports);
67
68
  ...require("./registry"),
68
69
  ...require("./isPortalInBody"),
69
70
  ...require("./uid"),
70
- ...require("./url")
71
+ ...require("./url"),
72
+ ...require("./parseHTML")
71
73
  });
@@ -101,14 +101,11 @@ const parseString = (() => {
101
101
  if (typeof value === "function") {
102
102
  value = value();
103
103
  }
104
- if (typeof value === "object" && value !== null) {
104
+ if (str.startsWith("{{") && str.endsWith("}}")) {
105
105
  return value;
106
106
  }
107
- if (matches.length === 1 && str.startsWith("{{") && str.endsWith("}}")) {
108
- return value;
109
- }
110
- if (matches.length === 1 && str.startsWith("{{") && str.endsWith("}}")) {
111
- return value;
107
+ if (value instanceof Date) {
108
+ value = value.toISOString();
112
109
  }
113
110
  return result.replace(match, value == null ? "" : value);
114
111
  }, str);
@@ -0,0 +1,7 @@
1
+ /**
2
+ * parseHTML('<span>{{version}}</span>', { version: '1.0.0' }) -> '<span>1.0.0</span>'
3
+ * @param html
4
+ * @param variables
5
+ * @returns
6
+ */
7
+ export declare function parseHTML(html: string, variables: Record<string, any>): string;
@@ -0,0 +1,33 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var parseHTML_exports = {};
20
+ __export(parseHTML_exports, {
21
+ parseHTML: () => parseHTML
22
+ });
23
+ module.exports = __toCommonJS(parseHTML_exports);
24
+ function parseHTML(html, variables) {
25
+ return html.replace(/\{\{(\w+)\}\}/g, function(match, key) {
26
+ return typeof variables[key] !== "undefined" ? variables[key] : match;
27
+ });
28
+ }
29
+ __name(parseHTML, "parseHTML");
30
+ // Annotate the CommonJS export names for ESM import in node:
31
+ 0 && (module.exports = {
32
+ parseHTML
33
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/utils",
3
- "version": "0.20.0-alpha.9",
3
+ "version": "0.21.0-alpha.1",
4
4
  "main": "lib/index.js",
5
5
  "types": "./lib/index.d.ts",
6
6
  "license": "Apache-2.0",
@@ -15,5 +15,5 @@
15
15
  "multer": "^1.4.5-lts.1",
16
16
  "object-path": "^0.11.8"
17
17
  },
18
- "gitHead": "5473d9039cfdb649a8c8c625edefc9a3ac464be5"
18
+ "gitHead": "afd2f3d1341b85ea9daa7b2667dd4ace1fafb7ff"
19
19
  }