jww-parser-mbt 2025.12.2 → 2025.12.3

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 CHANGED
@@ -996,58 +996,58 @@ const f4ah6o$jww_parser$core$$default$46$record$47$742 = {
996
996
  protect: 0,
997
997
  name: ""
998
998
  };
999
- const f4ah6o$jww_parser$core$$parse$46$constr$47$1000 = 8;
1000
- const f4ah6o$jww_parser$dxf$$ltype_table$46$tuple$47$1037 = {
999
+ const f4ah6o$jww_parser$core$$parse$46$constr$47$1004 = 8;
1000
+ const f4ah6o$jww_parser$dxf$$ltype_table$46$tuple$47$1041 = {
1001
1001
  _0: "CONTINUOUS",
1002
1002
  _1: "Solid line",
1003
1003
  _2: ""
1004
1004
  };
1005
- const f4ah6o$jww_parser$dxf$$ltype_table$46$tuple$47$1038 = {
1005
+ const f4ah6o$jww_parser$dxf$$ltype_table$46$tuple$47$1042 = {
1006
1006
  _0: "DASHED",
1007
1007
  _1: "Dashed",
1008
1008
  _2: ""
1009
1009
  };
1010
- const f4ah6o$jww_parser$dxf$$ltype_table$46$tuple$47$1039 = {
1010
+ const f4ah6o$jww_parser$dxf$$ltype_table$46$tuple$47$1043 = {
1011
1011
  _0: "DOTTED",
1012
1012
  _1: "Dotted",
1013
1013
  _2: ""
1014
1014
  };
1015
- const f4ah6o$jww_parser$dxf$$ltype_table$46$tuple$47$1040 = {
1015
+ const f4ah6o$jww_parser$dxf$$ltype_table$46$tuple$47$1044 = {
1016
1016
  _0: "DASHDOT",
1017
1017
  _1: "Dash dot",
1018
1018
  _2: ""
1019
1019
  };
1020
- const f4ah6o$jww_parser$dxf$$ltype_table$46$tuple$47$1041 = {
1020
+ const f4ah6o$jww_parser$dxf$$ltype_table$46$tuple$47$1045 = {
1021
1021
  _0: "DOT2",
1022
1022
  _1: "Dot (small)",
1023
1023
  _2: ""
1024
1024
  };
1025
- const f4ah6o$jww_parser$dxf$$ltype_table$46$tuple$47$1042 = {
1025
+ const f4ah6o$jww_parser$dxf$$ltype_table$46$tuple$47$1046 = {
1026
1026
  _0: "DASHDOT2",
1027
1027
  _1: "Dash dot (small)",
1028
1028
  _2: ""
1029
1029
  };
1030
- const f4ah6o$jww_parser$dxf$$ltype_table$46$tuple$47$1043 = {
1030
+ const f4ah6o$jww_parser$dxf$$ltype_table$46$tuple$47$1047 = {
1031
1031
  _0: "DASHDOTDOT",
1032
1032
  _1: "Dash dot dot",
1033
1033
  _2: ""
1034
1034
  };
1035
- const f4ah6o$jww_parser$dxf$$ltype_table$46$tuple$47$1044 = {
1035
+ const f4ah6o$jww_parser$dxf$$ltype_table$46$tuple$47$1048 = {
1036
1036
  _0: "DIVIDE",
1037
1037
  _1: "Divide",
1038
1038
  _2: ""
1039
1039
  };
1040
- const f4ah6o$jww_parser$dxf$$ltype_table$46$tuple$47$1045 = {
1040
+ const f4ah6o$jww_parser$dxf$$ltype_table$46$tuple$47$1049 = {
1041
1041
  _0: "CENTER",
1042
1042
  _1: "Center",
1043
1043
  _2: ""
1044
1044
  };
1045
- const f4ah6o$jww_parser$dxf$$ltype_table$46$tuple$47$1046 = {
1045
+ const f4ah6o$jww_parser$dxf$$ltype_table$46$tuple$47$1050 = {
1046
1046
  _0: "BORDER",
1047
1047
  _1: "Border",
1048
1048
  _2: ""
1049
1049
  };
1050
- const f4ah6o$jww_parser$dxf$$ltype_table$46$tuple$47$1047 = {
1050
+ const f4ah6o$jww_parser$dxf$$ltype_table$46$tuple$47$1051 = {
1051
1051
  _0: "HIDDEN",
1052
1052
  _1: "Hidden",
1053
1053
  _2: ""
@@ -9612,6 +9612,11 @@ function f4ah6o$jww_parser$core$$Reader$read_double(self) {
9612
9612
  return moonbitlang$core$uint64$$UInt64$to_double(f4ah6o$jww_parser$core$$Reader$read_uint64(self));
9613
9613
  }
9614
9614
  function f4ah6o$jww_parser$core$$Reader$read_bytes(self, n) {
9615
+ if ((self.data.length - self.pos | 0) < n) return moonbitlang$core$bytes$$Bytes$from_array({
9616
+ buf: new Uint8Array([]),
9617
+ start: 0,
9618
+ end: 0
9619
+ });
9615
9620
  const start = self.pos;
9616
9621
  const end = self.pos + n | 0;
9617
9622
  self.pos = end;
@@ -9684,10 +9689,14 @@ function f4ah6o$jww_parser$core$$read_cstring(reader) {
9684
9689
  if (len_byte < 255) length = len_byte;
9685
9690
  else {
9686
9691
  const len_word = f4ah6o$jww_parser$core$$Reader$read_word(reader);
9687
- length = len_word < 65535 ? len_word : f4ah6o$jww_parser$core$$Reader$read_dword(reader);
9692
+ if (len_word < 65535) length = len_word;
9693
+ else {
9694
+ const len_dword = f4ah6o$jww_parser$core$$Reader$read_dword(reader);
9695
+ length = len_dword < 0 || len_dword > 1e6 ? 0 : len_dword;
9696
+ }
9688
9697
  }
9689
- if (length === 0) return "";
9690
- return f4ah6o$encoding_sjis_mbt$$shift_jis_to_utf8(f4ah6o$jww_parser$core$$Reader$read_bytes(reader, length));
9698
+ if (length <= 0 || length > 1e6) return "";
9699
+ return f4ah6o$encoding_sjis_mbt$$shift_jis_to_utf8(f4ah6o$jww_parser$core$$Reader$read_bytes(reader, (reader.data.length - reader.pos | 0) < length ? reader.data.length - reader.pos | 0 : length));
9691
9700
  }
9692
9701
  function f4ah6o$jww_parser$core$$parse_entity_by_class(class_name, reader, version) {
9693
9702
  if (class_name === "CDataSen") return new $64$f4ah6o$47$jww_parser$47$core$46$Entity$Line({
@@ -9854,7 +9863,7 @@ function f4ah6o$jww_parser$core$$parse_entity_with_pid_tracking(reader, version,
9854
9863
  } else break;
9855
9864
  }
9856
9865
  const class_name = name_chars;
9857
- if (next_pid < 256) moonbitlang$core$array$$Array$set$13$(pid_to_class, next_pid, class_name);
9866
+ if (next_pid < 65536) moonbitlang$core$array$$Array$set$13$(pid_to_class, next_pid, class_name);
9858
9867
  _bind = {
9859
9868
  _0: class_name,
9860
9869
  _1: pid_to_class,
@@ -9867,7 +9876,7 @@ function f4ah6o$jww_parser$core$$parse_entity_with_pid_tracking(reader, version,
9867
9876
  };
9868
9877
  else {
9869
9878
  const class_pid = class_id & 32767;
9870
- if (class_pid < 256) {
9879
+ if (class_pid < 65536) {
9871
9880
  const name = moonbitlang$core$array$$Array$at$13$(pid_to_class, class_pid);
9872
9881
  if (name === "") return {
9873
9882
  entity: void 0,
@@ -9903,7 +9912,7 @@ function f4ah6o$jww_parser$core$$parse_entity_list(data, offset, version) {
9903
9912
  let _tmp = 0;
9904
9913
  while (true) {
9905
9914
  const _ = _tmp;
9906
- if (_ < 256) {
9915
+ if (_ < 65536) {
9907
9916
  moonbitlang$core$array$$Array$push$13$(pid_to_class, "");
9908
9917
  _tmp = _ + 1 | 0;
9909
9918
  continue;
@@ -10012,6 +10021,7 @@ function f4ah6o$jww_parser$core$$parse_block_def_with_tracking(reader, version,
10012
10021
  function f4ah6o$jww_parser$core$$parse_block_def_list(data, offset, version) {
10013
10022
  if (offset >= data.length) return moonbitlang$core$array$$Array$new$46$inner$19$(0);
10014
10023
  const reader = f4ah6o$jww_parser$core$$Reader$new(moonbitlang$core$bytes$$Bytes$from_array(moonbitlang$core$array$$Array$sub$46$inner$3$(moonbitlang$core$bytes$$Bytes$to_array(data), offset, data.length)));
10024
+ if ((reader.data.length - reader.pos | 0) < 4) return moonbitlang$core$array$$Array$new$46$inner$19$(0);
10015
10025
  const count = f4ah6o$jww_parser$core$$Reader$read_dword(reader);
10016
10026
  if (count >>> 0 > 1e4) return moonbitlang$core$array$$Array$new$46$inner$19$(0);
10017
10027
  const block_defs = moonbitlang$core$array$$Array$new$46$inner$19$(0);
@@ -10031,6 +10041,7 @@ function f4ah6o$jww_parser$core$$parse_block_def_list(data, offset, version) {
10031
10041
  while (true) {
10032
10042
  const _ = _tmp$2;
10033
10043
  if (_ < _end50) {
10044
+ if ((reader.data.length - reader.pos | 0) < 8) break;
10034
10045
  const result = f4ah6o$jww_parser$core$$parse_block_def_with_tracking(reader, version, class_map, next_id);
10035
10046
  const _bind = result.block_def;
10036
10047
  if (_bind === void 0) {} else moonbitlang$core$array$$Array$push$19$(block_defs, _bind);
@@ -10084,7 +10095,7 @@ function f4ah6o$jww_parser$core$$set_layer_names(layer_groups) {
10084
10095
  }
10085
10096
  function f4ah6o$jww_parser$core$$parse(data) {
10086
10097
  if (data.length < 8) return f4ah6o$jww_parser$core$$Document$default();
10087
- if (moonbitlang$core$builtin$$op_notequal$9$(moonbitlang$core$bytes$$Bytes$from_array(moonbitlang$core$array$$Array$sub$46$inner$3$(moonbitlang$core$bytes$$Bytes$to_array(data), 0, f4ah6o$jww_parser$core$$parse$46$constr$47$1000)), $bytes_literal$1)) return f4ah6o$jww_parser$core$$Document$default();
10098
+ if (moonbitlang$core$builtin$$op_notequal$9$(moonbitlang$core$bytes$$Bytes$from_array(moonbitlang$core$array$$Array$sub$46$inner$3$(moonbitlang$core$bytes$$Bytes$to_array(data), 0, f4ah6o$jww_parser$core$$parse$46$constr$47$1004)), $bytes_literal$1)) return f4ah6o$jww_parser$core$$Document$default();
10088
10099
  const reader = f4ah6o$jww_parser$core$$Reader$new(moonbitlang$core$bytes$$Bytes$from_array(moonbitlang$core$array$$Array$sub$46$inner$3$(moonbitlang$core$bytes$$Bytes$to_array(data), 8, data.length)));
10089
10100
  const version = f4ah6o$jww_parser$core$$Reader$read_dword(reader);
10090
10101
  const memo = f4ah6o$jww_parser$core$$read_cstring(reader);
@@ -10187,17 +10198,17 @@ function f4ah6o$jww_parser$dxf$$ltype_table() {
10187
10198
  output = `${output}2\nLTYPE\n`;
10188
10199
  output = `${output}70\n11\n`;
10189
10200
  const ltypes = [
10190
- f4ah6o$jww_parser$dxf$$ltype_table$46$tuple$47$1037,
10191
- f4ah6o$jww_parser$dxf$$ltype_table$46$tuple$47$1038,
10192
- f4ah6o$jww_parser$dxf$$ltype_table$46$tuple$47$1039,
10193
- f4ah6o$jww_parser$dxf$$ltype_table$46$tuple$47$1040,
10194
10201
  f4ah6o$jww_parser$dxf$$ltype_table$46$tuple$47$1041,
10195
10202
  f4ah6o$jww_parser$dxf$$ltype_table$46$tuple$47$1042,
10196
10203
  f4ah6o$jww_parser$dxf$$ltype_table$46$tuple$47$1043,
10197
10204
  f4ah6o$jww_parser$dxf$$ltype_table$46$tuple$47$1044,
10198
10205
  f4ah6o$jww_parser$dxf$$ltype_table$46$tuple$47$1045,
10199
10206
  f4ah6o$jww_parser$dxf$$ltype_table$46$tuple$47$1046,
10200
- f4ah6o$jww_parser$dxf$$ltype_table$46$tuple$47$1047
10207
+ f4ah6o$jww_parser$dxf$$ltype_table$46$tuple$47$1047,
10208
+ f4ah6o$jww_parser$dxf$$ltype_table$46$tuple$47$1048,
10209
+ f4ah6o$jww_parser$dxf$$ltype_table$46$tuple$47$1049,
10210
+ f4ah6o$jww_parser$dxf$$ltype_table$46$tuple$47$1050,
10211
+ f4ah6o$jww_parser$dxf$$ltype_table$46$tuple$47$1051
10201
10212
  ];
10202
10213
  const _len = ltypes.length;
10203
10214
  let _tmp = 0;
@@ -10485,6 +10496,10 @@ function f4ah6o$jww_parser$dxf$$to_string(doc) {
10485
10496
  output = `${output}0\nEOF\n`;
10486
10497
  return output;
10487
10498
  }
10499
+ function f4ah6o$jww_parser$dxf$$feq(a, b) {
10500
+ const _p = a - b;
10501
+ return (_p < 0 ? -_p : _p) < 1e-9;
10502
+ }
10488
10503
  function f4ah6o$jww_parser$dxf$$cos(_tmp) {
10489
10504
  return Math.cos(_tmp);
10490
10505
  }
@@ -10568,7 +10583,7 @@ function f4ah6o$jww_parser$dxf$$convert_entity(entity, jww_doc) {
10568
10583
  }
10569
10584
  case 1: {
10570
10585
  const _arc = entity._0;
10571
- if (_arc.is_full_circle && _arc.flatness === 1) return new $64$f4ah6o$47$jww_parser$47$dxf$46$DxfEntity$Circle({
10586
+ if (_arc.is_full_circle && f4ah6o$jww_parser$dxf$$feq(_arc.flatness, 1)) return new $64$f4ah6o$47$jww_parser$47$dxf$46$DxfEntity$Circle({
10572
10587
  layer: layer_name,
10573
10588
  color,
10574
10589
  line_type,
@@ -10576,7 +10591,7 @@ function f4ah6o$jww_parser$dxf$$convert_entity(entity, jww_doc) {
10576
10591
  center_y: _arc.center_y,
10577
10592
  radius: _arc.radius
10578
10593
  });
10579
- else if (_arc.flatness !== 1) {
10594
+ else if (!f4ah6o$jww_parser$dxf$$feq(_arc.flatness, 1)) {
10580
10595
  let major_radius = _arc.radius;
10581
10596
  let minor_ratio = _arc.flatness;
10582
10597
  let tilt_angle = _arc.tilt_angle;