sanity-plugin-all-in-one-accessibility 1.1.4 → 1.1.5
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/dist/index.js +44 -70
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useColorSchemeValue, useColorSchemeSetValue, useCurrentUser, definePlugin } from "sanity";
|
|
2
2
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { forwardRef, createContext, useContext, useRef, useEffect, useState, useCallback, useMemo } from "react";
|
|
4
|
-
const AIOA_API_BASE = "https://ada.skynettechnologies.us/api/", AIOA_UPDATE_API = `${AIOA_API_BASE}widget-setting-update-platform`, AIOA_PLATFORM = "sanity",
|
|
4
|
+
const AIOA_API_BASE = "https://ada.skynettechnologies.us/api/", AIOA_UPDATE_API = `${AIOA_API_BASE}widget-setting-update-platform`, AIOA_PLATFORM = "sanity", AIOA_CHECK_WEBSITE_API = "https://ada.skynettechnologies.us/check-website", AIOA_GEO_API = "https://ipapi.co/json", AIOA_UPGRADE_URL = "https://ada.skynettechnologies.us/trial-subscription", AIOA_HTTP_TIMEOUT = 30, AIOA_GEO_TIMEOUT = 8e3, AIOA_SCAN_API = "https://skynetaccessibilityscan.com/api/ada-scanner/domain/details", AIOA_SCAN_LANG = "en", AIOA_SCORE_LEVELS = [
|
|
5
5
|
[85, "compliant", "Compliant"],
|
|
6
6
|
[50, "semi", "Semi Compliant"],
|
|
7
7
|
[0, "not", "Not Compliant"]
|
|
@@ -110,17 +110,7 @@ const storage = {
|
|
|
110
110
|
class PendingError extends Error {
|
|
111
111
|
pending = !0;
|
|
112
112
|
}
|
|
113
|
-
const
|
|
114
|
-
"is_mobile_position",
|
|
115
|
-
"is_widget_custom_position_mobile",
|
|
116
|
-
"widget_position_mobile",
|
|
117
|
-
"widget_position_top_mobile",
|
|
118
|
-
"widget_position_bottom_mobile",
|
|
119
|
-
"widget_position_left_mobile",
|
|
120
|
-
"widget_position_right_mobile",
|
|
121
|
-
"widget_position_vertical_center_offset_mobile",
|
|
122
|
-
"widget_position_horizontal_center_offset_mobile"
|
|
123
|
-
], INVALID_DOMAIN = "A valid domain is required, for example example.com or localhost.";
|
|
113
|
+
const INVALID_DOMAIN = "A valid domain is required, for example example.com or localhost.";
|
|
124
114
|
async function fetchWidgetSettings(domain) {
|
|
125
115
|
const url = normalizeDomain(domain);
|
|
126
116
|
if (!isValidDomain(url))
|
|
@@ -145,8 +135,8 @@ async function getDashboardLink(domain) {
|
|
|
145
135
|
const res = await post(AIOA_CHECK_WEBSITE_API, { domain: url });
|
|
146
136
|
if (res === null)
|
|
147
137
|
return { error: "Unable to load the dashboard link right now." };
|
|
148
|
-
const link = toStr(res.manage_domain);
|
|
149
|
-
return /^https
|
|
138
|
+
const link = toStr(res.manage_domain).trim();
|
|
139
|
+
return /^https:\/\/\S+$/i.test(link) ? { link } : { error: `No dashboard link was found for ${url}.` };
|
|
150
140
|
}
|
|
151
141
|
async function getScanDetails(domain) {
|
|
152
142
|
const url = normalizeDomain(domain);
|
|
@@ -218,18 +208,16 @@ async function getSettingsData(url) {
|
|
|
218
208
|
if (res === null)
|
|
219
209
|
return !1;
|
|
220
210
|
const data = res.Data;
|
|
221
|
-
return isEmpty(data) || !isObject(data) ? null :
|
|
211
|
+
return isEmpty(data) || !isObject(data) ? null : withPlanStatus(url, data);
|
|
222
212
|
}
|
|
223
|
-
async function
|
|
213
|
+
async function withPlanStatus(url, data) {
|
|
224
214
|
if (toInt(data.is_free_widget) === 1)
|
|
225
215
|
return data;
|
|
226
|
-
const res = await post(
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
!Object.prototype.hasOwnProperty.call(merged, field) && field in widget && (merged[field] = widget[field]);
|
|
232
|
-
return merged;
|
|
216
|
+
const res = await post(AIOA_CHECK_WEBSITE_API, { domain: url });
|
|
217
|
+
return {
|
|
218
|
+
...data,
|
|
219
|
+
plan_expired: res !== null && (toStr(res.plan_status).trim().toLowerCase() === "expired" || toInt(res.status) === 3)
|
|
220
|
+
};
|
|
233
221
|
}
|
|
234
222
|
async function waitForSettings(url, attempts = 3) {
|
|
235
223
|
for (let i = 0; i < attempts; i++) {
|
|
@@ -1050,7 +1038,7 @@ function ReportIcon() {
|
|
|
1050
1038
|
/* @__PURE__ */ jsx("path", { d: "M12 10v4M12 17v.5" })
|
|
1051
1039
|
] });
|
|
1052
1040
|
}
|
|
1053
|
-
const UpgradeUrlContext = createContext(AIOA_UPGRADE_URL);
|
|
1041
|
+
const UpgradeUrlContext = createContext(AIOA_UPGRADE_URL), PlanExpiredContext = createContext(!1);
|
|
1054
1042
|
function Header({
|
|
1055
1043
|
theme,
|
|
1056
1044
|
onToggleTheme
|
|
@@ -1085,17 +1073,21 @@ function Header({
|
|
|
1085
1073
|
] });
|
|
1086
1074
|
}
|
|
1087
1075
|
function UpgradeBanner() {
|
|
1088
|
-
const upgradeHref = useContext(UpgradeUrlContext);
|
|
1076
|
+
const upgradeHref = useContext(UpgradeUrlContext), expired = useContext(PlanExpiredContext);
|
|
1089
1077
|
return /* @__PURE__ */ jsxs("section", { className: "aioa-upgrade", "aria-labelledby": "aioa-upgrade-title", children: [
|
|
1090
1078
|
/* @__PURE__ */ jsx(WatermarkIcon, {}),
|
|
1091
1079
|
/* @__PURE__ */ jsxs("div", { className: "aioa-upgrade-head", children: [
|
|
1092
1080
|
/* @__PURE__ */ jsxs("div", { className: "aioa-upgrade-intro", children: [
|
|
1093
|
-
/* @__PURE__ */ jsxs("p", { className:
|
|
1081
|
+
/* @__PURE__ */ jsxs("p", { className: `aioa-upgrade-tag${expired ? " is-expired" : ""}`, children: [
|
|
1094
1082
|
/* @__PURE__ */ jsx("i", { "aria-hidden": "true" }),
|
|
1095
|
-
"Free plan active"
|
|
1083
|
+
expired ? "Paid plan expired" : "Free plan active"
|
|
1096
1084
|
] }),
|
|
1097
|
-
/* @__PURE__ */ jsx("h2", { id: "aioa-upgrade-title", children: "With 24 Features" }),
|
|
1098
|
-
/* @__PURE__ */ jsxs("p", { children: [
|
|
1085
|
+
/* @__PURE__ */ jsx("h2", { id: "aioa-upgrade-title", children: expired ? "Your paid plan has expired" : "With 24 Features" }),
|
|
1086
|
+
expired ? /* @__PURE__ */ jsxs("p", { children: [
|
|
1087
|
+
"Upgrade again to unlock ",
|
|
1088
|
+
/* @__PURE__ */ jsx("strong", { children: "100+ Premium Accessibility Features" }),
|
|
1089
|
+
". Paid Features and Accessibility Score are locked until then."
|
|
1090
|
+
] }) : /* @__PURE__ */ jsxs("p", { children: [
|
|
1099
1091
|
"Upgrade to unlock ",
|
|
1100
1092
|
/* @__PURE__ */ jsx("strong", { children: "90+ Premium Accessibility Features" }),
|
|
1101
1093
|
" and make your website even more inclusive."
|
|
@@ -1120,7 +1112,7 @@ function UpgradeBanner() {
|
|
|
1120
1112
|
]
|
|
1121
1113
|
}
|
|
1122
1114
|
),
|
|
1123
|
-
/* @__PURE__ */ jsx("small", { children: "10-day free trial \xB7 Cancel anytime" })
|
|
1115
|
+
!expired && /* @__PURE__ */ jsx("small", { children: "10-day free trial \xB7 Cancel anytime" })
|
|
1124
1116
|
] })
|
|
1125
1117
|
] }),
|
|
1126
1118
|
/* @__PURE__ */ jsxs("p", { className: "aioa-upgrade-note", children: [
|
|
@@ -1227,14 +1219,14 @@ function Lockable({
|
|
|
1227
1219
|
children,
|
|
1228
1220
|
contentClassName = ""
|
|
1229
1221
|
}) {
|
|
1230
|
-
const contentRef = useRef(null), upgradeHref = useContext(UpgradeUrlContext);
|
|
1222
|
+
const contentRef = useRef(null), upgradeHref = useContext(UpgradeUrlContext), expired = useContext(PlanExpiredContext);
|
|
1231
1223
|
return useEffect(() => {
|
|
1232
1224
|
contentRef.current && (contentRef.current.inert = locked);
|
|
1233
1225
|
}, [locked]), /* @__PURE__ */ jsxs("div", { className: `aioa-lockable${locked ? " is-locked" : ""}`, children: [
|
|
1234
1226
|
/* @__PURE__ */ jsx("div", { ref: contentRef, className: `aioa-lock-content ${contentClassName}`.trim(), children }),
|
|
1235
1227
|
locked && /* @__PURE__ */ jsx("div", { className: `aioa-lock${center ? " is-center" : ""}`, children: /* @__PURE__ */ jsxs("div", { className: "aioa-lock-card", role: "group", "aria-labelledby": `${lockId}-text`, children: [
|
|
1236
1228
|
/* @__PURE__ */ jsx("span", { className: "aioa-lock-icon", "aria-hidden": "true", children: /* @__PURE__ */ jsx(LockIcon, {}) }),
|
|
1237
|
-
/* @__PURE__ */ jsx("p", { className: "aioa-lock-text", id: `${lockId}-text`, children: "Try a 10-day free trial to view all 90+ features." }),
|
|
1229
|
+
/* @__PURE__ */ jsx("p", { className: "aioa-lock-text", id: `${lockId}-text`, children: expired ? "Your paid plan has expired. Upgrade to view all 100+ features again." : "Try a 10-day free trial to view all 90+ features." }),
|
|
1238
1230
|
/* @__PURE__ */ jsxs(
|
|
1239
1231
|
"a",
|
|
1240
1232
|
{
|
|
@@ -1934,6 +1926,8 @@ const AIOA_CSS = `
|
|
|
1934
1926
|
font-size: 12.5px; font-weight: 600; background: rgba(255, 255, 255, .14); color: #f0e8ff;
|
|
1935
1927
|
}
|
|
1936
1928
|
.aioa-upgrade-tag i { width: 7px; height: 7px; border-radius: 50%; background: #4ade80; }
|
|
1929
|
+
/* "Paid plan expired": amber dot */
|
|
1930
|
+
.aioa-upgrade-tag.is-expired i { background: #fbbf24; }
|
|
1937
1931
|
|
|
1938
1932
|
/* 190+ languages / 12 profiles */
|
|
1939
1933
|
.aioa-upgrade-points { display: flex; flex-wrap: wrap; gap: 5px 20px; margin: 12px 0 0; padding: 0; list-style: none; font-weight: 600; }
|
|
@@ -2358,7 +2352,7 @@ function SettingsPage({ tool }) {
|
|
|
2358
2352
|
const upgradeHref = useMemo(
|
|
2359
2353
|
() => upgradeUrl(activeDomain, adminName, adminEmail),
|
|
2360
2354
|
[activeDomain, adminName, adminEmail]
|
|
2361
|
-
), { theme, toggleTheme } = useTheme(), { toasts, toast, dismiss } = useToasts(), [view, setView] = useState({ name: "load" }), [isPaid, setIsPaid] = useState(!1), [tab, setTab] = useState("appearance"), [appearance, setAppearance] = useState(emptyAppearance), [paid, setPaid] = useState(() => paidFrom({})), [dirty, setDirty] = useState(!1), [saving, setSaving] = useState(!1), [score, setScore] = useState({ status: "idle" }), [dashboardBusy, setDashboardBusy] = useState(!1), latest = useRef({ appearance, paid, isPaid });
|
|
2355
|
+
), { theme, toggleTheme } = useTheme(), { toasts, toast, dismiss } = useToasts(), [view, setView] = useState({ name: "load" }), [isPaid, setIsPaid] = useState(!1), [planExpired, setPlanExpired] = useState(!1), [tab, setTab] = useState("appearance"), [appearance, setAppearance] = useState(emptyAppearance), [paid, setPaid] = useState(() => paidFrom({})), [dirty, setDirty] = useState(!1), [saving, setSaving] = useState(!1), [score, setScore] = useState({ status: "idle" }), [dashboardBusy, setDashboardBusy] = useState(!1), latest = useRef({ appearance, paid, isPaid });
|
|
2362
2356
|
latest.current = { appearance, paid, isPaid };
|
|
2363
2357
|
const updateAppearance = useCallback((patch) => {
|
|
2364
2358
|
setAppearance((state) => ({ ...state, ...patch })), setDirty(!0);
|
|
@@ -2388,51 +2382,31 @@ function SettingsPage({ tool }) {
|
|
|
2388
2382
|
});
|
|
2389
2383
|
const selectTab = useCallback((name) => {
|
|
2390
2384
|
setTab(name), storage.set(STORAGE_TAB, name);
|
|
2391
|
-
}, []),
|
|
2392
|
-
|
|
2393
|
-
link: "",
|
|
2394
|
-
failure: null
|
|
2395
|
-
}), loadDashboard = useCallback(() => {
|
|
2396
|
-
if (dashboard.current.request)
|
|
2397
|
-
return;
|
|
2398
|
-
const request = getDashboardLink(activeDomain).then((result) => {
|
|
2399
|
-
const value = "link" in result ? result.link : "";
|
|
2400
|
-
if (!value || !/^https:\/\//i.test(value))
|
|
2401
|
-
throw new Error("error" in result && result.error || "Unable to load the dashboard link.");
|
|
2402
|
-
return dashboard.current.link = value, value;
|
|
2403
|
-
});
|
|
2404
|
-
dashboard.current.request = request, request.catch((err) => {
|
|
2405
|
-
dashboard.current.failure = err;
|
|
2406
|
-
});
|
|
2407
|
-
}, [activeDomain]), openIn = (win, url) => {
|
|
2408
|
-
win && !win.closed ? (win.opener = null, win.location.href = url) : toast("success", "Your dashboard link is ready", "Your browser blocked the new tab.", {
|
|
2385
|
+
}, []), openIn = (win, url) => {
|
|
2386
|
+
win && !win.closed ? (win.opener = null, win.location.href = url) : toast("success", "Your dashboard is ready to open", "Your browser blocked the new tab.", {
|
|
2409
2387
|
href: url,
|
|
2410
2388
|
label: "Open dashboard"
|
|
2411
2389
|
});
|
|
2412
2390
|
}, showDashboardError = (err) => {
|
|
2413
2391
|
const reason = err instanceof TypeError ? "Please check your connection." : err instanceof Error && err.message || "";
|
|
2414
|
-
toast(
|
|
2415
|
-
"error",
|
|
2416
|
-
"Could not open the dashboard",
|
|
2417
|
-
`${reason ? `${reason} ` : ""}Reload the page to try again.`
|
|
2418
|
-
);
|
|
2392
|
+
toast("error", "Could not open the dashboard", `${reason ? `${reason} ` : ""}Please try again.`);
|
|
2419
2393
|
}, openDashboard = () => {
|
|
2420
|
-
|
|
2421
|
-
if (link) {
|
|
2422
|
-
openIn(window.open("", "_blank"), link);
|
|
2423
|
-
return;
|
|
2424
|
-
}
|
|
2425
|
-
if (failure || !request) {
|
|
2426
|
-
showDashboardError(failure);
|
|
2394
|
+
if (dashboardBusy)
|
|
2427
2395
|
return;
|
|
2428
|
-
}
|
|
2429
2396
|
const win = window.open("", "_blank");
|
|
2430
2397
|
if (win)
|
|
2431
2398
|
try {
|
|
2432
2399
|
win.document.title = "Opening dashboard\u2026", win.document.body.style.cssText = "font-family:system-ui,sans-serif;display:grid;place-items:center;min-height:90vh;color:#420083", win.document.body.textContent = "Opening your All in One Accessibility dashboard\u2026";
|
|
2433
2400
|
} catch {
|
|
2434
2401
|
}
|
|
2435
|
-
setDashboardBusy(!0),
|
|
2402
|
+
setDashboardBusy(!0), getDashboardLink(activeDomain).then((result) => {
|
|
2403
|
+
const link = "link" in result ? result.link : "";
|
|
2404
|
+
if (!link || !/^https:\/\//i.test(link))
|
|
2405
|
+
throw new Error(
|
|
2406
|
+
"error" in result && result.error || "Unable to load the dashboard link."
|
|
2407
|
+
);
|
|
2408
|
+
openIn(win, link);
|
|
2409
|
+
}).catch((err) => {
|
|
2436
2410
|
win && !win.closed && win.close(), showDashboardError(err);
|
|
2437
2411
|
}).finally(() => setDashboardBusy(!1));
|
|
2438
2412
|
}, register2 = useRef({
|
|
@@ -2471,10 +2445,10 @@ function SettingsPage({ tool }) {
|
|
|
2471
2445
|
}, [activeDomain]), applyResult = useCallback(
|
|
2472
2446
|
(result) => {
|
|
2473
2447
|
storage.remove(STORAGE_REGISTERED + activeDomain);
|
|
2474
|
-
const paidPlan = toInt(result.is_free_widget) !== 1, order = paidPlan ? TAB_ORDER.paid : TAB_ORDER.free, stored = storage.get(STORAGE_TAB);
|
|
2475
|
-
setAppearance(appearanceFrom(result)), setPaid(paidFrom(result)), setIsPaid(paidPlan), setTab(TABS.includes(stored) ? stored : order[0]), setDirty(!1), setView({ name: "settings" })
|
|
2448
|
+
const flag = result.plan_expired, expired = flag === !0 || flag === 1 || flag === "1" || flag === "true", paidPlan = toInt(result.is_free_widget) !== 1 && !expired, order = paidPlan ? TAB_ORDER.paid : TAB_ORDER.free, stored = storage.get(STORAGE_TAB);
|
|
2449
|
+
setAppearance(appearanceFrom(result)), setPaid(paidFrom(result)), setIsPaid(paidPlan), setPlanExpired(expired), setTab(TABS.includes(stored) ? stored : order[0]), setDirty(!1), setView({ name: "settings" });
|
|
2476
2450
|
},
|
|
2477
|
-
[activeDomain
|
|
2451
|
+
[activeDomain]
|
|
2478
2452
|
), loadSettings = useCallback(() => {
|
|
2479
2453
|
if (!activeDomain) {
|
|
2480
2454
|
showError(
|
|
@@ -2555,7 +2529,7 @@ function SettingsPage({ tool }) {
|
|
|
2555
2529
|
/* @__PURE__ */ jsx("p", { children: view.message }),
|
|
2556
2530
|
view.retry && /* @__PURE__ */ jsx("button", { type: "button", className: "aioa-btn aioa-btn-primary", onClick: loadSettings, children: "Try again" })
|
|
2557
2531
|
] }),
|
|
2558
|
-
view.name === "settings" && /* @__PURE__ */
|
|
2532
|
+
view.name === "settings" && /* @__PURE__ */ jsx(UpgradeUrlContext.Provider, { value: upgradeHref, children: /* @__PURE__ */ jsxs(PlanExpiredContext.Provider, { value: planExpired, children: [
|
|
2559
2533
|
isPaid ? /* @__PURE__ */ jsx(PaidBanner, { busy: dashboardBusy, onDashboard: openDashboard }) : /* @__PURE__ */ jsx(UpgradeBanner, {}),
|
|
2560
2534
|
/* @__PURE__ */ jsx(SiteStrip, { domain: activeDomain }),
|
|
2561
2535
|
/* @__PURE__ */ jsx(
|
|
@@ -2646,7 +2620,7 @@ function SettingsPage({ tool }) {
|
|
|
2646
2620
|
/* @__PURE__ */ jsx("p", { className: "aioa-after-note", children: "It may take a few seconds for changes to appear on your website. If you don't see them, clear your browser cache or check in a private window." })
|
|
2647
2621
|
] })
|
|
2648
2622
|
] })
|
|
2649
|
-
] })
|
|
2623
|
+
] }) })
|
|
2650
2624
|
] })
|
|
2651
2625
|
] }),
|
|
2652
2626
|
/* @__PURE__ */ jsx(ToastRegion, { toasts, onDismiss: dismiss })
|