@cj-tech-master/excelts 4.2.3-canary.20260122073152.a9bb6b0 → 4.2.3-canary.20260122075539.cc11b20

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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @cj-tech-master/excelts v4.2.3-canary.20260122073152.a9bb6b0
2
+ * @cj-tech-master/excelts v4.2.3-canary.20260122075539.cc11b20
3
3
  * TypeScript Excel Workbook Manager - Read and Write xlsx and csv Files.
4
4
  * (c) 2026 cjnoname
5
5
  * Released under the MIT License
@@ -6765,8 +6765,6 @@ var ExcelTS = (function(exports) {
6765
6765
  quot: "\"",
6766
6766
  apos: "'"
6767
6767
  };
6768
- const HAN_CELL_PREFIXES = /^(ep|cp|dc|dcterms|dcmitype|vt):/;
6769
- const SPREADSHEETML_NS = "http://schemas.openxmlformats.org/spreadsheetml/2006/main";
6770
6768
  const S_TEXT = 0;
6771
6769
  const S_OPEN_WAKA = 1;
6772
6770
  const S_OPEN_WAKA_BANG = 2;
@@ -6818,7 +6816,6 @@ var ExcelTS = (function(exports) {
6818
6816
  this.positionAtNewLine = 0;
6819
6817
  this.chunkPosition = 0;
6820
6818
  this.ENTITIES = { ...XML_ENTITIES };
6821
- this.nsPrefix = null;
6822
6819
  this.trackPosition = opt?.position !== false;
6823
6820
  this.fileName = opt?.fileName;
6824
6821
  this.fragment = opt?.fragment ?? false;
@@ -6853,11 +6850,6 @@ var ExcelTS = (function(exports) {
6853
6850
  this.chunk = "";
6854
6851
  this.i = 0;
6855
6852
  this.prevI = 0;
6856
- this.nsPrefix = null;
6857
- }
6858
- stripNsPrefix(name) {
6859
- const n = name.replace(HAN_CELL_PREFIXES, "");
6860
- return this.nsPrefix && n.startsWith(this.nsPrefix + ":") ? n.slice(this.nsPrefix.length + 1) : n;
6861
6853
  }
6862
6854
  on(name, handler) {
6863
6855
  switch (name) {
@@ -7197,7 +7189,7 @@ var ExcelTS = (function(exports) {
7197
7189
  return;
7198
7190
  }
7199
7191
  this.tag = {
7200
- name: this.stripNsPrefix(this.name),
7192
+ name: this.name,
7201
7193
  attributes: Object.create(null),
7202
7194
  isSelfClosing: false
7203
7195
  };
@@ -7493,7 +7485,8 @@ var ExcelTS = (function(exports) {
7493
7485
  openTag() {
7494
7486
  const tag = this.tag;
7495
7487
  tag.isSelfClosing = false;
7496
- this.processAttributes(tag);
7488
+ for (const { name, value } of this.attribList) tag.attributes[name] = value;
7489
+ this.attribList = [];
7497
7490
  this.openTagHandler?.(tag);
7498
7491
  this.tags.push(tag);
7499
7492
  this.name = "";
@@ -7502,26 +7495,16 @@ var ExcelTS = (function(exports) {
7502
7495
  openSelfClosingTag() {
7503
7496
  const tag = this.tag;
7504
7497
  tag.isSelfClosing = true;
7505
- this.processAttributes(tag);
7498
+ for (const { name, value } of this.attribList) tag.attributes[name] = value;
7499
+ this.attribList = [];
7506
7500
  this.openTagHandler?.(tag);
7507
7501
  this.closeTagHandler?.(tag);
7508
7502
  if (this.tags.length === 0) this.closedRoot = true;
7509
7503
  this.name = "";
7510
7504
  this.state = S_TEXT;
7511
7505
  }
7512
- processAttributes(tag) {
7513
- for (const { name, value } of this.attribList) {
7514
- tag.attributes[name] = value;
7515
- if (name.startsWith("xmlns:") && value === SPREADSHEETML_NS) {
7516
- this.nsPrefix = name.slice(6);
7517
- tag.name = this.stripNsPrefix(tag.name);
7518
- }
7519
- }
7520
- this.attribList = [];
7521
- }
7522
7506
  closeTag() {
7523
- const { tags } = this;
7524
- const name = this.stripNsPrefix(this.name);
7507
+ const { tags, name } = this;
7525
7508
  this.state = S_TEXT;
7526
7509
  this.name = "";
7527
7510
  if (name === "") {
@@ -7596,6 +7579,30 @@ var ExcelTS = (function(exports) {
7596
7579
 
7597
7580
  //#endregion
7598
7581
  //#region src/modules/excel/xlsx/xform/base-xform.ts
7582
+ const HAN_CELL_PREFIXES = new Set([
7583
+ "ep",
7584
+ "cp",
7585
+ "dc",
7586
+ "dcterms",
7587
+ "dcmitype",
7588
+ "vt"
7589
+ ]);
7590
+ const SPREADSHEETML_NS = "http://schemas.openxmlformats.org/spreadsheetml/2006/main";
7591
+ function detectHanCellPrefix(tagName, attrs) {
7592
+ for (const key in attrs) if (key.length > 6 && key.startsWith("xmlns:")) {
7593
+ const prefix = key.slice(6);
7594
+ if (attrs[key] === SPREADSHEETML_NS) return prefix;
7595
+ if (HAN_CELL_PREFIXES.has(prefix)) return null;
7596
+ }
7597
+ const i = tagName.indexOf(":");
7598
+ return i !== -1 && HAN_CELL_PREFIXES.has(tagName.slice(0, i)) ? null : void 0;
7599
+ }
7600
+ function stripPrefix(name, nsPrefix) {
7601
+ const i = name.indexOf(":");
7602
+ if (i === -1) return name;
7603
+ const p = name.slice(0, i);
7604
+ return p === nsPrefix || HAN_CELL_PREFIXES.has(p) ? name.slice(i + 1) : name;
7605
+ }
7599
7606
  var BaseXform = class BaseXform {
7600
7607
  prepare(_model, _options) {}
7601
7608
  render(_xmlStream, _model) {}
@@ -7618,12 +7625,38 @@ var ExcelTS = (function(exports) {
7618
7625
  async parse(saxParser) {
7619
7626
  let done = false;
7620
7627
  let finalModel;
7628
+ let nsMode = 0;
7629
+ let nsPrefix = null;
7621
7630
  for await (const events of saxParser) {
7622
7631
  if (done) continue;
7623
- for (const { eventType, value } of events) if (eventType === "opentag") this.parseOpen(value);
7624
- else if (eventType === "text") this.parseText(value);
7632
+ for (const { eventType, value } of events) if (eventType === "opentag") {
7633
+ if (nsMode === 1) {
7634
+ this.parseOpen(value);
7635
+ continue;
7636
+ }
7637
+ if (nsMode === 0) {
7638
+ const prefix = detectHanCellPrefix(value.name, value.attributes);
7639
+ if (prefix === void 0) {
7640
+ nsMode = 1;
7641
+ this.parseOpen(value);
7642
+ continue;
7643
+ }
7644
+ nsMode = 2;
7645
+ nsPrefix = prefix;
7646
+ }
7647
+ value.name = stripPrefix(value.name, nsPrefix);
7648
+ this.parseOpen(value);
7649
+ } else if (eventType === "text") this.parseText(value);
7625
7650
  else if (eventType === "closetag") {
7626
- if (!this.parseClose(value.name)) {
7651
+ if (nsMode === 1) {
7652
+ if (!this.parseClose(value.name)) {
7653
+ done = true;
7654
+ finalModel = this.model;
7655
+ break;
7656
+ }
7657
+ continue;
7658
+ }
7659
+ if (!this.parseClose(stripPrefix(value.name, nsPrefix))) {
7627
7660
  done = true;
7628
7661
  finalModel = this.model;
7629
7662
  break;