unicode-input-toolconverter 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc.json +3 -0
- package/.editorconfig +16 -0
- package/.nojekyll +0 -0
- package/.nyc_output/out.json +173804 -0
- package/.nyc_output/processinfo/index.json +1 -0
- package/CHANGES.md +11 -0
- package/COPYING.LESSER.txt +180 -0
- package/COPYING.txt +687 -0
- package/README.md +65 -0
- package/_locales/en-US/messages.json +3126 -0
- package/_locales/hu-HU/messages.json +3126 -0
- package/_locales/pt-BR/messages.json +3126 -0
- package/_locales/sv-SE/messages.json +3126 -0
- package/babel.config.json +5 -0
- package/browser_action/characterSelection.js +91 -0
- package/browser_action/charrefConverters.js +389 -0
- package/browser_action/chartBuild.js +155 -0
- package/browser_action/encodingBehaviors.js +72 -0
- package/browser_action/encodings.js +97 -0
- package/browser_action/entities.js +12 -0
- package/browser_action/entityBehaviors.js +96 -0
- package/browser_action/index-es.html +15 -0
- package/browser_action/index-instrumented.html +16 -0
- package/browser_action/index-pages.html +16 -0
- package/browser_action/index.html +16 -0
- package/browser_action/index.iife.min.js +2 -0
- package/browser_action/index.iife.min.js.map +1 -0
- package/browser_action/index.instrumented.iife.min.js +2 -0
- package/browser_action/index.instrumented.iife.min.js.map +1 -0
- package/browser_action/index.js +95 -0
- package/browser_action/preferences/prefDefaults.js +52 -0
- package/browser_action/service-worker/sw-activateCallback.js +53 -0
- package/browser_action/service-worker/sw-locales.json +6 -0
- package/browser_action/service-worker/sw-resources.json +73 -0
- package/browser_action/service-worker/sw-unicode-data.json +3 -0
- package/browser_action/styles/unicode-dialog.css +391 -0
- package/browser_action/templateUtils/elements.js +12 -0
- package/browser_action/templateUtils/fill.js +3 -0
- package/browser_action/templateUtils/validation.js +6 -0
- package/browser_action/templates/chartBuild.js +185 -0
- package/browser_action/templates/index.js +1304 -0
- package/browser_action/templatesElementCustomization/widgets.js +56 -0
- package/browser_action/unicode/UnicodeConverter.js +793 -0
- package/browser_action/unicode/charrefunicodeDb.js +258 -0
- package/browser_action/unicode/getScriptInfoForCodePoint.js +646 -0
- package/browser_action/unicode/hangul.js +253 -0
- package/browser_action/unicode/lastScriptNames.json +5 -0
- package/browser_action/unicode/parseUnihanFromTextFileStrings.js +56 -0
- package/browser_action/unicode/unicodeFieldInfo.js +120 -0
- package/browser_action/unicode/unicodeScripts.js +4912 -0
- package/browser_action/unicode/unihan.js +129 -0
- package/browser_action/unicode/unihanDbPopulate.js +26 -0
- package/browser_action/unicodecharref.js +1480 -0
- package/browser_action/utils/DOMUtils.js +122 -0
- package/browser_action/utils/FetchUtils.js +19 -0
- package/browser_action/utils/TextUtils.js +28 -0
- package/browser_action/utils/TypedArrayUtils.js +21 -0
- package/browser_action/utils/semicolonSeparatedToArray.js +12 -0
- package/browser_action/utils/setupServiceWorker.js +193 -0
- package/cypress.config.js +21 -0
- package/download/entities/copyright-software-20021231.html +70 -0
- package/download/entities/html5-uppercase.ent +54 -0
- package/download/entities/htmlmathml-f.ent +2164 -0
- package/download/entities/isoamsa.ent +201 -0
- package/download/entities/isoamsb.ent +177 -0
- package/download/entities/isoamsc.ent +77 -0
- package/download/entities/isoamsn.ent +148 -0
- package/download/entities/isoamso.ent +107 -0
- package/download/entities/isoamsr.ent +238 -0
- package/download/entities/isobox.ent +95 -0
- package/download/entities/isocyr1.ent +122 -0
- package/download/entities/isocyr2.ent +81 -0
- package/download/entities/isodia.ent +69 -0
- package/download/entities/isogrk1.ent +104 -0
- package/download/entities/isogrk2.ent +75 -0
- package/download/entities/isogrk3.ent +98 -0
- package/download/entities/isogrk4.ent +98 -0
- package/download/entities/isolat1.ent +117 -0
- package/download/entities/isolat2.ent +176 -0
- package/download/entities/isomfrk.ent +107 -0
- package/download/entities/isomopf.ent +81 -0
- package/download/entities/isomscr.ent +107 -0
- package/download/entities/isonum.ent +131 -0
- package/download/entities/isopub.ent +140 -0
- package/download/entities/isotech.ent +216 -0
- package/download/entities/mmlalias.ent +598 -0
- package/download/entities/mmlextra.ent +154 -0
- package/download/entities/predefined.ent +52 -0
- package/download/entities/w3centities-f.ent +2276 -0
- package/download/entities/xhtml1-lat1.ent +143 -0
- package/download/entities/xhtml1-special.ent +78 -0
- package/download/entities/xhtml1-symbol.ent +171 -0
- package/eslint.config.js +66 -0
- package/icons/openWindow16.png +0 -0
- package/icons/openWindow24.png +0 -0
- package/lgtm.yml +5 -0
- package/lib/background.html +11 -0
- package/lib/background.js +13 -0
- package/lib/overlay.css +6 -0
- package/manifest.json +37 -0
- package/package.json +121 -0
- package/polyfills/browser-polyfill.min.js +8 -0
- package/polyfills/browser-polyfill.min.js.map +1 -0
- package/server.js +61 -0
- package/sw.js +259 -0
- package/tools/entities-import.js +62 -0
- package/tools/findEsResources.js +30 -0
- package/tools/list-locales.js +17 -0
- package/tools/parseUnicodeCharts.js +428 -0
- package/tools/ucd-import.js +24 -0
- package/tools/unicode-charts.html +596 -0
- package/tools/unihan-import.js +72 -0
- package/unicode_copyright.txt +46 -0
- package/vendor/camelcase/index.js +110 -0
- package/vendor/fflate/esm/browser.js +2665 -0
- package/vendor/intl-dom/dist/index.esm.js +2962 -0
- package/vendor/jamilih/dist/jml-es.js +2359 -0
- package/vendor/jquery/dist/jquery.js +10716 -0
- package/vendor/json-6/dist/index.mjs +1783 -0
- package/vendor/miller-columns/dist/index-es.min.js +1 -0
- package/vendor/miller-columns/miller-columns.css +75 -0
- package/vendor/simple-prefs/dist/index.esm.js +286 -0
- package/web-ext-config.cjs +13 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e,{before:t,after:n,favicon:c,canvas:s,image:r=!0,acceptErrors:l}={}){return e=Array.isArray(e)?e:[e],Promise.all(e.map(e=>function(e){let i={};Array.isArray(e)&&([e,i={}]=e);let{favicon:a=c}=i;const{before:o=t,after:d=n,canvas:u=s,image:f=r}=i;function h(){o?o.before(m):d?d.after(m):document.head.appendChild(m)}const m=document.createElement("link");return new Promise((t,n)=>{let c=n;if(l&&(c="function"==typeof l?c=>{l({error:c,stylesheetURL:e,options:i,resolve:t,reject:n})}:t),e.endsWith(".css")?a=!1:e.endsWith(".ico")&&(a=!0),a){if(m.rel="shortcut icon",m.type="image/x-icon",!1===f)return m.href=e,h(),void t(m);const c=document.createElement("canvas");c.width=16,c.height=16;const s=c.getContext("2d"),r=document.createElement("img");return r.addEventListener("error",e=>{n(e)}),r.addEventListener("load",()=>{s.drawImage(r,0,0),m.href=u?c.toDataURL("image/x-icon"):e,h(),t(m)}),void(r.src=e)}m.rel="stylesheet",m.type="text/css",m.href=e,h(),m.addEventListener("error",e=>{c(e)}),m.addEventListener("load",()=>{t(m)})})}(e)))}const t=new URL("node_modules/miller-columns/src/index.js",location),n=new URL("../miller-columns.css",t).href;export default async function(t,{namespace:c="miller",stylesheets:s=["@default"]}={}){let r;const l=`ul:not(.${c}-no-columns),ol:not(.${c}-no-columns)`;function i(){return t(`.${c}-column > .${c}-selected`)}function a(){const e=t(`.${c}-breadcrumbs`).empty();i().each((function(){const n=t(this);t(`<span class="${c}-breadcrumb">`).text(n.text().trim()).click((function(){n.click()})).appendTo(e)}))}function o(e,n){let s=0;i().not(e).each((function(){s+=t(this).outerWidth(!0)})),n.stop().animate({scrollLeft:s},r.delay,(function(){n.find(`.${c}-column:not(.${c}-collapse)`).last()[0].scrollLeft=s,r.scroll&&r.scroll.call(this,e,n)}))}function d(){t(`.${c}-column:gt(0)`).addClass(c+"-collapse")}function u(){return i().last()}function f(e){h(e),function(e){o(null,e)}(e)}function h(e){d(),i().removeClass(c+"-selected"),a(),r.reset(e),r.preview&&t(`.${c}-preview`).remove()}function m(){u().next().click()}function p(e){let n,s="";return function(r){const{key:l}=r;let i=!1;switch(l){case"Escape":f(e);break;case"ArrowUp":u().prev().click(),i=!0;break;case"ArrowDown":m(),i=!0;break;case"ArrowLeft":!function(){const e=u().data(c+"-ancestor");e&&e.click()}(),i=!0;break;case"ArrowRight":!function(){const e=u().data(c+"-child");e?e.children("li").first().click():m()}(),i=!0;break;default:if(1===l.length){!function(e){const t=new Date;!n||t-n<500?s+=e:s=e,n=t}(l);e.find(`li.${c}-selected`).last().siblings().filter((function(){return new RegExp("^"+(e=s,e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")),"i").test(t(this).text().trim());var e})).first().click()}i=!0}i&&0===u().length&&t(`.${c}-column`).first().children().first().click(),i&&r.preventDefault()}}return s&&await e(s.map(e=>"@default"===e?n:e)),t.fn.millerColumns=function(e){const n={current(e){},reset(e){},preview:null,breadcrumb:a,animation:o,delay:500,resetOnOutsideClick:!0};return r=t.extend(n,e),this.each((function(){const e=t(this);!function(e){const n=[];let s;for(n.push(e.children());n.length;)s=n.shift(),s.children("li").each((function(s,r){const i=t(this),a=i.children(l),o=i.parent().parent();o.length&&null==i.data(c+"-ancestor")&&t(this).siblings().addBack().data(c+"-ancestor",o),a.length&&(n.push(a),t(this).data(c+"-child",a).addClass(c+"-parent")),t(this).parent(l).appendTo(e).addClass(c+"-column")}))}(e),d(),e.find("li").on("click",(function(n){const s=t(this);h(e);const l=s.data(c+"-child");let i=s;for(l&&l.removeClass(c+"-collapse").children().removeClass(c+"-selected");i;)i.addClass(c+"-selected").parent().removeClass(c+"-collapse"),i=i.data(c+"-ancestor");if(r.animation.call(this,s,e),r.breadcrumb.call(this),r.current.call(this,s,e),r.preview){if(s.hasClass(c+"-selected")&&!s.hasClass(c+"-parent")){const t=r.preview.call(this,s,e);s.parent().parent().append(`<ul class="${c}-column ${c}-preview">\n <li>${t}</li>\n </ul>`)}}n.stopPropagation()})),e.on("keydown",p(e)),e.on("click",()=>{r.resetOnOutsideClick&&f(e)})}))},t}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* Cascading columns styling.
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
.miller-columns {
|
|
7
|
+
float: left;
|
|
8
|
+
width: 100%;
|
|
9
|
+
height: 100%;
|
|
10
|
+
overflow: auto;
|
|
11
|
+
white-space: nowrap;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/* Display the lists as columns in blocks. */
|
|
15
|
+
ul.miller-column {
|
|
16
|
+
display: inline-block;
|
|
17
|
+
|
|
18
|
+
vertical-align: top;
|
|
19
|
+
overflow: hidden;
|
|
20
|
+
margin: 0;
|
|
21
|
+
padding: 0;
|
|
22
|
+
|
|
23
|
+
border-right: 1px solid #eee;
|
|
24
|
+
white-space: normal;
|
|
25
|
+
visibility: visible;
|
|
26
|
+
transition: 400ms;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* Setting a list container class to "collapsed" will hide the column. */
|
|
30
|
+
ul.miller-column.miller-collapse {
|
|
31
|
+
opacity: 0;
|
|
32
|
+
display: none;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/* Put some space between the column's list entries. */
|
|
36
|
+
ul.miller-column > li {
|
|
37
|
+
list-style: none;
|
|
38
|
+
padding: 0.5em;
|
|
39
|
+
min-width: 10em;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
ul.miller-column > li.miller-parent:after {
|
|
43
|
+
content: "›";
|
|
44
|
+
font-weight: bold;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/* Highlight while hovering, without allowing selected items to override. */
|
|
48
|
+
ul.miller-column > li:hover {
|
|
49
|
+
color: black;
|
|
50
|
+
background-color: #eee;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/* Ensure all selected nodes in the hierarchy are easily seen. */
|
|
54
|
+
.miller-column > .miller-selected,
|
|
55
|
+
.miller-column > .miller-selected:hover {
|
|
56
|
+
background-color: #08C;
|
|
57
|
+
color: white;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
*
|
|
62
|
+
* Breadcrumb styling.
|
|
63
|
+
*
|
|
64
|
+
*/
|
|
65
|
+
.miller-breadcrumbs {
|
|
66
|
+
border-bottom: 1px solid #eee;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.miller-breadcrumb:after {
|
|
70
|
+
content: " › ";
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.miller-breadcrumb:last-child:after {
|
|
74
|
+
content: "";
|
|
75
|
+
}
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
function _classCallCheck(instance, Constructor) {
|
|
2
|
+
if (!(instance instanceof Constructor)) {
|
|
3
|
+
throw new TypeError("Cannot call a class as a function");
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
function _defineProperties(target, props) {
|
|
7
|
+
for (var i = 0; i < props.length; i++) {
|
|
8
|
+
var descriptor = props[i];
|
|
9
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
10
|
+
descriptor.configurable = true;
|
|
11
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
12
|
+
Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
16
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
17
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
18
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
19
|
+
writable: false
|
|
20
|
+
});
|
|
21
|
+
return Constructor;
|
|
22
|
+
}
|
|
23
|
+
function _toPrimitive(input, hint) {
|
|
24
|
+
if (typeof input !== "object" || input === null) return input;
|
|
25
|
+
var prim = input[Symbol.toPrimitive];
|
|
26
|
+
if (prim !== undefined) {
|
|
27
|
+
var res = prim.call(input, hint || "default");
|
|
28
|
+
if (typeof res !== "object") return res;
|
|
29
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
30
|
+
}
|
|
31
|
+
return (hint === "string" ? String : Number)(input);
|
|
32
|
+
}
|
|
33
|
+
function _toPropertyKey(arg) {
|
|
34
|
+
var key = _toPrimitive(arg, "string");
|
|
35
|
+
return typeof key === "symbol" ? key : String(key);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @typedef {{[key: string]: Value}} Defaults
|
|
40
|
+
*/
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @typedef {boolean|number|string} Value
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Preferences storage.
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
function _await(value, then, direct) {
|
|
51
|
+
if (direct) {
|
|
52
|
+
return then ? then(value) : value;
|
|
53
|
+
}
|
|
54
|
+
if (!value || !value.then) {
|
|
55
|
+
value = Promise.resolve(value);
|
|
56
|
+
}
|
|
57
|
+
return then ? value.then(then) : value;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Defaults for SimplePrefs.
|
|
62
|
+
*/
|
|
63
|
+
var SimplePrefs = /*#__PURE__*/function () {
|
|
64
|
+
/**
|
|
65
|
+
* @param {object} cfg
|
|
66
|
+
* @param {string} [cfg.namespace] Avoid clashes with other apps
|
|
67
|
+
* @param {Defaults} [cfg.defaults]
|
|
68
|
+
* @param {SimplePrefsDefaults} [cfg.prefDefaults]
|
|
69
|
+
*/
|
|
70
|
+
function SimplePrefs(cfg) {
|
|
71
|
+
_classCallCheck(this, SimplePrefs);
|
|
72
|
+
this.configurePrefs(cfg);
|
|
73
|
+
|
|
74
|
+
/** @type {((e: StorageEvent) => void)[]} */
|
|
75
|
+
this.listeners = [];
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* @param {object} cfg
|
|
79
|
+
* @param {string} [cfg.namespace] Avoid clashes with other apps
|
|
80
|
+
* @param {Defaults} [cfg.defaults]
|
|
81
|
+
* @param {SimplePrefsDefaults} [cfg.prefDefaults]
|
|
82
|
+
* @returns {void}
|
|
83
|
+
*/
|
|
84
|
+
_createClass(SimplePrefs, [{
|
|
85
|
+
key: "configurePrefs",
|
|
86
|
+
value: function configurePrefs(_ref) {
|
|
87
|
+
var namespace = _ref.namespace,
|
|
88
|
+
defaults = _ref.defaults,
|
|
89
|
+
_ref$prefDefaults = _ref.prefDefaults,
|
|
90
|
+
prefDefaults = _ref$prefDefaults === void 0 ? simplePrefsDefaults(defaults) : _ref$prefDefaults;
|
|
91
|
+
this.namespace = namespace !== null && namespace !== void 0 ? namespace : '';
|
|
92
|
+
this.prefDefaults = prefDefaults;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Get parsed preference value; returns `Promise` in anticipation
|
|
96
|
+
* of https://domenic.github.io/async-local-storage/ .
|
|
97
|
+
* @callback GetPref
|
|
98
|
+
* @param {string} key Preference key (for Chrome-Compatibility, only `\w+`)
|
|
99
|
+
* @returns {Promise<Value>} Resolves to the parsed
|
|
100
|
+
* value (defaulting if necessary)
|
|
101
|
+
*/
|
|
102
|
+
|
|
103
|
+
/** @type {GetPref} */
|
|
104
|
+
}, {
|
|
105
|
+
key: "getPref",
|
|
106
|
+
value: function getPref(key) {
|
|
107
|
+
try {
|
|
108
|
+
var _this = this;
|
|
109
|
+
var result = localStorage.getItem(_this.namespace + key);
|
|
110
|
+
return _await(_await(result === null ? /** @type {SimplePrefsDefaults} */_this.prefDefaults.getPrefDefault(key) : JSON.parse(result), void 0, !(result === null)));
|
|
111
|
+
} catch (e) {
|
|
112
|
+
return Promise.reject(e);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Set a stringifiable preference value; returns `Promise` in anticipation
|
|
117
|
+
* of https://domenic.github.io/async-local-storage/ .
|
|
118
|
+
* @callback SetPref
|
|
119
|
+
* @param {string} key Preference key (for Chrome-Compatibility, only `\w+`)
|
|
120
|
+
* @param {Value} val Stringifiable value
|
|
121
|
+
* @returns {Promise<void>} Resolves after setting the item (Not currently
|
|
122
|
+
* in use)
|
|
123
|
+
*/
|
|
124
|
+
/** @type {SetPref} */
|
|
125
|
+
}, {
|
|
126
|
+
key: "setPref",
|
|
127
|
+
value: function setPref(key, val) {
|
|
128
|
+
try {
|
|
129
|
+
var _this2 = this;
|
|
130
|
+
return _await(localStorage.setItem(_this2.namespace + key, JSON.stringify(val)));
|
|
131
|
+
} catch (e) {
|
|
132
|
+
return Promise.reject(e);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* @typedef {object} GetPrefSetPref
|
|
137
|
+
* @property {GetPref} getPref
|
|
138
|
+
* @property {SetPref} setPref
|
|
139
|
+
*/
|
|
140
|
+
/**
|
|
141
|
+
* Convenience utility to return two main methods `getPref` and
|
|
142
|
+
* `setPref` bound to the current object.
|
|
143
|
+
* @returns {GetPrefSetPref}
|
|
144
|
+
*/
|
|
145
|
+
}, {
|
|
146
|
+
key: "bind",
|
|
147
|
+
value: function bind() {
|
|
148
|
+
return {
|
|
149
|
+
getPref: this.getPref.bind(this),
|
|
150
|
+
setPref: this.setPref.bind(this)
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* @callback PreferenceCallback
|
|
156
|
+
* @param {StorageEvent} e
|
|
157
|
+
* @returns {void}
|
|
158
|
+
*/
|
|
159
|
+
|
|
160
|
+
/* eslint-disable promise/prefer-await-to-callbacks -- Repeating event */
|
|
161
|
+
/**
|
|
162
|
+
* @param {string|PreferenceCallback|undefined} key
|
|
163
|
+
* @param {PreferenceCallback} cb
|
|
164
|
+
* @returns {PreferenceCallback}
|
|
165
|
+
*/
|
|
166
|
+
}, {
|
|
167
|
+
key: "listen",
|
|
168
|
+
value: function listen(key, cb) {
|
|
169
|
+
var _this3 = this;
|
|
170
|
+
if (typeof key === 'function') {
|
|
171
|
+
cb = key;
|
|
172
|
+
key = undefined;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* @param {StorageEvent} e
|
|
177
|
+
*/
|
|
178
|
+
var listener = function listener(e) {
|
|
179
|
+
if (e.key === null) {
|
|
180
|
+
// `null` for clear browser action or user `clear()`
|
|
181
|
+
if (key === undefined) {
|
|
182
|
+
// Only trigger when no key supplied
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
} else {
|
|
186
|
+
if (!e.key.startsWith( /** @type {string} */_this3.namespace)) {
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
if (key !== undefined && !e.key.startsWith( /** @type {string} */_this3.namespace + key)) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
cb(e);
|
|
194
|
+
};
|
|
195
|
+
window.addEventListener('storage', listener);
|
|
196
|
+
this.listeners.push(listener);
|
|
197
|
+
return listener;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* @param {EventListener} listener
|
|
202
|
+
* @returns {void}
|
|
203
|
+
*/
|
|
204
|
+
}, {
|
|
205
|
+
key: "unlisten",
|
|
206
|
+
value: function unlisten(listener) {
|
|
207
|
+
if (listener) {
|
|
208
|
+
for (var i = 0; i < this.listeners.length; i++) {
|
|
209
|
+
if (listener === this.listeners[i]) {
|
|
210
|
+
this.listeners.splice(i, 1);
|
|
211
|
+
window.removeEventListener('storage', listener);
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
this.listeners.forEach(function (listenerItem) {
|
|
217
|
+
window.removeEventListener('storage', listenerItem);
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
/* eslint-enable promise/prefer-await-to-callbacks -- Repeating event */
|
|
221
|
+
}]);
|
|
222
|
+
return SimplePrefs;
|
|
223
|
+
}();
|
|
224
|
+
var SimplePrefsDefaults = /*#__PURE__*/function () {
|
|
225
|
+
/**
|
|
226
|
+
*
|
|
227
|
+
* @param {{defaults: Defaults}} defaults
|
|
228
|
+
*/
|
|
229
|
+
function SimplePrefsDefaults(_ref2) {
|
|
230
|
+
var defaults = _ref2.defaults;
|
|
231
|
+
_classCallCheck(this, SimplePrefsDefaults);
|
|
232
|
+
this.defaults = defaults;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Get parsed default value for a preference.
|
|
236
|
+
* @param {string} key Preference key
|
|
237
|
+
* @returns {Promise<Value>}
|
|
238
|
+
*/
|
|
239
|
+
_createClass(SimplePrefsDefaults, [{
|
|
240
|
+
key: "getPrefDefault",
|
|
241
|
+
value: function getPrefDefault(key) {
|
|
242
|
+
try {
|
|
243
|
+
var _this4 = this;
|
|
244
|
+
return _await(_this4.defaults[key], function (_this4$defaults$key) {
|
|
245
|
+
return _this4$defaults$key !== null && _this4$defaults$key !== void 0 ? _this4$defaults$key : null;
|
|
246
|
+
});
|
|
247
|
+
} catch (e) {
|
|
248
|
+
return Promise.reject(e);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Set parsed default value for a preference.
|
|
253
|
+
* @param {string} key Preference key
|
|
254
|
+
* @param {Value} value
|
|
255
|
+
* @returns {Promise<Value>} The old value
|
|
256
|
+
*/
|
|
257
|
+
}, {
|
|
258
|
+
key: "setPrefDefault",
|
|
259
|
+
value: function setPrefDefault(key, value) {
|
|
260
|
+
try {
|
|
261
|
+
var _this5$defaults$key;
|
|
262
|
+
var _this5 = this;
|
|
263
|
+
var oldValue = (_this5$defaults$key = _this5.defaults[key]) !== null && _this5$defaults$key !== void 0 ? _this5$defaults$key : null;
|
|
264
|
+
_this5.defaults[key] = value;
|
|
265
|
+
return _await(oldValue);
|
|
266
|
+
} catch (e) {
|
|
267
|
+
return Promise.reject(e);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}]);
|
|
271
|
+
return SimplePrefsDefaults;
|
|
272
|
+
}();
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Simplified factory for `SimplePrefsDefaults`
|
|
276
|
+
* @param {Defaults} [defaults]
|
|
277
|
+
* @returns {SimplePrefsDefaults}
|
|
278
|
+
*/
|
|
279
|
+
function simplePrefsDefaults() {
|
|
280
|
+
var defaults = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
281
|
+
return new SimplePrefsDefaults({
|
|
282
|
+
defaults: defaults
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
export { SimplePrefs, SimplePrefsDefaults, simplePrefsDefaults };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
verbose: true,
|
|
5
|
+
ignoreFiles: [
|
|
6
|
+
// Files beginning with dot, zip/xpi, node_modules, and
|
|
7
|
+
// web-ext-artifacts auto-ignored
|
|
8
|
+
'package-lock.json',
|
|
9
|
+
'package.json',
|
|
10
|
+
'screenshots',
|
|
11
|
+
'old' // Remove when deleted
|
|
12
|
+
]
|
|
13
|
+
};
|