@cj-tech-master/excelts 4.2.1-canary.20260112134913.a3cecdd → 4.2.2-canary.20260115044841.88820eb

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.
Files changed (27) hide show
  1. package/dist/browser/modules/excel/utils/parse-sax.d.ts +3 -0
  2. package/dist/browser/modules/excel/utils/parse-sax.js +32 -13
  3. package/dist/browser/modules/excel/xlsx/xform/core/app-xform.js +3 -3
  4. package/dist/browser/modules/excel/xlsx/xform/core/core-xform.js +56 -68
  5. package/dist/browser/modules/excel/xlsx/xform/list-xform.js +8 -10
  6. package/dist/browser/modules/excel/xlsx/xform/strings/shared-string-xform.js +2 -3
  7. package/dist/browser/modules/excel/xlsx/xform/strings/text-xform.js +5 -7
  8. package/dist/browser/modules/excel/xlsx/xlsx.browser.js +8 -4
  9. package/dist/cjs/modules/excel/utils/parse-sax.js +32 -13
  10. package/dist/cjs/modules/excel/xlsx/xform/core/app-xform.js +3 -3
  11. package/dist/cjs/modules/excel/xlsx/xform/core/core-xform.js +56 -68
  12. package/dist/cjs/modules/excel/xlsx/xform/list-xform.js +8 -10
  13. package/dist/cjs/modules/excel/xlsx/xform/strings/shared-string-xform.js +2 -3
  14. package/dist/cjs/modules/excel/xlsx/xform/strings/text-xform.js +5 -7
  15. package/dist/cjs/modules/excel/xlsx/xlsx.browser.js +8 -4
  16. package/dist/esm/modules/excel/utils/parse-sax.js +32 -13
  17. package/dist/esm/modules/excel/xlsx/xform/core/app-xform.js +3 -3
  18. package/dist/esm/modules/excel/xlsx/xform/core/core-xform.js +56 -68
  19. package/dist/esm/modules/excel/xlsx/xform/list-xform.js +8 -10
  20. package/dist/esm/modules/excel/xlsx/xform/strings/shared-string-xform.js +2 -3
  21. package/dist/esm/modules/excel/xlsx/xform/strings/text-xform.js +5 -7
  22. package/dist/esm/modules/excel/xlsx/xlsx.browser.js +8 -4
  23. package/dist/iife/excelts.iife.js +100 -100
  24. package/dist/iife/excelts.iife.js.map +1 -1
  25. package/dist/iife/excelts.iife.min.js +24 -24
  26. package/dist/types/modules/excel/utils/parse-sax.d.ts +3 -0
  27. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @cj-tech-master/excelts v4.2.1-canary.20260112134913.a3cecdd
