@dudousxd/nestjs-telescope-ui 1.19.0 → 1.20.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,35 @@
1
1
  # @dudousxd/nestjs-telescope-ui
2
2
 
3
+ ## 1.20.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#69](https://github.com/DavideCarvalho/nestjs-telescope/pull/69) [`acdfacb`](https://github.com/DavideCarvalho/nestjs-telescope/commit/acdfacba22495b6517bf89d7e50a25d3032c1933) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Clear the console launcher's pending state when the page is restored from the back/forward cache.
8
+
9
+ `useOpenTelescopeConsole` deliberately keeps `isPending` set after a successful mint so the button
10
+ does not flicker back to idle on a page that is navigating away. With bfcache the page does not die:
11
+ pressing Back restored the launcher with its React state intact, leaving a permanent "Opening…"
12
+ spinner on a button that could never be clicked again. The hook now listens for `pageshow` and
13
+ resets only when `event.persisted` is true, so a fresh load and a mint that is still genuinely in
14
+ flight both keep the original behaviour.
15
+
16
+ ## 1.20.0
17
+
18
+ ### Minor Changes
19
+
20
+ - [#67](https://github.com/DavideCarvalho/nestjs-telescope/pull/67) [`87c8732`](https://github.com/DavideCarvalho/nestjs-telescope/commit/87c8732006a46eeea50d1dd1536c8a9794a13ae5) Thanks [@DavideCarvalho](https://github.com/DavideCarvalho)! - Ship the console launcher on its own subpath: `@dudousxd/nestjs-telescope-ui/react/console`.
21
+
22
+ The launcher was only reachable from the `./react` barrel, which re-exports the whole dashboard
23
+ component set and therefore pulls in `recharts` and `react-router-dom`. Neither is declared by this
24
+ package, and a bundler resolves re-exported modules even when nothing references them — so a host
25
+ that wanted nothing but the launcher button got a hard build failure on a missing dependency
26
+ instead of tree-shaking it away.
27
+
28
+ `./react/console` re-exports the hook, the button and the headless client primitives, and nothing
29
+ else. Its entire dependency footprint is `react`, guarded by a test that walks the import graph.
30
+
31
+ `./react` is unchanged and still exports the launcher, so nothing breaks.
32
+
3
33
  ## 1.19.0
4
34
 
5
35
  ### Minor Changes
@@ -0,0 +1,4 @@
1
+ export * from './use-open-console.js';
2
+ export * from './open-console-button.js';
3
+ export { ConsoleSessionError, telescopeConsoleSessionUrl, telescopeConsoleUrl, mintTelescopeConsoleSession, openTelescopeConsole, type OpenConsoleOptions, } from '../client/console-session.js';
4
+ //# sourceMappingURL=console.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"console.d.ts","sourceRoot":"","sources":["../../src/react/console.ts"],"names":[],"mappings":"AAUA,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,OAAO,EACL,mBAAmB,EACnB,0BAA0B,EAC1B,mBAAmB,EACnB,2BAA2B,EAC3B,oBAAoB,EACpB,KAAK,kBAAkB,GACxB,MAAM,8BAA8B,CAAC"}
@@ -0,0 +1,14 @@
1
+ // The console launcher on its own subpath (`@dudousxd/nestjs-telescope-ui/react/console`).
2
+ //
3
+ // It is also exported from `./react`, but that barrel re-exports the whole dashboard component set,
4
+ // which pulls in `recharts` and `react-router-dom`. Those are not declared by this package, so a
5
+ // host that wants ONLY the launcher — the common case, a button on an admin page — cannot import
6
+ // from the barrel: a bundler resolves re-exported modules even when nothing uses them, and the
7
+ // build fails on the missing dependency rather than tree-shaking it away.
8
+ //
9
+ // This entry re-exports only the launcher and the headless primitives it wraps, so its entire
10
+ // dependency footprint is `react`.
11
+ export * from './use-open-console.js';
12
+ export * from './open-console-button.js';
13
+ export { ConsoleSessionError, telescopeConsoleSessionUrl, telescopeConsoleUrl, mintTelescopeConsoleSession, openTelescopeConsole, } from '../client/console-session.js';
14
+ //# sourceMappingURL=console.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"console.js","sourceRoot":"","sources":["../../src/react/console.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,EAAE;AACF,oGAAoG;AACpG,iGAAiG;AACjG,iGAAiG;AACjG,+FAA+F;AAC/F,0EAA0E;AAC1E,EAAE;AACF,8FAA8F;AAC9F,mCAAmC;AACnC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,OAAO,EACL,mBAAmB,EACnB,0BAA0B,EAC1B,mBAAmB,EACnB,2BAA2B,EAC3B,oBAAoB,GAErB,MAAM,8BAA8B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-open-console.d.ts","sourceRoot":"","sources":["../../src/react/use-open-console.ts"],"names":[],"mappings":"AACA,OAAO,EACL,mBAAmB,EACnB,KAAK,kBAAkB,EAGxB,MAAM,8BAA8B,CAAC;AAEtC;;;;;;;GAOG;AACH,MAAM,WAAW,oBAAoB;IACnC,0EAA0E;IAC1E,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,0EAA0E;IAC1E,SAAS,EAAE,OAAO,CAAC;IACnB,0EAA0E;IAC1E,KAAK,EAAE,mBAAmB,GAAG,IAAI,CAAC;IAClC,uEAAuE;IACvE,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED,wBAAgB,uBAAuB,CAAC,OAAO,GAAE,kBAAuB,GAAG,oBAAoB,CAoC9F;AAED;;;;;;;;GAQG;AACH,wBAAgB,mCAAmC,CAAC,OAAO,GAAE,kBAAuB,GAAG;IACrF,WAAW,EAAE,SAAS,OAAO,EAAE,CAAC;IAChC,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACjC,CAKA"}
1
+ {"version":3,"file":"use-open-console.d.ts","sourceRoot":"","sources":["../../src/react/use-open-console.ts"],"names":[],"mappings":"AACA,OAAO,EACL,mBAAmB,EACnB,KAAK,kBAAkB,EAGxB,MAAM,8BAA8B,CAAC;AAEtC;;;;;;;GAOG;AACH,MAAM,WAAW,oBAAoB;IACnC,0EAA0E;IAC1E,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,0EAA0E;IAC1E,SAAS,EAAE,OAAO,CAAC;IACnB,0EAA0E;IAC1E,KAAK,EAAE,mBAAmB,GAAG,IAAI,CAAC;IAClC,uEAAuE;IACvE,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED,wBAAgB,uBAAuB,CAAC,OAAO,GAAE,kBAAuB,GAAG,oBAAoB,CA0D9F;AAED;;;;;;;;GAQG;AACH,wBAAgB,mCAAmC,CAAC,OAAO,GAAE,kBAAuB,GAAG;IACrF,WAAW,EAAE,SAAS,OAAO,EAAE,CAAC;IAChC,UAAU,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACjC,CAKA"}
@@ -1,4 +1,4 @@
1
- import { useCallback, useRef, useState } from 'react';
1
+ import { useCallback, useEffect, useRef, useState } from 'react';
2
2
  import { ConsoleSessionError, openTelescopeConsole, telescopeConsoleSessionUrl, } from '../client/console-session.js';
3
3
  export function useOpenTelescopeConsole(options = {}) {
4
4
  const [isPending, setIsPending] = useState(false);
@@ -15,6 +15,9 @@ export function useOpenTelescopeConsole(options = {}) {
15
15
  // Deliberately NOT clearing `isPending` on success: the navigation is already underway and
16
16
  // this component is about to be torn down. Flipping the button back to idle first produces
17
17
  // a visible flicker of "ready to click again" on a page that is leaving.
18
+ //
19
+ // "About to be torn down" is not guaranteed, though — see the `pageshow` effect below for
20
+ // the case where the page comes back instead of dying.
18
21
  })
19
22
  .catch((cause) => {
20
23
  setError(cause instanceof ConsoleSessionError
@@ -25,6 +28,26 @@ export function useOpenTelescopeConsole(options = {}) {
25
28
  setIsPending(false);
26
29
  });
27
30
  }, []);
31
+ // The success path above leaves `isPending` true on the assumption that the page is leaving for
32
+ // good. The back/forward cache breaks that assumption: instead of destroying the document, the
33
+ // browser freezes it and restores it — React state and all — when the user presses Back. Without
34
+ // this the user returns from the console to a spinner that never stops, on a button that is
35
+ // permanently disabled because nothing else ever clears the flag.
36
+ //
37
+ // `persisted === true` is the ONLY signal that distinguishes a restore from a fresh load, and the
38
+ // condition is load-bearing in both directions: a normal `pageshow` (`persisted: false`) fires on
39
+ // every page load and must not touch anything, and a mint that is genuinely still in flight must
40
+ // keep its spinner. Dropping the check to "simplify" reintroduces the flicker this hook avoids.
41
+ useEffect(() => {
42
+ if (typeof window === 'undefined')
43
+ return;
44
+ const onPageShow = (event) => {
45
+ if (event.persisted)
46
+ setIsPending(false);
47
+ };
48
+ window.addEventListener('pageshow', onPageShow);
49
+ return () => window.removeEventListener('pageshow', onPageShow);
50
+ }, []);
28
51
  const reset = useCallback(() => setError(null), []);
29
52
  return { open, isPending, error, reset };
30
53
  }
