Download web/src/sheet/index.ts from fsanyoto/loopable: direct link, hf CLI and curl.
- Browser
- Download file 5.01 kB
-
https://huggingface.co/spaces/fsanyoto/loopable/resolve/main/web/src/sheet/index.ts
- Command line
-
hf download hf://spaces/fsanyoto/loopable/web/src/sheet/index.ts
-
curl -L -o index.ts https://huggingface.co/spaces/fsanyoto/loopable/resolve/main/web/src/sheet/index.ts
5.01 kB
| // --------------------------------------------------------------------------- | |
| // sheet/index.ts β the Sheet MODULE's route vocabulary, and nothing else. | |
| // | |
| // ββ WAVE 49 Β· T01 (owner rulings R1, R2, R30) β Sheet is its own module. | |
| // R1 the module is called `Sheet`. | |
| // R2 a rail row immediately above `Data`, carrying the ordinary view rail with exactly ONE | |
| // view kind. Time-series and Chart views stay INTACT and are neither merged nor deprecated | |
| // (`customer-grid/types.ts::DISPLAY_MODES` is untouched by this ticket, on purpose). | |
| // R30 Sheet sits at the HEAD of the data band: Home Β· Starred Β· Inbox | Assistant Β· Agents | | |
| // Sheet Β· Data Β· Connectors. | |
| // | |
| // β WHY THE ROUTE CONSTANT LIVES HERE AND NOT IN `shell/nav.ts`, WHERE ITS SIBLINGS DO. | |
| // The other chrome routes (`CONNECTORS_ROUTE`, `INBOX_ROUTE`, `STARRED_ROUTE` β¦) are declared in | |
| // `shell/nav.ts`, and this constant would sit beside them if the ticket that added it owned that | |
| // file. W49-T01's `files` fence does not include `shell/nav.ts`, so widening the fence to reach it | |
| // was the one thing not on offer. Placing it here costs nothing the shell notices: `nav.ts:: | |
| // CHROME_ROUTES` has exactly ONE runtime consumer β `firstDestination`, which answers the LANDING | |
| // question β and `sheet` is not in `LANDING_PREFERENCE`, so membership changes no behaviour today. | |
| // Reachability comes from elsewhere and was read rather than assumed: `Shell.tsx`'s hash-normaliser | |
| // rewrites only `route === LOGIN_ROUTE || route === ""`, and `nav.ts::resolveRoute` answers an | |
| // unknown key with `undefined` (its fallback is `home`, which is chrome and therefore matches no | |
| // nav entry) β so `#/sheet` renders its own branch instead of being bounced to Home. | |
| // β MOVING IT INTO `CHROME_ROUTES` LATER IS A SAFE, PURELY ADDITIVE EDIT and is the tidier home | |
| // for it; it is recorded in this ticket's handoff rather than done behind the fence. | |
| // | |
| // β THIS FILE IS NOT A BARREL. It deliberately does NOT re-export `SheetPage`: the shell reaches | |
| // the page through `lazy(() => import("../sheet/SheetPage"))`, and a re-export here would pull the | |
| // page into whatever chunk imports this constant β which is the entry chunk β making the lazy | |
| // split cosmetic (see `shell/Shell.tsx`'s route-splitting note). | |
| // | |
| // β THE WORKBOOK / CELL VOCABULARY IS **NOT** HERE. `sheet/types.ts` belongs to W49-T02 and owns | |
| // the cell, range and workbook types. This file carries the route and the view kind the rail | |
| // paints, which is all T01 is allowed to know. | |
| // --------------------------------------------------------------------------- | |
| /** The hash route the rail row points at: `#/sheet`. */ | |
| export const SHEET_ROUTE = "sheet"; | |
| /** | |
| * The ONE view kind the Sheet rail offers (R2). | |
| * | |
| * β A LITERAL OF ITS OWN, NOT A MEMBER OF `customer-grid/types.ts::DISPLAY_MODES`. Adding `sheet` | |
| * to that union would edit the file where Time-series and Chart live, which R2 forbids touching β | |
| * and it would offer Sheet as a display mode of a customer-grid view, which is precisely the | |
| * "merged view" the ruling rejected in favour of a separate module. | |
| */ | |
| export const SHEET_VIEW_KIND = "sheet"; | |
| /** C2: null means no workbook was named; even an empty wb parameter is an explicit request. */ | |
| export type SheetAddress = { | |
| wb: string | null; | |
| tab?: string; | |
| cell?: string; | |
| chart?: string; | |
| }; | |
| /** Route vocabulary only, keeping SheetPage in its lazy chunk. */ | |
| export function readSheetAddress(hash: string): SheetAddress | null { | |
| const route = hash.replace(/^#\/?/, "").split("#")[0]; | |
| const queryAt = route.indexOf("?"); | |
| if ((queryAt < 0 ? route : route.slice(0, queryAt)) !== SHEET_ROUTE) return null; | |
| const query = new URLSearchParams(queryAt < 0 ? "" : route.slice(queryAt + 1)); | |
| const cell = query.get("cell") ?? ""; | |
| return { | |
| wb: query.get("wb"), | |
| tab: query.get("tab") || undefined, | |
| cell: /^[A-Za-z]+[1-9]\d*$/.test(cell) ? cell.toUpperCase() : undefined, | |
| chart: query.get("chart") || undefined, | |
| }; | |
| } | |
| export function sheetAddressHash(address: SheetAddress): string { | |
| if (address.wb === null) return `#/${SHEET_ROUTE}`; | |
| const query = new URLSearchParams({ wb: address.wb }); | |
| if (address.tab) query.set("tab", address.tab); | |
| if (address.cell) query.set("cell", address.cell); | |
| if (address.chart) query.set("chart", address.chart); | |
| return `#/${SHEET_ROUTE}?${query.toString()}`; | |
| } | |
| /** Match the shell's History API notification; ordinary choices retain a Back entry. */ | |
| export function writeSheetAddress(address: SheetAddress, mode: "push" | "replace" = "push"): void { | |
| const hash = sheetAddressHash(address); | |
| if (window.location.hash === hash) return; | |
| const oldURL = window.location.href; | |
| if (mode === "replace") window.history.replaceState(window.history.state, "", hash); | |
| else window.history.pushState(window.history.state, "", hash); | |
| window.dispatchEvent(new HashChangeEvent("hashchange", { oldURL, newURL: window.location.href })); | |
| } | |