mapexplorer-rails 1.0.0.pre.alpha → 1.0.0.pre.alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mapexplorer/rails/version.rb +1 -1
- data/vendor/assets/babel-polyfill/README.md +0 -0
- data/vendor/assets/babel-polyfill/bower.json +22 -0
- data/vendor/assets/babel-polyfill/browser-polyfill.js +5 -0
- data/vendor/assets/d3/LICENSE +27 -0
- data/vendor/assets/d3/README.md +45 -0
- data/vendor/assets/d3/bower.json +7 -0
- data/vendor/assets/d3/d3.js +16383 -0
- data/vendor/assets/d3/d3.min.js +8 -0
- data/vendor/assets/jsrender/MIT-LICENSE.txt +20 -0
- data/vendor/assets/jsrender/bower.json +43 -0
- data/vendor/assets/jsrender/index.js +8 -0
- data/vendor/assets/jsrender/jsrender-node.js +2298 -0
- data/vendor/assets/jsrender/jsrender.js +2350 -0
- data/vendor/assets/jsrender/jsrender.min.js +4 -0
- data/vendor/assets/jsrender/jsrender.min.js.map +1 -0
- data/vendor/assets/jsrender/tmplify/index.js +64 -0
- data/vendor/assets/mapexplorer-core/LICENSE +21 -0
- data/vendor/assets/mapexplorer-core/README.md +235 -0
- data/vendor/assets/mapexplorer-core/assets/stylesheets/map.scss +38 -0
- data/vendor/assets/mapexplorer-core/assets/stylesheets/mapexplorer-core.scss +3 -0
- data/vendor/assets/mapexplorer-core/assets/stylesheets/merkle-path.scss +10 -0
- data/vendor/assets/mapexplorer-core/assets/stylesheets/variables.scss +14 -0
- data/vendor/assets/mapexplorer-core/bower.json +32 -0
- data/vendor/assets/mapexplorer-core/dist/mapexplorer-core.js +3872 -0
- data/vendor/assets/mapexplorer-core/dist/mapexplorer-core.js.map +1 -0
- data/vendor/assets/mapexplorer-core/dist/mapexplorer-core.min.js +35 -0
- data/vendor/assets/mapexplorer-core/karma.conf.js +117 -0
- data/vendor/assets/mapexplorer-core/package.json +85 -0
- data/vendor/assets/mapexplorer-core/rollup.bower.config.js +41 -0
- data/vendor/assets/mapexplorer-core/rollup.es.config.js +16 -0
- data/vendor/assets/mapexplorer-core/rollup.umd.config.js +25 -0
- data/vendor/assets/stratumn-sdk/LICENSE +21 -0
- data/vendor/assets/stratumn-sdk/README.md +267 -0
- data/vendor/assets/stratumn-sdk/bower.json +27 -0
- data/vendor/assets/stratumn-sdk/dist/stratumn-sdk.js +813 -0
- data/vendor/assets/stratumn-sdk/dist/stratumn-sdk.js.map +1 -0
- data/vendor/assets/stratumn-sdk/dist/stratumn-sdk.min.js +2 -0
- data/vendor/assets/stratumn-sdk/dist/stratumn-sdk.min.js.map +1 -0
- data/vendor/assets/stratumn-sdk/examples/browser/index.html +34 -0
- data/vendor/assets/stratumn-sdk/package.json +67 -0
- data/vendor/assets/stratumn-sdk/rollup.base.config.js +13 -0
- data/vendor/assets/stratumn-sdk/rollup.bower.config.js +18 -0
- data/vendor/assets/stratumn-sdk/rollup.bower.min.config.js +7 -0
- data/vendor/assets/stratumn-sdk/rollup.es.config.js +9 -0
- data/vendor/assets/stratumn-sdk/rollup.umd.config.js +10 -0
- metadata +46 -1
@@ -0,0 +1,235 @@
|
|
1
|
+
# MapExplorer Core
|
2
|
+
|
3
|
+
[![build status](https://travis-ci.org/stratumn/mapexplorer-core.svg?branch=master)](https://travis-ci.org/stratumn/mapexplorer-core.svg?branch=master)
|
4
|
+
|
5
|
+
Core library for building Map Explorer components
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
### Browser
|
10
|
+
|
11
|
+
```html
|
12
|
+
<!-- Polyfill for browser compatibility -->
|
13
|
+
<script src="https://libs.stratumn.com/babel-polyfill.min.js"></script>
|
14
|
+
<!-- Actual Library -->
|
15
|
+
<script src="https://libs.stratumn.com/mapexplorer-core.min.js"></script>
|
16
|
+
```
|
17
|
+
|
18
|
+
If you want a specific version, include `https://libs.stratumn.com/mapexplorer-core-{version}.min.js` instead (for instance `https://libs.stratumn.com/mapexplorer-core-0.4.1.min.js`).
|
19
|
+
|
20
|
+
|
21
|
+
### Node.js
|
22
|
+
|
23
|
+
```
|
24
|
+
$ npm install mapexplorer-core
|
25
|
+
```
|
26
|
+
|
27
|
+
```javascript
|
28
|
+
var MapexplorerCore = require('mapexplorer-core');
|
29
|
+
```
|
30
|
+
|
31
|
+
### Bower
|
32
|
+
|
33
|
+
```
|
34
|
+
$ bower install mapexplorer-core
|
35
|
+
```
|
36
|
+
|
37
|
+
## Usage
|
38
|
+
|
39
|
+
### Display a map explorer
|
40
|
+
|
41
|
+
```javascript
|
42
|
+
const builder = new MapexplorerCore.ChainTreeBuilder(element);
|
43
|
+
|
44
|
+
// with an application and a mapId
|
45
|
+
builder.build({
|
46
|
+
id: myMapId,
|
47
|
+
application: myApplication
|
48
|
+
}, options);
|
49
|
+
|
50
|
+
// with a chainscript (JSON string of array of segment as POJO)
|
51
|
+
builder.build({
|
52
|
+
chainscript: myChainscript
|
53
|
+
}), options;
|
54
|
+
```
|
55
|
+
#### Available options
|
56
|
+
|
57
|
+
##### withArgs
|
58
|
+
```
|
59
|
+
Default: false
|
60
|
+
```
|
61
|
+
|
62
|
+
Display action arguments on the paths between segments.
|
63
|
+
|
64
|
+
##### duration
|
65
|
+
```
|
66
|
+
Default: 750
|
67
|
+
```
|
68
|
+
|
69
|
+
Transition duration
|
70
|
+
|
71
|
+
##### verticalSpacing
|
72
|
+
```
|
73
|
+
Default: 1.2
|
74
|
+
```
|
75
|
+
Vertical space factor between segment polygon
|
76
|
+
|
77
|
+
##### polygonSize
|
78
|
+
```
|
79
|
+
Default:
|
80
|
+
{
|
81
|
+
width: 78,
|
82
|
+
height: 91
|
83
|
+
}
|
84
|
+
```
|
85
|
+
|
86
|
+
Object with width and height properties that gives the size (in pixels) of the polygon representing
|
87
|
+
a segment.
|
88
|
+
|
89
|
+
##### getArrowLength()
|
90
|
+
```
|
91
|
+
Default: () => this.polygonSize.width
|
92
|
+
```
|
93
|
+
|
94
|
+
Function that returns the length (in pixels) of the transition arrow.
|
95
|
+
|
96
|
+
#### box
|
97
|
+
```
|
98
|
+
Default:
|
99
|
+
() => return {
|
100
|
+
width: this.polygonSize.width,
|
101
|
+
height: 25
|
102
|
+
}
|
103
|
+
```
|
104
|
+
|
105
|
+
Function that return an object with width and height properties that gives the size (in pixels) of the box containing the
|
106
|
+
segment text.
|
107
|
+
|
108
|
+
##### getSegmentText(node)
|
109
|
+
```
|
110
|
+
Default: node => compactHash(node.data.meta.linkHash)
|
111
|
+
```
|
112
|
+
|
113
|
+
Function that returns the text displayed on a segment.
|
114
|
+
|
115
|
+
|
116
|
+
|
117
|
+
##### getLinkText(node)
|
118
|
+
```
|
119
|
+
Default:
|
120
|
+
function(node) {
|
121
|
+
return node.target.data.link.meta.action +
|
122
|
+
(this.withArgs ? `(${node.target.data.link.meta.arguments.join(', ')})` : '');
|
123
|
+
}
|
124
|
+
```
|
125
|
+
|
126
|
+
Function that return the text displayed on a path between segments.
|
127
|
+
|
128
|
+
##### onclick(data)
|
129
|
+
```
|
130
|
+
Default: noop
|
131
|
+
```
|
132
|
+
|
133
|
+
##### onTag(tag)
|
134
|
+
```
|
135
|
+
Default: noop
|
136
|
+
```
|
137
|
+
|
138
|
+
Hook that is called when a segment is tagged
|
139
|
+
|
140
|
+
Event handler called when the user clicks on a segment.
|
141
|
+
|
142
|
+
### Display a merkle path tree
|
143
|
+
|
144
|
+
```javascript
|
145
|
+
const merklePathTree = new MapexplorerCore.MerklePathTree(element);
|
146
|
+
merklePathTree.display(merklePath);
|
147
|
+
```
|
148
|
+
|
149
|
+
where `merklePath` looks like:
|
150
|
+
|
151
|
+
```
|
152
|
+
[
|
153
|
+
{
|
154
|
+
"left": "14b9468d3b8ca51b45e27ecddc5875a48902a74d1182fed9693c1531dfcfd56c",
|
155
|
+
"right": "d15e1460234292852400271530be35cabe822eae5a4ed3376728d5acbbf04f27",
|
156
|
+
"parent": "3bfbc00bfe7aa149e17029e8bb08671636c1c1c16aa5addfc307d6c937134620"
|
157
|
+
},
|
158
|
+
{
|
159
|
+
"left": "3bfbc00bfe7aa149e17029e8bb08671636c1c1c16aa5addfc307d6c937134620",
|
160
|
+
"right": "9fd68d3335eabcad5777b4c717af6de3c51f4aa0af72c26aaf866cde176c96f1",
|
161
|
+
"parent": "8f16bfbe247be6ca881f3d9e462bc154f099298e26cd53662ef7119e1e60a887"
|
162
|
+
},
|
163
|
+
...
|
164
|
+
]
|
165
|
+
```
|
166
|
+
|
167
|
+
### Validate a chainscript
|
168
|
+
|
169
|
+
```javascript
|
170
|
+
new MapexplorerCore.ChainValidator(JSON.parse(chainscript)).validate()
|
171
|
+
```
|
172
|
+
|
173
|
+
Returns a Promise that resolves to an error object such as:
|
174
|
+
|
175
|
+
```
|
176
|
+
{
|
177
|
+
linkHash: [Promise, ...],
|
178
|
+
stateHash: [Promise, ...],
|
179
|
+
merklePath: [Promise, ...],
|
180
|
+
fossil: [Promise, ...]
|
181
|
+
}
|
182
|
+
```
|
183
|
+
|
184
|
+
Each promise, in each array of each category resolves to an error string if an inconsistency has been detected. It resolves to null otherwise.
|
185
|
+
|
186
|
+
Errors can be retrieved with (for instance):
|
187
|
+
|
188
|
+
```javascript
|
189
|
+
Promise.all(errors.linkHash).
|
190
|
+
then(err => err.filter(Boolean));
|
191
|
+
```
|
192
|
+
|
193
|
+
## Development
|
194
|
+
|
195
|
+
Install dependencies:
|
196
|
+
|
197
|
+
```
|
198
|
+
$ npm install
|
199
|
+
```
|
200
|
+
|
201
|
+
Build:
|
202
|
+
|
203
|
+
```
|
204
|
+
$ npm run build:all
|
205
|
+
```
|
206
|
+
|
207
|
+
Test:
|
208
|
+
|
209
|
+
```
|
210
|
+
$ npm test
|
211
|
+
```
|
212
|
+
|
213
|
+
Lint:
|
214
|
+
|
215
|
+
```
|
216
|
+
$ npm run lint
|
217
|
+
```
|
218
|
+
|
219
|
+
Lint and test:
|
220
|
+
|
221
|
+
```
|
222
|
+
$ npm run check
|
223
|
+
```
|
224
|
+
|
225
|
+
Bump version:
|
226
|
+
|
227
|
+
```
|
228
|
+
$ npm version major|minor|patch
|
229
|
+
```
|
230
|
+
|
231
|
+
Publish:
|
232
|
+
|
233
|
+
```
|
234
|
+
$ npm publish
|
235
|
+
```
|
@@ -0,0 +1,38 @@
|
|
1
|
+
.node {
|
2
|
+
cursor: pointer;
|
3
|
+
}
|
4
|
+
|
5
|
+
.node polygon {
|
6
|
+
fill: $segment-primary-color;
|
7
|
+
}
|
8
|
+
|
9
|
+
.node text {
|
10
|
+
font-family: $segment-text-font;
|
11
|
+
font-size: 14px;
|
12
|
+
fill: $segment-text-color;
|
13
|
+
}
|
14
|
+
|
15
|
+
.node rect {
|
16
|
+
fill: $segment-secondary-color;
|
17
|
+
}
|
18
|
+
|
19
|
+
.textpath {
|
20
|
+
font-family: $link-text-font;
|
21
|
+
font-size: 14px;
|
22
|
+
fill: $link-text-color;
|
23
|
+
}
|
24
|
+
|
25
|
+
.link {
|
26
|
+
fill: none;
|
27
|
+
stroke: $link-color;
|
28
|
+
stroke-width: 5px;
|
29
|
+
marker-end: url('#triangle');
|
30
|
+
}
|
31
|
+
|
32
|
+
.node.selected polygon {
|
33
|
+
fill: $selected-segment-primary-color;
|
34
|
+
}
|
35
|
+
|
36
|
+
.node.selected rect {
|
37
|
+
fill: $selected-segment-secondary-color;
|
38
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
$segment-primary-color: #7BC0D2 !default;
|
2
|
+
$segment-secondary-color: #459FB7 !default;
|
3
|
+
$segment-text-color: white !default;
|
4
|
+
$segment-text-font: 'RationalTWText-SemiBold', 'Roboto Mono', monospace !default;
|
5
|
+
|
6
|
+
$selected-segment-primary-color: #3E3E3E;
|
7
|
+
$selected-segment-secondary-color: #2E2E2E;
|
8
|
+
|
9
|
+
$link-text-font: 'Gibson-Regular', 'Montserrat', sans-serif !default;
|
10
|
+
$link-text-color: #C1C1C1 !default;
|
11
|
+
$link-color: #CCC !default;
|
12
|
+
|
13
|
+
$merkle-path-node-color: black !default;
|
14
|
+
$merkle-path-link-color: black !default;
|
@@ -0,0 +1,32 @@
|
|
1
|
+
{
|
2
|
+
"name": "mapexplorer-core",
|
3
|
+
"description": "Core library for building Map Explorer components",
|
4
|
+
"main": [
|
5
|
+
"dist/mapexplorer-core.js",
|
6
|
+
"assets/stylesheets/mapexplorer-core.scss"
|
7
|
+
],
|
8
|
+
"authors": [
|
9
|
+
"Stratumn Team"
|
10
|
+
],
|
11
|
+
"license": "MIT",
|
12
|
+
"keywords": [
|
13
|
+
"stratumn",
|
14
|
+
"lib",
|
15
|
+
"blockchain",
|
16
|
+
"mapexplorer",
|
17
|
+
"chainscript"
|
18
|
+
],
|
19
|
+
"homepage": "https://github.com/stratumn/mapexplorer-core",
|
20
|
+
"ignore": [
|
21
|
+
"**/.*",
|
22
|
+
"node_modules",
|
23
|
+
"bower_components",
|
24
|
+
"test",
|
25
|
+
"tests",
|
26
|
+
"src"
|
27
|
+
],
|
28
|
+
"dependencies": {
|
29
|
+
"d3": "^4.1.1",
|
30
|
+
"stratumn-sdk": "alpha"
|
31
|
+
}
|
32
|
+
}
|