@nocobase/utils 1.0.0-alpha.8 → 1.0.1-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.
@@ -56,14 +56,14 @@ const getValuesByPath = /* @__PURE__ */ __name((obj, path, defaultValue) => {
56
56
  result.push(currentValue);
57
57
  }
58
58
  }
59
- result = result.filter((item) => item != null);
59
+ result = result.filter((item) => item !== void 0);
60
60
  if (result.length === 0) {
61
61
  return defaultValue;
62
62
  }
63
63
  if (shouldReturnArray) {
64
- return result;
64
+ return result.filter((item) => item !== null);
65
65
  }
66
- return result.length === 1 ? result[0] : result;
66
+ return result[0];
67
67
  }, "getValuesByPath");
68
68
  // Annotate the CommonJS export names for ESM import in node:
69
69
  0 && (module.exports = {
@@ -7,11 +7,9 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- var __create = Object.create;
11
10
  var __defProp = Object.defineProperty;
12
11
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
13
12
  var __getOwnPropNames = Object.getOwnPropertyNames;
14
- var __getProtoOf = Object.getPrototypeOf;
15
13
  var __hasOwnProp = Object.prototype.hasOwnProperty;
16
14
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
17
15
  var __export = (target, all) => {
@@ -26,14 +24,6 @@ var __copyProps = (to, from, except, desc) => {
26
24
  }
27
25
  return to;
28
26
  };
29
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
30
- // If the importer is in node compatibility mode or this is not an ESM
31
- // file that has been converted to a CommonJS file using a Babel-
32
- // compatible transform (i.e. "__esModule" has not been set), then set
33
- // "default" to the CommonJS "module.exports" for node compatibility.
34
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
35
- mod
36
- ));
37
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
38
28
  var json_templates_exports = {};
39
29
  __export(json_templates_exports, {
@@ -41,7 +31,6 @@ __export(json_templates_exports, {
41
31
  });
42
32
  module.exports = __toCommonJS(json_templates_exports);
43
33
  var import_lodash = require("lodash");
44
- var import_dedupe = __toESM(require("dedupe"));
45
34
  function type(value) {
46
35
  let valueType = typeof value;
47
36
  if (Array.isArray(value)) {
@@ -70,9 +59,7 @@ function Parameter(match) {
70
59
  }
71
60
  __name(Parameter, "Parameter");
72
61
  function Template(fn, parameters) {
73
- Object.assign(fn, {
74
- parameters: (0, import_dedupe.default)(parameters, (item) => item.key)
75
- });
62
+ fn.parameters = Array.from(new Map(parameters.map((parameter) => [parameter.key, parameter])).values());
76
63
  return fn;
77
64
  }
78
65
  __name(Template, "Template");
@@ -92,7 +79,7 @@ function parse(value) {
92
79
  }
93
80
  __name(parse, "parse");
94
81
  const parseString = (() => {
95
- const regex = /{{(\w|:|[\s-+.,@///()?=*_$])+}}/g;
82
+ const regex = /{{(\w|:|[\s-+.,@/()?=*_$])+}}/g;
96
83
  return (str) => {
97
84
  let parameters = [];
98
85
  let templateFn = /* @__PURE__ */ __name((context) => str, "templateFn");
@@ -110,7 +97,7 @@ const parseString = (() => {
110
97
  if (typeof value === "function") {
111
98
  value = value();
112
99
  }
113
- if (str.startsWith("{{") && str.endsWith("}}")) {
100
+ if (matches.length === 1 && str.startsWith("{{") && str.endsWith("}}")) {
114
101
  return value;
115
102
  }
116
103
  if (value instanceof Date) {
@@ -6,6 +6,7 @@
6
6
  * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
+ export declare function requireResolve(m: any): Promise<string>;
9
10
  export declare function requireModule(m: any): any;
10
11
  export default requireModule;
11
12
  export declare function importModule(m: string): Promise<any>;
@@ -39,11 +39,27 @@ var requireModule_exports = {};
39
39
  __export(requireModule_exports, {
40
40
  default: () => requireModule_default,
41
41
  importModule: () => importModule,
42
- requireModule: () => requireModule
42
+ requireModule: () => requireModule,
43
+ requireResolve: () => requireResolve
43
44
  });
44
45
  module.exports = __toCommonJS(requireModule_exports);
46
+ var import_fs = __toESM(require("fs"));
45
47
  var import_path = __toESM(require("path"));
46
48
  var import_url = require("url");
49
+ async function requireResolve(m) {
50
+ if (!process.env.VITEST) {
51
+ return require.resolve(m);
52
+ }
53
+ const json = JSON.parse(
54
+ await import_fs.default.promises.readFile(import_path.default.resolve(process.cwd(), "./tsconfig.paths.json"), { encoding: "utf8" })
55
+ );
56
+ const paths = json.compilerOptions.paths;
57
+ if (paths[m]) {
58
+ return require.resolve(import_path.default.resolve(process.cwd(), paths[m][0], "index.ts"));
59
+ }
60
+ return require.resolve(m);
61
+ }
62
+ __name(requireResolve, "requireResolve");
47
63
  function requireModule(m) {
48
64
  if (typeof m === "string") {
49
65
  m = require(m);
@@ -69,5 +85,6 @@ __name(importModule, "importModule");
69
85
  // Annotate the CommonJS export names for ESM import in node:
70
86
  0 && (module.exports = {
71
87
  importModule,
72
- requireModule
88
+ requireModule,
89
+ requireResolve
73
90
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/utils",
3
- "version": "1.0.0-alpha.8",
3
+ "version": "1.0.1-alpha.1",
4
4
  "main": "lib/index.js",
5
5
  "types": "./lib/index.d.ts",
6
6
  "license": "AGPL-3.0",
@@ -8,12 +8,11 @@
8
8
  "@hapi/topo": "^6.0.0",
9
9
  "@rc-component/mini-decimal": "^1.1.0",
10
10
  "dayjs": "^1.11.9",
11
- "dedupe": "^3.0.2",
12
11
  "deepmerge": "^4.2.2",
13
12
  "flat-to-nested": "^1.1.1",
14
13
  "graphlib": "^2.1.8",
15
14
  "multer": "^1.4.5-lts.1",
16
15
  "object-path": "^0.11.8"
17
16
  },
18
- "gitHead": "3c4e978f6fc366c01621c9d625678e91f53f8662"
17
+ "gitHead": "d24aa16987a4068f857ae073fcce18f3cb490660"
19
18
  }
package/plugin-symlink.js CHANGED
@@ -1,5 +1,5 @@
1
1
  const { dirname, resolve } = require('path');
2
- const { readFile, writeFile, readdir, symlink, unlink, mkdir, stat } = require('fs').promises;
2
+ const { realpath, readFile, writeFile, readdir, symlink, unlink, mkdir, stat } = require('fs').promises;
3
3
 
4
4
  async function getStoragePluginNames(target) {
5
5
  const plugins = [];
@@ -76,6 +76,10 @@ async function createDevPluginSymLink(pluginName) {
76
76
  }
77
77
  const link = resolve(nodeModulesPath, pluginName);
78
78
  if (await fsExists(link)) {
79
+ const real = await realpath(link);
80
+ if (real === resolve(packagePluginsPath, pluginName)) {
81
+ return;
82
+ }
79
83
  await unlink(link);
80
84
  }
81
85
  await symlink(resolve(packagePluginsPath, pluginName), link, 'dir');