@siteping/widget 0.10.2 → 0.10.4
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/dist/chunk-RHP4S23A.cjs +1796 -0
- package/dist/chunk-RHP4S23A.cjs.map +1 -0
- package/dist/de-AZUOIGF2.cjs +2 -0
- package/dist/de-AZUOIGF2.cjs.map +1 -0
- package/dist/errors.d.cts +41 -0
- package/dist/errors.d.ts +41 -0
- package/dist/es-5XQA3TPT.cjs +2 -0
- package/dist/es-5XQA3TPT.cjs.map +1 -0
- package/dist/filters.d.cts +31 -0
- package/dist/filters.d.ts +31 -0
- package/dist/fr-ERYSAH32.cjs +2 -0
- package/dist/fr-ERYSAH32.cjs.map +1 -0
- package/dist/index.cjs +1589 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +24 -0
- package/dist/index.global.js +90 -90
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +40 -40
- package/dist/index.js.map +1 -1
- package/dist/it-NXAZR4K6.cjs +2 -0
- package/dist/it-NXAZR4K6.cjs.map +1 -0
- package/dist/panel-N7TAQKDR.cjs +2 -0
- package/dist/panel-N7TAQKDR.cjs.map +1 -0
- package/dist/pt-CODDT6VY.cjs +2 -0
- package/dist/pt-CODDT6VY.cjs.map +1 -0
- package/dist/react.cjs +1589 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +59 -0
- package/dist/react.js +44 -44
- package/dist/react.js.map +1 -1
- package/dist/ru-72WUEADV.cjs +2 -0
- package/dist/ru-72WUEADV.cjs.map +1 -0
- package/dist/schema.d.cts +263 -0
- package/dist/screenshot-storage.d.cts +56 -0
- package/dist/screenshot-storage.d.ts +56 -0
- package/dist/siteping-core.d.cts +11 -0
- package/dist/type-utils.d.cts +89 -0
- package/dist/type-utils.d.ts +89 -0
- package/dist/types.d.cts +799 -0
- package/package.json +19 -6
package/dist/react.d.cts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { SitepingConfig, SitepingInstance } from './siteping-core.cjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* React helper for `@siteping/widget`.
|
|
5
|
+
*
|
|
6
|
+
* `useSiteping` initialises the widget once for the lifetime of the component
|
|
7
|
+
* tree, even under React.StrictMode's double-invoke effect dance. Returns the
|
|
8
|
+
* `SitepingInstance` so consumers can drive `open()` / `close()` / `refresh()`
|
|
9
|
+
* programmatically from anywhere in their tree.
|
|
10
|
+
*
|
|
11
|
+
* Why a dedicated entry instead of a snippet in the README:
|
|
12
|
+
* - StrictMode mounts every effect twice in dev, which the obvious
|
|
13
|
+
* `useEffect(() => { const i = initSiteping(...); return i.destroy }, [])`
|
|
14
|
+
* handles fine for *re-mount*, but not for the brief window where the
|
|
15
|
+
* second mount sees a still-alive widget (the widget's own singleton guard
|
|
16
|
+
* logs an info message and returns the existing instance — surprising
|
|
17
|
+
* noise for developers).
|
|
18
|
+
* - The hook also captures the latest `config` in a ref so callbacks (e.g.
|
|
19
|
+
* `onFeedbackSent`) read closure values without re-initialising the widget.
|
|
20
|
+
*
|
|
21
|
+
* Peer dep on react ≥ 18 (declared as optional in package.json), so projects
|
|
22
|
+
* that never import `@siteping/widget/react` don't need React installed.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Initialise the SitePing widget for the lifetime of the calling component.
|
|
27
|
+
*
|
|
28
|
+
* Safe to call from a Server Component file as long as the component itself
|
|
29
|
+
* is marked `"use client"` — the hook bails out cleanly on the server because
|
|
30
|
+
* `useEffect` never runs there.
|
|
31
|
+
*
|
|
32
|
+
* @example Next.js App Router
|
|
33
|
+
* ```tsx
|
|
34
|
+
* "use client"
|
|
35
|
+
* import { useSiteping } from "@siteping/widget/react"
|
|
36
|
+
*
|
|
37
|
+
* export function FeedbackProvider({ children }: { children: React.ReactNode }) {
|
|
38
|
+
* useSiteping({
|
|
39
|
+
* endpoint: "/api/siteping",
|
|
40
|
+
* projectName: "my-app",
|
|
41
|
+
* })
|
|
42
|
+
* return <>{children}</>
|
|
43
|
+
* }
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* @example Driving the panel programmatically
|
|
47
|
+
* ```tsx
|
|
48
|
+
* "use client"
|
|
49
|
+
* import { useSiteping } from "@siteping/widget/react"
|
|
50
|
+
*
|
|
51
|
+
* export function HelpButton() {
|
|
52
|
+
* const widget = useSiteping({ endpoint: "/api/siteping", projectName: "my-app" })
|
|
53
|
+
* return <button onClick={() => widget?.open()}>Need help?</button>
|
|
54
|
+
* }
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
declare function useSiteping(config: SitepingConfig): SitepingInstance | null;
|
|
58
|
+
|
|
59
|
+
export { useSiteping };
|