@chart-on/vue 0.0.0-stage → 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 +202 -0
- package/NOTICE +2 -0
- package/README.md +16 -2
- package/dist/chart.d.ts +33 -0
- package/dist/context.d.ts +11 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/shell.d.ts +83 -0
- package/dist/shell.js +46 -0
- package/dist/shell.js.map +1 -0
- package/dist/sync.d.ts +110 -0
- package/dist/sync.js +112 -0
- package/dist/sync.js.map +1 -0
- package/package.json +66 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
202
|
+
|
package/NOTICE
ADDED
package/README.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @chart-on/vue
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Components and composables that mount @chart-on/core charts and @chart-on/ui shells in Vue apps, with server rendering support.
|
|
4
|
+
|
|
5
|
+
Part of [charton](https://github.com/chart-on/chart-on#readme), a WebGL2 charting library.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @chart-on/vue @chart-on/core @chart-on/ui vue
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
- [Template wrapper guide](https://github.com/chart-on/chart-on/blob/main/docs/guide/template-wrapper.md)
|
|
12
|
+
- [Changelog](https://github.com/chart-on/chart-on/blob/main/CHANGELOG.md)
|
|
13
|
+
- [Issues](https://github.com/chart-on/chart-on/issues)
|
|
14
|
+
|
|
15
|
+
## License
|
|
16
|
+
|
|
17
|
+
[Apache-2.0](https://github.com/chart-on/chart-on/blob/main/LICENSE). See [NOTICE](https://github.com/chart-on/chart-on/blob/main/NOTICE).
|
package/dist/chart.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type Chart as CoreChart } from '@chart-on/core';
|
|
2
|
+
import { type ChartEventHandlers, type ChartInputs } from './sync';
|
|
3
|
+
/** What a template ref on `<Chart>` reaches. */
|
|
4
|
+
export interface ChartExposed {
|
|
5
|
+
/** The `Chart` while the component is mounted; null before, after and on a server. */
|
|
6
|
+
readonly chart: CoreChart | null;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The chart engine alone, in a `div`. The chart is created when the component
|
|
10
|
+
* mounts and destroyed when it unmounts; prop changes update it in place.
|
|
11
|
+
* `class`, `style` and other attributes go to the `div`: give it a height, the
|
|
12
|
+
* chart fills it. The default slot renders inside the `div`, where `useChart()`
|
|
13
|
+
* returns this chart.
|
|
14
|
+
*/
|
|
15
|
+
export declare const Chart: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
16
|
+
options: import("vue").PropType<import("@chart-on/core").ChartOptionsPatch>;
|
|
17
|
+
dataSource: import("vue").PropType<import("@chart-on/core").DataSource | null>;
|
|
18
|
+
symbol: StringConstructor;
|
|
19
|
+
interval: import("vue").PropType<import("@chart-on/core").Interval>;
|
|
20
|
+
on: import("vue").PropType<ChartEventHandlers>;
|
|
21
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
22
|
+
[key: string]: any;
|
|
23
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
24
|
+
options: import("vue").PropType<import("@chart-on/core").ChartOptionsPatch>;
|
|
25
|
+
dataSource: import("vue").PropType<import("@chart-on/core").DataSource | null>;
|
|
26
|
+
symbol: StringConstructor;
|
|
27
|
+
interval: import("vue").PropType<import("@chart-on/core").Interval>;
|
|
28
|
+
on: import("vue").PropType<ChartEventHandlers>;
|
|
29
|
+
}>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
30
|
+
/** The props of `<Chart>`, for apps that build them in code. */
|
|
31
|
+
export interface ChartProps extends ChartInputs {
|
|
32
|
+
on?: ChartEventHandlers;
|
|
33
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type InjectionKey, type ShallowRef } from 'vue';
|
|
2
|
+
import type { Chart } from '@chart-on/core';
|
|
3
|
+
/** The chart of the nearest `<Chart>` or `<ChartShell>`; null before mount and on a server. */
|
|
4
|
+
export declare const chartKey: InjectionKey<Readonly<ShallowRef<Chart | null>>>;
|
|
5
|
+
/**
|
|
6
|
+
* The chart of the nearest enclosing `<Chart>` or `<ChartShell>`, as a ref. It
|
|
7
|
+
* holds null during server rendering and until the component has mounted,
|
|
8
|
+
* then the chart, so a `watch` on it runs once the chart exists. Outside a
|
|
9
|
+
* chart component it always holds null.
|
|
10
|
+
*/
|
|
11
|
+
export declare function useChart(): Readonly<ShallowRef<Chart | null>>;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Components and composables for `@chart-on/core`. The widget component is in
|
|
3
|
+
* the `@chart-on/vue/shell` entry, so apps that use only the engine do not need
|
|
4
|
+
* `@chart-on/ui`.
|
|
5
|
+
*/
|
|
6
|
+
export { Chart } from './chart';
|
|
7
|
+
export type { ChartExposed, ChartProps } from './chart';
|
|
8
|
+
export { useChart } from './context';
|
|
9
|
+
export type { ChartEventHandlers, ChartInputs } from './sync';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { a as e, d as t, l as n, n as r, s as i, t as a, u as o } from "./sync.js";
|
|
2
|
+
import { defineComponent as s, h as c, markRaw as l, onActivated as u, onDeactivated as d, onMounted as f, onUnmounted as p, provide as m, shallowRef as h } from "vue";
|
|
3
|
+
import { createChart as g } from "@chart-on/core";
|
|
4
|
+
//#region src/chart.ts
|
|
5
|
+
var _ = s({
|
|
6
|
+
name: "Chart",
|
|
7
|
+
props: a,
|
|
8
|
+
setup(t, { slots: a, expose: s }) {
|
|
9
|
+
let _ = h(null), v = h(null), y = null;
|
|
10
|
+
return m(o, v), f(() => {
|
|
11
|
+
let n = e(t);
|
|
12
|
+
y = i(l(g(_.value, n.options)), n, () => t.on), v.value = y.chart;
|
|
13
|
+
}), u(() => y?.chart.resize()), d(() => y?.chart.resize()), p(() => {
|
|
14
|
+
y && (r(y.events), y.chart.destroy(), y = null, v.value = null);
|
|
15
|
+
}), n(t, () => y), s({ chart: v }), () => c("div", { ref: _ }, a.default?.());
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
//#endregion
|
|
19
|
+
export { _ as Chart, t as useChart };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["readInputs","useChart","watchEngine","clearEvents","startEngine","chartProps","chartKey","Chart","defineComponent","element","shallowRef","chart","mounted","provide","onMounted","inputs","props","markRaw","createChart","onActivated","onDeactivated","onUnmounted","expose","h","slots"],"sources":["../src/chart.ts"],"sourcesContent":["import { defineComponent, h, markRaw, onActivated, onDeactivated, onMounted, onUnmounted, provide, shallowRef } from 'vue';\nimport { createChart, type Chart as CoreChart } from '@chart-on/core';\nimport { chartKey } from './context';\nimport { chartProps, clearEvents, readInputs, startEngine, watchEngine, type ChartEventHandlers, type ChartInputs, type Engine } from './sync';\n\n/** What a template ref on `<Chart>` reaches. */\nexport interface ChartExposed {\n /** The `Chart` while the component is mounted; null before, after and on a server. */\n readonly chart: CoreChart | null;\n}\n\n/**\n * The chart engine alone, in a `div`. The chart is created when the component\n * mounts and destroyed when it unmounts; prop changes update it in place.\n * `class`, `style` and other attributes go to the `div`: give it a height, the\n * chart fills it. The default slot renders inside the `div`, where `useChart()`\n * returns this chart.\n */\nexport const Chart = defineComponent({\n name: 'Chart',\n props: chartProps,\n setup(props, { slots, expose }) {\n const element = shallowRef<HTMLDivElement | null>(null);\n const chart = shallowRef<CoreChart | null>(null);\n let mounted: Engine | null = null;\n provide(chartKey, chart);\n\n // Mount: runs only in the browser, never during server rendering.\n onMounted(() => {\n const inputs = readInputs(props);\n // Kept out of reactivity: the chart is a large mutable object the app never needs proxied.\n mounted = startEngine(markRaw(createChart(element.value!, inputs.options)), inputs, () => props.on);\n chart.value = mounted.chart;\n });\n\n // Inside a kept-alive branch: measure when taken out of the page (no size, so no drawing)\n // and when put back, without waiting for the resize observer.\n onActivated(() => mounted?.chart.resize());\n onDeactivated(() => mounted?.chart.resize());\n\n // Unmount: after the slot content has unmounted, so its clean-up still sees a live chart.\n onUnmounted(() => {\n if (!mounted) return;\n clearEvents(mounted.events);\n mounted.chart.destroy();\n mounted = null;\n chart.value = null;\n });\n\n // Updates: apply what changed since the last time, never through a new chart.\n watchEngine(props, () => mounted);\n\n expose({ chart });\n return () => h('div', { ref: element }, slots.default?.());\n },\n});\n\n/** The props of `<Chart>`, for apps that build them in code. */\nexport interface ChartProps extends ChartInputs {\n on?: ChartEventHandlers;\n}\n"],"mappings":";;;;AAkBA,IAAaO,IAAQC,EAAgB;CACnC,MAAM;CACN,OAAOH;CACP,MAAM,GAAO,EAAE,UAAO,aAAU;EAC9B,IAAMI,IAAUC,EAAkC,IAAI,GAChDC,IAAQD,EAA6B,IAAI,GAC3CE,IAAyB;EA6B7B,OA5BAC,EAAQP,GAAUK,CAAK,GAGvBG,QAAgB;GACd,IAAMC,IAASf,EAAWgB,CAAK;GAG/B,AADA,IAAUZ,EAAYa,EAAQC,EAAYT,EAAQ,OAAQM,EAAO,OAAO,CAAC,GAAGA,SAAcC,EAAM,EAAE,GAClG,EAAM,QAAQJ,EAAQ;EACxB,CAAC,GAIDO,QAAkBP,GAAS,MAAM,OAAO,CAAC,GACzCQ,QAAoBR,GAAS,MAAM,OAAO,CAAC,GAG3CS,QAAkB;GAChB,AAAKT,MACLT,EAAYS,EAAQ,MAAM,GAC1BA,EAAQ,MAAM,QAAQ,GACtB,IAAU,MACV,EAAM,QAAQ;EAChB,CAAC,GAGDV,EAAYc,SAAaJ,CAAO,GAEhCU,EAAO,EAAE,SAAM,CAAC,SACHC,EAAE,OAAO,EAAE,KAAKd,EAAQ,GAAGe,EAAM,UAAU,CAAC;CAC3D;AACF,CAAC"}
|
package/dist/shell.d.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { type PropType, type ShallowRef } from 'vue';
|
|
2
|
+
import type { Chart } from '@chart-on/core';
|
|
3
|
+
import { type ChartShell as CoreShell, type ChartShellOptions, type ShellEvents, type ShellFeatures, type ShellPalette, type ShellTheme } from '@chart-on/ui';
|
|
4
|
+
import { type ChartEventHandlers, type ChartInputs } from './sync';
|
|
5
|
+
export type { ChartEventHandlers, ChartInputs } from './sync';
|
|
6
|
+
/** One callback per shell event the app listens to, keyed by event name. */
|
|
7
|
+
export type ShellEventHandlers = {
|
|
8
|
+
[K in keyof ShellEvents]?: (payload: ShellEvents[K]) => void;
|
|
9
|
+
};
|
|
10
|
+
/** Shell options that can only be chosen when the shell is created. */
|
|
11
|
+
export type ShellCreationOptions = Omit<ChartShellOptions, 'chart' | 'theme' | 'palette' | 'features'>;
|
|
12
|
+
/**
|
|
13
|
+
* The shell of the nearest enclosing `<ChartShell>`, as a ref. It holds null
|
|
14
|
+
* on a server and until the shell has mounted, then the shell.
|
|
15
|
+
*/
|
|
16
|
+
export declare function useChartShell(): Readonly<ShallowRef<CoreShell | null>>;
|
|
17
|
+
/** What a template ref on `<ChartShell>` reaches. */
|
|
18
|
+
export interface ChartShellExposed {
|
|
19
|
+
/** The `ChartShell` while the component is mounted; null before, after and on a server. */
|
|
20
|
+
readonly shell: CoreShell | null;
|
|
21
|
+
/** The shell's chart, `shell.chart`, under the same conditions. */
|
|
22
|
+
readonly chart: Chart | null;
|
|
23
|
+
}
|
|
24
|
+
/** The props of `<ChartShell>`, for apps that build them in code. */
|
|
25
|
+
export interface ChartShellProps extends ChartInputs {
|
|
26
|
+
theme?: ShellTheme;
|
|
27
|
+
palette?: ShellPalette;
|
|
28
|
+
features?: Partial<ShellFeatures>;
|
|
29
|
+
shellOptions?: ShellCreationOptions;
|
|
30
|
+
on?: ChartEventHandlers;
|
|
31
|
+
shellOn?: ShellEventHandlers;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The batteries-included widget: toolbar, drawing rail, bottom bar and the
|
|
35
|
+
* chart, in a `div`. Import `@chart-on/ui/style.css` once in the app. The shell
|
|
36
|
+
* is created when the component mounts and destroyed when it unmounts; prop
|
|
37
|
+
* changes update it in place. `class`, `style` and other attributes go to the
|
|
38
|
+
* `div`. The default slot renders inside it, where `useChart()` returns the
|
|
39
|
+
* shell's chart and `useChartShell()` the shell.
|
|
40
|
+
*/
|
|
41
|
+
export declare const ChartShell: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
42
|
+
/**
|
|
43
|
+
* Toolbar, rail, dialogs and the rest of the shell's set-up. Read once, when
|
|
44
|
+
* the shell is created: to change them, remount the component on purpose,
|
|
45
|
+
* for example with a new `key`.
|
|
46
|
+
*/
|
|
47
|
+
shellOptions: PropType<ShellCreationOptions>;
|
|
48
|
+
/** Colour scheme of the chrome and the chart; changes go through `setTheme`. Default `dark`. */
|
|
49
|
+
theme: PropType<ShellTheme>;
|
|
50
|
+
/** Up and down colours; changes go through `setPalette`. */
|
|
51
|
+
palette: PropType<ShellPalette>;
|
|
52
|
+
/** Shell parts to show or hide; changes go through `applyFeatures` and are compared by value. */
|
|
53
|
+
features: PropType<Partial<ShellFeatures>>;
|
|
54
|
+
/** Shell events to listen to, keyed by event name, e.g. `{ 'theme:change': (e) => … }`. */
|
|
55
|
+
shellOn: PropType<ShellEventHandlers>;
|
|
56
|
+
options: PropType<import("@chart-on/core").ChartOptionsPatch>;
|
|
57
|
+
dataSource: PropType<import("@chart-on/core").DataSource | null>;
|
|
58
|
+
symbol: StringConstructor;
|
|
59
|
+
interval: PropType<import("@chart-on/core").Interval>;
|
|
60
|
+
on: PropType<ChartEventHandlers>;
|
|
61
|
+
}>, () => import("vue").VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
62
|
+
[key: string]: any;
|
|
63
|
+
}>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
64
|
+
/**
|
|
65
|
+
* Toolbar, rail, dialogs and the rest of the shell's set-up. Read once, when
|
|
66
|
+
* the shell is created: to change them, remount the component on purpose,
|
|
67
|
+
* for example with a new `key`.
|
|
68
|
+
*/
|
|
69
|
+
shellOptions: PropType<ShellCreationOptions>;
|
|
70
|
+
/** Colour scheme of the chrome and the chart; changes go through `setTheme`. Default `dark`. */
|
|
71
|
+
theme: PropType<ShellTheme>;
|
|
72
|
+
/** Up and down colours; changes go through `setPalette`. */
|
|
73
|
+
palette: PropType<ShellPalette>;
|
|
74
|
+
/** Shell parts to show or hide; changes go through `applyFeatures` and are compared by value. */
|
|
75
|
+
features: PropType<Partial<ShellFeatures>>;
|
|
76
|
+
/** Shell events to listen to, keyed by event name, e.g. `{ 'theme:change': (e) => … }`. */
|
|
77
|
+
shellOn: PropType<ShellEventHandlers>;
|
|
78
|
+
options: PropType<import("@chart-on/core").ChartOptionsPatch>;
|
|
79
|
+
dataSource: PropType<import("@chart-on/core").DataSource | null>;
|
|
80
|
+
symbol: StringConstructor;
|
|
81
|
+
interval: PropType<import("@chart-on/core").Interval>;
|
|
82
|
+
on: PropType<ChartEventHandlers>;
|
|
83
|
+
}>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
package/dist/shell.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { a as e, c as t, i as n, l as r, n as i, o as a, r as o, s, t as c, u as l } from "./sync.js";
|
|
2
|
+
import { defineComponent as u, h as d, inject as f, markRaw as p, onActivated as m, onDeactivated as h, onMounted as g, onUnmounted as _, provide as v, shallowRef as y, watch as b } from "vue";
|
|
3
|
+
import { createChartShell as x } from "@chart-on/ui";
|
|
4
|
+
//#region src/shell.ts
|
|
5
|
+
var S = Symbol("charton-shell");
|
|
6
|
+
function C() {
|
|
7
|
+
return f(S, () => y(null), !0);
|
|
8
|
+
}
|
|
9
|
+
function w(e, t, r) {
|
|
10
|
+
let i = { ...n(e.shellOptions) };
|
|
11
|
+
return t && (i.chart = t), e.theme && (i.theme = e.theme), e.palette && (i.palette = e.palette), r && (i.features = r), i;
|
|
12
|
+
}
|
|
13
|
+
var T = u({
|
|
14
|
+
name: "ChartShell",
|
|
15
|
+
props: {
|
|
16
|
+
...c,
|
|
17
|
+
shellOptions: Object,
|
|
18
|
+
theme: String,
|
|
19
|
+
palette: String,
|
|
20
|
+
features: Object,
|
|
21
|
+
shellOn: Object
|
|
22
|
+
},
|
|
23
|
+
setup(c, { slots: u, expose: f }) {
|
|
24
|
+
let C = y(null), T = y(null), E = y(null), D = null;
|
|
25
|
+
return v(S, T), v(l, E), g(() => {
|
|
26
|
+
let r = e(c), i = n(c.features), a = p(x(C.value, w(c, r.options, i))), o = /* @__PURE__ */ new Map();
|
|
27
|
+
t(a, o, () => c.shellOn), D = {
|
|
28
|
+
shell: a,
|
|
29
|
+
engine: s(p(a.chart), r, () => c.on),
|
|
30
|
+
shellEvents: o,
|
|
31
|
+
features: i
|
|
32
|
+
}, T.value = a, E.value = a.chart;
|
|
33
|
+
}), m(() => D?.shell.chart.resize()), h(() => D?.shell.chart.resize()), _(() => {
|
|
34
|
+
D && (i(D.engine.events), i(D.shellEvents), D.shell.destroy(), D = null, T.value = null, E.value = null);
|
|
35
|
+
}), r(c, () => D?.engine ?? null), b(() => c.theme, (e) => e && D?.shell.setTheme(e)), b(() => c.palette, (e) => e && D?.shell.setPalette(e)), b(() => n(c.features), (e) => {
|
|
36
|
+
D && e && !a(e, D.features) && (D.shell.applyFeatures(e), D.features = e);
|
|
37
|
+
}), b(() => o(c.shellOn), () => D && t(D.shell, D.shellEvents, () => c.shellOn)), f({
|
|
38
|
+
shell: T,
|
|
39
|
+
chart: E
|
|
40
|
+
}), () => d("div", { ref: C }, u.default?.());
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
//#endregion
|
|
44
|
+
export { T as ChartShell, C as useChartShell };
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=shell.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shell.js","names":["readInputs","syncEvents","plainCopy","watchEngine","clearEvents","sameValue","handledNames","chartProps","chartKey","shellKey","useChartShell","inject","shallowRef","creationOptions","options","props","chart","features","ChartShell","defineComponent","element","shell","mounted","provide","onMounted","inputs","created","markRaw","createChartShell","shellEvents","startEngine","onActivated","onDeactivated","onUnmounted","watch","theme","palette","expose","h","slots"],"sources":["../src/shell.ts"],"sourcesContent":["import { defineComponent, h, inject, markRaw, onActivated, onDeactivated, onMounted, onUnmounted, provide, shallowRef, watch, type InjectionKey, type PropType, type ShallowRef } from 'vue';\nimport type { Chart } from '@chart-on/core';\nimport {\n createChartShell,\n type ChartShell as CoreShell,\n type ChartShellOptions,\n type ShellEvents,\n type ShellFeatures,\n type ShellPalette,\n type ShellTheme,\n} from '@chart-on/ui';\nimport { chartKey } from './context';\nimport { chartProps, clearEvents, handledNames, plainCopy, readInputs, sameValue, startEngine, syncEvents, watchEngine, type ChartEventHandlers, type ChartInputs, type Engine } from './sync';\n\n// Main entry types the props use, so this entry's typings name only what it exports.\nexport type { ChartEventHandlers, ChartInputs } from './sync';\n\n/** One callback per shell event the app listens to, keyed by event name. */\nexport type ShellEventHandlers = { [K in keyof ShellEvents]?: (payload: ShellEvents[K]) => void };\n\n/** Shell options that can only be chosen when the shell is created. */\nexport type ShellCreationOptions = Omit<ChartShellOptions, 'chart' | 'theme' | 'palette' | 'features'>;\n\nconst shellKey: InjectionKey<Readonly<ShallowRef<CoreShell | null>>> = Symbol('charton-shell');\n\n/**\n * The shell of the nearest enclosing `<ChartShell>`, as a ref. It holds null\n * on a server and until the shell has mounted, then the shell.\n */\nexport function useChartShell(): Readonly<ShallowRef<CoreShell | null>> {\n return inject(shellKey, () => shallowRef(null), true);\n}\n\n/** What a template ref on `<ChartShell>` reaches. */\nexport interface ChartShellExposed {\n /** The `ChartShell` while the component is mounted; null before, after and on a server. */\n readonly shell: CoreShell | null;\n /** The shell's chart, `shell.chart`, under the same conditions. */\n readonly chart: Chart | null;\n}\n\ninterface Mounted {\n shell: CoreShell;\n engine: Engine;\n shellEvents: Map<keyof ShellEvents, () => void>;\n /** The features last applied, to compare by value. */\n features?: Partial<ShellFeatures>;\n}\n\n/** The props of `<ChartShell>`, for apps that build them in code. */\nexport interface ChartShellProps extends ChartInputs {\n theme?: ShellTheme;\n palette?: ShellPalette;\n features?: Partial<ShellFeatures>;\n shellOptions?: ShellCreationOptions;\n on?: ChartEventHandlers;\n shellOn?: ShellEventHandlers;\n}\n\n/** The options `createChartShell` gets at mount, leaving out props that are not set. */\nfunction creationOptions(props: ChartShellProps, chart: ChartInputs['options'], features: ChartShellProps['features']): ChartShellOptions {\n const options: ChartShellOptions = { ...plainCopy(props.shellOptions) };\n if (chart) options.chart = chart;\n if (props.theme) options.theme = props.theme;\n if (props.palette) options.palette = props.palette;\n if (features) options.features = features;\n return options;\n}\n\n/**\n * The batteries-included widget: toolbar, drawing rail, bottom bar and the\n * chart, in a `div`. Import `@chart-on/ui/style.css` once in the app. The shell\n * is created when the component mounts and destroyed when it unmounts; prop\n * changes update it in place. `class`, `style` and other attributes go to the\n * `div`. The default slot renders inside it, where `useChart()` returns the\n * shell's chart and `useChartShell()` the shell.\n */\nexport const ChartShell = defineComponent({\n name: 'ChartShell',\n props: {\n ...chartProps,\n /**\n * Toolbar, rail, dialogs and the rest of the shell's set-up. Read once, when\n * the shell is created: to change them, remount the component on purpose,\n * for example with a new `key`.\n */\n shellOptions: Object as PropType<ShellCreationOptions>,\n /** Colour scheme of the chrome and the chart; changes go through `setTheme`. Default `dark`. */\n theme: String as PropType<ShellTheme>,\n /** Up and down colours; changes go through `setPalette`. */\n palette: String as PropType<ShellPalette>,\n /** Shell parts to show or hide; changes go through `applyFeatures` and are compared by value. */\n features: Object as PropType<Partial<ShellFeatures>>,\n /** Shell events to listen to, keyed by event name, e.g. `{ 'theme:change': (e) => … }`. */\n shellOn: Object as PropType<ShellEventHandlers>,\n },\n setup(props, { slots, expose }) {\n const element = shallowRef<HTMLDivElement | null>(null);\n const shell = shallowRef<CoreShell | null>(null);\n const chart = shallowRef<Chart | null>(null);\n let mounted: Mounted | null = null;\n provide(shellKey, shell);\n provide(chartKey, chart);\n\n // Mount: runs only in the browser, never during server rendering.\n onMounted(() => {\n const inputs = readInputs(props);\n const features = plainCopy(props.features);\n // Kept out of reactivity: the shell and its chart are large mutable objects.\n const created = markRaw(createChartShell(element.value!, creationOptions(props, inputs.options, features)));\n const shellEvents = new Map<keyof ShellEvents, () => void>();\n syncEvents(created, shellEvents, () => props.shellOn);\n mounted = { shell: created, engine: startEngine(markRaw(created.chart), inputs, () => props.on), shellEvents, features };\n shell.value = created;\n chart.value = created.chart;\n });\n\n // Inside a kept-alive branch: measure when taken out of the page and when put back.\n onActivated(() => mounted?.shell.chart.resize());\n onDeactivated(() => mounted?.shell.chart.resize());\n\n // Unmount: after the slot content has unmounted, so its clean-up still sees a live shell.\n onUnmounted(() => {\n if (!mounted) return;\n clearEvents(mounted.engine.events);\n clearEvents(mounted.shellEvents);\n mounted.shell.destroy();\n mounted = null;\n shell.value = null;\n chart.value = null;\n });\n\n // Updates: apply what changed since the last time, never through a new shell. Like every\n // prop, a theme, palette or features left out or set to `undefined` leaves the shell as it is.\n watchEngine(props, () => mounted?.engine ?? null);\n watch(\n () => props.theme,\n (theme) => theme && mounted?.shell.setTheme(theme),\n );\n watch(\n () => props.palette,\n (palette) => palette && mounted?.shell.setPalette(palette),\n );\n watch(\n () => plainCopy(props.features),\n (features) => {\n if (!mounted || !features || sameValue(features, mounted.features)) return;\n mounted.shell.applyFeatures(features);\n mounted.features = features;\n },\n );\n watch(\n () => handledNames(props.shellOn),\n () => mounted && syncEvents(mounted.shell, mounted.shellEvents, () => props.shellOn),\n );\n\n expose({ shell, chart });\n return () => h('div', { ref: element }, slots.default?.());\n },\n});\n"],"mappings":";;;;AAuBA,IAAMS,IAAiE,OAAO,eAAe;AAM7F,SAAgBC,IAAwD;CACtE,OAAOC,EAAOF,SAAgBG,EAAW,IAAI,GAAG,EAAI;AACtD;AA6BA,SAASC,EAAgB,GAAwB,GAA+B,GAA0D;CACxI,IAAMC,IAA6B,EAAE,GAAGZ,EAAUa,EAAM,YAAY,EAAE;CAKtE,OAJIC,MAAO,EAAQ,QAAQA,IACvBD,EAAM,UAAO,EAAQ,QAAQA,EAAM,QACnCA,EAAM,YAAS,EAAQ,UAAUA,EAAM,UACvCE,MAAU,EAAQ,WAAWA,IAC1BH;AACT;AAUA,IAAaI,IAAaC,EAAgB;CACxC,MAAM;CACN,OAAO;EACL,GAAGZ;EAMH,cAAc;EAEd,OAAO;EAEP,SAAS;EAET,UAAU;EAEV,SAAS;CACX;CACA,MAAM,GAAO,EAAE,UAAO,aAAU;EAC9B,IAAMa,IAAUR,EAAkC,IAAI,GAChDS,IAAQT,EAA6B,IAAI,GACzCI,IAAQJ,EAAyB,IAAI,GACvCU,IAA0B;EAyD9B,OAxDAC,EAAQd,GAAUY,CAAK,GACvBE,EAAQf,GAAUQ,CAAK,GAGvBQ,QAAgB;GACd,IAAMC,IAASzB,EAAWe,CAAK,GACzBE,IAAWf,EAAUa,EAAM,QAAQ,GAEnCW,IAAUC,EAAQC,EAAiBR,EAAQ,OAAQP,EAAgBE,GAAOU,EAAO,SAASR,CAAQ,CAAC,CAAC,GACpGY,oBAAc,IAAI,IAAmC;GAI3D,AAHA5B,EAAWyB,GAASG,SAAmBd,EAAM,OAAO,GACpD,IAAU;IAAE,OAAOW;IAAS,QAAQI,EAAYH,EAAQD,EAAQ,KAAK,GAAGD,SAAcV,EAAM,EAAE;IAAG;IAAa;GAAS,GACvH,EAAM,QAAQW,GACd,EAAM,QAAQA,EAAQ;EACxB,CAAC,GAGDK,QAAkBT,GAAS,MAAM,MAAM,OAAO,CAAC,GAC/CU,QAAoBV,GAAS,MAAM,MAAM,OAAO,CAAC,GAGjDW,QAAkB;GAChB,AAAKX,MACLlB,EAAYkB,EAAQ,OAAO,MAAM,GACjClB,EAAYkB,EAAQ,WAAW,GAC/BA,EAAQ,MAAM,QAAQ,GACtB,IAAU,MACV,EAAM,QAAQ,MACd,EAAM,QAAQ;EAChB,CAAC,GAIDnB,EAAYY,SAAaO,GAAS,UAAU,IAAI,GAChDY,QACQnB,EAAM,QACX,MAAUoB,KAASb,GAAS,MAAM,SAASa,CAAK,CACnD,GACAD,QACQnB,EAAM,UACX,MAAYqB,KAAWd,GAAS,MAAM,WAAWc,CAAO,CAC3D,GACAF,QACQhC,EAAUa,EAAM,QAAQ,IAC7B,MAAa;GACZ,AAAKO,KAAYL,KAAY,GAAUA,GAAUK,EAAQ,QAAQ,MACjEA,EAAQ,MAAM,cAAcL,CAAQ,GACpC,EAAQ,WAAWA;EACrB,CACF,GACAiB,QACQ5B,EAAaS,EAAM,OAAO,SAC1BO,KAAWrB,EAAWqB,EAAQ,OAAOA,EAAQ,mBAAmBP,EAAM,OAAO,CACrF,GAEAsB,EAAO;GAAE;GAAO;EAAM,CAAC,SACVC,EAAE,OAAO,EAAE,KAAKlB,EAAQ,GAAGmB,EAAM,UAAU,CAAC;CAC3D;AACF,CAAC"}
|
package/dist/sync.d.ts
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { type PropType } from 'vue';
|
|
2
|
+
import type { Chart, ChartEvents, ChartOptionsPatch, DataSource, Interval } from '@chart-on/core';
|
|
3
|
+
/** One callback per chart event the app listens to, keyed by the chart's own `noun:verb` names. */
|
|
4
|
+
export type ChartEventHandlers = {
|
|
5
|
+
[K in keyof ChartEvents]?: (payload: ChartEvents[K]) => void;
|
|
6
|
+
};
|
|
7
|
+
/** The props both components hand to the engine. */
|
|
8
|
+
export interface ChartInputs {
|
|
9
|
+
/**
|
|
10
|
+
* Chart options. Given to the chart when it is created, then applied with
|
|
11
|
+
* `applyOptions` whenever they change, including changes made inside a
|
|
12
|
+
* reactive object. Plain data in them is compared by value, so an object
|
|
13
|
+
* literal written in the template does not apply again on every render.
|
|
14
|
+
* Functions, dates and class instances are compared by identity: a formatter
|
|
15
|
+
* written inline in the template is new on every render and applies the
|
|
16
|
+
* options again each time, so define callbacks once in the script.
|
|
17
|
+
*/
|
|
18
|
+
options?: ChartOptionsPatch;
|
|
19
|
+
/**
|
|
20
|
+
* Where bars come from. Changing it attaches the new source and loads
|
|
21
|
+
* `symbol` again; `null` detaches it. Like every prop, leaving it out or
|
|
22
|
+
* setting it to `undefined` leaves the chart as it is. The chart needs the
|
|
23
|
+
* `dataSource()` plugin in `options.plugins` (or `builtins()`); without it
|
|
24
|
+
* the source is not attached and development builds warn once
|
|
25
|
+
* (`data-source-missing`).
|
|
26
|
+
*/
|
|
27
|
+
dataSource?: DataSource | null;
|
|
28
|
+
/** Symbol to load from `dataSource`; loads once both it and `interval` are set. */
|
|
29
|
+
symbol?: string;
|
|
30
|
+
interval?: Interval;
|
|
31
|
+
}
|
|
32
|
+
/** Props both components share: the engine inputs and the chart event callbacks. */
|
|
33
|
+
export declare const chartProps: {
|
|
34
|
+
options: PropType<ChartOptionsPatch>;
|
|
35
|
+
dataSource: PropType<DataSource | null>;
|
|
36
|
+
symbol: StringConstructor;
|
|
37
|
+
interval: PropType<Interval>;
|
|
38
|
+
/**
|
|
39
|
+
* Chart events to listen to, keyed by event name, e.g.
|
|
40
|
+
* `{ 'crosshair:move': (e) => … }`. Only the events listed here are
|
|
41
|
+
* subscribed. A new callback for the same event is used without subscribing
|
|
42
|
+
* again.
|
|
43
|
+
*/
|
|
44
|
+
on: PropType<ChartEventHandlers>;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* A plain copy of `value` without reactive proxies: arrays and plain objects
|
|
48
|
+
* are copied, anything else (functions, class instances) is kept as it is. An
|
|
49
|
+
* object met again inside itself becomes the copy being built, so the copy has
|
|
50
|
+
* the same cycles and never points back into the original. Reading every
|
|
51
|
+
* nested property also makes a watcher track all of them, so changes inside a
|
|
52
|
+
* reactive options object are seen too.
|
|
53
|
+
*/
|
|
54
|
+
export declare function plainCopy<T>(value: T, building?: Map<object, object>): T;
|
|
55
|
+
/**
|
|
56
|
+
* Structural equality for plain data: primitives, arrays and plain objects are
|
|
57
|
+
* compared by content, anything else (functions, class instances) by identity.
|
|
58
|
+
* Cycles are equal when they lead back to the same place on both sides.
|
|
59
|
+
*/
|
|
60
|
+
export declare function sameValue(a: unknown, b: unknown, comparing?: Map<object, object>): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* The engine inputs of `props` as plain values: the options copied out of any
|
|
63
|
+
* reactive proxy, the data source unwrapped, so the engine never holds a
|
|
64
|
+
* proxy and a reactive source keeps its identity.
|
|
65
|
+
*/
|
|
66
|
+
export declare function readInputs(props: ChartInputs): ChartInputs;
|
|
67
|
+
/** A mounted chart and what the component last brought it in line with. */
|
|
68
|
+
export interface Engine {
|
|
69
|
+
chart: Chart;
|
|
70
|
+
inputs: ChartInputs;
|
|
71
|
+
events: Map<keyof ChartEvents, () => void>;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Create the engine state for a chart just made with `inputs.options`: listen
|
|
75
|
+
* first, because loading the symbol emits events straight away, then load.
|
|
76
|
+
*/
|
|
77
|
+
export declare function startEngine(chart: Chart, inputs: ChartInputs, on: () => ChartEventHandlers | undefined): Engine;
|
|
78
|
+
/**
|
|
79
|
+
* Watch the engine props and apply what changed to the mounted chart. The
|
|
80
|
+
* options are copied and compared only when something inside them changed,
|
|
81
|
+
* not on every change of another prop.
|
|
82
|
+
*/
|
|
83
|
+
export declare function watchEngine(props: ChartInputs & {
|
|
84
|
+
on?: ChartEventHandlers;
|
|
85
|
+
}, engine: () => Engine | null): void;
|
|
86
|
+
/**
|
|
87
|
+
* Bring a chart in line with `next`, calling only the methods whose input
|
|
88
|
+
* changed since `last`. Pass `last: null` right after creating the chart with
|
|
89
|
+
* `next.options`, so the options are not applied twice.
|
|
90
|
+
*/
|
|
91
|
+
export declare function syncChart(chart: Chart, last: ChartInputs | null, next: ChartInputs): void;
|
|
92
|
+
/** Something with the chart's `on(name, listener)` subscription shape. */
|
|
93
|
+
export interface Subscribable<Events> {
|
|
94
|
+
on<K extends keyof Events>(event: K, listener: (payload: Events[K]) => void): () => void;
|
|
95
|
+
}
|
|
96
|
+
type Handlers<Events> = {
|
|
97
|
+
[K in keyof Events]?: (payload: Events[K]) => void;
|
|
98
|
+
};
|
|
99
|
+
/** The event names in `handlers` that have a callback, as a key a watcher can compare. */
|
|
100
|
+
export declare function handledNames(handlers: object | undefined): string;
|
|
101
|
+
/**
|
|
102
|
+
* Keep one subscription per event name that has a callback in `latest()`:
|
|
103
|
+
* subscribe names that appeared, unsubscribe names that went away. Each
|
|
104
|
+
* listener calls whatever callback `latest()` holds when the event fires, so a
|
|
105
|
+
* new callback for the same event takes effect without subscribing again.
|
|
106
|
+
*/
|
|
107
|
+
export declare function syncEvents<Events>(target: Subscribable<Events>, subscriptions: Map<keyof Events, () => void>, latest: () => Handlers<Events> | undefined): void;
|
|
108
|
+
/** Call and forget every subscription in `subscriptions`. */
|
|
109
|
+
export declare function clearEvents(subscriptions: Map<unknown, () => void>): void;
|
|
110
|
+
export {};
|
package/dist/sync.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { inject as e, shallowRef as t, toRaw as n, watch as r } from "vue";
|
|
2
|
+
import { ERRORS_DOCS_URL as i } from "@chart-on/core";
|
|
3
|
+
//#region src/context.ts
|
|
4
|
+
var a = Symbol("charton-chart");
|
|
5
|
+
function o() {
|
|
6
|
+
return e(a, () => t(null), !0);
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/sync.ts
|
|
10
|
+
var s = {
|
|
11
|
+
options: Object,
|
|
12
|
+
dataSource: Object,
|
|
13
|
+
symbol: String,
|
|
14
|
+
interval: String,
|
|
15
|
+
on: Object
|
|
16
|
+
};
|
|
17
|
+
function c(e) {
|
|
18
|
+
let t = Object.getPrototypeOf(e);
|
|
19
|
+
return t === Object.prototype || t === null;
|
|
20
|
+
}
|
|
21
|
+
function l(e, t = /* @__PURE__ */ new Map()) {
|
|
22
|
+
let r = n(e);
|
|
23
|
+
if (typeof r != "object" || !r || !(Array.isArray(r) || c(r))) return r;
|
|
24
|
+
let i = t.get(r);
|
|
25
|
+
if (i) return i;
|
|
26
|
+
let a = e, o = Array.isArray(r) ? [] : {};
|
|
27
|
+
t.set(r, o);
|
|
28
|
+
for (let e of Object.keys(a)) o[e] = l(a[e], t);
|
|
29
|
+
return t.delete(r), o;
|
|
30
|
+
}
|
|
31
|
+
function u(e, t, n = /* @__PURE__ */ new Map()) {
|
|
32
|
+
if (Object.is(e, t)) return !0;
|
|
33
|
+
if (typeof e != "object" || typeof t != "object" || e === null || t === null) return !1;
|
|
34
|
+
if (n.has(e)) return n.get(e) === t;
|
|
35
|
+
if (Array.isArray(e) !== Array.isArray(t) || !(Array.isArray(e) || c(e) && c(t))) return !1;
|
|
36
|
+
let r = Object.keys(e);
|
|
37
|
+
if (r.length !== Object.keys(t).length) return !1;
|
|
38
|
+
n.set(e, t);
|
|
39
|
+
let i = r.every((r) => Object.hasOwn(t, r) && u(e[r], t[r], n));
|
|
40
|
+
return n.delete(e), i;
|
|
41
|
+
}
|
|
42
|
+
function d(e) {
|
|
43
|
+
return {
|
|
44
|
+
options: l(e.options),
|
|
45
|
+
dataSource: n(e.dataSource),
|
|
46
|
+
symbol: e.symbol,
|
|
47
|
+
interval: e.interval
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function f(e, t, n) {
|
|
51
|
+
let r = {
|
|
52
|
+
chart: e,
|
|
53
|
+
inputs: t,
|
|
54
|
+
events: /* @__PURE__ */ new Map()
|
|
55
|
+
};
|
|
56
|
+
return v(e, r.events, n), g(e, null, t), r;
|
|
57
|
+
}
|
|
58
|
+
function p(e, t) {
|
|
59
|
+
let i = (e) => {
|
|
60
|
+
let n = t();
|
|
61
|
+
if (!n) return;
|
|
62
|
+
let r = { ...n.inputs };
|
|
63
|
+
for (let [t, n] of Object.entries(e)) n !== void 0 && (r[t] = n);
|
|
64
|
+
g(n.chart, n.inputs, r), n.inputs = r;
|
|
65
|
+
};
|
|
66
|
+
r(() => l(e.options), (e) => i({ options: e })), r([
|
|
67
|
+
() => n(e.dataSource),
|
|
68
|
+
() => e.symbol,
|
|
69
|
+
() => e.interval
|
|
70
|
+
], ([e, t, n]) => i({
|
|
71
|
+
dataSource: e,
|
|
72
|
+
symbol: t,
|
|
73
|
+
interval: n
|
|
74
|
+
})), r(() => _(e.on), () => {
|
|
75
|
+
let n = t();
|
|
76
|
+
n && v(n.chart, n.events, () => e.on);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
var m = !1;
|
|
80
|
+
function h(e, t) {
|
|
81
|
+
try {
|
|
82
|
+
e.setDataSource(t);
|
|
83
|
+
} catch (e) {
|
|
84
|
+
if (e?.code !== "not-registered") throw e;
|
|
85
|
+
try {
|
|
86
|
+
process.env.NODE_ENV !== "production" && !m && (m = !0, console.warn(`charton [data-source-missing]: the dataSource prop needs the dataSource() plugin; pass plugins: [dataSource()] (or builtins()) in options (${i}#data-source-missing)`));
|
|
87
|
+
} catch {}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
function g(e, t, n) {
|
|
91
|
+
t && n.options && !u(t.options, n.options) && e.applyOptions(n.options);
|
|
92
|
+
let r = n.dataSource !== void 0 && (t === null || n.dataSource !== t.dataSource);
|
|
93
|
+
r && h(e, n.dataSource ?? null);
|
|
94
|
+
let i = n.symbol !== t?.symbol || n.interval !== t?.interval;
|
|
95
|
+
n.dataSource && n.symbol && n.interval && (r || i) && e.setSymbol(n.symbol, n.interval).catch(() => {});
|
|
96
|
+
}
|
|
97
|
+
function _(e) {
|
|
98
|
+
return e ? Object.keys(e).filter((t) => e[t]).sort().join("\n") : "";
|
|
99
|
+
}
|
|
100
|
+
function v(e, t, n) {
|
|
101
|
+
let r = n();
|
|
102
|
+
for (let [e, n] of t) r?.[e] || (n(), t.delete(e));
|
|
103
|
+
for (let i of Object.keys(r ?? {})) !t.has(i) && r?.[i] && t.set(i, e.on(i, (e) => n()?.[i]?.(e)));
|
|
104
|
+
}
|
|
105
|
+
function y(e) {
|
|
106
|
+
for (let t of e.values()) t();
|
|
107
|
+
e.clear();
|
|
108
|
+
}
|
|
109
|
+
//#endregion
|
|
110
|
+
export { d as a, v as c, o as d, l as i, p as l, y as n, u as o, _ as r, f as s, s as t, a as u };
|
|
111
|
+
|
|
112
|
+
//# sourceMappingURL=sync.js.map
|
package/dist/sync.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sync.js","names":["chartKey","useChart","inject","shallowRef","chartProps","isPlain","proto","value","plainCopy","raw","toRaw","cycle","building","source","copy","key","sameValue","a","b","comparing","keys","same","readInputs","props","startEngine","engine","syncEvents","chart","on","syncChart","inputs","watchEngine","apply","state","next","patch","watch","dataSource","symbol","interval","handledNames","warnedNoPlugin","attachSource","error","ERRORS_DOCS_URL","last","sourceChanged","symbolChanged","handlers","name","latest","off","subscriptions","target","payload","clearEvents"],"sources":["../src/context.ts","../src/sync.ts"],"sourcesContent":["import { inject, shallowRef, type InjectionKey, type ShallowRef } from 'vue';\nimport type { Chart } from '@chart-on/core';\n\n/** The chart of the nearest `<Chart>` or `<ChartShell>`; null before mount and on a server. */\nexport const chartKey: InjectionKey<Readonly<ShallowRef<Chart | null>>> = Symbol('charton-chart');\n\n/**\n * The chart of the nearest enclosing `<Chart>` or `<ChartShell>`, as a ref. It\n * holds null during server rendering and until the component has mounted,\n * then the chart, so a `watch` on it runs once the chart exists. Outside a\n * chart component it always holds null.\n */\nexport function useChart(): Readonly<ShallowRef<Chart | null>> {\n return inject(chartKey, () => shallowRef(null), true);\n}\n","import { toRaw, watch, type PropType } from 'vue';\nimport { ERRORS_DOCS_URL } from '@chart-on/core';\nimport type { Chart, ChartEvents, ChartOptionsPatch, DataSource, Interval } from '@chart-on/core';\n\n/** One callback per chart event the app listens to, keyed by the chart's own `noun:verb` names. */\nexport type ChartEventHandlers = { [K in keyof ChartEvents]?: (payload: ChartEvents[K]) => void };\n\n/** The props both components hand to the engine. */\nexport interface ChartInputs {\n /**\n * Chart options. Given to the chart when it is created, then applied with\n * `applyOptions` whenever they change, including changes made inside a\n * reactive object. Plain data in them is compared by value, so an object\n * literal written in the template does not apply again on every render.\n * Functions, dates and class instances are compared by identity: a formatter\n * written inline in the template is new on every render and applies the\n * options again each time, so define callbacks once in the script.\n */\n options?: ChartOptionsPatch;\n /**\n * Where bars come from. Changing it attaches the new source and loads\n * `symbol` again; `null` detaches it. Like every prop, leaving it out or\n * setting it to `undefined` leaves the chart as it is. The chart needs the\n * `dataSource()` plugin in `options.plugins` (or `builtins()`); without it\n * the source is not attached and development builds warn once\n * (`data-source-missing`).\n */\n dataSource?: DataSource | null;\n /** Symbol to load from `dataSource`; loads once both it and `interval` are set. */\n symbol?: string;\n interval?: Interval;\n}\n\n/** Props both components share: the engine inputs and the chart event callbacks. */\nexport const chartProps = {\n options: Object as PropType<ChartOptionsPatch>,\n dataSource: Object as PropType<DataSource | null>,\n symbol: String,\n interval: String as PropType<Interval>,\n /**\n * Chart events to listen to, keyed by event name, e.g.\n * `{ 'crosshair:move': (e) => … }`. Only the events listed here are\n * subscribed. A new callback for the same event is used without subscribing\n * again.\n */\n on: Object as PropType<ChartEventHandlers>,\n};\n\nfunction isPlain(value: object): boolean {\n const proto = Object.getPrototypeOf(value);\n return proto === Object.prototype || proto === null;\n}\n\n/**\n * A plain copy of `value` without reactive proxies: arrays and plain objects\n * are copied, anything else (functions, class instances) is kept as it is. An\n * object met again inside itself becomes the copy being built, so the copy has\n * the same cycles and never points back into the original. Reading every\n * nested property also makes a watcher track all of them, so changes inside a\n * reactive options object are seen too.\n */\nexport function plainCopy<T>(value: T, building = new Map<object, object>()): T {\n const raw = toRaw(value);\n if (typeof raw !== 'object' || raw === null || !(Array.isArray(raw) || isPlain(raw))) return raw;\n const cycle = building.get(raw);\n if (cycle) return cycle as T;\n const source = value as Record<string, unknown>;\n const copy = (Array.isArray(raw) ? [] : {}) as Record<string, unknown>;\n building.set(raw, copy);\n for (const key of Object.keys(source)) copy[key] = plainCopy(source[key], building);\n building.delete(raw);\n return copy as T;\n}\n\n/**\n * Structural equality for plain data: primitives, arrays and plain objects are\n * compared by content, anything else (functions, class instances) by identity.\n * Cycles are equal when they lead back to the same place on both sides.\n */\nexport function sameValue(a: unknown, b: unknown, comparing = new Map<object, object>()): boolean {\n if (Object.is(a, b)) return true;\n if (typeof a !== 'object' || typeof b !== 'object' || a === null || b === null) return false;\n if (comparing.has(a)) return comparing.get(a) === b;\n if (Array.isArray(a) !== Array.isArray(b) || !(Array.isArray(a) || (isPlain(a) && isPlain(b)))) return false;\n const keys = Object.keys(a);\n if (keys.length !== Object.keys(b).length) return false;\n comparing.set(a, b);\n const same = keys.every((key) => Object.hasOwn(b, key) && sameValue((a as Record<string, unknown>)[key], (b as Record<string, unknown>)[key], comparing));\n comparing.delete(a);\n return same;\n}\n\n/**\n * The engine inputs of `props` as plain values: the options copied out of any\n * reactive proxy, the data source unwrapped, so the engine never holds a\n * proxy and a reactive source keeps its identity.\n */\nexport function readInputs(props: ChartInputs): ChartInputs {\n return { options: plainCopy(props.options), dataSource: toRaw(props.dataSource), symbol: props.symbol, interval: props.interval };\n}\n\n/** A mounted chart and what the component last brought it in line with. */\nexport interface Engine {\n chart: Chart;\n inputs: ChartInputs;\n events: Map<keyof ChartEvents, () => void>;\n}\n\n/**\n * Create the engine state for a chart just made with `inputs.options`: listen\n * first, because loading the symbol emits events straight away, then load.\n */\nexport function startEngine(chart: Chart, inputs: ChartInputs, on: () => ChartEventHandlers | undefined): Engine {\n const engine: Engine = { chart, inputs, events: new Map() };\n syncEvents(chart, engine.events, on);\n syncChart(chart, null, inputs);\n return engine;\n}\n\n/**\n * Watch the engine props and apply what changed to the mounted chart. The\n * options are copied and compared only when something inside them changed,\n * not on every change of another prop.\n */\nexport function watchEngine(props: ChartInputs & { on?: ChartEventHandlers }, engine: () => Engine | null): void {\n const apply = (patch: ChartInputs) => {\n const state = engine();\n if (!state) return;\n // An input set to `undefined` keeps its last value, so a new symbol still loads from the\n // last source after the source prop is left out.\n const next = { ...state.inputs };\n for (const [key, value] of Object.entries(patch) as [keyof ChartInputs, never][]) if (value !== undefined) next[key] = value;\n syncChart(state.chart, state.inputs, next);\n state.inputs = next;\n };\n watch(() => plainCopy(props.options), (options) => apply({ options }));\n watch([() => toRaw(props.dataSource), () => props.symbol, () => props.interval], ([dataSource, symbol, interval]) => apply({ dataSource, symbol, interval }));\n watch(\n () => handledNames(props.on),\n () => {\n const state = engine();\n if (state) syncEvents(state.chart, state.events, () => props.on);\n },\n );\n}\n\n// Bundlers replace `process.env.NODE_ENV` in production builds. Declared here,\n// module-local, so it never clashes with Node's own typings.\ndeclare const process: { env: { NODE_ENV?: string } };\n\nlet warnedNoPlugin = false;\n\n/**\n * Attach `source`. A chart created without the `dataSource()` plugin cannot\n * load from one; that is not worth tearing the component down for, so it is\n * reported once in development builds instead of thrown.\n */\nfunction attachSource(chart: Chart, source: DataSource | null): void {\n try {\n chart.setDataSource(source);\n } catch (error) {\n if ((error as { code?: unknown } | null)?.code !== 'not-registered') throw error;\n try {\n if (process.env.NODE_ENV !== 'production' && !warnedNoPlugin) {\n warnedNoPlugin = true;\n console.warn(\n `charton [data-source-missing]: the dataSource prop needs the dataSource() plugin; pass plugins: [dataSource()] (or builtins()) in options (${ERRORS_DOCS_URL}#data-source-missing)`,\n );\n }\n } catch {\n // No `process` (loaded without a bundler): stay quiet.\n }\n }\n}\n\n/**\n * Bring a chart in line with `next`, calling only the methods whose input\n * changed since `last`. Pass `last: null` right after creating the chart with\n * `next.options`, so the options are not applied twice.\n */\nexport function syncChart(chart: Chart, last: ChartInputs | null, next: ChartInputs): void {\n if (last && next.options && !sameValue(last.options, next.options)) chart.applyOptions(next.options);\n const sourceChanged = next.dataSource !== undefined && (last === null || next.dataSource !== last.dataSource);\n if (sourceChanged) attachSource(chart, next.dataSource ?? null);\n const symbolChanged = next.symbol !== last?.symbol || next.interval !== last?.interval;\n if (next.dataSource && next.symbol && next.interval && (sourceChanged || symbolChanged)) {\n // A failed load also emits `data:error`, which is how the app hears about it; a load\n // overtaken by the next symbol or by unmounting rejects too, and needs no handling.\n chart.setSymbol(next.symbol, next.interval).catch(() => {});\n }\n}\n\n/** Something with the chart's `on(name, listener)` subscription shape. */\nexport interface Subscribable<Events> {\n on<K extends keyof Events>(event: K, listener: (payload: Events[K]) => void): () => void;\n}\n\ntype Handlers<Events> = { [K in keyof Events]?: (payload: Events[K]) => void };\n\n/** The event names in `handlers` that have a callback, as a key a watcher can compare. */\nexport function handledNames(handlers: object | undefined): string {\n if (!handlers) return '';\n return Object.keys(handlers)\n .filter((name) => (handlers as Record<string, unknown>)[name])\n .sort()\n .join('\\n');\n}\n\n/**\n * Keep one subscription per event name that has a callback in `latest()`:\n * subscribe names that appeared, unsubscribe names that went away. Each\n * listener calls whatever callback `latest()` holds when the event fires, so a\n * new callback for the same event takes effect without subscribing again.\n */\nexport function syncEvents<Events>(\n target: Subscribable<Events>,\n subscriptions: Map<keyof Events, () => void>,\n latest: () => Handlers<Events> | undefined,\n): void {\n const handlers = latest();\n for (const [name, off] of subscriptions) {\n if (handlers?.[name]) continue;\n off();\n subscriptions.delete(name);\n }\n for (const name of Object.keys(handlers ?? {}) as (keyof Events)[]) {\n if (subscriptions.has(name) || !handlers?.[name]) continue;\n subscriptions.set(\n name,\n target.on(name, (payload) => latest()?.[name]?.(payload)),\n );\n }\n}\n\n/** Call and forget every subscription in `subscriptions`. */\nexport function clearEvents(subscriptions: Map<unknown, () => void>): void {\n for (const off of subscriptions.values()) off();\n subscriptions.clear();\n}\n"],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,69 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chart-on/vue",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Components and composables that mount @chart-on/core charts and @chart-on/ui shells in Vue apps, with server rendering support.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/chart-on/chart-on.git",
|
|
9
|
+
"directory": "packages/vue"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/chart-on/chart-on#readme",
|
|
12
|
+
"bugs": "https://github.com/chart-on/chart-on/issues",
|
|
13
|
+
"type": "module",
|
|
14
|
+
"sideEffects": false,
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=22"
|
|
17
|
+
},
|
|
18
|
+
"browserslist": [
|
|
19
|
+
"chrome >= 111",
|
|
20
|
+
"edge >= 111",
|
|
21
|
+
"firefox >= 114",
|
|
22
|
+
"safari >= 16.4",
|
|
23
|
+
"ios_saf >= 16.4"
|
|
24
|
+
],
|
|
25
|
+
"main": "./dist/index.js",
|
|
26
|
+
"types": "./dist/index.d.ts",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"import": "./dist/index.js",
|
|
31
|
+
"default": "./dist/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./shell": {
|
|
34
|
+
"types": "./dist/shell.d.ts",
|
|
35
|
+
"import": "./dist/shell.js",
|
|
36
|
+
"default": "./dist/shell.js"
|
|
37
|
+
},
|
|
38
|
+
"./package.json": "./package.json"
|
|
39
|
+
},
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public"
|
|
42
|
+
},
|
|
43
|
+
"files": [
|
|
44
|
+
"dist",
|
|
45
|
+
"README.md",
|
|
46
|
+
"LICENSE",
|
|
47
|
+
"NOTICE"
|
|
48
|
+
],
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"vue": "^3.5.0",
|
|
51
|
+
"@chart-on/core": "^0.1.0",
|
|
52
|
+
"@chart-on/ui": "^0.1.0"
|
|
53
|
+
},
|
|
54
|
+
"peerDependenciesMeta": {
|
|
55
|
+
"@chart-on/ui": {
|
|
56
|
+
"optional": true
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"happy-dom": "^21.0.1",
|
|
61
|
+
"vue": "^3.5.0",
|
|
62
|
+
"@chart-on/core": "^0.1.0",
|
|
63
|
+
"@chart-on/ui": "^0.1.0"
|
|
64
|
+
},
|
|
65
|
+
"scripts": {
|
|
66
|
+
"build": "vite build && tsc -p tsconfig.build.json",
|
|
67
|
+
"typecheck": "tsc -p ."
|
|
68
|
+
}
|
|
6
69
|
}
|