@metweave/parser 0.1.0 → 0.1.2
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/index.cjs +27 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +27 -3
- package/dist/index.js.map +1 -1
- package/package.json +6 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MetarParseError, MetarReport, ParseOptions } from "@metweave/core";
|
|
1
|
+
import { AltimeterReading, CloudCondition, CloudElement, MetarParseError, MetarReport, MetarReport as MetarReport$1, Observed, ParseOptions, ParseWarning, ReportKind, RunwayStateGroup, RunwayVisualRange, Span, TemperatureReading, TrendElements, TrendGroup, TrendKind, VisibilityGroup, WeatherGroup, WindGroup } from "@metweave/core";
|
|
2
2
|
//#region src/index.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Temperature/dewpoint group shape: always dd/dd (M = negative; // on either side = that side missing).
|
|
@@ -25,12 +25,12 @@ export declare const TEMP_DEW_PATTERN: RegExp;
|
|
|
25
25
|
* @param raw - Report text, verbatim (kept on report.raw). 报文原文(原样保真于 report.raw)。
|
|
26
26
|
* @param options - See ParseOptions (kind override, compact spans). 见 ParseOptions(类型位注入、紧凑模式)。
|
|
27
27
|
*/
|
|
28
|
-
export declare function parse(raw: string, options?: ParseOptions): MetarReport;
|
|
28
|
+
export declare function parse(raw: string, options?: ParseOptions): MetarReport$1;
|
|
29
29
|
/** Result-style parse outcome: never throws for parse-level failures — branch on `ok` instead of try/catch.
|
|
30
30
|
* 结果式解析出口:解析层失败不抛出,按 ok 分流——批量回放/管道消费免 try/catch 控制流。 */
|
|
31
31
|
export type TryParseResult = {
|
|
32
32
|
readonly ok: true;
|
|
33
|
-
readonly report: MetarReport;
|
|
33
|
+
readonly report: MetarReport$1;
|
|
34
34
|
} | {
|
|
35
35
|
readonly ok: false;
|
|
36
36
|
readonly error: MetarParseError;
|
|
@@ -44,4 +44,5 @@ export type TryParseResult = {
|
|
|
44
44
|
*/
|
|
45
45
|
export declare function tryParse(raw: string, options?: ParseOptions): TryParseResult;
|
|
46
46
|
//#endregion
|
|
47
|
+
export type { AltimeterReading, CloudCondition, CloudElement, MetarReport, Observed, ParseWarning, ReportKind, RunwayStateGroup, RunwayVisualRange, Span, TemperatureReading, TrendElements, TrendGroup, TrendKind, VisibilityGroup, WeatherGroup, WindGroup };
|
|
47
48
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MetarParseError, MetarReport, ParseOptions } from "@metweave/core";
|
|
1
|
+
import { AltimeterReading, CloudCondition, CloudElement, MetarParseError, MetarReport, MetarReport as MetarReport$1, Observed, ParseOptions, ParseWarning, ReportKind, RunwayStateGroup, RunwayVisualRange, Span, TemperatureReading, TrendElements, TrendGroup, TrendKind, VisibilityGroup, WeatherGroup, WindGroup } from "@metweave/core";
|
|
2
2
|
//#region src/index.d.ts
|
|
3
3
|
/**
|
|
4
4
|
* Temperature/dewpoint group shape: always dd/dd (M = negative; // on either side = that side missing).
|
|
@@ -25,12 +25,12 @@ export declare const TEMP_DEW_PATTERN: RegExp;
|
|
|
25
25
|
* @param raw - Report text, verbatim (kept on report.raw). 报文原文(原样保真于 report.raw)。
|
|
26
26
|
* @param options - See ParseOptions (kind override, compact spans). 见 ParseOptions(类型位注入、紧凑模式)。
|
|
27
27
|
*/
|
|
28
|
-
export declare function parse(raw: string, options?: ParseOptions): MetarReport;
|
|
28
|
+
export declare function parse(raw: string, options?: ParseOptions): MetarReport$1;
|
|
29
29
|
/** Result-style parse outcome: never throws for parse-level failures — branch on `ok` instead of try/catch.
|
|
30
30
|
* 结果式解析出口:解析层失败不抛出,按 ok 分流——批量回放/管道消费免 try/catch 控制流。 */
|
|
31
31
|
export type TryParseResult = {
|
|
32
32
|
readonly ok: true;
|
|
33
|
-
readonly report: MetarReport;
|
|
33
|
+
readonly report: MetarReport$1;
|
|
34
34
|
} | {
|
|
35
35
|
readonly ok: false;
|
|
36
36
|
readonly error: MetarParseError;
|
|
@@ -44,4 +44,5 @@ export type TryParseResult = {
|
|
|
44
44
|
*/
|
|
45
45
|
export declare function tryParse(raw: string, options?: ParseOptions): TryParseResult;
|
|
46
46
|
//#endregion
|
|
47
|
+
export type { AltimeterReading, CloudCondition, CloudElement, MetarReport, Observed, ParseWarning, ReportKind, RunwayStateGroup, RunwayVisualRange, Span, TemperatureReading, TrendElements, TrendGroup, TrendKind, VisibilityGroup, WeatherGroup, WindGroup };
|
|
47
48
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1006,7 +1006,7 @@ function parse(raw, options) {
|
|
|
1006
1006
|
i += 1;
|
|
1007
1007
|
let period;
|
|
1008
1008
|
const periodTok = peek();
|
|
1009
|
-
if (kindText !== "NOSIG" && periodTok !== void 0 && /^(AT|FM|TL)\d{4}$/.test(periodTok.text)) {
|
|
1009
|
+
if (kindText !== "NOSIG" && periodTok !== void 0 && (/^(?:AT|FM|TL)\d{4}$/.test(periodTok.text) || /^\d{4}\/\d{4}$/.test(periodTok.text))) {
|
|
1010
1010
|
period = {
|
|
1011
1011
|
text: periodTok.text,
|
|
1012
1012
|
span: spanOf(periodTok)
|
|
@@ -1027,7 +1027,7 @@ function parse(raw, options) {
|
|
|
1027
1027
|
continue;
|
|
1028
1028
|
}
|
|
1029
1029
|
if (text.length === 6 && (text.charCodeAt(0) === 65 || text.charCodeAt(0) === 84 || text.charCodeAt(0) === 70) || text.startsWith("BECMG") || text.startsWith("TEMPO")) {
|
|
1030
|
-
const fused = /^(BECMG|TEMPO)(AT|TL|FM)\d{4}$/.exec(text);
|
|
1030
|
+
const fused = /^(BECMG|TEMPO)((?:AT|TL|FM)\d{4}|\d{4}\/\d{4})$/.exec(text);
|
|
1031
1031
|
if (fused !== null) {
|
|
1032
1032
|
const indicator = fused[1] ?? "";
|
|
1033
1033
|
const collected = [t];
|
|
@@ -1075,12 +1075,36 @@ function parse(raw, options) {
|
|
|
1075
1075
|
warnings.push({
|
|
1076
1076
|
code: "invalid-format",
|
|
1077
1077
|
severity: "warning",
|
|
1078
|
-
message: `趋势时段词缺指示组(${text}——§15.14.3 时段词须随 BECMG/TEMPO
|
|
1078
|
+
message: `趋势时段词缺指示组(${text}——§15.14.3 时段词须随 BECMG/TEMPO 出现)——按指示组缺失的趋势段收下,指示组类型不可辨`,
|
|
1079
1079
|
span: spanOf(t)
|
|
1080
1080
|
});
|
|
1081
1081
|
continue;
|
|
1082
1082
|
}
|
|
1083
1083
|
}
|
|
1084
|
+
if (text.length === 9 && text.charCodeAt(4) === 47 && /^\d{4}\/\d{4}$/.test(text)) {
|
|
1085
|
+
const collected = [t];
|
|
1086
|
+
i += 1;
|
|
1087
|
+
collectTrendTokens(collected);
|
|
1088
|
+
trendCloseWarning();
|
|
1089
|
+
const bareElements = structureTrendElements(collected, 1);
|
|
1090
|
+
trends.push({
|
|
1091
|
+
kind: "unspecified",
|
|
1092
|
+
period: {
|
|
1093
|
+
text,
|
|
1094
|
+
span: spanOf(t)
|
|
1095
|
+
},
|
|
1096
|
+
...bareElements !== void 0 ? { elements: bareElements } : {},
|
|
1097
|
+
raw: collected.map((c) => c.text).join(" "),
|
|
1098
|
+
span: joinSpan(collected)
|
|
1099
|
+
});
|
|
1100
|
+
warnings.push({
|
|
1101
|
+
code: "invalid-format",
|
|
1102
|
+
severity: "warning",
|
|
1103
|
+
message: `趋势时段词缺指示组(${text}——ICAO Annex 3 模板趋势时段须随 BECMG/TEMPO 出现)——按指示组缺失的趋势段收下,指示组类型不可辨`,
|
|
1104
|
+
span: spanOf(t)
|
|
1105
|
+
});
|
|
1106
|
+
continue;
|
|
1107
|
+
}
|
|
1084
1108
|
if (text === "CAVOK") {
|
|
1085
1109
|
cavok = true;
|
|
1086
1110
|
cavokSpan = spanOf(t);
|