@powerhousedao/connect 6.2.3-dev.65 → 6.2.3-dev.67
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/CUSTOMIZING.md +77 -0
- package/README.md +18 -91
- package/RUNTIME-CONFIG.md +472 -0
- package/dist/{AddDriveModal-D_3jDwjp.js → AddDriveModal-BjgmiHJr.js} +6 -6
- package/dist/AddDriveModal-BjgmiHJr.js.map +1 -0
- package/dist/{ClearStorageModal-BWSktCmz.js → ClearStorageModal-_03VgDb5.js} +6 -6
- package/dist/ClearStorageModal-_03VgDb5.js.map +1 -0
- package/dist/{ConfirmDocumentUpgradeModal-CrU2Z1CL.js → ConfirmDocumentUpgradeModal-CoixS60F.js} +5 -5
- package/dist/ConfirmDocumentUpgradeModal-CoixS60F.js.map +1 -0
- package/dist/{CookiesPolicyModal-DQwsgDI9.js → CookiesPolicyModal-BpFjYc7T.js} +4 -4
- package/dist/{CookiesPolicyModal-DQwsgDI9.js.map → CookiesPolicyModal-BpFjYc7T.js.map} +1 -1
- package/dist/{CreateDocumentModal-Cf1APibL.js → CreateDocumentModal-B-cXzeOA.js} +10 -10
- package/dist/CreateDocumentModal-B-cXzeOA.js.map +1 -0
- package/dist/{DebugSettingsModal-FR4Ygn1r.js → DebugSettingsModal-CGScJ_r2.js} +8 -8
- package/dist/DebugSettingsModal-CGScJ_r2.js.map +1 -0
- package/dist/{DeleteDriveModal-lE9eCBua.js → DeleteDriveModal-1pAIayG_.js} +5 -5
- package/dist/DeleteDriveModal-1pAIayG_.js.map +1 -0
- package/dist/{DeleteItemModal-BFgcGsm3.js → DeleteItemModal-BUpqmFxS.js} +5 -5
- package/dist/DeleteItemModal-BUpqmFxS.js.map +1 -0
- package/dist/{DisclaimerModal-CF6JkIIu.js → DisclaimerModal-TIJXRYLF.js} +5 -5
- package/dist/DisclaimerModal-TIJXRYLF.js.map +1 -0
- package/dist/{DocumentVersionUnsupportedModal-Cm9Jb9W7.js → DocumentVersionUnsupportedModal-DH9Zzsyw.js} +5 -5
- package/dist/DocumentVersionUnsupportedModal-DH9Zzsyw.js.map +1 -0
- package/dist/{DownloadDocumentWithErrorsModal-CShKhfEQ.js → DownloadDocumentWithErrorsModal-Beh-xw8B.js} +5 -5
- package/dist/DownloadDocumentWithErrorsModal-Beh-xw8B.js.map +1 -0
- package/dist/{DriveAuthRequiredModal-CMwPUyZf.js → DriveAuthRequiredModal-XTcoJKvj.js} +6 -6
- package/dist/DriveAuthRequiredModal-XTcoJKvj.js.map +1 -0
- package/dist/{DriveSettingsModal-BSImj4BH.js → DriveSettingsModal-DZKawN7w.js} +5 -5
- package/dist/DriveSettingsModal-DZKawN7w.js.map +1 -0
- package/dist/{InspectorModal-Df_Dj4Gy.js → InspectorModal-DA_TGmM6.js} +16 -16
- package/dist/InspectorModal-DA_TGmM6.js.map +1 -0
- package/dist/{LoginModal-DT_05uva.js → LoginModal-O06ZvWFI.js} +6 -6
- package/dist/LoginModal-O06ZvWFI.js.map +1 -0
- package/dist/{OpenFileDocumentsModal-X9GnX2Bk.js → OpenFileDocumentsModal-BNHD0vg9.js} +6 -6
- package/dist/OpenFileDocumentsModal-BNHD0vg9.js.map +1 -0
- package/dist/{UpgradeDriveModal-DvM-PNWe.js → UpgradeDriveModal-CCWKp5yn.js} +5 -5
- package/dist/UpgradeDriveModal-CCWKp5yn.js.map +1 -0
- package/dist/{app-loader-FBmwAnUq.js → app-loader-CEN_4I3I.js} +149 -196
- package/dist/app-loader-CEN_4I3I.js.map +1 -0
- package/dist/app-loader-Cj2p8L1I.js +4 -0
- package/dist/{app-skeleton-gzg8cRzm.js → app-skeleton-BFjvlTWd.js} +11 -11
- package/dist/app-skeleton-BFjvlTWd.js.map +1 -0
- package/dist/{app-skeleton-DYLZ7npI.js → app-skeleton-DFg65Rxa.js} +3 -3
- package/dist/{boot-CC_DgQKX.js → boot-JTGLJtmJ.js} +6 -6
- package/dist/boot-JTGLJtmJ.js.map +1 -0
- package/dist/{build-info-D89jTqV-.js → build-info-DkY9PU7c.js} +5 -5
- package/dist/{build-info-D89jTqV-.js.map → build-info-DkY9PU7c.js.map} +1 -1
- package/dist/{components-Ksj8WTJ5.js → components-2wvJ3_Ho.js} +11 -10
- package/dist/{components-Ksj8WTJ5.js.map → components-2wvJ3_Ho.js.map} +1 -1
- package/dist/{connect.config-uZF-gnvV.js → connect.config-D1pGNmaF.js} +4 -4
- package/dist/connect.config-D1pGNmaF.js.map +1 -0
- package/dist/{connection-state-C_477Kr_.js → connection-state-B6fleM37.js} +6 -6
- package/dist/connection-state-B6fleM37.js.map +1 -0
- package/dist/{cookie-banner-HPgyuHM5.js → cookie-banner-CAvd3PC3.js} +6 -6
- package/dist/{cookie-banner-HPgyuHM5.js.map → cookie-banner-CAvd3PC3.js.map} +1 -1
- package/dist/document-editor-container-BnEjlmaN.js +307 -0
- package/dist/document-editor-container-BnEjlmaN.js.map +1 -0
- package/dist/document-editor-container-kgS38mkb.js +4 -0
- package/dist/error-boundary-BsUBww61.js +155 -0
- package/dist/error-boundary-BsUBww61.js.map +1 -0
- package/dist/generic.d.ts +116 -0
- package/dist/generic.d.ts.map +1 -0
- package/dist/generic.js +31 -0
- package/dist/generic.js.map +1 -0
- package/dist/{i18n-CTgT1HG-.js → i18n-D9WYPgk9.js} +4 -4
- package/dist/{i18n-CTgT1HG-.js.map → i18n-D9WYPgk9.js.map} +1 -1
- package/dist/index-B4g8swZG.d.ts +4 -0
- package/dist/layout-BOX6fL5v.js +5 -0
- package/dist/layout.d.ts +2 -28
- package/dist/layout.js +4 -6
- package/dist/{load-B-M2dI6C.js → load-CCCHqC0d.js} +11 -11
- package/dist/{load-B-M2dI6C.js.map → load-CCCHqC0d.js.map} +1 -1
- package/dist/load-runtime-config-Dhy-b5wT.js +14 -0
- package/dist/load-runtime-config-Dhy-b5wT.js.map +1 -0
- package/dist/main.js +2 -2
- package/dist/{open-file-uploads-BcyWmUZn.js → open-file-uploads-B5pr1sA2.js} +4 -4
- package/dist/{open-file-uploads-BcyWmUZn.js.map → open-file-uploads-B5pr1sA2.js.map} +1 -1
- package/dist/{package-manager-BkFRzovd.js → package-manager-x_fK8Hzm.js} +92 -60
- package/dist/package-manager-x_fK8Hzm.js.map +1 -0
- package/dist/{pglite-seed-BsEPByVM.js → pglite-seed-eGzXMld2.js} +4 -4
- package/dist/{pglite-seed-BsEPByVM.js.map → pglite-seed-eGzXMld2.js.map} +1 -1
- package/dist/{plugin-host--lBWChr9.js → plugins-B9VBgzio.js} +75 -83
- package/dist/plugins-B9VBgzio.js.map +1 -0
- package/dist/{preferences-store-DANUajdg.js → preferences-store-CSqauT9V.js} +5 -5
- package/dist/preferences-store-CSqauT9V.js.map +1 -0
- package/dist/prerender.d.ts +38 -0
- package/dist/prerender.d.ts.map +1 -0
- package/dist/prerender.js +177 -0
- package/dist/prerender.js.map +1 -0
- package/dist/{prerendered-shell-DxCUDEXL.js → prerendered-shell-peKE7AqI.js} +10 -4
- package/dist/prerendered-shell-peKE7AqI.js.map +1 -0
- package/dist/{reactor-CMXWKWup.js → reactor-BmI-D8O-.js} +25 -156
- package/dist/reactor-BmI-D8O-.js.map +1 -0
- package/dist/{registerServiceWorker-CkVxA2KC.js → registerServiceWorker-APlHkrmH.js} +4 -4
- package/dist/{registerServiceWorker-CkVxA2KC.js.map → registerServiceWorker-APlHkrmH.js.map} +1 -1
- package/dist/root-B1Pq9x6S.js +24 -0
- package/dist/root-B1Pq9x6S.js.map +1 -0
- package/dist/route-tree.d.ts +147 -156
- package/dist/route-tree.d.ts.map +1 -1
- package/dist/route-tree.js +93 -169
- package/dist/route-tree.js.map +1 -1
- package/dist/route-views-BF0p-4Fi.js +60 -0
- package/dist/route-views-BF0p-4Fi.js.map +1 -0
- package/dist/route-views-CTARvT5N.js +55 -0
- package/dist/route-views-CTARvT5N.js.map +1 -0
- package/dist/route-views-D8I-1PWU.js +4 -0
- package/dist/route-views.d.ts +7 -0
- package/dist/route-views.d.ts.map +1 -0
- package/dist/route-views.js +4 -0
- package/dist/router-BguOMBUh.js +4 -0
- package/dist/router-L9X9U-97.js +46 -0
- package/dist/router-L9X9U-97.js.map +1 -0
- package/dist/router.d.ts +1 -3
- package/dist/router.js +3 -7
- package/dist/sentry-Cuc_Nbba.js +22 -0
- package/dist/sentry-Cuc_Nbba.js.map +1 -0
- package/dist/{settings-D7lXsfBl.js → settings-DjQfTrBe.js} +488 -22
- package/dist/settings-DjQfTrBe.js.map +1 -0
- package/dist/settings-tabs-iTlo2pYz.js +365 -0
- package/dist/settings-tabs-iTlo2pYz.js.map +1 -0
- package/dist/shell-core-head.html +2 -0
- package/dist/shell-core.html +1 -0
- package/dist/shell-head.html +2 -1
- package/dist/shell-plugins.json +1 -0
- package/dist/shell.html +1 -1
- package/dist/start-connect.d.ts +5 -9
- package/dist/start-connect.d.ts.map +1 -1
- package/dist/start-connect.js +5 -6
- package/dist/start-connect.js.map +1 -1
- package/dist/style.css +3127 -4014
- package/dist/ui-b6sMhi5V.js +66 -0
- package/dist/ui-b6sMhi5V.js.map +1 -0
- package/dist/{use-renown-login-BzOSQETV.js → use-renown-login-dPpDOYq5.js} +4 -4
- package/dist/use-renown-login-dPpDOYq5.js.map +1 -0
- package/docs/customizing/data-and-navigation.md +177 -0
- package/docs/customizing/hosts-and-plugins.md +65 -0
- package/docs/customizing/layout.md +149 -0
- package/docs/customizing/modals.md +78 -0
- package/docs/customizing/overrides.md +113 -0
- package/docs/customizing/packages.md +38 -0
- package/docs/customizing/pages.md +136 -0
- package/docs/customizing/styles-and-branding.md +41 -0
- package/docs/customizing/types-and-troubleshooting.md +44 -0
- package/package.json +41 -18
- package/scripts/prerender-shell.ts +35 -84
- package/skills/customize-connect/SKILL.md +74 -0
- package/src/route-tree.ts +3 -0
- package/src/routeTree.gen.ts +134 -192
- package/src/router/index.ts +2 -51
- package/src/router/register.ts +1 -1
- package/src/routes/__root.tsx +8 -24
- package/src/routes/_app/$.tsx +13 -0
- package/src/routes/_app/d/$driveSlug/{-$nodeSlug}.tsx +13 -0
- package/src/routes/_app/d/$driveSlug.tsx +13 -0
- package/src/routes/_app/index.tsx +13 -0
- package/src/routes/_app/settings/appearance.tsx +13 -0
- package/src/routes/_app/settings/packages.tsx +13 -0
- package/src/routes/_app/settings.tsx +13 -0
- package/src/routes/_app.tsx +13 -0
- package/style.css +5 -22
- package/tailwind.css +12 -0
- package/dist/AddDriveModal-D_3jDwjp.js.map +0 -1
- package/dist/ClearStorageModal-BWSktCmz.js.map +0 -1
- package/dist/ConfirmDocumentUpgradeModal-CrU2Z1CL.js.map +0 -1
- package/dist/CreateDocumentModal-Cf1APibL.js.map +0 -1
- package/dist/DebugSettingsModal-FR4Ygn1r.js.map +0 -1
- package/dist/DeleteDriveModal-lE9eCBua.js.map +0 -1
- package/dist/DeleteItemModal-BFgcGsm3.js.map +0 -1
- package/dist/DisclaimerModal-CF6JkIIu.js.map +0 -1
- package/dist/DocumentVersionUnsupportedModal-Cm9Jb9W7.js.map +0 -1
- package/dist/DownloadDocumentWithErrorsModal-CShKhfEQ.js.map +0 -1
- package/dist/DriveAuthRequiredModal-CMwPUyZf.js.map +0 -1
- package/dist/DriveSettingsModal-BSImj4BH.js.map +0 -1
- package/dist/InspectorModal-Df_Dj4Gy.js.map +0 -1
- package/dist/LoginModal-DT_05uva.js.map +0 -1
- package/dist/MissingPackageModal-DtISKgub.js +0 -49
- package/dist/MissingPackageModal-DtISKgub.js.map +0 -1
- package/dist/OpenFileDocumentsModal-X9GnX2Bk.js.map +0 -1
- package/dist/UpgradeDriveModal-DvM-PNWe.js.map +0 -1
- package/dist/app-layout-BIq-ZW-6.js +0 -394
- package/dist/app-layout-BIq-ZW-6.js.map +0 -1
- package/dist/app-loader-DWVnAJhQ.js +0 -4
- package/dist/app-loader-FBmwAnUq.js.map +0 -1
- package/dist/app-skeleton-gzg8cRzm.js.map +0 -1
- package/dist/boot-CC_DgQKX.js.map +0 -1
- package/dist/connect-router-KmNBGS0G.js +0 -434
- package/dist/connect-router-KmNBGS0G.js.map +0 -1
- package/dist/connect.config-uZF-gnvV.js.map +0 -1
- package/dist/connection-state-C_477Kr_.js.map +0 -1
- package/dist/index-UrZFqSgm.d.ts +0 -166
- package/dist/index-UrZFqSgm.d.ts.map +0 -1
- package/dist/layout.d.ts.map +0 -1
- package/dist/multi-reactor-fSKpLBjT.js +0 -220
- package/dist/multi-reactor-fSKpLBjT.js.map +0 -1
- package/dist/package-manager-BkFRzovd.js.map +0 -1
- package/dist/plugin-host--lBWChr9.js.map +0 -1
- package/dist/preferences-store-DANUajdg.js.map +0 -1
- package/dist/prerendered-shell-DxCUDEXL.js.map +0 -1
- package/dist/reactor-CMXWKWup.js.map +0 -1
- package/dist/route-components-BkztQruF.js +0 -148
- package/dist/route-components-BkztQruF.js.map +0 -1
- package/dist/router-Bh19hdNU.js +0 -4
- package/dist/router-Cxt7uaaL.js +0 -604
- package/dist/router-Cxt7uaaL.js.map +0 -1
- package/dist/runtime-config-DdN1Frg7.js +0 -34
- package/dist/runtime-config-DdN1Frg7.js.map +0 -1
- package/dist/runtime-flag-B8IYhkz-.js +0 -4
- package/dist/runtime-flag-CT5OKujT.js +0 -45
- package/dist/runtime-flag-CT5OKujT.js.map +0 -1
- package/dist/sentry-CJb7--mu.js +0 -18
- package/dist/sentry-CJb7--mu.js.map +0 -1
- package/dist/settings-CjvK8OKA.js +0 -91
- package/dist/settings-CjvK8OKA.js.map +0 -1
- package/dist/settings-D7lXsfBl.js.map +0 -1
- package/dist/sidebar-BXf8OEwm.d.ts +0 -34
- package/dist/sidebar-BXf8OEwm.d.ts.map +0 -1
- package/dist/sidebar-lAVFRsni.js +0 -31
- package/dist/sidebar-lAVFRsni.js.map +0 -1
- package/dist/use-renown-login-BzOSQETV.js.map +0 -1
- package/dist/useIsEmbedded-BWJ0qb7w.js +0 -26
- package/dist/useIsEmbedded-BWJ0qb7w.js.map +0 -1
- package/dist/useRegistryPackages-BqIWwXV-.js +0 -452
- package/dist/useRegistryPackages-BqIWwXV-.js.map +0 -1
- package/scripts/critical-css.ts +0 -243
- package/src/router/connect-router.ts +0 -170
- package/src/router/drive-route-loader.ts +0 -116
- package/src/router/navigation.ts +0 -230
- package/src/router/perf-marks.test.tsx +0 -98
- package/src/router/perf-marks.ts +0 -97
- package/src/router/route-components.tsx +0 -98
- package/src/router/route-tree.ts +0 -88
- package/src/router/scroll.ts +0 -69
- package/src/router/search.ts +0 -66
- package/src/router/settings.ts +0 -120
- package/src/router/sidebar.ts +0 -55
- package/src/router/titles.test.ts +0 -24
- package/src/router/titles.ts +0 -33
- package/src/routes/core/_app/$.tsx +0 -13
- package/src/routes/core/_app/_content/d/$driveSlug/{-$nodeSlug}.tsx +0 -52
- package/src/routes/core/_app/_content/index.tsx +0 -3
- package/src/routes/core/_app/_content.tsx +0 -9
- package/src/routes/core/_app/settings/about.tsx +0 -20
- package/src/routes/core/_app/settings/ai-assistant.tsx +0 -20
- package/src/routes/core/_app/settings/danger-zone.tsx +0 -21
- package/src/routes/core/_app/settings/default-editors.tsx +0 -20
- package/src/routes/core/_app/settings/package-manager.tsx +0 -20
- package/src/routes/core/_app/settings.tsx +0 -35
- package/src/routes/core/_app.tsx +0 -10
package/scripts/critical-css.ts
DELETED
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
// Prunes Tailwind's minified output down to what the prerendered shell uses.
|
|
2
|
-
|
|
3
|
-
type Node =
|
|
4
|
-
| { kind: "statement"; text: string }
|
|
5
|
-
| { kind: "rule"; prelude: string; body: string }
|
|
6
|
-
| { kind: "block"; prelude: string; children: Node[] };
|
|
7
|
-
|
|
8
|
-
/** Parses minified CSS into statements, leaf rules and nested blocks. */
|
|
9
|
-
function parse(css: string): Node[] {
|
|
10
|
-
const nodes: Node[] = [];
|
|
11
|
-
let i = 0;
|
|
12
|
-
while (i < css.length) {
|
|
13
|
-
if (css.startsWith("/*", i)) {
|
|
14
|
-
const end = css.indexOf("*/", i + 2);
|
|
15
|
-
i = end < 0 ? css.length : end + 2;
|
|
16
|
-
continue;
|
|
17
|
-
}
|
|
18
|
-
const open = scan(css, i, "{;");
|
|
19
|
-
if (open < 0) break;
|
|
20
|
-
const prelude = css.slice(i, open).trim();
|
|
21
|
-
if (css[open] === ";") {
|
|
22
|
-
if (prelude) nodes.push({ kind: "statement", text: `${prelude};` });
|
|
23
|
-
i = open + 1;
|
|
24
|
-
continue;
|
|
25
|
-
}
|
|
26
|
-
const close = matching(css, open);
|
|
27
|
-
const inner = css.slice(open + 1, close);
|
|
28
|
-
nodes.push(
|
|
29
|
-
scan(inner, 0, "{") < 0
|
|
30
|
-
? { kind: "rule", prelude, body: inner }
|
|
31
|
-
: { kind: "block", prelude, children: parse(inner) },
|
|
32
|
-
);
|
|
33
|
-
i = close + 1;
|
|
34
|
-
}
|
|
35
|
-
return nodes;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// The first of `chars` outside quotes and parentheses, or -1.
|
|
39
|
-
function scan(css: string, from: number, chars: string) {
|
|
40
|
-
let quote = "";
|
|
41
|
-
let depth = 0;
|
|
42
|
-
for (let i = from; i < css.length; i++) {
|
|
43
|
-
const c = css[i];
|
|
44
|
-
if (quote) {
|
|
45
|
-
if (c === "\\") i++;
|
|
46
|
-
else if (c === quote) quote = "";
|
|
47
|
-
} else if (c === '"' || c === "'") quote = c;
|
|
48
|
-
else if (c === "(") depth++;
|
|
49
|
-
else if (c === ")") depth--;
|
|
50
|
-
else if (depth === 0 && chars.includes(c)) return i;
|
|
51
|
-
}
|
|
52
|
-
return -1;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function matching(css: string, open: number) {
|
|
56
|
-
let depth = 0;
|
|
57
|
-
let quote = "";
|
|
58
|
-
for (let i = open; i < css.length; i++) {
|
|
59
|
-
const c = css[i];
|
|
60
|
-
if (quote) {
|
|
61
|
-
if (c === "\\") i++;
|
|
62
|
-
else if (c === quote) quote = "";
|
|
63
|
-
} else if (c === '"' || c === "'") quote = c;
|
|
64
|
-
else if (c === "{") depth++;
|
|
65
|
-
else if (c === "}" && --depth === 0) return i;
|
|
66
|
-
}
|
|
67
|
-
return css.length;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function print(nodes: Node[]): string {
|
|
71
|
-
return nodes
|
|
72
|
-
.map((node) =>
|
|
73
|
-
node.kind === "statement"
|
|
74
|
-
? node.text
|
|
75
|
-
: node.kind === "rule"
|
|
76
|
-
? `${node.prelude}{${node.body}}`
|
|
77
|
-
: `${node.prelude}{${print(node.children)}}`,
|
|
78
|
-
)
|
|
79
|
-
.join("");
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function splitTopLevel(text: string, separator: string) {
|
|
83
|
-
const parts: string[] = [];
|
|
84
|
-
let start = 0;
|
|
85
|
-
for (;;) {
|
|
86
|
-
const at = scan(text, start, separator);
|
|
87
|
-
if (at < 0) break;
|
|
88
|
-
parts.push(text.slice(start, at));
|
|
89
|
-
start = at + 1;
|
|
90
|
-
}
|
|
91
|
-
parts.push(text.slice(start));
|
|
92
|
-
return parts;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// Form-control pseudo-elements only apply to these.
|
|
96
|
-
const FORM_PSEUDO = /::(placeholder|file-selector-button|-webkit-[\w-]+)/;
|
|
97
|
-
const FORM_TAGS = ["input", "textarea", "select"];
|
|
98
|
-
|
|
99
|
-
/** Whether a preflight selector can match an element of `tags`/`attributes`. */
|
|
100
|
-
function selectorApplies(
|
|
101
|
-
selector: string,
|
|
102
|
-
tags: Set<string>,
|
|
103
|
-
attributes: Set<string>,
|
|
104
|
-
) {
|
|
105
|
-
// Element names: not after `:`, `.`, `#`, `-` or inside an attribute selector.
|
|
106
|
-
const bare = selector.replace(/\[[^\]]*\]/g, (attr) => {
|
|
107
|
-
const name = /^\[([\w-]+)/.exec(attr)?.[1];
|
|
108
|
-
return name && !attributes.has(name) ? "[missing]" : "";
|
|
109
|
-
});
|
|
110
|
-
if (bare.includes("[missing]")) return false;
|
|
111
|
-
const types = [...bare.matchAll(/(?:^|[\s>+~(,])([a-z][a-z0-9-]*)/g)].map(
|
|
112
|
-
(match) => match[1],
|
|
113
|
-
);
|
|
114
|
-
if (types.some((type) => !tags.has(type))) return false;
|
|
115
|
-
if (FORM_PSEUDO.test(selector)) return FORM_TAGS.some((tag) => tags.has(tag));
|
|
116
|
-
return true;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
function prunePreflight(
|
|
120
|
-
nodes: Node[],
|
|
121
|
-
tags: Set<string>,
|
|
122
|
-
attributes: Set<string>,
|
|
123
|
-
): Node[] {
|
|
124
|
-
return nodes.flatMap((node): Node[] => {
|
|
125
|
-
if (node.kind === "statement") return [node];
|
|
126
|
-
if (node.kind === "block") {
|
|
127
|
-
const children = prunePreflight(node.children, tags, attributes);
|
|
128
|
-
return children.length ? [{ ...node, children }] : [];
|
|
129
|
-
}
|
|
130
|
-
const kept = splitTopLevel(node.prelude, ",").filter((selector) =>
|
|
131
|
-
selectorApplies(selector.trim(), tags, attributes),
|
|
132
|
-
);
|
|
133
|
-
return kept.length ? [{ ...node, prelude: kept.join(",") }] : [];
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
const VAR_REFERENCE = /var\((--[\w-]+)/g;
|
|
138
|
-
const references = (text: string) =>
|
|
139
|
-
[...text.matchAll(VAR_REFERENCE)].map((match) => match[1]);
|
|
140
|
-
|
|
141
|
-
/** Rules that only declare custom properties: theme tokens and resets. */
|
|
142
|
-
function isVariableRule(node: Extract<Node, { kind: "rule" }>) {
|
|
143
|
-
return splitTopLevel(node.body, ";").every(
|
|
144
|
-
(declaration) => !declaration.trim() || declaration.trim().startsWith("--"),
|
|
145
|
-
);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
function declarationsOf(body: string) {
|
|
149
|
-
return splitTopLevel(body, ";").filter((declaration) => declaration.trim());
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
function walk(nodes: Node[], visit: (node: Node) => void) {
|
|
153
|
-
for (const node of nodes) {
|
|
154
|
-
visit(node);
|
|
155
|
-
if (node.kind === "block") walk(node.children, visit);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
function filterTree(nodes: Node[], keep: (node: Node) => Node | null): Node[] {
|
|
160
|
-
return nodes.flatMap((node): Node[] => {
|
|
161
|
-
const kept = keep(node);
|
|
162
|
-
if (!kept) return [];
|
|
163
|
-
if (kept.kind !== "block" || kept.prelude.startsWith("@keyframes")) {
|
|
164
|
-
return [kept];
|
|
165
|
-
}
|
|
166
|
-
const children = filterTree(kept.children, keep);
|
|
167
|
-
return children.length ? [{ ...kept, children }] : [];
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/** `css` without the preflight, tokens, `@property` rules and keyframes that
|
|
172
|
-
* `markup` and `extraCss` never reach. */
|
|
173
|
-
export function pruneCriticalCss(css: string, markup: string, extraCss = "") {
|
|
174
|
-
const tags = new Set(
|
|
175
|
-
["html", "body"].concat(
|
|
176
|
-
[...markup.matchAll(/<([a-zA-Z][\w-]*)/g)].map((m) => m[1].toLowerCase()),
|
|
177
|
-
),
|
|
178
|
-
);
|
|
179
|
-
const attributes = new Set(
|
|
180
|
-
[...markup.matchAll(/\s([a-zA-Z][\w-:]*)(?==|[\s>])/g)].map((m) => m[1]),
|
|
181
|
-
);
|
|
182
|
-
let nodes = parse(css).map((node) =>
|
|
183
|
-
node.kind === "block" && node.prelude === "@layer base"
|
|
184
|
-
? { ...node, children: prunePreflight(node.children, tags, attributes) }
|
|
185
|
-
: node,
|
|
186
|
-
);
|
|
187
|
-
|
|
188
|
-
// Custom properties: reached from real declarations, the markup or extraCss.
|
|
189
|
-
const definitions = new Map<string, string[]>();
|
|
190
|
-
const seeds: string[] = [markup, extraCss];
|
|
191
|
-
walk(nodes, (node) => {
|
|
192
|
-
if (node.kind === "rule" && isVariableRule(node)) {
|
|
193
|
-
for (const declaration of declarationsOf(node.body)) {
|
|
194
|
-
const colon = declaration.indexOf(":");
|
|
195
|
-
const name = declaration.slice(0, colon).trim();
|
|
196
|
-
const refs = definitions.get(name) ?? [];
|
|
197
|
-
refs.push(...references(declaration.slice(colon + 1)));
|
|
198
|
-
definitions.set(name, refs);
|
|
199
|
-
}
|
|
200
|
-
} else if (node.kind === "rule") {
|
|
201
|
-
seeds.push(node.body);
|
|
202
|
-
}
|
|
203
|
-
});
|
|
204
|
-
const used = new Set(seeds.flatMap(references));
|
|
205
|
-
for (const name of used) {
|
|
206
|
-
for (const ref of definitions.get(name) ?? []) used.add(ref);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
nodes = filterTree(nodes, (node) => {
|
|
210
|
-
if (node.kind === "rule" && isVariableRule(node)) {
|
|
211
|
-
const kept = declarationsOf(node.body).filter((declaration) =>
|
|
212
|
-
used.has(declaration.slice(0, declaration.indexOf(":")).trim()),
|
|
213
|
-
);
|
|
214
|
-
return kept.length ? { ...node, body: kept.join(";") } : null;
|
|
215
|
-
}
|
|
216
|
-
if (node.kind === "rule" && node.prelude.startsWith("@property ")) {
|
|
217
|
-
return used.has(node.prelude.slice(10).trim()) ? node : null;
|
|
218
|
-
}
|
|
219
|
-
return node;
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
// Keyframes: kept when a remaining declaration names them.
|
|
223
|
-
const remaining = print(
|
|
224
|
-
filterTree(nodes, (node) =>
|
|
225
|
-
node.kind === "block" && node.prelude.startsWith("@keyframes")
|
|
226
|
-
? null
|
|
227
|
-
: node,
|
|
228
|
-
),
|
|
229
|
-
).concat(extraCss, markup);
|
|
230
|
-
return print(
|
|
231
|
-
filterTree(nodes, (node) => {
|
|
232
|
-
if (node.kind !== "block" || !node.prelude.startsWith("@keyframes")) {
|
|
233
|
-
return node;
|
|
234
|
-
}
|
|
235
|
-
const name = node.prelude.slice(10).trim();
|
|
236
|
-
return new RegExp(
|
|
237
|
-
`(animation[\\w-]*:|--animate-[\\w-]+:)[^;}]*\\b${name}\\b`,
|
|
238
|
-
).test(remaining)
|
|
239
|
-
? node
|
|
240
|
-
: null;
|
|
241
|
-
}),
|
|
242
|
-
);
|
|
243
|
-
}
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
import type { DriveArrivals, PHStore } from "@powerhousedao/reactor-browser";
|
|
2
|
-
import { getPHStoreSubscribe } from "@powerhousedao/reactor-browser";
|
|
3
|
-
import type { AnyRoute, Router, RouterHistory } from "@tanstack/react-router";
|
|
4
|
-
import { createRouter } from "@tanstack/react-router";
|
|
5
|
-
import type { ErrorInfo, PropsWithChildren, ReactElement } from "react";
|
|
6
|
-
import { createElement } from "react";
|
|
7
|
-
import { captureException } from "../services/sentry.js";
|
|
8
|
-
import { markRouterNavigations } from "./perf-marks.js";
|
|
9
|
-
import { bindConnectScroll, connectScrollRestoration } from "./scroll.js";
|
|
10
|
-
import type { DriveRouteData } from "./drive-route-loader.js";
|
|
11
|
-
import { isDriveNotFound } from "./drive-route-loader.js";
|
|
12
|
-
import type {
|
|
13
|
-
ConnectRootRoute,
|
|
14
|
-
ConnectRouteComponents,
|
|
15
|
-
ConnectRoutes,
|
|
16
|
-
} from "./route-tree.js";
|
|
17
|
-
import { createConnectNavigation } from "./navigation.js";
|
|
18
|
-
import { DriveNotFoundView, NotFoundView } from "./route-components.js";
|
|
19
|
-
import { addConnectRoutes, connectRoutes } from "./route-tree.js";
|
|
20
|
-
import { parseConnectSearch, stringifyConnectSearch } from "./search.js";
|
|
21
|
-
import { driveTitle } from "./titles.js";
|
|
22
|
-
|
|
23
|
-
/** The scroll container of the content view. */
|
|
24
|
-
export const CONTENT_VIEW_ID = "content-view";
|
|
25
|
-
|
|
26
|
-
export type ConnectRouterOptions = {
|
|
27
|
-
store: PHStore;
|
|
28
|
-
arrivals?: DriveArrivals;
|
|
29
|
-
components: ConnectRouteComponents;
|
|
30
|
-
basepath?: string;
|
|
31
|
-
history?: RouterHistory;
|
|
32
|
-
InnerWrap?: (props: PropsWithChildren) => ReactElement;
|
|
33
|
-
/** Code routes added to Connect's file routes; see `addConnectRoutes`. */
|
|
34
|
-
routes?: readonly AnyRoute[];
|
|
35
|
-
/** Reports a route's loader or render error; Sentry by default. */
|
|
36
|
-
onCatch?: (error: unknown, info?: ErrorInfo) => void;
|
|
37
|
-
/** Ends every document title; "Connect" without one. */
|
|
38
|
-
appName?: string;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
function reportRouteError(error: unknown, info?: ErrorInfo) {
|
|
42
|
-
captureException(
|
|
43
|
-
error,
|
|
44
|
-
info?.componentStack
|
|
45
|
-
? { data: { componentStack: info.componentStack } }
|
|
46
|
-
: undefined,
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/** The router over `TRouteTree`; a project's generated tree registers its own. */
|
|
51
|
-
export type ConnectRouterFor<TRouteTree extends AnyRoute> = Router<
|
|
52
|
-
TRouteTree,
|
|
53
|
-
"never",
|
|
54
|
-
false,
|
|
55
|
-
RouterHistory,
|
|
56
|
-
Record<string, any>
|
|
57
|
-
>;
|
|
58
|
-
// Written out, not inferred; see ConnectRootRoute.
|
|
59
|
-
export type ConnectRouter = ConnectRouterFor<ConnectRootRoute>;
|
|
60
|
-
export type ConnectRouterBundle = Pick<
|
|
61
|
-
ConnectRoutes,
|
|
62
|
-
"homeRoute" | "driveRoute" | "settingsRoute"
|
|
63
|
-
> & { router: ConnectRouter };
|
|
64
|
-
|
|
65
|
-
export function createConnectRouter(
|
|
66
|
-
options: ConnectRouterOptions,
|
|
67
|
-
): ConnectRouterBundle {
|
|
68
|
-
if (options.routes) addConnectRoutes(options.routes);
|
|
69
|
-
const { routeTree, homeRoute, driveRoute, settingsRoute } = connectRoutes();
|
|
70
|
-
const router = createRouter({
|
|
71
|
-
routeTree,
|
|
72
|
-
basepath: options.basepath,
|
|
73
|
-
history: options.history,
|
|
74
|
-
context: {
|
|
75
|
-
store: options.store,
|
|
76
|
-
arrivals: options.arrivals,
|
|
77
|
-
components: options.components,
|
|
78
|
-
appName: options.appName,
|
|
79
|
-
},
|
|
80
|
-
parseSearch: parseConnectSearch,
|
|
81
|
-
stringifySearch: stringifyConnectSearch,
|
|
82
|
-
scrollRestoration: connectScrollRestoration(),
|
|
83
|
-
scrollToTopSelectors: [`#${CONTENT_VIEW_ID}`],
|
|
84
|
-
InnerWrap: options.InnerWrap,
|
|
85
|
-
defaultErrorComponent: options.components.error,
|
|
86
|
-
// Not per route: a route's notFoundComponent mounts a boundary that
|
|
87
|
-
// re-renders on every navigation.
|
|
88
|
-
defaultNotFoundComponent: ({ data }) =>
|
|
89
|
-
isDriveNotFound(data)
|
|
90
|
-
? createElement(DriveNotFoundView, { driveSlug: data.driveSlug })
|
|
91
|
-
: createElement(NotFoundView),
|
|
92
|
-
defaultOnCatch: options.onCatch ?? reportRouteError,
|
|
93
|
-
});
|
|
94
|
-
return { router, homeRoute, driveRoute, settingsRoute };
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
function writeSelection(store: PHStore, data: DriveRouteData | undefined) {
|
|
98
|
-
// Revision history belongs to the document it was opened for.
|
|
99
|
-
if (store.selectedNodeId !== data?.nodeId) {
|
|
100
|
-
store.revisionHistoryVisible = false;
|
|
101
|
-
}
|
|
102
|
-
// Drive first: a new drive resets the node.
|
|
103
|
-
store.selectedDriveId = data?.driveId;
|
|
104
|
-
store.selectedNodeId = data?.nodeId;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/** Makes `router` the store's navigation and writes the selection it commits. */
|
|
108
|
-
export function bindConnectRouter(
|
|
109
|
-
connectRouter: ConnectRouterBundle,
|
|
110
|
-
store: PHStore,
|
|
111
|
-
) {
|
|
112
|
-
const { router, driveRoute } = connectRouter;
|
|
113
|
-
|
|
114
|
-
// Only committed matches select; pending ones keep the open view.
|
|
115
|
-
const commitSelection = () => {
|
|
116
|
-
const matches = router.state.matches;
|
|
117
|
-
const drive = matches.find((match) => match.routeId === driveRoute.id);
|
|
118
|
-
if (drive) {
|
|
119
|
-
if (drive.status === "success" && drive.loaderData) {
|
|
120
|
-
writeSelection(store, drive.loaderData);
|
|
121
|
-
} else if (matches.some((match) => match.status === "notFound")) {
|
|
122
|
-
// The drive's 404 page shows no drive.
|
|
123
|
-
writeSelection(store, undefined);
|
|
124
|
-
}
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
// Any other page (home, settings, a project's, a 404) shows no drive.
|
|
128
|
-
const shown = matches.at(-1)?.status;
|
|
129
|
-
if (shown === "success" || shown === "notFound") {
|
|
130
|
-
writeSelection(store, undefined);
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
// Set once, before the first render; selection setters navigate from the start.
|
|
135
|
-
const navigation = createConnectNavigation(connectRouter);
|
|
136
|
-
store.navigation = navigation;
|
|
137
|
-
|
|
138
|
-
// The drive route's head reads names from the store; a rename re-runs it.
|
|
139
|
-
const shownTitle = () => {
|
|
140
|
-
const drive = router.state.matches.find((m) => m.routeId === driveRoute.id);
|
|
141
|
-
return driveTitle(store, drive?.loaderData, router.options.context.appName);
|
|
142
|
-
};
|
|
143
|
-
let title = shownTitle();
|
|
144
|
-
const retitle = () => {
|
|
145
|
-
const next = shownTitle();
|
|
146
|
-
if (next === title) return;
|
|
147
|
-
title = next;
|
|
148
|
-
void router.invalidate({ filter: (m) => m.routeId === driveRoute.id });
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
// Before mount, so the view and scroll restoration see the new selection.
|
|
152
|
-
const unsubscribes = [
|
|
153
|
-
router.subscribe("onBeforeRouteMount", commitSelection),
|
|
154
|
-
router.subscribe("onResolved", commitSelection),
|
|
155
|
-
router.subscribe("onResolved", () => {
|
|
156
|
-
title = shownTitle();
|
|
157
|
-
}),
|
|
158
|
-
getPHStoreSubscribe(store, "drives")(retitle),
|
|
159
|
-
markRouterNavigations(router),
|
|
160
|
-
];
|
|
161
|
-
const unbindScroll = bindConnectScroll(router, CONTENT_VIEW_ID);
|
|
162
|
-
commitSelection();
|
|
163
|
-
|
|
164
|
-
return () => {
|
|
165
|
-
navigation.dispose();
|
|
166
|
-
unbindScroll();
|
|
167
|
-
for (const unsubscribe of unsubscribes) unsubscribe();
|
|
168
|
-
if (store.navigation === navigation) store.navigation = undefined;
|
|
169
|
-
};
|
|
170
|
-
}
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
// The drive route's loader. Server-safe: it reads everything from router context.
|
|
2
|
-
import type { DriveArrivals, PHStore } from "@powerhousedao/reactor-browser";
|
|
3
|
-
import {
|
|
4
|
-
findDriveBySlugOrId,
|
|
5
|
-
makeDriveSlug,
|
|
6
|
-
makeNodeSlug,
|
|
7
|
-
resolveDriveRoute,
|
|
8
|
-
} from "@powerhousedao/reactor-browser";
|
|
9
|
-
import { notFound, redirect } from "@tanstack/react-router";
|
|
10
|
-
import type { ConnectRouteComponents } from "./route-components.js";
|
|
11
|
-
|
|
12
|
-
export type ConnectRouterContext = {
|
|
13
|
-
store: PHStore;
|
|
14
|
-
/** Without it the drive route never waits for drives to arrive. */
|
|
15
|
-
arrivals?: DriveArrivals;
|
|
16
|
-
/** What the file routes render; `createConnectRouter` sets them. */
|
|
17
|
-
components?: ConnectRouteComponents;
|
|
18
|
-
/** Ends every document title; "Connect" without one. */
|
|
19
|
-
appName?: string;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
/** The route a missing drive's not-found page replaces: the content view. */
|
|
23
|
-
export const DRIVE_NOT_FOUND_ROUTE_ID = "/_app/_content";
|
|
24
|
-
|
|
25
|
-
/** A missing drive's not-found data. */
|
|
26
|
-
export type DriveNotFoundData = { driveSlug: string };
|
|
27
|
-
|
|
28
|
-
export function isDriveNotFound(data: unknown): data is DriveNotFoundData {
|
|
29
|
-
return (
|
|
30
|
-
typeof data === "object" &&
|
|
31
|
-
data !== null &&
|
|
32
|
-
typeof (data as { driveSlug?: unknown }).driveSlug === "string"
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/** What the drive route resolved its params to. */
|
|
37
|
-
export type DriveRouteData = { driveId: string; nodeId?: string };
|
|
38
|
-
|
|
39
|
-
export type DriveRouteParams = { driveSlug: string; nodeSlug?: string };
|
|
40
|
-
|
|
41
|
-
/** Resolves a drive route's slugs; a missing drive is not found and a missing
|
|
42
|
-
* node leads to its drive. */
|
|
43
|
-
export async function loadDriveRoute(options: {
|
|
44
|
-
params: DriveRouteParams;
|
|
45
|
-
context: ConnectRouterContext;
|
|
46
|
-
signal: AbortSignal;
|
|
47
|
-
preload: boolean;
|
|
48
|
-
}): Promise<DriveRouteData> {
|
|
49
|
-
const { params, context, signal, preload } = options;
|
|
50
|
-
const result = await resolveDriveRoute({
|
|
51
|
-
store: context.store,
|
|
52
|
-
arrivals: context.arrivals,
|
|
53
|
-
driveSlug: params.driveSlug,
|
|
54
|
-
nodeSlug: params.nodeSlug,
|
|
55
|
-
signal,
|
|
56
|
-
preload,
|
|
57
|
-
});
|
|
58
|
-
switch (result.kind) {
|
|
59
|
-
case "drive": {
|
|
60
|
-
const data: DriveRouteData = result.nodeId
|
|
61
|
-
? { driveId: result.driveId, nodeId: result.nodeId }
|
|
62
|
-
: { driveId: result.driveId };
|
|
63
|
-
const canonical = canonicalParams(context.store, data);
|
|
64
|
-
// An id, an old name or an old drive id in the URL becomes the current slugs.
|
|
65
|
-
if (
|
|
66
|
-
!preload &&
|
|
67
|
-
canonical &&
|
|
68
|
-
(canonical.driveSlug !== params.driveSlug ||
|
|
69
|
-
canonical.nodeSlug !== (params.nodeSlug || undefined))
|
|
70
|
-
) {
|
|
71
|
-
// oxlint-disable-next-line typescript/only-throw-error -- router control flow
|
|
72
|
-
throw redirectTo(canonical);
|
|
73
|
-
}
|
|
74
|
-
return data;
|
|
75
|
-
}
|
|
76
|
-
case "drive-not-found":
|
|
77
|
-
// Shown in place of the content view, so no stale drive renders beside it.
|
|
78
|
-
// oxlint-disable-next-line typescript/only-throw-error -- router control flow
|
|
79
|
-
throw notFound({
|
|
80
|
-
routeId: DRIVE_NOT_FOUND_ROUTE_ID as never,
|
|
81
|
-
data: { driveSlug: params.driveSlug } satisfies DriveNotFoundData,
|
|
82
|
-
});
|
|
83
|
-
case "node-not-found":
|
|
84
|
-
// oxlint-disable-next-line typescript/only-throw-error -- router control flow
|
|
85
|
-
throw redirectTo({
|
|
86
|
-
driveSlug:
|
|
87
|
-
canonicalParams(context.store, { driveId: result.driveId })
|
|
88
|
-
?.driveSlug ?? params.driveSlug,
|
|
89
|
-
nodeSlug: undefined,
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// The slugs links write for `data`; unknown while the drive is unlisted.
|
|
95
|
-
function canonicalParams(
|
|
96
|
-
store: PHStore,
|
|
97
|
-
data: DriveRouteData,
|
|
98
|
-
): DriveRouteParams | undefined {
|
|
99
|
-
const drive = findDriveBySlugOrId(store, data.driveId);
|
|
100
|
-
if (!drive) return undefined;
|
|
101
|
-
if (!data.nodeId) return { driveSlug: makeDriveSlug(drive) };
|
|
102
|
-
const node = drive.state.global.nodes.find((n) => n.id === data.nodeId);
|
|
103
|
-
if (!node) return undefined;
|
|
104
|
-
return { driveSlug: makeDriveSlug(drive), nodeSlug: makeNodeSlug(node) };
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
// In place, with the URL's search params and history state (the opened-from index).
|
|
108
|
-
function redirectTo(params: DriveRouteParams) {
|
|
109
|
-
return redirect({
|
|
110
|
-
to: "/d/$driveSlug/{-$nodeSlug}",
|
|
111
|
-
params,
|
|
112
|
-
search: true,
|
|
113
|
-
state: true,
|
|
114
|
-
replace: true,
|
|
115
|
-
});
|
|
116
|
-
}
|