@goflowstate/widget-sdk 0.3.1 → 0.3.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/README.md +24 -2
- package/dist/canvas-widget-sdk.js +534 -28
- package/dist/canvas-widget-sdk.js.map +3 -3
- package/dist/feedback.d.ts +81 -1
- package/dist/feedback.d.ts.map +1 -1
- package/dist/index.mjs +534 -28
- package/dist/index.mjs.map +3 -3
- package/package.json +1 -1
package/dist/feedback.d.ts
CHANGED
|
@@ -23,6 +23,12 @@ export interface FlowFeedbackTheme {
|
|
|
23
23
|
fontBody: string;
|
|
24
24
|
fontDisplay: string;
|
|
25
25
|
displayWeight: string;
|
|
26
|
+
/** Letter spacing of the flow's titles, in em, so it scales to the sheet's title size. */
|
|
27
|
+
displayTracking: string;
|
|
28
|
+
fontButton: string;
|
|
29
|
+
buttonWeight: string;
|
|
30
|
+
buttonTracking: string;
|
|
31
|
+
buttonTransform: string;
|
|
26
32
|
radius: string;
|
|
27
33
|
buttonRadius: string;
|
|
28
34
|
dark: boolean;
|
|
@@ -41,7 +47,8 @@ export interface FlowFeedbackOptions {
|
|
|
41
47
|
/** Sends the report. The session client passes `session.request('feedback', report)`. */
|
|
42
48
|
submit: (report: FlowFeedbackReport) => Promise<unknown>;
|
|
43
49
|
/** Renders the page to a JPEG data URL, or null when it cannot. Defaults to the built-in
|
|
44
|
-
* rasterizer; tests and unusual hosts pass their own.
|
|
50
|
+
* rasterizer; tests and unusual hosts pass their own. It runs while the sheet is already
|
|
51
|
+
* open, so a host's own capture must leave the feedback host element out of the picture. */
|
|
45
52
|
capture?: () => Promise<string | null>;
|
|
46
53
|
/** Called once the icon is on the page, so a host page can hide its own fallback. */
|
|
47
54
|
onReady?: () => void;
|
|
@@ -71,6 +78,79 @@ export declare const luminance: (c: Rgba) => number;
|
|
|
71
78
|
export declare function readFlowTheme(doc?: Document): FlowFeedbackTheme;
|
|
72
79
|
/** Step the JPEG quality, then the size, until the picture fits the service's cap. */
|
|
73
80
|
export declare function encodeScreenshot(canvas: HTMLCanvasElement): string | null;
|
|
81
|
+
export declare const PLACEMENT_BASE = 16;
|
|
82
|
+
export declare const PLACEMENT_STEP = 8;
|
|
83
|
+
/** Clear space kept around the icon, so it does not crowd what it sits beside. */
|
|
84
|
+
export declare const PLACEMENT_PAD = 8;
|
|
85
|
+
/** The icon never climbs past this share of the viewport. */
|
|
86
|
+
export declare const PLACEMENT_MAX_SHARE = 0.6;
|
|
87
|
+
/** How far up empty space is still worth more than sitting on a line of text lower down. */
|
|
88
|
+
export declare const PLACEMENT_READ_COST = 240;
|
|
89
|
+
/** What is at a point: nothing, something to read or look at, or something to tap. */
|
|
90
|
+
export declare const EMPTY = 0;
|
|
91
|
+
export declare const READ = 1;
|
|
92
|
+
export declare const TAP = 2;
|
|
93
|
+
export type Occupancy = typeof EMPTY | typeof READ | typeof TAP;
|
|
94
|
+
export interface PlacementBox {
|
|
95
|
+
/** The icon's box as measured now, in viewport pixels. */
|
|
96
|
+
left: number;
|
|
97
|
+
top: number;
|
|
98
|
+
size: number;
|
|
99
|
+
/** The bottom offset that box was measured at. */
|
|
100
|
+
bottom: number;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* The bottom offset to sit at. `at(x, y)` says what is at a viewport point. An empty spot costs
|
|
104
|
+
* its height; a spot over text or a picture costs its height plus PLACEMENT_READ_COST; a spot
|
|
105
|
+
* over a control is taken only when there is no other, and then it is the base.
|
|
106
|
+
*/
|
|
107
|
+
export declare function choosePlacement(box: PlacementBox, viewportHeight: number, at: (x: number, y: number) => Occupancy): number;
|
|
108
|
+
/**
|
|
109
|
+
* Reads what is at viewport points, the feedback host aside. One reader serves one placement
|
|
110
|
+
* pass: what it learns about an element is kept for the pass and dropped with it.
|
|
111
|
+
*
|
|
112
|
+
* A tap lands on the topmost element and travels up its ancestors, so only those can make a
|
|
113
|
+
* point a control: a button under the flow's own bottom sheet is not one. What a person reads
|
|
114
|
+
* is whatever shows through, down to the first element that paints its own ground.
|
|
115
|
+
*/
|
|
116
|
+
export declare function occupancyReader(host: Element, doc?: Document): (x: number, y: number) => Occupancy;
|
|
117
|
+
export type DockState = 'float' | 'dock-left' | 'dock-right';
|
|
118
|
+
export declare const BUTTON_SIZE = 44;
|
|
119
|
+
export declare const TAB_WIDTH = 26;
|
|
120
|
+
export declare const TAB_HEIGHT = 54;
|
|
121
|
+
export declare const EDGE_MARGIN = 12;
|
|
122
|
+
/** How far past an edge a release has to be heading before the button docks there. */
|
|
123
|
+
export declare const DOCK_PAST = 14;
|
|
124
|
+
/** Storage key for where the person left the button. One origin serves every flow, so the
|
|
125
|
+
* choice follows them from flow to flow. */
|
|
126
|
+
export declare const SPOT_KEY = "fs-feedback-spot";
|
|
127
|
+
/** The part of the viewport the button may rest in: its size, less the safe-area insets. */
|
|
128
|
+
export interface FeedbackViewport {
|
|
129
|
+
width: number;
|
|
130
|
+
height: number;
|
|
131
|
+
top: number;
|
|
132
|
+
bottom: number;
|
|
133
|
+
}
|
|
134
|
+
export interface FeedbackSpot {
|
|
135
|
+
state: DockState;
|
|
136
|
+
x: number;
|
|
137
|
+
y: number;
|
|
138
|
+
}
|
|
139
|
+
/** Where a release at velocity `v` (px per second) comes to rest: scroll deceleration. */
|
|
140
|
+
export declare const projectMomentum: (v: number, deceleration?: number) => number;
|
|
141
|
+
/** Past a boundary the button follows less and less, so the edge reads as soft, not stuck. */
|
|
142
|
+
export declare const rubberband: (overshoot: number, dimension: number, constant?: number) => number;
|
|
143
|
+
/** The resting spot for a state on one side, at a height. */
|
|
144
|
+
export declare function restingSpot(state: DockState, left: boolean, y: number, view: FeedbackViewport): FeedbackSpot;
|
|
145
|
+
/**
|
|
146
|
+
* Where a drag that ends at (x, y) with velocity (vx, vy) settles. A floating button heading
|
|
147
|
+
* past an edge, or let go against one, docks on that side; otherwise it floats on the side its
|
|
148
|
+
* momentum carries it to. A docked tab stays docked and only slides along its edge.
|
|
149
|
+
*/
|
|
150
|
+
export declare function settleRelease(from: FeedbackSpot, velocity: {
|
|
151
|
+
x: number;
|
|
152
|
+
y: number;
|
|
153
|
+
}, view: FeedbackViewport): FeedbackSpot;
|
|
74
154
|
/** Whether the page asked for no feedback icon (`<html data-fs-feedback="off">`). */
|
|
75
155
|
export declare const feedbackOptedOut: (doc?: Document) => boolean;
|
|
76
156
|
export declare function mountFlowFeedback(options: FlowFeedbackOptions): FlowFeedbackHandle | null;
|
package/dist/feedback.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feedback.d.ts","sourceRoot":"","sources":["../src/feedback.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;CAC7C;AAED,MAAM,WAAW,mBAAmB;IAClC,yFAAyF;IACzF,MAAM,EAAE,CAAC,MAAM,EAAE,kBAAkB,KAAK,OAAO,CAAC,OA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