parent
cbbdf9db02
commit
feeed5d859
@ -1,7 +0,0 @@
|
|||||||
# `-`
|
|
||||||
|
|
||||||
> Created using https://github.com/parzh/create-package-typescript
|
|
||||||
|
|
||||||
```
|
|
||||||
npm i -
|
|
||||||
```
|
|
@ -1,3 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
exports.default = null;
|
|
@ -1,18 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "-",
|
|
||||||
"version": "0.0.1",
|
|
||||||
"license": "UNLICENSED",
|
|
||||||
"keywords": [],
|
|
||||||
"main": "dist/index.js",
|
|
||||||
"types": "dist/index.d.ts",
|
|
||||||
"scripts": {
|
|
||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
|
||||||
"start": "node --require ts-node/register src",
|
|
||||||
"build": "tsc"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@types/node": "13.9.0",
|
|
||||||
"ts-node": "8.6.2",
|
|
||||||
"typescript": "3.8.3"
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@ -1,758 +0,0 @@
|
|||||||
# @achrinza/node-ipc
|
|
||||||
|
|
||||||
> **NOTE:** This is a maintenance fork of `node-ipc` This is intended for
|
|
||||||
> packages that directly or indirectly depend on `node-ipc` where maintainers
|
|
||||||
> need a drop-in replacement.
|
|
||||||
>
|
|
||||||
> See https://github.com/achrinza/node-ipc/issues/1 for more details.
|
|
||||||
|
|
||||||
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](code_of_conduct.md)
|
|
||||||
[![Coverage Status](https://coveralls.io/repos/github/achrinza/node-ipc/badge.svg?branch=main)](https://coveralls.io/github/achrinza/node-ipc?branch=main)
|
|
||||||
|
|
||||||
_a nodejs module for local and remote Inter Process Communication_ with full support for Linux, Mac and Windows. It also supports all forms of socket communication from low level unix and windows sockets to UDP and secure TLS and TCP sockets.
|
|
||||||
|
|
||||||
A great solution for complex multiprocess **Neural Networking** in Node.JS
|
|
||||||
|
|
||||||
**npm install @achrinza/node-ipc**
|
|
||||||
|
|
||||||
#### Older versions of node
|
|
||||||
|
|
||||||
the latest versions of `@achrinza/node-ipc` may work with the --harmony flag. Officially though, we support node v4 and newer with es5 and es6
|
|
||||||
|
|
||||||
#### Testing
|
|
||||||
|
|
||||||
`npm test` will run the jasmine tests with istanbul for @achrinza/node-ipc and generate a coverage report in the spec folder.
|
|
||||||
|
|
||||||
You may want to install jasmine and istanbul globally with `sudo npm install -g jasmine istanbul`
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
#### Contents
|
|
||||||
|
|
||||||
1. [Types of IPC Sockets and Supporting OS](#types-of-ipc-sockets)
|
|
||||||
1. [IPC Config](#ipc-config)
|
|
||||||
1. [IPC Methods](#ipc-methods)
|
|
||||||
1. [log](#log)
|
|
||||||
2. [connectTo](#connectto)
|
|
||||||
3. [connectToNet](#connecttonet)
|
|
||||||
4. [disconnect](#disconnect)
|
|
||||||
5. [serve](#serve)
|
|
||||||
6. [serveNet](#servenet)
|
|
||||||
1. [IPC Stores and Default Variables](#ipc-stores-and-default-variables)
|
|
||||||
1. [IPC Events](#ipc-events)
|
|
||||||
1. [Multiple IPC instances](#multiple-ipc-instances)
|
|
||||||
1. [Basic Examples](#basic-examples)
|
|
||||||
1. [Server for Unix||Windows Sockets & TCP Sockets](#server-for-unix-sockets-windows-sockets--tcp-sockets)
|
|
||||||
2. [Client for Unix||Windows Sockets & TCP Sockets](#client-for-unix-sockets--tcp-sockets)
|
|
||||||
3. [Server & Client for UDP Sockets](#server--client-for-udp-sockets)
|
|
||||||
4. [Raw Buffers, Real Time and / or Binary Sockets](#raw-buffer-or-binary-sockets)
|
|
||||||
1. [Working with TLS/SSL Socket Servers & Clients](https://github.com/RIAEvangelist/@achrinza/node-ipc/tree/master/example/TLSSocket)
|
|
||||||
1. [Node Code Examples](https://github.com/RIAEvangelist/@achrinza/node-ipc/tree/master/example)
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
#### Types of IPC Sockets
|
|
||||||
|
|
||||||
| Type | Stability | Definition |
|
|
||||||
| ----------------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
||||||
| Unix Socket or Windows Socket | Stable | Gives Linux, Mac, and Windows lightning fast communication and avoids the network card to reduce overhead and latency. [Local Unix and Windows Socket examples ](https://github.com/RIAEvangelist/@achrinza/node-ipc/tree/master/example/unixWindowsSocket/ "Unix and Windows Socket Node IPC examples") |
|
|
||||||
| TCP Socket | Stable | Gives the most reliable communication across the network. Can be used for local IPC as well, but is slower than #1's Unix Socket Implementation because TCP sockets go through the network card while Unix Sockets and Windows Sockets do not. [Local or remote network TCP Socket examples ](https://github.com/RIAEvangelist/@achrinza/node-ipc/tree/master/example/TCPSocket/ "TCP Socket Node IPC examples") |
|
|
||||||
| TLS Socket | Stable | Configurable and secure network socket over SSL. Equivalent to https. [TLS/SSL documentation](https://github.com/RIAEvangelist/@achrinza/node-ipc/tree/master/example/TLSSocket) |
|
|
||||||
| UDP Sockets | Stable | Gives the **fastest network communication**. UDP is less reliable but much faster than TCP. It is best used for streaming non critical data like sound, video, or multiplayer game data as it can drop packets depending on network connectivity and other factors. UDP can be used for local IPC as well, but is slower than #1's Unix Socket or Windows Socket Implementation because UDP sockets go through the network card while Unix and Windows Sockets do not. [Local or remote network UDP Socket examples ](https://github.com/RIAEvangelist/@achrinza/node-ipc/tree/master/example/UDPSocket/ "UDP Socket Node IPC examples") |
|
|
||||||
|
|
||||||
| OS | Supported Sockets |
|
|
||||||
| ----- | -------------------------- |
|
|
||||||
| Linux | Unix, Posix, TCP, TLS, UDP |
|
|
||||||
| Mac | Unix, Posix, TCP, TLS, UDP |
|
|
||||||
| Win | Windows, TCP, TLS, UDP |
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
#### IPC Config
|
|
||||||
|
|
||||||
`ipc.config`
|
|
||||||
|
|
||||||
Set these variables in the `ipc.config` scope to overwrite or set default values.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
|
|
||||||
{
|
|
||||||
appspace : 'app.',
|
|
||||||
socketRoot : '/tmp/',
|
|
||||||
id : os.hostname(),
|
|
||||||
networkHost : 'localhost', //should resolve to 127.0.0.1 or ::1 see the table below related to this
|
|
||||||
networkPort : 8000,
|
|
||||||
readableAll : false,
|
|
||||||
writableAll : false,
|
|
||||||
encoding : 'utf8',
|
|
||||||
rawBuffer : false,
|
|
||||||
delimiter : '\f',
|
|
||||||
sync : false,
|
|
||||||
silent : false,
|
|
||||||
logInColor : true,
|
|
||||||
logDepth : 5,
|
|
||||||
logger : console.log,
|
|
||||||
maxConnections : 100,
|
|
||||||
retry : 500,
|
|
||||||
maxRetries : false,
|
|
||||||
stopRetrying : false,
|
|
||||||
unlink : true,
|
|
||||||
interfaces : {
|
|
||||||
localAddress: false,
|
|
||||||
localPort : false,
|
|
||||||
family : false,
|
|
||||||
hints : false,
|
|
||||||
lookup : false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
| variable | documentation |
|
|
||||||
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
||||||
| appspace | used for Unix Socket (Unix Domain Socket) namespacing. If not set specifically, the Unix Domain Socket will combine the socketRoot, appspace, and id to form the Unix Socket Path for creation or binding. This is available in case you have many apps running on your system, you may have several sockets with the same id, but if you change the appspace, you will still have app specic unique sockets. |
|
|
||||||
| socketRoot | the directory in which to create or bind to a Unix Socket |
|
|
||||||
| id | the id of this socket or service |
|
|
||||||
| networkHost | the local or remote host on which TCP, TLS or UDP Sockets should connect |
|
|
||||||
| networkPort | the default port on which TCP, TLS, or UDP sockets should connect |
|
|
||||||
| readableAll | makes the pipe readable for all users including windows services |
|
|
||||||
| writableAll | makes the pipe writable for all users including windows services |
|
|
||||||
| encoding | the default encoding for data sent on sockets. Mostly used if rawBuffer is set to true. Valid values are : ` ascii` `utf8` ` utf16le` ` ucs2` ` base64` `hex` . |
|
|
||||||
| rawBuffer | if true, data will be sent and received as a raw node `Buffer` **NOT** an `Object` as JSON. This is great for Binary or hex IPC, and communicating with other processes in languages like C and C++ |
|
|
||||||
| delimiter | the delimiter at the end of each data packet. |
|
|
||||||
| sync | synchronous requests. Clients will not send new requests until the server answers. |
|
|
||||||
| silent | turn on/off logging default is false which means logging is on |
|
|
||||||
| logInColor | turn on/off util.inspect colors for ipc.log |
|
|
||||||
| logDepth | set the depth for util.inspect during ipc.log |
|
|
||||||
| logger | the function which receives the output from ipc.log; should take a single string argument |
|
|
||||||
| maxConnections | this is the max number of connections allowed to a socket. It is currently only being set on Unix Sockets. Other Socket types are using the system defaults. |
|
|
||||||
| retry | this is the time in milliseconds a client will wait before trying to reconnect to a server if the connection is lost. This does not effect UDP sockets since they do not have a client server relationship like Unix Sockets and TCP Sockets. |
|
|
||||||
| maxRetries | if set, it represents the maximum number of retries after each disconnect before giving up and completely killing a specific connection |
|
|
||||||
| stopRetrying | Defaults to false meaning clients will continue to retry to connect to servers indefinitely at the retry interval. If set to any number the client will stop retrying when that number is exceeded after each disconnect. If set to true in real time it will immediately stop trying to connect regardless of maxRetries. If set to 0, the client will **_NOT_** try to reconnect. |
|
|
||||||
| unlink | Defaults to true meaning that the module will take care of deleting the IPC socket prior to startup. If you use `@achrinza/node-ipc` in a clustered environment where there will be multiple listeners on the same socket, you must set this to `false` and then take care of deleting the socket in your own code. |
|
|
||||||
| interfaces | primarily used when specifying which interface a client should connect through. see the [socket.connect documentation in the node.js api](https://nodejs.org/api/net.html#net_socket_connect_options_connectlistener) |
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
#### IPC Methods
|
|
||||||
|
|
||||||
These methods are available in the IPC Scope.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
##### log
|
|
||||||
|
|
||||||
`ipc.log(a,b,c,d,e...);`
|
|
||||||
|
|
||||||
ipc.log will accept any number of arguments and if `ipc.config.silent` is not set, it will concat them all with a single space ' ' between them and then log them to the console. This is fast because it prevents any concatenation from happening if the ipc.config.silent is set `true`. That way if you leave your logging in place it should have almost no effect on performance.
|
|
||||||
|
|
||||||
The log also uses util.inspect You can control if it should log in color, the log depth, and the destination via `ipc.config`
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
ipc.config.logInColor = true; //default
|
|
||||||
ipc.config.logDepth = 5; //default
|
|
||||||
ipc.config.logger = console.log.bind(console); // default
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
##### connectTo
|
|
||||||
|
|
||||||
`ipc.connectTo(id,path,callback);`
|
|
||||||
|
|
||||||
Used for connecting as a client to local Unix Sockets and Windows Sockets. **_This is the fastest way for processes on the same machine to communicate_** because it bypasses the network card which TCP and UDP must both use.
|
|
||||||
|
|
||||||
| variable | required | definition |
|
|
||||||
| -------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
||||||
| id | required | is the string id of the socket being connected to. The socket with this id is added to the ipc.of object when created. |
|
|
||||||
| path | optional | is the path of the Unix Domain Socket File, if the System is Windows, this will automatically be converted to an appropriate pipe with the same information as the Unix Domain Socket File. If not set this will default to `ipc.config.socketRoot`+`ipc.config.appspace`+`id` |
|
|
||||||
| callback | optional | this is the function to execute when the socket has been created. |
|
|
||||||
|
|
||||||
**examples** arguments can be ommitted so long as they are still in order.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
ipc.connectTo("world");
|
|
||||||
```
|
|
||||||
|
|
||||||
or using just an id and a callback
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
ipc.connectTo("world", function () {
|
|
||||||
ipc.of.world.on("hello", function (data) {
|
|
||||||
ipc.log(data.debug);
|
|
||||||
//if data was a string, it would have the color set to the debug style applied to it
|
|
||||||
});
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
or explicitly setting the path
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
ipc.connectTo("world", "myapp.world");
|
|
||||||
```
|
|
||||||
|
|
||||||
or explicitly setting the path with callback
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
|
|
||||||
ipc.connectTo(
|
|
||||||
'world',
|
|
||||||
'myapp.world',
|
|
||||||
function(){
|
|
||||||
...
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
##### connectToNet
|
|
||||||
|
|
||||||
`ipc.connectToNet(id,host,port,callback)`
|
|
||||||
|
|
||||||
Used to connect as a client to a TCP or [TLS socket](https://github.com/RIAEvangelist/@achrinza/node-ipc/tree/master/example/TLSSocket) via the network card. This can be local or remote, if local, it is recommended that you use the Unix and Windows Socket Implementaion of `connectTo` instead as it is much faster since it avoids the network card altogether.
|
|
||||||
|
|
||||||
For TLS and SSL Sockets see the [@achrinza/node-ipc TLS and SSL docs](https://github.com/RIAEvangelist/@achrinza/node-ipc/tree/master/example/TLSSocket). They have a few additional requirements, and things to know about and so have their own doc.
|
|
||||||
|
|
||||||
| variable | required | definition |
|
|
||||||
| -------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
||||||
| id | required | is the string id of the socket being connected to. For TCP & TLS sockets, this id is added to the `ipc.of` object when the socket is created with a reference to the socket. |
|
|
||||||
| host | optional | is the host on which the TCP or TLS socket resides. This will default to `ipc.config.networkHost` if not specified. |
|
|
||||||
| port | optional | the port on which the TCP or TLS socket resides. |
|
|
||||||
| callback | optional | this is the function to execute when the socket has been created. |
|
|
||||||
|
|
||||||
**examples** arguments can be ommitted so long as they are still in order.
|
|
||||||
So while the default is : (id,host,port,callback), the following examples will still work because they are still in order (id,port,callback) or (id,host,callback) or (id,port) etc.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
ipc.connectToNet("world");
|
|
||||||
```
|
|
||||||
|
|
||||||
or using just an id and a callback
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
|
|
||||||
ipc.connectToNet(
|
|
||||||
'world',
|
|
||||||
function(){
|
|
||||||
...
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
or explicitly setting the host and path
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
|
|
||||||
ipc.connectToNet(
|
|
||||||
'world',
|
|
||||||
'myapp.com',serve(path,callback)
|
|
||||||
3435
|
|
||||||
);
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
or only explicitly setting port and callback
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
|
|
||||||
ipc.connectToNet(
|
|
||||||
'world',
|
|
||||||
3435,
|
|
||||||
function(){
|
|
||||||
...
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
##### disconnect
|
|
||||||
|
|
||||||
`ipc.disconnect(id)`
|
|
||||||
|
|
||||||
Used to disconnect a client from a Unix, Windows, TCP or TLS socket. The socket and its refrence will be removed from memory and the `ipc.of` scope. This can be local or remote. UDP clients do not maintain connections and so there are no Clients and this method has no value to them.
|
|
||||||
|
|
||||||
| variable | required | definition |
|
|
||||||
| -------- | -------- | -------------------------------------------------------- |
|
|
||||||
| id | required | is the string id of the socket from which to disconnect. |
|
|
||||||
|
|
||||||
**examples**
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
ipc.disconnect("world");
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
##### serve
|
|
||||||
|
|
||||||
`ipc.serve(path,callback);`
|
|
||||||
|
|
||||||
Used to create local Unix Socket Server or Windows Socket Server to which Clients can bind. The server can `emit` events to specific Client Sockets, or `broadcast` events to all known Client Sockets.
|
|
||||||
|
|
||||||
| variable | required | definition |
|
|
||||||
| -------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
||||||
| path | optional | This is the path of the Unix Domain Socket File, if the System is Windows, this will automatically be converted to an appropriate pipe with the same information as the Unix Domain Socket File. If not set this will default to `ipc.config.socketRoot`+`ipc.config.appspace`+`id` |
|
|
||||||
| callback | optional | This is a function to be called after the Server has started. This can also be done by binding an event to the start event like `ipc.server.on('start',function(){});` |
|
|
||||||
|
|
||||||
**_examples_** arguments can be omitted so long as they are still in order.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
ipc.serve();
|
|
||||||
```
|
|
||||||
|
|
||||||
or specifying callback
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
|
|
||||||
ipc.serve(
|
|
||||||
function(){...}
|
|
||||||
);
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
or specify path
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
ipc.serve("/tmp/myapp.myservice");
|
|
||||||
```
|
|
||||||
|
|
||||||
or specifying everything
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
|
|
||||||
ipc.serve(
|
|
||||||
'/tmp/myapp.myservice',
|
|
||||||
function(){...}
|
|
||||||
);
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
##### serveNet
|
|
||||||
|
|
||||||
`serveNet(host,port,UDPType,callback)`
|
|
||||||
|
|
||||||
Used to create TCP, TLS or UDP Socket Server to which Clients can bind or other servers can send data to. The server can `emit` events to specific Client Sockets, or `broadcast` events to all known Client Sockets.
|
|
||||||
|
|
||||||
| variable | required | definition |
|
|
||||||
| -------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
||||||
| host | optional | If not specified this defaults to the first address in os.networkInterfaces(). For TCP, TLS & UDP servers this is most likely going to be 127.0.0.1 or ::1 |
|
|
||||||
| port | optional | The port on which the TCP, UDP, or TLS Socket server will be bound, this defaults to 8000 if not specified |
|
|
||||||
| UDPType | optional | If set this will create the server as a UDP socket. 'udp4' or 'udp6' are valid values. This defaults to not being set. When using udp6 make sure to specify a valid IPv6 host, like `::1` |
|
|
||||||
| callback | optional | Function to be called when the server is created |
|
|
||||||
|
|
||||||
**_examples_** arguments can be ommitted solong as they are still in order.
|
|
||||||
|
|
||||||
default tcp server
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
ipc.serveNet();
|
|
||||||
```
|
|
||||||
|
|
||||||
default udp server
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
ipc.serveNet("udp4");
|
|
||||||
```
|
|
||||||
|
|
||||||
or specifying TCP server with callback
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
|
|
||||||
ipc.serveNet(
|
|
||||||
function(){...}
|
|
||||||
);
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
or specifying UDP server with callback
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
|
|
||||||
ipc.serveNet(
|
|
||||||
'udp4',
|
|
||||||
function(){...}
|
|
||||||
);
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
or specify port
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
ipc.serveNet(3435);
|
|
||||||
```
|
|
||||||
|
|
||||||
or specifying everything TCP
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
|
|
||||||
ipc.serveNet(
|
|
||||||
'MyMostAwesomeApp.com',
|
|
||||||
3435,
|
|
||||||
function(){...}
|
|
||||||
);
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
or specifying everything UDP
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
|
|
||||||
ipc.serveNet(
|
|
||||||
'MyMostAwesomeApp.com',
|
|
||||||
3435,
|
|
||||||
'udp4',
|
|
||||||
function(){...}
|
|
||||||
);
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
### IPC Stores and Default Variables
|
|
||||||
|
|
||||||
| variable | definition |
|
|
||||||
| ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
||||||
| ipc.of | This is where socket connection refrences will be stored when connecting to them as a client via the `ipc.connectTo` or `iupc.connectToNet`. They will be stored based on the ID used to create them, eg : ipc.of.mySocket |
|
|
||||||
| ipc.server | This is a refrence to the server created by `ipc.serve` or `ipc.serveNet` |
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
### IPC Server Methods
|
|
||||||
|
|
||||||
| method | definition |
|
|
||||||
| ------ | --------------------------------------------------------------------------- |
|
|
||||||
| start | start serving need to call `serve` or `serveNet` first to set up the server |
|
|
||||||
| stop | close the server and stop serving |
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
### IPC Events
|
|
||||||
|
|
||||||
| event name | params | definition |
|
|
||||||
| --------------------- | ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
||||||
| error | err obj | triggered when an error has occured |
|
|
||||||
| connect | | triggered when socket connected |
|
|
||||||
| disconnect | | triggered by client when socket has disconnected from server |
|
|
||||||
| socket.disconnected | socket destroyedSocketID | triggered by server when a client socket has disconnected |
|
|
||||||
| destroy | | triggered when socket has been totally destroyed, no further auto retries will happen and all references are gone. |
|
|
||||||
| data | buffer | triggered when ipc.config.rawBuffer is true and a message is received. |
|
|
||||||
| **_your event type_** | **_your event data_** | triggered when a JSON message is received. The event name will be the type string from your message and the param will be the data object from your message eg : `{ type:'myEvent',data:{a:1}}` |
|
|
||||||
|
|
||||||
### Multiple IPC Instances
|
|
||||||
|
|
||||||
Sometimes you might need explicit and independent instances of @achrinza/node-ipc. Just for such scenarios we have exposed the core IPC class on the IPC singleton.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
const RawIPC = require("@achrinza/node-ipc").IPC;
|
|
||||||
const ipc = new RawIPC();
|
|
||||||
const someOtherExplicitIPC = new RawIPC();
|
|
||||||
|
|
||||||
//OR
|
|
||||||
|
|
||||||
const ipc = require("@achrinza/node-ipc");
|
|
||||||
const someOtherExplicitIPC = new ipc.IPC();
|
|
||||||
|
|
||||||
//setting explicit configs
|
|
||||||
|
|
||||||
//keep one silent and the other verbose
|
|
||||||
ipc.config.silent = true;
|
|
||||||
someOtherExplicitIPC.config.silent = true;
|
|
||||||
|
|
||||||
//make one a raw binary and the other json based ipc
|
|
||||||
ipc.config.rawBuffer = false;
|
|
||||||
|
|
||||||
someOtherExplicitIPC.config.rawBuffer = true;
|
|
||||||
someOtherExplicitIPC.config.encoding = "hex";
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
### Basic Examples
|
|
||||||
|
|
||||||
You can find [Advanced Examples](https://github.com/RIAEvangelist/@achrinza/node-ipc/tree/master/example) in the examples folder. In the examples you will find more complex demos including multi client examples.
|
|
||||||
|
|
||||||
#### Server for Unix Sockets, Windows Sockets & TCP Sockets
|
|
||||||
|
|
||||||
The server is the process keeping a socket for IPC open. Multiple sockets can connect to this server and talk to it. It can also broadcast to all clients or emit to a specific client. This is the most basic example which will work for local Unix and Windows Sockets as well as local or remote network TCP Sockets.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var ipc = require("@achrinza/node-ipc");
|
|
||||||
|
|
||||||
ipc.config.id = "world";
|
|
||||||
ipc.config.retry = 1500;
|
|
||||||
|
|
||||||
ipc.serve(function () {
|
|
||||||
ipc.server.on("message", function (data, socket) {
|
|
||||||
ipc.log("got a message : ".debug, data);
|
|
||||||
ipc.server.emit(
|
|
||||||
socket,
|
|
||||||
"message", //this can be anything you want so long as
|
|
||||||
//your client knows.
|
|
||||||
data + " world!"
|
|
||||||
);
|
|
||||||
});
|
|
||||||
ipc.server.on("socket.disconnected", function (socket, destroyedSocketID) {
|
|
||||||
ipc.log("client " + destroyedSocketID + " has disconnected!");
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
ipc.server.start();
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Client for Unix Sockets & TCP Sockets
|
|
||||||
|
|
||||||
The client connects to the servers socket for Inter Process Communication. The socket will receive events emitted to it specifically as well as events which are broadcast out on the socket by the server. This is the most basic example which will work for both local Unix Sockets and local or remote network TCP Sockets.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var ipc = require("@achrinza/node-ipc");
|
|
||||||
|
|
||||||
ipc.config.id = "hello";
|
|
||||||
ipc.config.retry = 1500;
|
|
||||||
|
|
||||||
ipc.connectTo("world", function () {
|
|
||||||
ipc.of.world.on("connect", function () {
|
|
||||||
ipc.log("## connected to world ##".rainbow, ipc.config.delay);
|
|
||||||
ipc.of.world.emit(
|
|
||||||
"message", //any event or message type your server listens for
|
|
||||||
"hello"
|
|
||||||
);
|
|
||||||
});
|
|
||||||
ipc.of.world.on("disconnect", function () {
|
|
||||||
ipc.log("disconnected from world".notice);
|
|
||||||
});
|
|
||||||
ipc.of.world.on(
|
|
||||||
"message", //any event or message type your server listens for
|
|
||||||
function (data) {
|
|
||||||
ipc.log("got a message from world : ".debug, data);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Server & Client for UDP Sockets
|
|
||||||
|
|
||||||
UDP Sockets are different than Unix, Windows & TCP Sockets because they must be bound to a unique port on their machine to receive messages. For example, A TCP, Unix, or Windows Socket client could just connect to a separate TCP, Unix, or Windows Socket sever. That client could then exchange, both send and receive, data on the servers port or location. UDP Sockets can not do this. They must bind to a port to receive or send data.
|
|
||||||
|
|
||||||
This means a UDP Client and Server are the same thing because in order to receive data, a UDP Socket must have its own port to receive data on, and only one process can use this port at a time. It also means that in order to `emit` or `broadcast` data the UDP server will need to know the host and port of the Socket it intends to broadcast the data to.
|
|
||||||
|
|
||||||
This is the most basic example which will work for both local and remote UDP Sockets.
|
|
||||||
|
|
||||||
##### UDP Server 1 - "World"
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var ipc = require("../../../@achrinza/node-ipc");
|
|
||||||
|
|
||||||
ipc.config.id = "world";
|
|
||||||
ipc.config.retry = 1500;
|
|
||||||
|
|
||||||
ipc.serveNet("udp4", function () {
|
|
||||||
console.log(123);
|
|
||||||
ipc.server.on("message", function (data, socket) {
|
|
||||||
ipc.log(
|
|
||||||
"got a message from ".debug,
|
|
||||||
data.from.variable,
|
|
||||||
" : ".debug,
|
|
||||||
data.message.variable
|
|
||||||
);
|
|
||||||
ipc.server.emit(socket, "message", {
|
|
||||||
from: ipc.config.id,
|
|
||||||
message: data.message + " world!",
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
console.log(ipc.server);
|
|
||||||
});
|
|
||||||
|
|
||||||
ipc.server.start();
|
|
||||||
```
|
|
||||||
|
|
||||||
##### UDP Server 2 - "Hello"
|
|
||||||
|
|
||||||
_note_ we set the port here to 8001 because the world server is already using the default ipc.config.networkPort of 8000. So we can not bind to 8000 while world is using it.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
ipc.config.id = "hello";
|
|
||||||
ipc.config.retry = 1500;
|
|
||||||
|
|
||||||
ipc.serveNet(8001, "udp4", function () {
|
|
||||||
ipc.server.on("message", function (data) {
|
|
||||||
ipc.log("got Data");
|
|
||||||
ipc.log(
|
|
||||||
"got a message from ".debug,
|
|
||||||
data.from.variable,
|
|
||||||
" : ".debug,
|
|
||||||
data.message.variable
|
|
||||||
);
|
|
||||||
});
|
|
||||||
ipc.server.emit(
|
|
||||||
{
|
|
||||||
address: "127.0.0.1", //any hostname will work
|
|
||||||
port: ipc.config.networkPort,
|
|
||||||
},
|
|
||||||
"message",
|
|
||||||
{
|
|
||||||
from: ipc.config.id,
|
|
||||||
message: "Hello",
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
ipc.server.start();
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Raw Buffer or Binary Sockets
|
|
||||||
|
|
||||||
Binary or Buffer sockets can be used with any of the above socket types, however the way data events are emit is **_slightly_** different. These may come in handy if working with embedded systems or C / C++ processes. You can even make sure to match C or C++ string typing.
|
|
||||||
|
|
||||||
When setting up a rawBuffer socket you must specify it as such :
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
ipc.config.rawBuffer = true;
|
|
||||||
```
|
|
||||||
|
|
||||||
You can also specify its encoding type. The default is `utf8`
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
ipc.config.encoding = "utf8";
|
|
||||||
```
|
|
||||||
|
|
||||||
emit string buffer :
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
//server
|
|
||||||
ipc.server.emit(socket, "hello");
|
|
||||||
|
|
||||||
//client
|
|
||||||
ipc.of.world.emit("hello");
|
|
||||||
```
|
|
||||||
|
|
||||||
emit byte array buffer :
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
//hex encoding may work best for this.
|
|
||||||
ipc.config.encoding = "hex";
|
|
||||||
|
|
||||||
//server
|
|
||||||
ipc.server.emit(socket, [10, 20, 30]);
|
|
||||||
|
|
||||||
//client
|
|
||||||
ipc.server.emit([10, 20, 30]);
|
|
||||||
```
|
|
||||||
|
|
||||||
emit binary or hex array buffer, this is best for real time data transfer, especially whan connecting to C or C++ processes, or embedded systems :
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
ipc.config.encoding = "hex";
|
|
||||||
|
|
||||||
//server
|
|
||||||
ipc.server.emit(socket, [0x05, 0x6d, 0x5c]);
|
|
||||||
|
|
||||||
//client
|
|
||||||
ipc.server.emit([0x05, 0x6d, 0x5c]);
|
|
||||||
```
|
|
||||||
|
|
||||||
Writing explicit buffers, int types, doubles, floats etc. as well as big endian and little endian data to raw buffer nostly valuable when connecting to C or C++ processes, or embedded systems (see more detailed info on buffers as well as UInt, Int, double etc. here)[https://nodejs.org/api/buffer.html]:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
ipc.config.encoding = "hex";
|
|
||||||
|
|
||||||
//make a 6 byte buffer for example
|
|
||||||
const myBuffer = Buffer.alloc(6).fill(0);
|
|
||||||
|
|
||||||
//fill the first 2 bytes with a 16 bit (2 byte) short unsigned int
|
|
||||||
|
|
||||||
//write a UInt16 (2 byte or short) as Big Endian
|
|
||||||
myBuffer.writeUInt16BE(
|
|
||||||
2, //value to write
|
|
||||||
0 //offset in bytes
|
|
||||||
);
|
|
||||||
//OR
|
|
||||||
myBuffer.writeUInt16LE(0x2, 0);
|
|
||||||
//OR
|
|
||||||
myBuffer.writeUInt16LE(0x02, 0);
|
|
||||||
|
|
||||||
//fill the remaining 4 bytes with a 32 bit (4 byte) long unsigned int
|
|
||||||
|
|
||||||
//write a UInt32 (4 byte or long) as Big Endian
|
|
||||||
myBuffer.writeUInt32BE(
|
|
||||||
16772812, //value to write
|
|
||||||
2 //offset in bytes
|
|
||||||
);
|
|
||||||
//OR
|
|
||||||
myBuffer.writeUInt32BE(0xffeecc, 0);
|
|
||||||
|
|
||||||
//server
|
|
||||||
ipc.server.emit(socket, myBuffer);
|
|
||||||
|
|
||||||
//client
|
|
||||||
ipc.server.emit(myBuffer);
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Server with the `cluster` Module
|
|
||||||
|
|
||||||
`@achrinza/node-ipc` can be used with Node.js' [cluster module](https://nodejs.org/api/cluster.html) to provide the ability to have multiple readers for a single socket. Doing so simply requires you to set the `unlink` property in the config to `false` and take care of unlinking the socket path in the master process:
|
|
||||||
|
|
||||||
##### Server
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
const fs = require("fs");
|
|
||||||
const ipc = require("../../../@achrinza/node-ipc");
|
|
||||||
const cpuCount = require("os").cpus().length;
|
|
||||||
const cluster = require("cluster");
|
|
||||||
const socketPath = "/tmp/ipc.sock";
|
|
||||||
|
|
||||||
ipc.config.unlink = false;
|
|
||||||
|
|
||||||
if (cluster.isMaster) {
|
|
||||||
if (fs.existsSync(socketPath)) {
|
|
||||||
fs.unlinkSync(socketPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let i = 0; i < cpuCount; i++) {
|
|
||||||
cluster.fork();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ipc.serve(socketPath, function () {
|
|
||||||
ipc.server.on("currentDate", function (data, socket) {
|
|
||||||
console.log(`pid ${process.pid} got: `, data);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
ipc.server.start();
|
|
||||||
console.log(`pid ${process.pid} listening on ${socketPath}`);
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
##### Client
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
const fs = require("fs");
|
|
||||||
const ipc = require("../../@achrinza/node-ipc");
|
|
||||||
|
|
||||||
const socketPath = "/tmp/ipc.sock";
|
|
||||||
|
|
||||||
//loop forever so you can see the pid of the cluster sever change in the logs
|
|
||||||
setInterval(function () {
|
|
||||||
ipc.connectTo("world", socketPath, connecting);
|
|
||||||
}, 2000);
|
|
||||||
|
|
||||||
function connecting(socket) {
|
|
||||||
ipc.of.world.on("connect", function () {
|
|
||||||
ipc.of.world.emit("currentDate", {
|
|
||||||
message: new Date().toISOString(),
|
|
||||||
});
|
|
||||||
ipc.disconnect("world");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
#### Licensed under MIT license
|
|
||||||
|
|
||||||
See the [MIT license](https://github.com/RIAEvangelist/@achrinza/node-ipc/blob/master/license) file.
|
|
@ -1,256 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
const net = require('net'),
|
|
||||||
tls = require('tls'),
|
|
||||||
EventParser = require('../entities/EventParser.js'),
|
|
||||||
Message = require('js-message'),
|
|
||||||
fs = require('fs'),
|
|
||||||
Queue = require('@node-ipc/js-queue'),
|
|
||||||
Events = require('event-pubsub');
|
|
||||||
|
|
||||||
let eventParser = new EventParser();
|
|
||||||
|
|
||||||
class Client extends Events{
|
|
||||||
constructor(config,log){
|
|
||||||
super();
|
|
||||||
Object.assign(
|
|
||||||
this,
|
|
||||||
{
|
|
||||||
Client : Client,
|
|
||||||
config : config,
|
|
||||||
queue : new Queue,
|
|
||||||
socket : false,
|
|
||||||
connect : connect,
|
|
||||||
emit : emit,
|
|
||||||
log : log,
|
|
||||||
retriesRemaining:config.maxRetries||0,
|
|
||||||
explicitlyDisconnected: false
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
eventParser=new EventParser(this.config);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function emit(type,data){
|
|
||||||
this.log('dispatching event to ', this.id, this.path, ' : ', type, ',', data);
|
|
||||||
|
|
||||||
let message=new Message;
|
|
||||||
message.type=type;
|
|
||||||
message.data=data;
|
|
||||||
|
|
||||||
if(this.config.rawBuffer){
|
|
||||||
message=Buffer.from(type,this.config.encoding);
|
|
||||||
}else{
|
|
||||||
message=eventParser.format(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!this.config.sync){
|
|
||||||
this.socket.write(message);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.queue.add(
|
|
||||||
syncEmit.bind(this,message)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function syncEmit(message){
|
|
||||||
this.log('dispatching event to ', this.id, this.path, ' : ', message);
|
|
||||||
this.socket.write(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
function connect(){
|
|
||||||
//init client object for scope persistance especially inside of socket events.
|
|
||||||
let client=this;
|
|
||||||
|
|
||||||
client.log('requested connection to ', client.id, client.path);
|
|
||||||
if(!this.path){
|
|
||||||
client.log('\n\n######\nerror: ', client.id ,' client has not specified socket path it wishes to connect to.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const options={};
|
|
||||||
|
|
||||||
if(!client.port){
|
|
||||||
client.log('Connecting client on Unix Socket :', client.path);
|
|
||||||
|
|
||||||
options.path=client.path;
|
|
||||||
|
|
||||||
if (process.platform ==='win32' && !client.path.startsWith('\\\\.\\pipe\\')){
|
|
||||||
options.path = options.path.replace(/^\//, '');
|
|
||||||
options.path = options.path.replace(/\//g, '-');
|
|
||||||
options.path= `\\\\.\\pipe\\${options.path}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
client.socket = net.connect(options);
|
|
||||||
}else{
|
|
||||||
options.host=client.path;
|
|
||||||
options.port=client.port;
|
|
||||||
|
|
||||||
if(client.config.interface.localAddress){
|
|
||||||
options.localAddress=client.config.interface.localAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(client.config.interface.localPort){
|
|
||||||
options.localPort=client.config.interface.localPort;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(client.config.interface.family){
|
|
||||||
options.family=client.config.interface.family;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(client.config.interface.hints){
|
|
||||||
options.hints=client.config.interface.hints;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(client.config.interface.lookup){
|
|
||||||
options.lookup=client.config.interface.lookup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!client.config.tls){
|
|
||||||
client.log('Connecting client via TCP to', options);
|
|
||||||
client.socket = net.connect(options);
|
|
||||||
}else{
|
|
||||||
client.log('Connecting client via TLS to', client.path ,client.port,client.config.tls);
|
|
||||||
if(client.config.tls.private){
|
|
||||||
client.config.tls.key=fs.readFileSync(client.config.tls.private);
|
|
||||||
}
|
|
||||||
if(client.config.tls.public){
|
|
||||||
client.config.tls.cert=fs.readFileSync(client.config.tls.public);
|
|
||||||
}
|
|
||||||
if(client.config.tls.trustedConnections){
|
|
||||||
if(typeof client.config.tls.trustedConnections === 'string'){
|
|
||||||
client.config.tls.trustedConnections=[client.config.tls.trustedConnections];
|
|
||||||
}
|
|
||||||
client.config.tls.ca=[];
|
|
||||||
for(let i=0; i<client.config.tls.trustedConnections.length; i++){
|
|
||||||
client.config.tls.ca.push(
|
|
||||||
fs.readFileSync(client.config.tls.trustedConnections[i])
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Object.assign(client.config.tls,options);
|
|
||||||
|
|
||||||
client.socket = tls.connect(
|
|
||||||
client.config.tls
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
client.socket.setEncoding(this.config.encoding);
|
|
||||||
|
|
||||||
client.socket.on(
|
|
||||||
'error',
|
|
||||||
function(err){
|
|
||||||
client.log('\n\n######\nerror: ', err);
|
|
||||||
client.publish('error', err);
|
|
||||||
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
client.socket.on(
|
|
||||||
'connect',
|
|
||||||
function connectionMade(){
|
|
||||||
client.publish('connect');
|
|
||||||
client.retriesRemaining=client.config.maxRetries;
|
|
||||||
client.log('retrying reset');
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
client.socket.on(
|
|
||||||
'close',
|
|
||||||
function connectionClosed(){
|
|
||||||
client.log('connection closed' ,client.id , client.path,
|
|
||||||
client.retriesRemaining, 'tries remaining of', client.config.maxRetries
|
|
||||||
);
|
|
||||||
|
|
||||||
if(
|
|
||||||
client.config.stopRetrying ||
|
|
||||||
client.retriesRemaining<1 ||
|
|
||||||
client.explicitlyDisconnected
|
|
||||||
|
|
||||||
){
|
|
||||||
client.publish('disconnect');
|
|
||||||
client.log(
|
|
||||||
(client.config.id),
|
|
||||||
'exceeded connection rety amount of',
|
|
||||||
' or stopRetrying flag set.'
|
|
||||||
);
|
|
||||||
|
|
||||||
client.socket.destroy();
|
|
||||||
client.publish('destroy');
|
|
||||||
client=undefined;
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setTimeout(
|
|
||||||
function retryTimeout(){
|
|
||||||
if (client.explicitlyDisconnected) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
client.retriesRemaining--;
|
|
||||||
client.connect();
|
|
||||||
}.bind(null,client),
|
|
||||||
client.config.retry
|
|
||||||
);
|
|
||||||
|
|
||||||
client.publish('disconnect');
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
client.socket.on(
|
|
||||||
'data',
|
|
||||||
function(data) {
|
|
||||||
client.log('## received events ##');
|
|
||||||
if(client.config.rawBuffer){
|
|
||||||
client.publish(
|
|
||||||
'data',
|
|
||||||
Buffer.from(data,client.config.encoding)
|
|
||||||
);
|
|
||||||
if(!client.config.sync){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
client.queue.next();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!this.ipcBuffer){
|
|
||||||
this.ipcBuffer='';
|
|
||||||
}
|
|
||||||
|
|
||||||
data=(this.ipcBuffer+=data);
|
|
||||||
|
|
||||||
if(data.slice(-1)!=eventParser.delimiter || data.indexOf(eventParser.delimiter) == -1){
|
|
||||||
client.log('Messages are large, You may want to consider smaller messages.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.ipcBuffer='';
|
|
||||||
|
|
||||||
const events = eventParser.parse(data);
|
|
||||||
const eCount = events.length;
|
|
||||||
for(let i=0; i<eCount; i++){
|
|
||||||
let message=new Message;
|
|
||||||
message.load(events[i]);
|
|
||||||
|
|
||||||
client.log('detected event', message.type, message.data);
|
|
||||||
client.publish(
|
|
||||||
message.type,
|
|
||||||
message.data
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!client.config.sync){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
client.queue.next();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports=Client;
|
|
@ -1,399 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
const net = require('net'),
|
|
||||||
tls = require('tls'),
|
|
||||||
fs = require('fs'),
|
|
||||||
dgram = require('dgram'),
|
|
||||||
EventParser = require('../entities/EventParser.js'),
|
|
||||||
Message = require('js-message'),
|
|
||||||
Events = require('event-pubsub');
|
|
||||||
|
|
||||||
let eventParser = new EventParser();
|
|
||||||
|
|
||||||
class Server extends Events{
|
|
||||||
constructor(path,config,log,port){
|
|
||||||
super();
|
|
||||||
Object.assign(
|
|
||||||
this,
|
|
||||||
{
|
|
||||||
config : config,
|
|
||||||
path : path,
|
|
||||||
port : port,
|
|
||||||
udp4 : false,
|
|
||||||
udp6 : false,
|
|
||||||
log : log,
|
|
||||||
server : false,
|
|
||||||
sockets : [],
|
|
||||||
emit : emit,
|
|
||||||
broadcast : broadcast
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
eventParser=new EventParser(this.config);
|
|
||||||
|
|
||||||
this.on(
|
|
||||||
'close',
|
|
||||||
serverClosed.bind(this)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
onStart(socket){
|
|
||||||
this.trigger(
|
|
||||||
'start',
|
|
||||||
socket
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
stop(){
|
|
||||||
this.server.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
start(){
|
|
||||||
if(!this.path){
|
|
||||||
this.log('Socket Server Path not specified, refusing to start');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(this.config.unlink){
|
|
||||||
fs.unlink(
|
|
||||||
this.path,
|
|
||||||
startServer.bind(this)
|
|
||||||
);
|
|
||||||
}else{
|
|
||||||
startServer.bind(this)();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function emit(socket, type, data){
|
|
||||||
this.log('dispatching event to socket', ' : ', type, data);
|
|
||||||
|
|
||||||
let message=new Message;
|
|
||||||
message.type=type;
|
|
||||||
message.data=data;
|
|
||||||
|
|
||||||
if(this.config.rawBuffer){
|
|
||||||
this.log(this.config.encoding)
|
|
||||||
message=Buffer.from(type,this.config.encoding);
|
|
||||||
}else{
|
|
||||||
message=eventParser.format(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(this.udp4 || this.udp6){
|
|
||||||
|
|
||||||
if(!socket.address || !socket.port){
|
|
||||||
this.log('Attempting to emit to a single UDP socket without supplying socket address or port. Redispatching event as broadcast to all connected sockets');
|
|
||||||
this.broadcast(type,data);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.server.write(
|
|
||||||
message,
|
|
||||||
socket
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
socket.write(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
function broadcast(type,data){
|
|
||||||
this.log('broadcasting event to all known sockets listening to ', this.path,' : ', ((this.port)?this.port:''), type, data);
|
|
||||||
let message=new Message;
|
|
||||||
message.type=type;
|
|
||||||
message.data=data;
|
|
||||||
|
|
||||||
if(this.config.rawBuffer){
|
|
||||||
message=Buffer.from(type,this.config.encoding);
|
|
||||||
}else{
|
|
||||||
message=eventParser.format(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(this.udp4 || this.udp6){
|
|
||||||
for(let i=1, count=this.sockets.length; i<count; i++){
|
|
||||||
this.server.write(message,this.sockets[i]);
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
for(let i=0, count=this.sockets.length; i<count; i++){
|
|
||||||
this.sockets[i].write(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function serverClosed(){
|
|
||||||
for(let i=0, count=this.sockets.length; i<count; i++){
|
|
||||||
let socket=this.sockets[i];
|
|
||||||
let destroyedSocketId=false;
|
|
||||||
|
|
||||||
if(socket){
|
|
||||||
if(socket.readable){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(socket.id){
|
|
||||||
destroyedSocketId=socket.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.log('socket disconnected',destroyedSocketId.toString());
|
|
||||||
|
|
||||||
if(socket && socket.destroy){
|
|
||||||
socket.destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.sockets.splice(i,1);
|
|
||||||
|
|
||||||
this.publish('socket.disconnected', socket, destroyedSocketId);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function gotData(socket,data,UDPSocket){
|
|
||||||
let sock=((this.udp4 || this.udp6)? UDPSocket : socket);
|
|
||||||
if(this.config.rawBuffer){
|
|
||||||
data=Buffer.from(data,this.config.encoding);
|
|
||||||
this.publish(
|
|
||||||
'data',
|
|
||||||
data,
|
|
||||||
sock
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!sock.ipcBuffer){
|
|
||||||
sock.ipcBuffer='';
|
|
||||||
}
|
|
||||||
|
|
||||||
data=(sock.ipcBuffer+=data);
|
|
||||||
|
|
||||||
if(data.slice(-1)!=eventParser.delimiter || data.indexOf(eventParser.delimiter) == -1){
|
|
||||||
this.log('Messages are large, You may want to consider smaller messages.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
sock.ipcBuffer='';
|
|
||||||
|
|
||||||
data=eventParser.parse(data);
|
|
||||||
|
|
||||||
while(data.length>0){
|
|
||||||
let message=new Message;
|
|
||||||
message.load(data.shift());
|
|
||||||
|
|
||||||
// Only set the sock id if it is specified.
|
|
||||||
if (message.data && message.data.id){
|
|
||||||
sock.id=message.data.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.log('received event of : ',message.type,message.data);
|
|
||||||
|
|
||||||
this.publish(
|
|
||||||
message.type,
|
|
||||||
message.data,
|
|
||||||
sock
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function socketClosed(socket){
|
|
||||||
this.publish(
|
|
||||||
'close',
|
|
||||||
socket
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function serverCreated(socket) {
|
|
||||||
this.sockets.push(socket);
|
|
||||||
|
|
||||||
if(socket.setEncoding){
|
|
||||||
socket.setEncoding(this.config.encoding);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.log('## socket connection to server detected ##');
|
|
||||||
socket.on(
|
|
||||||
'close',
|
|
||||||
socketClosed.bind(this)
|
|
||||||
);
|
|
||||||
|
|
||||||
socket.on(
|
|
||||||
'error',
|
|
||||||
function(err){
|
|
||||||
this.log('server socket error',err);
|
|
||||||
|
|
||||||
this.publish('error',err);
|
|
||||||
}.bind(this)
|
|
||||||
);
|
|
||||||
|
|
||||||
socket.on(
|
|
||||||
'data',
|
|
||||||
gotData.bind(this,socket)
|
|
||||||
);
|
|
||||||
|
|
||||||
socket.on(
|
|
||||||
'message',
|
|
||||||
function(msg,rinfo) {
|
|
||||||
if (!rinfo){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.log('Received UDP message from ', rinfo.address, rinfo.port);
|
|
||||||
let data;
|
|
||||||
|
|
||||||
if(this.config.rawSocket){
|
|
||||||
data=Buffer.from(msg,this.config.encoding);
|
|
||||||
}else{
|
|
||||||
data=msg.toString();
|
|
||||||
}
|
|
||||||
socket.emit('data',data,rinfo);
|
|
||||||
}.bind(this)
|
|
||||||
);
|
|
||||||
|
|
||||||
this.publish(
|
|
||||||
'connect',
|
|
||||||
socket
|
|
||||||
);
|
|
||||||
|
|
||||||
if(this.config.rawBuffer){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function startServer() {
|
|
||||||
this.log(
|
|
||||||
'starting server on ',this.path,
|
|
||||||
((this.port)?`:${this.port}`:'')
|
|
||||||
);
|
|
||||||
|
|
||||||
if(!this.udp4 && !this.udp6){
|
|
||||||
this.log('starting TLS server',this.config.tls);
|
|
||||||
if(!this.config.tls){
|
|
||||||
this.server=net.createServer(
|
|
||||||
serverCreated.bind(this)
|
|
||||||
);
|
|
||||||
}else{
|
|
||||||
startTLSServer.bind(this)();
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
this.server=dgram.createSocket(
|
|
||||||
((this.udp4)? 'udp4':'udp6')
|
|
||||||
);
|
|
||||||
this.server.write=UDPWrite.bind(this);
|
|
||||||
this.server.on(
|
|
||||||
'listening',
|
|
||||||
function UDPServerStarted() {
|
|
||||||
serverCreated.bind(this)(this.server);
|
|
||||||
}.bind(this)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.server.on(
|
|
||||||
'error',
|
|
||||||
function(err){
|
|
||||||
this.log('server error',err);
|
|
||||||
|
|
||||||
this.publish(
|
|
||||||
'error',
|
|
||||||
err
|
|
||||||
);
|
|
||||||
}.bind(this)
|
|
||||||
);
|
|
||||||
|
|
||||||
this.server.maxConnections=this.config.maxConnections;
|
|
||||||
|
|
||||||
if(!this.port){
|
|
||||||
this.log('starting server as', 'Unix || Windows Socket');
|
|
||||||
if (process.platform ==='win32'){
|
|
||||||
this.path = this.path.replace(/^\//, '');
|
|
||||||
this.path = this.path.replace(/\//g, '-');
|
|
||||||
this.path= `\\\\.\\pipe\\${this.path}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.server.listen({
|
|
||||||
path: this.path,
|
|
||||||
readableAll: this.config.readableAll,
|
|
||||||
writableAll: this.config.writableAll
|
|
||||||
}, this.onStart.bind(this));
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!this.udp4 && !this.udp6){
|
|
||||||
this.log('starting server as', (this.config.tls?'TLS':'TCP'));
|
|
||||||
this.server.listen(
|
|
||||||
this.port,
|
|
||||||
this.path,
|
|
||||||
this.onStart.bind(this)
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.log('starting server as',((this.udp4)? 'udp4':'udp6'));
|
|
||||||
|
|
||||||
this.server.bind(
|
|
||||||
this.port,
|
|
||||||
this.path
|
|
||||||
);
|
|
||||||
|
|
||||||
this.onStart(
|
|
||||||
{
|
|
||||||
address : this.path,
|
|
||||||
port : this.port
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function startTLSServer(){
|
|
||||||
this.log('starting TLS server',this.config.tls);
|
|
||||||
if(this.config.tls.private){
|
|
||||||
this.config.tls.key=fs.readFileSync(this.config.tls.private);
|
|
||||||
}else{
|
|
||||||
this.config.tls.key=fs.readFileSync(`${__dirname}/../local-node-ipc-certs/private/server.key`);
|
|
||||||
}
|
|
||||||
if(this.config.tls.public){
|
|
||||||
this.config.tls.cert=fs.readFileSync(this.config.tls.public);
|
|
||||||
}else{
|
|
||||||
this.config.tls.cert=fs.readFileSync(`${__dirname}/../local-node-ipc-certs/server.pub`);
|
|
||||||
}
|
|
||||||
if(this.config.tls.dhparam){
|
|
||||||
this.config.tls.dhparam=fs.readFileSync(this.config.tls.dhparam);
|
|
||||||
}
|
|
||||||
if(this.config.tls.trustedConnections){
|
|
||||||
if(typeof this.config.tls.trustedConnections === 'string'){
|
|
||||||
this.config.tls.trustedConnections=[this.config.tls.trustedConnections];
|
|
||||||
}
|
|
||||||
this.config.tls.ca=[];
|
|
||||||
for(let i=0; i<this.config.tls.trustedConnections.length; i++){
|
|
||||||
this.config.tls.ca.push(
|
|
||||||
fs.readFileSync(this.config.tls.trustedConnections[i])
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.server=tls.createServer(
|
|
||||||
this.config.tls,
|
|
||||||
serverCreated.bind(this)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function UDPWrite(message,socket){
|
|
||||||
let data=Buffer.from(message, this.config.encoding);
|
|
||||||
this.server.send(
|
|
||||||
data,
|
|
||||||
0,
|
|
||||||
data.length,
|
|
||||||
socket.port,
|
|
||||||
socket.address,
|
|
||||||
function(err, bytes) {
|
|
||||||
if(err){
|
|
||||||
this.log('error writing data to socket',err);
|
|
||||||
this.publish(
|
|
||||||
'error',
|
|
||||||
function(err){
|
|
||||||
this.publish('error',err);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports=Server;
|
|
@ -1,83 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
/*eslint no-magic-numbers: ["error", { "ignore": [ 0] }]*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @module entities
|
|
||||||
*/
|
|
||||||
|
|
||||||
const os = require('os');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @class Defaults
|
|
||||||
* @description Defaults Entity
|
|
||||||
*/
|
|
||||||
class Defaults{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @method constructor
|
|
||||||
* @return {void}
|
|
||||||
*/
|
|
||||||
constructor(){
|
|
||||||
|
|
||||||
this.appspace='app.';
|
|
||||||
this.socketRoot='/tmp/';
|
|
||||||
this.id=os.hostname();
|
|
||||||
|
|
||||||
this.encoding='utf8';
|
|
||||||
this.rawBuffer=false;
|
|
||||||
this.sync=false;
|
|
||||||
this.unlink=true;
|
|
||||||
|
|
||||||
this.delimiter='\f';
|
|
||||||
|
|
||||||
this.silent=false;
|
|
||||||
this.logDepth=5;
|
|
||||||
this.logInColor=true;
|
|
||||||
this.logger=console.log.bind(console);
|
|
||||||
|
|
||||||
this.maxConnections=100;
|
|
||||||
this.retry=500;
|
|
||||||
this.maxRetries=Infinity;
|
|
||||||
this.stopRetrying=false;
|
|
||||||
|
|
||||||
this.IPType=getIPType();
|
|
||||||
this.tls=false;
|
|
||||||
this.networkHost = (this.IPType == 'IPv6') ? '::1' : '127.0.0.1';
|
|
||||||
this.networkPort = 8000;
|
|
||||||
|
|
||||||
this.readableAll = false;
|
|
||||||
this.writableAll = false;
|
|
||||||
|
|
||||||
this.interface={
|
|
||||||
localAddress:false,
|
|
||||||
localPort:false,
|
|
||||||
family:false,
|
|
||||||
hints:false,
|
|
||||||
lookup:false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* method to get ip type
|
|
||||||
*
|
|
||||||
* @method getIPType
|
|
||||||
* @return {string} ip type
|
|
||||||
*/
|
|
||||||
function getIPType() {
|
|
||||||
const networkInterfaces = os.networkInterfaces();
|
|
||||||
let IPType = '';
|
|
||||||
if (networkInterfaces
|
|
||||||
&& Array.isArray(networkInterfaces)
|
|
||||||
&& networkInterfaces.length > 0) {
|
|
||||||
// getting the family of first network interface available
|
|
||||||
IPType = networkInterfaces [
|
|
||||||
Object.keys( networkInterfaces )[0]
|
|
||||||
][0].family;
|
|
||||||
}
|
|
||||||
return IPType;
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports=Defaults;
|
|
@ -1,32 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
const Defaults = require('./Defaults.js');
|
|
||||||
|
|
||||||
class Parser{
|
|
||||||
constructor(config){
|
|
||||||
if(!config){
|
|
||||||
config=new Defaults;
|
|
||||||
}
|
|
||||||
this.delimiter=config.delimiter;
|
|
||||||
}
|
|
||||||
|
|
||||||
format(message){
|
|
||||||
if(!message.data && message.data!==false && message.data!==0){
|
|
||||||
message.data={};
|
|
||||||
}
|
|
||||||
if(message.data['_maxListeners']){
|
|
||||||
message.data={};
|
|
||||||
}
|
|
||||||
|
|
||||||
message=message.JSON+this.delimiter;
|
|
||||||
return message;
|
|
||||||
}
|
|
||||||
|
|
||||||
parse(data){
|
|
||||||
let events=data.split(this.delimiter);
|
|
||||||
events.pop();
|
|
||||||
return events;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports=Parser;
|
|
@ -1,24 +0,0 @@
|
|||||||
-----BEGIN CERTIFICATE-----
|
|
||||||
MIID+zCCAuOgAwIBAgIJAKUVVihb00q/MA0GCSqGSIb3DQEBCwUAMIGTMQswCQYD
|
|
||||||
VQQGEwJVUzETMBEGA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNVGhvdXNhbmQg
|
|
||||||
T2FrczEUMBIGA1UECgwLRGlnaU5vdyBpbmMxDDAKBgNVBAsMA1JuRDEQMA4GA1UE
|
|
||||||
AwwHRGlnaU5vdzEhMB8GCSqGSIb3DQEJARYSYnJhbmRvbkBkaWdpbm93Lml0MB4X
|
|
||||||
DTE2MDkxMDIxNTk0NloXDTE3MDkxMDIxNTk0NlowgZMxCzAJBgNVBAYTAlVTMRMw
|
|
||||||
EQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQHDA1UaG91c2FuZCBPYWtzMRQwEgYD
|
|
||||||
VQQKDAtE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+Kks3
|
|
||||||
58ANS3VkbXXzB3MeNGoB
|
|
||||||
-----END CERTIFICATE-----
|
|
@ -1,352 +0,0 @@
|
|||||||
#
|
|
||||||
# OpenSSL example configuration file.
|
|
||||||
# This is mostly being used for generation of certificate requests.
|
|
||||||
#
|
|
||||||
|
|
||||||
# This definition stops the following lines choking if HOME isn't
|
|
||||||
# defined.
|
|
||||||
HOME = .
|
|
||||||
RANDFILE = $ENV::HOME/.rnd
|
|
||||||
|
|
||||||
# Extra OBJECT IDENTIFIER info:
|
|
||||||
#oid_file = $ENV::HOME/.oid
|
|
||||||
oid_section = new_oids
|
|
||||||
|
|
||||||
# To use this configuration file with the "-extfile" option of the
|
|
||||||
# "openssl x509" utility, name here the section containing the
|
|
||||||
# X.509v3 extensions to use:
|
|
||||||
# extensions =
|
|
||||||
# (Alternatively, use a configuration file that has only
|
|
||||||
# X.509v3 extensions in its main [= default] section.)
|
|
||||||
|
|
||||||
[ new_oids ]
|
|
||||||
|
|
||||||
# We can add new OIDs in here for use by 'ca', 'req' and 'ts'.
|
|
||||||
# Add a simple OID like this:
|
|
||||||
# testoid1=1.2.3.4
|
|
||||||
# Or use config file substitution like this:
|
|
||||||
# testoid2=${testoid1}.5.6
|
|
||||||
|
|
||||||
# Policies used by the TSA examples.
|
|
||||||
tsa_policy1 = 1.2.3.4.1
|
|
||||||
tsa_policy2 = 1.2.3.4.5.6
|
|
||||||
tsa_policy3 = 1.2.3.4.5.7
|
|
||||||
|
|
||||||
####################################################################
|
|
||||||
[ ca ]
|
|
||||||
default_ca = CA_default # The default ca section
|
|
||||||
|
|
||||||
####################################################################
|
|
||||||
[ CA_default ]
|
|
||||||
|
|
||||||
dir = ./demoCA # Where everything is kept
|
|
||||||
certs = $dir/certs # Where the issued certs are kept
|
|
||||||
crl_dir = $dir/crl # Where the issued crl are kept
|
|
||||||
database = $dir/index.txt # database index file.
|
|
||||||
#unique_subject = no # Set to 'no' to allow creation of
|
|
||||||
# several ctificates with same subject.
|
|
||||||
new_certs_dir = $dir/newcerts # default place for new certs.
|
|
||||||
|
|
||||||
certificate = $dir/cacert.pem # The CA certificate
|
|
||||||
serial = $dir/serial # The current serial number
|
|
||||||
crlnumber = $dir/crlnumber # the current crl number
|
|
||||||
# must be commented out to leave a V1 CRL
|
|
||||||
crl = $dir/crl.pem # The current CRL
|
|
||||||
private_key = $dir/private/cakey.pem# The private key
|
|
||||||
RANDFILE = $dir/private/.rand # private random number file
|
|
||||||
|
|
||||||
x509_extensions = usr_cert # The extentions to add to the cert
|
|
||||||
|
|
||||||
# Comment out the following two lines for the "traditional"
|
|
||||||
# (and highly broken) format.
|
|
||||||
name_opt = ca_default # Subject Name options
|
|
||||||
cert_opt = ca_default # Certificate field options
|
|
||||||
|
|
||||||
# Extension copying option: use with caution.
|
|
||||||
# copy_extensions = copy
|
|
||||||
|
|
||||||
# Extensions to add to a CRL. Note: Netscape communicator chokes on V2 CRLs
|
|
||||||
# so this is commented out by default to leave a V1 CRL.
|
|
||||||
# crlnumber must also be commented out to leave a V1 CRL.
|
|
||||||
# crl_extensions = crl_ext
|
|
||||||
|
|
||||||
default_days = 365 # how long to certify for
|
|
||||||
default_crl_days= 30 # how long before next CRL
|
|
||||||
default_md = default # use public key default MD
|
|
||||||
preserve = no # keep passed DN ordering
|
|
||||||
|
|
||||||
# A few difference way of specifying how similar the request should look
|
|
||||||
# For type CA, the listed attributes must be the same, and the optional
|
|
||||||
# and supplied fields are just that :-)
|
|
||||||
policy = policy_match
|
|
||||||
|
|
||||||
# For the CA policy
|
|
||||||
[ policy_match ]
|
|
||||||
countryName = match
|
|
||||||
stateOrProvinceName = match
|
|
||||||
organizationName = match
|
|
||||||
organizationalUnitName = optional
|
|
||||||
commonName = supplied
|
|
||||||
emailAddress = optional
|
|
||||||
|
|
||||||
# For the 'anything' policy
|
|
||||||
# At this point in time, you must list all acceptable 'object'
|
|
||||||
# types.
|
|
||||||
[ policy_anything ]
|
|
||||||
countryName = optional
|
|
||||||
stateOrProvinceName = optional
|
|
||||||
localityName = optional
|
|
||||||
organizationName = optional
|
|
||||||
organizationalUnitName = optional
|
|
||||||
commonName = supplied
|
|
||||||
emailAddress = optional
|
|
||||||
|
|
||||||
####################################################################
|
|
||||||
[ req ]
|
|
||||||
default_bits = 2048
|
|
||||||
default_keyfile = privkey.pem
|
|
||||||
distinguished_name = req_distinguished_name
|
|
||||||
attributes = req_attributes
|
|
||||||
x509_extensions = v3_ca # The extentions to add to the self signed cert
|
|
||||||
|
|
||||||
# Passwords for private keys if not present they will be prompted for
|
|
||||||
# input_password = secret
|
|
||||||
# output_password = secret
|
|
||||||
|
|
||||||
# This sets a mask for permitted string types. There are several options.
|
|
||||||
# default: PrintableString, T61String, BMPString.
|
|
||||||
# pkix : PrintableString, BMPString (PKIX recommendation before 2004)
|
|
||||||
# utf8only: only UTF8Strings (PKIX recommendation after 2004).
|
|
||||||
# nombstr : PrintableString, T61String (no BMPStrings or UTF8Strings).
|
|
||||||
# MASK:XXXX a literal mask value.
|
|
||||||
# WARNING: ancient versions of Netscape crash on BMPStrings or UTF8Strings.
|
|
||||||
string_mask = utf8only
|
|
||||||
|
|
||||||
req_extensions = v3_req # The extensions to add to a certificate request
|
|
||||||
|
|
||||||
[ req_distinguished_name ]
|
|
||||||
countryName = Country Name (2 letter code)
|
|
||||||
countryName_default = AU
|
|
||||||
countryName_min = 2
|
|
||||||
countryName_max = 2
|
|
||||||
|
|
||||||
stateOrProvinceName = State or Province Name (full name)
|
|
||||||
stateOrProvinceName_default = Some-State
|
|
||||||
|
|
||||||
localityName = Locality Name (eg, city)
|
|
||||||
|
|
||||||
0.organizationName = Organization Name (eg, company)
|
|
||||||
0.organizationName_default = Internet Widgits Pty Ltd
|
|
||||||
|
|
||||||
# we can do this but it is not needed normally :-)
|
|
||||||
#1.organizationName = Second Organization Name (eg, company)
|
|
||||||
#1.organizationName_default = World Wide Web Pty Ltd
|
|
||||||
|
|
||||||
organizationalUnitName = Organizational Unit Name (eg, section)
|
|
||||||
#organizationalUnitName_default =
|
|
||||||
|
|
||||||
commonName = Common Name (e.g. server FQDN or YOUR name)
|
|
||||||
commonName_max = 64
|
|
||||||
|
|
||||||
emailAddress = Email Address
|
|
||||||
emailAddress_max = 64
|
|
||||||
|
|
||||||
# SET-ex3 = SET extension number 3
|
|
||||||
|
|
||||||
[ req_attributes ]
|
|
||||||
challengePassword = A challenge password
|
|
||||||
challengePassword_min = 4
|
|
||||||
challengePassword_max = 20
|
|
||||||
|
|
||||||
unstructuredName = An optional company name
|
|
||||||
|
|
||||||
[ usr_cert ]
|
|
||||||
|
|
||||||
# These extensions are added when 'ca' signs a request.
|
|
||||||
|
|
||||||
# This goes against PKIX guidelines but some CAs do it and some software
|
|
||||||
# requires this to avoid interpreting an end user certificate as a CA.
|
|
||||||
|
|
||||||
basicConstraints=CA:FALSE
|
|
||||||
|
|
||||||
# Here are some examples of the usage of nsCertType. If it is omitted
|
|
||||||
# the certificate can be used for anything *except* object signing.
|
|
||||||
|
|
||||||
# This is OK for an SSL server.
|
|
||||||
# nsCertType = server
|
|
||||||
|
|
||||||
# For an object signing certificate this would be used.
|
|
||||||
# nsCertType = objsign
|
|
||||||
|
|
||||||
# For normal client use this is typical
|
|
||||||
# nsCertType = client, email
|
|
||||||
|
|
||||||
# and for everything including object signing:
|
|
||||||
# nsCertType = client, email, objsign
|
|
||||||
|
|
||||||
# This is typical in keyUsage for a client certificate.
|
|
||||||
# keyUsage = nonRepudiation, digitalSignature, keyEncipherment
|
|
||||||
|
|
||||||
# This will be displayed in Netscape's comment listbox.
|
|
||||||
nsComment = "OpenSSL Generated Certificate"
|
|
||||||
|
|
||||||
# PKIX recommendations harmless if included in all certificates.
|
|
||||||
subjectKeyIdentifier=hash
|
|
||||||
authorityKeyIdentifier=keyid,issuer
|
|
||||||
|
|
||||||
# This stuff is for subjectAltName and issuerAltname.
|
|
||||||
# Import the email address.
|
|
||||||
# subjectAltName=email:copy
|
|
||||||
# An alternative to produce certificates that aren't
|
|
||||||
# deprecated according to PKIX.
|
|
||||||
# subjectAltName=email:move
|
|
||||||
|
|
||||||
# Copy subject details
|
|
||||||
# issuerAltName=issuer:copy
|
|
||||||
|
|
||||||
#nsCaRevocationUrl = http://www.domain.dom/ca-crl.pem
|
|
||||||
#nsBaseUrl
|
|
||||||
#nsRevocationUrl
|
|
||||||
#nsRenewalUrl
|
|
||||||
#nsCaPolicyUrl
|
|
||||||
#nsSslServerName
|
|
||||||
|
|
||||||
# This is required for TSA certificates.
|
|
||||||
# extendedKeyUsage = critical,timeStamping
|
|
||||||
|
|
||||||
[ v3_req ]
|
|
||||||
|
|
||||||
subjectAltName="DNS:localhost,IP:127.0.0.1"
|
|
||||||
|
|
||||||
# Extensions to add to a certificate request
|
|
||||||
|
|
||||||
basicConstraints = CA:FALSE
|
|
||||||
keyUsage = nonRepudiation, digitalSignature, keyEncipherment
|
|
||||||
|
|
||||||
[ v3_ca ]
|
|
||||||
|
|
||||||
|
|
||||||
# Extensions for a typical CA
|
|
||||||
|
|
||||||
|
|
||||||
# PKIX recommendation.
|
|
||||||
|
|
||||||
subjectKeyIdentifier=hash
|
|
||||||
|
|
||||||
authorityKeyIdentifier=keyid:always,issuer
|
|
||||||
|
|
||||||
# This is what PKIX recommends but some broken software chokes on critical
|
|
||||||
# extensions.
|
|
||||||
#basicConstraints = critical,CA:true
|
|
||||||
# So we do this instead.
|
|
||||||
basicConstraints = CA:true
|
|
||||||
|
|
||||||
# Key usage: this is typical for a CA certificate. However since it will
|
|
||||||
# prevent it being used as an test self-signed certificate it is best
|
|
||||||
# left out by default.
|
|
||||||
# keyUsage = cRLSign, keyCertSign
|
|
||||||
|
|
||||||
# Some might want this also
|
|
||||||
# nsCertType = sslCA, emailCA
|
|
||||||
|
|
||||||
# Include email address in subject alt name: another PKIX recommendation
|
|
||||||
# subjectAltName=email:copy
|
|
||||||
# Copy issuer details
|
|
||||||
# issuerAltName=issuer:copy
|
|
||||||
|
|
||||||
# DER hex encoding of an extension: beware experts only!
|
|
||||||
# obj=DER:02:03
|
|
||||||
# Where 'obj' is a standard or added object
|
|
||||||
# You can even override a supported extension:
|
|
||||||
# basicConstraints= critical, DER:30:03:01:01:FF
|
|
||||||
|
|
||||||
[ crl_ext ]
|
|
||||||
|
|
||||||
# CRL extensions.
|
|
||||||
# Only issuerAltName and authorityKeyIdentifier make any sense in a CRL.
|
|
||||||
|
|
||||||
# issuerAltName=issuer:copy
|
|
||||||
authorityKeyIdentifier=keyid:always
|
|
||||||
|
|
||||||
[ proxy_cert_ext ]
|
|
||||||
# These extensions should be added when creating a proxy certificate
|
|
||||||
|
|
||||||
# This goes against PKIX guidelines but some CAs do it and some software
|
|
||||||
# requires this to avoid interpreting an end user certificate as a CA.
|
|
||||||
|
|
||||||
basicConstraints=CA:FALSE
|
|
||||||
|
|
||||||
# Here are some examples of the usage of nsCertType. If it is omitted
|
|
||||||
# the certificate can be used for anything *except* object signing.
|
|
||||||
|
|
||||||
# This is OK for an SSL server.
|
|
||||||
# nsCertType = server
|
|
||||||
|
|
||||||
# For an object signing certificate this would be used.
|
|
||||||
# nsCertType = objsign
|
|
||||||
|
|
||||||
# For normal client use this is typical
|
|
||||||
# nsCertType = client, email
|
|
||||||
|
|
||||||
# and for everything including object signing:
|
|
||||||
# nsCertType = client, email, objsign
|
|
||||||
|
|
||||||
# This is typical in keyUsage for a client certificate.
|
|
||||||
# keyUsage = nonRepudiation, digitalSignature, keyEncipherment
|
|
||||||
|
|
||||||
# This will be displayed in Netscape's comment listbox.
|
|
||||||
nsComment = "OpenSSL Generated Certificate"
|
|
||||||
|
|
||||||
# PKIX recommendations harmless if included in all certificates.
|
|
||||||
subjectKeyIdentifier=hash
|
|
||||||
authorityKeyIdentifier=keyid,issuer
|
|
||||||
|
|
||||||
# This stuff is for subjectAltName and issuerAltname.
|
|
||||||
# Import the email address.
|
|
||||||
# subjectAltName=email:copy
|
|
||||||
# An alternative to produce certificates that aren't
|
|
||||||
# deprecated according to PKIX.
|
|
||||||
# subjectAltName=email:move
|
|
||||||
|
|
||||||
# Copy subject details
|
|
||||||
# issuerAltName=issuer:copy
|
|
||||||
|
|
||||||
#nsCaRevocationUrl = http://www.domain.dom/ca-crl.pem
|
|
||||||
#nsBaseUrl
|
|
||||||
#nsRevocationUrl
|
|
||||||
#nsRenewalUrl
|
|
||||||
#nsCaPolicyUrl
|
|
||||||
#nsSslServerName
|
|
||||||
|
|
||||||
# This really needs to be in place for it to be a proxy certificate.
|
|
||||||
proxyCertInfo=critical,language:id-ppl-anyLanguage,pathlen:3,policy:foo
|
|
||||||
|
|
||||||
####################################################################
|
|
||||||
[ tsa ]
|
|
||||||
|
|
||||||
default_tsa = tsa_config1 # the default TSA section
|
|
||||||
|
|
||||||
[ tsa_config1 ]
|
|
||||||
|
|
||||||
# These are used by the TSA reply generation only.
|
|
||||||
dir = ./demoCA # TSA root directory
|
|
||||||
serial = $dir/tsaserial # The current serial number (mandatory)
|
|
||||||
crypto_device = builtin # OpenSSL engine to use for signing
|
|
||||||
signer_cert = $dir/tsacert.pem # The TSA signing certificate
|
|
||||||
# (optional)
|
|
||||||
certs = $dir/cacert.pem # Certificate chain to include in reply
|
|
||||||
# (optional)
|
|
||||||
signer_key = $dir/private/tsakey.pem # The TSA private key (optional)
|
|
||||||
|
|
||||||
default_policy = tsa_policy1 # Policy if request did not specify it
|
|
||||||
# (optional)
|
|
||||||
other_policies = tsa_policy2, tsa_policy3 # acceptable policies (optional)
|
|
||||||
digests = md5, sha1 # Acceptable message digests (mandatory)
|
|
||||||
accuracy = secs:1, millisecs:500, microsecs:100 # (optional)
|
|
||||||
clock_precision_digits = 0 # number of digits after dot. (optional)
|
|
||||||
ordering = yes # Is ordering defined for timestamps?
|
|
||||||
# (optional, default: no)
|
|
||||||
tsa_name = yes # Must the TSA name be included in the reply?
|
|
||||||
# (optional, default: no)
|
|
||||||
ess_cert_id_chain = no # Must the ESS cert id chain be included?
|
|
||||||
# (optional, default: no)
|
|
27
src/front/node_modules/@achrinza/node-ipc/local-node-ipc-certs/private/client.key
generated
vendored
27
src/front/node_modules/@achrinza/node-ipc/local-node-ipc-certs/private/client.key
generated
vendored
@ -1,27 +0,0 @@
|
|||||||
-----BEGIN RSA PRIVATE KEY-----
|
|
||||||
MIIEogIBAAKCAQEAqzR1m22jL5citxDXr2Hm/suYFrTn+U/B0uZNBO37m/I1OH+I
|
|
||||||
+6aMYbwGIGjHrlFIoEd2GTkhnNzfMlxSxa61PFkMiuygMFnMlL6liu5r4+nUADbZ
|
|
||||||
xr55LfqtqYzDtZ8VT7l4KL9BiGlh3O4C+K37qIQXLepW8Tl2lMVh3hW0KFpasbPp
|
|
||||||
WGjTCDJ+z4DcDwyDaCXgAypFRV5TRvf2J0+Y+00HoJsxcQQXZKPBDVvGPdURvv2B
|
|
||||||
4bRD8inkBq5tzbZfOSaJE/xlLFFH1I15LiqybKy4cDFSzw9t7nMuycwXHnNFYKbv
|
|
||||||
fQZLOdcP3aOn/NKyJQISPonrGZTyY6QyGIZhFwIDAQABAoIBAHpxZ1dE/zuvFLXm
|
|
||||||
xsr48vLxexFqSqnEv/NsoFLRPWzXufZxR+/qumW/yoXtSjpCifWPhkgd0wtT8BEd
|
|
||||||
dFlLTPUfHthQyXQrFSSggNavE9yJxARvNits2E/pA8DKGsJPRzeghu5lcqHz9HjE
|
|
||||||
hL2D+QMZjVZaTdnx5fwaepcR4KomYTUupci0HoMWyoKPhIfItVueiHVo4d60dIRz
|
|
||||||
OpkSGCAZ/Czv5CJrmK/5e+roKti4ChF/n28hUu7OGzvkG+qYep08tf48MyZCPHgO
|
|
||||||
Vj+kuxMRkjIP0iXLmiF32lZXzpOFvjtXovI46dYiINCE9tNyKqDWYUJf9qNqwAsm
|
|
||||||
OuOfXtkCgYEA18Ywabu/Z4vYUhWtTFrP6iSLVcXd0rZuWud7kwv/G4DMrNh7oi1s
|
|
||||||
0AVvphaEqEn8OsgcuyIlyjtJl60aQzvYwdu2KEcTjcqvUX7p/41t5O/LzaYwZ3hh
|
|
||||||
9oFIWXXFpskg7Kh0EGCGG/yvAdTai5M0lO9XQ1DUK0MWc1KQ5yKd0mUCgYEAyx80
|
|
||||||
dgIZTyHl0ZgF712mRda5KfQlmgWoo0zu/IFSFuINEMC/3laYEJCowOnUb8VZ8mbJ
|
|
||||||
Wd/FhOTadv7joY0eAhfSNAItaubuZWo91bbD2vwpi/U2OEfy0LzF7BNXHCpH69wk
|
|
||||||
vujKBxmRTGvBLbabcWA97UPFM2K33rsM72DAL8sCgYB03SOFcKk3BLfRpWnpy9mF
|
|
||||||
/+rzNqpwoFveojb8qmet1rGD/+/eI2omtHsG4nVQzFlu4Mkm1VTQVhICsz9hIL3C
|
|
||||||
KSRcZjqB9j/EDM/hmBDoCLRCGntm3v13zAeKZE37ij1pz8akxBJ+f/mtLUJ8i+rT
|
|
||||||
q1mA3Ps8vyYeqZ5PgSEnPQKBgD6szEU1dJXEQeOgYwRvAyU9kjjtysRxxo1M6dkk
|
|
||||||
Fi5VZe6rawix84349PlBrXknjg+Lw8llkM7mxro9AAQTRRUkQIonudfoldrZI2dU
|
|
||||||
U664bCFxcl9/Y98gwHmNpi1cpoCSlwwJTH1QWFMaVKtEU0ZyiekyJiEq7s1dLiqW
|
|
||||||
0fZtAoGABvAOikMmOn6ewt+NyYd6HkwgcvI0R0aHxOQz8aldW4gwrkuvuOOHdfah
|
|
||||||
RAcc8LiZFqhNFN7DMkRt1crtP5v3vh2Nbyf9Zg2ZizsIupsNlvSlh/aTueVozVuM
|
|
||||||
hc/wEVlrqeJInf4jkxYna6G6CoTfPVyQCjNcvlI3kMfIoyXS+vc=
|
|
||||||
-----END RSA PRIVATE KEY-----
|
|
8
src/front/node_modules/@achrinza/node-ipc/local-node-ipc-certs/private/dhparam.pem
generated
vendored
8
src/front/node_modules/@achrinza/node-ipc/local-node-ipc-certs/private/dhparam.pem
generated
vendored
@ -1,8 +0,0 @@
|
|||||||
-----BEGIN DH PARAMETERS-----
|
|
||||||
MIIBCAKCAQEAhDA93df5Qa7pMWiqJ8IeCDw4fCIJCNbzRklS2saOeQRkUY/kPy07
|
|
||||||
EByFWUDNtgtWRx7YndJKwyFepHXxI3P0DDuSPYKq/bfiWDr/cUmTBJcpPmg6w/SU
|
|
||||||
ReOB6vORXyF9iytyLCKk1Pyo2nXOdpADcTflhi+zxTSpGLtPAU2XIYENtmC4HKJm
|
|
||||||
y6nbSIbe4BA74bxyqzp6RVuMvyHAgCjPDwvHlp5UV1Mjtr1aNqgzpLQSjK4VwiJ+
|
|
||||||
DZ48/1D9IYksDl8NWJopFpudyPD1WFou/CZ6PYsjprFrTKVPqoFD5Zj6zPey9C70
|
|
||||||
Go0uHRNPr9UrhwCqDEKNszulME8heSVSQwIBAg==
|
|
||||||
-----END DH PARAMETERS-----
|
|
27
src/front/node_modules/@achrinza/node-ipc/local-node-ipc-certs/private/oldclient.key
generated
vendored
27
src/front/node_modules/@achrinza/node-ipc/local-node-ipc-certs/private/oldclient.key
generated
vendored
@ -1,27 +0,0 @@
|
|||||||
-----BEGIN RSA PRIVATE KEY-----
|
|
||||||
MIIEowIBAAKCAQEAvmw4yTAd5EdNxksnKEx+ky8XgEqTJVAvcrgF1jaPrC0QNr94
|
|
||||||
EfEHouiEyqWlf4kDzksIA9HcuGhVPZ9gsjjgLvi1pwT+e2vfyOHOWOf96NDlfW02
|
|
||||||
Fx6d92k1zEfhfVmTJU0j6ANG2eNMfF5rhK+xKzH3FC0Vm5e7np9wVuRD4CjggJJL
|
|
||||||
fBm6xJPSBWeY1gum3m5sH4Ec3X0zacZXeBOdjMx1a5I2gfTHJe5fizDfw1vgsYhh
|
|
||||||
I3z6OEXEg5kFtOiz34y4SVCDRZGDVXiAdx8uVXXPdryFybjiZGWGEeTFDZfCAuZp
|
|
||||||
h0I04cqfniD5FbSPIdVVAImH9Nm1sbpLafyuXwIDAQABAoIBADTd8OoSXMoq7bHW
|
|
||||||
3Zk3m5Cba2fnzHB4kaPE6YHuhfbkT/MTN2+rvlYBPhTQ5mDBFnhopmIBGslr1faU
|
|
||||||
0BD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Kv/h
|
|
||||||
zC0ssQKBgEXyFNRGHul7ku8Ss6ZZBZjQEOFdpu7npbZWcqy273tKOdV6uOG93rQX
|
|
||||||
6Ez6yxuBepSdwP716CT7o8EaSPBy+QjDH/e2qI3rIUHzfPwAwf4kGbNa6relTCVR
|
|
||||||
fLrzEICSbFZKST/zeKvrY0ACOCIn8b6LiiP7GJfnV8bvvpTWXyil
|
|
||||||
-----END RSA PRIVATE KEY-----
|
|
27
src/front/node_modules/@achrinza/node-ipc/local-node-ipc-certs/private/oldserver.key
generated
vendored
27
src/front/node_modules/@achrinza/node-ipc/local-node-ipc-certs/private/oldserver.key
generated
vendored
@ -1,27 +0,0 @@
|
|||||||
-----BEGIN RSA PRIVATE KEY-----
|
|
||||||
MIIEogIBAAKCAQEAyHKCBWzkf58gKkqRIBjJR8cSXlsiuOuirlbBQ1K+recVbh2b
|
|
||||||
MdDoqBCk3ibeGw4p/smOxJiH/9rxpcCQ0XrSeNGasLxGB8RcNgenRFonyBPmTAjS
|
|
||||||
O85Aa74g8CUBXaYSgk0hMWQNxkkHecGuu9F6LtN5TM7XG6Td7OTRB+bDEGdwfny4
|
|
||||||
bqc2ELUsj99CVNxSNc5h0dJE9M6ejvIjdRQFFtfNKGgT3O7inEdDSpPZfeM+JmTB
|
|
||||||
r/vz2jnHaSsD7d9hWKYo7Kp74rL0QJSH97ugb+g8kDAkqV1bQaVdzp+nC74/GbVL
|
|
||||||
B9E+YH+zzvs2x9nLYPJHknia5KRfOmRjPnCdVwIDAQABAoIBACdNXHUX3s2vM61X
|
|
||||||
JZF3iq/KNq3NjMdZXHJ2jDpZFQ4gCzGmGHHyFkwtx0XPtSj05AMTHi0qAzCFi3AG
|
|
||||||
i96nCHGsF3qjz89iDvqBEajzTG2MiVFLQX18eWEmzGqJtvTXxTVLTkDS72h7lT2o
|
|
||||||
XkxxTFW2HUiUHdVLxD/Ytauo8YJbjGJM5pdCxEp+uJbYWYwsvvfE4IHb8LJmqtOP
|
|
||||||
fUG/wR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J
|
|
||||||
76aC7LlmX9WlHqaZV/GNcj3PhKao5mIk77BKySxINRaflRiCWjI=
|
|
||||||
-----END RSA PRIVATE KEY-----
|
|
27
src/front/node_modules/@achrinza/node-ipc/local-node-ipc-certs/private/server.key
generated
vendored
27
src/front/node_modules/@achrinza/node-ipc/local-node-ipc-certs/private/server.key
generated
vendored
@ -1,27 +0,0 @@
|
|||||||
-----BEGIN RSA PRIVATE KEY-----
|
|
||||||
MIIEpAIBAAKCAQEAw+YwIWPQAh8WlhPAaasfUyb13Fcg0P0y+UmtAHpAxnUKAxc1
|
|
||||||
/bkl4FNjbS+kkTGkIvRE4NHJh4DMqEDBsf7mwhfaOl8bTCoustyh14bzxJKdM1Cx
|
|
||||||
Q/L2GsTIwF1vZCvqOvrV1glLruRrw8PvSFaWt1JAZ8CUhtyddR3itkSF+suTORxh
|
|
||||||
+aUjUreyfuaWx0dfIQLYOxMeTa/g94Ar9Q7KPCXgxmDqu8DVCmurDH2jz6iFktbp
|
|
||||||
+iNvrUfs88Y3I0E8/QRBAK37j7fEp296QcYIDJKkS2z2lenJykAdaqF9qLhb3zrM
|
|
||||||
UpGt5VUUSNdHeXzCQr7J9wA7TWjCXnQh3d/xlwIDAQABAoIBACUSQHVxIAHmxC1u
|
|
||||||
W3Ejsu/XZZtm2Yzy/VxzdsuqVuu3ZkejctIq4WIMJbqZ03iufjMnKomo6Yw88X29
|
|
||||||
k2oNpLmCLgfxy4akTOYIHpBct3CxlhIJ6SHErpHuP1c310aLkO3MXf79D1dvXn1T
|
|
||||||
bMqxqB/U7t8zcGf9A8cP+sEnQnttCdj2ayUlDqfPV06sDRPndIS2LFkzIswwHED8
|
|
||||||
Z9jRk6tWg+APsEgFAo58lIEYM2iR04c2ffWBvffIEWotYM4YH1pdgvVtILLzky8C
|
|
||||||
IogcF/LWe4mFKgBi8O3cS03YowoPgkPBh/4lXBiCXio5rkKJaMJrJMNDmoQTSzqU
|
|
||||||
80r8zuECgYEA8PqoY3p6lpUIxR1i4jrDzcmnFJ8vNoehr4SySR8G5EkPloltT0OK
|
|
||||||
o1d7g/b19RbulR7XnMq/H4Ic5GDiP2EEI5zM093JbV5luQZHwKrqTykXVdlgiDan
|
|
||||||
GAxsJ9Q31ASAixCA92una1+08Xe8N7aNBuJNPuvaPB2603dO30hIlQkCgYEA0Bwu
|
|
||||||
oqZMh8Td4pB3nUQM08NiLrYy1vwzbAHhOx3VxRGiF7x8X32NSnAzQmusqYuT6j02
|
|
||||||
o4Jg0Jyn+XV67AD4f0D8+4urQEnrfnf32GxSvefucFbekypGLR8w3WR18mkBhVst
|
|
||||||
WTkKqZwoJtmyJlbSRRpDZ6ewQqZ/a79NmMkxmZ8CgYEAwQQ0jgGTYTucW64u/v+M
|
|
||||||
yC8l2dmrCmVW92w1FWZ5sa5ngu8uk9eIm06+CzRrS1WD4gNjNh4bOdSQ6chET/mY
|
|
||||||
RCIa2fSCm0yJ88p4/HSp2qASJdxIerIz4opIsxpDYVn9z+V3NzaOUe3F08dRBdr9
|
|
||||||
WK84qhZlpdM2Spz8mtGd+WkCgYBCV3mWaCUlcuC5BQzcmYDtUO/PrE1ws11BJShD
|
|
||||||
zDMFa6Wco32Sg1ezTylIF0MnmVNB7NmqLjnmxsnVgFn7OiP9jR4YomGpUOc9ncjo
|
|
||||||
uT93QqSEM20oxOUyJStSqF/hMxBFDtfaBZEcmKdEG0nrZuoJFWI/fPl3hdRA6O83
|
|
||||||
sYuaSQKBgQCGTN1vEshVEu2Sbdpw+9p/JpHOWT4HuTU78EGfjd4wDtWgme3WgbB4
|
|
||||||
geixhSTsoGdb95Da5Wp81nEUN7P/VE9VTX74qcXD3AseCYmhmbFaZTOi0kjYEbAQ
|
|
||||||
wGuBa8CDIzttKhBsBQWZpG7YQq3pOqKLgKOuwwf6kJk1eh+HMS7ktQ==
|
|
||||||
-----END RSA PRIVATE KEY-----
|
|
@ -1,24 +0,0 @@
|
|||||||
-----BEGIN CERTIFICATE-----
|
|
||||||
MIID+zCCAuOgAw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SMEGDAWgBSWtsrqQGry
|
|
||||||
JVSJER5int40YIpuxjAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQDA
|
|
||||||
NySrqGBF+h/UCph/YEXTTea8MQIvihLecZ0VpZ/0VDZfwxzZns5oV0znoZEQcyYZ
|
|
||||||
olTr40jyCt0Ex59VRWRUUfdR1JgZtaMd29iYxUvGy+tK5pw75mIl3upc8hEe2uzN
|
|
||||||
c8hynlLSh9y75GM3RUkUlkSIrIRQIvOTW1+lhqBzhesvYjScCbH8MXL5e6qCkbhZ
|
|
||||||
tP5xuTjQlY38oJxDmMHmIxholxCxQtnEVTpKn0lp2diPMXU9qbsTuZ9eYTwZabSk
|
|
||||||
+CXrtjYtaZPkHGDSldWdMdbHw/+81ViMA3CA2f61aqTcIYyAZz8o9b+4IghLLicZ
|
|
||||||
C84hYbMbCAz0rp6bt+PJ
|
|
||||||
-----END CERTIFICATE-----
|
|
@ -1,21 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
const IPC = require('./services/IPC.js');
|
|
||||||
|
|
||||||
class IPCModule extends IPC{
|
|
||||||
constructor(){
|
|
||||||
super();
|
|
||||||
//include IPC to make extensible
|
|
||||||
Object.defineProperty(
|
|
||||||
this,
|
|
||||||
'IPC',
|
|
||||||
{
|
|
||||||
enumerable:true,
|
|
||||||
writable:false,
|
|
||||||
value:IPC
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports=new IPCModule;
|
|
@ -1,66 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "@achrinza/node-ipc",
|
|
||||||
"version": "9.2.7",
|
|
||||||
"description": "A nodejs module for local and remote Inter Process Communication (IPC), Neural Networking, and able to facilitate machine learning.",
|
|
||||||
"main": "node-ipc.js",
|
|
||||||
"directories": {
|
|
||||||
"example": "example"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": "8 || 9 || 10 || 11 || 12 || 13 || 14 || 15 || 16 || 17 || 18 || 19 || 20"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"@node-ipc/js-queue": "2.0.3",
|
|
||||||
"event-pubsub": "4.3.0",
|
|
||||||
"js-message": "1.0.7"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"istanbul": "0.4.1",
|
|
||||||
"jasmine": "2.4.1",
|
|
||||||
"lockfile-lint": "^4.7.4",
|
|
||||||
"node-cmd": "2.0.0"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"istanbul": "istanbul cover -x ./spec/**",
|
|
||||||
"test-windows": "npm run-script istanbul -- ./node_modules/jasmine/bin/jasmine.js",
|
|
||||||
"test": "npm run-script istanbul -- jasmine"
|
|
||||||
},
|
|
||||||
"keywords": [
|
|
||||||
"IPC",
|
|
||||||
"Neural Networking",
|
|
||||||
"Machine Learning",
|
|
||||||
"inter",
|
|
||||||
"process",
|
|
||||||
"communication",
|
|
||||||
"unix",
|
|
||||||
"windows",
|
|
||||||
"win",
|
|
||||||
"socket",
|
|
||||||
"TCP",
|
|
||||||
"UDP",
|
|
||||||
"domain",
|
|
||||||
"sockets",
|
|
||||||
"threaded",
|
|
||||||
"communication",
|
|
||||||
"multi",
|
|
||||||
"process",
|
|
||||||
"shared",
|
|
||||||
"memory"
|
|
||||||
],
|
|
||||||
"author": "Brandon Nozaki Miller",
|
|
||||||
"license": "MIT",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/achrinza/node-ipc.git"
|
|
||||||
},
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/achrinza/node-ipc/issues"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"dao",
|
|
||||||
"entities",
|
|
||||||
"local-node-ipc-certs",
|
|
||||||
"services"
|
|
||||||
],
|
|
||||||
"homepage": "https://github.com/achrinza/node-ipc"
|
|
||||||
}
|
|
@ -1,338 +0,0 @@
|
|||||||
'use strict';
|
|
||||||
|
|
||||||
const Defaults = require('../entities/Defaults.js'),
|
|
||||||
Client = require('../dao/client.js'),
|
|
||||||
Server = require('../dao/socketServer.js'),
|
|
||||||
util = require('util');
|
|
||||||
|
|
||||||
class IPC{
|
|
||||||
constructor(){
|
|
||||||
Object.defineProperties(
|
|
||||||
this,
|
|
||||||
{
|
|
||||||
config : {
|
|
||||||
enumerable:true,
|
|
||||||
writable:true,
|
|
||||||
value:new Defaults
|
|
||||||
},
|
|
||||||
connectTo : {
|
|
||||||
enumerable:true,
|
|
||||||
writable:false,
|
|
||||||
value:connect
|
|
||||||
},
|
|
||||||
connectToNet: {
|
|
||||||
enumerable:true,
|
|
||||||
writable:false,
|
|
||||||
value:connectNet
|
|
||||||
},
|
|
||||||
disconnect : {
|
|
||||||
enumerable:true,
|
|
||||||
writable:false,
|
|
||||||
value:disconnect
|
|
||||||
},
|
|
||||||
serve : {
|
|
||||||
enumerable:true,
|
|
||||||
writable:false,
|
|
||||||
value:serve
|
|
||||||
},
|
|
||||||
serveNet : {
|
|
||||||
enumerable:true,
|
|
||||||
writable:false,
|
|
||||||
value:serveNet
|
|
||||||
},
|
|
||||||
of : {
|
|
||||||
enumerable:true,
|
|
||||||
writable:true,
|
|
||||||
value:{}
|
|
||||||
},
|
|
||||||
server : {
|
|
||||||
enumerable:true,
|
|
||||||
writable:true,
|
|
||||||
configurable:true,
|
|
||||||
value:false
|
|
||||||
},
|
|
||||||
log : {
|
|
||||||
enumerable:true,
|
|
||||||
writable:false,
|
|
||||||
value:log
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function log(...args){
|
|
||||||
if(this.config.silent){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for(let i=0, count=args.length; i<count; i++){
|
|
||||||
if(typeof args[i] != 'object'){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
args[i]=util.inspect(
|
|
||||||
args[i],
|
|
||||||
{
|
|
||||||
depth:this.config.logDepth,
|
|
||||||
colors:this.config.logInColor
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.config.logger(
|
|
||||||
args.join(' ')
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function disconnect(id){
|
|
||||||
if(!this.of[id]){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.of[id].explicitlyDisconnected=true;
|
|
||||||
|
|
||||||
this.of[id].off('*','*');
|
|
||||||
if(this.of[id].socket){
|
|
||||||
if(this.of[id].socket.destroy){
|
|
||||||
this.of[id].socket.destroy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
delete this.of[id];
|
|
||||||
}
|
|
||||||
|
|
||||||
function serve(path,callback){
|
|
||||||
if(typeof path=='function'){
|
|
||||||
callback=path;
|
|
||||||
path=false;
|
|
||||||
}
|
|
||||||
if(!path){
|
|
||||||
this.log(
|
|
||||||
'Server path not specified, so defaulting to',
|
|
||||||
'ipc.config.socketRoot + ipc.config.appspace + ipc.config.id',
|
|
||||||
this.config.socketRoot+this.config.appspace+this.config.id
|
|
||||||
);
|
|
||||||
path=this.config.socketRoot+this.config.appspace+this.config.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!callback){
|
|
||||||
callback=emptyCallback;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.server=new Server(
|
|
||||||
path,
|
|
||||||
this.config,
|
|
||||||
log
|
|
||||||
);
|
|
||||||
|
|
||||||
this.server.on(
|
|
||||||
'start',
|
|
||||||
callback
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function emptyCallback(){
|
|
||||||
//Do Nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
function serveNet(host,port,UDPType,callback){
|
|
||||||
if(typeof host=='number'){
|
|
||||||
callback=UDPType;
|
|
||||||
UDPType=port;
|
|
||||||
port=host;
|
|
||||||
host=false;
|
|
||||||
}
|
|
||||||
if(typeof host=='function'){
|
|
||||||
callback=host;
|
|
||||||
UDPType=false;
|
|
||||||
host=false;
|
|
||||||
port=false;
|
|
||||||
}
|
|
||||||
if(!host){
|
|
||||||
this.log(
|
|
||||||
'Server host not specified, so defaulting to',
|
|
||||||
'ipc.config.networkHost',
|
|
||||||
this.config.networkHost
|
|
||||||
);
|
|
||||||
host=this.config.networkHost;
|
|
||||||
}
|
|
||||||
if(host.toLowerCase()=='udp4' || host.toLowerCase()=='udp6'){
|
|
||||||
callback=port;
|
|
||||||
UDPType=host.toLowerCase();
|
|
||||||
port=false;
|
|
||||||
host=this.config.networkHost;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(typeof port=='string'){
|
|
||||||
callback=UDPType;
|
|
||||||
UDPType=port;
|
|
||||||
port=false;
|
|
||||||
}
|
|
||||||
if(typeof port=='function'){
|
|
||||||
callback=port;
|
|
||||||
UDPType=false;
|
|
||||||
port=false;
|
|
||||||
}
|
|
||||||
if(!port){
|
|
||||||
this.log(
|
|
||||||
'Server port not specified, so defaulting to',
|
|
||||||
'ipc.config.networkPort',
|
|
||||||
this.config.networkPort
|
|
||||||
);
|
|
||||||
port=this.config.networkPort;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(typeof UDPType=='function'){
|
|
||||||
callback=UDPType;
|
|
||||||
UDPType=false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!callback){
|
|
||||||
callback=emptyCallback;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.server=new Server(
|
|
||||||
host,
|
|
||||||
this.config,
|
|
||||||
log,
|
|
||||||
port
|
|
||||||
);
|
|
||||||
|
|
||||||
if(UDPType){
|
|
||||||
this.server[UDPType]=true;
|
|
||||||
if(UDPType === "udp4" && host === "::1") {
|
|
||||||
// bind udp4 socket to an ipv4 address
|
|
||||||
this.server.path = "127.0.0.1";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.server.on(
|
|
||||||
'start',
|
|
||||||
callback
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function connect(id,path,callback){
|
|
||||||
if(typeof path == 'function'){
|
|
||||||
callback=path;
|
|
||||||
path=false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!callback){
|
|
||||||
callback=emptyCallback;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!id){
|
|
||||||
this.log(
|
|
||||||
'Service id required',
|
|
||||||
'Requested service connection without specifying service id. Aborting connection attempt'
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!path){
|
|
||||||
this.log(
|
|
||||||
'Service path not specified, so defaulting to',
|
|
||||||
'ipc.config.socketRoot + ipc.config.appspace + id',
|
|
||||||
(this.config.socketRoot+this.config.appspace+id).data
|
|
||||||
);
|
|
||||||
path=this.config.socketRoot+this.config.appspace+id;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(this.of[id]){
|
|
||||||
if(!this.of[id].socket.destroyed){
|
|
||||||
this.log(
|
|
||||||
'Already Connected to',
|
|
||||||
id,
|
|
||||||
'- So executing success without connection'
|
|
||||||
);
|
|
||||||
callback();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.of[id].socket.destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.of[id] = new Client(this.config,this.log);
|
|
||||||
this.of[id].id = id;
|
|
||||||
this.of[id].path = path;
|
|
||||||
|
|
||||||
this.of[id].connect();
|
|
||||||
|
|
||||||
callback(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
function connectNet(id,host,port,callback){
|
|
||||||
if(!id){
|
|
||||||
this.log(
|
|
||||||
'Service id required',
|
|
||||||
'Requested service connection without specifying service id. Aborting connection attempt'
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(typeof host=='number'){
|
|
||||||
callback=port;
|
|
||||||
port=host;
|
|
||||||
host=false;
|
|
||||||
}
|
|
||||||
if(typeof host=='function'){
|
|
||||||
callback=host;
|
|
||||||
host=false;
|
|
||||||
port=false;
|
|
||||||
}
|
|
||||||
if(!host){
|
|
||||||
this.log(
|
|
||||||
'Server host not specified, so defaulting to',
|
|
||||||
'ipc.config.networkHost',
|
|
||||||
this.config.networkHost
|
|
||||||
);
|
|
||||||
host=this.config.networkHost;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(typeof port=='function'){
|
|
||||||
callback=port;
|
|
||||||
port=false;
|
|
||||||
}
|
|
||||||
if(!port){
|
|
||||||
this.log(
|
|
||||||
'Server port not specified, so defaulting to',
|
|
||||||
'ipc.config.networkPort',
|
|
||||||
this.config.networkPort
|
|
||||||
);
|
|
||||||
port=this.config.networkPort;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(typeof callback == 'string'){
|
|
||||||
UDPType=callback;
|
|
||||||
callback=false;
|
|
||||||
}
|
|
||||||
if(!callback){
|
|
||||||
callback=emptyCallback;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(this.of[id]){
|
|
||||||
if(!this.of[id].socket.destroyed){
|
|
||||||
|
|
||||||
this.log(
|
|
||||||
'Already Connected to',
|
|
||||||
id,
|
|
||||||
'- So executing success without connection'
|
|
||||||
);
|
|
||||||
callback();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.of[id].socket.destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
this.of[id] = new Client(this.config,this.log);
|
|
||||||
this.of[id].id = id;
|
|
||||||
(this.of[id].socket)? this.of[id].socket.id=id:null;
|
|
||||||
this.of[id].path = host;
|
|
||||||
this.of[id].port = port;
|
|
||||||
|
|
||||||
this.of[id].connect();
|
|
||||||
|
|
||||||
callback(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports=IPC;
|
|
@ -1,218 +0,0 @@
|
|||||||
# @ampproject/remapping
|
|
||||||
|
|
||||||
> Remap sequential sourcemaps through transformations to point at the original source code
|
|
||||||
|
|
||||||
Remapping allows you to take the sourcemaps generated through transforming your code and "remap"
|
|
||||||
them to the original source locations. Think "my minified code, transformed with babel and bundled
|
|
||||||
with webpack", all pointing to the correct location in your original source code.
|
|
||||||
|
|
||||||
With remapping, none of your source code transformations need to be aware of the input's sourcemap,
|
|
||||||
they only need to generate an output sourcemap. This greatly simplifies building custom
|
|
||||||
transformations (think a find-and-replace).
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install @ampproject/remapping
|
|
||||||
```
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
```typescript
|
|
||||||
function remapping(
|
|
||||||
map: SourceMap | SourceMap[],
|
|
||||||
loader: (file: string, ctx: LoaderContext) => (SourceMap | null | undefined),
|
|
||||||
options?: { excludeContent: boolean, decodedMappings: boolean }
|
|
||||||
): SourceMap;
|
|
||||||
|
|
||||||
// LoaderContext gives the loader the importing sourcemap, tree depth, the ability to override the
|
|
||||||
// "source" location (where child sources are resolved relative to, or the location of original
|
|
||||||
// source), and the ability to override the "content" of an original source for inclusion in the
|
|
||||||
// output sourcemap.
|
|
||||||
type LoaderContext = {
|
|
||||||
readonly importer: string;
|
|
||||||
readonly depth: number;
|
|
||||||
source: string;
|
|
||||||
content: string | null | undefined;
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
`remapping` takes the final output sourcemap, and a `loader` function. For every source file pointer
|
|
||||||
in the sourcemap, the `loader` will be called with the resolved path. If the path itself represents
|
|
||||||
a transformed file (it has a sourcmap associated with it), then the `loader` should return that
|
|
||||||
sourcemap. If not, the path will be treated as an original, untransformed source code.
|
|
||||||
|
|
||||||
```js
|
|
||||||
// Babel transformed "helloworld.js" into "transformed.js"
|
|
||||||
const transformedMap = JSON.stringify({
|
|
||||||
file: 'transformed.js',
|
|
||||||
// 1st column of 2nd line of output file translates into the 1st source
|
|
||||||
// file, line 3, column 2
|
|
||||||
mappings: ';CAEE',
|
|
||||||
sources: ['helloworld.js'],
|
|
||||||
version: 3,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Uglify minified "transformed.js" into "transformed.min.js"
|
|
||||||
const minifiedTransformedMap = JSON.stringify({
|
|
||||||
file: 'transformed.min.js',
|
|
||||||
// 0th column of 1st line of output file translates into the 1st source
|
|
||||||
// file, line 2, column 1.
|
|
||||||
mappings: 'AACC',
|
|
||||||
names: [],
|
|
||||||
sources: ['transformed.js'],
|
|
||||||
version: 3,
|
|
||||||
});
|
|
||||||
|
|
||||||
const remapped = remapping(
|
|
||||||
minifiedTransformedMap,
|
|
||||||
(file, ctx) => {
|
|
||||||
|
|
||||||
// The "transformed.js" file is an transformed file.
|
|
||||||
if (file === 'transformed.js') {
|
|
||||||
// The root importer is empty.
|
|
||||||
console.assert(ctx.importer === '');
|
|
||||||
// The depth in the sourcemap tree we're currently loading.
|
|
||||||
// The root `minifiedTransformedMap` is depth 0, and its source children are depth 1, etc.
|
|
||||||
console.assert(ctx.depth === 1);
|
|
||||||
|
|
||||||
return transformedMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Loader will be called to load transformedMap's source file pointers as well.
|
|
||||||
console.assert(file === 'helloworld.js');
|
|
||||||
// `transformed.js`'s sourcemap points into `helloworld.js`.
|
|
||||||
console.assert(ctx.importer === 'transformed.js');
|
|
||||||
// This is a source child of `transformed`, which is a source child of `minifiedTransformedMap`.
|
|
||||||
console.assert(ctx.depth === 2);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
console.log(remapped);
|
|
||||||
// {
|
|
||||||
// file: 'transpiled.min.js',
|
|
||||||
// mappings: 'AAEE',
|
|
||||||
// sources: ['helloworld.js'],
|
|
||||||
// version: 3,
|
|
||||||
// };
|
|
||||||
```
|
|
||||||
|
|
||||||
In this example, `loader` will be called twice:
|
|
||||||
|
|
||||||
1. `"transformed.js"`, the first source file pointer in the `minifiedTransformedMap`. We return the
|
|
||||||
associated sourcemap for it (its a transformed file, after all) so that sourcemap locations can
|
|
||||||
be traced through it into the source files it represents.
|
|
||||||
2. `"helloworld.js"`, our original, unmodified source code. This file does not have a sourcemap, so
|
|
||||||
we return `null`.
|
|
||||||
|
|
||||||
The `remapped` sourcemap now points from `transformed.min.js` into locations in `helloworld.js`. If
|
|
||||||
you were to read the `mappings`, it says "0th column of the first line output line points to the 1st
|
|
||||||
column of the 2nd line of the file `helloworld.js`".
|
|
||||||
|
|
||||||
### Multiple transformations of a file
|
|
||||||
|
|
||||||
As a convenience, if you have multiple single-source transformations of a file, you may pass an
|
|
||||||
array of sourcemap files in the order of most-recent transformation sourcemap first. Note that this
|
|
||||||
changes the `importer` and `depth` of each call to our loader. So our above example could have been
|
|
||||||
written as:
|
|
||||||
|
|
||||||
```js
|
|
||||||
const remapped = remapping(
|
|
||||||
[minifiedTransformedMap, transformedMap],
|
|
||||||
() => null
|
|
||||||
);
|
|
||||||
|
|
||||||
console.log(remapped);
|
|
||||||
// {
|
|
||||||
// file: 'transpiled.min.js',
|
|
||||||
// mappings: 'AAEE',
|
|
||||||
// sources: ['helloworld.js'],
|
|
||||||
// version: 3,
|
|
||||||
// };
|
|
||||||
```
|
|
||||||
|
|
||||||
### Advanced control of the loading graph
|
|
||||||
|
|
||||||
#### `source`
|
|
||||||
|
|
||||||
The `source` property can overridden to any value to change the location of the current load. Eg,
|
|
||||||
for an original source file, it allows us to change the location to the original source regardless
|
|
||||||
of what the sourcemap source entry says. And for transformed files, it allows us to change the
|
|
||||||
relative resolving location for child sources of the loaded sourcemap.
|
|
||||||
|
|
||||||
```js
|
|
||||||
const remapped = remapping(
|
|
||||||
minifiedTransformedMap,
|
|
||||||
(file, ctx) => {
|
|
||||||
|
|
||||||
if (file === 'transformed.js') {
|
|
||||||
// We pretend the transformed.js file actually exists in the 'src/' directory. When the nested
|
|
||||||
// source files are loaded, they will now be relative to `src/`.
|
|
||||||
ctx.source = 'src/transformed.js';
|
|
||||||
return transformedMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
console.assert(file === 'src/helloworld.js');
|
|
||||||
// We could futher change the source of this original file, eg, to be inside a nested directory
|
|
||||||
// itself. This will be reflected in the remapped sourcemap.
|
|
||||||
ctx.source = 'src/nested/transformed.js';
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
console.log(remapped);
|
|
||||||
// {
|
|
||||||
// …,
|
|
||||||
// sources: ['src/nested/helloworld.js'],
|
|
||||||
// };
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
#### `content`
|
|
||||||
|
|
||||||
The `content` property can be overridden when we encounter an original source file. Eg, this allows
|
|
||||||
you to manually provide the source content of the original file regardless of whether the
|
|
||||||
`sourcesContent` field is present in the parent sourcemap. It can also be set to `null` to remove
|
|
||||||
the source content.
|
|
||||||
|
|
||||||
```js
|
|
||||||
const remapped = remapping(
|
|
||||||
minifiedTransformedMap,
|
|
||||||
(file, ctx) => {
|
|
||||||
|
|
||||||
if (file === 'transformed.js') {
|
|
||||||
// transformedMap does not include a `sourcesContent` field, so usually the remapped sourcemap
|
|
||||||
// would not include any `sourcesContent` values.
|
|
||||||
return transformedMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
console.assert(file === 'helloworld.js');
|
|
||||||
// We can read the file to provide the source content.
|
|
||||||
ctx.content = fs.readFileSync(file, 'utf8');
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
console.log(remapped);
|
|
||||||
// {
|
|
||||||
// …,
|
|
||||||
// sourcesContent: [
|
|
||||||
// 'console.log("Hello world!")',
|
|
||||||
// ],
|
|
||||||
// };
|
|
||||||
```
|
|
||||||
|
|
||||||
### Options
|
|
||||||
|
|
||||||
#### excludeContent
|
|
||||||
|
|
||||||
By default, `excludeContent` is `false`. Passing `{ excludeContent: true }` will exclude the
|
|
||||||
`sourcesContent` field from the returned sourcemap. This is mainly useful when you want to reduce
|
|
||||||
the size out the sourcemap.
|
|
||||||
|
|
||||||
#### decodedMappings
|
|
||||||
|
|
||||||
By default, `decodedMappings` is `false`. Passing `{ decodedMappings: true }` will leave the
|
|
||||||
`mappings` field in a [decoded state](https://github.com/rich-harris/sourcemap-codec) instead of
|
|
||||||
encoding into a VLQ string.
|
|
@ -1,191 +0,0 @@
|
|||||||
import { decodedMappings, traceSegment, TraceMap } from '@jridgewell/trace-mapping';
|
|
||||||
import { GenMapping, maybeAddSegment, setSourceContent, toDecodedMap, toEncodedMap } from '@jridgewell/gen-mapping';
|
|
||||||
|
|
||||||
const SOURCELESS_MAPPING = /* #__PURE__ */ SegmentObject('', -1, -1, '', null);
|
|
||||||
const EMPTY_SOURCES = [];
|
|
||||||
function SegmentObject(source, line, column, name, content) {
|
|
||||||
return { source, line, column, name, content };
|
|
||||||
}
|
|
||||||
function Source(map, sources, source, content) {
|
|
||||||
return {
|
|
||||||
map,
|
|
||||||
sources,
|
|
||||||
source,
|
|
||||||
content,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* MapSource represents a single sourcemap, with the ability to trace mappings into its child nodes
|
|
||||||
* (which may themselves be SourceMapTrees).
|
|
||||||
*/
|
|
||||||
function MapSource(map, sources) {
|
|
||||||
return Source(map, sources, '', null);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* A "leaf" node in the sourcemap tree, representing an original, unmodified source file. Recursive
|
|
||||||
* segment tracing ends at the `OriginalSource`.
|
|
||||||
*/
|
|
||||||
function OriginalSource(source, content) {
|
|
||||||
return Source(null, EMPTY_SOURCES, source, content);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* traceMappings is only called on the root level SourceMapTree, and begins the process of
|
|
||||||
* resolving each mapping in terms of the original source files.
|
|
||||||
*/
|
|
||||||
function traceMappings(tree) {
|
|
||||||
// TODO: Eventually support sourceRoot, which has to be removed because the sources are already
|
|
||||||
// fully resolved. We'll need to make sources relative to the sourceRoot before adding them.
|
|
||||||
const gen = new GenMapping({ file: tree.map.file });
|
|
||||||
const { sources: rootSources, map } = tree;
|
|
||||||
const rootNames = map.names;
|
|
||||||
const rootMappings = decodedMappings(map);
|
|
||||||
for (let i = 0; i < rootMappings.length; i++) {
|
|
||||||
const segments = rootMappings[i];
|
|
||||||
for (let j = 0; j < segments.length; j++) {
|
|
||||||
const segment = segments[j];
|
|
||||||
const genCol = segment[0];
|
|
||||||
let traced = SOURCELESS_MAPPING;
|
|
||||||
// 1-length segments only move the current generated column, there's no source information
|
|
||||||
// to gather from it.
|
|
||||||
if (segment.length !== 1) {
|
|
||||||
const source = rootSources[segment[1]];
|
|
||||||
traced = originalPositionFor(source, segment[2], segment[3], segment.length === 5 ? rootNames[segment[4]] : '');
|
|
||||||
// If the trace is invalid, then the trace ran into a sourcemap that doesn't contain a
|
|
||||||
// respective segment into an original source.
|
|
||||||
if (traced == null)
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const { column, line, name, content, source } = traced;
|
|
||||||
maybeAddSegment(gen, i, genCol, source, line, column, name);
|
|
||||||
if (source && content != null)
|
|
||||||
setSourceContent(gen, source, content);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return gen;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* originalPositionFor is only called on children SourceMapTrees. It recurses down into its own
|
|
||||||
* child SourceMapTrees, until we find the original source map.
|
|
||||||
*/
|
|
||||||
function originalPositionFor(source, line, column, name) {
|
|
||||||
if (!source.map) {
|
|
||||||
return SegmentObject(source.source, line, column, name, source.content);
|
|
||||||
}
|
|
||||||
const segment = traceSegment(source.map, line, column);
|
|
||||||
// If we couldn't find a segment, then this doesn't exist in the sourcemap.
|
|
||||||
if (segment == null)
|
|
||||||
return null;
|
|
||||||
// 1-length segments only move the current generated column, there's no source information
|
|
||||||
// to gather from it.
|
|
||||||
if (segment.length === 1)
|
|
||||||
return SOURCELESS_MAPPING;
|
|
||||||
return originalPositionFor(source.sources[segment[1]], segment[2], segment[3], segment.length === 5 ? source.map.names[segment[4]] : name);
|
|
||||||
}
|
|
||||||
|
|
||||||
function asArray(value) {
|
|
||||||
if (Array.isArray(value))
|
|
||||||
return value;
|
|
||||||
return [value];
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Recursively builds a tree structure out of sourcemap files, with each node
|
|
||||||
* being either an `OriginalSource` "leaf" or a `SourceMapTree` composed of
|
|
||||||
* `OriginalSource`s and `SourceMapTree`s.
|
|
||||||
*
|
|
||||||
* Every sourcemap is composed of a collection of source files and mappings
|
|
||||||
* into locations of those source files. When we generate a `SourceMapTree` for
|
|
||||||
* the sourcemap, we attempt to load each source file's own sourcemap. If it
|
|
||||||
* does not have an associated sourcemap, it is considered an original,
|
|
||||||
* unmodified source file.
|
|
||||||
*/
|
|
||||||
function buildSourceMapTree(input, loader) {
|
|
||||||
const maps = asArray(input).map((m) => new TraceMap(m, ''));
|
|
||||||
const map = maps.pop();
|
|
||||||
for (let i = 0; i < maps.length; i++) {
|
|
||||||
if (maps[i].sources.length > 1) {
|
|
||||||
throw new Error(`Transformation map ${i} must have exactly one source file.\n` +
|
|
||||||
'Did you specify these with the most recent transformation maps first?');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let tree = build(map, loader, '', 0);
|
|
||||||
for (let i = maps.length - 1; i >= 0; i--) {
|
|
||||||
tree = MapSource(maps[i], [tree]);
|
|
||||||
}
|
|
||||||
return tree;
|
|
||||||
}
|
|
||||||
function build(map, loader, importer, importerDepth) {
|
|
||||||
const { resolvedSources, sourcesContent } = map;
|
|
||||||
const depth = importerDepth + 1;
|
|
||||||
const children = resolvedSources.map((sourceFile, i) => {
|
|
||||||
// The loading context gives the loader more information about why this file is being loaded
|
|
||||||
// (eg, from which importer). It also allows the loader to override the location of the loaded
|
|
||||||
// sourcemap/original source, or to override the content in the sourcesContent field if it's
|
|
||||||
// an unmodified source file.
|
|
||||||
const ctx = {
|
|
||||||
importer,
|
|
||||||
depth,
|
|
||||||
source: sourceFile || '',
|
|
||||||
content: undefined,
|
|
||||||
};
|
|
||||||
// Use the provided loader callback to retrieve the file's sourcemap.
|
|
||||||
// TODO: We should eventually support async loading of sourcemap files.
|
|
||||||
const sourceMap = loader(ctx.source, ctx);
|
|
||||||
const { source, content } = ctx;
|
|
||||||
// If there is a sourcemap, then we need to recurse into it to load its source files.
|
|
||||||
if (sourceMap)
|
|
||||||
return build(new TraceMap(sourceMap, source), loader, source, depth);
|
|
||||||
// Else, it's an an unmodified source file.
|
|
||||||
// The contents of this unmodified source file can be overridden via the loader context,
|
|
||||||
// allowing it to be explicitly null or a string. If it remains undefined, we fall back to
|
|
||||||
// the importing sourcemap's `sourcesContent` field.
|
|
||||||
const sourceContent = content !== undefined ? content : sourcesContent ? sourcesContent[i] : null;
|
|
||||||
return OriginalSource(source, sourceContent);
|
|
||||||
});
|
|
||||||
return MapSource(map, children);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A SourceMap v3 compatible sourcemap, which only includes fields that were
|
|
||||||
* provided to it.
|
|
||||||
*/
|
|
||||||
class SourceMap {
|
|
||||||
constructor(map, options) {
|
|
||||||
const out = options.decodedMappings ? toDecodedMap(map) : toEncodedMap(map);
|
|
||||||
this.version = out.version; // SourceMap spec says this should be first.
|
|
||||||
this.file = out.file;
|
|
||||||
this.mappings = out.mappings;
|
|
||||||
this.names = out.names;
|
|
||||||
this.sourceRoot = out.sourceRoot;
|
|
||||||
this.sources = out.sources;
|
|
||||||
if (!options.excludeContent) {
|
|
||||||
this.sourcesContent = out.sourcesContent;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
toString() {
|
|
||||||
return JSON.stringify(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Traces through all the mappings in the root sourcemap, through the sources
|
|
||||||
* (and their sourcemaps), all the way back to the original source location.
|
|
||||||
*
|
|
||||||
* `loader` will be called every time we encounter a source file. If it returns
|
|
||||||
* a sourcemap, we will recurse into that sourcemap to continue the trace. If
|
|
||||||
* it returns a falsey value, that source file is treated as an original,
|
|
||||||
* unmodified source file.
|
|
||||||
*
|
|
||||||
* Pass `excludeContent` to exclude any self-containing source file content
|
|
||||||
* from the output sourcemap.
|
|
||||||
*
|
|
||||||
* Pass `decodedMappings` to receive a SourceMap with decoded (instead of
|
|
||||||
* VLQ encoded) mappings.
|
|
||||||
*/
|
|
||||||
function remapping(input, loader, options) {
|
|
||||||
const opts = typeof options === 'object' ? options : { excludeContent: !!options, decodedMappings: false };
|
|
||||||
const tree = buildSourceMapTree(input, loader);
|
|
||||||
return new SourceMap(traceMappings(tree), opts);
|
|
||||||
}
|
|
||||||
|
|
||||||
export { remapping as default };
|
|
||||||
//# sourceMappingURL=remapping.mjs.map
|
|
File diff suppressed because one or more lines are too long
@ -1,196 +0,0 @@
|
|||||||
(function (global, factory) {
|
|
||||||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@jridgewell/trace-mapping'), require('@jridgewell/gen-mapping')) :
|
|
||||||
typeof define === 'function' && define.amd ? define(['@jridgewell/trace-mapping', '@jridgewell/gen-mapping'], factory) :
|
|
||||||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.remapping = factory(global.traceMapping, global.genMapping));
|
|
||||||
})(this, (function (traceMapping, genMapping) { 'use strict';
|
|
||||||
|
|
||||||
const SOURCELESS_MAPPING = /* #__PURE__ */ SegmentObject('', -1, -1, '', null);
|
|
||||||
const EMPTY_SOURCES = [];
|
|
||||||
function SegmentObject(source, line, column, name, content) {
|
|
||||||
return { source, line, column, name, content };
|
|
||||||
}
|
|
||||||
function Source(map, sources, source, content) {
|
|
||||||
return {
|
|
||||||
map,
|
|
||||||
sources,
|
|
||||||
source,
|
|
||||||
content,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* MapSource represents a single sourcemap, with the ability to trace mappings into its child nodes
|
|
||||||
* (which may themselves be SourceMapTrees).
|
|
||||||
*/
|
|
||||||
function MapSource(map, sources) {
|
|
||||||
return Source(map, sources, '', null);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* A "leaf" node in the sourcemap tree, representing an original, unmodified source file. Recursive
|
|
||||||
* segment tracing ends at the `OriginalSource`.
|
|
||||||
*/
|
|
||||||
function OriginalSource(source, content) {
|
|
||||||
return Source(null, EMPTY_SOURCES, source, content);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* traceMappings is only called on the root level SourceMapTree, and begins the process of
|
|
||||||
* resolving each mapping in terms of the original source files.
|
|
||||||
*/
|
|
||||||
function traceMappings(tree) {
|
|
||||||
// TODO: Eventually support sourceRoot, which has to be removed because the sources are already
|
|
||||||
// fully resolved. We'll need to make sources relative to the sourceRoot before adding them.
|
|
||||||
const gen = new genMapping.GenMapping({ file: tree.map.file });
|
|
||||||
const { sources: rootSources, map } = tree;
|
|
||||||
const rootNames = map.names;
|
|
||||||
const rootMappings = traceMapping.decodedMappings(map);
|
|
||||||
for (let i = 0; i < rootMappings.length; i++) {
|
|
||||||
const segments = rootMappings[i];
|
|
||||||
for (let j = 0; j < segments.length; j++) {
|
|
||||||
const segment = segments[j];
|
|
||||||
const genCol = segment[0];
|
|
||||||
let traced = SOURCELESS_MAPPING;
|
|
||||||
// 1-length segments only move the current generated column, there's no source information
|
|
||||||
// to gather from it.
|
|
||||||
if (segment.length !== 1) {
|
|
||||||
const source = rootSources[segment[1]];
|
|
||||||
traced = originalPositionFor(source, segment[2], segment[3], segment.length === 5 ? rootNames[segment[4]] : '');
|
|
||||||
// If the trace is invalid, then the trace ran into a sourcemap that doesn't contain a
|
|
||||||
// respective segment into an original source.
|
|
||||||
if (traced == null)
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const { column, line, name, content, source } = traced;
|
|
||||||
genMapping.maybeAddSegment(gen, i, genCol, source, line, column, name);
|
|
||||||
if (source && content != null)
|
|
||||||
genMapping.setSourceContent(gen, source, content);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return gen;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* originalPositionFor is only called on children SourceMapTrees. It recurses down into its own
|
|
||||||
* child SourceMapTrees, until we find the original source map.
|
|
||||||
*/
|
|
||||||
function originalPositionFor(source, line, column, name) {
|
|
||||||
if (!source.map) {
|
|
||||||
return SegmentObject(source.source, line, column, name, source.content);
|
|
||||||
}
|
|
||||||
const segment = traceMapping.traceSegment(source.map, line, column);
|
|
||||||
// If we couldn't find a segment, then this doesn't exist in the sourcemap.
|
|
||||||
if (segment == null)
|
|
||||||
return null;
|
|
||||||
// 1-length segments only move the current generated column, there's no source information
|
|
||||||
// to gather from it.
|
|
||||||
if (segment.length === 1)
|
|
||||||
return SOURCELESS_MAPPING;
|
|
||||||
return originalPositionFor(source.sources[segment[1]], segment[2], segment[3], segment.length === 5 ? source.map.names[segment[4]] : name);
|
|
||||||
}
|
|
||||||
|
|
||||||
function asArray(value) {
|
|
||||||
if (Array.isArray(value))
|
|
||||||
return value;
|
|
||||||
return [value];
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Recursively builds a tree structure out of sourcemap files, with each node
|
|
||||||
* being either an `OriginalSource` "leaf" or a `SourceMapTree` composed of
|
|
||||||
* `OriginalSource`s and `SourceMapTree`s.
|
|
||||||
*
|
|
||||||
* Every sourcemap is composed of a collection of source files and mappings
|
|
||||||
* into locations of those source files. When we generate a `SourceMapTree` for
|
|
||||||
* the sourcemap, we attempt to load each source file's own sourcemap. If it
|
|
||||||
* does not have an associated sourcemap, it is considered an original,
|
|
||||||
* unmodified source file.
|
|
||||||
*/
|
|
||||||
function buildSourceMapTree(input, loader) {
|
|
||||||
const maps = asArray(input).map((m) => new traceMapping.TraceMap(m, ''));
|
|
||||||
const map = maps.pop();
|
|
||||||
for (let i = 0; i < maps.length; i++) {
|
|
||||||
if (maps[i].sources.length > 1) {
|
|
||||||
throw new Error(`Transformation map ${i} must have exactly one source file.\n` +
|
|
||||||
'Did you specify these with the most recent transformation maps first?');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let tree = build(map, loader, '', 0);
|
|
||||||
for (let i = maps.length - 1; i >= 0; i--) {
|
|
||||||
tree = MapSource(maps[i], [tree]);
|
|
||||||
}
|
|
||||||
return tree;
|
|
||||||
}
|
|
||||||
function build(map, loader, importer, importerDepth) {
|
|
||||||
const { resolvedSources, sourcesContent } = map;
|
|
||||||
const depth = importerDepth + 1;
|
|
||||||
const children = resolvedSources.map((sourceFile, i) => {
|
|
||||||
// The loading context gives the loader more information about why this file is being loaded
|
|
||||||
// (eg, from which importer). It also allows the loader to override the location of the loaded
|
|
||||||
// sourcemap/original source, or to override the content in the sourcesContent field if it's
|
|
||||||
// an unmodified source file.
|
|
||||||
const ctx = {
|
|
||||||
importer,
|
|
||||||
depth,
|
|
||||||
source: sourceFile || '',
|
|
||||||
content: undefined,
|
|
||||||
};
|
|
||||||
// Use the provided loader callback to retrieve the file's sourcemap.
|
|
||||||
// TODO: We should eventually support async loading of sourcemap files.
|
|
||||||
const sourceMap = loader(ctx.source, ctx);
|
|
||||||
const { source, content } = ctx;
|
|
||||||
// If there is a sourcemap, then we need to recurse into it to load its source files.
|
|
||||||
if (sourceMap)
|
|
||||||
return build(new traceMapping.TraceMap(sourceMap, source), loader, source, depth);
|
|
||||||
// Else, it's an an unmodified source file.
|
|
||||||
// The contents of this unmodified source file can be overridden via the loader context,
|
|
||||||
// allowing it to be explicitly null or a string. If it remains undefined, we fall back to
|
|
||||||
// the importing sourcemap's `sourcesContent` field.
|
|
||||||
const sourceContent = content !== undefined ? content : sourcesContent ? sourcesContent[i] : null;
|
|
||||||
return OriginalSource(source, sourceContent);
|
|
||||||
});
|
|
||||||
return MapSource(map, children);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A SourceMap v3 compatible sourcemap, which only includes fields that were
|
|
||||||
* provided to it.
|
|
||||||
*/
|
|
||||||
class SourceMap {
|
|
||||||
constructor(map, options) {
|
|
||||||
const out = options.decodedMappings ? genMapping.toDecodedMap(map) : genMapping.toEncodedMap(map);
|
|
||||||
this.version = out.version; // SourceMap spec says this should be first.
|
|
||||||
this.file = out.file;
|
|
||||||
this.mappings = out.mappings;
|
|
||||||
this.names = out.names;
|
|
||||||
this.sourceRoot = out.sourceRoot;
|
|
||||||
this.sources = out.sources;
|
|
||||||
if (!options.excludeContent) {
|
|
||||||
this.sourcesContent = out.sourcesContent;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
toString() {
|
|
||||||
return JSON.stringify(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Traces through all the mappings in the root sourcemap, through the sources
|
|
||||||
* (and their sourcemaps), all the way back to the original source location.
|
|
||||||
*
|
|
||||||
* `loader` will be called every time we encounter a source file. If it returns
|
|
||||||
* a sourcemap, we will recurse into that sourcemap to continue the trace. If
|
|
||||||
* it returns a falsey value, that source file is treated as an original,
|
|
||||||
* unmodified source file.
|
|
||||||
*
|
|
||||||
* Pass `excludeContent` to exclude any self-containing source file content
|
|
||||||
* from the output sourcemap.
|
|
||||||
*
|
|
||||||
* Pass `decodedMappings` to receive a SourceMap with decoded (instead of
|
|
||||||
* VLQ encoded) mappings.
|
|
||||||
*/
|
|
||||||
function remapping(input, loader, options) {
|
|
||||||
const opts = typeof options === 'object' ? options : { excludeContent: !!options, decodedMappings: false };
|
|
||||||
const tree = buildSourceMapTree(input, loader);
|
|
||||||
return new SourceMap(traceMappings(tree), opts);
|
|
||||||
}
|
|
||||||
|
|
||||||
return remapping;
|
|
||||||
|
|
||||||
}));
|
|
||||||
//# sourceMappingURL=remapping.umd.js.map
|
|
File diff suppressed because one or more lines are too long
14
src/front/node_modules/@ampproject/remapping/dist/types/build-source-map-tree.d.ts
generated
vendored
14
src/front/node_modules/@ampproject/remapping/dist/types/build-source-map-tree.d.ts
generated
vendored
@ -1,14 +0,0 @@
|
|||||||
import type { MapSource as MapSourceType } from './source-map-tree';
|
|
||||||
import type { SourceMapInput, SourceMapLoader } from './types';
|
|
||||||
/**
|
|
||||||
* Recursively builds a tree structure out of sourcemap files, with each node
|
|
||||||
* being either an `OriginalSource` "leaf" or a `SourceMapTree` composed of
|
|
||||||
* `OriginalSource`s and `SourceMapTree`s.
|
|
||||||
*
|
|
||||||
* Every sourcemap is composed of a collection of source files and mappings
|
|
||||||
* into locations of those source files. When we generate a `SourceMapTree` for
|
|
||||||
* the sourcemap, we attempt to load each source file's own sourcemap. If it
|
|
||||||
* does not have an associated sourcemap, it is considered an original,
|
|
||||||
* unmodified source file.
|
|
||||||
*/
|
|
||||||
export default function buildSourceMapTree(input: SourceMapInput | SourceMapInput[], loader: SourceMapLoader): MapSourceType;
|
|
@ -1,19 +0,0 @@
|
|||||||
import SourceMap from './source-map';
|
|
||||||
import type { SourceMapInput, SourceMapLoader, Options } from './types';
|
|
||||||
export type { SourceMapSegment, EncodedSourceMap, EncodedSourceMap as RawSourceMap, DecodedSourceMap, SourceMapInput, SourceMapLoader, LoaderContext, Options, } from './types';
|
|
||||||
/**
|
|
||||||
* Traces through all the mappings in the root sourcemap, through the sources
|
|
||||||
* (and their sourcemaps), all the way back to the original source location.
|
|
||||||
*
|
|
||||||
* `loader` will be called every time we encounter a source file. If it returns
|
|
||||||
* a sourcemap, we will recurse into that sourcemap to continue the trace. If
|
|
||||||
* it returns a falsey value, that source file is treated as an original,
|
|
||||||
* unmodified source file.
|
|
||||||
*
|
|
||||||
* Pass `excludeContent` to exclude any self-containing source file content
|
|
||||||
* from the output sourcemap.
|
|
||||||
*
|
|
||||||
* Pass `decodedMappings` to receive a SourceMap with decoded (instead of
|
|
||||||
* VLQ encoded) mappings.
|
|
||||||
*/
|
|
||||||
export default function remapping(input: SourceMapInput | SourceMapInput[], loader: SourceMapLoader, options?: boolean | Options): SourceMap;
|
|
@ -1,42 +0,0 @@
|
|||||||
import { GenMapping } from '@jridgewell/gen-mapping';
|
|
||||||
import type { TraceMap } from '@jridgewell/trace-mapping';
|
|
||||||
export declare type SourceMapSegmentObject = {
|
|
||||||
column: number;
|
|
||||||
line: number;
|
|
||||||
name: string;
|
|
||||||
source: string;
|
|
||||||
content: string | null;
|
|
||||||
};
|
|
||||||
export declare type OriginalSource = {
|
|
||||||
map: null;
|
|
||||||
sources: Sources[];
|
|
||||||
source: string;
|
|
||||||
content: string | null;
|
|
||||||
};
|
|
||||||
export declare type MapSource = {
|
|
||||||
map: TraceMap;
|
|
||||||
sources: Sources[];
|
|
||||||
source: string;
|
|
||||||
content: null;
|
|
||||||
};
|
|
||||||
export declare type Sources = OriginalSource | MapSource;
|
|
||||||
/**
|
|
||||||
* MapSource represents a single sourcemap, with the ability to trace mappings into its child nodes
|
|
||||||
* (which may themselves be SourceMapTrees).
|
|
||||||
*/
|
|
||||||
export declare function MapSource(map: TraceMap, sources: Sources[]): MapSource;
|
|
||||||
/**
|
|
||||||
* A "leaf" node in the sourcemap tree, representing an original, unmodified source file. Recursive
|
|
||||||
* segment tracing ends at the `OriginalSource`.
|
|
||||||
*/
|
|
||||||
export declare function OriginalSource(source: string, content: string | null): OriginalSource;
|
|
||||||
/**
|
|
||||||
* traceMappings is only called on the root level SourceMapTree, and begins the process of
|
|
||||||
* resolving each mapping in terms of the original source files.
|
|
||||||
*/
|
|
||||||
export declare function traceMappings(tree: MapSource): GenMapping;
|
|
||||||
/**
|
|
||||||
* originalPositionFor is only called on children SourceMapTrees. It recurses down into its own
|
|
||||||
* child SourceMapTrees, until we find the original source map.
|
|
||||||
*/
|
|
||||||
export declare function originalPositionFor(source: Sources, line: number, column: number, name: string): SourceMapSegmentObject | null;
|
|
@ -1,17 +0,0 @@
|
|||||||
import type { GenMapping } from '@jridgewell/gen-mapping';
|
|
||||||
import type { DecodedSourceMap, EncodedSourceMap, Options } from './types';
|
|
||||||
/**
|
|
||||||
* A SourceMap v3 compatible sourcemap, which only includes fields that were
|
|
||||||
* provided to it.
|
|
||||||
*/
|
|
||||||
export default class SourceMap {
|
|
||||||
file?: string | null;
|
|
||||||
mappings: EncodedSourceMap['mappings'] | DecodedSourceMap['mappings'];
|
|
||||||
sourceRoot?: string;
|
|
||||||
names: string[];
|
|
||||||
sources: (string | null)[];
|
|
||||||
sourcesContent?: (string | null)[];
|
|
||||||
version: 3;
|
|
||||||
constructor(map: GenMapping, options: Options);
|
|
||||||
toString(): string;
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
import type { SourceMapInput } from '@jridgewell/trace-mapping';
|
|
||||||
export type { SourceMapSegment, DecodedSourceMap, EncodedSourceMap, } from '@jridgewell/trace-mapping';
|
|
||||||
export type { SourceMapInput };
|
|
||||||
export declare type LoaderContext = {
|
|
||||||
readonly importer: string;
|
|
||||||
readonly depth: number;
|
|
||||||
source: string;
|
|
||||||
content: string | null | undefined;
|
|
||||||
};
|
|
||||||
export declare type SourceMapLoader = (file: string, ctx: LoaderContext) => SourceMapInput | null | undefined | void;
|
|
||||||
export declare type Options = {
|
|
||||||
excludeContent?: boolean;
|
|
||||||
decodedMappings?: boolean;
|
|
||||||
};
|
|
@ -1,75 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "@ampproject/remapping",
|
|
||||||
"version": "2.2.1",
|
|
||||||
"description": "Remap sequential sourcemaps through transformations to point at the original source code",
|
|
||||||
"keywords": [
|
|
||||||
"source",
|
|
||||||
"map",
|
|
||||||
"remap"
|
|
||||||
],
|
|
||||||
"main": "dist/remapping.umd.js",
|
|
||||||
"module": "dist/remapping.mjs",
|
|
||||||
"types": "dist/types/remapping.d.ts",
|
|
||||||
"exports": {
|
|
||||||
".": [
|
|
||||||
{
|
|
||||||
"types": "./dist/types/remapping.d.ts",
|
|
||||||
"browser": "./dist/remapping.umd.js",
|
|
||||||
"require": "./dist/remapping.umd.js",
|
|
||||||
"import": "./dist/remapping.mjs"
|
|
||||||
},
|
|
||||||
"./dist/remapping.umd.js"
|
|
||||||
],
|
|
||||||
"./package.json": "./package.json"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"dist"
|
|
||||||
],
|
|
||||||
"author": "Justin Ridgewell <jridgewell@google.com>",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/ampproject/remapping.git"
|
|
||||||
},
|
|
||||||
"license": "Apache-2.0",
|
|
||||||
"engines": {
|
|
||||||
"node": ">=6.0.0"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"build": "run-s -n build:*",
|
|
||||||
"build:rollup": "rollup -c rollup.config.js",
|
|
||||||
"build:ts": "tsc --project tsconfig.build.json",
|
|
||||||
"lint": "run-s -n lint:*",
|
|
||||||
"lint:prettier": "npm run test:lint:prettier -- --write",
|
|
||||||
"lint:ts": "npm run test:lint:ts -- --fix",
|
|
||||||
"prebuild": "rm -rf dist",
|
|
||||||
"prepublishOnly": "npm run preversion",
|
|
||||||
"preversion": "run-s test build",
|
|
||||||
"test": "run-s -n test:lint test:only",
|
|
||||||
"test:debug": "node --inspect-brk node_modules/.bin/jest --runInBand",
|
|
||||||
"test:lint": "run-s -n test:lint:*",
|
|
||||||
"test:lint:prettier": "prettier --check '{src,test}/**/*.ts'",
|
|
||||||
"test:lint:ts": "eslint '{src,test}/**/*.ts'",
|
|
||||||
"test:only": "jest --coverage",
|
|
||||||
"test:watch": "jest --coverage --watch"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@rollup/plugin-typescript": "8.3.2",
|
|
||||||
"@types/jest": "27.4.1",
|
|
||||||
"@typescript-eslint/eslint-plugin": "5.20.0",
|
|
||||||
"@typescript-eslint/parser": "5.20.0",
|
|
||||||
"eslint": "8.14.0",
|
|
||||||
"eslint-config-prettier": "8.5.0",
|
|
||||||
"jest": "27.5.1",
|
|
||||||
"jest-config": "27.5.1",
|
|
||||||
"npm-run-all": "4.1.5",
|
|
||||||
"prettier": "2.6.2",
|
|
||||||
"rollup": "2.70.2",
|
|
||||||
"ts-jest": "27.1.4",
|
|
||||||
"tslib": "2.4.0",
|
|
||||||
"typescript": "4.6.3"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"@jridgewell/gen-mapping": "^0.3.0",
|
|
||||||
"@jridgewell/trace-mapping": "^0.3.9"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2018 AntV team
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
@ -1,39 +0,0 @@
|
|||||||
# @antv/adjust
|
|
||||||
|
|
||||||
> Data `adjust` for @antv/G2.
|
|
||||||
|
|
||||||
[![](https://img.shields.io/travis/antvis/adjust.svg)](https://travis-ci.org/antvis/adjust)
|
|
||||||
![](https://img.shields.io/badge/language-javascript-red.svg)
|
|
||||||
![](https://img.shields.io/badge/license-MIT-000000.svg)
|
|
||||||
[![npm package](https://img.shields.io/npm/v/@antv/adjust.svg)](https://www.npmjs.com/package/@antv/adjust)
|
|
||||||
[![NPM downloads](http://img.shields.io/npm/dm/@antv/adjust.svg)](https://npmjs.org/package/@antv/adjust)
|
|
||||||
[![Percentage of issues still open](http://isitmaintained.com/badge/open/antvis/adjust.svg)](http://isitmaintained.com/project/antvis/adjust "Percentage of issues still open")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Installing
|
|
||||||
|
|
||||||
```bash
|
|
||||||
npm install @antv/adjust
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
|
|
||||||
```js
|
|
||||||
import { getAdjust } from '@antv/adjust';
|
|
||||||
|
|
||||||
// contains Dodge, Jitter, Stack, Symmetric
|
|
||||||
const Dodge = getAdjust('dodge');
|
|
||||||
|
|
||||||
const d = new Dodge();
|
|
||||||
|
|
||||||
// adjust the data
|
|
||||||
const r = d.process();
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
MIT
|
|
@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"adjust.js","sourceRoot":"","sources":["../../src/adjusts/adjust.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,YAAY,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AASxC;IA6CE,gBAAY,GAAoD;QACtD,IAAA,MAAM,GAAqD,GAAG,OAAxD,EAAE,MAAM,GAA6C,GAAG,OAAhD,EAAE,KAA2C,GAAG,YAAtB,EAAxB,WAAW,mBAAG,CAAC,GAAG,EAAE,GAAG,CAAC,KAAA,EAAE,YAAY,GAAK,GAAG,aAAR,CAAS;QAEvE,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;IAKD;;;OAGG;IACI,yBAAQ,GAAf,UAAgB,GAAW;QACzB,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC5C,CAAC;IAES,+BAAc,GAAxB,UAAyB,GAAW,EAAE,QAAgB,EAAE,MAAgB;QAC9D,IAAA,MAAM,GAAK,IAAI,OAAT,CAAU;QAExB,IAAM,KAAK,GAAG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C,CAAC;QAEvE,QAAQ;QACR,IAAM,IAAI,GAAG,EAAE,CAAC;QAChB,IAAI,MAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;YAChC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SACnB;QACD,IAAI,MAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;YAChC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SACnB;QAED,IAAI,CAAC,OAAO,CAAC,UAAC,GAAW;YACvB,IAAI,YAAY,IAAI,YAAY,CAAC,GAAG,CAAC,EAAE;gBACrC,OAAO;aACR;YACD,cAAc;YACd,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,WAAW,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,UAAC,EAAE,EAAE,EAAE,IAAK,OAAA,EAAE,GAAG,EAAE,EAAP,CAAO,CAAa,CAAC;QAC3F,CAAC,CAAC,CAAC;QAEH,wBAAwB;QACxB,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;YACjC,IAAM,GAAG,GAAG,GAAG,CAAC;YAChB,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,sBAAsB;SAC3D;QAED,OAAO,YAAY,CAAC;IACtB,CAAC;IACH,aAAC;AAAD,CAAC,AAjLD,IAiLC"}
|
|
@ -1,15 +0,0 @@
|
|||||||
import { Data, DodgeCfg } from '../interface';
|
|
||||||
import Adjust from './adjust';
|
|
||||||
export default class Dodge extends Adjust {
|
|
||||||
private cacheMap;
|
|
||||||
private adjustDataArray;
|
|
||||||
private mergeData;
|
|
||||||
constructor(cfg: DodgeCfg);
|
|
||||||
process(groupDataArray: Data[][]): Data[][];
|
|
||||||
protected adjustDim(dim: string, values: number[], data: Data[], frameIndex: number): any[];
|
|
||||||
private getDodgeOffset;
|
|
||||||
private getIntervalOnlyOffset;
|
|
||||||
private getDodgeOnlyOffset;
|
|
||||||
private getIntervalAndDodgeOffset;
|
|
||||||
private getDistribution;
|
|
||||||
}
|
|
@ -1,192 +0,0 @@
|
|||||||
import { __extends } from "tslib";
|
|
||||||
import * as _ from '@antv/util';
|
|
||||||
import { DODGE_RATIO, MARGIN_RATIO } from '../constant';
|
|
||||||
import Adjust from './adjust';
|
|
||||||
var Dodge = /** @class */ (function (_super) {
|
|
||||||
__extends(Dodge, _super);
|
|
||||||
function Dodge(cfg) {
|
|
||||||
var _this = _super.call(this, cfg) || this;
|
|
||||||
_this.cacheMap = {};
|
|
||||||
_this.adjustDataArray = [];
|
|
||||||
_this.mergeData = [];
|
|
||||||
var _a = cfg.marginRatio, marginRatio = _a === void 0 ? MARGIN_RATIO : _a, _b = cfg.dodgeRatio, dodgeRatio = _b === void 0 ? DODGE_RATIO : _b, dodgeBy = cfg.dodgeBy, intervalPadding = cfg.intervalPadding, dodgePadding = cfg.dodgePadding, xDimensionLength = cfg.xDimensionLength, groupNum = cfg.groupNum, defaultSize = cfg.defaultSize, maxColumnWidth = cfg.maxColumnWidth, minColumnWidth = cfg.minColumnWidth, columnWidthRatio = cfg.columnWidthRatio, customOffset = cfg.customOffset;
|
|
||||||
_this.marginRatio = marginRatio;
|
|
||||||
_this.dodgeRatio = dodgeRatio;
|
|
||||||
_this.dodgeBy = dodgeBy;
|
|
||||||
_this.intervalPadding = intervalPadding;
|
|
||||||
_this.dodgePadding = dodgePadding;
|
|
||||||
_this.xDimensionLegenth = xDimensionLength;
|
|
||||||
_this.groupNum = groupNum;
|
|
||||||
_this.defaultSize = defaultSize;
|
|
||||||
_this.maxColumnWidth = maxColumnWidth;
|
|
||||||
_this.minColumnWidth = minColumnWidth;
|
|
||||||
_this.columnWidthRatio = columnWidthRatio;
|
|
||||||
_this.customOffset = customOffset;
|
|
||||||
return _this;
|
|
||||||
}
|
|
||||||
Dodge.prototype.process = function (groupDataArray) {
|
|
||||||
var groupedDataArray = _.clone(groupDataArray);
|
|
||||||
// 将数据数组展开一层
|
|
||||||
var mergeData = _.flatten(groupedDataArray);
|
|
||||||
var dodgeBy = this.dodgeBy;
|
|
||||||
// 如果指定了分组 dim 的字段
|
|
||||||
var adjustDataArray = dodgeBy ? _.group(mergeData, dodgeBy) : groupedDataArray;
|
|
||||||
this.cacheMap = {};
|
|
||||||
this.adjustDataArray = adjustDataArray;
|
|
||||||
this.mergeData = mergeData;
|
|
||||||
this.adjustData(adjustDataArray, mergeData);
|
|
||||||
this.adjustDataArray = [];
|
|
||||||
this.mergeData = [];
|
|
||||||
return groupedDataArray;
|
|
||||||
};
|
|
||||||
Dodge.prototype.adjustDim = function (dim, values, data, frameIndex) {
|
|
||||||
var _this = this;
|
|
||||||
var customOffset = this.customOffset;
|
|
||||||
var map = this.getDistribution(dim);
|
|
||||||
var groupData = this.groupData(data, dim); // 根据值分组
|
|
||||||
_.each(groupData, function (group, key) {
|
|
||||||
var range;
|
|
||||||
// xField 中只有一个值,不需要做 dodge
|
|
||||||
if (values.length === 1) {
|
|
||||||
range = {
|
|
||||||
pre: values[0] - 1,
|
|
||||||
next: values[0] + 1,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// 如果有多个,则需要获取调整的范围
|
|
||||||
range = _this.getAdjustRange(dim, parseFloat(key), values);
|
|
||||||
}
|
|
||||||
_.each(group, function (d) {
|
|
||||||
var value = d[dim];
|
|
||||||
var valueArr = map[value];
|
|
||||||
var valIndex = valueArr.indexOf(frameIndex);
|
|
||||||
if (!_.isNil(customOffset)) {
|
|
||||||
var pre = range.pre, next = range.next;
|
|
||||||
d[dim] = _.isFunction(customOffset) ? customOffset(d, range) : (pre + next) / 2 + customOffset;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
d[dim] = _this.getDodgeOffset(range, valIndex, valueArr.length);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return [];
|
|
||||||
};
|
|
||||||
Dodge.prototype.getDodgeOffset = function (range, idx, len) {
|
|
||||||
var _a = this, dodgeRatio = _a.dodgeRatio, marginRatio = _a.marginRatio, intervalPadding = _a.intervalPadding, dodgePadding = _a.dodgePadding;
|
|
||||||
var pre = range.pre, next = range.next;
|
|
||||||
var tickLength = next - pre;
|
|
||||||
var position;
|
|
||||||
// 分多种输入情况
|
|
||||||
if (!_.isNil(intervalPadding) && _.isNil(dodgePadding) && intervalPadding >= 0) {
|
|
||||||
// 仅配置intervalPadding
|
|
||||||
var offset = this.getIntervalOnlyOffset(len, idx);
|
|
||||||
position = pre + offset;
|
|
||||||
}
|
|
||||||
else if (!_.isNil(dodgePadding) && _.isNil(intervalPadding) && dodgePadding >= 0) {
|
|
||||||
// 仅配置dodgePadding
|
|
||||||
var offset = this.getDodgeOnlyOffset(len, idx);
|
|
||||||
position = pre + offset;
|
|
||||||
}
|
|
||||||
else if (!_.isNil(intervalPadding) &&
|
|
||||||
!_.isNil(dodgePadding) &&
|
|
||||||
intervalPadding >= 0 &&
|
|
||||||
dodgePadding >= 0) {
|
|
||||||
// 同时配置intervalPadding和dodgePadding
|
|
||||||
var offset = this.getIntervalAndDodgeOffset(len, idx);
|
|
||||||
position = pre + offset;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// 默认情况
|
|
||||||
var width = (tickLength * dodgeRatio) / len;
|
|
||||||
var margin = marginRatio * width;
|
|
||||||
var offset = (1 / 2) * (tickLength - len * width - (len - 1) * margin) +
|
|
||||||
((idx + 1) * width + idx * margin) -
|
|
||||||
(1 / 2) * width -
|
|
||||||
(1 / 2) * tickLength;
|
|
||||||
position = (pre + next) / 2 + offset;
|
|
||||||
}
|
|
||||||
return position;
|
|
||||||
};
|
|
||||||
Dodge.prototype.getIntervalOnlyOffset = function (len, idx) {
|
|
||||||
var _a = this, defaultSize = _a.defaultSize, intervalPadding = _a.intervalPadding, xDimensionLegenth = _a.xDimensionLegenth, groupNum = _a.groupNum, dodgeRatio = _a.dodgeRatio, maxColumnWidth = _a.maxColumnWidth, minColumnWidth = _a.minColumnWidth, columnWidthRatio = _a.columnWidthRatio;
|
|
||||||
var normalizedIntervalPadding = intervalPadding / xDimensionLegenth;
|
|
||||||
var normalizedDodgePadding = (1 - (groupNum - 1) * normalizedIntervalPadding) / groupNum * dodgeRatio / (len - 1);
|
|
||||||
var geomWidth = ((1 - normalizedIntervalPadding * (groupNum - 1)) / groupNum - normalizedDodgePadding * (len - 1)) / len;
|
|
||||||
// 根据columnWidthRatio/defaultSize/maxColumnWidth/minColumnWidth调整宽度
|
|
||||||
geomWidth = (!_.isNil(columnWidthRatio)) ? 1 / groupNum / len * columnWidthRatio : geomWidth;
|
|
||||||
if (!_.isNil(maxColumnWidth)) {
|
|
||||||
var normalizedMaxWidht = maxColumnWidth / xDimensionLegenth;
|
|
||||||
geomWidth = Math.min(geomWidth, normalizedMaxWidht);
|
|
||||||
}
|
|
||||||
if (!_.isNil(minColumnWidth)) {
|
|
||||||
var normalizedMinWidht = minColumnWidth / xDimensionLegenth;
|
|
||||||
geomWidth = Math.max(geomWidth, normalizedMinWidht);
|
|
||||||
}
|
|
||||||
geomWidth = defaultSize ? (defaultSize / xDimensionLegenth) : geomWidth;
|
|
||||||
// 调整组内间隔
|
|
||||||
normalizedDodgePadding = ((1 - (groupNum - 1) * normalizedIntervalPadding) / groupNum - len * geomWidth) / (len - 1);
|
|
||||||
var offset = ((1 / 2 + idx) * geomWidth + idx * normalizedDodgePadding +
|
|
||||||
(1 / 2) * normalizedIntervalPadding) * groupNum -
|
|
||||||
normalizedIntervalPadding / 2;
|
|
||||||
return offset;
|
|
||||||
};
|
|
||||||
Dodge.prototype.getDodgeOnlyOffset = function (len, idx) {
|
|
||||||
var _a = this, defaultSize = _a.defaultSize, dodgePadding = _a.dodgePadding, xDimensionLegenth = _a.xDimensionLegenth, groupNum = _a.groupNum, marginRatio = _a.marginRatio, maxColumnWidth = _a.maxColumnWidth, minColumnWidth = _a.minColumnWidth, columnWidthRatio = _a.columnWidthRatio;
|
|
||||||
var normalizedDodgePadding = dodgePadding / xDimensionLegenth;
|
|
||||||
var normalizedIntervalPadding = 1 * marginRatio / (groupNum - 1);
|
|
||||||
var geomWidth = ((1 - normalizedIntervalPadding * (groupNum - 1)) / groupNum - normalizedDodgePadding * (len - 1)) / len;
|
|
||||||
// 根据columnWidthRatio/defaultSize/maxColumnWidth/minColumnWidth调整宽度
|
|
||||||
geomWidth = columnWidthRatio ? 1 / groupNum / len * columnWidthRatio : geomWidth;
|
|
||||||
if (!_.isNil(maxColumnWidth)) {
|
|
||||||
var normalizedMaxWidht = maxColumnWidth / xDimensionLegenth;
|
|
||||||
geomWidth = Math.min(geomWidth, normalizedMaxWidht);
|
|
||||||
}
|
|
||||||
if (!_.isNil(minColumnWidth)) {
|
|
||||||
var normalizedMinWidht = minColumnWidth / xDimensionLegenth;
|
|
||||||
geomWidth = Math.max(geomWidth, normalizedMinWidht);
|
|
||||||
}
|
|
||||||
geomWidth = defaultSize ? (defaultSize / xDimensionLegenth) : geomWidth;
|
|
||||||
// 调整组间距
|
|
||||||
normalizedIntervalPadding = (1 - (geomWidth * len + normalizedDodgePadding * (len - 1)) * groupNum) / (groupNum - 1);
|
|
||||||
var offset = ((1 / 2 + idx) * geomWidth + idx * normalizedDodgePadding +
|
|
||||||
(1 / 2) * normalizedIntervalPadding) * groupNum -
|
|
||||||
normalizedIntervalPadding / 2;
|
|
||||||
return offset;
|
|
||||||
};
|
|
||||||
Dodge.prototype.getIntervalAndDodgeOffset = function (len, idx) {
|
|
||||||
var _a = this, intervalPadding = _a.intervalPadding, dodgePadding = _a.dodgePadding, xDimensionLegenth = _a.xDimensionLegenth, groupNum = _a.groupNum;
|
|
||||||
var normalizedIntervalPadding = intervalPadding / xDimensionLegenth;
|
|
||||||
var normalizedDodgePadding = dodgePadding / xDimensionLegenth;
|
|
||||||
var geomWidth = ((1 - normalizedIntervalPadding * (groupNum - 1)) / groupNum - normalizedDodgePadding * (len - 1)) / len;
|
|
||||||
var offset = ((1 / 2 + idx) * geomWidth + idx * normalizedDodgePadding +
|
|
||||||
(1 / 2) * normalizedIntervalPadding) * groupNum -
|
|
||||||
normalizedIntervalPadding / 2;
|
|
||||||
return offset;
|
|
||||||
};
|
|
||||||
Dodge.prototype.getDistribution = function (dim) {
|
|
||||||
var groupedDataArray = this.adjustDataArray;
|
|
||||||
var cacheMap = this.cacheMap;
|
|
||||||
var map = cacheMap[dim];
|
|
||||||
if (!map) {
|
|
||||||
map = {};
|
|
||||||
_.each(groupedDataArray, function (data, index) {
|
|
||||||
var values = _.valuesOfKey(data, dim);
|
|
||||||
if (!values.length) {
|
|
||||||
values.push(0);
|
|
||||||
}
|
|
||||||
_.each(values, function (val) {
|
|
||||||
if (!map[val]) {
|
|
||||||
map[val] = [];
|
|
||||||
}
|
|
||||||
map[val].push(index);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
cacheMap[dim] = map;
|
|
||||||
}
|
|
||||||
return map;
|
|
||||||
};
|
|
||||||
return Dodge;
|
|
||||||
}(Adjust));
|
|
||||||
export default Dodge;
|
|
||||||
//# sourceMappingURL=dodge.js.map
|
|
File diff suppressed because one or more lines are too long
@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"jitter.js","sourceRoot":"","sources":["../../src/adjusts/jitter.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,CAAC,MAAM,YAAY,CAAC;AAChC,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC,OAAO,MAAM,MAAM,UAAU,CAAC;AAE9B,SAAS,YAAY,CAAC,GAAW,EAAE,GAAW;IAC5C,OAAO,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC;AAC3C,CAAC;AAED;IAAoC,0BAAM;IAA1C;;IA6CA,CAAC;IA5CQ,wBAAO,GAAd,UAAe,cAAwB;QACrC,IAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;QAEjD,mC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rD,CAAC,CAAC,CAAC;QACH,OAAO,KAAK,CAAC;IACf,CAAC;IACH,aAAC;AAAD,CAAC,AA7CD,CAAoC,MAAM,GA6CzC"}
|
|
@ -1,13 +0,0 @@
|
|||||||
import { Data, StackCfg } from '../interface';
|
|
||||||
import Adjust from './adjust';
|
|
||||||
export default class Stack extends Adjust {
|
|
||||||
constructor(cfg: StackCfg);
|
|
||||||
/**
|
|
||||||
* 方法入参是经过数据分组、数据数字化之后的二维数组
|
|
||||||
* @param groupDataArray 分组之后的数据
|
|
||||||
*/
|
|
||||||
process(groupDataArray: Data[][]): Data[][];
|
|
||||||
private reverse;
|
|
||||||
private processStack;
|
|
||||||
private processOneDimStack;
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"stack.js","sourceRoot":"","sources":["../../src/adjusts/stack.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,CAAC,MAAM,YAAY,CAAC;AAEhC,OAAO,MAAM,MAAM,UAAU,CAAC;AAE9B,IAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;AAEtB;IAAmC,yBAAM;IACvC,eAAY,GAAa;QAAzB,YACE,kBAAM,GAAG,CAAC,SAOX;QALS,IAAA,KAAuE,GAAG,YAAvD,EAAnB,WAAW,mBAAG,CAAC,GAAG,CAAC,KAAA,EAAE,KAAkD,GAAG,OAAzC,EAAZ,MAAM,mBAAG,GAAG,KAAA,EAAE,KAAoC,GAAG,KAA9B,EAAT,IAAI,mBAAG,EAAE,KAAA,EAAE,KAAyB,GAAG,aAAR,EAApB,YAAY,mBAAG,KAAK,KAAA,CAAS;QACnF,KAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,KAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,KAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,KAAI,CAAC,YAAY,GAAG,YAAY,CAAC;;IACnC,CAAC;IAED;;;OAGG;IACI,uBAAO,GAAd,UAAe,cAAwB;QAC/B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A,IAAI,GAAK,KAAI,KAAT,CAAU;gBACtB,IAAM,MAAM,GAAW,IAAI,CAAC,MAAM,CAAC,CAAC;gBAEpC,yBAAyB;gBACzB,IAAM,WAAW,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC;gBAExC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;oBACtB,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,WAAW,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ;iBAC7C;gBAED,IAAM,UAAU,GAAG,KAAK,CAAC,GAAG,CAAC,MAAM,CAAW,CAAC;gBAC/C,mBAAmB;gBACnB,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,UAAU,GAAG,WAAW,CAAC,CAAC;gBAE5C,6BACK,IAAI,gBACN,MAAM,IAAG,UAAU,OACpB;YACJ,CAAC,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IACH,YAAC;AAAD,CAAC,AA7GD,CAAmC,MAAM,GA6GxC"}
|
|
@ -1,7 +0,0 @@
|
|||||||
import { Data } from '../interface';
|
|
||||||
import Adjust from './adjust';
|
|
||||||
export default class Symmetric extends Adjust {
|
|
||||||
process(groupDataArray: Data[][]): Data[][];
|
|
||||||
private getXValuesMaxMap;
|
|
||||||
private getDimMaxValue;
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"symmetric.js","sourceRoot":"","sources":["../../src/adjusts/symmetric.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,CAAC,MAAM,YAAY,CAAC;AAEhC,OAAO,MAAM,MAAM,UAAU,CAAC;AAE9B;IAAuC,6BAAM;IAA7C;;IAyDA,CAAC;IAxDQ,2BAAO,GAAd,UAAe,cAAwB;QACrC,IAAM,SAAS,GAAG,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;QAEtC,IAAA,KAAqB,IAAI,EAAvB,MAAM,YAAA,EAAE,MAAM,YAA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c,GAAG,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,UAAC,IAAI,IAAK,OAAA,IAAI,CAAC,MAAM,CAAW,EAAtB,CAAsB,CAAC,CAAC;QAE9E,qBAAqB;QACrB,OAAO,CAAC,CAAC,SAAS,CAAC,cAAc,EAAE,UAAC,SAAS,IAAK,OAAA,KAAI,CAAC,cAAc,CAAC,SAAS,EAAE,MAAM,CAAC,EAAtC,CAAsC,CAAC,CAAC;IAC5F,CAAC;IAEO,kCAAc,GAAtB,UAAuB,SAAiB,EAAE,GAAW;QACnD,cAAc;QACd,IAAM,SAAS,GAAG,CAAC,CAAC,GAAG,CAAC,SAAS,EAAE,UAAC,IAAI,IAAK,OAAA,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,EAApB,CAAoB,CAAC,CAAC;QACnE,uCAAuC;QACvC,IAAM,aAAa,GAAG,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAE3C,WAAW;QACX,OAAO,IAAI,CAAC,GAAG,OAAR,IAAI,EAAQ,aAAa,EAAE;IACpC,CAAC;IACH,gBAAC;AAAD,CAAC,AAzDD,CAAuC,MAAM,GAyD5C"}
|
|
@ -1,4 +0,0 @@
|
|||||||
export declare const DEFAULT_Y = 0;
|
|
||||||
export declare const MARGIN_RATIO: number;
|
|
||||||
export declare const DODGE_RATIO: number;
|
|
||||||
export declare const GAP = 0.05;
|
|
@ -1,7 +0,0 @@
|
|||||||
export var DEFAULT_Y = 0; // 默认的 y 的值
|
|
||||||
// 偏移之后,间距
|
|
||||||
export var MARGIN_RATIO = 1 / 2;
|
|
||||||
export var DODGE_RATIO = 1 / 2;
|
|
||||||
// 散点分开之后,距离边界的距离
|
|
||||||
export var GAP = 0.05;
|
|
||||||
//# sourceMappingURL=constant.js.map
|
|
@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"constant.js","sourceRoot":"","sources":["../src/constant.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,IAAM,SAAS,GAAG,CAAC,CAAC,CAAC,WAAW;AAEvC,UAAU;AACV,MAAM,CAAC,IAAM,YAAY,GAAG,CAAC,GAAG,CAAC,CAAC;AAClC,MAAM,CAAC,IAAM,WAAW,GAAG,CAAC,GAAG,CAAC,CAAC;AAEjC,iBAAiB;AACjB,MAAM,CAAC,IAAM,GAAG,GAAG,IAAI,CAAC"}
|
|
@ -1,14 +0,0 @@
|
|||||||
import Adjust, { AdjustConstructor } from './adjusts/adjust';
|
|
||||||
/**
|
|
||||||
* 根据类型获取 Adjust 类
|
|
||||||
* @param type
|
|
||||||
*/
|
|
||||||
declare const getAdjust: (type: string) => AdjustConstructor;
|
|
||||||
/**
|
|
||||||
* 注册自定义 Adjust
|
|
||||||
* @param type
|
|
||||||
* @param ctor
|
|
||||||
*/
|
|
||||||
declare const registerAdjust: (type: string, ctor: AdjustConstructor) => void;
|
|
||||||
export { getAdjust, registerAdjust, Adjust };
|
|
||||||
export * from './interface';
|
|
@ -1,25 +0,0 @@
|
|||||||
import Adjust from './adjusts/adjust';
|
|
||||||
var ADJUST_MAP = {};
|
|
||||||
/**
|
|
||||||
* 根据类型获取 Adjust 类
|
|
||||||
* @param type
|
|
||||||
*/
|
|
||||||
var getAdjust = function (type) {
|
|
||||||
return ADJUST_MAP[type.toLowerCase()];
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* 注册自定义 Adjust
|
|
||||||
* @param type
|
|
||||||
* @param ctor
|
|
||||||
*/
|
|
||||||
var registerAdjust = function (type, ctor) {
|
|
||||||
// 注册的时候,需要校验 type 重名,不区分大小写
|
|
||||||
if (getAdjust(type)) {
|
|
||||||
throw new Error("Adjust type '" + type + "' existed.");
|
|
||||||
}
|
|
||||||
// 存储到 map 中
|
|
||||||
ADJUST_MAP[type.toLowerCase()] = ctor;
|
|
||||||
};
|
|
||||||
export { getAdjust, registerAdjust, Adjust };
|
|
||||||
export * from './interface';
|
|
||||||
//# sourceMappingURL=factory.js.map
|
|
@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAAA,OAAO,MAA6B,MAAM,kBAAkB,CAAC;AAM7D,IAAM,UAAU,GAAkB,EAAE,CAAC;AAErC;;;GAGG;AACH,IAAM,SAAS,GAAG,UAAC,IAAY;IAC7B,OAAO,UAAU,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;AACxC,CAAC,CAAC;AAEF;;;;GAIG;AACH,IAAM,cAAc,GAAG,UAAC,IAAY,EAAE,IAAuB;IAC3D,4BAA4B;IAC5B,IAAI,SAAS,CAAC,IAAI,CAAC,EAAE;QACnB,MAAM,IAAI,KAAK,CAAC,kBAAgB,IAAI,eAAY,CAAC,CAAC;KACnD;IACD,YAAY;IACZ,UAAU,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,GAAG,IAAI,CAAC;AACxC,CAAC,CAAC;AAEF,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,EAAE,CAAC;AAE7C,cAAc,aAAa,CAAC"}
|
|
@ -1,4 +0,0 @@
|
|||||||
import { getAdjust, registerAdjust } from './factory';
|
|
||||||
import Adjust from './adjusts/adjust';
|
|
||||||
export { getAdjust, registerAdjust, Adjust };
|
|
||||||
export * from './interface';
|
|
@ -1,15 +0,0 @@
|
|||||||
import { getAdjust, registerAdjust } from './factory';
|
|
||||||
import Adjust from './adjusts/adjust';
|
|
||||||
import Dodge from './adjusts/dodge';
|
|
||||||
import Jitter from './adjusts/jitter';
|
|
||||||
import Stack from './adjusts/stack';
|
|
||||||
import Symmetric from './adjusts/symmetric';
|
|
||||||
// 注册内置的 adjust
|
|
||||||
registerAdjust('Dodge', Dodge);
|
|
||||||
registerAdjust('Jitter', Jitter);
|
|
||||||
registerAdjust('Stack', Stack);
|
|
||||||
registerAdjust('Symmetric', Symmetric);
|
|
||||||
// 最终暴露给外部的方法
|
|
||||||
export { getAdjust, registerAdjust, Adjust };
|
|
||||||
export * from './interface';
|
|
||||||
//# sourceMappingURL=index.js.map
|
|
@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEtD,OAAO,MAAM,MAAM,kBAAkB,CAAC;AAEtC,OAAO,KAAK,MAAM,iBAAiB,CAAC;AACpC,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,KAAK,MAAM,iBAAiB,CAAC;AACpC,OAAO,SAAS,MAAM,qBAAqB,CAAC;AAE5C,eAAe;AACf,cAAc,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AAC/B,cAAc,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;AACjC,cAAc,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;AAC/B,cAAc,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;AAEvC,aAAa;AACb,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,EAAE,CAAC;AAE7C,cAAc,aAAa,CAAC"}
|
|
@ -1,43 +0,0 @@
|
|||||||
export interface AdjustCfg {
|
|
||||||
readonly adjustNames?: string[];
|
|
||||||
readonly xField?: string;
|
|
||||||
readonly yField?: string;
|
|
||||||
readonly dodgeBy?: string;
|
|
||||||
readonly marginRatio?: number;
|
|
||||||
readonly dodgeRatio?: number;
|
|
||||||
readonly size?: number;
|
|
||||||
readonly height?: number;
|
|
||||||
readonly reverseOrder?: boolean;
|
|
||||||
}
|
|
||||||
export interface DodgeCfg {
|
|
||||||
readonly adjustNames?: string[];
|
|
||||||
readonly xField: string;
|
|
||||||
readonly yField?: string;
|
|
||||||
readonly marginRatio?: number;
|
|
||||||
readonly dodgeRatio?: number;
|
|
||||||
readonly dodgeBy?: string;
|
|
||||||
readonly intervalPadding?: number;
|
|
||||||
readonly dodgePadding?: number;
|
|
||||||
readonly xDimensionLength?: number;
|
|
||||||
readonly groupNum?: number;
|
|
||||||
readonly defaultSize?: number;
|
|
||||||
readonly maxColumnWidth?: number;
|
|
||||||
readonly minColumnWidth?: number;
|
|
||||||
readonly columnWidthRatio?: number;
|
|
||||||
readonly customOffset?: ((data: any, range: any) => number) | number;
|
|
||||||
}
|
|
||||||
export interface StackCfg {
|
|
||||||
readonly adjustNames?: string[];
|
|
||||||
readonly xField: string;
|
|
||||||
readonly yField?: string;
|
|
||||||
readonly height?: number;
|
|
||||||
readonly size?: number;
|
|
||||||
readonly reverseOrder?: boolean;
|
|
||||||
}
|
|
||||||
export interface Data {
|
|
||||||
[key: string]: any;
|
|
||||||
}
|
|
||||||
export interface Range {
|
|
||||||
pre: number;
|
|
||||||
next: number;
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
//# sourceMappingURL=interface.js.map
|
|
@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"interface.js","sourceRoot":"","sources":["../src/interface.ts"],"names":[],"mappings":""}
|
|
@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"adjust.js","sourceRoot":"","sources":["../../src/adjusts/adjust.ts"],"names":[],"mappings":";;AAAA,8BAAgC;AAChC,wCAAwC;AASxC;IA6CE,gBAAY,GAAoD;QACtD,IAAA,MAAM,GAAqD,GAAG,OAAxD,EAAE,MAAM,GAA6C,GAAG,OAAhD,EAAE,KAA2C,GAAG,YAAtB,EAAxB,WAAW,mBAAG,CAAC,GAAG,EAAE,GAAG,CAAC,KAAA,EAAE,YAAY,GAAK,GAAG,aAAR,CAAS;QAEvE,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACnC,CAAC;IAKD;;;OAGG;IACI,yBAAQ,GAAf,UAAgB,GAAW;QACzB,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAA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,IAAA,KAAqB,IAAI,EAAvB,MAAM,YAAA,EAAE,MAAM,YAAS,CAAC;QAEhC,IAAM,YAAY,GAAqB,CAAC,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,YAAY,CAAC,CAAC;QAEvE,QAAQ;QACR,IAAM,IAAI,GAAG,EAAE,CAAC;QAChB,IAAI,MAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;YAChC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SACnB;QACD,IAAI,MAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;YAChC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SACnB;QAED,IAAI,CAAC,OAAO,CAAC,UAAC,GAAW;YACvB,IAAI,YAAY,IAAI,YAAY,CAAC,GAAG,CAAC,EAAE;gBACrC,OAAO;aACR;YACD,cAAc;YACd,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,WAAW,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,UAAC,EAAE,EAAE,EAAE,IAAK,OAAA,EAAE,GAAG,EAAE,EAAP,CAAO,CAAa,CAAC;QAC3F,CAAC,CAAC,CAAC;QAEH,wBAAwB;QACxB,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;YACjC,IAAM,GAAG,GAAG,GAAG,CAAC;YAChB,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,oBAAS,EAAE,CAAC,CAAC,CAAC,CAAC,sBAAsB;SAC3D;QAED,OAAO,YAAY,CAAC;IACtB,CAAC;IACH,aAAC;AAAD,CAAC,AAjLD,IAiLC"}
|
|
@ -1,15 +0,0 @@
|
|||||||
import { Data, DodgeCfg } from '../interface';
|
|
||||||
import Adjust from './adjust';
|
|
||||||
export default class Dodge extends Adjust {
|
|
||||||
private cacheMap;
|
|
||||||
private adjustDataArray;
|
|
||||||
private mergeData;
|
|
||||||
constructor(cfg: DodgeCfg);
|
|
||||||
process(groupDataArray: Data[][]): Data[][];
|
|
||||||
protected adjustDim(dim: string, values: number[], data: Data[], frameIndex: number): any[];
|
|
||||||
private getDodgeOffset;
|
|
||||||
private getIntervalOnlyOffset;
|
|
||||||
private getDodgeOnlyOffset;
|
|
||||||
private getIntervalAndDodgeOffset;
|
|
||||||
private getDistribution;
|
|
||||||
}
|
|
@ -1,194 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
var tslib_1 = require("tslib");
|
|
||||||
var _ = require("@antv/util");
|
|
||||||
var constant_1 = require("../constant");
|
|
||||||
var adjust_1 = require("./adjust");
|
|
||||||
var Dodge = /** @class */ (function (_super) {
|
|
||||||
tslib_1.__extends(Dodge, _super);
|
|
||||||
function Dodge(cfg) {
|
|
||||||
var _this = _super.call(this, cfg) || this;
|
|
||||||
_this.cacheMap = {};
|
|
||||||
_this.adjustDataArray = [];
|
|
||||||
_this.mergeData = [];
|
|
||||||
var _a = cfg.marginRatio, marginRatio = _a === void 0 ? constant_1.MARGIN_RATIO : _a, _b = cfg.dodgeRatio, dodgeRatio = _b === void 0 ? constant_1.DODGE_RATIO : _b, dodgeBy = cfg.dodgeBy, intervalPadding = cfg.intervalPadding, dodgePadding = cfg.dodgePadding, xDimensionLength = cfg.xDimensionLength, groupNum = cfg.groupNum, defaultSize = cfg.defaultSize, maxColumnWidth = cfg.maxColumnWidth, minColumnWidth = cfg.minColumnWidth, columnWidthRatio = cfg.columnWidthRatio, customOffset = cfg.customOffset;
|
|
||||||
_this.marginRatio = marginRatio;
|
|
||||||
_this.dodgeRatio = dodgeRatio;
|
|
||||||
_this.dodgeBy = dodgeBy;
|
|
||||||
_this.intervalPadding = intervalPadding;
|
|
||||||
_this.dodgePadding = dodgePadding;
|
|
||||||
_this.xDimensionLegenth = xDimensionLength;
|
|
||||||
_this.groupNum = groupNum;
|
|
||||||
_this.defaultSize = defaultSize;
|
|
||||||
_this.maxColumnWidth = maxColumnWidth;
|
|
||||||
_this.minColumnWidth = minColumnWidth;
|
|
||||||
_this.columnWidthRatio = columnWidthRatio;
|
|
||||||
_this.customOffset = customOffset;
|
|
||||||
return _this;
|
|
||||||
}
|
|
||||||
Dodge.prototype.process = function (groupDataArray) {
|
|
||||||
var groupedDataArray = _.clone(groupDataArray);
|
|
||||||
// 将数据数组展开一层
|
|
||||||
var mergeData = _.flatten(groupedDataArray);
|
|
||||||
var dodgeBy = this.dodgeBy;
|
|
||||||
// 如果指定了分组 dim 的字段
|
|
||||||
var adjustDataArray = dodgeBy ? _.group(mergeData, dodgeBy) : groupedDataArray;
|
|
||||||
this.cacheMap = {};
|
|
||||||
this.adjustDataArray = adjustDataArray;
|
|
||||||
this.mergeData = mergeData;
|
|
||||||
this.adjustData(adjustDataArray, mergeData);
|
|
||||||
this.adjustDataArray = [];
|
|
||||||
this.mergeData = [];
|
|
||||||
return groupedDataArray;
|
|
||||||
};
|
|
||||||
Dodge.prototype.adjustDim = function (dim, values, data, frameIndex) {
|
|
||||||
var _this = this;
|
|
||||||
var customOffset = this.customOffset;
|
|
||||||
var map = this.getDistribution(dim);
|
|
||||||
var groupData = this.groupData(data, dim); // 根据值分组
|
|
||||||
_.each(groupData, function (group, key) {
|
|
||||||
var range;
|
|
||||||
// xField 中只有一个值,不需要做 dodge
|
|
||||||
if (values.length === 1) {
|
|
||||||
range = {
|
|
||||||
pre: values[0] - 1,
|
|
||||||
next: values[0] + 1,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// 如果有多个,则需要获取调整的范围
|
|
||||||
range = _this.getAdjustRange(dim, parseFloat(key), values);
|
|
||||||
}
|
|
||||||
_.each(group, function (d) {
|
|
||||||
var value = d[dim];
|
|
||||||
var valueArr = map[value];
|
|
||||||
var valIndex = valueArr.indexOf(frameIndex);
|
|
||||||
if (!_.isNil(customOffset)) {
|
|
||||||
var pre = range.pre, next = range.next;
|
|
||||||
d[dim] = _.isFunction(customOffset) ? customOffset(d, range) : (pre + next) / 2 + customOffset;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
d[dim] = _this.getDodgeOffset(range, valIndex, valueArr.length);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return [];
|
|
||||||
};
|
|
||||||
Dodge.prototype.getDodgeOffset = function (range, idx, len) {
|
|
||||||
var _a = this, dodgeRatio = _a.dodgeRatio, marginRatio = _a.marginRatio, intervalPadding = _a.intervalPadding, dodgePadding = _a.dodgePadding;
|
|
||||||
var pre = range.pre, next = range.next;
|
|
||||||
var tickLength = next - pre;
|
|
||||||
var position;
|
|
||||||
// 分多种输入情况
|
|
||||||
if (!_.isNil(intervalPadding) && _.isNil(dodgePadding) && intervalPadding >= 0) {
|
|
||||||
// 仅配置intervalPadding
|
|
||||||
var offset = this.getIntervalOnlyOffset(len, idx);
|
|
||||||
position = pre + offset;
|
|
||||||
}
|
|
||||||
else if (!_.isNil(dodgePadding) && _.isNil(intervalPadding) && dodgePadding >= 0) {
|
|
||||||
// 仅配置dodgePadding
|
|
||||||
var offset = this.getDodgeOnlyOffset(len, idx);
|
|
||||||
position = pre + offset;
|
|
||||||
}
|
|
||||||
else if (!_.isNil(intervalPadding) &&
|
|
||||||
!_.isNil(dodgePadding) &&
|
|
||||||
intervalPadding >= 0 &&
|
|
||||||
dodgePadding >= 0) {
|
|
||||||
// 同时配置intervalPadding和dodgePadding
|
|
||||||
var offset = this.getIntervalAndDodgeOffset(len, idx);
|
|
||||||
position = pre + offset;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// 默认情况
|
|
||||||
var width = (tickLength * dodgeRatio) / len;
|
|
||||||
var margin = marginRatio * width;
|
|
||||||
var offset = (1 / 2) * (tickLength - len * width - (len - 1) * margin) +
|
|
||||||
((idx + 1) * width + idx * margin) -
|
|
||||||
(1 / 2) * width -
|
|
||||||
(1 / 2) * tickLength;
|
|
||||||
position = (pre + next) / 2 + offset;
|
|
||||||
}
|
|
||||||
return position;
|
|
||||||
};
|
|
||||||
Dodge.prototype.getIntervalOnlyOffset = function (len, idx) {
|
|
||||||
var _a = this, defaultSize = _a.defaultSize, intervalPadding = _a.intervalPadding, xDimensionLegenth = _a.xDimensionLegenth, groupNum = _a.groupNum, dodgeRatio = _a.dodgeRatio, maxColumnWidth = _a.maxColumnWidth, minColumnWidth = _a.minColumnWidth, columnWidthRatio = _a.columnWidthRatio;
|
|
||||||
var normalizedIntervalPadding = intervalPadding / xDimensionLegenth;
|
|
||||||
var normalizedDodgePadding = (1 - (groupNum - 1) * normalizedIntervalPadding) / groupNum * dodgeRatio / (len - 1);
|
|
||||||
var geomWidth = ((1 - normalizedIntervalPadding * (groupNum - 1)) / groupNum - normalizedDodgePadding * (len - 1)) / len;
|
|
||||||
// 根据columnWidthRatio/defaultSize/maxColumnWidth/minColumnWidth调整宽度
|
|
||||||
geomWidth = (!_.isNil(columnWidthRatio)) ? 1 / groupNum / len * columnWidthRatio : geomWidth;
|
|
||||||
if (!_.isNil(maxColumnWidth)) {
|
|
||||||
var normalizedMaxWidht = maxColumnWidth / xDimensionLegenth;
|
|
||||||
geomWidth = Math.min(geomWidth, normalizedMaxWidht);
|
|
||||||
}
|
|
||||||
if (!_.isNil(minColumnWidth)) {
|
|
||||||
var normalizedMinWidht = minColumnWidth / xDimensionLegenth;
|
|
||||||
geomWidth = Math.max(geomWidth, normalizedMinWidht);
|
|
||||||
}
|
|
||||||
geomWidth = defaultSize ? (defaultSize / xDimensionLegenth) : geomWidth;
|
|
||||||
// 调整组内间隔
|
|
||||||
normalizedDodgePadding = ((1 - (groupNum - 1) * normalizedIntervalPadding) / groupNum - len * geomWidth) / (len - 1);
|
|
||||||
var offset = ((1 / 2 + idx) * geomWidth + idx * normalizedDodgePadding +
|
|
||||||
(1 / 2) * normalizedIntervalPadding) * groupNum -
|
|
||||||
normalizedIntervalPadding / 2;
|
|
||||||
return offset;
|
|
||||||
};
|
|
||||||
Dodge.prototype.getDodgeOnlyOffset = function (len, idx) {
|
|
||||||
var _a = this, defaultSize = _a.defaultSize, dodgePadding = _a.dodgePadding, xDimensionLegenth = _a.xDimensionLegenth, groupNum = _a.groupNum, marginRatio = _a.marginRatio, maxColumnWidth = _a.maxColumnWidth, minColumnWidth = _a.minColumnWidth, columnWidthRatio = _a.columnWidthRatio;
|
|
||||||
var normalizedDodgePadding = dodgePadding / xDimensionLegenth;
|
|
||||||
var normalizedIntervalPadding = 1 * marginRatio / (groupNum - 1);
|
|
||||||
var geomWidth = ((1 - normalizedIntervalPadding * (groupNum - 1)) / groupNum - normalizedDodgePadding * (len - 1)) / len;
|
|
||||||
// 根据columnWidthRatio/defaultSize/maxColumnWidth/minColumnWidth调整宽度
|
|
||||||
geomWidth = columnWidthRatio ? 1 / groupNum / len * columnWidthRatio : geomWidth;
|
|
||||||
if (!_.isNil(maxColumnWidth)) {
|
|
||||||
var normalizedMaxWidht = maxColumnWidth / xDimensionLegenth;
|
|
||||||
geomWidth = Math.min(geomWidth, normalizedMaxWidht);
|
|
||||||
}
|
|
||||||
if (!_.isNil(minColumnWidth)) {
|
|
||||||
var normalizedMinWidht = minColumnWidth / xDimensionLegenth;
|
|
||||||
geomWidth = Math.max(geomWidth, normalizedMinWidht);
|
|
||||||
}
|
|
||||||
geomWidth = defaultSize ? (defaultSize / xDimensionLegenth) : geomWidth;
|
|
||||||
// 调整组间距
|
|
||||||
normalizedIntervalPadding = (1 - (geomWidth * len + normalizedDodgePadding * (len - 1)) * groupNum) / (groupNum - 1);
|
|
||||||
var offset = ((1 / 2 + idx) * geomWidth + idx * normalizedDodgePadding +
|
|
||||||
(1 / 2) * normalizedIntervalPadding) * groupNum -
|
|
||||||
normalizedIntervalPadding / 2;
|
|
||||||
return offset;
|
|
||||||
};
|
|
||||||
Dodge.prototype.getIntervalAndDodgeOffset = function (len, idx) {
|
|
||||||
var _a = this, intervalPadding = _a.intervalPadding, dodgePadding = _a.dodgePadding, xDimensionLegenth = _a.xDimensionLegenth, groupNum = _a.groupNum;
|
|
||||||
var normalizedIntervalPadding = intervalPadding / xDimensionLegenth;
|
|
||||||
var normalizedDodgePadding = dodgePadding / xDimensionLegenth;
|
|
||||||
var geomWidth = ((1 - normalizedIntervalPadding * (groupNum - 1)) / groupNum - normalizedDodgePadding * (len - 1)) / len;
|
|
||||||
var offset = ((1 / 2 + idx) * geomWidth + idx * normalizedDodgePadding +
|
|
||||||
(1 / 2) * normalizedIntervalPadding) * groupNum -
|
|
||||||
normalizedIntervalPadding / 2;
|
|
||||||
return offset;
|
|
||||||
};
|
|
||||||
Dodge.prototype.getDistribution = function (dim) {
|
|
||||||
var groupedDataArray = this.adjustDataArray;
|
|
||||||
var cacheMap = this.cacheMap;
|
|
||||||
var map = cacheMap[dim];
|
|
||||||
if (!map) {
|
|
||||||
map = {};
|
|
||||||
_.each(groupedDataArray, function (data, index) {
|
|
||||||
var values = _.valuesOfKey(data, dim);
|
|
||||||
if (!values.length) {
|
|
||||||
values.push(0);
|
|
||||||
}
|
|
||||||
_.each(values, function (val) {
|
|
||||||
if (!map[val]) {
|
|
||||||
map[val] = [];
|
|
||||||
}
|
|
||||||
map[val].push(index);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
cacheMap[dim] = map;
|
|
||||||
}
|
|
||||||
return map;
|
|
||||||
};
|
|
||||||
return Dodge;
|
|
||||||
}(adjust_1.default));
|
|
||||||
exports.default = Dodge;
|
|
||||||
//# sourceMappingURL=dodge.js.map
|
|
File diff suppressed because one or more lines are too long
@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"jitter.js","sourceRoot":"","sources":["../../src/adjusts/jitter.ts"],"names":[],"mappings":";;;AAAA,8BAAgC;AAChC,wCAAkC;AAElC,mCAA8B;AAE9B,SAAS,YAAY,CAAC,GAAW,EAAE,GAAW;IAC5C,OAAO,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC;AAC3C,CAAC;AAED;IAAoC,kCAA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C,CAAC,IAAI,CAAC,KAAK,EAAE,UAAC,IAAU;YACvB,IAAI,CAAC,GAAG,CAAC,GAAG,KAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU;QACrD,CAAC,CAAC,CAAC;QACH,OAAO,KAAK,CAAC;IACf,CAAC;IACH,aAAC;AAAD,CAAC,AA7CD,CAAoC,gBAAM,GA6CzC"}
|
|
@ -1,13 +0,0 @@
|
|||||||
import { Data, StackCfg } from '../interface';
|
|
||||||
import Adjust from './adjust';
|
|
||||||
export default class Stack extends Adjust {
|
|
||||||
constructor(cfg: StackCfg);
|
|
||||||
/**
|
|
||||||
* 方法入参是经过数据分组、数据数字化之后的二维数组
|
|
||||||
* @param groupDataArray 分组之后的数据
|
|
||||||
*/
|
|
||||||
process(groupDataArray: Data[][]): Data[][];
|
|
||||||
private reverse;
|
|
||||||
private processStack;
|
|
||||||
private processOneDimStack;
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"stack.js","sourceRoot":"","sources":["../../src/adjusts/stack.ts"],"names":[],"mappings":";;;AAAA,8BAAgC;AAEhC,mCAA8B;AAE9B,IAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;AAEtB;IAAmC,iCAAM;IACvC,eAAY,GAAa;QAAzB,YACE,kBAAM,GAAG,CAAC,SAOX;QALS,IAAA,KAAuE,GAAG,YAAvD,EAAnB,WAAW,mBAAG,CAAC,GAAG,CAAC,KAAA,EAAE,KAAkD,GAAG,OAAzC,EAAZ,MAAM,mBAAG,GAAG,KAAA,EAAE,KAAoC,GAAG,KAA9B,EAAT,IAAI,mBAAG,EAAE,KAAA,EAAE,KAAyB,GAAG,aAAR,EAApB,YAAY,mBAAG,KAAK,KAAA,CAAS;QACnF,KAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,KAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,KAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,KAAI,CA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B,CAAC,GAAG,CAAC,UAAC,SAAS;YACpC,OAAO,SAAS,CAAC,GAAG,CAClB,UAAC,IAAI;;gBACK,IAAA,IAAI,GAAK,KAAI,KAAT,CAAU;gBACtB,IAAM,MAAM,GAAW,IAAI,CAAC,MAAM,CAAC,CAAC;gBAEpC,yBAAyB;gBACzB,IAAM,WAAW,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC;gBAExC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;oBACtB,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,WAAW,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ;iBAC7C;gBAED,IAAM,UAAU,GAAG,KAAK,CAAC,GAAG,CAAC,MAAM,CAAW,CAAC;gBAC/C,mBAAmB;gBACnB,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,UAAU,GAAG,WAAW,CAAC,CAAC;gBAE5C,6CACK,IAAI,gBACN,MAAM,IAAG,UAAU,OACpB;YACJ,CAAC,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IACH,YAAC;AAAD,CAAC,AA7GD,CAAmC,gBAAM,GA6GxC"}
|
|
@ -1,7 +0,0 @@
|
|||||||
import { Data } from '../interface';
|
|
||||||
import Adjust from './adjust';
|
|
||||||
export default class Symmetric extends Adjust {
|
|
||||||
process(groupDataArray: Data[][]): Data[][];
|
|
||||||
private getXValuesMaxMap;
|
|
||||||
private getDimMaxValue;
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"symmetric.js","sourceRoot":"","sources":["../../src/adjusts/symmetric.ts"],"names":[],"mappings":";;;AAAA,8BAAgC;AAEhC,mCAA8B;AAE9B;IAAuC,qCAAM;IAA7C;;IAyDA,CAAC;IAxDQ,2BAAO,GAAd,UAAe,cAAwB;QACrC,IAAM,SAAS,GAAG,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;QAEtC,IAAA,KA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M,YAAS,CAAC;QAEhC,mBAAmB;QACnB,IAAM,cAAc,GAAG,CAAC,CAAC,OAAO,CAAC,SAAS,EAAE,UAAC,IAAI,IAAK,OAAA,IAAI,CAAC,MAAM,CAAW,EAAtB,CAAsB,CAAC,CAAC;QAE9E,qBAAqB;QACrB,OAAO,CAAC,CAAC,SAAS,CAAC,cAAc,EAAE,UAAC,SAAS,IAAK,OAAA,KAAI,CAAC,cAAc,CAAC,SAAS,EAAE,MAAM,CAAC,EAAtC,CAAsC,CAAC,CAAC;IAC5F,CAAC;IAEO,kCAAc,GAAtB,UAAuB,SAAiB,EAAE,GAAW;QACnD,cAAc;QACd,IAAM,SAAS,GAAG,CAAC,CAAC,GAAG,CAAC,SAAS,EAAE,UAAC,IAAI,IAAK,OAAA,CAAC,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,EAApB,CAAoB,CAAC,CAAC;QACnE,uCAAuC;QACvC,IAAM,aAAa,GAAG,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;QAE3C,WAAW;QACX,OAAO,IAAI,CAAC,GAAG,OAAR,IAAI,EAAQ,aAAa,EAAE;IACpC,CAAC;IACH,gBAAC;AAAD,CAAC,AAzDD,CAAuC,gBAAM,GAyD5C"}
|
|
@ -1,4 +0,0 @@
|
|||||||
export declare const DEFAULT_Y = 0;
|
|
||||||
export declare const MARGIN_RATIO: number;
|
|
||||||
export declare const DODGE_RATIO: number;
|
|
||||||
export declare const GAP = 0.05;
|
|
@ -1,10 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
exports.GAP = exports.DODGE_RATIO = exports.MARGIN_RATIO = exports.DEFAULT_Y = void 0;
|
|
||||||
exports.DEFAULT_Y = 0; // 默认的 y 的值
|
|
||||||
// 偏移之后,间距
|
|
||||||
exports.MARGIN_RATIO = 1 / 2;
|
|
||||||
exports.DODGE_RATIO = 1 / 2;
|
|
||||||
// 散点分开之后,距离边界的距离
|
|
||||||
exports.GAP = 0.05;
|
|
||||||
//# sourceMappingURL=constant.js.map
|
|
@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"constant.js","sourceRoot":"","sources":["../src/constant.ts"],"names":[],"mappings":";;;AAAa,QAAA,SAAS,GAAG,CAAC,CAAC,CAAC,WAAW;AAEvC,UAAU;AACG,QAAA,YAAY,GAAG,CAAC,GAAG,CAAC,CAAC;AACrB,QAAA,WAAW,GAAG,CAAC,GAAG,CAAC,CAAC;AAEjC,iBAAiB;AACJ,QAAA,GAAG,GAAG,IAAI,CAAC"}
|
|
@ -1,14 +0,0 @@
|
|||||||
import Adjust, { AdjustConstructor } from './adjusts/adjust';
|
|
||||||
/**
|
|
||||||
* 根据类型获取 Adjust 类
|
|
||||||
* @param type
|
|
||||||
*/
|
|
||||||
declare const getAdjust: (type: string) => AdjustConstructor;
|
|
||||||
/**
|
|
||||||
* 注册自定义 Adjust
|
|
||||||
* @param type
|
|
||||||
* @param ctor
|
|
||||||
*/
|
|
||||||
declare const registerAdjust: (type: string, ctor: AdjustConstructor) => void;
|
|
||||||
export { getAdjust, registerAdjust, Adjust };
|
|
||||||
export * from './interface';
|
|
@ -1,31 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
exports.Adjust = exports.registerAdjust = exports.getAdjust = void 0;
|
|
||||||
var tslib_1 = require("tslib");
|
|
||||||
var adjust_1 = require("./adjusts/adjust");
|
|
||||||
exports.Adjust = adjust_1.default;
|
|
||||||
var ADJUST_MAP = {};
|
|
||||||
/**
|
|
||||||
* 根据类型获取 Adjust 类
|
|
||||||
* @param type
|
|
||||||
*/
|
|
||||||
var getAdjust = function (type) {
|
|
||||||
return ADJUST_MAP[type.toLowerCase()];
|
|
||||||
};
|
|
||||||
exports.getAdjust = getAdjust;
|
|
||||||
/**
|
|
||||||
* 注册自定义 Adjust
|
|
||||||
* @param type
|
|
||||||
* @param ctor
|
|
||||||
*/
|
|
||||||
var registerAdjust = function (type, ctor) {
|
|
||||||
// 注册的时候,需要校验 type 重名,不区分大小写
|
|
||||||
if (getAdjust(type)) {
|
|
||||||
throw new Error("Adjust type '" + type + "' existed.");
|
|
||||||
}
|
|
||||||
// 存储到 map 中
|
|
||||||
ADJUST_MAP[type.toLowerCase()] = ctor;
|
|
||||||
};
|
|
||||||
exports.registerAdjust = registerAdjust;
|
|
||||||
tslib_1.__exportStar(require("./interface"), exports);
|
|
||||||
//# sourceMappingURL=factory.js.map
|
|
@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":";;;;AAAA,2CAA6D;AA8BzB,iBA9B7B,gBAAM,CA8B6B;AAxB1C,IAAM,UAAU,GAAkB,EAAE,CAAC;AAErC;;;GAGG;AACH,IAAM,SAAS,GAAG,UAAC,IAAY;IAC7B,OAAO,UAAU,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;AACxC,CAAC,CAAC;AAgBO,8BAAS;AAdlB;;;;GAIG;AACH,IAAM,cAAc,GAAG,UAAC,IAAY,EAAE,IAAuB;IAC3D,4BAA4B;IAC5B,IAAI,SAAS,CAAC,IAAI,CAAC,EAAE;QACnB,MAAM,IAAI,KAAK,CAAC,kBAAgB,IAAI,eAAY,CAAC,CAAC;KACnD;IACD,YAAY;IACZ,UAAU,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,GAAG,IAAI,CAAC;AACxC,CAAC,CAAC;AAEkB,wCAAc;AAElC,sDAA4B"}
|
|
@ -1,4 +0,0 @@
|
|||||||
import { getAdjust, registerAdjust } from './factory';
|
|
||||||
import Adjust from './adjusts/adjust';
|
|
||||||
export { getAdjust, registerAdjust, Adjust };
|
|
||||||
export * from './interface';
|
|
@ -1,20 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
exports.Adjust = exports.registerAdjust = exports.getAdjust = void 0;
|
|
||||||
var tslib_1 = require("tslib");
|
|
||||||
var factory_1 = require("./factory");
|
|
||||||
Object.defineProperty(exports, "getAdjust", { enumerable: true, get: function () { return factory_1.getAdjust; } });
|
|
||||||
Object.defineProperty(exports, "registerAdjust", { enumerable: true, get: function () { return factory_1.registerAdjust; } });
|
|
||||||
var adjust_1 = require("./adjusts/adjust");
|
|
||||||
exports.Adjust = adjust_1.default;
|
|
||||||
var dodge_1 = require("./adjusts/dodge");
|
|
||||||
var jitter_1 = require("./adjusts/jitter");
|
|
||||||
var stack_1 = require("./adjusts/stack");
|
|
||||||
var symmetric_1 = require("./adjusts/symmetric");
|
|
||||||
// 注册内置的 adjust
|
|
||||||
factory_1.registerAdjust('Dodge', dodge_1.default);
|
|
||||||
factory_1.registerAdjust('Jitter', jitter_1.default);
|
|
||||||
factory_1.registerAdjust('Stack', stack_1.default);
|
|
||||||
factory_1.registerAdjust('Symmetric', symmetric_1.default);
|
|
||||||
tslib_1.__exportStar(require("./interface"), exports);
|
|
||||||
//# sourceMappingURL=index.js.map
|
|
@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,qCAAsD;AAgB7C,0FAhBA,mBAAS,OAgBA;AAAE,+FAhBA,wBAAc,OAgBA;AAdlC,2CAAsC;AAcF,iBAd7B,gBAAM,CAc6B;AAZ1C,yCAAoC;AACpC,2CAAsC;AACtC,yCAAoC;AACpC,iDAA4C;AAE5C,eAAe;AACf,wBAAc,CAAC,OAAO,EAAE,eAAK,CAAC,CAAC;AAC/B,wBAAc,CAAC,QAAQ,EAAE,gBAAM,CAAC,CAAC;AACjC,wBAAc,CAAC,OAAO,EAAE,eAAK,CAAC,CAAC;AAC/B,wBAAc,CAAC,WAAW,EAAE,mBAAS,CAAC,CAAC;AAKvC,sDAA4B"}
|
|
@ -1,43 +0,0 @@
|
|||||||
export interface AdjustCfg {
|
|
||||||
readonly adjustNames?: string[];
|
|
||||||
readonly xField?: string;
|
|
||||||
readonly yField?: string;
|
|
||||||
readonly dodgeBy?: string;
|
|
||||||
readonly marginRatio?: number;
|
|
||||||
readonly dodgeRatio?: number;
|
|
||||||
readonly size?: number;
|
|
||||||
readonly height?: number;
|
|
||||||
readonly reverseOrder?: boolean;
|
|
||||||
}
|
|
||||||
export interface DodgeCfg {
|
|
||||||
readonly adjustNames?: string[];
|
|
||||||
readonly xField: string;
|
|
||||||
readonly yField?: string;
|
|
||||||
readonly marginRatio?: number;
|
|
||||||
readonly dodgeRatio?: number;
|
|
||||||
readonly dodgeBy?: string;
|
|
||||||
readonly intervalPadding?: number;
|
|
||||||
readonly dodgePadding?: number;
|
|
||||||
readonly xDimensionLength?: number;
|
|
||||||
readonly groupNum?: number;
|
|
||||||
readonly defaultSize?: number;
|
|
||||||
readonly maxColumnWidth?: number;
|
|
||||||
readonly minColumnWidth?: number;
|
|
||||||
readonly columnWidthRatio?: number;
|
|
||||||
readonly customOffset?: ((data: any, range: any) => number) | number;
|
|
||||||
}
|
|
||||||
export interface StackCfg {
|
|
||||||
readonly adjustNames?: string[];
|
|
||||||
readonly xField: string;
|
|
||||||
readonly yField?: string;
|
|
||||||
readonly height?: number;
|
|
||||||
readonly size?: number;
|
|
||||||
readonly reverseOrder?: boolean;
|
|
||||||
}
|
|
||||||
export interface Data {
|
|
||||||
[key: string]: any;
|
|
||||||
}
|
|
||||||
export interface Range {
|
|
||||||
pre: number;
|
|
||||||
next: number;
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
//# sourceMappingURL=interface.js.map
|
|
@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"interface.js","sourceRoot":"","sources":["../src/interface.ts"],"names":[],"mappings":""}
|
|
@ -1,142 +0,0 @@
|
|||||||
# tslib
|
|
||||||
|
|
||||||
This is a runtime library for [TypeScript](http://www.typescriptlang.org/) that contains all of the TypeScript helper functions.
|
|
||||||
|
|
||||||
This library is primarily used by the `--importHelpers` flag in TypeScript.
|
|
||||||
When using `--importHelpers`, a module that uses helper functions like `__extends` and `__assign` in the following emitted file:
|
|
||||||
|
|
||||||
```ts
|
|
||||||
var __assign = (this && this.__assign) || Object.assign || function(t) {
|
|
||||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
||||||
s = arguments[i];
|
|
||||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
||||||
t[p] = s[p];
|
|
||||||
}
|
|
||||||
return t;
|
|
||||||
};
|
|
||||||
exports.x = {};
|
|
||||||
exports.y = __assign({}, exports.x);
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|
||||||
will instead be emitted as something like the following:
|
|
||||||
|
|
||||||
```ts
|
|
||||||
var tslib_1 = require("tslib");
|
|
||||||
exports.x = {};
|
|
||||||
exports.y = tslib_1.__assign({}, exports.x);
|
|
||||||
```
|
|
||||||
|
|
||||||
Because this can avoid duplicate declarations of things like `__extends`, `__assign`, etc., this means delivering users smaller files on average, as well as less runtime overhead.
|
|
||||||
For optimized bundles with TypeScript, you should absolutely consider using `tslib` and `--importHelpers`.
|
|
||||||
|
|
||||||
# Installing
|
|
||||||
|
|
||||||
For the latest stable version, run:
|
|
||||||
|
|
||||||
## npm
|
|
||||||
|
|
||||||
```sh
|
|
||||||
# TypeScript 2.3.3 or later
|
|
||||||
npm install tslib
|
|
||||||
|
|
||||||
# TypeScript 2.3.2 or earlier
|
|
||||||
npm install tslib@1.6.1
|
|
||||||
```
|
|
||||||
|
|
||||||
## yarn
|
|
||||||
|
|
||||||
```sh
|
|
||||||
# TypeScript 2.3.3 or later
|
|
||||||
yarn add tslib
|
|
||||||
|
|
||||||
# TypeScript 2.3.2 or earlier
|
|
||||||
yarn add tslib@1.6.1
|
|
||||||
```
|
|
||||||
|
|
||||||
## bower
|
|
||||||
|
|
||||||
```sh
|
|
||||||
# TypeScript 2.3.3 or later
|
|
||||||
bower install tslib
|
|
||||||
|
|
||||||
# TypeScript 2.3.2 or earlier
|
|
||||||
bower install tslib@1.6.1
|
|
||||||
```
|
|
||||||
|
|
||||||
## JSPM
|
|
||||||
|
|
||||||
```sh
|
|
||||||
# TypeScript 2.3.3 or later
|
|
||||||
jspm install tslib
|
|
||||||
|
|
||||||
# TypeScript 2.3.2 or earlier
|
|
||||||
jspm install tslib@1.6.1
|
|
||||||
```
|
|
||||||
|
|
||||||
# Usage
|
|
||||||
|
|
||||||
Set the `importHelpers` compiler option on the command line:
|
|
||||||
|
|
||||||
```
|
|
||||||
tsc --importHelpers file.ts
|
|
||||||
```
|
|
||||||
|
|
||||||
or in your tsconfig.json:
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"importHelpers": true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
#### For bower and JSPM users
|
|
||||||
|
|
||||||
You will need to add a `paths` mapping for `tslib`, e.g. For Bower users:
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"module": "amd",
|
|
||||||
"importHelpers": true,
|
|
||||||
"baseUrl": "./",
|
|
||||||
"paths": {
|
|
||||||
"tslib" : ["bower_components/tslib/tslib.d.ts"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
For JSPM users:
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"compilerOptions": {
|
|
||||||
"module": "system",
|
|
||||||
"importHelpers": true,
|
|
||||||
"baseUrl": "./",
|
|
||||||
"paths": {
|
|
||||||
"tslib" : ["jspm_packages/npm/tslib@1.[version].0/tslib.d.ts"]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
# Contribute
|
|
||||||
|
|
||||||
There are many ways to [contribute](https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md) to TypeScript.
|
|
||||||
|
|
||||||
* [Submit bugs](https://github.com/Microsoft/TypeScript/issues) and help us verify fixes as they are checked in.
|
|
||||||
* Review the [source code changes](https://github.com/Microsoft/TypeScript/pulls).
|
|
||||||
* Engage with other TypeScript users and developers on [StackOverflow](http://stackoverflow.com/questions/tagged/typescript).
|
|
||||||
* Join the [#typescript](http://twitter.com/#!/search/realtime/%23typescript) discussion on Twitter.
|
|
||||||
* [Contribute bug fixes](https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md).
|
|
||||||
|
|
||||||
# Documentation
|
|
||||||
|
|
||||||
* [Quick tutorial](http://www.typescriptlang.org/Tutorial)
|
|
||||||
* [Programming handbook](http://www.typescriptlang.org/Handbook)
|
|
||||||
* [Homepage](http://www.typescriptlang.org/)
|
|
@ -1,51 +0,0 @@
|
|||||||
import tslib from '../tslib.js';
|
|
||||||
const {
|
|
||||||
__extends,
|
|
||||||
__assign,
|
|
||||||
__rest,
|
|
||||||
__decorate,
|
|
||||||
__param,
|
|
||||||
__metadata,
|
|
||||||
__awaiter,
|
|
||||||
__generator,
|
|
||||||
__exportStar,
|
|
||||||
__createBinding,
|
|
||||||
__values,
|
|
||||||
__read,
|
|
||||||
__spread,
|
|
||||||
__spreadArrays,
|
|
||||||
__await,
|
|
||||||
__asyncGenerator,
|
|
||||||
__asyncDelegator,
|
|
||||||
__asyncValues,
|
|
||||||
__makeTemplateObject,
|
|
||||||
__importStar,
|
|
||||||
__importDefault,
|
|
||||||
__classPrivateFieldGet,
|
|
||||||
__classPrivateFieldSet,
|
|
||||||
} = tslib;
|
|
||||||
export {
|
|
||||||
__extends,
|
|
||||||
__assign,
|
|
||||||
__rest,
|
|
||||||
__decorate,
|
|
||||||
__param,
|
|
||||||
__metadata,
|
|
||||||
__awaiter,
|
|
||||||
__generator,
|
|
||||||
__exportStar,
|
|
||||||
__createBinding,
|
|
||||||
__values,
|
|
||||||
__read,
|
|
||||||
__spread,
|
|
||||||
__spreadArrays,
|
|
||||||
__await,
|
|
||||||
__asyncGenerator,
|
|
||||||
__asyncDelegator,
|
|
||||||
__asyncValues,
|
|
||||||
__makeTemplateObject,
|
|
||||||
__importStar,
|
|
||||||
__importDefault,
|
|
||||||
__classPrivateFieldGet,
|
|
||||||
__classPrivateFieldSet,
|
|
||||||
};
|
|
@ -1,37 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "tslib",
|
|
||||||
"author": "Microsoft Corp.",
|
|
||||||
"homepage": "https://www.typescriptlang.org/",
|
|
||||||
"version": "1.14.1",
|
|
||||||
"license": "0BSD",
|
|
||||||
"description": "Runtime library for TypeScript helper functions",
|
|
||||||
"keywords": [
|
|
||||||
"TypeScript",
|
|
||||||
"Microsoft",
|
|
||||||
"compiler",
|
|
||||||
"language",
|
|
||||||
"javascript",
|
|
||||||
"tslib",
|
|
||||||
"runtime"
|
|
||||||
],
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/Microsoft/TypeScript/issues"
|
|
||||||
},
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/Microsoft/tslib.git"
|
|
||||||
},
|
|
||||||
"main": "tslib.js",
|
|
||||||
"module": "tslib.es6.js",
|
|
||||||
"jsnext:main": "tslib.es6.js",
|
|
||||||
"typings": "tslib.d.ts",
|
|
||||||
"sideEffects": false,
|
|
||||||
"exports": {
|
|
||||||
".": {
|
|
||||||
"module": "./tslib.es6.js",
|
|
||||||
"import": "./modules/index.js",
|
|
||||||
"default": "./tslib.js"
|
|
||||||
},
|
|
||||||
"./": "./"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
// When on node 14, it validates that all of the commonjs exports
|
|
||||||
// are correctly re-exported for es modules importers.
|
|
||||||
|
|
||||||
const nodeMajor = Number(process.version.split(".")[0].slice(1))
|
|
||||||
if (nodeMajor < 14) {
|
|
||||||
console.log("Skipping because node does not support module exports.")
|
|
||||||
process.exit(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ES Modules import via the ./modules folder
|
|
||||||
import * as esTSLib from "../../modules/index.js"
|
|
||||||
|
|
||||||
// Force a commonjs resolve
|
|
||||||
import { createRequire } from "module";
|
|
||||||
const commonJSTSLib = createRequire(import.meta.url)("../../tslib.js");
|
|
||||||
|
|
||||||
for (const key in commonJSTSLib) {
|
|
||||||
if (commonJSTSLib.hasOwnProperty(key)) {
|
|
||||||
if(!esTSLib[key]) throw new Error(`ESModules is missing ${key} - it needs to be re-exported in ./modules/index.js`)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log("All exports in commonjs are available for es module consumers.")
|
|
@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"type": "module",
|
|
||||||
"scripts": {
|
|
||||||
"test": "node index.js"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,37 +0,0 @@
|
|||||||
/*! *****************************************************************************
|
|
||||||
Copyright (c) Microsoft Corporation.
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
||||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
||||||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
||||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
||||||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
||||||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
||||||
PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
***************************************************************************** */
|
|
||||||
export declare function __extends(d: Function, b: Function): void;
|
|
||||||
export declare function __assign(t: any, ...sources: any[]): any;
|
|
||||||
export declare function __rest(t: any, propertyNames: (string | symbol)[]): any;
|
|
||||||
export declare function __decorate(decorators: Function[], target: any, key?: string | symbol, desc?: any): any;
|
|
||||||
export declare function __param(paramIndex: number, decorator: Function): Function;
|
|
||||||
export declare function __metadata(metadataKey: any, metadataValue: any): Function;
|
|
||||||
export declare function __awaiter(thisArg: any, _arguments: any, P: Function, generator: Function): any;
|
|
||||||
export declare function __generator(thisArg: any, body: Function): any;
|
|
||||||
export declare function __exportStar(m: any, exports: any): void;
|
|
||||||
export declare function __values(o: any): any;
|
|
||||||
export declare function __read(o: any, n?: number): any[];
|
|
||||||
export declare function __spread(...args: any[][]): any[];
|
|
||||||
export declare function __spreadArrays(...args: any[][]): any[];
|
|
||||||
export declare function __await(v: any): any;
|
|
||||||
export declare function __asyncGenerator(thisArg: any, _arguments: any, generator: Function): any;
|
|
||||||
export declare function __asyncDelegator(o: any): any;
|
|
||||||
export declare function __asyncValues(o: any): any;
|
|
||||||
export declare function __makeTemplateObject(cooked: string[], raw: string[]): TemplateStringsArray;
|
|
||||||
export declare function __importStar<T>(mod: T): T;
|
|
||||||
export declare function __importDefault<T>(mod: T): T | { default: T };
|
|
||||||
export declare function __classPrivateFieldGet<T extends object, V>(receiver: T, privateMap: { has(o: T): boolean, get(o: T): V | undefined }): V;
|
|
||||||
export declare function __classPrivateFieldSet<T extends object, V>(receiver: T, privateMap: { has(o: T): boolean, set(o: T, value: V): any }, value: V): V;
|
|
||||||
export declare function __createBinding(object: object, target: object, key: PropertyKey, objectKey?: PropertyKey): void;
|
|
@ -1,218 +0,0 @@
|
|||||||
/*! *****************************************************************************
|
|
||||||
Copyright (c) Microsoft Corporation.
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
||||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
||||||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
||||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
||||||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
||||||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
||||||
PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
***************************************************************************** */
|
|
||||||
/* global Reflect, Promise */
|
|
||||||
|
|
||||||
var extendStatics = function(d, b) {
|
|
||||||
extendStatics = Object.setPrototypeOf ||
|
|
||||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
||||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
||||||
return extendStatics(d, b);
|
|
||||||
};
|
|
||||||
|
|
||||||
export function __extends(d, b) {
|
|
||||||
extendStatics(d, b);
|
|
||||||
function __() { this.constructor = d; }
|
|
||||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
||||||
}
|
|
||||||
|
|
||||||
export var __assign = function() {
|
|
||||||
__assign = Object.assign || function __assign(t) {
|
|
||||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
||||||
s = arguments[i];
|
|
||||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
||||||
}
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
return __assign.apply(this, arguments);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function __rest(s, e) {
|
|
||||||
var t = {};
|
|
||||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
||||||
t[p] = s[p];
|
|
||||||
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
||||||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
||||||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
||||||
t[p[i]] = s[p[i]];
|
|
||||||
}
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function __decorate(decorators, target, key, desc) {
|
|
||||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
||||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
||||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
||||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function __param(paramIndex, decorator) {
|
|
||||||
return function (target, key) { decorator(target, key, paramIndex); }
|
|
||||||
}
|
|
||||||
|
|
||||||
export function __metadata(metadataKey, metadataValue) {
|
|
||||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function __awaiter(thisArg, _arguments, P, generator) {
|
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export function __generator(thisArg, body) {
|
|
||||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
||||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
||||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
||||||
function step(op) {
|
|
||||||
if (f) throw new TypeError("Generator is already executing.");
|
|
||||||
while (_) try {
|
|
||||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
||||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
||||||
switch (op[0]) {
|
|
||||||
case 0: case 1: t = op; break;
|
|
||||||
case 4: _.label++; return { value: op[1], done: false };
|
|
||||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
||||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
||||||
default:
|
|
||||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
||||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
||||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
||||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
||||||
if (t[2]) _.ops.pop();
|
|
||||||
_.trys.pop(); continue;
|
|
||||||
}
|
|
||||||
op = body.call(thisArg, _);
|
|
||||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
||||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export function __createBinding(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}
|
|
||||||
|
|
||||||
export function __exportStar(m, exports) {
|
|
||||||
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
||||||
}
|
|
||||||
|
|
||||||
export function __values(o) {
|
|
||||||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
||||||
if (m) return m.call(o);
|
|
||||||
if (o && typeof o.length === "number") return {
|
|
||||||
next: function () {
|
|
||||||
if (o && i >= o.length) o = void 0;
|
|
||||||
return { value: o && o[i++], done: !o };
|
|
||||||
}
|
|
||||||
};
|
|
||||||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
||||||
}
|
|
||||||
|
|
||||||
export function __read(o, n) {
|
|
||||||
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
||||||
if (!m) return o;
|
|
||||||
var i = m.call(o), r, ar = [], e;
|
|
||||||
try {
|
|
||||||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
||||||
}
|
|
||||||
catch (error) { e = { error: error }; }
|
|
||||||
finally {
|
|
||||||
try {
|
|
||||||
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
||||||
}
|
|
||||||
finally { if (e) throw e.error; }
|
|
||||||
}
|
|
||||||
return ar;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function __spread() {
|
|
||||||
for (var ar = [], i = 0; i < arguments.length; i++)
|
|
||||||
ar = ar.concat(__read(arguments[i]));
|
|
||||||
return ar;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function __spreadArrays() {
|
|
||||||
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
||||||
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
||||||
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
||||||
r[k] = a[j];
|
|
||||||
return r;
|
|
||||||
};
|
|
||||||
|
|
||||||
export function __await(v) {
|
|
||||||
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function __asyncGenerator(thisArg, _arguments, generator) {
|
|
||||||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
||||||
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
||||||
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
||||||
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
|
||||||
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
||||||
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
||||||
function fulfill(value) { resume("next", value); }
|
|
||||||
function reject(value) { resume("throw", value); }
|
|
||||||
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
||||||
}
|
|
||||||
|
|
||||||
export function __asyncDelegator(o) {
|
|
||||||
var i, p;
|
|
||||||
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
|
||||||
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
|
|
||||||
}
|
|
||||||
|
|
||||||
export function __asyncValues(o) {
|
|
||||||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
||||||
var m = o[Symbol.asyncIterator], i;
|
|
||||||
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
||||||
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
||||||
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
||||||
}
|
|
||||||
|
|
||||||
export function __makeTemplateObject(cooked, raw) {
|
|
||||||
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
||||||
return cooked;
|
|
||||||
};
|
|
||||||
|
|
||||||
export function __importStar(mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
||||||
result.default = mod;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function __importDefault(mod) {
|
|
||||||
return (mod && mod.__esModule) ? mod : { default: mod };
|
|
||||||
}
|
|
||||||
|
|
||||||
export function __classPrivateFieldGet(receiver, privateMap) {
|
|
||||||
if (!privateMap.has(receiver)) {
|
|
||||||
throw new TypeError("attempted to get private field on non-instance");
|
|
||||||
}
|
|
||||||
return privateMap.get(receiver);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function __classPrivateFieldSet(receiver, privateMap, value) {
|
|
||||||
if (!privateMap.has(receiver)) {
|
|
||||||
throw new TypeError("attempted to set private field on non-instance");
|
|
||||||
}
|
|
||||||
privateMap.set(receiver, value);
|
|
||||||
return value;
|
|
||||||
}
|
|
@ -1,284 +0,0 @@
|
|||||||
/*! *****************************************************************************
|
|
||||||
Copyright (c) Microsoft Corporation.
|
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for any
|
|
||||||
purpose with or without fee is hereby granted.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
||||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
||||||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
||||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
||||||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
||||||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
||||||
PERFORMANCE OF THIS SOFTWARE.
|
|
||||||
***************************************************************************** */
|
|
||||||
|
|
||||||
/* global global, define, System, Reflect, Promise */
|
|
||||||
var __extends;
|
|
||||||
var __assign;
|
|
||||||
var __rest;
|
|
||||||
var __decorate;
|
|
||||||
var __param;
|
|
||||||
var __metadata;
|
|
||||||
var __awaiter;
|
|
||||||
var __generator;
|
|
||||||
var __exportStar;
|
|
||||||
var __values;
|
|
||||||
var __read;
|
|
||||||
var __spread;
|
|
||||||
var __spreadArrays;
|
|
||||||
var __await;
|
|
||||||
var __asyncGenerator;
|
|
||||||
var __asyncDelegator;
|
|
||||||
var __asyncValues;
|
|
||||||
var __makeTemplateObject;
|
|
||||||
var __importStar;
|
|
||||||
var __importDefault;
|
|
||||||
var __classPrivateFieldGet;
|
|
||||||
var __classPrivateFieldSet;
|
|
||||||
var __createBinding;
|
|
||||||
(function (factory) {
|
|
||||||
var root = typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : {};
|
|
||||||
if (typeof define === "function" && define.amd) {
|
|
||||||
define("tslib", ["exports"], function (exports) { factory(createExporter(root, createExporter(exports))); });
|
|
||||||
}
|
|
||||||
else if (typeof module === "object" && typeof module.exports === "object") {
|
|
||||||
factory(createExporter(root, createExporter(module.exports)));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
factory(createExporter(root));
|
|
||||||
}
|
|
||||||
function createExporter(exports, previous) {
|
|
||||||
if (exports !== root) {
|
|
||||||
if (typeof Object.create === "function") {
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
exports.__esModule = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return function (id, v) { return exports[id] = previous ? previous(id, v) : v; };
|
|
||||||
}
|
|
||||||
})
|
|
||||||
(function (exporter) {
|
|
||||||
var extendStatics = Object.setPrototypeOf ||
|
|
||||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
||||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
||||||
|
|
||||||
__extends = function (d, b) {
|
|
||||||
extendStatics(d, b);
|
|
||||||
function __() { this.constructor = d; }
|
|
||||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
||||||
};
|
|
||||||
|
|
||||||
__assign = Object.assign || function (t) {
|
|
||||||
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
||||||
s = arguments[i];
|
|
||||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
||||||
}
|
|
||||||
return t;
|
|
||||||
};
|
|
||||||
|
|
||||||
__rest = function (s, e) {
|
|
||||||
var t = {};
|
|
||||||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
||||||
t[p] = s[p];
|
|
||||||
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
||||||
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
||||||
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
||||||
t[p[i]] = s[p[i]];
|
|
||||||
}
|
|
||||||
return t;
|
|
||||||
};
|
|
||||||
|
|
||||||
__decorate = function (decorators, target, key, desc) {
|
|
||||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
||||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
||||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
||||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
||||||
};
|
|
||||||
|
|
||||||
__param = function (paramIndex, decorator) {
|
|
||||||
return function (target, key) { decorator(target, key, paramIndex); }
|
|
||||||
};
|
|
||||||
|
|
||||||
__metadata = function (metadataKey, metadataValue) {
|
|
||||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
||||||
};
|
|
||||||
|
|
||||||
__awaiter = function (thisArg, _arguments, P, generator) {
|
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
__generator = function (thisArg, body) {
|
|
||||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
||||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
||||||
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
||||||
function step(op) {
|
|
||||||
if (f) throw new TypeError("Generator is already executing.");
|
|
||||||
while (_) try {
|
|
||||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
||||||
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
||||||
switch (op[0]) {
|
|
||||||
case 0: case 1: t = op; break;
|
|
||||||
case 4: _.label++; return { value: op[1], done: false };
|
|
||||||
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
||||||
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
||||||
default:
|
|
||||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
||||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
||||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
||||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
||||||
if (t[2]) _.ops.pop();
|
|
||||||
_.trys.pop(); continue;
|
|
||||||
}
|
|
||||||
op = body.call(thisArg, _);
|
|
||||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
||||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
__createBinding = function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
};
|
|
||||||
|
|
||||||
__exportStar = function (m, exports) {
|
|
||||||
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
||||||
};
|
|
||||||
|
|
||||||
__values = function (o) {
|
|
||||||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
||||||
if (m) return m.call(o);
|
|
||||||
if (o && typeof o.length === "number") return {
|
|
||||||
next: function () {
|
|
||||||
if (o && i >= o.length) o = void 0;
|
|
||||||
return { value: o && o[i++], done: !o };
|
|
||||||
}
|
|
||||||
};
|
|
||||||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
||||||
};
|
|
||||||
|
|
||||||
__read = function (o, n) {
|
|
||||||
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
||||||
if (!m) return o;
|
|
||||||
var i = m.call(o), r, ar = [], e;
|
|
||||||
try {
|
|
||||||
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
||||||
}
|
|
||||||
catch (error) { e = { error: error }; }
|
|
||||||
finally {
|
|
||||||
try {
|
|
||||||
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
||||||
}
|
|
||||||
finally { if (e) throw e.error; }
|
|
||||||
}
|
|
||||||
return ar;
|
|
||||||
};
|
|
||||||
|
|
||||||
__spread = function () {
|
|
||||||
for (var ar = [], i = 0; i < arguments.length; i++)
|
|
||||||
ar = ar.concat(__read(arguments[i]));
|
|
||||||
return ar;
|
|
||||||
};
|
|
||||||
|
|
||||||
__spreadArrays = function () {
|
|
||||||
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
||||||
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
||||||
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
||||||
r[k] = a[j];
|
|
||||||
return r;
|
|
||||||
};
|
|
||||||
|
|
||||||
__await = function (v) {
|
|
||||||
return this instanceof __await ? (this.v = v, this) : new __await(v);
|
|
||||||
};
|
|
||||||
|
|
||||||
__asyncGenerator = function (thisArg, _arguments, generator) {
|
|
||||||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
||||||
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
||||||
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
||||||
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
|
||||||
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
||||||
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
||||||
function fulfill(value) { resume("next", value); }
|
|
||||||
function reject(value) { resume("throw", value); }
|
|
||||||
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
||||||
};
|
|
||||||
|
|
||||||
__asyncDelegator = function (o) {
|
|
||||||
var i, p;
|
|
||||||
return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
|
|
||||||
function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
|
|
||||||
};
|
|
||||||
|
|
||||||
__asyncValues = function (o) {
|
|
||||||
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
||||||
var m = o[Symbol.asyncIterator], i;
|
|
||||||
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
||||||
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
||||||
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
||||||
};
|
|
||||||
|
|
||||||
__makeTemplateObject = function (cooked, raw) {
|
|
||||||
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
||||||
return cooked;
|
|
||||||
};
|
|
||||||
|
|
||||||
__importStar = function (mod) {
|
|
||||||
if (mod && mod.__esModule) return mod;
|
|
||||||
var result = {};
|
|
||||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
|
||||||
result["default"] = mod;
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
|
|
||||||
__importDefault = function (mod) {
|
|
||||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
||||||
};
|
|
||||||
|
|
||||||
__classPrivateFieldGet = function (receiver, privateMap) {
|
|
||||||
if (!privateMap.has(receiver)) {
|
|
||||||
throw new TypeError("attempted to get private field on non-instance");
|
|
||||||
}
|
|
||||||
return privateMap.get(receiver);
|
|
||||||
};
|
|
||||||
|
|
||||||
__classPrivateFieldSet = function (receiver, privateMap, value) {
|
|
||||||
if (!privateMap.has(receiver)) {
|
|
||||||
throw new TypeError("attempted to set private field on non-instance");
|
|
||||||
}
|
|
||||||
privateMap.set(receiver, value);
|
|
||||||
return value;
|
|
||||||
};
|
|
||||||
|
|
||||||
exporter("__extends", __extends);
|
|
||||||
exporter("__assign", __assign);
|
|
||||||
exporter("__rest", __rest);
|
|
||||||
exporter("__decorate", __decorate);
|
|
||||||
exporter("__param", __param);
|
|
||||||
exporter("__metadata", __metadata);
|
|
||||||
exporter("__awaiter", __awaiter);
|
|
||||||
exporter("__generator", __generator);
|
|
||||||
exporter("__exportStar", __exportStar);
|
|
||||||
exporter("__createBinding", __createBinding);
|
|
||||||
exporter("__values", __values);
|
|
||||||
exporter("__read", __read);
|
|
||||||
exporter("__spread", __spread);
|
|
||||||
exporter("__spreadArrays", __spreadArrays);
|
|
||||||
exporter("__await", __await);
|
|
||||||
exporter("__asyncGenerator", __asyncGenerator);
|
|
||||||
exporter("__asyncDelegator", __asyncDelegator);
|
|
||||||
exporter("__asyncValues", __asyncValues);
|
|
||||||
exporter("__makeTemplateObject", __makeTemplateObject);
|
|
||||||
exporter("__importStar", __importStar);
|
|
||||||
exporter("__importDefault", __importDefault);
|
|
||||||
exporter("__classPrivateFieldGet", __classPrivateFieldGet);
|
|
||||||
exporter("__classPrivateFieldSet", __classPrivateFieldSet);
|
|
||||||
});
|
|
@ -1,92 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "@antv/adjust",
|
|
||||||
"version": "0.2.5",
|
|
||||||
"description": "The adjust module for G2, F2.",
|
|
||||||
"main": "lib/index.js",
|
|
||||||
"module": "esm/index.js",
|
|
||||||
"types": "lib/index.d.ts",
|
|
||||||
"files": [
|
|
||||||
"src",
|
|
||||||
"lib",
|
|
||||||
"esm",
|
|
||||||
"README.md",
|
|
||||||
"LICENSE"
|
|
||||||
],
|
|
||||||
"scripts": {
|
|
||||||
"clean": "rimraf lib esm",
|
|
||||||
"lint": "lint-staged",
|
|
||||||
"test": "jest",
|
|
||||||
"test-live": "DEBUG_MODE=1 jest",
|
|
||||||
"coverage": "jest --coverage",
|
|
||||||
"lib:cjs": "tsc -p tsconfig.json --target ES5 --module commonjs --outDir lib",
|
|
||||||
"lib:esm": "tsc -p tsconfig.json --target ES5 --module ESNext --outDir esm",
|
|
||||||
"lib": "run-p lib:*",
|
|
||||||
"build": "run-s clean lib",
|
|
||||||
"ci": "run-s build coverage",
|
|
||||||
"coveralls": "cat ./coverage/lcov.info | coveralls"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"@antv/util": "~2.0.0",
|
|
||||||
"tslib": "^1.10.0"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@antv/scale": "~0.3.0",
|
|
||||||
"@types/jest": "^24.0.18",
|
|
||||||
"husky": "^3.0.4",
|
|
||||||
"jest": "^24.9.0",
|
|
||||||
"jest-electron": "^0.1.7",
|
|
||||||
"jest-extended": "^0.11.2",
|
|
||||||
"lint-staged": "^9.2.3",
|
|
||||||
"npm-run-all": "^4.1.5",
|
|
||||||
"prettier": "^1.18.2",
|
|
||||||
"rimraf": "^3.0.0",
|
|
||||||
"ts-jest": "^24.1.0",
|
|
||||||
"tslint": "^5.18.0",
|
|
||||||
"tslint-config-prettier": "^1.18.0",
|
|
||||||
"typescript": "^3.5.3",
|
|
||||||
"coveralls": "^3.0.6"
|
|
||||||
},
|
|
||||||
"husky": {
|
|
||||||
"hooks": {
|
|
||||||
"pre-commit": "run-s lint build test"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"lint-staged": {
|
|
||||||
"*.{js,css,json,md}": [
|
|
||||||
"prettier --write",
|
|
||||||
"git add"
|
|
||||||
],
|
|
||||||
"*.{ts}": [
|
|
||||||
"tslint -c tslint.json --fix",
|
|
||||||
"prettier --write",
|
|
||||||
"git add"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"jest": {
|
|
||||||
"runner": "jest-electron/runner",
|
|
||||||
"testEnvironment": "jest-electron/environment",
|
|
||||||
"preset": "ts-jest",
|
|
||||||
"collectCoverage": false,
|
|
||||||
"collectCoverageFrom": [
|
|
||||||
"src/**/*.{ts,js}",
|
|
||||||
"!**/node_modules/**",
|
|
||||||
"!**/vendor/**"
|
|
||||||
],
|
|
||||||
"testRegex": "/tests/.*-spec\\.ts?$"
|
|
||||||
},
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git@github.com:antvis/adjust.git"
|
|
||||||
},
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/antvis/adjust/issues"
|
|
||||||
},
|
|
||||||
"keywords": [
|
|
||||||
"antv",
|
|
||||||
"adjust",
|
|
||||||
"g2",
|
|
||||||
"f2"
|
|
||||||
],
|
|
||||||
"author": "https://github.com/orgs/antvis/people",
|
|
||||||
"license": "MIT"
|
|
||||||
}
|
|
@ -1,248 +0,0 @@
|
|||||||
import * as _ from '@antv/util';
|
|
||||||
import { DODGE_RATIO, MARGIN_RATIO } from '../constant';
|
|
||||||
import { Data, DodgeCfg, Range } from '../interface';
|
|
||||||
import Adjust from './adjust';
|
|
||||||
|
|
||||||
export default class Dodge extends Adjust {
|
|
||||||
private cacheMap: { [key: string]: any } = {};
|
|
||||||
private adjustDataArray: Data[][] = [];
|
|
||||||
private mergeData: Data[] = [];
|
|
||||||
|
|
||||||
constructor(cfg: DodgeCfg) {
|
|
||||||
super(cfg);
|
|
||||||
const {
|
|
||||||
marginRatio = MARGIN_RATIO,
|
|
||||||
dodgeRatio = DODGE_RATIO,
|
|
||||||
dodgeBy,
|
|
||||||
intervalPadding,
|
|
||||||
dodgePadding,
|
|
||||||
xDimensionLength,
|
|
||||||
groupNum,
|
|
||||||
defaultSize,
|
|
||||||
maxColumnWidth,
|
|
||||||
minColumnWidth,
|
|
||||||
columnWidthRatio,
|
|
||||||
customOffset
|
|
||||||
} = cfg;
|
|
||||||
this.marginRatio = marginRatio;
|
|
||||||
this.dodgeRatio = dodgeRatio;
|
|
||||||
this.dodgeBy = dodgeBy;
|
|
||||||
this.intervalPadding = intervalPadding;
|
|
||||||
this.dodgePadding = dodgePadding;
|
|
||||||
this.xDimensionLegenth = xDimensionLength;
|
|
||||||
this.groupNum = groupNum;
|
|
||||||
this.defaultSize = defaultSize;
|
|
||||||
this.maxColumnWidth = maxColumnWidth;
|
|
||||||
this.minColumnWidth = minColumnWidth;
|
|
||||||
this.columnWidthRatio = columnWidthRatio;
|
|
||||||
this.customOffset = customOffset;
|
|
||||||
}
|
|
||||||
|
|
||||||
public process(groupDataArray: Data[][]): Data[][] {
|
|
||||||
const groupedDataArray = _.clone(groupDataArray);
|
|
||||||
// 将数据数组展开一层
|
|
||||||
const mergeData = _.flatten(groupedDataArray);
|
|
||||||
|
|
||||||
const { dodgeBy } = this;
|
|
||||||
|
|
||||||
// 如果指定了分组 dim 的字段
|
|
||||||
const adjustDataArray = dodgeBy ? _.group(mergeData, dodgeBy) : groupedDataArray;
|
|
||||||
|
|
||||||
this.cacheMap = {};
|
|
||||||
this.adjustDataArray = adjustDataArray;
|
|
||||||
this.mergeData = mergeData;
|
|
||||||
|
|
||||||
this.adjustData(adjustDataArray, mergeData);
|
|
||||||
|
|
||||||
this.adjustDataArray = [];
|
|
||||||
this.mergeData = [];
|
|
||||||
|
|
||||||
return groupedDataArray;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected adjustDim(dim: string, values: number[], data: Data[], frameIndex: number): any[] {
|
|
||||||
const { customOffset } = this;
|
|
||||||
const map = this.getDistribution(dim);
|
|
||||||
const groupData = this.groupData(data, dim); // 根据值分组
|
|
||||||
|
|
||||||
_.each(groupData, (group, key) => {
|
|
||||||
let range: Range;
|
|
||||||
|
|
||||||
// xField 中只有一个值,不需要做 dodge
|
|
||||||
if (values.length === 1) {
|
|
||||||
range = {
|
|
||||||
pre: values[0] - 1,
|
|
||||||
next: values[0] + 1,
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
// 如果有多个,则需要获取调整的范围
|
|
||||||
range = this.getAdjustRange(dim, parseFloat(key), values);
|
|
||||||
}
|
|
||||||
_.each(group, (d) => {
|
|
||||||
const value = d[dim];
|
|
||||||
const valueArr = map[value];
|
|
||||||
const valIndex = valueArr.indexOf(frameIndex);
|
|
||||||
if (!_.isNil(customOffset)) {
|
|
||||||
const { pre, next } = range;
|
|
||||||
d[dim] = _.isFunction(customOffset) ? customOffset(d, range) : (pre + next) / 2 + customOffset;
|
|
||||||
} else {
|
|
||||||
d[dim] = this.getDodgeOffset(range, valIndex, valueArr.length);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
private getDodgeOffset(range: Range, idx: number, len: number): number {
|
|
||||||
const {
|
|
||||||
dodgeRatio,
|
|
||||||
marginRatio,
|
|
||||||
intervalPadding,
|
|
||||||
dodgePadding,
|
|
||||||
} = this;
|
|
||||||
const { pre, next } = range;
|
|
||||||
|
|
||||||
const tickLength = next - pre;
|
|
||||||
let position;
|
|
||||||
// 分多种输入情况
|
|
||||||
if (!_.isNil(intervalPadding) && _.isNil(dodgePadding) && intervalPadding >= 0) {
|
|
||||||
// 仅配置intervalPadding
|
|
||||||
const offset = this.getIntervalOnlyOffset(len, idx);
|
|
||||||
position = pre + offset;
|
|
||||||
} else if (!_.isNil(dodgePadding) && _.isNil(intervalPadding) && dodgePadding >= 0) {
|
|
||||||
// 仅配置dodgePadding
|
|
||||||
const offset = this.getDodgeOnlyOffset(len, idx);
|
|
||||||
position = pre + offset;
|
|
||||||
} else if (
|
|
||||||
!_.isNil(intervalPadding) &&
|
|
||||||
!_.isNil(dodgePadding) &&
|
|
||||||
intervalPadding >= 0 &&
|
|
||||||
dodgePadding >= 0
|
|
||||||
) {
|
|
||||||
// 同时配置intervalPadding和dodgePadding
|
|
||||||
const offset = this.getIntervalAndDodgeOffset(len, idx);
|
|
||||||
position = pre + offset;
|
|
||||||
} else {
|
|
||||||
// 默认情况
|
|
||||||
const width = (tickLength * dodgeRatio) / len;
|
|
||||||
const margin = marginRatio * width;
|
|
||||||
const offset =
|
|
||||||
(1 / 2) * (tickLength - len * width - (len - 1) * margin) +
|
|
||||||
((idx + 1) * width + idx * margin) -
|
|
||||||
(1 / 2) * width -
|
|
||||||
(1 / 2) * tickLength;
|
|
||||||
position = (pre + next) / 2 + offset;
|
|
||||||
}
|
|
||||||
return position;
|
|
||||||
}
|
|
||||||
|
|
||||||
private getIntervalOnlyOffset(len: number, idx: number): number {
|
|
||||||
const {
|
|
||||||
defaultSize,
|
|
||||||
intervalPadding,
|
|
||||||
xDimensionLegenth,
|
|
||||||
groupNum,
|
|
||||||
dodgeRatio,
|
|
||||||
maxColumnWidth,
|
|
||||||
minColumnWidth,
|
|
||||||
columnWidthRatio,
|
|
||||||
} = this;
|
|
||||||
const normalizedIntervalPadding = intervalPadding / xDimensionLegenth;
|
|
||||||
let normalizedDodgePadding = (1 - (groupNum - 1) * normalizedIntervalPadding) / groupNum * dodgeRatio / (len - 1);
|
|
||||||
let geomWidth = ((1 - normalizedIntervalPadding * (groupNum - 1)) / groupNum - normalizedDodgePadding * (len - 1)) / len;
|
|
||||||
// 根据columnWidthRatio/defaultSize/maxColumnWidth/minColumnWidth调整宽度
|
|
||||||
geomWidth = (!_.isNil(columnWidthRatio)) ? 1 / groupNum / len * columnWidthRatio : geomWidth;
|
|
||||||
if (!_.isNil(maxColumnWidth)) {
|
|
||||||
const normalizedMaxWidht = maxColumnWidth / xDimensionLegenth;
|
|
||||||
geomWidth = Math.min(geomWidth, normalizedMaxWidht);
|
|
||||||
}
|
|
||||||
if (!_.isNil(minColumnWidth)) {
|
|
||||||
const normalizedMinWidht = minColumnWidth / xDimensionLegenth;
|
|
||||||
geomWidth = Math.max(geomWidth, normalizedMinWidht);
|
|
||||||
}
|
|
||||||
geomWidth = defaultSize ? (defaultSize / xDimensionLegenth) : geomWidth;
|
|
||||||
// 调整组内间隔
|
|
||||||
normalizedDodgePadding = ((1 - (groupNum - 1) * normalizedIntervalPadding) / groupNum - len * geomWidth) / (len - 1);
|
|
||||||
const offset =
|
|
||||||
((1 / 2 + idx) * geomWidth + idx * normalizedDodgePadding +
|
|
||||||
(1 / 2) * normalizedIntervalPadding) * groupNum -
|
|
||||||
normalizedIntervalPadding / 2;
|
|
||||||
return offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
private getDodgeOnlyOffset(len: number, idx: number): number {
|
|
||||||
const {
|
|
||||||
defaultSize,
|
|
||||||
dodgePadding,
|
|
||||||
xDimensionLegenth,
|
|
||||||
groupNum,
|
|
||||||
marginRatio,
|
|
||||||
maxColumnWidth,
|
|
||||||
minColumnWidth,
|
|
||||||
columnWidthRatio,
|
|
||||||
} = this;
|
|
||||||
const normalizedDodgePadding = dodgePadding / xDimensionLegenth;
|
|
||||||
let normalizedIntervalPadding = 1 * marginRatio / (groupNum - 1);
|
|
||||||
let geomWidth = ((1 - normalizedIntervalPadding * (groupNum - 1)) / groupNum - normalizedDodgePadding * (len - 1)) / len;
|
|
||||||
// 根据columnWidthRatio/defaultSize/maxColumnWidth/minColumnWidth调整宽度
|
|
||||||
geomWidth = columnWidthRatio ? 1 / groupNum / len * columnWidthRatio : geomWidth;
|
|
||||||
if (!_.isNil(maxColumnWidth)) {
|
|
||||||
const normalizedMaxWidht = maxColumnWidth / xDimensionLegenth;
|
|
||||||
geomWidth = Math.min(geomWidth, normalizedMaxWidht);
|
|
||||||
}
|
|
||||||
if (!_.isNil(minColumnWidth)) {
|
|
||||||
const normalizedMinWidht = minColumnWidth / xDimensionLegenth;
|
|
||||||
geomWidth = Math.max(geomWidth, normalizedMinWidht);
|
|
||||||
}
|
|
||||||
geomWidth = defaultSize ? (defaultSize / xDimensionLegenth) : geomWidth;
|
|
||||||
// 调整组间距
|
|
||||||
normalizedIntervalPadding = (1 - (geomWidth * len + normalizedDodgePadding * (len - 1)) * groupNum) / (groupNum - 1);
|
|
||||||
const offset =
|
|
||||||
((1 / 2 + idx) * geomWidth + idx * normalizedDodgePadding +
|
|
||||||
(1 / 2) * normalizedIntervalPadding) * groupNum -
|
|
||||||
normalizedIntervalPadding / 2;
|
|
||||||
return offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
private getIntervalAndDodgeOffset(len: number, idx: number): number {
|
|
||||||
const {
|
|
||||||
intervalPadding,
|
|
||||||
dodgePadding,
|
|
||||||
xDimensionLegenth,
|
|
||||||
groupNum,
|
|
||||||
} = this;
|
|
||||||
const normalizedIntervalPadding = intervalPadding / xDimensionLegenth;
|
|
||||||
const normalizedDodgePadding = dodgePadding / xDimensionLegenth;
|
|
||||||
const geomWidth = ((1 - normalizedIntervalPadding * (groupNum - 1)) / groupNum - normalizedDodgePadding * (len - 1)) / len;
|
|
||||||
const offset =
|
|
||||||
((1 / 2 + idx) * geomWidth + idx * normalizedDodgePadding +
|
|
||||||
(1 / 2) * normalizedIntervalPadding) * groupNum -
|
|
||||||
normalizedIntervalPadding / 2;
|
|
||||||
return offset;
|
|
||||||
}
|
|
||||||
|
|
||||||
private getDistribution(dim: string) {
|
|
||||||
const groupedDataArray = this.adjustDataArray;
|
|
||||||
const cacheMap = this.cacheMap;
|
|
||||||
let map = cacheMap[dim];
|
|
||||||
|
|
||||||
if (!map) {
|
|
||||||
map = {};
|
|
||||||
_.each(groupedDataArray, (data, index) => {
|
|
||||||
const values = _.valuesOfKey(data, dim) as number[];
|
|
||||||
if (!values.length) {
|
|
||||||
values.push(0);
|
|
||||||
}
|
|
||||||
_.each(values, (val: number) => {
|
|
||||||
if (!map[val]) {
|
|
||||||
map[val] = [];
|
|
||||||
}
|
|
||||||
map[val].push(index);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
cacheMap[dim] = map;
|
|
||||||
}
|
|
||||||
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue