autosolutions-os 0.4.2 → 0.4.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/CHANGELOG.md +41 -0
- package/README.md +29 -3
- 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 +4 -1
- package/dist/feedback.js +2 -2
- package/dist/feedbackAsk.d.ts +1 -1
- package/dist/feedbackAsk.js +6 -1
- package/dist/feedbackEverywhere.d.ts +28 -0
- package/dist/feedbackEverywhere.js +98 -0
- package/dist/feedbackSend.d.ts +3 -0
- package/dist/feedbackSend.js +43 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +7 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,46 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.4 - 2026-11-06
|
|
4
|
+
|
|
5
|
+
The Feedback button on every page (Didac, 6 November 2026: "I want the new
|
|
6
|
+
feedback button EVERYWHERE").
|
|
7
|
+
|
|
8
|
+
- New `autosolutions-os/feedback-everywhere`: `startOsFeedback({ appKey, token })`,
|
|
9
|
+
called once when an app starts. On a page with no Feedback button of its own
|
|
10
|
+
(a 404, an error page, a "no access" screen), a signed-in person gets the same
|
|
11
|
+
pink button floating at the top right, after about three seconds. It stays up
|
|
12
|
+
when the app's own tree has failed. People who are not signed in do not see it,
|
|
13
|
+
as the form cannot send for them.
|
|
14
|
+
- The button draws correctly outside the frame too, so `OsFeedbackButton` can go
|
|
15
|
+
in any TopBar's `actions`.
|
|
16
|
+
- The path now keeps which view a page is on (`view`, `screen`, `mode`, `tab`,
|
|
17
|
+
`section`), so the Slack DM and Admin list say `/?view=labels`, not `/`.
|
|
18
|
+
- The address a message keeps has no sign-in code or token in it.
|
|
19
|
+
|
|
20
|
+
## 0.4.3 - 2026-11-06
|
|
21
|
+
|
|
22
|
+
The company switcher works in Ops Hub and Asset Portal with no Hub tab open
|
|
23
|
+
(Didac asked on 6 November 2026: "this should be working across everywhere").
|
|
24
|
+
|
|
25
|
+
Those two apps keep their own Supabase projects and borrow the Hub's session
|
|
26
|
+
from the shared cookie for their menu and company switcher. Only the Hub and
|
|
27
|
+
the apps on the core may refresh it, so an hour with no Hub tab open left the
|
|
28
|
+
borrowed token useless: a new page showed the app's fixed plate with no
|
|
29
|
+
switcher, and a switch from a page already open failed with "Couldn't switch".
|
|
30
|
+
|
|
31
|
+
- `autosolutions-os/core-view`: a call that finds the token run out asks the Hub
|
|
32
|
+
to renew it (`renewHubSession`), in a hidden frame on the Hub's blank page
|
|
33
|
+
`/renew-session`. The Hub's own client refreshes by the rules in session.ts
|
|
34
|
+
and writes the shared cookie; the call waits for that, up to 15 seconds, then
|
|
35
|
+
goes on. The reader still never touches a token itself.
|
|
36
|
+
- The frame shows "checking" while that runs, then the Hub's frame.
|
|
37
|
+
- One renewal at a time on a page, and five minutes before the next try after
|
|
38
|
+
one that did not work. A session that has ended or was signed out is not
|
|
39
|
+
brought back: the frame stays the app's fixed one.
|
|
40
|
+
- The page must be live on the Hub first (autosolutions-os PR #67). Before that,
|
|
41
|
+
a renewal gives up after 15 seconds and the frame is the fixed one, as in
|
|
42
|
+
0.4.2.
|
|
43
|
+
|
|
3
44
|
## 0.4.2 - 2026-11-05
|
|
4
45
|
|
|
5
46
|
The ? becomes a Feedback button that people see, and pasting a picture into
|
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;
|
|
@@ -486,6 +492,26 @@ layout, and Escape closes it. Closing it keeps the draft until it is sent.
|
|
|
486
492
|
`autosolutions-os/feedback` also exports the form's logic (`sendFeedback`,
|
|
487
493
|
`feedbackContext`, `readPicture`) for tests.
|
|
488
494
|
|
|
495
|
+
A page with no top bar gets the button too (0.4.4). Each app starts the watch
|
|
496
|
+
once, in its router or its entry file:
|
|
497
|
+
|
|
498
|
+
```ts
|
|
499
|
+
import { startOsFeedback } from "autosolutions-os/feedback-everywhere";
|
|
500
|
+
|
|
501
|
+
startOsFeedback({
|
|
502
|
+
appKey: "key_accounts",
|
|
503
|
+
token: async () => (await supabase.auth.getSession()).data.session?.access_token,
|
|
504
|
+
});
|
|
505
|
+
```
|
|
506
|
+
|
|
507
|
+
It does nothing on the server. In the browser it looks at the page every 1.5
|
|
508
|
+
seconds. On a page with no Feedback button of its own (a 404, an error page, a
|
|
509
|
+
"no access" screen), a signed-in person gets the pink button floating at the top
|
|
510
|
+
right. It leaves as soon as a page has its own, and it has its own React root,
|
|
511
|
+
so it stays up when the app's tree has failed. The file is small and loads the
|
|
512
|
+
form only when a page needs it. A page with its own bar that is not the frame
|
|
513
|
+
puts `OsFeedbackButton` from `autosolutions-os/feedback` in the bar's `actions`.
|
|
514
|
+
|
|
489
515
|
## On the server
|
|
490
516
|
|
|
491
517
|
The package is plain ES modules, so Node, a test runner and a dev server's SSR
|
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
|
@@ -2,4 +2,7 @@ import { type OsFeedbackProps } from "./feedbackSend.js";
|
|
|
2
2
|
export { OS_FEEDBACK_ASK_CSS } from "./feedbackAsk.js";
|
|
3
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
4
|
/** The bar's Feedback button and its form. */
|
|
5
|
-
export declare function OsFeedbackButton({ appKey, token, tenant, endpoint }: OsFeedbackProps
|
|
5
|
+
export declare function OsFeedbackButton({ appKey, token, tenant, endpoint, float }: OsFeedbackProps & {
|
|
6
|
+
/** On a page with no top bar (0.4.4, feedbackEverywhere.ts): it floats at the top right. */
|
|
7
|
+
float?: boolean;
|
|
8
|
+
}): import("react").JSX.Element;
|
package/dist/feedback.js
CHANGED
|
@@ -69,7 +69,7 @@ ${D} .osfb-sr{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overf
|
|
|
69
69
|
`;
|
|
70
70
|
const EMPTY = { type: "bug", message: "", pictures: [] };
|
|
71
71
|
/** The bar's Feedback button and its form. */
|
|
72
|
-
export function OsFeedbackButton({ appKey, token, tenant, endpoint }) {
|
|
72
|
+
export function OsFeedbackButton({ appKey, token, tenant, endpoint, float = false }) {
|
|
73
73
|
const [open, setOpen] = useState(false);
|
|
74
74
|
/* Kept here, not in the dialog, so closing the form keeps what was typed. */
|
|
75
75
|
const [draft, setDraft] = useState(EMPTY);
|
|
@@ -78,7 +78,7 @@ export function OsFeedbackButton({ appKey, token, tenant, endpoint }) {
|
|
|
78
78
|
if (readSeen())
|
|
79
79
|
setSeen(true);
|
|
80
80
|
}, []);
|
|
81
|
-
return (_jsxs(_Fragment, { children: [_jsxs("button", { type: "button", className:
|
|
81
|
+
return (_jsxs(_Fragment, { children: [_jsxs("button", { type: "button", className: `${float ? "osfb-ask--float" : "as-topbar__target"} osfb-ask${seen ? " is-seen" : ""}`, "aria-label": "Send feedback", title: "Send feedback", "aria-haspopup": "dialog", "data-os-feedback": "button", onClick: () => {
|
|
82
82
|
setOpen(true);
|
|
83
83
|
if (!seen) {
|
|
84
84
|
setSeen(true);
|
package/dist/feedbackAsk.d.ts
CHANGED
|
@@ -1,4 +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";
|
|
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;display:inline-flex;align-items:center;justify-content:center;box-sizing:border-box;cursor:pointer;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--float{position:fixed;top:.75rem;inset-inline-end:1rem;z-index:2147483000;margin:0;padding:0 .875rem 0 .6875rem;width:auto;box-shadow:0 .25rem .75rem rgba(0,0,0,.25)}\n.osfb-ask.osfb-ask.osfb-ask.osfb-ask.osfb-ask.osfb-ask.osfb-ask--float .osfb-ask__icon{display:block}\n.osfb-ask.osfb-ask.osfb-ask.osfb-ask.osfb-ask.osfb-ask.osfb-ask--float .osfb-ask__word{display:inline}\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
2
|
export declare const OS_FEEDBACK_SEEN_KEY = "autosolutions-os:feedback-seen";
|
|
3
3
|
export declare function readSeen(): boolean;
|
|
4
4
|
export declare function keepSeen(): void;
|
package/dist/feedbackAsk.js
CHANGED
|
@@ -8,15 +8,20 @@
|
|
|
8
8
|
* Phones: the icon and the word from 410px, the word alone from 380px (a
|
|
9
9
|
* 390px iPhone), the icon alone below (measured on the Hub's bar: the search
|
|
10
10
|
* gives way, the plate stays whole, the bar keeps its end padding).
|
|
11
|
+
* A page with no top bar gets the same pill floating at its top right, always
|
|
12
|
+
* with the icon and the word (0.4.4, `osfb-ask--float`).
|
|
11
13
|
* Six classes outrank the frame's `.as-frame.as-ws > ... .as-topbar__target`
|
|
12
14
|
* (five), which sizes every bar target as a 36px circle.
|
|
13
15
|
*/
|
|
14
16
|
const A = ".osfb-ask.osfb-ask.osfb-ask.osfb-ask.osfb-ask.osfb-ask";
|
|
15
17
|
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}
|
|
18
|
+
${A}{width:auto;height:2.25rem;display:inline-flex;align-items:center;justify-content:center;box-sizing:border-box;cursor:pointer;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
19
|
${A}:hover{filter:brightness(1.1)}
|
|
18
20
|
${A}:active{filter:brightness(.95)}
|
|
19
21
|
${A}.is-seen{animation:none}
|
|
22
|
+
${A}.osfb-ask--float{position:fixed;top:.75rem;inset-inline-end:1rem;z-index:2147483000;margin:0;padding:0 .875rem 0 .6875rem;width:auto;box-shadow:0 .25rem .75rem rgba(0,0,0,.25)}
|
|
23
|
+
${A}.osfb-ask--float .osfb-ask__icon{display:block}
|
|
24
|
+
${A}.osfb-ask--float .osfb-ask__word{display:inline}
|
|
20
25
|
${A} .osfb-ask__icon{display:block;flex:0 0 auto}
|
|
21
26
|
@keyframes osfb-ask-drift{from{background-position:0% 50%}to{background-position:100% 50%}}
|
|
22
27
|
@media (max-width:767px){${A}{margin-inline-end:.5rem;gap:.3125rem;padding:0 .6875rem 0 .5rem}}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* autosolutions-os/feedback-everywhere (0.4.4): the Feedback button on every
|
|
3
|
+
* page the top bar does not reach (Didac, 6 November 2026: "I want the new
|
|
4
|
+
* feedback button EVERYWHERE"). A 404, an error page, a "no access" screen
|
|
5
|
+
* and any page an app adds later have no frame, so they have no button. A
|
|
6
|
+
* person who lands there is the person with something to report.
|
|
7
|
+
*
|
|
8
|
+
* Each app calls `startOsFeedback` once when it starts. From then on it looks
|
|
9
|
+
* at the page every 1.5 seconds. When a signed-in person has been on a page
|
|
10
|
+
* with no Feedback button for two looks, the button floats at the top right.
|
|
11
|
+
* It goes away as soon as a page has a button of its own. Someone who is not
|
|
12
|
+
* signed in never sees it: the form cannot send without their token.
|
|
13
|
+
*
|
|
14
|
+
* It has its own React root on document.body, so it stays up when the app's
|
|
15
|
+
* tree has failed, which is when an error page shows. This file is small and
|
|
16
|
+
* loads nothing else until a page needs the button, so it can sit in an app's
|
|
17
|
+
* first bundle.
|
|
18
|
+
*/
|
|
19
|
+
import type { OsFeedbackProps } from "./feedbackSend.js";
|
|
20
|
+
export type OsFeedbackEverywhereOptions = Pick<OsFeedbackProps, "appKey" | "token" | "endpoint"> & {
|
|
21
|
+
/** How often it looks at the page, for tests. Default 1,500 ms. */
|
|
22
|
+
checkMs?: number;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Starts the watch on this page and returns what stops it. A second call
|
|
26
|
+
* changes nothing and returns the same stop. On the server it does nothing.
|
|
27
|
+
*/
|
|
28
|
+
export declare function startOsFeedback(options: OsFeedbackEverywhereOptions): () => void;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
const BUTTON = '[data-os-feedback="button"]';
|
|
2
|
+
const LOOKS = 2;
|
|
3
|
+
let stopRunning = null;
|
|
4
|
+
/**
|
|
5
|
+
* Starts the watch on this page and returns what stops it. A second call
|
|
6
|
+
* changes nothing and returns the same stop. On the server it does nothing.
|
|
7
|
+
*/
|
|
8
|
+
export function startOsFeedback(options) {
|
|
9
|
+
if (typeof window === "undefined" || typeof document === "undefined")
|
|
10
|
+
return () => { };
|
|
11
|
+
if (stopRunning)
|
|
12
|
+
return stopRunning;
|
|
13
|
+
let host = null;
|
|
14
|
+
let root = null;
|
|
15
|
+
let watcher = null;
|
|
16
|
+
let looks = 0;
|
|
17
|
+
let busy = false;
|
|
18
|
+
let loading = false;
|
|
19
|
+
let stopped = false;
|
|
20
|
+
/* A button that is not ours: the frame's, or one the page drew. */
|
|
21
|
+
const hasOwn = () => Array.from(document.querySelectorAll(BUTTON)).some((node) => !host?.contains(node));
|
|
22
|
+
const hide = () => {
|
|
23
|
+
/* Never under someone's hands: the open form keeps what they typed. */
|
|
24
|
+
if (host?.querySelector("dialog[open]"))
|
|
25
|
+
return;
|
|
26
|
+
watcher?.disconnect();
|
|
27
|
+
watcher = null;
|
|
28
|
+
root?.unmount();
|
|
29
|
+
root = null;
|
|
30
|
+
host?.remove();
|
|
31
|
+
host = null;
|
|
32
|
+
};
|
|
33
|
+
const show = async () => {
|
|
34
|
+
if (host || loading)
|
|
35
|
+
return;
|
|
36
|
+
loading = true;
|
|
37
|
+
try {
|
|
38
|
+
const [{ createElement }, { createRoot }, { OsFeedbackButton }] = await Promise.all([
|
|
39
|
+
import("react"),
|
|
40
|
+
import("react-dom/client"),
|
|
41
|
+
import("./feedback.js"),
|
|
42
|
+
]);
|
|
43
|
+
if (stopped || hasOwn())
|
|
44
|
+
return;
|
|
45
|
+
host = document.createElement("div");
|
|
46
|
+
host.setAttribute("data-os-feedback", "float");
|
|
47
|
+
document.body.appendChild(host);
|
|
48
|
+
root = createRoot(host);
|
|
49
|
+
const endpoint = options.endpoint ? { endpoint: options.endpoint } : {};
|
|
50
|
+
root.render(createElement(OsFeedbackButton, { appKey: options.appKey, token: options.token, ...endpoint, float: true }));
|
|
51
|
+
/* A frame that arrives takes over at once, not at the next look. */
|
|
52
|
+
watcher = new MutationObserver(() => {
|
|
53
|
+
if (hasOwn())
|
|
54
|
+
hide();
|
|
55
|
+
});
|
|
56
|
+
watcher.observe(document.body, { childList: true, subtree: true });
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
/* A chunk that will not load: the next look tries again. */
|
|
60
|
+
}
|
|
61
|
+
finally {
|
|
62
|
+
loading = false;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
const look = async () => {
|
|
66
|
+
if (busy || stopped)
|
|
67
|
+
return;
|
|
68
|
+
if (hasOwn()) {
|
|
69
|
+
looks = 0;
|
|
70
|
+
hide();
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (!host) {
|
|
74
|
+
looks += 1;
|
|
75
|
+
if (looks < LOOKS)
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
busy = true;
|
|
79
|
+
const token = await Promise.resolve().then(options.token).catch(() => null);
|
|
80
|
+
busy = false;
|
|
81
|
+
if (stopped)
|
|
82
|
+
return;
|
|
83
|
+
if (token)
|
|
84
|
+
await show();
|
|
85
|
+
else
|
|
86
|
+
hide();
|
|
87
|
+
};
|
|
88
|
+
const timer = setInterval(() => void look(), options.checkMs ?? 1500);
|
|
89
|
+
stopRunning = () => {
|
|
90
|
+
stopped = true;
|
|
91
|
+
clearInterval(timer);
|
|
92
|
+
watcher?.disconnect();
|
|
93
|
+
root?.unmount();
|
|
94
|
+
host?.remove();
|
|
95
|
+
stopRunning = null;
|
|
96
|
+
};
|
|
97
|
+
return stopRunning;
|
|
98
|
+
}
|
package/dist/feedbackSend.d.ts
CHANGED
|
@@ -44,6 +44,9 @@ export type OsFeedbackResult = {
|
|
|
44
44
|
};
|
|
45
45
|
/** Where the form sends by default. */
|
|
46
46
|
export declare function feedbackEndpoint(): string;
|
|
47
|
+
/** The part of a query that names the view, with its ?, or "". */
|
|
48
|
+
export declare function viewQuery(query: string): string;
|
|
49
|
+
export declare function safeAddress(href: string): string;
|
|
47
50
|
/** What the form sends besides what the person types, read when they press Send. */
|
|
48
51
|
export declare function feedbackContext(): {
|
|
49
52
|
page: {
|
package/dist/feedbackSend.js
CHANGED
|
@@ -16,6 +16,46 @@ const PICTURE_TYPES = ["image/png", "image/jpeg", "image/webp"];
|
|
|
16
16
|
export function feedbackEndpoint() {
|
|
17
17
|
return `${coreUrl().replace(/\/+$/, "")}/functions/v1/feedback-submit`;
|
|
18
18
|
}
|
|
19
|
+
/*
|
|
20
|
+
* The query names that say which view of a page this is (0.4.4). Only these go
|
|
21
|
+
* in the path, which the Slack DM and the Admin list show. A query can also
|
|
22
|
+
* hold a sign-in code or an invitation token, so nothing else does.
|
|
23
|
+
*/
|
|
24
|
+
const VIEW_PARAMS = ["view", "screen", "mode", "tab", "section"];
|
|
25
|
+
/** The part of a query that names the view, with its ?, or "". */
|
|
26
|
+
export function viewQuery(query) {
|
|
27
|
+
const from = new URLSearchParams(query);
|
|
28
|
+
const keep = new URLSearchParams();
|
|
29
|
+
for (const name of VIEW_PARAMS) {
|
|
30
|
+
const value = from.get(name);
|
|
31
|
+
if (value)
|
|
32
|
+
keep.set(name, value);
|
|
33
|
+
}
|
|
34
|
+
const out = keep.toString();
|
|
35
|
+
return out ? `?${out}` : "";
|
|
36
|
+
}
|
|
37
|
+
/*
|
|
38
|
+
* The page's address with no sign-in code or token in it (0.4.4). The button
|
|
39
|
+
* now reaches pages like an invitation link, and an address is kept for good.
|
|
40
|
+
*/
|
|
41
|
+
const SECRET_PARAM = /(^|[_-])(token|code|otp|secret|password|key)$|^state$/i;
|
|
42
|
+
export function safeAddress(href) {
|
|
43
|
+
let url;
|
|
44
|
+
try {
|
|
45
|
+
url = new URL(href);
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return href;
|
|
49
|
+
}
|
|
50
|
+
for (const name of Array.from(url.searchParams.keys())) {
|
|
51
|
+
if (SECRET_PARAM.test(name))
|
|
52
|
+
url.searchParams.delete(name);
|
|
53
|
+
}
|
|
54
|
+
/* A hash that is not a route is a sign-in return (#access_token=...). */
|
|
55
|
+
if (url.hash && !url.hash.startsWith("#/"))
|
|
56
|
+
url.hash = "";
|
|
57
|
+
return url.toString();
|
|
58
|
+
}
|
|
19
59
|
/** What the form sends besides what the person types, read when they press Send. */
|
|
20
60
|
export function feedbackContext() {
|
|
21
61
|
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
@@ -23,7 +63,8 @@ export function feedbackContext() {
|
|
|
23
63
|
}
|
|
24
64
|
const where = window.location;
|
|
25
65
|
/* A hash router's place is in the hash ("#/assets"); keep it in the path. */
|
|
26
|
-
const
|
|
66
|
+
const [hashPath = "", hashQuery = ""] = where.hash.startsWith("#/") ? where.hash.split("?") : [];
|
|
67
|
+
const route = hashPath + viewQuery(hashQuery);
|
|
27
68
|
const ratio = window.devicePixelRatio || 1;
|
|
28
69
|
const commit = document.querySelector("script[data-commit-sha]")?.getAttribute("data-commit-sha")
|
|
29
70
|
?? document.documentElement.getAttribute("data-commit-sha")
|
|
@@ -40,7 +81,7 @@ export function feedbackContext() {
|
|
|
40
81
|
? `${Math.round(window.screen.width * ratio)}x${Math.round(window.screen.height * ratio)}`
|
|
41
82
|
: null;
|
|
42
83
|
return {
|
|
43
|
-
page: { path: where.pathname + route, title: document.title || null, url: where.href },
|
|
84
|
+
page: { path: where.pathname + viewQuery(where.search ?? "") + route, title: document.title || null, url: safeAddress(where.href) },
|
|
44
85
|
client: {
|
|
45
86
|
user_agent: typeof navigator === "object" ? navigator.userAgent : null,
|
|
46
87
|
viewport: `${window.innerWidth}x${window.innerHeight}`,
|
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.4";
|
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.4";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "autosolutions-os",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
4
4
|
"description": "One sign-in, one company switcher, one app grid. What every AutoSolutions app imports instead of copying.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"./search": { "types": "./dist/search.d.ts", "import": "./dist/search.js" },
|
|
16
16
|
"./core-view": { "types": "./dist/coreView.d.ts", "import": "./dist/coreView.js" },
|
|
17
17
|
"./feedback": { "types": "./dist/feedback.d.ts", "import": "./dist/feedback.js" },
|
|
18
|
+
"./feedback-everywhere": { "types": "./dist/feedbackEverywhere.d.ts", "import": "./dist/feedbackEverywhere.js" },
|
|
18
19
|
"./chrome.css": "./dist/chrome.css"
|
|
19
20
|
},
|
|
20
21
|
"files": ["dist", "CHANGELOG.md"],
|
|
@@ -26,14 +27,17 @@
|
|
|
26
27
|
"peerDependencies": {
|
|
27
28
|
"@supabase/supabase-js": ">=2.40.0",
|
|
28
29
|
"autosolutions-design-system": ">=6.5.0 <7",
|
|
29
|
-
"react": ">=18"
|
|
30
|
+
"react": ">=18",
|
|
31
|
+
"react-dom": ">=18"
|
|
30
32
|
},
|
|
31
33
|
"peerDependenciesMeta": {
|
|
32
34
|
"autosolutions-design-system": { "optional": true },
|
|
33
|
-
"react": { "optional": true }
|
|
35
|
+
"react": { "optional": true },
|
|
36
|
+
"react-dom": { "optional": true }
|
|
34
37
|
},
|
|
35
38
|
"devDependencies": {
|
|
36
39
|
"@types/react": "^19.2.0",
|
|
40
|
+
"@types/react-dom": "^19.2.0",
|
|
37
41
|
"typescript": "^5.8.3"
|
|
38
42
|
}
|
|
39
43
|
}
|