@dryui/feedback 0.0.2

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.
Files changed (79) hide show
  1. package/dist/components/annotation-marker.svelte +163 -0
  2. package/dist/components/annotation-marker.svelte.d.ts +11 -0
  3. package/dist/components/annotation-popup.svelte +669 -0
  4. package/dist/components/annotation-popup.svelte.d.ts +42 -0
  5. package/dist/components/highlight-overlay.svelte +48 -0
  6. package/dist/components/highlight-overlay.svelte.d.ts +8 -0
  7. package/dist/components/settings-panel.svelte +446 -0
  8. package/dist/components/settings-panel.svelte.d.ts +24 -0
  9. package/dist/components/toolbar.svelte +1111 -0
  10. package/dist/components/toolbar.svelte.d.ts +46 -0
  11. package/dist/constants.d.ts +9 -0
  12. package/dist/constants.js +37 -0
  13. package/dist/feedback.svelte +2879 -0
  14. package/dist/feedback.svelte.d.ts +4 -0
  15. package/dist/index.d.ts +10 -0
  16. package/dist/index.js +7 -0
  17. package/dist/layout-mode/catalog.d.ts +16 -0
  18. package/dist/layout-mode/catalog.js +81 -0
  19. package/dist/layout-mode/component-actions.svelte +84 -0
  20. package/dist/layout-mode/component-actions.svelte.d.ts +18 -0
  21. package/dist/layout-mode/component-picker.svelte +73 -0
  22. package/dist/layout-mode/component-picker.svelte.d.ts +10 -0
  23. package/dist/layout-mode/design-mode.svelte +1115 -0
  24. package/dist/layout-mode/design-mode.svelte.d.ts +24 -0
  25. package/dist/layout-mode/design-palette.svelte +396 -0
  26. package/dist/layout-mode/design-palette.svelte.d.ts +20 -0
  27. package/dist/layout-mode/element-heuristics.d.ts +5 -0
  28. package/dist/layout-mode/element-heuristics.js +51 -0
  29. package/dist/layout-mode/freeze.d.ts +6 -0
  30. package/dist/layout-mode/freeze.js +163 -0
  31. package/dist/layout-mode/generated-library.d.ts +940 -0
  32. package/dist/layout-mode/generated-library.js +1445 -0
  33. package/dist/layout-mode/geometry.d.ts +38 -0
  34. package/dist/layout-mode/geometry.js +133 -0
  35. package/dist/layout-mode/history.d.ts +10 -0
  36. package/dist/layout-mode/history.js +45 -0
  37. package/dist/layout-mode/index.d.ts +23 -0
  38. package/dist/layout-mode/index.js +18 -0
  39. package/dist/layout-mode/live-mount.d.ts +20 -0
  40. package/dist/layout-mode/live-mount.js +70 -0
  41. package/dist/layout-mode/output.d.ts +26 -0
  42. package/dist/layout-mode/output.js +550 -0
  43. package/dist/layout-mode/placement-skeleton.d.ts +9 -0
  44. package/dist/layout-mode/placement-skeleton.js +535 -0
  45. package/dist/layout-mode/rearrange-overlay.svelte +1293 -0
  46. package/dist/layout-mode/rearrange-overlay.svelte.d.ts +18 -0
  47. package/dist/layout-mode/responsive-bar.svelte +39 -0
  48. package/dist/layout-mode/responsive-bar.svelte.d.ts +8 -0
  49. package/dist/layout-mode/route-creator.svelte +70 -0
  50. package/dist/layout-mode/route-creator.svelte.d.ts +8 -0
  51. package/dist/layout-mode/section-detection.d.ts +6 -0
  52. package/dist/layout-mode/section-detection.js +214 -0
  53. package/dist/layout-mode/spatial.d.ts +42 -0
  54. package/dist/layout-mode/spatial.js +156 -0
  55. package/dist/layout-mode/types.d.ts +144 -0
  56. package/dist/layout-mode/types.js +84 -0
  57. package/dist/types.d.ts +157 -0
  58. package/dist/types.js +1 -0
  59. package/dist/utils/dryui-detection.d.ts +1 -0
  60. package/dist/utils/dryui-detection.js +219 -0
  61. package/dist/utils/element-id.d.ts +12 -0
  62. package/dist/utils/element-id.js +333 -0
  63. package/dist/utils/freeze.d.ts +7 -0
  64. package/dist/utils/freeze.js +168 -0
  65. package/dist/utils/output.d.ts +15 -0
  66. package/dist/utils/output.js +245 -0
  67. package/dist/utils/selection.d.ts +22 -0
  68. package/dist/utils/selection.js +58 -0
  69. package/dist/utils/shadow-dom.d.ts +4 -0
  70. package/dist/utils/shadow-dom.js +39 -0
  71. package/dist/utils/storage.d.ts +30 -0
  72. package/dist/utils/storage.js +206 -0
  73. package/dist/utils/svelte-detection.d.ts +8 -0
  74. package/dist/utils/svelte-detection.js +86 -0
  75. package/dist/utils/svelte-meta.d.ts +6 -0
  76. package/dist/utils/svelte-meta.js +69 -0
  77. package/dist/utils/sync.d.ts +18 -0
  78. package/dist/utils/sync.js +62 -0
  79. package/package.json +65 -0
