Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hyphenopoly

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hyphenopoly - npm Package Compare versions

Comparing version 5.0.0-beta.1 to 5.0.0-beta.2

562

Hyphenopoly_Loader.js
/**
* @license Hyphenopoly_Loader 5.0.0-beta.1 - client side hyphenation
* @license Hyphenopoly_Loader 5.0.0-beta.2 - client side hyphenation
* ©2021 Mathias Nater, Güttingen (mathiasnater at gmail dot com)

@@ -10,2 +10,4 @@ * https://github.com/mnater/Hyphenopoly

/* globals Hyphenopoly:readonly */
window.Hyphenopoly = {};
((w, d, H, o) => {

@@ -23,275 +25,196 @@ "use strict";

/**
* Sets default properties for an Object
* @param {object} obj - The object to set defaults to
* @param {object} defaults - The defaults to set
* @returns {object}
*/
const setDefaults = (obj, defaults) => {
if (obj) {
o.entries(defaults).forEach(([k, v]) => {
// eslint-disable-next-line security/detect-object-injection
obj[k] = obj[k] || v;
});
return obj;
}
return defaults;
};
const scriptName = "Hyphenopoly_Loader.js";
const thisScript = d.currentScript.src;
const store = sessionStorage;
const scriptName = "Hyphenopoly_Loader.js";
const lcRequire = mp();
let mainScriptLoaded = false;
const shortcuts = {
"ac": "appendChild",
"ce": "createElement",
"ct": "createTextNode"
};
/**
* Set H.cf (Hyphenopoly.clientFeatures) either by reading out previously
* computed settings from sessionStorage or creating a template object.
* This is in an iife to keep complexity low.
* The main function runs the feature test and loads Hyphenopoly if
* necessary.
*/
(() => {
if (H.cacheFeatureTests && store.getItem(scriptName)) {
H.cf = JSON.parse(store.getItem(scriptName));
H.cf.langs = mp(H.cf.langs);
} else {
H.cf = {
"langs": mp(),
"pf": false
};
}
})();
const main = (() => {
const shortcuts = {
"ac": "appendChild",
"ce": "createElement",
"ct": "createTextNode"
};
/**
* Set H.paths and some H.s (setup) fields to defaults or
* overwrite with user settings.
* These is an iife to keep complexity low.
*/
(() => {
const thisScript = d.currentScript.src;
const maindir = thisScript.slice(0, (thisScript.lastIndexOf("/") + 1));
const patterndir = maindir + "patterns/";
H.paths = setDefaults(H.paths, {
maindir,
patterndir
});
H.s = setDefaults(H.setup, {
"CORScredentials": "include",
"hide": "all",
"selectors": {".hyphenate": {}},
"timeout": 1000
});
// Change mode string to mode int
H.s.hide = ["all", "element", "text"].indexOf(H.s.hide);
})();
/**
* Copy required languages to local lcRequire (lowercaseRequire) and
* eventually fallbacks to local lcFallbacks (lowercaseFallbacks).
* This is in an iife to keep complexity low.
*/
(() => {
const fallbacks = mp(o.entries(H.fallbacks || {}));
o.entries(H.require).forEach(([lang, wo]) => {
lcRequire.set(lang.toLowerCase(), {
"fn": fallbacks.get(lang) || lang,
wo
/**
* Create deferred Promise
*
* From http://lea.verou.me/2016/12/resolve-promises-externally-with-
* this-one-weird-trick/
* @return {promise}
*/
const defProm = () => {
let res = null;
let rej = null;
const promise = new Promise((resolve, reject) => {
res = resolve;
rej = reject;
});
});
})();
promise.resolve = res;
promise.reject = rej;
return promise;
};
/**
* Create deferred Promise
*
* Kudos to http://lea.verou.me/2016/12/resolve-promises-externally-with-
* this-one-weird-trick/
* @return {promise}
*/
const defProm = () => {
let res = null;
let rej = null;
const promise = new Promise((resolve, reject) => {
res = resolve;
rej = reject;
});
promise.resolve = res;
promise.reject = rej;
let stylesNode = null;
return promise;
};
let stylesNode = null;
/**
* Define function H.hide.
* This function hides (state = 1) or unhides (state = 0)
* the whole document (mode == 0) or
* each selected element (mode == 1) or
* text of each selected element (mode == 2) or
* nothing (mode == -1)
* @param {integer} state - State
* @param {integer} mode - Mode
*/
H.hide = (state, mode) => {
if (state === 0) {
if (stylesNode) {
stylesNode.remove();
}
} else {
const vis = "{visibility:hidden!important}";
stylesNode = d[shortcuts.ce]("style");
let myStyle = "";
if (mode === 0) {
myStyle = "html" + vis;
/**
* Define function H.hide.
* This function hides (state = 1) or unhides (state = 0)
* the whole document (mode == 0) or
* each selected element (mode == 1) or
* text of each selected element (mode == 2) or
* nothing (mode == -1)
* @param {integer} state - State
* @param {integer} mode - Mode
*/
H.hide = (state, mode) => {
if (state === 0) {
if (stylesNode) {
stylesNode.remove();
}
} else {
o.keys(H.s.selectors).forEach((sel) => {
if (mode === 1) {
let vis = "{visibility:hidden!important}";
stylesNode = d[shortcuts.ce]("style");
let myStyle = "";
if (mode === 0) {
myStyle = "html" + vis;
} else if (mode !== -1) {
if (mode === 2) {
vis = "{color:transparent!important}";
}
o.keys(H.s.selectors).forEach((sel) => {
myStyle += sel + vis;
} else {
myStyle += sel + "{color:transparent!important}";
}
});
});
}
stylesNode[shortcuts.ac](d[shortcuts.ct](myStyle));
d.head[shortcuts.ac](stylesNode);
}
stylesNode[shortcuts.ac](d[shortcuts.ct](myStyle));
d.head[shortcuts.ac](stylesNode);
}
};
};
const tester = (() => {
let fakeBody = null;
return {
const tester = (() => {
let fakeBody = null;
return {
/**
* Append fakeBody with tests to document
* @returns {Object|null} The body element or null, if no tests
*/
"ap": () => {
if (fakeBody) {
d.documentElement[shortcuts.ac](fakeBody);
return fakeBody;
}
return null;
},
/**
* Append fakeBody with tests to document
* @returns {Object|null} The body element or null, if no tests
*/
"ap": () => {
if (fakeBody) {
d.documentElement[shortcuts.ac](fakeBody);
return fakeBody;
}
return null;
},
/**
* Remove fakeBody
* @returns {undefined}
*/
"cl": () => {
if (fakeBody) {
fakeBody.remove();
/**
* Remove fakeBody
* @returns {undefined}
*/
"cl": () => {
if (fakeBody) {
fakeBody.remove();
}
},
/**
* Create and append div with CSS-hyphenated word
* @param {string} lang Language
* @returns {undefined}
*/
"cr": (lang) => {
if (H.cf.langs.has(lang)) {
return;
}
fakeBody = fakeBody || d[shortcuts.ce]("body");
const testDiv = d[shortcuts.ce]("div");
const ha = "hyphens:auto";
testDiv.lang = lang;
testDiv.style.cssText = `visibility:hidden;-webkit-${ha};-ms-${ha};${ha};width:48px;font-size:12px;line-height:12px;border:none;padding:0;word-wrap:normal`;
testDiv[shortcuts.ac](
d[shortcuts.ct](H.lrq.get(lang).wo.toLowerCase())
);
fakeBody[shortcuts.ac](testDiv);
}
},
};
})();
/**
* Create and append div with CSS-hyphenated word
* @param {string} lang Language
* @returns {undefined}
*/
"cr": (lang) => {
if (H.cf.langs.has(lang)) {
return;
}
fakeBody = fakeBody || d[shortcuts.ce]("body");
const testDiv = d[shortcuts.ce]("div");
const ha = "hyphens:auto";
testDiv.lang = lang;
testDiv.style.cssText = `visibility:hidden;-webkit-${ha};-ms-${ha};${ha};width:48px;font-size:12px;line-height:12px;border:none;padding:0;word-wrap:normal`;
testDiv[shortcuts.ac](
d[shortcuts.ct](lcRequire.get(lang).wo.toLowerCase())
);
fakeBody[shortcuts.ac](testDiv);
}
/**
* Checks if hyphens (ev.prefixed) is set to auto for the element.
* @param {Object} elm - the element
* @returns {Boolean} result of the check
*/
const checkCSSHyphensSupport = (elmStyle) => {
const h = elmStyle.hyphens ||
elmStyle.webkitHyphens ||
elmStyle.msHyphens;
return (h === "auto");
};
})();
/**
* Checks if hyphens (ev.prefixed) is set to auto for the element.
* @param {Object} elm - the element
* @returns {Boolean} result of the check
*/
const checkCSSHyphensSupport = (elmStyle) => {
const h = elmStyle.hyphens ||
elmStyle.webkitHyphens ||
elmStyle.msHyphens;
return (h === "auto");
};
H.res = {
"he": mp()
};
H.res = {
"he": mp()
};
const fw = mp();
/**
* Load hyphenEngines
*
* Make sure each .wasm is loaded exactly once, even for fallbacks
* fw: fetched wasm (maps filename to language)
* he: hyphenEngines (maps lang to wasm and counter)
* c (counter) is needed in Hyphenopoly.js to decide
* if wasm needs to be cloned
* @param {string} lang The language
* @returns {undefined}
*/
const loadhyphenEngine = (lang) => {
const filename = lcRequire.get(lang).fn + ".wasm";
H.cf.pf = true;
H.cf.langs.set(lang, "H9Y");
if (fw.has(filename)) {
const hyphenEngineWrapper = H.res.he.get(fw.get(filename));
hyphenEngineWrapper.c = true;
H.res.he.set(lang, hyphenEngineWrapper);
} else {
H.res.he.set(
lang,
{
"w": w.fetch(H.paths.patterndir + filename, {"credentials": H.s.CORScredentials})
}
);
fw.set(filename, lang);
}
};
lcRequire.forEach((value, lang) => {
if (value.wo === "FORCEHYPHENOPOLY" || H.cf.langs.get(lang) === "H9Y") {
loadhyphenEngine(lang);
} else {
tester.cr(lang);
}
});
const testContainer = tester.ap();
if (testContainer) {
testContainer.querySelectorAll("div").forEach((n) => {
if (checkCSSHyphensSupport(n.style) && n.offsetHeight > 12) {
H.cf.langs.set(n.lang, "CSS");
/**
* Load hyphenEngines to H.res.he
*
* Make sure each .wasm is loaded exactly once, even for fallbacks
* Store a list of languages to by hyphenated with each .wasm
* @param {string} lang The language
* @returns {undefined}
*/
const loadhyphenEngine = (lang) => {
const fn = H.lrq.get(lang).fn;
H.cf.pf = true;
H.cf.langs.set(lang, "H9Y");
if (H.res.he.has(fn)) {
H.res.he.get(fn).l.push(lang);
} else {
loadhyphenEngine(n.lang);
}
});
tester.cl();
}
const he = H.handleEvent;
if (H.cf.pf) {
H.res.DOM = new Promise((res) => {
if (d.readyState === "loading") {
d.addEventListener(
"DOMContentLoaded",
res,
H.res.he.set(
fn,
{
"once": true,
"passive": true
"l": [lang],
"w": w.fetch(H.paths.patterndir + fn + ".wasm", {"credentials": H.s.CORScredentials})
}
);
}
};
H.lrq.forEach((value, lang) => {
if (value.wo === "FORCEHYPHENOPOLY" || H.cf.langs.get(lang) === "H9Y") {
loadhyphenEngine(lang);
} else {
res();
tester.cr(lang);
}
});
const hide = H.s.hide;
if (hide === 0) {
H.hide(1, 0);
const testContainer = tester.ap();
if (testContainer) {
testContainer.querySelectorAll("div").forEach((n) => {
if (checkCSSHyphensSupport(n.style) && n.offsetHeight > 12) {
H.cf.langs.set(n.lang, "CSS");
} else {
loadhyphenEngine(n.lang);
}
});
tester.cl();
}
if (hide !== -1) {
const hev = H.hev;
if (H.cf.pf) {
H.res.DOM = new Promise((res) => {
if (d.readyState === "loading") {
d.addEventListener(
"DOMContentLoaded",
res,
{
"once": true,
"passive": true
}
);
} else {
res();
}
});
H.hide(1, H.s.hide);
H.timeOutHandler = w.setTimeout(() => {

@@ -302,51 +225,110 @@ H.hide(0, null);

}, H.s.timeout);
if (mainScriptLoaded) {
H.main();
} else {
// Load main script
const script = d[shortcuts.ce]("script");
script.src = H.paths.maindir + "Hyphenopoly.js";
d.head[shortcuts.ac](script);
mainScriptLoaded = true;
}
H.hy6ors = mp();
H.cf.langs.forEach((langDef, lang) => {
if (langDef === "H9Y") {
H.hy6ors.set(lang, defProm());
}
});
H.hy6ors.set("HTML", defProm());
H.hyphenators = new Proxy(H.hy6ors, {
"get": (target, key) => {
return target.get(key);
},
"set": () => {
// Inhibit setting of hyphenators
return true;
}
});
(() => {
if (hev && hev.polyfill) {
hev.polyfill();
}
})();
} else {
(() => {
if (hev && hev.tearDown) {
hev.tearDown();
}
w.Hyphenopoly = null;
})();
}
H.res.DOM.then(() => {
if (hide > 0) {
H.hide(1, hide);
}
});
// Load main script
const script = d[shortcuts.ce]("script");
script.src = H.paths.maindir + "Hyphenopoly.js";
d.head[shortcuts.ac](script);
H.hy6ors = mp();
H.cf.langs.forEach((langDef, lang) => {
if (langDef === "H9Y") {
H.hy6ors.set(lang, defProm());
}
});
H.hy6ors.set("HTML", defProm());
H.hyphenators = new Proxy(H.hy6ors, {
"get": (target, key) => {
return target.get(key);
},
"set": () => {
// Inhibit setting of hyphenators
return true;
}
});
(() => {
if (he && he.polyfill) {
he.polyfill();
if (H.cft) {
store.setItem(scriptName, JSON.stringify(
{
"langs": [...H.cf.langs.entries()],
"pf": H.cf.pf
}
));
}
})();
} else {
(() => {
if (he && he.tearDown) {
he.tearDown();
});
H.config = (c) => {
/**
* Sets default properties for an Object
* @param {object} obj - The object to set defaults to
* @param {object} defaults - The defaults to set
* @returns {object}
*/
const setDefaults = (obj, defaults) => {
if (obj) {
o.entries(defaults).forEach(([k, v]) => {
// eslint-disable-next-line security/detect-object-injection
obj[k] = obj[k] || v;
});
return obj;
}
w.Hyphenopoly = null;
})();
}
(() => {
if (H.cacheFeatureTests) {
store.setItem(scriptName, JSON.stringify(
{
"langs": [...H.cf.langs.entries()],
"pf": H.cf.pf
}
));
return defaults;
};
H.cft = Boolean(c.cacheFeatureTests);
if (H.cft && store.getItem(scriptName)) {
H.cf = JSON.parse(store.getItem(scriptName));
H.cf.langs = mp(H.cf.langs);
} else {
H.cf = {
"langs": mp(),
"pf": false
};
}
})();
const maindir = thisScript.slice(0, (thisScript.lastIndexOf("/") + 1));
const patterndir = maindir + "patterns/";
H.paths = setDefaults(c.paths, {
maindir,
patterndir
});
H.s = setDefaults(c.setup, {
"CORScredentials": "include",
"hide": "all",
"selectors": {".hyphenate": {}},
"timeout": 1000
});
// Change mode string to mode int
H.s.hide = ["all", "element", "text"].indexOf(H.s.hide);
if (c.handleEvent) {
H.hev = c.handleEvent;
}
const fallbacks = mp(o.entries(c.fallbacks || {}));
H.lrq = mp();
o.entries(c.require).forEach(([lang, wo]) => {
H.lrq.set(lang.toLowerCase(), {
"fn": fallbacks.get(lang) || lang,
wo
});
});
main();
};
})(window, document, Hyphenopoly, Object);
/**
* @license Hyphenopoly 5.0.0-beta.1 - client side hyphenation for webbrowsers
* @license Hyphenopoly 5.0.0-beta.2 - client side hyphenation for webbrowsers
* ©2021 Mathias Nater, Güttingen (mathiasnater at gmail dot com)

@@ -35,4 +35,4 @@ * https://github.com/mnater/Hyphenopoly

]);
if (H.handleEvent) {
const userEvents = new Map(o.entries(H.handleEvent));
if (H.hev) {
const userEvents = new Map(o.entries(H.hev));
knownEvents.forEach((eventFuncs, eventName) => {

@@ -677,5 +677,3 @@ if (userEvents.has(eventName)) {

w.clearTimeout(H.timeOutHandler);
if (C.hide !== -1) {
H.hide(0, null);
}
H.hide(0, null);
event.fire(

@@ -857,21 +855,19 @@ "hyphenopolyEnd",

alphalen = registerSubstitutions(alphalen, exp);
prepareLanguagesObj(
lang,
encloseHyphenateFunction(
exp.mem.buffer,
exp.hyphenate
),
decode(new Uint16Array(exp.mem.buffer, 1280, alphalen)),
/* eslint-disable multiline-ternary */
(wa.Global) ? exp.lmi.value : exp.lmi,
(wa.Global) ? exp.rmi.value : exp.rmi
/* eslint-enable multiline-ternary */
);
heProm.l.forEach((l) => {
prepareLanguagesObj(
l,
encloseHyphenateFunction(
exp.mem.buffer,
exp.hyphenate
),
decode(new Uint16Array(exp.mem.buffer, 1280, alphalen)),
/* eslint-disable multiline-ternary */
(wa.Global) ? exp.lmi.value : exp.lmi,
(wa.Global) ? exp.rmi.value : exp.rmi
/* eslint-enable multiline-ternary */
);
});
}
heProm.w.then((response) => {
if (response.ok) {
let r2 = response;
if (heProm.c) {
r2 = response.clone();
}
if (

@@ -881,24 +877,5 @@ wa.instantiateStreaming &&

) {
// Return wa.instantiateStreaming(r2);
return wa.instantiateStreaming(r2, {
"hyphenEngine": {
"log": (value) => {
// eslint-disable-next-line no-console
return console.log(value);
},
"log2": (value) => {
// eslint-disable-next-line no-console
return console.log(
// eslint-disable-next-line no-bitwise
(value >>> 0).
toString(2).
padStart(32, "0")
);
}
}
});
return wa.instantiateStreaming(response);
}
return r2.arrayBuffer().then((ab) => {
return response.arrayBuffer().then((ab) => {
return wa.instantiate(ab);

@@ -914,39 +891,40 @@ });

H.res.DOM.then(() => {
mainLanguage = getLang(w.document.documentElement, "", false);
if (!mainLanguage && C.defaultLanguage !== "") {
mainLanguage = C.defaultLanguage;
}
const elements = collectElements();
H.res.els = elements;
elements.list.forEach((ignore, lang) => {
if (H.languages &&
H.languages.has(lang) &&
H.languages.get(lang).ready
) {
hyphenateLangElements(lang, elements);
H.main = () => {
H.res.DOM.then(() => {
mainLanguage = getLang(w.document.documentElement, "", false);
if (!mainLanguage && C.defaultLanguage !== "") {
mainLanguage = C.defaultLanguage;
}
const elements = collectElements();
H.res.els = elements;
elements.list.forEach((ignore, lang) => {
if (H.languages &&
H.languages.has(lang) &&
H.languages.get(lang).ready
) {
hyphenateLangElements(lang, elements);
}
});
});
});
H.res.he.forEach((heProm, lang) => {
instantiateWasmEngine(heProm, lang);
});
H.res.he.forEach(instantiateWasmEngine);
Promise.all(
// Make sure all lang specific hyphenators and DOM are ready
[...H.hy6ors.entries()].
reduce((accumulator, value) => {
if (value[0] !== "HTML") {
return accumulator.concat(value[1]);
}
return accumulator;
}, []).
concat(H.res.DOM)
).then(() => {
H.hy6ors.get("HTML").resolve(createDOMHyphenator());
}, (e) => {
event.fire("error", e);
});
Promise.all(
// Make sure all lang specific hyphenators and DOM are ready
[...H.hy6ors.entries()].
reduce((accumulator, value) => {
if (value[0] !== "HTML") {
return accumulator.concat(value[1]);
}
return accumulator;
}, []).
concat(H.res.DOM)
).then(() => {
H.hy6ors.get("HTML").resolve(createDOMHyphenator());
}, (e) => {
event.fire("error", e);
});
};
H.main();
})(Hyphenopoly);
})(window, Object);
/**
* @license Hyphenopoly.module.js 5.0.0-beta.1 - hyphenation for node
* @license Hyphenopoly.module.js 5.0.0-beta.2 - hyphenation for node
* ©2021 Mathias Nater, Güttingen (mathiasnater at gmail dot com)

@@ -4,0 +4,0 @@ * https://github.com/mnater/Hyphenopoly

/**
* @license Hyphenopoly_Loader 5.0.0-beta.1 - client side hyphenation
* @license Hyphenopoly_Loader 5.0.0-beta.2 - client side hyphenation
* ©2021 Mathias Nater, Güttingen (mathiasnater at gmail dot com)

@@ -9,2 +9,2 @@ * https://github.com/mnater/Hyphenopoly

*/
((e,t,s,n)=>{"use strict";const o=e=>new Map(e),r=(e,t)=>e?(n.entries(t).forEach((([t,s])=>{e[t]=e[t]||s})),e):t,l=sessionStorage,a="Hyphenopoly_Loader.js",i=o(),c="appendChild",h="createElement",d="createTextNode";s.cacheFeatureTests&&l.getItem(a)?(s.cf=JSON.parse(l.getItem(a)),s.cf.langs=o(s.cf.langs)):s.cf={langs:o(),pf:!1},(()=>{const e=t.currentScript.src,n=e.slice(0,e.lastIndexOf("/")+1),o=n+"patterns/";s.paths=r(s.paths,{maindir:n,patterndir:o}),s.s=r(s.setup,{CORScredentials:"include",hide:"all",selectors:{".hyphenate":{}},timeout:1e3}),s.s.hide=["all","element","text"].indexOf(s.s.hide)})(),(()=>{const e=o(n.entries(s.fallbacks||{}));n.entries(s.require).forEach((([t,s])=>{i.set(t.toLowerCase(),{fn:e.get(t)||t,wo:s})}))})();const p=()=>{let e=null,t=null;const s=new Promise(((s,n)=>{e=s,t=n}));return s.resolve=e,s.reject=t,s};let f=null;s.hide=(e,o)=>{if(0===e)f&&f.remove();else{const e="{visibility:hidden!important}";f=t[h]("style");let r="";0===o?r="html"+e:n.keys(s.s.selectors).forEach((t=>{r+=1===o?t+e:t+"{color:transparent!important}"})),f[c](t[d](r)),t.head[c](f)}};const y=(()=>{let e=null;return{ap:()=>e?(t.documentElement[c](e),e):null,cl:()=>{e&&e.remove()},cr:n=>{if(s.cf.langs.has(n))return;e=e||t[h]("body");const o=t[h]("div"),r="hyphens:auto";o.lang=n,o.style.cssText=`visibility:hidden;-webkit-${r};-ms-${r};${r};width:48px;font-size:12px;line-height:12px;border:none;padding:0;word-wrap:normal`,o[c](t[d](i.get(n).wo.toLowerCase())),e[c](o)}}})();s.res={he:o()};const g=o(),u=t=>{const n=i.get(t).fn+".wasm";if(s.cf.pf=!0,s.cf.langs.set(t,"H9Y"),g.has(n)){const e=s.res.he.get(g.get(n));e.c=!0,s.res.he.set(t,e)}else s.res.he.set(t,{w:e.fetch(s.paths.patterndir+n,{credentials:s.s.CORScredentials})}),g.set(n,t)};i.forEach(((e,t)=>{"FORCEHYPHENOPOLY"===e.wo||"H9Y"===s.cf.langs.get(t)?u(t):y.cr(t)}));const m=y.ap();m&&(m.querySelectorAll("div").forEach((e=>{var t;"auto"===((t=e.style).hyphens||t.webkitHyphens||t.msHyphens)&&e.offsetHeight>12?s.cf.langs.set(e.lang,"CSS"):u(e.lang)})),y.cl());const w=s.handleEvent;if(s.cf.pf){s.res.DOM=new Promise((e=>{"loading"===t.readyState?t.addEventListener("DOMContentLoaded",e,{once:!0,passive:!0}):e()}));const n=s.s.hide;0===n&&s.hide(1,0),-1!==n&&(s.timeOutHandler=e.setTimeout((()=>{s.hide(0,null),console.info(a+" timed out.")}),s.s.timeout)),s.res.DOM.then((()=>{n>0&&s.hide(1,n)}));const r=t[h]("script");r.src=s.paths.maindir+"Hyphenopoly.js",t.head[c](r),s.hy6ors=o(),s.cf.langs.forEach(((e,t)=>{"H9Y"===e&&s.hy6ors.set(t,p())})),s.hy6ors.set("HTML",p()),s.hyphenators=new Proxy(s.hy6ors,{get:(e,t)=>e.get(t),set:()=>!0}),w&&w.polyfill&&w.polyfill()}else w&&w.tearDown&&w.tearDown(),e.Hyphenopoly=null;s.cacheFeatureTests&&l.setItem(a,JSON.stringify({langs:[...s.cf.langs.entries()],pf:s.cf.pf}))})(window,document,Hyphenopoly,Object);
window.Hyphenopoly={},((e,t,s,n)=>{"use strict";const l=e=>new Map(e),r="Hyphenopoly_Loader.js",o=t.currentScript.src,a=sessionStorage;let i=!1;s.config=c=>{const h=(e,t)=>e?(n.entries(t).forEach((([t,s])=>{e[t]=e[t]||s})),e):t;s.cft=!!c.cacheFeatureTests,s.cft&&a.getItem(r)?(s.cf=JSON.parse(a.getItem(r)),s.cf.langs=l(s.cf.langs)):s.cf={langs:l(),pf:!1};const d=o.slice(0,o.lastIndexOf("/")+1),p=d+"patterns/";s.paths=h(c.paths,{maindir:d,patterndir:p}),s.s=h(c.setup,{CORScredentials:"include",hide:"all",selectors:{".hyphenate":{}},timeout:1e3}),s.s.hide=["all","element","text"].indexOf(s.s.hide),c.handleEvent&&(s.hev=c.handleEvent);const f=l(n.entries(c.fallbacks||{}));s.lrq=l(),n.entries(c.require).forEach((([e,t])=>{s.lrq.set(e.toLowerCase(),{fn:f.get(e)||e,wo:t})})),(()=>{const o="appendChild",c="createElement",h="createTextNode",d=()=>{let e=null,t=null;const s=new Promise(((s,n)=>{e=s,t=n}));return s.resolve=e,s.reject=t,s};let p=null;s.hide=(e,l)=>{if(0===e)p&&p.remove();else{let e="{visibility:hidden!important}";p=t[c]("style");let r="";0===l?r="html"+e:-1!==l&&(2===l&&(e="{color:transparent!important}"),n.keys(s.s.selectors).forEach((t=>{r+=t+e}))),p[o](t[h](r)),t.head[o](p)}};const f=(()=>{let e=null;return{ap:()=>e?(t.documentElement[o](e),e):null,cl:()=>{e&&e.remove()},cr:n=>{if(s.cf.langs.has(n))return;e=e||t[c]("body");const l=t[c]("div"),r="hyphens:auto";l.lang=n,l.style.cssText=`visibility:hidden;-webkit-${r};-ms-${r};${r};width:48px;font-size:12px;line-height:12px;border:none;padding:0;word-wrap:normal`,l[o](t[h](s.lrq.get(n).wo.toLowerCase())),e[o](l)}}})();s.res={he:l()};const y=t=>{const n=s.lrq.get(t).fn;s.cf.pf=!0,s.cf.langs.set(t,"H9Y"),s.res.he.has(n)?s.res.he.get(n).l.push(t):s.res.he.set(n,{l:[t],w:e.fetch(s.paths.patterndir+n+".wasm",{credentials:s.s.CORScredentials})})};s.lrq.forEach(((e,t)=>{"FORCEHYPHENOPOLY"===e.wo||"H9Y"===s.cf.langs.get(t)?y(t):f.cr(t)}));const g=f.ap();g&&(g.querySelectorAll("div").forEach((e=>{var t;"auto"===((t=e.style).hyphens||t.webkitHyphens||t.msHyphens)&&e.offsetHeight>12?s.cf.langs.set(e.lang,"CSS"):y(e.lang)})),f.cl());const m=s.hev;if(s.cf.pf){if(s.res.DOM=new Promise((e=>{"loading"===t.readyState?t.addEventListener("DOMContentLoaded",e,{once:!0,passive:!0}):e()})),s.hide(1,s.s.hide),s.timeOutHandler=e.setTimeout((()=>{s.hide(0,null),console.info(r+" timed out.")}),s.s.timeout),i)s.main();else{const e=t[c]("script");e.src=s.paths.maindir+"Hyphenopoly.js",t.head[o](e),i=!0}s.hy6ors=l(),s.cf.langs.forEach(((e,t)=>{"H9Y"===e&&s.hy6ors.set(t,d())})),s.hy6ors.set("HTML",d()),s.hyphenators=new Proxy(s.hy6ors,{get:(e,t)=>e.get(t),set:()=>!0}),m&&m.polyfill&&m.polyfill()}else m&&m.tearDown&&m.tearDown(),e.Hyphenopoly=null;s.cft&&a.setItem(r,JSON.stringify({langs:[...s.cf.langs.entries()],pf:s.cf.pf}))})()}})(window,document,Hyphenopoly,Object);
/**
* @license Hyphenopoly 5.0.0-beta.1 - client side hyphenation for webbrowsers
* @license Hyphenopoly 5.0.0-beta.2 - client side hyphenation for webbrowsers
* ©2021 Mathias Nater, Güttingen (mathiasnater at gmail dot com)

@@ -9,2 +9,2 @@ * https://github.com/mnater/Hyphenopoly

*/
((e,t)=>{"use strict";const n=(n=>{const r=new Map([["afterElementHyphenation",[]],["beforeElementHyphenation",[]],["engineReady",[]],["error",[t=>{t.runDefault&&e.console.warn(t)}]],["hyphenopolyEnd",[]],["hyphenopolyStart",[]]]);if(n.handleEvent){const e=new Map(t.entries(n.handleEvent));r.forEach(((t,n)=>{e.has(n)&&t.unshift(e.get(n))}))}return{fire:(e,t)=>{t.runDefault=!0,t.preventDefault=()=>{t.runDefault=!1},r.get(e).forEach((e=>{e(t)}))}}})(Hyphenopoly);(e=>{function n(e){const t=new Map;function n(n){return t.has(n)?t.get(n):e.get(n)}function r(e,n){t.set(e,n)}return new Proxy(e,{get:(e,t)=>"set"===t?r:"get"===t?n:n(t),ownKeys:()=>[...new Set([...e.keys(),...t.keys()])]})}const r=n(new Map([["defaultLanguage","en-us"],["dontHyphenate",n(new Map("abbr,acronym,audio,br,button,code,img,input,kbd,label,math,option,pre,samp,script,style,sub,sup,svg,textarea,var,video".split(",").map((e=>[e,!0]))))],["dontHyphenateClass","donthyphenate"],["exceptions",new Map],["keepAlive",!0],["normalize",!1],["processShadows",!1],["safeCopy",!0],["substitute",new Map],["timeout",1e3]]));t.entries(e.s).forEach((([e,o])=>{switch(e){case"selectors":r.set("selectors",t.keys(o)),t.entries(o).forEach((([e,o])=>{const a=n(new Map([["compound","hyphen"],["hyphen","­"],["leftmin",0],["leftminPerLang",0],["minWordLength",6],["mixedCase",!0],["orphanControl",1],["rightmin",0],["rightminPerLang",0]]));t.entries(o).forEach((([e,n])=>{"object"==typeof n?a.set(e,new Map(t.entries(n))):a.set(e,n)})),r.set(e,a)}));break;case"dontHyphenate":case"exceptions":t.entries(o).forEach((([t,n])=>{r.get(e).set(t,n)}));break;case"substitute":t.entries(o).forEach((([e,n])=>{r.substitute.set(e,new Map(t.entries(n)))}));break;default:r.set(e,o)}})),e.c=r})(Hyphenopoly),(r=>{const o=r.c;let a=null;function s(e,t="",n=!0){return(e=e.closest("[lang]:not([lang=''])"))&&e.lang?e.lang.toLowerCase():t||(n?a:null)}function l(a=null,l=null){const i=function(){const e=new Map,t=[0];return{add:function(n,r,o){const a={element:n,selector:o};return e.has(r)||e.set(r,[]),e.get(r).push(a),t[0]+=1,a},counter:t,list:e,rem:function(r){let a=0;e.has(r)&&(a=e.get(r).length,e.delete(r),t[0]-=a,0===t[0]&&(n.fire("hyphenopolyEnd",{msg:"hyphenopolyEnd"}),o.keepAlive||(window.Hyphenopoly=null)))}}}(),c=(()=>{let e="."+o.dontHyphenateClass;return t.getOwnPropertyNames(o.dontHyphenate).forEach((t=>{o.dontHyphenate.get(t)&&(e+=","+t)})),e})(),h=o.selectors.join(",")+","+c;function p(t,a,l,c=!1){const u=s(t,a),g=r.cf.langs.get(u);"H9Y"===g?(i.add(t,u,l),!c&&o.safeCopy&&function(t){t.addEventListener("copy",(t=>{t.preventDefault();const n=e.getSelection(),r=document.createElement("div");r.appendChild(n.getRangeAt(0).cloneContents()),t.clipboardData.setData("text/plain",n.toString().replace(/­/g,"")),t.clipboardData.setData("text/html",r.innerHTML.replace(/­/g,""))}),!0)}(t)):g||"zxx"===u||n.fire("error",Error(`Element with '${u}' found, but '${u}.wasm' not loaded. Check language tags!`)),t.childNodes.forEach((e=>{1!==e.nodeType||e.matches(h)||p(e,u,l,!0)}))}function u(e){o.selectors.forEach((t=>{e.querySelectorAll(t).forEach((e=>{p(e,s(e),t,!1)}))}))}return null===a?(o.processShadows&&e.document.querySelectorAll("*").forEach((e=>{e.shadowRoot&&u(e.shadowRoot)})),u(e.document)):p(a,s(a),l),i}n.fire("hyphenopolyStart",{msg:"hyphenopolyStart"});const i=new Map;function c(e,t,r){const a=t+"-"+r;if(i.has(a))return i.get(a);const s=o.get(r);function l(o){let a=e.cache.get(r).get(o);var l;return a||(a=e.exc.has(o)?e.exc.get(o).replace(/-/g,s.hyphen):!s.mixedCase&&(l=o,[...l].map((e=>e===e.toLowerCase())).some(((e,t,n)=>e!==n[0])))?o:-1===o.indexOf("-")?function(r){if(r.length>61)n.fire("error",Error("Found word longer than 61 characters"));else if(!e.reNotAlphabet.test(r))return e.hyphenate(r,s.hyphen.charCodeAt(0),s.leftminPerLang.get(t),s.rightminPerLang.get(t));return r}(o):function(n){let o=null,a=null;return"auto"===s.compound||"all"===s.compound?(a=c(e,t,r),o=n.split("-").map((e=>e.length>=s.minWordLength?a(e):e)),n="auto"===s.compound?o.join("-"):o.join("-​")):n=n.replace("-","-​"),n}(o),e.cache.get(r).set(o,a)),a}return e.cache.set(r,new Map),i.set(a,l),l}const h=new Map;function p(e,t,a){const s=r.languages.get(e),l=o.get(t),i=l.minWordLength,p=RegExp(`[${s.alphabet}a-z̀-ͯ҃-҇ß-öø-þāăąćĉčďđēėęěĝğģĥīįıĵķļľłńņňōőœŕřśŝşšťūŭůűųźżžſǎǐǒǔǖǘǚǜșțʼΐά-ώϐϣϥϧϩϫϭϯϲа-яё-ќўџґүөա-օևअ-ऌएऐओ-नप-रलळव-हऽॠॡঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹઅ-ઋએઐઓ-નપ-રલળવ-હઽૠଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହୠୡஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-வஷ-ஹఅ-ఌఎ-ఐఒ-నప-ళవ-హౠౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡഅ-ഌഎ-ഐഒ-നപ-ഹൠൡൺ-ൿก-ฮะาำเ-ๅა-ჰሀ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏḍḷṁṃṅṇṭἀ-ἇἐ-ἕἠ-ἧἰ-ἷὀ-ὅὐ-ὗὠ-ὧὰ-ώᾀ-ᾇᾐ-ᾗᾠ-ᾧᾲ-ᾴᾶᾷῂ-ῄῆῇῒΐῖῗῢ-ῧῲ-ῴῶῷⲁⲃⲅⲇⲉⲍⲏⲑⲓⲕⲗⲙⲛⲝⲟⲡⲣⲥⲧⲩⲫⲭⲯⲱⳉⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮ­​-‍-]{${i},}`,"gui");function u(n){o.normalize&&(n=n.normalize("NFC"));let r=n.replace(p,c(s,e,t));return 1!==l.orphanControl&&(r=r.replace(/(\u0020*)(\S+)(\s*)$/,function(e){if(h.has(e))return h.get(e);const t=o.get(e);function n(e,n,r,o){return 3===t.orphanControl&&" "===n&&(n=" "),n+r.replace(RegExp(t.hyphen,"g"),"")+o}return h.set(e,n),n}(t))),r}let g=null;var f;return"string"==typeof a?g=u(a):a instanceof HTMLElement&&(f=a,n.fire("beforeElementHyphenation",{el:f,lang:e}),f.childNodes.forEach((e=>{3===e.nodeType&&/\S/.test(e.data)&&e.data.length>=i&&(e.data=u(e.data))})),r.res.els.counter[0]-=1,n.fire("afterElementHyphenation",{el:f,lang:e})),g}function u(t,a){const s=a.list.get(t);s?s.forEach((e=>{p(t,e.selector,e.element)})):n.fire("error",Error(`Engine for language '${t}' loaded, but no elements found.`)),0===a.counter[0]&&(e.clearTimeout(r.timeOutHandler),-1!==o.hide&&r.hide(0,null),n.fire("hyphenopolyEnd",{msg:"hyphenopolyEnd"}),o.keepAlive||(window.Hyphenopoly=null))}function g(e){let t="";return o.exceptions.has(e)&&(t=o.exceptions.get(e)),o.exceptions.has("global")&&(""===t?t=o.exceptions.get("global"):t+=", "+o.exceptions.get("global")),""===t?new Map:new Map(t.split(", ").map((e=>[e.replace(/-/g,""),e])))}r.unhyphenate=()=>(r.res.els.list.forEach((e=>{e.forEach((e=>{const t=e.element.firstChild;t.data=t.data.replace(RegExp(o[e.selector].hyphen,"g"),"")}))})),Promise.resolve(r.res.els));const f=(()=>{if(e.TextDecoder){const e=new TextDecoder("utf-16le");return t=>e.decode(t)}return e=>String.fromCharCode.apply(null,e)})();r.res.DOM.then((()=>{a=s(e.document.documentElement,"",!1),a||""===o.defaultLanguage||(a=o.defaultLanguage);const t=l();r.res.els=t,t.list.forEach(((e,n)=>{r.languages&&r.languages.has(n)&&r.languages.get(n).ready&&u(n,t)}))})),r.res.he.forEach(((e,t)=>{!function(e,t){const a=window.WebAssembly;e.w.then((n=>{if(n.ok){let t=n;return e.c&&(t=n.clone()),a.instantiateStreaming&&"application/wasm"===n.headers.get("Content-Type")?a.instantiateStreaming(t,{hyphenEngine:{log:e=>console.log(e),log2:e=>console.log((e>>>0).toString(2).padStart(32,"0"))}}):t.arrayBuffer().then((e=>a.instantiate(e)))}return Promise.reject(Error(`File ${t}.wasm can't be loaded from ${r.paths.patterndir}`))})).then((function(e){const s=e.instance.exports;let l=a.Global?s.lct.value:s.lct;l=function(e,n){return o.substitute.has(t)&&o.substitute.get(t).forEach(((t,r)=>{const o=r.toUpperCase(),a=o===r?0:o.charCodeAt(0);e=n.subst(r.charCodeAt(0),a,t.charCodeAt(0))})),e}(l,s),function(e,t,a,s,l){o.selectors.forEach((t=>{const n=o.get(t);0===n.leftminPerLang&&n.set("leftminPerLang",new Map),0===n.rightminPerLang&&n.set("rightminPerLang",new Map),n.leftminPerLang.set(e,Math.max(s,n.leftmin,Number(n.leftminPerLang.get(e))||0)),n.rightminPerLang.set(e,Math.max(l,n.rightmin,Number(n.rightminPerLang.get(e))||0))})),r.languages||(r.languages=new Map),a=a.replace(/\\*-/g,"\\-"),r.languages.set(e,{alphabet:a,cache:new Map,exc:g(e),hyphenate:t,ready:!0,reNotAlphabet:RegExp(`[^${a}]`,"i")}),r.hy6ors.get(e).resolve(function(e){return(t,r=".hyphenate")=>("string"!=typeof t&&n.fire("error",Error("This use of hyphenators is deprecated. See https://mnater.github.io/Hyphenopoly/Hyphenators.html")),p(e,r,t))}(e)),n.fire("engineReady",{lang:e}),r.res.els&&u(e,r.res.els)}(t,function(e,t){const n=new Uint16Array(e,0,64);return(r,o,a,s)=>{n.set([46,...[...r].map((e=>e.charCodeAt(0))),46,0]);const l=t(a,s,o);return l>0&&(r=f(new Uint16Array(e,0,l))),r}}(s.mem.buffer,s.hyphenate),f(new Uint16Array(s.mem.buffer,1280,l)),a.Global?s.lmi.value:s.lmi,a.Global?s.rmi.value:s.rmi)}),(e=>{n.fire("error",e),r.res.els.rem(t)}))}(e,t)})),Promise.all([...r.hy6ors.entries()].reduce(((e,t)=>"HTML"!==t[0]?e.concat(t[1]):e),[]).concat(r.res.DOM)).then((()=>{r.hy6ors.get("HTML").resolve(((e,t=".hyphenate")=>(l(e,t).list.forEach(((e,t)=>{e.forEach((e=>{p(t,e.selector,e.element)}))})),null)))}),(e=>{n.fire("error",e)}))})(Hyphenopoly)})(window,Object);
((e,t)=>{"use strict";const n=(n=>{const r=new Map([["afterElementHyphenation",[]],["beforeElementHyphenation",[]],["engineReady",[]],["error",[t=>{t.runDefault&&e.console.warn(t)}]],["hyphenopolyEnd",[]],["hyphenopolyStart",[]]]);if(n.hev){const e=new Map(t.entries(n.hev));r.forEach(((t,n)=>{e.has(n)&&t.unshift(e.get(n))}))}return{fire:(e,t)=>{t.runDefault=!0,t.preventDefault=()=>{t.runDefault=!1},r.get(e).forEach((e=>{e(t)}))}}})(Hyphenopoly);(e=>{function n(e){const t=new Map;function n(n){return t.has(n)?t.get(n):e.get(n)}function r(e,n){t.set(e,n)}return new Proxy(e,{get:(e,t)=>"set"===t?r:"get"===t?n:n(t),ownKeys:()=>[...new Set([...e.keys(),...t.keys()])]})}const r=n(new Map([["defaultLanguage","en-us"],["dontHyphenate",n(new Map("abbr,acronym,audio,br,button,code,img,input,kbd,label,math,option,pre,samp,script,style,sub,sup,svg,textarea,var,video".split(",").map((e=>[e,!0]))))],["dontHyphenateClass","donthyphenate"],["exceptions",new Map],["keepAlive",!0],["normalize",!1],["processShadows",!1],["safeCopy",!0],["substitute",new Map],["timeout",1e3]]));t.entries(e.s).forEach((([e,a])=>{switch(e){case"selectors":r.set("selectors",t.keys(a)),t.entries(a).forEach((([e,a])=>{const o=n(new Map([["compound","hyphen"],["hyphen","­"],["leftmin",0],["leftminPerLang",0],["minWordLength",6],["mixedCase",!0],["orphanControl",1],["rightmin",0],["rightminPerLang",0]]));t.entries(a).forEach((([e,n])=>{"object"==typeof n?o.set(e,new Map(t.entries(n))):o.set(e,n)})),r.set(e,o)}));break;case"dontHyphenate":case"exceptions":t.entries(a).forEach((([t,n])=>{r.get(e).set(t,n)}));break;case"substitute":t.entries(a).forEach((([e,n])=>{r.substitute.set(e,new Map(t.entries(n)))}));break;default:r.set(e,a)}})),e.c=r})(Hyphenopoly),(r=>{const a=r.c;let o=null;function s(e,t="",n=!0){return(e=e.closest("[lang]:not([lang=''])"))&&e.lang?e.lang.toLowerCase():t||(n?o:null)}function l(o=null,l=null){const i=function(){const e=new Map,t=[0];return{add:function(n,r,a){const o={element:n,selector:a};return e.has(r)||e.set(r,[]),e.get(r).push(o),t[0]+=1,o},counter:t,list:e,rem:function(r){let o=0;e.has(r)&&(o=e.get(r).length,e.delete(r),t[0]-=o,0===t[0]&&(n.fire("hyphenopolyEnd",{msg:"hyphenopolyEnd"}),a.keepAlive||(window.Hyphenopoly=null)))}}}(),c=(()=>{let e="."+a.dontHyphenateClass;return t.getOwnPropertyNames(a.dontHyphenate).forEach((t=>{a.dontHyphenate.get(t)&&(e+=","+t)})),e})(),h=a.selectors.join(",")+","+c;function p(t,o,l,c=!1){const u=s(t,o),g=r.cf.langs.get(u);"H9Y"===g?(i.add(t,u,l),!c&&a.safeCopy&&function(t){t.addEventListener("copy",(t=>{t.preventDefault();const n=e.getSelection(),r=document.createElement("div");r.appendChild(n.getRangeAt(0).cloneContents()),t.clipboardData.setData("text/plain",n.toString().replace(/­/g,"")),t.clipboardData.setData("text/html",r.innerHTML.replace(/­/g,""))}),!0)}(t)):g||"zxx"===u||n.fire("error",Error(`Element with '${u}' found, but '${u}.wasm' not loaded. Check language tags!`)),t.childNodes.forEach((e=>{1!==e.nodeType||e.matches(h)||p(e,u,l,!0)}))}function u(e){a.selectors.forEach((t=>{e.querySelectorAll(t).forEach((e=>{p(e,s(e),t,!1)}))}))}return null===o?(a.processShadows&&e.document.querySelectorAll("*").forEach((e=>{e.shadowRoot&&u(e.shadowRoot)})),u(e.document)):p(o,s(o),l),i}n.fire("hyphenopolyStart",{msg:"hyphenopolyStart"});const i=new Map;function c(e,t,r){const o=t+"-"+r;if(i.has(o))return i.get(o);const s=a.get(r);function l(a){let o=e.cache.get(r).get(a);var l;return o||(o=e.exc.has(a)?e.exc.get(a).replace(/-/g,s.hyphen):!s.mixedCase&&(l=a,[...l].map((e=>e===e.toLowerCase())).some(((e,t,n)=>e!==n[0])))?a:-1===a.indexOf("-")?function(r){if(r.length>61)n.fire("error",Error("Found word longer than 61 characters"));else if(!e.reNotAlphabet.test(r))return e.hyphenate(r,s.hyphen.charCodeAt(0),s.leftminPerLang.get(t),s.rightminPerLang.get(t));return r}(a):function(n){let a=null,o=null;return"auto"===s.compound||"all"===s.compound?(o=c(e,t,r),a=n.split("-").map((e=>e.length>=s.minWordLength?o(e):e)),n="auto"===s.compound?a.join("-"):a.join("-​")):n=n.replace("-","-​"),n}(a),e.cache.get(r).set(a,o)),o}return e.cache.set(r,new Map),i.set(o,l),l}const h=new Map;function p(e,t,o){const s=r.languages.get(e),l=a.get(t),i=l.minWordLength,p=RegExp(`[${s.alphabet}a-z̀-ͯ҃-҇ß-öø-þāăąćĉčďđēėęěĝğģĥīįıĵķļľłńņňōőœŕřśŝşšťūŭůűųźżžſǎǐǒǔǖǘǚǜșțʼΐά-ώϐϣϥϧϩϫϭϯϲа-яё-ќўџґүөա-օևअ-ऌएऐओ-नप-रलळव-हऽॠॡঅ-ঌএঐও-নপ-রলশ-হঽৎড়ঢ়য়-ৡਅ-ਊਏਐਓ-ਨਪ-ਰਲਲ਼ਵਸ਼ਸਹઅ-ઋએઐઓ-નપ-રલળવ-હઽૠଅ-ଌଏଐଓ-ନପ-ରଲଳଵ-ହୠୡஃஅ-ஊஎ-ஐஒ-கஙசஜஞடணதந-பம-வஷ-ஹఅ-ఌఎ-ఐఒ-నప-ళవ-హౠౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠೡഅ-ഌഎ-ഐഒ-നപ-ഹൠൡൺ-ൿก-ฮะาำเ-ๅა-ჰሀ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏḍḷṁṃṅṇṭἀ-ἇἐ-ἕἠ-ἧἰ-ἷὀ-ὅὐ-ὗὠ-ὧὰ-ώᾀ-ᾇᾐ-ᾗᾠ-ᾧᾲ-ᾴᾶᾷῂ-ῄῆῇῒΐῖῗῢ-ῧῲ-ῴῶῷⲁⲃⲅⲇⲉⲍⲏⲑⲓⲕⲗⲙⲛⲝⲟⲡⲣⲥⲧⲩⲫⲭⲯⲱⳉⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞꬁ-ꬆꬉ-ꬎꬑ-ꬖꬠ-ꬦꬨ-ꬮ­​-‍-]{${i},}`,"gui");function u(n){a.normalize&&(n=n.normalize("NFC"));let r=n.replace(p,c(s,e,t));return 1!==l.orphanControl&&(r=r.replace(/(\u0020*)(\S+)(\s*)$/,function(e){if(h.has(e))return h.get(e);const t=a.get(e);function n(e,n,r,a){return 3===t.orphanControl&&" "===n&&(n=" "),n+r.replace(RegExp(t.hyphen,"g"),"")+a}return h.set(e,n),n}(t))),r}let g=null;var f;return"string"==typeof o?g=u(o):o instanceof HTMLElement&&(f=o,n.fire("beforeElementHyphenation",{el:f,lang:e}),f.childNodes.forEach((e=>{3===e.nodeType&&/\S/.test(e.data)&&e.data.length>=i&&(e.data=u(e.data))})),r.res.els.counter[0]-=1,n.fire("afterElementHyphenation",{el:f,lang:e})),g}function u(t,o){const s=o.list.get(t);s?s.forEach((e=>{p(t,e.selector,e.element)})):n.fire("error",Error(`Engine for language '${t}' loaded, but no elements found.`)),0===o.counter[0]&&(e.clearTimeout(r.timeOutHandler),r.hide(0,null),n.fire("hyphenopolyEnd",{msg:"hyphenopolyEnd"}),a.keepAlive||(window.Hyphenopoly=null))}function g(e){let t="";return a.exceptions.has(e)&&(t=a.exceptions.get(e)),a.exceptions.has("global")&&(""===t?t=a.exceptions.get("global"):t+=", "+a.exceptions.get("global")),""===t?new Map:new Map(t.split(", ").map((e=>[e.replace(/-/g,""),e])))}r.unhyphenate=()=>(r.res.els.list.forEach((e=>{e.forEach((e=>{const t=e.element.firstChild;t.data=t.data.replace(RegExp(a[e.selector].hyphen,"g"),"")}))})),Promise.resolve(r.res.els));const f=(()=>{if(e.TextDecoder){const e=new TextDecoder("utf-16le");return t=>e.decode(t)}return e=>String.fromCharCode.apply(null,e)})();function d(e,t){const o=window.WebAssembly;e.w.then((e=>e.ok?o.instantiateStreaming&&"application/wasm"===e.headers.get("Content-Type")?o.instantiateStreaming(e):e.arrayBuffer().then((e=>o.instantiate(e))):Promise.reject(Error(`File ${t}.wasm can't be loaded from ${r.paths.patterndir}`)))).then((function(s){const l=s.instance.exports;let i=o.Global?l.lct.value:l.lct;i=function(e,n){return a.substitute.has(t)&&a.substitute.get(t).forEach(((t,r)=>{const a=r.toUpperCase(),o=a===r?0:a.charCodeAt(0);e=n.subst(r.charCodeAt(0),o,t.charCodeAt(0))})),e}(i,l),e.l.forEach((e=>{!function(e,t,o,s,l){a.selectors.forEach((t=>{const n=a.get(t);0===n.leftminPerLang&&n.set("leftminPerLang",new Map),0===n.rightminPerLang&&n.set("rightminPerLang",new Map),n.leftminPerLang.set(e,Math.max(s,n.leftmin,Number(n.leftminPerLang.get(e))||0)),n.rightminPerLang.set(e,Math.max(l,n.rightmin,Number(n.rightminPerLang.get(e))||0))})),r.languages||(r.languages=new Map),o=o.replace(/\\*-/g,"\\-"),r.languages.set(e,{alphabet:o,cache:new Map,exc:g(e),hyphenate:t,ready:!0,reNotAlphabet:RegExp(`[^${o}]`,"i")}),r.hy6ors.get(e).resolve(function(e){return(t,r=".hyphenate")=>("string"!=typeof t&&n.fire("error",Error("This use of hyphenators is deprecated. See https://mnater.github.io/Hyphenopoly/Hyphenators.html")),p(e,r,t))}(e)),n.fire("engineReady",{lang:e}),r.res.els&&u(e,r.res.els)}(e,function(e,t){const n=new Uint16Array(e,0,64);return(r,a,o,s)=>{n.set([46,...[...r].map((e=>e.charCodeAt(0))),46,0]);const l=t(o,s,a);return l>0&&(r=f(new Uint16Array(e,0,l))),r}}(l.mem.buffer,l.hyphenate),f(new Uint16Array(l.mem.buffer,1280,i)),o.Global?l.lmi.value:l.lmi,o.Global?l.rmi.value:l.rmi)}))}),(e=>{n.fire("error",e),r.res.els.rem(t)}))}r.main=()=>{r.res.DOM.then((()=>{o=s(e.document.documentElement,"",!1),o||""===a.defaultLanguage||(o=a.defaultLanguage);const t=l();r.res.els=t,t.list.forEach(((e,n)=>{r.languages&&r.languages.has(n)&&r.languages.get(n).ready&&u(n,t)}))})),r.res.he.forEach(d),Promise.all([...r.hy6ors.entries()].reduce(((e,t)=>"HTML"!==t[0]?e.concat(t[1]):e),[]).concat(r.res.DOM)).then((()=>{r.hy6ors.get("HTML").resolve(((e,t=".hyphenate")=>(l(e,t).list.forEach(((e,t)=>{e.forEach((e=>{p(t,e.selector,e.element)}))})),null)))}),(e=>{n.fire("error",e)}))},r.main()})(Hyphenopoly)})(window,Object);
{
"name": "hyphenopoly",
"version": "5.0.0-beta.1",
"version": "5.0.0-beta.2",
"description": "Hyphenation for node and Polyfill for client-side hyphenation.",

@@ -44,15 +44,15 @@ "keywords": [

"devDependencies": {
"@typescript-eslint/eslint-plugin": "^4.31.1",
"@typescript-eslint/parser": "^4.31.1",
"@typescript-eslint/eslint-plugin": "^5.3.0",
"@typescript-eslint/parser": "^5.3.0",
"all-contributors-cli": "^6.20.0",
"assemblyscript": "^0.19.14",
"assemblyscript": "^0.19.18",
"characterset": "^1.3.0",
"eslint": "^7.32.0",
"eslint": "^8.1.0",
"eslint-plugin-security": "^1.4.0",
"remark-cli": "^10.0.0",
"remark-lint-no-consecutive-blank-lines": "^4.0.1",
"remark-preset-lint-recommended": "^6.0.1",
"tap": "^15.0.9",
"terser": "^5.8.0",
"typescript": "^4.4.3",
"remark-lint-no-consecutive-blank-lines": "^4.1.1",
"remark-preset-lint-recommended": "^6.1.1",
"tap": "^15.0.10",
"terser": "^5.9.0",
"typescript": "^4.4.4",
"yaml": "^1.10.2"

@@ -59,0 +59,0 @@ },

# Hyphenopoly.js
[![Build Status](https://travis-ci.org/mnater/Hyphenopoly.svg?branch=master)](https://travis-ci.org/mnater/Hyphenopoly) [![Coverage Status](https://coveralls.io/repos/github/mnater/Hyphenopoly/badge.svg?branch=master)](https://coveralls.io/github/mnater/Hyphenopoly?branch=master) [![dependencies Status](https://david-dm.org/mnater/Hyphenopoly/status.svg)](https://david-dm.org/mnater/Hyphenopoly) [![devDependencies Status](https://david-dm.org/mnater/Hyphenopoly/dev-status.svg)](https://david-dm.org/mnater/Hyphenopoly?type=dev) [![npms score](https://badges.npms.io/hyphenopoly.svg)](https://npms.io/search?q=hyphenopoly) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/de50e1ae70a64a47b0bd9b5449f89353)](https://www.codacy.com/app/mnater/Hyphenopoly?utm_source=github.com&utm_medium=referral&utm_content=mnater/Hyphenopoly&utm_campaign=Badge_Grade)
[![Build Status](https://app.travis-ci.com/mnater/Hyphenopoly.svg?branch=master)](https://travis-ci.com/mnater/Hyphenopoly) [![Coverage Status](https://coveralls.io/repos/github/mnater/Hyphenopoly/badge.svg?branch=master)](https://coveralls.io/github/mnater/Hyphenopoly?branch=master) [![dependencies Status](https://david-dm.org/mnater/Hyphenopoly/status.svg)](https://david-dm.org/mnater/Hyphenopoly) [![devDependencies Status](https://david-dm.org/mnater/Hyphenopoly/dev-status.svg)](https://david-dm.org/mnater/Hyphenopoly?type=dev) [![npms score](https://badges.npms.io/hyphenopoly.svg)](https://npms.io/search?q=hyphenopoly) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/de50e1ae70a64a47b0bd9b5449f89353)](https://www.codacy.com/app/mnater/Hyphenopoly?utm_source=github.com&utm_medium=referral&utm_content=mnater/Hyphenopoly&utm_campaign=Badge_Grade)

@@ -9,3 +9,3 @@ Hyphenopoly.js is a __JavaScript-polyfill for hyphenation in HTML__: it hyphenates text if the user agent does not support CSS-hyphenation at all or not for the required languages and it is a __Node.js-module__.

- _Hyphenopoly.js_ (~36KB unpacked, ~5KB minified and compressed): does the whole DOM-foo and wraps wasm.
- _wasm-Modules_ (sizes differ! e.g. en-us.wasm: ~24KB uncompressed, ~15KB compressed): core hyphenation functions and hyphenation patterns in a space saving binary format (including pattern license).
- _wasm-Modules_ (sizes differ! e.g. en-us.wasm: ~21KB uncompressed, ~15KB compressed): core hyphenation functions and hyphenation patterns in a space saving binary format (including pattern license).
- _hyphenopoly.module.js_: the node module to hyphenate plain text strings.

@@ -15,3 +15,6 @@

Place all code for Hyphenopoly at the top of the header (immediately after the `<title>` tag) to ensure resources are loaded as early as possible.
You'll have to insert two script blocks. In the first block provide the initial configurations for Hyphenopoly_Loader as inline script. In the second block load Hyphenopoly_Loader.js as external script.
You'll have to insert two script blocks. In the first block load Hyphenopoly_Loader.js as external script.
In the second block provide the initial configurations for Hyphenopoly_Loader as inline script. This also triggers all further steps.
Also, don't forget to enable CSS hyphenation.

@@ -27,3 +30,4 @@

<script>
var Hyphenopoly = {
<script src="./Hyphenopoly_Loader.js"></script>
Hyphenopoly.config({
require: {

@@ -39,5 +43,4 @@ "la": "honorificabilitudinitas",

}
};
});
</script>
<script src="./Hyphenopoly_Loader.js"></script>
<style type="text/css">

@@ -76,14 +79,18 @@ body {

### First script block – configurations
Hyphenopoly_Loader.js needs some information to run. This information is provided in a globally accessible Object called `Hyphenopoly`. Hyphenopoly_Loader.js and (if necessary) Hyphenopoly.js will add other methods and properties only to this object – there will be no other global variables/functions beyond this object.
### script blocks – load, configure and run Hyphenopoly_Loader.js
Hyphenopoly_Loader.js needs some information to run. This information is provided as a parameter object to the function `Hyphenopoly.config()`. This information is stored in a globally accessible Object called `window.Hyphenopoly`. Hyphenopoly_Loader.js and (if necessary) Hyphenopoly.js will add other methods and properties only to this object – there will be no other global variables/functions beyond this object.
#### require
The `Hyphenopoly` object must have exactly one property called `require` which itself is an object containing at least one nameValuePair where the name is a language code string (Some languages are region-specific. See the patterns directory for supported languages. E.g. just using `en` won't work, use either `en-us`or `en-gb`) and the value is a long word string in that language (preferably more than 12 characters long).
The configuration object must have exactly one property called `require` which itself is an object containing at least one nameValuePair where the name is a language code string (Some languages are region-specific. See the patterns directory for supported languages. E.g. just using `en` won't work, use `en-us`or `en-gb`) and the value is a long word string in that language (preferably more than 12 characters long).
Hyphenator_Loader.js will feature test the client (aka browser, aka user agent) for CSS-hyphens support for the given languages with the given words respectively. In the example above it will test if the client supports CSS-hyphenation for latin, german and us-english.
If you want to force the usage of Hyphenopoly.js for a language (e.g. for testing purposes) write `"FORCEHYPHENOPOLY"` instead of the long word.
### Second script block – load and run Hyphenopoly_Loader.js
Hyphenopoly_Loader.js tests if the browser supports CSS hyphenation for the language(s) given in `Hyphenopoly.require`. If one of the given languages isn't supported it automatically hides the documents contents and loads Hyphenopoly.js and the necessary WebAssembly modules. Hyphenopoly.js – once loaded – will hyphenate the elements according to the settings and unhide the document when it's done. If something goes wrong and Hyphenopoly.js is unable to unhide the document Hyphenopoly_Loader.js has a timeout that kicks in after some time (defaults to 1000ms) and unhides the document and writes a message to the console.
Hyphenopoly_Loader.js tests if the client (aka browser, aka user agent) supports CSS hyphenation for the language(s) given in `require`. In the example above it will test if the client supports CSS-hyphenation for latin, german and us-english.
If one of the given languages isn't supported, it automatically hides the documents contents and loads Hyphenopoly.js and the necessary WebAssembly modules.
Hyphenopoly.js – once loaded – will hyphenate the elements according to the settings and unhide the document when it's done.
If something goes wrong and Hyphenopoly.js is unable to unhide the document Hyphenopoly_Loader.js has a timeout that kicks in after some time (defaults to 1000ms) and unhides the document and writes a message to the console.
If the browser supports all required languages the script deletes the `Hyphenopoly`-object and terminates without further ado.

@@ -162,4 +169,6 @@

The patterns are precomputed and available for many languages on CTAN. Hyphenopoly.js uses a proprietary binary format (including pattern license, metadata and the patterns). Patterns are computed from a large list of hyphenated words by a program called `patgen`. They aim to find some hyphenation points – not all – because it's better to miss a hyphenation point then to have some false hyphenation points. Most patterns are really good but none is error free.
The patterns are precomputed and available for many languages on [CTAN](https://www.ctan.org/tex-archive/language/hyphenation/) and [tex-hyphen](https://github.com/hyphenation/tex-hyphen). For Hyphenopoly.js they are converted to a succinct trie data structure (including pattern license, metadata and the patterns).
The original patterns are computed from a large list of hyphenated words by a program called `patgen`. They aim to find some hyphenation points – not all – because it's better to miss a hyphenation point then to have some false hyphenation points. Most patterns are really good but none is error free.
These pattern vary in size. This is mostly due to the different linguistic characteristics of the languages.

@@ -166,0 +175,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc