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