@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,38 @@
1
+ import type { DetectedSection, Rect, DesignPlacement } from './types.js';
2
+ export type Guide = {
3
+ axis: 'x' | 'y';
4
+ pos: number;
5
+ };
6
+ export type SnapRect = Rect;
7
+ export declare const MIN_SIZE = 24;
8
+ export declare const SNAP_THRESHOLD = 5;
9
+ export declare const MIN_CAPTURE_SIZE = 16;
10
+ export declare function computeSnap(rect: SnapRect, others: readonly DesignPlacement[], excludeIds: ReadonlySet<string>, activeEdges?: {
11
+ left?: boolean;
12
+ right?: boolean;
13
+ top?: boolean;
14
+ bottom?: boolean;
15
+ }, extraRects?: readonly SnapRect[]): {
16
+ dx: number;
17
+ dy: number;
18
+ guides: Guide[];
19
+ };
20
+ export declare function computeSectionSnap(rect: SnapRect, sections: readonly DetectedSection[], excludeIds: ReadonlySet<string>, activeEdges?: {
21
+ left?: boolean;
22
+ right?: boolean;
23
+ top?: boolean;
24
+ bottom?: boolean;
25
+ }, extraRects?: readonly SnapRect[]): {
26
+ dx: number;
27
+ dy: number;
28
+ guides: Guide[];
29
+ };
30
+ export declare function createRectFromPoint(start: {
31
+ x: number;
32
+ y: number;
33
+ }, end: {
34
+ x: number;
35
+ y: number;
36
+ }): Rect;
37
+ export declare function isMeaningfulDrag(rect: Rect, threshold?: number): boolean;
38
+ export declare function dedupeRects(rects: readonly Rect[]): Rect[];
@@ -0,0 +1,133 @@
1
+ export const MIN_SIZE = 24;
2
+ export const SNAP_THRESHOLD = 5;
3
+ export const MIN_CAPTURE_SIZE = 16;
4
+ function snapAxes(rect, targets, activeEdges, extraRects) {
5
+ let bestDx = Infinity;
6
+ let bestDy = Infinity;
7
+ const middleLeft = rect.x;
8
+ const middleRight = rect.x + rect.width;
9
+ const middleCenterX = rect.x + rect.width / 2;
10
+ const middleTop = rect.y;
11
+ const middleBottom = rect.y + rect.height;
12
+ const middleCenterY = rect.y + rect.height / 2;
13
+ const allTargets = [];
14
+ for (const target of targets) {
15
+ allTargets.push(target);
16
+ }
17
+ if (extraRects) {
18
+ allTargets.push(...extraRects);
19
+ }
20
+ const fromX = activeEdges
21
+ ? [
22
+ ...(activeEdges.left ? [middleLeft] : []),
23
+ ...(activeEdges.right ? [middleRight] : []),
24
+ ]
25
+ : [middleLeft, middleRight, middleCenterX];
26
+ const fromY = activeEdges
27
+ ? [
28
+ ...(activeEdges.top ? [middleTop] : []),
29
+ ...(activeEdges.bottom ? [middleBottom] : []),
30
+ ]
31
+ : [middleTop, middleBottom, middleCenterY];
32
+ for (const target of allTargets) {
33
+ const left = target.x;
34
+ const right = target.x + target.width;
35
+ const centerX = target.x + target.width / 2;
36
+ const top = target.y;
37
+ const bottom = target.y + target.height;
38
+ const centerY = target.y + target.height / 2;
39
+ for (const from of fromX) {
40
+ for (const to of [left, right, centerX]) {
41
+ const delta = to - from;
42
+ if (Math.abs(delta) < SNAP_THRESHOLD && Math.abs(delta) < Math.abs(bestDx)) {
43
+ bestDx = delta;
44
+ }
45
+ }
46
+ }
47
+ for (const from of fromY) {
48
+ for (const to of [top, bottom, centerY]) {
49
+ const delta = to - from;
50
+ if (Math.abs(delta) < SNAP_THRESHOLD && Math.abs(delta) < Math.abs(bestDy)) {
51
+ bestDy = delta;
52
+ }
53
+ }
54
+ }
55
+ }
56
+ const dx = Math.abs(bestDx) < SNAP_THRESHOLD ? bestDx : 0;
57
+ const dy = Math.abs(bestDy) < SNAP_THRESHOLD ? bestDy : 0;
58
+ const guides = [];
59
+ const seen = new Set();
60
+ const snappedLeft = middleLeft + dx;
61
+ const snappedRight = middleRight + dx;
62
+ const snappedCenterX = middleCenterX + dx;
63
+ const snappedTop = middleTop + dy;
64
+ const snappedBottom = middleBottom + dy;
65
+ const snappedCenterY = middleCenterY + dy;
66
+ for (const target of allTargets) {
67
+ const left = target.x;
68
+ const right = target.x + target.width;
69
+ const centerX = target.x + target.width / 2;
70
+ const top = target.y;
71
+ const bottom = target.y + target.height;
72
+ const centerY = target.y + target.height / 2;
73
+ for (const xPos of [left, centerX, right]) {
74
+ for (const snapped of [snappedLeft, snappedCenterX, snappedRight]) {
75
+ if (Math.abs(snapped - xPos) < 0.5) {
76
+ const key = `x:${Math.round(xPos)}`;
77
+ if (!seen.has(key)) {
78
+ seen.add(key);
79
+ guides.push({ axis: 'x', pos: xPos });
80
+ }
81
+ }
82
+ }
83
+ }
84
+ for (const yPos of [top, centerY, bottom]) {
85
+ for (const snapped of [snappedTop, snappedCenterY, snappedBottom]) {
86
+ if (Math.abs(snapped - yPos) < 0.5) {
87
+ const key = `y:${Math.round(yPos)}`;
88
+ if (!seen.has(key)) {
89
+ seen.add(key);
90
+ guides.push({ axis: 'y', pos: yPos });
91
+ }
92
+ }
93
+ }
94
+ }
95
+ }
96
+ return { dx, dy, guides };
97
+ }
98
+ export function computeSnap(rect, others, excludeIds, activeEdges, extraRects) {
99
+ const targets = others.filter((placement) => !excludeIds.has(placement.id)).map((placement) => ({
100
+ x: placement.x,
101
+ y: placement.y,
102
+ width: placement.width,
103
+ height: placement.height,
104
+ }));
105
+ return snapAxes(rect, targets, activeEdges, extraRects);
106
+ }
107
+ export function computeSectionSnap(rect, sections, excludeIds, activeEdges, extraRects) {
108
+ const targets = sections.filter((section) => !excludeIds.has(section.id)).map((section) => section.currentRect);
109
+ return snapAxes(rect, targets, activeEdges, extraRects);
110
+ }
111
+ export function createRectFromPoint(start, end) {
112
+ return {
113
+ x: Math.min(start.x, end.x),
114
+ y: Math.min(start.y, end.y),
115
+ width: Math.abs(end.x - start.x),
116
+ height: Math.abs(end.y - start.y),
117
+ };
118
+ }
119
+ export function isMeaningfulDrag(rect, threshold = MIN_SIZE) {
120
+ return rect.width >= threshold && rect.height >= threshold;
121
+ }
122
+ export function dedupeRects(rects) {
123
+ const seen = new Set();
124
+ const result = [];
125
+ for (const rect of rects) {
126
+ const key = `${Math.round(rect.x)}:${Math.round(rect.y)}:${Math.round(rect.width)}:${Math.round(rect.height)}`;
127
+ if (seen.has(key))
128
+ continue;
129
+ seen.add(key);
130
+ result.push(rect);
131
+ }
132
+ return result;
133
+ }
@@ -0,0 +1,10 @@
1
+ import type { DesignPlacement } from './types.js';
2
+ export interface History {
3
+ push(placements: DesignPlacement[]): void;
4
+ undo(): DesignPlacement[] | null;
5
+ redo(): DesignPlacement[] | null;
6
+ canUndo(): boolean;
7
+ canRedo(): boolean;
8
+ clear(): void;
9
+ }
10
+ export declare function createHistory(maxEntries?: number): History;
@@ -0,0 +1,45 @@
1
+ function clonePlacements(placements) {
2
+ return placements.map((p) => ({ ...p }));
3
+ }
4
+ export function createHistory(maxEntries = 50) {
5
+ const undoStack = [];
6
+ const redoStack = [];
7
+ return {
8
+ push(placements) {
9
+ undoStack.push(clonePlacements(placements));
10
+ redoStack.length = 0;
11
+ if (undoStack.length > maxEntries + 1) {
12
+ undoStack.shift();
13
+ }
14
+ },
15
+ undo() {
16
+ if (undoStack.length < 2)
17
+ return null;
18
+ const current = undoStack.pop();
19
+ if (!current)
20
+ return null;
21
+ redoStack.push(current);
22
+ const previous = undoStack[undoStack.length - 1];
23
+ return previous ? clonePlacements(previous) : null;
24
+ },
25
+ redo() {
26
+ if (redoStack.length === 0)
27
+ return null;
28
+ const next = redoStack.pop();
29
+ if (!next)
30
+ return null;
31
+ undoStack.push(next);
32
+ return clonePlacements(next);
33
+ },
34
+ canUndo() {
35
+ return undoStack.length >= 2;
36
+ },
37
+ canRedo() {
38
+ return redoStack.length > 0;
39
+ },
40
+ clear() {
41
+ undoStack.length = 0;
42
+ redoStack.length = 0;
43
+ },
44
+ };
45
+ }
@@ -0,0 +1,23 @@
1
+ export { default as DesignPalette } from './design-palette.svelte';
2
+ export { default as DesignMode } from './design-mode.svelte';
3
+ export { default as RearrangeOverlay } from './rearrange-overlay.svelte';
4
+ export { default as ComponentPicker } from './component-picker.svelte';
5
+ export { default as RouteCreator } from './route-creator.svelte';
6
+ export { default as ComponentActions } from './component-actions.svelte';
7
+ export { default as ResponsiveBar } from './responsive-bar.svelte';
8
+ export type { LayoutModeComponentType, CanvasPurpose, CanvasWidth, CatalogEntry, ComponentAction, ComponentDefinition, ComponentSection, CSSContext, DesignPlacement, DetectedSection, HistoryEntry, RearrangeState, Rect, SpatialContext, ViewportSize, } from './types.js';
9
+ export { CANVAS_WIDTHS, COMPONENT_MAP, COMPONENT_REGISTRY, DEFAULT_SIZES, } from './types.js';
10
+ export { captureElement, detectPageSections, generateSelector, getSectionLabels, labelSection, } from './section-detection.js';
11
+ export { computeSectionSnap, computeSnap, createRectFromPoint, dedupeRects, MIN_CAPTURE_SIZE, MIN_SIZE, SNAP_THRESHOLD, isMeaningfulDrag, } from './geometry.js';
12
+ export type { Guide } from './geometry.js';
13
+ export { analyzeLayoutPatterns, formatCSSPosition, formatPositionSummary, formatSpatialLines, getElementCSSContext, getPageLayout, getPopupPosition, getSpatialContext, hasMeaningfulArea, intersectsRect, normalizeText, rectFromPoints, toRect, unionRects, uniqueLabels, } from './spatial.js';
14
+ export { generateDesignOutput, generateRearrangeOutput, } from './output.js';
15
+ export { getCatalog, loadCatalog, searchCatalog, getAlternatives, getAntiPatterns, } from './catalog.js';
16
+ export { createHistory } from './history.js';
17
+ export type { History } from './history.js';
18
+ export { createMountManager, } from './live-mount.js';
19
+ export type { MountManager, ReconcileDiff } from './live-mount.js';
20
+ export { generateSketchBrief, generateEditBrief, } from './output.js';
21
+ export type { SketchBriefOptions, EditAnnotation, EditBriefOptions } from './output.js';
22
+ export { INTERACTIVE_TAGS, isElementFixed, isSelectableAreaTarget, rectFromElement, } from './element-heuristics.js';
23
+ export { freezeLayoutModeAnimations, isLayoutModeFrozen, originalRequestAnimationFrame, originalSetInterval, originalSetTimeout, unfreezeLayoutModeAnimations, } from './freeze.js';
@@ -0,0 +1,18 @@
1
+ export { default as DesignPalette } from './design-palette.svelte';
2
+ export { default as DesignMode } from './design-mode.svelte';
3
+ export { default as RearrangeOverlay } from './rearrange-overlay.svelte';
4
+ export { default as ComponentPicker } from './component-picker.svelte';
5
+ export { default as RouteCreator } from './route-creator.svelte';
6
+ export { default as ComponentActions } from './component-actions.svelte';
7
+ export { default as ResponsiveBar } from './responsive-bar.svelte';
8
+ export { CANVAS_WIDTHS, COMPONENT_MAP, COMPONENT_REGISTRY, DEFAULT_SIZES, } from './types.js';
9
+ export { captureElement, detectPageSections, generateSelector, getSectionLabels, labelSection, } from './section-detection.js';
10
+ export { computeSectionSnap, computeSnap, createRectFromPoint, dedupeRects, MIN_CAPTURE_SIZE, MIN_SIZE, SNAP_THRESHOLD, isMeaningfulDrag, } from './geometry.js';
11
+ export { analyzeLayoutPatterns, formatCSSPosition, formatPositionSummary, formatSpatialLines, getElementCSSContext, getPageLayout, getPopupPosition, getSpatialContext, hasMeaningfulArea, intersectsRect, normalizeText, rectFromPoints, toRect, unionRects, uniqueLabels, } from './spatial.js';
12
+ export { generateDesignOutput, generateRearrangeOutput, } from './output.js';
13
+ export { getCatalog, loadCatalog, searchCatalog, getAlternatives, getAntiPatterns, } from './catalog.js';
14
+ export { createHistory } from './history.js';
15
+ export { createMountManager, } from './live-mount.js';
16
+ export { generateSketchBrief, generateEditBrief, } from './output.js';
17
+ export { INTERACTIVE_TAGS, isElementFixed, isSelectableAreaTarget, rectFromElement, } from './element-heuristics.js';
18
+ export { freezeLayoutModeAnimations, isLayoutModeFrozen, originalRequestAnimationFrame, originalSetInterval, originalSetTimeout, unfreezeLayoutModeAnimations, } from './freeze.js';
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Manages mounting/unmounting Svelte components into placement wrapper divs.
3
+ *
4
+ * The reconcile/tracking logic is browser-agnostic and testable in bun.
5
+ * The mount/unmount calls are try/caught since svelte's mount() is a browser API
6
+ * that is unavailable in the bun test environment.
7
+ */
8
+ export interface ReconcileDiff {
9
+ added: string[];
10
+ removed: string[];
11
+ }
12
+ export interface MountManager {
13
+ mountComponent(id: string, componentName: string, target: HTMLElement): void;
14
+ unmountComponent(id: string): void;
15
+ unmountAll(): void;
16
+ hasMounted(id: string): boolean;
17
+ markMounted(id: string): void;
18
+ reconcile(currentIds: string[], previousIds: Set<string>): ReconcileDiff;
19
+ }
20
+ export declare function createMountManager(): MountManager;
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Manages mounting/unmounting Svelte components into placement wrapper divs.
3
+ *
4
+ * The reconcile/tracking logic is browser-agnostic and testable in bun.
5
+ * The mount/unmount calls are try/caught since svelte's mount() is a browser API
6
+ * that is unavailable in the bun test environment.
7
+ */
8
+ export function createMountManager() {
9
+ const mounted = new Map();
10
+ function mountComponent(id, componentName, target) {
11
+ if (mounted.has(id))
12
+ return;
13
+ try {
14
+ // Dynamic import deferred to avoid top-level svelte import breaking bun tests
15
+ const { mount } = require('svelte');
16
+ const { thumbnailMap } = require('@dryui/ui/thumbnail');
17
+ const component = thumbnailMap[componentName];
18
+ if (!component)
19
+ return;
20
+ const instance = mount(component, { target, props: {} });
21
+ mounted.set(id, { instance });
22
+ }
23
+ catch {
24
+ // Silently fail in environments where svelte mount is unavailable (e.g. bun tests)
25
+ }
26
+ }
27
+ function unmountComponent(id) {
28
+ const entry = mounted.get(id);
29
+ if (!entry)
30
+ return;
31
+ try {
32
+ const { unmount } = require('svelte');
33
+ unmount(entry.instance);
34
+ }
35
+ catch {
36
+ // Silently fail in environments where svelte unmount is unavailable
37
+ }
38
+ finally {
39
+ mounted.delete(id);
40
+ }
41
+ }
42
+ function unmountAll() {
43
+ for (const id of mounted.keys()) {
44
+ unmountComponent(id);
45
+ }
46
+ mounted.clear();
47
+ }
48
+ function hasMounted(id) {
49
+ return mounted.has(id);
50
+ }
51
+ function markMounted(id) {
52
+ if (!mounted.has(id)) {
53
+ mounted.set(id, { instance: null });
54
+ }
55
+ }
56
+ function reconcile(currentIds, previousIds) {
57
+ const currentSet = new Set(currentIds);
58
+ const added = currentIds.filter((id) => !previousIds.has(id));
59
+ const removed = [...previousIds].filter((id) => !currentSet.has(id));
60
+ return { added, removed };
61
+ }
62
+ return {
63
+ mountComponent,
64
+ unmountComponent,
65
+ unmountAll,
66
+ hasMounted,
67
+ markMounted,
68
+ reconcile,
69
+ };
70
+ }
@@ -0,0 +1,26 @@
1
+ import type { CanvasWidth, ComponentAction, DesignPlacement, RearrangeState, ViewportSize } from './types.js';
2
+ type OutputDetail = 'compact' | 'standard' | 'detailed' | 'forensic';
3
+ export declare function generateDesignOutput(placements: readonly DesignPlacement[], viewport: ViewportSize, options?: {
4
+ blankCanvas?: boolean;
5
+ wireframePurpose?: string;
6
+ }, detailLevel?: OutputDetail): string;
7
+ export declare function generateRearrangeOutput(state: RearrangeState, detailLevel?: OutputDetail, viewport?: ViewportSize): string;
8
+ export interface SketchBriefOptions {
9
+ placements: DesignPlacement[];
10
+ route: string;
11
+ canvasWidth: CanvasWidth;
12
+ recipeName?: string;
13
+ }
14
+ export interface EditAnnotation {
15
+ selector: string;
16
+ note: string;
17
+ }
18
+ export interface EditBriefOptions {
19
+ actions: ComponentAction[];
20
+ annotations: EditAnnotation[];
21
+ currentUrl: string;
22
+ canvasWidth: CanvasWidth;
23
+ }
24
+ export declare function generateSketchBrief(options: SketchBriefOptions): string;
25
+ export declare function generateEditBrief(options: EditBriefOptions): string;
26
+ export {};