Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release #1797

Merged
merged 4 commits into from
Oct 23, 2024
Merged

Release #1797

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
7 changes: 7 additions & 0 deletions .browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# docs: https://github.com/browserslist/browserslist
# see https://browsersl.ist/#q=defaults

defaults
partially supports es6-module
iOS >= 10
ChromeAndroid >= 49
11 changes: 0 additions & 11 deletions .eslintignore

This file was deleted.

23 changes: 0 additions & 23 deletions .eslintrc

This file was deleted.

129 changes: 129 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
// see docs: https://eslint.org/docs/user-guide/configuring

module.exports = {
ignorePatterns: [
'node_modules',
//
'.commitlintrc.cjs',
'.eslintrc.cjs',
'.lintstagedrc.mjs',
'babel.config.mjs',
'rollup.config.mjs',
'vite.config.mjs',
//
'packages/g-devtool',
'packages/g-webgpu-compiler',
'packages/site',
//
'build',
'coverage',
'esm',
'lib',
'dist',
'rust',
'__tests__',
'scripts',
'types',
],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'airbnb',
'airbnb/hooks',
'airbnb-typescript',
'plugin:prettier/recommended',
],
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.json',
},
plugins: ['eslint-plugin-tsdoc', 'jest'],
root: true,
env: {
node: true,
browser: true,
'jest/globals': true,
},
rules: {
'import/no-cycle': 'warn',
'import/no-duplicates': 'warn',
'class-methods-use-this': 'warn',
'no-plusplus': [
'warn',
{
allowForLoopAfterthoughts: true,
},
],
'no-restricted-globals': 'warn',
'no-continue': 'warn',
'no-multi-assign': 'warn',
'no-cond-assign': 'warn',
'no-return-assign': 'warn',
'no-new': 'warn',
'new-cap': 'warn',
'default-case': 'warn',
'consistent-return': 'warn',
'prefer-regex-literals': 'warn',
'guard-for-in': 'warn',
'no-underscore-dangle': 'off',
'no-fallthrough': 'off',
'no-empty': 'off',
'no-param-reassign': 'off',
'no-redeclare': 'off',
'no-useless-escape': 'off',
'no-case-declarations': 'off',
'no-constant-condition': 'off',
'import/prefer-default-export': 'off',
'prefer-destructuring': 'off',
'no-restricted-syntax': 'off',
'no-bitwise': 'off',
//
'@typescript-eslint/naming-convention': 'warn',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-unsafe-member-access': 'warn',
'@typescript-eslint/no-unsafe-assignment': 'warn',
'@typescript-eslint/no-unsafe-return': 'warn',
'@typescript-eslint/no-unsafe-argument': 'warn',
'@typescript-eslint/no-unsafe-call': 'warn',
'@typescript-eslint/no-unsafe-function-type': 'warn',
'@typescript-eslint/no-unsafe-enum-comparison': 'warn',
'@typescript-eslint/no-redundant-type-constituents': 'warn',
'@typescript-eslint/no-floating-promises': 'warn',
'@typescript-eslint/no-misused-promises': [
'warn',
{
checksConditionals: false,
},
],
'@typescript-eslint/no-unused-vars': [
'error',
{ args: 'none', ignoreRestSiblings: true },
],
'@typescript-eslint/no-unused-expressions': 'warn',
'@typescript-eslint/no-base-to-string': 'warn',
'@typescript-eslint/no-use-before-define': [
'error',
{ functions: false, classes: false },
],
'@typescript-eslint/no-redeclare': ['error'],
'@typescript-eslint/restrict-template-expressions': 'warn',
'@typescript-eslint/return-await': 'warn',
'@typescript-eslint/default-param-last': 'warn',
'@typescript-eslint/prefer-promise-reject-errors': 'off',
'@typescript-eslint/no-empty-object-type': 'off',
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/no-shadow': 'off',
'@typescript-eslint/no-parameter-properties': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-invalid-this': 'off',
// not found
'@typescript-eslint/lines-between-class-members': 'off',
'@typescript-eslint/no-throw-literal': 'off',
'@typescript-eslint/ban-types': 'off',
//
'tsdoc/syntax': 'warn',
},
globals: { G: true, window: true, document: true, module: true },
};
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jspm_packages/

# TypeScript v1 declaration files
typings/
types/

# Optional npm cache directory
.npm
Expand Down
9 changes: 0 additions & 9 deletions .prettierrc

This file was deleted.

10 changes: 10 additions & 0 deletions .prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# see docs: https://prettier.io/docs/en/configuration.html

