@rnacanvas/utilities 2.2.0 → 2.3.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.
@@ -0,0 +1,14 @@
1
+ export declare class KeyBinding {
2
+ #private;
3
+ readonly key: string;
4
+ constructor(key: string, callbackFn: () => void);
5
+ /**
6
+ * Must be currently being interacted with by the user
7
+ * for the key binding to be triggered.
8
+ *
9
+ * Is the document body by default (i.e., key bindings apply to the whole webpage by default).
10
+ */
11
+ get scope(): Element;
12
+ set scope(scope: Element);
13
+ }
14
+ //# sourceMappingURL=KeyBinding.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KeyBinding.d.ts","sourceRoot":"","sources":["../src/KeyBinding.ts"],"names":[],"mappings":"AAIA,qBAAa,UAAU;;IAGT,QAAQ,CAAC,GAAG,EAAE,MAAM;gBAAX,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,IAAI;IAYxD;;;;;OAKG;IACH,IAAI,KAAK,IAAI,OAAO,CAEnB;IAED,IAAI,KAAK,CAAC,KAAK,EAJF,OAIE,EAEd;CACF"}
package/dist/index.d.ts CHANGED
@@ -4,6 +4,8 @@ import { userIsTyping } from './userIsTyping';
4
4
  export { userIsTyping };
5
5
  import { isBeingInteractedWith } from './isBeingInteractedWith';
6
6
  export { isBeingInteractedWith };
7
+ import { KeyBinding } from './KeyBinding';
8
+ export { KeyBinding };
7
9
  import { detectMac } from './detectMac';
8
10
  export { detectMac };
