dxf-json 0.0.30 → 0.0.32

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.
@@ -36,3 +36,12 @@ export default class DxfArrayScanner {
36
36
  */
37
37
  isEOF(): boolean;
38
38
  }
39
+ /**
40
+ * Parse a value to its proper type.
41
+ * See pages 3 - 10 of the AutoCad DXF 2012 reference given at the top of this file
42
+ *
43
+ * @param code
44
+ * @param value
45
+ * @returns {*}
46
+ */
47
+ export declare function parseGroupValue(code: number, value: string): string | number | boolean;
@@ -1,11 +1,23 @@
1
1
  /// <reference types="node" />
2
2
  import fs from "fs";
3
- import DxfArrayScanner from './DxfArrayScanner';
4
3
  import type { ParsedDxf } from './types';
5
4
  import { Readable } from 'readable-stream';
6
- export default class DxfParser {
5
+ /** Options for {@link DxfParser} construction. */
6
+ export declare class DxfParserOptions {
7
+ /** Encoding label.
8
+ * See https://developer.mozilla.org/en-US/docs/Web/API/Encoding_API/Encodings
9
+ */
10
+ encoding: string;
11
+ /** Throw `TypeError` when encountering invalid encoded data when true. When false, the decoder
12
+ * will substitute malformed data with a replacement character.
13
+ */
14
+ encodingFailureFatal: boolean;
15
+ }
16
+ export default class DxfParser extends EventTarget {
17
+ private readonly _decoder;
18
+ constructor(options?: DxfParserOptions);
7
19
  parseSync(dxfString: string): ParsedDxf;
8
20
  parseStream(stream: Readable | fs.ReadStream): Promise<ParsedDxf>;
9
- parseFromUrl(url: string, encoding?: string, init?: RequestInit | undefined): Promise<ParsedDxf | null>;
10
- parseAll(scanner: DxfArrayScanner): ParsedDxf;
21
+ parseFromUrl(url: string, init?: RequestInit | undefined): Promise<ParsedDxf | null>;
22
+ private parseAll;
11
23
  }
@@ -1,21 +1,21 @@
1
- import { DefaultLightingType, OrthographicType, RenderMode, ShadePlotMode, UCSPerViewport } from '../../../consts';
2
- import type { Vector2, Vector3 } from 'three';
1
+ import type { DefaultLightingType, OrthographicType, RenderMode, ShadePlotMode, UCSPerViewport } from '../../../consts';
2
+ import type { Point2D, Point3D } from '../../../types';
3
3
  export interface ViewportEntity {
4
4
  type: 'VIEWPORT';
5
5
  subclassMarker: string;
6
6
  handle?: string;
7
7
  layer?: string;
8
- viewportCenter: Vector3;
8
+ viewportCenter: Point3D;
9
9
  width: number;
10
10
  height: number;
11
11
  status: number;
12
12
  viewportId: string;
13
- displayCenter: Vector2;
14
- snapBase: Vector2;
15
- snapSpacing: Vector2;
16
- gridSpacing: Vector2;
17
- viewDirection: Vector3;
18
- targetPoint: Vector3;
13
+ displayCenter: Point2D;
14
+ snapBase: Point2D;
15
+ snapSpacing: Point2D;
16
+ gridSpacing: Point2D;
17
+ viewDirection: Point3D;
18
+ targetPoint: Point3D;
19
19
  perspectiveLensLength: number;
20
20
  frontClipZ: number;
21
21
  backClipZ: number;
@@ -29,9 +29,9 @@ export interface ViewportEntity {
29
29
  sheetName: string;
30
30
  renderMode: RenderMode;
31
31
  ucsPerViewport: UCSPerViewport;
32
- ucsOrigin?: Vector3;
33
- ucsXAxis?: Vector3;
34
- ucsYAxis?: Vector3;
32
+ ucsOrigin?: Point3D;
33
+ ucsXAxis?: Point3D;
34
+ ucsYAxis?: Point3D;
35
35
  ucsId?: string;
36
36
  ucsBaseId?: string;
37
37
  orthographicType?: OrthographicType;
@@ -0,0 +1,43 @@
1
+ import { ParsedDxf } from 'parser/types';
2
+ type ErrorOptions = {
3
+ cause: Error;
4
+ } | undefined;
5
+ /** Options for {@link DxfStreamParser} construction. */
6
+ export declare class DxfStreamParserOptions {
7
+ /** Encoding label.
8
+ * See https://developer.mozilla.org/en-US/docs/Web/API/Encoding_API/Encodings
9
+ */
10
+ encoding: string;
11
+ /** Throw `TypeError` when encountering invalid encoded data when true. When false, the decoder
12
+ * will substitute malformed data with a replacement character.
13
+ */
14
+ encodingFailureFatal: boolean;
15
+ }
16
+ export declare class DxfParsingError extends Error {
17
+ readonly line: number;
18
+ constructor(msg: string, line: number, options?: ErrorOptions);
19
+ }
20
+ export default class DxfStreamParser extends EventTarget {
21
+ dxf: ParsedDxf;
22
+ private readonly _decoder;
23
+ private readonly _pointParser;
24
+ constructor(options?: DxfStreamParserOptions);
25
+ private _finalChunkSeen;
26
+ private _curChunk;
27
+ private _curGroupCode;
28
+ private _curLineNum;
29
+ private _eof;
30
+ private _curValue;
31
+ private _curSection;
32
+ private _currVarName;
33
+ private Feed;
34
+ /** Feed next string chunk to the parser. */
35
+ private FeedString;
36
+ private _Finalize;
37
+ FeedFile(file: ArrayBuffer, abortSignal?: AbortSignal): Promise<void>;
38
+ private _ProcessCurChunk;
39
+ private _ConsumeCurChunkLines;
40
+ private _ProcessLine;
41
+ private _Error;
42
+ }
43
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,19 @@
1
+ import { ScannerGroup } from 'parser/DxfArrayScanner';
2
+ import type { Point3D } from '../../types';
3
+ export declare class parsePoint {
4
+ point: Point3D;
5
+ startCode: number;
6
+ private code;
7
+ private value;
8
+ x: number | undefined;
9
+ y: number | undefined;
10
+ z: number | undefined;
11
+ constructor();
12
+ parseStart(point: ScannerGroup): void;
13
+ setPoint(point: ScannerGroup): {
14
+ x: number;
15
+ y: number;
16
+ z: number;
17
+ } | undefined;
18
+ reset(): void;
19
+ }
@@ -1,6 +1,5 @@
1
1
  export * from './color';
2
2
  export * from './dxfHeader';
3
- export * from './entity';
4
3
  export interface Point2D {
5
4
  x: number;
6
5
  y: number;
@@ -1,23 +1,6 @@
1
- export * from './binarySearch';
2
- export * from './disjointSet';
3
- export * from './graph';
4
- export * from './functional';
5
1
  export * from './flooding';
6
- export * from './triangle';
7
- export * from './queue';
8
- import { Vector2, Vector3 } from 'three';
9
- import type { Bound, Point2D, Point3D } from '../types';
10
- export declare function pointToVector2(point: Point3D | Point2D): Vector2;
11
- export declare function pointToVector3(point: Point3D | Point2D): Vector3;
12
- export declare function swapVector(v1: Vector2, v2: Vector2): void;
2
+ import type { Point2D, Point3D } from 'types';
13
3
  export declare function classify<T>(iterable: Iterable<T>, keySelector: (value: T) => string | undefined): Record<string, T[]>;
14
- export declare function updateBounds(v: Point2D, bounds?: Bound): Bound;
15
- export declare function getBoundBox(vertices: Iterable<Point2D>): {
16
- minX: number;
17
- maxX: number;
18
- minY: number;
19
- maxY: number;
20
- };
21
4
  /**
22
5
  * 정수 생성기
23
6
  *
@@ -26,5 +9,10 @@ export declare function getBoundBox(vertices: Iterable<Point2D>): {
26
9
  * @param increment Default = 1
27
10
  */
28
11
  export declare function generateIntegers(start: number, end?: number, increment?: number): Generator<number, void, unknown>;
29
- export declare function swap<T>(list: T[], i1: number, i2: number): void;
30
- export declare function pushIfNotEqual(v: Vector2, vertices: Vector2[]): void;
12
+ /**
13
+ * There might be some situation of ill conditioned points.
14
+ * This function ensure every values exists for possible
15
+ * missing data.
16
+ * @param point Any data parsed by `parsePoint`
17
+ */
18
+ export declare function ensurePoint3D(point: Partial<Point2D | Point3D>): Point3D;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dxf-json",
3
- "version": "0.0.30",
3
+ "version": "0.0.32",
4
4
  "description": "perfect dxf parser",
5
5
  "main": "./dist/index.d.ts",
6
6
  "type": "module",
@@ -30,6 +30,9 @@
30
30
  "publishConfig": {
31
31
  "registry": "https://registry.npmjs.org/"
32
32
  },
33
+ "contributors": [
34
+ "phryxia"
35
+ ],
33
36
  "license": "GPL-3.0",
34
37
  "bugs": {
35
38
  "url": "https://github.com/dotoritos-kim/dxf-json/issues",
@@ -40,9 +43,9 @@
40
43
  "@fxts/core": "^0.23.0",
41
44
  "@swc/cli": "^0.1.63",
42
45
  "@swc/core": "^1.3.104",
46
+ "file-api": "^0.10.4",
43
47
  "readable-stream": "^4.5.2",
44
48
  "swc-loader": "^0.2.3",
45
- "three": "^0.160.0",
46
49
  "webpack": "^5.89.0",
47
50
  "webpack-cli": "^5.1.4",
48
51
  "webpack-dev-server": "^4.15.1"