semi: true
singleQuote: true
trailingComma: 'all'
bracketSpacing: true
arrowParens: 'always'
printWidth: 80
proseWrap: 'never'
endOfLine: 'auto'
11 changes: 6 additions & 5 deletions __tests__/demos/bugfix/1747.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Text, Path, Rect } from '@antv/g';
import { Canvas, Text, Path, Rect } from '@antv/g';

export async function test_pick(context) {
export async function test_pick(context: { canvas: Canvas }) {
const { canvas } = context;
await canvas.ready;

Expand All @@ -20,7 +20,8 @@ export async function test_pick(context) {
x: 300,
y: 300,
cursor: 'pointer',
// transform: 'rotate(45)',
transform: 'rotate(45)',
transformOrigin: 'center',
},
});
console.log(text.getBounds());
Expand All @@ -38,7 +39,7 @@ export async function test_pick(context) {
test(path, 'fill');

canvas.appendChild(text);
// canvas.appendChild(path);
canvas.appendChild(path);

const { x, y, width, height } = text.getBBox();
const rect = new Rect({
Expand All @@ -54,5 +55,5 @@ export async function test_pick(context) {
});
test(rect, 'stroke');

// canvas.appendChild(rect);
canvas.appendChild(rect);
}
59 changes: 59 additions & 0 deletions __tests__/demos/perf/image.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { Canvas, Image as GImage } from '@antv/g';

export async function image(context: { canvas: Canvas }) {
const { canvas } = context;
await canvas.ready;
console.log(canvas);

const $dom = canvas.getContextService().getDomElement() as HTMLCanvasElement;
$dom.style.border = '1px solid gray';

// ---
$dom.addEventListener('wheel', (event) => {
event.preventDefault();

const { deltaX, deltaY } = event;
const d = -(deltaX ?? deltaY);

const ratio = 1 + (Math.min(Math.max(d, -50), 50) * 1) / 100;
const zoom = canvas.getCamera().getZoom();

canvas
.getCamera()
.setZoomByViewportPoint(zoom * ratio, [event.offsetX, event.offsetY]);
});

let isDragging = false;
let lastX, lastY;
$dom.addEventListener('mousedown', (e) => {
isDragging = true;
lastX = e.clientX;
lastY = e.clientY;
});
$dom.addEventListener('mousemove', (e) => {
if (isDragging) {
const dx = e.clientX - lastX;
const dy = e.clientY - lastY;
canvas.getCamera().pan(-dx, -dy);
lastX = e.clientX;
lastY = e.clientY;
}
});
$dom.addEventListener('mouseup', () => {
isDragging = false;
});

// ---

let image = new GImage({
style: {
x: 0,
y: 0,
// width: 100,
// height: 400,
// src: 'https://gw.alipayobjects.com/mdn/rms_6ae20b/afts/img/A*N4ZMS7gHsUIAAAAAAAAAAABkARQnAQ',
src: 'http://mmtcdp.stable.alipay.net/cto_designhubcore/afts/img/g1a5QYkvbcMAAAAAAAAAAAAADgLVAQBr/original',
},
});
canvas.appendChild(image);
}
1 change: 1 addition & 0 deletions __tests__/demos/perf/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export { circles } from './circles';
export { rects } from './rect';
export { image } from './image';
1 change: 1 addition & 0 deletions __tests__/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as lil from 'lil-gui';
import '@antv/g-camera-api';
import { Canvas, CanvasEvent, runtime } from '@antv/g';
import { Renderer as CanvasRenderer } from '@antv/g-canvas';
import { Renderer as CanvaskitRenderer } from '@antv/g-canvaskit';
Expand Down
37 changes: 37 additions & 0 deletions babel.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// See https://babeljs.io/docs/en/configuration

export default {
assumptions: {
privateFieldsAsProperties: true,
setPublicClassFields: true,
},
presets: [
[
'@babel/preset-env',
{
// Exclude transforms that make all code slower
exclude: ['transform-typeof-symbol'],
},
],
'@babel/preset-typescript',
'@babel/preset-react',
],
plugins: [
[
'@babel/plugin-transform-typescript',
{
allowDeclareFields: true,
},
],
// https://babeljs.io/docs/en/babel-plugin-transform-runtime
[
'@babel/plugin-transform-runtime',
{
// By default, babel assumes babel/runtime version 7.0.0-beta.0,
// explicitly resolving to match the provided helper functions.
// https://github.com/babel/babel/issues/10261
version: '7.25.6',
},
],
],
};
Loading
Loading