Merge branch 'master' into feat-extension-type
diff --git a/.gitignore b/.gitignore
index ba75419..a974b3a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -205,4 +205,6 @@
/renderers.d.ts
/features.js
/features.d.ts
+/extensionHelper.js
+/extensionHelper.d.ts
*.tgz
diff --git a/build/pre-publish.js b/build/pre-publish.js
index 75d7c77..18eff26 100644
--- a/build/pre-publish.js
+++ b/build/pre-publish.js
@@ -169,9 +169,9 @@
process.stdout.write(chalk.green.dim(` done \n`));
}
- process.stdout.write(chalk.green.dim(`Generating entries ...`));
+ process.stdout.write(chalk.green.dim(`Generating entries ...\n`));
generateEntries();
- process.stdout.write(chalk.green.dim(`Bundling DTS ...`));
+ process.stdout.write(chalk.green.dim(`Bundling DTS ...\n`));
await bundleDTS();
console.log(chalk.green.dim('All done.'));
@@ -372,7 +372,7 @@
// Bundle chunks.
const parts = [
- 'core', 'charts', 'components', 'renderers', 'option', 'features'
+ 'core', 'charts', 'components', 'renderers', 'option', 'features', 'extensionHelper'
];
const inputs = {};
parts.forEach(partName => {
@@ -383,7 +383,7 @@
input: inputs,
...commonConfig
});
- let idx = 1;
+
await bundle.write({
dir: outDir,
minifyInternalExports: false,
@@ -414,7 +414,7 @@
function generateEntries() {
- ['charts', 'components', 'renderers', 'core', 'features'].forEach(entryName => {
+ ['charts', 'components', 'renderers', 'core', 'features', 'extensionHelper'].forEach(entryName => {
if (entryName !== 'option') {
const jsCode = fs.readFileSync(nodePath.join(__dirname, `template/${entryName}.js`), 'utf-8');
fs.writeFileSync(nodePath.join(__dirname, `../${entryName}.js`), jsCode, 'utf-8');
diff --git a/build/template/extensionHelper.d.ts b/build/template/extensionHelper.d.ts
new file mode 100644
index 0000000..a40a51c
--- /dev/null
+++ b/build/template/extensionHelper.d.ts
@@ -0,0 +1,20 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+export * from './types/dist/extensionHelper';
\ No newline at end of file
diff --git a/build/template/extensionHelper.js b/build/template/extensionHelper.js
new file mode 100644
index 0000000..f2b9fc3
--- /dev/null
+++ b/build/template/extensionHelper.js
@@ -0,0 +1,20 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+export * from './lib/export/extensionHelper';
\ No newline at end of file
diff --git a/src/export/api.ts b/src/export/api.ts
index 6575f79..6d78c5f 100644
--- a/src/export/api.ts
+++ b/src/export/api.ts
@@ -57,7 +57,7 @@
// --------------------- Export for Exension Usage ---------------------
// export {SeriesData};
-export {SeriesData as List}; // TODO: Compatitable with exists echarts-gl code
+export {SeriesData as List}; // TODO: Compatible with exists echarts-gl code
export {default as Model} from '../model/Model';
export {default as Axis} from '../coord/Axis';
@@ -77,7 +77,7 @@
// Should use `ComponentModel.extend` or `class XXXX extend ComponentModel` to create class.
// Then use `registerComponentModel` in `install` parameter when `use` this extension. For example:
// class Bar3DModel extends ComponentModel {}
-// export function install(registers) { regsiters.registerComponentModel(Bar3DModel); }
+// export function install(registers) { registers.registerComponentModel(Bar3DModel); }
// echarts.use(install);
export function extendComponentModel(proto: object): ComponentModel {
const Model = (ComponentModel as ComponentModelConstructor).extend(proto) as any;
diff --git a/src/export/extensionHelper.ts b/src/export/extensionHelper.ts
new file mode 100644
index 0000000..633c461
--- /dev/null
+++ b/src/export/extensionHelper.ts
@@ -0,0 +1,22 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements. See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership. The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License. You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+* KIND, either express or implied. See the License for the
+* specific language governing permissions and limitations
+* under the License.
+*/
+
+// export helpful types and APIs for extension developers
+export * from './api';
+export * from '../extension';
\ No newline at end of file
diff --git a/src/extension.ts b/src/extension.ts
index a04ef54..c425f32 100644
--- a/src/extension.ts
+++ b/src/extension.ts
@@ -88,7 +88,7 @@
export type EChartsExtensionInstallRegisters = typeof extensionRegisters;
-export type EChartsExtensionInstaller = (ec: EChartsExtensionInstallRegisters) => void;
+export type EChartsExtensionInstaller = (registers: EChartsExtensionInstallRegisters) => void;
export interface EChartsExtension {
install: EChartsExtensionInstaller
}
@@ -116,8 +116,3 @@
}
ext.install(extensionRegisters);
}
-
-// A simpler use type for exporting to reduce exported inner modules.
-export type EChartsExtensionInstallerSimple = (registers: any) => void;
-type SimpleEChartsExtensionType = EChartsExtensionInstallerSimple | { install: EChartsExtensionInstallerSimple };
-export declare function useSimple(ext: SimpleEChartsExtensionType | (SimpleEChartsExtensionType)[]): void;
diff --git a/test/types/importPartial.ts b/test/types/importPartial.ts
index c4eb8c7..839f144 100644
--- a/test/types/importPartial.ts
+++ b/test/types/importPartial.ts
@@ -34,8 +34,22 @@
import {
CanvasRenderer
} from '../../renderers';
+import { EChartsExtension, EChartsExtensionInstaller } from '../../extensionHelper';
-use([BarChart, LineChart, GridComponent, DataZoomComponent, CanvasRenderer]);
+const customExtension: EChartsExtension = {
+ install(registers) {}
+}
+const customExtensionInstaller: EChartsExtensionInstaller = (registers) => {}
+
+use([
+ BarChart,
+ LineChart,
+ GridComponent,
+ DataZoomComponent,
+ CanvasRenderer,
+ customExtension,
+ customExtensionInstaller
+]);
type Option = ComposeOption<
GridComponentOption | DataZoomComponentOption