mirror of
https://github.com/stefanpejcic/openpanel
synced 2025-06-26 18:28:26 +00:00
packages
This commit is contained in:
11
packages/devtools-internal/.npmignore
Normal file
11
packages/devtools-internal/.npmignore
Normal file
@@ -0,0 +1,11 @@
|
||||
node_modules
|
||||
.DS_Store
|
||||
test
|
||||
jest.config.js
|
||||
**/*.spec.ts
|
||||
**/*.spec.tsx
|
||||
**/*.test.ts
|
||||
**/*.test.tsx
|
||||
tsup.config.ts
|
||||
tsconfig.test.json
|
||||
tsconfig.declarations.json
|
||||
314
packages/devtools-internal/CHANGELOG.md
Normal file
314
packages/devtools-internal/CHANGELOG.md
Normal file
@@ -0,0 +1,314 @@
|
||||
# @refinedev/devtools-internal
|
||||
|
||||
## 1.1.14
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#6165](https://github.com/refinedev/refine/pull/6165) [`ccddff6eba23286d4025a7301de3ebfc24b1b633`](https://github.com/refinedev/refine/commit/ccddff6eba23286d4025a7301de3ebfc24b1b633) Thanks [@aliemir](https://github.com/aliemir)! - fix(devtools-internal): fix noop return on hooks for production builds
|
||||
|
||||
Currently, `@refinedev/devtools-internal` returns noop function when bundled for production, yet the notation is not correctly interpreted by some bundlers. This PR fixes the issue by moving the empty return and noop functions to a separate definition.
|
||||
|
||||
[Resolves #6030](https://github.com/refinedev/refine/issues/6030)
|
||||
|
||||
- [#6185](https://github.com/refinedev/refine/pull/6185) [`603c73eb7d376fc2357a577f5921f844a8f444e4`](https://github.com/refinedev/refine/commit/603c73eb7d376fc2357a577f5921f844a8f444e4) Thanks [@aliemir](https://github.com/aliemir)! - feat(devtools): ability to change the port of the devtools server
|
||||
|
||||
Now users can change the port of the devtools server by setting the `REFINE_DEVTOOLS_PORT` environment variable. Previously, the port was hardcoded to "5001" and could not be changed.
|
||||
|
||||
If you're using `@refinedev/cli`'s runner commands to start your development server, `REFINE_DEVTOOLS_PORT` will be propagated to your app with appropriate prefix. E.g. if you're using Vite, the environment variable will be `VITE_REFINE_DEVTOOLS_PORT` and it will be used by the `@refinedev/devtools`'s `<DevtoolsProvider />` component to connect to the devtools server.
|
||||
|
||||
- In Next.js apps, it will be prefixed with `NEXT_PUBLIC_`
|
||||
- In Craco and Create React App apps, it will be prefixed with `REACT_APP_`
|
||||
- In Remix apps and other custom setups, the environment variable will be used as is.
|
||||
|
||||
In some scenarios where the environment variables are not passed to the browser, you may need to manually set the Refine Devtools URL in the `<DevtoolsProvider />` component via the `url` prop. Remix apps do not automatically pass environment variables to the browser, so you will need to set the URL manually. If not set, the default URL will be used.
|
||||
|
||||
While the port can be changed, this feature also allows users to host the devtools server on a different machine or domain and provide the `<DevtoolsProvider />` with the custom domain URL. This such case will be useful if you're dockerizing your app and devtools server separately.
|
||||
|
||||
**Enterprise Edition**: Refine Devtools running on ports other than "5001" is only available in the Enterprise Edition. If you're using the Community Edition, Refine Devtools will not work if the port is changed.
|
||||
|
||||
[Resolves #5111](https://github.com/refinedev/refine/issues/5111)
|
||||
|
||||
- Updated dependencies [[`603c73eb7d376fc2357a577f5921f844a8f444e4`](https://github.com/refinedev/refine/commit/603c73eb7d376fc2357a577f5921f844a8f444e4)]:
|
||||
- @refinedev/devtools-shared@1.1.12
|
||||
|
||||
## 1.1.13
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`8bc2c1c6790d1e098ce0d98e01f608e3310f7b4a`](https://github.com/refinedev/refine/commit/8bc2c1c6790d1e098ce0d98e01f608e3310f7b4a), [`8bc2c1c6790d1e098ce0d98e01f608e3310f7b4a`](https://github.com/refinedev/refine/commit/8bc2c1c6790d1e098ce0d98e01f608e3310f7b4a)]:
|
||||
- @refinedev/devtools-shared@1.1.11
|
||||
|
||||
## 1.1.11
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [`6bd14228760d3e1e205ea9248e427f9afa2ec046`](https://github.com/refinedev/refine/commit/6bd14228760d3e1e205ea9248e427f9afa2ec046) Thanks [@BatuhanW](https://github.com/BatuhanW)! - fix(devtools-internal): broken env conditional in useQuerySubscription hook
|
||||
|
||||
When using Refine with React Native, `process.env.NODE_ENV !== "development" ? () => ({}) : () => {...}` conditional in `useQuerySubscription` hook was causing a syntax error. This PR fixes the issue by explicitly returning an empty object on non-development environments.
|
||||
|
||||
- [`6bd14228760d3e1e205ea9248e427f9afa2ec046`](https://github.com/refinedev/refine/commit/6bd14228760d3e1e205ea9248e427f9afa2ec046) Thanks [@BatuhanW](https://github.com/BatuhanW)! - chore: added `type` qualifier to imports used as type only.
|
||||
|
||||
```diff
|
||||
- import { A } from "./example.ts";
|
||||
+ import type { A } from "./example.ts";
|
||||
```
|
||||
|
||||
- Updated dependencies [[`6bd14228760d3e1e205ea9248e427f9afa2ec046`](https://github.com/refinedev/refine/commit/6bd14228760d3e1e205ea9248e427f9afa2ec046), [`6bd14228760d3e1e205ea9248e427f9afa2ec046`](https://github.com/refinedev/refine/commit/6bd14228760d3e1e205ea9248e427f9afa2ec046), [`6bd14228760d3e1e205ea9248e427f9afa2ec046`](https://github.com/refinedev/refine/commit/6bd14228760d3e1e205ea9248e427f9afa2ec046)]:
|
||||
- @refinedev/devtools-shared@1.1.9
|
||||
|
||||
## 1.1.10
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#5945](https://github.com/refinedev/refine/pull/5945) [`a1e36e6e909a91bc6218478f136b49a8e82a7e32`](https://github.com/refinedev/refine/commit/a1e36e6e909a91bc6218478f136b49a8e82a7e32) Thanks [@aliemir](https://github.com/aliemir)! - fix(devtools-internal): broken env conditional in useQuerySubscription hook
|
||||
|
||||
When using Refine with React Native, `process.env.NODE_ENV !== "development" ? () => ({}) : () => {...}` conditional in `useQuerySubscription` hook was causing a syntax error. This PR fixes the issue by explicitly returning an empty object on non-development environments.
|
||||
|
||||
- [#5945](https://github.com/refinedev/refine/pull/5945) [`90930b381d8d369c63bc59beedf69c391875166d`](https://github.com/refinedev/refine/commit/90930b381d8d369c63bc59beedf69c391875166d) Thanks [@aliemir](https://github.com/aliemir)! - chore: added `type` qualifier to imports used as type only.
|
||||
|
||||
```diff
|
||||
- import { A } from "./example.ts";
|
||||
+ import type { A } from "./example.ts";
|
||||
```
|
||||
|
||||
- Updated dependencies [[`bb89dc34bf6ef061d0bcdcf0cb3173fe7014ae5e`](https://github.com/refinedev/refine/commit/bb89dc34bf6ef061d0bcdcf0cb3173fe7014ae5e), [`6c22ece19f44ca2b99ad70543f9ee40b4b139863`](https://github.com/refinedev/refine/commit/6c22ece19f44ca2b99ad70543f9ee40b4b139863), [`90930b381d8d369c63bc59beedf69c391875166d`](https://github.com/refinedev/refine/commit/90930b381d8d369c63bc59beedf69c391875166d)]:
|
||||
- @refinedev/devtools-shared@1.1.8
|
||||
|
||||
## 1.1.9
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#5928](https://github.com/refinedev/refine/pull/5928) [`db9756e7908`](https://github.com/refinedev/refine/commit/db9756e79086ff80774ee75d570d610bf0d5d76d) Thanks [@aliemir](https://github.com/aliemir)! - fix: type errors on typescript <5
|
||||
|
||||
Due to the changes in #5881, typescript users below version 5 are facing type errors. This PR fixes the type errors by updating the file extensions required by the `d.mts` declaration files to provide a compatible declarations for both typescript 4 and 5 users.
|
||||
|
||||
- Updated dependencies [[`db9756e7908`](https://github.com/refinedev/refine/commit/db9756e79086ff80774ee75d570d610bf0d5d76d)]:
|
||||
- @refinedev/devtools-shared@1.1.7
|
||||
|
||||
## 1.1.8
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#5875](https://github.com/refinedev/refine/pull/5875) [`1c9a95f22ab`](https://github.com/refinedev/refine/commit/1c9a95f22ab8c3f1d1e48c7c889227ce1d9160cf) Thanks [@aliemir](https://github.com/aliemir)! - feat: update resource name accessing logic
|
||||
|
||||
Updated resource name displaying logic to use `resourceName` from activity records to make sure `resource` is correctly displayed with custom query keys.
|
||||
|
||||
- [#5875](https://github.com/refinedev/refine/pull/5875) [`1c9a95f22ab`](https://github.com/refinedev/refine/commit/1c9a95f22ab8c3f1d1e48c7c889227ce1d9160cf) Thanks [@aliemir](https://github.com/aliemir)! - feat: add invalidate query button
|
||||
|
||||
Added `Invalidate Query` button to settled queries in the devtools panel to allow users to manually invalidate queries for debugging purposes.
|
||||
|
||||
- [#5881](https://github.com/refinedev/refine/pull/5881) [`ba719f6ea26`](https://github.com/refinedev/refine/commit/ba719f6ea264ee87226f42de900a754e81f1f22f) Thanks [@aliemir](https://github.com/aliemir)! - fix: declaration files in node10, node16 and nodenext module resolutions
|
||||
|
||||
- Updated dependencies [[`1c9a95f22ab`](https://github.com/refinedev/refine/commit/1c9a95f22ab8c3f1d1e48c7c889227ce1d9160cf), [`1c9a95f22ab`](https://github.com/refinedev/refine/commit/1c9a95f22ab8c3f1d1e48c7c889227ce1d9160cf), [`ba719f6ea26`](https://github.com/refinedev/refine/commit/ba719f6ea264ee87226f42de900a754e81f1f22f)]:
|
||||
- @refinedev/devtools-shared@1.1.6
|
||||
|
||||
## 1.1.7
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#5765](https://github.com/refinedev/refine/pull/5765) [`0c197d82393`](https://github.com/refinedev/refine/commit/0c197d823939ae1fd4e0ee4b5a422322853b1e45) Thanks [@aliemir](https://github.com/aliemir)! - refactor: package bundles and package.json configuration for exports
|
||||
|
||||
Previously, Refine packages had exported ESM and CJS bundles with same `.js` extension and same types for both with `.d.ts` extensions. This was causing issues with bundlers and compilers to pick up the wrong files for the wrong environment. Now we're outputting ESM bundles with `.mjs` extension and CJS bundles with `.cjs` extension. Also types are now exported with both `.d.mts` and `.d.cts` extensions.
|
||||
|
||||
In older versions ESM and CJS outputs of some packages were using wrong imports/requires to dependencies causing errors in some environments. This will be fixed since now we're also enforcing the module type with extensions.
|
||||
|
||||
Above mentioned changes also supported with changes in `package.json` files of the packages to support the new extensions and types. All Refine packages now include `exports` fields in their configuration to make sure the correct bundle is picked up by the bundlers and compilers.
|
||||
|
||||
- [#5754](https://github.com/refinedev/refine/pull/5754) [`56ed144a0f5`](https://github.com/refinedev/refine/commit/56ed144a0f5af218fd9e6edbfd999ae433329927) Thanks [@alicanerdurmaz](https://github.com/alicanerdurmaz)! - chore: TypeScript upgraded to [v5.x.x](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-0.html). #5752
|
||||
|
||||
- Updated dependencies [[`0c197d82393`](https://github.com/refinedev/refine/commit/0c197d823939ae1fd4e0ee4b5a422322853b1e45), [`56ed144a0f5`](https://github.com/refinedev/refine/commit/56ed144a0f5af218fd9e6edbfd999ae433329927)]:
|
||||
- @refinedev/devtools-shared@1.1.5
|
||||
|
||||
## 1.1.6
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#5695](https://github.com/refinedev/refine/pull/5695) [`79865affa1c`](https://github.com/refinedev/refine/commit/79865affa1c657e6b14ed34585caeec1f3d3da7f) Thanks [@BatuhanW](https://github.com/BatuhanW)! - chore: apply biome format and fix lint errors.
|
||||
|
||||
- Updated dependencies [[`79865affa1c`](https://github.com/refinedev/refine/commit/79865affa1c657e6b14ed34585caeec1f3d3da7f)]:
|
||||
- @refinedev/devtools-shared@1.1.4
|
||||
|
||||
## 1.1.5
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#5573](https://github.com/refinedev/refine/pull/5573) [`546df06482`](https://github.com/refinedev/refine/commit/546df06482807e59a7f2a735361a8e9169bb2563) Thanks [@alicanerdurmaz](https://github.com/alicanerdurmaz)! - chore: add "use client" directive to exported files to work with nextjs app router
|
||||
|
||||
- Updated dependencies [[`546df06482`](https://github.com/refinedev/refine/commit/546df06482807e59a7f2a735361a8e9169bb2563)]:
|
||||
- @refinedev/devtools-shared@1.1.3
|
||||
|
||||
## 1.1.4
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#5022](https://github.com/refinedev/refine/pull/5022) [`80513a4e42f`](https://github.com/refinedev/refine/commit/80513a4e42f8dda39e01157643594a9e4c32001b) Thanks [@BatuhanW](https://github.com/BatuhanW)! - chore: update README.md
|
||||
|
||||
- fix grammar errors.
|
||||
- make all README.md files consistent.
|
||||
- add code example code snippets.
|
||||
|
||||
- Updated dependencies [[`80513a4e42f`](https://github.com/refinedev/refine/commit/80513a4e42f8dda39e01157643594a9e4c32001b)]:
|
||||
- @refinedev/devtools-shared@1.1.2
|
||||
|
||||
## 1.1.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#5022](https://github.com/refinedev/refine/pull/5022) [`80513a4e42f`](https://github.com/refinedev/refine/commit/80513a4e42f8dda39e01157643594a9e4c32001b) Thanks [@BatuhanW](https://github.com/BatuhanW)! - chore: update README.md
|
||||
|
||||
- fix grammar errors.
|
||||
- make all README.md files consistent.
|
||||
- add code example code snippets.
|
||||
|
||||
- Updated dependencies [[`80513a4e42f`](https://github.com/refinedev/refine/commit/80513a4e42f8dda39e01157643594a9e4c32001b)]:
|
||||
- @refinedev/devtools-shared@1.1.1
|
||||
|
||||
## 1.1.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#5008](https://github.com/refinedev/refine/pull/5008) [`c8499114e55`](https://github.com/refinedev/refine/commit/c8499114e55968d8b440a8cd6eb2f29fbf3deb94) Thanks [@aliemir](https://github.com/aliemir)! - Fixing the version of `@refinedev/devtools-shared` dependency to avoid breaking projects in mismatching releases.
|
||||
|
||||
## 1.1.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- [#5008](https://github.com/refinedev/refine/pull/5008) [`c8499114e55`](https://github.com/refinedev/refine/commit/c8499114e55968d8b440a8cd6eb2f29fbf3deb94) Thanks [@aliemir](https://github.com/aliemir)! - Fixing the version of `@refinedev/devtools-shared` dependency to avoid breaking projects in mismatching releases.
|
||||
|
||||
## 1.1.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- [#4960](https://github.com/refinedev/refine/pull/4960) [`d8e464fa2c4`](https://github.com/refinedev/refine/commit/d8e464fa2c461d0fd60050cf18247758ecdc42e3) Thanks [@aliemir](https://github.com/aliemir)! - Initial beta release of refine devtools.🎉
|
||||
|
||||
We're releasing refine devtools in beta. refine devtools is designed to help you debug and develop your refine apps. It will be a collection of features including monitoring queries and mutations, testing out inferencer generated codes, adding and updating refine packages from the UI and more. 🤯
|
||||
|
||||

|
||||
|
||||
## Usage
|
||||
|
||||
Install the dependencies using your package manager.
|
||||
|
||||
```bash
|
||||
npm i @refinedev/devtools@latest @refinedev/cli@latest
|
||||
```
|
||||
|
||||
Add `<DevtoolsProvider />` and `<DevtoolsPanel />` components to your app:
|
||||
|
||||
You'll need to wrap your app with `<DevtoolsProvider />` component and add `<DevtoolsPanel />` component to your app to access the devtools UI.
|
||||
|
||||
```tsx
|
||||
import { DevtoolsPanel, DevtoolsProvider } from "@refinedev/devtools";
|
||||
|
||||
const App = () => {
|
||||
return (
|
||||
<DevtoolsProvider>
|
||||
<Refine
|
||||
// ...
|
||||
>
|
||||
{/* ... */}
|
||||
</Refine>
|
||||
<DevtoolsPanel />
|
||||
</DevtoolsProvider>
|
||||
);
|
||||
};
|
||||
```
|
||||
|
||||
Then you're good to go 🙌, `<DevtoolsProvider />` will tell refine to connect to the devtools server and track your queries and mutations. `<DevtoolsPanel />` will render the devtools UI in your app.
|
||||
|
||||
note: Devtools only works in development mode and have no overhead on production builds. You don't need to do anything special to exclude DevTools from your bundle.
|
||||
|
||||
Devtools is integrated with `@refinedev/cli` and it will be started automatically in development mode if you have `@refinedev/devtools` installed.
|
||||
|
||||
If you want to start devtools manually or have a custom dev script, you can run `refine devtools` in your project directory or add the following scripts to your `package.json`:
|
||||
|
||||
```js
|
||||
{
|
||||
"scripts": {
|
||||
// If you have not customized the start script.
|
||||
"start": "refine dev", // The devtools server runs automatically; you don't need to do anything.
|
||||
|
||||
// If you have customized the start script.
|
||||
"start": "my-custom-dev-script & refine devtools" // Run the devtools server manually.
|
||||
|
||||
// other scripts
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
If you don't have `@refinedev/cli` installed already, you can follow the [installation guide](https://refine.dev/docs/packages/documentation/cli/#how-to-add-to-an-existing-project) to add it to your project.
|
||||
|
||||
These commands will start the devtools server. If you want to access the devtools UI outside of your app without depending on the `<DevtoolsPanel />` component, you can go to `http://localhost:5001` in your browser. 🚀
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`d8e464fa2c4`](https://github.com/refinedev/refine/commit/d8e464fa2c461d0fd60050cf18247758ecdc42e3)]:
|
||||
- @refinedev/devtools-shared@1.1.0
|
||||
|
||||
## 1.0.0
|
||||
|
||||
### Major Changes
|
||||
|
||||
- [#4960](https://github.com/refinedev/refine/pull/4960) [`d8e464fa2c4`](https://github.com/refinedev/refine/commit/d8e464fa2c461d0fd60050cf18247758ecdc42e3) Thanks [@aliemir](https://github.com/aliemir)! - Initial beta release of refine devtools.🎉
|
||||
|
||||
We're releasing refine devtools in beta. refine devtools is designed to help you debug and develop your refine apps. It will be a collection of features including monitoring queries and mutations, testing out inferencer generated codes, adding and updating refine packages from the UI and more. 🤯
|
||||
|
||||
## Usage
|
||||
|
||||
Install the dependencies using your package manager.
|
||||
|
||||
```bash
|
||||
npm i @refinedev/devtools@next @refinedev/cli@next @refinedev/core@next
|
||||
```
|
||||
|
||||
Add `<DevtoolsProvider />` and `<DevtoolsPanel />` components to your app:
|
||||
|
||||
You'll need to wrap your app with `<DevtoolsProvider />` component and add `<DevtoolsPanel />` component to your app to access the devtools UI.
|
||||
|
||||
```tsx
|
||||
import { DevtoolsPanel, DevtoolsProvider } from "@refinedev/devtools";
|
||||
|
||||
const App = () => {
|
||||
return (
|
||||
<DevtoolsProvider>
|
||||
<Refine
|
||||
// ...
|
||||
>
|
||||
{/* ... */}
|
||||
</Refine>
|
||||
<DevtoolsPanel />
|
||||
</DevtoolsProvider>
|
||||
);
|
||||
};
|
||||
```
|
||||
|
||||
Then you're good to go 🙌, `<DevtoolsProvider />` will tell refine to connect to the devtools server and track your queries and mutations. `<DevtoolsPanel />` will render the devtools UI in your app.
|
||||
|
||||
note: Devtools only works in development mode and have no overhead on production builds. You don't need to do anything special to exclude DevTools from your bundle.
|
||||
|
||||
Devtools is integrated with `@refinedev/cli` and it will be started automatically in development mode if you have `@refinedev/devtools` installed.
|
||||
|
||||
If you want to start devtools manually or have a custom dev script, you can run `refine devtools` in your project directory or add the following scripts to your `package.json`:
|
||||
|
||||
```js
|
||||
{
|
||||
"scripts": {
|
||||
// If you have not customized the start script.
|
||||
"start": "refine dev", // The devtools server runs automatically; you don't need to do anything.
|
||||
|
||||
// If you have customized the start script.
|
||||
"start": "my-custom-dev-script & refine devtools" // Run the devtools server manually.
|
||||
|
||||
// other scripts
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
If you don't have `@refinedev/cli` installed already, you can follow the [installation guide](https://refine.dev/docs/packages/documentation/cli/#how-to-add-to-an-existing-project) to add it to your project.
|
||||
|
||||
These commands will start the devtools server. If you want to access the devtools UI outside of your app without depending on the `<DevtoolsPanel />` component, you can go to `http://localhost:5001` in your browser. 🚀
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [[`d8e464fa2c4`](https://github.com/refinedev/refine/commit/d8e464fa2c461d0fd60050cf18247758ecdc42e3)]:
|
||||
- @refinedev/devtools-shared@1.0.0
|
||||
21
packages/devtools-internal/LICENSE
Normal file
21
packages/devtools-internal/LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2022 Refine Dev Corporation
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
37
packages/devtools-internal/README.md
Normal file
37
packages/devtools-internal/README.md
Normal file
@@ -0,0 +1,37 @@
|
||||
<div align="center" style="margin: 30px;">
|
||||
<a href="https://refine.dev">
|
||||
<img alt="refine logo" src="https://refine.ams3.cdn.digitaloceanspaces.com/readme/refine-readme-banner.png">
|
||||
</a>
|
||||
</div>
|
||||
<br/>
|
||||
<div align="center">refine is an open-source, headless React framework for developers building enterprise web applications.
|
||||
|
||||
It eliminates repetitive tasks in CRUD operations and provides industry-standard solutions for critical project components like **authentication**, **access control**, **routing**, **networking**, **state management**, and **i18n**.
|
||||
|
||||
</div>
|
||||
<br/>
|
||||
|
||||
<div align="center">
|
||||
<sub>Created by <a href="https://refine.dev">refine</a></sub>
|
||||
</div>
|
||||
|
||||
## About
|
||||
|
||||
[refine](https://refine.dev/) is **headless by design**, offering unlimited styling and customization options. Moreover, refine ships with ready-made integrations for [Ant Design](https://ant.design/), [Material UI](https://mui.com/material-ui/getting-started/overview/), [Mantine](https://mantine.dev/), and [Chakra UI](https://chakra-ui.com/) for convenience.
|
||||
|
||||
refine has connectors for 15+ backend services, including REST API, [GraphQL](https://graphql.org/), and popular services like [Airtable](https://www.airtable.com/), [Strapi](https://strapi.io/), [Supabase](https://supabase.com/), [Firebase](https://firebase.google.com/), and [Directus](https://directus.io/)
|
||||
|
||||
[Refer to documentation for more info about refine→](https://refine.dev/docs/)
|
||||
[Step up to refine tutorials →](https://refine.dev/docs/tutorial/introduction/index/)
|
||||
|
||||
## Documentation
|
||||
|
||||
This package is an internal package and a part of the `@refinedev/devtools` package.
|
||||
|
||||
For more detailed information an usage, refer to the [refine devtools documentation](https://refine.dev/docs/packages/devtools)
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
npm install @refinedev/devtools
|
||||
```
|
||||
15
packages/devtools-internal/jest.config.js
Normal file
15
packages/devtools-internal/jest.config.js
Normal file
@@ -0,0 +1,15 @@
|
||||
module.exports = {
|
||||
preset: "ts-jest",
|
||||
rootDir: "./",
|
||||
displayName: "react-hook-form",
|
||||
testPathIgnorePatterns: ["<rootDir>/node_modules/", "<rootDir>/dist/"],
|
||||
testEnvironment: "jsdom",
|
||||
transform: {
|
||||
"^.+\\.tsx?$": [
|
||||
"ts-jest",
|
||||
{
|
||||
tsconfig: "<rootDir>/tsconfig.test.json",
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
73
packages/devtools-internal/package.json
Normal file
73
packages/devtools-internal/package.json
Normal file
@@ -0,0 +1,73 @@
|
||||
{
|
||||
"name": "@refinedev/devtools-internal",
|
||||
"version": "1.1.14",
|
||||
"private": false,
|
||||
"description": "refine devtools offers a set of features from monitoring to quickly prototyping a UI.",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/refinedev/refine.git",
|
||||
"directory": "packages/devtools"
|
||||
},
|
||||
"license": "MIT",
|
||||
"author": "refine",
|
||||
"sideEffects": false,
|
||||
"exports": {
|
||||
".": {
|
||||
"import": {
|
||||
"types": "./dist/index.d.mts",
|
||||
"default": "./dist/index.mjs"
|
||||
},
|
||||
"require": {
|
||||
"types": "./dist/index.d.cts",
|
||||
"default": "./dist/index.cjs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"main": "dist/index.cjs",
|
||||
"module": "dist/index.mjs",
|
||||
"typings": "dist/index.d.ts",
|
||||
"files": [
|
||||
"dist",
|
||||
"src"
|
||||
],
|
||||
"scripts": {
|
||||
"attw": "attw --pack .",
|
||||
"build": "tsup && node ../shared/generate-declarations.js",
|
||||
"dev": "tsup --watch",
|
||||
"prepare": "pnpm build",
|
||||
"publint": "publint --strict=true --level=suggestion",
|
||||
"test": "jest --passWithNoTests --runInBand",
|
||||
"types": "node ../shared/generate-declarations.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@refinedev/devtools-shared": "1.1.12",
|
||||
"@tanstack/react-query": "^4.10.1",
|
||||
"error-stack-parser": "^2.1.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@esbuild-plugins/node-resolve": "^0.1.4",
|
||||
"@testing-library/jest-dom": "^5.16.4",
|
||||
"@types/jest": "^29.2.4",
|
||||
"@types/node": "^18.16.2",
|
||||
"@types/testing-library__jest-dom": "^5.14.3",
|
||||
"jest": "^29.3.1",
|
||||
"jest-environment-jsdom": "^29.3.1",
|
||||
"react-router-dom": "^6.8.1",
|
||||
"ts-jest": "^29.1.2",
|
||||
"tslib": "^2.6.2",
|
||||
"tsup": "^6.7.0",
|
||||
"typescript": "^5.4.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@types/react": "^17.0.0 || ^18.0.0",
|
||||
"@types/react-dom": "^17.0.0 || ^18.0.0",
|
||||
"react": "^17.0.0 || ^18.0.0",
|
||||
"react-dom": "^17.0.0 || ^18.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
}
|
||||
}
|
||||
15
packages/devtools-internal/src/clean-stack.ts
Normal file
15
packages/devtools-internal/src/clean-stack.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import type { StackFrame } from "error-stack-parser";
|
||||
|
||||
const unrelatedFunctionName = "renderWithHooks";
|
||||
|
||||
export const cleanStack = (stack: StackFrame[]) => {
|
||||
const firstUnrelatedIndex = stack.findIndex(
|
||||
(frame) => frame.functionName === unrelatedFunctionName,
|
||||
);
|
||||
|
||||
if (firstUnrelatedIndex !== -1) {
|
||||
return stack.slice(0, firstUnrelatedIndex);
|
||||
}
|
||||
|
||||
return stack;
|
||||
};
|
||||
4
packages/devtools-internal/src/constants.ts
Normal file
4
packages/devtools-internal/src/constants.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export const REFINE_PACKAGE_FILEPATH_REGEXP =
|
||||
__DEV_CONDITION__ !== "development"
|
||||
? /node_modules\/refinedev\/(?<name>.*?)\//
|
||||
: /\/refine\/packages\/(?<name>.*?)\//;
|
||||
17
packages/devtools-internal/src/create-identifier.ts
Normal file
17
packages/devtools-internal/src/create-identifier.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import type { TraceType } from "@refinedev/devtools-shared";
|
||||
import type { MutationKey, QueryKey } from "@tanstack/react-query";
|
||||
|
||||
export const createIdentifier = (
|
||||
key?: QueryKey | MutationKey,
|
||||
trace?: TraceType[],
|
||||
) => {
|
||||
const simpleTrace = trace?.map(
|
||||
(t) =>
|
||||
`${t.file}:${t.line}:${t.column}#${t.function}-${t.packageName}-${
|
||||
t.isRefine ? 1 : 0
|
||||
}`,
|
||||
);
|
||||
const str = JSON.stringify([...(key ?? []), ...(simpleTrace ?? [])]);
|
||||
|
||||
return str;
|
||||
};
|
||||
1
packages/devtools-internal/src/define.d.ts
vendored
Normal file
1
packages/devtools-internal/src/define.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
declare const __DEV_CONDITION__: string;
|
||||
@@ -0,0 +1,13 @@
|
||||
import { REFINE_PACKAGE_FILEPATH_REGEXP } from "./constants";
|
||||
|
||||
export const getPackageNameFromFilename = (filename?: string) => {
|
||||
if (!filename) return;
|
||||
|
||||
const match = filename.match(REFINE_PACKAGE_FILEPATH_REGEXP);
|
||||
|
||||
const name = match?.groups?.name;
|
||||
|
||||
if (!name) return;
|
||||
|
||||
return `@refinedev/${name}`;
|
||||
};
|
||||
53
packages/devtools-internal/src/get-resource-path.ts
Normal file
53
packages/devtools-internal/src/get-resource-path.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
import {
|
||||
type DevtoolsEvent,
|
||||
type DevtoolsEventPayloads,
|
||||
type RefineHook,
|
||||
scopes,
|
||||
} from "@refinedev/devtools-shared";
|
||||
|
||||
export type Activity =
|
||||
DevtoolsEventPayloads[DevtoolsEvent.DEVTOOLS_ACTIVITY_UPDATE]["updatedActivities"][number];
|
||||
|
||||
export const getResourcePath = (
|
||||
hookName: RefineHook,
|
||||
legacyKey: boolean,
|
||||
): string | null => {
|
||||
if (scopes[hookName] === "auth") {
|
||||
return null;
|
||||
}
|
||||
if (hookName === "useCan") {
|
||||
if (legacyKey) {
|
||||
return "key[1].resource";
|
||||
}
|
||||
return "key[1]";
|
||||
}
|
||||
if (scopes[hookName] === "audit-log") {
|
||||
if (hookName === "useLog") {
|
||||
return "variables.resource";
|
||||
}
|
||||
return "key[1]";
|
||||
}
|
||||
if (scopes[hookName] === "data") {
|
||||
if (hookName === "useCustom" || hookName === "useCustomMutation") {
|
||||
return null;
|
||||
}
|
||||
switch (hookName) {
|
||||
case "useList":
|
||||
case "useInfiniteList":
|
||||
case "useOne":
|
||||
case "useMany":
|
||||
if (legacyKey) {
|
||||
return "key[1]";
|
||||
}
|
||||
return "key[2]";
|
||||
case "useCreate":
|
||||
case "useCreateMany":
|
||||
case "useDelete":
|
||||
case "useDeleteMany":
|
||||
case "useUpdate":
|
||||
case "useUpdateMany":
|
||||
return "variables.resource";
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
33
packages/devtools-internal/src/get-trace.ts
Normal file
33
packages/devtools-internal/src/get-trace.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import ErrorStackParser from "error-stack-parser";
|
||||
import { cleanStack } from "./clean-stack";
|
||||
import { isRefineStack } from "./is-refine-stack";
|
||||
import { getPackageNameFromFilename } from "./get-package-name-from-filename";
|
||||
import type { TraceType } from "@refinedev/devtools-shared";
|
||||
|
||||
export function getTrace(excludeFromTrace?: string[]) {
|
||||
if (__DEV_CONDITION__ !== "development") {
|
||||
return [];
|
||||
}
|
||||
try {
|
||||
const error = new Error();
|
||||
const stack = ErrorStackParser.parse(error);
|
||||
const clean = cleanStack(stack);
|
||||
const traces = clean
|
||||
.map(
|
||||
(frame) =>
|
||||
({
|
||||
file: frame.fileName,
|
||||
line: frame.lineNumber,
|
||||
column: frame.columnNumber,
|
||||
function: frame.functionName,
|
||||
isRefine: isRefineStack(frame.fileName),
|
||||
packageName: getPackageNameFromFilename(frame.fileName),
|
||||
}) as TraceType,
|
||||
)
|
||||
.filter((trace) => trace.function)
|
||||
.filter((trace) => !excludeFromTrace?.includes(trace.function ?? ""));
|
||||
return traces.slice(1);
|
||||
} catch (error) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
38
packages/devtools-internal/src/get-xray.ts
Normal file
38
packages/devtools-internal/src/get-xray.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import type { RefineHook, TraceType } from "@refinedev/devtools-shared";
|
||||
import { getTrace } from "./get-trace";
|
||||
import { getResourcePath } from "./get-resource-path";
|
||||
|
||||
export type XRayResponse = {
|
||||
hookName: string;
|
||||
trace: TraceType[];
|
||||
resourcePath: string | null;
|
||||
legacyKey: boolean;
|
||||
resourceName?: string;
|
||||
};
|
||||
|
||||
export function getXRay(
|
||||
hookName: string,
|
||||
legacyKey: boolean,
|
||||
resourceName?: string,
|
||||
excludeFromTrace?: string[],
|
||||
): XRayResponse {
|
||||
if (__DEV_CONDITION__ !== "development") {
|
||||
return {
|
||||
hookName: "",
|
||||
trace: [],
|
||||
resourcePath: null,
|
||||
legacyKey: false,
|
||||
};
|
||||
}
|
||||
const trace = getTrace(excludeFromTrace).slice(1);
|
||||
|
||||
const resourcePath = getResourcePath(hookName as RefineHook, legacyKey);
|
||||
|
||||
return {
|
||||
hookName,
|
||||
trace,
|
||||
resourcePath,
|
||||
legacyKey,
|
||||
resourceName,
|
||||
};
|
||||
}
|
||||
3
packages/devtools-internal/src/index.ts
Normal file
3
packages/devtools-internal/src/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export { getTrace } from "./get-trace.js";
|
||||
export { getXRay } from "./get-xray.js";
|
||||
export { useQuerySubscription } from "./use-query-subscription.js";
|
||||
9
packages/devtools-internal/src/is-refine-stack.ts
Normal file
9
packages/devtools-internal/src/is-refine-stack.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { REFINE_PACKAGE_FILEPATH_REGEXP } from "./constants";
|
||||
|
||||
export const isRefineStack = (filename?: string) => {
|
||||
if (!filename) return false;
|
||||
|
||||
const match = filename.match(REFINE_PACKAGE_FILEPATH_REGEXP);
|
||||
|
||||
return !!match;
|
||||
};
|
||||
46
packages/devtools-internal/src/listeners.ts
Normal file
46
packages/devtools-internal/src/listeners.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import { DevtoolsEvent, send } from "@refinedev/devtools-shared";
|
||||
import type { Mutation, Query } from "@tanstack/react-query";
|
||||
|
||||
import { createIdentifier } from "./create-identifier";
|
||||
import type { XRayResponse } from "./get-xray";
|
||||
|
||||
export const createMutationListener =
|
||||
(ws: WebSocket) => (mutation?: Mutation) => {
|
||||
if (!mutation?.meta?.trace) return;
|
||||
|
||||
const meta: XRayResponse = mutation?.meta as any;
|
||||
|
||||
new Promise<void>((resolve) => {
|
||||
send(ws, DevtoolsEvent.ACTIVITY, {
|
||||
type: "mutation",
|
||||
identifier: createIdentifier(
|
||||
mutation?.options.mutationKey,
|
||||
mutation?.meta?.trace as any,
|
||||
),
|
||||
key: mutation?.options.mutationKey as any,
|
||||
status: mutation?.state.status,
|
||||
state: mutation?.state,
|
||||
variables: mutation?.state?.variables,
|
||||
...meta,
|
||||
});
|
||||
resolve();
|
||||
});
|
||||
};
|
||||
|
||||
export const createQueryListener = (ws: WebSocket) => (query: Query) => {
|
||||
if (!query?.meta?.trace) return;
|
||||
|
||||
const meta: XRayResponse = query?.meta as any;
|
||||
|
||||
new Promise<void>((resolve) => {
|
||||
send(ws, DevtoolsEvent.ACTIVITY, {
|
||||
type: "query",
|
||||
identifier: createIdentifier(query.queryKey, query.meta?.trace as any),
|
||||
key: query.queryKey as any,
|
||||
status: query.state.status,
|
||||
state: query.state,
|
||||
...meta,
|
||||
});
|
||||
resolve();
|
||||
});
|
||||
};
|
||||
77
packages/devtools-internal/src/use-query-subscription.tsx
Normal file
77
packages/devtools-internal/src/use-query-subscription.tsx
Normal file
@@ -0,0 +1,77 @@
|
||||
import {
|
||||
DevToolsContext,
|
||||
DevtoolsEvent,
|
||||
receive,
|
||||
} from "@refinedev/devtools-shared";
|
||||
import type { QueryClient } from "@tanstack/react-query";
|
||||
import React, { useContext } from "react";
|
||||
import { createQueryListener, createMutationListener } from "./listeners";
|
||||
|
||||
const empty = {};
|
||||
const noop = () => empty;
|
||||
|
||||
export const useQuerySubscription =
|
||||
__DEV_CONDITION__ !== "development"
|
||||
? noop
|
||||
: (queryClient: QueryClient) => {
|
||||
const { ws } = useContext(DevToolsContext);
|
||||
const queryCacheSubscription = React.useRef<() => void>();
|
||||
const mutationCacheSubscription = React.useRef<() => void>();
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!ws) return () => 0;
|
||||
|
||||
const queryCache = queryClient.getQueryCache();
|
||||
|
||||
const queryListener = createQueryListener(ws);
|
||||
|
||||
queryCache.getAll().forEach(queryListener);
|
||||
|
||||
queryCacheSubscription.current = queryCache.subscribe(
|
||||
({ query, type }) =>
|
||||
(type === "added" || type === "updated") && queryListener(query),
|
||||
);
|
||||
|
||||
return () => {
|
||||
queryCacheSubscription.current?.();
|
||||
};
|
||||
}, [ws, queryClient]);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!ws) return () => 0;
|
||||
|
||||
const mutationCache = queryClient.getMutationCache();
|
||||
|
||||
const mutationListener = createMutationListener(ws);
|
||||
|
||||
mutationCache.getAll().forEach(mutationListener);
|
||||
|
||||
mutationCacheSubscription.current = mutationCache.subscribe(
|
||||
({ mutation, type }) =>
|
||||
(type === "added" || type === "updated") &&
|
||||
mutationListener(mutation),
|
||||
);
|
||||
|
||||
return () => {
|
||||
mutationCacheSubscription.current?.();
|
||||
};
|
||||
}, [ws, queryClient]);
|
||||
|
||||
React.useEffect(() => {
|
||||
if (!ws) return () => 0;
|
||||
|
||||
const cb = receive(
|
||||
ws,
|
||||
DevtoolsEvent.DEVTOOLS_INVALIDATE_QUERY_ACTION,
|
||||
({ queryKey }) => {
|
||||
if (queryKey) {
|
||||
queryClient.invalidateQueries(queryKey);
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
return cb;
|
||||
}, [ws, queryClient]);
|
||||
|
||||
return {};
|
||||
};
|
||||
22
packages/devtools-internal/tsconfig.declarations.json
Normal file
22
packages/devtools-internal/tsconfig.declarations.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
"dist",
|
||||
"test",
|
||||
"../test/**/*",
|
||||
"**/*.spec.ts",
|
||||
"**/*.test.ts",
|
||||
"**/*.spec.tsx",
|
||||
"**/*.test.tsx"
|
||||
],
|
||||
"compilerOptions": {
|
||||
"outDir": "dist",
|
||||
"declarationDir": "dist",
|
||||
"declaration": true,
|
||||
"emitDeclarationOnly": true,
|
||||
"noEmit": false,
|
||||
"declarationMap": true,
|
||||
"paths": {}
|
||||
}
|
||||
}
|
||||
13
packages/devtools-internal/tsconfig.json
Normal file
13
packages/devtools-internal/tsconfig.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"include": ["src", "types"],
|
||||
"extends": "../../tsconfig.build.json",
|
||||
"compilerOptions": {
|
||||
"types": ["node"],
|
||||
"rootDir": "./src",
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@test/*": ["test/*"],
|
||||
"@test": ["test"]
|
||||
}
|
||||
}
|
||||
}
|
||||
8
packages/devtools-internal/tsconfig.test.json
Normal file
8
packages/devtools-internal/tsconfig.test.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"include": ["test", "src"],
|
||||
"compilerOptions": {
|
||||
"rootDir": ".",
|
||||
"types": ["node", "jest", "@testing-library/jest-dom"]
|
||||
}
|
||||
}
|
||||
36
packages/devtools-internal/tsup.config.ts
Normal file
36
packages/devtools-internal/tsup.config.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { defineConfig } from "tsup";
|
||||
import { NodeResolvePlugin } from "@esbuild-plugins/node-resolve";
|
||||
|
||||
export default defineConfig((options) => ({
|
||||
entry: ["src/index.ts"],
|
||||
splitting: false,
|
||||
sourcemap: true,
|
||||
clean: false,
|
||||
minify: true,
|
||||
format: ["cjs", "esm"],
|
||||
outExtension: ({ format }) => ({ js: format === "cjs" ? ".cjs" : ".mjs" }),
|
||||
platform: "browser",
|
||||
esbuildOptions: (options) => {
|
||||
options.define = {
|
||||
...options.define,
|
||||
__DEV_CONDITION__: "process.env.NODE_ENV",
|
||||
};
|
||||
options.banner = {
|
||||
js: '"use client"',
|
||||
};
|
||||
},
|
||||
esbuildPlugins: [
|
||||
NodeResolvePlugin({
|
||||
extensions: [".js", "ts", "tsx", "jsx"],
|
||||
onResolved: (resolved) => {
|
||||
if (resolved.includes("node_modules")) {
|
||||
return {
|
||||
external: true,
|
||||
};
|
||||
}
|
||||
return resolved;
|
||||
},
|
||||
}),
|
||||
],
|
||||
onSuccess: options.watch ? "pnpm types" : undefined,
|
||||
}));
|
||||
Reference in New Issue
Block a user