@rnacanvas/drop-interface 1.0.0 → 1.1.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/dist/App.d.ts +14 -0
- package/dist/App.d.ts.map +1 -0
- package/dist/DropHandler.d.ts +13 -0
- package/dist/DropHandler.d.ts.map +1 -0
- package/dist/RNAcanvasFileDropHandler.d.ts +15 -0
- package/dist/RNAcanvasFileDropHandler.d.ts.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/App.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The app interface used by drop handler classes.
|
|
3
|
+
*/
|
|
4
|
+
export interface App {
|
|
5
|
+
undo(): void;
|
|
6
|
+
pushUndoStack(): void;
|
|
7
|
+
/**
|
|
8
|
+
* Restores the app to a previous state.
|
|
9
|
+
*
|
|
10
|
+
* Throws if unable to do so.
|
|
11
|
+
*/
|
|
12
|
+
restore(previousState: unknown): void | never;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=App.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"App.d.ts","sourceRoot":"","sources":["../src/App.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,GAAG;IAClB,IAAI,IAAI,IAAI,CAAC;IACb,aAAa,IAAI,IAAI,CAAC;IAEtB;;;;OAIG;IACH,OAAO,CAAC,aAAa,EAAE,OAAO,GAAG,IAAI,GAAG,KAAK,CAAC;CAC/C"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { App } from './App';
|
|
2
|
+
/**
|
|
3
|
+
* Handles drop events for a target RNAcanvas app.
|
|
4
|
+
*/
|
|
5
|
+
export declare class DropHandler {
|
|
6
|
+
#private;
|
|
7
|
+
constructor(targetApp: App);
|
|
8
|
+
/**
|
|
9
|
+
* Handles the provided drop event.
|
|
10
|
+
*/
|
|
11
|
+
handle(event: DragEvent): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=DropHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DropHandler.d.ts","sourceRoot":"","sources":["../src/DropHandler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAIjC;;GAEG;AACH,qBAAa,WAAW;;gBAGV,SAAS,EAAE,GAAG;IAI1B;;OAEG;IACG,MAAM,CAAC,KAAK,EAAE,SAAS;CAG9B"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { App } from './App';
|
|
2
|
+
/**
|
|
3
|
+
* Opens dropped RNAcanvas files (with ".rnacanvas" extension) in the target app.
|
|
4
|
+
*/
|
|
5
|
+
export declare class RNAcanvasFileDropHandler {
|
|
6
|
+
#private;
|
|
7
|
+
constructor(targetApp: App);
|
|
8
|
+
/**
|
|
9
|
+
* Handles the provided drop event.
|
|
10
|
+
*
|
|
11
|
+
* Does nothing if an RNAcanvas file (with ".rnacanvas") was not dropped.
|
|
12
|
+
*/
|
|
13
|
+
handle(event: DragEvent): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=RNAcanvasFileDropHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RNAcanvasFileDropHandler.d.ts","sourceRoot":"","sources":["../src/RNAcanvasFileDropHandler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAEjC;;GAEG;AACH,qBAAa,wBAAwB;;gBAGvB,SAAS,EAAE,GAAG;IAI1B;;;;OAIG;IACG,MAAM,CAAC,KAAK,EAAE,SAAS;CA2B9B"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,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.dropInterface=t():e.dropInterface=t()}(this,(()=>(()=>{"use strict";return{}})()));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.dropInterface=t():e.dropInterface=t()}(this,(()=>(()=>{"use strict";var e={d:(t,r)=>{for(var o in r)e.o(r,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:r[o]})},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={};e.r(t),e.d(t,{DropHandler:()=>i});var r,o=function(e,t,r,o){if("a"===r&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?o:"a"===r?o.call(e):o?o.value:t.get(e)};class n{constructor(e){r.set(this,void 0),function(e,t,r,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===o?n.call(e,r):n?n.value=r:t.set(e,r)}(this,r,e,"f")}handle(e){return t=this,n=void 0,i=function*(){var t,n;let a=[...null!==(n=null===(t=e.dataTransfer)||void 0===t?void 0:t.files)&&void 0!==n?n:[]];if(0==a.length)return;let i=a[0];if(i.name.toLowerCase().endsWith(".rnacanvas")){e.preventDefault(),o(this,r,"f").pushUndoStack();try{o(this,r,"f").restore(JSON.parse(yield i.text()))}catch(e){console.error(e),console.error("Unable to open saved drawing."),o(this,r,"f").undo()}}},new((a=void 0)||(a=Promise))((function(e,r){function o(e){try{s(i.next(e))}catch(e){r(e)}}function c(e){try{s(i.throw(e))}catch(e){r(e)}}function s(t){var r;t.done?e(t.value):(r=t.value,r instanceof a?r:new a((function(e){e(r)}))).then(o,c)}s((i=i.apply(t,n||[])).next())}));var t,n,a,i}}r=new WeakMap;var a;class i{constructor(e){a.set(this,void 0),function(e,t,r,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");"a"===o?n.call(e,r):n?n.value=r:t.set(e,r)}(this,a,new n(e),"f")}handle(e){return t=this,r=void 0,n=function*(){yield function(e,t,r,o){if("a"===r&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?o:"a"===r?o.call(e):o?o.value:t.get(e)}(this,a,"f").handle(e)},new((o=void 0)||(o=Promise))((function(e,a){function i(e){try{s(n.next(e))}catch(e){a(e)}}function c(e){try{s(n.throw(e))}catch(e){a(e)}}function s(t){var r;t.done?e(t.value):(r=t.value,r instanceof o?r:new o((function(e){e(r)}))).then(i,c)}s((n=n.apply(t,r||[])).next())}));var t,r,o,n}}return a=new WeakMap,t})()));
|