build-dxf 0.0.3 → 0.0.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "build-dxf",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "线段构建双线墙壁的dxf版本",
5
5
  "main": "./src/index.js",
6
6
  "types": "./src/index.d.ts",
package/src/index.d.ts CHANGED
@@ -180,7 +180,7 @@ declare class Dxf extends Component<{
180
180
  * @param width
181
181
  * @param scale
182
182
  */
183
- set(data: OriginalDataItem[], width?: number, scale?: number): void;
183
+ set(data: OriginalDataItem[] | string, width?: number, scale?: number): Promise<any>;
184
184
  /** 创建分组
185
185
  * @description 根据相交数组insetionArr, 把相交的线段,划分到一组内,方便后续路径查找合并使用
186
186
  * @returns
package/src/index.js CHANGED
@@ -13044,7 +13044,21 @@ class Dxf extends Component {
13044
13044
  * @param width
13045
13045
  * @param scale
13046
13046
  */
13047
- set(data, width = this.width, scale = this.scale) {
13047
+ async set(data, width = this.width, scale = this.scale) {
13048
+ if (typeof data === "string") {
13049
+ if (typeof global !== "undefined") {
13050
+ const packageName = "fs";
13051
+ const { default: fs } = await import(
13052
+ /* @vite-ignore */
13053
+ packageName
13054
+ );
13055
+ const buffer = fs.readFileSync(data);
13056
+ const json = JSON.parse(buffer.toString("utf-8"));
13057
+ return this.set(json, width, scale);
13058
+ } else {
13059
+ throw new Error("非node环境不允许使用路径");
13060
+ }
13061
+ }
13048
13062
  this.scale = scale;
13049
13063
  this.width = width;
13050
13064
  this.originalData = data;