@bitblit/ratchet-echarts 0.1.4-alpha → 4.0.1-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -6,7 +6,7 @@ indebted. I have forked it because that library appears to now be dormant, and
6
6
  versions of echarts, and the new prebuilt versions of canvas in my Lambda functions. I also prefer typescript
7
7
  and will be bringing in type information.
8
8
 
9
- ### Install
9
+ ## Install
10
10
 
11
11
  Note: Since this library depends on Echarts >= 5.x and node-canvas (canvas) >= 2.9.3, it auto-bundles in the
12
12
  correct native libraries (prebuilt) for Windows, OSX, and Linux - see [the canvas github page](https://github.com/Automattic/node-canvas)
@@ -16,7 +16,62 @@ for details. Therefore, all you have to do is:
16
16
  npm install @bitblit/ratchet-echarts
17
17
  ```
18
18
 
19
- ### Usage
19
+ ### Special notes for AWS Lambda
20
+
21
+ Most important - you MUST set your lambda to have sufficient memory - probably 512Mb or more. If you find yourself
22
+ getting timeouts with no errors logged after adding the library, you most likely have insufficient memory set.
23
+
24
+
25
+ If you are using AWS Lambda (either Node 14/16, or containers built from the AWS parent container for them), you will
26
+ likely encounter the error "/lib64/libz.so.1: version `ZLIB_1.2.9' not found (required by /var/task/node_modules/canvas/build/Release/libpng16.so.16)"
27
+
28
+ See [the node-canvas issue for more details](https://github.com/Automattic/node-canvas/issues/1779). The solution
29
+ varies depending on how you use Lambda.
30
+
31
+ ### Using a custom docker container (1st way)
32
+ To make sure it is compatible with whatever the current build of the image is, we will build from scratch. In our
33
+ docker container, we'll add :
34
+
35
+ ```docker
36
+ # To build things in yarn
37
+ RUN yum -y install python3
38
+ RUN yum -y install pkgconfig make
39
+
40
+ # Specifically for building canvas
41
+ RUN yum -y install gcc-c++ cairo-devel pango-devel libjpeg-turbo-devel giflib-devel
42
+ ```
43
+
44
+ And then, in the container we'll force a clean build, either by using
45
+ ```docker
46
+ RUN npm install --build-from-source
47
+ ```
48
+
49
+ or
50
+
51
+ ```docker
52
+ RUN npm_config_build_from_source=true yarn install
53
+ ```
54
+
55
+ ### Using a custom docker container (alternate way)
56
+ Add this to your container:
57
+ ```docker
58
+ # Bring these in to make echarts work...
59
+ # Also requires setting the LD_LIBRARY_PATH variable in the config
60
+ # https://github.com/Automattic/node-canvas/issues/1779
61
+ RUN yum -y install libuuid-devel libmount-devel
62
+ RUN cp /lib64/{libuuid,libmount,libblkid}.so.1 ${LAMBDA_TASK_ROOT}/node_modules/canvas/build/Release/
63
+ # End charts stuff
64
+ ```
65
+
66
+ And then set an environment variable:
67
+ ```
68
+ LD_LIBRARY_PATH="${LAMBDA_TASK_ROOT}/modules/api/node_modules/canvas/build/Release:${LD_LIBRARY_PATH}"
69
+ ```
70
+
71
+ ### Using one of the AWS Node options
72
+ Use a [prebuilt layer](https://serverlessrepo.aws.amazon.com/applications/arn:aws:serverlessrepo:us-east-1:990551184979:applications~lambda-layer-canvas-nodejs)
73
+
74
+ ## Usage
20
75
 
21
76
  ```typescript
22
77
 
@@ -0,0 +1,5 @@
1
+ import { BuildInformation } from '@bitblit/ratchet-common';
2
+ export declare class RatchetEchartsInfo {
3
+ private constructor();
4
+ static buildInformation(): BuildInformation;
5
+ }
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" />
2
2
  import { EChartsOption } from 'echarts';
3
3
  import { Canvas } from 'canvas';
4
- import { EChartCanvasConfig } from './echart-canvas-config';
4
+ import { EChartCanvasConfig } from './echart-canvas-config.js';
5
5
  export declare class EChartRatchet {
6
6
  static renderChartUsingProvidedCanvas(opt: EChartsOption, canvas: Canvas): Promise<Buffer>;
7
7
  static renderChart(opts: EChartsOption, config: EChartCanvasConfig): Promise<Buffer>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
package/lib/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from './build/ratchet-echarts-info.js';
2
+ export * from './common/echart-canvas-config.js';
3
+ export * from './common/echart-ratchet.js';
package/lib/index.mjs ADDED
@@ -0,0 +1,2 @@
1
+ import*as r from"echarts";import{Canvas as t}from"canvas";import e from"fs";class n{constructor(){}static buildInformation(){return{version:"LOCAL-SNAPSHOT",hash:"LOCAL-HASH",branch:"LOCAL-BRANCH",tag:"LOCAL-TAG",timeBuiltISO:"LOCAL-TIME-ISO",notes:"LOCAL-NOTES"}}}class a{static async renderChartUsingProvidedCanvas(t,e){if(!t)throw new Error("You must supply an opts parameter");if(!e)throw new Error("You must supply an canvas parameter");let n=null;t.animation=!1;const a=e;return r.init(a).setOption(t),n=e.toBuffer(),n}static async renderChart(r,e){if(!r)throw new Error("You must supply an opts parameter");if(!e)throw new Error("You must supply an config parameter");const n=new t(e.width,e.height);return await this.renderChartUsingProvidedCanvas(r,n)}static async renderChartToPngFile(r,t,n){if(!t)throw new Error("You must supply an opts parameter");if(!n)throw new Error("You must supply an config parameter");if(!r||0===r.trim().length)throw new Error("You must supply a non-empty filename parameter");if(!r.toLowerCase().endsWith(".png"))throw new Error("Your filename should end with .png - this generates a png file");const a=await this.renderChart(t,n);return e.writeFileSync(r,a),a}}export{a as EChartRatchet,n as RatchetEchartsInfo};
2
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","sources":["../src/build/ratchet-echarts-info.ts","../src/common/echart-ratchet.ts"],"sourcesContent":[null,null],"names":["RatchetEchartsInfo","constructor","static","version","hash","branch","tag","timeBuiltISO","notes","EChartRatchet","opt","canvas","Error","rval","animation","canvasHtml","echarts","init","setOption","toBuffer","opts","config","Canvas","width","height","this","renderChartUsingProvidedCanvas","filename","trim","length","toLowerCase","endsWith","renderChart","fs","writeFileSync"],"mappings":"kFAEaA,EAGXC,cAAwB,CAEjBC,0BASL,MAR8B,CAC5BC,QAAS,iBACTC,KAAM,aACNC,OAAQ,eACRC,IAAK,YACLC,aAAc,iBACdC,MAAO,cAGV,QCXUC,EACJP,4CAA4CQ,EAAoBC,GACrE,IAAKD,EACH,MAAM,IAAIE,MAAM,qCAElB,IAAKD,EACH,MAAM,IAAIC,MAAM,uCAElB,IAAIC,EAAe,KAEnBH,EAAII,WAAY,EAChB,MAAMC,EAA0BJ,EAMhC,OAHuBK,EAAQC,KAAKF,GAC9BG,UAAUR,GAChBG,EAAOF,EAAOQ,WACPN,CACR,CAEMX,yBAAyBkB,EAAqBC,GACnD,IAAKD,EACH,MAAM,IAAIR,MAAM,qCAElB,IAAKS,EACH,MAAM,IAAIT,MAAM,uCAElB,MAAMD,EAAiB,IAAIW,EAAOD,EAAOE,MAAOF,EAAOG,QAGvD,aAF2BC,KAAKC,+BAA+BN,EAAMT,EAGtE,CAEMT,kCAAkCyB,EAAkBP,EAAqBC,GAC9E,IAAKD,EACH,MAAM,IAAIR,MAAM,qCAElB,IAAKS,EACH,MAAM,IAAIT,MAAM,uCAElB,IAAKe,GAAuC,IAA3BA,EAASC,OAAOC,OAC/B,MAAM,IAAIjB,MAAM,kDAElB,IAAKe,EAASG,cAAcC,SAAS,QACnC,MAAM,IAAInB,MAAM,kEAElB,MAAMC,QAAqBY,KAAKO,YAAYZ,EAAMC,GAGlD,OAFAY,EAAGC,cAAcP,EAAUd,GAEpBA,CACR"}
package/package.json CHANGED
@@ -1,12 +1,18 @@
1
1
  {
2
2
  "name": "@bitblit/ratchet-echarts",
3
- "version": "0.1.4-alpha",
3
+ "version": "4.0.1-alpha",
4
4
  "description": "Library for using echarts on Node",
5
+ "type": "module",
5
6
  "files": [
6
- "dist"
7
+ "lib/*",
8
+ "bin/*"
7
9
  ],
8
- "main": "./dist/index.js",
9
- "typings": "./dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./lib/index.d.ts",
13
+ "import": "./lib/index.mjs"
14
+ }
15
+ },
10
16
  "contributors": [
11
17
  "Christopher Weiss <bitblit@gmail.com>"
12
18
  ],
@@ -22,56 +28,21 @@
22
28
  },
23
29
  "config": {},
24
30
  "scripts": {
25
- "prepare-to-publish": "yarn build && yarn remove-compiled-tests && yarn run apply-ci-vars",
26
- "copy-static-files": "shx cp -R src/static dist",
27
- "build": "yarn run clean && yarn run generate-barrels && yarn run compile && yarn copy-static-files",
28
- "compile": "tsc",
29
31
  "watch": "tsc-watch",
30
- "remove-compiled-tests": "rimraf ./dist/examples && rimraf ./dist/**/*.spec.d.ts && rimraf ./dist/**/*.spec.js && rimraf ./dist/**/*.spec.js.map",
31
- "clean": "shx rm -Rf dist",
32
- "compile-test": "yarn compile && yarn test",
33
- "apply-ci-vars": "node node_modules/@bitblit/ratchet/dist/node-only/ci/apply-ci-env-variables-to-files github dist/static/build-properties.json",
34
- "test": "jest",
32
+ "clean": "shx rm -Rf lib",
33
+ "test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest",
35
34
  "lint": "eslint src/**/*.ts",
36
35
  "lint-fix": "eslint --fix src/**/*.ts",
37
- "generate-barrels": "barrelsby -q --delete -d src -l top -e .*\\.spec\\.ts"
38
- },
39
- "repository": {
40
- "type": "git",
41
- "url": "https://github.com/bitblit/ratchet-echarts"
42
- },
43
- "engines": {
44
- "node": ">=16.15"
36
+ "generate-barrels": "barrelsby -q --delete -d src -e .*\\.spec\\.ts && sed -i 's/\\x27;/.js\\x27;/' src/index.ts",
37
+ "build": "yarn clean && yarn generate-barrels && shx mkdir -p lib/native && rollup -c rollup.config.js",
38
+ "force-build": "tsc --build --force"
45
39
  },
46
40
  "license": "Apache-2.0",
47
- "bugs": {
48
- "url": "https://github.com/bitblit/ratchet-echarts-echarts/issues"
49
- },
50
- "homepage": "https://github.com/bitblit/ratchet-echarts-echarts#readme",
51
41
  "dependencies": {
52
- "canvas": "2.9.3",
53
- "echarts": "5.3.3"
42
+ "canvas": "2.11.2",
43
+ "echarts": "5.4.2"
54
44
  },
55
45
  "devDependencies": {
56
- "@bitblit/ratchet": "0.21.25",
57
- "@types/jest": "28.1.4",
58
- "@types/node": "14.18.1",
59
- "@typescript-eslint/eslint-plugin": "5.30.5",
60
- "@typescript-eslint/parser": "5.30.5",
61
- "barrelsby": "2.3.4",
62
- "cross-fetch": "3.1.5",
63
- "eslint": "8.19.0",
64
- "eslint-config-prettier": "8.5.0",
65
- "eslint-plugin-import": "2.26.0",
66
- "eslint-plugin-prettier": "4.2.1",
67
- "husky": "8.0.1",
68
- "jest": "28.1.2",
69
- "jsonwebtoken": "8.5.1",
70
- "prettier": "2.7.1",
71
- "pretty-quick": "3.1.3",
72
- "rimraf": "3.0.2",
73
- "shx": "0.3.4",
74
- "ts-jest": "28.0.5",
75
- "typescript": "4.6.4"
46
+ "@bitblit/ratchet-common": "4.0.1-alpha"
76
47
  }
77
48
  }
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=echart-canvas-config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"echart-canvas-config.js","sourceRoot":"","sources":["../src/echart-canvas-config.ts"],"names":[],"mappings":""}
@@ -1,96 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
- var __importDefault = (this && this.__importDefault) || function (mod) {
35
- return (mod && mod.__esModule) ? mod : { "default": mod };
36
- };
37
- Object.defineProperty(exports, "__esModule", { value: true });
38
- exports.EChartRatchet = void 0;
39
- const echarts = __importStar(require("echarts"));
40
- const canvas_1 = require("canvas");
41
- const fs_1 = __importDefault(require("fs"));
42
- class EChartRatchet {
43
- static renderChartUsingProvidedCanvas(opt, canvas) {
44
- return __awaiter(this, void 0, void 0, function* () {
45
- if (!opt) {
46
- throw new Error('You must supply an opts parameter');
47
- }
48
- if (!canvas) {
49
- throw new Error('You must supply an canvas parameter');
50
- }
51
- let rval = null;
52
- opt.animation = false; // Always do not animate given its is a static image
53
- const canvasHtml = canvas;
54
- // This is deprecated, and unneeded so far as I can tell
55
- //echarts.setCanvasCreator(()=>{return canvasHtml;});
56
- const chart = echarts.init(canvasHtml);
57
- chart.setOption(opt);
58
- rval = canvas.toBuffer();
59
- return rval;
60
- });
61
- }
62
- static renderChart(opts, config) {
63
- return __awaiter(this, void 0, void 0, function* () {
64
- if (!opts) {
65
- throw new Error('You must supply an opts parameter');
66
- }
67
- if (!config) {
68
- throw new Error('You must supply an config parameter');
69
- }
70
- const canvas = new canvas_1.Canvas(config.width, config.height);
71
- const rval = yield this.renderChartUsingProvidedCanvas(opts, canvas);
72
- return rval;
73
- });
74
- }
75
- static renderChartToPngFile(filename, opts, config) {
76
- return __awaiter(this, void 0, void 0, function* () {
77
- if (!opts) {
78
- throw new Error('You must supply an opts parameter');
79
- }
80
- if (!config) {
81
- throw new Error('You must supply an config parameter');
82
- }
83
- if (!filename || filename.trim().length === 0) {
84
- throw new Error('You must supply a non-empty filename parameter');
85
- }
86
- if (!filename.toLowerCase().endsWith('.png')) {
87
- throw new Error('Your filename should end with .png - this generates a png file');
88
- }
89
- const rval = yield this.renderChart(opts, config);
90
- fs_1.default.writeFileSync(filename, rval);
91
- return rval;
92
- });
93
- }
94
- }
95
- exports.EChartRatchet = EChartRatchet;
96
- //# sourceMappingURL=echart-ratchet.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"echart-ratchet.js","sourceRoot":"","sources":["../src/echart-ratchet.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAmC;AAEnC,mCAAgC;AAEhC,4CAAoB;AAEpB,MAAa,aAAa;IACjB,MAAM,CAAO,8BAA8B,CAAC,GAAkB,EAAE,MAAc;;YACnF,IAAI,CAAC,GAAG,EAAE;gBACR,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;aACtD;YACD,IAAI,CAAC,MAAM,EAAE;gBACX,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;aACxD;YACD,IAAI,IAAI,GAAW,IAAI,CAAC;YAExB,GAAG,CAAC,SAAS,GAAG,KAAK,CAAC,CAAC,oDAAoD;YAC3E,MAAM,UAAU,GAAsB,MAAsC,CAAC;YAC7E,wDAAwD;YACxD,qDAAqD;YACrD,MAAM,KAAK,GAAY,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAChD,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;YACrB,IAAI,GAAG,MAAM,CAAC,QAAQ,EAAE,CAAC;YACzB,OAAO,IAAI,CAAC;QACd,CAAC;KAAA;IAEM,MAAM,CAAO,WAAW,CAAC,IAAmB,EAAE,MAA0B;;YAC7E,IAAI,CAAC,IAAI,EAAE;gBACT,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;aACtD;YACD,IAAI,CAAC,MAAM,EAAE;gBACX,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;aACxD;YACD,MAAM,MAAM,GAAW,IAAI,eAAM,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;YAC/D,MAAM,IAAI,GAAW,MAAM,IAAI,CAAC,8BAA8B,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YAE7E,OAAO,IAAI,CAAC;QACd,CAAC;KAAA;IAEM,MAAM,CAAO,oBAAoB,CAAC,QAAgB,EAAE,IAAmB,EAAE,MAA0B;;YACxG,IAAI,CAAC,IAAI,EAAE;gBACT,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;aACtD;YACD,IAAI,CAAC,MAAM,EAAE;gBACX,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;aACxD;YACD,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE;gBAC7C,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;aACnE;YACD,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;gBAC5C,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAC;aACnF;YACD,MAAM,IAAI,GAAW,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YAC1D,YAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;YAEjC,OAAO,IAAI,CAAC;QACd,CAAC;KAAA;CACF;AAnDD,sCAmDC"}
package/dist/index.d.ts DELETED
@@ -1,5 +0,0 @@
1
- /**
2
- * @file Automatically generated by barrelsby.
3
- */
4
- export * from './echart-canvas-config';
5
- export * from './echart-ratchet';
package/dist/index.js DELETED
@@ -1,22 +0,0 @@
1
- "use strict";
2
- /**
3
- * @file Automatically generated by barrelsby.
4
- */
5
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- var desc = Object.getOwnPropertyDescriptor(m, k);
8
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
- desc = { enumerable: true, get: function() { return m[k]; } };
10
- }
11
- Object.defineProperty(o, k2, desc);
12
- }) : (function(o, m, k, k2) {
13
- if (k2 === undefined) k2 = k;
14
- o[k2] = m[k];
15
- }));
16
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
17
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
18
- };
19
- Object.defineProperty(exports, "__esModule", { value: true });
20
- __exportStar(require("./echart-canvas-config"), exports);
21
- __exportStar(require("./echart-ratchet"), exports);
22
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;AAEH,yDAAuC;AACvC,mDAAiC"}
@@ -1,7 +0,0 @@
1
- {
2
- "buildVersion": "4",
3
- "buildHash": "df9f733d07443116a0c1b22e5862355579ad1e73",
4
- "buildBranch": "alpha-2022-08-06-10",
5
- "buildTag": "alpha-2022-08-06-10",
6
- "buildTime": "2022-08-06 23:21:55 PM America/Los_Angeles"
7
- }
File without changes