@progress/kendo-spreadsheet-common 1.2.10-develop.1 → 1.2.10-develop.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-esm.js CHANGED
@@ -2621,6 +2621,7 @@ function defineFunction(name, func) {
2621
2621
  }
2622
2622
 
2623
2623
  function defineBuiltinFunction$1(name, isAsync, x, impl) {
2624
+ name = name.toLowerCase();
2624
2625
  FUNCS$1[name] = isAsync
2625
2626
  ? makeAsyncFunction(impl, x.resolve, x.check, x.arrayArgs)
2626
2627
  : makeSyncFunction(impl, x.resolve, x.check, x.arrayArgs);
@@ -20532,7 +20533,7 @@ function UCS2(out, code) {
20532
20533
  if (code > 0xFFFF) {
20533
20534
  code -= 0x10000;
20534
20535
  out.push(code >>> 10 & 0x3FF | 0xD800,
20535
- 0xDC00 | code & 0x3FF);
20536
+ 0xDC00 | code & 0x3FF);
20536
20537
  } else {
20537
20538
  out.push(code);
20538
20539
  }
@@ -20559,7 +20560,7 @@ let UPPERCASE_X = CODE("X");
20559
20560
 
20560
20561
  let EXIT = {};
20561
20562
 
20562
- function parse$1(data, callbacks) {
20563
+ function parse$1(data, options) {
20563
20564
  let index = 0;
20564
20565
  let stack = [];
20565
20566
  let object = {
@@ -20577,24 +20578,102 @@ function parse$1(data, callbacks) {
20577
20578
  },
20578
20579
  stack: stack
20579
20580
  };
20581
+ let namespaces = null;
20582
+
20583
+ function nsPushFrame() {
20584
+ namespaces = Object.create(namespaces);
20585
+ }
20586
+
20587
+ function nsPopFrame() {
20588
+ namespaces = Object.getPrototypeOf(namespaces);
20589
+ }
20590
+
20591
+ function findNamespace(ns) {
20592
+ let uri = namespaces?.[ns];
20593
+ if (uri == null && ns !== "") {
20594
+ croak(`Undefined namespace ${ns}`);
20595
+ }
20596
+ return uri;
20597
+ }
20598
+
20599
+ function nsIntern(name, ns) {
20600
+ let url = findNamespace(ns);
20601
+ if (url != null) {
20602
+ let prefix = options.namespaces[url];
20603
+ if (prefix) {
20604
+ name = `${prefix}:${name}`;
20605
+ }
20606
+ }
20607
+ return name;
20608
+ }
20609
+
20610
+ // This does two things if `options.namespaces` was specified: (1) it looks for `xmlns` or `xmlns:foo`
20611
+ // attributes. If they are found, the `namespaces` environment is extended with the new definitions. (2) it
20612
+ // qualifies attribute names and $tag with the prefixes specified by the caller in `options.namespaces`, which
20613
+ // should map URL->prefix.
20614
+ //
20615
+ // For example if an XML would use:
20616
+ //
20617
+ // <stuff:workbook xmlns:stuff="http://schemas.openxmlformats.org/spreadsheetml/2006/main">...</stuff:workbook>
20618
+ //
20619
+ // and caller specified an empty prefix for this URL in `options.namespaces`, then tag name sent to the callbacks
20620
+ // will be just `workbook` (no prefix).
20621
+ function nsMaybeExtend(tagName, attrs) {
20622
+ if (!options.namespaces) {
20623
+ return false;
20624
+ }
20625
+ let newFrame = false;
20626
+ for (let [ attr, value ] of Object.entries(attrs)) {
20627
+ if (attr === "xmlns") {
20628
+ if (!newFrame) {
20629
+ nsPushFrame();
20630
+ newFrame = true;
20631
+ }
20632
+ namespaces[""] = value;
20633
+ } else {
20634
+ let m = /^([^:]+):(.*)$/.exec(attr);
20635
+ if (m) {
20636
+ let attrNS = m[1];
20637
+ if (attrNS === "xmlns") {
20638
+ let newNS = m[2];
20639
+ if (!newFrame) {
20640
+ nsPushFrame();
20641
+ newFrame = true;
20642
+ }
20643
+ namespaces[newNS] = value || null;
20644
+ } else if (/^xml/i.test(attrNS)) ; else {
20645
+ attrs[nsIntern(m[2], attrNS)] = value;
20646
+ }
20647
+ }
20648
+ }
20649
+ }
20650
+ let m = /^([^:]+):(.*)$/.exec(tagName);
20651
+ if (m) {
20652
+ tagName = nsIntern(m[2], m[1]);
20653
+ } else {
20654
+ tagName = nsIntern(tagName, "");
20655
+ }
20656
+ attrs.$tag = tagName;
20657
+ return newFrame;
20658
+ }
20580
20659
 
20581
20660
  function readChar(body) {
20582
20661
  let code = data[index++];
20583
20662
  if (!(code & 0xF0 ^ 0xF0)) {// 4 bytes
20584
20663
  UCS2(body,
20585
- ((code & 0x03) << 18) |
20586
- ((data[index++] & 0x3F) << 12) |
20587
- ((data[index++] & 0x3F) << 6) |
20588
- (data[index++] & 0x3F));
20664
+ ((code & 0x03) << 18) |
20665
+ ((data[index++] & 0x3F) << 12) |
20666
+ ((data[index++] & 0x3F) << 6) |
20667
+ (data[index++] & 0x3F));
20589
20668
  } else if (!(code & 0xE0 ^ 0xE0)) {// 3 bytes
20590
20669
  UCS2(body,
20591
- ((code & 0x0F) << 12) |
20592
- ((data[index++] & 0x3F) << 6) |
20593
- (data[index++] & 0x3F));
20670
+ ((code & 0x0F) << 12) |
20671
+ ((data[index++] & 0x3F) << 6) |
20672
+ (data[index++] & 0x3F));
20594
20673
  } else if (!(code & 0xC0 ^ 0xC0)) {// 2 bytes
20595
20674
  UCS2(body,
20596
- ((code & 0x1F) << 6) |
20597
- (data[index++] & 0x3F));
20675
+ ((code & 0x1F) << 6) |
20676
+ (data[index++] & 0x3F));
20598
20677
  } else {
20599
20678
  body.push(code);
20600
20679
  }
@@ -20647,19 +20726,19 @@ function parse$1(data, callbacks) {
20647
20726
 
20648
20727
  function isHexDigit(code) {
20649
20728
  return (code >= 48 && code <= 57) ||
20650
- ((code |= 32) >= 97 && code <= 102); // a..f or A..F
20729
+ ((code |= 32) >= 97 && code <= 102); // a..f or A..F
20651
20730
  }
20652
20731
 
20653
20732
  function isNameStart(code) {
20654
20733
  return code === 58 || // :
20655
- code === 95 || // _
20656
- ((code |= 32) >= 97 && code <= 122); // a..z or A..Z
20734
+ code === 95 || // _
20735
+ ((code |= 32) >= 97 && code <= 122); // a..z or A..Z
20657
20736
  }
20658
20737
 
20659
20738
  function isName(code) {
20660
20739
  return code === 45 || // -
20661
- isDigit(code) ||
20662
- isNameStart(code);
20740
+ isDigit(code) ||
20741
+ isNameStart(code);
20663
20742
  }
20664
20743
 
20665
20744
  function xmlComment() {
@@ -20681,20 +20760,24 @@ function parse$1(data, callbacks) {
20681
20760
  } else {
20682
20761
  name = xmlName();
20683
20762
  attrs = xmlAttrs(name);
20763
+ let nsframe = nsMaybeExtend(name, attrs);
20684
20764
  stack.push(attrs);
20685
20765
  if (eat(END_SHORT_TAG)) {
20686
- call("enter", name, attrs, true);
20766
+ call("enter", attrs.$tag, attrs, true);
20687
20767
  } else {
20688
20768
  skip(GREATER_THAN);
20689
- call("enter", name, attrs);
20769
+ call("enter", attrs.$tag, attrs);
20690
20770
  xmlContent(name);
20691
20771
  if (name !== xmlName()) {
20692
20772
  croak("Bad closing tag");
20693
20773
  }
20694
- call("leave", name, attrs);
20774
+ call("leave", attrs.$tag, attrs);
20695
20775
  skipWhitespace();
20696
20776
  skip(GREATER_THAN);
20697
20777
  }
20778
+ if (nsframe) {
20779
+ nsPopFrame();
20780
+ }
20698
20781
  stack.pop();
20699
20782
  }
20700
20783
  }
@@ -20789,7 +20872,7 @@ function parse$1(data, callbacks) {
20789
20872
  }
20790
20873
 
20791
20874
  function call(what, thing, arg1, arg2) {
20792
- let f = callbacks && callbacks[what];
20875
+ let f = options && options[what];
20793
20876
  if (f) {
20794
20877
  f.call(object, thing, arg1, arg2);
20795
20878
  }
@@ -20886,8 +20969,32 @@ class Deferred {
20886
20969
  /* eslint-disable complexity */
20887
20970
 
20888
20971
 
20889
- // WARNING: removing the following jshint declaration and turning
20890
- // == into === to make JSHint happy will break functionality.
20972
+ // This is a mapping of namespace URI -> prefix expected by our reader. If a
20973
+ // document uses different prefixes, `parseXML` will rename tags based on this
20974
+ // mapping, so our reader can still make sense of it.
20975
+ //
20976
+ // This list is based on what we have in kendo-ooxml. Not all of them are used
20977
+ // here.
20978
+ let NAMESPACES = {
20979
+ "http://schemas.openxmlformats.org/package/2006/relationships": "",
20980
+ "http://schemas.openxmlformats.org/officeDocument/2006/extended-properties": "",
20981
+ "http://schemas.openxmlformats.org/package/2006/content-types": "",
20982
+ "http://schemas.openxmlformats.org/spreadsheetml/2006/main": "",
20983
+ "http://schemas.openxmlformats.org/package/2006/metadata/core-properties": "cp",
20984
+ "http://purl.org/dc/elements/1.1/": "dc",
20985
+ "http://purl.org/dc/terms/": "dcterms",
20986
+ "http://purl.org/dc/dcmitype/": "dcmitype",
20987
+ "http://www.w3.org/2001/XMLSchema-instance": "xsi",
20988
+ "http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes": "vt",
20989
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships": "r",
20990
+ "http://schemas.openxmlformats.org/markup-compatibility/2006": "mc",
20991
+ "http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac": "x14ac",
20992
+ "urn:schemas-microsoft-com:vml": "v",
20993
+ "urn:schemas-microsoft-com:office:office": "o",
20994
+ "urn:schemas-microsoft-com:office:excel": "x",
20995
+ "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing": "xdr",
20996
+ "http://schemas.openxmlformats.org/drawingml/2006/main": "a",
20997
+ };
20891
20998
 
20892
20999
  let MAP_EXCEL_OPERATOR = {
20893
21000
  // includes only what differs; key is Excel's operator, value
@@ -21135,6 +21242,7 @@ function sheetDimensions(bytes) {
21135
21242
  };
21136
21243
 
21137
21244
  parseXML(bytes, {
21245
+ namespaces: NAMESPACES,
21138
21246
  enter: function(tag, attrs) {
21139
21247
  if (tag === "dimension") {
21140
21248
  ref = calc.parseReference(attrs.ref);
@@ -21916,7 +22024,7 @@ function parse(zip, file, callbacks) {
21916
22024
  let obj = zip.file(file);
21917
22025
  if (obj) {
21918
22026
  obj.async("uint8array").then(bytes => {
21919
- parseXML(bytes, callbacks);
22027
+ parseXML(bytes, { namespaces: NAMESPACES, ...callbacks });
21920
22028
  resolve();
21921
22029
  });
21922
22030
  } else {
package/dist/index.js CHANGED
@@ -2622,6 +2622,7 @@
2622
2622
  }
2623
2623
 
2624
2624
  function defineBuiltinFunction$1(name, isAsync, x, impl) {
2625
+ name = name.toLowerCase();
2625
2626
  FUNCS$1[name] = isAsync
2626
2627
  ? makeAsyncFunction(impl, x.resolve, x.check, x.arrayArgs)
2627
2628
  : makeSyncFunction(impl, x.resolve, x.check, x.arrayArgs);
@@ -20533,7 +20534,7 @@
20533
20534
  if (code > 0xFFFF) {
20534
20535
  code -= 0x10000;
20535
20536
  out.push(code >>> 10 & 0x3FF | 0xD800,
20536
- 0xDC00 | code & 0x3FF);
20537
+ 0xDC00 | code & 0x3FF);
20537
20538
  } else {
20538
20539
  out.push(code);
20539
20540
  }
@@ -20560,7 +20561,7 @@
20560
20561
 
20561
20562
  let EXIT = {};
20562
20563
 
20563
- function parse$1(data, callbacks) {
20564
+ function parse$1(data, options) {
20564
20565
  let index = 0;
20565
20566
  let stack = [];
20566
20567
  let object = {
@@ -20578,24 +20579,102 @@
20578
20579
  },
20579
20580
  stack: stack
20580
20581
  };
20582
+ let namespaces = null;
20583
+
20584
+ function nsPushFrame() {
20585
+ namespaces = Object.create(namespaces);
20586
+ }
20587
+
20588
+ function nsPopFrame() {
20589
+ namespaces = Object.getPrototypeOf(namespaces);
20590
+ }
20591
+
20592
+ function findNamespace(ns) {
20593
+ let uri = namespaces?.[ns];
20594
+ if (uri == null && ns !== "") {
20595
+ croak(`Undefined namespace ${ns}`);
20596
+ }
20597
+ return uri;
20598
+ }
20599
+
20600
+ function nsIntern(name, ns) {
20601
+ let url = findNamespace(ns);
20602
+ if (url != null) {
20603
+ let prefix = options.namespaces[url];
20604
+ if (prefix) {
20605
+ name = `${prefix}:${name}`;
20606
+ }
20607
+ }
20608
+ return name;
20609
+ }
20610
+
20611
+ // This does two things if `options.namespaces` was specified: (1) it looks for `xmlns` or `xmlns:foo`
20612
+ // attributes. If they are found, the `namespaces` environment is extended with the new definitions. (2) it
20613
+ // qualifies attribute names and $tag with the prefixes specified by the caller in `options.namespaces`, which
20614
+ // should map URL->prefix.
20615
+ //
20616
+ // For example if an XML would use:
20617
+ //
20618
+ // <stuff:workbook xmlns:stuff="http://schemas.openxmlformats.org/spreadsheetml/2006/main">...</stuff:workbook>
20619
+ //
20620
+ // and caller specified an empty prefix for this URL in `options.namespaces`, then tag name sent to the callbacks
20621
+ // will be just `workbook` (no prefix).
20622
+ function nsMaybeExtend(tagName, attrs) {
20623
+ if (!options.namespaces) {
20624
+ return false;
20625
+ }
20626
+ let newFrame = false;
20627
+ for (let [ attr, value ] of Object.entries(attrs)) {
20628
+ if (attr === "xmlns") {
20629
+ if (!newFrame) {
20630
+ nsPushFrame();
20631
+ newFrame = true;
20632
+ }
20633
+ namespaces[""] = value;
20634
+ } else {
20635
+ let m = /^([^:]+):(.*)$/.exec(attr);
20636
+ if (m) {
20637
+ let attrNS = m[1];
20638
+ if (attrNS === "xmlns") {
20639
+ let newNS = m[2];
20640
+ if (!newFrame) {
20641
+ nsPushFrame();
20642
+ newFrame = true;
20643
+ }
20644
+ namespaces[newNS] = value || null;
20645
+ } else if (/^xml/i.test(attrNS)) ; else {
20646
+ attrs[nsIntern(m[2], attrNS)] = value;
20647
+ }
20648
+ }
20649
+ }
20650
+ }
20651
+ let m = /^([^:]+):(.*)$/.exec(tagName);
20652
+ if (m) {
20653
+ tagName = nsIntern(m[2], m[1]);
20654
+ } else {
20655
+ tagName = nsIntern(tagName, "");
20656
+ }
20657
+ attrs.$tag = tagName;
20658
+ return newFrame;
20659
+ }
20581
20660
 
20582
20661
  function readChar(body) {
20583
20662
  let code = data[index++];
20584
20663
  if (!(code & 0xF0 ^ 0xF0)) {// 4 bytes
20585
20664
  UCS2(body,
20586
- ((code & 0x03) << 18) |
20587
- ((data[index++] & 0x3F) << 12) |
20588
- ((data[index++] & 0x3F) << 6) |
20589
- (data[index++] & 0x3F));
20665
+ ((code & 0x03) << 18) |
20666
+ ((data[index++] & 0x3F) << 12) |
20667
+ ((data[index++] & 0x3F) << 6) |
20668
+ (data[index++] & 0x3F));
20590
20669
  } else if (!(code & 0xE0 ^ 0xE0)) {// 3 bytes
20591
20670
  UCS2(body,
20592
- ((code & 0x0F) << 12) |
20593
- ((data[index++] & 0x3F) << 6) |
20594
- (data[index++] & 0x3F));
20671
+ ((code & 0x0F) << 12) |
20672
+ ((data[index++] & 0x3F) << 6) |
20673
+ (data[index++] & 0x3F));
20595
20674
  } else if (!(code & 0xC0 ^ 0xC0)) {// 2 bytes
20596
20675
  UCS2(body,
20597
- ((code & 0x1F) << 6) |
20598
- (data[index++] & 0x3F));
20676
+ ((code & 0x1F) << 6) |
20677
+ (data[index++] & 0x3F));
20599
20678
  } else {
20600
20679
  body.push(code);
20601
20680
  }
@@ -20648,19 +20727,19 @@
20648
20727
 
20649
20728
  function isHexDigit(code) {
20650
20729
  return (code >= 48 && code <= 57) ||
20651
- ((code |= 32) >= 97 && code <= 102); // a..f or A..F
20730
+ ((code |= 32) >= 97 && code <= 102); // a..f or A..F
20652
20731
  }
20653
20732
 
20654
20733
  function isNameStart(code) {
20655
20734
  return code === 58 || // :
20656
- code === 95 || // _
20657
- ((code |= 32) >= 97 && code <= 122); // a..z or A..Z
20735
+ code === 95 || // _
20736
+ ((code |= 32) >= 97 && code <= 122); // a..z or A..Z
20658
20737
  }
20659
20738
 
20660
20739
  function isName(code) {
20661
20740
  return code === 45 || // -
20662
- isDigit(code) ||
20663
- isNameStart(code);
20741
+ isDigit(code) ||
20742
+ isNameStart(code);
20664
20743
  }
20665
20744
 
20666
20745
  function xmlComment() {
@@ -20682,20 +20761,24 @@
20682
20761
  } else {
20683
20762
  name = xmlName();
20684
20763
  attrs = xmlAttrs(name);
20764
+ let nsframe = nsMaybeExtend(name, attrs);
20685
20765
  stack.push(attrs);
20686
20766
  if (eat(END_SHORT_TAG)) {
20687
- call("enter", name, attrs, true);
20767
+ call("enter", attrs.$tag, attrs, true);
20688
20768
  } else {
20689
20769
  skip(GREATER_THAN);
20690
- call("enter", name, attrs);
20770
+ call("enter", attrs.$tag, attrs);
20691
20771
  xmlContent(name);
20692
20772
  if (name !== xmlName()) {
20693
20773
  croak("Bad closing tag");
20694
20774
  }
20695
- call("leave", name, attrs);
20775
+ call("leave", attrs.$tag, attrs);
20696
20776
  skipWhitespace();
20697
20777
  skip(GREATER_THAN);
20698
20778
  }
20779
+ if (nsframe) {
20780
+ nsPopFrame();
20781
+ }
20699
20782
  stack.pop();
20700
20783
  }
20701
20784
  }
@@ -20790,7 +20873,7 @@
20790
20873
  }
20791
20874
 
20792
20875
  function call(what, thing, arg1, arg2) {
20793
- let f = callbacks && callbacks[what];
20876
+ let f = options && options[what];
20794
20877
  if (f) {
20795
20878
  f.call(object, thing, arg1, arg2);
20796
20879
  }
@@ -20887,8 +20970,32 @@
20887
20970
  /* eslint-disable complexity */
20888
20971
 
20889
20972
 
20890
- // WARNING: removing the following jshint declaration and turning
20891
- // == into === to make JSHint happy will break functionality.
20973
+ // This is a mapping of namespace URI -> prefix expected by our reader. If a
20974
+ // document uses different prefixes, `parseXML` will rename tags based on this
20975
+ // mapping, so our reader can still make sense of it.
20976
+ //
20977
+ // This list is based on what we have in kendo-ooxml. Not all of them are used
20978
+ // here.
20979
+ let NAMESPACES = {
20980
+ "http://schemas.openxmlformats.org/package/2006/relationships": "",
20981
+ "http://schemas.openxmlformats.org/officeDocument/2006/extended-properties": "",
20982
+ "http://schemas.openxmlformats.org/package/2006/content-types": "",
20983
+ "http://schemas.openxmlformats.org/spreadsheetml/2006/main": "",
20984
+ "http://schemas.openxmlformats.org/package/2006/metadata/core-properties": "cp",
20985
+ "http://purl.org/dc/elements/1.1/": "dc",
20986
+ "http://purl.org/dc/terms/": "dcterms",
20987
+ "http://purl.org/dc/dcmitype/": "dcmitype",
20988
+ "http://www.w3.org/2001/XMLSchema-instance": "xsi",
20989
+ "http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes": "vt",
20990
+ "http://schemas.openxmlformats.org/officeDocument/2006/relationships": "r",
20991
+ "http://schemas.openxmlformats.org/markup-compatibility/2006": "mc",
20992
+ "http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac": "x14ac",
20993
+ "urn:schemas-microsoft-com:vml": "v",
20994
+ "urn:schemas-microsoft-com:office:office": "o",
20995
+ "urn:schemas-microsoft-com:office:excel": "x",
20996
+ "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing": "xdr",
20997
+ "http://schemas.openxmlformats.org/drawingml/2006/main": "a",
20998
+ };
20892
20999
 
20893
21000
  let MAP_EXCEL_OPERATOR = {
20894
21001
  // includes only what differs; key is Excel's operator, value
@@ -21136,6 +21243,7 @@
21136
21243
  };
21137
21244
 
21138
21245
  parseXML(bytes, {
21246
+ namespaces: NAMESPACES,
21139
21247
  enter: function(tag, attrs) {
21140
21248
  if (tag === "dimension") {
21141
21249
  ref = calc.parseReference(attrs.ref);
@@ -21917,7 +22025,7 @@
21917
22025
  let obj = zip.file(file);
21918
22026
  if (obj) {
21919
22027
  obj.async("uint8array").then(bytes => {
21920
- parseXML(bytes, callbacks);
22028
+ parseXML(bytes, { namespaces: NAMESPACES, ...callbacks });
21921
22029
  resolve();
21922
22030
  });
21923
22031
  } else {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@progress/kendo-spreadsheet-common",
3
3
  "description": "Kendo UI platform-independent Spreadsheet library",
4
- "version": "1.2.10-develop.1",
4
+ "version": "1.2.10-develop.3",
5
5
  "keywords": [
6
6
  "Kendo UI"
7
7
  ],