From c4d9ba0948950ec492111afb62517997ccba0eda Mon Sep 17 00:00:00 2001 From: SheetJS Date: Tue, 25 Jun 2024 03:16:41 -0400 Subject: [PATCH] Synthetic DOM demo refresh --- .../docs/03-demos/03-net/08-headless/index.md | 10 ++-- docz/docs/03-demos/03-net/09-dom.md | 50 ++++++++++++++++--- docz/docs/03-demos/42-engines/04-jsc.md | 2 +- docz/docs/03-demos/42-engines/07-nashorn.md | 30 +++++------ tests/cli-bunsea.sh | 1 - tests/cli-denosea.sh | 1 - tests/cli-nodesea.sh | 2 - tests/cli-pkg.sh | 2 +- tests/dom-happydom.sh | 20 ++++++++ tests/dom-jsdom.sh | 36 +++++++++++++ tests/engines-boa.sh | 2 +- tests/engines-execjs.sh | 2 +- tests/engines-graaljs.sh | 2 +- tests/engines-jerryscript.sh | 2 +- tests/engines-nashorn.sh | 3 +- tests/engines-rhino.sh | 2 +- tests/headless-playwright.sh | 46 +++++++++++++++++ tests/headless-puppeteer-deno.sh | 44 ++++++++++++++++ tests/headless-puppeteer.sh | 47 +++++++++++++++++ 19 files changed, 264 insertions(+), 40 deletions(-) create mode 100755 tests/dom-happydom.sh create mode 100755 tests/dom-jsdom.sh create mode 100755 tests/headless-playwright.sh create mode 100755 tests/headless-puppeteer-deno.sh create mode 100755 tests/headless-puppeteer.sh diff --git a/docz/docs/03-demos/03-net/08-headless/index.md b/docz/docs/03-demos/03-net/08-headless/index.md index d7c53b7..e0c7077 100644 --- a/docz/docs/03-demos/03-net/08-headless/index.md +++ b/docz/docs/03-demos/03-net/08-headless/index.md @@ -131,14 +131,14 @@ const puppeteer = require('puppeteer'); :::note Tested Deployments -This demo was last tested on 2024 January 27 against Puppeteer 21.9.0. +This demo was last tested on 2024 June 24 against Puppeteer 22.12.0. ::: 1) Install SheetJS and Puppeteer: {`\ -npm i --save https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz puppeteer@21.9.0`} +npm i --save https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz puppeteer@22.12.0`} 2) Save the `SheetJSPuppeteer.js` code snippet to `SheetJSPuppeteer.js`. @@ -206,7 +206,7 @@ await browser.close();`} :::note Tested Deployments -This demo was last tested on 2024 January 27 against deno-puppeteer 16.2.0. +This demo was last tested on 2024 June 24 against deno-puppeteer 16.2.0. ::: @@ -294,14 +294,14 @@ const { webkit } = require('playwright'); // import desired browser :::note Tested Deployments -This demo was last tested on 2024 January 27 against Playwright 1.41.1. +This demo was last tested on 2024 June 24 against Playwright 1.45.0. ::: 1) Install SheetJS and Playwright: {`\ -npm i --save https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz playwright@1.41.1`} +npm i --save https://cdn.sheetjs.com/xlsx-${current}/xlsx-${current}.tgz playwright@1.45.0`} 2) Save the `SheetJSPlaywright.js` code snippet to `SheetJSPlaywright.js`. diff --git a/docz/docs/03-demos/03-net/09-dom.md b/docz/docs/03-demos/03-net/09-dom.md index 1607138..d0cb261 100644 --- a/docz/docs/03-demos/03-net/09-dom.md +++ b/docz/docs/03-demos/03-net/09-dom.md @@ -107,15 +107,33 @@ const workbook = XLSX.utils.table_to_book(doc); XLSX.writeFile(workbook, "SheetJSDOM.xlsx"); ``` -
- Complete Demo (click to show) - :::note Tested Deployments -This demo was last tested on 2024 January 27 against JSDOM `24.0.0` +This demo was tested in the following deployments: + +| JSDOM | Date | +|:--------|:-----------| +| 24.1.0 | 2024-06-24 | +| 23.2.0 | 2024-06-24 | +| 22.1.0 | 2024-06-24 | +| 21.1.2 | 2024-06-24 | +| 20.0.3 | 2024-06-24 | +| 19.0.0 | 2024-06-24 | +| 18.1.1 | 2024-06-24 | +| 17.0.0 | 2024-06-24 | +| 16.7.0 | 2024-06-24 | +| 15.2.1 | 2024-06-24 | +| 14.1.0 | 2024-06-24 | +| 13.2.0 | 2024-06-24 | +| 12.2.0 | 2024-06-24 | +| 11.12.0 | 2024-06-24 | +| 10.1.0 | 2024-06-24 | ::: +
+ Complete Demo (click to show) + 1) Install SheetJS and JSDOM libraries: {`\ @@ -148,15 +166,31 @@ the following patches were needed: - TABLE `rows` property (explained above) - TR `cells` property (explained above) -
- Complete Demo (click to show) - :::note Tested Deployments -This demo was last tested on 2024 January 27 against HappyDOM `13.3.1` +This demo was tested in the following deployments: + +| HappyDOM | Date | +|:---------|:-----------| +| 14.12.3 | 2024-06-24 | +| 13.10.1 | 2024-06-24 | +| 12.10.3 | 2024-06-24 | +| 11.2.0 | 2024-06-24 | +| 10.11.2 | 2024-06-24 | +| 9.20.3 | 2024-06-24 | +| 8.9.0 | 2024-06-24 | +| 7.8.1 | 2024-06-24 | +| 6.0.4 | 2024-06-24 | +| 5.4.0 | 2024-06-24 | +| 4.1.0 | 2024-06-24 | +| 3.2.2 | 2024-06-24 | +| 2.55.0 | 2024-06-24 | ::: +
+ Complete Demo (click to show) + 1) Install SheetJS and HappyDOM libraries: {`\ diff --git a/docz/docs/03-demos/42-engines/04-jsc.md b/docz/docs/03-demos/42-engines/04-jsc.md index 7c98eff..19de00f 100644 --- a/docz/docs/03-demos/42-engines/04-jsc.md +++ b/docz/docs/03-demos/42-engines/04-jsc.md @@ -324,7 +324,7 @@ Swift on MacOS supports JavaScriptCore without additional dependencies. **Compiled** The ["Swift C"](#swift-c) section starts from the static libraries built in the -["C++"](#c) section and build Swift bindings. +["C++"](#c) section and builds Swift bindings. | Architecture | Version | Date | |:-------------|:-----------------|:-----------| diff --git a/docz/docs/03-demos/42-engines/07-nashorn.md b/docz/docs/03-demos/42-engines/07-nashorn.md index ba62882..c1c05e4 100644 --- a/docz/docs/03-demos/42-engines/07-nashorn.md +++ b/docz/docs/03-demos/42-engines/07-nashorn.md @@ -105,21 +105,21 @@ This demo was tested in the following deployments: | OpenJDK | Nashorn | Date | |:--------|:----------------|:-----------| -| 22 | 15.4 standalone | 2024-03-23 | -| 21.0.3 | 15.4 standalone | 2024-05-24 | -| 20.0.2 | 15.4 standalone | 2024-03-23 | -| 19.0.2 | 15.4 standalone | 2024-03-23 | -| 18.0.2 | 15.4 standalone | 2024-03-23 | -| 17.0.10 | 15.4 standalone | 2024-03-25 | -| 16.0.1 | 15.4 standalone | 2024-03-23 | -| 15.0.10 | 15.4 standalone | 2024-03-23 | -| 14.0.2 | Built-in | 2024-03-23 | -| 13.0.14 | Built-in | 2024-03-23 | -| 12.0.2 | Built-in | 2024-03-23 | -| 11.0.20 | Built-in | 2024-03-23 | -| 10.0.2 | Built-in | 2024-03-23 | -| 9 | Built-in | 2024-03-23 | -| 1.8.0 | Built-in | 2024-03-23 | +| 22.0.1 | 15.4 standalone | 2024-06-24 | +| 21.0.3 | 15.4 standalone | 2024-06-24 | +| 20.0.2 | 15.4 standalone | 2024-06-24 | +| 19.0.2 | 15.4 standalone | 2024-06-24 | +| 18.0.2 | 15.4 standalone | 2024-06-24 | +| 17.0.11 | 15.4 standalone | 2024-06-24 | +| 16.0.1 | 15.4 standalone | 2024-06-24 | +| 15.0.10 | 15.4 standalone | 2024-06-24 | +| 14.0.2 | Built-in | 2024-06-24 | +| 13.0.14 | Built-in | 2024-06-24 | +| 12.0.2 | Built-in | 2024-06-24 | +| 11.0.23 | Built-in | 2024-06-24 | +| 10.0.2 | Built-in | 2024-06-24 | +| 9 | Built-in | 2024-06-24 | +| 1.8.0 | Built-in | 2024-06-24 | ::: diff --git a/tests/cli-bunsea.sh b/tests/cli-bunsea.sh index 6a88862..ac6b4ef 100755 --- a/tests/cli-bunsea.sh +++ b/tests/cli-bunsea.sh @@ -32,4 +32,3 @@ bun run sheet2csv.ts pres.numbers bun build ./sheet2csv.ts --compile --outfile sheet2csv ./sheet2csv pres.numbers - diff --git a/tests/cli-denosea.sh b/tests/cli-denosea.sh index 0f49f48..a13858f 100755 --- a/tests/cli-denosea.sh +++ b/tests/cli-denosea.sh @@ -13,4 +13,3 @@ deno run -r --allow-read https://docs.sheetjs.com/cli/sheet2csv.ts pres.numbers deno compile -r --allow-read https://docs.sheetjs.com/cli/sheet2csv.ts ./sheet2csv pres.numbers - diff --git a/tests/cli-nodesea.sh b/tests/cli-nodesea.sh index 6eaabe2..abf9cdd 100755 --- a/tests/cli-nodesea.sh +++ b/tests/cli-nodesea.sh @@ -61,5 +61,3 @@ codesign -s - ./sheet2csv ./sheet2csv pres.numbers codesign -dv ./sheet2csv - - diff --git a/tests/cli-pkg.sh b/tests/cli-pkg.sh index 55eb2f4..32e6908 100755 --- a/tests/cli-pkg.sh +++ b/tests/cli-pkg.sh @@ -17,4 +17,4 @@ npx pkg xlsx-cli.js ## NOTE: these steps are for darwin-x64 -./xlsx-cli-macos pres.numbers \ No newline at end of file +./xlsx-cli-macos pres.numbers diff --git a/tests/dom-happydom.sh b/tests/dom-happydom.sh new file mode 100755 index 0000000..6b6ac37 --- /dev/null +++ b/tests/dom-happydom.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# https://docs.sheetjs.com/docs/demos/net/dom#happydom + +cd /tmp +rm -rf sheetjs-happydom +mkdir sheetjs-happydom +cd sheetjs-happydom + +npm i --save https://cdn.sheetjs.com/xlsx-0.20.2/xlsx-0.20.2.tgz + +curl -LO https://docs.sheetjs.com/dom/SheetJSHappyDOM.js +curl -LO https://docs.sheetjs.com/dom/SheetJSTable.html + +for n in {2..14}; do + rm -f SheetJSHappyDOM.xlsx + npm i --save happy-dom@$n + npm ls | grep happy-dom + node SheetJSHappyDOM.js + npx -y xlsx-cli SheetJSHappyDOM.xlsx | head -n 3 +done diff --git a/tests/dom-jsdom.sh b/tests/dom-jsdom.sh new file mode 100755 index 0000000..38673f1 --- /dev/null +++ b/tests/dom-jsdom.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# https://docs.sheetjs.com/docs/demos/net/dom#jsdom + +cd /tmp +rm -rf sheetjs-jsdom +mkdir sheetjs-jsdom +cd sheetjs-jsdom + +npm i --save https://cdn.sheetjs.com/xlsx-0.20.2/xlsx-0.20.2.tgz + +cat >SheetJSDOM.js < xlsx.jerry.js -jerryscript/build/bin/jerry xlsx.jerry.js; echo $? \ No newline at end of file +jerryscript/build/bin/jerry xlsx.jerry.js; echo $? diff --git a/tests/engines-nashorn.sh b/tests/engines-nashorn.sh index d90e074..614a6b4 100755 --- a/tests/engines-nashorn.sh +++ b/tests/engines-nashorn.sh @@ -19,7 +19,9 @@ curl -L -o asm-util-9.5.jar "https://search.maven.org/remotecontent?filepath=org # Standalone Nashorn for n in {15..22}; do + echo $n export JAVA_HOME=`/usr/libexec/java_home -v $n` + echo $JAVA_HOME java -version rm -fr SheetJSNashorn.class SheetJSNashorn.jar sheethorn javac SheetJSNashorn.java @@ -46,4 +48,3 @@ for n in 1.8 {9..14}; do java -cp .:SheetJSNashorn.jar SheetJSNashorn pres.xlsx cd - done - diff --git a/tests/engines-rhino.sh b/tests/engines-rhino.sh index 415c8da..281ef63 100755 --- a/tests/engines-rhino.sh +++ b/tests/engines-rhino.sh @@ -51,4 +51,4 @@ for n in 1.8 {9..22}; do jar -cf SheetJS.jar SheetJSRhino.class com/sheetjs/*.class xlsx.full.min.js java -cp ".:SheetJS.jar:rhino.jar" SheetJSRhino pres.xlsx -done \ No newline at end of file +done diff --git a/tests/headless-playwright.sh b/tests/headless-playwright.sh new file mode 100755 index 0000000..9365fcd --- /dev/null +++ b/tests/headless-playwright.sh @@ -0,0 +1,46 @@ +#!/bin/bash +# https://docs.sheetjs.com/docs/demos/net/headless#playwright + +cd /tmp +rm -rf sheetjs-playwright +mkdir sheetjs-playwright +cd sheetjs-playwright + +npm i --save https://cdn.sheetjs.com/xlsx-0.20.2/xlsx-0.20.2.tgz playwright@1.45.0 + +cat >SheetJSPlaywright.js < { + /* (1) Load the target page */ + const browser = await webkit.launch(); // launch desired browser + const page = await browser.newPage(); + page.on("console", msg => console.log("PAGE LOG:", msg.text())); + await page.setViewportSize({width: 1920, height: 1080}); // different name :( + await page.goto('https://sheetjs.com/demos/table'); + + /* (2) Load the standalone SheetJS build from the CDN */ + await page.addScriptTag({ url: 'https://cdn.sheetjs.com/xlsx-0.20.2/package/dist/xlsx.full.min.js' }); + + /* (3) Run the snippet in browser and return data */ + const bin = await page.evaluate(() => { + /* find first table */ + var table = document.body.getElementsByTagName('table')[0]; + + /* call table_to_book on first table */ + var wb = XLSX.utils.table_to_book(table); + + /* generate XLSB and return binary string */ + return XLSX.write(wb, {type: "binary", bookType: "xlsb"}); + }); + + /* (4) write data to file */ + fs.writeFileSync("SheetJSPlaywright.xlsb", bin, { encoding: "binary" }); + + await browser.close(); +})(); +EOF + +node SheetJSPlaywright.js +npx -y playwright@1.45.0 install +npx -y xlsx-cli SheetJSPlaywright.xlsb diff --git a/tests/headless-puppeteer-deno.sh b/tests/headless-puppeteer-deno.sh new file mode 100755 index 0000000..d268835 --- /dev/null +++ b/tests/headless-puppeteer-deno.sh @@ -0,0 +1,44 @@ +#!/bin/bash +# https://docs.sheetjs.com/docs/demos/net/headless#puppeteer + +cd /tmp +rm -rf sheetjs-puppeteer-deno +mkdir sheetjs-puppeteer-deno +cd sheetjs-puppeteer-deno + +env PUPPETEER_PRODUCT=chrome deno run -A --unstable https://deno.land/x/puppeteer@16.2.0/install.ts + +cat >SheetJSPuppeteer.ts < console.log("PAGE LOG:", msg.text())); +await page.setViewport({width: 1920, height: 1080}); +await page.goto('https://sheetjs.com/demos/table'); + +/* (2) Load the standalone SheetJS build from the CDN */ +await page.addScriptTag({ url: 'https://cdn.sheetjs.com/xlsx-0.20.2/package/dist/xlsx.full.min.js' }); + +/* (3) Run the snippet in browser and return data */ +const b64 = await page.evaluate(() => { + + /* find first table */ + var table = document.body.getElementsByTagName('table')[0]; + + /* call table_to_book on first table */ + var wb = XLSX.utils.table_to_book(table); + + /* generate XLSB and return binary string */ + return XLSX.write(wb, {type: "base64", bookType: "xlsb"}); +}); +/* (4) write data to file */ +Deno.writeFileSync("SheetJSPuppeteer.xlsb", decode(b64)); + +await browser.close(); +EOF + +deno run -A --unstable SheetJSPuppeteer.ts +npx -y xlsx-cli SheetJSPuppeteer.xlsb diff --git a/tests/headless-puppeteer.sh b/tests/headless-puppeteer.sh new file mode 100755 index 0000000..14ddc23 --- /dev/null +++ b/tests/headless-puppeteer.sh @@ -0,0 +1,47 @@ +#!/bin/bash +# https://docs.sheetjs.com/docs/demos/net/headless#puppeteer + +cd /tmp +rm -rf sheetjs-puppeteer +mkdir sheetjs-puppeteer +cd sheetjs-puppeteer + +npm i --save https://cdn.sheetjs.com/xlsx-0.20.2/xlsx-0.20.2.tgz puppeteer@22.12.0 + +cat >SheetJSPuppeteer.js < { + /* (1) Load the target page */ + const browser = await puppeteer.launch(); + const page = await browser.newPage(); + page.on("console", msg => console.log("PAGE LOG:", msg.text())); + await page.setViewport({width: 1920, height: 1080}); + await page.goto('https://sheetjs.com/demos/table'); + + /* (2) Load the standalone SheetJS build from the CDN */ + await page.addScriptTag({ url: 'https://cdn.sheetjs.com/xlsx-0.20.2/package/dist/xlsx.full.min.js' }); + + /* (3) Run the snippet in browser and return data */ + const bin = await page.evaluate(() => { + + /* find first table */ + var table = document.body.getElementsByTagName('table')[0]; + + /* call table_to_book on first table */ + var wb = XLSX.utils.table_to_book(table); + + /* generate XLSB and return binary string */ + return XLSX.write(wb, {type: "binary", bookType: "xlsb"}); + }); + + /* (4) write data to file */ + fs.writeFileSync("SheetJSPuppeteer.xlsb", bin, { encoding: "binary" }); + + await browser.close(); +})(); +EOF + +node SheetJSPuppeteer.js +npx -y xlsx-cli SheetJSPuppeteer.xlsb