autosolutions-os 0.4.3 → 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 +17 -0
- package/README.md +20 -0
- 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,22 @@
|
|
|
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
|
+
|
|
3
20
|
## 0.4.3 - 2026-11-06
|
|
4
21
|
|
|
5
22
|
The company switcher works in Ops Hub and Asset Portal with no Hub tab open
|
package/README.md
CHANGED
|
@@ -492,6 +492,26 @@ layout, and Escape closes it. Closing it keeps the draft until it is sent.
|
|
|
492
492
|
`autosolutions-os/feedback` also exports the form's logic (`sendFeedback`,
|
|
493
493
|
`feedbackContext`, `readPicture`) for tests.
|
|
494
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
|
+
|
|
495
515
|
## On the server
|
|
496
516
|
|
|
497
517
|
The package is plain ES modules, so Node, a test runner and a dev server's SSR
|
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
|
}
|