@mlightcad/data-model 1.7.29 → 1.7.30
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/data-model.cjs +7 -4
- package/dist/data-model.js +15348 -9163
- package/lib/misc/index.d.ts +1 -0
- package/lib/misc/index.d.ts.map +1 -1
- package/lib/misc/index.js +1 -0
- package/lib/misc/index.js.map +1 -1
- package/lib/misc/pat/AcDbPatDefinition.d.ts +148 -0
- package/lib/misc/pat/AcDbPatDefinition.d.ts.map +1 -0
- package/lib/misc/pat/AcDbPatDefinition.js +2 -0
- package/lib/misc/pat/AcDbPatDefinition.js.map +1 -0
- package/lib/misc/pat/AcDbPatParser.d.ts +93 -0
- package/lib/misc/pat/AcDbPatParser.d.ts.map +1 -0
- package/lib/misc/pat/AcDbPatParser.js +245 -0
- package/lib/misc/pat/AcDbPatParser.js.map +1 -0
- package/lib/misc/pat/AcDbPatPredefined.d.ts +10 -0
- package/lib/misc/pat/AcDbPatPredefined.d.ts.map +1 -0
- package/lib/misc/pat/AcDbPatPredefined.js +5960 -0
- package/lib/misc/pat/AcDbPatPredefined.js.map +1 -0
- package/lib/misc/pat/AcDbPatSvgRenderer.d.ts +91 -0
- package/lib/misc/pat/AcDbPatSvgRenderer.d.ts.map +1 -0
- package/lib/misc/pat/AcDbPatSvgRenderer.js +287 -0
- package/lib/misc/pat/AcDbPatSvgRenderer.js.map +1 -0
- package/lib/misc/pat/index.d.ts +5 -0
- package/lib/misc/pat/index.d.ts.map +1 -0
- package/lib/misc/pat/index.js +5 -0
- package/lib/misc/pat/index.js.map +1 -0
- package/package.json +4 -4
package/lib/misc/index.d.ts
CHANGED
package/lib/misc/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/misc/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,sBAAsB,CAAA;AACpC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA;AAClC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,sBAAsB,CAAA;AACpC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/misc/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,sBAAsB,CAAA;AACpC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA;AAClC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,sBAAsB,CAAA;AACpC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,OAAO,CAAA"}
|
package/lib/misc/index.js
CHANGED
package/lib/misc/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/misc/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,sBAAsB,CAAA;AACpC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA;AAClC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,sBAAsB,CAAA;AACpC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/misc/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAA;AAChC,cAAc,sBAAsB,CAAA;AACpC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA;AAClC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,sBAAsB,CAAA;AACpC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,OAAO,CAAA"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A single PAT line-family descriptor.
|
|
3
|
+
*
|
|
4
|
+
* Matches the PAT syntax:
|
|
5
|
+
* `angle, x-origin, y-origin, delta-x, delta-y, dash-1, dash-2, ...`
|
|
6
|
+
*/
|
|
7
|
+
export interface AcDbPatLine {
|
|
8
|
+
/**
|
|
9
|
+
* Line-family angle in degrees.
|
|
10
|
+
*
|
|
11
|
+
* Following AutoCAD PAT conventions:
|
|
12
|
+
* `0` points along +X, and positive values rotate counterclockwise.
|
|
13
|
+
*/
|
|
14
|
+
angle: number;
|
|
15
|
+
/**
|
|
16
|
+
* Base origin X coordinate in pattern units.
|
|
17
|
+
*
|
|
18
|
+
* Represents the X component of the first baseline start point.
|
|
19
|
+
*/
|
|
20
|
+
originX: number;
|
|
21
|
+
/**
|
|
22
|
+
* Base origin Y coordinate in pattern units.
|
|
23
|
+
*
|
|
24
|
+
* Represents the Y component of the first baseline start point.
|
|
25
|
+
*/
|
|
26
|
+
originY: number;
|
|
27
|
+
/**
|
|
28
|
+
* X component of the offset to the next parallel line, in pattern units.
|
|
29
|
+
*
|
|
30
|
+
* Combined with {@link deltaY} to define the translation from one family line
|
|
31
|
+
* to the next.
|
|
32
|
+
*/
|
|
33
|
+
deltaX: number;
|
|
34
|
+
/**
|
|
35
|
+
* Y component of the offset to the next parallel line, in pattern units.
|
|
36
|
+
*
|
|
37
|
+
* Combined with {@link deltaX} to define the translation from one family line
|
|
38
|
+
* to the next.
|
|
39
|
+
*/
|
|
40
|
+
deltaY: number;
|
|
41
|
+
/**
|
|
42
|
+
* Dash pattern segment array in pattern units.
|
|
43
|
+
*
|
|
44
|
+
* Rules:
|
|
45
|
+
* - positive: draw segment (pen-down)
|
|
46
|
+
* - negative: gap length (pen-up)
|
|
47
|
+
* - `0`: dot
|
|
48
|
+
*
|
|
49
|
+
* An empty array means a continuous solid line.
|
|
50
|
+
*/
|
|
51
|
+
dashes: number[];
|
|
52
|
+
/**
|
|
53
|
+
* Source line number in the original PAT text (1-based).
|
|
54
|
+
*
|
|
55
|
+
* Useful for diagnostics and error tracing.
|
|
56
|
+
*/
|
|
57
|
+
sourceLine: number;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* A complete PAT pattern definition (starts with `*NAME, description`).
|
|
61
|
+
*/
|
|
62
|
+
export interface AcDbPatPattern {
|
|
63
|
+
/**
|
|
64
|
+
* Pattern name.
|
|
65
|
+
*
|
|
66
|
+
* Examples: `ANSI31`, `SOLID`.
|
|
67
|
+
*/
|
|
68
|
+
name: string;
|
|
69
|
+
/**
|
|
70
|
+
* Pattern description text.
|
|
71
|
+
*
|
|
72
|
+
* This is the part after the comma in the PAT header; may be empty.
|
|
73
|
+
*/
|
|
74
|
+
description?: string;
|
|
75
|
+
/**
|
|
76
|
+
* Line-family descriptors included in this pattern.
|
|
77
|
+
*
|
|
78
|
+
* Order is preserved from the source PAT file.
|
|
79
|
+
*/
|
|
80
|
+
lines: AcDbPatLine[];
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* A single issue captured during PAT parsing.
|
|
84
|
+
*/
|
|
85
|
+
export interface AcDbPatParseIssue {
|
|
86
|
+
/**
|
|
87
|
+
* Line number where the issue occurred (1-based).
|
|
88
|
+
*
|
|
89
|
+
* Implementations may use `0` when no exact line can be mapped.
|
|
90
|
+
*/
|
|
91
|
+
line: number;
|
|
92
|
+
/**
|
|
93
|
+
* Developer-facing error or warning message.
|
|
94
|
+
*/
|
|
95
|
+
message: string;
|
|
96
|
+
/**
|
|
97
|
+
* Raw source line text that triggered the issue.
|
|
98
|
+
*
|
|
99
|
+
* Useful for debugging, logs, and UI error display.
|
|
100
|
+
*/
|
|
101
|
+
source: string;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Structured result of parsing a PAT file.
|
|
105
|
+
*/
|
|
106
|
+
export interface AcDbPatDocument {
|
|
107
|
+
/**
|
|
108
|
+
* Successfully parsed pattern definitions.
|
|
109
|
+
*/
|
|
110
|
+
patterns: AcDbPatPattern[];
|
|
111
|
+
/**
|
|
112
|
+
* Issues collected during parsing.
|
|
113
|
+
*
|
|
114
|
+
* Parsers typically use a best-effort strategy, so both `patterns` and
|
|
115
|
+
* `issues` can be present at the same time.
|
|
116
|
+
*/
|
|
117
|
+
issues: AcDbPatParseIssue[];
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Optional preview options when rendering a PAT pattern to SVG.
|
|
121
|
+
*/
|
|
122
|
+
export interface AcDbPatPreviewOptions {
|
|
123
|
+
/**
|
|
124
|
+
* SVG viewport width in pixels.
|
|
125
|
+
*/
|
|
126
|
+
width?: number;
|
|
127
|
+
/**
|
|
128
|
+
* SVG viewport height in pixels.
|
|
129
|
+
*/
|
|
130
|
+
height?: number;
|
|
131
|
+
/**
|
|
132
|
+
* Stroke color.
|
|
133
|
+
*
|
|
134
|
+
* Accepts any valid CSS color value (for example `#1f2937`, `rgb(...)`, `red`).
|
|
135
|
+
*/
|
|
136
|
+
stroke?: string;
|
|
137
|
+
/**
|
|
138
|
+
* Stroke width in pixels.
|
|
139
|
+
*/
|
|
140
|
+
strokeWidth?: number;
|
|
141
|
+
/**
|
|
142
|
+
* Background fill color.
|
|
143
|
+
*
|
|
144
|
+
* Accepts any valid CSS color value.
|
|
145
|
+
*/
|
|
146
|
+
background?: string;
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=AcDbPatDefinition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcDbPatDefinition.d.ts","sourceRoot":"","sources":["../../../src/misc/pat/AcDbPatDefinition.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;;OAKG;IACH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[],"mappings":""}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { AcDbPatDocument } from './AcDbPatDefinition';
|
|
2
|
+
/**
|
|
3
|
+
* Parser for AutoCAD PAT text content.
|
|
4
|
+
*
|
|
5
|
+
* This parser follows a best-effort strategy:
|
|
6
|
+
* - valid patterns are still returned when some rows are malformed;
|
|
7
|
+
* - non-fatal problems are collected into {@link AcDbPatDocument.issues};
|
|
8
|
+
* - PAT line numbers are preserved in parsed descriptors for diagnostics.
|
|
9
|
+
*
|
|
10
|
+
* Typical usage:
|
|
11
|
+
* - instantiate once and call {@link parse} for each PAT payload;
|
|
12
|
+
* - or call the convenience static {@link AcDbPatParser.parse} method.
|
|
13
|
+
*/
|
|
14
|
+
export declare class AcDbPatParser {
|
|
15
|
+
/**
|
|
16
|
+
* Parse PAT file text into structured patterns and issues.
|
|
17
|
+
*
|
|
18
|
+
* The method accepts complete PAT file content (including comments, blank
|
|
19
|
+
* lines, and multiple pattern blocks). It normalizes line endings, parses
|
|
20
|
+
* headers and line descriptors, and records any recoverable errors.
|
|
21
|
+
*
|
|
22
|
+
* @param content - Raw PAT file text.
|
|
23
|
+
* @returns Parsed document containing both successful patterns and collected
|
|
24
|
+
* parse issues.
|
|
25
|
+
*/
|
|
26
|
+
parse(content: string): AcDbPatDocument;
|
|
27
|
+
/**
|
|
28
|
+
* Parse PAT text without manually creating a parser instance.
|
|
29
|
+
*
|
|
30
|
+
* @param content - Raw PAT file text.
|
|
31
|
+
* @returns Parsed PAT document.
|
|
32
|
+
*/
|
|
33
|
+
static parse(content: string): AcDbPatDocument;
|
|
34
|
+
/**
|
|
35
|
+
* Normalize line endings to Unix `\n` form.
|
|
36
|
+
*
|
|
37
|
+
* @param content - Raw text that may include `\r\n`, `\r`, or `\n`.
|
|
38
|
+
* @returns Text with all line endings converted to `\n`.
|
|
39
|
+
*/
|
|
40
|
+
private normalizeLineEndings;
|
|
41
|
+
/**
|
|
42
|
+
* Remove inline PAT comments from a source line.
|
|
43
|
+
*
|
|
44
|
+
* PAT comment syntax uses `;` and ignores everything after it.
|
|
45
|
+
*
|
|
46
|
+
* @param rawLine - Unprocessed source line from the PAT file.
|
|
47
|
+
* @returns Source line without trailing comment section.
|
|
48
|
+
*/
|
|
49
|
+
private stripInlineComment;
|
|
50
|
+
/**
|
|
51
|
+
* Parse a PAT header body after the leading `*`.
|
|
52
|
+
*
|
|
53
|
+
* Examples:
|
|
54
|
+
* - `ANSI31, 45 degree hatch`
|
|
55
|
+
* - `SOLID`
|
|
56
|
+
*
|
|
57
|
+
* @param body - Header content without the leading `*`.
|
|
58
|
+
* @returns Parsed `{ name, description }`, or `null` when header is invalid.
|
|
59
|
+
*/
|
|
60
|
+
private parseHeader;
|
|
61
|
+
/**
|
|
62
|
+
* Parse a numeric token from PAT syntax.
|
|
63
|
+
*
|
|
64
|
+
* @param token - Numeric field text from a PAT row.
|
|
65
|
+
* @returns Finite number value, or `null` when token is not a valid number.
|
|
66
|
+
*/
|
|
67
|
+
private parseNumber;
|
|
68
|
+
/**
|
|
69
|
+
* Parse one PAT line descriptor row.
|
|
70
|
+
*
|
|
71
|
+
* Expected format:
|
|
72
|
+
* `angle,x-origin,y-origin,delta-x,delta-y[,dash-1,dash-2,...]`
|
|
73
|
+
*
|
|
74
|
+
* @param raw - Row text without inline comments.
|
|
75
|
+
* @param lineNumber - Original 1-based source line number.
|
|
76
|
+
* @returns Parsed line descriptor with source metadata, or `null` when row
|
|
77
|
+
* does not satisfy the expected numeric schema.
|
|
78
|
+
*/
|
|
79
|
+
private parseLineDescriptor;
|
|
80
|
+
/**
|
|
81
|
+
* Finalize the current pattern and append it to output collections.
|
|
82
|
+
*
|
|
83
|
+
* If a pattern header was parsed but no line descriptor followed, this method
|
|
84
|
+
* records an issue and still emits the empty pattern to preserve source
|
|
85
|
+
* intent and ordering.
|
|
86
|
+
*
|
|
87
|
+
* @param currentPattern - Pattern currently being accumulated.
|
|
88
|
+
* @param patterns - Target array that receives completed patterns.
|
|
89
|
+
* @param issues - Target array that receives parse issues.
|
|
90
|
+
*/
|
|
91
|
+
private flushCurrentPattern;
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=AcDbPatParser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcDbPatParser.d.ts","sourceRoot":"","sources":["../../../src/misc/pat/AcDbPatParser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EAIhB,MAAM,qBAAqB,CAAA;AAiB5B;;;;;;;;;;;GAWG;AACH,qBAAa,aAAa;IACxB;;;;;;;;;;OAUG;IACH,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,eAAe;IAiEvC;;;;;OAKG;IACH,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,eAAe;IAI9C;;;;;OAKG;IACH,OAAO,CAAC,oBAAoB;IAI5B;;;;;;;OAOG;IACH,OAAO,CAAC,kBAAkB;IAM1B;;;;;;;;;OASG;IACH,OAAO,CAAC,WAAW;IAgBnB;;;;;OAKG;IACH,OAAO,CAAC,WAAW;IAKnB;;;;;;;;;;OAUG;IACH,OAAO,CAAC,mBAAmB;IA6C3B;;;;;;;;;;OAUG;IACH,OAAO,CAAC,mBAAmB;CAiB5B"}
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
var __values = (this && this.__values) || function(o) {
|
|
2
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
3
|
+
if (m) return m.call(o);
|
|
4
|
+
if (o && typeof o.length === "number") return {
|
|
5
|
+
next: function () {
|
|
6
|
+
if (o && i >= o.length) o = void 0;
|
|
7
|
+
return { value: o && o[i++], done: !o };
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Parser for AutoCAD PAT text content.
|
|
14
|
+
*
|
|
15
|
+
* This parser follows a best-effort strategy:
|
|
16
|
+
* - valid patterns are still returned when some rows are malformed;
|
|
17
|
+
* - non-fatal problems are collected into {@link AcDbPatDocument.issues};
|
|
18
|
+
* - PAT line numbers are preserved in parsed descriptors for diagnostics.
|
|
19
|
+
*
|
|
20
|
+
* Typical usage:
|
|
21
|
+
* - instantiate once and call {@link parse} for each PAT payload;
|
|
22
|
+
* - or call the convenience static {@link AcDbPatParser.parse} method.
|
|
23
|
+
*/
|
|
24
|
+
var AcDbPatParser = /** @class */ (function () {
|
|
25
|
+
function AcDbPatParser() {
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Parse PAT file text into structured patterns and issues.
|
|
29
|
+
*
|
|
30
|
+
* The method accepts complete PAT file content (including comments, blank
|
|
31
|
+
* lines, and multiple pattern blocks). It normalizes line endings, parses
|
|
32
|
+
* headers and line descriptors, and records any recoverable errors.
|
|
33
|
+
*
|
|
34
|
+
* @param content - Raw PAT file text.
|
|
35
|
+
* @returns Parsed document containing both successful patterns and collected
|
|
36
|
+
* parse issues.
|
|
37
|
+
*/
|
|
38
|
+
AcDbPatParser.prototype.parse = function (content) {
|
|
39
|
+
var _this = this;
|
|
40
|
+
var normalized = this.normalizeLineEndings(content);
|
|
41
|
+
var rawLines = normalized.split('\n');
|
|
42
|
+
var patterns = [];
|
|
43
|
+
var issues = [];
|
|
44
|
+
var currentPattern = null;
|
|
45
|
+
rawLines.forEach(function (rawLine, index) {
|
|
46
|
+
var lineNumber = index + 1;
|
|
47
|
+
var lineWithoutComment = _this.stripInlineComment(rawLine).trim();
|
|
48
|
+
if (!lineWithoutComment)
|
|
49
|
+
return;
|
|
50
|
+
if (lineWithoutComment.startsWith('*')) {
|
|
51
|
+
_this.flushCurrentPattern(currentPattern, patterns, issues);
|
|
52
|
+
var header = _this.parseHeader(lineWithoutComment.slice(1));
|
|
53
|
+
if (!header) {
|
|
54
|
+
issues.push({
|
|
55
|
+
line: lineNumber,
|
|
56
|
+
message: 'Invalid pattern header.',
|
|
57
|
+
source: rawLine
|
|
58
|
+
});
|
|
59
|
+
currentPattern = null;
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
currentPattern = {
|
|
63
|
+
pattern: {
|
|
64
|
+
name: header.name,
|
|
65
|
+
description: header.description,
|
|
66
|
+
lines: []
|
|
67
|
+
},
|
|
68
|
+
headerLine: lineNumber
|
|
69
|
+
};
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (!currentPattern) {
|
|
73
|
+
issues.push({
|
|
74
|
+
line: lineNumber,
|
|
75
|
+
message: 'Line descriptor appears before any pattern header.',
|
|
76
|
+
source: rawLine
|
|
77
|
+
});
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
var descriptor = _this.parseLineDescriptor(lineWithoutComment, lineNumber);
|
|
81
|
+
if (!descriptor) {
|
|
82
|
+
issues.push({
|
|
83
|
+
line: lineNumber,
|
|
84
|
+
message: 'Invalid line descriptor. Expect: angle,x-origin,y-origin,delta-x,delta-y[,dash-1,...].',
|
|
85
|
+
source: rawLine
|
|
86
|
+
});
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
currentPattern.pattern.lines.push(descriptor);
|
|
90
|
+
});
|
|
91
|
+
this.flushCurrentPattern(currentPattern, patterns, issues);
|
|
92
|
+
return { patterns: patterns, issues: issues };
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Parse PAT text without manually creating a parser instance.
|
|
96
|
+
*
|
|
97
|
+
* @param content - Raw PAT file text.
|
|
98
|
+
* @returns Parsed PAT document.
|
|
99
|
+
*/
|
|
100
|
+
AcDbPatParser.parse = function (content) {
|
|
101
|
+
return new AcDbPatParser().parse(content);
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Normalize line endings to Unix `\n` form.
|
|
105
|
+
*
|
|
106
|
+
* @param content - Raw text that may include `\r\n`, `\r`, or `\n`.
|
|
107
|
+
* @returns Text with all line endings converted to `\n`.
|
|
108
|
+
*/
|
|
109
|
+
AcDbPatParser.prototype.normalizeLineEndings = function (content) {
|
|
110
|
+
return content.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* Remove inline PAT comments from a source line.
|
|
114
|
+
*
|
|
115
|
+
* PAT comment syntax uses `;` and ignores everything after it.
|
|
116
|
+
*
|
|
117
|
+
* @param rawLine - Unprocessed source line from the PAT file.
|
|
118
|
+
* @returns Source line without trailing comment section.
|
|
119
|
+
*/
|
|
120
|
+
AcDbPatParser.prototype.stripInlineComment = function (rawLine) {
|
|
121
|
+
var commentIndex = rawLine.indexOf(';');
|
|
122
|
+
if (commentIndex < 0)
|
|
123
|
+
return rawLine;
|
|
124
|
+
return rawLine.slice(0, commentIndex);
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Parse a PAT header body after the leading `*`.
|
|
128
|
+
*
|
|
129
|
+
* Examples:
|
|
130
|
+
* - `ANSI31, 45 degree hatch`
|
|
131
|
+
* - `SOLID`
|
|
132
|
+
*
|
|
133
|
+
* @param body - Header content without the leading `*`.
|
|
134
|
+
* @returns Parsed `{ name, description }`, or `null` when header is invalid.
|
|
135
|
+
*/
|
|
136
|
+
AcDbPatParser.prototype.parseHeader = function (body) {
|
|
137
|
+
var firstComma = body.indexOf(',');
|
|
138
|
+
if (firstComma < 0) {
|
|
139
|
+
var nameOnly = body.trim();
|
|
140
|
+
if (!nameOnly)
|
|
141
|
+
return null;
|
|
142
|
+
return { name: nameOnly, description: '' };
|
|
143
|
+
}
|
|
144
|
+
var name = body.slice(0, firstComma).trim();
|
|
145
|
+
var description = body.slice(firstComma + 1).trim();
|
|
146
|
+
if (!name)
|
|
147
|
+
return null;
|
|
148
|
+
return { name: name, description: description };
|
|
149
|
+
};
|
|
150
|
+
/**
|
|
151
|
+
* Parse a numeric token from PAT syntax.
|
|
152
|
+
*
|
|
153
|
+
* @param token - Numeric field text from a PAT row.
|
|
154
|
+
* @returns Finite number value, or `null` when token is not a valid number.
|
|
155
|
+
*/
|
|
156
|
+
AcDbPatParser.prototype.parseNumber = function (token) {
|
|
157
|
+
var value = Number(token.trim());
|
|
158
|
+
return Number.isFinite(value) ? value : null;
|
|
159
|
+
};
|
|
160
|
+
/**
|
|
161
|
+
* Parse one PAT line descriptor row.
|
|
162
|
+
*
|
|
163
|
+
* Expected format:
|
|
164
|
+
* `angle,x-origin,y-origin,delta-x,delta-y[,dash-1,dash-2,...]`
|
|
165
|
+
*
|
|
166
|
+
* @param raw - Row text without inline comments.
|
|
167
|
+
* @param lineNumber - Original 1-based source line number.
|
|
168
|
+
* @returns Parsed line descriptor with source metadata, or `null` when row
|
|
169
|
+
* does not satisfy the expected numeric schema.
|
|
170
|
+
*/
|
|
171
|
+
AcDbPatParser.prototype.parseLineDescriptor = function (raw, lineNumber) {
|
|
172
|
+
var e_1, _a;
|
|
173
|
+
var tokens = raw
|
|
174
|
+
.split(',')
|
|
175
|
+
.map(function (token) { return token.trim(); })
|
|
176
|
+
.filter(function (token) { return token.length > 0; });
|
|
177
|
+
if (tokens.length < 5)
|
|
178
|
+
return null;
|
|
179
|
+
var angle = this.parseNumber(tokens[0]);
|
|
180
|
+
var originX = this.parseNumber(tokens[1]);
|
|
181
|
+
var originY = this.parseNumber(tokens[2]);
|
|
182
|
+
var deltaX = this.parseNumber(tokens[3]);
|
|
183
|
+
var deltaY = this.parseNumber(tokens[4]);
|
|
184
|
+
if (angle == null ||
|
|
185
|
+
originX == null ||
|
|
186
|
+
originY == null ||
|
|
187
|
+
deltaX == null ||
|
|
188
|
+
deltaY == null) {
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
var dashTokens = tokens.slice(5);
|
|
192
|
+
var dashes = [];
|
|
193
|
+
try {
|
|
194
|
+
for (var dashTokens_1 = __values(dashTokens), dashTokens_1_1 = dashTokens_1.next(); !dashTokens_1_1.done; dashTokens_1_1 = dashTokens_1.next()) {
|
|
195
|
+
var token = dashTokens_1_1.value;
|
|
196
|
+
var value = this.parseNumber(token);
|
|
197
|
+
if (value == null)
|
|
198
|
+
return null;
|
|
199
|
+
dashes.push(value);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
203
|
+
finally {
|
|
204
|
+
try {
|
|
205
|
+
if (dashTokens_1_1 && !dashTokens_1_1.done && (_a = dashTokens_1.return)) _a.call(dashTokens_1);
|
|
206
|
+
}
|
|
207
|
+
finally { if (e_1) throw e_1.error; }
|
|
208
|
+
}
|
|
209
|
+
return {
|
|
210
|
+
angle: angle,
|
|
211
|
+
originX: originX,
|
|
212
|
+
originY: originY,
|
|
213
|
+
deltaX: deltaX,
|
|
214
|
+
deltaY: deltaY,
|
|
215
|
+
dashes: dashes,
|
|
216
|
+
sourceLine: lineNumber
|
|
217
|
+
};
|
|
218
|
+
};
|
|
219
|
+
/**
|
|
220
|
+
* Finalize the current pattern and append it to output collections.
|
|
221
|
+
*
|
|
222
|
+
* If a pattern header was parsed but no line descriptor followed, this method
|
|
223
|
+
* records an issue and still emits the empty pattern to preserve source
|
|
224
|
+
* intent and ordering.
|
|
225
|
+
*
|
|
226
|
+
* @param currentPattern - Pattern currently being accumulated.
|
|
227
|
+
* @param patterns - Target array that receives completed patterns.
|
|
228
|
+
* @param issues - Target array that receives parse issues.
|
|
229
|
+
*/
|
|
230
|
+
AcDbPatParser.prototype.flushCurrentPattern = function (currentPattern, patterns, issues) {
|
|
231
|
+
if (!currentPattern)
|
|
232
|
+
return;
|
|
233
|
+
if (currentPattern.pattern.lines.length === 0) {
|
|
234
|
+
issues.push({
|
|
235
|
+
line: currentPattern.headerLine,
|
|
236
|
+
message: "Pattern \"".concat(currentPattern.pattern.name, "\" has no line descriptor."),
|
|
237
|
+
source: ''
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
patterns.push(currentPattern.pattern);
|
|
241
|
+
};
|
|
242
|
+
return AcDbPatParser;
|
|
243
|
+
}());
|
|
244
|
+
export { AcDbPatParser };
|
|
245
|
+
//# sourceMappingURL=AcDbPatParser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcDbPatParser.js","sourceRoot":"","sources":["../../../src/misc/pat/AcDbPatParser.ts"],"names":[],"mappings":";;;;;;;;;;;AAsBA;;;;;;;;;;;GAWG;AACH;IAAA;IAwOA,CAAC;IAvOC;;;;;;;;;;OAUG;IACH,6BAAK,GAAL,UAAM,OAAe;QAArB,iBA+DC;QA9DC,IAAM,UAAU,GAAG,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAA;QACrD,IAAM,QAAQ,GAAG,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;QACvC,IAAM,QAAQ,GAAqB,EAAE,CAAA;QACrC,IAAM,MAAM,GAAwB,EAAE,CAAA;QAEtC,IAAI,cAAc,GAAiC,IAAI,CAAA;QAEvD,QAAQ,CAAC,OAAO,CAAC,UAAC,OAAO,EAAE,KAAK;YAC9B,IAAM,UAAU,GAAG,KAAK,GAAG,CAAC,CAAA;YAC5B,IAAM,kBAAkB,GAAG,KAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAA;YAClE,IAAI,CAAC,kBAAkB;gBAAE,OAAM;YAE/B,IAAI,kBAAkB,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;gBACvC,KAAI,CAAC,mBAAmB,CAAC,cAAc,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAA;gBAC1D,IAAM,MAAM,GAAG,KAAI,CAAC,WAAW,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;gBAC5D,IAAI,CAAC,MAAM,EAAE,CAAC;oBACZ,MAAM,CAAC,IAAI,CAAC;wBACV,IAAI,EAAE,UAAU;wBAChB,OAAO,EAAE,yBAAyB;wBAClC,MAAM,EAAE,OAAO;qBAChB,CAAC,CAAA;oBACF,cAAc,GAAG,IAAI,CAAA;o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AC,KAAK,CAAC,CAAA;YACpB,CAAC;;;;;;;;;QAED,OAAO;YACL,KAAK,OAAA;YACL,OAAO,SAAA;YACP,OAAO,SAAA;YACP,MAAM,QAAA;YACN,MAAM,QAAA;YACN,MAAM,QAAA;YACN,UAAU,EAAE,UAAU;SACvB,CAAA;IACH,CAAC;IAED;;;;;;;;;;OAUG;IACK,2CAAmB,GAA3B,UACE,cAA4C,EAC5C,QAA0B,EAC1B,MAA2B;QAE3B,IAAI,CAAC,cAAc;YAAE,OAAM;QAE3B,IAAI,cAAc,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC9C,MAAM,CAAC,IAAI,CAAC;gBACV,IAAI,EAAE,cAAc,CAAC,UAAU;gBAC/B,OAAO,EAAE,oBAAY,cAAc,CAAC,OAAO,CAAC,IAAI,+BAA2B;gBAC3E,MAAM,EAAE,EAAE;aACX,CAAC,CAAA;QACJ,CAAC;QAED,QAAQ,CAAC,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,CAAA;IACvC,CAAC;IACH,oBAAC;AAAD,CAAC,AAxOD,IAwOC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AcDbPatDocument } from './AcDbPatDefinition';
|
|
2
|
+
/**
|
|
3
|
+
* Predefined hatch patterns from the classic `acad.pat` library.
|
|
4
|
+
*/
|
|
5
|
+
export declare const AcDbPredefinedAcadPat: AcDbPatDocument;
|
|
6
|
+
/**
|
|
7
|
+
* Predefined hatch patterns from the ISO-oriented `acadiso.pat` library.
|
|
8
|
+
*/
|
|
9
|
+
export declare const AcDbPredefinedAcadIsoPat: AcDbPatDocument;
|
|
10
|
+
//# sourceMappingURL=AcDbPatPredefined.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcDbPatPredefined.d.ts","sourceRoot":"","sources":["../../../src/misc/pat/AcDbPatPredefined.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAE1D;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,eA8wFnC,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,wBAAwB,EAAE,eAijGtC,CAAA"}
|