@@ -0,0 +1,86 @@
1
+ import { collectRawSvelteLocations } from './svelte-meta.js';
2
+ const INTERNAL_FILE_PATTERNS = [
3
+ /(^|\/)node_modules\//i,
4
+ /(^|\/)\.svelte-kit\//i,
5
+ /(^|\/)svelte\/internal\//i,
6
+ /(^|\/)svelte\/src\/internal\//i,
7
+ /(^|\/)vite\/deps\//i,
8
+ /^webpack-internal:/i,
9
+ /^<anonymous>$/i,
10
+ ];
11
+ function normalizeSourceFile(file) {
12
+ const normalized = file.trim().replace(/^file:\/\//i, '').replace(/\\/g, '/');
13
+ if (!normalized)
14
+ return null;
15
+ for (const pattern of INTERNAL_FILE_PATTERNS) {
16
+ if (pattern.test(normalized))
17
+ return null;
18
+ }
19
+ const srcIndex = normalized.lastIndexOf('/src/');
20
+ if (srcIndex >= 0) {
21
+ return normalized.slice(srcIndex + 1);
22
+ }
23
+ const routesIndex = normalized.lastIndexOf('/routes/');
24
+ if (routesIndex >= 0) {
25
+ return normalized.slice(routesIndex + 1);
26
+ }
27
+ const libIndex = normalized.lastIndexOf('/lib/');
28
+ if (libIndex >= 0) {
29
+ return normalized.slice(libIndex + 1);
30
+ }
31
+ return normalized;
32
+ }
33
+ function getComponentName(file) {
34
+ const normalized = file.replace(/\\/g, '/');
35
+ const parts = normalized.split('/').filter(Boolean);
36
+ const filePart = parts.at(-1) ?? normalized;
37
+ const baseName = filePart.replace(/\.svelte(?:\.(?:js|ts))?$/i, '');
38
+ const rawName = baseName === 'index' ? (parts.at(-2) ?? baseName) : baseName;
39
+ if (rawName.startsWith('+') || rawName.includes('[')) {
40
+ return rawName;
41
+ }
42
+ const normalizedName = rawName
43
+ .split(/[-_]+/)
44
+ .filter(Boolean)
45
+ .map((part) => part.charAt(0).toUpperCase() + part.slice(1))
46
+ .join('');
47
+ if (normalizedName) {
48
+ return normalizedName;
49
+ }
50
+ return rawName.charAt(0).toUpperCase() + rawName.slice(1);
51
+ }
52
+ function formatSourceFile(file, line) {
53
+ return line ? `${file}:${line}` : file;
54
+ }
55
+ function collectComponentChain(target) {
56
+ return collectRawSvelteLocations(target)
57
+ .map((location) => {
58
+ const file = normalizeSourceFile(location.file);
59
+ if (!file)
60
+ return null;
61
+ return { file, ...(location.line ? { line: location.line } : {}) };
62
+ })
63
+ .filter((location) => location !== null);
64
+ }
65
+ export function detectSvelteMetadata(target) {
66
+ const chain = collectComponentChain(target);
67
+ if (chain.length === 0) {
68
+ return {
69
+ componentStack: [],
70
+ sourceFiles: [],
71
+ };
72
+ }
73
+ const nearest = chain[0];
74
+ const outerToInner = [...chain].reverse();
75
+ const componentStack = outerToInner.map((entry) => getComponentName(entry.file));
76
+ const sourceFiles = outerToInner.map((entry) => entry.file);
77
+ return {
78
+ sourceFile: formatSourceFile(nearest.file, nearest.line),
79
+ svelteComponent: componentStack.join(' > '),
80
+ componentStack,
81
+ sourceFiles,
82
+ };
83
+ }
84
+ export function hasSvelteMetadata(target) {
85
+ return detectSvelteMetadata(target).componentStack.length > 0;
86
+ }
@@ -0,0 +1,6 @@
1
+ export interface RawSvelteLocation {
2
+ readonly file: string;
3
+ readonly line?: number;
4
+ }
5
+ export declare function collectRawSvelteLocations(target: EventTarget | null): RawSvelteLocation[];
6
+ export declare function findTargetElement(target: EventTarget | null): Element | null;
@@ -0,0 +1,69 @@
1
+ function isRecord(value) {
2
+ return typeof value === 'object' && value !== null;
3
+ }
4
+ function isNodeLike(value) {
5
+ return typeof Node !== 'undefined' && value instanceof Node;
6
+ }
7
+ function getNumericLine(value) {
8
+ if (typeof value === 'number' && Number.isFinite(value) && value > 0) {
9
+ return Math.trunc(value);
10
+ }
11
+ return undefined;
12
+ }
13
+ function readRawSvelteLocation(node) {
14
+ const meta = node.__svelte_meta;
15
+ if (!isRecord(meta))
16
+ return null;
17
+ const loc = isRecord(meta.loc) ? meta.loc : null;
18
+ if (!loc || typeof loc.file !== 'string')
19
+ return null;
20
+ const start = isRecord(loc.start) ? loc.start : null;
21
+ const line = getNumericLine(loc.line) ?? getNumericLine(start?.line);
22
+ return { file: loc.file, ...(line ? { line } : {}) };
23
+ }
24
+ function getNextNode(node) {
25
+ if (typeof ShadowRoot !== 'undefined' && node instanceof ShadowRoot) {
26
+ return node.host;
27
+ }
28
+ if (node.parentNode) {
29
+ return node.parentNode;
30
+ }
31
+ const root = typeof node.getRootNode === 'function' ? node.getRootNode() : null;
32
+ if (typeof ShadowRoot !== 'undefined' && root instanceof ShadowRoot) {
33
+ return root.host;
34
+ }
35
+ return null;
36
+ }
37
+ export function collectRawSvelteLocations(target) {
38
+ if (!isNodeLike(target))
39
+ return [];
40
+ const chain = [];
41
+ const visited = new Set();
42
+ let current = target;
43
+ while (current && !visited.has(current)) {
44
+ visited.add(current);
45
+ const location = readRawSvelteLocation(current);
46
+ if (location) {
47
+ const previous = chain.at(-1);
48
+ if (previous?.file === location.file) {
49
+ if (previous.line === undefined && location.line !== undefined) {
50
+ chain[chain.length - 1] = location;
51
+ }
52
+ }
53
+ else {
54
+ chain.push(location);
55
+ }
56
+ }
57
+ current = getNextNode(current);
58
+ }
59
+ return chain;
60
+ }
61
+ export function findTargetElement(target) {
62
+ if (target instanceof Element)
63
+ return target;
64
+ if (target instanceof Text)
65
+ return target.parentElement;
66
+ if (isNodeLike(target) && target.parentNode instanceof Element)
67
+ return target.parentNode;
68
+ return null;
69
+ }
@@ -0,0 +1,18 @@
1
+ import type { Annotation, Session, SessionWithAnnotations, ThreadMessage } from '../types.js';
2
+ export interface ActionResponse {
3
+ success: boolean;
4
+ annotationCount: number;
5
+ delivered: {
6
+ sseListeners: number;
7
+ webhooks: number;
8
+ total: number;
9
+ };
10
+ }
11
+ export declare function listSessions(endpoint: string): Promise<Session[]>;
12
+ export declare function createSession(endpoint: string, url: string): Promise<Session>;
13
+ export declare function getSession(endpoint: string, sessionId: string): Promise<SessionWithAnnotations>;
14
+ export declare function syncAnnotation(endpoint: string, sessionId: string, annotation: Annotation): Promise<Annotation>;
15
+ export declare function updateAnnotation(endpoint: string, annotationId: string, data: Partial<Annotation>): Promise<Annotation>;
16
+ export declare function replyToAnnotation(endpoint: string, annotationId: string, message: ThreadMessage): Promise<Annotation>;
17
+ export declare function deleteAnnotation(endpoint: string, annotationId: string): Promise<void>;
18
+ export declare function requestAction(endpoint: string, sessionId: string, output: string): Promise<ActionResponse>;
@@ -0,0 +1,62 @@
1
+ async function readJson(response, message) {
2
+ if (!response.ok) {
3
+ throw new Error(`${message}: ${response.status}`);
4
+ }
5
+ return response.json();
6
+ }
7
+ export async function listSessions(endpoint) {
8
+ const response = await fetch(`${endpoint}/sessions`);
9
+ return readJson(response, 'Failed to list sessions');
10
+ }
11
+ export async function createSession(endpoint, url) {
12
+ const response = await fetch(`${endpoint}/sessions`, {
13
+ method: 'POST',
14
+ headers: { 'Content-Type': 'application/json' },
15
+ body: JSON.stringify({ url }),
16
+ });
17
+ return readJson(response, 'Failed to create session');
18
+ }
19
+ export async function getSession(endpoint, sessionId) {
20
+ const response = await fetch(`${endpoint}/sessions/${sessionId}`);
21
+ return readJson(response, 'Failed to get session');
22
+ }
23
+ export async function syncAnnotation(endpoint, sessionId, annotation) {
24
+ const response = await fetch(`${endpoint}/sessions/${sessionId}/annotations`, {
25
+ method: 'POST',
26
+ headers: { 'Content-Type': 'application/json' },
27
+ body: JSON.stringify(annotation),
28
+ });
29
+ return readJson(response, 'Failed to sync annotation');
30
+ }
31
+ export async function updateAnnotation(endpoint, annotationId, data) {
32
+ const response = await fetch(`${endpoint}/annotations/${annotationId}`, {
33
+ method: 'PATCH',
34
+ headers: { 'Content-Type': 'application/json' },
35
+ body: JSON.stringify(data),
36
+ });
37
+ return readJson(response, 'Failed to update annotation');
38
+ }
39
+ export async function replyToAnnotation(endpoint, annotationId, message) {
40
+ const response = await fetch(`${endpoint}/annotations/${annotationId}/thread`, {
41
+ method: 'POST',
42
+ headers: { 'Content-Type': 'application/json' },
43
+ body: JSON.stringify(message),
44
+ });
45
+ return readJson(response, 'Failed to reply to annotation');
46
+ }
47
+ export async function deleteAnnotation(endpoint, annotationId) {
48
+ const response = await fetch(`${endpoint}/annotations/${annotationId}`, {
49
+ method: 'DELETE',
50
+ });
51
+ if (!response.ok) {
52
+ throw new Error(`Failed to delete annotation: ${response.status}`);
53
+ }
54
+ }
55
+ export async function requestAction(endpoint, sessionId, output) {
56
+ const response = await fetch(`${endpoint}/sessions/${sessionId}/action`, {
57
+ method: 'POST',
58
+ headers: { 'Content-Type': 'application/json' },
59
+ body: JSON.stringify({ output }),
60
+ });
61
+ return readJson(response, 'Failed to request action');
62
+ }
package/package.json ADDED
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "@dryui/feedback",
3
+ "version": "0.0.2",
4
+ "author": "Rob Balfre",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/rob-balfre/dryui.git",
9
+ "directory": "packages/feedback"
10
+ },
11
+ "homepage": "https://github.com/rob-balfre/dryui#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/rob-balfre/dryui/issues"
14
+ },
15
+ "type": "module",
16
+ "svelte": "./dist/index.js",
17
+ "types": "./dist/index.d.ts",
18
+ "exports": {
19
+ ".": {
20
+ "types": "./dist/index.js",
21
+ "svelte": "./dist/index.js",
22
+ "default": "./dist/index.js"
23
+ }
24
+ },
25
+ "publishConfig": {
26
+ "access": "public",
27
+ "svelte": "./dist/index.js",
28
+ "types": "./dist/index.d.ts",
29
+ "exports": {
30
+ ".": {
31
+ "types": "./dist/index.d.ts",
32
+ "svelte": "./dist/index.js",
33
+ "default": "./dist/index.js"
34
+ }
35
+ }
36
+ },
37
+ "files": [
38
+ "dist"
39
+ ],
40
+ "scripts": {
41
+ "generate-layout-library": "node ./scripts/generate-layout-library.mjs",
42
+ "build": "bun run generate-layout-library && svelte-package -i src",
43
+ "check": "svelte-check --tsconfig ./tsconfig.json"
44
+ },
45
+ "dependencies": {
46
+ "@dryui/primitives": "workspace:*",
47
+ "@dryui/ui": "workspace:*",
48
+ "@dryui/mcp": "workspace:*"
49
+ },
50
+ "peerDependencies": {
51
+ "svelte": "^5.55.1",
52
+ "lucide-svelte": ">=1.0.1"
53
+ },
54
+ "peerDependenciesMeta": {
55
+ "lucide-svelte": {
56
+ "optional": true
57
+ }
58
+ },
59
+ "devDependencies": {
60
+ "svelte": "^5.55.1",
61
+ "@sveltejs/package": "^2.5.7",
62
+ "svelte-check": "^4.4.5",
63
+ "typescript": "^6.0.2"
64
+ }
65
+ }