next-cache-toolbar 0.3.0 → 0.3.1

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.
@@ -1,19 +1,19 @@
1
1
  'use client';
2
2
  var jsxRuntime = require('react/jsx-runtime');
3
- var getCacheEntriesServer = require('./getCacheEntries-server-B4Sz1uw3.js');
3
+ var getCacheEntriesServer = require('./getCacheEntries-server-Bq5gM82M.js');
4
4
  var cacheEntryClient = require('./cache-entry-client-BlFbLrtq.js');
5
5
  var lucideReact = require('lucide-react');
6
6
  var navigation = require('next/navigation');
7
7
  var React = require('react');
8
8
  var cachePanelContextClient = require('./cache-panel-context-client-CkDMJX2-.js');
9
9
 
10
- function RefreshDataButton({ enabled, interval }) {
10
+ function RefreshDataButton({ enabled, interval, distDir }) {
11
11
  const { setEntries } = cachePanelContextClient.useCachePanelContext();
12
12
  const [isPending, startTransition] = React.useTransition();
13
13
  const pathname = navigation.usePathname();
14
14
  const refreshData = ()=>{
15
15
  startTransition(async ()=>{
16
- const files = await getCacheEntriesServer.getCacheFiles();
16
+ const files = await getCacheEntriesServer.getCacheFiles(distDir);
17
17
  setEntries(files ?? []);
18
18
  });
19
19
  };
@@ -61,8 +61,8 @@ const nextCacheFileSchema = zod.z.union([
61
61
  };
62
62
  });
63
63
 
64
- const cachePath = ".next/cache/fetch-cache";
65
- const getCacheFiles = async ()=>{
64
+ const getCacheFiles = async (distDir)=>{
65
+ const cachePath = `${distDir}/cache/fetch-cache`;
66
66
  if (!node_fs.existsSync(cachePath)) {
67
67
  return;
68
68
  }
@@ -16,7 +16,12 @@ type Props = {
16
16
  * @default false
17
17
  */
18
18
  purgeButton?: boolean;
19
+ /**
20
+ * Output path for next build, should be in sync with `distDir` parameter from next.config
21
+ * @default ".next"
22
+ */
23
+ distDir?: string;
19
24
  };
20
- declare function NextCacheToolbar({ autoRefresh, interval, purgeButton, }: Props): Promise<react_jsx_runtime.JSX.Element>;
25
+ declare function NextCacheToolbar({ autoRefresh, interval, purgeButton, distDir, }: Props): Promise<react_jsx_runtime.JSX.Element>;
21
26
 
22
27
  export { NextCacheToolbar };
package/dist/cjs/index.js CHANGED
@@ -2,18 +2,18 @@ Object.defineProperty(exports, '__esModule', { value: true });
2
2
 
3
3
  var jsxRuntime = require('react/jsx-runtime');
4
4
  var lucideReact = require('lucide-react');
5
- var getCacheEntriesServer = require('./getCacheEntries-server-B4Sz1uw3.js');
5
+ var getCacheEntriesServer = require('./getCacheEntries-server-Bq5gM82M.js');
6
6
  var cacheEntryClient = require('./cache-entry-client-BlFbLrtq.js');
7
7
  var cachePanelContextClient = require('./cache-panel-context-client-CkDMJX2-.js');
8
8
  var cachePanelTableClient = require('./cache-panel-table-client-DBvA6vo5.js');
9
9
  var cachePanelTriggerClient = require('./cache-panel-trigger-client-0RzTHzAT.js');
10
10
  var cachePanelWrapperClient = require('./cache-panel-wrapper-client-DTI35uJg.js');
11
11
  var cachePurgeButtonClient = require('./cache-purge-button-client-CXGIDomZ.js');
12
- var cacheRefreshDataClient = require('./cache-refresh-data-client-DJC8x360.js');
12
+ var cacheRefreshDataClient = require('./cache-refresh-data-client-DIPw0IhW.js');
13
13
  var cachePanelHeadClient = require('./cache-panel-head-client-BqfBWPpR.js');
14
14
 
15
- async function NextCacheToolbar({ autoRefresh = false, interval = 10000, purgeButton = false }) {
16
- const files = await getCacheEntriesServer.getCacheFiles();
15
+ async function NextCacheToolbar({ autoRefresh = false, interval = 10000, purgeButton = false, distDir = ".next" }) {
16
+ const files = await getCacheEntriesServer.getCacheFiles(distDir);
17
17
  return /*#__PURE__*/ jsxRuntime.jsx("div", {
18
18
  id: "next-cache-toolbar",
19
19
  className: "nct-text-primary nct-font-mono",
@@ -56,7 +56,8 @@ async function NextCacheToolbar({ autoRefresh = false, interval = 10000, purgeBu
56
56
  children: [
57
57
  /*#__PURE__*/ jsxRuntime.jsx(cacheRefreshDataClient.RefreshDataButton, {
58
58
  enabled: autoRefresh,
59
- interval: interval
59
+ interval: interval,
60
+ distDir: distDir
60
61
  }),
61
62
  purgeButton && /*#__PURE__*/ jsxRuntime.jsx(cachePurgeButtonClient.CachePurgeButton, {}),
62
63
  /*#__PURE__*/ jsxRuntime.jsx(cachePanelTriggerClient.CachePanelTrigger, {
@@ -1,19 +1,19 @@
1
1
  'use client';
2
2
  import { jsx } from 'react/jsx-runtime';
3
- import { g as getCacheFiles } from './getCacheEntries-server-CPw1bnT3.mjs';
3
+ import { g as getCacheFiles } from './getCacheEntries-server-eY7FwQMw.mjs';
4
4
  import { B as Button, c as cn } from './cache-entry-client-Bk7a0rFQ.mjs';
5
5
  import { Loader2 } from 'lucide-react';
6
6
  import { usePathname } from 'next/navigation';
7
7
  import { useTransition, useEffect } from 'react';
8
8
  import { u as useCachePanelContext } from './cache-panel-context-client-DlqXZGzO.mjs';
9
9
 
10
- function RefreshDataButton({ enabled, interval }) {
10
+ function RefreshDataButton({ enabled, interval, distDir }) {
11
11
  const { setEntries } = useCachePanelContext();
12
12
  const [isPending, startTransition] = useTransition();
13
13
  const pathname = usePathname();
14
14
  const refreshData = ()=>{
15
15
  startTransition(async ()=>{
16
- const files = await getCacheFiles();
16
+ const files = await getCacheFiles(distDir);
17
17
  setEntries(files ?? []);
18
18
  });
19
19
  };
@@ -61,8 +61,8 @@ const nextCacheFileSchema = z.union([
61
61
  };
62
62
  });
63
63
 
64
- const cachePath = ".next/cache/fetch-cache";
65
- const getCacheFiles = async ()=>{
64
+ const getCacheFiles = async (distDir)=>{
65
+ const cachePath = `${distDir}/cache/fetch-cache`;
66
66
  if (!existsSync(cachePath)) {
67
67
  return;
68
68
  }
@@ -16,7 +16,12 @@ type Props = {
16
16
  * @default false
17
17
  */
18
18
  purgeButton?: boolean;
19
+ /**
20
+ * Output path for next build, should be in sync with `distDir` parameter from next.config
21
+ * @default ".next"
22
+ */
23
+ distDir?: string;
19
24
  };
20
- declare function NextCacheToolbar({ autoRefresh, interval, purgeButton, }: Props): Promise<react_jsx_runtime.JSX.Element>;
25
+ declare function NextCacheToolbar({ autoRefresh, interval, purgeButton, distDir, }: Props): Promise<react_jsx_runtime.JSX.Element>;
21
26
 
22
27
  export { NextCacheToolbar };
package/dist/es/index.mjs CHANGED
@@ -1,17 +1,17 @@
1
1
  import { jsx, jsxs } from 'react/jsx-runtime';
2
2
  import { Layers3Icon, PanelBottomCloseIcon } from 'lucide-react';
3
- import { g as getCacheFiles } from './getCacheEntries-server-CPw1bnT3.mjs';
3
+ import { g as getCacheFiles } from './getCacheEntries-server-eY7FwQMw.mjs';
4
4
  import { f as TableHeader, b as TableRow, T as TableHead } from './cache-entry-client-Bk7a0rFQ.mjs';
5
5
  import { C as CachePanelContextProvider } from './cache-panel-context-client-DlqXZGzO.mjs';
6
6
  import { C as CachePanelTable } from './cache-panel-table-client-B844eHwF.mjs';
7
7
  import { C as CachePanelTrigger } from './cache-panel-trigger-client-CbXiKLEx.mjs';
8
8
  import { C as CacheTable } from './cache-panel-wrapper-client-Dcmlm3kc.mjs';
9
9
  import { C as CachePurgeButton } from './cache-purge-button-client-CN9H6t8R.mjs';
10
- import { R as RefreshDataButton } from './cache-refresh-data-client-Cixnlkkn.mjs';
10
+ import { R as RefreshDataButton } from './cache-refresh-data-client-CX8rfbFV.mjs';
11
11
  import { C as CachePanelHead } from './cache-panel-head-client-DTReOdNO.mjs';
12
12
 
13
- async function NextCacheToolbar({ autoRefresh = false, interval = 10000, purgeButton = false }) {
14
- const files = await getCacheFiles();
13
+ async function NextCacheToolbar({ autoRefresh = false, interval = 10000, purgeButton = false, distDir = ".next" }) {
14
+ const files = await getCacheFiles(distDir);
15
15
  return /*#__PURE__*/ jsx("div", {
16
16
  id: "next-cache-toolbar",
17
17
  className: "nct-text-primary nct-font-mono",
@@ -54,7 +54,8 @@ async function NextCacheToolbar({ autoRefresh = false, interval = 10000, purgeBu
54
54
  children: [
55
55
  /*#__PURE__*/ jsx(RefreshDataButton, {
56
56
  enabled: autoRefresh,
57
- interval: interval
57
+ interval: interval,
58
+ distDir: distDir
58
59
  }),
59
60
  purgeButton && /*#__PURE__*/ jsx(CachePurgeButton, {}),
60
61
  /*#__PURE__*/ jsx(CachePanelTrigger, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-cache-toolbar",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Toolbar with all cached data in Next.js app router",
5
5
  "scripts": {
6
6
  "prepublish": "npm run build",