mirror of
https://github.com/chartjs/Chart.js
synced 2025-04-29 15:57:22 +08:00
fix: move types to src dir to escape src / dist dirs in paths (#10993)
This commit is contained in:
parent
bc84a98ec6
commit
64a027874c
3
.github/workflows/ci.yml
vendored
3
.github/workflows/ci.yml
vendored
@ -52,7 +52,6 @@ jobs:
|
||||
- 'karma.conf.js'
|
||||
- 'package.json'
|
||||
types:
|
||||
- 'types/**'
|
||||
- 'package.json'
|
||||
- 'tsconfig.json'
|
||||
- name: Install
|
||||
@ -64,7 +63,7 @@ jobs:
|
||||
- name: Test
|
||||
if: |
|
||||
(steps.changes.outputs.src == 'true' ||
|
||||
steps.changes.outputs.test == 'true') &&
|
||||
steps.changes.outputs.test == 'true') &&
|
||||
runner.os != 'Windows'
|
||||
run: |
|
||||
pnpm run build
|
||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -31,7 +31,7 @@ docs/.vuepress/dist
|
||||
*.stackdump
|
||||
|
||||
# Generated
|
||||
/types/tests/autogen*.ts
|
||||
/test/types/autogen*.ts
|
||||
|
||||
# Eslint
|
||||
.eslintcache
|
||||
|
@ -34,7 +34,7 @@ export default defineConfig({
|
||||
}],
|
||||
['vuepress-plugin-code-copy', true],
|
||||
['vuepress-plugin-typedoc', {
|
||||
entryPoints: ['../../types/index.d.ts'],
|
||||
entryPoints: ['../../src/types/index.d.ts'],
|
||||
hideInPageTOC: true,
|
||||
tsconfig: path.resolve(__dirname, '../../tsconfig.json'),
|
||||
},
|
||||
|
@ -50,13 +50,11 @@
|
||||
"auto/**",
|
||||
"dist/**",
|
||||
"!dist/docs/**",
|
||||
"helpers/**",
|
||||
"types/**/*.ts",
|
||||
"!types/tests/**"
|
||||
"helpers/**"
|
||||
],
|
||||
"scripts": {
|
||||
"autobuild": "rollup -c -w",
|
||||
"emitDeclarations": "tsc --emitDeclarationOnly",
|
||||
"emitDeclarations": "tsc --emitDeclarationOnly && cp -R ./src/types/ ./dist/types/",
|
||||
"build": "rollup -c && pnpm emitDeclarations",
|
||||
"dev": "karma start ./karma.conf.cjs --auto-watch --no-single-run --browsers chrome --grep",
|
||||
"dev:ff": "karma start ./karma.conf.cjs --auto-watch --no-single-run --browsers firefox --grep",
|
||||
@ -64,7 +62,7 @@
|
||||
"docs:dev": "pnpm run build && pnpm --filter \"./docs/**\" dev",
|
||||
"lint-js": "eslint \"src/**/*.{js,ts}\" \"test/**/*.js\" \"docs/**/*.js\" --cache",
|
||||
"lint-md": "eslint \"**/*.md\" --cache",
|
||||
"lint-types": "eslint \"types/**/*.ts\" --cache && pnpm build && node types/tests/autogen.js && tsc -p types/tests/",
|
||||
"lint-types": "pnpm build && node test/types/autogen.js && tsc -p test/types",
|
||||
"lint": "concurrently \"pnpm:lint-*\"",
|
||||
"test-size": "size-limit",
|
||||
"test": "pnpm lint && pnpm test-ci",
|
||||
|
@ -4,8 +4,8 @@
|
||||
* @private
|
||||
*/
|
||||
|
||||
import type {AnyObject} from '../../types/basic.js';
|
||||
import type {ChartOptions} from '../../types/index.js';
|
||||
import type {AnyObject} from '../types/basic.js';
|
||||
import type {ChartOptions} from '../types/index.js';
|
||||
|
||||
export type TimeUnit = 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year';
|
||||
|
||||
|
@ -14,8 +14,8 @@ import {version} from '../../package.json';
|
||||
import {debounce} from '../helpers/helpers.extras.js';
|
||||
|
||||
/**
|
||||
* @typedef { import('../../types/index.js').ChartEvent } ChartEvent
|
||||
* @typedef { import('../../types/index.js').Point } Point
|
||||
* @typedef { import('../types/index.js').ChartEvent } ChartEvent
|
||||
* @typedef { import('../types/index.js').Point } Point
|
||||
*/
|
||||
|
||||
const KNOWN_POSITIONS = ['top', 'bottom', 'left', 'right', 'chartArea'];
|
||||
@ -1258,10 +1258,10 @@ class Chart {
|
||||
|
||||
/**
|
||||
* @param {ChartEvent} e - The event
|
||||
* @param {import('../../types/index.js').ActiveElement[]} lastActive - Previously active elements
|
||||
* @param {import('../types/index.js').ActiveElement[]} lastActive - Previously active elements
|
||||
* @param {boolean} inChartArea - Is the envent inside chartArea
|
||||
* @param {boolean} useFinalPosition - Should the evaluation be done with current or final (after animation) element positions
|
||||
* @returns {import('../../types/index.js').ActiveElement[]} - The active elements
|
||||
* @returns {import('../types/index.js').ActiveElement[]} - The active elements
|
||||
* @pravate
|
||||
*/
|
||||
_getActiveElements(e, lastActive, inChartArea, useFinalPosition) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import type {AnyObject} from '../../types/basic.js';
|
||||
import type {Point} from '../../types/geometric.js';
|
||||
import type {Animation} from '../../types/animation.js';
|
||||
import type {AnyObject} from '../types/basic.js';
|
||||
import type {Point} from '../types/geometric.js';
|
||||
import type {Animation} from '../types/animation.js';
|
||||
import {isNumber} from '../helpers/helpers.math.js';
|
||||
|
||||
export default class Element<T = AnyObject, O = AnyObject> {
|
||||
|
@ -5,10 +5,10 @@ import {_isPointInArea} from '../helpers/index.js';
|
||||
|
||||
/**
|
||||
* @typedef { import('./core.controller.js').default } Chart
|
||||
* @typedef { import('../../types/index.js').ChartEvent } ChartEvent
|
||||
* @typedef { import('../types/index.js').ChartEvent } ChartEvent
|
||||
* @typedef {{axis?: string, intersect?: boolean, includeInvisible?: boolean}} InteractionOptions
|
||||
* @typedef {{datasetIndex: number, index: number, element: import('./core.element.js').default}} InteractionItem
|
||||
* @typedef { import('../../types/index.js').Point } Point
|
||||
* @typedef { import('../types/index.js').Point } Point
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -3,7 +3,7 @@ import {callback as callCallback, isNullOrUndef, valueOrDefault} from '../helper
|
||||
|
||||
/**
|
||||
* @typedef { import('./core.controller.js').default } Chart
|
||||
* @typedef { import('../../types/index.js').ChartEvent } ChartEvent
|
||||
* @typedef { import('../types/index.js').ChartEvent } ChartEvent
|
||||
* @typedef { import('../plugins/plugin.tooltip.js').default } Tooltip
|
||||
*/
|
||||
|
||||
|
@ -2,7 +2,7 @@ import Element from '../core/core.element.js';
|
||||
import {_angleBetween, getAngleFromPoint, TAU, HALF_PI, valueOrDefault} from '../helpers/index.js';
|
||||
import {PI, _isBetween, _limitValue} from '../helpers/helpers.math.js';
|
||||
import {_readValueToProps} from '../helpers/helpers.options.js';
|
||||
import type {ArcOptions, Point} from '../../types/index.js';
|
||||
import type {ArcOptions, Point} from '../types/index.js';
|
||||
|
||||
|
||||
function clipArc(ctx: CanvasRenderingContext2D, element: ArcElement, endAngle: number) {
|
||||
|
@ -6,7 +6,7 @@ import type {
|
||||
Point,
|
||||
PointHoverOptions,
|
||||
PointOptions,
|
||||
} from '../../types/index.js';
|
||||
} from '../types/index.js';
|
||||
|
||||
function inRange(el: PointElement, pos: number, axis: 'x' | 'y', useFinalPosition?: boolean) {
|
||||
const options = el.options;
|
||||
|
@ -6,7 +6,7 @@ import {PI, TAU, HALF_PI, QUARTER_PI, TWO_THIRDS_PI, RAD_PER_DEG} from './helper
|
||||
* necessary to avoid duplicates with `export * from './helpers`; see
|
||||
* https://github.com/microsoft/TypeScript/issues/46011
|
||||
* @typedef { import('../core/core.controller.js').default } canvas.Chart
|
||||
* @typedef { import('../../types/index.js').Point } Point
|
||||
* @typedef { import('../types/index.js').Point } Point
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -2,8 +2,8 @@
|
||||
* @namespace Chart.helpers
|
||||
*/
|
||||
|
||||
import type {AnyObject} from '../../types/basic.js';
|
||||
import type {ActiveDataPoint, ChartEvent} from '../../types/index.js';
|
||||
import type {AnyObject} from '../types/basic.js';
|
||||
import type {ActiveDataPoint, ChartEvent} from '../types/index.js';
|
||||
|
||||
/**
|
||||
* An empty function that can be used, for example, for optional callback.
|
||||
|
@ -1,6 +1,6 @@
|
||||
import {almostEquals, distanceBetweenPoints, sign} from './helpers.math.js';
|
||||
import {_isPointInArea} from './helpers.canvas.js';
|
||||
import type {ChartArea} from '../../types/index.js';
|
||||
import type {ChartArea} from '../types/index.js';
|
||||
|
||||
export interface SplinePoint {
|
||||
x: number;
|
||||
|
@ -1,4 +1,4 @@
|
||||
import type {ChartArea, Scale} from '../../types/index.js';
|
||||
import type {ChartArea, Scale} from '../types/index.js';
|
||||
import type Chart from '../core/core.controller.js';
|
||||
import type {ChartEvent} from '../types.js';
|
||||
import {INFINITY} from './helpers.math.js';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import type {ChartMeta, PointElement} from '../../types/index.js';
|
||||
import type {ChartMeta, PointElement} from '../types/index.js';
|
||||
|
||||
import {_limitValue} from './helpers.math.js';
|
||||
import {_lookupByKey} from './helpers.collection.js';
|
||||
|
@ -1,4 +1,4 @@
|
||||
import type {Point} from '../../types/geometric.js';
|
||||
import type {Point} from '../types/geometric.js';
|
||||
import type {SplinePoint} from './helpers.curve.js';
|
||||
|
||||
/**
|
||||
|
@ -1,4 +1,4 @@
|
||||
import type {Point} from '../../types/geometric.js';
|
||||
import type {Point} from '../types/geometric.js';
|
||||
import {isFinite as isFiniteNumber} from './helpers.core.js';
|
||||
|
||||
/**
|
||||
|
@ -1,8 +1,8 @@
|
||||
import defaults from '../core/core.defaults.js';
|
||||
import {isArray, isObject, toDimension, valueOrDefault} from './helpers.core.js';
|
||||
import {Point, toFontString} from './helpers.canvas.js';
|
||||
import type {ChartArea, FontSpec} from '../../types/index.js';
|
||||
import type {TRBL, TRBLCorners} from '../../types/geometric.js';
|
||||
import type {ChartArea, FontSpec} from '../types/index.js';
|
||||
import type {TRBL, TRBLCorners} from '../types/geometric.js';
|
||||
|
||||
const LINE_HEIGHT = /^(normal|(\d+(?:\.\d+)?)(px|em|%)?)$/;
|
||||
const FONT_STYLE = /^(normal|italic|initial|inherit|unset|(oblique( -?[0-9]?[0-9]deg)?))$/;
|
||||
|
@ -16,4 +16,4 @@ export * from './helpers.intl.js';
|
||||
export * from './helpers.math.js';
|
||||
export * from './helpers.options.js';
|
||||
export * from './helpers.rtl.js';
|
||||
export * from '../../types/helpers/index.js';
|
||||
export * from '../types/helpers/index.js';
|
||||
|
@ -3,8 +3,8 @@ import {isObject, isFinite, valueOrDefault} from '../../helpers/helpers.core.js'
|
||||
/**
|
||||
* @typedef { import('../../core/core.scale.js').default } Scale
|
||||
* @typedef { import('../../elements/element.line.js').default } LineElement
|
||||
* @typedef { import('../../../types/index.js').FillTarget } FillTarget
|
||||
* @typedef { import('../../../types/index.js').ComplexFillTarget } ComplexFillTarget
|
||||
* @typedef { import('../../types/index.js').FillTarget } FillTarget
|
||||
* @typedef { import('../../types/index.js').ComplexFillTarget } ComplexFillTarget
|
||||
*/
|
||||
|
||||
export function _resolveTarget(sources, index, propagate) {
|
||||
|
@ -18,7 +18,7 @@ import {_alignStartEnd, _textX, _toLeftRightCenter} from '../helpers/helpers.ext
|
||||
import {toTRBLCorners} from '../helpers/helpers.options.js';
|
||||
|
||||
/**
|
||||
* @typedef { import('../../types/index.js').ChartEvent } ChartEvent
|
||||
* @typedef { import('../types/index.js').ChartEvent } ChartEvent
|
||||
*/
|
||||
|
||||
const getBoxSize = (labelOpts, fontSize) => {
|
||||
|
@ -9,8 +9,8 @@ import {createContext, drawPoint} from '../helpers/index.js';
|
||||
|
||||
/**
|
||||
* @typedef { import('../platform/platform.base.js').Chart } Chart
|
||||
* @typedef { import('../../types/index.js').ChartEvent } ChartEvent
|
||||
* @typedef { import('../../types/index.js').ActiveElement } ActiveElement
|
||||
* @typedef { import('../types/index.js').ChartEvent } ChartEvent
|
||||
* @typedef { import('../types/index.js').ActiveElement } ActiveElement
|
||||
* @typedef { import('../core/core.interaction.js').InteractionItem } InteractionItem
|
||||
*/
|
||||
|
||||
|
@ -46,5 +46,5 @@ export {
|
||||
TimeScale,
|
||||
TimeSeriesScale,
|
||||
registerables
|
||||
} from '../types/index.js';
|
||||
export * from '../types/index.js';
|
||||
} from './types/index.js';
|
||||
export * from './types/index.js';
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { Chart } from './index.js';
|
||||
import { AnyObject } from './basic.js';
|
||||
import {Chart} from './index.js';
|
||||
import {AnyObject} from './basic.js';
|
||||
|
||||
export declare class Animation {
|
||||
constructor(cfg: AnyObject, target: AnyObject, prop: string, to?: unknown);
|
0
types/basic.d.ts → src/types/basic.d.ts
vendored
0
types/basic.d.ts → src/types/basic.d.ts
vendored
0
types/color.d.ts → src/types/color.d.ts
vendored
0
types/color.d.ts → src/types/color.d.ts
vendored
@ -1,7 +1,7 @@
|
||||
import { PointStyle, Scriptable, ScriptableScaleContext } from '../index.js';
|
||||
import { Color } from '../color.js';
|
||||
import { ChartArea, RoundedRect } from '../geometric.js';
|
||||
import { CanvasFontSpec } from '../../src/helpers/helpers.options.js';
|
||||
import {PointStyle, Scriptable, ScriptableScaleContext} from '../index.js';
|
||||
import {Color} from '../color.js';
|
||||
import {ChartArea, RoundedRect} from '../geometric.js';
|
||||
import {CanvasFontSpec} from '../../helpers/helpers.options.js';
|
||||
|
||||
export function clearCanvas(canvas: HTMLCanvasElement, ctx?: CanvasRenderingContext2D): void;
|
||||
|
41
types/index.d.ts → src/types/index.d.ts
vendored
41
types/index.d.ts → src/types/index.d.ts
vendored
@ -1,24 +1,25 @@
|
||||
import { DeepPartial, DistributiveArray, UnionToIntersection } from './utils.js';
|
||||
/* eslint-disable @typescript-eslint/ban-types */
|
||||
import {DeepPartial, DistributiveArray, UnionToIntersection} from './utils.js';
|
||||
|
||||
import { TimeUnit } from '../src/core/core.adapters.js';
|
||||
import PointElement from '../src/elements/element.point.js';
|
||||
import { EasingFunction } from '../src/helpers/helpers.easing.js';
|
||||
import { AnimationEvent } from './animation.js';
|
||||
import { AnyObject, EmptyObject } from './basic.js';
|
||||
import { Color } from './color.js';
|
||||
import Element from '../src/core/core.element.js';
|
||||
import { ChartArea, Padding, Point } from './geometric.js';
|
||||
import { LayoutItem, LayoutPosition } from './layout.js';
|
||||
import { RenderTextOpts } from './helpers/helpers.canvas.js';
|
||||
import { CanvasFontSpec } from '../src/helpers/helpers.options.js';
|
||||
import {TimeUnit} from '../core/core.adapters.js';
|
||||
import PointElement from '../elements/element.point.js';
|
||||
import {EasingFunction} from '../helpers/helpers.easing.js';
|
||||
import {AnimationEvent} from './animation.js';
|
||||
import {AnyObject, EmptyObject} from './basic.js';
|
||||
import {Color} from './color.js';
|
||||
import Element from '../core/core.element.js';
|
||||
import {ChartArea, Padding, Point} from './geometric.js';
|
||||
import {LayoutItem, LayoutPosition} from './layout.js';
|
||||
import {RenderTextOpts} from './helpers/helpers.canvas.js';
|
||||
import {CanvasFontSpec} from '../helpers/helpers.options.js';
|
||||
|
||||
export { EasingFunction } from '../src/helpers/helpers.easing.js';
|
||||
export { default as ArcElement, ArcProps } from '../src/elements/element.arc.js';
|
||||
export { default as PointElement, PointProps } from '../src/elements/element.point.js';
|
||||
export { Animation, Animations, Animator, AnimationEvent } from './animation.js';
|
||||
export { Color } from './color.js';
|
||||
export { ChartArea, Point } from './geometric.js';
|
||||
export { LayoutItem, LayoutPosition } from './layout.js';
|
||||
export {EasingFunction} from '../helpers/helpers.easing.js';
|
||||
export {default as ArcElement, ArcProps} from '../elements/element.arc.js';
|
||||
export {default as PointElement, PointProps} from '../elements/element.point.js';
|
||||
export {Animation, Animations, Animator, AnimationEvent} from './animation.js';
|
||||
export {Color} from './color.js';
|
||||
export {ChartArea, Point} from './geometric.js';
|
||||
export {LayoutItem, LayoutPosition} from './layout.js';
|
||||
|
||||
export interface ScriptableContext<TType extends ChartType> {
|
||||
active: boolean;
|
||||
@ -234,7 +235,7 @@ export declare const LineController: ChartComponent & {
|
||||
|
||||
export type ScatterControllerDatasetOptions = LineControllerDatasetOptions;
|
||||
|
||||
export interface ScatterDataPoint extends Point {}
|
||||
export type ScatterDataPoint = Point
|
||||
|
||||
export type ScatterControllerChartOptions = LineControllerChartOptions;
|
||||
|
2
types/layout.d.ts → src/types/layout.d.ts
vendored
2
types/layout.d.ts → src/types/layout.d.ts
vendored
@ -1,4 +1,4 @@
|
||||
import { ChartArea } from './geometric.js';
|
||||
import {ChartArea} from './geometric.js';
|
||||
|
||||
export type LayoutPosition = 'left' | 'top' | 'right' | 'bottom' | 'center' | 'chartArea' | {[scaleId: string]: number};
|
||||
|
0
types/utils.d.ts → src/types/utils.d.ts
vendored
0
types/utils.d.ts → src/types/utils.d.ts
vendored
@ -1,6 +1,5 @@
|
||||
rules:
|
||||
# These rules were set to warning to make the linting pass initially,
|
||||
# without making any major changes to types.
|
||||
'@typescript-eslint/no-unused-vars': 'off'
|
||||
object-curly-spacing: ["warn", "always"]
|
||||
'@typescript-eslint/no-empty-interface': "warn"
|
||||
'@typescript-eslint/ban-types': "warn"
|
@ -1,4 +1,4 @@
|
||||
import { AnyObject } from '../../basic.js';
|
||||
import { AnyObject } from '../../../src/types/basic.js';
|
||||
import { CartesianScaleOptions, Chart, Scale } from '../../../src/types.js';
|
||||
|
||||
export type TestScaleOptions = CartesianScaleOptions & {
|
||||
@ -17,7 +17,7 @@ export class TestScale<O extends TestScaleOptions = TestScaleOptions> extends Sc
|
||||
}
|
||||
}
|
||||
|
||||
declare module '../../index.js' {
|
||||
declare module '../../../src/types/index.js' {
|
||||
interface CartesianScaleTypeRegistry {
|
||||
test: {
|
||||
options: TestScaleOptions
|
@ -5,7 +5,7 @@
|
||||
"rootDir": "../../"
|
||||
},
|
||||
"include": [
|
||||
"../",
|
||||
"./",
|
||||
"../../src/",
|
||||
"../../dist/**/*.d.ts"
|
||||
],
|
@ -33,18 +33,16 @@
|
||||
},
|
||||
"typedocOptions": {
|
||||
"name": "Chart.js",
|
||||
"entryPoints": ["types/index.d.ts"],
|
||||
"entryPoints": ["src/types/index.d.ts"],
|
||||
"readme": "none",
|
||||
"excludeExternals": true,
|
||||
"includeVersion": true,
|
||||
"out": "./dist/docs/typedoc"
|
||||
},
|
||||
"include": [
|
||||
"./src/**/*",
|
||||
"./types"
|
||||
"./src/**/*"
|
||||
],
|
||||
"exclude": [
|
||||
"./types/tests",
|
||||
"./dist/**"
|
||||
]
|
||||
}
|
||||
|
@ -1,2 +0,0 @@
|
||||
rules:
|
||||
'@typescript-eslint/no-unused-vars': 'off'
|
Loading…
x
Reference in New Issue
Block a user