From 5c53a015c23b15772ea8bde12639150abcc1d908 Mon Sep 17 00:00:00 2001 From: mnater Date: Mon, 27 May 2019 19:40:24 +0200 Subject: [PATCH] =?UTF-8?q?fixes=20for=20IE11=F0=9F=99=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Hyphenopoly.js | 2 +- Hyphenopoly_Loader.js | 4 +-- package-lock.json | 77 ++++++++++++++++++++++++++----------------- testsuite/test36.html | 25 ++++++++++---- testsuite/test37.html | 25 ++++++++++---- testsuite/test38.html | 50 +++++++++++++++++----------- 6 files changed, 116 insertions(+), 67 deletions(-) diff --git a/Hyphenopoly.js b/Hyphenopoly.js index ae140a02..17038a75 100644 --- a/Hyphenopoly.js +++ b/Hyphenopoly.js @@ -750,7 +750,7 @@ if (H.cf.wasm) { return Math.ceil(targetSize / 65536) * 65536; } - const exp = Math.ceil(Math.log2(targetSize)); + const exp = Math.ceil(Math.log(targetSize) * Math.LOG2E); if (exp <= 12) { return 1 << 12; } diff --git a/Hyphenopoly_Loader.js b/Hyphenopoly_Loader.js index 9422306b..ebed7641 100644 --- a/Hyphenopoly_Loader.js +++ b/Hyphenopoly_Loader.js @@ -21,7 +21,7 @@ "use strict"; const store = sessionStorage; - const wa = WebAssembly; + const wa = w.WebAssembly; const lcFallbacks = new Map(); const lcRequire = new Map(); @@ -68,7 +68,7 @@ (function configPaths() { const maindir = (d.currentScript) ? d.currentScript.src.replace(/Hyphenopoly_Loader.js/i, "") - : "../Hyphenopoly/"; + : "../"; const patterndir = maindir + "patterns/"; if (H.paths) { H.paths.maindir = H.paths.maindir || maindir; diff --git a/package-lock.json b/package-lock.json index 235f32af..0e362280 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "hyphenopoly", - "version": "3.0.2", + "version": "3.1.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -870,6 +870,19 @@ "make-dir": "^2.0.0", "package-hash": "^3.0.0", "write-file-atomic": "^2.4.2" + }, + "dependencies": { + "write-file-atomic": { + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-2.4.3.tgz", + "integrity": "sha512-GaETH5wwsX+GcnzhPgKcKjJ6M2Cq3/iZp1WyY/X1CSqrW+jVNM9Y7D8EC2sM4ZG/V8wZlSniJnCKWPmBYAucRQ==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.11", + "imurmurhash": "^0.1.4", + "signal-exit": "^3.0.2" + } + } } }, "caller-callsite": { @@ -1185,9 +1198,9 @@ "dev": true }, "core-js": { - "version": "2.6.8", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.8.tgz", - "integrity": "sha512-RWlREFU74TEkdXzyl1bka66O3kYp8jeTXrvJZDzVVMH8AiHUSOFpL1yfhQJ+wHocAm1m+4971W1PPzfLuCv1vg==", + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.9.tgz", + "integrity": "sha512-HOpZf6eXmnl7la+cUdMnLvUxKNqLUzJvgIziQ0DiF3JwSImNphIqdGqzj6hIKyX04MmV0poclQ7+wjWvxQyR2A==", "dev": true }, "core-util-is": { @@ -1245,9 +1258,9 @@ } }, "csstype": { - "version": "2.6.4", - "resolved": "https://registry.npmjs.org/csstype/-/csstype-2.6.4.tgz", - "integrity": "sha512-lAJUJP3M6HxFXbqtGRc0iZrdyeN+WzOWeY0q/VnFzI+kqVrYIzC7bWlKqCW7oCIdzoPkvfp82EVvrTlQ8zsWQg==", + "version": "2.6.5", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-2.6.5.tgz", + "integrity": "sha512-JsTaiksRsel5n7XwqPAfB0l3TFKdpjW/kgAELf9vrb5adGA7UCPLajKK5s3nFrcFm3Rkyp/Qkgl73ENc1UY3cA==", "dev": true }, "dashdash": { @@ -4320,9 +4333,9 @@ "dev": true }, "psl": { - "version": "1.1.31", - "resolved": "https://registry.npmjs.org/psl/-/psl-1.1.31.tgz", - "integrity": "sha512-/6pt4+C+T+wZUieKR620OpzN/LlnNKuWjy1iFLQ/UG35JqHlR/89MP1d96dUfkf6Dne3TuLQzOYEYshJ+Hx8mw==", + "version": "1.1.32", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.1.32.tgz", + "integrity": "sha512-MHACAkHpihU/REGGPLj4sEfc/XKW2bheigvHO1dUqjaKigMp1C8+WLQYRGgeKFMsw5PMfegZcaN8IDXK/cD0+g==", "dev": true }, "pump": { @@ -5430,9 +5443,9 @@ } }, "tap": { - "version": "14.1.10", - "resolved": "https://registry.npmjs.org/tap/-/tap-14.1.10.tgz", - "integrity": "sha512-mwYjPJpbnBvwsy1IP12g7UgtvgfnFwIVfeYcI27LDuefFGe1XtW+7+ZgFwu0qHG9f+YCBPMhm82W5o8QggPxkA==", + "version": "14.1.11", + "resolved": "https://registry.npmjs.org/tap/-/tap-14.1.11.tgz", + "integrity": "sha512-lz/nGffbk4M7RfKfK14QrXBSy8cYNKTMZXAgPFSThyDDwsy46VGlp+sEX6jHydQa2xe1Q/Ea3IWCrMI04JM4+A==", "dev": true, "requires": { "async-hook-domain": "^1.1.0", @@ -5473,7 +5486,7 @@ "ts-node": "^8.1.0", "typescript": "^3.4.5", "which": "^1.3.1", - "write-file-atomic": "^2.4.2", + "write-file-atomic": "^3.0.0", "yaml": "^1.6.0", "yapool": "^1.0.0" }, @@ -5880,24 +5893,16 @@ "dev": true }, "ts-node": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.1.0.tgz", - "integrity": "sha512-34jpuOrxDuf+O6iW1JpgTRDFynUZ1iEqtYruBqh35gICNjN8x+LpVcPAcwzLPi9VU6mdA3ym+x233nZmZp445A==", + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.2.0.tgz", + "integrity": "sha512-m8XQwUurkbYqXrKqr3WHCW310utRNvV5OnRVeISeea7LoCWVcdfeB/Ntl8JYWFh+WRoUAdBgESrzKochQt7sMw==", "dev": true, "requires": { "arg": "^4.1.0", - "diff": "^3.1.0", + "diff": "^4.0.1", "make-error": "^1.1.1", "source-map-support": "^0.5.6", "yn": "^3.0.0" - }, - "dependencies": { - "diff": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", - "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", - "dev": true - } } }, "tslib": { @@ -5936,6 +5941,15 @@ "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", "dev": true }, + "typedarray-to-buffer": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz", + "integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==", + "dev": true, + "requires": { + "is-typedarray": "^1.0.0" + } + }, "typescript": { "version": "3.4.5", "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.4.5.tgz", @@ -6469,14 +6483,15 @@ } }, "write-file-atomic": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-2.4.2.tgz", - "integrity": "sha512-s0b6vB3xIVRLWywa6X9TOMA7k9zio0TMOsl9ZnDkliA/cfJlpHXAscj0gbHVJiTdIuAYpIyqS5GW91fqm6gG5g==", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-3.0.0.tgz", + "integrity": "sha512-EIgkf60l2oWsffja2Sf2AL384dx328c0B+cIYPTQq5q2rOYuDV00/iPFBOUiDKKwKMOhkymH8AidPaRvzfxY+Q==", "dev": true, "requires": { - "graceful-fs": "^4.1.11", "imurmurhash": "^0.1.4", - "signal-exit": "^3.0.2" + "is-typedarray": "^1.0.0", + "signal-exit": "^3.0.2", + "typedarray-to-buffer": "^3.1.5" } }, "x-is-string": { diff --git a/testsuite/test36.html b/testsuite/test36.html index 41870d13..18834639 100644 --- a/testsuite/test36.html +++ b/testsuite/test36.html @@ -28,13 +28,24 @@ window.onload = function () { function hyphenate_fur(text) { - Hyphenopoly.hyphenators.fur.then( - function (furhyph) { - document.getElementById("test1").innerText = furhyph(text); - assertAll(); - }).catch(function(e) { - assertError(e); - }); + if (window.Promise) { + Hyphenopoly.hyphenators.fur.then( + function (furhyph) { + document.getElementById("test1").innerText = furhyph(text); + assertAll(); + }).catch(function(e) { + assertError(e); + }); + } else { + result = false + if (parent != window) { + parent.postMessage(JSON.stringify({ + desc: document.getElementById("desc").innerHTML, + index: 36, + result: (result ? "passed" : "failed") + }), window.location.href); + } + } } hyphenate_fur("Il furlan e je une lenghe romanze de famee des lenghis retichis, che e je fevelade soredut intal Friûl, ma ancje vie pal mont. Cualchi volte al ven clamât Ladin orientâl, parcè che al à diviers ponts in comun cul ladin, ma si è svilupât in un altri mût cul passâ dal timp, sot de influence des lenghis ator dal Friûl"); }; diff --git a/testsuite/test37.html b/testsuite/test37.html index fde414c5..5510826f 100644 --- a/testsuite/test37.html +++ b/testsuite/test37.html @@ -28,13 +28,24 @@ window.onload = function () { function hyphenate_fur(text) { - Hyphenopoly.hyphenators.fur.then( - function (furhyph) { - document.getElementById("test1").innerText = furhyph(text); - assertAll(); - }).catch(function(e) { - assertError(e); - }); + if (window.Promise) { + Hyphenopoly.hyphenators.fur.then( + function (furhyph) { + document.getElementById("test1").innerText = furhyph(text); + assertAll(); + }).catch(function(e) { + assertError(e); + }); + } else { + result = false + if (parent != window) { + parent.postMessage(JSON.stringify({ + desc: document.getElementById("desc").innerHTML, + index: 37, + result: (result ? "passed" : "failed") + }), window.location.href); + } + } } hyphenate_fur("Il furlan e je une lenghe romanze de famee des lenghis retichis, che e je fevelade soredut intal Friûl, ma ancje vie pal mont. Cualchi volte al ven clamât Ladin orientâl, parcè che al à diviers ponts in comun cul ladin, ma si è svilupât in un altri mût cul passâ dal timp, sot de influence des lenghis ator dal Friûl"); }; diff --git a/testsuite/test38.html b/testsuite/test38.html index 2575a274..8a3f6e68 100644 --- a/testsuite/test38.html +++ b/testsuite/test38.html @@ -26,26 +26,38 @@ }; window.onload = function () { - function hyphenate_en(text) { - Hyphenopoly.hyphenators["en"].then( - function (enhyph) { - document.getElementById("test1").innerText = enhyph(text); - assertAll(); - }).catch(function(e) { - assertError(e); - }); - } - function hyphenate_de(text) { - Hyphenopoly.hyphenators["de"].then( - function (dehyph) { - document.getElementById("test2").innerText = dehyph(text); - assertAll(); - }).catch(function(e) { - assertError(e); - }); + if (window.Promise) { + function hyphenate_en(text) { + Hyphenopoly.hyphenators["en"].then( + function (enhyph) { + document.getElementById("test1").innerText = enhyph(text); + assertAll(); + }).catch(function(e) { + assertError(e); + }); + } + function hyphenate_de(text) { + Hyphenopoly.hyphenators["de"].then( + function (dehyph) { + document.getElementById("test2").innerText = dehyph(text); + assertAll(); + }).catch(function(e) { + assertError(e); + }); + } + hyphenate_en("hyphenation algorithm"); + hyphenate_de("Silbentrennungsalgorithmus"); + } else { + result = false + if (parent != window) { + parent.postMessage(JSON.stringify({ + desc: document.getElementById("desc").innerHTML, + index: 38, + result: (result ? "passed" : "failed") + }), window.location.href); + } + } - hyphenate_en("hyphenation algorithm"); - hyphenate_de("Silbentrennungsalgorithmus"); }; function assertError(e) {