@rnacanvas/draw.interact 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/LICENSE +21 -0
- package/babel.config.js +6 -0
- package/dist/ConsecutiveBasesSelectingTool.d.ts +62 -0
- package/dist/ConsecutiveBasesSelectingTool.d.ts.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/package.json +27 -0
- package/tsconfig.json +13 -0
- package/webpack.config.js +28 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 pzhaojohnson
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/babel.config.js
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
interface Nucleobase {
|
|
2
|
+
/**
|
|
3
|
+
* The actual DOM node comprising the nucleobase.
|
|
4
|
+
*/
|
|
5
|
+
domNode: Node;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* An RNAcanvas structure drawing.
|
|
9
|
+
*/
|
|
10
|
+
interface Drawing<B extends Nucleobase> {
|
|
11
|
+
/**
|
|
12
|
+
* The actual DOM node comprising the drawing (e.g., an SVG document).
|
|
13
|
+
*/
|
|
14
|
+
domNode: Node;
|
|
15
|
+
/**
|
|
16
|
+
* The bases in the drawing.
|
|
17
|
+
*
|
|
18
|
+
* The ordering of bases in this iterable is the ordering of bases in the drawing.
|
|
19
|
+
*/
|
|
20
|
+
bases: Iterable<B>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A set of items that is also assumed to be referenced and used by outside code.
|
|
24
|
+
*/
|
|
25
|
+
interface LiveSet<T> {
|
|
26
|
+
/**
|
|
27
|
+
* Returns true if the set includes the specified item and returns false otherwise.
|
|
28
|
+
*/
|
|
29
|
+
include(item: T): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Adds all of the specified items to the set.
|
|
32
|
+
*/
|
|
33
|
+
addAll(items: T[]): void;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* A tool that allows users to select consecutive sequences of bases in a target drawing
|
|
37
|
+
* by dragging the mouse over them while holding down the mouse and the `Shift` key.
|
|
38
|
+
*/
|
|
39
|
+
export declare class ConsecutiveBasesSelectingTool<B extends Nucleobase> {
|
|
40
|
+
private targetDrawing;
|
|
41
|
+
private selectedBases;
|
|
42
|
+
/**
|
|
43
|
+
* The most recent mouse down event.
|
|
44
|
+
*/
|
|
45
|
+
private lastMouseDown;
|
|
46
|
+
/**
|
|
47
|
+
* Is to be set to true when the mouse is down.
|
|
48
|
+
*/
|
|
49
|
+
private mouseIsDown;
|
|
50
|
+
/**
|
|
51
|
+
* The provided set of selected bases will be modified based on user interaction with the target drawing.
|
|
52
|
+
*
|
|
53
|
+
* @param targetDrawing The drawing that the tool is for.
|
|
54
|
+
* @param selectedBases A live set of the currently selected bases.
|
|
55
|
+
*/
|
|
56
|
+
constructor(targetDrawing: Drawing<B>, selectedBases: LiveSet<B>);
|
|
57
|
+
handleMouseDown(event: MouseEvent): void;
|
|
58
|
+
handleMouseUp(event: MouseEvent): void;
|
|
59
|
+
handleMouseOver(event: MouseEvent): void;
|
|
60
|
+
}
|
|
61
|
+
export {};
|
|
62
|
+
//# sourceMappingURL=ConsecutiveBasesSelectingTool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConsecutiveBasesSelectingTool.d.ts","sourceRoot":"","sources":["../src/ConsecutiveBasesSelectingTool.ts"],"names":[],"mappings":"AAAA,UAAU,UAAU;IAClB;;OAEG;IACH,OAAO,EAAE,IAAI,CAAC;CACf;AAED;;GAEG;AACH,UAAU,OAAO,CAAC,CAAC,SAAS,UAAU;IACpC;;OAEG;IACH,OAAO,EAAE,IAAI,CAAC;IAEd;;;;OAIG;IACH,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;CACpB;AAED;;GAEG;AACH,UAAU,OAAO,CAAC,CAAC;IACjB;;OAEG;IACH,OAAO,CAAC,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC;IAE1B;;OAEG;IACH,MAAM,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC;CAC1B;AAED;;;GAGG;AACH,qBAAa,6BAA6B,CAAC,CAAC,SAAS,UAAU;IAiBjD,OAAO,CAAC,aAAa;IAAc,OAAO,CAAC,aAAa;IAhBpE;;OAEG;IACH,OAAO,CAAC,aAAa,CAAyB;IAE9C;;OAEG;IACH,OAAO,CAAC,WAAW,CAAS;IAE5B;;;;;OAKG;gBACiB,aAAa,EAAE,OAAO,CAAC,CAAC,CAAC,EAAU,aAAa,EAAE,OAAO,CAAC,CAAC,CAAC;IAQhF,eAAe,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IAMxC,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IAItC,eAAe,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;CA+BzC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,6BAA6B,EAAE,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +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["draw.interact"]=t():e["draw.interact"]=t()}(this,(()=>(()=>{"use strict";var e={d:(t,o)=>{for(var s in o)e.o(o,s)&&!e.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:o[s]})},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,{ConsecutiveBasesSelectingTool:()=>o});class o{constructor(e,t){this.targetDrawing=e,this.selectedBases=t,this.mouseIsDown=!1,window.addEventListener("mousedown",(e=>this.handleMouseDown(e))),window.addEventListener("mouseup",(e=>this.handleMouseUp(e))),window.addEventListener("mouseover",(e=>this.handleMouseOver(e)))}handleMouseDown(e){this.lastMouseDown=e,this.mouseIsDown=!0}handleMouseUp(e){this.mouseIsDown=!1}handleMouseOver(e){if(!this.mouseIsDown)return;let t=this.lastMouseDown;if(!t)return;if(!t.shiftKey)return;if(!(e.target instanceof Node))return;if(!this.targetDrawing.domNode.contains(e.target))return;let o=[...this.targetDrawing.bases],s=o.findIndex((t=>t.domNode===e.target));if(s<0)return;let n=o.findIndex((e=>e.domNode===t.target));if(n<0)return;try{let e=o[n];if(!this.selectedBases.include(e))return}catch(e){console.error(e)}let r=Math.min(n,s),i=Math.max(n,s);this.selectedBases.addAll(o.slice(r,i+1))}}return t})()));
|
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rnacanvas/draw.interact",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "Interact with RNAcanvas structure drawings",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/pzhaojohnson/rnacanvas.draw.interact.git"
|
|
8
|
+
},
|
|
9
|
+
"main": "./dist/index.js",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"test": "jest",
|
|
12
|
+
"build": "webpack"
|
|
13
|
+
},
|
|
14
|
+
"author": "pzhaojohnson",
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@babel/core": "^7.23.7",
|
|
18
|
+
"@babel/preset-env": "^7.23.7",
|
|
19
|
+
"@babel/preset-typescript": "^7.23.3",
|
|
20
|
+
"babel-jest": "^29.7.0",
|
|
21
|
+
"jest": "^29.7.0",
|
|
22
|
+
"ts-loader": "^9.5.1",
|
|
23
|
+
"typescript": "^5.3.3",
|
|
24
|
+
"webpack": "^5.89.0",
|
|
25
|
+
"webpack-cli": "^5.1.4"
|
|
26
|
+
}
|
|
27
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const path = require('path');
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
entry: './src/index.ts',
|
|
5
|
+
mode: 'production',
|
|
6
|
+
module: {
|
|
7
|
+
rules: [
|
|
8
|
+
{
|
|
9
|
+
test: /\.tsx?$/,
|
|
10
|
+
use: 'ts-loader',
|
|
11
|
+
exclude: /node_modules/,
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
|
+
},
|
|
15
|
+
resolve: {
|
|
16
|
+
extensions: ['.tsx', '.ts', '.js'],
|
|
17
|
+
},
|
|
18
|
+
output: {
|
|
19
|
+
path: path.resolve(__dirname, 'dist'),
|
|
20
|
+
filename: 'index.js',
|
|
21
|
+
globalObject: 'this',
|
|
22
|
+
library: {
|
|
23
|
+
name: 'draw.interact',
|
|
24
|
+
type: 'umd',
|
|
25
|
+
},
|
|
26
|
+
clean: true,
|
|
27
|
+
},
|
|
28
|
+
};
|