@vis-pilot/runtime 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026-present vis-pilot contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # @vis-pilot/runtime
2
+
3
+ Browser runtime wrapper for vis-pilot based on ECharts.
4
+
5
+ ## Usage
6
+
7
+ ```ts
8
+ import { VisPilot } from '@vis-pilot/runtime'
9
+
10
+ const container = document.getElementById('chart') as HTMLDivElement
11
+ const pilot = new VisPilot(container, 'dark')
12
+
13
+ pilot.render({
14
+ mode: 'text',
15
+ input: `
16
+ chart: line
17
+ title: Runtime Demo
18
+ x: month
19
+ y: value
20
+ data:
21
+ - month: Jan
22
+ value: 120
23
+ - month: Feb
24
+ value: 150
25
+ - month: Mar
26
+ value: 170
27
+ `
28
+ })
29
+
30
+ pilot.appendData([{ month: 'Apr', value: 190 }])
31
+
32
+ window.addEventListener('beforeunload', () => {
33
+ pilot.dispose()
34
+ })
35
+ ```
@@ -0,0 +1,11 @@
1
+ import type { RenderInput } from '@vis-pilot/core';
2
+ export declare class VisPilot {
3
+ private readonly chart;
4
+ private currentSchema?;
5
+ constructor(dom: HTMLElement, theme?: string);
6
+ render(input: RenderInput): void;
7
+ updateData(data: Record<string, unknown>[]): void;
8
+ appendData(data: Record<string, unknown>[]): void;
9
+ resize(): void;
10
+ dispose(): void;
11
+ }
@@ -0,0 +1,58 @@
1
+ import * as echarts from 'echarts';
2
+ import { buildOption, parseTextOrThrow, normalizeSchema, sanitizeOption, validateOption, validateSchema } from '@vis-pilot/engine';
3
+ export class VisPilot {
4
+ constructor(dom, theme) {
5
+ this.chart = echarts.init(dom, theme);
6
+ }
7
+ render(input) {
8
+ if (input.mode === 'option') {
9
+ validateOption(input.input);
10
+ const option = sanitizeOption(input.input);
11
+ this.chart.setOption(option, { notMerge: true });
12
+ return;
13
+ }
14
+ const schema = input.mode === 'schema'
15
+ ? normalizeSchema(input.input)
16
+ : normalizeSchema(parseTextOrThrow(input.input));
17
+ validateSchema(schema);
18
+ this.currentSchema = schema;
19
+ const option = sanitizeOption(buildOption(schema));
20
+ this.chart.setOption(option, { notMerge: true });
21
+ }
22
+ updateData(data) {
23
+ if (!this.currentSchema) {
24
+ throw new Error('No active schema to update. Call render with schema/text mode first.');
25
+ }
26
+ this.render({
27
+ mode: 'schema',
28
+ input: {
29
+ ...this.currentSchema,
30
+ dataset: {
31
+ ...this.currentSchema.dataset,
32
+ source: data
33
+ }
34
+ }
35
+ });
36
+ }
37
+ appendData(data) {
38
+ if (!this.currentSchema) {
39
+ throw new Error('No active schema to append. Call render with schema/text mode first.');
40
+ }
41
+ this.render({
42
+ mode: 'schema',
43
+ input: {
44
+ ...this.currentSchema,
45
+ dataset: {
46
+ ...this.currentSchema.dataset,
47
+ source: [...this.currentSchema.dataset.source, ...data]
48
+ }
49
+ }
50
+ });
51
+ }
52
+ resize() {
53
+ this.chart.resize();
54
+ }
55
+ dispose() {
56
+ this.chart.dispose();
57
+ }
58
+ }
@@ -0,0 +1 @@
1
+ export * from './VisPilot.js';
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ export * from './VisPilot.js';
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@vis-pilot/runtime",
3
+ "version": "0.1.0",
4
+ "description": "Browser runtime wrapper for vis-pilot based on ECharts.",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ }
14
+ },
15
+ "publishConfig": {
16
+ "access": "public"
17
+ },
18
+ "files": [
19
+ "dist",
20
+ "README.md"
21
+ ],
22
+ "sideEffects": false,
23
+ "dependencies": {
24
+ "echarts": "^5.6.0",
25
+ "@vis-pilot/core": "0.1.0",
26
+ "@vis-pilot/engine": "0.1.0"
27
+ },
28
+ "scripts": {
29
+ "build": "tsc -b",
30
+ "typecheck": "tsc -b",
31
+ "clean": "rm -rf dist *.tsbuildinfo"
32
+ }
33
+ }