9
11
  import { DownloadableFile } from './DownloadableFile';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,CAAC;AAEpB,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,CAAC;AAExB,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,CAAC;AAEjC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,CAAC;AAErB,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAE5B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,CAAC;AAEpB,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,CAAC;AAExB,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,CAAC;AAEjC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,CAAC;AAEtB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,CAAC;AAErB,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,CAAC;AAE5B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,CAAC"}
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.utilities=t():e.utilities=t()}(this,(()=>(()=>{"use strict";var e={d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function n(e){return e.map((e=>({v:e,priority:Math.random()}))).sort(((e,t)=>e.priority-t.priority)).map((({v:e})=>e))}function r(){return!(!document.activeElement||"textarea"!==document.activeElement.tagName.toLowerCase()&&(e=document.activeElement,"input"!==e.tagName.toLowerCase()||"text"!==(null===(t=e.getAttribute("type"))||void 0===t?void 0:t.toLowerCase())));var e,t}e.r(t),e.d(t,{DownloadableFile:()=>l,EventfulSet:()=>a,detectMac:()=>s,isBeingInteractedWith:()=>o,shuffled:()=>n,userIsTyping:()=>r});let i=null;function o(e){return e===document.body||(document.activeElement?e.contains(document.activeElement):!!i&&i.target instanceof Node&&e.contains(i.target))}function s(){try{return window.navigator.platform.toLowerCase().includes("mac")}catch(e){return!1}}window.addEventListener("mousedown",(e=>i=e));class l{constructor(e){this.textContent=e}downloadAs(e,t){let n=new File([this.textContent],e,{type:t.type}),r=URL.createObjectURL(n),i=document.createElement("a");i.href=r,i.download=n.name,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}}class a{constructor(){this.eventListeners={change:[]},this.underlyingSet=new Set}[Symbol.iterator](){return this.underlyingSet.values()}includes(e){return this.underlyingSet.has(e)}include(e){return this.includes(e)}addAll(e){let t=[...e];0!=t.length&&(t.every((e=>this.includes(e)))||(t.forEach((e=>this.underlyingSet.add(e))),this.callEventListeners("change")))}removeAll(e){let t=[...e];0!=t.length&&(t.every((e=>!this.includes(e)))||(t.forEach((e=>this.underlyingSet.delete(e))),this.callEventListeners("change")))}clear(){0!=this.underlyingSet.size&&(this.underlyingSet.clear(),this.callEventListeners("change"))}addEventListener(e,t){this.eventListeners[e].push(t)}callEventListeners(e){this.eventListeners[e].forEach((e=>e()))}removeEventListener(e,t){this.eventListeners[e]=this.eventListeners[e].filter((e=>e!==t))}}return t})()));
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.utilities=t():e.utilities=t()}(this,(()=>(()=>{"use strict";var e={d:(t,n)=>{for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function n(e){return e.map((e=>({v:e,priority:Math.random()}))).sort(((e,t)=>e.priority-t.priority)).map((({v:e})=>e))}function r(){return!(!document.activeElement||"textarea"!==document.activeElement.tagName.toLowerCase()&&(e=document.activeElement,"input"!==e.tagName.toLowerCase()||"text"!==(null===(t=e.getAttribute("type"))||void 0===t?void 0:t.toLowerCase())));var e,t}e.r(t),e.d(t,{DownloadableFile:()=>l,EventfulSet:()=>d,KeyBinding:()=>a,detectMac:()=>c,isBeingInteractedWith:()=>i,shuffled:()=>n,userIsTyping:()=>r});let o=null;function i(e){return e===document.body||(document.activeElement?e.contains(document.activeElement):!!o&&o.target instanceof Node&&e.contains(o.target))}window.addEventListener("mousedown",(e=>o=e));var s;class a{constructor(e,t){this.key=e,s.set(this,void 0),window.addEventListener("keydown",(n=>{n.key.toUpperCase()!==e.toUpperCase()||r()||!i(this.scope)||t()}))}get scope(){var e;return null!==(e=function(e,t,n,r){if("a"===n&&!r)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?r:"a"===n?r.call(e):r?r.value:t.get(e)}(this,s,"f"))&&void 0!==e?e:document.body}set scope(e){!function(e,t,n,r,o){if("m"===r)throw new TypeError("Private method is not writable");if("a"===r&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===r?o.call(e,n):o?o.value=n:t.set(e,n)}(this,s,e,"f")}}function c(){try{return window.navigator.platform.toLowerCase().includes("mac")}catch(e){return!1}}s=new WeakMap;class l{constructor(e){this.textContent=e}downloadAs(e,t){let n=new File([this.textContent],e,{type:t.type}),r=URL.createObjectURL(n),o=document.createElement("a");o.href=r,o.download=n.name,document.body.appendChild(o),o.click(),o.remove(),URL.revokeObjectURL(r)}}class d{constructor(){this.eventListeners={change:[]},this.underlyingSet=new Set}[Symbol.iterator](){return this.underlyingSet.values()}includes(e){return this.underlyingSet.has(e)}include(e){return this.includes(e)}addAll(e){let t=[...e];0!=t.length&&(t.every((e=>this.includes(e)))||(t.forEach((e=>this.underlyingSet.add(e))),this.callEventListeners("change")))}removeAll(e){let t=[...e];0!=t.length&&(t.every((e=>!this.includes(e)))||(t.forEach((e=>this.underlyingSet.delete(e))),this.callEventListeners("change")))}clear(){0!=this.underlyingSet.size&&(this.underlyingSet.clear(),this.callEventListeners("change"))}addEventListener(e,t){this.eventListeners[e].push(t)}callEventListeners(e){this.eventListeners[e].forEach((e=>e()))}removeEventListener(e,t){this.eventListeners[e]=this.eventListeners[e].filter((e=>e!==t))}}return t})()));
@@ -1,6 +1,9 @@
1
1
  /**
2
2
  * Returns true if and only if the provided element (or any of its child elements)
3
3
  * are currently being interacted with by the user.
4
+ *
5
+ * Note that this function may not work properly with lazy loading or dynamic imports
6
+ * (since it only begins tracking which element is being interacted with after being imported).
4
7
  */
5
8
  export declare function isBeingInteractedWith(ele: Element): boolean;
6
9
  //# sourceMappingURL=isBeingInteractedWith.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"isBeingInteractedWith.d.ts","sourceRoot":"","sources":["../src/isBeingInteractedWith.ts"],"names":[],"mappings":"AAIA;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAY3D"}
1
+ {"version":3,"file":"isBeingInteractedWith.d.ts","sourceRoot":"","sources":["../src/isBeingInteractedWith.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAY3D"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rnacanvas/utilities",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "description": "General utilities",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {