You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by sh...@apache.org on 2020/09/20 15:21:42 UTC

[incubator-echarts] branch next updated: fix: add registerPostInit for gl.

This is an automated email from the ASF dual-hosted git repository.

shenyi pushed a commit to branch next
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git


The following commit(s) were added to refs/heads/next by this push:
     new e8f22f2  fix: add registerPostInit for gl.
e8f22f2 is described below

commit e8f22f2a7665e4f9300bc9307825c6330fb13812
Author: pissang <bm...@gmail.com>
AuthorDate: Sun Sep 20 23:20:58 2020 +0800

    fix: add registerPostInit for gl.
---
 build/build.js | 10 ++++++++--
 src/echarts.ts | 21 ++++++++++++++++++++-
 2 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/build/build.js b/build/build.js
index 1fd2a1a..592b3f6 100755
--- a/build/build.js
+++ b/build/build.js
@@ -125,7 +125,7 @@ async function run() {
     validateIO(opt.input, opt.output);
 
     if (isWatch) {
-        watch(config.createECharts(opt));
+        watch(config.createECharts(opt), opt.sourcemap);
     }
     else if (isPrePublish) {
         await prePublish();
@@ -257,7 +257,7 @@ async function build(configs, min, sourcemap) {
  *      watch: {chokidar, include, exclude}
  *  }
  */
-function watch(singleConfig) {
+function watch(singleConfig, sourcemap) {
 
     let watcher = rollup.watch(singleConfig);
 
@@ -280,6 +280,12 @@ function watch(singleConfig) {
             printCodeError(event.error);
         }
         if (event.code === 'BUNDLE_END') {
+
+            const sourceCode = fs.readFileSync(singleConfig.output.file, 'utf-8');
+            // Convert __DEV__ to true;
+            const transformResult = transformDEV.transform(sourceCode, sourcemap, 'true');
+            fs.writeFileSync(singleConfig.output.file, transformResult.code, 'utf-8');
+
             printWatchResult(event);
         }
     });
diff --git a/src/echarts.ts b/src/echarts.ts
index dbe4378..f019c49 100644
--- a/src/echarts.ts
+++ b/src/echarts.ts
@@ -188,6 +188,10 @@ interface SetOptionOpts {
     replaceMerge?: GlobalModelSetOptionOpts['replaceMerge']
 };
 
+interface PostIniter {
+    (chart: EChartsType): void
+}
+
 type EventMethodName = 'on' | 'off';
 function createRegisterEventWithLowercaseECharts(method: EventMethodName) {
     return function (this: ECharts, ...args: any): ECharts {
@@ -2330,6 +2334,8 @@ const dataProcessorFuncs: StageHandlerInternal[] = [];
 
 const optionPreprocessorFuncs: OptionPreprocessor[] = [];
 
+const postInitFuncs: PostIniter[] = [];
+
 const postUpdateFuncs: PostUpdater[] = [];
 
 const visualFuncs: StageHandlerInternal[] = [];
@@ -2402,6 +2408,10 @@ export function init(
 
     enableConnect(chart);
 
+    each(postInitFuncs, (postInitFunc) => {
+        postInitFunc(chart);
+    });
+
     return chart;
 }
 
@@ -2499,12 +2509,21 @@ export function registerProcessor(
     normalizeRegister(dataProcessorFuncs, priority, processor, PRIORITY_PROCESSOR_DEFAULT);
 }
 
+
+/**
+ * Register postIniter
+ * @param {Function} postInitFunc
+ */
+export function registerPostInit(postInitFunc: PostIniter): void {
+    postInitFunc && postInitFuncs.push(postInitFunc);
+}
+
 /**
  * Register postUpdater
  * @param {Function} postUpdateFunc
  */
 export function registerPostUpdate(postUpdateFunc: PostUpdater): void {
-    postUpdateFuncs.push(postUpdateFunc);
+    postUpdateFunc && postUpdateFuncs.push(postUpdateFunc);
 }
 
 /**


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org