@mahmulp/feedback-sdk 0.0.1 → 0.1.0
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/LICENSE +21 -21
- package/README.md +110 -111
- package/dist/index.cjs.map +1 -1
- package/dist/index.global.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/mock.cjs.map +1 -1
- package/dist/mock.js.map +1 -1
- package/dist/svelte.js.map +1 -1
- package/package.json +1 -1
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Machmul Pratama
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Machmul Pratama
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,111 +1,110 @@
|
|
|
1
|
-
# @mahmulp/feedback-sdk
|
|
2
|
-
|
|
3
|
-
[](https://www.npmjs.com/package/@mahmulp/feedback-sdk)
|
|
4
|
-
[](https://www.npmjs.com/package/@mahmulp/feedback-sdk)
|
|
4
|
+
[](https://bundlephobia.com/package/@mahmulp/feedback-sdk)
|
|
5
|
+
|
|
6
|
+
Framework-agnostic visual feedback SDK for prototype review. Reviewers pin comments to UI elements; you get back a stable DOM selector, percentage + pixel coordinates, viewport metadata, and an optional screenshot.
|
|
7
|
+
|
|
8
|
+
Designed for **self-hosted** setups: pair this SDK with a backend (we ship one in the same repo) and own your data.
|
|
9
|
+
|
|
10
|
+
- Floating launcher widget built in (toggle feedback mode, hide pins, hide launcher)
|
|
11
|
+
- Stable DOM selectors that survive layout changes
|
|
12
|
+
- Drag-to-move pins with optimistic update
|
|
13
|
+
- Optional screenshot capture (via dynamically loaded `html2canvas`)
|
|
14
|
+
- Svelte adapter for ergonomic SvelteKit integration
|
|
15
|
+
- Works in React, Vue, and plain HTML via the same core API
|
|
16
|
+
|
|
17
|
+
## Install
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install @mahmulp/feedback-sdk
|
|
21
|
+
bun add @mahmulp/feedback-sdk
|
|
22
|
+
pnpm add @mahmulp/feedback-sdk
|
|
23
|
+
yarn add @mahmulp/feedback-sdk
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Quick start
|
|
27
|
+
|
|
28
|
+
You always need an `apiUrl` and an `apiKey`. The key tells the API which project this prototype belongs to — generate one in your dashboard's project settings.
|
|
29
|
+
|
|
30
|
+
### Vanilla / React / Vue
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
import { initFeedback } from '@mahmulp/feedback-sdk'
|
|
34
|
+
|
|
35
|
+
initFeedback({
|
|
36
|
+
apiUrl: 'https://feedback.example.com',
|
|
37
|
+
apiKey: 'mp_…',
|
|
38
|
+
})
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
That's it. A floating launcher appears in the bottom-right corner.
|
|
42
|
+
|
|
43
|
+
### Svelte / SvelteKit
|
|
44
|
+
|
|
45
|
+
```svelte
|
|
46
|
+
<script lang="ts">
|
|
47
|
+
import { feedback } from '@mahmulp/feedback-sdk/svelte'
|
|
48
|
+
</script>
|
|
49
|
+
|
|
50
|
+
<div use:feedback={{
|
|
51
|
+
apiUrl: 'https://feedback.example.com',
|
|
52
|
+
apiKey: 'mp_…',
|
|
53
|
+
}}>
|
|
54
|
+
<slot />
|
|
55
|
+
</div>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Local development without a backend
|
|
59
|
+
|
|
60
|
+
For demos, e2e tests, or styling work — use the in-memory mock transport:
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
import { initFeedback } from '@mahmulp/feedback-sdk'
|
|
64
|
+
import { createMockTransport } from '@mahmulp/feedback-sdk/mock'
|
|
65
|
+
|
|
66
|
+
initFeedback({ transport: createMockTransport() })
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## What it does
|
|
70
|
+
|
|
71
|
+
When the user enters feedback mode (via the launcher or `setEnabled(true)`):
|
|
72
|
+
|
|
73
|
+
- **Hover** any element → outline highlight + tag/class HUD.
|
|
74
|
+
- **Click** → composer popover (name, email, comment, optional screenshot).
|
|
75
|
+
- **Alt-click** → walks one parent up so you can pin a coarser element.
|
|
76
|
+
- **Esc** → cancel.
|
|
77
|
+
|
|
78
|
+
Existing pins are rendered as draggable markers. Click a pin to open its thread, reply, or change status. Drop a `data-feedback-id="some-key"` attribute on important elements to make their selectors human-readable and refactor-proof.
|
|
79
|
+
|
|
80
|
+
## Public API
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
import {
|
|
84
|
+
initFeedback,
|
|
85
|
+
setFeedbackEnabled,
|
|
86
|
+
destroyFeedback,
|
|
87
|
+
resolveSelector,
|
|
88
|
+
findElement,
|
|
89
|
+
createHttpTransport,
|
|
90
|
+
captureViewport,
|
|
91
|
+
} from '@mahmulp/feedback-sdk'
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
import { feedback, feedbackEnabled } from '@mahmulp/feedback-sdk/svelte'
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
```ts
|
|
99
|
+
import { createMockTransport } from '@mahmulp/feedback-sdk/mock'
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
The full set of options is documented in `InitFeedbackOptions` (TypeScript types ship with the package).
|
|
103
|
+
|
|
104
|
+
## Self-host the backend
|
|
105
|
+
|
|
106
|
+
The SDK pairs with a small self-hostable backend (Hono on Bun + PostgreSQL or in-memory store) that lives in the same monorepo: <https://github.com/MahmulP/feedback-prototype>. The dashboard there manages users, projects, and per-project API keys.
|
|
107
|
+
|
|
108
|
+
## License
|
|
109
|
+
|
|
110
|
+
MIT © Mahmul Pratama
|