From 5dd16ae6405e84156789e9288d3aa4e40a6158b8 Mon Sep 17 00:00:00 2001 From: SheetJS Date: Wed, 28 Feb 2018 05:41:49 -0500 Subject: [PATCH] version bump 0.12.3: cleanup - PtgList and old Ptg record support - fleshed out ftab constants from macrosheet support - reimplemented / fixed / removed shim functions - demo refresh --- README.md | 8 +- bits/01_version.js | 2 +- bits/20_jsutils.js | 6 +- bits/21_ziputils.js | 6 + bits/62_fxls.js | 91 +++- bits/64_ftab.js | 13 + bits/80_parseods.js | 1 + bits/85_parsezip.js | 3 +- bits/86_writezip.js | 8 +- bits/90_utils.js | 2 +- demos/altjs/Makefile | 2 +- demos/rollup/Makefile | 2 +- demos/rollup/rollup.config.js | 7 +- demos/rollup/rollup.config.node.js | 10 +- demos/rollup/rollup.config.worker.js | 7 +- dist/shim.min.js | 2 +- dist/xlsx.core.min.js | 28 +- dist/xlsx.core.min.map | 2 +- dist/xlsx.extendscript.js | 608 ++++++++++----------------- dist/xlsx.full.min.js | 32 +- dist/xlsx.full.min.map | 2 +- dist/xlsx.js | 132 +++++- dist/xlsx.min.js | 24 +- dist/xlsx.min.map | 2 +- docbits/12_optional.md | 6 +- docbits/82_util.md | 2 +- misc/docs/README.md | 8 +- package.json | 2 +- shim.js | 476 ++++++--------------- test.js | 10 +- tests.lst | 2 +- tests/base64.js | 67 +++ tests/core.js | 10 +- tests/fs_.js | 6 +- tests/index.html | 1 + tests/sauce.html | 1 + xlsx.flow.js | 132 +++++- xlsx.js | 132 +++++- 38 files changed, 963 insertions(+), 892 deletions(-) create mode 100644 tests/base64.js diff --git a/README.md b/README.md index 31e9d26..16199df 100644 --- a/README.md +++ b/README.md @@ -257,11 +257,15 @@ To use the shim, add the shim before the script tag that loads `xlsx.js`: ```html - + ``` +The script also includes `IE_LoadFile` and `IE_SaveFile` for loading and saving +files in Internet Explorer versions 6-9. The `xlsx.extendscript.js` script +bundles the shim in a format suitable for Photoshop and other Adobe products. + ## Philosophy
@@ -2050,7 +2054,7 @@ For the example sheet: ```js > var o = XLSX.utils.sheet_to_formulae(ws); -> o.filter(function(v, i) { return i % 5 === 0; }); +> [o[0], o[5], o[10], o[15], o[20]]; [ 'A1=\'S', 'F1=\'J', 'D2=4', 'B3=3', 'G3=8' ] ```
diff --git a/bits/01_version.js b/bits/01_version.js index b00391e..db2f6d3 100644 --- a/bits/01_version.js +++ b/bits/01_version.js @@ -1 +1 @@ -XLSX.version = '0.12.2'; +XLSX.version = '0.12.3'; diff --git a/bits/20_jsutils.js b/bits/20_jsutils.js index edd389d..0e6474a 100644 --- a/bits/20_jsutils.js +++ b/bits/20_jsutils.js @@ -1,4 +1,8 @@ -function keys(o/*:any*/)/*:Array*/ { return Object.keys(o); } +function keys(o/*:any*/)/*:Array*/ { + var ks = Object.keys(o), o2 = []; + for(var i = 0; i < ks.length; ++i) if(o.hasOwnProperty(ks[i])) o2.push(ks[i]); + return o2; +} function evert_key(obj/*:any*/, key/*:string*/)/*:EvertType*/ { var o = ([]/*:any*/), K = keys(obj); diff --git a/bits/21_ziputils.js b/bits/21_ziputils.js index 6a2b9e4..3f7c06f 100644 --- a/bits/21_ziputils.js +++ b/bits/21_ziputils.js @@ -51,6 +51,12 @@ function getzipstr(zip, file/*:string*/, safe/*:?boolean*/)/*:?string*/ { try { return getzipstr(zip, file); } catch(e) { return null; } } +function zipentries(zip) { + var k = keys(zip.files), o = []; + for(var i = 0; i < k.length; ++i) if(k[i].slice(-1) != '/') o.push(k[i]); + return o.sort(); +} + var jszip; /*:: declare var JSZip:any; */ /*global JSZip:true */ diff --git a/bits/62_fxls.js b/bits/62_fxls.js index a9f926f..c70f622 100644 --- a/bits/62_fxls.js +++ b/bits/62_fxls.js @@ -100,7 +100,7 @@ function parse_PtgArea3d(blob, length, opts) { /* [MS-XLS] 2.5.198.29 ; [MS-XLSB] 2.5.97.20 */ function parse_PtgAreaErr(blob, length, opts) { var type = (blob[blob.l++] & 0x60) >> 5; - blob.l += opts && opts.biff > 8 ? 12 : 8; + blob.l += opts && (opts.biff > 8) ? 12 : (opts.biff < 8 ? 6 : 8); return [type]; } /* [MS-XLS] 2.5.198.30 ; [MS-XLSB] 2.5.97.21 */ @@ -232,8 +232,8 @@ function parse_PtgFunc(blob, length, opts) { } /* [MS-XLS] 2.5.198.63 ; [MS-XLSB] 2.5.97.46 TODO */ function parse_PtgFuncVar(blob, length, opts) { - blob.l++; - var cparams = blob.read_shift(1), tab = opts && opts.biff <= 3 ? [0, blob.read_shift(1)]: parsetab(blob); + var type = blob[blob.l++]; + var cparams = blob.read_shift(1), tab = opts && opts.biff <= 3 ? [(type == 0x58 ? -1 : 0), blob.read_shift(1)]: parsetab(blob); return [cparams, (tab[0] === 0 ? Ftab : Cetab)[tab[1]]]; } @@ -430,12 +430,35 @@ var parse_PtgElfRw = parse_PtgElfLoc; /* [MS-XLS] 2.5.198.55 */ var parse_PtgElfRwV = parse_PtgElfLoc; -/* [MS-XLSB] 2.5.97.52 */ +/* [MS-XLSB] 2.5.97.52 TODO */ +var PtgListRT = [ + "Data", + "All", + "Headers", + "??", + "?Data2", + "??", + "?DataHeaders", + "??", + "Totals", + "??", + "??", + "??", + "?DataTotals", + "??", + "??", + "??", + "?Current" +]; function parse_PtgList(blob/*::, length, opts*/) { blob.l += 2; var ixti = blob.read_shift(2); - blob.l += 10; - return {ixti: ixti}; + var flags = blob.read_shift(2); + var idx = blob.read_shift(4); + var c = blob.read_shift(2); + var C = blob.read_shift(2); + var rt = PtgListRT[(flags >> 2) & 0x1F]; + return {ixti: ixti, coltype:(flags&0x3), rt:rt, idx:idx, c:c, C:C}; } /* [MS-XLS] 2.5.198.91 ; [MS-XLSB] 2.5.97.76 */ function parse_PtgSxName(blob/*::, length, opts*/) { @@ -443,6 +466,32 @@ function parse_PtgSxName(blob/*::, length, opts*/) { return [blob.read_shift(4)]; } +/* [XLS] old spec */ +function parse_PtgSheet(blob, length, opts) { + blob.l += 5; + blob.l += 2; + blob.l += (opts.biff == 2 ? 1 : 4); + return ["PTGSHEET"]; +} +function parse_PtgEndSheet(blob, length, opts) { + blob.l += (opts.biff == 2 ? 4 : 5); + return ["PTGENDSHEET"]; +} +function parse_PtgMemAreaN(blob/*::, length, opts*/) { + var type = (blob.read_shift(1) >>> 5) & 0x03; + var cce = blob.read_shift(2); + return [type, cce]; +} +function parse_PtgMemNoMemN(blob/*::, length, opts*/) { + var type = (blob.read_shift(1) >>> 5) & 0x03; + var cce = blob.read_shift(2); + return [type, cce]; +} +function parse_PtgAttrNoop(blob/*::, length, opts*/) { + blob.l += 4; + return [0, 0]; +} + /* [MS-XLS] 2.5.198.25 ; [MS-XLSB] 2.5.97.16 */ var PtgTypes = { /*::[*/0x01/*::]*/: { n:'PtgExp', f:parse_PtgExp }, @@ -468,6 +517,8 @@ var PtgTypes = { /*::[*/0x15/*::]*/: { n:'PtgParen', f:parseread1 }, /*::[*/0x16/*::]*/: { n:'PtgMissArg', f:parseread1 }, /*::[*/0x17/*::]*/: { n:'PtgStr', f:parse_PtgStr }, + /*::[*/0x1A/*::]*/: { n:'PtgSheet', f:parse_PtgSheet }, + /*::[*/0x1B/*::]*/: { n:'PtgEndSheet', f:parse_PtgEndSheet }, /*::[*/0x1C/*::]*/: { n:'PtgErr', f:parse_PtgErr }, /*::[*/0x1D/*::]*/: { n:'PtgBool', f:parse_PtgBool }, /*::[*/0x1E/*::]*/: { n:'PtgInt', f:parse_PtgInt }, @@ -486,6 +537,8 @@ var PtgTypes = { /*::[*/0x2B/*::]*/: { n:'PtgAreaErr', f:parse_PtgAreaErr }, /*::[*/0x2C/*::]*/: { n:'PtgRefN', f:parse_PtgRefN }, /*::[*/0x2D/*::]*/: { n:'PtgAreaN', f:parse_PtgAreaN }, + /*::[*/0x2E/*::]*/: { n:'PtgMemAreaN', f:parse_PtgMemAreaN }, + /*::[*/0x2F/*::]*/: { n:'PtgMemNoMemN', f:parse_PtgMemNoMemN }, /*::[*/0x39/*::]*/: { n:'PtgNameX', f:parse_PtgNameX }, /*::[*/0x3A/*::]*/: { n:'PtgRef3d', f:parse_PtgRef3d }, /*::[*/0x3B/*::]*/: { n:'PtgArea3d', f:parse_PtgArea3d }, @@ -509,6 +562,9 @@ var PtgDupes = { /*::[*/0x4B/*::]*/: 0x2B, /*::[*/0x6B/*::]*/: 0x2B, /*::[*/0x4C/*::]*/: 0x2C, /*::[*/0x6C/*::]*/: 0x2C, /*::[*/0x4D/*::]*/: 0x2D, /*::[*/0x6D/*::]*/: 0x2D, + /*::[*/0x4E/*::]*/: 0x2E, /*::[*/0x6E/*::]*/: 0x2E, + /*::[*/0x4F/*::]*/: 0x2F, /*::[*/0x6F/*::]*/: 0x2F, + /*::[*/0x58/*::]*/: 0x22, /*::[*/0x78/*::]*/: 0x22, /*::[*/0x59/*::]*/: 0x39, /*::[*/0x79/*::]*/: 0x39, /*::[*/0x5A/*::]*/: 0x3A, /*::[*/0x7A/*::]*/: 0x3A, /*::[*/0x5B/*::]*/: 0x3B, /*::[*/0x7B/*::]*/: 0x3B, @@ -533,6 +589,7 @@ var Ptg18 = { /*::[*/0xFF/*::]*/: {} }; var Ptg19 = { + /*::[*/0x00/*::]*/: { n:'PtgAttrNoop', f:parse_PtgAttrNoop }, /*::[*/0x01/*::]*/: { n:'PtgAttrSemi', f:parse_PtgAttrSemi }, /*::[*/0x02/*::]*/: { n:'PtgAttrIf', f:parse_PtgAttrIf }, /*::[*/0x04/*::]*/: { n:'PtgAttrChoose', f:parse_PtgAttrChoose }, @@ -589,10 +646,7 @@ function parse_Rgce(blob, length, opts) { length = target - blob.l; id = blob[blob.l]; R = PtgTypes[id]; - if(id === 0x18 || id === 0x19) { - id = blob[blob.l + 1]; - R = (id === 0x18 ? Ptg18 : Ptg19)[id]; - } + if(id === 0x18 || id === 0x19) R = (id === 0x18 ? Ptg18 : Ptg19)[blob[blob.l + 1]]; if(!R || !R.f) { /*ptgs.push*/(parsenoop(blob, length)); } // $FlowIgnore else { ptgs.push([R.n, R.f(blob, length, opts)]); } @@ -919,6 +973,18 @@ function stringify_formula(formula/*Array*/, range, cell/*:any*/, supbooks, case 'PtgAreaErr3d': /* [MS-XLS] 2.5.198.30 */ stack.push("#REF!"); break; + case 'PtgList': /* [MS-XLSB] 2.5.97.52 */ + // $FlowIgnore + stack.push("Table" + f[1].idx + "[#" + f[1].rt + "]"); + break; + + case 'PtgMemAreaN': + case 'PtgMemNoMemN': + case 'PtgAttrNoop': + case 'PtgSheet': + case 'PtgEndSheet': + break; + case 'PtgMemFunc': /* [MS-XLS] 2.5.198.72 TODO */ break; case 'PtgMemNoMem': /* [MS-XLS] 2.5.198.73 TODO */ @@ -938,13 +1004,10 @@ function stringify_formula(formula/*Array*/, range, cell/*:any*/, supbooks, case 'PtgSxName': /* [MS-XLS] 2.5.198.91 TODO -- find a test case */ throw new Error('Unrecognized Formula Token: ' + String(f)); - case 'PtgList': /* [MS-XLSB] 2.5.97.52 TODO -- find a test case */ - throw new Error('Unrecognized Formula Token: ' + String(f)); - default: throw new Error('Unrecognized Formula Token: ' + String(f)); } var PtgNonDisp = ['PtgAttrSpace', 'PtgAttrSpaceSemi', 'PtgAttrGoto']; - if(last_sp >= 0 && PtgNonDisp.indexOf(formula[0][ff][0]) == -1) { + if(opts.biff != 3) if(last_sp >= 0 && PtgNonDisp.indexOf(formula[0][ff][0]) == -1) { f = formula[0][last_sp]; var _left = true; switch(f[1][0]) { diff --git a/bits/64_ftab.js b/bits/64_ftab.js index ff0cb3d..bb3fa0b 100644 --- a/bits/64_ftab.js +++ b/bits/64_ftab.js @@ -885,6 +885,7 @@ var Ftab = { var FtabArgc = { /*::[*/0x0002/*::]*/: 1, /* ISNA */ /*::[*/0x0003/*::]*/: 1, /* ISERROR */ + /*::[*/0x000A/*::]*/: 0, /* NA */ /*::[*/0x000F/*::]*/: 1, /* SIN */ /*::[*/0x0010/*::]*/: 1, /* COS */ /*::[*/0x0011/*::]*/: 1, /* TAN */ @@ -902,6 +903,8 @@ var FtabArgc = { /*::[*/0x001F/*::]*/: 3, /* MID */ /*::[*/0x0020/*::]*/: 1, /* LEN */ /*::[*/0x0021/*::]*/: 1, /* VALUE */ + /*::[*/0x0022/*::]*/: 0, /* TRUE */ + /*::[*/0x0023/*::]*/: 0, /* FALSE */ /*::[*/0x0026/*::]*/: 1, /* NOT */ /*::[*/0x0027/*::]*/: 2, /* MOD */ /*::[*/0x0028/*::]*/: 3, /* DCOUNT */ @@ -914,6 +917,7 @@ var FtabArgc = { /*::[*/0x0030/*::]*/: 2, /* TEXT */ /*::[*/0x0035/*::]*/: 1, /* GOTO */ /*::[*/0x003D/*::]*/: 3, /* MIRR */ + /*::[*/0x003F/*::]*/: 0, /* RAND */ /*::[*/0x0041/*::]*/: 3, /* DATE */ /*::[*/0x0042/*::]*/: 3, /* TIME */ /*::[*/0x0043/*::]*/: 1, /* DAY */ @@ -923,6 +927,7 @@ var FtabArgc = { /*::[*/0x0047/*::]*/: 1, /* HOUR */ /*::[*/0x0048/*::]*/: 1, /* MINUTE */ /*::[*/0x0049/*::]*/: 1, /* SECOND */ + /*::[*/0x004A/*::]*/: 0, /* NOW */ /*::[*/0x004B/*::]*/: 1, /* AREAS */ /*::[*/0x004C/*::]*/: 1, /* ROWS */ /*::[*/0x004D/*::]*/: 1, /* COLUMNS */ @@ -931,13 +936,18 @@ var FtabArgc = { /*::[*/0x0053/*::]*/: 1, /* TRANSPOSE */ /*::[*/0x0055/*::]*/: 0, /* STEP */ /*::[*/0x0056/*::]*/: 1, /* TYPE */ + /*::[*/0x0059/*::]*/: 0, /* CALLER */ /*::[*/0x005A/*::]*/: 1, /* DEREF */ + /*::[*/0x005E/*::]*/: 0, /* ACTIVE.CELL */ + /*::[*/0x005F/*::]*/: 0, /* SELECTION */ /*::[*/0x0061/*::]*/: 2, /* ATAN2 */ /*::[*/0x0062/*::]*/: 1, /* ASIN */ /*::[*/0x0063/*::]*/: 1, /* ACOS */ /*::[*/0x0065/*::]*/: 3, /* HLOOKUP */ /*::[*/0x0066/*::]*/: 3, /* VLOOKUP */ /*::[*/0x0069/*::]*/: 1, /* ISREF */ + /*::[*/0x006A/*::]*/: 1, /* GET.FORMULA */ + /*::[*/0x006C/*::]*/: 2, /* SET.VALUE */ /*::[*/0x006F/*::]*/: 1, /* CHAR */ /*::[*/0x0070/*::]*/: 1, /* LOWER */ /*::[*/0x0071/*::]*/: 1, /* UPPER */ @@ -963,6 +973,7 @@ var FtabArgc = { /*::[*/0x008E/*::]*/: 3, /* SLN */ /*::[*/0x008F/*::]*/: 4, /* SYD */ /*::[*/0x0090/*::]*/: 4, /* DDB */ + /*::[*/0x00A1/*::]*/: 1, /* DIALOG.BOX */ /*::[*/0x00A2/*::]*/: 1, /* CLEAN */ /*::[*/0x00A3/*::]*/: 1, /* MDETERM */ /*::[*/0x00A4/*::]*/: 1, /* MINVERSE */ @@ -974,6 +985,7 @@ var FtabArgc = { /*::[*/0x00B2/*::]*/: 2, /* EXECUTE */ /*::[*/0x00B3/*::]*/: 1, /* TERMINATE */ /*::[*/0x00B8/*::]*/: 1, /* FACT */ + /*::[*/0x00BA/*::]*/: 1, /* GET.WORKSPACE */ /*::[*/0x00BD/*::]*/: 3, /* DPRODUCT */ /*::[*/0x00BE/*::]*/: 1, /* ISNONTEXT */ /*::[*/0x00C3/*::]*/: 3, /* DSTDEVP */ @@ -989,6 +1001,7 @@ var FtabArgc = { /*::[*/0x00D5/*::]*/: 2, /* ROUNDDOWN */ /*::[*/0x00D6/*::]*/: 1, /* ASC */ /*::[*/0x00D7/*::]*/: 1, /* DBCS */ + /*::[*/0x00E1/*::]*/: 0, /* END.IF */ /*::[*/0x00E5/*::]*/: 1, /* SINH */ /*::[*/0x00E6/*::]*/: 1, /* COSH */ /*::[*/0x00E7/*::]*/: 1, /* TANH */ diff --git a/bits/80_parseods.js b/bits/80_parseods.js index b41b71a..6a51acc 100644 --- a/bits/80_parseods.js +++ b/bits/80_parseods.js @@ -65,6 +65,7 @@ var parse_content_xml = (function() { if(merges.length) ws['!merges'] = merges; if(rowinfo.length) ws["!rows"] = rowinfo; sheetag.name = utf8read(sheetag['名称'] || sheetag.name); + if(typeof JSON !== 'undefined') JSON.stringify(sheetag); SheetNames.push(sheetag.name); Sheets[sheetag.name] = ws; intable = false; diff --git a/bits/85_parsezip.js b/bits/85_parsezip.js index 686e8ed..b260d7c 100644 --- a/bits/85_parsezip.js +++ b/bits/85_parsezip.js @@ -36,7 +36,6 @@ function safe_parse_sheet(zip, path/*:string*/, relsPath/*:string*/, sheet, idx/ } catch(e) { if(opts.WTF) throw e; } } -var nodirs = function nodirs(x/*:string*/)/*:boolean*/{return x.slice(-1) != '/';}; function strip_front_slash(x/*:string*/)/*:string*/ { return x.charAt(0) == '/' ? x.slice(1) : x; } function parse_zip(zip/*:ZIP*/, opts/*:?ParseOpts*/)/*:Workbook*/ { @@ -51,7 +50,7 @@ function parse_zip(zip/*:ZIP*/, opts/*:?ParseOpts*/)/*:Workbook*/ { /* Numbers */ if(safegetzipfile(zip, 'Index/Document.iwa')) throw new Error('Unsupported NUMBERS file'); - var entries = keys(zip.files).filter(nodirs).sort(); + var entries = zipentries(zip); var dir = parse_ct((getzipstr(zip, '[Content_Types].xml')/*:?any*/)); var xlsb = false; var sheets, binname; diff --git a/bits/86_writezip.js b/bits/86_writezip.js index 65e58ef..2489c34 100644 --- a/bits/86_writezip.js +++ b/bits/86_writezip.js @@ -34,8 +34,12 @@ function write_zip(wb/*:Workbook*/, opts/*:WriteOpts*/)/*:ZIP*/ { f = "docProps/app.xml"; if(wb.Props && wb.Props.SheetNames){/* empty */} else if(!wb.Workbook || !wb.Workbook.Sheets) wb.Props.SheetNames = wb.SheetNames; - // $FlowIgnore - else wb.Props.SheetNames = wb.SheetNames.map(function(x,i) { return [(wb.Workbook.Sheets[i]||{}).Hidden != 2, x];}).filter(function(x) { return x[0]; }).map(function(x) { return x[1]; }); + else { + var _sn = []; + for(var _i = 0; _i < wb.SheetNames.length; ++_i) + if((wb.Workbook.Sheets[_i]||{}).Hidden != 2) _sn.push(wb.SheetNames[_i]); + wb.Props.SheetNames = _sn; + } wb.Props.Worksheets = wb.Props.SheetNames.length; zip.file(f, write_ext_props(wb.Props, opts)); ct.extprops.push(f); diff --git a/bits/90_utils.js b/bits/90_utils.js index 77db4a5..43f63b8 100644 --- a/bits/90_utils.js +++ b/bits/90_utils.js @@ -191,7 +191,7 @@ function sheet_add_json(_ws/*:?Worksheet*/, js/*:Array*/, opts)/*:Worksheet var hdr/*:Array*/ = o.header || [], C = 0; js.forEach(function (JS, R/*:number*/) { - keys(JS).filter(function(x) { return JS.hasOwnProperty(x); }).forEach(function(k) { + keys(JS).forEach(function(k) { if((C=hdr.indexOf(k)) == -1) hdr[C=hdr.length] = k; var v = JS[k]; var t = 'z'; diff --git a/demos/altjs/Makefile b/demos/altjs/Makefile index 21a607c..49047c4 100644 --- a/demos/altjs/Makefile +++ b/demos/altjs/Makefile @@ -40,7 +40,7 @@ SheetJSRhino.class: $(RHDEPS) javac -cp .:SheetJS.jar:rhino.jar SheetJSRhino.java rhino.jar: - if [ ! -e rhino ]; then git clone https://github.com/mozilla/rhino; fi + if [ ! -e rhino ]; then git clone --depth=1 https://github.com/mozilla/rhino; fi #if [ ! -e rhino/build/rhino*/js.jar ]; then cd rhino; ant jar; fi #cp rhino/build/rhino*/js.jar rhino.jar if [ ! -e rhino/buildGradle/libs/rhino*.jar ]; then cd rhino; ./gradlew jar; fi diff --git a/demos/rollup/Makefile b/demos/rollup/Makefile index 4041ee5..bea7264 100644 --- a/demos/rollup/Makefile +++ b/demos/rollup/Makefile @@ -20,4 +20,4 @@ worker.min.js: worker.js .PHONY: init init: @npm install rollup-plugin-node-resolve rollup-plugin-commonjs - @mkdir -p node_modules; cd node_modules; ln -s ../../../ xlsx; cd - + @mkdir -p node_modules; cd node_modules; if [ ! -e xlsx ]; then ln -s ../../../ xlsx; fi; cd - diff --git a/demos/rollup/rollup.config.js b/demos/rollup/rollup.config.js index b9a2e43..3b62c00 100644 --- a/demos/rollup/rollup.config.js +++ b/demos/rollup/rollup.config.js @@ -2,8 +2,13 @@ import resolve from 'rollup-plugin-node-resolve'; import commonjs from 'rollup-plugin-commonjs'; export default { + input: 'app.js', + output: { + file: 'rollup.js', + format: 'iife' + }, entry: 'app.js', - dest: 'rollup.js', + //dest: 'rollup.js', plugins: [ resolve({ module: false, diff --git a/demos/rollup/rollup.config.node.js b/demos/rollup/rollup.config.node.js index 0947f8f..7aaf1b1 100644 --- a/demos/rollup/rollup.config.node.js +++ b/demos/rollup/rollup.config.node.js @@ -2,12 +2,16 @@ import resolve from 'rollup-plugin-node-resolve'; import commonjs from 'rollup-plugin-commonjs'; export default { + input: 'main.js', + output: { + file: 'rollup.node.js', + format: 'cjs' + }, entry: 'main.js', - dest: 'rollup.node.js', + //dest: 'rollup.node.js', plugins: [ resolve({ - module: false, - browser: true, + module: false }), commonjs() ], diff --git a/demos/rollup/rollup.config.worker.js b/demos/rollup/rollup.config.worker.js index 61a4d33..966332c 100644 --- a/demos/rollup/rollup.config.worker.js +++ b/demos/rollup/rollup.config.worker.js @@ -2,8 +2,13 @@ import resolve from 'rollup-plugin-node-resolve'; import commonjs from 'rollup-plugin-commonjs'; export default { + input: 'xlsxworker.js', + output: { + file: 'worker.js', + format: 'iife' + }, entry: 'xlsxworker.js', - dest: 'worker.js', + //dest: 'worker.js', plugins: [ resolve({ module: false, diff --git a/dist/shim.min.js b/dist/shim.min.js index 2f669b4..4b72440 100644 --- a/dist/shim.min.js +++ b/dist/shim.min.js @@ -1,2 +1,2 @@ /* xlsx.js (C) 2013-present SheetJS -- http://sheetjs.com */ -if(!Object.keys){Object.keys=function(){var t=Object.prototype.hasOwnProperty,e=!{toString:null}.propertyIsEnumerable("toString"),r=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],i=r.length;return function(n){if(typeof n!=="object"&&typeof n!=="function"||n===null)throw new TypeError("Object.keys called on non-object");var o=[];for(var a in n){if(t.call(n,a))o.push(a)}if(e){for(var f=0;f>>0;if(typeof t!="function")throw new TypeError;var i=[];var n=arguments[1];for(var o=0;o>>0;if(typeof t!=="function")throw new TypeError;var i=arguments.length>=2?arguments[1]:void 0;for(var n=0;n>>0;if(typeof t!=="function"){throw new TypeError(t+" is not a function")}if(e){r=e}i=new Array(a);n=0;while(n>>0;e=+e||0;if(Math.abs(e)===Infinity){e=0}if(e<0){e+=r;if(e<0){e=0}}for(;e=r||t>=e){return new ArrayBuffer(0)}var i=Math.min(r-t,e-t);var n=new ArrayBuffer(i);var o=new Uint8Array(n);o.set(new Uint8Array(this,t,i));return n}}(function(){var t=typeof exports!="undefined"?exports:typeof self!="undefined"?self:$.global;var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";function r(t){this.message=t}r.prototype=new Error;r.prototype.name="InvalidCharacterError";t.btoa||(t.btoa=function(t){var i=String(t);for(var n,o,a=0,f=e,l="";i.charAt(a|0)||(f="=",a%1);l+=f.charAt(63&n>>8-a%1*8)){o=i.charCodeAt(a+=3/4);if(o>255){throw new r("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.")}n=n<<8|o}return l});t.atob||(t.atob=function(t){var i=String(t).replace(/[=]+$/,"");if(i.length%4==1){throw new r("'atob' failed: The string to be decoded is not correctly encoded.")}for(var n=0,o,a,f=0,l="";a=i.charAt(f++);~a&&(o=n%4?o*64+a:a,n++%4)?l+=String.fromCharCode(255&o>>(-2*n&6)):0){a=e.indexOf(a)}return l})})();if(!Date.prototype.toISOString){(function(){function t(t){if(t<10){return"0"+t}return t}Date.prototype.toISOString=function(){return this.getUTCFullYear()+"-"+t(this.getUTCMonth()+1)+"-"+t(this.getUTCDate())+"T"+t(this.getUTCHours())+":"+t(this.getUTCMinutes())+":"+t(this.getUTCSeconds())+"."+(this.getUTCMilliseconds()/1e3).toFixed(3).slice(2,5)+"Z"}})()}if(typeof Uint8Array!=="undefined"&&!Uint8Array.prototype.slice)Uint8Array.prototype.slice=function(t,e){if(t<0){t+=this.length;if(t<0)t=0}if(t>=this.length)return new Uint8Array(0);if(e==null)e=this.length;if(e<0){e+=this.length;if(e<0)e=0}if(e>this.length)e=this.length;var r=new Uint8Array(e-t);while(t<=--e)r[e-t]=this[e];return r};var IE_SaveFile=function(){try{if(typeof IE_SaveFile_Impl=="undefined")document.write(['