autosolutions-os 0.4.1 → 0.4.3
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/CHANGELOG.md +70 -0
- package/README.md +19 -9
- package/dist/coreReader.d.ts +23 -3
- package/dist/coreReader.js +74 -7
- package/dist/coreView.d.ts +3 -3
- package/dist/coreView.js +9 -1
- package/dist/feedback.d.ts +3 -2
- package/dist/feedback.js +42 -16
- package/dist/feedbackAsk.d.ts +4 -0
- package/dist/feedbackAsk.js +47 -0
- package/dist/feedbackSend.d.ts +18 -0
- package/dist/feedbackSend.js +28 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,75 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.3 - 2026-11-06
|
|
4
|
+
|
|
5
|
+
The company switcher works in Ops Hub and Asset Portal with no Hub tab open
|
|
6
|
+
(Didac asked on 6 November 2026: "this should be working across everywhere").
|
|
7
|
+
|
|
8
|
+
Those two apps keep their own Supabase projects and borrow the Hub's session
|
|
9
|
+
from the shared cookie for their menu and company switcher. Only the Hub and
|
|
10
|
+
the apps on the core may refresh it, so an hour with no Hub tab open left the
|
|
11
|
+
borrowed token useless: a new page showed the app's fixed plate with no
|
|
12
|
+
switcher, and a switch from a page already open failed with "Couldn't switch".
|
|
13
|
+
|
|
14
|
+
- `autosolutions-os/core-view`: a call that finds the token run out asks the Hub
|
|
15
|
+
to renew it (`renewHubSession`), in a hidden frame on the Hub's blank page
|
|
16
|
+
`/renew-session`. The Hub's own client refreshes by the rules in session.ts
|
|
17
|
+
and writes the shared cookie; the call waits for that, up to 15 seconds, then
|
|
18
|
+
goes on. The reader still never touches a token itself.
|
|
19
|
+
- The frame shows "checking" while that runs, then the Hub's frame.
|
|
20
|
+
- One renewal at a time on a page, and five minutes before the next try after
|
|
21
|
+
one that did not work. A session that has ended or was signed out is not
|
|
22
|
+
brought back: the frame stays the app's fixed one.
|
|
23
|
+
- The page must be live on the Hub first (autosolutions-os PR #67). Before that,
|
|
24
|
+
a renewal gives up after 15 seconds and the frame is the fixed one, as in
|
|
25
|
+
0.4.2.
|
|
26
|
+
|
|
27
|
+
## 0.4.2 - 2026-11-05
|
|
28
|
+
|
|
29
|
+
The ? becomes a Feedback button that people see, and pasting a picture into
|
|
30
|
+
the feedback form works in every browser, Safari too (Didac asked for both on
|
|
31
|
+
5 November 2026, and picked the button's look: "B", with more space before
|
|
32
|
+
the company).
|
|
33
|
+
|
|
34
|
+
### The Feedback button
|
|
35
|
+
|
|
36
|
+
- The ? left of the company plate is now a pill in the logo's pink and
|
|
37
|
+
purple, with a chat icon and the word Feedback. Its name for screen readers
|
|
38
|
+
stays "Send feedback".
|
|
39
|
+
- 20px before the company plate (was 4px); 12px on a phone.
|
|
40
|
+
- For its first minute on a page its colour drifts slowly from pink to purple
|
|
41
|
+
and back. It stops for good once the person has opened the form in this
|
|
42
|
+
browser (localStorage `autosolutions-os:feedback-seen`; a browser that
|
|
43
|
+
keeps nothing still gets a working button). It never moves with reduced
|
|
44
|
+
motion.
|
|
45
|
+
- Phones (measured on the Hub's bar): the icon and the word from 410px, the
|
|
46
|
+
word alone from 380px (a 390px iPhone), the icon alone below. The search
|
|
47
|
+
gives way first; the plate stays whole.
|
|
48
|
+
- The button brings its own styles (a `<style>` inside it, `OS_FEEDBACK_ASK_CSS`),
|
|
49
|
+
drawn right on a server-rendered first page. Apps change nothing.
|
|
50
|
+
- An app that adds its own buttons to the bar leaves less room on a phone:
|
|
51
|
+
none does today.
|
|
52
|
+
|
|
53
|
+
### autosolutions-os/feedback
|
|
54
|
+
|
|
55
|
+
- A paste reads the picture from `clipboardData.files` and, when `files` has
|
|
56
|
+
no picture, from `clipboardData.items` (items of kind "file"). Safari, and
|
|
57
|
+
some "Copy image" menus, give the picture only in `items`. A browser that
|
|
58
|
+
fills both gives the same picture in each, so it is added once.
|
|
59
|
+
- A paste with no picture (text) goes on as normal: the form stops a paste
|
|
60
|
+
only when it adds a picture.
|
|
61
|
+
- Safari sends no paste event while a button or a radio has focus. Cmd+V or
|
|
62
|
+
Ctrl+V there now moves focus to the text box first, so the paste lands in
|
|
63
|
+
the form.
|
|
64
|
+
- A HEIC, GIF or TIFF picture is redrawn as a JPEG when the browser can read
|
|
65
|
+
it, as before; when it cannot, the form says "Use a PNG, JPEG or WebP
|
|
66
|
+
picture."
|
|
67
|
+
- New: `pastedPictures(clipboardData)` (also from `autosolutions-os`), the
|
|
68
|
+
pictures in a paste, and its type `OsPastedData`.
|
|
69
|
+
- Unchanged: the form, its limits (three pictures, 3 MB each), what it sends,
|
|
70
|
+
and the button's place (left of the company plate).
|
|
71
|
+
- Apps take this release with a lockfile bump.
|
|
72
|
+
|
|
3
73
|
## 0.4.1 - 2026-11-05
|
|
4
74
|
|
|
5
75
|
The owner's sheet has Commercial > Tools > Line form populator, which the
|
package/README.md
CHANGED
|
@@ -427,9 +427,15 @@ sees, without the token) is read-only:
|
|
|
427
427
|
only while that token is good (more than 30 seconds left). It never signs in,
|
|
428
428
|
never refreshes the token, never writes a cookie or storage, and never
|
|
429
429
|
publishes a session: a refresh would rotate the Hub's refresh token behind
|
|
430
|
-
the Hub's back
|
|
431
|
-
|
|
432
|
-
|
|
430
|
+
the Hub's back;
|
|
431
|
+
- when the token has run out, as it does after an hour with no Hub tab open, it
|
|
432
|
+
asks the Hub to renew it (0.4.3): the Hub's blank page `/renew-session` in a
|
|
433
|
+
hidden frame, whose own client refreshes and writes the shared cookie. The
|
|
434
|
+
call waits for that, up to 15 seconds, with the frame on "checking", then goes
|
|
435
|
+
on. A token that has expired since the frame was read keeps the frame, and
|
|
436
|
+
the next call renews it. If the Hub cannot renew it (the session has ended, or
|
|
437
|
+
the Hub does not answer), the frame is the fallback and the next try is five
|
|
438
|
+
minutes later;
|
|
433
439
|
- it sends the token to the core's REST endpoint and nowhere else, for
|
|
434
440
|
`os_context`, `my_admin_scope` and `switch_company_for_app` only
|
|
435
441
|
(`CORE_VIEW_FUNCTIONS`); any other name is refused before anything is sent;
|
|
@@ -443,12 +449,16 @@ On the server there is no cookie to read, so the hook gives the fallback:
|
|
|
443
449
|
render the frame in the browser only (Asset Portal's staff face does), or
|
|
444
450
|
accept a first paint of the fallback.
|
|
445
451
|
|
|
446
|
-
### Feedback: the
|
|
452
|
+
### Feedback: the Feedback button in the top bar (0.4.0; the button 0.4.2)
|
|
447
453
|
|
|
448
|
-
Every app has one way to send feedback: the
|
|
449
|
-
of the company plate
|
|
450
|
-
|
|
451
|
-
|
|
454
|
+
Every app has one way to send feedback: the Feedback button in the top bar,
|
|
455
|
+
left of the company plate (a pink-to-purple pill with a chat icon; on a small
|
|
456
|
+
phone the word or the icon alone; its colour drifts for a page's first minute
|
|
457
|
+
until the person has opened the form once). It opens the same form
|
|
458
|
+
everywhere: a type (Bug, Idea, Question, Other), what happened, and up to
|
|
459
|
+
three pictures (picked, pasted or dropped; PNG, JPEG or WebP, 3 MB each, big
|
|
460
|
+
ones made smaller first; a paste reads the clipboard's files, or its items as
|
|
461
|
+
Safari gives them). Send adds
|
|
452
462
|
what the page knows (the app, the page's path, title and address, the company
|
|
453
463
|
on the plate, the browser, the screen, the language, the time zone, the app's
|
|
454
464
|
commit from Lovable's `data-commit-sha`, and this package's version) and posts
|
|
@@ -476,7 +486,7 @@ const core = useCoreFrame({
|
|
|
476
486
|
```
|
|
477
487
|
|
|
478
488
|
Without `feedback` the hook gives `core.feedback === null`, so an app shows
|
|
479
|
-
the
|
|
489
|
+
the button only once it hands its token. The form is a native `<dialog>` with its
|
|
480
490
|
own styles: it needs no stylesheet from the app, sits above the app's own
|
|
481
491
|
layout, and Escape closes it. Closing it keeps the draft until it is sent.
|
|
482
492
|
`autosolutions-os/feedback` also exports the form's logic (`sendFeedback`,
|
package/dist/coreReader.d.ts
CHANGED
|
@@ -23,6 +23,23 @@ export type HubSession = {
|
|
|
23
23
|
* shared session, signed out at the Hub, someone else, or cookies blocked.
|
|
24
24
|
*/
|
|
25
25
|
export declare function hubSession(email: string | null | undefined): HubSession | null;
|
|
26
|
+
/** The Hub's blank page that renews its session (the Hub's src/routes/renew-session.tsx). */
|
|
27
|
+
export declare const HUB_RENEW_PATH = "/renew-session";
|
|
28
|
+
/** Test seam: forget this page's renewal. */
|
|
29
|
+
export declare function resetHubRenewal(): void;
|
|
30
|
+
/**
|
|
31
|
+
* Ask the Hub to renew the session this person's token came from, and wait
|
|
32
|
+
* for a good token in the shared cookie. True when one is there. One at a time
|
|
33
|
+
* on a page, and none for five minutes after one that did not work.
|
|
34
|
+
*
|
|
35
|
+
* Only the Hub's own client touches the session. A session that has ended, or
|
|
36
|
+
* a signed-out one, is not brought back: the Hub's rules decide, and this then
|
|
37
|
+
* answers false, and the frame stays the app's fixed one.
|
|
38
|
+
*/
|
|
39
|
+
export declare function renewHubSession(email: () => string | null | undefined, timing?: {
|
|
40
|
+
look?: number;
|
|
41
|
+
wait?: number;
|
|
42
|
+
}): Promise<boolean>;
|
|
26
43
|
/** What a call answers: the shape supabase-js's `rpc` resolves to, as the package's frame code reads it. */
|
|
27
44
|
export type CoreViewResult = {
|
|
28
45
|
data: unknown;
|
|
@@ -39,13 +56,16 @@ export type CoreViewClientOptions = {
|
|
|
39
56
|
email: () => string | null | undefined;
|
|
40
57
|
/** For tests: the fetch to use. Default the global one. */
|
|
41
58
|
fetch?: typeof fetch;
|
|
59
|
+
/** For tests: how the Hub is asked to renew its session. Default `renewHubSession`. */
|
|
60
|
+
renew?: (email: () => string | null | undefined) => Promise<boolean>;
|
|
42
61
|
};
|
|
43
62
|
/**
|
|
44
63
|
* A client for the core that borrows the Hub's session from the shared
|
|
45
64
|
* cookie, read at every call: `rpc(fn, args)` for os_context,
|
|
46
65
|
* my_admin_scope and switch_company_for_app, posted to the core's REST
|
|
47
|
-
* endpoint with the session's access token, as supabase-js would.
|
|
48
|
-
*
|
|
49
|
-
*
|
|
66
|
+
* endpoint with the session's access token, as supabase-js would. A token
|
|
67
|
+
* that has run out waits for the Hub to renew it first (`renewHubSession`).
|
|
68
|
+
* With no usable Hub session for the app's person, or for any other function,
|
|
69
|
+
* it answers with an error and sends nothing.
|
|
50
70
|
*/
|
|
51
71
|
export declare function createCoreViewClient(options: CoreViewClientOptions): CoreViewClient;
|
package/dist/coreReader.js
CHANGED
|
@@ -16,6 +16,10 @@
|
|
|
16
16
|
* cookie on every call and uses the access token in it while that token is
|
|
17
17
|
* good. A refresh would rotate the Hub's refresh token behind the Hub's
|
|
18
18
|
* back; only the Hub and the apps on the core refresh it.
|
|
19
|
+
* - When that token has run out, which an hour with no Hub tab open does, it
|
|
20
|
+
* asks the Hub to renew it (0.4.3): the Hub's own blank page in a hidden
|
|
21
|
+
* frame, whose client refreshes by the rules in session.ts and writes the
|
|
22
|
+
* shared cookie. The reader waits for the cookie, then goes on.
|
|
19
23
|
* - The token goes to the core's REST endpoint and nowhere else, for three
|
|
20
24
|
* functions only (CORE_VIEW_FUNCTIONS). Any other name is refused before
|
|
21
25
|
* anything is sent. The token is never handed to the app.
|
|
@@ -26,7 +30,7 @@
|
|
|
26
30
|
* Hub, or for someone else, there is no Hub session and the reader answers
|
|
27
31
|
* every call with an error, sending nothing. No React, no supabase-js.
|
|
28
32
|
*/
|
|
29
|
-
import { coreProjectRef, corePublishableKey, coreUrl, PARENT_DOMAIN } from "./config.js";
|
|
33
|
+
import { coreProjectRef, corePublishableKey, coreUrl, HUB_URL, PARENT_DOMAIN } from "./config.js";
|
|
30
34
|
import { joinChunks, parseCopy, parseSignedOutNote, sharedSessionCookieName, signedOutCookieName, signedOutCopy, } from "./session.js";
|
|
31
35
|
/** The only core functions the reader calls: the frame's two questions, and the company switch. */
|
|
32
36
|
export const CORE_VIEW_FUNCTIONS = ["os_context", "my_admin_scope", "switch_company_for_app"];
|
|
@@ -94,14 +98,71 @@ function readShared(email) {
|
|
|
94
98
|
export function hubSession(email) {
|
|
95
99
|
return readShared(email)?.session ?? null;
|
|
96
100
|
}
|
|
101
|
+
/** The Hub's blank page that renews its session (the Hub's src/routes/renew-session.tsx). */
|
|
102
|
+
export const HUB_RENEW_PATH = "/renew-session";
|
|
103
|
+
/** How often the cookie is read while the Hub renews, and how long it gets. */
|
|
104
|
+
const RENEW_LOOK_MS = 250;
|
|
105
|
+
const RENEW_WAIT_MS = 15_000;
|
|
106
|
+
/** After a renewal that did not work, the wait before the next try: the Hub's page is not small. */
|
|
107
|
+
const RENEW_GAP_MS = 5 * 60_000;
|
|
108
|
+
let renewal = null;
|
|
109
|
+
let renewFailedAt = null;
|
|
110
|
+
/** Test seam: forget this page's renewal. */
|
|
111
|
+
export function resetHubRenewal() {
|
|
112
|
+
renewal = null;
|
|
113
|
+
renewFailedAt = null;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Ask the Hub to renew the session this person's token came from, and wait
|
|
117
|
+
* for a good token in the shared cookie. True when one is there. One at a time
|
|
118
|
+
* on a page, and none for five minutes after one that did not work.
|
|
119
|
+
*
|
|
120
|
+
* Only the Hub's own client touches the session. A session that has ended, or
|
|
121
|
+
* a signed-out one, is not brought back: the Hub's rules decide, and this then
|
|
122
|
+
* answers false, and the frame stays the app's fixed one.
|
|
123
|
+
*/
|
|
124
|
+
export function renewHubSession(email, timing = {}) {
|
|
125
|
+
if (renewal)
|
|
126
|
+
return renewal;
|
|
127
|
+
if (typeof document === "undefined" || typeof document.createElement !== "function" || !document.body) {
|
|
128
|
+
return Promise.resolve(false);
|
|
129
|
+
}
|
|
130
|
+
if (renewFailedAt !== null && Date.now() - renewFailedAt < RENEW_GAP_MS)
|
|
131
|
+
return Promise.resolve(false);
|
|
132
|
+
const frame = document.createElement("iframe");
|
|
133
|
+
frame.src = `${HUB_URL}${HUB_RENEW_PATH}`;
|
|
134
|
+
frame.title = "AutoSolutions sign-in";
|
|
135
|
+
frame.hidden = true;
|
|
136
|
+
frame.tabIndex = -1;
|
|
137
|
+
frame.setAttribute("aria-hidden", "true");
|
|
138
|
+
document.body.appendChild(frame);
|
|
139
|
+
const started = Date.now();
|
|
140
|
+
const wait = timing.wait ?? RENEW_WAIT_MS;
|
|
141
|
+
renewal = new Promise((resolve) => {
|
|
142
|
+
const timer = setInterval(() => {
|
|
143
|
+
const session = hubSession(email());
|
|
144
|
+
if (session !== null && !session.usable && Date.now() - started < wait)
|
|
145
|
+
return;
|
|
146
|
+
clearInterval(timer);
|
|
147
|
+
frame.remove();
|
|
148
|
+
renewal = null;
|
|
149
|
+
const renewed = session?.usable === true;
|
|
150
|
+
/* No session any more (signed out, or someone else) is no failure: nothing to try again. */
|
|
151
|
+
renewFailedAt = session !== null && !session.usable ? Date.now() : null;
|
|
152
|
+
resolve(renewed);
|
|
153
|
+
}, timing.look ?? RENEW_LOOK_MS);
|
|
154
|
+
});
|
|
155
|
+
return renewal;
|
|
156
|
+
}
|
|
97
157
|
const refused = (message) => ({ data: null, error: { message } });
|
|
98
158
|
/**
|
|
99
159
|
* A client for the core that borrows the Hub's session from the shared
|
|
100
160
|
* cookie, read at every call: `rpc(fn, args)` for os_context,
|
|
101
161
|
* my_admin_scope and switch_company_for_app, posted to the core's REST
|
|
102
|
-
* endpoint with the session's access token, as supabase-js would.
|
|
103
|
-
*
|
|
104
|
-
*
|
|
162
|
+
* endpoint with the session's access token, as supabase-js would. A token
|
|
163
|
+
* that has run out waits for the Hub to renew it first (`renewHubSession`).
|
|
164
|
+
* With no usable Hub session for the app's person, or for any other function,
|
|
165
|
+
* it answers with an error and sends nothing.
|
|
105
166
|
*/
|
|
106
167
|
export function createCoreViewClient(options) {
|
|
107
168
|
const allowed = new Set(CORE_VIEW_FUNCTIONS);
|
|
@@ -109,11 +170,17 @@ export function createCoreViewClient(options) {
|
|
|
109
170
|
async rpc(fn, args = {}) {
|
|
110
171
|
if (!allowed.has(fn))
|
|
111
172
|
return refused(`${fn}: not one of the core functions a frame reads`);
|
|
112
|
-
|
|
173
|
+
let shared = readShared(options.email());
|
|
113
174
|
if (!shared)
|
|
114
175
|
return refused("No Hub session for this person");
|
|
115
|
-
if (!shared.session.usable)
|
|
116
|
-
|
|
176
|
+
if (!shared.session.usable) {
|
|
177
|
+
await (options.renew ?? renewHubSession)(options.email);
|
|
178
|
+
shared = readShared(options.email());
|
|
179
|
+
if (!shared)
|
|
180
|
+
return refused("No Hub session for this person");
|
|
181
|
+
if (!shared.session.usable)
|
|
182
|
+
return refused("The Hub session needs a refresh at the Hub");
|
|
183
|
+
}
|
|
117
184
|
const send = options.fetch ?? (typeof fetch === "function" ? fetch : undefined);
|
|
118
185
|
if (!send)
|
|
119
186
|
return refused("No fetch");
|
package/dist/coreView.d.ts
CHANGED
|
@@ -63,9 +63,9 @@ export type CoreFrameOptions = {
|
|
|
63
63
|
/**
|
|
64
64
|
* Where the frame comes from:
|
|
65
65
|
* - "core": the core's view of the person, through the Hub's session;
|
|
66
|
-
* - "checking": the Hub's session is there and the core is being asked,
|
|
67
|
-
* other apps' rows read "Checking your access…"
|
|
68
|
-
* place, as in the Hub while it loads;
|
|
66
|
+
* - "checking": the Hub's session is there and the core is being asked, or
|
|
67
|
+
* the Hub is renewing it, so other apps' rows read "Checking your access…"
|
|
68
|
+
* and the plate keeps its place, as in the Hub while it loads;
|
|
69
69
|
* - "static": no Hub session for this person, or the core could not be
|
|
70
70
|
* read: the fixed addresses and the app's own company.
|
|
71
71
|
*/
|
package/dist/coreView.js
CHANGED
|
@@ -92,6 +92,14 @@ export function useCoreFrame({ appKey, email, fallback, companySwitch = "os", fe
|
|
|
92
92
|
void retryOsContext(client);
|
|
93
93
|
}, [usable, client]);
|
|
94
94
|
const { context, status, current, plate } = useOsPlate(client, appKey, companySwitch);
|
|
95
|
+
/* The read may have waited for the Hub to renew its session (0.4.3): take
|
|
96
|
+
the new token now, for the Admin row, not on the next look. */
|
|
97
|
+
useEffect(() => {
|
|
98
|
+
if (status !== "ready")
|
|
99
|
+
return;
|
|
100
|
+
const next = hubSession(emailNow.current);
|
|
101
|
+
setHub((was) => (sameHub(was, next) ? was : next));
|
|
102
|
+
}, [status]);
|
|
95
103
|
/* The Admin row, as OsWorkspaceFrame decides it: the core's my_admin_scope().
|
|
96
104
|
Asked for each person whose token can be used; a failed answer keeps the
|
|
97
105
|
last one for that person, and nobody's carries over to someone else. */
|
|
@@ -115,7 +123,7 @@ export function useCoreFrame({ appKey, email, fallback, companySwitch = "os", fe
|
|
|
115
123
|
const manages = admin !== null && admin.person === person && admin.manages;
|
|
116
124
|
const source = hub !== null && status === "ready" && context !== null
|
|
117
125
|
? "core"
|
|
118
|
-
:
|
|
126
|
+
: hub !== null && status === "loading" ? "checking" : "static";
|
|
119
127
|
const apps = context?.apps;
|
|
120
128
|
const slug = current?.slug ?? null;
|
|
121
129
|
const frameOptions = useMemo(() => {
|
package/dist/feedback.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type OsFeedbackProps } from "./feedbackSend.js";
|
|
2
|
-
export {
|
|
3
|
-
|
|
2
|
+
export { OS_FEEDBACK_ASK_CSS } from "./feedbackAsk.js";
|
|
3
|
+
export { OS_FEEDBACK_LIMITS, OS_FEEDBACK_TYPES, feedbackContext, feedbackEndpoint, pastedPictures, readPicture, sendFeedback, type OsFeedbackPicture, type OsFeedbackProps, type OsFeedbackResult, type OsFeedbackTenant, type OsFeedbackType, type OsPastedData, } from "./feedbackSend.js";
|
|
4
|
+
/** The bar's Feedback button and its form. */
|
|
4
5
|
export declare function OsFeedbackButton({ appKey, token, tenant, endpoint }: OsFeedbackProps): import("react").JSX.Element;
|
package/dist/feedback.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { jsx as _jsx,
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
/**
|
|
3
|
-
* autosolutions-os/feedback (0.4.0): the
|
|
4
|
-
* feedback form every app shares.
|
|
3
|
+
* autosolutions-os/feedback (0.4.0): the Feedback button in the top bar (a ?
|
|
4
|
+
* until 0.4.2), and the one feedback form every app shares.
|
|
5
5
|
*
|
|
6
|
-
* OsWorkspaceFrame draws the
|
|
6
|
+
* OsWorkspaceFrame draws the button by itself, left of the company plate.
|
|
7
7
|
* An app on its own project gets it from `useCoreFrame({ feedback })` as
|
|
8
8
|
* `core.feedback`, for its TopBar's `actions`.
|
|
9
9
|
*
|
|
@@ -23,10 +23,12 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
23
23
|
* is sent or the page reloads.
|
|
24
24
|
*/
|
|
25
25
|
import { useEffect, useId, useRef, useState } from "react";
|
|
26
|
-
import { OS_FEEDBACK_LIMITS, OS_FEEDBACK_TYPES, readPicture, sendFeedback, } from "./feedbackSend.js";
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
import { OS_FEEDBACK_LIMITS, OS_FEEDBACK_TYPES, pastedPictures, readPicture, sendFeedback, } from "./feedbackSend.js";
|
|
27
|
+
import { keepSeen, OS_FEEDBACK_ASK_CSS, readSeen } from "./feedbackAsk.js";
|
|
28
|
+
export { OS_FEEDBACK_ASK_CSS } from "./feedbackAsk.js";
|
|
29
|
+
export { OS_FEEDBACK_LIMITS, OS_FEEDBACK_TYPES, feedbackContext, feedbackEndpoint, pastedPictures, readPicture, sendFeedback, } from "./feedbackSend.js";
|
|
30
|
+
/* Lucide's message-circle-more (ISC), inline so the bar fetches nothing. */
|
|
31
|
+
const GLYPH = (_jsxs("svg", { className: "osfb-ask__icon", width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", focusable: "false", children: [_jsx("path", { d: "M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719" }), _jsx("path", { d: "M8 12h.01" }), _jsx("path", { d: "M12 12h.01" }), _jsx("path", { d: "M16 12h.01" })] }));
|
|
30
32
|
const D = 'dialog[data-os-feedback="dialog"]';
|
|
31
33
|
const CSS = `
|
|
32
34
|
${D}{box-sizing:border-box;width:min(34rem,calc(100vw - 2rem));max-width:none;max-height:calc(100vh - 2rem);margin:auto;padding:0;border:1px solid var(--ws-color-panel-stroke,#E6E6E8);border-radius:var(--ws-radius-sheet,1rem);background:var(--ws-color-surface,#FFFFFF);color:var(--ws-color-text,#303030);font-family:var(--ws-font,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif);font-size:.875rem;line-height:1.45;text-align:start;box-shadow:0 1.25rem 3.75rem rgba(0,0,0,.25);overflow:auto}
|
|
@@ -66,12 +68,23 @@ ${D} .osfb-alert ul{margin:.375rem 0 0;padding-inline-start:1.25rem}
|
|
|
66
68
|
${D} .osfb-sr{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
|
|
67
69
|
`;
|
|
68
70
|
const EMPTY = { type: "bug", message: "", pictures: [] };
|
|
69
|
-
/** The
|
|
71
|
+
/** The bar's Feedback button and its form. */
|
|
70
72
|
export function OsFeedbackButton({ appKey, token, tenant, endpoint }) {
|
|
71
73
|
const [open, setOpen] = useState(false);
|
|
72
74
|
/* Kept here, not in the dialog, so closing the form keeps what was typed. */
|
|
73
75
|
const [draft, setDraft] = useState(EMPTY);
|
|
74
|
-
|
|
76
|
+
const [seen, setSeen] = useState(false);
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
if (readSeen())
|
|
79
|
+
setSeen(true);
|
|
80
|
+
}, []);
|
|
81
|
+
return (_jsxs(_Fragment, { children: [_jsxs("button", { type: "button", className: seen ? "as-topbar__target osfb-ask is-seen" : "as-topbar__target osfb-ask", "aria-label": "Send feedback", title: "Send feedback", "aria-haspopup": "dialog", "data-os-feedback": "button", onClick: () => {
|
|
82
|
+
setOpen(true);
|
|
83
|
+
if (!seen) {
|
|
84
|
+
setSeen(true);
|
|
85
|
+
keepSeen();
|
|
86
|
+
}
|
|
87
|
+
}, children: [_jsx("style", { children: OS_FEEDBACK_ASK_CSS }), GLYPH, _jsx("span", { className: "osfb-ask__word", children: "Feedback" })] }), open && (_jsx(FeedbackDialog, { appKey: appKey, token: token, tenant: tenant ?? null, ...(endpoint ? { endpoint } : {}), draft: draft, setDraft: setDraft, onClose: () => setOpen(false) }))] }));
|
|
75
88
|
}
|
|
76
89
|
function FeedbackDialog({ appKey, token, tenant, endpoint, draft, setDraft, onClose, }) {
|
|
77
90
|
const ref = useRef(null);
|
|
@@ -114,13 +127,30 @@ function FeedbackDialog({ appKey, token, tenant, endpoint, draft, setDraft, onCl
|
|
|
114
127
|
if (good.length)
|
|
115
128
|
setDraft((d) => ({ ...d, pictures: [...d.pictures, ...good].slice(0, OS_FEEDBACK_LIMITS.pictures) }));
|
|
116
129
|
};
|
|
130
|
+
/* A paste with a picture adds the picture; any other paste (text) goes on
|
|
131
|
+
as normal. pastedPictures reads clipboardData.files, and items when files
|
|
132
|
+
has none (Safari). */
|
|
117
133
|
const onPaste = (e) => {
|
|
118
|
-
const files =
|
|
134
|
+
const files = pastedPictures(e.clipboardData);
|
|
119
135
|
if (files.length === 0)
|
|
120
136
|
return;
|
|
121
137
|
e.preventDefault();
|
|
122
138
|
void addFiles(files);
|
|
123
139
|
};
|
|
140
|
+
/* Keys typed in the form are the form's: the frame's and the app's own key
|
|
141
|
+
handlers above it (menus, search) never see them. Escape still closes the
|
|
142
|
+
dialog (its cancel event). Safari sends no paste event while a button or
|
|
143
|
+
a radio has focus, so Cmd+V or Ctrl+V there moves focus to the text box
|
|
144
|
+
first, and the paste (a picture or text) lands in the form. */
|
|
145
|
+
const onKeyDown = (e) => {
|
|
146
|
+
e.stopPropagation();
|
|
147
|
+
if (!(e.metaKey || e.ctrlKey) || e.altKey || e.key.toLowerCase() !== "v")
|
|
148
|
+
return;
|
|
149
|
+
const at = e.target;
|
|
150
|
+
const typing = at?.tagName === "TEXTAREA" || (at?.tagName === "INPUT" && at.type === "text") || at?.isContentEditable;
|
|
151
|
+
if (!typing)
|
|
152
|
+
text.current?.focus();
|
|
153
|
+
};
|
|
124
154
|
const onDrop = (e) => {
|
|
125
155
|
if (!e.dataTransfer?.files?.length)
|
|
126
156
|
return;
|
|
@@ -163,11 +193,7 @@ function FeedbackDialog({ appKey, token, tenant, endpoint, draft, setDraft, onCl
|
|
|
163
193
|
return (_jsxs("dialog", { ref: ref, "data-os-feedback": "dialog", "aria-labelledby": `${id}-title`, onCancel: (e) => {
|
|
164
194
|
e.preventDefault();
|
|
165
195
|
close();
|
|
166
|
-
},
|
|
167
|
-
/* Keys typed in the form are the form's: the frame's and the app's own
|
|
168
|
-
key handlers above it (menus, search) never see them. Escape still
|
|
169
|
-
closes the dialog (its cancel event). */
|
|
170
|
-
onKeyDown: (e) => e.stopPropagation(), onPaste: onPaste, onDragOver: (e) => {
|
|
196
|
+
}, onKeyDown: onKeyDown, onPaste: onPaste, onDragOver: (e) => {
|
|
171
197
|
if (e.dataTransfer?.types?.includes("Files"))
|
|
172
198
|
e.preventDefault();
|
|
173
199
|
}, onDrop: onDrop, children: [_jsx("style", { children: CSS }), _jsxs("form", { className: "osfb-form", method: "dialog", onSubmit: (e) => {
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const OS_FEEDBACK_ASK_CSS = "\n.osfb-ask.osfb-ask.osfb-ask.osfb-ask.osfb-ask.osfb-ask{width:auto;height:2.25rem;gap:.375rem;margin-inline-end:1rem;padding:0 .875rem 0 .6875rem;border:0;border-radius:999px;background:linear-gradient(110deg,#D1007C 0%,#6E3192 50%,#D1007C 100%);background-size:200% 100%;background-position:0% 50%;color:#FFFFFF;font:inherit;font-size:.8125rem;font-weight:600;line-height:1;white-space:nowrap;animation:osfb-ask-drift 6s ease-in-out 1s 10 alternate}\n.osfb-ask.osfb-ask.osfb-ask.osfb-ask.osfb-ask.osfb-ask:hover{filter:brightness(1.1)}\n.osfb-ask.osfb-ask.osfb-ask.osfb-ask.osfb-ask.osfb-ask:active{filter:brightness(.95)}\n.osfb-ask.osfb-ask.osfb-ask.osfb-ask.osfb-ask.osfb-ask.is-seen{animation:none}\n.osfb-ask.osfb-ask.osfb-ask.osfb-ask.osfb-ask.osfb-ask .osfb-ask__icon{display:block;flex:0 0 auto}\n@keyframes osfb-ask-drift{from{background-position:0% 50%}to{background-position:100% 50%}}\n@media (max-width:767px){.osfb-ask.osfb-ask.osfb-ask.osfb-ask.osfb-ask.osfb-ask{margin-inline-end:.5rem;gap:.3125rem;padding:0 .6875rem 0 .5rem}}\n@media (max-width:409px){.osfb-ask.osfb-ask.osfb-ask.osfb-ask.osfb-ask.osfb-ask{padding:0 .75rem}.osfb-ask.osfb-ask.osfb-ask.osfb-ask.osfb-ask.osfb-ask .osfb-ask__icon{display:none}}\n@media (max-width:379px){.osfb-ask.osfb-ask.osfb-ask.osfb-ask.osfb-ask.osfb-ask{width:2.25rem;padding:0}.osfb-ask.osfb-ask.osfb-ask.osfb-ask.osfb-ask.osfb-ask .osfb-ask__icon{display:block}.osfb-ask.osfb-ask.osfb-ask.osfb-ask.osfb-ask.osfb-ask .osfb-ask__word{display:none}}\n@media (max-width:359px){.osfb-ask.osfb-ask.osfb-ask.osfb-ask.osfb-ask.osfb-ask{margin-inline-end:.25rem}}\n@media (prefers-reduced-motion:reduce){.osfb-ask.osfb-ask.osfb-ask.osfb-ask.osfb-ask.osfb-ask{animation:none}}\n@media (forced-colors:active){.osfb-ask.osfb-ask.osfb-ask.osfb-ask.osfb-ask.osfb-ask{border:1px solid ButtonText;background:ButtonFace;color:ButtonText;forced-color-adjust:none}}\n";
|
|
2
|
+
export declare const OS_FEEDBACK_SEEN_KEY = "autosolutions-os:feedback-seen";
|
|
3
|
+
export declare function readSeen(): boolean;
|
|
4
|
+
export declare function keepSeen(): void;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* The bar's Feedback button (0.4.2; Didac, 5 November 2026, picked "B" with
|
|
3
|
+
* more space before the company). A pill in the logo's pink and purple, with
|
|
4
|
+
* a chat icon and the word Feedback, 20px before the company plate (12px on
|
|
5
|
+
* a phone). For its first minute on a page its colour drifts slowly from pink
|
|
6
|
+
* to purple and back, until the person has opened the form once in this
|
|
7
|
+
* browser (`is-seen`, kept in localStorage); never with reduced motion.
|
|
8
|
+
* Phones: the icon and the word from 410px, the word alone from 380px (a
|
|
9
|
+
* 390px iPhone), the icon alone below (measured on the Hub's bar: the search
|
|
10
|
+
* gives way, the plate stays whole, the bar keeps its end padding).
|
|
11
|
+
* Six classes outrank the frame's `.as-frame.as-ws > ... .as-topbar__target`
|
|
12
|
+
* (five), which sizes every bar target as a 36px circle.
|
|
13
|
+
*/
|
|
14
|
+
const A = ".osfb-ask.osfb-ask.osfb-ask.osfb-ask.osfb-ask.osfb-ask";
|
|
15
|
+
export const OS_FEEDBACK_ASK_CSS = `
|
|
16
|
+
${A}{width:auto;height:2.25rem;gap:.375rem;margin-inline-end:1rem;padding:0 .875rem 0 .6875rem;border:0;border-radius:999px;background:linear-gradient(110deg,#D1007C 0%,#6E3192 50%,#D1007C 100%);background-size:200% 100%;background-position:0% 50%;color:#FFFFFF;font:inherit;font-size:.8125rem;font-weight:600;line-height:1;white-space:nowrap;animation:osfb-ask-drift 6s ease-in-out 1s 10 alternate}
|
|
17
|
+
${A}:hover{filter:brightness(1.1)}
|
|
18
|
+
${A}:active{filter:brightness(.95)}
|
|
19
|
+
${A}.is-seen{animation:none}
|
|
20
|
+
${A} .osfb-ask__icon{display:block;flex:0 0 auto}
|
|
21
|
+
@keyframes osfb-ask-drift{from{background-position:0% 50%}to{background-position:100% 50%}}
|
|
22
|
+
@media (max-width:767px){${A}{margin-inline-end:.5rem;gap:.3125rem;padding:0 .6875rem 0 .5rem}}
|
|
23
|
+
@media (max-width:409px){${A}{padding:0 .75rem}${A} .osfb-ask__icon{display:none}}
|
|
24
|
+
@media (max-width:379px){${A}{width:2.25rem;padding:0}${A} .osfb-ask__icon{display:block}${A} .osfb-ask__word{display:none}}
|
|
25
|
+
@media (max-width:359px){${A}{margin-inline-end:.25rem}}
|
|
26
|
+
@media (prefers-reduced-motion:reduce){${A}{animation:none}}
|
|
27
|
+
@media (forced-colors:active){${A}{border:1px solid ButtonText;background:ButtonFace;color:ButtonText;forced-color-adjust:none}}
|
|
28
|
+
`;
|
|
29
|
+
/* Opened once in this browser: the button stops drifting for good. Storage can
|
|
30
|
+
be missing or refuse (private windows, blocked site data); then it drifts. */
|
|
31
|
+
export const OS_FEEDBACK_SEEN_KEY = "autosolutions-os:feedback-seen";
|
|
32
|
+
export function readSeen() {
|
|
33
|
+
try {
|
|
34
|
+
return globalThis.localStorage?.getItem(OS_FEEDBACK_SEEN_KEY) === "1";
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export function keepSeen() {
|
|
41
|
+
try {
|
|
42
|
+
globalThis.localStorage?.setItem(OS_FEEDBACK_SEEN_KEY, "1");
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
/* nothing to keep it in */
|
|
46
|
+
}
|
|
47
|
+
}
|
package/dist/feedbackSend.d.ts
CHANGED
|
@@ -64,5 +64,23 @@ export declare function sendFeedback(input: {
|
|
|
64
64
|
endpoint?: string;
|
|
65
65
|
fetch?: typeof fetch;
|
|
66
66
|
}): Promise<OsFeedbackResult>;
|
|
67
|
+
/** What a paste or a drop carries: its files, and each item that is a file. */
|
|
68
|
+
export type OsPastedData = {
|
|
69
|
+
files?: ArrayLike<File> | null;
|
|
70
|
+
items?: ArrayLike<{
|
|
71
|
+
kind: string;
|
|
72
|
+
type: string;
|
|
73
|
+
getAsFile(): File | null;
|
|
74
|
+
}> | null;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* The pictures in a paste (0.4.2). Most browsers put a copied picture in
|
|
78
|
+
* `clipboardData.files`. Safari, and some "Copy image" menus, give it only in
|
|
79
|
+
* `clipboardData.items` (an item of kind "file"). This reads `files` first;
|
|
80
|
+
* only when `files` has no picture does it read `items`, because a browser
|
|
81
|
+
* that fills both puts the same picture in each. An item's file with no type
|
|
82
|
+
* takes the item's type. Text is never a picture, so a text paste gives [].
|
|
83
|
+
*/
|
|
84
|
+
export declare function pastedPictures(data: OsPastedData | null | undefined): File[];
|
|
67
85
|
/** One picture the person added, made ready to send, or a sentence saying why it cannot be. */
|
|
68
86
|
export declare function readPicture(file: File): Promise<OsFeedbackPicture | string>;
|
package/dist/feedbackSend.js
CHANGED
|
@@ -116,6 +116,34 @@ async function shrink(file) {
|
|
|
116
116
|
bitmap.close?.();
|
|
117
117
|
return await new Promise((resolve) => canvas.toBlob((blob) => resolve(blob), "image/jpeg", 0.85));
|
|
118
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* The pictures in a paste (0.4.2). Most browsers put a copied picture in
|
|
121
|
+
* `clipboardData.files`. Safari, and some "Copy image" menus, give it only in
|
|
122
|
+
* `clipboardData.items` (an item of kind "file"). This reads `files` first;
|
|
123
|
+
* only when `files` has no picture does it read `items`, because a browser
|
|
124
|
+
* that fills both puts the same picture in each. An item's file with no type
|
|
125
|
+
* takes the item's type. Text is never a picture, so a text paste gives [].
|
|
126
|
+
*/
|
|
127
|
+
export function pastedPictures(data) {
|
|
128
|
+
if (!data)
|
|
129
|
+
return [];
|
|
130
|
+
const files = Array.from(data.files ?? []).filter((f) => f.type.startsWith("image/"));
|
|
131
|
+
if (files.length)
|
|
132
|
+
return files;
|
|
133
|
+
const out = [];
|
|
134
|
+
for (const item of Array.from(data.items ?? [])) {
|
|
135
|
+
if (item.kind !== "file")
|
|
136
|
+
continue;
|
|
137
|
+
const f = item.getAsFile();
|
|
138
|
+
if (!f)
|
|
139
|
+
continue;
|
|
140
|
+
const type = f.type || item.type;
|
|
141
|
+
if (!type.startsWith("image/"))
|
|
142
|
+
continue;
|
|
143
|
+
out.push(f.type ? f : new File([f], f.name || "picture", { type }));
|
|
144
|
+
}
|
|
145
|
+
return out;
|
|
146
|
+
}
|
|
119
147
|
/** One picture the person added, made ready to send, or a sentence saying why it cannot be. */
|
|
120
148
|
export async function readPicture(file) {
|
|
121
149
|
if (!file.type.startsWith("image/"))
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,6 @@ export { loadOsContext, invalidateOsContext, refreshOsContext, retryOsContext, w
|
|
|
5
5
|
export { isEntitled, isActiveMember, appRole, appVariant, currentTenant, toolAllowed, myAdminScope, canManageCurrentCompany, type AdminScope, } from "./identity.js";
|
|
6
6
|
export { OsAppSwitcher, OsAppSwitcherPlate, OsCompanySwitcher, OsBar, useCompanySwitch } from "./chrome.js";
|
|
7
7
|
export { OsAuthGate, type OsAuthGateProps } from "./gate.js";
|
|
8
|
-
export { OsFeedbackButton, sendFeedback, feedbackContext, feedbackEndpoint, readPicture, OS_FEEDBACK_TYPES, OS_FEEDBACK_LIMITS, type OsFeedbackProps, type OsFeedbackResult, type OsFeedbackTenant, type OsFeedbackType, type OsFeedbackPicture, } from "./feedback.js";
|
|
8
|
+
export { OsFeedbackButton, sendFeedback, feedbackContext, feedbackEndpoint, readPicture, pastedPictures, OS_FEEDBACK_TYPES, OS_FEEDBACK_LIMITS, type OsFeedbackProps, type OsFeedbackResult, type OsFeedbackTenant, type OsFeedbackType, type OsFeedbackPicture, type OsPastedData, } from "./feedback.js";
|
|
9
9
|
export { osAccessToken } from "./client.js";
|
|
10
10
|
export { OS_VERSION } from "./version.js";
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,6 @@ export { loadOsContext, invalidateOsContext, refreshOsContext, retryOsContext, w
|
|
|
5
5
|
export { isEntitled, isActiveMember, appRole, appVariant, currentTenant, toolAllowed, myAdminScope, canManageCurrentCompany, } from "./identity.js";
|
|
6
6
|
export { OsAppSwitcher, OsAppSwitcherPlate, OsCompanySwitcher, OsBar, useCompanySwitch } from "./chrome.js";
|
|
7
7
|
export { OsAuthGate } from "./gate.js";
|
|
8
|
-
export { OsFeedbackButton, sendFeedback, feedbackContext, feedbackEndpoint, readPicture, OS_FEEDBACK_TYPES, OS_FEEDBACK_LIMITS, } from "./feedback.js";
|
|
8
|
+
export { OsFeedbackButton, sendFeedback, feedbackContext, feedbackEndpoint, readPicture, pastedPictures, OS_FEEDBACK_TYPES, OS_FEEDBACK_LIMITS, } from "./feedback.js";
|
|
9
9
|
export { osAccessToken } from "./client.js";
|
|
10
10
|
export { OS_VERSION } from "./version.js";
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** This package's version, sent with each feedback message. A test keeps it equal to package.json. */
|
|
2
|
-
export declare const OS_VERSION = "0.4.
|
|
2
|
+
export declare const OS_VERSION = "0.4.3";
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** This package's version, sent with each feedback message. A test keeps it equal to package.json. */
|
|
2
|
-
export const OS_VERSION = "0.4.
|
|
2
|
+
export const OS_VERSION = "0.4.3";
|
package/package.json
CHANGED