forked from sheetjs/sheetjs
workarounds for webpack 5
This commit is contained in:
parent
fbf43d4b73
commit
d50a7812c4
22
Makefile
22
Makefile
@ -73,18 +73,24 @@ DISTHDR=misc/suppress_export.js
|
||||
.PHONY: dist
|
||||
dist: dist-deps $(TARGET) bower.json ## Prepare JS files for distribution
|
||||
mkdir -p dist
|
||||
<$(TARGET) sed "s/require('....*')/undefined/g" > dist/$(TARGET)
|
||||
cp LICENSE dist/
|
||||
uglifyjs shim.js $(UGLIFYOPTS) -o dist/shim.min.js --preamble "$$(head -n 1 bits/00_header.js)"
|
||||
uglifyjs $(DISTHDR) dist/$(TARGET) $(UGLIFYOPTS) -o dist/$(LIB).min.js --source-map dist/$(LIB).min.map --preamble "$$(head -n 1 bits/00_header.js)"
|
||||
misc/strip_sourcemap.sh dist/$(LIB).min.js
|
||||
uglifyjs $(DISTHDR) $(REQS) dist/$(TARGET) $(UGLIFYOPTS) -o dist/$(LIB).core.min.js --source-map dist/$(LIB).core.min.map --preamble "$$(head -n 1 bits/00_header.js)"
|
||||
@#
|
||||
<$(TARGET) sed "s/require('.*')/undefined/g;s/ process / undefined /g;s/process.versions/({})/g" > dist/$(TARGET)
|
||||
<$(MINITGT) sed "s/require('.*')/undefined/g;s/ process / undefined /g;s/process.versions/({})/g" > dist/$(MINITGT)
|
||||
@# core
|
||||
uglifyjs $(REQS) dist/$(TARGET) $(UGLIFYOPTS) -o dist/$(LIB).core.min.js --source-map dist/$(LIB).core.min.map --preamble "$$(head -n 1 bits/00_header.js)"
|
||||
misc/strip_sourcemap.sh dist/$(LIB).core.min.js
|
||||
@# full
|
||||
uglifyjs $(DISTHDR) $(REQS) $(ADDONS) dist/$(TARGET) $(AUXTARGETS) $(UGLIFYOPTS) -o dist/$(LIB).full.min.js --source-map dist/$(LIB).full.min.map --preamble "$$(head -n 1 bits/00_header.js)"
|
||||
uglifyjs $(DISTHDR) $(MINITGT) $(UGLIFYOPTS) -o dist/$(LIB).mini.min.js --source-map dist/$(LIB).mini.min.map --preamble "$$(head -n 1 bits/00_header.js)"
|
||||
misc/strip_sourcemap.sh dist/$(LIB).full.min.js
|
||||
@# mini
|
||||
uglifyjs dist/$(MINITGT) $(UGLIFYOPTS) -o dist/$(LIB).mini.min.js --source-map dist/$(LIB).mini.min.map --preamble "$$(head -n 1 bits/00_header.js)"
|
||||
misc/strip_sourcemap.sh dist/$(LIB).mini.min.js
|
||||
@# extendscript
|
||||
cat <(head -n 1 bits/00_header.js) shim.js $(DISTHDR) $(REQS) dist/$(TARGET) > dist/$(LIB).extendscript.js
|
||||
@#
|
||||
rm dist/$(TARGET) dist/$(MINITGT)
|
||||
|
||||
.PHONY: dist-deps
|
||||
dist-deps: ## Copy dependencies for distribution
|
||||
@ -94,10 +100,12 @@ dist-deps: ## Copy dependencies for distribution
|
||||
.PHONY: aux
|
||||
aux: $(AUXTARGETS)
|
||||
|
||||
BYTEFILE=dist/xlsx.min.js dist/xlsx.{core,full,mini}.min.js dist/xlsx.extendscript.js
|
||||
BYTEFILEC=dist/xlsx.{full,core,mini}.min.js
|
||||
BYTEFILER=dist/xlsx.extendscript.js
|
||||
.PHONY: bytes
|
||||
bytes: ## Display minified and gzipped file sizes
|
||||
for i in $(BYTEFILE); do printj "%-30s %7d %10d" $$i $$(wc -c < $$i) $$(gzip --best --stdout $$i | wc -c); done
|
||||
@for i in $(BYTEFILEC); do printj "%-30s %7d %10d" $$i $$(wc -c < $$i) $$(gzip --best --stdout $$i | wc -c); done
|
||||
@for i in $(BYTEFILER); do printj "%-30s %7d" $$i $$(wc -c < $$i); done
|
||||
|
||||
.PHONY: graph
|
||||
graph: formats.png legend.png ## Rebuild format conversion graph
|
||||
|
@ -1,38 +0,0 @@
|
||||
var OFFCRYPTO = {};
|
||||
|
||||
var make_offcrypto = function(O, _crypto) {
|
||||
var crypto;
|
||||
if(typeof _crypto !== 'undefined') crypto = _crypto;
|
||||
else if(typeof require !== 'undefined') {
|
||||
try { crypto = require('crypto'); }
|
||||
catch(e) { crypto = null; }
|
||||
}
|
||||
|
||||
O.rc4 = function(key, data) {
|
||||
var S = new Array(256);
|
||||
var c = 0, i = 0, j = 0, t = 0;
|
||||
for(i = 0; i != 256; ++i) S[i] = i;
|
||||
for(i = 0; i != 256; ++i) {
|
||||
j = (j + S[i] + (key[i%key.length]).charCodeAt(0))&255;
|
||||
t = S[i]; S[i] = S[j]; S[j] = t;
|
||||
}
|
||||
// $FlowIgnore
|
||||
i = j = 0; var out = new_raw_buf(data.length);
|
||||
for(c = 0; c != data.length; ++c) {
|
||||
i = (i + 1)&255;
|
||||
j = (j + S[i])%256;
|
||||
t = S[i]; S[i] = S[j]; S[j] = t;
|
||||
out[c] = (data[c] ^ S[(S[i]+S[j])&255]);
|
||||
}
|
||||
return out;
|
||||
};
|
||||
|
||||
O.md5 = function(hex) {
|
||||
if(!crypto) throw new Error("Unsupported crypto");
|
||||
return crypto.createHash('md5').update(hex).digest('hex');
|
||||
};
|
||||
};
|
||||
/*:: declare var crypto:any; */
|
||||
/*global crypto:true */
|
||||
make_offcrypto(OFFCRYPTO, typeof crypto !== "undefined" ? crypto : undefined);
|
||||
|
@ -43,6 +43,7 @@ function read_plaintext_raw(data/*:RawData*/, o/*:ParseOpts*/)/*:Workbook*/ {
|
||||
default: throw new Error("Unrecognized type " + o.type);
|
||||
}
|
||||
if(bytes[0] == 0xEF && bytes[1] == 0xBB && bytes[2] == 0xBF) str = utf8read(str);
|
||||
o.type = "binary";
|
||||
return read_plaintext(str, o);
|
||||
}
|
||||
|
||||
|
BIN
dist/xlsx.full.min.js.zip
generated
vendored
BIN
dist/xlsx.full.min.js.zip
generated
vendored
Binary file not shown.
23847
dist/xlsx.js
generated
vendored
23847
dist/xlsx.js
generated
vendored
File diff suppressed because it is too large
Load Diff
16
dist/xlsx.min.js
generated
vendored
16
dist/xlsx.min.js
generated
vendored
File diff suppressed because one or more lines are too long
1
dist/xlsx.min.map
generated
vendored
1
dist/xlsx.min.map
generated
vendored
File diff suppressed because one or more lines are too long
16
dist/xlsx.mini.min.js
generated
vendored
16
dist/xlsx.mini.min.js
generated
vendored
File diff suppressed because one or more lines are too long
2
dist/xlsx.mini.min.map
generated
vendored
2
dist/xlsx.mini.min.map
generated
vendored
File diff suppressed because one or more lines are too long
@ -34,10 +34,12 @@ For example, `unpkg` makes the latest version available at:
|
||||
|
||||
The complete single-file version is generated at `dist/xlsx.full.min.js`
|
||||
|
||||
`dist/xlsx.core.min.js` omits codepage library (no support for XLS encodings)
|
||||
|
||||
A slimmer build is generated at `dist/xlsx.mini.min.js`. Compared to full build:
|
||||
- codepage library skipped (no support for XLS encodings)
|
||||
- XLSX compression option not currently available
|
||||
- no support for XLSB / XLS / Lotus 1-2-3 / SpreadsheetML 2003
|
||||
- no support for XLSB / XLS / Lotus 1-2-3 / SpreadsheetML 2003 / Numbers
|
||||
- node stream utils removed
|
||||
|
||||
</details>
|
||||
|
7
mini.lst
7
mini.lst
@ -1,6 +1,6 @@
|
||||
bits/00_header.js
|
||||
bits/01_version.js
|
||||
bits/02_codepage.js
|
||||
misc/02_cpmini.js
|
||||
bits/03_consts.js
|
||||
bits/04_base64.js
|
||||
bits/05_buf.js
|
||||
@ -19,6 +19,7 @@ bits/27_csfutils.js
|
||||
bits/29_xlsenum.js
|
||||
bits/30_ctype.js
|
||||
bits/31_rels.js
|
||||
bits/32_odmanrdf.js
|
||||
bits/33_coreprops.js
|
||||
bits/34_extprops.js
|
||||
bits/35_custprops.js
|
||||
@ -35,17 +36,17 @@ bits/57_cmntxml.js
|
||||
bits/59_vba.js
|
||||
bits/60_macrovba.js
|
||||
bits/61_fcommon.js
|
||||
bits/65_fods.js
|
||||
bits/66_wscommon.js
|
||||
bits/67_wsxml.js
|
||||
bits/69_chartxml.js
|
||||
bits/70_csheet.js
|
||||
misc/70_csheet.js
|
||||
bits/71_wbcommon.js
|
||||
bits/72_wbxml.js
|
||||
bits/74_xmlbin.js
|
||||
bits/79_html.js
|
||||
bits/80_parseods.js
|
||||
bits/81_writeods.js
|
||||
bits/83_numbers.js
|
||||
bits/84_defaults.js
|
||||
bits/85_parsezip.js
|
||||
bits/86_writezip.js
|
||||
|
57
misc/02_cpmini.js
Normal file
57
misc/02_cpmini.js
Normal file
@ -0,0 +1,57 @@
|
||||
var current_codepage = 1200, current_ansi = 1252;
|
||||
|
||||
var VALID_ANSI = [ 874, 932, 936, 949, 950, 10000 ];
|
||||
for(var i = 0; i <= 8; ++i) VALID_ANSI.push(1250 + i);
|
||||
/* ECMA-376 Part I 18.4.1 charset to codepage mapping */
|
||||
var CS2CP = ({
|
||||
/*::[*/0/*::]*/: 1252, /* ANSI */
|
||||
/*::[*/1/*::]*/: 65001, /* DEFAULT */
|
||||
/*::[*/2/*::]*/: 65001, /* SYMBOL */
|
||||
/*::[*/77/*::]*/: 10000, /* MAC */
|
||||
/*::[*/128/*::]*/: 932, /* SHIFTJIS */
|
||||
/*::[*/129/*::]*/: 949, /* HANGUL */
|
||||
/*::[*/130/*::]*/: 1361, /* JOHAB */
|
||||
/*::[*/134/*::]*/: 936, /* GB2312 */
|
||||
/*::[*/136/*::]*/: 950, /* CHINESEBIG5 */
|
||||
/*::[*/161/*::]*/: 1253, /* GREEK */
|
||||
/*::[*/162/*::]*/: 1254, /* TURKISH */
|
||||
/*::[*/163/*::]*/: 1258, /* VIETNAMESE */
|
||||
/*::[*/177/*::]*/: 1255, /* HEBREW */
|
||||
/*::[*/178/*::]*/: 1256, /* ARABIC */
|
||||
/*::[*/186/*::]*/: 1257, /* BALTIC */
|
||||
/*::[*/204/*::]*/: 1251, /* RUSSIAN */
|
||||
/*::[*/222/*::]*/: 874, /* THAI */
|
||||
/*::[*/238/*::]*/: 1250, /* EASTEUROPE */
|
||||
/*::[*/255/*::]*/: 1252, /* OEM */
|
||||
/*::[*/69/*::]*/: 6969 /* MISC */
|
||||
}/*:any*/);
|
||||
|
||||
var set_ansi = function(cp/*:number*/) { if(VALID_ANSI.indexOf(cp) == -1) return; current_ansi = CS2CP[0] = cp; };
|
||||
function reset_ansi() { set_ansi(1252); }
|
||||
|
||||
var set_cp = function(cp/*:number*/) { current_codepage = cp; set_ansi(cp); };
|
||||
function reset_cp() { set_cp(1200); reset_ansi(); }
|
||||
|
||||
function char_codes(data/*:string*/)/*:Array<number>*/ { var o/*:Array<number>*/ = []; for(var i = 0, len = data.length; i < len; ++i) o[i] = data.charCodeAt(i); return o; }
|
||||
|
||||
function utf16leread(data/*:string*/)/*:string*/ {
|
||||
var o/*:Array<string>*/ = [];
|
||||
for(var i = 0; i < (data.length>>1); ++i) o[i] = String.fromCharCode(data.charCodeAt(2*i) + (data.charCodeAt(2*i+1)<<8));
|
||||
return o.join("");
|
||||
}
|
||||
function utf16beread(data/*:string*/)/*:string*/ {
|
||||
var o/*:Array<string>*/ = [];
|
||||
for(var i = 0; i < (data.length>>1); ++i) o[i] = String.fromCharCode(data.charCodeAt(2*i+1) + (data.charCodeAt(2*i)<<8));
|
||||
return o.join("");
|
||||
}
|
||||
|
||||
var debom = function(data/*:string*/)/*:string*/ {
|
||||
var c1 = data.charCodeAt(0), c2 = data.charCodeAt(1);
|
||||
if(c1 == 0xFF && c2 == 0xFE) return utf16leread(data.slice(2));
|
||||
if(c1 == 0xFE && c2 == 0xFF) return utf16beread(data.slice(2));
|
||||
if(c1 == 0xFEFF) return data.slice(1);
|
||||
return data;
|
||||
};
|
||||
|
||||
var _getchar = function _gc1(x/*:number*/)/*:string*/ { return String.fromCharCode(x); };
|
||||
var _getansi = function _ga1(x/*:number*/)/*:string*/ { return String.fromCharCode(x); };
|
32
misc/70_csheet.js
Normal file
32
misc/70_csheet.js
Normal file
@ -0,0 +1,32 @@
|
||||
RELS.CS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartsheet";
|
||||
|
||||
var CS_XML_ROOT = writextag('chartsheet', null, {
|
||||
'xmlns': XMLNS.main[0],
|
||||
'xmlns:r': XMLNS.r
|
||||
});
|
||||
|
||||
/* 18.3 Worksheets also covers Chartsheets */
|
||||
function parse_cs_xml(data/*:?string*/, opts, idx/*:number*/, rels, wb/*::, themes, styles*/)/*:Worksheet*/ {
|
||||
if(!data) return data;
|
||||
/* 18.3.1.12 chartsheet CT_ChartSheet */
|
||||
if(!rels) rels = {'!id':{}};
|
||||
var s = ({'!type':"chart", '!drawel':null, '!rel':""}/*:any*/);
|
||||
var m;
|
||||
|
||||
/* 18.3.1.83 sheetPr CT_ChartsheetPr */
|
||||
var sheetPr = data.match(sheetprregex);
|
||||
if(sheetPr) parse_ws_xml_sheetpr(sheetPr[0], s, wb, idx);
|
||||
|
||||
/* 18.3.1.36 drawing CT_Drawing */
|
||||
if((m = data.match(/drawing r:id="(.*?)"/))) s['!rel'] = m[1];
|
||||
|
||||
if(rels['!id'][s['!rel']]) s['!drawel'] = rels['!id'][s['!rel']];
|
||||
return s;
|
||||
}
|
||||
function write_cs_xml(idx/*:number*/, opts, wb/*:Workbook*/, rels)/*:string*/ {
|
||||
var o = [XML_HEADER, CS_XML_ROOT];
|
||||
o[o.length] = writextag("drawing", null, {"r:id": "rId1"});
|
||||
add_rels(rels, -1, "../drawings/drawing" + (idx+1) + ".xml", RELS.DRAW);
|
||||
if(o.length>2) { o[o.length] = ('</chartsheet>'); o[1]=o[1].replace("/>",">"); }
|
||||
return o.join("");
|
||||
}
|
Loading…
Reference in New Issue
Block a user