2
+ * @cj-tech-master/excelts v4.2.2-canary.20260115044841.88820eb
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
@@ -6764,6 +6764,8 @@ var ExcelTS = (function(exports) {
6764
6764
  quot: "\"",
6765
6765
  apos: "'"
6766
6766
  };
6767
+ const HAN_CELL_PREFIXES = /^(ep|cp|dc|dcterms|dcmitype|vt):/;
6768
+ const SPREADSHEETML_NS = "http://schemas.openxmlformats.org/spreadsheetml/2006/main";
6767
6769
  const S_TEXT = 0;
6768
6770
  const S_OPEN_WAKA = 1;
6769
6771
  const S_OPEN_WAKA_BANG = 2;
@@ -6815,6 +6817,7 @@ var ExcelTS = (function(exports) {
6815
6817
  this.positionAtNewLine = 0;
6816
6818
  this.chunkPosition = 0;
6817
6819
  this.ENTITIES = { ...XML_ENTITIES };
6820
+ this.nsPrefix = null;
6818
6821
  this.trackPosition = opt?.position !== false;
6819
6822
  this.fileName = opt?.fileName;
6820
6823
  this.fragment = opt?.fragment ?? false;
@@ -6849,6 +6852,11 @@ var ExcelTS = (function(exports) {
6849
6852
  this.chunk = "";
6850
6853
  this.i = 0;
6851
6854
  this.prevI = 0;
6855
+ this.nsPrefix = null;
6856
+ }
6857
+ stripNsPrefix(name) {
6858
+ const n = name.replace(HAN_CELL_PREFIXES, "");
6859
+ return this.nsPrefix && n.startsWith(this.nsPrefix + ":") ? n.slice(this.nsPrefix.length + 1) : n;
6852
6860
  }
6853
6861
  on(name, handler) {
6854
6862
  switch (name) {
@@ -7188,7 +7196,7 @@ var ExcelTS = (function(exports) {
7188
7196
  return;
7189
7197
  }
7190
7198
  this.tag = {
7191
- name: this.name,
7199
+ name: this.stripNsPrefix(this.name),
7192
7200
  attributes: Object.create(null),
7193
7201
  isSelfClosing: false
7194
7202
  };
@@ -7484,8 +7492,7 @@ var ExcelTS = (function(exports) {
7484
7492
  openTag() {
7485
7493
  const tag = this.tag;
7486
7494
  tag.isSelfClosing = false;
7487
- for (const { name, value } of this.attribList) tag.attributes[name] = value;
7488
- this.attribList = [];
7495
+ this.processAttributes(tag);
7489
7496
  this.openTagHandler?.(tag);
7490
7497
  this.tags.push(tag);
7491
7498
  this.name = "";
@@ -7494,16 +7501,26 @@ var ExcelTS = (function(exports) {
7494
7501
  openSelfClosingTag() {
7495
7502
  const tag = this.tag;
7496
7503
  tag.isSelfClosing = true;
7497
- for (const { name, value } of this.attribList) tag.attributes[name] = value;
7498
- this.attribList = [];
7504
+ this.processAttributes(tag);
7499
7505
  this.openTagHandler?.(tag);
7500
7506
  this.closeTagHandler?.(tag);
7501
7507
  if (this.tags.length === 0) this.closedRoot = true;
7502
7508
  this.name = "";
7503
7509
  this.state = S_TEXT;
7504
7510
  }
7511
+ processAttributes(tag) {
7512
+ for (const { name, value } of this.attribList) {
7513
+ tag.attributes[name] = value;
7514
+ if (name.startsWith("xmlns:") && value === SPREADSHEETML_NS) {
7515
+ this.nsPrefix = name.slice(6);
7516
+ tag.name = this.stripNsPrefix(tag.name);
7517
+ }
7518
+ }
7519
+ this.attribList = [];
7520
+ }
7505
7521
  closeTag() {
7506
- const { tags, name } = this;
7522
+ const { tags } = this;
7523
+ const name = this.stripNsPrefix(this.name);
7507
7524
  this.state = S_TEXT;
7508
7525
  this.name = "";
7509
7526
  if (name === "") {
@@ -7730,17 +7747,15 @@ var ExcelTS = (function(exports) {
7730
7747
  this.parser.parseOpen(node);
7731
7748
  return true;
7732
7749
  }
7733
- switch (node.name) {
7734
- case this.tag:
7735
- this.model = [];
7736
- return true;
7737
- default:
7738
- if (this.childXform.parseOpen(node)) {
7739
- this.parser = this.childXform;
7740
- return true;
7741
- }
7742
- return false;
7750
+ if (node.name === this.tag) {
7751
+ this.model = [];
7752
+ return true;
7743
7753
  }
7754
+ if (this.childXform.parseOpen(node)) {
7755
+ this.parser = this.childXform;
7756
+ return true;
7757
+ }
7758
+ return false;
7744
7759
  }
7745
7760
  parseText(text) {
7746
7761
  if (this.parser) this.parser.parseText(text);
@@ -9591,34 +9606,52 @@ var ExcelTS = (function(exports) {
9591
9606
 
9592
9607
  //#endregion
9593
9608
  //#region src/modules/excel/xlsx/xform/core/core-xform.ts
9609
+ const PROPS = {
9610
+ creator: "dc:creator",
9611
+ title: "dc:title",
9612
+ subject: "dc:subject",
9613
+ description: "dc:description",
9614
+ identifier: "dc:identifier",
9615
+ language: "dc:language",
9616
+ keywords: "cp:keywords",
9617
+ category: "cp:category",
9618
+ lastModifiedBy: "cp:lastModifiedBy",
9619
+ lastPrinted: "cp:lastPrinted",
9620
+ revision: "cp:revision",
9621
+ version: "cp:version",
9622
+ contentStatus: "cp:contentStatus",
9623
+ contentType: "cp:contentType",
9624
+ created: "dcterms:created",
9625
+ modified: "dcterms:modified"
9626
+ };
9594
9627
  var CoreXform = class CoreXform extends BaseXform {
9595
9628
  constructor() {
9596
9629
  super();
9597
9630
  this.map = {
9598
- "dc:creator": new StringXform({ tag: "dc:creator" }),
9599
- "dc:title": new StringXform({ tag: "dc:title" }),
9600
- "dc:subject": new StringXform({ tag: "dc:subject" }),
9601
- "dc:description": new StringXform({ tag: "dc:description" }),
9602
- "dc:identifier": new StringXform({ tag: "dc:identifier" }),
9603
- "dc:language": new StringXform({ tag: "dc:language" }),
9604
- "cp:keywords": new StringXform({ tag: "cp:keywords" }),
9605
- "cp:category": new StringXform({ tag: "cp:category" }),
9606
- "cp:lastModifiedBy": new StringXform({ tag: "cp:lastModifiedBy" }),
9607
- "cp:lastPrinted": new DateXform({
9608
- tag: "cp:lastPrinted",
9631
+ creator: new StringXform({ tag: PROPS.creator }),
9632
+ title: new StringXform({ tag: PROPS.title }),
9633
+ subject: new StringXform({ tag: PROPS.subject }),
9634
+ description: new StringXform({ tag: PROPS.description }),
9635
+ identifier: new StringXform({ tag: PROPS.identifier }),
9636
+ language: new StringXform({ tag: PROPS.language }),
9637
+ keywords: new StringXform({ tag: PROPS.keywords }),
9638
+ category: new StringXform({ tag: PROPS.category }),
9639
+ lastModifiedBy: new StringXform({ tag: PROPS.lastModifiedBy }),
9640
+ lastPrinted: new DateXform({
9641
+ tag: PROPS.lastPrinted,
9609
9642
  format: CoreXform.DateFormat
9610
9643
  }),
9611
- "cp:revision": new IntegerXform({ tag: "cp:revision" }),
9612
- "cp:version": new StringXform({ tag: "cp:version" }),
9613
- "cp:contentStatus": new StringXform({ tag: "cp:contentStatus" }),
9614
- "cp:contentType": new StringXform({ tag: "cp:contentType" }),
9615
- "dcterms:created": new DateXform({
9616
- tag: "dcterms:created",
9644
+ revision: new IntegerXform({ tag: PROPS.revision }),
9645
+ version: new StringXform({ tag: PROPS.version }),
9646
+ contentStatus: new StringXform({ tag: PROPS.contentStatus }),
9647
+ contentType: new StringXform({ tag: PROPS.contentType }),
9648
+ created: new DateXform({
9649
+ tag: PROPS.created,
9617
9650
  attrs: CoreXform.DateAttrs,
9618
9651
  format: CoreXform.DateFormat
9619
9652
  }),
9620
- "dcterms:modified": new DateXform({
9621
- tag: "dcterms:modified",
9653
+ modified: new DateXform({
9654
+ tag: PROPS.modified,
9622
9655
  attrs: CoreXform.DateAttrs,
9623
9656
  format: CoreXform.DateFormat
9624
9657
  })
@@ -9627,22 +9660,7 @@ var ExcelTS = (function(exports) {
9627
9660
  render(xmlStream, model) {
9628
9661
  xmlStream.openXml(XmlStream.StdDocAttributes);
9629
9662
  xmlStream.openNode("cp:coreProperties", CoreXform.CORE_PROPERTY_ATTRIBUTES);
9630
- this.map["dc:creator"].render(xmlStream, model.creator);
9631
- this.map["dc:title"].render(xmlStream, model.title);
9632
- this.map["dc:subject"].render(xmlStream, model.subject);
9633
- this.map["dc:description"].render(xmlStream, model.description);
9634
- this.map["dc:identifier"].render(xmlStream, model.identifier);
9635
- this.map["dc:language"].render(xmlStream, model.language);
9636
- this.map["cp:keywords"].render(xmlStream, model.keywords);
9637
- this.map["cp:category"].render(xmlStream, model.category);
9638
- this.map["cp:lastModifiedBy"].render(xmlStream, model.lastModifiedBy);
9639
- this.map["cp:lastPrinted"].render(xmlStream, model.lastPrinted);
9640
- this.map["cp:revision"].render(xmlStream, model.revision);
9641
- this.map["cp:version"].render(xmlStream, model.version);
9642
- this.map["cp:contentStatus"].render(xmlStream, model.contentStatus);
9643
- this.map["cp:contentType"].render(xmlStream, model.contentType);
9644
- this.map["dcterms:created"].render(xmlStream, model.created);
9645
- this.map["dcterms:modified"].render(xmlStream, model.modified);
9663
+ for (const key of Object.keys(PROPS)) this.map[key].render(xmlStream, model[key]);
9646
9664
  xmlStream.closeNode();
9647
9665
  }
9648
9666
  parseOpen(node) {
@@ -9650,17 +9668,11 @@ var ExcelTS = (function(exports) {
9650
9668
  this.parser.parseOpen(node);
9651
9669
  return true;
9652
9670
  }
9653
- switch (node.name) {
9654
- case "cp:coreProperties":
9655
- case "coreProperties": return true;
9656
- default:
9657
- this.parser = this.map[node.name];
9658
- if (this.parser) {
9659
- this.parser.parseOpen(node);
9660
- return true;
9661
- }
9662
- throw new Error(`Unexpected xml node in parseOpen: ${JSON.stringify(node)}`);
9671
+ if (node.name !== "coreProperties") {
9672
+ this.parser = this.map[node.name];
9673
+ if (this.parser) this.parser.parseOpen(node);
9663
9674
  }
9675
+ return true;
9664
9676
  }
9665
9677
  parseText(text) {
9666
9678
  if (this.parser) this.parser.parseText(text);
@@ -9670,29 +9682,15 @@ var ExcelTS = (function(exports) {
9670
9682
  if (!this.parser.parseClose(name)) this.parser = void 0;
9671
9683
  return true;
9672
9684
  }
9673
- switch (name) {
9674
- case "cp:coreProperties":
9675
- case "coreProperties":
9676
- this.model = {
9677
- creator: this.map["dc:creator"].model,
9678
- title: this.map["dc:title"].model,
9679
- subject: this.map["dc:subject"].model,
9680
- description: this.map["dc:description"].model,
9681
- identifier: this.map["dc:identifier"].model,
9682
- language: this.map["dc:language"].model,
9683
- keywords: this.map["cp:keywords"].model,
9684
- category: this.map["cp:category"].model,
9685
- lastModifiedBy: this.map["cp:lastModifiedBy"].model,
9686
- lastPrinted: this.map["cp:lastPrinted"].model,
9687
- revision: this.map["cp:revision"].model,
9688
- contentStatus: this.map["cp:contentStatus"].model,
9689
- contentType: this.map["cp:contentType"].model,
9690
- created: this.map["dcterms:created"].model,
9691
- modified: this.map["dcterms:modified"].model
9692
- };
9693
- return false;
9694
- default: throw new Error(`Unexpected xml node in parseClose: ${name}`);
9685
+ if (name === "coreProperties") {
9686
+ this.model = {};
9687
+ for (const key of Object.keys(PROPS)) {
9688
+ const val = this.map[key].model;
9689
+ if (val !== void 0 && val !== "") this.model[key] = val;
9690
+ }
9691
+ return false;
9695
9692
  }
9693
+ return true;
9696
9694
  }
9697
9695
  static {
9698
9696
  this.DateFormat = function(dt) {
@@ -9726,13 +9724,12 @@ var ExcelTS = (function(exports) {
9726
9724
  xmlStream.closeNode();
9727
9725
  }
9728
9726
  parseOpen(node) {
9729
- switch (node.name) {
9730
- case "t":
9731
- this._text = [];
9732
- this.model = "";
9733
- return true;
9734
- default: return false;
9727
+ if (node.name === "t") {
9728
+ this._text = [];
9729
+ this.model = "";
9730
+ return true;
9735
9731
  }
9732
+ return false;
9736
9733
  }
9737
9734
  parseText(text) {
9738
9735
  this._text.push(text);
@@ -9913,16 +9910,15 @@ var ExcelTS = (function(exports) {
9913
9910
  xmlStream.closeNode();
9914
9911
  }
9915
9912
  parseOpen(node) {
9916
- const { name } = node;
9917
9913
  if (this.parser) {
9918
9914
  this.parser.parseOpen(node);
9919
9915
  return true;
9920
9916
  }
9921
- if (name === this.tag) {
9917
+ if (node.name === this.tag) {
9922
9918
  this.model = {};
9923
9919
  return true;
9924
9920
  }
9925
- this.parser = this.map[name];
9921
+ this.parser = this.map[node.name];
9926
9922
  if (this.parser) {
9927
9923
  this.parser.parseOpen(node);
9928
9924
  return true;
@@ -10515,7 +10511,7 @@ var ExcelTS = (function(exports) {
10515
10511
  Company: new StringXform({ tag: "Company" }),
10516
10512
  Manager: new StringXform({ tag: "Manager" }),
10517
10513
  HeadingPairs: new AppHeadingPairsXform(),
10518
- TitleOfParts: new AppTitlesOfPartsXform()
10514
+ TitlesOfParts: new AppTitlesOfPartsXform()
10519
10515
  };
10520
10516
  }
10521
10517
  render(xmlStream, model) {
@@ -10525,7 +10521,7 @@ var ExcelTS = (function(exports) {
10525
10521
  xmlStream.leafNode("DocSecurity", void 0, "0");
10526
10522
  xmlStream.leafNode("ScaleCrop", void 0, "false");
10527
10523
  this.map.HeadingPairs.render(xmlStream, model.worksheets);
10528
- this.map.TitleOfParts.render(xmlStream, model.worksheets);
10524
+ this.map.TitlesOfParts.render(xmlStream, model.worksheets);
10529
10525
  this.map.Company.render(xmlStream, model.company || "");
10530
10526
  this.map.Manager.render(xmlStream, model.manager);
10531
10527
  xmlStream.leafNode("LinksUpToDate", void 0, "false");
@@ -10561,7 +10557,7 @@ var ExcelTS = (function(exports) {
10561
10557
  switch (name) {
10562
10558
  case "Properties":
10563
10559
  this.model = {
10564
- worksheets: this.map.TitleOfParts.model,
10560
+ worksheets: this.map.TitlesOfParts.model,
10565
10561
  company: this.map.Company.model,
10566
10562
  manager: this.map.Manager.model
10567
10563
  };
@@ -20494,8 +20490,10 @@ var ExcelTS = (function(exports) {
20494
20490
  break;
20495
20491
  case OOXML_PATHS.docPropsApp: {
20496
20492
  const appProperties = await new AppXform().parseStream(stream);
20497
- model.company = appProperties.company;
20498
- model.manager = appProperties.manager;
20493
+ if (appProperties) {
20494
+ model.company = appProperties.company;
20495
+ model.manager = appProperties.manager;
20496
+ }
20499
20497
  break;
20500
20498
  }
20501
20499
  case OOXML_PATHS.docPropsCore: {
@@ -20873,8 +20871,10 @@ var ExcelTS = (function(exports) {
20873
20871
  break;
20874
20872
  case OOXML_PATHS.docPropsApp: {
20875
20873
  const appProperties = await new AppXform().parseStream(stream);
20876
- model.company = appProperties.company;
20877
- model.manager = appProperties.manager;
20874
+ if (appProperties) {
20875
+ model.company = appProperties.company;
20876
+ model.manager = appProperties.manager;
20877
+ }
20878
20878
  break;
20879
20879
  }
20880
20880
  case OOXML_PATHS.docPropsCore: {