-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
99 changed files
with
4,569 additions
and
4,753 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { webVitals } from './vitals'; | ||
|
||
webVitals({ debug: true }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* ref: https://vercel.com/docs/speed-insights/api */ | ||
import { getCLS, getFCP, getFID, getLCP, getTTFB } from 'web-vitals'; | ||
|
||
const vitalsUrl = 'https://vitals.vercel-analytics.com/v1/vitals'; | ||
|
||
function getConnectionSpeed() { | ||
return 'connection' in navigator && | ||
navigator['connection'] && | ||
'effectiveType' in (navigator as any)['connection'] | ||
? navigator['connection']['effectiveType'] | ||
: ''; | ||
} | ||
|
||
function sendToAnalytics(metric, options) { | ||
const analyticsId = process.env.VERCEL_ANALYTICS_ID; | ||
|
||
const body = { | ||
dsn: analyticsId, | ||
id: metric.id, | ||
page: window.location.pathname, | ||
href: window.location.href, | ||
event_name: metric.name, | ||
value: metric.value.toString(), | ||
speed: getConnectionSpeed(), | ||
}; | ||
|
||
if (options.debug) { | ||
console.log('[Analytics]', metric.name, JSON.stringify(body, null, 2)); | ||
} | ||
|
||
const blob = new Blob([new URLSearchParams(body).toString()], { | ||
// This content type is necessary for `sendBeacon` | ||
type: 'application/x-www-form-urlencoded', | ||
}); | ||
if (navigator.sendBeacon) { | ||
navigator.sendBeacon(vitalsUrl, blob); | ||
} else | ||
fetch(vitalsUrl, { | ||
body: blob, | ||
method: 'POST', | ||
credentials: 'omit', | ||
keepalive: true, | ||
}); | ||
} | ||
|
||
export function webVitals(options) { | ||
try { | ||
getFID(metric => sendToAnalytics(metric, options)); | ||
getTTFB(metric => sendToAnalytics(metric, options)); | ||
getLCP(metric => sendToAnalytics(metric, options)); | ||
getCLS(metric => sendToAnalytics(metric, options)); | ||
getFCP(metric => sendToAnalytics(metric, options)); | ||
} catch (err) { | ||
console.error('[Analytics]', err); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,10 +39,10 @@ | |
}, | ||
"devDependencies": { | ||
"@ant-design/colors": "^7.0.0", | ||
"@ant-design/cssinjs": "^1.17.0", | ||
"@ant-design/cssinjs": "^1.17.2", | ||
"@ant-design/icons": "^5.2.6", | ||
"@babel/cli": "^7.22.15", | ||
"@babel/preset-env": "^7.22.20", | ||
"@babel/cli": "^7.23.0", | ||
"@babel/preset-env": "^7.23.2", | ||
"@ctrl/tinycolor": "^4.0.2", | ||
"@emotion/babel-preset-css-prop": "^11.11.0", | ||
"@emotion/css": "^11.11.2", | ||
|
@@ -51,65 +51,68 @@ | |
"@chenshuai2144/less2cssinjs": "^1.0.7", | ||
"@qixian.cs/github-contributors-list": "^1.1.0", | ||
"@stackblitz/sdk": "^1.9.0", | ||
"@testing-library/dom": "^9.3.1", | ||
"@testing-library/jest-dom": "^6.1.2", | ||
"@testing-library/dom": "^9.3.3", | ||
"@testing-library/jest-dom": "^6.1.4", | ||
"@testing-library/react": "^14.0.0", | ||
"@testing-library/react-hooks": "^8.0.1", | ||
"@testing-library/user-event": "^14.5.1", | ||
"@types/jest": "^29.5.4", | ||
"@types/node": "^20.6.2", | ||
"@types/react": "^18.2.21", | ||
"@types/jest": "^29.5.5", | ||
"@types/lodash": "^4.14.199", | ||
"@types/node": "^20.8.6", | ||
"@types/react": "^18.2.28", | ||
"@umijs/fabric": "^4.0.1", | ||
"@umijs/test": "^4.0.79", | ||
"antd": "^5.9.0", | ||
"@umijs/test": "^4.0.86", | ||
"@vercel/analytics": "^1.1.1", | ||
"antd": "^5.10.1", | ||
"antd-style": "^3.5.0", | ||
"antd-token-previewer": "^1.1.0", | ||
"babel-jest": "^29.6.4", | ||
"babel-jest": "^29.7.0", | ||
"classnames": "^2.3.2", | ||
"copy-to-clipboard": "^3.3.3", | ||
"cross-env": "^7.0.3", | ||
"dayjs": "^1.11.9", | ||
"dumi": "^2.2.10", | ||
"eslint-plugin-jest": "^27.2.3", | ||
"dayjs": "^1.11.10", | ||
"dumi": "^2.2.13", | ||
"eslint-plugin-jest": "^27.4.2", | ||
"execa": "^5.1.1", | ||
"father": "^4.3.1", | ||
"father": "^4.3.5", | ||
"fs-extra": "^11.1.1", | ||
"gh-pages": "^5.0.0", | ||
"gh-pages": "^6.0.0", | ||
"html2sketch": "^1.0.2", | ||
"identity-obj-proxy": "^3.0.0", | ||
"jest": "^29.6.4", | ||
"jest": "^29.7.0", | ||
"jest-canvas-mock": "^2.5.2", | ||
"jest-environment-jsdom": "^29.7.0", | ||
"jest-fetch-mock": "^3.0.3", | ||
"jest-svg-transformer": "^1.0.0", | ||
"jsonml-to-react-element": "^1.1.11", | ||
"jsonml.js": "^0.1.0", | ||
"lerna": "^7.2.0", | ||
"lerna": "^7.3.1", | ||
"lint-staged": "^14.0.1", | ||
"lodash": "^4.17.21", | ||
"lz-string": "^1.5.0", | ||
"mockdate": "^3.0.5", | ||
"prettier": "^3.0.3", | ||
"prismjs": "^1.29.0", | ||
"rc-checkbox": "^3.1.0", | ||
"rc-drawer": "^6.4.1", | ||
"rc-drawer": "^6.5.2", | ||
"rc-footer": "^0.6.8", | ||
"rc-tabs": "^12.12.1", | ||
"rc-util": "^5.37.0", | ||
"rc-tabs": "^12.13.1", | ||
"rc-util": "^5.38.0", | ||
"react": "^18.2.0", | ||
"react-color": "^2.19.3", | ||
"react-copy-to-clipboard": "^5.1.0", | ||
"react-dom": "^18.2.0", | ||
"react-fast-marquee": "^1.6.0", | ||
"react-intl": "^6.4.7", | ||
"react-router-dom": "^6.15.0", | ||
"react-fast-marquee": "^1.6.2", | ||
"react-intl": "^6.5.0", | ||
"react-router-dom": "^6.17.0", | ||
"runscript": "^1.5.3", | ||
"svg-jest": "^1.0.1", | ||
"sylvanas": "^0.6.1", | ||
"ts-jest": "^29.1.1", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^5.2.2", | ||
"vanilla-jsoneditor": "^0.18.3", | ||
"vanilla-jsoneditor": "^0.18.9", | ||
"web-vitals": "^3.5.0", | ||
"yorkie": "^2.0.0" | ||
}, | ||
"packageManager": "[email protected]", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
packages/charts/src/Area/__tests__/__snapshots__/ref.test.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Area ref ref 1`] = ` | ||
<div | ||
data-chart-source-type="G2Plot" | ||
size-sensor-id="1" | ||
style="height: inherit;" | ||
> | ||
<div | ||
style="position:relative;" | ||
> | ||
<canvas | ||
height="400" | ||
style="width: 400px; height: 400px; display: inline-block; vertical-align: middle;" | ||
width="400" | ||
/> | ||
</div> | ||
<object | ||
class="size-sensor-object" | ||
data="about:blank" | ||
style="display: block; position: absolute; top: 0px; left: 0px; height: 100%; width: 100%; overflow: hidden; pointer-events: none; z-index: -1; opacity: 0;" | ||
tabindex="-1" | ||
type="text/html" | ||
/> | ||
</div> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React, { useEffect, useRef } from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import { Area } from '@oceanbase/charts'; | ||
|
||
describe('Area ref', () => { | ||
it('ref', () => { | ||
const DemoArea = () => { | ||
const ref = useRef(null); | ||
useEffect(() => { | ||
expect(ref.current).not.toBeNull(); | ||
expect(typeof ref.current?.getChart).toBe('function'); | ||
}, []); | ||
const config = { | ||
data: [], | ||
xField: 'x', | ||
yField: 'y', | ||
}; | ||
return <Area {...config} ref={ref} />; | ||
}; | ||
const { asFragment } = render(<DemoArea />); | ||
expect(asFragment().firstChild).toMatchSnapshot(); | ||
}); | ||
}); |
Oops, something went wrong.