@@ -1 +1 @@
1
- {"version":3,"file":"use-open-console.js","sourceRoot":"","sources":["../../src/react/use-open-console.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,EACL,mBAAmB,EAEnB,oBAAoB,EACpB,0BAA0B,GAC3B,MAAM,8BAA8B,CAAC;AAqBtC,MAAM,UAAU,uBAAuB,CAAC,UAA8B,EAAE;IACtE,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAClD,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAA6B,IAAI,CAAC,CAAC;IAErE,kGAAkG;IAClG,wFAAwF;IACxF,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;IACnC,UAAU,CAAC,OAAO,GAAG,OAAO,CAAC;IAE7B,MAAM,IAAI,GAAG,WAAW,CAAC,GAAG,EAAE;QAC5B,YAAY,CAAC,IAAI,CAAC,CAAC;QACnB,QAAQ,CAAC,IAAI,CAAC,CAAC;QACf,KAAK,oBAAoB,CAAC,UAAU,CAAC,OAAO,CAAC;aAC1C,IAAI,CAAC,GAAG,EAAE;YACT,2FAA2F;YAC3F,2FAA2F;YAC3F,yEAAyE;QAC3E,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE;YACxB,QAAQ,CACN,KAAK,YAAY,mBAAmB;gBAClC,CAAC,C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UAAU,CAAC,CAAC;IAClE,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;IAEpD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AAC3C,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,mCAAmC,CAAC,UAA8B,EAAE;IAIlF,OAAO;QACL,WAAW,EAAE,CAAC,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAU;QAChF,UAAU,EAAE,GAAG,EAAE,CAAC,oBAAoB,CAAC,OAAO,CAAC;KAChD,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dudousxd/nestjs-telescope-ui",
3
- "version": "1.19.0",
3
+ "version": "1.20.1",
4
4
  "description": "Bundled dashboard + composable React components for @dudousxd/nestjs-telescope.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -27,6 +27,11 @@
27
27
  "import": "./dist/react/index.js",
28
28
  "default": "./dist/react/index.js"
29
29
  },
30
+ "./react/console": {
31
+ "types": "./dist/react/console.d.ts",
32
+ "import": "./dist/react/console.js",
33
+ "default": "./dist/react/console.js"
34
+ },
30
35
  "./client": {
31
36
  "types": "./dist/client/index.d.ts",
32
37
  "import": "./dist/client/index.js",