diff --git a/README.md b/README.md index a86143c1..862322cf 100644 --- a/README.md +++ b/README.md @@ -46,8 +46,87 @@ to new users. Volunteers are always welcome! ## Documentation -- [Visual Language](https://solidos.github.io/solid-panes/Documentation/VisualLanguage.html) -- [Conventions](./Documentation/conventions.md) +- [Visual Language](https://solidos.github.io/solid-panes/docs/VisualLanguage.html) +- [Conventions](./docs/conventions.md) +- [Navigation design](./docs/navigation-design.md) + +### Profile heading + +Page shells can call `initializeProfileHeading(getPageUrl)` with a function +returning the currently browsed resource URL. Without an argument, the heading +uses `window.location.href`. The function is evaluated on each refresh, including +authentication changes, so shell-specific URL/query parsing stays in the shell. +Call `refreshProfileHeading(true)` after changing the shell's target. + +The `solid-panes-profile-heading` component accepts presentation data through +`profileData`. Its boolean `compact` property (also available as an attribute) +halves the responsive avatar size and shows only the photo, name, and job title. +The page controller uses the full heading on the profile pane and compact mode +on every other pane where the heading is visible. Owner editing remains exclusive +to the profile pane. On storage panes, the heading is shown only when the active +storage URI matches the viewed profile's navbar entry. Opening the logged-in +user's storage from the header menu hides the heading, even when the URL still +points to someone else's profile. Reloading a WebID URL always shows its profile +with Profile selected in the navbar. On a container or resource URL (not a WebID) the page +shows the resource as usual with the navbar visible and nothing selected; choosing Storage +in the navbar replaces that view with the whole storage, with the container or resource +from the URL opened inside it. Any other pane on a page inside someone else's pod +(for example their container) shows the compact heading of that pod's owner; it is +hidden inside the viewer's own pod and for account-menu views. Pressing Enter on the current URL, +or using the browser's back and forward buttons, re-renders the page without a reload, and +like a reload shows what the URL is: the profile on a WebID (selected in the navbar), otherwise +the container or resource itself, whatever the history entry last displayed through the navbar +or the account menu. Solid-panes locally presents the heading data and checks +viewer edit access; the component owns the edit interaction and opens the local +heading editor. The page controller refreshes the heading after a successful save. +After a successful save the component also dispatches a bubbling, composed +`profile-heading-saved` event with `detail.subjectUri`, which profile-pane uses to +rerender sections such as More contacts. +The heading editor includes its own dialog and responsive styles. +On mobile, the edit icon sits closer to the heading's top-right edge while +preserving its full touch target. + +On the profile pane, logged-in visitors viewing someone else's profile also see +an "Add as friend" action to the left of Edit (when available). The page controller +sets `friendSubject` only in that context. The action loads the viewer's profile, +checks `foaf:knows`, and saves the new friendship in the viewer's profile document. +Existing friends have a disabled "Already a friend" button (hidden on mobile). +Success and error messages are centered below the button, announced and focused, +and dismissed after 10 seconds; failed operations can be +retried. Anonymous visitors, owners, and other panes do not show this action. +On mobile, friend actions sit in the top-right corner beside the name, which +wraps as needed. + +Navigation reuses the mounted heading, with a 300ms CSS transition for the avatar, +padding, and detail rows in both directions. Transitions are disabled when the +user prefers reduced motion. +When navigating to a pane without a heading, the entire heading fades and +collapses (including its outer spacing) over 300ms before removal. Navigating +back during that animation cancels it and reuses the existing component. +The reverse navigation fades and expands the full or compact heading and its +outer spacing over 300ms, after the component has rendered. Reduced-motion users +get immediate appearance and removal instead. + +The navbar is hidden when the loaded URL is the logged-in user's WebID or its +fragment-free profile document URL. Other URLs in the same pod and other users' +profiles keep the navbar. Account-menu navigation continues to hide it. + +### Friends list + +On your own editable profile, drop a friend's WebID anywhere in the social pane's +friends list, including its empty space or an existing friend card, to add a +`foaf:knows` link to your profile. The whole list is the drop target; there is no +separate target icon. Other people's lists and non-editable profiles remain +read-only. This uses solid-ui's existing attachment-list save and refresh handlers. +Navigation icons are rendered directly by solid-ui using the imported Lucide +`square-arrow-out-up-right` component in neutral gray and match the remove icons' +size and right alignment. +Remove-friend confirmations appear as compact popups centered over the list, +above its contents and outside the clipped cards, including when there is only +one friend. They do not change the list's layout. Cancel is focused when the +confirmation opens. +The pane passes solid-ui's optional `confirmationContainer` rather than relocating +the widget's popup after it opens. ## Development @@ -65,6 +144,15 @@ npm start 3. You can change the `subject` in the sandbox to determine which pane gets rendered. For example, the default subject loads the `profile-pane`. +### Using a local profile-pane + +When working inside the SolidOS monorepo, `profile-pane` (and the other local +workspaces) are symlinked by `npx lerna bootstrap --force-local` (run from the +monorepo root, as `npm run watch-pivot` does), even if the version in +`package.json` is not published to npm. Use a plain version in `package.json` +(not a `file:` path, which lerna does not link) and avoid a bare `npm install` +here, which fails for unpublished versions and removes the links. + ## Contributing panes When you created a pane, you can either add it as an npm dependency of this repo (for instance meeting-pane, issue-pane, chat-pane are all diff --git a/docs/navigation-design.md b/docs/navigation-design.md new file mode 100644 index 00000000..f7311c73 --- /dev/null +++ b/docs/navigation-design.md @@ -0,0 +1,342 @@ +# Navigation in the databrowser + +This document describes how navigation works in `solid-panes` as implemented: what decides what the +page shows, where that logic lives, the rules it follows, and its known limits. + +## What decides what is shown + +What the user sees depends on several things at once: + +- the page URL +- the pane that was last opened, and whether the account menu or the navbar opened it +- who is logged in +- whose pod the URL is in + +Each of these is read in one place (below), and the rules that combine them are pure functions, so +the heading, the navbar, the outline and the file explorer header all apply the same decision. + +## Where the logic lives + +| Concern | Where | +|---|---| +| Reading and writing what a history entry displayed (`paneName`, `paneUri`, `viaAccountMenu`) | `navigation/state.ts`; the one write is in `GotoSubject` (`outline/manager.js`) | +| Rules for the heading, navbar and file explorer header | `navigation/chrome.ts` (pure functions) | +| Whose pod the page is in, the viewer's storages | `navigation/podContext.ts` (cached lookups) | +| Displaying a view and the follow-up effects | `navigation/controller.ts`, wired to the real navbar and heading in `mainPage/navigation.ts` | +| Telling the page that a view was displayed | `navigation/events.ts` (`solid-panes:navigated`, dispatched by `GotoSubject`) | +| Who asked for a view (`GotoSubject`'s seventh argument) | `navigation/options.ts` | +| Showing or hiding the navbar | `navigation/navbarVisibility.ts` | +| Page load and reload | `initMainPage` (`mainPage/index.ts`) | +| Layout and theme changes | `refreshUI` (`mainPage/index.ts`), called by mashlib | +| Enter on the current URL, back and forward | `navigation/browserEvents.ts` | +| Account menu | `mainPage/header.ts` (maps a choice to an intent) | +| Navbar | `mainPage/navbar.ts` (builds items from the pod context, maps a choice to an intent) | +| Profile heading | `mainPage/profileHeading.ts` (applies `deriveHeading` to the pod context) | +| What is displayed for a pane | `GotoSubject` (displayed subject, open-inside-storage), `FileExplorerProvider` (applies the header rule) | +| Other callers of `GotoSubject` | links in the outline, `solid-ui` buttons, `tabbedPane`, mashlib | + +## Paths into the page + +Every way of changing what is displayed ends in `GotoSubject`. Most of them go through the +navigation controller, which always applies the same follow-up effects. + +| Path | Resolves the pane | Navbar | Heading | +|---|---|---|---| +| Page load (`initMainPage`) | controller (`restore`) | built once from the pod context | refreshed by the controller | +| Account menu (`header.ts`) | controller | hidden | refreshed by the controller | +| Navbar click (`navbar.ts`) | controller | selection kept by the navbar, then `selectNavbarPane` | refreshed by the controller | +| Enter, back and forward | controller (`restore`, after clearing the saved pane) | `selectNavbarPane` | refreshed by the controller | +| Layout or theme change | controller (`restore`, keeps the saved pane and the account-menu marker) | `selectNavbarPane`, or hidden | refreshed by the controller | +| Links and buttons in `solid-ui`, `GotoSubject` calls from mashlib | none (default pane); not through the controller | selection updated within the same pod; rebuilt on a pod change, via the `navigated` event | refreshed via the `navigated` event | + +`GotoSubject` is called directly, with `solo` true, by `solid-ui` (`buttons.ts`, `forms.js`) and +mashlib. Those callers rely on it to push the history entry and the URL, so it is the one place that +writes history, and it announces what it did. + +Standalone shells such as `browse.html` can pass `preserveUrl: true` in the seventh argument when +they display a subject while keeping their own document URL (the subject is carried in the shell's +query parameters). The current history entry is still replaced with the displayed pane and +account-menu metadata, and navigation is announced from that updated state. This is intentionally +opt-in; ordinary `GotoSubject` callers continue to make the displayed subject the page URL. + +Storage is an explicit browser view, not a resource's default pane. Its pane item +renders the storage root with `solo` and `fullView` disabled, so the storage +header, sidebar and listing remain visible even if the root has an index document. +Selecting resources inside Storage replaces only its content area. + +Direct resource URLs use `getRelevantPanes` to choose the full-page resource +view. With no explicitly requested pane, a container containing `index.ttl` +resolves to `index.ttl#this` before selecting its pane. Indexed subjects have no +file-explorer header. Ordinary containers retain their contents view, without +the Storage shell during solo resource navigation. + +## Rules + +### URL and history +- The page URL is never changed by the account menu or the navbar. They display something else while + the URL keeps pointing at what the user opened. +- A history entry records the displayed pane (`paneName`, `paneUri`) and whether the account menu + opened it (`viaAccountMenu`). Pane details are never copied into the entry of a different URL. + +### What loads +- **Reload, Enter and back/forward all show what the URL is.** Whatever the entry last displayed + through the navbar or the account menu is discarded first. + - A WebID (ends in `#me`): the profile pane, with Profile selected in the navbar. + - Any other URL, including the document that holds a WebID such as `/timea2/profile/card`: the + resource or container as it is, with its file explorer header (unless it is a root resource) and + its content. Only `#me` URLs count as profile pages. +- **Enter on the current URL** does this without reloading the page. It is only handled when the + browser has the Navigation API; otherwise Enter reloads the page, which is the same result for a + URL without a fragment. +- **Layout or theme change** (`refreshUI`) re-renders the current entry in place, keeping the URL + and the account-menu marker. + +### Displayed subject +- A pane with its own subject (profile, friends, or the storage of a person) is displayed for that + subject, not for the URL. +- For a storage, the container or resource from the URL is opened inside it, level by level. + +### Navbar +- Hidden for the logged-in viewer's own profile (WebID or its document) and URLs inside any of + their storages, including resources opened through storage links. Also hidden by the account + menu. Shown for other URLs, including when logged out. +- Built from the pod the page is in. Profile and Friends are only offered when the owner of the pod + is known. When a navigation lands in another pod, the items are built again. Within the same pod, + navigation events update the selection from the displayed view without rebuilding the menu. +- On a container or resource URL nothing is selected; on a WebID, Profile is. +- Choosing an item displays it for the URL the page has at that moment, not the one it had when the + items were built. + +### Profile heading +- Full on the profile pane, compact on friends and on other panes. +- On other panes it shows the pod owner, unless the owner is the viewer, the view came from the + account menu, or the owner is unknown. +- It reads the owner from the pod context, so it does not depend on the navbar existing. + +### File explorer header +- Never shown for profile, friends, preferences or dashboard panes (`home` and `dashboard`). +- Never shown over the folder pane, which supplies its own storage header or navbar. +- Never shown for root resources or WebIDs. +- For other account-menu views and panes with their own subject: shown only when the URL is inside + the viewer's own pod. + +## Modules + +### Navigation state (`navigation/state.ts`) +The only place that knows how a history entry records what was displayed. + +```ts +type ViewKind = 'default' | 'profile' | 'friends' | 'storage' | 'pane' + +interface NavigationView { + kind: ViewKind + pane?: string // registry name of the pane; set unless the kind is 'default' + subject?: string // what the pane displays when that is not the page URL +} + +interface NavigationState { view: NavigationView, viaAccountMenu: boolean } +``` + +- `readNavigationState()` and `parseNavigationState(raw)` read an entry. +- `nextHistoryState(current, change)` is the rule for what to store after displaying something: pane + details never leak into another URL's entry, a subject does not outlive its pane, and the + account-menu marker is set or cleared. +- `clearPaneState()` and `withoutPaneState()` forget what an entry displayed. +- The stored shape is `paneName`, `paneUri`, `viaAccountMenu`. The kind is derived from the pane + name. There is no stored record of whether the URL or the navbar opened a view; the account-menu + marker is the only source any rule uses. + +### Chrome rules (`navigation/chrome.ts`) +Pure functions that read no history, DOM or session: + +| Function | Decides | Used by | +|---|---|---| +| `deriveHeading` | whether the profile heading shows, full or compact, and for which profile; takes the pod `owner` and the pod's `storageUris` | `profileHeading.ts` | +| `deriveNavbarSelection`, `isNavbarItemSelected`, `pickNavbarItem` | which navbar item is selected | `navbar.ts` | +| `isNavbarHidden` (with `setNavbarHidden` in `navbarVisibility.ts`) | whether the navbar is shown | `navbar.ts`, `controller.ts`, `outline/manager.js` | +| `deriveExplorerHeader`, `explorerHeaderForPane`, `isPersonPane` | whether the file explorer header shows | `outline/manager.js`, `FileExplorerProvider` | + +There is no single "derive everything" function: each consumer needs different inputs (the explorer +header is decided per provider, the heading needs the pod), so the controller composes the effects. + +### Pod context (`navigation/podContext.ts`) +Whose pod the page is in, loaded once and cached. + +```ts +interface PodContext { viewer?: string, owner?: string, storagePanes: PaneItem[], viewerStorages: string[] } +``` + +- `getPodContext(url)` assembles it from the parts below. `isInViewerPod`, `isSamePod` and + `isPageInViewerPod` answer questions about a context. +- The parts are cached separately because they depend on different things: + - the **owner**, per document: the profile lookup can end with that document's own + `foaf:primaryTopic`, so two pages of one pod need not share an owner; + - the **storages**, per pod (origin and first path segment); + - the **viewer's storages**, per viewer. +- A failed lookup is not kept, so the next request asks again. At most 500 documents are remembered. +- The owner is unknown when the lookup falls back to the page URL itself, so an unrelated resource + does not get a "pod owner" heading. Tests call `resetPodContexts()` between cases. + +### Event (`navigation/events.ts`) +When `solo`, `GotoSubject` dispatches `solid-panes:navigated` on the document after writing the +history entry, with the URL and the stored state. This is how calls that bypass the controller +(`solid-ui`, mashlib) still reach the chrome: the navbar listens, to rebuild itself when a +navigation lands in another pod, and the heading listens, to refresh itself. The heading does not +watch the DOM. + +History writes made by the outline or `clearPaneState()` go through `writeNavigationHistory()`. +While a write is in progress, the Navigation API's `navigate` handler ignores its synchronous +event: Safari can report these programmatic replacements as user-initiated, which otherwise causes +the handler to clear the state recursively. Actual address-bar navigation remains handled normally. +History write failures are logged. + +### Options (`navigation/options.ts`) +`GotoSubject`'s seventh argument takes `{ source: 'accountMenu' | 'default' }`. The older boolean form +(`false` for the account menu) is still accepted with the same meaning. + +### Controller (`navigation/controller.ts`) +`navigation.show(intent)` is the one way to display a view and bring the chrome in line with it: + +```ts +type NavigationIntent = + | { kind: 'restore', subject?, forceHeading? } // what the URL (or current entry) displays + | { kind: 'profile' | 'friends', subject, source? } // a person, by WebID + | { kind: 'storage', pane, source? } + | { kind: 'app', pane, source? } // by registry name: home, basicPreferences +``` + +- It resolves the pane, renders through `GotoSubject`, then sets navbar visibility and selection and + refreshes the heading, in that order. +- For an account-menu source it hides the navbar before resolving the pane. +- A newer intent wins over one still resolving its pane. This latest-wins token covers the + controller's renders only; the heading's own request counter and the manager's open-inside-storage + guard protect different async work, which callers that bypass the controller also use. +- If a pane cannot be built for anything but `restore`, it warns and displays nothing, rather than + falling back to the page URL's default view. +- `restore` without a pane shows the profile on a WebID, and the default view elsewhere. +- `mainPage/navigation.ts` wires the controller to the real navbar and heading, one per outliner. + The controller is internal; it is not exported from the package. + +`header.ts`, `navbar.ts`, `initMainPage` and `refreshUI` are thin callers that map a choice to an +intent. `createHeader` and `createNavbar` take the controller. Header and navbar clicks pass no table +to `GotoSubject`, so the outline's current container is used. The account menu does nothing at all +when nobody is logged in. + +### Browser events (`navigation/browserEvents.ts`) +`registerBrowserNavigation(controller)` handles two things; both clear the saved pane and call +`show({ kind: 'restore', forceHeading: true })`. + +- **Enter on the current URL.** The Navigation API `navigate` event is intercepted when + `canIntercept`, `userInitiated`, `navigationType === 'replace'` and the destination is the + current URL. +- **Back and forward.** `currententrychange` with `navigationType === 'traverse'`, or `popstate` in + browsers without the Navigation API. + +The listeners are added once; a later call only changes which controller they use. +`isHandlingBrowserNavigation()` (exported from the package) is true once they are registered. +mashlib's `window.onpopstate` returns early when it is true, so only the main page reacts to back +and forward. mashlib keeps its handler for pages that load it without running the main page, and +reads the flag when the event fires, because it registers the handler at load, before the main page +starts. mashlib pins `solid-panes` to an exact version, so the two release together; a mashlib built +against a `solid-panes` without this export must not be paired with this version. + +### Profile heading placement +The navbar is inserted at the top of the page after the heading's mount point exists, so +`initMainPage` calls `placeProfileHeading()` once the navbar is created, which keeps the heading +above it. + +## Tests + +- `test/unit/navigation/`: `state`, `chrome`, `podContext`, `controller`, `events`, `options` and + `browserEvents` tests, one per module. +- `test/unit/mainPage/`: `header`, `navbar`, `index` and `profileHeading` tests against the + controller and pod context. `reload.test.ts` wires the real navbar, heading and outline manager + together, including a direct `GotoSubject` call into another pod (as `solid-ui` makes) and a + back navigation to the first pod. +- `test/unit/outline/manager.test.ts` covers the header rule; `test/unit/components/fileExplorerProvider.test.ts` + covers the provider. + +The tests run in jsdom with the network mocked, and the setup answers every fetch with an empty +Turtle response, so tests that render real file explorer headers need a partial `podUtils` mock. + +## Browser support + +The controller relies on the Navigation API for two things: handling Enter on the current URL, and +telling back/forward apart from in-page `#` links. Everything else works without it. + +### Navigation API support + +Source: MDN browser-compat-data (last updated 2026-01-14). Every member we use (`navigate`, +`currententrychange`, `userInitiated`, `canIntercept`, `navigationType`, `intercept`) is supported +from the same version. + +| Browser | Supported from | +|---|---| +| Chrome, Edge, Opera, Samsung Internet, Android WebView | Chrome 102 (`intercept()` and `canIntercept` from 105) | +| Firefox | 147 | +| Safari (macOS and iOS) | 26.2 | + +Every iPhone and iPad browser uses Safari's engine, so it follows the Safari row. + +### What our build targets + +| Layer | Setting | Effect | +|---|---|---| +| TypeScript (`tsconfig.json`, also in mashlib) | `target: ES2019`, `lib: ["DOM", "ES2019"]` | Type checking only; both packages run `tsc --noEmit`. The `lib` setting makes newer built-ins fail the type check. | +| `solid-panes` build (`vite.config.mts`) | no explicit target, so Vite 8's default `baseline-widely-available` | Syntax lowered to Chrome and Edge 111, Firefox 114, Safari and iOS 16.4 | +| solidos-toolkit's Babel step | `preset-env` only when `transpileTargets` is passed; we don't pass it | Only TypeScript, decorators and class fields are transformed | +| mashlib (`babel.config.mjs`) | `> 1%, last 3 versions, not dead` | Syntax lowered for the final bundle | + +Nothing in this setup polyfills runtime APIs (no `core-js`, no `useBuiltIns`). The Navigation API +is therefore always feature-detected, and TypeScript does not know `window.navigation`, so the code +casts it. + +mashlib's webpack config skips Babel for `node_modules` except `solid-panes/src`. A published +`solid-panes` package is not re-transpiled for mashlib's list and keeps Vite's baseline floor. In +the workspace, the symlinked source most likely does go through Babel. + +### Gap between targets and the Navigation API + +Browsers inside our build targets that lack the Navigation API: + +- Safari and iOS 16.4 to 26.1, including iOS 18.5 to 18.7, which is in mashlib's resolved set. +- Firefox 114 to 146, including the ESR line. +- From mashlib's resolved set: Opera Mini, Opera Mobile 80 and KaiOS. UC and QQ are probably in the + same position, but their engine versions have not been confirmed. + +The gap includes browsers a few months old, so it is not an edge case. The `popstate` fallback has +its own test. + +### Behaviour without the Navigation API + +| Behaviour | With | Without | +|---|---|---| +| Back and forward | `currententrychange` with `traverse`, not fired for `#` links | `popstate`, which may also fire for in-page `#` links and re-render the page | +| Enter on the current URL | Handled: shows the URL's own view | Not handled: content opened through the account menu stays in place | +| Reload | Handled on page load | Handled on page load | + +## Known limits + +- **Back and forward render in the event itself.** Nothing else is expected to re-render on + `popstate`. A package that does would race with the main page. +- **Calls that bypass the controller** (`solid-ui` links and buttons, mashlib's own `GotoSubject` + calls) reach the navbar and heading through the `navigated` event. They are not recorded as an + intent. The event is only dispatched when `solo`, after the history entry is written, so a call + that fails before that point announces nothing. +- **The heading does not watch the DOM.** A change to what it should show that happens without a + `GotoSubject` call, a login or logout, or a profile save is missed. Today the only such change is + the main page's own `clearPaneState()`, which the controller always follows. +- **Pod discovery is heuristic.** The owner comes from `loadProfileFromURI`, which assumes + `profile/card#me` at the origin or under the first path segment, and falls back to the document's + `foaf:primaryTopic`. The pod for the storages is keyed on the origin and first path segment, so a + storage nested deeper, or two storages under one first segment, share one lookup. +- **Pods without a `pim:Storage` triple in the profile** cannot be recognised as "the viewer's pod", + so the file explorer header stays hidden there. The pod context could fall back to a path derived + from the WebID. +- **Not covered by automated tests:** a real browser, the Navigation API itself, and mashlib's own + test suite. Worth checking by hand: a refresh on a WebID and on a container, the account menu on + someone else's container, back and forward across entries opened through the navbar or the account + menu, and a `solid-ui` link into another pod (the navbar and heading should follow). +- **A stale `dist/` looks like a bug.** mashlib consumes `solid-panes/dist` through a symlink; if + `vite build --watch` stalls, the browser runs old code. The watcher also skips type declarations, + so mashlib's `tsc` needs a full `npm run build` in `solid-panes` first. diff --git a/package-lock.json b/package-lock.json index 4f3a8675..1cb6fb44 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,32 +1,33 @@ { "name": "solid-panes", - "version": "5.0.0", + "version": "5.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "solid-panes", - "version": "5.0.0", + "version": "5.1.0", "license": "MIT", "dependencies": { + "@lit/context": "^1.1.6", "@solid/better-simple-slideshow": "^0.1.0", - "activitystreams-pane": "2.0.0", + "activitystreams-pane": "2.1.0", "chat-pane": "4.0.0", - "contacts-pane": "4.0.0", + "contacts-pane": "4.1.0", "dompurify": "^3.4.4", - "folder-pane": "4.0.0", - "issue-pane": "4.0.0", + "folder-pane": "4.1.0", + "issue-pane": "4.1.0", "lit-html": "^3.3.2", "marked": "^18.0.3", - "meeting-pane": "4.0.0", + "meeting-pane": "4.1.0", "mime-types": "^3.0.2", - "pane-registry": "5.0.1", - "profile-pane": "4.0.0", + "pane-registry": "5.1.1", + "profile-pane": "4.1.0", "rdflib": "2.4.1", - "solid-logic": "6.0.0", + "solid-logic": "6.2.0", "solid-namespace": "^0.5.4", - "solid-ui": "5.0.1", - "source-pane": "4.0.0" + "solid-ui": "5.1.0", + "source-pane": "4.1.0" }, "devDependencies": { "@iconify/json": "2.2.494", @@ -47,9 +48,9 @@ } }, "node_modules/@acemir/cssom": { - "version": "0.9.31", - "resolved": "https://registry.npmjs.org/@acemir/cssom/-/cssom-0.9.31.tgz", - "integrity": "sha512-ZnR3GSaH+/vJ0YlHau21FjfLYjMpYVIzTD8M8vIEQvIGxeOXyXdzCI140rrCY862p/C/BbzWsjc1dgnM9mkoTA==", + "version": "0.9.33", + "resolved": "https://registry.npmjs.org/@acemir/cssom/-/cssom-0.9.33.tgz", + "integrity": "sha512-52IMmrBsIsDZLp/KFM+KmaMLJ8GTj113K+iFGFCoOjstZSZbsAxMJE8KYtwao7bz1LsEG810ts1m5wvkVEqPlg==", "devOptional": true, "license": "MIT" }, @@ -184,21 +185,21 @@ } }, "node_modules/@babel/core": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.29.7.tgz", - "integrity": "sha512-RgHBCvtjbOK2gXSNBNIkNoEc9qoVEtau3hj8gEqKQuL3HZAibKarWFEI3Lfm6EYKkLalOh8eSrj9b+ch9H/VBA==", + "version": "7.29.13", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.29.13.tgz", + "integrity": "sha512-j1nvOQCZYSgp7HLmisnCXFTpVvFODiijQ9QHkORfGKWH6YDtskTEeCJS7eV545GZ9UBzrq0e2xsOd5QQ5PjIqw==", "dev": true, "license": "MIT", "dependencies": { "@babel/code-frame": "^7.29.7", - "@babel/generator": "^7.29.7", - "@babel/helper-compilation-targets": "^7.29.7", - "@babel/helper-module-transforms": "^7.29.7", - "@babel/helpers": "^7.29.7", - "@babel/parser": "^7.29.7", + "@babel/generator": "^7.29.13", + "@babel/helper-compilation-targets": "^7.29.13", + "@babel/helper-module-transforms": "^7.29.13", + "@babel/helpers": "^7.29.13", + "@babel/parser": "^7.29.13", "@babel/template": "^7.29.7", - "@babel/traverse": "^7.29.7", - "@babel/types": "^7.29.7", + "@babel/traverse": "^7.29.13", + "@babel/types": "^7.29.11", "@jridgewell/remapping": "^2.3.5", "convert-source-map": "^2.0.0", "debug": "^4.1.0", @@ -215,9 +216,9 @@ } }, "node_modules/@babel/core/node_modules/semver": { - "version": "6.3.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", - "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "version": "6.3.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.2.tgz", + "integrity": "sha512-GYrCADwpu6yV5OAvchkQ27Z5wwMxWAEMg5NNWjyHh/5DboFFqbdbvYNIvZouQpxXyeMPoTOh0vdPYKlf0ZswdQ==", "dev": true, "license": "ISC", "bin": { @@ -225,14 +226,14 @@ } }, "node_modules/@babel/generator": { - "version": "7.29.8", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.29.8.tgz", - "integrity": "sha512-gZbepsdh3WDtgZKWL+vTPh71LSBrm/Y4/QDZBVCcYfmeTEEuoOYwlSy+G1StfJg+/Zy550u/3TATbm7qDbbMtg==", + "version": "7.29.14", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.29.14.tgz", + "integrity": "sha512-qSY56jgW5JnSXzuekLVil6zaOQxOCtOHidr65KkaMBw772IuAY28Qx4ZykAcDn8+FRF15qk80XzKwgSc/RYW6g==", "dev": true, "license": "MIT", "dependencies": { - "@babel/parser": "^7.29.8", - "@babel/types": "^7.29.8", + "@babel/parser": "^7.29.14", + "@babel/types": "^7.29.14", "@jridgewell/gen-mapping": "^0.3.12", "@jridgewell/trace-mapping": "^0.3.28", "jsesc": "^3.0.2" @@ -255,9 +256,9 @@ } }, "node_modules/@babel/helper-compilation-targets": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.29.7.tgz", - "integrity": "sha512-wem6WaBj4NaVYVdNhLPPVacES6ZJ+KBBfSkTMD3YZxbP3rm3Di85tJU5ljaUNhaOynt+Aj0xruhYuzQBt8n71g==", + "version": "7.29.13", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.29.13.tgz", + "integrity": "sha512-8WxJ4/Vmes3ghacj8VOJy3NW8eyHiFY/4thU/LSBuBE470+igjR/j1ZTNn8fV5VdNrLx6iXUwig526UdOvfP0w==", "dev": true, "license": "MIT", "dependencies": { @@ -282,9 +283,9 @@ } }, "node_modules/@babel/helper-compilation-targets/node_modules/semver": { - "version": "6.3.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", - "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "version": "6.3.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.2.tgz", + "integrity": "sha512-GYrCADwpu6yV5OAvchkQ27Z5wwMxWAEMg5NNWjyHh/5DboFFqbdbvYNIvZouQpxXyeMPoTOh0vdPYKlf0ZswdQ==", "dev": true, "license": "ISC", "bin": { @@ -292,9 +293,9 @@ } }, "node_modules/@babel/helper-create-class-features-plugin": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.29.7.tgz", - "integrity": "sha512-IY3ZD9Tmooqr3TUhc3DUWxiuo8xx1DWLhd5M7hQ+ZWJamqM2BbalrBJb2MisSLoYorOj75U03qULCxQTY9r3hg==", + "version": "7.29.13", + "resolved": "https://registry.npmjs.org/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.29.13.tgz", + "integrity": "sha512-fo8/Fr44/DMV71FQjk/HA0Npmu3bo5DFoWTCW1dhUR8Vx3NFfAVeEy0TbcBpt4e+hd2QhdmWgmspHo/9iWj8RA==", "dev": true, "license": "MIT", "dependencies": { @@ -302,8 +303,8 @@ "@babel/helper-member-expression-to-functions": "^7.29.7", "@babel/helper-optimise-call-expression": "^7.29.7", "@babel/helper-replace-supers": "^7.29.7", - "@babel/helper-skip-transparent-expression-wrappers": "^7.29.7", - "@babel/traverse": "^7.29.7", + "@babel/helper-skip-transparent-expression-wrappers": "^7.29.13", + "@babel/traverse": "^7.29.13", "semver": "^6.3.1" }, "engines": { @@ -314,9 +315,9 @@ } }, "node_modules/@babel/helper-create-class-features-plugin/node_modules/semver": { - "version": "6.3.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", - "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "version": "6.3.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.2.tgz", + "integrity": "sha512-GYrCADwpu6yV5OAvchkQ27Z5wwMxWAEMg5NNWjyHh/5DboFFqbdbvYNIvZouQpxXyeMPoTOh0vdPYKlf0ZswdQ==", "dev": true, "license": "ISC", "bin": { @@ -324,14 +325,14 @@ } }, "node_modules/@babel/helper-create-regexp-features-plugin": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/helper-create-regexp-features-plugin/-/helper-create-regexp-features-plugin-7.29.7.tgz", - "integrity": "sha512-907Uymvqgg1dwUA+7IGwFAOSYzQOuzPXKNJ1yxzwPffzkYFg2q2eHi1fIOs6sXkG9NbIUMunnUlkYsfRFNvomg==", + "version": "7.29.14", + "resolved": "https://registry.npmjs.org/@babel/helper-create-regexp-features-plugin/-/helper-create-regexp-features-plugin-7.29.14.tgz", + "integrity": "sha512-nKvzhuLMMnFHHsENpUZh4N2e+LqnKDgT0SMibSyv8aW8FqGKWMqLO/zdnRjAYcruH9At6LVicWg7DgTc6IPzNg==", "dev": true, "license": "MIT", "dependencies": { "@babel/helper-annotate-as-pure": "^7.29.7", - "regexpu-core": "^6.3.1", + "regexpu-core": "^6.5.4", "semver": "^6.3.1" }, "engines": { @@ -342,9 +343,9 @@ } }, "node_modules/@babel/helper-create-regexp-features-plugin/node_modules/semver": { - "version": "6.3.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", - "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "version": "6.3.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.2.tgz", + "integrity": "sha512-GYrCADwpu6yV5OAvchkQ27Z5wwMxWAEMg5NNWjyHh/5DboFFqbdbvYNIvZouQpxXyeMPoTOh0vdPYKlf0ZswdQ==", "dev": true, "license": "ISC", "bin": { @@ -369,14 +370,14 @@ } }, "node_modules/@babel/helper-define-polyfill-provider/node_modules/resolve": { - "version": "1.22.12", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.12.tgz", - "integrity": "sha512-TyeJ1zif53BPfHootBGwPRYT1RUt6oGWsaQr8UyZW/eAm9bKoijtvruSDEmZHm92CwS9nj7/fWttqPCgzep8CA==", + "version": "1.22.14", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.14.tgz", + "integrity": "sha512-1ZjYvR9sbkiwC5+9QHetqW5HmA2pHRMaoupD01t2HlYnV/vydC2zPwLixhsMieSWVZt0JJRg5LVIk0Ow1D/TrA==", "dev": true, "license": "MIT", "dependencies": { "es-errors": "^1.3.0", - "is-core-module": "^2.16.1", + "is-core-module": "^2.18.0", "path-parse": "^1.0.7", "supports-preserve-symlinks-flag": "^1.0.0" }, @@ -401,14 +402,15 @@ } }, "node_modules/@babel/helper-member-expression-to-functions": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.29.7.tgz", - "integrity": "sha512-j+7JYmk1JYDtACIGj0QJqqWZjoUpMoEikQGADMaHgCMCSDqd2+P32rfcibUNrGOMWrlzK1WJBdxrB3JJQZwWtg==", + "version": "7.29.14", + "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.29.14.tgz", + "integrity": "sha512-FuTSn8mXKAP+aHXnbkCYQsQAdlEIJptEutwc2NaPd28hyVqsjRDmBnI2EPJX6HCodKIqOHfayQHqtxQCkqwthA==", "dev": true, "license": "MIT", "dependencies": { - "@babel/traverse": "^7.29.7", - "@babel/types": "^7.29.7" + "@babel/helper-skip-transparent-expression-wrappers": "^7.29.13", + "@babel/traverse": "^7.29.14", + "@babel/types": "^7.29.14" }, "engines": { "node": ">=6.9.0" @@ -429,15 +431,15 @@ } }, "node_modules/@babel/helper-module-transforms": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.29.7.tgz", - "integrity": "sha512-UPUVSyXbOh627KiCIGQSgwWzGeBKLkaJ9PJEdrngIwMSzxLR4jS4+f1f1jb7VzBbg8nFLaYotvVPFCTqdrmTAg==", + "version": "7.29.14", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.29.14.tgz", + "integrity": "sha512-2XDvQVd9JESaOgGc4jT2/jquTAO7ppA5noTZQqH+MmZ89yjCzScLwtCPbWtkPZylL+TLWR49IwWmk+QkRR4GsA==", "dev": true, "license": "MIT", "dependencies": { "@babel/helper-module-imports": "^7.29.7", "@babel/helper-validator-identifier": "^7.29.7", - "@babel/traverse": "^7.29.7" + "@babel/traverse": "^7.29.14" }, "engines": { "node": ">=6.9.0" @@ -506,23 +508,23 @@ } }, "node_modules/@babel/helper-skip-transparent-expression-wrappers": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.29.7.tgz", - "integrity": "sha512-brcMGQaVzIeUb+6/bs1Av0f8YuNNjKY2JyvfRCsFuFsdKccEQ5Ges2y74D74NZ1Rz8lKJ9ksJkfqwQFJ/iNEyQ==", + "version": "7.29.13", + "resolved": "https://registry.npmjs.org/@babel/helper-skip-transparent-expression-wrappers/-/helper-skip-transparent-expression-wrappers-7.29.13.tgz", + "integrity": "sha512-Abm4rKIH0tmCayJLwcoeOkdzpYUphTbO52fHhyEBHn7S0R+ni4epNLI/8nq1L0DN2Bl0u5qmgWm2Og/z4fBb+Q==", "dev": true, "license": "MIT", "dependencies": { - "@babel/traverse": "^7.29.7", - "@babel/types": "^7.29.7" + "@babel/traverse": "^7.29.13", + "@babel/types": "^7.29.11" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-string-parser": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.29.7.tgz", - "integrity": "sha512-Pb5ijPrZ89GDH8223L4UP8i6QApWxs04RbPQJTeWDV0/keR2E36MeKnyr6LYmUUvqRRI+Iv87SuF1W6ErINzYw==", + "version": "7.29.14", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.29.14.tgz", + "integrity": "sha512-CXvKMFvM80ihI7Vox9jb+kQjnyjESQNPM+vB7U0Zz6TWuZA+Z/FL0QPMH300h33qJtIx+REeBhXqWOPW48TcAQ==", "devOptional": true, "license": "MIT", "engines": { @@ -550,42 +552,42 @@ } }, "node_modules/@babel/helper-wrap-function": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/helper-wrap-function/-/helper-wrap-function-7.29.7.tgz", - "integrity": "sha512-iES0Skag9ERIF68aXadpO6dbXa03mNWK3sEqJaMnLNs/eC3l0lkImdfoy6Y09/SfkpawdAB4RjQ7PVA7TcVGdw==", + "version": "7.29.14", + "resolved": "https://registry.npmjs.org/@babel/helper-wrap-function/-/helper-wrap-function-7.29.14.tgz", + "integrity": "sha512-sBCQEL5D9MYOI5RvWpYtXJBeFLuGGI40hU7wW4WtDvuSZGi0zDV+cn8y9sJWD5rKpjZdsde0+oJniLbU2vdfIg==", "dev": true, "license": "MIT", "dependencies": { "@babel/template": "^7.29.7", - "@babel/traverse": "^7.29.7", - "@babel/types": "^7.29.7" + "@babel/traverse": "^7.29.14", + "@babel/types": "^7.29.14" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helpers": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.29.7.tgz", - "integrity": "sha512-1k2lAGRMfHTcwuNYcCNUmaUffmQv8KWMfh2iJUUeRlwlwH4FdNG7mfPI10NPfLHJFThE4Tyr4mv7kTNZOiPuBg==", + "version": "7.29.14", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.29.14.tgz", + "integrity": "sha512-6E3Mi1r0B0umq6vmZa4/78q+64fqO2YY0THUdjDPKUCKhNb0yQy5NQIaPHCSD3ryTgiTss//P4JsWS80AsZ6LQ==", "dev": true, "license": "MIT", "dependencies": { "@babel/template": "^7.29.7", - "@babel/types": "^7.29.7" + "@babel/types": "^7.29.14" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/parser": { - "version": "7.29.9", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.9.tgz", - "integrity": "sha512-CjXrNHTnvqBVqHgdBysY3vk2T8tpJHb5/RMeHJBTyVa9xgugCB0CJTx/3oO8RV2QRQP391RWpB7D6hLjm8V9uA==", + "version": "7.29.14", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.14.tgz", + "integrity": "sha512-VL220vXuyO2z3rNIQwY7ftj9UwpqOt+33sH+sBWkOekbsSR2g7EEMnOx24ZlCH0xOA3DM/33SifVFGbnJD8r/w==", "devOptional": true, "license": "MIT", "dependencies": { - "@babel/types": "^7.29.8" + "@babel/types": "^7.29.14" }, "bin": { "parser": "bin/babel-parser.js" @@ -644,14 +646,14 @@ } }, "node_modules/@babel/plugin-bugfix-safari-rest-destructuring-rhs-array": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-bugfix-safari-rest-destructuring-rhs-array/-/plugin-bugfix-safari-rest-destructuring-rhs-array-7.29.7.tgz", - "integrity": "sha512-oBNVCvnO5tND+xSopWvV8WNGfpTfgP4Zr/YXXSj8zfmcPktp5Ku/aZlsIowgSD4fjmgHn6sGmB9APVsU5zOdhA==", + "version": "7.29.13", + "resolved": "https://registry.npmjs.org/@babel/plugin-bugfix-safari-rest-destructuring-rhs-array/-/plugin-bugfix-safari-rest-destructuring-rhs-array-7.29.13.tgz", + "integrity": "sha512-7RpEgFZq9xNRHsWwPLFQpjPOi0ZECE2QZWMBes+vgK7E02krjOfPiYtnHTIUF2nCDyeCJPvSAj0AP4NTVf4hsw==", "dev": true, "license": "MIT", "dependencies": { "@babel/helper-plugin-utils": "^7.29.7", - "@babel/helper-skip-transparent-expression-wrappers": "^7.29.7" + "@babel/helper-skip-transparent-expression-wrappers": "^7.29.13" }, "engines": { "node": ">=6.9.0" @@ -892,9 +894,9 @@ } }, "node_modules/@babel/plugin-transform-block-scoping": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.29.7.tgz", - "integrity": "sha512-ONyr4+AZhKh8yKWInVxU9AXA9EbsyeLcL6V0dJy6M2/62vuvpGm29zzuymbTpdc451GEpDIdAyPLP3r+P61yKQ==", + "version": "7.29.13", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.29.13.tgz", + "integrity": "sha512-q7f5zYLtDLqO11ydQK1w2RqZ1m5kmcAlmgZlfXssKgqVyL8+HgDvWXMxvuEz8TuJfq1UNsY9sB6ABjjtQkN6wA==", "dev": true, "license": "MIT", "dependencies": { @@ -925,13 +927,13 @@ } }, "node_modules/@babel/plugin-transform-class-static-block": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-class-static-block/-/plugin-transform-class-static-block-7.29.7.tgz", - "integrity": "sha512-kibJgmEdX2iMwsHY2tSZNDgj8PwIlCQz7FK9KuGKO8zsuoUwSEhoNnNVp/emKWrbY4HeO6kkXfdMqRKKKXBm2A==", + "version": "7.29.14", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-class-static-block/-/plugin-transform-class-static-block-7.29.14.tgz", + "integrity": "sha512-4rr6WKSu9DzMYpcTlbjHw6hFRk0Gkys3D54mqNE4tOyYQFOTrf3RBhntYH62ec/fbvgGEVATh5cqGZjM2Yc3gw==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-create-class-features-plugin": "^7.29.7", + "@babel/helper-create-class-features-plugin": "^7.29.13", "@babel/helper-plugin-utils": "^7.29.7" }, "engines": { @@ -942,9 +944,9 @@ } }, "node_modules/@babel/plugin-transform-classes": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-classes/-/plugin-transform-classes-7.29.7.tgz", - "integrity": "sha512-qV0OGGBVacduzQHE649JyCneOFI/maT+YKsO+K4Yi3xv2wTPNjM/W2o2gdzMwEAZz7fXNTHAe0NcSg30bIN69g==", + "version": "7.29.11", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-classes/-/plugin-transform-classes-7.29.11.tgz", + "integrity": "sha512-f8kTDM/nTvpLeafb+TJ4jboFr/Y3BbC+QzgPpPGzSKJqWLnj9LW0WLqv4XKA11LX5sr+EgvLE6Ix3YsCEusodw==", "dev": true, "license": "MIT", "dependencies": { @@ -953,7 +955,7 @@ "@babel/helper-globals": "^7.29.7", "@babel/helper-plugin-utils": "^7.29.7", "@babel/helper-replace-supers": "^7.29.7", - "@babel/traverse": "^7.29.7" + "@babel/traverse": "^7.29.10" }, "engines": { "node": ">=6.9.0" @@ -980,14 +982,14 @@ } }, "node_modules/@babel/plugin-transform-destructuring": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.29.7.tgz", - "integrity": "sha512-iPX8aD6H9zV5s7ZsqTdNocPN/MGQ5sSMnElKrktxjJRMnB2jN/1p2+R7GkfD6CAYoVFqy5A4XnSIUeGgJzIWpg==", + "version": "7.29.13", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.29.13.tgz", + "integrity": "sha512-X2meXB39NOPPmmshSRJzyd50hX9uCzbscNQwVCjLCtq363PZIJFFxJIeZPpgAewC570vpdeGIHTcltwd0QUlJg==", "dev": true, "license": "MIT", "dependencies": { "@babel/helper-plugin-utils": "^7.29.7", - "@babel/traverse": "^7.29.7" + "@babel/traverse": "^7.29.13" }, "engines": { "node": ">=6.9.0" @@ -1112,14 +1114,14 @@ } }, "node_modules/@babel/plugin-transform-for-of": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-for-of/-/plugin-transform-for-of-7.29.7.tgz", - "integrity": "sha512-zeSIHh0+E1Um1WJRXCFlHQYu2ieJNdivLLjlBEp+dIBu3S51n+SZZmIXjxnItw6pz56Cn+KvK68BIBVsxq2JiQ==", + "version": "7.29.13", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-for-of/-/plugin-transform-for-of-7.29.13.tgz", + "integrity": "sha512-dFjiIw+xBYpgLhYDc1QFQOZmMX44se0YCmXUjPsm9SQEj9HaCJAjvVnK6/yK9iE4E1LaKU5fIAKVJPZWCbKwXw==", "dev": true, "license": "MIT", "dependencies": { "@babel/helper-plugin-utils": "^7.29.7", - "@babel/helper-skip-transparent-expression-wrappers": "^7.29.7" + "@babel/helper-skip-transparent-expression-wrappers": "^7.29.13" }, "engines": { "node": ">=6.9.0" @@ -1211,13 +1213,13 @@ } }, "node_modules/@babel/plugin-transform-modules-amd": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-amd/-/plugin-transform-modules-amd-7.29.7.tgz", - "integrity": "sha512-fxtQoH3m5ywUSIfaH0FGCzWu4McsYon5bD3K4XnskC7f+OyQMj7rsOMi4NvvmJ83WwBAg4UCe+ov4VZlqEvyew==", + "version": "7.29.14", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-amd/-/plugin-transform-modules-amd-7.29.14.tgz", + "integrity": "sha512-n0CzmQX3BoyPq3p3+udWNd99Yag9NJPKA1d/2SA5wLZS2Rrep8BSIP6uXfwz3ydJYL2ycXIMsuew2mtSYacG1A==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-module-transforms": "^7.29.7", + "@babel/helper-module-transforms": "^7.29.14", "@babel/helper-plugin-utils": "^7.29.7" }, "engines": { @@ -1228,13 +1230,13 @@ } }, "node_modules/@babel/plugin-transform-modules-commonjs": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.29.7.tgz", - "integrity": "sha512-j0vCldybPC5b5dwCQOJ21uKtHzt7hxLygJTg9eF1ScfaikEDNfzn94XoW5Fi+seBR0nCyL23xaBFFkq7dTM8XQ==", + "version": "7.29.14", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.29.14.tgz", + "integrity": "sha512-mbv2yy5dqP6e3DbusCx+5AypXkFbyJD/JhG4/XhA+BIADOw5o7W+X0ewSp/h3w7gRL3oR5yny2/K8ljiydj4uA==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-module-transforms": "^7.29.7", + "@babel/helper-module-transforms": "^7.29.14", "@babel/helper-plugin-utils": "^7.29.7" }, "engines": { @@ -1264,13 +1266,13 @@ } }, "node_modules/@babel/plugin-transform-modules-umd": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-umd/-/plugin-transform-modules-umd-7.29.7.tgz", - "integrity": "sha512-B4UkaTK3QpgCwJnrxKfMPKdo92CN7OKXAlpAAnM3UPu0Q0lCCk57ylA9AJbRy2v8dDKOPAAWcoR6CMyeoHwRCA==", + "version": "7.29.14", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-umd/-/plugin-transform-modules-umd-7.29.14.tgz", + "integrity": "sha512-R9DargOyEaXhrsZNsUTof3RUxZupSpSmwQ58emYbmdUa/aMrZE/mLpeEZjze4RnijUyivyjJnLa/hbVEB7sy3w==", "dev": true, "license": "MIT", "dependencies": { - "@babel/helper-module-transforms": "^7.29.7", + "@babel/helper-module-transforms": "^7.29.14", "@babel/helper-plugin-utils": "^7.29.7" }, "engines": { @@ -1553,9 +1555,9 @@ } }, "node_modules/@babel/plugin-transform-runtime/node_modules/semver": { - "version": "6.3.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", - "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "version": "6.3.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.2.tgz", + "integrity": "sha512-GYrCADwpu6yV5OAvchkQ27Z5wwMxWAEMg5NNWjyHh/5DboFFqbdbvYNIvZouQpxXyeMPoTOh0vdPYKlf0ZswdQ==", "dev": true, "license": "ISC", "bin": { @@ -1579,9 +1581,9 @@ } }, "node_modules/@babel/plugin-transform-spread": { - "version": "7.29.8", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-spread/-/plugin-transform-spread-7.29.8.tgz", - "integrity": "sha512-4S9ksMGVWUshvgK0mKfvZky7leuG5/uoFVwMpAomJ8bMoDJiNHRVmc1EglwW/CmGVSqqWpEbXm9FmbRit22qoA==", + "version": "7.29.11", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-spread/-/plugin-transform-spread-7.29.11.tgz", + "integrity": "sha512-5xWGhfuMgbOfIjsk/I2c4uMnoqRwQdKYi4QjvybQrcEVE0G9/p3qmIkp2Sxe8YF8DGNNVs5whfwNqIM5684XoQ==", "dev": true, "license": "MIT", "dependencies": { @@ -1731,20 +1733,20 @@ } }, "node_modules/@babel/preset-env": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.29.7.tgz", - "integrity": "sha512-GYzX36n1nsciIb0uyH0GHwxwtNwPQIcpxSeiVLDtG/B7jB5xXgchnmL1f/jCX5o+pwnaDBtO60ONSJhEBJfxYA==", + "version": "7.29.14", + "resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.29.14.tgz", + "integrity": "sha512-Vigj5vlTvQVUUzw5geGRE7SLQ3wEDHWP00PMxmM80eWNUfLPCrvaKttN+bqqu6ev4g+GJ24ILel4stUN+DPAUw==", "dev": true, "license": "MIT", "dependencies": { "@babel/compat-data": "^7.29.7", - "@babel/helper-compilation-targets": "^7.29.7", + "@babel/helper-compilation-targets": "^7.29.13", "@babel/helper-plugin-utils": "^7.29.7", "@babel/helper-validator-option": "^7.29.7", "@babel/plugin-bugfix-firefox-class-in-computed-class-key": "^7.29.7", "@babel/plugin-bugfix-safari-class-field-initializer-scope": "^7.29.7", "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression": "^7.29.7", - "@babel/plugin-bugfix-safari-rest-destructuring-rhs-array": "^7.29.7", + "@babel/plugin-bugfix-safari-rest-destructuring-rhs-array": "^7.29.13", "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining": "^7.29.7", "@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly": "^7.29.7", "@babel/plugin-proposal-private-property-in-object": "7.21.0-placeholder-for-preset-env.2", @@ -1755,12 +1757,12 @@ "@babel/plugin-transform-async-generator-functions": "^7.29.7", "@babel/plugin-transform-async-to-generator": "^7.29.7", "@babel/plugin-transform-block-scoped-functions": "^7.29.7", - "@babel/plugin-transform-block-scoping": "^7.29.7", + "@babel/plugin-transform-block-scoping": "^7.29.13", "@babel/plugin-transform-class-properties": "^7.29.7", - "@babel/plugin-transform-class-static-block": "^7.29.7", - "@babel/plugin-transform-classes": "^7.29.7", + "@babel/plugin-transform-class-static-block": "^7.29.14", + "@babel/plugin-transform-classes": "^7.29.11", "@babel/plugin-transform-computed-properties": "^7.29.7", - "@babel/plugin-transform-destructuring": "^7.29.7", + "@babel/plugin-transform-destructuring": "^7.29.13", "@babel/plugin-transform-dotall-regex": "^7.29.7", "@babel/plugin-transform-duplicate-keys": "^7.29.7", "@babel/plugin-transform-duplicate-named-capturing-groups-regex": "^7.29.7", @@ -1768,16 +1770,16 @@ "@babel/plugin-transform-explicit-resource-management": "^7.29.7", "@babel/plugin-transform-exponentiation-operator": "^7.29.7", "@babel/plugin-transform-export-namespace-from": "^7.29.7", - "@babel/plugin-transform-for-of": "^7.29.7", + "@babel/plugin-transform-for-of": "^7.29.13", "@babel/plugin-transform-function-name": "^7.29.7", "@babel/plugin-transform-json-strings": "^7.29.7", "@babel/plugin-transform-literals": "^7.29.7", "@babel/plugin-transform-logical-assignment-operators": "^7.29.7", "@babel/plugin-transform-member-expression-literals": "^7.29.7", - "@babel/plugin-transform-modules-amd": "^7.29.7", - "@babel/plugin-transform-modules-commonjs": "^7.29.7", - "@babel/plugin-transform-modules-systemjs": "^7.29.7", - "@babel/plugin-transform-modules-umd": "^7.29.7", + "@babel/plugin-transform-modules-amd": "^7.29.14", + "@babel/plugin-transform-modules-commonjs": "^7.29.14", + "@babel/plugin-transform-modules-systemjs": "^7.29.8", + "@babel/plugin-transform-modules-umd": "^7.29.14", "@babel/plugin-transform-named-capturing-groups-regex": "^7.29.7", "@babel/plugin-transform-new-target": "^7.29.7", "@babel/plugin-transform-nullish-coalescing-operator": "^7.29.7", @@ -1790,11 +1792,11 @@ "@babel/plugin-transform-private-methods": "^7.29.7", "@babel/plugin-transform-private-property-in-object": "^7.29.7", "@babel/plugin-transform-property-literals": "^7.29.7", - "@babel/plugin-transform-regenerator": "^7.29.7", + "@babel/plugin-transform-regenerator": "^7.29.8", "@babel/plugin-transform-regexp-modifiers": "^7.29.7", "@babel/plugin-transform-reserved-words": "^7.29.7", "@babel/plugin-transform-shorthand-properties": "^7.29.7", - "@babel/plugin-transform-spread": "^7.29.7", + "@babel/plugin-transform-spread": "^7.29.11", "@babel/plugin-transform-sticky-regex": "^7.29.7", "@babel/plugin-transform-template-literals": "^7.29.7", "@babel/plugin-transform-typeof-symbol": "^7.29.7", @@ -1831,9 +1833,9 @@ } }, "node_modules/@babel/preset-env/node_modules/semver": { - "version": "6.3.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", - "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "version": "6.3.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.2.tgz", + "integrity": "sha512-GYrCADwpu6yV5OAvchkQ27Z5wwMxWAEMg5NNWjyHh/5DboFFqbdbvYNIvZouQpxXyeMPoTOh0vdPYKlf0ZswdQ==", "dev": true, "license": "ISC", "bin": { @@ -1876,9 +1878,9 @@ } }, "node_modules/@babel/runtime": { - "version": "7.29.7", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.29.7.tgz", - "integrity": "sha512-Nq8OhGWiZIZGV6hLHoyAKLLcJihP/xFeBMGJoUrxTX2psI8dCifzLhZISFb+VWS3wFMRDmCGw5R+dOySCqPLhw==", + "version": "7.29.14", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.29.14.tgz", + "integrity": "sha512-Y5tqevQaUAZhhj82BpYMNC1ssvLQTVAfwKdm8iy8qwmhvC2/CpcAu8OC+QEtjM7pMk7knx83u1Qj8gzkicyelw==", "license": "MIT", "engines": { "node": ">=6.9.0" @@ -1900,18 +1902,18 @@ } }, "node_modules/@babel/traverse": { - "version": "7.29.8", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.29.8.tgz", - "integrity": "sha512-I5z7H3bf/41ktsNVLtpN0wAa336HkqIHQ5BuPLEhTkt1jVSyZpeNKIzTgEWmlxjdg81R0IgUCcaE+Ok3NvrfZg==", + "version": "7.29.14", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.29.14.tgz", + "integrity": "sha512-RAdQJrBgmIH1FWvN0X+1hoDxzMzlP4cv/1Zi4dn4tG1H0cTb+rw7CzUxQJhp1f4ANd8j5vH3fy8BAWFGkBDEsA==", "dev": true, "license": "MIT", "dependencies": { "@babel/code-frame": "^7.29.7", - "@babel/generator": "^7.29.8", + "@babel/generator": "^7.29.14", "@babel/helper-globals": "^7.29.7", - "@babel/parser": "^7.29.8", + "@babel/parser": "^7.29.14", "@babel/template": "^7.29.7", - "@babel/types": "^7.29.8", + "@babel/types": "^7.29.14", "debug": "^4.3.1" }, "engines": { @@ -1919,13 +1921,13 @@ } }, "node_modules/@babel/types": { - "version": "7.29.8", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.8.tgz", - "integrity": "sha512-Vj1jF3cPfxg7OAfoI7QnVKLoILlm2JF9pnVHrX8qx7AHMiYWT+NDAA7jChlNgRS4WTLc/fD1lXLmPixluj+3Gg==", + "version": "7.29.14", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.14.tgz", + "integrity": "sha512-UjI/dKmwJwT9pOszJitq2G6EObZPnsZUfdCr92z2TlF3EZK9J3EdfOKUrCzHl6wFthbzwhzl1Soc/UIwxRiq6w==", "devOptional": true, "license": "MIT", "dependencies": { - "@babel/helper-string-parser": "^7.29.7", + "@babel/helper-string-parser": "^7.29.14", "@babel/helper-validator-identifier": "^7.29.7" }, "engines": { @@ -1943,22 +1945,22 @@ } }, "node_modules/@bramus/specificity": { - "version": "2.4.2", - "resolved": "https://registry.npmjs.org/@bramus/specificity/-/specificity-2.4.2.tgz", - "integrity": "sha512-ctxtJ/eA+t+6q2++vj5j7FYX3nRu311q1wfYH3xjlLOsczhlhxAg2FWNUXhpGvAw3BWo1xBcvOV6/YLc2r5FJw==", + "version": "2.4.3", + "resolved": "https://registry.npmjs.org/@bramus/specificity/-/specificity-2.4.3.tgz", + "integrity": "sha512-0GEz8qJWokkUVYQYRukmkSHIFNoBH8QTreeHrAFbvz1XFYc3Y+puhMs8PQ5x8GNugiC2l5jvDBXKLbBIByeSBw==", "devOptional": true, "license": "MIT", "dependencies": { - "css-tree": "^3.0.0" + "css-tree": "^3.2.1" }, "bin": { "specificity": "bin/cli.js" } }, "node_modules/@codemirror/autocomplete": { - "version": "6.20.3", - "resolved": "https://registry.npmjs.org/@codemirror/autocomplete/-/autocomplete-6.20.3.tgz", - "integrity": "sha512-tlosUqb+3BbxCxZdu4tKeRghPFC+QM7q4X5YhKV2eCmPG+1r2F3f4AaSz5sCrFqUtX4Jh20VFTKecl16MgiV9g==", + "version": "6.20.4", + "resolved": "https://registry.npmjs.org/@codemirror/autocomplete/-/autocomplete-6.20.4.tgz", + "integrity": "sha512-yF8RhOf2SXlg00+qtupzLhrglcas61boqaONiNcbPIebHCpJocpqTBA6dyrtUrQO47hqyTdeob/3XnYilT7TaQ==", "license": "MIT", "dependencies": { "@codemirror/language": "^6.0.0", @@ -2064,12 +2066,13 @@ } }, "node_modules/@codemirror/language": { - "version": "6.12.4", - "resolved": "https://registry.npmjs.org/@codemirror/language/-/language-6.12.4.tgz", - "integrity": "sha512-1q4PaT+o6PbgpkJt4Q8Fv5XJxTy4FUZ4MWETtyiDw3J0Pyr9E2vqcKL+k9wcvjNTIsauxvE7OfmWj3FRPHQ76A==", + "version": "6.13.1", + "resolved": "https://registry.npmjs.org/@codemirror/language/-/language-6.13.1.tgz", + "integrity": "sha512-zfvU2r3TyylQLMj/te+5CnQ0rSqZi8B1oTCBbQkagcLW4Xc6imab6qN+pEJhsuNOLaJqiRyBXp9UhWA1DhVvDw==", "license": "MIT", "dependencies": { "@codemirror/state": "^6.0.0", + "@codemirror/streamparser": "^6.0.0", "@codemirror/view": "^6.23.0", "@lezer/common": "^1.5.0", "@lezer/highlight": "^1.0.0", @@ -2078,18 +2081,18 @@ } }, "node_modules/@codemirror/legacy-modes": { - "version": "6.5.4", - "resolved": "https://registry.npmjs.org/@codemirror/legacy-modes/-/legacy-modes-6.5.4.tgz", - "integrity": "sha512-/cZr6qZyl08iYNLGsJ862CXXNI51LryRFRE40ejgoIjXZz0C1rGkD3/Ek5jM/8w1ceRjqtt4qx/KLMh4zBTgew==", + "version": "6.5.5", + "resolved": "https://registry.npmjs.org/@codemirror/legacy-modes/-/legacy-modes-6.5.5.tgz", + "integrity": "sha512-9ltT214oMb3Y1w5eAZMSigzrjzZnMI2Wa3Feq73rU/i4C56MkwrpfswfQYOr28C5pXr6dWwspNTMyeHXlzWMxg==", "license": "MIT", "dependencies": { - "@codemirror/language": "^6.0.0" + "@codemirror/streamparser": "^6.0.0" } }, "node_modules/@codemirror/lint": { - "version": "6.9.7", - "resolved": "https://registry.npmjs.org/@codemirror/lint/-/lint-6.9.7.tgz", - "integrity": "sha512-28/+iWLYxKxsvGYhSYL7zaCZqLz5+FFFDq9tVsvGv9kv8RY4fFAchJ5WX9M3YrrRlTIsECjsXPqeNgnSmNP2dg==", + "version": "6.9.8", + "resolved": "https://registry.npmjs.org/@codemirror/lint/-/lint-6.9.8.tgz", + "integrity": "sha512-qNvtcE73xUto/D1RvtgSRI4A1Hg8ekxlvtZpjHpdpisLBnhyu82EUEJMEgaxkjuQCA8vqnrylENWKOsEDCOHcw==", "license": "MIT", "dependencies": { "@codemirror/state": "^6.0.0", @@ -2106,10 +2109,16 @@ "@marijn/find-cluster-break": "^1.0.0" } }, + "node_modules/@codemirror/streamparser": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/@codemirror/streamparser/-/streamparser-6.0.0.tgz", + "integrity": "sha512-JTFPF6xrfjt0mnfGPgzcLiMwYmvIyNaoizp8BYzv8FE8KrT6GBGDZ190rtt+O7Wke3gG/MFHyiY9YGNeimof4w==", + "license": "MIT" + }, "node_modules/@codemirror/view": { - "version": "6.43.13", - "resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.43.13.tgz", - "integrity": "sha512-sihaFrUzAsYBQsL9J2t69y8nfMQGwcYmggAZsk+kjPbjYZMyuf2hU8tUNTZ+P+isb6XRr8JE22TZlJxBoVdH1A==", + "version": "6.43.15", + "resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.43.15.tgz", + "integrity": "sha512-HHsfpqFeHyXLs983pSRe38Xajs0vFWZQ2BuX0m7Ki8w3jZ5iD8cuR3lBz2/5/X53Dhf32SBHKh6rtSTB6tKeGw==", "license": "MIT", "dependencies": { "@codemirror/state": "^6.7.0", @@ -2119,9 +2128,9 @@ } }, "node_modules/@csstools/cascade-layer-name-parser": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@csstools/cascade-layer-name-parser/-/cascade-layer-name-parser-3.0.1.tgz", - "integrity": "sha512-EqmSJE8CcNoGXcgpiOD12PPMeuJZwiGMX69HPoam+GzltcjZjr6THQ0S+8a0NtQuefJtILzoDyQj+fp7+Qiorg==", + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@csstools/cascade-layer-name-parser/-/cascade-layer-name-parser-3.0.2.tgz", + "integrity": "sha512-B731RJ9pfJj3D5GJPp8ccsaaHMdwBmlOb4QWAYQUFpmMxonxJvNeeIoo0E89CjMJaKDvQXy9MKpSXY/i7XgeFA==", "dev": true, "funding": [ { @@ -2138,7 +2147,7 @@ "node": ">=20.19.0" }, "peerDependencies": { - "@csstools/css-parser-algorithms": "^4.0.1", + "@csstools/css-parser-algorithms": "^4.0.2", "@csstools/css-tokenizer": "^4.0.2" } }, @@ -2163,9 +2172,9 @@ } }, "node_modules/@csstools/css-calc": { - "version": "3.4.1", - "resolved": "https://registry.npmjs.org/@csstools/css-calc/-/css-calc-3.4.1.tgz", - "integrity": "sha512-EtC7SoN1j6J4E4DCwg5QgbO5TGxgxIA1RXqe+W+qUM+BUcezx9wT+/tiQ/WO2yCX4i5X+Cuf9ciJ22aP4UEwWw==", + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/@csstools/css-calc/-/css-calc-3.4.3.tgz", + "integrity": "sha512-iex20d8CHVkyvg6B7UKV7uHnI2Bqo9g+EFfT9E0y+GvTvhZ/DwONJ+9aKb1dlqm0ZiGsL5RXjp0fCoJYnkeDjA==", "devOptional": true, "funding": [ { @@ -2182,14 +2191,14 @@ "node": ">=20.19.0" }, "peerDependencies": { - "@csstools/css-parser-algorithms": "^4.0.1", + "@csstools/css-parser-algorithms": "^4.0.2", "@csstools/css-tokenizer": "^4.0.2" } }, "node_modules/@csstools/css-color-parser": { - "version": "4.2.4", - "resolved": "https://registry.npmjs.org/@csstools/css-color-parser/-/css-color-parser-4.2.4.tgz", - "integrity": "sha512-DyefytAZ735mX4Dq/WcDAXFtXhaEFvme0ZS9tVEBAc2whxUthXr0R0L2rmEPm59SrMBkGrFzQviBXMs/UtnABQ==", + "version": "4.2.7", + "resolved": "https://registry.npmjs.org/@csstools/css-color-parser/-/css-color-parser-4.2.7.tgz", + "integrity": "sha512-zgm9yjQz5iJB4VL8RyVwd71TWB8Q89FSxt/NzXoWqPSkEBOVtn9L6vAPtSc9hpKfB0Awo/AL2VKFHjYetBLFHQ==", "devOptional": true, "funding": [ { @@ -2204,20 +2213,20 @@ "license": "MIT", "dependencies": { "@csstools/color-helpers": "^6.1.2", - "@csstools/css-calc": "^3.4.1" + "@csstools/css-calc": "^3.4.3" }, "engines": { "node": ">=20.19.0" }, "peerDependencies": { - "@csstools/css-parser-algorithms": "^4.0.1", + "@csstools/css-parser-algorithms": "^4.0.2", "@csstools/css-tokenizer": "^4.0.2" } }, "node_modules/@csstools/css-parser-algorithms": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/@csstools/css-parser-algorithms/-/css-parser-algorithms-4.0.1.tgz", - "integrity": "sha512-ShL8BqPfbKJrJiKFH0xBbN0i7Nrh9HXYRuF+pzyj93R/BL2YAsUxJeqANErzqM+0JGl7vjHp+3OIgd/DL69YIA==", + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@csstools/css-parser-algorithms/-/css-parser-algorithms-4.0.2.tgz", + "integrity": "sha512-40cSKyMvK+tq4qz6Awrlye2WGuOKt3FwPgtGg6KTfbHOWNw+Rk1rzbAtZnZ6IBhsY491HLRnDXwoyBAijmmILA==", "devOptional": true, "funding": [ { @@ -2238,9 +2247,9 @@ } }, "node_modules/@csstools/css-syntax-patches-for-csstree": { - "version": "1.1.14", - "resolved": "https://registry.npmjs.org/@csstools/css-syntax-patches-for-csstree/-/css-syntax-patches-for-csstree-1.1.14.tgz", - "integrity": "sha512-HpbVXyrofRXpHpgkNIjU/3EWR4WJvOkO3emNK/L6X/mTJU7bGUI3AkkpoTNXznQLp0KRjLHELTGeKI5dIkI9JQ==", + "version": "1.1.16", + "resolved": "https://registry.npmjs.org/@csstools/css-syntax-patches-for-csstree/-/css-syntax-patches-for-csstree-1.1.16.tgz", + "integrity": "sha512-LsDbJPP/B8cPasUJyTA5S99F7C4G93ngW8hUluXz8CFeOaaRnBPtBiIlvgcPYU0HmHNz8CXg+1vwFrIB4F6Dgw==", "devOptional": true, "funding": [ { @@ -2283,9 +2292,9 @@ } }, "node_modules/@csstools/media-query-list-parser": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/@csstools/media-query-list-parser/-/media-query-list-parser-5.0.1.tgz", - "integrity": "sha512-DR5NpEOOxDOhmMWPJlhYAV9gTmV4XpfYjtE+aXSCurkxS65KzNogI4wqzRIoujieQcmFkeRtK1nRIF8ImUZTDg==", + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/@csstools/media-query-list-parser/-/media-query-list-parser-5.0.2.tgz", + "integrity": "sha512-qx19O8AbbLLbDSAcI6YOby/Vq8rV51psgIvlF5OZT/L8fQJDCyQifL6k+kYU4a8ySpzJ4RBzZkIs530bAn8y4Q==", "dev": true, "funding": [ { @@ -2302,7 +2311,7 @@ "node": ">=20.19.0" }, "peerDependencies": { - "@csstools/css-parser-algorithms": "^4.0.1", + "@csstools/css-parser-algorithms": "^4.0.2", "@csstools/css-tokenizer": "^4.0.2" } }, @@ -2329,14 +2338,56 @@ } }, "node_modules/@digitalbazaar/http-client/node_modules/undici": { - "version": "6.29.0", - "resolved": "https://registry.npmjs.org/undici/-/undici-6.29.0.tgz", - "integrity": "sha512-R+RODBqp6i2pPflGdq+xIOUkl+RNfGgHwoinecKu/JCuf2uO06cOKoDbI2P7Dn6KcswdKwrczbU6IYJ6K8X+wg==", + "version": "6.29.1", + "resolved": "https://registry.npmjs.org/undici/-/undici-6.29.1.tgz", + "integrity": "sha512-EvRlUt/QqAEvXdQeRMYUfwOQsfzpDztykrG2owGEE/rBOBoYv9uF39ZzsNDh4lTFHhTr2XOZjKkYgueD12ZmGA==", "license": "MIT", "engines": { "node": ">=18.17" } }, + "node_modules/@dokieli/web-access-control": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@dokieli/web-access-control/-/web-access-control-1.1.0.tgz", + "integrity": "sha512-LId2cNz0pKafc6dwohaX6j+mr886uEV2o8L0VrAWUDxU0LPN4+8Yc8Yx3D94zrsRSJuBWRtQzSjgtEqhYg5y/w==", + "license": "Apache-2.0", + "dependencies": { + "@rdfjs/data-model": "^2.1.1", + "@rdfjs/types": "^2.0.1", + "n3": "^2.2.0" + } + }, + "node_modules/@emnapi/core": { + "version": "2.0.0-beta.2", + "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-2.0.0-beta.2.tgz", + "integrity": "sha512-MzCVoWtcg4Pm2B3je5mMvYMvj3MmBKw+fU7vbsJc9/iT8ip6/eYIHo/Dsm/mr+wsHB6SEyJDuxB09Yy6r/8+4A==", + "license": "MIT", + "optional": true, + "dependencies": { + "@emnapi/wasi-threads": "2.2.0", + "tslib": "^2.4.0" + } + }, + "node_modules/@emnapi/runtime": { + "version": "2.0.0-beta.2", + "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-2.0.0-beta.2.tgz", + "integrity": "sha512-JcrSPzPvZuNZvJqPTF9Fw25LbOJ8avzFVlaf2grmH4Cku0oGP47tRgqPZadcfj3YoZMHkFVnCYFbQM8I+i5QEw==", + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@emnapi/wasi-threads": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-2.2.0.tgz", + "integrity": "sha512-JP7OYH38Q7+pyTAe14raZHLQIK7BDKbdwji+Xi3pcd/6QkJYQH3SX4wu6EplGrGJWRepoNzedfm0G3B9Z4e9Rw==", + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, "node_modules/@emotion/is-prop-valid": { "version": "0.7.3", "resolved": "https://registry.npmjs.org/@emotion/is-prop-valid/-/is-prop-valid-0.7.3.tgz", @@ -2356,6 +2407,7 @@ "version": "4.10.1", "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.10.1.tgz", "integrity": "sha512-cuadcxVFE8sDK6iWJbs8Sn0av2Nrh2QSGQhVlBW9AaAHqHwjWsZHT8LJ4hFGPh7ASBV2deFdM7H/DPjulmh8rg==", + "dev": true, "license": "MIT", "dependencies": { "eslint-visitor-keys": "^3.4.3" @@ -2374,6 +2426,7 @@ "version": "3.4.3", "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "dev": true, "license": "Apache-2.0", "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -2383,9 +2436,10 @@ } }, "node_modules/@eslint-community/regexpp": { - "version": "4.12.2", - "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.12.2.tgz", - "integrity": "sha512-EriSTlt5OC9/7SXkRSCAhfSxxoSUgBm33OH+IkwbdpgoqsSsUg7y3uh+IICI/Qg4BBWr3U2i39RpmycbxMq4ew==", + "version": "4.12.3", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.12.3.tgz", + "integrity": "sha512-R76UKbvsqI68DJJVTVyqFKqU98CN4+B+acxNfEA2IFarSzP0SjtKf/3+fFiXzTyv5Fj3PxLkGHe2wnVWWMxobQ==", + "dev": true, "license": "MIT", "engines": { "node": "^12.0.0 || ^14.0.0 || >=16.0.0" @@ -2395,6 +2449,7 @@ "version": "0.21.2", "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.21.2.tgz", "integrity": "sha512-nJl2KGTlrf9GjLimgIru+V/mzgSK0ABCDQRvxw5BjURL7WfH5uoWmizbH7QB6MmnMBd8cIC9uceWnezL1VZWWw==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@eslint/object-schema": "^2.1.7", @@ -2409,12 +2464,14 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true, "license": "MIT" }, "node_modules/@eslint/config-array/node_modules/brace-expansion": { - "version": "1.1.21", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.21.tgz", - "integrity": "sha512-9zeA+KLZNNzglF2TPKRQEDyx6Yby7daAkuy8MiPzpXPsYDWi/DRM8jmwUDxokQjYqBpv5DgPiwD4h4ZZSy1Ujw==", + "version": "1.1.22", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.22.tgz", + "integrity": "sha512-CKLDTuSsN0+r1ThM0WkzzBI7dnPI6xEGfa/JnVYIK9JNBA1N1NyPwXVHor//NKD/y3sDxp764sZdLhFK7pH8XQ==", + "dev": true, "license": "MIT", "dependencies": { "balanced-match": "^1.0.0", @@ -2425,6 +2482,7 @@ "version": "3.1.5", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz", "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==", + "dev": true, "license": "ISC", "dependencies": { "brace-expansion": "^1.1.7" @@ -2437,6 +2495,7 @@ "version": "0.4.2", "resolved": "https://registry.npmjs.org/@eslint/config-helpers/-/config-helpers-0.4.2.tgz", "integrity": "sha512-gBrxN88gOIf3R7ja5K9slwNayVcZgK6SOUORm2uBzTeIEfeVaIhOpCtTox3P6R7o2jLFwLFTLnC7kU/RGcYEgw==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@eslint/core": "^0.17.0" @@ -2449,6 +2508,7 @@ "version": "0.17.0", "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.17.0.tgz", "integrity": "sha512-yL/sLrpmtDaFEiUj1osRP4TI2MDz1AddJL+jZ7KSqvBuliN4xqYY54IfdN8qD8Toa6g1iloph1fxQNkjOxrrpQ==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@types/json-schema": "^7.0.15" @@ -2461,6 +2521,7 @@ "version": "3.3.7", "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.3.7.tgz", "integrity": "sha512-F42g89Qd5oAWtp0k0nnSrjziAKza7w8SVT4mStc18LZMaRb4J1HQAHLCalEtDCxrTuksx7NU9qsmeLwpOfPqWw==", + "dev": true, "license": "MIT", "dependencies": { "ajv": "^6.14.0", @@ -2484,12 +2545,14 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true, "license": "MIT" }, "node_modules/@eslint/eslintrc/node_modules/brace-expansion": { - "version": "1.1.21", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.21.tgz", - "integrity": "sha512-9zeA+KLZNNzglF2TPKRQEDyx6Yby7daAkuy8MiPzpXPsYDWi/DRM8jmwUDxokQjYqBpv5DgPiwD4h4ZZSy1Ujw==", + "version": "1.1.22", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.22.tgz", + "integrity": "sha512-CKLDTuSsN0+r1ThM0WkzzBI7dnPI6xEGfa/JnVYIK9JNBA1N1NyPwXVHor//NKD/y3sDxp764sZdLhFK7pH8XQ==", + "dev": true, "license": "MIT", "dependencies": { "balanced-match": "^1.0.0", @@ -2500,6 +2563,7 @@ "version": "14.0.0", "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", + "dev": true, "license": "MIT", "engines": { "node": ">=18" @@ -2512,6 +2576,7 @@ "version": "3.1.5", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz", "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==", + "dev": true, "license": "ISC", "dependencies": { "brace-expansion": "^1.1.7" @@ -2524,6 +2589,7 @@ "version": "9.39.5", "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.39.5.tgz", "integrity": "sha512-QywQuszQh77pIXCsq998c8hbhSTI/azTty1Z6N53dmAudKHhy573j3yvRLsX2BSp8YpLtoCEG8E9DJe+8zUh4A==", + "dev": true, "license": "MIT", "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -2536,6 +2602,7 @@ "version": "2.1.7", "resolved": "https://registry.npmjs.org/@eslint/object-schema/-/object-schema-2.1.7.tgz", "integrity": "sha512-VtAOaymWVfZcmZbp6E2mympDIHvyjXs/12LqWYjVw6qjrfF+VK+fyG33kChz3nnK+SU5/NeHOqrTEHS8sXO3OA==", + "dev": true, "license": "Apache-2.0", "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -2545,6 +2612,7 @@ "version": "0.4.1", "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.4.1.tgz", "integrity": "sha512-43/qtrDUokr7LJqoF2c3+RInu/t4zfrpYdoSDfYyhg52rwLV6TnOvdG4fXm7IkSB3wErkcmJS9iEhjVtOSEjjA==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@eslint/core": "^0.17.0", @@ -2610,6 +2678,7 @@ "version": "0.19.2", "resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.2.tgz", "integrity": "sha512-UhXNm+CFMWcbChXywFwkmhqjs3PRCmcSa/hfBgLIb7oQ5HNb1wS0icWsGtSAUNgefHeI+eBrA8I1fxmbHsGdvA==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@humanfs/types": "^0.15.0" @@ -2622,6 +2691,7 @@ "version": "0.16.8", "resolved": "https://registry.npmjs.org/@humanfs/node/-/node-0.16.8.tgz", "integrity": "sha512-gE1eQNZ3R++kTzFUpdGlpmy8kDZD/MLyHqDwqjkVQI0JMdI1D51sy1H958PNXYkM2rAac7e5/CnIKZrHtPh3BQ==", + "dev": true, "license": "Apache-2.0", "dependencies": { "@humanfs/core": "^0.19.2", @@ -2636,6 +2706,7 @@ "version": "0.15.0", "resolved": "https://registry.npmjs.org/@humanfs/types/-/types-0.15.0.tgz", "integrity": "sha512-ZZ1w0aoQkwuUuC7Yf+7sdeaNfqQiiLcSRbfI08oAxqLtpXQr9AIVX7Ay7HLDuiLYAaFPu8oBYNq/QIi9URHJ3Q==", + "dev": true, "license": "Apache-2.0", "engines": { "node": ">=18.18.0" @@ -2656,6 +2727,7 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", + "dev": true, "license": "Apache-2.0", "engines": { "node": ">=12.22" @@ -2669,6 +2741,7 @@ "version": "0.4.3", "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.4.3.tgz", "integrity": "sha512-bV0Tgo9K4hfPCek+aMAn81RppFKv2ySDQeMoSZuvTASywNTnVJCArCZE2FWqpvIatKu7VMRLWlR1EazvVhDyhQ==", + "dev": true, "license": "Apache-2.0", "engines": { "node": ">=18.18" @@ -2722,6 +2795,13 @@ "url": "https://github.com/sponsors/antfu" } }, + "node_modules/@isaacs/nonrecursive-glob-match": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@isaacs/nonrecursive-glob-match/-/nonrecursive-glob-match-1.1.0.tgz", + "integrity": "sha512-GPm/Dbvk5RLmhRnxXIa7nTpK0xtl4E0wj0MslsuNiJ1FIROU+2+9lgUC/dgF7Ey4QCWhfEsgxilMRMCdHPfDfw==", + "dev": true, + "license": "BlueOak-1.0.0" + }, "node_modules/@jridgewell/gen-mapping": { "version": "0.3.13", "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", @@ -2745,9 +2825,9 @@ } }, "node_modules/@jridgewell/resolve-uri": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", - "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.3.tgz", + "integrity": "sha512-lhTtjtoEArWBjismtfS761S9Hlyn+nIZqOZVYoZ1Xn82PMNMVnk+jj/NhC4fAXGTs7ydONcJiR5vyQBTMDu27g==", "devOptional": true, "license": "MIT", "engines": { @@ -2778,15 +2858,15 @@ "license": "MIT" }, "node_modules/@lezer/common": { - "version": "1.5.3", - "resolved": "https://registry.npmjs.org/@lezer/common/-/common-1.5.3.tgz", - "integrity": "sha512-H0iErY4e43LpXbYDyBci5W4v/RwTgGV3YzYOlJPiGZ8RY8w51kVE+xLn1tg3Z6UmSfyETvtsUK3r7YsgDQEI7Q==", + "version": "1.5.5", + "resolved": "https://registry.npmjs.org/@lezer/common/-/common-1.5.5.tgz", + "integrity": "sha512-Pw7PVCndruF1pb3ebCxpSVpkMHSDjwRCLcTRw+RizUKco5QbWylwq2g4lnG/RYN7yTTQDXE9F77MwtkAyphrjg==", "license": "MIT" }, "node_modules/@lezer/css": { - "version": "1.3.8", - "resolved": "https://registry.npmjs.org/@lezer/css/-/css-1.3.8.tgz", - "integrity": "sha512-EJn1zcL9qoDptief6ipWKZKLiOpXkxSe0+t8CH9oiMVcZlq7NBWrjCqnc/41EIjeo/ITj1gFFiATdTkaJDL+Og==", + "version": "1.3.9", + "resolved": "https://registry.npmjs.org/@lezer/css/-/css-1.3.9.tgz", + "integrity": "sha512-ZmzgvTOBdJWGIsY/ItAfN7UW8DV802oZG+jeG6E508SwEzz5YhuAajptpWPICvIyqYAD2+VjMdOS40GgGkyEOQ==", "license": "MIT", "dependencies": { "@lezer/common": "^1.2.0", @@ -2815,9 +2895,9 @@ } }, "node_modules/@lezer/javascript": { - "version": "1.5.5", - "resolved": "https://registry.npmjs.org/@lezer/javascript/-/javascript-1.5.5.tgz", - "integrity": "sha512-sWg4yX1J6XW67AaAynVt0iwF0M5c+np36TEu+P2ifAJ8haRYvHnWDV28r1jdwnJehWCwXECutAUy56K4RBZIyg==", + "version": "1.5.6", + "resolved": "https://registry.npmjs.org/@lezer/javascript/-/javascript-1.5.6.tgz", + "integrity": "sha512-sEvOqpl4vJQca0NugSQK02vQPbc5KrvoojnYGoqqFgFO0MtcYhwGiHKVEB+LuXYJnfyXo4QPA8ztbrEa4Fw5NA==", "license": "MIT", "dependencies": { "@lezer/common": "^1.2.0", @@ -2837,18 +2917,18 @@ } }, "node_modules/@lezer/lr": { - "version": "1.4.10", - "resolved": "https://registry.npmjs.org/@lezer/lr/-/lr-1.4.10.tgz", - "integrity": "sha512-rnCpTIBafOx4mRp43xOxDJbFipJm/c0cia/V5TiGlhmMa+wsSdoGmUN3w5Bqrks/09Q/D4tNAmWaT8p6NRi77A==", + "version": "1.4.12", + "resolved": "https://registry.npmjs.org/@lezer/lr/-/lr-1.4.12.tgz", + "integrity": "sha512-On9HU4oMMiHPMkQDgoTnGahjgG5n/MkN38CgG77sMraKLL+3JBbeQNi1FcCXV9QRqwF9/BUXP3caHyJC1fBOTQ==", "license": "MIT", "dependencies": { "@lezer/common": "^1.0.0" } }, "node_modules/@lezer/markdown": { - "version": "1.7.2", - "resolved": "https://registry.npmjs.org/@lezer/markdown/-/markdown-1.7.2.tgz", - "integrity": "sha512-iTkYvoVcKt3WkeL7qUDyXHONZEwLio4wj8KTNi2dnjQEXBZKMV63BpQrPqfsM+OkvuRbiSTAcycYAsQzLhRNoQ==", + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/@lezer/markdown/-/markdown-1.8.1.tgz", + "integrity": "sha512-M5YmEcKWO4mJ45Y1hECwqyu8cLv25EiXOK554PVOvDOWOP0olwelHHQUWr9sjF+d1bENVhy0nfJ8E57XZUTiXg==", "license": "MIT", "dependencies": { "@lezer/common": "^1.5.0", @@ -2996,6 +3076,27 @@ "integrity": "sha512-Wy0V7+SGUjnF9/TkiM1hKVDPj7jKXduPNboMVtHTA8dySMURWqfg/JZ9E2Sq8JgSJmkl7k7Qe9FLeMSrSraWmQ==", "license": "MIT" }, + "node_modules/@napi-rs/wasm-runtime": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.2.6.tgz", + "integrity": "sha512-mRyDmEw9/fCDXCGfL1sbgIw/GUK0PVxRW4YwgPN61F3LQ+fSyoBFarJVzgGyhF6kRzEQZ0FejDqm4WLXSeqQmw==", + "license": "MIT", + "optional": true, + "dependencies": { + "@tybys/wasm-util": "^0.10.3" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=23.5.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/Brooooooklyn" + }, + "peerDependencies": { + "@emnapi/core": "^1.7.1 || 2.0.0-beta.2", + "@emnapi/runtime": "^1.7.1 || 2.0.0-beta.2" + } + }, "node_modules/@noble/curves": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-2.4.0.tgz", @@ -3024,10 +3125,12 @@ } }, "node_modules/@oxc-project/types": { - "version": "0.151.0", - "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.151.0.tgz", - "integrity": "sha512-J1yXrIlNDZVzE3ada310xeAw7nH8yCAyLPuUIsjKatFPmfn5bS1oW+cM+QsGOtVWd5nhSpbwZWx/rue+r5Z+PA==", + "version": "0.158.0", + "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.158.0.tgz", + "integrity": "sha512-xZ66qA4WmLbTLlxH3mqMd8f9UKbaOzOT0ATwFf4DH/14pMgpUrtqtjyYzOQmgfl2a0iRAAMbQ9G1th/67jRzGw==", + "dev": true, "license": "MIT", + "peer": true, "funding": { "url": "https://github.com/sponsors/oxc-project" } @@ -3065,6 +3168,15 @@ "url": "https://github.com/inikulin/parse5?sponsor=1" } }, + "node_modules/@rdfjs/data-model": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@rdfjs/data-model/-/data-model-2.1.2.tgz", + "integrity": "sha512-yoSVlyCltqbaCTse3uSdf5Vo3q4UskcTm+3klaUQTwOq7Z5aCZLtLPZatXTPzr+S0WEcjTZvD++A+r3QmgamsA==", + "license": "MIT", + "bin": { + "rdfjs-data-model-test": "bin/test.js" + } + }, "node_modules/@rdfjs/types": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/@rdfjs/types/-/types-2.0.1.tgz", @@ -3075,108 +3187,121 @@ } }, "node_modules/@rolldown/binding-android-arm-eabi": { - "version": "1.2.11", - "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm-eabi/-/binding-android-arm-eabi-1.2.11.tgz", - "integrity": "sha512-A5kXfGKvKWWZE0TtPrfsvT+q4Y5d1QG8gGUzpYjGydM+fARM9MuX90PrXYXe0XbsDVgyxxNzHo6giCj90bsFNw==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm-eabi/-/binding-android-arm-eabi-1.3.2.tgz", + "integrity": "sha512-kqR2xcygEx3WwDY69LsKeyf7SVmx4yzMtKZRknyaHieVJdRvvnAM97L0Gq6tUFc9T2YXcW/Ghij2+Um6He0LTw==", "cpu": [ "arm" ], + "dev": true, "license": "MIT", "optional": true, "os": [ "android" ], + "peer": true, "engines": { "node": "^20.19.0 || >=22.12.0" } }, "node_modules/@rolldown/binding-android-arm64": { - "version": "1.2.11", - "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.2.11.tgz", - "integrity": "sha512-z6cTycz+iJ4PVkuL4HHW4DfTfoeU/2nqYYuSOrTmH7yHK5Y0LCOnA03V4ZNxavyVaU1oOqUgIg2klN/s+USGOA==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.3.2.tgz", + "integrity": "sha512-gXM4GAAvvIZA7qUuSCQS+Zz91H2fagKa5MNppUdjzysJ8LXMWm9D/gQj4nfOKo6okquDQ5pkjsuo2SUMXNW0Rw==", "cpu": [ "arm64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ "android" ], + "peer": true, "engines": { "node": "^20.19.0 || >=22.12.0" } }, "node_modules/@rolldown/binding-darwin-arm64": { - "version": "1.2.11", - "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.2.11.tgz", - "integrity": "sha512-jShvqNtP6vDC6/A5JOAzbVV+DkgHqhl/ScVCJEbt+TUY6QYz7YnXcrg3sLtFBniro0f/Ld50ZwCWA6f7KYD1nQ==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.3.2.tgz", + "integrity": "sha512-OBs5hp3W+LwMEUmDMMMnu08ncG0t6DDgnFU+6TAucKtAfNgerYLZSr2jtREKb/JuPQ1J7bJnWIgKKkxvjuAw1g==", "cpu": [ "arm64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ "darwin" ], + "peer": true, "engines": { "node": "^20.19.0 || >=22.12.0" } }, "node_modules/@rolldown/binding-darwin-x64": { - "version": "1.2.11", - "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.2.11.tgz", - "integrity": "sha512-f2i2xiNWq1Z1l2++q2fuhZRdLAT3aqxD6vRNm1RAxpUoBcdqNB3C0s1Bt+K+PbEx2F5F4gQp6hqKkphCY/xF9w==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.3.2.tgz", + "integrity": "sha512-X0VGYd4v/gdjfa/IP6uHuMhofPoUDYvK/byk3bC0jQ1pKKgt6RZ4B4puMqP0AHkjmIHAsxA471mM6AxZ39IaTA==", "cpu": [ "x64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ "darwin" ], + "peer": true, "engines": { "node": "^20.19.0 || >=22.12.0" } }, "node_modules/@rolldown/binding-freebsd-x64": { - "version": "1.2.11", - "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.2.11.tgz", - "integrity": "sha512-4Ir5FSOKIAMr4r0kExpt1s3bMgzJU3rA45AYOHtQpls0oNeqcYBKrWMlckrYH4KCfGLfkfn1tN1dmZPMVsdXow==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.3.2.tgz", + "integrity": "sha512-mr04K4cp9J/fj9fknrX8e4QvI/V48Sp+4v64PoLwhoirIH8b8L8EBrF/0bTjV1It2IL91hoNG13GblnWLglkxA==", "cpu": [ "x64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ "freebsd" ], + "peer": true, "engines": { "node": "^20.19.0 || >=22.12.0" } }, "node_modules/@rolldown/binding-linux-arm-gnueabihf": { - "version": "1.2.11", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.2.11.tgz", - "integrity": "sha512-/gnRDM+39BROzAN/k1OZjDPnDMcZxB/0EUxKjONO5yVkNEvlsoMDrxGNKgZi/ttFriS2gwlDNzB65pvNbFOXIQ==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.3.2.tgz", + "integrity": "sha512-VgWy02HU9Tiy6tU8U+kF3Fd4TQwTNdIBvs2MlgViP1ksMtAnQQTIPAj0ZsJzIQXKIOugqQSpqxQgELJ3fkuL5w==", "cpu": [ "arm" ], + "dev": true, "license": "MIT", "optional": true, "os": [ "linux" ], + "peer": true, "engines": { "node": "^20.19.0 || >=22.12.0" } }, "node_modules/@rolldown/binding-linux-arm64-gnu": { - "version": "1.2.11", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.2.11.tgz", - "integrity": "sha512-PFaK8HwvAHbaKbBcDNQihjMKYvFnA5hiENx/l5tphTDz1E0WFp32l0A7aq7lyUwGsRw/xSrNIy/gIK4thrSCrw==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.3.2.tgz", + "integrity": "sha512-0wloJFYqV844gv6boiERbHpErxbxHbmlgnMX5VxP1Ux+DLBqGrUOn0cIpBmCZEcTITes3QUelxya4u8c9ziQvQ==", "cpu": [ "arm64" ], + "dev": true, "libc": [ "glibc" ], @@ -3185,17 +3310,19 @@ "os": [ "linux" ], + "peer": true, "engines": { "node": "^20.19.0 || >=22.12.0" } }, "node_modules/@rolldown/binding-linux-arm64-musl": { - "version": "1.2.11", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.2.11.tgz", - "integrity": "sha512-AskzJUIKRLPxkruR1wLKewGbOw+EYfU/9lOrBFj4AFrEA8hPpKFnODWNu2WLaNs0QNkEb9QIJufmVZZIL/bJlg==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.3.2.tgz", + "integrity": "sha512-Kys8wgFQy8H8vua0MNpC0akMBFoNO8455RHk2yycBM0iayMIAtVAL6xmV9TWAkehFgrrlImTL2fZdX5LXfYtAA==", "cpu": [ "arm64" ], + "dev": true, "libc": [ "musl" ], @@ -3204,17 +3331,19 @@ "os": [ "linux" ], + "peer": true, "engines": { "node": "^20.19.0 || >=22.12.0" } }, "node_modules/@rolldown/binding-linux-ppc64-gnu": { - "version": "1.2.11", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.2.11.tgz", - "integrity": "sha512-qlUGAheh2yh8afH7QBgx0PrRHN85hKnNd78x8MeMhXivuevgd8vgf6/CstOzmNKY/lLTHvNTrPy98cLnAugzJw==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.3.2.tgz", + "integrity": "sha512-L8eej7+/StRxUHHOPsOVl7Fzx/3tumuGB4hGQZKT73xRI16KZhaSJr0gi3C3WBjNRxeJRKKps2UD4lQukP+oBw==", "cpu": [ "ppc64" ], + "dev": true, "libc": [ "glibc" ], @@ -3223,17 +3352,19 @@ "os": [ "linux" ], + "peer": true, "engines": { "node": "^20.19.0 || >=22.12.0" } }, "node_modules/@rolldown/binding-linux-s390x-gnu": { - "version": "1.2.11", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.2.11.tgz", - "integrity": "sha512-secpEad+0vCbSfn8upFySkDskv+bGPk3THSDS9Y89yc4rb4kzqHp8Dmyd9BkQW4SnhNXBZCl/6CrO//hZahNJQ==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.3.2.tgz", + "integrity": "sha512-MV5CEb/nV8neQOj7l6945q1vy62HXtWO8zPDvfySPusoUzdBoLoJ/DfXXwaYThGTXZCniF+5bCf253WTPPK7Yw==", "cpu": [ "s390x" ], + "dev": true, "libc": [ "glibc" ], @@ -3242,17 +3373,19 @@ "os": [ "linux" ], + "peer": true, "engines": { "node": "^20.19.0 || >=22.12.0" } }, "node_modules/@rolldown/binding-linux-x64-gnu": { - "version": "1.2.11", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.2.11.tgz", - "integrity": "sha512-mOVBT3dPpkWm8XBWPmU4bf+U6dYDLeMo/9ojUmis4N0L5uu10qra5vOyngZ7/PSdoE4G9KvRt4bloRxNjLas7A==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.3.2.tgz", + "integrity": "sha512-3qssvvVvkwQookZ1/1avlKWc5orAR85vgKdzDd5noZS8nnHiI/ejOAEt0xfNYvtBBF7/DZmP8dANWkRBJVOBCA==", "cpu": [ "x64" ], + "dev": true, "libc": [ "glibc" ], @@ -3261,17 +3394,19 @@ "os": [ "linux" ], + "peer": true, "engines": { "node": "^20.19.0 || >=22.12.0" } }, "node_modules/@rolldown/binding-linux-x64-musl": { - "version": "1.2.11", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.2.11.tgz", - "integrity": "sha512-Is78i9A8Ui4SqcxUwFJ9uMmjDn58IbVTjFWYdQestFEgeuEmHMLGNriXnVJKkwG2YiZjw8cP0zCTyDMdDGtOOg==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.3.2.tgz", + "integrity": "sha512-rJqoFTm/bCZFKKgaT4NzWn/TuJkFDToZ/rzYFnYVBL28jH1nIfg6snx2mDri30nal9H+wcYfKpoPR9jrMQgQQg==", "cpu": [ "x64" ], + "dev": true, "libc": [ "musl" ], @@ -3280,54 +3415,81 @@ "os": [ "linux" ], + "peer": true, "engines": { "node": "^20.19.0 || >=22.12.0" } }, "node_modules/@rolldown/binding-openharmony-arm64": { - "version": "1.2.11", - "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.2.11.tgz", - "integrity": "sha512-dUCXneZ87INUMyQ0D+C0HrEBNUPNXHaPmU5GTjyKTJEiussw9Kaj5Ln8UztPe4epV/ffvgNBEadksdYhmW6xJA==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.3.2.tgz", + "integrity": "sha512-ozdbCjHfh0N//wJNExjJlSlcDaeIKo8k1ktzkLUyESr2Gu/Qw7nBYxKe3jgtoaxda570vg10WdYosre82263hQ==", "cpu": [ "arm64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ "openharmony" ], + "peer": true, "engines": { "node": "^20.19.0 || >=22.12.0" } }, + "node_modules/@rolldown/binding-wasm32-wasi": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@rolldown/binding-wasm32-wasi/-/binding-wasm32-wasi-1.3.2.tgz", + "integrity": "sha512-p5VA6Vk/2cXZPVWf+dDbuE0dkhrcoAo6pISTJmzUnsSdQqNJdusyR8lZgHku095+r27zrYISNLZnJoqrcePW0A==", + "cpu": [ + "wasm32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "peer": true, + "dependencies": { + "@emnapi/core": "2.0.0-beta.2", + "@emnapi/runtime": "2.0.0-beta.2", + "@napi-rs/wasm-runtime": "1.2.6" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=23.5.0" + } + }, "node_modules/@rolldown/binding-win32-arm64-msvc": { - "version": "1.2.11", - "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.2.11.tgz", - "integrity": "sha512-jByxb6qfd+bH1xUd0qnfFnb17i9sWBPY2tOavJ0l3tdr3OTu+Kvtm8cd/JV5nFt657b1VqGltxg9olOEfofXWw==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.3.2.tgz", + "integrity": "sha512-XDb2U14Orf4r76SwzvJ7avePL00w4gHBmi1Ig4B/itYFEUTmYMNDHVU0dcYuBa0LgNBqyREoJOrQKxQlyYJA7A==", "cpu": [ "arm64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ "win32" ], + "peer": true, "engines": { "node": "^20.19.0 || >=22.12.0" } }, "node_modules/@rolldown/binding-win32-x64-msvc": { - "version": "1.2.11", - "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.2.11.tgz", - "integrity": "sha512-/PzKqzAJ03i19oy2ItPvyvaVjOjBCNnfaJs8yvUdGBKmiESgnrJSQ2awd81QzFbbnAmu7YO9ZnJrDCb9VSJPRA==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.3.2.tgz", + "integrity": "sha512-lEsKzKJqIUDZVCBhS4lkZuyQUhV1oRg5UHkI72qlOAqJn7qEXcoVdTridFS7PHNWdZknBl95EAF/4P1Xv0K1eQ==", "cpu": [ "x64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ "win32" ], + "peer": true, "engines": { "node": "^20.19.0 || >=22.12.0" } @@ -3364,15 +3526,15 @@ } }, "node_modules/@rolldown/pluginutils": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.1.tgz", - "integrity": "sha512-2j9bGt5Jh8hj+vPtgzPtl72j0yRxHAyumoo6TNfAjsLB04UtpSvPbPcDcBMxz7n+9CYB0c1GxQFxYRg2jimqGw==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.1.1.tgz", + "integrity": "sha512-glFIJDvLNDtJhT9qrMFWLPbvS+skxgt4L0K8Ei2YtnhPysAJnsI7nyxSJxKj4ADeKX0OLjC4ntRkwpLOoS3rwA==", "license": "MIT" }, "node_modules/@rollup/pluginutils": { - "version": "5.4.0", - "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.4.0.tgz", - "integrity": "sha512-MfPp06CjRLfXQ3wY0R8vJDYBy/MvVcc9OulEfR0B8Iv9ko+GCNaRZ+EpJYFl27LhKsZK0o420sYCRHCjfCgeUg==", + "version": "5.5.1", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.5.1.tgz", + "integrity": "sha512-P9ZvnfouRu4MSC+ilERaw6FmZs8zqKhpHxEs4aGDGWQAMzQGXnhvCSvoNwokfNvdt7t3Y5Y4p6gStQgezeIqug==", "dev": true, "license": "MIT", "dependencies": { @@ -3530,6 +3692,16 @@ "dev": true, "license": "MIT" }, + "node_modules/@tybys/wasm-util": { + "version": "0.10.5", + "resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.5.tgz", + "integrity": "sha512-dOGOPxlaNV+G046mZzN+9C0dAcQZeSKcXiVaM0TYy/LM4ttTmgSBDxYfovcYI8Em3+eAbiAYpvWLOv8+ZVRJKA==", + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, "node_modules/@types/aria-query": { "version": "5.0.4", "resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-5.0.4.tgz", @@ -3554,21 +3726,22 @@ "license": "MIT" }, "node_modules/@types/estree": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.9.tgz", - "integrity": "sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==", + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.10.tgz", + "integrity": "sha512-lTyOMnOcmRBzdCv6/4zUZCrEhV0xrqQiUZBZtVcbmLHBXKLnN8q89v/wKRF/Q0HbwVsqbIG3o5HDoFl9sduM+g==", "license": "MIT" }, "node_modules/@types/json-schema": { "version": "7.0.15", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", + "dev": true, "license": "MIT" }, "node_modules/@types/node": { - "version": "22.20.4", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.20.4.tgz", - "integrity": "sha512-zJRE40jpHtKqE/C4fgHrAKQLJuSpzEnP9ff9Y7YtoR3Wd2pwqzlekDeEuUQXjRd+QCYnVnNwuJYmhdk9XV8gvA==", + "version": "22.20.5", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.20.5.tgz", + "integrity": "sha512-U2+DNr+wSjpsTS/wZGYHq7GcwfuSmKiKvoPvK22zwTlRhU91yOniN4qRR5KhIjvif7ysw/dz/hKmfDH0Ris4aA==", "license": "MIT", "dependencies": { "undici-types": "~6.21.0" @@ -3591,17 +3764,17 @@ "license": "MIT" }, "node_modules/@typescript-eslint/eslint-plugin": { - "version": "8.71.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.71.0.tgz", - "integrity": "sha512-pqcS9c1HxZTHt7End4nXqd0s5lJrrFzrgCkKFJrsbUnaL6M3+6oBFZaslg6Gjsl3argl2DDRFROnXARaZ2e4Nw==", + "version": "8.73.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.73.0.tgz", + "integrity": "sha512-UkygMFer53Yzn29MCYFTHf34hGXf5KJhiDWfIm1tXtXRrym1CS6l5H9Y3yCtPWChpC0/f93H88gdj8tN0dd4kw==", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/regexpp": "^4.12.2", - "@typescript-eslint/scope-manager": "8.71.0", - "@typescript-eslint/type-utils": "8.71.0", - "@typescript-eslint/utils": "8.71.0", - "@typescript-eslint/visitor-keys": "8.71.0", + "@typescript-eslint/scope-manager": "8.73.0", + "@typescript-eslint/type-utils": "8.73.0", + "@typescript-eslint/utils": "8.73.0", + "@typescript-eslint/visitor-keys": "8.73.0", "ignore": "^7.0.5", "natural-compare": "^1.4.0", "ts-api-utils": "^2.5.0" @@ -3614,15 +3787,15 @@ "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { - "@typescript-eslint/parser": "^8.71.0", + "@typescript-eslint/parser": "^8.73.0", "eslint": "^8.57.0 || ^9.0.0 || ^10.0.0", "typescript": ">=4.8.4 <6.1.0" } }, "node_modules/@typescript-eslint/eslint-plugin/node_modules/ignore": { - "version": "7.0.10", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.10.tgz", - "integrity": "sha512-HpbUakT7xp5miBUywCHf36ZEuAJNklBJDDsGpUIjMzOSmM8ELSfA9Sa/QDPeNeqeoN31u+UTCkL4klCOVvRm4Q==", + "version": "7.0.14", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.14.tgz", + "integrity": "sha512-wCBiZ77u1tuWde6G/nfOtLaCTYcFDU5yCzARzK10y+rLhzYoL7a7yEemcopcc2Mzow7gZOIjnV2ym1NYmdiJOQ==", "dev": true, "license": "MIT", "engines": { @@ -3630,15 +3803,16 @@ } }, "node_modules/@typescript-eslint/parser": { - "version": "8.71.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.71.0.tgz", - "integrity": "sha512-CG4nPk1f2zc8yw4pALqHsFYH2hdo+h1T9daSp21+Hnxi9LOE3GT9hAfTKJCBXVNM2GmYs1eMEP615wPoeOgk3A==", + "version": "8.73.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.73.0.tgz", + "integrity": "sha512-AuL45bVcmssHfZ3Di3cs9Q0l4gBm4ZFVrJOQEE7VpqW+PVgQaEwSwazz4TVIiFabXkk6U51EprYDwqw+HR8ePw==", + "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/scope-manager": "8.71.0", - "@typescript-eslint/types": "8.71.0", - "@typescript-eslint/typescript-estree": "8.71.0", - "@typescript-eslint/visitor-keys": "8.71.0", + "@typescript-eslint/scope-manager": "8.73.0", + "@typescript-eslint/types": "8.73.0", + "@typescript-eslint/typescript-estree": "8.73.0", + "@typescript-eslint/visitor-keys": "8.73.0", "debug": "^4.4.3" }, "engines": { @@ -3654,13 +3828,14 @@ } }, "node_modules/@typescript-eslint/project-service": { - "version": "8.71.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.71.0.tgz", - "integrity": "sha512-aABjw5rjBacYONVPaPiWOCjJu0vEF4a25iQuodlmQYL1trtLZ0X/y+2Vzl3BKI1odM4LnwLE1oUDXYp1wzx1TQ==", + "version": "8.73.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.73.0.tgz", + "integrity": "sha512-/pEf8Rc4Mjk+qJnY0uO1+Gadeal8uv50xpuic+srG2vIVatA0XxvWMUeMtFvs6OCHqftiQ7/+qH4aehG5stzIA==", + "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/tsconfig-utils": "^8.71.0", - "@typescript-eslint/types": "^8.71.0", + "@typescript-eslint/tsconfig-utils": "^8.73.0", + "@typescript-eslint/types": "^8.73.0", "debug": "^4.4.3" }, "engines": { @@ -3675,13 +3850,14 @@ } }, "node_modules/@typescript-eslint/scope-manager": { - "version": "8.71.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.71.0.tgz", - "integrity": "sha512-gWF0BhUcnjZxSpLE8ngS/59n2SB0J3YqRxvX1+2aoRJk9hNtHSLOV+TcarFiOr5ipXm3yc1QrI4c9YZc8zyCxw==", + "version": "8.73.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.73.0.tgz", + "integrity": "sha512-/TjD738Iq2rzj5z0ixVOi+TsvgjAzZPLPaH1yWdDBytR/HTR5gMpyYWZeCe5WTQZLwk3ho8AV7U3muoQCRtXBQ==", + "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.71.0", - "@typescript-eslint/visitor-keys": "8.71.0" + "@typescript-eslint/types": "8.73.0", + "@typescript-eslint/visitor-keys": "8.73.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -3692,9 +3868,10 @@ } }, "node_modules/@typescript-eslint/tsconfig-utils": { - "version": "8.71.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.71.0.tgz", - "integrity": "sha512-Z1UlWHADEK2Mlb9NpWfDeSjqoZ5EyrOv4R3eQpbkzqn/EwaIdOpXXupEA1+0ZIOSJSZZDBHG0BrQyN8zUG6Pwg==", + "version": "8.73.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.73.0.tgz", + "integrity": "sha512-lmtCFOfYaJfpqZywGuXi4FpNtE+NQ+YLe3T0K9rtEDcW8ZuGWvfI++pj8r05sYMI8vWT2CYK4rWyedmD6Rp4og==", + "dev": true, "license": "MIT", "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -3708,15 +3885,15 @@ } }, "node_modules/@typescript-eslint/type-utils": { - "version": "8.71.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.71.0.tgz", - "integrity": "sha512-i8uO1qbdxeKgRnS5sCRt6On3/nfo2d2DwQe3Yvjx543zLy7r8ySqRuPPiIIXAhS03U0v5NfAFx+rUgxFzKKwNw==", + "version": "8.73.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.73.0.tgz", + "integrity": "sha512-MOC9i4xy1F7KcDde7Ip8jf1SrRiALb2Km4UWxGNjUE2YlhjIEo1ayE27GHIwIQyfWuHTmEonQT14uyurlyC6aA==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.71.0", - "@typescript-eslint/typescript-estree": "8.71.0", - "@typescript-eslint/utils": "8.71.0", + "@typescript-eslint/types": "8.73.0", + "@typescript-eslint/typescript-estree": "8.73.0", + "@typescript-eslint/utils": "8.73.0", "debug": "^4.4.3", "ts-api-utils": "^2.5.0" }, @@ -3733,9 +3910,10 @@ } }, "node_modules/@typescript-eslint/types": { - "version": "8.71.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.71.0.tgz", - "integrity": "sha512-cJ4OoxPGWvFnBTnSZyaU+qJzGTqPTGJY+gDchj6cRyLRdmIdt4rcsE4twj+zPfrNiWuVi38wijHzShL++Z9atQ==", + "version": "8.73.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.73.0.tgz", + "integrity": "sha512-O/1ytYzflF16QDKXx4/qOXg1IuZp+n7hr9t+S0nv7N/2Tl8rJiNCshztV1gcSUvHbPtoX3+zmNbtSAyVbzxVfw==", + "dev": true, "license": "MIT", "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -3746,17 +3924,18 @@ } }, "node_modules/@typescript-eslint/typescript-estree": { - "version": "8.71.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.71.0.tgz", - "integrity": "sha512-PEEF4G5sLLWAS5BpPrUvms4ySZkiBQQZM4z+3ReI46axK5Vqr/vXBQatJQIZZOYdGyPUAKTtsrWzpqKuU+3DEw==", + "version": "8.73.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.73.0.tgz", + "integrity": "sha512-InjlBkSdWceIwIBWSwS3ENUp+i0O02PGX3Zv2wnihWJC1WDVGvG7mTHuf8b57uAaITj94d6tRPDH+sUEtXdRQQ==", + "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/project-service": "8.71.0", - "@typescript-eslint/tsconfig-utils": "8.71.0", - "@typescript-eslint/types": "8.71.0", - "@typescript-eslint/visitor-keys": "8.71.0", + "@typescript-eslint/project-service": "8.73.0", + "@typescript-eslint/tsconfig-utils": "8.73.0", + "@typescript-eslint/types": "8.73.0", + "@typescript-eslint/visitor-keys": "8.73.0", "debug": "^4.4.3", - "minimatch": "^10.2.2", + "minimatch": "^11.0.1", "semver": "^7.7.3", "tinyglobby": "^0.2.15", "ts-api-utils": "^2.5.0" @@ -3769,20 +3948,26 @@ "url": "https://opencollective.com/typescript-eslint" }, "peerDependencies": { + "@typescript/native": "npm:typescript@>=7.1.0-dev.20261009.1 || >=7.1.0-beta <7.1.0-dev", "typescript": ">=4.8.4 <6.1.0" + }, + "peerDependenciesMeta": { + "@typescript/native": { + "optional": true + } } }, "node_modules/@typescript-eslint/utils": { - "version": "8.71.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.71.0.tgz", - "integrity": "sha512-pKR/tEMVrXZG23UFKUn5BQf3zfmfk7KQceI2cGzywZ5nxM5Eu3hEJU1utjWzydtzBbcJAQhHN8iPCxobHpPcZQ==", + "version": "8.73.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.73.0.tgz", + "integrity": "sha512-j2SVJJvVkXdUL0WcEzo4vEH1mO1vIi8KlVukcYA2MgMZvYN2LlZR4PmsW+GTSxSW24j6Q/EP7+MOifLtg5hmsA==", "dev": true, "license": "MIT", "dependencies": { "@eslint-community/eslint-utils": "^4.9.1", - "@typescript-eslint/scope-manager": "8.71.0", - "@typescript-eslint/types": "8.71.0", - "@typescript-eslint/typescript-estree": "8.71.0" + "@typescript-eslint/scope-manager": "8.73.0", + "@typescript-eslint/types": "8.73.0", + "@typescript-eslint/typescript-estree": "8.73.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -3797,12 +3982,13 @@ } }, "node_modules/@typescript-eslint/visitor-keys": { - "version": "8.71.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.71.0.tgz", - "integrity": "sha512-8eQ9R218XORK+KLosnf4bu/QsUXvUyVwTbArg7/0NMB1Pu87OJKvj4nhFblkYE8gQV73mW1dx1ptlPCkwRGa7A==", + "version": "8.73.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.73.0.tgz", + "integrity": "sha512-k4lsFVpRZICbltkIEEH4hZRkwXkqDF1GHBpClKQOHQY+RkoZAAuyc1ci3I6p+CB6v3U4jaHIUshc4RzzQXZWLg==", + "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/types": "8.71.0", + "@typescript-eslint/types": "8.73.0", "eslint-visitor-keys": "^5.0.0" }, "engines": { @@ -3856,14 +4042,14 @@ } }, "node_modules/@vitest/coverage-v8": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/@vitest/coverage-v8/-/coverage-v8-4.1.11.tgz", - "integrity": "sha512-8MVGEFnJIcdGjcbfKmeq8z0pZHH0JlVtoVZH9Q/qwUp6wyFnEJUBMrw9DCaj+ra3vShGmhavjalMIhPNxZAUcw==", + "version": "4.1.12", + "resolved": "https://registry.npmjs.org/@vitest/coverage-v8/-/coverage-v8-4.1.12.tgz", + "integrity": "sha512-6S7/iVknKglLAxMFxQGNppBI0iqJS2NgM6FBxavitj7KaDq/vywOWGf6dGu7F2L1Qy0G6S3uTp7aGshHrzK8JA==", "devOptional": true, "license": "MIT", "dependencies": { "@bcoe/v8-coverage": "^1.0.2", - "@vitest/utils": "4.1.11", + "@vitest/utils": "4.1.12", "ast-v8-to-istanbul": "^1.0.0", "istanbul-lib-coverage": "^3.2.2", "istanbul-lib-report": "^3.0.1", @@ -3877,8 +4063,8 @@ "url": "https://opencollective.com/vitest" }, "peerDependencies": { - "@vitest/browser": "4.1.11", - "vitest": "4.1.11" + "@vitest/browser": "4.1.12", + "vitest": "4.1.12" }, "peerDependenciesMeta": { "@vitest/browser": { @@ -3887,15 +4073,15 @@ } }, "node_modules/@vitest/expect": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-4.1.11.tgz", - "integrity": "sha512-VX2x5vNJXET47KAFzwERI+KRMtTTCSWTfSMKsW7JsUsXV4psq++e3DvZpuTDOpHcxytiDs6p2nhVb2tVDiiUYw==", + "version": "4.1.12", + "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-4.1.12.tgz", + "integrity": "sha512-vFlTt+YEu9WBpNjdGayNmlMVzrWPi1+sv853/7t2FU7hpO5gAFBKHzQmkCq5Xjpr+evegF2994LQT3hF3mRlqQ==", "license": "MIT", "dependencies": { "@standard-schema/spec": "^1.1.0", "@types/chai": "^5.2.2", - "@vitest/spy": "4.1.11", - "@vitest/utils": "4.1.11", + "@vitest/spy": "4.1.12", + "@vitest/utils": "4.1.12", "chai": "^6.2.2", "tinyrainbow": "^3.1.0" }, @@ -3904,12 +4090,12 @@ } }, "node_modules/@vitest/mocker": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-4.1.11.tgz", - "integrity": "sha512-2XJVD55d1o5AZous5CCGKS74g/riOj9odEt2bQpCVZeblHyHdnMeFl4jl0XjU21stf4mbjUkew2eXQZt65g5CQ==", + "version": "4.1.12", + "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-4.1.12.tgz", + "integrity": "sha512-fKShNpKZzupWZuY0z7egydvL0sqW4INEZBEExMBMAa6izlENEVHwoXgdaTCaBZ5fwlr4xf2o1wXC83n9RpO+NA==", "license": "MIT", "dependencies": { - "@vitest/spy": "4.1.11", + "@vitest/spy": "4.1.12", "estree-walker": "^3.0.3", "magic-string": "^0.30.21" }, @@ -3930,9 +4116,9 @@ } }, "node_modules/@vitest/pretty-format": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-4.1.11.tgz", - "integrity": "sha512-yiZzPbGTS9Sr/JpFl8zHrcIkAofNbFV6k21vIgQN/cY/oxZeXhJv5sc/MBJ5jFKWmWs+oJHw0UXLZjmf931+Vw==", + "version": "4.1.12", + "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-4.1.12.tgz", + "integrity": "sha512-XW9O8+Mxx4VpCtkYdMJLZQQwsVryP9wk7cPKDxtXFfwSak6yRh5+2fep/Y0XF/ElBvJHq8bcYdi6aeuai0opZA==", "license": "MIT", "dependencies": { "tinyrainbow": "^3.1.0" @@ -3942,12 +4128,12 @@ } }, "node_modules/@vitest/runner": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-4.1.11.tgz", - "integrity": "sha512-LztvUgdwMNJMIkj3hQnnxiC2Xy1zNxq928W/xhjCLaNCzqTZOudjwbQf6v9IntZGPw132i2Lq2rgTRZHD3JHNw==", + "version": "4.1.12", + "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-4.1.12.tgz", + "integrity": "sha512-NKlVKCr5QnCe8jijdMnmkpHHU+WTqiLFR6G0pHji9uRjXK9xJl1k1nTw6F3pOOj2PDcsDt2GKQMI7wIsaT491w==", "license": "MIT", "dependencies": { - "@vitest/utils": "4.1.11", + "@vitest/utils": "4.1.12", "pathe": "^2.0.3" }, "funding": { @@ -3955,13 +4141,13 @@ } }, "node_modules/@vitest/snapshot": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-4.1.11.tgz", - "integrity": "sha512-pN7ikn1ON7h8ee4gIAp4AzyK+zBtJPzVbqOgu5LCEh4VaJVbPQcgYQYJIMGQPXVeJJq1fnfazis7a5pFNPahog==", + "version": "4.1.12", + "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-4.1.12.tgz", + "integrity": "sha512-ko1y1Qgb/slzQ9mr+b89Cuqud8WG1TKtsPD8r7ZUBdvVOGt85Af2HwCqHujrhwJq95hs/9RM7fcAPg57o1vlzw==", "license": "MIT", "dependencies": { - "@vitest/pretty-format": "4.1.11", - "@vitest/utils": "4.1.11", + "@vitest/pretty-format": "4.1.12", + "@vitest/utils": "4.1.12", "magic-string": "^0.30.21", "pathe": "^2.0.3" }, @@ -3970,21 +4156,21 @@ } }, "node_modules/@vitest/spy": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-4.1.11.tgz", - "integrity": "sha512-apNa/prQy2qCeywhnixOHPRCgGNhvg7T4Dapfl1GahLp/R+uhBm5cPyFoNVyqsNd2h1nJxL6BqqdIjiABL60YA==", + "version": "4.1.12", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-4.1.12.tgz", + "integrity": "sha512-RGq9x4JNGNTZHEJxvN0oSiJjeSCExm0n2gZKKJZHY9cX5AVA6M7VJILBT3ZJ/tJ/0J9uWT7fETV9/btoi//vSg==", "license": "MIT", "funding": { "url": "https://opencollective.com/vitest" } }, "node_modules/@vitest/utils": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-4.1.11.tgz", - "integrity": "sha512-zTCVGpyFsGWBhllOyKlTw/vnr6D9qxsfSDyfbyZmTyjHw5N/VuvzHpHoQjm2ZJzn4RJgx5w4r7V0er69CmLgPQ==", + "version": "4.1.12", + "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-4.1.12.tgz", + "integrity": "sha512-Q3awXrwOfEV+qc3WmO5ONyE0yO7Q1gQ9/oyHxGLZ/pl7N3NO/ZztqQwKLuwMkV+CA1JYSIeO3gkHnRDIo4AVaA==", "license": "MIT", "dependencies": { - "@vitest/pretty-format": "4.1.11", + "@vitest/pretty-format": "4.1.12", "convert-source-map": "^2.0.0", "tinyrainbow": "^3.1.0" }, @@ -3993,32 +4179,62 @@ } }, "node_modules/@volar/language-core": { - "version": "2.4.28", - "resolved": "https://registry.npmjs.org/@volar/language-core/-/language-core-2.4.28.tgz", - "integrity": "sha512-w4qhIJ8ZSitgLAkVay6AbcnC7gP3glYM3fYwKV3srj8m494E3xtrCv6E+bWviiK/8hs6e6t1ij1s2Endql7vzQ==", + "version": "2.4.31", + "resolved": "https://registry.npmjs.org/@volar/language-core/-/language-core-2.4.31.tgz", + "integrity": "sha512-OM+OZfynHa1/4WlC8klqvwTQVmhYUZuwpAKdfl/rlvK8jaIozMD5qwXsOkxcRJA2tC+TEFsG1K81lNP4s/IAzQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@volar/source-map": "2.4.31" + } + }, + "node_modules/@volar/language-service": { + "version": "2.4.31", + "resolved": "https://registry.npmjs.org/@volar/language-service/-/language-service-2.4.31.tgz", + "integrity": "sha512-LM9HFsBVhHZ7RbFUZK9P23FvamK8XCDcN0kNgOTts02wVgnygo3ReLbmBmUZ3GuYnrYn6HHoQvqk/eHIzzTnrg==", "dev": true, "license": "MIT", "dependencies": { - "@volar/source-map": "2.4.28" + "@volar/language-core": "2.4.31", + "vscode-languageserver-protocol": "^3.17.5", + "vscode-languageserver-textdocument": "^1.0.11", + "vscode-uri": "^3.0.8" + }, + "peerDependencies": { + "typescript": "<7" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } } }, "node_modules/@volar/source-map": { - "version": "2.4.28", - "resolved": "https://registry.npmjs.org/@volar/source-map/-/source-map-2.4.28.tgz", - "integrity": "sha512-yX2BDBqJkRXfKw8my8VarTyjv48QwxdJtvRgUpNE5erCsgEUdI2DsLbpa+rOQVAJYshY99szEcRDmyHbF10ggQ==", + "version": "2.4.31", + "resolved": "https://registry.npmjs.org/@volar/source-map/-/source-map-2.4.31.tgz", + "integrity": "sha512-odi31S3mKm57aO7Pd5P624FmGIB49U4lUPnYRUKvCDa8WZy5N5Yb+GMp2WJNaeIr4+q0ijNpuHsJLrfEiWvHtA==", "dev": true, "license": "MIT" }, "node_modules/@volar/typescript": { - "version": "2.4.28", - "resolved": "https://registry.npmjs.org/@volar/typescript/-/typescript-2.4.28.tgz", - "integrity": "sha512-Ja6yvWrbis2QtN4ClAKreeUZPVYMARDYZl9LMEv1iQ1QdepB6wn0jTRxA9MftYmYa4DQ4k/DaSZpFPUfxl8giw==", + "version": "2.4.31", + "resolved": "https://registry.npmjs.org/@volar/typescript/-/typescript-2.4.31.tgz", + "integrity": "sha512-OBHLLAi03AmaRWqzytdFhgtW2B3HM+2/vXFkvnZAlEKltalUTyu+No7g9aZx7e9efrDLOtHsd/3PgCHSfgVJ/Q==", "dev": true, "license": "MIT", "dependencies": { - "@volar/language-core": "2.4.28", + "@volar/language-core": "2.4.31", + "@volar/language-service": "2.4.31", "path-browserify": "^1.0.1", "vscode-uri": "^3.0.8" + }, + "peerDependencies": { + "typescript": "<7" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } } }, "node_modules/@xmldom/xmldom": { @@ -4049,9 +4265,10 @@ } }, "node_modules/acorn": { - "version": "8.18.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.18.0.tgz", - "integrity": "sha512-lGq+9yr1/GuAWaVYIHRjvvySG5/4VfKIvC8EWxStPdcDh/Ka7FG3twP6v4d5BkravUilhIAsG4Qj83t02LWUPQ==", + "version": "8.19.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.19.0.tgz", + "integrity": "sha512-oJlA3XiRm7Cyk6qFD2Jn8ak9B7jSy0qy00ADO3+8dpT0LSjFihQYv4C02LFCSYJV3Q37xYwwRy5m+IpIiUzqWw==", + "dev": true, "license": "MIT", "bin": { "acorn": "bin/acorn" @@ -4064,25 +4281,26 @@ "version": "5.3.2", "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", + "dev": true, "license": "MIT", "peerDependencies": { "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" } }, "node_modules/activitystreams-pane": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/activitystreams-pane/-/activitystreams-pane-2.0.0.tgz", - "integrity": "sha512-NLwCi2sH2NayuACURhHotWTcazAxyWtq32C8NMKcnfSk8XMrJmEdb+NqnzYQN12/sCnLkFJWvRD/C8QIqa7uLQ==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/activitystreams-pane/-/activitystreams-pane-2.1.0.tgz", + "integrity": "sha512-KftHX9fJ+FHD8ygZf23BgLgRcWBf1x6sr8yeavClqanU4ufFbgmug8CIPyQtp2ykTG2I/yO5xWx52HkAhnKOxQ==", "license": "MIT", "dependencies": { - "pane-registry": "5.0.1", + "pane-registry": "5.1.1", "patch-package": "^8.0.1", "rdflib": "2.4.1", "react": "^19.2.3", "react-dom": "^19.2.3", "react-jss": "^10.10.0", - "solid-logic": "6.0.0", - "solid-ui": "5.0.1", + "solid-logic": "6.2.0", + "solid-ui": "5.1.0", "timeago.js": "^4.0.2" } }, @@ -4100,6 +4318,7 @@ "version": "6.15.0", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.15.0.tgz", "integrity": "sha512-fgFx7Hfoq60ytK2c7DhnF8jIvzYgOMxfugjLOSMHjLIPgenqa7S7oaagATUq99mV6IYvN2tRmC0wnTYX6iPbMw==", + "dev": true, "license": "MIT", "dependencies": { "fast-deep-equal": "^3.1.1", @@ -4140,6 +4359,7 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true, "license": "Python-2.0" }, "node_modules/aria-query": { @@ -4299,9 +4519,9 @@ } }, "node_modules/ast-v8-to-istanbul": { - "version": "1.0.7", - "resolved": "https://registry.npmjs.org/ast-v8-to-istanbul/-/ast-v8-to-istanbul-1.0.7.tgz", - "integrity": "sha512-kFL68AG6ajd8fg248zwM9GQrUWEp79gsmjum34OEXjs4yHuUMZfYKwOLW9GMmB4oNvVrj+EAGxsP7ye2UR9UlA==", + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/ast-v8-to-istanbul/-/ast-v8-to-istanbul-1.0.8.tgz", + "integrity": "sha512-lPdpagk13ANXV+HClJEpCZM7kUsl5XcvgqKzZhaj6Ve1ZFICcY2sGhAN1n1vT0tML6EclT7bfVgTxqL57Gkpow==", "devOptional": true, "license": "MIT", "dependencies": { @@ -4344,9 +4564,9 @@ } }, "node_modules/axe-core": { - "version": "4.13.0", - "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.13.0.tgz", - "integrity": "sha512-UzGt8zg7Ny8djbYMhxl2zuEevVa7r2gJjYY5Lwr1xM7+XU2nd6CkIWFTVcCIbAP63vSz71NaVyyuSk9lHKcy0A==", + "version": "4.14.1", + "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.14.1.tgz", + "integrity": "sha512-FHfa+lmNjQZfJz1q8wKqIDwC6DExcHt/pkjNQb09a3NPjCKg2rhu5qb2S4r76ASyFNNtuFooJpZe37OgudVGtQ==", "license": "MPL-2.0", "engines": { "node": ">=4" @@ -4368,9 +4588,9 @@ } }, "node_modules/babel-plugin-polyfill-corejs2/node_modules/semver": { - "version": "6.3.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", - "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "version": "6.3.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.2.tgz", + "integrity": "sha512-GYrCADwpu6yV5OAvchkQ27Z5wwMxWAEMg5NNWjyHh/5DboFFqbdbvYNIvZouQpxXyeMPoTOh0vdPYKlf0ZswdQ==", "dev": true, "license": "ISC", "bin": { @@ -4408,6 +4628,7 @@ "version": "4.0.4", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==", + "dev": true, "license": "MIT", "engines": { "node": "18 || 20 || >=22" @@ -4434,9 +4655,9 @@ "license": "MIT" }, "node_modules/baseline-browser-mapping": { - "version": "2.11.26", - "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.26.tgz", - "integrity": "sha512-GLQdD3y6UF8iVuMJl5fHgE4jdn/ua7n+toKfLgNlg3BqQtOZjpy68T8Tup8/wGWZCDlm7KMg7tPb4MPn7oN0TQ==", + "version": "2.11.37", + "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.37.tgz", + "integrity": "sha512-QYph+vfurmaxhNwi9FprfmtkT5cx2Keg8FzZ0vnjO8ukscIybVyZGMFwdllKGlTI6qyU8ck43OM9UXh+IFJihQ==", "dev": true, "license": "Apache-2.0", "bin": { @@ -4457,9 +4678,10 @@ } }, "node_modules/brace-expansion": { - "version": "5.0.12", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.12.tgz", - "integrity": "sha512-YovQ3rzhaLMIrDjNDMkNS01tea93qhEhG5xy8f6+R0l+dw3Ki+5sCoIoI942iuLZTHWogWktgwVDhU09iNEimQ==", + "version": "5.0.13", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.13.tgz", + "integrity": "sha512-Vh3dmFbc4wZeox7M9I/0L9GfFd83Su4+yCck/OF9Gi/P/dAHn0RT7X4K9R7gMNMhDck3DvhR6QXsnQdjjgwNvQ==", + "dev": true, "license": "MIT", "dependencies": { "balanced-match": "^4.0.2" @@ -4481,9 +4703,9 @@ } }, "node_modules/browserslist": { - "version": "4.29.3", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.29.3.tgz", - "integrity": "sha512-1R4kiYKXGViqEN0CnoDrXc1StD9niAwu+j2dukWzrD4bJgsD4lDmEp0CRbc6E/vYJIfTHwPmwyaKtVSudICdPA==", + "version": "4.29.6", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.29.6.tgz", + "integrity": "sha512-CmVVIQ3RVc5HxYEc9X84GvxK/C8C1wH8TlKAiO7uTxF8PDwt7r8t9Qk3J9NkMOVzX5O/HbLv3yzxZg9HPrnI9w==", "dev": true, "funding": [ { @@ -4501,11 +4723,11 @@ ], "license": "MIT", "dependencies": { - "baseline-browser-mapping": "^2.11.26", - "caniuse-lite": "^1.0.30001813", - "electron-to-chromium": "^1.5.439", - "node-releases": "^2.0.57", - "update-browserslist-db": "^1.3.3" + "baseline-browser-mapping": "^2.11.37", + "caniuse-lite": "^1.0.30001826", + "electron-to-chromium": "^1.5.486", + "node-releases": "^2.0.64", + "update-browserslist-db": "^1.4.0" }, "bin": { "browserslist": "cli.js" @@ -4589,6 +4811,7 @@ "version": "3.1.0", "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true, "license": "MIT", "engines": { "node": ">=6" @@ -4604,9 +4827,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001813", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001813.tgz", - "integrity": "sha512-zfjJo4rM0+fUomGDBW/xcDjhIwz/210DGvip2MAMDZ8KHcRPnOHmEgHPZP0UHlZoxr8fYKVJOqcORhYQcG4FKQ==", + "version": "1.0.30001826", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001826.tgz", + "integrity": "sha512-wTB+9tIbLro/BCXwLuNV1meHE4L9dS6dArMDwgYfNBPMYScqClHyGunhkCSDtHhe/69Xl0sHlKgBVZ+fNsYtWA==", "dev": true, "funding": [ { @@ -4634,9 +4857,9 @@ } }, "node_modules/chai": { - "version": "6.2.2", - "resolved": "https://registry.npmjs.org/chai/-/chai-6.2.2.tgz", - "integrity": "sha512-NUPRluOfOiTKBKvWPtSD4PhFvWCqOi0BGStNWs57X9js7XGTprSmFoz5F0tWhR4WPjNeR9jXqdC7/UpSJTnlRg==", + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-6.3.0.tgz", + "integrity": "sha512-XWAtwJ6OHO+tj0EKCs0Y2UamnyOxseZWltU4x2U2wh8g4AigdjwvtUjvLP2tqkA/avxHEtzxNaqGq/YGNwckKg==", "license": "MIT", "engines": { "node": ">=18" @@ -4674,8 +4897,69 @@ "vitest-axe": "^0.1.0" } }, - "node_modules/ci-info": { - "version": "3.9.0", + "node_modules/chat-pane/node_modules/pane-registry": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/pane-registry/-/pane-registry-5.0.1.tgz", + "integrity": "sha512-3aeLxm6TnRHfIDoEbpZpNe3Tlm7wWT+ipEpiV6h3cRgxyzmEtrUpS9WB8yJa/VJq0RHXEoaYlLu94fcbuOPnbA==", + "license": "MIT", + "dependencies": { + "rdflib": "2.4.1", + "solid-logic": "6.0.0" + } + }, + "node_modules/chat-pane/node_modules/solid-logic": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/solid-logic/-/solid-logic-6.0.0.tgz", + "integrity": "sha512-irRWnU28Simo2WBhbCgAz4d+QawGJ4zJuiwuBQyObNwuwr4KbDC9evf0CFdnr/PJD8EhLrYT0Fk3nh1eJmQAbA==", + "license": "MIT", + "dependencies": { + "@uvdsl/solid-oidc-client-browser": "^0.2.3", + "solid-namespace": "^0.5.4", + "vite": "^8.0.16", + "vitest": "^4.1.9" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/chat-pane/node_modules/solid-ui": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/solid-ui/-/solid-ui-5.0.1.tgz", + "integrity": "sha512-kqHYMoMN+FMSu1+1TaPqOfeuoZErS6EicFJh8erxWdRz5aNbLAGQfVlB7HaafcUvnHKDiWFtlZETfD7YqmRy8Q==", + "license": "MIT", + "dependencies": { + "@awesome.me/webawesome": "^3.9.0", + "@codemirror/commands": "^6.10.0", + "@codemirror/lang-css": "^6.3.1", + "@codemirror/lang-html": "^6.4.11", + "@codemirror/lang-javascript": "^6.2.5", + "@codemirror/lang-json": "^6.0.2", + "@codemirror/lang-markdown": "^6.3.1", + "@codemirror/lang-xml": "^6.1.0", + "@codemirror/language": "^6.12.3", + "@codemirror/legacy-modes": "^6.5.3", + "@codemirror/state": "^6.6.0", + "@codemirror/view": "^6.43.0", + "@lit/context": "^1.1.6", + "@lit/task": "^1.0.3", + "@noble/curves": "^2.2.0", + "@noble/hashes": "^2.2.0", + "@uiw/codemirror-theme-vscode": "^4.25.10", + "escape-html": "^1.0.3", + "lit": "^3.3.3", + "mime-types": "^3.0.2", + "pane-registry": "5.0.1", + "rdflib": "2.4.1", + "solid-logic": "6.0.0", + "solid-namespace": "^0.5.4", + "uuid": "^14.0.0" + }, + "optionalDependencies": { + "fsevents": "*" + } + }, + "node_modules/ci-info": { + "version": "3.9.0", "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.9.0.tgz", "integrity": "sha512-NIxF55hv4nSqQswkAeiOi1r83xy8JldOFDTWiug55KBu9Jnblncd2U6ViHmYgHf01TPZS77NJBhBMKdWj9HQMQ==", "funding": [ @@ -4738,27 +5022,28 @@ "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true, "license": "MIT" }, "node_modules/confbox": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/confbox/-/confbox-0.3.1.tgz", - "integrity": "sha512-cKUSoKa8YxFZZSmraVi7onONx3amu77ngK3kGpsYHDH7drPwCRkQE1RYMPlLRrMtnciRj274XNRxcHxnKmDSnA==", + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/confbox/-/confbox-0.3.2.tgz", + "integrity": "sha512-ZUAKhKlkCOrIGKc8cj7zek9s9z1mveHif/25nUshI2BzCRzF7KH7KHa+Lnh2ubq+e1tIlaFuP763mzW4qVoehg==", "dev": true, "license": "MIT" }, "node_modules/contacts-pane": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/contacts-pane/-/contacts-pane-4.0.0.tgz", - "integrity": "sha512-lEE/nXSDXElE1qy+wzx5KWKs1bad+4XkBMtMmjZVxxr4W4g0Ftw6hAXDuqPsbDjZopBMUlPajMUUUDmySgKj8A==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/contacts-pane/-/contacts-pane-4.1.0.tgz", + "integrity": "sha512-PnM+nxzWZc92iNAxvE18dsC9AeYlK1FnzNPJA93un5fO5l2uOX17MHK5ARFdyg8NjryxVVwmBQ8GTRPAdNfJUA==", "license": "MIT", "dependencies": { "@lit/context": "^1.1.6", "lit": "^3.3.3", - "pane-registry": "5.0.1", + "pane-registry": "5.1.1", "rdflib": "2.4.1", - "solid-logic": "6.0.0", - "solid-ui": "5.0.1" + "solid-logic": "6.2.0", + "solid-ui": "5.1.0" } }, "node_modules/convert-source-map": { @@ -4768,13 +5053,13 @@ "license": "MIT" }, "node_modules/core-js-compat": { - "version": "3.50.0", - "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.50.0.tgz", - "integrity": "sha512-XGpFGbMLHwSt74YLTKho7Ib242qi6O8MSX+sRokV4oz7iKXvQWGYZthjIhjRGMxjzVkAubBO512dKGYcefmX3Q==", + "version": "3.51.0", + "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.51.0.tgz", + "integrity": "sha512-52r6fkXgxv4GLMjmFcMWRx7X9bw071xTTdrDcdyPGRqU2oE+9pCG0bAOMifSBdLw0JRBZKEF0q3B55qPlLuE8g==", "dev": true, "license": "MIT", "dependencies": { - "browserslist": "^4.28.7" + "browserslist": "^4.29.3" }, "engines": { "node": ">=6.4.0" @@ -4958,6 +5243,7 @@ "version": "4.4.3", "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "devOptional": true, "license": "MIT", "dependencies": { "ms": "^2.1.3" @@ -4991,6 +5277,7 @@ "version": "0.1.4", "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", + "dev": true, "license": "MIT" }, "node_modules/define-data-property": { @@ -5072,9 +5359,9 @@ "license": "MIT" }, "node_modules/dompurify": { - "version": "3.4.16", - "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.4.16.tgz", - "integrity": "sha512-sqo+pNp3qRhCIpbgRi1y8Tgk27Bo2Ry7w0dC1NBeNTdZChWjz9Xb/KOoZbRP/R6pQZ80Qw8YhXw13hWWBbMRnQ==", + "version": "3.4.18", + "resolved": "https://registry.npmjs.org/dompurify/-/dompurify-3.4.18.tgz", + "integrity": "sha512-ofe3wI/uNm68HInABYFJYqQxRw1EaKAjNdrFVKqjUY+UZurvNd2L/HuQe097s/4RivWiZyP6tT7aoT8atjfhwg==", "license": "(MPL-2.0 OR Apache-2.0)", "optionalDependencies": { "@types/trusted-types": "^2.0.7" @@ -5095,9 +5382,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.5.440", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.440.tgz", - "integrity": "sha512-SghDzqdJokdz8zP8YNlvS74+CwLRoUPDGvP/gFA+HrKVw+pOshUAgx8pXR37xl/u16zGae746rFNWvZ/22kU2Q==", + "version": "1.5.486", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.486.tgz", + "integrity": "sha512-rpybw4Ac4ak/An6G1Me2+61xzwobowDGyuJe71QHHOVpkZv4fPVobsLl7WH6zHSKusAMpaHxGKTpOvpy7+r3dQ==", "dev": true, "license": "ISC" }, @@ -5108,9 +5395,9 @@ "license": "MIT" }, "node_modules/enhanced-resolve": { - "version": "5.26.0", - "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.26.0.tgz", - "integrity": "sha512-9vhedylFonb2YGogzUKX6+Ja72gOJbN1QHAqdrvqLwhdl/QWbKopzoUC9EbQNVsAns/bx/4uyqalrQAoy1IByw==", + "version": "5.27.0", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.27.0.tgz", + "integrity": "sha512-Do6BB2xzlcc/odFg+XEYyneAx4T/WfywO71yw9ePS2tVfRsf7JVR4mUeELadIeHzixkzbG5DpluiEFPi2WGfYQ==", "license": "MIT", "dependencies": { "graceful-fs": "^4.2.4", @@ -5121,9 +5408,9 @@ } }, "node_modules/entities": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/entities/-/entities-8.1.0.tgz", - "integrity": "sha512-kxL7msIffSuh9aaFAMD7rxAIuTRMAHMeBtgHW2yUdWw732ZNh4MehkF2gdjvtdmikkaIP9bFDDJOPlsvm7avrA==", + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/entities/-/entities-9.0.0.tgz", + "integrity": "sha512-oJFNDJg3kTPwAD1cNn2+WmUq4wFoo09npc3Ydf1D7ED4smRiWrsKnaLxykrTWgyGEcusc87P5dxlAleol9kpkg==", "devOptional": true, "license": "BSD-2-Clause", "engines": { @@ -5355,6 +5642,7 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, "license": "MIT", "engines": { "node": ">=10" @@ -5368,6 +5656,7 @@ "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.39.5.tgz", "integrity": "sha512-DgZS62aPLXKlnxILS/AYCoRvHaZeXceIzlXPkkGGzJWSow1aEk0lbTlxUSlyjC8jcaKxAdOnTDz+o1JFSBsyjw==", "deprecated": "This version is no longer supported. Please see https://eslint.org/version-support for other options.", + "dev": true, "license": "MIT", "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", @@ -5561,9 +5850,9 @@ "license": "MIT" }, "node_modules/eslint-plugin-react/node_modules/brace-expansion": { - "version": "1.1.21", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.21.tgz", - "integrity": "sha512-9zeA+KLZNNzglF2TPKRQEDyx6Yby7daAkuy8MiPzpXPsYDWi/DRM8jmwUDxokQjYqBpv5DgPiwD4h4ZZSy1Ujw==", + "version": "1.1.22", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.22.tgz", + "integrity": "sha512-CKLDTuSsN0+r1ThM0WkzzBI7dnPI6xEGfa/JnVYIK9JNBA1N1NyPwXVHor//NKD/y3sDxp764sZdLhFK7pH8XQ==", "dev": true, "license": "MIT", "dependencies": { @@ -5585,9 +5874,9 @@ } }, "node_modules/eslint-plugin-react/node_modules/semver": { - "version": "6.3.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", - "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "version": "6.3.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.2.tgz", + "integrity": "sha512-GYrCADwpu6yV5OAvchkQ27Z5wwMxWAEMg5NNWjyHh/5DboFFqbdbvYNIvZouQpxXyeMPoTOh0vdPYKlf0ZswdQ==", "dev": true, "license": "ISC", "bin": { @@ -5598,6 +5887,7 @@ "version": "8.4.0", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.4.0.tgz", "integrity": "sha512-sNXOfKCn74rt8RICKMvJS7XKV/Xk9kA7DyJr8mJik3S7Cwgy3qlkkmyS2uQB3jiJg6VNdZd/pDBJu0nvG2NlTg==", + "dev": true, "license": "BSD-2-Clause", "dependencies": { "esrecurse": "^4.3.0", @@ -5614,6 +5904,7 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-5.0.1.tgz", "integrity": "sha512-tD40eHxA35h0PEIZNeIjkHoDR4YjjJp34biM0mDvplBe//mB+IHCqHDGV7pxF+7MklTvighcCPPZC7ynWyjdTA==", + "dev": true, "license": "Apache-2.0", "engines": { "node": "^20.19.0 || ^22.13.0 || >=24" @@ -5626,12 +5917,14 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true, "license": "MIT" }, "node_modules/eslint/node_modules/brace-expansion": { - "version": "1.1.21", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.21.tgz", - "integrity": "sha512-9zeA+KLZNNzglF2TPKRQEDyx6Yby7daAkuy8MiPzpXPsYDWi/DRM8jmwUDxokQjYqBpv5DgPiwD4h4ZZSy1Ujw==", + "version": "1.1.22", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.22.tgz", + "integrity": "sha512-CKLDTuSsN0+r1ThM0WkzzBI7dnPI6xEGfa/JnVYIK9JNBA1N1NyPwXVHor//NKD/y3sDxp764sZdLhFK7pH8XQ==", + "dev": true, "license": "MIT", "dependencies": { "balanced-match": "^1.0.0", @@ -5642,6 +5935,7 @@ "version": "4.2.1", "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.1.tgz", "integrity": "sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ==", + "dev": true, "license": "Apache-2.0", "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -5654,6 +5948,7 @@ "version": "3.1.5", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.5.tgz", "integrity": "sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==", + "dev": true, "license": "ISC", "dependencies": { "brace-expansion": "^1.1.7" @@ -5666,6 +5961,7 @@ "version": "10.4.0", "resolved": "https://registry.npmjs.org/espree/-/espree-10.4.0.tgz", "integrity": "sha512-j6PAQ2uUr79PZhBjP5C5fhl8e39FmRnOjsD5lGnWrFU8i2G776tBK7+nP8KuQUTTyAZUwfQqXAgrVH5MbH9CYQ==", + "dev": true, "license": "BSD-2-Clause", "dependencies": { "acorn": "^8.15.0", @@ -5683,6 +5979,7 @@ "version": "4.2.1", "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.1.tgz", "integrity": "sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ==", + "dev": true, "license": "Apache-2.0", "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -5695,6 +5992,7 @@ "version": "1.7.0", "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.7.0.tgz", "integrity": "sha512-Ap6G0WQwcU/LHsvLwON1fAQX9Zp0A2Y6Y/cJBl9r/JbW90Zyg4/zbG6zzKa2OTALELarYHmKu0GhpM5EO+7T0g==", + "dev": true, "license": "BSD-3-Clause", "dependencies": { "estraverse": "^5.1.0" @@ -5707,6 +6005,7 @@ "version": "4.3.0", "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", + "dev": true, "license": "BSD-2-Clause", "dependencies": { "estraverse": "^5.2.0" @@ -5719,6 +6018,7 @@ "version": "5.3.0", "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true, "license": "BSD-2-Clause", "engines": { "node": ">=4.0" @@ -5737,6 +6037,7 @@ "version": "2.0.3", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", + "dev": true, "license": "BSD-2-Clause", "engines": { "node": ">=0.10.0" @@ -5770,9 +6071,9 @@ } }, "node_modules/exsolve": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/exsolve/-/exsolve-1.1.1.tgz", - "integrity": "sha512-9U/jZUgjnSGyntRr6y5Muu1MJcwFl6kPu7k8qLF0IMNfLqvw0NZ4nnVDq0RVoZ0RvCyumib4Ez3KYrVfilrw+g==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/exsolve/-/exsolve-1.2.0.tgz", + "integrity": "sha512-h1pQPR9XoeSMdntRNCjyTznaume4UpfXrULBnlkZ2CUM/G5eSa+pBByGldO5uR8dxbPC+OuJXsPPNf+JZ81ADg==", "dev": true, "license": "MIT" }, @@ -5780,18 +6081,21 @@ "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true, "license": "MIT" }, "node_modules/fast-json-stable-stringify": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true, "license": "MIT" }, "node_modules/fast-levenshtein": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", + "dev": true, "license": "MIT" }, "node_modules/fdir": { @@ -5838,6 +6142,7 @@ "version": "8.0.0", "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz", "integrity": "sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==", + "dev": true, "license": "MIT", "dependencies": { "flat-cache": "^4.0.0" @@ -5862,6 +6167,7 @@ "version": "5.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, "license": "MIT", "dependencies": { "locate-path": "^6.0.0", @@ -5887,6 +6193,7 @@ "version": "4.0.1", "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-4.0.1.tgz", "integrity": "sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==", + "dev": true, "license": "MIT", "dependencies": { "flatted": "^3.2.9", @@ -5900,20 +6207,21 @@ "version": "3.4.4", "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.4.4.tgz", "integrity": "sha512-5+ybhBZANEJxaH3X5evAFatUxLfEHSr7n6kYJ+1Qd0mUqr4eu9gIf6GDbWHf8RJijHrjjO8G+la14SlL2SeS1Q==", + "dev": true, "license": "ISC" }, "node_modules/folder-pane": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/folder-pane/-/folder-pane-4.0.0.tgz", - "integrity": "sha512-WDaX1sFMfy2Dnea2Ud0aZFZxndAxmNugjFHZoxMzVN8wBOp2cJPxmiHl6k8MLDKAnQsN3AeXKdgEaAgKG8/S/A==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/folder-pane/-/folder-pane-4.1.0.tgz", + "integrity": "sha512-COxIE4X1XeNP88uyhE5cATxFsQeZ1p4pzUMHKziCbn5XyPN3fWa3fQpqFAZpj8TsmT9DOrZzDtDREmYC2cAAow==", "license": "MIT", "dependencies": { + "@lit/context": "^1.1.6", + "lit": "^3.3.3", + "pane-registry": "5.1.1", "rdflib": "2.4.1", - "solid-logic": "6.0.0", - "solid-ui": "5.0.1", - "vite": "^8.0.16", - "vitest": "^4.0.18", - "vitest-axe": "^0.1.0" + "solid-logic": "6.2.0", + "solid-ui": "5.1.0" } }, "node_modules/for-each": { @@ -6116,6 +6424,7 @@ "version": "6.0.2", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "dev": true, "license": "ISC", "dependencies": { "is-glob": "^4.0.3" @@ -6132,9 +6441,9 @@ "license": "BSD-2-Clause" }, "node_modules/globals": { - "version": "17.12.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-17.12.0.tgz", - "integrity": "sha512-cezEd/DTyyht9cvSSURyygXPfy04GtWO/5e6ZPvH7fCtjKz9PYOmuawphw1Ctd1f6C+5JypXfGD7ahNMXvevBA==", + "version": "17.14.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-17.14.0.tgz", + "integrity": "sha512-UtdkTVyAJePQv0J2M9Xe4L0ruNSDV314XiIJsADI2Zf40bcdAonE/D/OhAU8AT99oij9mhLByb+NvA3QWZYgCg==", "dev": true, "license": "MIT", "engines": { @@ -6181,10 +6490,10 @@ } }, "node_modules/graceful-fs": { - "version": "4.2.11", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", - "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", - "license": "ISC" + "version": "4.2.12", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.12.tgz", + "integrity": "sha512-iuyGF2E4oafQfPsRrG2wtY2ILupMhvtdrhzrxB+0VcjsPpSPttpfYdjnGFGsTi5MaJFjI1jOKHPQ6UTbTj9TAw==", + "license": "BlueOak-1.0.0" }, "node_modules/has-bigints": { "version": "1.1.0", @@ -6369,6 +6678,7 @@ "version": "5.3.2", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", "integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==", + "dev": true, "license": "MIT", "engines": { "node": ">= 4" @@ -6378,6 +6688,7 @@ "version": "3.3.1", "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.1.tgz", "integrity": "sha512-TR3KfrTZTYLPB6jUjfx6MF9WcWrHL9su5TObK4ZkYgBdWKPOFoSoQIdEuTuR82pmtxH2spWG9h6etwfr1pLBqQ==", + "dev": true, "license": "MIT", "dependencies": { "parent-module": "^1.0.0", @@ -6405,6 +6716,7 @@ "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", + "dev": true, "license": "MIT", "engines": { "node": ">=0.8.19" @@ -6519,9 +6831,9 @@ } }, "node_modules/is-core-module": { - "version": "2.17.0", - "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.17.0.tgz", - "integrity": "sha512-J/vG0zBCbIKOQFfufSwyXdMrsohyJIUNkrnmo6WZGzoM7tr/lsbfW5b2BvisL6zsyMzK9UxV9L6c7AoFbyXHOA==", + "version": "2.18.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.18.0.tgz", + "integrity": "sha512-qyax9fgaKOEC4qK8WZn7Q4IcoZC9RC1O1fFxRcRTq/oMMkWT/uXpqpXa12kzWR409zAt1drYN9N9BO26UmBCmw==", "dev": true, "license": "MIT", "dependencies": { @@ -6604,6 +6916,7 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, "license": "MIT", "engines": { "node": ">=0.10.0" @@ -6658,6 +6971,7 @@ "version": "4.0.3", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, "license": "MIT", "dependencies": { "is-extglob": "^2.1.1" @@ -6901,16 +7215,16 @@ "license": "ISC" }, "node_modules/issue-pane": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/issue-pane/-/issue-pane-4.0.0.tgz", - "integrity": "sha512-NcNBybZ/5/BOtDVJkJzud3bmesWeCI1niua3rp+IeCsHMQwdw4vQ9GVOrbe88Q2Hv5P/hCPcikyX2ozdBEcBAA==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/issue-pane/-/issue-pane-4.1.0.tgz", + "integrity": "sha512-t8zgWfbD6cwnpiDDhtW1gFa+P4RWw/wTW09fuZJ4xiEY0gmwoV7v1oWFFAnMki42iM3aXJPjNVhBg2mCuIKM+g==", "license": "MIT", "dependencies": { "@babel/runtime": "^7.28.6", "patch-package": "^8.0.1", "rdflib": "2.4.1", - "solid-logic": "6.0.0", - "solid-ui": "5.0.1" + "solid-logic": "6.2.0", + "solid-ui": "5.1.0" }, "engines": { "node": ">=20.19.2" @@ -6992,6 +7306,7 @@ "version": "4.3.2", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.3.2.tgz", "integrity": "sha512-SFNOvSJ+Dgf/9An904Yx+CgSlIPCkIpao4qo51lpee25TIRejdH3rhR4EZMGoNx3/TP3O+wzWuiTFl4sqbltzA==", + "dev": true, "funding": [ { "type": "github", @@ -7068,12 +7383,14 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==", + "dev": true, "license": "MIT" }, "node_modules/json-schema-traverse": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true, "license": "MIT" }, "node_modules/json-stable-stringify": { @@ -7099,6 +7416,7 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", + "dev": true, "license": "MIT" }, "node_modules/json5": { @@ -7354,6 +7672,7 @@ "version": "4.5.4", "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", "integrity": "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==", + "dev": true, "license": "MIT", "dependencies": { "json-buffer": "3.0.1" @@ -7391,6 +7710,7 @@ "version": "0.4.1", "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "dev": true, "license": "MIT", "dependencies": { "prelude-ls": "^1.2.1", @@ -7714,6 +8034,7 @@ "version": "6.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, "license": "MIT", "dependencies": { "p-locate": "^5.0.0" @@ -7742,6 +8063,7 @@ "version": "4.6.2", "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", + "dev": true, "license": "MIT" }, "node_modules/loose-envify": { @@ -7766,6 +8088,12 @@ "node": "20 || >=22" } }, + "node_modules/lucide": { + "version": "1.73.0", + "resolved": "https://registry.npmjs.org/lucide/-/lucide-1.73.0.tgz", + "integrity": "sha512-qiNin5j7qEflnAdLG/9Yb4d5N9qnnP8TOMdn6e66399fgX25Y0eYEPS3PUPWGIPLloOj4X+xLTdF2lk9gSgWpA==", + "license": "ISC" + }, "node_modules/lz-string": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/lz-string/-/lz-string-1.5.0.tgz", @@ -7814,9 +8142,9 @@ } }, "node_modules/marked": { - "version": "18.0.14", - "resolved": "https://registry.npmjs.org/marked/-/marked-18.0.14.tgz", - "integrity": "sha512-mBHK6FBHuBAlhgRe88w9F0O1AbwwXJUcQibUbC/QcdTbVGAD7aWza+xt3N6oT/jCZx3/OMeS+8rnuiHZcQ9s7A==", + "version": "18.2.1", + "resolved": "https://registry.npmjs.org/marked/-/marked-18.2.1.tgz", + "integrity": "sha512-ii4bxCTCqqwpT86XZWgJNs+ZnAIZksmLGYMViWA7PDIXYIeNo1x6cDdX3JOip9NM/cI6p8z57FxliACboTruMA==", "license": "MIT", "bin": { "marked": "bin/marked.js" @@ -7842,15 +8170,15 @@ "license": "CC0-1.0" }, "node_modules/meeting-pane": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/meeting-pane/-/meeting-pane-4.0.0.tgz", - "integrity": "sha512-5aMuBBTQINoA+CX25AgxEEf77zyoAReZ8xSApR/Bla0NEoQqofsW87cp/AhKoBnexFAz9nL9mXGG6wVrULgR5w==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/meeting-pane/-/meeting-pane-4.1.0.tgz", + "integrity": "sha512-84c4SQCks3JO/mawFVGxYB5fSHFy4dXOfQ2TBeQs8XQo4kzPif/yMYnWpE0I7nvrOAXXAHPgzkseHDWFrpbSqA==", "license": "MIT", "dependencies": { "patch-package": "^8.0.1", "rdflib": "2.4.1", - "solid-logic": "6.0.0", - "solid-ui": "5.0.1" + "solid-logic": "6.2.0", + "solid-ui": "5.1.0" } }, "node_modules/micromatch": { @@ -7913,15 +8241,17 @@ } }, "node_modules/minimatch": { - "version": "10.2.6", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.6.tgz", - "integrity": "sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==", + "version": "11.0.8", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-11.0.8.tgz", + "integrity": "sha512-nFQuYSTVrGvysVBps5Ih+0BdnYFN/Cj3C816r6+p7yK+FHrVLGE4O4N9AFwykrlNlvM2HYt+Rad1Uiro6h88Ig==", + "dev": true, "license": "BlueOak-1.0.0", "dependencies": { - "brace-expansion": "^5.0.8" + "@isaacs/nonrecursive-glob-match": "^1.1.0", + "brace-expansion": "^5.0.12" }, "engines": { - "node": "18 || 20 || >=22" + "node": "20 || >=22" }, "funding": { "url": "https://github.com/sponsors/isaacs" @@ -7972,12 +8302,13 @@ "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "devOptional": true, "license": "MIT" }, "node_modules/n3": { - "version": "2.7.12", - "resolved": "https://registry.npmjs.org/n3/-/n3-2.7.12.tgz", - "integrity": "sha512-Hy6dfGg9yniLQpSBirvH2E2yO3EG7dSmA3aefRbtO411oqtzG8roD3h1kTc/N065bivCOPfTFIjf0KlwW7KlnQ==", + "version": "2.13.12", + "resolved": "https://registry.npmjs.org/n3/-/n3-2.13.12.tgz", + "integrity": "sha512-z944NsyJi58WXcYevtNkUL2JhVr0KP6nvED9AgymQq5V35TDaNn1N8kO+OWJk/kj4PR0L/ilWB3d7/bWceg1CQ==", "license": "MIT", "dependencies": { "buffer": "^6.0.3", @@ -8009,6 +8340,7 @@ "version": "1.4.0", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", + "dev": true, "license": "MIT" }, "node_modules/neostandard": { @@ -8156,9 +8488,9 @@ } }, "node_modules/node-exports-info/node_modules/semver": { - "version": "6.3.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", - "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "version": "6.3.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.2.tgz", + "integrity": "sha512-GYrCADwpu6yV5OAvchkQ27Z5wwMxWAEMg5NNWjyHh/5DboFFqbdbvYNIvZouQpxXyeMPoTOh0vdPYKlf0ZswdQ==", "dev": true, "license": "ISC", "bin": { @@ -8208,9 +8540,9 @@ } }, "node_modules/node-releases": { - "version": "2.0.57", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.57.tgz", - "integrity": "sha512-kQK9LGGFiHtrWiNhZtA7Qbw17AQz+dmsEKODRIVTXA9+e5MS/2gZEBhYJt13GrAz5/IOZKddH/0Z3TP/Zgo+yw==", + "version": "2.0.64", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.64.tgz", + "integrity": "sha512-zAPCKqMcnqs2nGy6nlkm7JduFseiBJy3EXHGLh+8pFR+TxGCBxxiEN21+UROU5CKwX/f4TlUcYjiM+vs/tsyxw==", "dev": true, "license": "MIT", "engines": { @@ -8356,6 +8688,7 @@ "version": "0.9.4", "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", "integrity": "sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==", + "dev": true, "license": "MIT", "dependencies": { "deep-is": "^0.1.3", @@ -8392,6 +8725,7 @@ "version": "3.1.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, "license": "MIT", "dependencies": { "yocto-queue": "^0.1.0" @@ -8407,6 +8741,7 @@ "version": "5.0.0", "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, "license": "MIT", "dependencies": { "p-limit": "^3.0.2" @@ -8428,26 +8763,27 @@ } }, "node_modules/package-manager-detector": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/package-manager-detector/-/package-manager-detector-1.8.0.tgz", - "integrity": "sha512-yQA4H19AmPEoMUeavPMDIe1higySl/gH/yaQrkT/s07Qp+7pp2hYz30N3z2l5BkjVkF9Ow6o0wjJamm2y7Sn0A==", + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/package-manager-detector/-/package-manager-detector-1.9.0.tgz", + "integrity": "sha512-zAMfbta9nPA8AKkA4WdmNAT8R8s6Dk0/xwPsqNnRidMFcLo1YkLuPDTgs2f64XdzS8vbLNnoJ+uUIkgbz7oRHA==", "dev": true, "license": "MIT" }, "node_modules/pane-registry": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/pane-registry/-/pane-registry-5.0.1.tgz", - "integrity": "sha512-3aeLxm6TnRHfIDoEbpZpNe3Tlm7wWT+ipEpiV6h3cRgxyzmEtrUpS9WB8yJa/VJq0RHXEoaYlLu94fcbuOPnbA==", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/pane-registry/-/pane-registry-5.1.1.tgz", + "integrity": "sha512-CYuWnsXalK2oBEk1bY2L4PZvn4sDxGD2tVkIIwcRWcwgg4DhbmUf+O6/DyhMptuRJvn6aURz5/8vxuac0gdDnQ==", "license": "MIT", "dependencies": { "rdflib": "2.4.1", - "solid-logic": "6.0.0" + "solid-logic": "6.2.0" } }, "node_modules/parent-module": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, "license": "MIT", "dependencies": { "callsites": "^3.0.0" @@ -8457,13 +8793,13 @@ } }, "node_modules/parse5": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/parse5/-/parse5-8.0.1.tgz", - "integrity": "sha512-z1e/HMG90obSGeidlli3hj7cbocou0/wa5HacvI3ASx34PecNjNQeaHNo5WIZpWofN9kgkqV1q5YvXe3F0FoPw==", + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/parse5/-/parse5-8.1.1.tgz", + "integrity": "sha512-EcR/6WDcU7b2N3vQSxKALCk9lXGtUMQxXio008OEMBE0kavu/7JLfBEeFPzi43nMqVDSbEn3QCK+BMCc9zO//w==", "devOptional": true, "license": "MIT", "dependencies": { - "entities": "^8.0.0" + "entities": "^9.0.0" }, "funding": { "url": "https://github.com/inikulin/parse5?sponsor=1" @@ -8566,14 +8902,14 @@ } }, "node_modules/pkg-types": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/pkg-types/-/pkg-types-2.3.3.tgz", - "integrity": "sha512-j/lCFdcppV0JxWpCEITdbDltBxPP6cHT+yNJ6Go2OgoSA9518X847X9z0p6LtA4Nc16+eQzCZjRrWanTGvHJ5w==", + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/pkg-types/-/pkg-types-2.4.0.tgz", + "integrity": "sha512-07Fys7iVx0X6TcviMOgogM1Lk33ZyqOezMnU79S+kffWqwolG/5W9V8EgQSeYCIfFTYVgssRbnH630Oa2+soBA==", "dev": true, "license": "MIT", "dependencies": { "confbox": "^0.3.1", - "exsolve": "^1.1.1", + "exsolve": "^1.1.3", "pathe": "^2.0.3" } }, @@ -8597,9 +8933,9 @@ } }, "node_modules/postcss": { - "version": "8.5.28", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.28.tgz", - "integrity": "sha512-RRuzqDtt5Y9h3quz5hWhK+TPnsmVs6WwSU6LkJMeY4HstUEDuYTG8UJSdawMRzmzAtV+KEoG8N3Qg2qLy5vM/A==", + "version": "8.5.33", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.33.tgz", + "integrity": "sha512-RVHEU9/Pp1Fnjr/MpAJsZoADukCKhfIi15OunEYiGktIkYLkPVvC1sioWolGDS7XByMTx9m/IGbro0Js13zhnQ==", "funding": [ { "type": "opencollective", @@ -8616,18 +8952,18 @@ ], "license": "MIT", "dependencies": { - "nanoid": "^3.3.18", + "nanoid": "^3.3.20", "picocolors": "^1.1.1", - "source-map-js": "^1.2.1" + "source-map-js": "^1.2.2" }, "engines": { "node": "^10 || ^12 || >=14" } }, "node_modules/postcss-custom-media": { - "version": "12.0.2", - "resolved": "https://registry.npmjs.org/postcss-custom-media/-/postcss-custom-media-12.0.2.tgz", - "integrity": "sha512-qn+su6Ux/TVzBSPYlRxC3Kq5DZNWBZt7y1wj38mnHT+whYnM21IxuYVKJ2E9qahBo0KGvcv/1rAB/F5iY1UiIA==", + "version": "12.0.3", + "resolved": "https://registry.npmjs.org/postcss-custom-media/-/postcss-custom-media-12.0.3.tgz", + "integrity": "sha512-pgOICT/unQexoA/Vh4ZvyAUrcwwA/nHh0SJcOwOombpwDEj1x5N6zK+kz97wy9NslhU6UxhE5c5Q/M2gpYfkJA==", "dev": true, "funding": [ { @@ -8641,10 +8977,10 @@ ], "license": "MIT", "dependencies": { - "@csstools/cascade-layer-name-parser": "^3.0.1", - "@csstools/css-parser-algorithms": "^4.0.1", + "@csstools/cascade-layer-name-parser": "^3.0.2", + "@csstools/css-parser-algorithms": "^4.0.2", "@csstools/css-tokenizer": "^4.0.2", - "@csstools/media-query-list-parser": "^5.0.1" + "@csstools/media-query-list-parser": "^5.0.2" }, "engines": { "node": ">=20.19.0" @@ -8654,9 +8990,9 @@ } }, "node_modules/postcss/node_modules/nanoid": { - "version": "3.3.19", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.19.tgz", - "integrity": "sha512-Y2tUNy4ouw6tq5oDSKeQYGOyhkUBhNOcGV/02KC+6kd9eDGqdZd++mjMiIDilrBYvjEnCYvVtsuHCuP+okSfug==", + "version": "3.3.20", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.20.tgz", + "integrity": "sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ==", "funding": [ { "type": "github", @@ -8675,6 +9011,7 @@ "version": "1.2.1", "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", + "dev": true, "license": "MIT", "engines": { "node": ">= 0.8.0" @@ -8718,24 +9055,22 @@ } }, "node_modules/profile-pane": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/profile-pane/-/profile-pane-4.0.0.tgz", - "integrity": "sha512-0pM+jz5kLj3duOsLeHc4xwomQJ92sgAx0QMmYZaC+meY+gkT09qWhTzWqRKur7/HbOBJH1bPH/cu7UI0TBAxHw==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/profile-pane/-/profile-pane-4.1.0.tgz", + "integrity": "sha512-NxgkvE5XaKwsxzp/712t+ebGxVPTLl7Lgcwih/pXdiN7VkIYd9lurNYLoTZsBaqPrlj18rMQ9Vp8hErjaFBB5w==", "license": "MIT", "dependencies": { "@solid-data-modules/contacts-rdflib": "^0.7.1", "chat-pane": "4.0.0", "lit-html": "^3.3.3", - "pane-registry": "5.0.1", + "lucide": "^1.52.0", + "pane-registry": "5.1.1", "patch-package": "^8.0.1", "qrcode": "^1.5.4", "rdflib": "2.4.1", - "solid-logic": "6.0.0", - "solid-ui": "5.0.1", - "validate-color": "^2.2.4", - "vite": "^8.0.16", - "vitest": "^4.0.18", - "vitest-axe": "^0.1.0" + "solid-logic": "6.2.0", + "solid-ui": "5.1.0", + "validate-color": "^2.2.4" } }, "node_modules/prop-types": { @@ -8759,6 +9094,7 @@ "version": "2.3.1", "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "devOptional": true, "license": "MIT", "engines": { "node": ">=6" @@ -8827,9 +9163,9 @@ } }, "node_modules/react": { - "version": "19.3.0", - "resolved": "https://registry.npmjs.org/react/-/react-19.3.0.tgz", - "integrity": "sha512-E8LUcbtBWt20bbl2YoHfx4ZDBdxVTfOKtCZn9cDSJ4l6/nuoApcpIBcj47t2wZoVX8g2ZHuMHbiShgCR1T5Sog==", + "version": "19.3.1", + "resolved": "https://registry.npmjs.org/react/-/react-19.3.1.tgz", + "integrity": "sha512-QNhWdt7nrgVWWQG58QuGsAR3jv3Hbe4mb4vz7w2csnHavciZJgda1CPNaldF6eVxv90ud3jUXpKlHL69gO38yw==", "license": "MIT", "engines": { "node": ">=0.10.0" @@ -8842,15 +9178,15 @@ "license": "MIT" }, "node_modules/react-dom": { - "version": "19.3.0", - "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.3.0.tgz", - "integrity": "sha512-JDk8dgif51OjFoDE70+OT9ICyYr+69HlmihNwp1+Nsfbna3t5sIiCa9ZJktDmQ4/1b/rn26hIAR2uYXDMr5r0Q==", + "version": "19.3.1", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-19.3.1.tgz", + "integrity": "sha512-Y0bARz53lhEC1NMCASs0/j+faB/zqt3R8hpvg1e8+61ZVJ4UL0UdC4cBbXfZMcIuhrfgeILTLe+ZeBCavQPtKQ==", "license": "MIT", "dependencies": { "scheduler": "^0.28.0" }, "peerDependencies": { - "react": "^19.3.0" + "react": "^19.3.1" } }, "node_modules/react-is": { @@ -8883,9 +9219,9 @@ } }, "node_modules/readable-stream": { - "version": "4.7.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-4.7.0.tgz", - "integrity": "sha512-oIGGmcpTLwPga8Bn6/Z75SVaH1z5dUut2ibSyAMVhmUggWpmDn2dapB0n7f8nwaSiRtepAsfJyfXIO5DCVAODg==", + "version": "4.8.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-4.8.0.tgz", + "integrity": "sha512-2jhTTU3Eilp/2DMT71gbcoqC35eQHasMJH0RHkYxwlxIv3+FR6Y5xAFZIwEGLxKkjZYEFlsiMNIdwUqjK2lLHQ==", "license": "MIT", "dependencies": { "abort-controller": "^3.0.0", @@ -8935,9 +9271,9 @@ } }, "node_modules/regenerate": { - "version": "1.4.2", - "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.2.tgz", - "integrity": "sha512-zrceR/XhGYU/d/opr2EKO7aRHUeiBI8qjtfHqADTwZd6Szfy16la6kqD0MIUs5z5hx6AaKa+PixpPrR289+I0A==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.5.0.tgz", + "integrity": "sha512-1s+CxXjJ71i7LNVy8nYwg47XV4y6lAnOEhsMtSKq3WpmPfhl9LuKlTqKIn/3yUpE8lBz+W+TT88Bxyhnr0U4yw==", "dev": true, "license": "MIT" }, @@ -8976,16 +9312,16 @@ } }, "node_modules/regexpu-core": { - "version": "6.5.2", - "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-6.5.2.tgz", - "integrity": "sha512-zkmVH92DlzjSFc4xKGZp/2BXIFrDIdBQBC8gUXKCsMgKYb1bkCkxfSuoW1werDjaTEMTbULkHtKFHe1L+Abnaw==", + "version": "6.5.4", + "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-6.5.4.tgz", + "integrity": "sha512-VpdamrZ9bw4YmvMZfTA3Yg8IHU9Guvg21bonvgjC4l3KfBkOqCPJesHakz7cQeE4Vh4zz4r4Gy6igAcnJxZv9g==", "dev": true, "license": "MIT", "dependencies": { - "regenerate": "^1.4.2", + "regenerate": "^1.5.0", "regenerate-unicode-properties": "^10.3.0", "regjsgen": "^0.8.0", - "regjsparser": "^0.13.0", + "regjsparser": "^0.14.0", "unicode-match-property-ecmascript": "^2.0.0", "unicode-match-property-value-ecmascript": "^2.2.1" }, @@ -9001,9 +9337,9 @@ "license": "MIT" }, "node_modules/regjsparser": { - "version": "0.13.3", - "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.13.3.tgz", - "integrity": "sha512-ycwFAS14Jw4mppvmK4GR/J6u3WpWpjkEApehuHtLc/8VpPNpDMbQ4WjqwplXifGeyKOzHSFLmSPqzksDQE2Sfg==", + "version": "0.14.1", + "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.14.1.tgz", + "integrity": "sha512-IeYboCLG1KBNRksrZQIZ1SV5KVWZiR0ikFokOcA0n63vLvlaFvCsfxN+fd4aXwL0KW3YD+ByRzIgo9ZAHdbldw==", "dev": true, "license": "BSD-2-Clause", "dependencies": { @@ -9066,6 +9402,7 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true, "license": "MIT", "engines": { "node": ">=4" @@ -9082,12 +9419,14 @@ } }, "node_modules/rolldown": { - "version": "1.2.11", - "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.2.11.tgz", - "integrity": "sha512-qpSwIyz0jHQq5qXBTNxFmE6664rJ7O+4TvPFOiOaBSrz8IOHc1koKKSqTM2H6u1UG1+TveuC6vaDHKXFOvb1Kw==", + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.3.2.tgz", + "integrity": "sha512-EFHqbVkXiYZA6akmYm2bvJhNbEGdUwAResRhYwl/BO8QhB5KxsG+t3RVHJSIOy5jBEb0XCACvrIGnnl6Z8sMGA==", + "dev": true, "license": "MIT", + "peer": true, "dependencies": { - "@oxc-project/types": "=0.151.0", + "@oxc-project/types": "=0.158.0", "@rolldown/pluginutils": "^1.0.0" }, "bin": { @@ -9097,21 +9436,22 @@ "node": "^20.19.0 || >=22.12.0" }, "optionalDependencies": { - "@rolldown/binding-android-arm-eabi": "1.2.11", - "@rolldown/binding-android-arm64": "1.2.11", - "@rolldown/binding-darwin-arm64": "1.2.11", - "@rolldown/binding-darwin-x64": "1.2.11", - "@rolldown/binding-freebsd-x64": "1.2.11", - "@rolldown/binding-linux-arm-gnueabihf": "1.2.11", - "@rolldown/binding-linux-arm64-gnu": "1.2.11", - "@rolldown/binding-linux-arm64-musl": "1.2.11", - "@rolldown/binding-linux-ppc64-gnu": "1.2.11", - "@rolldown/binding-linux-s390x-gnu": "1.2.11", - "@rolldown/binding-linux-x64-gnu": "1.2.11", - "@rolldown/binding-linux-x64-musl": "1.2.11", - "@rolldown/binding-openharmony-arm64": "1.2.11", - "@rolldown/binding-win32-arm64-msvc": "1.2.11", - "@rolldown/binding-win32-x64-msvc": "1.2.11" + "@rolldown/binding-android-arm-eabi": "1.3.2", + "@rolldown/binding-android-arm64": "1.3.2", + "@rolldown/binding-darwin-arm64": "1.3.2", + "@rolldown/binding-darwin-x64": "1.3.2", + "@rolldown/binding-freebsd-x64": "1.3.2", + "@rolldown/binding-linux-arm-gnueabihf": "1.3.2", + "@rolldown/binding-linux-arm64-gnu": "1.3.2", + "@rolldown/binding-linux-arm64-musl": "1.3.2", + "@rolldown/binding-linux-ppc64-gnu": "1.3.2", + "@rolldown/binding-linux-s390x-gnu": "1.3.2", + "@rolldown/binding-linux-x64-gnu": "1.3.2", + "@rolldown/binding-linux-x64-musl": "1.3.2", + "@rolldown/binding-openharmony-arm64": "1.3.2", + "@rolldown/binding-wasm32-wasi": "1.3.2", + "@rolldown/binding-win32-arm64-msvc": "1.3.2", + "@rolldown/binding-win32-x64-msvc": "1.3.2" } }, "node_modules/safe-array-concat": { @@ -9209,9 +9549,9 @@ "license": "MIT" }, "node_modules/semver": { - "version": "7.8.5", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.5.tgz", - "integrity": "sha512-Y7/KDsb8LjooZpwaqGyulO6DQlksgCncchHGk+sZIY4SBvUocMBEFH5Ur1fI4dV+Jvl0w6cjvucaIi40puRioA==", + "version": "7.8.6", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.6.tgz", + "integrity": "sha512-9lpSSU4Mly3mrtruwLs1eLK6+gzbzqeBFwRNjIjE+9LuDpWdYctrQlQ3ej1Ilgi7gknpsTRnPoLP8DpCHqHIJw==", "license": "ISC", "bin": { "semver": "bin/semver.js" @@ -9409,15 +9749,15 @@ } }, "node_modules/solid-logic": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/solid-logic/-/solid-logic-6.0.0.tgz", - "integrity": "sha512-irRWnU28Simo2WBhbCgAz4d+QawGJ4zJuiwuBQyObNwuwr4KbDC9evf0CFdnr/PJD8EhLrYT0Fk3nh1eJmQAbA==", + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/solid-logic/-/solid-logic-6.2.0.tgz", + "integrity": "sha512-Q+aNLB80u2LTas49K+1z1ro47RlONaJ2kwVVYKvoy/96fkCobnKYLdnNsmagoRP06FdHKWET/nhy6+QX5Jz1Qw==", "license": "MIT", "dependencies": { + "@dokieli/web-access-control": "^1.1.0", "@uvdsl/solid-oidc-client-browser": "^0.2.3", - "solid-namespace": "^0.5.4", - "vite": "^8.0.16", - "vitest": "^4.1.9" + "mime-types": "^3.0.2", + "solid-namespace": "^0.5.4" }, "engines": { "node": ">=18" @@ -9430,9 +9770,9 @@ "license": "MIT" }, "node_modules/solid-ui": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/solid-ui/-/solid-ui-5.0.1.tgz", - "integrity": "sha512-kqHYMoMN+FMSu1+1TaPqOfeuoZErS6EicFJh8erxWdRz5aNbLAGQfVlB7HaafcUvnHKDiWFtlZETfD7YqmRy8Q==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/solid-ui/-/solid-ui-5.1.0.tgz", + "integrity": "sha512-2vQWnd/mgblegg7BMiKI7qxJ5iAeCA5CQmlX3OTKQbe+AAppqxbAbhsX6NldlMbiWQt/jz5S9qSHVPxagoG2BQ==", "license": "MIT", "dependencies": { "@awesome.me/webawesome": "^3.9.0", @@ -9455,9 +9795,9 @@ "escape-html": "^1.0.3", "lit": "^3.3.3", "mime-types": "^3.0.2", - "pane-registry": "5.0.1", + "pane-registry": "5.1.1", "rdflib": "2.4.1", - "solid-logic": "6.0.0", + "solid-logic": "6.2.0", "solid-namespace": "^0.5.4", "uuid": "^14.0.0" }, @@ -9466,9 +9806,9 @@ } }, "node_modules/solidos-toolkit": { - "version": "0.0.0-dev.998a984ddf8fda587eedb0c8125cb952ac28d191", - "resolved": "https://registry.npmjs.org/solidos-toolkit/-/solidos-toolkit-0.0.0-dev.998a984ddf8fda587eedb0c8125cb952ac28d191.tgz", - "integrity": "sha512-m2b3sZkKbjV5X/J8N25h3UIbsiQARdnXCGs1AeGqFiueoq8cWm+pdOyPpqiVuqRnnA5osmKG2wovUcBBYumL0Q==", + "version": "1.0.0-dev.2fb6be508170f3b28ca79d738aae71cd48f6d87e", + "resolved": "https://registry.npmjs.org/solidos-toolkit/-/solidos-toolkit-1.0.0-dev.2fb6be508170f3b28ca79d738aae71cd48f6d87e.tgz", + "integrity": "sha512-EQMddD3jV0YiPdPuEfBTRc1+QynYiIBwxMs8e3+F/gEP0lfIvSUjFSXCYsJxQxY8rqsEb4YXR4JW/5b1JRtdTQ==", "dev": true, "dependencies": { "@babel/core": "^7.29.0", @@ -9487,10 +9827,10 @@ "vite-plugin-lit-css": "^3.0.0" }, "peerDependencies": { - "pane-registry": "^3.1.1 || ^3.1.2-0 || ^5.0.0 || ^5.0.0-0", + "pane-registry": "^3.1.1 || ^3.1.2-0 || >=5.0.2-0 <6.0.0", "rdflib": "^2.3.6", - "solid-logic": "^4.0.7 || ^4.0.8-0 || ^6.0.0 || ^6.0.0-0", - "solid-ui": "^3.1.2 || ^3.1.3-0 || ^5.0.0 || ^5.0.0-0", + "solid-logic": "^4.0.7 || ^4.0.8-0 || >=6.0.1-0 <7.0.0", + "solid-ui": "^3.1.2 || ^3.1.3-0 || >=5.0.1-0 <6.0.0 || ^5.0.2-0", "vite": "^8.0.0", "vitest": "^4.0.0" }, @@ -9516,30 +9856,26 @@ } }, "node_modules/source-map-js": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", - "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.2.tgz", + "integrity": "sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw==", "license": "BSD-3-Clause", "engines": { "node": ">=0.10.0" } }, "node_modules/source-pane": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/source-pane/-/source-pane-4.0.0.tgz", - "integrity": "sha512-FKxM9xD8fFM1wyi953DdlRnnPAlXw/xGFe8Wx7ai9foek8OsHac+VbO/4r0Sdd7JJym2iLL7rD6t5R6exMi/9Q==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/source-pane/-/source-pane-4.1.0.tgz", + "integrity": "sha512-tVMB09oRHYI9m639VXHCF68Ixqw7IjUFG9go3imkBu1ck1VJD/HagBA7DJFckJij+ydtJy1zm3jVAN0Bz6sfew==", "license": "MIT", "dependencies": { "@lit/context": "^1.1.6", - "@typescript-eslint/parser": "^8.63.0", "lit": "^3.3.3", - "pane-registry": "5.0.1", + "pane-registry": "5.1.1", "rdflib": "2.4.1", - "solid-logic": "6.0.0", - "solid-ui": "5.0.1", - "vite": "^8.0.16", - "vitest": "^4.0.18", - "vitest-axe": "^0.1.0" + "solid-logic": "6.2.0", + "solid-ui": "5.1.0" } }, "node_modules/stackback": { @@ -9718,6 +10054,7 @@ "version": "3.1.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true, "license": "MIT", "engines": { "node": ">=8" @@ -9774,9 +10111,9 @@ "license": "MIT" }, "node_modules/tapable": { - "version": "2.3.3", - "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.3.3.tgz", - "integrity": "sha512-uxc/zpqFg6x7C8vOE7lh6Lbda8eEL9zmVm/PLeTPBRhh1xCgdWaQ+J1CUieGpIfm2HdtsUpRv+HshiasBMcc6A==", + "version": "2.3.4", + "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.3.4.tgz", + "integrity": "sha512-NHFiWnAbMJxNNpBwiO7jJVGDuqMxT9/oV8v57RR+fgBQShkJil5inGD8/xWy0hjLyHQyX1tu27QANhlz3KBqCg==", "license": "MIT", "engines": { "node": ">=6" @@ -9805,9 +10142,9 @@ } }, "node_modules/timeago.js": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/timeago.js/-/timeago.js-4.0.2.tgz", - "integrity": "sha512-a7wPxPdVlQL7lqvitHGGRsofhdwtkoSXPGATFuSOA2i1ZNQEPLrGnj68vOp2sOJTCFAQVXPeNMX/GctBaO9L2w==", + "version": "4.3.1", + "resolved": "https://registry.npmjs.org/timeago.js/-/timeago.js-4.3.1.tgz", + "integrity": "sha512-lK+ZtlgJlzmAIeWDMmnN2WTmTPPwfQoFn8NRanj1ZzIdfC+MMOsivRjQFvurvCy6kB22wJwH0s3TMisfnv93Tw==", "license": "MIT" }, "node_modules/tiny-warning": { @@ -9848,31 +10185,31 @@ } }, "node_modules/tinyrainbow": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-3.1.1.tgz", - "integrity": "sha512-yau8yJdTt989Mm0Bd/236QnzEiPf2xLLTqUZRUJOo/3CB078LSwzei343DgtJVmfJKJE3TMINY1u42SQsP6mXw==", + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-3.2.0.tgz", + "integrity": "sha512-LgO3D9yZJjApUiuUfl9iFAwrtaX4+lok3wJIqttGoKCHlWUqHqbQpnxCf82L8FjgKsh4iGo78hqJwgL8F6To2A==", "license": "MIT", "engines": { "node": ">=14.0.0" } }, "node_modules/tldts": { - "version": "7.4.16", - "resolved": "https://registry.npmjs.org/tldts/-/tldts-7.4.16.tgz", - "integrity": "sha512-QwBER5KMR86IIjpIiO7H/Z3IMJPsZ1A6RKPAqzTTgOyUQUSt9FdnKcqhTaJmkY6HVrgouZHZR0ncK5QxvmnQeg==", + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/tldts/-/tldts-7.5.4.tgz", + "integrity": "sha512-Rn2ABgjHZrA+jzqom5zhxA0hLohzYrIgfCPyhpTUxqsUrcsBYuab49LseR9waB9Jr8/MxdodvMHA91oRiGLO3Q==", "devOptional": true, "license": "MIT", "dependencies": { - "tldts-core": "^7.4.16" + "tldts-core": "^7.5.4" }, "bin": { "tldts": "bin/cli.js" } }, "node_modules/tldts-core": { - "version": "7.4.16", - "resolved": "https://registry.npmjs.org/tldts-core/-/tldts-core-7.4.16.tgz", - "integrity": "sha512-MDolfaSJtlSK5Y0A1xl3277ekubZwobpBjugknDizI9O5Rm60a1m8k4ICK+MRsCDzPygT81mp3BBf5RKDlFRfA==", + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/tldts-core/-/tldts-core-7.5.4.tgz", + "integrity": "sha512-9+4zWtKEDZ3V3FoZ1B97rv+5z5oqp7yeXGVze3CxgQ+CJro9do9DCPD00wxstYZDXDMXsurkBerFfiB6GYtPbA==", "devOptional": true, "license": "MIT" }, @@ -9898,9 +10235,9 @@ } }, "node_modules/tough-cookie": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-6.0.2.tgz", - "integrity": "sha512-exgYmnmL/sJpR3upZfXG5PoatXQii55xAiXGXzY+sROLZ/Y+SLcp9PgJNI9Vz37HpQ74WvDcLT8eqm+kV3FzrA==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-6.1.0.tgz", + "integrity": "sha512-FTxc8u8Kl2tz0Lat1u8ksvcy8bwHRyEMawwTWybo51JqaC6O7SvfuhAKg+Ld6VqyIe2QRJBzY9HA7y2WyFRT2w==", "devOptional": true, "license": "BSD-3-Clause", "dependencies": { @@ -9927,6 +10264,7 @@ "version": "2.5.0", "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.5.0.tgz", "integrity": "sha512-OJ/ibxhPlqrMM0UiNHJ/0CKQkoKF243/AEmplt3qpRgkW8VG7IfOS41h7V8TjITqdByHzrjcS/2si+y4lIh8NA==", + "dev": true, "license": "MIT", "engines": { "node": ">=18.12" @@ -9958,10 +10296,18 @@ "typescript": ">=4.0.0" } }, + "node_modules/tslib": { + "version": "2.9.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.9.1.tgz", + "integrity": "sha512-a4Ux9VKuIMHsOS7ENbEq6hK2ZGYIT27Rtl0E4eD9KqwxhKiQeMZE/9xb3IdYwWaSOyIBQLExhQgXDTYoiCxnWA==", + "license": "0BSD", + "optional": true + }, "node_modules/type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", + "dev": true, "license": "MIT", "dependencies": { "prelude-ls": "^1.2.1" @@ -10051,6 +10397,7 @@ "version": "6.0.3", "resolved": "https://registry.npmjs.org/typescript/-/typescript-6.0.3.tgz", "integrity": "sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw==", + "dev": true, "license": "Apache-2.0", "bin": { "tsc": "bin/tsc", @@ -10061,16 +10408,16 @@ } }, "node_modules/typescript-eslint": { - "version": "8.71.0", - "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.71.0.tgz", - "integrity": "sha512-fBdHYiqQ14RW6mOMXD14Svn82ZsCYAoQSzGRzyEjR59S5A2Krh/l7fGTOQ7iCr8gGy/mHVXtEF7s5fgjEdV0Pw==", + "version": "8.73.0", + "resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.73.0.tgz", + "integrity": "sha512-+EnKy9rkYPun4l+kG2bDuYWQ6y1tGVgdR/tY1U9AC6h21CjEwOoc7gsjwe0FXB8uWFzk4QiCFbuRWgX758PiAg==", "dev": true, "license": "MIT", "dependencies": { - "@typescript-eslint/eslint-plugin": "8.71.0", - "@typescript-eslint/parser": "8.71.0", - "@typescript-eslint/typescript-estree": "8.71.0", - "@typescript-eslint/utils": "8.71.0" + "@typescript-eslint/eslint-plugin": "8.73.0", + "@typescript-eslint/parser": "8.73.0", + "@typescript-eslint/typescript-estree": "8.73.0", + "@typescript-eslint/utils": "8.73.0" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" @@ -10111,9 +10458,9 @@ } }, "node_modules/undici": { - "version": "7.30.0", - "resolved": "https://registry.npmjs.org/undici/-/undici-7.30.0.tgz", - "integrity": "sha512-dkrQXeHSaoamnItlYbmzG0wFYrM0ZwDxCIg0A7aKjTyyhh9svRzCNFEzV+Vm05/yehjCzjDZ31KXfGEjYSztDQ==", + "version": "7.30.2", + "resolved": "https://registry.npmjs.org/undici/-/undici-7.30.2.tgz", + "integrity": "sha512-mLyPQnHwUxaM/rideoK/+KL8DaAJLRl4aBCfmX444aCSLnIaomqPLtNRe2jdCYcsk5wZzXrDIQC8ZeYNRAYyIA==", "devOptional": true, "license": "MIT", "engines": { @@ -10209,9 +10556,9 @@ } }, "node_modules/unplugin-dts": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/unplugin-dts/-/unplugin-dts-1.1.1.tgz", - "integrity": "sha512-Z2VcabC0hjYuzF62oWmZXVoxagkM8bUWgqUy+dotoJTPnooR5mNaxbpv63JCmcaxdGCW2Bb75omK6FOryOYCRg==", + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/unplugin-dts/-/unplugin-dts-1.1.2.tgz", + "integrity": "sha512-RDqy90XUmFj6rz4U5YoTMdYdaCJe2ZnQZaWIjkWS4952Gv0zBTQyqWtlGgVMPYHa982dURvyoc+sUOFIcDFv+w==", "dev": true, "license": "MIT", "dependencies": { @@ -10301,9 +10648,9 @@ } }, "node_modules/update-browserslist-db": { - "version": "1.3.3", - "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.3.3.tgz", - "integrity": "sha512-pJ2sYawQS0R/WI928Gj5GlPhTGzbMelq0+4INtSYNDV9ErKJcX6xjGWkoG/VnB3dpUm00zALaqkrUD77pO5TDQ==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.4.0.tgz", + "integrity": "sha512-WPJuOnjI9FWDct4fB+ej4Mz8opLaw5CDcZ2t44tFZ0vIQVYWzBhWR3mkixuUj/A7+vY4V9+ApOZ2YYLwdgq46w==", "dev": true, "funding": [ { @@ -10335,15 +10682,16 @@ "version": "4.4.1", "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, "license": "BSD-2-Clause", "dependencies": { "punycode": "^2.1.0" } }, "node_modules/uuid": { - "version": "14.0.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-14.0.2.tgz", - "integrity": "sha512-xZe/16rV4aa+HGSOCiY2YeLT1OybRLrrkL/Rqaq7p7GMVXjFh+6wN4oMYgjFmnSnhY8t6Xpdl2l9qmnHYuMHwQ==", + "version": "14.0.3", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-14.0.3.tgz", + "integrity": "sha512-Sc5u1VVln93y1Xnz4R+CunOZc7R9LUcTmhj7Rc7Eg3HVcf7rVn2FOoa812fe0W8p3jD7xeoGSYbfqCGGH2B6xw==", "funding": [ "https://github.com/sponsors/broofa", "https://github.com/sponsors/ctavan" @@ -10360,15 +10708,15 @@ "license": "MIT" }, "node_modules/vite": { - "version": "8.3.1", - "resolved": "https://registry.npmjs.org/vite/-/vite-8.3.1.tgz", - "integrity": "sha512-/bvH9E9tmCXRGp2uXY3WbOldqpTwFkbha/8ANaEQ6VkxhH60KyqLwgZq6lG2y+4uT55x9+9eUHMpQ7uGnOCKjA==", + "version": "8.3.8", + "resolved": "https://registry.npmjs.org/vite/-/vite-8.3.8.tgz", + "integrity": "sha512-LzOn3h9rG/0vhLdXrV4yJ4QFA9eEoqCl+Yx+kGJd7aB9w6nfNgVHKSYwLPZUHrz4ZGa+t+kXjV9itvcHDLQouA==", "license": "MIT", "dependencies": { "lightningcss": "^1.33.0", "picomatch": "^4.0.7", - "postcss": "^8.5.28", - "rolldown": "~1.2.9", + "postcss": "^8.5.32", + "rolldown": "~1.2.18", "tinyglobby": "^0.2.17" }, "bin": { @@ -10385,7 +10733,7 @@ }, "peerDependencies": { "@types/node": "^20.19.0 || >=22.12.0", - "@vitejs/devtools": "^0.7.1", + "@vitejs/devtools": "^0.7.1 || ^0.8.0", "esbuild": "^0.27.0 || ^0.28.0", "jiti": ">=1.21.0", "less": "^4.0.0", @@ -10459,19 +10807,338 @@ "vite": "^7.0.0 || ^8.0.0" } }, + "node_modules/vite/node_modules/@oxc-project/types": { + "version": "0.156.0", + "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.156.0.tgz", + "integrity": "sha512-1Duyg48TdJNdyhEB8Xn1L36bT9Pv6GUtlKjHxOys8xkaF/rQq3XJE+bAurSK/AgIz5mGFsb77cn9Pb20+WCScw==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/oxc-project" + } + }, + "node_modules/vite/node_modules/@rolldown/binding-android-arm-eabi": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm-eabi/-/binding-android-arm-eabi-1.2.19.tgz", + "integrity": "sha512-e+Ebe0WT+9tbXmNKPIiC8YrWAHYwug3m6i4p3rZGGulfZri1jtI4HslT+OZnFf/OIHowWF71DTlHwXBP2SiA7A==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/vite/node_modules/@rolldown/binding-android-arm64": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.2.19.tgz", + "integrity": "sha512-hOombrTJ+szt2ciEzS7oCA78lMPBgF5UMQWCJIyNfnrI7GLl8HYoFqCnpL2gcPOaXMqryGCU5ExdQKyDDcC+yA==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/vite/node_modules/@rolldown/binding-darwin-arm64": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.2.19.tgz", + "integrity": "sha512-XoMA2pwCKGTQzUjPgtRwkedH4WmXhdIPKT6l6oOxd1PUbNodGI6DcBekgN7EC//+x3pfBYX/qL1gNmZAqivw5g==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/vite/node_modules/@rolldown/binding-darwin-x64": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.2.19.tgz", + "integrity": "sha512-zo8EsSSwMZCY/e+fRnGaX02YGgvJD0yvhNi/9hpGPA2MJ9ZF8dPCw75UGfpI6OpQ/myR/dIYmogRvqiZD0TrXg==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/vite/node_modules/@rolldown/binding-freebsd-x64": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.2.19.tgz", + "integrity": "sha512-O8ISAOfI1nj7AuBPd30FSF47z7f7lzlk5poQVGgiikvQuGEBFYvW8ki+UEnT+YJPnNGjQzn304klt4O9FUE7mA==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/vite/node_modules/@rolldown/binding-linux-arm-gnueabihf": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.2.19.tgz", + "integrity": "sha512-/lYCba5NO0yq4S0jGMH8QTBtkvQxoXjoQWzF5BcWp9MjB9jxVRD1GQDNofkVjcOj30DWyhLIN/4Oe60JKzaONw==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/vite/node_modules/@rolldown/binding-linux-arm64-gnu": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.2.19.tgz", + "integrity": "sha512-pm/apFMBnSbFb3O6nG5pHO1iqHhZrjGDFEjSm+ot9J17XXPvH9L90y5h+jgfHCE+Qdlsvy8qKEcU4VKxgjD+vA==", + "cpu": [ + "arm64" + ], + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/vite/node_modules/@rolldown/binding-linux-arm64-musl": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.2.19.tgz", + "integrity": "sha512-K1SmQp3FFichn8oqrNIwvFoZ5wcvjC7goBzpaMNvLf9FZc+QB/QvLmnpJZgAAGHiD980tP8FZZnXk2K94rvlxg==", + "cpu": [ + "arm64" + ], + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/vite/node_modules/@rolldown/binding-linux-ppc64-gnu": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.2.19.tgz", + "integrity": "sha512-I0xwD57jP/3A7+5UPZin2w8Y7XHEmEM5zqpYZOcQ45MlNW6tUJUziymV3yRr7rL4vwyfEcRsRksC4a7Kc08p5Q==", + "cpu": [ + "ppc64" + ], + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/vite/node_modules/@rolldown/binding-linux-s390x-gnu": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.2.19.tgz", + "integrity": "sha512-BrtEHT24SNXj9HiXqy+s/kXiSiQGt6EKCPUlRirAoIioVxKGnbXBUEkbZASAei7iZJB0/Ynm+0JP00Ipx7AnSw==", + "cpu": [ + "s390x" + ], + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/vite/node_modules/@rolldown/binding-linux-x64-gnu": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.2.19.tgz", + "integrity": "sha512-rm75/9DkHKeU2WnA8w4X94WGYgLlDCFCfkQC+4bguVJmC/jvDRv2B+2wLOYhyE0fVuv7//Ckk39OoOufyCu76Q==", + "cpu": [ + "x64" + ], + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/vite/node_modules/@rolldown/binding-linux-x64-musl": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.2.19.tgz", + "integrity": "sha512-irh/4+iYFM4GAzpluDErgjz89bj6NDtqqMAG/6O1LG38Ed3NpyebzCpcVNkFW8uhy+/3/BocUvnXDR33CXWe9A==", + "cpu": [ + "x64" + ], + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/vite/node_modules/@rolldown/binding-openharmony-arm64": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.2.19.tgz", + "integrity": "sha512-+KWTWNoPt+CfSq94CiceWu3yPE+QzkaG+phPyz9G60tmZLwfQkcA4AeksafzvJAw4pvg1mcd5a1TkUqVv0s4JA==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/vite/node_modules/@rolldown/binding-wasm32-wasi": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-wasm32-wasi/-/binding-wasm32-wasi-1.2.19.tgz", + "integrity": "sha512-7EH+skOsl5qpWnK0vzamgJFhOv1cwxQpsxm8tI883K9fur5c27p8q87fzEO6BbBPabA2/+s/zR63/pLc137iOg==", + "cpu": [ + "wasm32" + ], + "license": "MIT", + "optional": true, + "dependencies": { + "@emnapi/core": "2.0.0-beta.2", + "@emnapi/runtime": "2.0.0-beta.2", + "@napi-rs/wasm-runtime": "1.2.6" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=23.5.0" + } + }, + "node_modules/vite/node_modules/@rolldown/binding-win32-arm64-msvc": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.2.19.tgz", + "integrity": "sha512-3Q1Yg1Q7tEvBWoZf5rFvG/GKZQPgwfru+p4wBajDfJFBs0SHCpL++dfTjW9gyAKd1T7ZpIYvdaUax7Pa/IhFVQ==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/vite/node_modules/@rolldown/binding-win32-x64-msvc": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.2.19.tgz", + "integrity": "sha512-y/sqRRc6d7hECzOFc5n3LSeqctmIp9mMjY1Kq4s14uLPd/LZ4z7i1zrW6fMtp2mPeuQIC4e6ULMcwQzMomqQag==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/vite/node_modules/rolldown": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.2.19.tgz", + "integrity": "sha512-QIiV1J9d0pzN4jeeTH4sjPy0AZ6cAy2cG0ExeoE1+U8Rvj+hR3gYkokx0YbeUNGlZqiQJJ2utcETe0oKXwzsuA==", + "license": "MIT", + "dependencies": { + "@oxc-project/types": "=0.156.0", + "@rolldown/pluginutils": "^1.0.0" + }, + "bin": { + "rolldown": "bin/cli.mjs" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "optionalDependencies": { + "@rolldown/binding-android-arm-eabi": "1.2.19", + "@rolldown/binding-android-arm64": "1.2.19", + "@rolldown/binding-darwin-arm64": "1.2.19", + "@rolldown/binding-darwin-x64": "1.2.19", + "@rolldown/binding-freebsd-x64": "1.2.19", + "@rolldown/binding-linux-arm-gnueabihf": "1.2.19", + "@rolldown/binding-linux-arm64-gnu": "1.2.19", + "@rolldown/binding-linux-arm64-musl": "1.2.19", + "@rolldown/binding-linux-ppc64-gnu": "1.2.19", + "@rolldown/binding-linux-s390x-gnu": "1.2.19", + "@rolldown/binding-linux-x64-gnu": "1.2.19", + "@rolldown/binding-linux-x64-musl": "1.2.19", + "@rolldown/binding-openharmony-arm64": "1.2.19", + "@rolldown/binding-wasm32-wasi": "1.2.19", + "@rolldown/binding-win32-arm64-msvc": "1.2.19", + "@rolldown/binding-win32-x64-msvc": "1.2.19" + } + }, "node_modules/vitest": { - "version": "4.1.11", - "resolved": "https://registry.npmjs.org/vitest/-/vitest-4.1.11.tgz", - "integrity": "sha512-fhACrNXUidIbGSBr5FlbuBkO7VWC1ZyLl0DO4CU2DrQoAPxX84Ysxs+HeGQpii5lZWV1Q4gBZTTu49mF+A6Edw==", - "license": "MIT", - "dependencies": { - "@vitest/expect": "4.1.11", - "@vitest/mocker": "4.1.11", - "@vitest/pretty-format": "4.1.11", - "@vitest/runner": "4.1.11", - "@vitest/snapshot": "4.1.11", - "@vitest/spy": "4.1.11", - "@vitest/utils": "4.1.11", + "version": "4.1.12", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-4.1.12.tgz", + "integrity": "sha512-5eWdz2yb3ajxWF3C8C4TjkXl7FGm3n2E/VlazALrQHzK7nYMSGFnCZto0bbPNl77AwkOZVLk0YnBAejUu0NiWA==", + "license": "MIT", + "dependencies": { + "@vitest/expect": "4.1.12", + "@vitest/mocker": "4.1.12", + "@vitest/pretty-format": "4.1.12", + "@vitest/runner": "4.1.12", + "@vitest/snapshot": "4.1.12", + "@vitest/spy": "4.1.12", + "@vitest/utils": "4.1.12", "es-module-lexer": "^2.0.0", "expect-type": "^1.3.0", "magic-string": "^0.30.21", @@ -10499,12 +11166,12 @@ "@edge-runtime/vm": "*", "@opentelemetry/api": "^1.9.0", "@types/node": "^20.0.0 || ^22.0.0 || >=24.0.0", - "@vitest/browser-playwright": "4.1.11", - "@vitest/browser-preview": "4.1.11", - "@vitest/browser-webdriverio": "4.1.11", - "@vitest/coverage-istanbul": "4.1.11", - "@vitest/coverage-v8": "4.1.11", - "@vitest/ui": "4.1.11", + "@vitest/browser-playwright": "4.1.12", + "@vitest/browser-preview": "4.1.12", + "@vitest/browser-webdriverio": "^4.1.11", + "@vitest/coverage-istanbul": "4.1.12", + "@vitest/coverage-v8": "4.1.12", + "@vitest/ui": "4.1.12", "happy-dom": "*", "jsdom": "*", "vite": "^6.0.0 || ^7.0.0 || ^8.0.0" @@ -10577,6 +11244,41 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, + "node_modules/vscode-jsonrpc": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-10.0.0.tgz", + "integrity": "sha512-USSfxg0vDIpTQqlQBGxF3mBARyoS8cU7LHLpbYNh6dOJt32dlskxPWB0Irrh5TllTmyf7oNLAvqDqzklbwwnpA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.17.0" + } + }, + "node_modules/vscode-languageserver-protocol": { + "version": "3.18.5", + "resolved": "https://registry.npmjs.org/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.18.5.tgz", + "integrity": "sha512-FW4fBMzZ99N8xeob4py0l050wgCoRgTpEq5Xcsb9lM1bc29UKGR/wSV+4knaqFxssFHajy7OzNiKP/m3U1ZEuA==", + "dev": true, + "license": "MIT", + "dependencies": { + "vscode-jsonrpc": "10.0.0", + "vscode-languageserver-types": "3.18.5" + } + }, + "node_modules/vscode-languageserver-textdocument": { + "version": "1.0.16", + "resolved": "https://registry.npmjs.org/vscode-languageserver-textdocument/-/vscode-languageserver-textdocument-1.0.16.tgz", + "integrity": "sha512-qeNEuOi9a3qkqRf7Gfez2WL2VwlBTLCNekHBGO9kxPVUp9XuY15yfTJ9jwvOwKI0I2MhUUfZq95NSp+LK1CLQg==", + "dev": true, + "license": "MIT" + }, + "node_modules/vscode-languageserver-types": { + "version": "3.18.5", + "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.18.5.tgz", + "integrity": "sha512-kPd6+JQNz3HMJvjKlqUxERSlZHAntl/aGpsk7ImwIh0ewDKDcjgAEyVSYciPiOJD3ftbK9IrfiqUeTZLSbCizw==", + "dev": true, + "license": "MIT" + }, "node_modules/vscode-uri": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/vscode-uri/-/vscode-uri-3.2.0.tgz", @@ -10784,6 +11486,7 @@ "version": "1.2.5", "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", + "dev": true, "license": "MIT", "engines": { "node": ">=0.10.0" @@ -10939,6 +11642,7 @@ "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "dev": true, "license": "MIT", "engines": { "node": ">=10" diff --git a/package.json b/package.json index 92d69c55..a1dcf968 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "solid-panes", - "version": "5.0.0", + "version": "5.1.0", "description": "Solid-compatible Panes: applets and views for the mashlib and databrowser", "main": "dist/index.cjs.js", "types": "dist/index.d.ts", @@ -25,7 +25,7 @@ "lint-fix": "eslint --fix", "typecheck": "tsc --noEmit", "typecheck-test": "tsc --noEmit -p tsconfig.test.json", - "test": "npm run typecheck-test && vitest run", + "test": "npm run build-version && npm run typecheck-test && vitest run", "test-coverage": "vitest run --coverage", "prepublishOnly": "npm run build && npm run lint && npm test", "preversion": "npm run lint && npm run typecheck && npm test", @@ -56,24 +56,25 @@ }, "homepage": "https://github.com/SolidOS/solid-panes", "dependencies": { + "@lit/context": "^1.1.6", "@solid/better-simple-slideshow": "^0.1.0", - "activitystreams-pane": "2.0.0", + "activitystreams-pane": "2.1.0", "chat-pane": "4.0.0", - "contacts-pane": "4.0.0", + "contacts-pane": "4.1.0", "dompurify": "^3.4.4", - "folder-pane": "4.0.0", - "issue-pane": "4.0.0", + "folder-pane": "4.1.0", + "issue-pane": "4.1.0", "lit-html": "^3.3.2", "marked": "^18.0.3", - "meeting-pane": "4.0.0", + "meeting-pane": "4.1.0", "mime-types": "^3.0.2", - "pane-registry": "5.0.1", - "profile-pane": "4.0.0", + "pane-registry": "5.1.1", + "profile-pane": "4.1.0", "rdflib": "2.4.1", - "solid-logic": "6.0.0", + "solid-logic": "6.2.0", "solid-namespace": "^0.5.4", - "solid-ui": "5.0.1", - "source-pane": "4.0.0" + "solid-ui": "5.1.0", + "source-pane": "4.1.0" }, "overrides": { "rdflib": "$rdflib" diff --git a/src/RDFXMLPane.ts b/src/RDFXMLPane.ts index 0617deeb..e45dcb36 100644 --- a/src/RDFXMLPane.ts +++ b/src/RDFXMLPane.ts @@ -67,9 +67,14 @@ export const RDFXMLPane: RDFXMLPaneDefinition = { const source = myDocument.createElement('solid-panes-editor-card') as HTMLElement & { contentType?: string content?: string + accessibilityLabel?: string + accessibilityDescription?: string } source.contentType = 'application/rdf+xml' source.content = serializedContent + source.accessibilityLabel = `Generated RDF/XML for ${subject.uri}` + source.accessibilityDescription = + 'Generated RDF/XML serialization. This content is read-only.' div.appendChild(source) return div diff --git a/src/components/editor-card/EditorCard.ts b/src/components/editor-card/EditorCard.ts index d3dd4300..66b66c85 100644 --- a/src/components/editor-card/EditorCard.ts +++ b/src/components/editor-card/EditorCard.ts @@ -19,6 +19,12 @@ export default class EditorCard extends WebComponent { @property() accessor content: string | undefined + @property() + accessor accessibilityLabel: string | undefined + + @property() + accessor accessibilityDescription: string | undefined + getEditor () { return this._editor } @@ -41,7 +47,17 @@ export default class EditorCard extends WebComponent { const { CodeEditor } = await import('solid-ui') this._editor = new CodeEditor() try { - await this._editor.initialize(editorDiv, this.content ?? '', this.contentType ?? '', 'dark') + await this._editor.initialize( + editorDiv, + this.content ?? '', + this.contentType ?? '', + 'dark', + undefined, + { + label: this.accessibilityLabel, + description: this.accessibilityDescription + } + ) } catch (err) { throw new Error(`Error initializing code editor: ${err instanceof Error ? err.message : String(err)}`) } diff --git a/src/components/file-explorer-header/FileExplorerHeader.styles.css b/src/components/file-explorer-header/FileExplorerHeader.styles.css deleted file mode 100644 index 866bd8cb..00000000 --- a/src/components/file-explorer-header/FileExplorerHeader.styles.css +++ /dev/null @@ -1,13 +0,0 @@ -:host { - header { - display: flex; - justify-content: space-between; - align-items: center; - gap: 6px; - flex-wrap: nowrap; - width: 100%; - text-align: right; - padding: 10px; - border-bottom: 1px solid var(--solid-ui-color-gray-200, #cbd5e1); - } -} diff --git a/src/components/file-explorer-header/FileExplorerHeader.ts b/src/components/file-explorer-header/FileExplorerHeader.ts deleted file mode 100644 index b51c4d82..00000000 --- a/src/components/file-explorer-header/FileExplorerHeader.ts +++ /dev/null @@ -1,86 +0,0 @@ -import { sym } from 'rdflib' -import { WebComponent, type FileExplorerContext, fileExplorerContext } from 'solid-ui' -import { customElement, property, state } from 'lit/decorators.js' -import { consume } from '@lit/context' -import { html } from 'lit' -import '~icons/lucide/share-2' -import '~icons/lucide/pencil' -import '~icons/lucide/ellipsis-vertical' -import styles from './FileExplorerHeader.styles.css' -import './FileExplorerHeaderSummary' -import './FileExplorerHeaderControls' -import { PaneIcon } from './types' -import { fetchResourceMetadata } from '../../utils/podUtils' -import { type FileExplorerResourceMetadata } from './types' -@customElement('file-explorer-header') -export default class FileExplorerHeader extends WebComponent { - static styles = styles - - private _loadedMetadataForUri: string | undefined - - @consume({ context: fileExplorerContext, subscribe: true }) - accessor fileExplorerContext: FileExplorerContext = undefined as unknown as FileExplorerContext - - @property({ attribute: false }) - accessor menuItems: Array<{ label: string, action: (event: Event) => void }> = [] - - @property({ attribute: false }) - accessor paneIcon: PaneIcon = undefined as unknown as PaneIcon - - @state() - accessor responseMetadata: Pick = { - modified: undefined, - isPublic: false, - canEdit: false, - aclUri: undefined - } - - private getDefaultResponseMetadata (): Pick { - return { - modified: undefined, - isPublic: false, - canEdit: false, - aclUri: undefined - } - } - - protected updated () { - if (this.fileExplorerContext?.store && this.fileExplorerContext.subjectUri && this._loadedMetadataForUri !== this.fileExplorerContext.subjectUri) { - this._loadedMetadataForUri = this.fileExplorerContext.subjectUri - this.loadResponseMetadata() - } - } - - private async loadResponseMetadata () { - if (!this.fileExplorerContext?.store || !this.fileExplorerContext.subjectUri) return - - try { - const metadata = await fetchResourceMetadata(this.fileExplorerContext.store, sym(this.fileExplorerContext.subjectUri)) - this.responseMetadata = { - modified: metadata.modified, - isPublic: metadata.isPublic, - canEdit: metadata.canEdit, - aclUri: metadata.aclUri - } - } catch (error) { - this.responseMetadata = this.getDefaultResponseMetadata() - console.warn('Failed to load response metadata', error) - } - } - - render () { - return html` -
- - -
- ` - } -} diff --git a/src/components/file-explorer-header/FileExplorerHeaderControls.styles.css b/src/components/file-explorer-header/FileExplorerHeaderControls.styles.css deleted file mode 100644 index dc411a3c..00000000 --- a/src/components/file-explorer-header/FileExplorerHeaderControls.styles.css +++ /dev/null @@ -1,69 +0,0 @@ -:host { - flex: 0 1 auto; - min-width: 0; - - div { - display: flex; - justify-content: flex-end; - align-items: center; - gap: 6px; - flex: 0 0 auto; - text-align: right; - } - - /* generative ai */ - div > * { - flex: 0 1 auto; - } - - .file-explorer-header-action-button { - width: var(--solid-ui-clickable-area, 42px); - height: var(--solid-ui-clickable-area, 42px); - padding: 0; - } - - /* TODO: look into what colors to use this is just to show */ - .dirtyIndicator { - display: inline-flex; - align-items: center; - border: 1px solid #F59E0B; - color: #92400E; - background: #FFFBEB; - border-radius: 999px; - font-size: 0.72rem; - font-weight: 600; - line-height: 1; - padding: 4px 8px; - white-space: nowrap; - } - - icon-lucide-user-round-cog, - icon-lucide-pencil { - width: 16px; - height: 16px; - } - - @media (max-width: 900px) { - div { - padding-right: 3px; - } - } - - @media (max-width: 600px) { - div { - justify-content: flex-start; - gap: 5px; - } - - .file-explorer-header-action-button { - display: none; - } - - icon-lucide-ellipsis-vertical { - width: 15.36px; - height: 15.36px; - flex-shrink: 0; - aspect-ratio: 1 / 1; - } - } -} diff --git a/src/components/file-explorer-header/FileExplorerHeaderControls.ts b/src/components/file-explorer-header/FileExplorerHeaderControls.ts deleted file mode 100644 index 5e03da39..00000000 --- a/src/components/file-explorer-header/FileExplorerHeaderControls.ts +++ /dev/null @@ -1,116 +0,0 @@ -import { WebComponent } from 'solid-ui' -import { customElement, property, state } from 'lit/decorators.js' -import { consume } from '@lit/context' -import { html, nothing } from 'lit' -import 'solid-ui/components/button' -import '~icons/lucide/user-round-cog' -import '~icons/lucide/pencil' -import styles from './FileExplorerHeaderControls.styles.css' -import '../resource-actions-menu/ResourceActionsMenu' -import { fileExplorerContext, type FileExplorerContext } from 'solid-ui' -import { isContainerSubject } from '../../utils/podUtils' - -@customElement('file-explorer-header-controls') -export default class FileExplorerHeaderControls extends WebComponent { - static styles = styles - - private mobileMediaQuery: MediaQueryList | undefined - private readonly mobileQuery = '(max-width: 600px)' - private readonly handleMobileMediaChange = (event: MediaQueryListEvent) => { - this.isMobile = event.matches - } - - @consume({ context: fileExplorerContext, subscribe: true }) - accessor fileExplorerContext: FileExplorerContext = undefined as unknown as FileExplorerContext - - @property({ attribute: false }) - accessor menuItems: Array<{ label: string, action: (event: Event) => void, icon?: HTMLElement }> = [] - - @property({ type: Boolean }) - accessor canEdit: boolean = false - - @state() - accessor isMobile = typeof window !== 'undefined' && typeof window.matchMedia === 'function' - ? window.matchMedia('(max-width: 600px)').matches - : false - - connectedCallback () { - super.connectedCallback() - - if (typeof window === 'undefined' || typeof window.matchMedia !== 'function') { - return - } - - this.mobileMediaQuery = window.matchMedia(this.mobileQuery) - this.isMobile = this.mobileMediaQuery.matches - this.mobileMediaQuery.addEventListener('change', this.handleMobileMediaChange) - } - - disconnectedCallback () { - this.mobileMediaQuery?.removeEventListener('change', this.handleMobileMediaChange) - this.mobileMediaQuery = undefined - super.disconnectedCallback() - } - - // TODO: Add broken then use this function to set tooltip and disable edit button - /* private setEditable() { - const sourcePaneState = this.sourceContext?.sourcePaneState - const { canEdit } = this.sourceContext?.headerMetadata ?? { canEdit: false } - const subject = this.sourceContext?.subject - if (!sourcePaneState || !canEdit || sourcePaneState.broken || (subject && subject.endsWith('/'))) return - - this.sourceContext?.setEditing?.() - } */ - - private getEditTooltip () { - if (!this.canEdit) return 'No Access' - return 'Edit' - } - - private renderDirtyIndicator () { - if (!this.fileExplorerContext.edit?.isDirty) return nothing - - return html`Unsaved` - } - - render () { - const isContainerResource = isContainerSubject(this.fileExplorerContext.store, this.fileExplorerContext.subjectUri) - const supportsEditing = this.fileExplorerContext.paneSupportsEditing - - return html` -
- ${this.renderDirtyIndicator()} - ${!isContainerResource && !this.isMobile - ? html` - - - - ${supportsEditing - ? html` - - - - ` - : nothing} - ` - : nothing} - -
- ` - } -} diff --git a/src/components/file-explorer-header/FileExplorerHeaderSummary.styles.css b/src/components/file-explorer-header/FileExplorerHeaderSummary.styles.css deleted file mode 100644 index db9952b7..00000000 --- a/src/components/file-explorer-header/FileExplorerHeaderSummary.styles.css +++ /dev/null @@ -1,148 +0,0 @@ - :host { - .file-explorer-header-summary { - display: flex; - justify-content: flex-start; - align-items: center; - gap: 6px; - flex-wrap: wrap; - flex: 1 1 auto; - min-width: 0; - text-align: left; - } - - h1 { - color: var(--solid-ui-color-gray-700, #364153); - font-size: var(--solid-ui-font-size-xl, 1.25rem); /* while in expand; will go to 2xl when new design is complete */ - font-weight: 500; - display: flex; - align-items: center; - gap: 8px; - margin: 0; - } - - .resource-info { - display: flex; - flex-direction: column; - min-width: 0; - } - - .container-info { - display: flex; - flex-direction: row; - gap: 10px; - min-width: 0; - } - - .pane-icon { - display: flex; - width: 40px; - height: 40px; - padding: 7.5px 7px 6.5px 7px; - justify-content: center; - align-items: center; - aspect-ratio: 1/1; - /* border-radius: 100px; */ - /* background: var(--slate-600, #45556C); */ - } - - .pane-icon img { - width: 100%; - height: 100%; - object-fit: contain; - display: block; - } - - p { - display: flex; - align-items: center; - gap: 5px; - color: var(--solid-ui-gray-500, #6A7282); - font-size: var(--solid-ui-font-size-xs, .75rem); - font-weight: 500; - } - - .public { - display: flex; - padding: 2px 5px; - justify-content: center; - align-items: center; - gap: 3px; - color: var(--blue-400, #51A2FF); - border-radius: 5px; - background: var(--blue-50, #EFF6FF); - } - - icon-lucide-globe { - stroke-width: 1.021px; - stroke: var(--blue-400, #51A2FF); - } - - .private { - display: flex; - padding: 2px 5px; - justify-content: center; - align-items: center; - gap: 3px; - color: var(--yellow-600, #D08700); - border-radius: 5px; - background: var(--yellow-100, #FEF9C2); - } - - icon-lucide-lock-keyhole { - stroke-width: 1.021px; - stroke: var(--yellow-600, #D08700); - } - - icon-lucide-globe, - icon-lucide-lock-keyhole { - width: 0.875rem; - height: 0.875rem; - } - - .resource-date { - font-size: inherit; - } - - icon-lucide-arrow-left { - width: 1.125rem; - height: 1.125rem; - } - - @media (max-width: 600px) { - .file-explorer-header-summary { - gap: 7px; - } - - h1 { - font-size: 14px; - } - - .pane-icon { - width: 18.2px; - height: 18.2px; - flex-shrink: 0; - aspect-ratio: 1 / 1; - padding: 0; - } - - p { - font-size: 14px; - } - - .resource-date { - font-size: 10px; - } - - .public, - .private { - font-size: 9px; - } - - icon-lucide-arrow-left { - width: 15px; - height: 18px; - flex-shrink: 0; - aspect-ratio: 5 / 6; - } - } -} diff --git a/src/components/file-explorer-header/FileExplorerHeaderSummary.ts b/src/components/file-explorer-header/FileExplorerHeaderSummary.ts deleted file mode 100644 index 2ca785d5..00000000 --- a/src/components/file-explorer-header/FileExplorerHeaderSummary.ts +++ /dev/null @@ -1,151 +0,0 @@ -import { sym } from 'rdflib' -import { widgets, utils, WebComponent, fileExplorerContext, type FileExplorerContext } from 'solid-ui' -import 'solid-ui/components/button' -import { customElement, property, query, state } from 'lit/decorators.js' -import { html } from 'lit' -import { consume } from '@lit/context' -import { PaneIcon } from './types' -import '~icons/lucide/globe' -import '~icons/lucide/lock-keyhole' -import '~icons/lucide/arrow-left' -import '~icons/lucide/folder' -import styles from './FileExplorerHeaderSummary.styles.css' -import { getContainerItemCount, isContainerSubject } from '../../utils/podUtils' -import type { FileExplorerResourceMetadata } from './types' - -@customElement('file-explorer-header-summary') -export default class FileExplorerHeaderSummary extends WebComponent { - static styles = styles - - private _draggableSubjectUri: string | undefined - private _resolvedPaneIconFor: PaneIcon | undefined - - @consume({ context: fileExplorerContext, subscribe: true }) - accessor fileExplorerContext: FileExplorerContext = undefined as unknown as FileExplorerContext - - @property({ attribute: false }) - accessor paneIcon: PaneIcon | undefined - - @property({ attribute: false }) - accessor onBackClick: (() => void) | undefined - - @property({ attribute: false }) - accessor responseMetadata: Pick = { - modified: undefined, - isPublic: false - } - - @state() - accessor resolvedPaneIcon: string | undefined = undefined - - @query('h1') - private accessor titleHeading: HTMLHeadingElement | null = null - - private formatModifiedDate (modified: string | undefined) { - if (!modified) return '' - - const date = new Date(modified) - if (Number.isNaN(date.getTime())) return modified - - const parts = new Intl.DateTimeFormat('en-GB', { - day: '2-digit', - month: 'short', - year: 'numeric', - hour: '2-digit', - minute: '2-digit', - hour12: true - }).formatToParts(date) - - const getPart = (type: Intl.DateTimeFormatPartTypes) => parts.find(part => part.type === type)?.value ?? '' - const day = getPart('day') - const month = getPart('month') - const year = getPart('year') - const hour = getPart('hour') - const minute = getPart('minute') - const dayPeriod = getPart('dayPeriod').toUpperCase() - - return `${day} ${month}, ${year} at ${hour}:${minute} ${dayPeriod}` - } - - protected updated () { - if (this.paneIcon !== undefined && this._resolvedPaneIconFor !== this.paneIcon) { - this._resolvedPaneIconFor = this.paneIcon - this.resolvePaneIcon() - } - - if (!this.titleHeading || !this.fileExplorerContext?.subjectUri || this._draggableSubjectUri === this.fileExplorerContext.subjectUri) return - - widgets.makeDraggable(this.titleHeading, sym(this.fileExplorerContext.subjectUri)) // doing it this way for now, just to keep the same functionality - this._draggableSubjectUri = this.fileExplorerContext.subjectUri - } - - // Needed because humanReadable pane can return a promise for an icon. - private async resolvePaneIcon () { - try { - if (this.paneIcon == null) { - this.resolvedPaneIcon = undefined - return - } - - const icon = await this.paneIcon - this.resolvedPaneIcon = icon ?? undefined - } catch (error) { - this.resolvedPaneIcon = undefined - console.warn('file-explorer-header-summary: failed to resolve pane icon', error) - } - } - - private renderContainerResourceHeader (label: string, isPublic: boolean) { - const itemCount = getContainerItemCount(this.fileExplorerContext?.store, this.fileExplorerContext?.subjectUri) ?? 0 - return html` -
-

- ${label} -

-

- ${itemCount} items - ${isPublic - ? html`` - : html``} -

-
- ` - } - - private renderResourceHeader (label: string, isPublic: boolean) { - const modified = this.formatModifiedDate(this.responseMetadata.modified) - - return html` -
-

- ${label} -

-

${modified} ${isPublic ? html` Public` : html` Private`}

-
- ` - } - - render () { - const subject = this.fileExplorerContext?.subjectUri ? sym(this.fileExplorerContext.subjectUri) : undefined - const label = subject ? utils.label(subject) : '' - const isPublic = this.responseMetadata.isPublic - const isContainerResource = isContainerSubject(this.fileExplorerContext?.store, this.fileExplorerContext?.subjectUri) - - return html` -
- - - - - ${this.resolvedPaneIcon ? html`` : ''} - - ${isContainerResource ? this.renderContainerResourceHeader(label, isPublic) : this.renderResourceHeader(label, isPublic)} -
- - ` - } -} diff --git a/src/components/file-explorer-header/FileExplorerProvider.styles.css b/src/components/file-explorer-header/FileExplorerProvider.styles.css deleted file mode 100644 index 298eedaa..00000000 --- a/src/components/file-explorer-header/FileExplorerProvider.styles.css +++ /dev/null @@ -1,20 +0,0 @@ -:host { - display: block; - width: 100%; - min-width: 0; - - .file-explorer-provider { - display: flex; - flex-direction: column; - width: 100%; - min-width: 0; - } - - slot.pane { - display: block; - flex: 1 1 auto; - width: 100%; - min-width: 0; - overflow: auto; - } -} diff --git a/src/components/file-explorer-header/FileExplorerProvider.ts b/src/components/file-explorer-header/FileExplorerProvider.ts deleted file mode 100644 index 3696b3e5..00000000 --- a/src/components/file-explorer-header/FileExplorerProvider.ts +++ /dev/null @@ -1,258 +0,0 @@ -import { html, nothing, type PropertyValues } from 'lit' -import type { NamedNode, LiveStore } from 'rdflib' -import { DataBrowserContext, type PaneDefinition } from 'pane-registry' -import { utils, WebComponent } from 'solid-ui' -import { provide } from '@lit/context' -import { fileExplorerContext, type FileExplorerContext, type FileExplorerEdit } from 'solid-ui' -import { customElement, property, state } from 'lit/decorators.js' -import './FileExplorerHeader' -import styles from './FileExplorerProvider.styles.css' -import personIcon from '../../icons/person.svg' -import friendsIcon from '../../icons/friends.svg' -import '~icons/lucide/share-2' - -const PERSON_ICON = personIcon -const FRIENDS_ICON = friendsIcon - -function createFileExplorerContextValue (value: { - store: LiveStore | undefined - subjectUri: string | undefined - pane?: PaneDefinition - soloPane?: boolean - onBack?: () => void - openPane?: (subject: NamedNode, paneName: string) => void - handleAccessClick?: () => void - paneSupportsEditing?: boolean - edit?: { - onEdit?: () => void - isDirty?: boolean - updateDirtyState?: (dirty: boolean) => void - } -}): FileExplorerContext { - return { - store: value.store as LiveStore, - subjectUri: value.subjectUri, - pane: value.pane, - soloPane: value.soloPane, - onBack: value.onBack, - openPane: value.openPane, - handleAccessClick: value.handleAccessClick, - paneSupportsEditing: value.paneSupportsEditing, - edit: value.edit - } -} -@customElement('file-explorer-provider') -export default class FileExplorerProvider extends WebComponent { - static styles = styles - - @property({ attribute: false }) - accessor context: DataBrowserContext | undefined = undefined - - @property({ attribute: false }) - accessor subjectUri: string | undefined = undefined - - @property({ attribute: false }) - accessor onBack: (() => void) | undefined = undefined - - @property({ attribute: false }) - accessor relevantPanes: PaneDefinition[] = [] - - @property({ attribute: false }) - accessor pane: PaneDefinition | undefined = undefined - - @property({ attribute: false }) - accessor paneRenderOptions: Record = {} - - @property({ attribute: false }) - accessor showHeader: boolean = true - - @property({ attribute: false }) - accessor handleAccessClick: (() => void) | undefined = undefined - - // TODO: Need to research this more, brought it over from manager. - @property({ attribute: false }) - accessor soloPane: boolean | undefined = undefined - - @property({ attribute: false }) - accessor openPane: ((subject: NamedNode, paneName: string) => void) | undefined = undefined - - @state() - accessor menuItems: Array<{ label: string, icon?: HTMLElement, action: (event: Event) => void }> = [] - - @state() - accessor isEditing: boolean = false - - @state() - accessor isDirty: boolean = false - - @state() - accessor paneSupportsEditing: boolean = false - - // TODO: For now this works, but check if there is a better way. - // because this means file explorer will know about the pane. - // what if other panes want to use this. If so maybe we should - // add more to the context to capture the provider for the pane that - // will be editing... anyway this shouldn't be just for source pane. - private beginEditingInSourcePane = () => { - const sourceProvider = this.querySelector('source-pane-source-provider') as { - beginEditing?: () => void - } | null - - sourceProvider?.beginEditing?.() - } - - // TODO: same as below. on Edit should be something more generic - @state() - accessor edit: FileExplorerEdit = { - onEdit: this.beginEditingInSourcePane, - isDirty: false, - updateDirtyState: (dirty: boolean) => { - if (this.isDirty === dirty) return - - this.isDirty = dirty - this.edit = { - ...this.edit, - isDirty: dirty - } - this.refreshFileExplorerContextValue() - } - } - - @provide({ context: fileExplorerContext }) - accessor fileExplorerContextValue: FileExplorerContext = createFileExplorerContextValue({ - store: this.context?.session.store as LiveStore, - subjectUri: this.subjectUri, - pane: this.pane, - soloPane: this.soloPane, - onBack: this.onBack, - openPane: this.openPane, - handleAccessClick: this.handleAccessClick, - paneSupportsEditing: false, - edit: this.edit - }) - - // Change the state for the pane so it can show the new icon. - openSelectedPane (pane: PaneDefinition) { - const store = this.context?.session.store as LiveStore - if (!store || !this.subjectUri) return - this.paneSupportsEditing = pane.name === 'source' - this.pane = pane - } - - private getPaneIcon (pane, subject, context) { - if (!pane) return undefined - - const icon = typeof pane.icon === 'function' - ? pane.icon(subject, context) - : pane.icon - return icon - } - - private async getPaneItems (subject, context, relevantPanes) { - const dom = context.dom - const menuItems = await Promise.all(relevantPanes.map(async pane => { - const label = pane.label(subject, context) - - let iconSrc = '' - if (pane.name === 'profile') { - iconSrc = PERSON_ICON - } else if (pane.name === 'social') { - iconSrc = FRIENDS_ICON - } else { - iconSrc = await this.getPaneIcon(pane, subject, context) - } - - const icon = utils.AJARImage(iconSrc, label, label, dom) - icon.setAttribute('slot', 'left-icon') - - return { - label, - icon, - action: () => this.openPane?.(subject, pane.name) - } - })) - return menuItems - } - - private refreshFileExplorerContextValue () { - this.fileExplorerContextValue = createFileExplorerContextValue({ - store: this.context?.session.store as LiveStore, - subjectUri: this.subjectUri, - pane: this.pane, - soloPane: this.soloPane, - onBack: this.onBack, - openPane: this.openPane, - handleAccessClick: this.handleAccessClick, - paneSupportsEditing: this.paneSupportsEditing, - edit: this.edit - }) - } - - private async refreshMenuItems () { - const store = this.context?.session.store as LiveStore - if (!store || !this.subjectUri) return - - const subject = store.sym(this.subjectUri) - const menuItems = await this.getPaneItems(subject, this.context as DataBrowserContext, this.relevantPanes) - - this.menuItems = menuItems - } - - protected willUpdate (changedProperties: PropertyValues) { - super.willUpdate(changedProperties) - const store = this.context?.session.store as LiveStore - if (!store) { - throw new Error('The element is missing the required `context.session.store` value. Ensure the `context` property is set.') - } - if (!this.subjectUri) { - throw new Error('The element is missing the required `subjectUri` property.') - } - - if ( - changedProperties.has('subjectUri') || - changedProperties.has('relevantPanes') || - changedProperties.has('context') - ) { - this.refreshMenuItems().catch(error => { - console.warn('Failed to refresh menu items', error) - }) - } - - if (changedProperties.has('pane') || changedProperties.has('subjectUri') || changedProperties.has('context')) { - this.paneSupportsEditing = this.pane?.name === 'source' - } - - if ( - changedProperties.has('context') || - changedProperties.has('subjectUri') || - changedProperties.has('pane') || - changedProperties.has('soloPane') || - changedProperties.has('onBack') || - changedProperties.has('openPane') || - changedProperties.has('handleAccessClick') || - changedProperties.has('pane') || - changedProperties.has('isDirty') - ) { - this.refreshFileExplorerContextValue() - } - } - - render () { - const store = this.context?.session.store as LiveStore - const subject = store.sym(this.subjectUri as string) - return html` -
- ${this.showHeader - ? html` - - ` - : nothing} - -
- ` - } -} diff --git a/src/components/file-explorer-header/index.ts b/src/components/file-explorer-header/index.ts deleted file mode 100644 index 2140b416..00000000 --- a/src/components/file-explorer-header/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export { default as FileExplorerHeader } from './FileExplorerHeader' -export { default as FileExplorerProvider } from './FileExplorerProvider' diff --git a/src/components/file-explorer-header/types.ts b/src/components/file-explorer-header/types.ts deleted file mode 100644 index 826d13a8..00000000 --- a/src/components/file-explorer-header/types.ts +++ /dev/null @@ -1,10 +0,0 @@ -export type PaneIcon = string | Promise | null | undefined - -export type FileExplorerResourceMetadata = { - contentType: string | undefined - canEdit: boolean - isPublic: boolean - aclUri: string | undefined - eTag: string | undefined - modified: string | undefined -} diff --git a/src/components/header/Header.styles.css b/src/components/header/Header.styles.css index d952fcc8..03cf3e9a 100644 --- a/src/components/header/Header.styles.css +++ b/src/components/header/Header.styles.css @@ -30,7 +30,7 @@ } @media (--solid-ui-mobile) { - padding: 0 16px 10px 16px; + padding: 5px 16px; a.logo, solid-ui-menu, diff --git a/src/components/navbar/Navbar.styles.css b/src/components/navbar/Navbar.styles.css index faf67c84..038f8a8d 100644 --- a/src/components/navbar/Navbar.styles.css +++ b/src/components/navbar/Navbar.styles.css @@ -1,5 +1,9 @@ :host { display: block; + position: relative; + z-index: 1; + flex-shrink: 0; + margin-bottom: 20px; } :host(.navbar--hidden) { @@ -12,6 +16,11 @@ display: flex; background: var(--solid-ui-color-white, #fff); overflow: hidden; + transition: box-shadow 0.2s ease; +} + +.navbar:hover { + box-shadow: 0 8px 10px rgba(124, 77, 255, 0.1); } button { diff --git a/src/components/navbar/Navbar.ts b/src/components/navbar/Navbar.ts index 2cc25ce4..fd0108e4 100644 --- a/src/components/navbar/Navbar.ts +++ b/src/components/navbar/Navbar.ts @@ -14,6 +14,8 @@ import styles from './Navbar.styles.css' export interface NavbarMenuItem { label: string | TemplateResult selected?: boolean + paneName?: string + paneUri?: string onSelected?(): void | Promise } diff --git a/src/components/profile-heading/ProfileHeading.styles.css b/src/components/profile-heading/ProfileHeading.styles.css new file mode 100644 index 00000000..ed988b04 --- /dev/null +++ b/src/components/profile-heading/ProfileHeading.styles.css @@ -0,0 +1,421 @@ +:host { + --profile-avatar-size: 8.75rem; + --profile-fallback-padding: 36.4px; + display: block; + width: 100%; + color: var(--color-text-secondary, #4a5565); + font-family: inherit; +} + +.profile-heading { + display: grid; + grid-template-columns: auto minmax(0, 1fr) auto; + grid-template-areas: + "avatar info edit" + "avatar details details"; + align-items: start; + column-gap: 20px; + row-gap: 20px; + width: 100%; + box-sizing: border-box; + padding: 25px; + overflow-x: clip; + background: var(--solid-ui-color-white, #fff); + border: 1px solid var(--solid-ui-color-slate-200, #e2e8f0); + border-radius: 5px; + transition: box-shadow 0.2s ease, transform 0.2s ease, padding 0.3s ease, row-gap 0.3s ease; +} + +.profile-heading:hover { + box-shadow: 0 8px 10px rgba(124, 77, 255, 0.1); +} + +.avatar { + grid-area: avatar; +} + +.image-frame { + position: relative; + display: grid; + place-items: center; + width: var(--profile-avatar-size); + aspect-ratio: 1; + overflow: hidden; + transition: width 0.3s ease; +} + +.image-frame--fallback { + border: 1px dashed var(--solid-ui-color-slate-200, #e2e8f0); + background: var(--solid-ui-color-slate-50, #f8fafc); + box-sizing: border-box; +} + +.hero { + position: absolute; + inset: 0; + width: 100%; + height: 100%; + border: 1px solid var(--solid-ui-color-primary, #7c4dff); + background: var(--color-surface-placeholder, var(--gray-300, #d1d5dc)) 50% / cover no-repeat; + object-fit: cover; + object-position: center; + box-sizing: border-box; + border-radius: 10px; +} + +.hero-fallback { + display: none; + align-items: center; + justify-content: center; + width: 100%; + height: 100%; + padding: 0 var(--profile-fallback-padding); + box-sizing: border-box; + transition: padding 0.3s ease; +} + +.hero-fallback icon-lucide-circle-user-round { + display: block; + width: 100%; + height: 100%; + color: #cbd5e1; +} + +.image-frame--fallback .hero-fallback { + display: flex; +} + +.info { + grid-area: info; + min-width: 0; +} + +.profile__heading-edit-action { + grid-area: edit; + margin-left: auto; + margin-right: 0; + margin-bottom: 0; + align-self: flex-start; + justify-self: end; + display: flex; + justify-content: flex-end; + align-items: flex-start; + gap: 8px; + padding: 0; +} + +.profile-friends-button__section { + display: grid; + gap: 8px; + max-width: 16rem; +} + +.profile__btn-friends-icon { + display: block; + width: 14px; + height: 14px; + align-self: center; + transform: translateY(-3px); +} + +.friend-message { + text-align: center; + font-size: var(--solid-ui-font-size-sm, 0.875rem); + overflow-wrap: anywhere; +} + +.friend-message[role="alert"] { + color: var(--solid-ui-color-red-700, #b91c1c); +} + +.friend-message[role="status"] { + color: var(--solid-ui-color-green-700, #15803d); +} + +.profile-section-collapsible__edit-button { + min-width: 0; +} + +.mobile-edit-button { + display: none; + color: var(--solid-ui-color-primary, #7c4dff); +} + +.profile-section-collapsible__action-label { + font-size: var(--solid-ui-font-size-sm, 0.875rem); +} + +.profile__add-more-icon { + margin-right: 0; + line-height: 0; + position: relative; + top: 0; + transform: translateY(0); +} + +.profile__add-more-icon icon-lucide-pencil, +.profile-section-collapsible__edit-icon icon-lucide-pencil { + display: block; + width: 14px; + height: 14px; +} + +.header-bar { + display: flex; + flex-direction: column; + align-items: flex-start; + gap: 2px; + width: 100%; + margin: 0; + padding: 0; +} + +.identity { + display: flex; + align-items: baseline; + gap: 7px; + width: 100%; + flex-wrap: wrap; +} + +.name { + display: block; + margin: 0; + color: var(--color-text-heading, #000); + font-size: 1.75rem; + font-weight: 600; + line-height: 1.2; + overflow-wrap: anywhere; +} + +.pronouns { + color: var(--color-text-secondary, #4a5565); + font-size: var(--solid-ui-font-size-sm, 0.875rem); + font-weight: 400; + line-height: 1.2; +} + +.role { + width: 100%; + color: var(--solid-ui-color-gray-800, #101828); + font-size: var(--solid-ui-font-size-lg, 1.125rem); + font-weight: 500; + line-height: 1.25; + overflow-wrap: anywhere; +} + +.details-collapse { + grid-area: details; + display: grid; + grid-template-rows: 1fr; + transition: grid-template-rows 0.3s ease, opacity 0.3s ease; +} + +.details { + display: flex; + flex-wrap: wrap; + align-content: flex-start; + align-items: flex-start; + gap: 12px 32px; + min-width: 0; + min-height: 0; + overflow: hidden; + width: 100%; + font-size: var(--font-size-sm, 0.875rem); +} + +:host([compact]) .profile-heading { + padding: 12.5px; + row-gap: 0; +} + +:host([compact]) .image-frame { + width: calc(var(--profile-avatar-size) / 2); +} + +:host([compact]) .hero-fallback { + padding-inline: calc(var(--profile-fallback-padding) / 2); +} + +:host([compact]) .info { + align-self: center; +} + +:host([compact]) .profile__heading-edit-action { + align-self: center; +} + +:host([compact]) .name { + white-space: normal; + overflow-wrap: anywhere; +} + +:host([compact]) .details-collapse { + grid-template-rows: 0fr; + opacity: 0; + visibility: hidden; +} + +.pronouns[hidden] { + display: none; +} + +.detail-row { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + align-items: start; + column-gap: clamp(12px, 2vw, 24px); + row-gap: 12px; + width: min(100%, 544px); +} + +.detail-item { + display: flex; + align-items: flex-start; + gap: 7px; + min-width: 0; +} + +.detail-icon { + display: inline-flex; + flex: 0 0 16px; + width: 16px; + height: 16px; + margin-top: 1px; +} + +.detail-icon > icon-lucide-cake, +.detail-icon > icon-lucide-map-pin, +.detail-icon > icon-lucide-phone, +.detail-icon > icon-lucide-mail { + display: block; + width: 16px; + height: 16px; + color: currentColor; +} + +.detail-value { + min-width: 0; + overflow-wrap: anywhere; + word-break: break-word; +} + +@media (max-width: 1200px) { + :host { + --profile-avatar-size: 6.5rem; + --profile-fallback-padding: 27px; + } + + .profile-heading { + column-gap: 15px; + } + +} + +@media (max-width: 768px) { + .profile-heading:has(.profile-friends-button__section) .name { + white-space: normal; + overflow-wrap: anywhere; + } + + .profile__btn-friends-icon { + display: none; + } + + .profile__btn-friends[disabled]:not([aria-busy="true"]) { + display: none; + } + + :host { + --profile-avatar-size: 4.375rem; + --profile-fallback-padding: 0px; + } + + .profile-heading { + grid-template-areas: + "avatar info edit" + "details details details"; + column-gap: 8px; + row-gap: 12px; + } + + .profile-section-collapsible__edit-button { + width: var(--solid-ui-clickable-area, 42px); + height: var(--solid-ui-clickable-area, 42px); + } + + .desktop-edit-button { + display: none; + } + + .mobile-edit-button { + display: inline-flex; + position: relative; + top: -12px; + right: -12px; + } + + .profile-section-collapsible__edit-icon { + display: inline-flex; + align-items: center; + justify-content: center; + line-height: 0; + } + + .profile-heading { + column-gap: 10px; + } + + .hero-fallback icon-lucide-circle-user-round { + width: 3rem; + height: 3rem; + transition: width 0.3s ease, height 0.3s ease; + } + + :host([compact]) .hero-fallback icon-lucide-circle-user-round { + width: 1.5rem; + height: 1.5rem; + } + + .name { + display: inline; + font-size: 1.375rem; + line-height: 1.15; + white-space: normal; + overflow-wrap: anywhere; + } + + .identity { + gap: 0; + } + + .pronouns { + margin-left: 2px; + font-size: 0.6875rem; + line-height: 1.1; + white-space: nowrap; + } + + .role { + font-size: var(--solid-ui-font-size-sm, 0.875rem); + } + + .details { + gap: 12px; + font-size: 0.75rem; + } + + .detail-row { + column-gap: 2px; + } +} + +@media (prefers-reduced-motion: reduce) { + .profile-heading, + .image-frame, + .hero-fallback, + .hero-fallback icon-lucide-circle-user-round, + .details-collapse { + transition: none; + } +} diff --git a/src/components/profile-heading/ProfileHeading.ts b/src/components/profile-heading/ProfileHeading.ts new file mode 100644 index 00000000..f1bbbeb9 --- /dev/null +++ b/src/components/profile-heading/ProfileHeading.ts @@ -0,0 +1,362 @@ +import { authn, store } from 'solid-logic' +import type { NamedNode, Node } from 'rdflib' +import { customElement, WebComponent, widgets } from 'solid-ui' +import { html, nothing, type PropertyValues, type TemplateResult } from 'lit' +import { property, state } from 'lit/decorators.js' +import { createHeadingEditDialog } from './editor/sections/heading/HeadingEditDialog' +import type { ProfileDetails, ProfilePresentation } from './editor/sections/heading/types' +import type { PointDetails } from './editor/sections/contactInfo/types' +import type { ViewerMode } from '../../types' +import { addFriend, checkFriend, friendTexts } from './friendActions' +import { formatDisplayError } from './editor/utils/errorDisplay' +import 'solid-ui/components/button' +import '~icons/lucide/cake' +import '~icons/lucide/circle-user-round' +import '~icons/lucide/mail' +import '~icons/lucide/map-pin' +import '~icons/lucide/pencil' +import '~icons/lucide/phone' +import '~icons/lucide/user-round-plus' +import styles from './ProfileHeading.styles.css' + +export type ProfileHeadingPoint = Pick + +// The heading renders a subset of the shared presentation model used by the editor. +export type ProfileHeadingData = + Pick & { + primaryPhone?: ProfileHeadingPoint + primaryEmail?: ProfileHeadingPoint + } + +export interface ProfileHeadingEditContext { + subject: NamedNode + profileData: ProfileDetails + viewerMode: ViewerMode + onSaved: () => Promise | void +} + +@customElement('solid-panes-profile-heading') +export default class ProfileHeading extends WebComponent { + static styles = styles + + @property({ attribute: false }) + accessor profileData: ProfileHeadingData | undefined = undefined + + @property({ attribute: false }) + accessor subject: NamedNode | undefined = undefined + + @property({ attribute: false }) + accessor editContext: ProfileHeadingEditContext | undefined = undefined + + @property({ attribute: false }) + accessor friendSubject: NamedNode | undefined = undefined + + @property({ type: Boolean, reflect: true }) + accessor compact = false + + @state() + accessor failedImageSrc: string | undefined = undefined + + @state() + accessor friendState: 'loading' | 'available' | 'exists' | 'saving' | 'error' = 'loading' + + @state() + accessor friendMessage = '' + + @state() + accessor friendError = false + + private friendRequest = 0 + private friendRequestInterrupted = false + private friendMessageTimer: ReturnType | undefined + private readonly draggableSubject = { uri: '' } + private draggableElementsAttached = false + + connectedCallback (): void { + super.connectedCallback() + if (this.friendRequestInterrupted) { + this.friendRequestInterrupted = false + this.startFriendCheck() + } + } + + disconnectedCallback (): void { + super.disconnectedCallback() + this.friendRequest++ + if (this.friendState === 'loading' || this.friendState === 'saving') { + this.friendRequestInterrupted = true + } + this.clearFriendMessage() + } + + private clearFriendMessage (): void { + clearTimeout(this.friendMessageTimer) + this.friendMessageTimer = undefined + this.friendMessage = '' + } + + protected willUpdate (changed: PropertyValues): void { + super.willUpdate(changed) + if (changed.has('profileData') && changed.get('profileData')?.imageSrc !== this.profileData?.imageSrc) { + this.failedImageSrc = undefined + } + if (!changed.has('friendSubject')) return + this.friendRequestInterrupted = false + this.startFriendCheck() + } + + protected updated (): void { + if (this.subject) this.draggableSubject.uri = this.subject.value + if (this.draggableElementsAttached || !this.subject) return + + const heading = this.shadowRoot?.querySelector('.profile-heading') + const name = this.shadowRoot?.querySelector('.name') + if (!heading || !name) return + + widgets.makeDraggable(heading, this.draggableSubject) + widgets.makeDraggable(name, this.draggableSubject) + this.draggableElementsAttached = true + } + + private startFriendCheck (): void { + const request = ++this.friendRequest + this.friendState = 'loading' + this.clearFriendMessage() + this.friendError = false + const subject = this.friendSubject + const viewer = authn.currentUser() + if (!subject || !viewer || viewer.sameTerm(subject)) return + + checkFriend(viewer, subject).then((exists) => { + if (request !== this.friendRequest || this.friendSubject !== subject) return + this.friendState = exists ? 'exists' : 'available' + }).catch((error: unknown) => { + if (request !== this.friendRequest || this.friendSubject !== subject) return + this.friendState = 'error' + this.showFriendMessage(error, true) + }) + } + + private async showFriendMessage (message: unknown, error: boolean): Promise { + this.clearFriendMessage() + this.friendMessage = formatDisplayError(message) + this.friendError = error + this.friendMessageTimer = setTimeout(() => { + this.clearFriendMessage() + }, 10000) + await this.updateComplete + this.shadowRoot?.querySelector('.friend-message')?.focus() + } + + private handleAddFriend = async (event: Event): Promise => { + event.preventDefault() + if (this.friendState !== 'available' && this.friendState !== 'error') return + const subject = this.friendSubject + if (!subject) return + const request = this.friendRequest + this.friendState = 'saving' + this.clearFriendMessage() + try { + const viewer = authn.currentUser() + if (!viewer) throw new Error(friendTexts.loginRequired) + await addFriend(viewer, subject) + if (request !== this.friendRequest || this.friendSubject !== subject) return + this.friendState = 'exists' + await this.showFriendMessage(friendTexts.success, false) + } catch (error: unknown) { + if (request !== this.friendRequest || this.friendSubject !== subject) return + this.friendState = 'error' + await this.showFriendMessage(error, true) + } + } + + private handleEdit = (event: Event) => { + const context = this.editContext + if (!context) return + + createHeadingEditDialog( + event, + store, + context.subject, + context.profileData, + context.viewerMode, + async () => { + this.dispatchEvent(new CustomEvent('profile-heading-saved', { + bubbles: true, + composed: true, + detail: { subjectUri: context.subject.value } + })) + await context.onSaved() + } + ).catch((error: unknown) => { + console.error('Failed to edit profile heading.', error) + }) + } + + private handleImageError = (event: Event) => { + this.failedImageSrc = (event.currentTarget as HTMLImageElement).getAttribute('src') ?? undefined + } + + render (): TemplateResult<1> { + const profile = this.profileData + if (!profile) return html`` + + const phone = textValue(profile.primaryPhone?.valueNode).replace(/^tel:/i, '') + const email = textValue(profile.primaryEmail?.valueNode).replace(/^mailto:/i, '') + const dateOfBirth = displayDate(profile.dateOfBirth) + const showImage = Boolean(profile.imageSrc && this.failedImageSrc !== profile.imageSrc) + const viewer = authn.currentUser() + const showFriend = Boolean(this.friendSubject && viewer && !viewer.sameTerm(this.friendSubject)) + + return html` +
+
+
+ ${showImage + ? html`${profile.name}` + : nothing} + +
+
+ +
+
+
+

${profile.name}

+ ${profile.pronouns ? html`(${profile.pronouns})` : nothing} +
+ ${profile.jobTitle ? html`
${profile.jobTitle}
` : nothing} +
+
+ + ${(this.editContext && !this.compact) || showFriend + ? html` +
+ ${showFriend + ? html` +
+ ${this.friendState === 'exists' + ? nothing + : html``}${this.friendState === 'exists' ? friendTexts.exists : friendTexts.add} + ${this.friendMessage + ? html` +
+ ${this.friendMessage} +
` + : nothing} +
+ ` + : nothing} + ${this.editContext && !this.compact + ? html` + + + Edit + + + + + ` + : nothing} +
+ ` + : nothing} + +
+
+
+ ${this.renderLine(dateOfBirth, 'birthday')} + ${this.renderLine(profile.location, 'location')} +
+
+ ${this.renderLine(phone, 'phone')} + ${this.renderLine(email, 'email')} +
+
+
+
+ ` + } + + private renderLine (value: string | undefined, icon: 'birthday' | 'location' | 'phone' | 'email') { + if (!value) return nothing + + return html` +
+ + ${value} +
+ ` + } + + private renderIcon (icon: 'birthday' | 'location' | 'phone' | 'email'): TemplateResult { + switch (icon) { + case 'birthday': + return html`` + case 'location': + return html`` + case 'phone': + return html`` + case 'email': + return html`` + } + } + + private renderEditIcon (): TemplateResult { + return html`` + } +} + +function textValue (value: Node | undefined): string { + return value?.value ?? '' +} + +function displayDate (value?: string): string { + const raw = (value || '').trim() + const isoDate = raw.match(/^(\d{4})-(\d{2})-(\d{2})/) + if (isoDate) { + const [, year, month, day] = isoDate + return `${day}-${month}-${year}` + } + + const dmyDate = raw.match(/^(\d{2})[/-](\d{2})[/-](\d{4})$/) + if (dmyDate) { + const [, day, month, year] = dmyDate + return `${day}-${month}-${year}` + } + + return raw +} diff --git a/src/components/profile-heading/editor/index.ts b/src/components/profile-heading/editor/index.ts new file mode 100644 index 00000000..a90608ef --- /dev/null +++ b/src/components/profile-heading/editor/index.ts @@ -0,0 +1,2 @@ +export { createHeadingEditDialog } from './sections/heading/HeadingEditDialog' +export type { ProfileDetails } from './sections/heading/types' diff --git a/src/components/profile-heading/editor/sections/contactInfo/types.ts b/src/components/profile-heading/editor/sections/contactInfo/types.ts new file mode 100644 index 00000000..3c4dd374 --- /dev/null +++ b/src/components/profile-heading/editor/sections/contactInfo/types.ts @@ -0,0 +1,50 @@ +import { Node } from 'rdflib' +import { MutationOps } from '../shared/types' +/* using Node instead of NamedNode because the data could +also be a blank node because it's coming from user-edited profile data */ +export interface PointDetails { + entryNode: Node, + type: Node, + valueNode: Node +} +export interface AddressDetails { + entryNode: Node, + type?: Node, + streetAddress?: string, + locality?: string, + region?: string, + postalCode?: string, + countryName?: string +} + +export interface ContactInfo { + emails: PointDetails[], + phones: PointDetails[], + addresses: AddressDetails[] +} + +export type ContactRowStatus = 'existing' | 'new' | 'modified' | 'deleted' + +export type ContactPointRow = { + value: string + type: string + entryNode: string + status: ContactRowStatus +} + +export type ContactAddressRow = { + streetAddress?: string, + locality?: string, + region?: string, + postalCode?: string, + countryName?: string + type: string + entryNode: string + status: ContactRowStatus +} + +export type ContactMutationPlan = { + phoneOps: MutationOps + emailOps: MutationOps + addressOps: MutationOps +} diff --git a/src/components/profile-heading/editor/sections/heading/HeadingEditDialog.ts b/src/components/profile-heading/editor/sections/heading/HeadingEditDialog.ts new file mode 100644 index 00000000..7d42fac7 --- /dev/null +++ b/src/components/profile-heading/editor/sections/heading/HeadingEditDialog.ts @@ -0,0 +1,933 @@ +import { openInputDialog } from '../../ui/dialog' +import { html, render, TemplateResult } from 'lit-html' +import 'solid-ui/components/button' +import 'solid-ui/components/combobox' +import 'solid-ui/components/combobox-option' +import { type ComboboxChangeEvent } from 'solid-ui/components/combobox' +import 'solid-ui/components/photo-capture' +import type { PhotoCapture } from 'solid-ui/components/photo-capture' +import { ProfileDetails, HeadingMutationPlan, ProfileBasicRow } from './types' +import { Image } from './imagePreview' +import '../../styles/EditDialogs.css' +import { LiveStore, NamedNode } from 'rdflib' +import { processHeadingMutations } from './mutations' +import { ViewerMode } from '../../../../../types' +import { + combinePhoneValue, + splitPhoneValue +} from '../shared/phoneCountries' +import { + normalizeEmailTypeForEdit, + normalizePhoneTypeForEdit, + toSavedHeadingEmailType, + toSavedHeadingPhoneType +} from '../shared/contactTypeUtils' +import { applyRowFieldChange, applyRowSelectChange, summarizeRowOps } from '../shared/rowState' +import { hasNonEmptyText, sanitizeTextValue, toText, toTypeLabel } from '../../textUtils' +import { + dialogCancelLabelText, + dialogSubmitLabelText, + editHeadingDialogTitleText, + ownerLoginRequiredDialogMessageText, + saveHeadingUpdatesFailedMessageText +} from '../../texts' +import '~icons/lucide/camera' +import { ContactAddressRow, ContactPointRow } from '../contactInfo/types' +import { sanitizeAddressFieldValue, sanitizeBasicInputFieldValue, sanitizeEmailValue, sanitizePhoneLocalValue } from '../shared/sanitizeUtils' +import { toStorageDateISO } from './dateHelpers' +import { invalidateResolvedPhotoDisplaySrc, resolvePhotoDisplaySrc, uploadPhotoFile } from './imageHelpers' +/* Note: new design - has address type in More Edit Contacts for now we will leave + out Address Type, but a ticket will be created to add type later + so I will keep the code and just comment it out for now. + new design - has country code, will comment out code for now and create a ticket to add later. */ + +type HeadingFormState = { + basicInfo: ProfileBasicRow + email: ContactPointRow + phone: ContactPointRow + address: ContactAddressRow + emailTypeWasMissing: boolean + phoneTypeWasMissing: boolean + pendingImageFile?: File | null + imagePreviewSrc: string + clearImagePreview: () => void +} + +type HeadingContactTypeOption = { + label: string + value: string +} + +type HeadingPronounsOption = { + label: string + value: string +} + +type HeadingContactTypeKind = 'phone' | 'email' + +const HEADING_PHONE_TYPE_OPTIONS: HeadingContactTypeOption[] = [ + { label: 'Mobile', value: 'Mobile' }, + { label: 'Home', value: 'Home' }, + { label: 'Work', value: 'Work' } +] + +const HEADING_EMAIL_TYPE_OPTIONS: HeadingContactTypeOption[] = [ + { label: 'Personal', value: 'Personal' }, + { label: 'Office', value: 'Office' } +] + +const HEADING_PRONOUN_OPTIONS: HeadingPronounsOption[] = [ + { label: 'He/Him', value: 'He/Him' }, + { label: 'She/Her', value: 'She/Her' }, + { label: 'They/Them', value: 'They/Them' } +] + +type Row = ProfileBasicRow | ContactPointRow | ContactAddressRow + +function isContactPointRow (row: Row): row is ContactPointRow { + return 'value' in row +} + +function isAddressRow (row: Row): row is ContactAddressRow { + return 'streetAddress' in row +} + +function isProfileBasicRow (row: Row): row is ProfileBasicRow { + return 'name' in row +} + +function normalizeHeadingContactTypeValue (value: string, options: HeadingContactTypeOption[]): string { + return options.some((option) => option.value === value) ? value : options[0]?.value || '' +} + +function getHeadingContactTypeOptions (kind: HeadingContactTypeKind): HeadingContactTypeOption[] { + return kind === 'phone' ? HEADING_PHONE_TYPE_OPTIONS : HEADING_EMAIL_TYPE_OPTIONS +} + +function withDefaultHeadingContactType ( + row: ContactPointRow, + kind: HeadingContactTypeKind +): ContactPointRow { + return { + ...row, + type: normalizeHeadingContactTypeValue(row.type || '', getHeadingContactTypeOptions(kind)) + } +} + +function rowHasContent (row: Row): boolean { + if (isContactPointRow(row)) { + return hasNonEmptyText(row.value) + } + if (isAddressRow(row)) { + return [ + row.streetAddress, + row.locality, + row.region, + row.postalCode, + row.countryName + ].some(hasNonEmptyText) + } + if (isProfileBasicRow(row)) { + return [ + row.name, + row.nickname, + row.imageSrc, + row.location, + row.pronouns, + row.dateOfBirth + ].some(hasNonEmptyText) + } + return false +} + +function normalizePronounsValue (value: string | undefined): string { + const normalized = sanitizeTextValue(value || '').toLowerCase().replace(/\s+/g, '') + if (!normalized) return '' + if (normalized === 'he' || normalized === 'he/him') return 'He/Him' + if (normalized === 'she' || normalized === 'she/her') return 'She/Her' + if (normalized === 'they' || normalized === 'they/them') return 'They/Them' + return value || '' +} + +function toFormState (profileData: ProfileDetails): HeadingFormState { + const basicInfo: ProfileBasicRow = { + name: sanitizeTextValue(toText(profileData.name)), + nickname: sanitizeTextValue(toText(profileData.nickname || '')), + imageSrc: sanitizeTextValue(toText(profileData.imageSrc || '')), + location: sanitizeTextValue(toText(profileData.location || '')), + pronouns: normalizePronounsValue(toText(profileData.pronouns || '')), + dateOfBirth: sanitizeTextValue(toText(profileData.dateOfBirth || '')), + entryNode: toText(profileData.entryNode), + status: toText(profileData.entryNode) ? 'existing' as const : 'new' as const + } + const primaryEmail = profileData.primaryEmail + const primaryPhone = profileData.primaryPhone + const primaryAddress = profileData.primaryAddress + const emailTypeWasMissing = !normalizeEmailTypeForEdit(primaryEmail?.type) + const phoneTypeWasMissing = !normalizePhoneTypeForEdit(primaryPhone?.type) + + const normalizedEmailType = normalizeEmailTypeForEdit(primaryEmail?.type) + const normalizedPhoneType = normalizePhoneTypeForEdit(primaryPhone?.type) + + const email: ContactPointRow = { + value: sanitizeEmailValue(toText(primaryEmail?.valueNode).replace(/^mailto:/i, '')), + type: normalizedEmailType, + entryNode: toText(primaryEmail?.entryNode), + status: toText(primaryEmail?.entryNode) ? 'existing' as const : 'new' as const + } + const phone: ContactPointRow = { + value: sanitizeTextValue( + toText(primaryPhone?.valueNode || primaryPhone?.entryNode || '').replace(/^tel:/i, '') + ), + type: normalizedPhoneType, + entryNode: toText(primaryPhone?.entryNode || ''), + status: toText(primaryPhone?.entryNode || '') ? 'existing' as const : 'new' as const + } + const address: ContactAddressRow = { + streetAddress: sanitizeAddressFieldValue(toText(primaryAddress?.streetAddress)), + locality: sanitizeAddressFieldValue(toText(primaryAddress?.locality)), + region: sanitizeAddressFieldValue(toText(primaryAddress?.region)), + postalCode: sanitizeAddressFieldValue(toText(primaryAddress?.postalCode)), + countryName: sanitizeAddressFieldValue(toText(primaryAddress?.countryName)), + type: toTypeLabel(primaryAddress?.type), + entryNode: toText(primaryAddress?.entryNode), + status: toText(primaryAddress?.entryNode) ? 'existing' as const : 'new' as const + } + + return { + basicInfo: (basicInfo) || { name: '', nickname: '', imageSrc: '', location: '', pronouns: '', dateOfBirth: '', entryNode: '', status: 'new' }, + email: (email) || { value: '', type: '', entryNode: '', status: 'new' }, + phone: (phone) || { value: '', type: '', entryNode: '', status: 'new' }, + address: (address) || { streetAddress: '', locality: '', region: '', postalCode: '', countryName: '', type: '', entryNode: '', status: 'new' }, + emailTypeWasMissing, + phoneTypeWasMissing, + imagePreviewSrc: '', + clearImagePreview: () => undefined + } +} + +function setHeadingImagePreview (formState: HeadingFormState, file: File) { + formState.clearImagePreview() + + if (typeof URL.createObjectURL !== 'function') { + formState.imagePreviewSrc = '' + formState.clearImagePreview = () => undefined + return + } + + const previewUrl = URL.createObjectURL(file) + formState.imagePreviewSrc = previewUrl + formState.clearImagePreview = () => { + URL.revokeObjectURL(previewUrl) + formState.imagePreviewSrc = '' + formState.clearImagePreview = () => undefined + } +} + +function setResolvedHeadingPreview (formState: HeadingFormState, resolvedImageSrc?: string) { + formState.clearImagePreview() + + if (!resolvedImageSrc) { + return + } + + formState.imagePreviewSrc = resolvedImageSrc + + formState.clearImagePreview = () => { + formState.imagePreviewSrc = '' + formState.clearImagePreview = () => undefined + } +} + +type ProfileBasicEditableField = + | 'name' + | 'nickname' + | 'imageSrc' + | 'pronouns' + | 'dateOfBirth' + +type ContactAddressEditableField = + | 'streetAddress' + | 'locality' + | 'region' + | 'postalCode' + | 'countryName' + +type ContactPhoneInputRowProps = { + phone: ContactPointRow +} + +type ContactEmailInputRowProps = { + email: ContactPointRow +} + +type ContactAddressInputRowProps = { + address: ContactAddressRow +} + +function mapEmailOpsForSave (ops: { create: ContactPointRow[], update: ContactPointRow[], remove: ContactPointRow[] }) { + const mapRow = (row: ContactPointRow): ContactPointRow => ({ + ...withDefaultHeadingContactType(row, 'email'), + type: toSavedHeadingEmailType(withDefaultHeadingContactType(row, 'email').type) + }) + + return { + create: ops.create.map(mapRow), + update: ops.update.map(mapRow), + remove: ops.remove.map(mapRow) + } +} + +function mapPhoneOpsForSave (ops: { create: ContactPointRow[], update: ContactPointRow[], remove: ContactPointRow[] }) { + const mapRow = (row: ContactPointRow): ContactPointRow => ({ + ...withDefaultHeadingContactType(row, 'phone'), + type: toSavedHeadingPhoneType(withDefaultHeadingContactType(row, 'phone').type) + }) + + return { + create: ops.create.map(mapRow), + update: ops.update.map(mapRow), + remove: ops.remove.map(mapRow) + } +} + +function summarizeHeadingContactOps ( + row: ContactPointRow, + kind: HeadingContactTypeKind, + typeWasMissing: boolean +) { + const ops = summarizeRowOps([row], rowHasContent) + + if ( + typeWasMissing && + row.entryNode && + row.status === 'existing' && + rowHasContent(row) && + ops.create.length === 0 && + ops.update.length === 0 && + ops.remove.length === 0 + ) { + return { + create: ops.create, + update: [withDefaultHeadingContactType({ ...row, status: 'modified' }, kind)], + remove: ops.remove + } + } + + return ops +} + +function renderContactPhoneInput ({ + phone +}: ContactPhoneInputRowProps) { + const label = 'Mobile Number' + const typeLabel = 'Phone Type 1' + const inputName = 'phone-value' + const splitValue = splitPhoneValue(phone?.value || '') + const selectedDialCode = splitValue.dialCode + + const handleValueInput = (e: Event) => { + const target = e.target as HTMLInputElement + const nextValue = sanitizePhoneLocalValue(target.value) + if (phone) { + applyRowFieldChange(phone, 'value', combinePhoneValue(selectedDialCode, nextValue), rowHasContent) + } + } + + const handleTypeInput = (e: Event) => { + const event = e as ComboboxChangeEvent + if (!event.detail.option) return + const nextType = String(event.detail.option.value) + if (phone) { + applyRowSelectChange(phone, 'type', nextType) + } + } + + return html` +
+
+ +
+ +
+ ` +} + +function renderContactEmailInputRow ({ + email +}: ContactEmailInputRowProps) { + const label = 'Email' + const typeLabel = 'Email Type' + const inputName = 'email-value' + + const handleValueInput = (e: Event) => { + const target = e.target as HTMLInputElement + const nextValue = sanitizeEmailValue(target.value) + if (email) { + applyRowFieldChange(email, 'value', nextValue, rowHasContent) + } + } + + const handleTypeInput = (e: Event) => { + const event = e as ComboboxChangeEvent + if (!event.detail.option) return + const nextType = String(event.detail.option.value) + if (email) { + applyRowSelectChange(email, 'type', nextType) + } + } + + return html` +
+ + +
+ ` +} + +function renderContactAddressInput ({ + address +}: ContactAddressInputRowProps) { + const label = 'Address' + /* const typeLabel = 'Address Type' */ + /* const typeInputName = 'address-type' */ + /* const addressTypeSelectId = 'address-type-select' */ + const streetAddressName = 'address-street' + const localityName = 'address-locality' + const regionName = 'address-region' + const postalCodeName = 'address-postal' + const countryName = 'address-country' + + const handleAddressInput = (field: ContactAddressEditableField) => (e: Event) => { + const target = e.target as HTMLInputElement + const nextValue = sanitizeAddressFieldValue(target.value) + if (address) { + applyRowFieldChange(address, field, nextValue, rowHasContent) + } + } + + /* const handleTypeInput = (e: Event) => { + const target = e.target as HTMLInputElement + const nextType = target.value + if (address) { + applyRowSelectChange(address, 'type', nextType) + } + } */ + + return html` + + +
+ + +
+ +
+ + +
+ ` +} + +function renderHeadingInfoInput ( + formState: HeadingFormState, + rerender: () => void +): TemplateResult { + const { basicInfo, phone, email, imagePreviewSrc } = formState + const imageSrcLabel = 'Profile Photo' + const recommendedImageToLoad = 'Recommended: Square JPG, PNG. Max 2MB.' + const nameLabel = 'Full Name' + const nicknameLabel = 'Nickname' + const pronounsLabel = 'Pronouns' + const dateOfBirthLabel = 'DOB' + + const handleBasicInfoInput = (field: ProfileBasicEditableField) => (e: Event) => { + const target = e.target as HTMLInputElement + const nextValue = sanitizeBasicInputFieldValue(target.value) + if (basicInfo) { + applyRowFieldChange(basicInfo, field, nextValue, rowHasContent) + } + } + + const handleDateOfBirthInput = (e: Event) => { + const target = e.target as HTMLInputElement + const nextValue = sanitizeBasicInputFieldValue(target.value) + if (basicInfo) { + applyRowFieldChange(basicInfo, 'dateOfBirth', toStorageDateISO(nextValue), rowHasContent) + } + } + const handlePronounsInput = (e: Event) => { + const event = e as ComboboxChangeEvent + if (!event.detail.option) return + const nextValue = normalizePronounsValue(String(event.detail.option.value)) + if (basicInfo) { + applyRowFieldChange(basicInfo, 'pronouns', nextValue, rowHasContent) + } + } + + const handleUpload = async (e: Event) => { + const button = e.currentTarget as HTMLButtonElement | null + const dom = button?.ownerDocument || document + const fileInput = dom.createElement('input') + fileInput.type = 'file' + fileInput.accept = 'image/*' + fileInput.hidden = true + + const cleanupFileInput = () => { + fileInput.remove() + } + + fileInput.addEventListener('change', async () => { + const file = fileInput.files?.[0] + cleanupFileInput() + if (!file || !basicInfo) return + + try { + formState.pendingImageFile = file + setHeadingImagePreview(formState, file) + basicInfo.status = basicInfo.entryNode ? 'modified' : 'new' + rerender() + } catch (error) { + console.error('Profile image upload failed', error) + } + }, { once: true }) + + dom.body.appendChild(fileInput) + fileInput.click() + } + + const handleCameraInput = async (event: InputEvent) => { + const file = (event.target as PhotoCapture).value + + if (!file || !basicInfo) return + + try { + formState.pendingImageFile = file + setHeadingImagePreview(formState, file) + basicInfo.status = basicInfo.entryNode ? 'modified' : 'new' + rerender() + } catch (error) { + console.error('Profile camera upload failed', error) + } + } + + const handleDelete = async () => { + if (!basicInfo) return + formState.pendingImageFile = null + formState.clearImagePreview() + applyRowFieldChange(basicInfo, 'imageSrc', '', rowHasContent) + rerender() + } + + return html` +
+
+
+ ${Image(imagePreviewSrc || basicInfo.imageSrc, basicInfo.name)} + + + +
+
+ +
+

${imageSrcLabel}

+

${recommendedImageToLoad}

+ +
+ + Upload + + + Remove + +
+
+
+
+ +
+
+
+ + +
+
+
+ + + ${HEADING_PRONOUN_OPTIONS.map((option) => html`${option.label}`)} + +
+
+ + +
+
+
+
+ ${renderContactPhoneInput({ phone })} +
+
+ ${renderContactEmailInputRow({ email })} +
+
+
+ ` +} + +function renderHeadingEditTemplate ( + form: HTMLFormElement, + formState: HeadingFormState, + viewerMode: ViewerMode +) { + const rerender = () => renderHeadingEditTemplate(form, formState, viewerMode) + + render(html` + ${renderHeadingInfoInput(formState, rerender)} + ${renderContactAddressInput({ address: formState.address })} + ${viewerMode !== 'owner' + ? html`` + : null} + `, form) +} + +function createHeadingEditForm ( + profileData: ProfileDetails, + viewerMode: ViewerMode +) { + const form = document.createElement('form') + form.classList.add('profile__edit-form', 'profile__edit-form--heading', 'profile-edit-dialog--heading') + form.autocomplete = 'off' + form.setAttribute('data-lpignore', 'true') + form.setAttribute('data-1p-ignore', 'true') + form.setAttribute('data-bwignore', 'true') + + const formState = toFormState(profileData) + renderHeadingEditTemplate(form, formState, viewerMode) + + return { form, formState } +} + +function isValidHeadingEmailAddress (value: string): boolean { + return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value) +} + +function isValidHeadingPhoneNumber (value: string): boolean { + return /^\d+$/.test(value) +} + +function validateHeadingDataBeforeSave (formState: HeadingFormState): string | null { + if (!hasNonEmptyText(formState.basicInfo.name)) { + return 'Full Name is required.' + } + + const { localNumber } = splitPhoneValue(formState.phone?.value || '') + if (rowHasContent(formState.phone) && !isValidHeadingPhoneNumber(localNumber)) { + return 'Phone Number 1 should contain only numbers.' + } + + if (rowHasContent(formState.email) && !isValidHeadingEmailAddress(formState.email?.value || '')) { + return 'Email address must be a valid email address.' + } + + return null +} + +export async function createHeadingEditDialog ( + _event: Event, + store: LiveStore, + subject: NamedNode, + profileData: ProfileDetails, + viewerMode: ViewerMode, + onSaved?: () => Promise | void +) { + const dom = document + const originalPhotoUri = sanitizeTextValue(toText(profileData.imageSrc || '')) + const { form, formState } = createHeadingEditForm(profileData, viewerMode) + + if (formState.basicInfo.imageSrc) { + const resolvedImageSrc = await resolvePhotoDisplaySrc(store, formState.basicInfo.imageSrc) + if (resolvedImageSrc && resolvedImageSrc !== formState.basicInfo.imageSrc) { + setResolvedHeadingPreview(formState, resolvedImageSrc) + renderHeadingEditTemplate(form, formState, viewerMode) + } + } + + const result = await openInputDialog({ + title: editHeadingDialogTitleText, + dom, + form, + headerAction: { type: 'none' }, + submitLabel: dialogSubmitLabelText, + cancelLabel: dialogCancelLabelText, + shouldCloseWithoutSave: () => { + const basicInfoOps = summarizeRowOps([formState.basicInfo], rowHasContent) + const phoneOps = summarizeHeadingContactOps(formState.phone, 'phone', formState.phoneTypeWasMissing) + const emailOps = summarizeHeadingContactOps(formState.email, 'email', formState.emailTypeWasMissing) + const addressOps = summarizeRowOps([formState.address], rowHasContent) + + return ( + basicInfoOps.create.length === 0 && basicInfoOps.update.length === 0 && basicInfoOps.remove.length === 0 && + phoneOps.create.length === 0 && phoneOps.update.length === 0 && phoneOps.remove.length === 0 && + emailOps.create.length === 0 && emailOps.update.length === 0 && emailOps.remove.length === 0 && + addressOps.create.length === 0 && addressOps.update.length === 0 && addressOps.remove.length === 0 + ) + }, + validate: () => { + if (viewerMode !== 'owner') { + return ownerLoginRequiredDialogMessageText + } + return validateHeadingDataBeforeSave(formState) + }, + onSave: async () => { + if (formState.pendingImageFile) { + const uploadedUri = await uploadPhotoFile(store, subject, formState.pendingImageFile) + applyRowFieldChange(formState.basicInfo, 'imageSrc', uploadedUri, rowHasContent) + } + + const phoneOps = summarizeHeadingContactOps(formState.phone, 'phone', formState.phoneTypeWasMissing) + const emailOps = summarizeHeadingContactOps(formState.email, 'email', formState.emailTypeWasMissing) + const plan: HeadingMutationPlan = { + basicOps: summarizeRowOps([formState.basicInfo], rowHasContent), + phoneOps: mapPhoneOpsForSave(phoneOps), + emailOps: mapEmailOpsForSave(emailOps), + addressOps: summarizeRowOps([formState.address], rowHasContent) + } + await processHeadingMutations(store, subject, plan) + + const nextPhotoUri = sanitizeTextValue(formState.basicInfo.imageSrc || '') + if (originalPhotoUri && originalPhotoUri !== nextPhotoUri) { + try { + invalidateResolvedPhotoDisplaySrc(originalPhotoUri) + } catch (error) { + console.warn('Failed to invalidate resolved photo cache', error) + } + } + }, + formatSaveError: (error: unknown) => { + return error instanceof Error ? error.message : saveHeadingUpdatesFailedMessageText + } + }) + + if (!result) { + return + } + + if (onSaved) { + await onSaved() + } +} diff --git a/src/components/profile-heading/editor/sections/heading/dateHelpers.ts b/src/components/profile-heading/editor/sections/heading/dateHelpers.ts new file mode 100644 index 00000000..186c0ed6 --- /dev/null +++ b/src/components/profile-heading/editor/sections/heading/dateHelpers.ts @@ -0,0 +1,52 @@ +function normalizeDmy (value: string): string { + const dmyMatch = value.match(/^(\d{2})[/-](\d{2})[/-](\d{4})$/) + if (!dmyMatch) return '' + + const [, day, month, year] = dmyMatch + return `${day}-${month}-${year}` +} + +export function toDisplayDateDMY (value: string | undefined, emptyFallback = ''): string { + const raw = (value || '').trim() + if (!raw) return emptyFallback + + const isoMatch = raw.match(/^(\d{4})-(\d{2})-(\d{2})/) + if (isoMatch) { + const [, year, month, day] = isoMatch + return `${day}-${month}-${year}` + } + + const normalizedDmy = normalizeDmy(raw) + if (normalizedDmy) return normalizedDmy + + return raw +} + +export function toEditableDateDMY (value: string | undefined): string { + const raw = (value || '').trim() + if (!raw) return '' + + const isoMatch = raw.match(/^(\d{4})-(\d{2})-(\d{2})$/) + if (isoMatch) { + const [, year, month, day] = isoMatch + return `${day}-${month}-${year}` + } + + return normalizeDmy(raw) +} + +export function toStorageDateISO (value: string | undefined): string { + const raw = (value || '').trim() + if (!raw) return '' + + const isoMatch = raw.match(/^(\d{4})-(\d{2})-(\d{2})$/) + if (isoMatch) return raw + + const dmyMatch = raw.match(/^(\d{2})[/-](\d{2})[/-](\d{4})$/) + if (dmyMatch) { + const [, day, month, year] = dmyMatch + return `${year}-${month}-${day}` + } + + return '' +} diff --git a/src/components/profile-heading/editor/sections/heading/imageHelpers.ts b/src/components/profile-heading/editor/sections/heading/imageHelpers.ts new file mode 100644 index 00000000..dd3dcb9b --- /dev/null +++ b/src/components/profile-heading/editor/sections/heading/imageHelpers.ts @@ -0,0 +1,134 @@ +import { LiveStore, NamedNode, sym } from 'rdflib' +import { ns } from 'solid-ui' +import { authn, solidLogicSingleton } from 'solid-logic' + +const resolvedHeadingImageCache = new Map() + +export function invalidateResolvedPhotoDisplaySrc (imageSrc?: string): void { + if (!imageSrc) return + + const cachedImageSrc = resolvedHeadingImageCache.get(imageSrc) + if (!cachedImageSrc) return + + resolvedHeadingImageCache.delete(imageSrc) + if (cachedImageSrc.startsWith('blob:') && typeof URL.revokeObjectURL === 'function') { + URL.revokeObjectURL(cachedImageSrc) + } +} +/* Code copied from contact-pane/src/mugshotGallery and modified to fit the needs of the new design */ +const mimeMap: Record = { + 'image/png': 'png', + 'image/jpeg': 'jpg', + 'image/gif': 'gif', + 'image/svg+xml': 'svg', + 'image/webp': 'webp', + 'image/bmp': 'bmp', + 'image/tiff': 'tiff', + 'application/pdf': 'pdf', + 'text/plain': 'txt', + 'text/html': 'html', + 'application/json': 'json', + 'application/octet-stream': 'bin' +} + +const extMap = Object.fromEntries( + Object.entries(mimeMap).map(([contentType, extension]) => [extension, contentType]) +) as Record + +const mime = { + extension: (contentType: string): string | false => mimeMap[contentType] || false, + lookup: (filename: string): string | false => { + const ext = filename.split('.').pop()?.toLowerCase() || '' + return extMap[ext] || false + } +} + +function subjectDirectoryUri (subject: NamedNode): string { + const docUri = subject.doc().uri + const lastSlash = docUri.lastIndexOf('/') + return lastSlash >= 0 ? docUri.slice(0, lastSlash + 1) : docUri +} + +export async function resolvePhotoDisplaySrc (store: LiveStore, imageSrc?: string): Promise { + if (!imageSrc || imageSrc.startsWith('blob:') || imageSrc.startsWith('data:')) { + return imageSrc + } + + const cachedImageSrc = resolvedHeadingImageCache.get(imageSrc) + if (cachedImageSrc) { + return cachedImageSrc + } + + const fetcher = store.fetcher as { _fetch?: (url: string) => Promise } | undefined + if (!fetcher?._fetch || typeof URL.createObjectURL !== 'function') { + return imageSrc + } + + try { + const response = await fetcher._fetch(imageSrc) + if (!response.ok) { + return imageSrc + } + + const imageBlob = await response.blob() + const resolvedImageSrc = URL.createObjectURL(imageBlob) + resolvedHeadingImageCache.set(imageSrc, resolvedImageSrc) + return resolvedImageSrc + } catch { + return imageSrc + } +} + +export async function uploadPhotoFile (store: LiveStore, subject: NamedNode, file: File): Promise { + if (!store.fetcher) { + throw new Error('Store has no fetcher.') + } + + const detectedContentType = file.type || mime.lookup(file.name) || 'application/octet-stream' + if (!detectedContentType.startsWith('image/')) { + throw new Error('Selected file is not an image.') + } + if (file.size > 2 * 1024 * 1024) { + throw new Error('Selected image must be 2 MB or smaller.') + } + + const extension = mime.extension(detectedContentType) || 'bin' + let filename = encodeURIComponent(file.name || `image.${extension}`) + + if (detectedContentType !== mime.lookup(file.name || '')) { + filename += `_.${extension}` + } + + const directoryUri = subjectDirectoryUri(subject) + let candidateUri = `${directoryUri}${filename}` + + for (let index = 0; store.holds(subject, ns.vcard('hasPhoto'), sym(candidateUri)); index++) { + const fallbackName = `image_${index}.${extension}` + candidateUri = `${directoryUri}${fallbackName}` + } + try { + const data = await file.arrayBuffer() + const response = await store.fetcher.webOperation('PUT', candidateUri, { + data: data as unknown as string, + contentType: detectedContentType + } as any) + if (!response.ok) { + throw new Error(`Error uploading picture: ${response.status} ${response.statusText}`) + } + } catch (error) { + throw new Error(`Error uploading picture: ${error}`) + } + + const currentUser = authn.currentUser() + if (currentUser) { + try { + await solidLogicSingleton.acl.setACLUserPublic(candidateUri, currentUser, { + public: ['Read'] as unknown as [] + }) + } catch (error) { + console.error(`Error setting uploaded picture permissions: ${error}`) + } + } + + return candidateUri +} diff --git a/src/components/profile-heading/editor/sections/heading/imagePreview.ts b/src/components/profile-heading/editor/sections/heading/imagePreview.ts new file mode 100644 index 00000000..6effcdb6 --- /dev/null +++ b/src/components/profile-heading/editor/sections/heading/imagePreview.ts @@ -0,0 +1,34 @@ +import { html, nothing } from 'lit-html' +import '~icons/lucide/circle-user-round' + +const personInCircleIcon = html`` + +const showHeadingImageFallback = (event: Event) => { + const image = event.currentTarget as HTMLImageElement | null + const frame = image?.parentElement + if (!image || !frame) return + + image.hidden = true + frame.classList.add('profile__image-frame--fallback') +} + +export const Image = (src?: string, alt?: string) => html` +
+ ${src + ? html` + ${alt + ` + : nothing} + +
+` diff --git a/src/components/profile-heading/editor/sections/heading/mutations.ts b/src/components/profile-heading/editor/sections/heading/mutations.ts new file mode 100644 index 00000000..7e74b5e9 --- /dev/null +++ b/src/components/profile-heading/editor/sections/heading/mutations.ts @@ -0,0 +1,318 @@ +import { LiveStore, NamedNode, Node, st, literal, sym } from 'rdflib' +import { ns } from 'solid-ui' +import { ProfileBasicRow, HeadingMutationPlan } from './types' +import { MutationOps } from '../shared/types' +import { MutationDocumentTextCache, collectLinkedNodeStatements, collectNodeStatements, findExistingNode, replacePredicateStatements, runUpdateTransport, shouldForceDocumentPutForStatements } from '../shared/rdfMutationHelpers' +import { createIdNode } from '../shared/idNodeFactory' +import { ContactAddressRow, ContactPointRow } from '../contactInfo/types' +import { headingMutationSaveFailedDebugText, saveHeadingUpdatesFailedMessageText, updaterUnsupportedStoreErrorMessageText } from '../../texts' + +function splitPronouns (value?: string): { subjectPronoun?: string, objectPronoun?: string } { + const normalized = (value || '').trim() + if (!normalized) return {} + + const [subjectPronounRaw, objectPronounRaw] = normalized.split('/').map((part) => part.trim()) + const subjectPronoun = subjectPronounRaw || undefined + const objectPronoun = objectPronounRaw || undefined + + return { subjectPronoun, objectPronoun } +} + +function buildPhoneStatements (subject: NamedNode, doc: NamedNode, node: Node, phone: ContactPointRow) { + const normalizedValue = phone.value.startsWith('tel:') ? phone.value : `tel:${phone.value}` + const valueNode = sym(normalizedValue) + const inserts = [ + st(subject, ns.vcard('hasTelephone'), node as any, doc), + st(node as any, ns.vcard('value'), valueNode as any, doc) + ] + + if (phone.type) { + inserts.push(st(node as any, ns.rdf('type'), ns.vcard(phone.type), doc)) + } + + return inserts +} + +function buildEmailStatements (subject: NamedNode, doc: NamedNode, node: Node, email: ContactPointRow) { + const normalizedValue = email.value.startsWith('mailto:') ? email.value : `mailto:${email.value}` + const valueNode = sym(normalizedValue) + const inserts = [ + st(subject, ns.vcard('hasEmail'), node as any, doc), + st(node as any, ns.vcard('value'), valueNode as any, doc) + ] + + if (email.type) { + inserts.push(st(node as any, ns.rdf('type'), ns.vcard(email.type), doc)) + } + + return inserts +} + +function buildAddressStatements (subject: NamedNode, doc: NamedNode, node: Node, address: ContactAddressRow) { + const inserts = [st(subject, ns.vcard('hasAddress'), node as any, doc)] + + if (address.type) inserts.push(st(node as any, ns.rdf('type'), ns.vcard(address.type), doc)) + if (address.streetAddress) inserts.push(st(node as any, ns.vcard('street-address'), literal(address.streetAddress), doc)) + if (address.locality) inserts.push(st(node as any, ns.vcard('locality'), literal(address.locality), doc)) + if (address.region) inserts.push(st(node as any, ns.vcard('region'), literal(address.region), doc)) + if (address.postalCode) inserts.push(st(node as any, ns.vcard('postal-code'), literal(address.postalCode), doc)) + if (address.countryName) inserts.push(st(node as any, ns.vcard('country-name'), literal(address.countryName), doc)) + + return inserts +} + +function findOpWithExistingEntry (ops: T[], existingNodes: Node[]): T | undefined { + return ops.find((op) => Boolean(op.entryNode) && Boolean(findExistingNode(existingNodes, op.entryNode))) +} + +function findCreateOp (ops: T[]): T | undefined { + return ops.find((op) => !op.entryNode) +} + +async function mutatePhoneEntry (store: LiveStore, subject: NamedNode, phoneOps: MutationOps, documentTextCache?: MutationDocumentTextCache) { + const doc = subject.doc() + const existingPhoneNodes = store.each(subject, ns.vcard('hasTelephone'), null, doc) as Node[] + const deletions: any[] = [] + const insertions: any[] = [] + + const removePhone = findOpWithExistingEntry(phoneOps.remove, existingPhoneNodes) + const updatePhone = findOpWithExistingEntry(phoneOps.update, existingPhoneNodes) + const createPhone = findCreateOp(phoneOps.create) || phoneOps.create[0] + + if (removePhone?.entryNode) { + const existingNode = findExistingNode(existingPhoneNodes, removePhone.entryNode) + if (existingNode) { + const linkedPhoneStatements = collectLinkedNodeStatements(store, subject, ns.vcard('hasTelephone'), doc) + const matchingLinkStatement = linkedPhoneStatements.linkStatements.find((statement) => statement.object?.value === existingNode.value) + if (matchingLinkStatement) { + deletions.push(matchingLinkStatement) + } + deletions.push(...collectNodeStatements(store, existingNode, doc)) + } + } + + if (updatePhone) { + const existingNode = findExistingNode(existingPhoneNodes, updatePhone.entryNode) + if (existingNode) { + deletions.push(...collectNodeStatements(store, existingNode, doc)) + insertions.push(...buildPhoneStatements(subject, doc, existingNode, updatePhone)) + } + } + + if (createPhone) { + insertions.push(...buildPhoneStatements(subject, doc, createIdNode(doc), createPhone)) + } + + const shouldSerializeDocument = await shouldForceDocumentPutForStatements(store, doc, insertions, undefined, { documentTextCache }) + + await runUpdateTransport(store, doc, deletions, insertions, { + unsupportedMessage: updaterUnsupportedStoreErrorMessageText, + failureMessage: 'Failed to save heading updates', + documentTextCache, + useDavFallback: false, + usePutFallback: shouldSerializeDocument, + forcePut: shouldSerializeDocument + }) +} + +async function mutateEmailEntry (store: LiveStore, subject: NamedNode, emailOps: MutationOps, documentTextCache?: MutationDocumentTextCache) { + const doc = subject.doc() + const existingEmailNodes = store.each(subject, ns.vcard('hasEmail'), null, doc) as Node[] + const deletions: any[] = [] + const insertions: any[] = [] + + const removeEmail = findOpWithExistingEntry(emailOps.remove, existingEmailNodes) + const updateEmail = findOpWithExistingEntry(emailOps.update, existingEmailNodes) + const createEmail = findCreateOp(emailOps.create) || emailOps.create[0] + + if (removeEmail?.entryNode) { + const existingNode = findExistingNode(existingEmailNodes, removeEmail.entryNode) + if (existingNode) { + const linkedEmailStatements = collectLinkedNodeStatements(store, subject, ns.vcard('hasEmail'), doc) + const matchingLinkStatement = linkedEmailStatements.linkStatements.find((statement) => statement.object?.value === existingNode.value) + if (matchingLinkStatement) { + deletions.push(matchingLinkStatement) + } + deletions.push(...collectNodeStatements(store, existingNode, doc)) + } + } + + if (updateEmail) { + const existingNode = findExistingNode(existingEmailNodes, updateEmail.entryNode) + if (existingNode) { + deletions.push(...collectNodeStatements(store, existingNode, doc)) + insertions.push(...buildEmailStatements(subject, doc, existingNode, updateEmail)) + } + } + + if (createEmail) { + insertions.push(...buildEmailStatements(subject, doc, createIdNode(doc), createEmail)) + } + + const shouldSerializeDocument = await shouldForceDocumentPutForStatements(store, doc, insertions, undefined, { documentTextCache }) + + await runUpdateTransport(store, doc, deletions, insertions, { + unsupportedMessage: updaterUnsupportedStoreErrorMessageText, + failureMessage: 'Failed to save heading updates', + documentTextCache, + useDavFallback: false, + usePutFallback: shouldSerializeDocument, + forcePut: shouldSerializeDocument + }) +} + +async function mutateAddressEntry (store: LiveStore, subject: NamedNode, addressOps: MutationOps, documentTextCache?: MutationDocumentTextCache) { + const doc = subject.doc() + const existingAddressNodes = store.each(subject, ns.vcard('hasAddress'), null, doc) as Node[] + const deletions: any[] = [] + const insertions: any[] = [] + + const removeAddress = findOpWithExistingEntry(addressOps.remove, existingAddressNodes) + const updateAddress = findOpWithExistingEntry(addressOps.update, existingAddressNodes) + const createAddress = findCreateOp(addressOps.create) || addressOps.create[0] + + if (removeAddress?.entryNode) { + const existingNode = findExistingNode(existingAddressNodes, removeAddress.entryNode) + if (existingNode) { + const linkedAddressStatements = collectLinkedNodeStatements(store, subject, ns.vcard('hasAddress'), doc) + const matchingLinkStatement = linkedAddressStatements.linkStatements.find((statement) => statement.object?.value === existingNode.value) + if (matchingLinkStatement) { + deletions.push(matchingLinkStatement) + } + deletions.push(...collectNodeStatements(store, existingNode, doc)) + } + } + + if (updateAddress) { + const existingNode = findExistingNode(existingAddressNodes, updateAddress.entryNode) + if (existingNode) { + deletions.push(...collectNodeStatements(store, existingNode, doc)) + insertions.push(...buildAddressStatements(subject, doc, existingNode, updateAddress)) + } + } + + if (createAddress) { + insertions.push(...buildAddressStatements(subject, doc, createIdNode(doc), createAddress)) + } + + const shouldSerializeDocument = await shouldForceDocumentPutForStatements(store, doc, insertions, undefined, { documentTextCache }) + + await runUpdateTransport(store, doc, deletions, insertions, { + unsupportedMessage: updaterUnsupportedStoreErrorMessageText, + failureMessage: 'Failed to save heading updates', + documentTextCache, + useDavFallback: false, + usePutFallback: shouldSerializeDocument, + forcePut: shouldSerializeDocument + }) +} + +async function mutateBasicProfileEntry (store: LiveStore, subject: NamedNode, basicOps: MutationOps, documentTextCache?: MutationDocumentTextCache) { + const doc = subject.doc() + const deletions: any[] = [] + const insertions: any[] = [] + + const replaceLiteralField = (predicate: NamedNode, value?: string) => { + const normalized = (value || '').trim() + const nextObject = normalized ? literal(normalized) : null + replacePredicateStatements(store, subject, predicate, doc, deletions, insertions, nextObject) + } + + const replacePhotoField = (value?: string) => { + const normalized = (value || '').trim() + const nextObject = !normalized + ? null + : (normalized.startsWith('http://') || normalized.startsWith('https://')) + ? sym(normalized) + : literal(normalized) + replacePredicateStatements(store, subject, ns.vcard('hasPhoto'), doc, deletions, insertions, nextObject) + } + + const replacePronounFields = (value?: string) => { + const { subjectPronoun, objectPronoun } = splitPronouns(value) + + replacePredicateStatements( + store, + subject, + ns.solid('preferredSubjectPronoun'), + doc, + deletions, + insertions, + subjectPronoun ? literal(subjectPronoun) : null + ) + replacePredicateStatements( + store, + subject, + ns.solid('preferredObjectPronoun'), + doc, + deletions, + insertions, + objectPronoun ? literal(objectPronoun) : null + ) + replacePredicateStatements( + store, + subject, + ns.solid('preferredRelativePronoun'), + doc, + deletions, + insertions, + null + ) + } + + const applyBasics = (basic: ProfileBasicRow, clearAll = false) => { + const data = clearAll + ? { + name: '', + nickname: '', + pronouns: '', + dateOfBirth: '', + imageSrc: '' + } + : basic + + replaceLiteralField(ns.vcard('fn'), data.name) + // Keep foaf:nick in sync where available in existing data. + replaceLiteralField(ns.foaf('nick'), data.nickname) + replaceLiteralField(ns.vcard('nickname'), data.nickname) + replaceLiteralField(ns.vcard('bday'), data.dateOfBirth) + replacePronounFields(data.pronouns) + replacePhotoField(data.imageSrc) + } + + const removeBasic = basicOps.remove[0] + const updateBasic = basicOps.update[0] + const createBasic = basicOps.create[0] + + const selectedBasic = updateBasic || createBasic || removeBasic + if (selectedBasic) { + applyBasics(selectedBasic, Boolean(removeBasic && !updateBasic && !createBasic)) + } + + const shouldSerializeDocument = await shouldForceDocumentPutForStatements(store, doc, insertions, undefined, { documentTextCache }) + + await runUpdateTransport(store, doc, deletions, insertions, { + unsupportedMessage: updaterUnsupportedStoreErrorMessageText, + failureMessage: 'Failed to save heading updates', + documentTextCache, + useDavFallback: false, + usePutFallback: shouldSerializeDocument, + forcePut: shouldSerializeDocument + }) +} + +export async function processHeadingMutations (store: LiveStore, subject: NamedNode, mutationPlan: HeadingMutationPlan) { + try { + const documentTextCache: MutationDocumentTextCache = new Map() + await mutateBasicProfileEntry(store, subject, mutationPlan.basicOps, documentTextCache) + await mutatePhoneEntry(store, subject, mutationPlan.phoneOps, documentTextCache) + await mutateEmailEntry(store, subject, mutationPlan.emailOps, documentTextCache) + await mutateAddressEntry(store, subject, mutationPlan.addressOps, documentTextCache) + } catch (error) { + const rootError = error instanceof Error ? error : new Error(String(error)) + console.error(headingMutationSaveFailedDebugText, rootError) + const saveError = new Error(saveHeadingUpdatesFailedMessageText) + Object.defineProperty(saveError, 'cause', { value: rootError }) + throw saveError + } +} diff --git a/src/components/profile-heading/editor/sections/heading/types.ts b/src/components/profile-heading/editor/sections/heading/types.ts new file mode 100644 index 00000000..5f9bd6b7 --- /dev/null +++ b/src/components/profile-heading/editor/sections/heading/types.ts @@ -0,0 +1,43 @@ +import { Node } from 'rdflib' +import { RowStatus } from '../shared/types' +import { MutationOps } from '../shared/types' +import type { AddressDetails, ContactAddressRow, ContactPointRow, PointDetails } from 'profile-pane' + +export interface ProfilePresentation { + name: string; + nickname?: string; + imageSrc?: string; + location?: string; + pronouns?: string; + dateOfBirth?: string; + jobTitle?: string; + primaryPhone?: PointDetails; + primaryEmail?: PointDetails; + primaryAddress?: AddressDetails; +} + +export interface ProfileDetails extends ProfilePresentation { + entryNode: Node +} + +export interface ProfileRow extends ProfilePresentation { + entryNode: string + status: RowStatus +} + +export type ProfileBasicFields = Omit< + ProfilePresentation, + 'jobTitle' | 'primaryPhone' | 'primaryEmail' | 'primaryAddress' +> + +export type ProfileBasicRow = ProfileBasicFields & { + entryNode: string + status: RowStatus +} + +export type HeadingMutationPlan = { + basicOps: MutationOps + phoneOps: MutationOps + emailOps: MutationOps + addressOps: MutationOps +} diff --git a/src/components/profile-heading/editor/sections/shared/contactTypeUtils.ts b/src/components/profile-heading/editor/sections/shared/contactTypeUtils.ts new file mode 100644 index 00000000..73270400 --- /dev/null +++ b/src/components/profile-heading/editor/sections/shared/contactTypeUtils.ts @@ -0,0 +1,47 @@ +import { toTypeLabel } from '../../textUtils' + +export function normalizePhoneTypeForEdit (value: unknown): string { + const label = toTypeLabel(value).trim().toLowerCase() + if (!label) return '' + + if (label === 'cell' || label === 'mobile') return 'Mobile' + if (label === 'home') return 'Home' + if (label === 'work' || label === 'office') return 'Work' + return '' +} + +export function normalizePhoneTypeForContactInfoEdit (value: unknown): string { + const label = toTypeLabel(value).trim().toLowerCase() + if (!label) return '' + + if (label === 'cell' || label === 'mobile') return 'Cell' + if (label === 'home') return 'Home' + if (label === 'work' || label === 'office') return 'Work' + return '' +} + +export function normalizeEmailTypeForEdit (value: unknown): string { + const label = toTypeLabel(value).trim().toLowerCase() + if (!label) return '' + + if (label === 'personal' || label === 'home') return 'Personal' + if (label === 'office' || label === 'work') return 'Office' + return '' +} + +export function normalizeEmailTypeForContactInfoEdit (value: unknown): string { + const label = toTypeLabel(value).trim().toLowerCase() + if (!label) return '' + + if (label === 'personal' || label === 'home') return 'Home' + if (label === 'office' || label === 'work') return 'Office' + return '' +} + +export function toSavedHeadingEmailType (type: string | undefined): string { + return type === 'Personal' ? 'Home' : (type || '') +} + +export function toSavedHeadingPhoneType (type: string | undefined): string { + return type === 'Mobile' ? 'Cell' : (type || '') +} diff --git a/src/components/profile-heading/editor/sections/shared/idNodeFactory.ts b/src/components/profile-heading/editor/sections/shared/idNodeFactory.ts new file mode 100644 index 00000000..834d58e0 --- /dev/null +++ b/src/components/profile-heading/editor/sections/shared/idNodeFactory.ts @@ -0,0 +1,10 @@ +import { NamedNode, sym } from 'rdflib' + +let lastIssuedTimestamp = 0 + +export function createIdNode (doc: NamedNode): NamedNode { + const now = Date.now() + const timestampId = now > lastIssuedTimestamp ? now : lastIssuedTimestamp + 1 + lastIssuedTimestamp = timestampId + return sym(`${doc.uri}#id${timestampId}`) as NamedNode +} diff --git a/src/components/profile-heading/editor/sections/shared/phoneCountries.ts b/src/components/profile-heading/editor/sections/shared/phoneCountries.ts new file mode 100644 index 00000000..58bb6073 --- /dev/null +++ b/src/components/profile-heading/editor/sections/shared/phoneCountries.ts @@ -0,0 +1,354 @@ +// Not in use now. + +export type CountryDialOption = { + iso2: string + dialCode: string + name: string +} + +export const DEFAULT_DIAL_CODE = '' + +export const COUNTRY_DIAL_OPTIONS: CountryDialOption[] = [ + { iso2: 'EG', dialCode: '+20', name: 'Egypt' }, + { iso2: 'ZA', dialCode: '+27', name: 'South Africa' }, + { iso2: 'GR', dialCode: '+30', name: 'Greece' }, + { iso2: 'NL', dialCode: '+31', name: 'Netherlands' }, + { iso2: 'BE', dialCode: '+32', name: 'Belgium' }, + { iso2: 'FR', dialCode: '+33', name: 'France' }, + { iso2: 'ES', dialCode: '+34', name: 'Spain' }, + { iso2: 'HU', dialCode: '+36', name: 'Hungary' }, + { iso2: 'IT', dialCode: '+39', name: 'Italy' }, + { iso2: 'RO', dialCode: '+40', name: 'Romania' }, + { iso2: 'CH', dialCode: '+41', name: 'Switzerland' }, + { iso2: 'AT', dialCode: '+43', name: 'Austria' }, + { iso2: 'GG', dialCode: '+44', name: 'Guernsey' }, + { iso2: 'IM', dialCode: '+44', name: 'Isle of Man' }, + { iso2: 'JE', dialCode: '+44', name: 'Jersey' }, + { iso2: 'GB', dialCode: '+44', name: 'United Kingdom' }, + { iso2: 'DK', dialCode: '+45', name: 'Denmark' }, + { iso2: 'SE', dialCode: '+46', name: 'Sweden' }, + { iso2: 'BV', dialCode: '+47', name: 'Bouvet Island' }, + { iso2: 'NO', dialCode: '+47', name: 'Norway' }, + { iso2: 'PL', dialCode: '+48', name: 'Poland' }, + { iso2: 'DE', dialCode: '+49', name: 'Germany' }, + { iso2: 'PE', dialCode: '+51', name: 'Peru' }, + { iso2: 'MX', dialCode: '+52', name: 'Mexico' }, + { iso2: 'CU', dialCode: '+53', name: 'Cuba' }, + { iso2: 'AR', dialCode: '+54', name: 'Argentina' }, + { iso2: 'BR', dialCode: '+55', name: 'Brazil' }, + { iso2: 'CL', dialCode: '+56', name: 'Chile' }, + { iso2: 'CO', dialCode: '+57', name: 'Colombia' }, + { iso2: 'VE', dialCode: '+58', name: 'Venezuela' }, + { iso2: 'MY', dialCode: '+60', name: 'Malaysia' }, + { iso2: 'AU', dialCode: '+61', name: 'Australia' }, + { iso2: 'CX', dialCode: '+61', name: 'Christmas Island' }, + { iso2: 'CC', dialCode: '+61', name: 'Cocos (Keeling) Islands' }, + { iso2: 'ID', dialCode: '+62', name: 'Indonesia' }, + { iso2: 'PH', dialCode: '+63', name: 'Philippines' }, + { iso2: 'NZ', dialCode: '+64', name: 'New Zealand' }, + { iso2: 'PN', dialCode: '+64', name: 'Pitcairn Islands' }, + { iso2: 'SG', dialCode: '+65', name: 'Singapore' }, + { iso2: 'TH', dialCode: '+66', name: 'Thailand' }, + { iso2: 'RU', dialCode: '+73', name: 'Russia' }, + { iso2: 'KZ', dialCode: '+76', name: 'Kazakhstan' }, + { iso2: 'JP', dialCode: '+81', name: 'Japan' }, + { iso2: 'KR', dialCode: '+82', name: 'South Korea' }, + { iso2: 'VN', dialCode: '+84', name: 'Vietnam' }, + { iso2: 'CN', dialCode: '+86', name: 'China' }, + { iso2: 'TR', dialCode: '+90', name: 'Turkiye' }, + { iso2: 'IN', dialCode: '+91', name: 'India' }, + { iso2: 'PK', dialCode: '+92', name: 'Pakistan' }, + { iso2: 'AF', dialCode: '+93', name: 'Afghanistan' }, + { iso2: 'LK', dialCode: '+94', name: 'Sri Lanka' }, + { iso2: 'MM', dialCode: '+95', name: 'Myanmar' }, + { iso2: 'IR', dialCode: '+98', name: 'Iran' }, + { iso2: 'SS', dialCode: '+211', name: 'South Sudan' }, + { iso2: 'MA', dialCode: '+212', name: 'Morocco' }, + { iso2: 'DZ', dialCode: '+213', name: 'Algeria' }, + { iso2: 'TN', dialCode: '+216', name: 'Tunisia' }, + { iso2: 'LY', dialCode: '+218', name: 'Libya' }, + { iso2: 'GM', dialCode: '+220', name: 'Gambia' }, + { iso2: 'SN', dialCode: '+221', name: 'Senegal' }, + { iso2: 'MR', dialCode: '+222', name: 'Mauritania' }, + { iso2: 'ML', dialCode: '+223', name: 'Mali' }, + { iso2: 'GN', dialCode: '+224', name: 'Guinea' }, + { iso2: 'CI', dialCode: '+225', name: 'Ivory Coast' }, + { iso2: 'BF', dialCode: '+226', name: 'Burkina Faso' }, + { iso2: 'NE', dialCode: '+227', name: 'Niger' }, + { iso2: 'TG', dialCode: '+228', name: 'Togo' }, + { iso2: 'BJ', dialCode: '+229', name: 'Benin' }, + { iso2: 'MU', dialCode: '+230', name: 'Mauritius' }, + { iso2: 'LR', dialCode: '+231', name: 'Liberia' }, + { iso2: 'SL', dialCode: '+232', name: 'Sierra Leone' }, + { iso2: 'GH', dialCode: '+233', name: 'Ghana' }, + { iso2: 'NG', dialCode: '+234', name: 'Nigeria' }, + { iso2: 'TD', dialCode: '+235', name: 'Chad' }, + { iso2: 'CF', dialCode: '+236', name: 'Central African Republic' }, + { iso2: 'CM', dialCode: '+237', name: 'Cameroon' }, + { iso2: 'CV', dialCode: '+238', name: 'Cape Verde' }, + { iso2: 'ST', dialCode: '+239', name: 'Sao Tome and Principe' }, + { iso2: 'GQ', dialCode: '+240', name: 'Equatorial Guinea' }, + { iso2: 'GA', dialCode: '+241', name: 'Gabon' }, + { iso2: 'CG', dialCode: '+242', name: 'Congo' }, + { iso2: 'CD', dialCode: '+243', name: 'DR Congo' }, + { iso2: 'AO', dialCode: '+244', name: 'Angola' }, + { iso2: 'GW', dialCode: '+245', name: 'Guinea-Bissau' }, + { iso2: 'IO', dialCode: '+246', name: 'British Indian Ocean Territory' }, + { iso2: 'SC', dialCode: '+248', name: 'Seychelles' }, + { iso2: 'SD', dialCode: '+249', name: 'Sudan' }, + { iso2: 'RW', dialCode: '+250', name: 'Rwanda' }, + { iso2: 'ET', dialCode: '+251', name: 'Ethiopia' }, + { iso2: 'SO', dialCode: '+252', name: 'Somalia' }, + { iso2: 'DJ', dialCode: '+253', name: 'Djibouti' }, + { iso2: 'KE', dialCode: '+254', name: 'Kenya' }, + { iso2: 'TZ', dialCode: '+255', name: 'Tanzania' }, + { iso2: 'UG', dialCode: '+256', name: 'Uganda' }, + { iso2: 'BI', dialCode: '+257', name: 'Burundi' }, + { iso2: 'MZ', dialCode: '+258', name: 'Mozambique' }, + { iso2: 'ZM', dialCode: '+260', name: 'Zambia' }, + { iso2: 'MG', dialCode: '+261', name: 'Madagascar' }, + { iso2: 'TF', dialCode: '+262', name: 'French Southern and Antarctic Lands' }, + { iso2: 'YT', dialCode: '+262', name: 'Mayotte' }, + { iso2: 'RE', dialCode: '+262', name: 'Reunion' }, + { iso2: 'ZW', dialCode: '+263', name: 'Zimbabwe' }, + { iso2: 'NA', dialCode: '+264', name: 'Namibia' }, + { iso2: 'MW', dialCode: '+265', name: 'Malawi' }, + { iso2: 'LS', dialCode: '+266', name: 'Lesotho' }, + { iso2: 'BW', dialCode: '+267', name: 'Botswana' }, + { iso2: 'SZ', dialCode: '+268', name: 'Eswatini' }, + { iso2: 'UM', dialCode: '+268', name: 'United States Minor Outlying Islands' }, + { iso2: 'KM', dialCode: '+269', name: 'Comoros' }, + { iso2: 'SH', dialCode: '+290', name: 'Saint Helena, Ascension and Tristan da Cunha' }, + { iso2: 'ER', dialCode: '+291', name: 'Eritrea' }, + { iso2: 'AW', dialCode: '+297', name: 'Aruba' }, + { iso2: 'FO', dialCode: '+298', name: 'Faroe Islands' }, + { iso2: 'GL', dialCode: '+299', name: 'Greenland' }, + { iso2: 'GI', dialCode: '+350', name: 'Gibraltar' }, + { iso2: 'PT', dialCode: '+351', name: 'Portugal' }, + { iso2: 'LU', dialCode: '+352', name: 'Luxembourg' }, + { iso2: 'IE', dialCode: '+353', name: 'Ireland' }, + { iso2: 'IS', dialCode: '+354', name: 'Iceland' }, + { iso2: 'AL', dialCode: '+355', name: 'Albania' }, + { iso2: 'MT', dialCode: '+356', name: 'Malta' }, + { iso2: 'CY', dialCode: '+357', name: 'Cyprus' }, + { iso2: 'FI', dialCode: '+358', name: 'Finland' }, + { iso2: 'BG', dialCode: '+359', name: 'Bulgaria' }, + { iso2: 'LT', dialCode: '+370', name: 'Lithuania' }, + { iso2: 'LV', dialCode: '+371', name: 'Latvia' }, + { iso2: 'EE', dialCode: '+372', name: 'Estonia' }, + { iso2: 'MD', dialCode: '+373', name: 'Moldova' }, + { iso2: 'AM', dialCode: '+374', name: 'Armenia' }, + { iso2: 'BY', dialCode: '+375', name: 'Belarus' }, + { iso2: 'AD', dialCode: '+376', name: 'Andorra' }, + { iso2: 'MC', dialCode: '+377', name: 'Monaco' }, + { iso2: 'SM', dialCode: '+378', name: 'San Marino' }, + { iso2: 'UA', dialCode: '+380', name: 'Ukraine' }, + { iso2: 'RS', dialCode: '+381', name: 'Serbia' }, + { iso2: 'ME', dialCode: '+382', name: 'Montenegro' }, + { iso2: 'XK', dialCode: '+383', name: 'Kosovo' }, + { iso2: 'HR', dialCode: '+385', name: 'Croatia' }, + { iso2: 'SI', dialCode: '+386', name: 'Slovenia' }, + { iso2: 'BA', dialCode: '+387', name: 'Bosnia and Herzegovina' }, + { iso2: 'MK', dialCode: '+389', name: 'North Macedonia' }, + { iso2: 'CZ', dialCode: '+420', name: 'Czechia' }, + { iso2: 'SK', dialCode: '+421', name: 'Slovakia' }, + { iso2: 'LI', dialCode: '+423', name: 'Liechtenstein' }, + { iso2: 'FK', dialCode: '+500', name: 'Falkland Islands' }, + { iso2: 'GS', dialCode: '+500', name: 'South Georgia' }, + { iso2: 'BZ', dialCode: '+501', name: 'Belize' }, + { iso2: 'GT', dialCode: '+502', name: 'Guatemala' }, + { iso2: 'SV', dialCode: '+503', name: 'El Salvador' }, + { iso2: 'HN', dialCode: '+504', name: 'Honduras' }, + { iso2: 'NI', dialCode: '+505', name: 'Nicaragua' }, + { iso2: 'CR', dialCode: '+506', name: 'Costa Rica' }, + { iso2: 'PA', dialCode: '+507', name: 'Panama' }, + { iso2: 'PM', dialCode: '+508', name: 'Saint Pierre and Miquelon' }, + { iso2: 'HT', dialCode: '+509', name: 'Haiti' }, + { iso2: 'GP', dialCode: '+590', name: 'Guadeloupe' }, + { iso2: 'BL', dialCode: '+590', name: 'Saint Barthelemy' }, + { iso2: 'MF', dialCode: '+590', name: 'Saint Martin' }, + { iso2: 'BO', dialCode: '+591', name: 'Bolivia' }, + { iso2: 'GY', dialCode: '+592', name: 'Guyana' }, + { iso2: 'EC', dialCode: '+593', name: 'Ecuador' }, + { iso2: 'GF', dialCode: '+594', name: 'French Guiana' }, + { iso2: 'PY', dialCode: '+595', name: 'Paraguay' }, + { iso2: 'MQ', dialCode: '+596', name: 'Martinique' }, + { iso2: 'SR', dialCode: '+597', name: 'Suriname' }, + { iso2: 'UY', dialCode: '+598', name: 'Uruguay' }, + { iso2: 'BQ', dialCode: '+599', name: 'Caribbean Netherlands' }, + { iso2: 'CW', dialCode: '+599', name: 'Curacao' }, + { iso2: 'TL', dialCode: '+670', name: 'Timor-Leste' }, + { iso2: 'NF', dialCode: '+672', name: 'Norfolk Island' }, + { iso2: 'BN', dialCode: '+673', name: 'Brunei' }, + { iso2: 'NR', dialCode: '+674', name: 'Nauru' }, + { iso2: 'PG', dialCode: '+675', name: 'Papua New Guinea' }, + { iso2: 'TO', dialCode: '+676', name: 'Tonga' }, + { iso2: 'SB', dialCode: '+677', name: 'Solomon Islands' }, + { iso2: 'VU', dialCode: '+678', name: 'Vanuatu' }, + { iso2: 'FJ', dialCode: '+679', name: 'Fiji' }, + { iso2: 'PW', dialCode: '+680', name: 'Palau' }, + { iso2: 'WF', dialCode: '+681', name: 'Wallis and Futuna' }, + { iso2: 'CK', dialCode: '+682', name: 'Cook Islands' }, + { iso2: 'NU', dialCode: '+683', name: 'Niue' }, + { iso2: 'WS', dialCode: '+685', name: 'Samoa' }, + { iso2: 'KI', dialCode: '+686', name: 'Kiribati' }, + { iso2: 'NC', dialCode: '+687', name: 'New Caledonia' }, + { iso2: 'TV', dialCode: '+688', name: 'Tuvalu' }, + { iso2: 'PF', dialCode: '+689', name: 'French Polynesia' }, + { iso2: 'TK', dialCode: '+690', name: 'Tokelau' }, + { iso2: 'FM', dialCode: '+691', name: 'Micronesia' }, + { iso2: 'MH', dialCode: '+692', name: 'Marshall Islands' }, + { iso2: 'KP', dialCode: '+850', name: 'North Korea' }, + { iso2: 'HK', dialCode: '+852', name: 'Hong Kong' }, + { iso2: 'MO', dialCode: '+853', name: 'Macau' }, + { iso2: 'KH', dialCode: '+855', name: 'Cambodia' }, + { iso2: 'LA', dialCode: '+856', name: 'Laos' }, + { iso2: 'BD', dialCode: '+880', name: 'Bangladesh' }, + { iso2: 'TW', dialCode: '+886', name: 'Taiwan' }, + { iso2: 'MV', dialCode: '+960', name: 'Maldives' }, + { iso2: 'LB', dialCode: '+961', name: 'Lebanon' }, + { iso2: 'JO', dialCode: '+962', name: 'Jordan' }, + { iso2: 'SY', dialCode: '+963', name: 'Syria' }, + { iso2: 'IQ', dialCode: '+964', name: 'Iraq' }, + { iso2: 'KW', dialCode: '+965', name: 'Kuwait' }, + { iso2: 'SA', dialCode: '+966', name: 'Saudi Arabia' }, + { iso2: 'YE', dialCode: '+967', name: 'Yemen' }, + { iso2: 'OM', dialCode: '+968', name: 'Oman' }, + { iso2: 'PS', dialCode: '+970', name: 'Palestine' }, + { iso2: 'AE', dialCode: '+971', name: 'United Arab Emirates' }, + { iso2: 'IL', dialCode: '+972', name: 'Israel' }, + { iso2: 'BH', dialCode: '+973', name: 'Bahrain' }, + { iso2: 'QA', dialCode: '+974', name: 'Qatar' }, + { iso2: 'BT', dialCode: '+975', name: 'Bhutan' }, + { iso2: 'MN', dialCode: '+976', name: 'Mongolia' }, + { iso2: 'NP', dialCode: '+977', name: 'Nepal' }, + { iso2: 'TJ', dialCode: '+992', name: 'Tajikistan' }, + { iso2: 'TM', dialCode: '+993', name: 'Turkmenistan' }, + { iso2: 'AZ', dialCode: '+994', name: 'Azerbaijan' }, + { iso2: 'GE', dialCode: '+995', name: 'Georgia' }, + { iso2: 'KG', dialCode: '+996', name: 'Kyrgyzstan' }, + { iso2: 'UZ', dialCode: '+998', name: 'Uzbekistan' }, + { iso2: 'US', dialCode: '+1201', name: 'United States' }, + { iso2: 'CA', dialCode: '+1204', name: 'Canada' }, + { iso2: 'BS', dialCode: '+1242', name: 'Bahamas' }, + { iso2: 'BB', dialCode: '+1246', name: 'Barbados' }, + { iso2: 'AI', dialCode: '+1264', name: 'Anguilla' }, + { iso2: 'AG', dialCode: '+1268', name: 'Antigua and Barbuda' }, + { iso2: 'VG', dialCode: '+1284', name: 'British Virgin Islands' }, + { iso2: 'VI', dialCode: '+1340', name: 'United States Virgin Islands' }, + { iso2: 'KY', dialCode: '+1345', name: 'Cayman Islands' }, + { iso2: 'BM', dialCode: '+1441', name: 'Bermuda' }, + { iso2: 'GD', dialCode: '+1473', name: 'Grenada' }, + { iso2: 'TC', dialCode: '+1649', name: 'Turks and Caicos Islands' }, + { iso2: 'MS', dialCode: '+1664', name: 'Montserrat' }, + { iso2: 'MP', dialCode: '+1670', name: 'Northern Mariana Islands' }, + { iso2: 'GU', dialCode: '+1671', name: 'Guam' }, + { iso2: 'AS', dialCode: '+1684', name: 'American Samoa' }, + { iso2: 'SX', dialCode: '+1721', name: 'Sint Maarten' }, + { iso2: 'LC', dialCode: '+1758', name: 'Saint Lucia' }, + { iso2: 'DM', dialCode: '+1767', name: 'Dominica' }, + { iso2: 'VC', dialCode: '+1784', name: 'Saint Vincent and the Grenadines' }, + { iso2: 'PR', dialCode: '+1787', name: 'Puerto Rico' }, + { iso2: 'DO', dialCode: '+1809', name: 'Dominican Republic' }, + { iso2: 'TT', dialCode: '+1868', name: 'Trinidad and Tobago' }, + { iso2: 'KN', dialCode: '+1869', name: 'Saint Kitts and Nevis' }, + { iso2: 'JM', dialCode: '+1876', name: 'Jamaica' }, + { iso2: 'SJ', dialCode: '+4779', name: 'Svalbard and Jan Mayen' }, + { iso2: 'AX', dialCode: '+35818', name: 'Aland Islands' }, + { iso2: 'EH', dialCode: '+2125288', name: 'Western Sahara' }, + { iso2: 'VA', dialCode: '+3906698', name: 'Vatican City' }, +] + +const NON_USER_FACING_ISO2 = new Set([ + 'AQ', 'AX', 'BL', 'BM', 'BQ', 'BV', 'CC', 'CK', 'CP', 'CW', 'CX', 'EH', 'FK', 'FO', + 'GF', 'GG', 'GI', 'GL', 'GP', 'GS', 'GU', 'HK', 'HM', 'IM', 'IO', 'JE', 'KY', 'MF', + 'MO', 'MP', 'MQ', 'MS', 'NC', 'NF', 'NU', 'PF', 'PM', 'PN', 'PR', 'RE', 'SH', 'SJ', + 'TC', 'TF', 'TK', 'UM', 'VG', 'VI', 'WF', 'YT' +]) + +function normalizeDialCode (rawDialCode: string): string { + if (/^\+1\d{3,}$/.test(rawDialCode)) return '+1' + if (/^\+7\d+$/.test(rawDialCode)) return '+7' + if (/^\+39\d{3,}$/.test(rawDialCode)) return '+39' + if (/^\+358\d+$/.test(rawDialCode)) return '+358' + if (/^\+47\d+$/.test(rawDialCode)) return '+47' + if (/^\+212\d+$/.test(rawDialCode)) return '+212' + return rawDialCode +} + +const COUNTRY_DIAL_OPTIONS_USER = COUNTRY_DIAL_OPTIONS + .filter((option) => !NON_USER_FACING_ISO2.has(option.iso2)) + .map((option) => ({ ...option, dialCode: normalizeDialCode(option.dialCode) })) + .filter((option, index, source) => { + const key = `${option.iso2}|${option.dialCode}` + return source.findIndex((candidate) => `${candidate.iso2}|${candidate.dialCode}` === key) === index + }) + +export const COUNTRY_DIAL_OPTIONS_ASC = [...COUNTRY_DIAL_OPTIONS_USER].sort((a, b) => { + const codeA = Number.parseInt(a.dialCode.replace('+', ''), 10) + const codeB = Number.parseInt(b.dialCode.replace('+', ''), 10) + if (codeA !== codeB) return codeA - codeB + return a.name.localeCompare(b.name) +}) + +const PREFERRED_ISO_BY_DIAL_CODE: Record = { + '+1': 'US', + '+7': 'RU' +} + +export const COUNTRY_PREFIX_OPTIONS = Array.from( + COUNTRY_DIAL_OPTIONS_ASC.reduce((map, option) => { + const current = map.get(option.dialCode) + if (!current) { + map.set(option.dialCode, option) + return map + } + + const preferredIso = PREFERRED_ISO_BY_DIAL_CODE[option.dialCode] + if (preferredIso && option.iso2 === preferredIso) { + map.set(option.dialCode, option) + } + + return map + }, new Map()).values() +) + +const DIAL_CODES_DESC = Array.from(new Set(COUNTRY_PREFIX_OPTIONS.map((option) => option.dialCode))).sort( + (a, b) => b.length - a.length +) + +export function countryCodeToFlag (iso2: string): string { + const normalized = iso2.toUpperCase() + if (!/^[A-Z]{2}$/.test(normalized)) return '' + const codePoints = [...normalized].map((char) => 127397 + char.charCodeAt(0)) + return String.fromCodePoint(...codePoints) +} + +export function splitPhoneValue (raw: string) { + const value = raw.trim() + if (!value) return { dialCode: DEFAULT_DIAL_CODE, localNumber: '' } + if (!value.startsWith('+')) return { dialCode: DEFAULT_DIAL_CODE, localNumber: value } + + const matchedDialCode = DIAL_CODES_DESC.find((dialCode) => value.startsWith(dialCode)) + if (!matchedDialCode) { + return { dialCode: DEFAULT_DIAL_CODE, localNumber: value } + } + + const normalizedDialCode = normalizeDialCode(matchedDialCode) + const localNumber = value.slice(matchedDialCode.length) + const fallbackLocalNumber = value.slice(normalizedDialCode.length) + + return { + dialCode: COUNTRY_PREFIX_OPTIONS.some((option) => option.dialCode === normalizedDialCode) + ? normalizedDialCode + : DEFAULT_DIAL_CODE, + localNumber: matchedDialCode.length > normalizedDialCode.length ? fallbackLocalNumber : localNumber + } +} + +export function combinePhoneValue (dialCode: string, localNumber: string): string { + const trimmed = localNumber.trim() + if (!trimmed) return '' + if (trimmed.startsWith('+')) return trimmed + return dialCode ? `${dialCode}${trimmed}` : trimmed +} diff --git a/src/components/profile-heading/editor/sections/shared/rdfMutationHelpers.ts b/src/components/profile-heading/editor/sections/shared/rdfMutationHelpers.ts new file mode 100644 index 00000000..ffdf5ca9 --- /dev/null +++ b/src/components/profile-heading/editor/sections/shared/rdfMutationHelpers.ts @@ -0,0 +1,503 @@ +import { graph, LiveStore, NamedNode, Node, st } from 'rdflib' +import { fallbackSaveUpdatesErrorMessageText, updaterUnsupportedStoreErrorMessageText } from '../../texts' +import { PrefixCapable, RdfFetcher, RdfStatement, RdfUpdater } from './types' +/* Some of the code below was generated by AI Model: GPT-5.4. + Prompt: can you add types to rdfMutationHelpers.ts and consolidate mutation logic + where appropriate. */ + +const STANDARD_MUTATION_PREFIXES: Record = { + rdf: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', + vcard: 'http://www.w3.org/2006/vcard/ns#', + foaf: 'http://xmlns.com/foaf/0.1/', + solid: 'http://www.w3.org/ns/solid/terms#', + schema: 'http://schema.org/', + org: 'http://www.w3.org/ns/org#', + owl: 'http://www.w3.org/2002/07/owl#', + dc: 'http://purl.org/dc/elements/1.1/' +} + +const STANDARD_MUTATION_NAMESPACE_URIS = Object.values(STANDARD_MUTATION_PREFIXES) + +export type MutationDocumentTextCache = Map + +type ForceDocumentPutCheckOptions = { + documentText?: string + documentTextCache?: MutationDocumentTextCache +} + +function normalizeNodeId (value: string): string { + return value.startsWith('_:') ? value.slice(2) : value +} + +function isCompleteStatement (statement: RdfStatement | null | undefined): statement is RdfStatement { + return Boolean(statement?.subject && statement?.predicate && statement?.object) +} + +function statementTermKey (term: { toNT?: () => string; value?: string } | null | undefined): string { + if (!term) return '' + if (typeof term.toNT === 'function') return term.toNT() + return term.value || '' +} + +export function registerStorePrefix (target: PrefixCapable | undefined, prefix: string, uri: string): void { + if (!target) return + if (typeof target.setPrefixForURI === 'function') { + target.setPrefixForURI(prefix, uri) + return + } + if (!target.namespaces) { + target.namespaces = {} + } + target.namespaces[prefix] = uri +} + +export function ensureStandardMutationPrefixes (store: LiveStore | undefined): void { + if (!store) return + + const updater = getStoreUpdater(store) + const targets: Array = [ + store as PrefixCapable, + updater, + updater?.store as PrefixCapable | undefined + ] + + Object.entries(STANDARD_MUTATION_PREFIXES).forEach(([prefix, uri]) => { + targets.forEach((target) => { + registerStorePrefix(target, prefix, uri) + }) + }) +} + +export function statementKey (statement: RdfStatement): string { + return `${statementTermKey(statement.subject)} ${statementTermKey(statement.predicate)} ${statementTermKey(statement.object)} ${statementTermKey(statement.why)}` +} + +export function uniqueStatements (statements: RdfStatement[]): RdfStatement[] { + return Array.from(new Map((statements || []).map((statement) => [statementKey(statement), statement])).values()) +} + +export function applyStatementsToStore (store: LiveStore, deletions: RdfStatement[], insertions: RdfStatement[]): void { + store.remove(deletions) + insertions.forEach((statement) => { + store.add(statement.subject, statement.predicate, statement.object, statement.why) + }) +} + +export function sanitizePatchStatements ( + store: LiveStore, + deletions: RdfStatement[], + insertions: RdfStatement[], + requireStoredDelete = false +): { + safeDeletions: RdfStatement[] + safeInsertions: RdfStatement[] + } { + const safeDeletions = uniqueStatements( + (deletions || []).filter((statement) => { + if (!isCompleteStatement(statement)) return false + if (store.holds(statement.subject, statement.predicate, statement.object, statement.why)) return true + return requireStoredDelete + ? false + : store.statementsMatching(statement.subject, statement.predicate, statement.object, statement.why).length > 0 + }) + ) + + const safeInsertions = uniqueStatements((insertions || []).filter(isCompleteStatement)) + + return { safeDeletions, safeInsertions } +} + +function getStoreUpdater (store: LiveStore): RdfUpdater | undefined { + return store.updater as RdfUpdater | undefined +} + +function getStoreFetcher (store: LiveStore): RdfFetcher | undefined { + return store.fetcher as RdfFetcher | undefined +} + +async function bestEffortLoadDocIfStoreEmpty (store: LiveStore, doc: NamedNode | null): Promise { + if (!doc) return + + const fetcher = getStoreFetcher(store) + if (typeof fetcher?.load !== 'function') return + if (store.statementsMatching(undefined, undefined, undefined, doc).length > 0) return + + try { + await fetcher.load(doc) + } catch { + // Continue with current in-memory statements if the pre-load fails. + } +} + +function escapeRegex (text: string): string { + return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&') +} + +function statementNamespaceUris (statement: RdfStatement, candidateNamespaceUris: string[]): string[] { + const uris = new Set() + const terms = [statement.subject, statement.predicate, statement.object] + + terms.forEach((term: any) => { + if (!term) return + + if (typeof term.value === 'string') { + candidateNamespaceUris.forEach((namespaceUri) => { + if (term.value.startsWith(namespaceUri)) { + uris.add(namespaceUri) + } + }) + } + + if (term.termType === 'Literal' && typeof term.datatype?.value === 'string') { + candidateNamespaceUris.forEach((namespaceUri) => { + if (term.datatype.value.startsWith(namespaceUri)) { + uris.add(namespaceUri) + } + }) + } + }) + + return [...uris] +} + +function documentDeclaresNamespacePrefix (documentText: string, namespaceUri: string): boolean { + const escapedNamespaceUri = escapeRegex(namespaceUri) + const prefixPattern = new RegExp(`(^|\\n)\\s*(?:@prefix|PREFIX)\\s+[A-Za-z][\\w-]*:\\s*<${escapedNamespaceUri}>`, 'i') + return prefixPattern.test(documentText) +} + +export async function shouldForceDocumentPutForStatements ( + store: LiveStore, + doc: NamedNode, + statements: RdfStatement[], + candidateNamespaceUris = STANDARD_MUTATION_NAMESPACE_URIS, + options: ForceDocumentPutCheckOptions = {} +): Promise { + const updater = getStoreUpdater(store) + const fetcher = getStoreFetcher(store) + + if (typeof updater?.serialize !== 'function' || typeof fetcher?.webOperation !== 'function') { + return false + } + + const neededNamespaceUris = Array.from(new Set( + (statements || []).flatMap((statement) => statementNamespaceUris(statement, candidateNamespaceUris)) + )) + + if (neededNamespaceUris.length === 0) { + return false + } + + const cachedDocumentText = options.documentTextCache?.get(doc.value) + const existingDocumentText = typeof options.documentText === 'string' + ? options.documentText + : cachedDocumentText + + if (typeof existingDocumentText === 'string') { + return neededNamespaceUris.some((namespaceUri) => { + return !documentDeclaresNamespacePrefix(existingDocumentText, namespaceUri) + }) + } + + try { + const response = await fetcher.webOperation('GET', doc.value, { + noMeta: true, + headers: { accept: 'text/turtle' } + }) + + if (!response?.ok || typeof response.responseText !== 'string') { + return false + } + + options.documentTextCache?.set(doc.value, response.responseText) + + return neededNamespaceUris.some((namespaceUri) => { + return !documentDeclaresNamespacePrefix(response.responseText || '', namespaceUri) + }) + } catch { + return false + } +} + +export function isPatchFailureMessage (message: string): boolean { + const text = (message || '').toLowerCase() + return ( + text.includes('fetch error for patch') || + text.includes('failed to fetch') || + text.includes(' on patch ') || + text.includes('web error: 400') || + text.includes('web error: 405') || + text.includes('web error: 500') || + text.includes('web error: 501') + ) +} + +export function isMissingGetRecordErrorMessage (message: string): boolean { + return (message || '').toLowerCase().includes('no record of our http get request for document') +} + +function runUpdaterUpdate ( + updater: RdfUpdater, + deletions: RdfStatement[], + insertions: RdfStatement[], + failureMessage: string +) { + if (typeof updater.update !== 'function') { + throw new Error(updaterUnsupportedStoreErrorMessageText) + } + const update = updater.update.bind(updater) + + return new Promise((resolve, reject) => { + try { + update(deletions, insertions, (_uri: string, ok: boolean, message?: string) => { + if (ok === true) { + resolve() + return + } + reject(new Error(message || failureMessage)) + }) + } catch (error) { + reject(error instanceof Error ? error : new Error(String(error))) + } + }) +} + +export async function runDirectUpdaterUpdate ( + store: LiveStore, + deletions: RdfStatement[], + insertions: RdfStatement[], + failureMessage = fallbackSaveUpdatesErrorMessageText +) { + ensureStandardMutationPrefixes(store) + + const updater = getStoreUpdater(store) + if (!updater) { + throw new Error(updaterUnsupportedStoreErrorMessageText) + } + + await runUpdaterUpdate(updater, deletions, insertions, failureMessage) +} + +export async function putResourceWithStatements ( + store: LiveStore, + doc: NamedNode, + deletions: RdfStatement[], + insertions: RdfStatement[], + unsupportedMessage: string, + documentTextCache?: MutationDocumentTextCache +) { + ensureStandardMutationPrefixes(store) + + const updater = getStoreUpdater(store) + const fetcher = getStoreFetcher(store) + + if (!updater || typeof updater.serialize !== 'function' || !fetcher || typeof fetcher.webOperation !== 'function') { + throw new Error(unsupportedMessage) + } + + await bestEffortLoadDocIfStoreEmpty(store, doc) + + const currentStatements = store.statementsMatching(undefined, undefined, undefined, doc).slice() + + const deletionKeys = new Set((deletions || []).map((statement) => statementKey(statement))) + const nextStatements = currentStatements.filter((statement) => !deletionKeys.has(statementKey(statement))).concat(insertions || []) + const serializationStore = graph() as LiveStore + nextStatements.forEach((statement) => { + serializationStore.add(statement.subject, statement.predicate, statement.object, statement.why) + }) + + const contentType = 'text/turtle' + const body = updater.serialize(doc.value, serializationStore.statementsMatching(undefined, undefined, undefined, doc), contentType) + const response = await fetcher.webOperation('PUT', doc.value, { + noMeta: true, + contentType, + body + }) + + if (!response || response.ok !== true) { + const status = response?.status || 'unknown' + throw new Error(`Web error: ${status} on PUT of <${doc.value}>`) + } + + documentTextCache?.set(doc.value, body) + + applyStatementsToStore(store, deletions, insertions) +} + +type UpdateTransportOptions = { + unsupportedMessage: string + failureMessage?: string + requireStoredDelete?: boolean + forcePut?: boolean + documentTextCache?: MutationDocumentTextCache + useDavFallback?: boolean + usePutFallback?: boolean + patchFailureMatcher?: (message: string) => boolean + missingGetRecordMatcher?: (message: string) => boolean +} + +export async function runUpdateTransport ( + store: LiveStore, + doc: NamedNode | null, + deletions: RdfStatement[], + insertions: RdfStatement[], + options: UpdateTransportOptions +) { + ensureStandardMutationPrefixes(store) + + const updater = getStoreUpdater(store) + if (!updater) { + throw new Error(options.unsupportedMessage) + } + + if (options.forcePut) { + await bestEffortLoadDocIfStoreEmpty(store, doc) + } + + const { + safeDeletions, + safeInsertions + } = sanitizePatchStatements(store, deletions, insertions, options.requireStoredDelete === true) + + if (safeDeletions.length === 0 && safeInsertions.length === 0) { + return + } + + if (options.forcePut) { + if (!doc) { + throw new Error(options.unsupportedMessage) + } + await putResourceWithStatements(store, doc, safeDeletions, safeInsertions, options.unsupportedMessage, options.documentTextCache) + return + } + + const failureMessage = options.failureMessage || fallbackSaveUpdatesErrorMessageText + + const isPatchFailure = options.patchFailureMatcher || isPatchFailureMessage + const isMissingGetRecord = options.missingGetRecordMatcher || isMissingGetRecordErrorMessage + + try { + await runUpdaterUpdate(updater, safeDeletions, safeInsertions, failureMessage) + } catch (error) { + const message = error instanceof Error ? error.message : String(error) + if (!isPatchFailure(message)) { + throw error + } + + const davDoc = doc + if (options.useDavFallback && typeof updater.updateDav === 'function' && davDoc) { + if (getStoreFetcher(store)?.load) { + try { + await getStoreFetcher(store)?.load?.(davDoc) + } catch { + // Continue to DAV fallback and then PUT fallback if needed. + } + } + + try { + await new Promise((resolve, reject) => { + updater.updateDav?.(davDoc, safeDeletions, safeInsertions, (_uri: string, ok: boolean, body?: string) => { + if (ok === true) { + resolve() + return + } + reject(new Error(body || message || failureMessage)) + }) + }) + return + } catch (davError) { + const davMessage = davError instanceof Error ? davError.message : String(davError) + if (!options.usePutFallback || !isMissingGetRecord(davMessage)) { + throw davError + } + } + } + + if (options.usePutFallback) { + if (!doc) { + throw new Error(options.unsupportedMessage) + } + await putResourceWithStatements(store, doc, safeDeletions, safeInsertions, options.unsupportedMessage, options.documentTextCache) + return + } + + throw error + } +} + +export function applyUpdaterPatch (store: LiveStore, deletions: RdfStatement[], insertions: RdfStatement[]) { + if (!store.updater) { + throw new Error(updaterUnsupportedStoreErrorMessageText) + } + + return runUpdateTransport(store, null, deletions, insertions, { + unsupportedMessage: updaterUnsupportedStoreErrorMessageText, + failureMessage: fallbackSaveUpdatesErrorMessageText, + requireStoredDelete: true, + useDavFallback: false, + usePutFallback: false + }) +} + +export function collectNodeStatements (store: LiveStore, node: Node, doc: NamedNode): RdfStatement[] { + return store.statementsMatching(node as any, null, null, doc) +} + +export function collectLinkStatements ( + store: LiveStore, + subject: NamedNode, + predicate: NamedNode, + node: Node, + doc: NamedNode +): RdfStatement[] { + return store.statementsMatching(subject, predicate, node, doc) +} + +/* The following helper was generated by AI Model: GPT-5.3-Codex. + Prompt: 'do you see anything I can do differently in the mutation code so that it's not so verbose and possible reusable accross sections' */ +export function replacePredicateStatements ( + store: LiveStore, + subject: NamedNode, + predicate: NamedNode, + doc: NamedNode, + deletions: RdfStatement[], + insertions: RdfStatement[], + nextObject?: Node | null +) { + deletions.push(...store.statementsMatching(subject, predicate, null, doc)) + if (nextObject) { + insertions.push(st(subject, predicate, nextObject, doc)) + } +} + +/* The following helper was generated by AI Model: GPT-5.3-Codex. + Prompt: 'do you see anything I can do differently in the mutation code so that it's not so verbose and possible reusable accross sections' */ +export function collectLinkedNodeStatements ( + store: LiveStore, + sourceNode: Node, + predicate: NamedNode, + doc: NamedNode +): { + linkedNodes: Node[] + linkedStatements: RdfStatement[] + linkStatements: RdfStatement[] + } { + const linkedNodes = store.each(sourceNode as any, predicate, null, doc) as Node[] + const linkedStatements = linkedNodes.flatMap((linkedNode) => collectNodeStatements(store, linkedNode, doc)) + const linkStatements = store.statementsMatching(sourceNode as any, predicate, null, doc) + + return { + linkedNodes, + linkedStatements, + linkStatements + } +} + +export function findExistingNode (nodes: Node[], entryNode: string) { + const normalizedEntryNode = normalizeNodeId(entryNode) + return nodes.find((node) => { + const nodeValue = normalizeNodeId(node.value) + if (nodeValue === normalizedEntryNode) return true + return node.value === entryNode + }) +} diff --git a/src/components/profile-heading/editor/sections/shared/rowState.ts b/src/components/profile-heading/editor/sections/shared/rowState.ts new file mode 100644 index 00000000..003c7b38 --- /dev/null +++ b/src/components/profile-heading/editor/sections/shared/rowState.ts @@ -0,0 +1,72 @@ +import { RowStatus } from './types' + +export type EditableRow = { + entryNode: string + status: RowStatus +} + +export type TypedEditableRow = EditableRow & { + type: string +} + +type StringKeyOf = { + [K in keyof T]-?: T[K] extends string ? K : never +}[keyof T] + +export function deleteRow (rows: T[], index: number) { + const row = rows[index] + if (!row) return + + if (row.entryNode) { + row.status = 'deleted' + return + } + + rows.splice(index, 1) +} + +export function applyRowSelectChange> ( + row: T, + field: K, + nextValue: Extract +) { + row[field] = nextValue.trim() as T[K] + + if (row.entryNode) { + row.status = row.status === 'existing' || row.status === 'deleted' ? 'modified' : row.status + return + } + + row.status = 'new' +} + +export function summarizeRowOps (rows: T[], rowHasContent: (row: T) => boolean) { + const create = rows.filter((row) => row.status === 'new' && rowHasContent(row)) + const update = rows.filter((row) => row.status === 'modified' && rowHasContent(row)) + const remove = rows.filter((row) => row.status === 'deleted') + return { create, update, remove } +} + +/* The following function was generated by AI Model: GPT-5.3-Codex */ +/* it was originally only for addresses but I made it more generic so it can be used for any type of rows */ +/* Prompt: can you have applyAddressFieldChange update the row status based on whether any fields have content */ +export function applyRowFieldChange ( + row: T, + field: K, + nextValue: T[K], + hasContent: (row: T) => boolean +) { + row[field] = nextValue + + if (!hasContent(row)) { + row.status = row.entryNode ? 'deleted' : 'new' + return + } + + if (row.entryNode) { + row.status = row.status === 'existing' || row.status === 'deleted' ? 'modified' : row.status + return + } + + row.status = 'new' +} diff --git a/src/components/profile-heading/editor/sections/shared/sanitizeUtils.ts b/src/components/profile-heading/editor/sections/shared/sanitizeUtils.ts new file mode 100644 index 00000000..d7b2930d --- /dev/null +++ b/src/components/profile-heading/editor/sections/shared/sanitizeUtils.ts @@ -0,0 +1,17 @@ +import { sanitizeTextValue } from '../../textUtils' + +export function sanitizeEmailValue (value: string): string { + return sanitizeTextValue(value).replace(/\s+/g, '') +} + +export function sanitizePhoneLocalValue (value: string): string { + return sanitizeTextValue(value).replace(/[^0-9()\-\s.]/g, '') +} + +export function sanitizeAddressFieldValue (value: string): string { + return sanitizeTextValue(value) +} + +export function sanitizeBasicInputFieldValue (value: string): string { + return sanitizeTextValue(value) +} diff --git a/src/components/profile-heading/editor/sections/shared/types.ts b/src/components/profile-heading/editor/sections/shared/types.ts new file mode 100644 index 00000000..b7310e4b --- /dev/null +++ b/src/components/profile-heading/editor/sections/shared/types.ts @@ -0,0 +1,40 @@ +import { LiveStore, NamedNode, st } from 'rdflib' + +export type RowStatus = 'existing' | 'new' | 'modified' | 'deleted' + +export type MutationOps = { + create: T[] + update: T[] + remove: T[] +} + +export type RdfStatement = ReturnType + +export type PrefixCapable = { + namespaces?: Record + setPrefixForURI?: (prefix: string, uri: string) => void +} + +export type UpdateCallback = (_uri: string, ok: boolean, message?: string) => void + +export type DavUpdateCallback = (_uri: string, ok: boolean, body?: string) => void + +export type RdfUpdater = PrefixCapable & { + update?: (deletions: RdfStatement[], insertions: RdfStatement[], callback: UpdateCallback) => void + updateDav?: (doc: NamedNode, deletions: RdfStatement[], insertions: RdfStatement[], callback: DavUpdateCallback) => void + serialize?: (docUri: string, statements: RdfStatement[], contentType: string) => string + store?: PrefixCapable +} + +export type WebOperationResponse = { + ok?: boolean + status?: number + responseText?: string +} + +export type RdfFetcher = { + load?: (doc: NamedNode) => Promise + webOperation?: (...args: unknown[]) => Promise +} + +export type MutationCapableStore = LiveStore diff --git a/src/components/profile-heading/editor/styles/EditDialogs.css b/src/components/profile-heading/editor/styles/EditDialogs.css new file mode 100644 index 00000000..a1ea0ad2 --- /dev/null +++ b/src/components/profile-heading/editor/styles/EditDialogs.css @@ -0,0 +1,743 @@ +@import './EditDialogs.responsive.css'; + +.profile__edit-form { + --profile-edit-dialog-row-max-width: 544px; + --profile-edit-dialog-muted-text: var(--solid-ui-color-gray-600, #4A5565); + --profile-edit-dialog-quiet-text: var(--solid-ui-color-gray-700, #364153); + --profile-edit-dialog-mobile-image-button-font-size: 0.75rem; + --profile-edit-dialog-mobile-image-label-font-size: var(--solid-ui-font-size-sm, 0.875rem); + --profile-edit-dialog-mobile-image-description-font-size: 0.625rem; + --profile-edit-dialog-mobile-image-button-padding: 6.6px 12px 7px 14px; + width: 100%; +} + +.profile-edit-dialog__section, +.profile-edit-dialog__section--education { + display: flex; + flex-direction: column; + gap: 12px; +} + +.profile-edit { + display: flex; + flex-direction: column; + gap: 25px; +} + +.profile-edit-dialog__section h4 { + margin: 0; +} + +.profile-edit-dialog__section fieldset { + width: 100%; + margin: 0; + display: grid; + gap: 15px; + border: 0; + padding: 0; + min-inline-size: 0; +} + +.profile-edit-dialog__field-description { + color: var(--profile-edit-dialog-muted-text); + font-size: var(--solid-ui-font-size-sm, 0.875rem); + font-weight: 400; + line-height: 1.5; +} + +.profile-edit-dialog__row { + display: flex; + align-items: flex-start; + gap: 15px; + max-width: var(--profile-edit-dialog-row-max-width); +} + +.profile-edit-dialog__row--heading-photo { + gap: 10px; +} + +.profile-edit-dialog__row--full { + max-width: 100%; + width: 100%; +} + +.profile-edit-dialog__field, +.profile-edit-dialog__field-type { + display: block; + margin: 0; +} + +.profile-edit-dialog__field-type { + width: 100%; +} + +.profile-edit-dialog__field { + min-width: 0; +} + +.profile-edit-dialog__field--stack { + display: grid; +} + +.profile-edit-dialog__field--stack > small { + display: block; + width: 100%; + text-align: right; + justify-self: end; +} + +.profile-edit-dialog__field--full { + max-width: 100% !important; + width: 100%; +} + +.profile-edit-dialog__field--row-width { + max-width: 544px; + width: 100%; +} + +.profile-edit-dialog__login-message { + margin: 0; + font-size: var(--solid-ui-font-size-xs, 0.75rem); + color: var(--solid-ui-color-error, #b00020); +} + +.profile-edit-dialog__section + .profile-edit-dialog__login-message { + margin-top: 15px; +} + +.profile__edit-form--projects .profile-edit-dialog__login-message { + margin-top: 15px; +} + +.profile-edit-dialog__actions { + display: flex; + align-items: center; + justify-content: flex-end; + flex: 0 0 auto; +} + +.profile-edit-dialog__actions--edge { + margin-left: auto; +} + +.profile-edit-dialog__input-wrap { + position: relative; + width: 100%; +} + +.profile-edit-dialog__input--with-action { + width: 100%; + box-sizing: border-box; + padding-right: 120px; +} + +.profile-edit-dialog__image-preview { + display: grid; +} + +.profile-edit-dialog__image-preview-header { + margin-bottom: 0; +} + +.profile-edit-dialog__image-preview-actions { + display: flex; + align-items: center; + gap: 12px; +} + +.profile-edit-dialog__image-preview-label { + color: var(--gray-900, #101828); + font-size: var(--solid-ui-font-size-sm, .875rem); + font-weight: 600; +} + +.profile-edit-dialog__image-preview-description { + color: var(--solid-ui-color-gray-600, #4a5565); + font-size: var(--solid-ui-font-size-sm, .875rem); + font-weight: 400; +} + +.profile-edit-dialog__image-preview-label, +.profile-edit-dialog__image-preview-description { + margin: 0; +} + +.profile-edit-dialog--heading { + --profile-edit-dialog-avatar-size: 5.625rem; +} + +.profile-edit-dialog__image-frame { + position: relative; + display: inline-block; + width: var(--profile-edit-dialog-avatar-size, 5.625rem); + height: var(--profile-edit-dialog-avatar-size, 5.625rem); + line-height: 0; + font-size: 0; + vertical-align: top; + overflow: visible; +} + +.profile-edit-dialog__image-frame > solid-ui-photo-capture { + position: absolute; + inset: 0; + display: block; + pointer-events: none; +} + +.profile-edit-dialog__image-frame > solid-ui-photo-capture > * { + pointer-events: auto; +} + +.profile__image-frame { + position: relative; + display: block; + width: var(--profile-edit-dialog-avatar-size, 5.625rem); + height: var(--profile-edit-dialog-avatar-size, 5.625rem); + overflow: hidden; + border-radius: 10px; + border: 1px solid var(--solid-ui-color-primary, #7c4dff); + background: var(--solid-ui-color-slate-50, #F8FAFC); + box-sizing: border-box; + padding: 0; + margin: 0; +} + +.profile__image-frame--fallback { + border: 1px dashed var(--solid-ui-color-slate-200, #E2E8F0); + background: var(--solid-ui-color-slate-50, #F8FAFC); +} + +.profile__hero, +.profile__hero-alt { + display: block; + width: 100%; + height: 100%; + box-sizing: border-box; + border-radius: 10px; +} + +.profile__hero { + object-fit: cover; + object-position: center; + background: var(--color-surface-placeholder, var(--gray-300, #d1d5dc)) 50% / cover no-repeat; +} + +.profile__hero-alt { + display: none; + align-items: center; + justify-content: center; + background: var(--solid-ui-color-slate-50, #F8FAFC); +} + +.profile__image-frame--fallback .profile__hero-alt { + display: flex; +} + +.profile__hero-icon { + display: flex; + align-items: center; + justify-content: center; + width: 100%; + height: 100%; + padding: 1.125rem; + box-sizing: border-box; +} + +.profile__hero-icon icon-lucide-circle-user-round, +.profile__hero-alt icon-lucide-circle-user-round { + display: block; + width: 1.75rem; + height: 1.75rem; + color: #D9E1F2; +} + +.profile-edit-dialog__image-camera-button { + position: absolute; + right: 5px; + bottom: 5px; + z-index: 1; + display: inline-flex; + align-items: center; + justify-content: center; + width: 1.75rem; + height: 1.75rem; + min-width: 1.75rem; + min-height: 1.75rem; + padding: 0; + border: 1px solid var(--solid-ui-color-slate-200, #E2E8F0); + border-radius: 7px; + background: var(--solid-ui-color-white, #FFFFFF); + box-shadow: 0 2px 6px rgba(15, 23, 42, 0.12); + color: var(--solid-ui-color-gray-700, #364153); + cursor: pointer; + box-sizing: border-box; + transition: none; + line-height: 0; +} + +.profile-edit-dialog__image-camera-button:hover, +.profile-edit-dialog__image-camera-button:focus-visible, +.profile-edit-dialog__image-camera-button:active { + width: 1.75rem; + height: 1.75rem; + min-width: 1.75rem; + min-height: 1.75rem; + padding: 0; + border-color: var(--solid-ui-color-slate-200, #E2E8F0); + background: color-mix(in srgb, var(--solid-ui-color-primary, #7c4dff) 12%, #FFFFFF); + box-shadow: 0 2px 6px rgba(15, 23, 42, 0.12); + transform: none; + color: var(--solid-ui-color-primary, #7c4dff); +} + +.profile-edit-dialog__image-camera-button icon-lucide-camera { + display: block; + width: 0.875rem; + height: 0.875rem; + flex-shrink: 0; + vertical-align: middle; + margin: 0.05rem; +} + +.profile-edit-dialog__image-camera-capture-row { + display: flex; + justify-content: center; + width: 100%; +} + +.profile-edit-dialog__image-camera-capture-frame { + position: relative; + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + width: fit-content; + max-width: 100%; + margin-left: auto; + margin-right: auto; + margin-top: calc(12px / 2); + margin-bottom: 12px; + padding: 10px; + box-sizing: border-box; + border: 1px solid var(--solid-color-gray-200, #E5E7EB); + border-radius: 8px; +} + +.profile-edit-dialog__image-camera-capture-frame[hidden] { + display: none; +} + +.profile-edit-dialog__paste-button { + position: absolute; + white-space: nowrap; + right: 10px; + top: 50%; + transform: translateY(-50%); + z-index: 1; +} + +.profile-edit-dialog__paste-icon { + width: 0.875rem; + height: 0.875rem; + stroke: var(--solid-ui-color-primary, #7c4dff); + fill: var(--solid-ui-color-primary, #7c4dff); +} + +.profile-edit-dialog__paste-icon svg { + display: block; + transform: translate(1px, 1px); +} + +solid-ui-button.profile-edit-dialog__drag-handle { + cursor: grab; + touch-action: none; + -webkit-user-select: none; + user-select: none; +} + +solid-ui-button.profile-edit-dialog__drag-handle:active { + cursor: grabbing; +} + +.profile-edit-dialog__row--drop-target { + outline: 1px dashed var(--solid-ui-color-gray-400, #99A1AF); + outline-offset: 2px; +} + +.profile-edit-dialog__field input, +.profile-edit-dialog__field select, +.profile-edit-dialog__field-type input, +.profile-edit-dialog__field-type select { + margin-block-start: 0; + width: 100%; + max-width: 100%; + box-sizing: border-box; + min-height: var(--solid-ui-clickable-area, 42px); + height: var(--solid-ui-clickable-area, 42px); + border-radius: 5px; + border: 1px solid var(--solid-ui-color-gray-400, #99A1AF); + background: var(--solid-ui-color-white, #FFF); + color: var(--color-text-subheading, var(--gray-900, #101828)); + font-size: var(--solid-ui-font-size-sm, 0.875rem); + font-weight: 500; + padding: 10px; +} + +.profile-edit-dialog__field input[type='date'], +.profile-edit-dialog__field-type input[type='date'] { + min-width: 0; +} + +.profile-edit-dialog__field textarea, +.profile-edit-dialog__field-type textarea { + width: 100%; + max-width: 100%; + box-sizing: border-box; + min-height: var(--solid-ui-clickable-area, 42px); +} + +.profile-edit-dialog__textarea { + color: var(--color-text-subheading, var(--gray-900, #101828)); + font-size: var(--solid-ui-font-size-sm, 0.875rem); + font-weight: 500; + line-height: 1.6; + border-radius: 5px; + border: 1px solid var(--solid-ui-color-gray-400, #99A1AF); + background: var(--solid-ui-color-white, #FFFFFF); + min-height: 160px !important; + height: auto; + resize: vertical; +} + +.profile__edit-form--heading { + display: flex; + flex-direction: column; + gap: 12px; +} + +/* Section-specific edit dialog overrides */ + +.profile-edit-dialog__bio-field-container { + display: flex; + width: 100%; + max-width: var(--profile-edit-dialog-row-max-width); + padding: 0; + flex-direction: column; + align-items: flex-start; + gap: 12px; + box-sizing: border-box; + margin: 0; +} + +.profile-edit-dialog__row--language { + margin-left: 0; +} + +.profile-edit-dialog__row--language > .profile-edit-dialog__field--language-name { + flex: 1 1 0; + min-width: 0; +} + +.profile-edit-dialog__field-type--language-proficiency, +.profile-edit-dialog__field-type--language-proficiency[hidden] { + display: none !important; +} + +.profile-edit-dialog__actions--language { + margin-left: 0; +} + +.profile-edit-dialog__row--social { + margin-left: calc(-1 * 10px); + max-width: 100%; + width: 100%; +} + +.profile-edit-dialog__field--social-type { + flex: 0 0 96px; + width: 96px; + max-width: 96px; +} + +.profile-edit-dialog__field--social-url { + flex: 1 1 auto; + min-width: 0; +} + +.profile-edit-dialog__row--project { + max-width: 100%; + width: 100%; +} + +.profile-edit-dialog__row--resume-entry-header { + align-items: center; + border-bottom: 1px solid var(--solid-ui-color-gray-400, #99A1AF); +} + +.profile-edit-dialog__row--resume-entry-header > .profile-edit-dialog__entry-heading { + margin: 0; +} + +.profile-edit-dialog__entry-heading { + margin: 0; + color: var(--solid-ui-color-gray-700, #364153); + font-size: var(--solid-ui-font-size-sm, 0.875rem); + font-weight: 500; +} + +.profile-edit-dialog__section--education .profile-edit-dialog__section-heading { + margin: 0; + color: var(--solid-ui-color-gray-700, #364153); + font-size: var(--solid-ui-font-size-md, 1rem); + font-weight: 500; +} + +/* Force two direct children to split the row into equal columns. */ +.profile-edit-dialog__row--equal > .profile-edit-dialog__field, +.profile-edit-dialog__row--equal > .profile-edit-dialog__field-type { + flex: 1 1 0; + min-width: 0; +} + +.profile-edit-dialog--heading .profile-edit-dialog__image-camera-capture-row { + margin-bottom: calc(25px / -2); +} + +/* An empty capture row would still add a flex gap below the divider. */ +.profile-edit-dialog--heading .profile-edit-dialog__image-camera-capture-row:has(> [hidden]) { + display: none; +} + +.profile-edit-dialog--heading .profile-edit-dialog__image-camera-capture-frame { + margin-top: calc(12px / 4); + margin-bottom: calc(12px / 2); +} + +.profile__edit-form--resume .profile-edit-dialog__field, +.profile__edit-form--resume .profile-edit-dialog__field-type:not(.hidden), +.profile__edit-form--contact-info .profile-edit-dialog__field, +.profile__edit-form--contact-info .profile-edit-dialog__field-type:not(.hidden) { + display: flex; + flex-direction: column; + align-items: flex-start; + gap: 5px; + flex: 1 0 0; +} + +.profile__edit-form--resume .profile-edit-dialog__row { + max-width: 100%; + width: 100%; +} + +.profile__edit-form--resume .profile-edit-dialog__section fieldset > .profile-edit-dialog__field { + max-width: 100%; +} + +.profile__edit-form--resume .profile-edit-dialog__field > input, +.profile__edit-form--resume .profile-edit-dialog__field > solid-ui-select, +.profile__edit-form--resume .profile-edit-dialog__field > solid-ui-combobox, +.profile__edit-form--resume .profile-edit-dialog__field > textarea, +.profile__edit-form--resume .profile-edit-dialog__field-type > input, +.profile__edit-form--resume .profile-edit-dialog__field-type > solid-ui-select, +.profile__edit-form--resume .profile-edit-dialog__field-type > textarea, +.profile__edit-form--contact-info .profile-edit-dialog__field > input, +.profile__edit-form--contact-info .profile-edit-dialog__field > solid-ui-select, +.profile__edit-form--contact-info .profile-edit-dialog__field > textarea, +.profile__edit-form--contact-info .profile-edit-dialog__field-type > input, +.profile__edit-form--contact-info .profile-edit-dialog__field-type > solid-ui-select, +.profile__edit-form--contact-info .profile-edit-dialog__field-type > textarea { + align-self: stretch; +} + +.profile-edit-dialog__field > solid-ui-combobox, +.profile-edit-dialog__field-type > solid-ui-combobox { + display: block; + width: 100%; + min-width: 0; + max-width: 100%; + box-sizing: border-box; + align-self: stretch; +} + +/* The combobox input is transparent and inherits its font from the host, so the host provides the field background and matches the 42px plain input height. */ +.profile__edit-form solid-ui-combobox { + background: var(--solid-ui-color-white, #FFFFFF); + border-radius: 5px; + color: var(--color-text-subheading, var(--gray-900, #101828)); + font-size: var(--solid-ui-font-size-sm, 0.875rem); + font-weight: 500; + line-height: calc(var(--solid-ui-clickable-area, 42px) - 22px); +} + +.profile-edit-dialog__field--resume-location { + flex: 1 0 0; + width: auto; + max-width: none; +} + +.profile-edit-dialog__row--resume-dates { + max-width: 100%; + width: 100%; +} + +.profile-edit-dialog__field--date-group { + flex: 1 1 0; + min-width: 0; +} + +.profile-edit-dialog__date-pair { + display: flex; + align-items: center; + gap: 15px; + width: 100%; +} + +.profile-edit-dialog__date-pair > solid-ui-select { + flex: 1 1 0; + min-width: 0; +} + +.profile-edit-dialog__resume-date-select { + display: block; + width: 100%; + min-width: 0; + max-width: 100%; + box-sizing: border-box; +} + +.profile-edit-dialog__resume-date-select--disabled { + pointer-events: none; + opacity: var(--opacity-input-disabled, 0.75); +} + +.profile-edit-dialog__bio-field-container > small { + align-self: flex-end; + text-align: right; +} + +.profile-edit-dialog--heading .profile-edit-dialog__row, +.profile-edit-dialog--heading .profile-edit-dialog__field--row-width { + max-width: 100%; + width: 100%; +} + +.profile-edit-dialog--heading .profile-edit-dialog__row--heading-photo { + padding-bottom: 20px; + border-bottom: 1px solid var(--solid-ui-color-slate-200, #E2E8F0); +} + +.profile-edit-dialog--heading .profile-edit { + gap: calc(25px / 2); +} + +.profile-edit-dialog--heading .profile-edit-dialog__row--heading-photo .profile__hero-alt { + padding: 0; +} + +.profile-edit-dialog--heading .profile-edit-dialog__row--contact-point { + max-width: 100%; + width: 100%; + gap: 10px; +} + +.profile-edit-dialog--heading .profile-edit-dialog__row--contact-point > .profile-edit-dialog__field { + flex: 1 1 0; + min-width: 0; +} + +.profile-edit-dialog--heading .profile-edit-dialog__field-type--contact-point { + padding-top: calc(var(--solid-ui-font-size-sm, 0.875rem) * 1.5); +} + +.profile-edit-dialog--heading .profile-edit-dialog__row--contact-point > .profile-edit-dialog__field > .label { + display: block; + width: 100%; +} + +.profile-edit-dialog--heading .profile-edit-dialog__row--contact-point.profile-edit-dialog__row--equal > .profile-edit-dialog__field-type.profile-edit-dialog__field-type--contact-point { + flex: 0 0 103px; + width: 103px; + min-width: 103px; + max-width: 103px; +} + +.profile-edit-dialog__row--address-header { + max-width: var(--profile-edit-dialog-row-max-width); + align-items: flex-end; +} + +.profile-edit-dialog__row--inline-end { + justify-content: flex-end; + max-width: 100%; +} + +.profile-edit-dialog__checkbox-label { + margin-left: auto; + display: inline-flex; + align-items: center; + gap: 12px; + cursor: var(--profile-interactive-cursor, pointer); +} + +.profile-edit-dialog__checkbox-input { + width: var(--icon-xxs, 1rem); + height: var(--icon-xxs, 1rem); + margin: 0; + flex: 0 0 auto; + accent-color: var(--solid-ui-color-primary, #7C4DFF); + cursor: var(--profile-interactive-cursor, pointer); +} + +.profile-edit-dialog__checkbox-input:focus-visible { + outline: var(--focus-indicator-width, 2px) solid var(--solid-ui-color-primary, #7C4DFF); + outline-offset: 2px; +} + +.profile-edit-dialog__checkbox-input:disabled { + opacity: var(--opacity-disabled, 0.5); +} + +/* The street-address row is a standalone label, so cap its width like the flex rows. */ +.profile-edit-dialog__section fieldset > .profile-edit-dialog__field { + max-width: var(--profile-edit-dialog-row-max-width); +} + +.profile-edit-dialog__field-type--wide { + flex: 1 1 auto; + min-width: 0; + width: 100%; + max-width: 100%; +} + +.profile-edit-dialog__field-type--contact-point { + flex: 0 0 auto; + width: auto; + max-width: none; + align-self: flex-start; +} + +/* Dedicated hook for the social account type select in SocialEditDialog. */ +.profile-edit-dialog__social-account-select { + display: block; + width: 100%; + min-width: 0; + max-width: 100%; + box-sizing: border-box; + contain: inline-size; +} + +.profile-edit-dialog__resume-organization-type-select { + display: block; + width: 100%; + min-width: 0; + max-width: 100%; + box-sizing: border-box; +} + +.profile-edit-dialog__bio-field-container textarea { + width: 100%; + max-width: 100%; + box-sizing: border-box; + min-height: var(--solid-ui-clickable-area, 42px); +} diff --git a/src/components/profile-heading/editor/styles/EditDialogs.responsive.css b/src/components/profile-heading/editor/styles/EditDialogs.responsive.css new file mode 100644 index 00000000..c0ed6dae --- /dev/null +++ b/src/components/profile-heading/editor/styles/EditDialogs.responsive.css @@ -0,0 +1,277 @@ +html[data-layout='mobile'] .profile-edit-dialog__row { + max-width: 100%; + flex-direction: column; + align-items: stretch; +} + +html[data-layout='mobile'] .profile-edit-dialog__row--equal > .profile-edit-dialog__field, +html[data-layout='mobile'] .profile-edit-dialog__row--equal > .profile-edit-dialog__field-type, +html[data-layout='mobile'] .profile-edit-dialog__field-type { + flex: 1 1 auto; +} + +html[data-layout='mobile'] #profile-modal .modal .profile-edit-dialog--heading .profile-edit-dialog__field--dob { + width: 100%; + max-width: 100%; + min-width: 0; + overflow: hidden; + align-self: stretch; +} + +html[data-layout='mobile'] #profile-modal .modal .profile-edit-dialog--heading .profile-edit-dialog__row--heading-dob { + flex-direction: column; + align-items: stretch; +} + +html[data-layout='mobile'] #profile-modal .modal .profile-edit-dialog--heading .profile-edit-dialog__row--heading-dob > .profile-edit-dialog__field, +html[data-layout='mobile'] #profile-modal .modal .profile-edit-dialog--heading .profile-edit-dialog__row--heading-dob > .profile-edit-dialog__field-type { + width: 100%; + max-width: 100%; + min-width: 0; + flex: 1 1 auto; +} + +html[data-layout='mobile'] #profile-modal .modal .profile-edit-dialog--heading .profile-edit-dialog__input--dob { + display: block; + height: var(--solid-ui-clickable-area, 42px); + min-height: var(--solid-ui-clickable-area, 42px); + max-height: var(--solid-ui-clickable-area, 42px); + box-sizing: border-box; + width: 100%; + max-width: 100%; + min-width: 0; + line-height: var(--line-height-base, 1.5); +} + +html[data-layout='mobile'] #profile-modal .modal .profile-edit-dialog--heading .profile-edit-dialog__input--dob::-webkit-date-and-time-value, +html[data-layout='mobile'] #profile-modal .modal .profile-edit-dialog--heading .profile-edit-dialog__input--dob::-webkit-datetime-edit, +html[data-layout='mobile'] #profile-modal .modal .profile-edit-dialog--heading .profile-edit-dialog__input--dob::-webkit-datetime-edit-fields-wrapper { + width: 100%; + min-width: 0; + max-width: 100%; + overflow: hidden; + text-align: center; +} + +html[data-layout='mobile'] #profile-modal .modal .profile-edit-dialog--heading .profile-edit-dialog__input--dob::-webkit-date-and-time-value { + text-align: center; + white-space: nowrap; +} + +@media (hover: none) and (pointer: coarse) { + /* Native mobile date pickers can overflow the shared field sizing. */ + html[data-layout='mobile'] #profile-modal .modal .profile-edit-dialog--heading .profile-edit-dialog__input--dob { + height: var(--solid-ui-clickable-area, 42px); + min-height: var(--solid-ui-clickable-area, 42px); + max-height: var(--solid-ui-clickable-area, 42px); + line-height: calc(var(--solid-ui-clickable-area, 42px) - 2px); + padding-block: 0; + width: calc(100% - 24px); + max-width: calc(100% - 24px); + } + + html[data-layout='mobile'] #profile-modal .modal .profile-edit-dialog--heading .profile-edit-dialog__input--dob::-webkit-date-and-time-value, + html[data-layout='mobile'] #profile-modal .modal .profile-edit-dialog--heading .profile-edit-dialog__input--dob::-webkit-datetime-edit, + html[data-layout='mobile'] #profile-modal .modal .profile-edit-dialog--heading .profile-edit-dialog__input--dob::-webkit-datetime-edit-fields-wrapper { + line-height: calc(var(--solid-ui-clickable-area, 42px) - 2px); + } + + html[data-layout='mobile'] #profile-modal .modal .profile-edit-dialog--heading .profile-edit-dialog__input--dob::-webkit-calendar-picker-indicator { + margin: 0; + padding: 0; + } +} + +html[data-layout='mobile'] .profile__edit-form { + --profile-edit-dialog-mobile-image-button-font-size: var(--solid-ui-font-size-md, 1rem); + --profile-edit-dialog-mobile-image-label-font-size: var(--solid-ui-font-size-sm, 0.875rem); + --profile-edit-dialog-mobile-image-description-font-size: 0.625rem; +} + +html[data-layout='mobile'] #profile-modal .modal label.profile-edit-dialog__field, +html[data-layout='mobile'] #profile-modal .modal label.profile-edit-dialog__field-type, +html[data-layout='mobile'] #profile-modal .modal .profile-edit-dialog__field > .label, +html[data-layout='mobile'] #profile-modal .modal .profile-edit-dialog__field-type > .label, +html[data-layout='mobile'] #profile-modal .modal .profile-edit-dialog__field-description { + font-size: var(--solid-ui-font-size-sm, 0.875rem); + line-height: 1.5; +} + +html[data-layout='mobile'] .profile-edit-dialog__field input, +html[data-layout='mobile'] .profile-edit-dialog__field-type input { + font-size: var(--solid-ui-font-size-md, 1rem); +} + +html[data-layout='mobile'] .profile-edit-dialog__field-type--contact-point { + flex: 1 1 auto; + width: 100%; + max-width: 100%; +} + +html[data-layout='mobile'] .profile-edit-dialog--heading .profile-edit-dialog__row--contact-point { + flex-direction: row; + align-items: stretch; +} + +html[data-layout='mobile'] .profile-edit-dialog--heading .profile-edit-dialog__row--contact-point.profile-edit-dialog__row--equal > .profile-edit-dialog__field-type.profile-edit-dialog__field-type--contact-point { + flex: 0 0 103px; + width: 103px; + min-width: 103px; + max-width: 103px; +} + +html[data-layout='mobile'] .profile-edit-dialog--heading .profile-edit-dialog__row--heading-photo { + flex-direction: row; + align-items: center; + flex-wrap: nowrap; + gap: 12px; + width: 100%; + max-width: 100%; +} + +html[data-layout='mobile'] .profile-edit-dialog--heading .profile-edit-dialog__row--heading-photo > header { + margin-bottom: 0; + flex: 0 0 auto; +} + +html[data-layout='mobile'] .profile-edit-dialog--heading { + --profile-edit-dialog-avatar-size: 5rem; +} + +html[data-layout='mobile'] .profile-edit-dialog--heading .profile-edit-dialog__row--heading-photo .profile__hero-alt { + padding: 0; +} + +html[data-layout='mobile'] .profile-edit-dialog--heading .profile-edit-dialog__row--heading-photo .profile__image-frame--fallback .profile__hero-alt { + display: flex; + align-items: center; + justify-content: center; +} + +html[data-layout='mobile'] .profile-edit-dialog--heading .profile-edit-dialog__row--heading-photo .profile-edit-dialog__image-preview { + flex: 1 1 auto; + min-width: 0; + gap: 5px; + width: 100%; +} + +html[data-layout='mobile'] .profile-edit-dialog--heading .profile-edit-dialog__row--heading-photo .profile-edit-dialog__image-preview-label { + font-size: var(--profile-edit-dialog-mobile-image-label-font-size); + line-height: 1.25; +} + +html[data-layout='mobile'] .profile-edit-dialog--heading .profile-edit-dialog__row--heading-photo .profile-edit-dialog__image-preview-description { + font-size: var(--profile-edit-dialog-mobile-image-description-font-size); + line-height: 1.4; +} + +html[data-layout='mobile'] .profile-edit-dialog--heading .profile-edit-dialog__row--heading-photo .profile-edit-dialog__image-preview-actions { + display: grid; + grid-template-columns: repeat(2, max-content); + gap: 8px; + width: 100%; + align-items: stretch; + justify-content: start; +} + +@media (max-width: 576px) { + .profile-edit-dialog__row { + max-width: 100%; + flex-direction: column; + align-items: stretch; + } + + .profile__edit-form { + --profile-edit-dialog-mobile-image-button-font-size: var(--solid-ui-font-size-md, 1rem); + --profile-edit-dialog-mobile-image-label-font-size: var(--solid-ui-font-size-sm, 0.875rem); + --profile-edit-dialog-mobile-image-description-font-size: 0.625rem; + } + + .profile-edit-dialog__row--equal > .profile-edit-dialog__field, + .profile-edit-dialog__row--equal > .profile-edit-dialog__field-type, + .profile-edit-dialog__field-type { + flex: 1 1 auto; + } + + .profile-edit-dialog__field input, + .profile-edit-dialog__field-type input { + font-size: var(--solid-ui-font-size-sm, 0.875rem); + } + + .profile-edit-dialog__field-type--contact-point { + flex: 1 1 auto; + width: 100%; + max-width: 100%; + } + + .profile-edit-dialog--heading .profile-edit-dialog__row--contact-point { + flex-direction: row; + align-items: stretch; + } + + .profile-edit-dialog--heading .profile-edit-dialog__row--contact-point.profile-edit-dialog__row--equal > .profile-edit-dialog__field-type.profile-edit-dialog__field-type--contact-point { + flex: 0 0 103px; + width: 103px; + min-width: 103px; + max-width: 103px; + } + + .profile-edit-dialog--heading .profile-edit-dialog__row--heading-photo { + flex-direction: row; + align-items: center; + flex-wrap: nowrap; + gap: 12px; + width: 100%; + max-width: 100%; + } + + .profile-edit-dialog--heading .profile-edit-dialog__row--heading-photo > header { + margin-bottom: 0; + flex: 0 0 auto; + } + + .profile__edit-form.profile-edit-dialog--heading { + --profile-edit-dialog-avatar-size: 5rem; + } + + .profile-edit-dialog--heading .profile-edit-dialog__row--heading-photo .profile__hero-alt { + padding: 0; + } + + .profile-edit-dialog--heading .profile-edit-dialog__row--heading-photo .profile__image-frame--fallback .profile__hero-alt { + display: flex; + align-items: center; + justify-content: center; + } + + .profile-edit-dialog--heading .profile-edit-dialog__row--heading-photo .profile-edit-dialog__image-preview { + flex: 1 1 auto; + min-width: 0; + gap: 5px; + width: 100%; + } + + .profile-edit-dialog--heading .profile-edit-dialog__row--heading-photo .profile-edit-dialog__image-preview-label { + font-size: var(--profile-edit-dialog-mobile-image-label-font-size); + line-height: var(--line-height-tight, 1.25); + } + + .profile-edit-dialog--heading .profile-edit-dialog__row--heading-photo .profile-edit-dialog__image-preview-description { + font-size: var(--profile-edit-dialog-mobile-image-description-font-size); + line-height: var(--line-height-base, 1.4); + } + + .profile-edit-dialog--heading .profile-edit-dialog__row--heading-photo .profile-edit-dialog__image-preview-actions { + display: grid; + grid-template-columns: repeat(2, max-content); + gap: 8px; + width: 100%; + align-items: stretch; + justify-content: start; + } + + .profile-edit-dialog--heading .profile-edit-dialog__row--heading-photo .profile-edit-dialog__image-button { + width: auto; + min-width: 0; + } +} diff --git a/src/components/profile-heading/editor/textUtils.ts b/src/components/profile-heading/editor/textUtils.ts new file mode 100644 index 00000000..7c60d455 --- /dev/null +++ b/src/components/profile-heading/editor/textUtils.ts @@ -0,0 +1,44 @@ +export function strToUpperCase (str: string) { + if (str.trim().length > 0) { + const strCase = str.split(' ') + for (let i = 0; i < strCase.length; i++) { + strCase[i] = strCase[i].charAt(0).toUpperCase() + + strCase[i].substring(1) + } + return strCase.join(' ') + } + return '' +} + +export function toText (value: unknown): string { + if (!value) return '' + if (typeof value === 'string') return value + if (typeof value === 'object' && 'value' in (value as Record)) { + const nested = (value as { value?: unknown }).value + return typeof nested === 'string' ? nested : '' + } + return '' +} + +export function toTypeLabel (value: unknown): string { + const raw = toText(value).trim() + if (!raw) return '' + const withoutAngles = raw.replace(/^<|>$/g, '') + const hashParts = withoutAngles.split('#') + const lastByHash = hashParts[hashParts.length - 1] + const slashParts = lastByHash.split('/') + return slashParts[slashParts.length - 1] +} + +export function sanitizeTextValue (value: string): string { + return value + // Control characters must be removed from user-entered profile values. + // eslint-disable-next-line no-control-regex + .replace(/[\u0000-\u001F\u007F]/g, ' ') + .replace(/\s+/g, ' ') + .trim() +} + +export function hasNonEmptyText (value: string | undefined): boolean { + return Boolean(value && value.trim() !== '') +} diff --git a/src/components/profile-heading/editor/texts.ts b/src/components/profile-heading/editor/texts.ts new file mode 100644 index 00000000..bf5ffd5f --- /dev/null +++ b/src/components/profile-heading/editor/texts.ts @@ -0,0 +1,6 @@ +/* The text refactor was generated by AI Model: GPT-5.4-Copilot. */ +export * from './texts/buttonTexts' +export * from './texts/dialogTexts' +export * from './texts/messageTexts' +export * from './texts/profileTexts' +export * from './texts/qrCodeTexts' diff --git a/src/components/profile-heading/editor/texts/buttonTexts.ts b/src/components/profile-heading/editor/texts/buttonTexts.ts new file mode 100644 index 00000000..40b09675 --- /dev/null +++ b/src/components/profile-heading/editor/texts/buttonTexts.ts @@ -0,0 +1,8 @@ +export const addMeToYourFriendsButtonText = 'Add as friend' +export const logInAddMeToYourFriendsButtonText = 'Log in to add as friend' +export const addMeToYourContactsButtonText = 'Add as Contact' +export const logInAddMeToYourContactsButtonText = 'Login to add me to your contacts' +export const logInToChatWithMeButtonText = 'Login to chat with me' +export const friendExistsAlreadyButtonText = 'Already a friend' +export const contactExistsAlreadyButtonText = 'Already part of contacts' +export const contactExistsAlreadyByNameButtonText = 'Add webID to contact' diff --git a/src/components/profile-heading/editor/texts/dialogTexts.ts b/src/components/profile-heading/editor/texts/dialogTexts.ts new file mode 100644 index 00000000..d09dd97c --- /dev/null +++ b/src/components/profile-heading/editor/texts/dialogTexts.ts @@ -0,0 +1,13 @@ +export const editSkillsDialogTitleText = 'Edit Skills' +export const editLanguagesDialogTitleText = 'Edit Languages' +export const editContactInfoDialogTitleText = 'Edit More Contacts' +export const editResumeDialogTitleText = 'Edit Resume' +export const editEducationDialogTitleText = 'Edit Education' +export const editProjectsDialogTitleText = 'Add Projects & Communities' +export const editHeadingDialogTitleText = 'Edit Heading' +export const editSocialDialogTitleText = 'Edit Social Links' +export const editBioDialogTitleText = 'Edit Bio' +export const dialogSubmitLabelText = 'Save Changes' +export const dialogCancelLabelText = 'Cancel' +export const pasteEntryButtonTitleText = 'Paste' +export const deleteEntryButtonTitleText = 'Delete entry' diff --git a/src/components/profile-heading/editor/texts/messageTexts.ts b/src/components/profile-heading/editor/texts/messageTexts.ts new file mode 100644 index 00000000..f1a171c4 --- /dev/null +++ b/src/components/profile-heading/editor/texts/messageTexts.ts @@ -0,0 +1,43 @@ +export const userNotLoggedInErrorMessage = 'Current user not found! Not logged in?' +export const friendWasAddedSuccesMessage = 'Friend was added!' +export const contactWasAddedSuccesMessage = 'Contact was added!' +export const friendExistsMessage = 'Friend already exists' +export const contactExistsMessage = 'Contact already exists' +export const loadingMessage = 'Loading...' +export const groupIsRequired = 'You need to either pick a group or enter one.' +export const errorGroupCreation = 'Unable to create the group.' +export const errorContactCreation = 'Unable to add the contact.' +export const errorAddressBookCreation = 'Unable to create your address book.' +export const errorReadingAddressBook = 'There was an error reading your address book.' +export const errorLoadingContact = 'There was an error loading the contact: ' +export const errorGettingAddressBooks = 'There was an error getting your address books.' +export const errorNotExistsAddressBookUri = 'Please enter an address book URI.' +export const errorProcessingUriAddressBook = 'Unable to add your address book.' +export const errorUnableToDetermineUserWorkspace = 'Unable to determine user workspace for new address book.' +export const errorAddingContactWebIDToAddressBook = 'Contact webID was not saved.' +export const ownerLoginRequiredDialogMessageText = 'You need to log in as the profile owner to save contact updates.' + +export const saveContactUpdatesFailedMessageText = 'Unable to save your contact information.' +export const saveHeadingUpdatesFailedMessageText = 'Unable to save your heading information.' +export const saveLanguageUpdatesFailedMessageText = 'Unable to save your languages.' +export const saveSkillsUpdatesFailedMessageText = 'Unable to save your skills.' +export const saveResumeUpdatesFailedMessageText = 'Unable to save your resume.' +export const saveEducationUpdatesFailedMessageText = 'Unable to save your education history.' +export const saveProjectsUpdatesFailedMessageText = 'Unable to save your project data.' +export const unfollowProjectFailedMessageText = 'Unable to unfollow the project.' +export const saveSocialUpdatesFailedMessageText = 'Unable to save your social accounts.' +export const saveBioUpdatesFailedMessageText = 'Unable to save your bio.' + +export const bioMutationSaveFailedDebugText = 'Bio mutation save failed' +export const addContactWebIdSaveFailedDebugText = 'Add contact WebID save failed' +export const contactInfoMutationSaveFailedDebugText = 'Contact info mutation save failed' +export const educationMutationSaveFailedDebugText = 'Education mutation save failed' +export const headingMutationSaveFailedDebugText = 'Heading mutation save failed' +export const languageMutationSaveFailedDebugText = 'Language mutation save failed' +export const projectsMutationSaveFailedDebugText = 'Projects mutation save failed' +export const resumeMutationSaveFailedDebugText = 'Resume mutation save failed' +export const skillsMutationSaveFailedDebugText = 'Skills mutation save failed' +export const socialMutationSaveFailedDebugText = 'Social mutation save failed' +export const resumeUpdateEntryNotFoundErrorMessageText = 'Could not find existing resume entry for update. Please reload profile data and try again.' +export const updaterUnsupportedStoreErrorMessageText = 'Store does not support updates' +export const fallbackSaveUpdatesErrorMessageText = 'Failed to save updates' diff --git a/src/components/profile-heading/editor/texts/profileTexts.ts b/src/components/profile-heading/editor/texts/profileTexts.ts new file mode 100644 index 00000000..b79a42d1 --- /dev/null +++ b/src/components/profile-heading/editor/texts/profileTexts.ts @@ -0,0 +1,13 @@ +export const yourContactInformationHeading = 'Your profile' +export const otherPreferencesHeadingText = 'Other preferences' +export const communitiesHeadingText = 'Your communities' +export const resumeHeadingText = 'Resume' +export const bioHeadingText = 'Bio' +export const educationHeadingText = 'Education' +export const skillsHeadingText = 'Skills' +export const languagesHeadingText = 'Languages' +export const projectsHeadingText = 'Projects & Communities' +export const contactInfoHeadingText = 'More Contacts' +export const contactInfoEmptyHeadingText = 'Contact Info' +export const socialAccountsHeadingText = 'Follow me on' +export const friendsHeadingText = 'Friends' diff --git a/src/components/profile-heading/editor/texts/qrCodeTexts.ts b/src/components/profile-heading/editor/texts/qrCodeTexts.ts new file mode 100644 index 00000000..bebf3b58 --- /dev/null +++ b/src/components/profile-heading/editor/texts/qrCodeTexts.ts @@ -0,0 +1 @@ +export const scanQrToConnectText = 'Add to Contacts' diff --git a/src/components/profile-heading/editor/ui/dialog.css b/src/components/profile-heading/editor/ui/dialog.css new file mode 100644 index 00000000..d4f48b63 --- /dev/null +++ b/src/components/profile-heading/editor/ui/dialog.css @@ -0,0 +1,163 @@ +@import './dialog.responsive.css'; + +/* CSS for the accessible modal dialogs created by dialog.ts */ +/* dialog host */ +#profile-modal { + --profile-modal-backdrop: var(--overlay-bg-muted, rgba(0, 0, 0, 0.5)); + --profile-modal-panel-inline-padding: 25px; + --profile-modal-panel-block-padding: 20px; + --profile-modal-compact-padding: 15px; + --profile-modal-button-gap: 15px; + --profile-modal-error-padding: 12px; + --profile-modal-panel-width: min(600px, calc(100vw - 32px)); + --profile-modal-panel-max-width: 600px; + --profile-modal-panel-max-height: calc(100dvh - 32px); + margin: 0; + padding: 0; + border: none; + background: var(--profile-modal-backdrop); + max-width: none; + max-height: none; + width: 100%; + height: 100%; + overflow: hidden; + position: fixed; + inset: 0; + z-index: 9999; + display: grid; + place-items: center; + overscroll-behavior: contain; + padding-top: max(25px, env(safe-area-inset-top)); + padding-right: 0; + padding-bottom: max(25px, env(safe-area-inset-bottom)); + padding-left: 0; +} + +#profile-modal:not([open]) { + display: none; +} + +#profile-modal::backdrop { + background: var(--profile-modal-backdrop); +} + +#profile-modal .modal { + box-sizing: border-box; + position: relative; + display: grid; + grid-template-rows: auto minmax(0, 1fr) auto auto; + margin: 0; + background: var(--color-background); + border-radius: 5px; + max-width: var(--profile-modal-panel-max-width); + width: var(--profile-modal-panel-width); + max-height: var(--profile-modal-panel-max-height); + overflow: hidden; + box-shadow: var(--box-shadow-modal, 0 2px 10px rgba(0, 0, 0, 0.3)); + align-self: center; + justify-self: center; +} + +#profile-modal .modal .modal-header { + gap: var(--spacing-lg); + width: 100%; + min-width: 0; + padding: var(--profile-modal-panel-block-padding) var(--profile-modal-panel-inline-padding); + box-sizing: border-box; + border-radius: 5px 5px 0 0; + border-bottom: 1px solid var(--solid-ui-color-slate-200, #E2E8F0); + background: var(--solid-ui-color-slate-50, #F8FAFC); +} + +#profile-modal .modal #modal-desc { + min-height: 0; + overflow: auto; + overscroll-behavior: contain; + width: 100%; + min-width: 0; + padding: var(--profile-modal-panel-inline-padding); + box-sizing: border-box; +} + +#profile-modal .modal #modal-desc:has(> .profile__edit-form--projects) { + padding: 10px var(--profile-modal-panel-inline-padding); +} + +#profile-modal .modal #modal-desc:has(> #contacts-addressbook-picker-dialog) { + padding-top: 0; +} + +#profile-modal #modal-desc > .profile__edit-form--projects { + display: flex; + flex-direction: column; + gap: 10px; +} + +#profile-modal .modal #modal-title { + margin: 0; + color: var(--color-text-subheading, var(--gray-900, #101828)); +} + +#profile-modal .modal:has(#modal-desc > .profile__edit-form--projects) #modal-header-action, +#profile-modal .modal:has(#modal-desc > .profile__edit-form--contact-info) #modal-header-action { + display: none; +} + +/* button container: center buttons horizontally (uses id in markup) */ +#profile-modal #modal-buttons { + width: 100%; + min-width: 0; + padding: var(--profile-modal-panel-block-padding) calc(var(--profile-modal-panel-inline-padding) + var(--spacing-xxs, 0.3125rem)) var(--profile-modal-compact-padding); + gap: var(--profile-modal-button-gap); + align-self: stretch; + box-sizing: border-box; + border-top: 1px solid var(--solid-ui-color-slate-200, #E2E8F0); + background: var(--color-surface-tertiary, var(--gray-50, #F9FAFB)); +} + +#profile-modal #modal-buttons[hidden] { + display: none !important; +} + +#profile-modal #modal-buttons > solid-ui-button { + width: 10.8rem; +} + +#profile-modal .modal__error-section { + margin-top: var(--spacing-sm); + margin-bottom: 0; + padding: var(--profile-modal-error-padding); + border: 1px solid var(--dialog-error-border, var(--pink-700, #ff98b3)); + border-radius: 5px; + background: var(--dialog-error-background, var(--pink-500, #ffdde6)); + color: var(--solid-ui-color-error, #B00020); + text-align: center; + white-space: pre-wrap; + overflow-wrap: anywhere; +} + +#profile-modal .modal__error-section[hidden] { + display: none !important; +} + +#profile-modal #modal-saving-overlay { + position: absolute; + inset: 0; + display: grid; + place-items: center; + background: rgba(255, 255, 255, 0.78); + z-index: 10; +} + +#profile-modal #modal-saving-overlay[hidden] { + display: none; +} + +#profile-modal.modal--saving #modal-desc { + opacity: 0.45; + pointer-events: none; +} + +#profile-modal .modal__saving-indicator { + gap: 0; +} diff --git a/src/components/profile-heading/editor/ui/dialog.responsive.css b/src/components/profile-heading/editor/ui/dialog.responsive.css new file mode 100644 index 00000000..caa4c0b9 --- /dev/null +++ b/src/components/profile-heading/editor/ui/dialog.responsive.css @@ -0,0 +1,107 @@ +#profile-modal .modal:has(#modal-desc > .profile__edit-form solid-ui-combobox:focus-within) #modal-desc { + padding-bottom: calc(var(--profile-modal-panel-inline-padding) + 30px); +} + +@media (max-width: 576px) { + #profile-modal { + --profile-modal-panel-max-height: calc(100dvh - 4 * 15px); + padding-top: max(15px, env(safe-area-inset-top)); + padding-right: 0; + padding-bottom: max(15px, env(safe-area-inset-bottom)); + padding-left: 0; + place-items: center; + } + + #profile-modal .modal { + width: var(--profile-modal-panel-width); + max-width: var(--profile-modal-panel-max-width); + min-width: 0; + padding: 0; + border-radius: 5px; + overscroll-behavior: contain; + justify-self: center; + align-self: center; + margin: 0; + } + + #profile-modal .modal .modal-header { + gap: 25px; + padding: 15px; + } + + #profile-modal .modal #modal-title { + font-size: var(--solid-ui-font-size-lg, 1.125rem); + line-height: 1.4; + } + + #profile-modal .modal #modal-desc { + padding: 15px 15px 25px; + } + + #profile-modal #modal-buttons { + flex-direction: row; + align-items: center; + justify-content: flex-end; + gap: var(--profile-modal-button-gap); + padding: var(--profile-modal-compact-padding); + width: 100%; + } + + #profile-modal #modal-buttons > solid-ui-button { + flex: 1 0 0; + width: auto; + min-width: 0; + } +} + +html[data-layout='mobile'] #profile-modal { + --profile-modal-panel-max-height: calc(100dvh - 4 * 15px); + padding-top: max(15px, env(safe-area-inset-top)); + padding-right: 0; + padding-bottom: max(15px, env(safe-area-inset-bottom)); + padding-left: 0; + place-items: center; +} + +html[data-layout='mobile'] #profile-modal .modal { + width: var(--profile-modal-panel-width); + height: auto; + max-height: var(--profile-modal-panel-max-height); + max-width: var(--profile-modal-panel-max-width); + min-width: 0; + padding: 0; + border-radius: 5px; + overscroll-behavior: contain; + justify-self: center; + align-self: center; + margin: 0; +} + +html[data-layout='mobile'] #profile-modal .modal .modal-header { + gap: 25px; + padding: 15px; +} + +html[data-layout='mobile'] #profile-modal .modal #modal-title { + font-size: var(--solid-ui-font-size-lg, 1.125rem); + line-height: 1.4; +} + +html[data-layout='mobile'] #profile-modal .modal #modal-desc { + padding: 15px 15px 25px; +} + +html[data-layout='mobile'] #profile-modal #modal-buttons { + flex-direction: row; + align-items: center; + justify-content: flex-end; + gap: var(--profile-modal-button-gap); + padding: var(--profile-modal-compact-padding); + width: 100%; +} + +html[data-layout='mobile'] #profile-modal #modal-buttons > solid-ui-button { + flex: 1 0 0; + width: auto; + min-width: 0; +} diff --git a/src/components/profile-heading/editor/ui/dialog.ts b/src/components/profile-heading/editor/ui/dialog.ts new file mode 100644 index 00000000..5d68a83d --- /dev/null +++ b/src/components/profile-heading/editor/ui/dialog.ts @@ -0,0 +1,656 @@ +import './dialog.css' +import 'solid-ui/components/button' +import '~icons/lucide/x' +import { html, render } from 'lit-html' +import { createSpinner } from './spinner' +import { formatDisplayError } from '../utils/errorDisplay' + +const closeIcon = html`` + +/* Copied from issue-pane, minor typescript adjustments */ +/* Changed modal from div to dialog element */ +let modalDialog: HTMLDialogElement | null = null + +const scrollLockState = new WeakMap void) | null +}>() + +function getEventTargetElement (target: EventTarget | null): HTMLElement | null { + if (target instanceof HTMLElement) return target + if (target instanceof Node) return target.parentElement + return null +} + +function getEventPath (event: Event): EventTarget[] { + if (typeof event.composedPath === 'function') { + return event.composedPath() + } + + return event.target ? [event.target] : [] +} + +function isDialogScrollRegionTarget (event: Event): boolean { + const path = getEventPath(event) + const description = modalDialog?.querySelector('#modal-desc') + + if (description && path.includes(description)) { + return true + } + + if (modalDialog && path.includes(modalDialog)) { + return true + } + + const targetElement = getEventTargetElement(event.target) + if (!targetElement || !modalDialog || !modalDialog.contains(targetElement)) { + return false + } + + return Boolean(targetElement.closest('#modal-desc')) +} + +function getDocumentScrollLockState (dom: Document) { + let state = scrollLockState.get(dom) + if (!state) { + state = { + count: 0, + previousHtmlOverflow: dom.documentElement.style.overflow, + previousBodyOverflow: dom.body.style.overflow, + removeScrollGuard: null + } + scrollLockState.set(dom, state) + } + return state +} + +function installDocumentScrollGuard (dom: Document): void { + const state = getDocumentScrollLockState(dom) + if (state.removeScrollGuard) return + + const preventBackgroundScroll = (event: Event) => { + if (!isDialogScrollRegionTarget(event)) { + event.preventDefault() + } + } + + dom.addEventListener('wheel', preventBackgroundScroll, { capture: true, passive: false }) + dom.addEventListener('touchmove', preventBackgroundScroll, { capture: true, passive: false }) + state.removeScrollGuard = () => { + dom.removeEventListener('wheel', preventBackgroundScroll, true) + dom.removeEventListener('touchmove', preventBackgroundScroll, true) + state.removeScrollGuard = null + } +} + +function lockDocumentScroll (dom: Document): void { + const state = getDocumentScrollLockState(dom) + + if (state.count === 0) { + state.previousHtmlOverflow = dom.documentElement.style.overflow + state.previousBodyOverflow = dom.body.style.overflow + + dom.documentElement.style.overflow = 'hidden' + dom.body.style.overflow = 'hidden' + installDocumentScrollGuard(dom) + } + + state.count += 1 +} + +function unlockDocumentScroll (dom: Document): void { + const state = getDocumentScrollLockState(dom) + if (state.count === 0) return + + state.count -= 1 + if (state.count > 0) return + + dom.documentElement.style.overflow = state.previousHtmlOverflow + dom.body.style.overflow = state.previousBodyOverflow + state.removeScrollGuard?.() + state.removeScrollGuard = null +} + +function getDialogMountTarget (dom: Document): HTMLElement { + return dom.body +} + +type DialogButtonValue = boolean | 'save' | null +type DialogButton = { + label: string, + value: DialogButtonValue, + primary?: boolean, + cancel?: boolean, + beforeClose?: () => Promise | boolean +} + +type DialogHeaderAction = + | { type: 'close' } + | { type: 'none' } + | { + type: 'button', + label: string, + ariaLabel?: string, + className?: string, + onClick?: () => Promise | void + } + +type DialogElements = { + dialog: HTMLDialogElement, + title: HTMLHeadingElement, + headerAction: HTMLDivElement, + description: HTMLDivElement, + error: HTMLElement, + buttons: HTMLDivElement, + savingOverlay: HTMLDivElement +} + +type DialogActionControl = HTMLElement & { + disabled?: boolean, + label?: string, + click: () => void, + shadowRoot?: ShadowRoot | null +} + +function isSolidUiButton (control: Element | null): control is DialogActionControl { + return control?.tagName === 'SOLID-UI-BUTTON' +} + +function setDialogActionDisabled (control: DialogActionControl | null, disabled: boolean): void { + if (!control) return + control.disabled = disabled + control.toggleAttribute('disabled', disabled) +} + +function setDialogActionLabel (control: DialogActionControl | null, label: string): void { + if (!control) return + + if (isSolidUiButton(control)) { + control.label = label + control.setAttribute('label', label) + control.textContent = label + return + } + + ;(control as HTMLElement).textContent = label +} + +export function getSharedDialogSaveButton (root: ParentNode): DialogActionControl | null { + return root.querySelector('#modal-buttons [data-dialog-primary="true"]') as DialogActionControl | null +} + +export function getSharedDialogCancelButton (root: ParentNode): DialogActionControl | null { + return root.querySelector('#modal-buttons [data-cancel="true"]') as DialogActionControl | null +} + +function ensureModalDialog (dom: Document): HTMLDialogElement { + const mountTarget = getDialogMountTarget(dom) + + // if we previously created a dialog but it was removed from the document + // (tests clear body), rebuild it. Checking presence ensures our reference + // doesn't point at a detached element. + if (modalDialog && dom.body.contains(modalDialog)) { + if (modalDialog.parentElement !== mountTarget) { + mountTarget.appendChild(modalDialog) + } + return modalDialog + } + + modalDialog = null + modalDialog = dom.createElement('dialog') + modalDialog.id = 'profile-modal' + modalDialog.setAttribute('aria-modal', 'true') + modalDialog.setAttribute('aria-labelledby', 'modal-title') + modalDialog.setAttribute('aria-describedby', 'modal-desc') + + modalDialog.innerHTML = ` + + ` + + mountTarget.appendChild(modalDialog) + return modalDialog +} + +function getDialogElements (dialog: HTMLDialogElement): DialogElements { + return { + dialog, + title: dialog.querySelector('#modal-title') as HTMLHeadingElement, + headerAction: dialog.querySelector('#modal-header-action') as HTMLDivElement, + description: dialog.querySelector('#modal-desc') as HTMLDivElement, + error: dialog.querySelector('#modal-error') as HTMLElement, + buttons: dialog.querySelector('#modal-buttons') as HTMLDivElement, + savingOverlay: dialog.querySelector('#modal-saving-overlay') as HTMLDivElement + } +} + +function syncDialogErrorDescription (elements: DialogElements): void { + const defaultDescription = 'modal-desc' + const describedBy = elements.error.hidden || !elements.error.textContent?.trim() + ? defaultDescription + : `${defaultDescription} modal-error` + + elements.dialog.setAttribute('aria-describedby', describedBy) +} + +function clearModalError (elements: DialogElements): void { + elements.error.textContent = '' + elements.error.setAttribute('aria-hidden', 'true') + elements.error.hidden = true + syncDialogErrorDescription(elements) +} + +function setModalError (elements: DialogElements, error: unknown, fallbackMessage?: string): void { + elements.error.textContent = formatDisplayError(error, fallbackMessage) + elements.error.setAttribute('aria-hidden', 'false') + elements.error.hidden = false + syncDialogErrorDescription(elements) +} + +function openDialogElement (dialog: HTMLDialogElement): void { + lockDocumentScroll(dialog.ownerDocument) + + if (typeof dialog.showModal === 'function') { + try { + if (!dialog.open) dialog.showModal() + return + } catch { + // Fall back for jsdom or partial dialog implementations. + } + } + + dialog.setAttribute('open', '') +} + +function closeDialogElement (dialog: HTMLDialogElement): void { + try { + if (typeof dialog.close === 'function' && dialog.open) { + dialog.close() + return + } + + dialog.removeAttribute('open') + } finally { + unlockDocumentScroll(dialog.ownerDocument) + } +} + +function isMobileDialogLayout (dom: Document): boolean { + return Boolean(dom.querySelector('[data-layout=\'mobile\']')) +} + +function isFocusableElement (element: HTMLElement): boolean { + if (element.hasAttribute('disabled')) return false + if (element.getAttribute('aria-hidden') === 'true') return false + if (element.getAttribute('hidden') !== null) return false + if (element.tabIndex < 0) return false + return true +} + +function findPreferredInitialFocusTarget (container: ParentNode): HTMLElement | null { + const focusableControls = container.querySelectorAll([ + 'input:not([type="hidden"]):not([disabled])', + 'textarea:not([disabled])', + 'select:not([disabled])', + 'solid-ui-select:not([disabled])', + 'solid-ui-combobox:not([disabled])', + '[contenteditable="true"]', + 'button:not([disabled])', + 'solid-ui-button:not([disabled])', + '[tabindex]:not([tabindex="-1"])' + ].join(',')) + + for (const match of focusableControls) { + if (match instanceof HTMLElement && isFocusableElement(match)) return match + } + + return null +} + +function focusInitialDialogTarget (dialog: HTMLDialogElement, description: HTMLDivElement, buttons: HTMLDivElement): void { + if (isMobileDialogLayout(dialog.ownerDocument)) { + dialog.tabIndex = -1 + dialog.focus() + return + } + + const initialTarget = findPreferredInitialFocusTarget(description) + if (initialTarget) { + initialTarget.focus() + if (initialTarget instanceof HTMLInputElement || initialTarget instanceof HTMLTextAreaElement) { + initialTarget.select() + } + return + } + + const firstButton = findPreferredInitialFocusTarget(buttons) + if (firstButton) { + firstButton.focus() + } +} + +function collectFormValues (form: HTMLFormElement): InputDialogValues { + const data = new FormData(form) + const values: InputDialogValues = {} + data.forEach((value, key) => { + values[key] = String(value) + }) + return values +} + +function openModal ({ + title, + message, + buttons, + headerAction, + dom +}: { + title?: string, + message?: string | Node, + buttons: DialogButton[], + headerAction?: DialogHeaderAction, + dom: Document +}) { + const dialog = ensureModalDialog(dom) + const elements = getDialogElements(dialog) + + openDialogElement(dialog) + + elements.title.textContent = title || '' + elements.description.innerHTML = '' + if (typeof message === 'string') { + elements.description.textContent = message + } else if (message) { + elements.description.appendChild(message) + } + + elements.buttons.innerHTML = '' + clearModalError(elements) + + return new Promise((resolve) => { + const finish = (value: DialogButtonValue) => { + closeModal(value) + resolve(value) + } + + const requestCancel = () => { + const cancelBtn = getSharedDialogCancelButton(dialog) + if (cancelBtn) { + cancelBtn.click() + return + } + + finish(false) + } + + dialog.oncancel = (event: Event) => { + event.preventDefault() + requestCancel() + } + + elements.headerAction.innerHTML = '' + const resolvedHeaderAction = headerAction || { type: 'close' as const } + if (resolvedHeaderAction.type === 'close') { + const closeButton = dom.createElement('solid-ui-button') as DialogActionControl + closeButton.setAttribute('variant', 'ghost') + closeButton.setAttribute('aria-label', 'Close dialog') + const iconSlot = dom.createElement('span') + iconSlot.setAttribute('slot', 'icon') + render(closeIcon, iconSlot) + closeButton.appendChild(iconSlot) + closeButton.onclick = () => requestCancel() + elements.headerAction.appendChild(closeButton) + } else if (resolvedHeaderAction.type === 'button') { + const actionButton = dom.createElement('solid-ui-button') as DialogActionControl + actionButton.setAttribute('variant', 'tertiary') + actionButton.className = resolvedHeaderAction.className || '' + actionButton.textContent = resolvedHeaderAction.label + actionButton.setAttribute('label', resolvedHeaderAction.label) + actionButton.setAttribute('aria-label', resolvedHeaderAction.ariaLabel || resolvedHeaderAction.label) + actionButton.onclick = async () => { + if (resolvedHeaderAction.onClick) { + await resolvedHeaderAction.onClick() + } + } + elements.headerAction.appendChild(actionButton) + } + + buttons.forEach((btn) => { + const b = dom.createElement('solid-ui-button') as DialogActionControl + b.setAttribute('label', btn.label) + b.setAttribute('variant', btn.primary ? 'primary' : 'secondary') + b.textContent = btn.label + if (btn.primary) { + b.setAttribute('data-dialog-primary', 'true') + } + if (btn.cancel) { + b.setAttribute('data-cancel', 'true') + } + b.addEventListener('click', async () => { + if (btn.beforeClose) { + const shouldClose = await btn.beforeClose() + if (!shouldClose) return + } + finish(btn.value) + }) + elements.buttons.appendChild(b) + }) + + const scheduleInitialFocus = dom.defaultView?.requestAnimationFrame + ? (callback: () => void) => dom.defaultView?.requestAnimationFrame(() => callback()) + : (callback: () => void) => setTimeout(callback, 0) + + scheduleInitialFocus(() => { + focusInitialDialogTarget(dialog, elements.description, elements.buttons) + }) + }) +} + +function closeModal (_result: DialogButtonValue): void { + if (modalDialog) { + const elements = getDialogElements(modalDialog) + clearModalError(elements) + closeDialogElement(modalDialog) + modalDialog.oncancel = null + const headerActionButton = modalDialog.querySelector('#modal-header-action button') as HTMLButtonElement | null + if (headerActionButton) headerActionButton.onclick = null + } +} + +export function closeSharedDialog (): void { + closeModal(null) +} + +export function alertDialog (message: string, title = 'Information', dom: Document) { + return openModal({ + title, + message, + buttons: [{ label: 'OK', value: true, primary: true }], + dom + }) +} + +function updateSavingUI (dialog: HTMLDialogElement, submitLabel: string, isSaving: boolean) { + const elements = getDialogElements(dialog) + const saveButton = getSharedDialogSaveButton(dialog) + const cancelButton = getSharedDialogCancelButton(dialog) + + dialog.classList.toggle('modal--saving', isSaving) + dialog.setAttribute('aria-busy', String(isSaving)) + elements.description.toggleAttribute('inert', isSaving) + + if (isSaving) { + const activeElement = dialog.ownerDocument.activeElement as HTMLElement | null + if (activeElement && dialog.contains(activeElement)) { + activeElement.blur() + } + } + + if (saveButton) { + setDialogActionDisabled(saveButton, isSaving) + saveButton.setAttribute('aria-busy', String(isSaving)) + setDialogActionLabel(saveButton, submitLabel) + } + + if (cancelButton) { + setDialogActionDisabled(cancelButton, isSaving) + } + + elements.savingOverlay.hidden = !isSaving + if (isSaving) { + render(html` + + `, elements.savingOverlay) + } else { + render(html``, elements.savingOverlay) + } +} + +export function setSharedDialogSavingState (dom: Document, isSaving: boolean, submitLabel = 'Saving Changes'): void { + const dialog = ensureModalDialog(dom) + updateSavingUI(dialog, submitLabel, isSaving) +} + +type OpenInputDialogCustom = { + title: string, + dom: Document, + form: HTMLFormElement, + submitLabel?: string, + cancelLabel?: string, + headerAction?: DialogHeaderAction, + hideFooterButtons?: boolean, + onOpen?: () => void, + shouldCloseWithoutSave?: () => Promise | boolean, + validate?: () => Promise | string | null, + onSave?: () => Promise | void, + formatSaveError?: (error: unknown) => string +} + +type InputDialogValues = Record +/* Function below generated by AI Model: GPT-5.3-Codex */ +/* Prompt: write me a reusable function to open a dialog with a form and return the form values on submit. +The function should also support validation and display error messages in the dialog. +It should reuse the OpenModal function for consistency. Done in 2 passes */ +export function openInputDialog (options: OpenInputDialogCustom): Promise { + const submitLabel = options.submitLabel || 'Save Changes' + const cancelLabel = options.cancelLabel || 'Cancel' + const dialog = ensureModalDialog(options.dom) + const elements = getDialogElements(dialog) + + const deriveDefaultFieldLabel = (value: string): string => value + .replace(/^\s*edit\s+/i, '') + .replace(/^\s*add\s+/i, '') + .replace(/^\s*create\s+/i, '') + .trim() + + const ensureFormControlsHaveAccessibleNames = () => { + const titleLabel = deriveDefaultFieldLabel(options.title) + if (!titleLabel) return + + const controls = Array.from(options.form.querySelectorAll([ + 'input:not([type="hidden"])', + 'textarea', + 'select' + ].join(','))) + + if (controls.length !== 1) return + + const [control] = controls + const hasExplicitLabel = control.hasAttribute('aria-label') || control.hasAttribute('aria-labelledby') + const hasNativeLabel = Boolean(control.closest('label')) + if (hasExplicitLabel || hasNativeLabel || control.getAttribute('type') === 'hidden') { + return + } + + if (!control.getAttribute('aria-label')) { + control.setAttribute('aria-label', titleLabel) + } + } + + ensureFormControlsHaveAccessibleNames() + + const handleSubmit = (event: SubmitEvent) => { + event.preventDefault() + const saveButton = getSharedDialogSaveButton(dialog) + saveButton?.click() + } + + options.form.addEventListener('submit', handleSubmit) + + const dialogPromise = openModal({ + title: options.title, + message: options.form, + headerAction: options.headerAction, + buttons: [ + { label: cancelLabel, value: null, cancel: true }, + { + label: submitLabel, + value: 'save', + primary: true, + beforeClose: async () => { + clearModalError(elements) + + if (options.shouldCloseWithoutSave && await options.shouldCloseWithoutSave()) { + return true + } + + if (options.validate) { + const validationMessage = await options.validate() + if (validationMessage) { + setModalError(elements, validationMessage) + return false + } + } + + if (!options.onSave) return true + + try { + updateSavingUI(dialog, submitLabel, true) + + await options.onSave() + return true + } catch (error) { + updateSavingUI(dialog, submitLabel, false) + const fallback = options.formatSaveError ? options.formatSaveError(error) : undefined + setModalError(elements, error, fallback) + return false + } + } + } + ], + dom: options.dom + }) + + const scheduleOpenCallback = options.dom.defaultView?.requestAnimationFrame + ? (callback: () => void) => options.dom.defaultView?.requestAnimationFrame(() => callback()) + : (callback: () => void) => setTimeout(callback, 0) + + if (options.onOpen) { + scheduleOpenCallback(options.onOpen) + } + + elements.buttons.hidden = Boolean(options.hideFooterButtons) + + return dialogPromise + .then((result) => { + if (result !== 'save') return null + return collectFormValues(options.form) + }) + .finally(() => { + elements.buttons.hidden = false + updateSavingUI(dialog, submitLabel, false) + options.form.removeEventListener('submit', handleSubmit) + }) +} diff --git a/src/components/profile-heading/editor/ui/spinner.ts b/src/components/profile-heading/editor/ui/spinner.ts new file mode 100644 index 00000000..78dddede --- /dev/null +++ b/src/components/profile-heading/editor/ui/spinner.ts @@ -0,0 +1,8 @@ +import { html, TemplateResult } from 'lit-html' + +export function createSpinner (): TemplateResult { + return html` + + Saving... + ` +} diff --git a/src/components/profile-heading/editor/utils/errorDisplay.ts b/src/components/profile-heading/editor/utils/errorDisplay.ts new file mode 100644 index 00000000..eaaccc8a --- /dev/null +++ b/src/components/profile-heading/editor/utils/errorDisplay.ts @@ -0,0 +1,15 @@ +function stringifyUnknown (value: unknown): string { + if (typeof value === 'string') return value + if (value instanceof Error) return value.message || value.name + if (value == null) return '' + + try { + return JSON.stringify(value) + } catch { + return String(value) + } +} + +export function formatDisplayError (error: unknown, fallbackMessage?: string): string { + return (fallbackMessage || stringifyUnknown(error) || 'Something went wrong.').trim() +} diff --git a/src/components/profile-heading/friendActions.ts b/src/components/profile-heading/friendActions.ts new file mode 100644 index 00000000..bf4f5984 --- /dev/null +++ b/src/components/profile-heading/friendActions.ts @@ -0,0 +1,39 @@ +import { authn, store } from 'solid-logic' +import { st, type NamedNode } from 'rdflib' +import { ns } from 'solid-ui' +import { ensureStandardMutationPrefixes } from './editor/sections/shared/rdfMutationHelpers' +import { formatDisplayError } from './editor/utils/errorDisplay' + +export const friendTexts = { + add: 'Add as friend', + exists: 'Already a friend', + success: 'Friend was added!', + duplicate: 'Friend already exists', + loginRequired: 'Current user not found! Not logged in?' +} + +function requireViewer (viewer: NamedNode): void { + if (!authn.currentUser()?.sameTerm(viewer)) { + throw new Error(friendTexts.loginRequired) + } +} + +export async function checkFriend (viewer: NamedNode, subject: NamedNode): Promise { + await store.fetcher.load(viewer) + requireViewer(viewer) + return store.whether(viewer, ns.foaf('knows'), subject, viewer.doc()) > 0 +} + +export async function addFriend (viewer: NamedNode, subject: NamedNode): Promise { + requireViewer(viewer) + if (await checkFriend(viewer, subject)) throw new Error(friendTexts.duplicate) + ensureStandardMutationPrefixes(store) + try { + await store.updater.update([], [st(viewer, ns.foaf('knows'), subject, viewer.doc())]) + } catch (error: unknown) { + if (formatDisplayError(error).includes('Unauthenticated')) { + throw new Error(friendTexts.loginRequired) + } + throw error + } +} diff --git a/src/components/profile-heading/index.ts b/src/components/profile-heading/index.ts new file mode 100644 index 00000000..810ec439 --- /dev/null +++ b/src/components/profile-heading/index.ts @@ -0,0 +1,5 @@ +import ProfileHeading from './ProfileHeading' + +export { ProfileHeading } +export type { ProfileHeadingData, ProfileHeadingEditContext, ProfileHeadingPoint } from './ProfileHeading' +export default ProfileHeading diff --git a/src/components/profile-heading/profileHeadingData.ts b/src/components/profile-heading/profileHeadingData.ts new file mode 100644 index 00000000..1bf592a5 --- /dev/null +++ b/src/components/profile-heading/profileHeadingData.ts @@ -0,0 +1,163 @@ +import { store } from 'solid-logic' +import { getViewerRelation } from '../../utils/viewerUtils' +import { NamedNode, type LiveStore, type Node } from 'rdflib' +import { ns, utils, widgets } from 'solid-ui' +import type { AddressDetails, PointDetails } from './editor/sections/contactInfo/types' +import type { ProfileDetails } from './editor/sections/heading/types' +import type { ViewerMode } from '../../types' + +export async function getViewerMode (subject: NamedNode): Promise { + const relation = getViewerRelation(subject) + if (relation !== 'owner') return relation + + try { + return store.updater?.editable?.(subject.doc()) ? 'owner' : 'anonymous' + } catch (error) { + console.warn('Failed to check profile edit permissions.', error) + return 'anonymous' + } +} + +export function presentProfile (subject: NamedNode, profileStore: LiveStore = store): ProfileDetails { + const doc = subject.doc() + const nickname = profileStore.anyValue(subject, ns.vcard('nickname')) || + profileStore.anyValue(subject, ns.foaf('nick')) || undefined + const dateOfBirth = profileStore.anyValue(subject, ns.vcard('bday')) || undefined + const imageSrc = widgets.findImage(subject) || undefined + const primaryPhone = selectPrimaryPoint(profileStore, subject, ns.vcard('hasTelephone'), doc, 'phone') + const primaryEmail = selectPrimaryPoint(profileStore, subject, ns.vcard('hasEmail'), doc, 'email') + const jobTitle = selectHeadingJobTitle(profileStore, subject, doc) + + const addressNode = profileStore.any(subject, ns.vcard('hasAddress'), null, doc) || undefined + const addressSubject = addressNode as NamedNode | undefined + const primaryAddress: AddressDetails | undefined = addressNode + ? { + entryNode: addressNode, + type: profileStore.any(addressSubject, ns.rdf('type'), null, doc) || undefined, + streetAddress: profileStore.anyValue(addressSubject, ns.vcard('street-address')) || undefined, + locality: profileStore.anyValue(addressSubject, ns.vcard('locality')) || undefined, + region: profileStore.anyValue(addressSubject, ns.vcard('region')) || undefined, + postalCode: profileStore.anyValue(addressSubject, ns.vcard('postal-code')) || undefined, + countryName: profileStore.anyValue(addressSubject, ns.vcard('country-name')) || undefined + } + : undefined + const country = primaryAddress?.countryName + const locality = primaryAddress?.locality + const subjectPronoun = profileStore.anyValue(subject, ns.solid('preferredSubjectPronoun')) || '' + const objectPronoun = profileStore.anyValue(subject, ns.solid('preferredObjectPronoun')) || '' + const pronouns = subjectPronoun ? `${subjectPronoun}${objectPronoun ? `/${objectPronoun}` : ''}` : undefined + + return { + name: utils.label(subject), + nickname, + imageSrc, + dateOfBirth, + jobTitle, + primaryPhone, + primaryEmail, + primaryAddress, + location: country && locality ? `${locality}, ${country}` : country || locality || undefined, + pronouns, + entryNode: subject + } +} + +function selectHeadingJobTitle (profileStore: LiveStore, subject: NamedNode, doc: NamedNode): string | undefined { + const roles = profileStore.each(null, ns.org('member'), subject, doc) + .filter(membership => + !profileStore.holds( + membership as NamedNode, + ns.rdf('type'), + ns.schema('EducationalOccupationalCredential'), + doc + ) + ) + .map(membership => { + const membershipNode = membership as NamedNode + const types = profileStore.each(membershipNode, ns.rdf('type'), null, doc) + const roleType = types.find(type => type.value.startsWith(ns.solid('').value))?.value.split(/[#/]/).pop()?.toLowerCase() + const roleText = profileStore.anyValue(membershipNode, ns.vcard('role'), null, doc) || undefined + const escoRole = profileStore.any(membershipNode, ns.org('role'), null, doc) + const escoRoleName = escoRole + ? profileStore.anyValue(escoRole as NamedNode, ns.schema('name'), null, doc) || undefined + : undefined + const endDate = profileStore.any(membershipNode, ns.schema('endDate'), null, doc) + const title = escoRoleName && roleText + ? `${escoRoleName} - ${roleText}` + : roleText || escoRoleName + + return { + title, + roleType, + isCurrent: !endDate || roleType === 'currentrole' + } + }) + const selected = roles.find(role => role.isCurrent) || + roles.find(role => role.roleType !== 'currentrole' && role.roleType !== 'futurerole') + return selected?.title +} + +function selectPrimaryPoint ( + profileStore: LiveStore, + subject: NamedNode, + predicate: NamedNode, + doc: NamedNode, + kind: 'email' | 'phone' +): PointDetails | undefined { + const candidates: PointDetails[] = [] + const nodes = [ + ...profileStore.statementsMatching(subject, predicate, null, doc), + ...profileStore.statementsMatching(subject, predicate) + ].map(statement => statement.object as Node) + const seen = new Set() + + for (const entryNode of nodes) { + if (seen.has(entryNode.value)) continue + seen.add(entryNode.value) + + const valueNode = resolvePointValue(profileStore, entryNode, doc, kind) + if (!valueNode) continue + + const types = entryNode.termType === 'NamedNode' + ? [ + ...profileStore.each(entryNode as NamedNode, ns.rdf('type'), null, doc), + ...profileStore.each(entryNode as NamedNode, ns.rdf('type')) + ] + : [] + const type = types[0] || (kind === 'email' ? ns.vcard('Internet') : ns.vcard('Voice')) + const candidate = { entryNode, type: type as Node, valueNode } + if (types.some(typeNode => isWorkType(typeNode.value))) return candidate + candidates.push(candidate) + } + + return candidates[0] +} + +function resolvePointValue ( + profileStore: LiveStore, + entryNode: Node, + doc: NamedNode, + kind: 'email' | 'phone' +): Node | undefined { + if (isContactValue(entryNode.value, kind)) return entryNode + if (entryNode.termType !== 'NamedNode') return undefined + + const values = [ + ...profileStore.each(entryNode as NamedNode, ns.vcard('value'), null, doc), + ...profileStore.each(entryNode as NamedNode, ns.vcard('value')) + ] + return values.find(value => isContactValue(value.value, kind)) +} + +function isContactValue (value: string, kind: 'email' | 'phone'): boolean { + const normalized = value.trim() + if (kind === 'email') { + return /^mailto:/i.test(normalized) || /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(normalized) + } + return /^tel:/i.test(normalized) || /^[+()\-\s\d]{5,}$/.test(normalized) +} + +function isWorkType (value: string): boolean { + const normalized = value.trim().toLowerCase() + return normalized === 'work' || normalized.endsWith('#work') || normalized.endsWith('/work') +} diff --git a/src/components/resource-action-dialog/ResourceActionDialog.styles.css b/src/components/resource-action-dialog/ResourceActionDialog.styles.css new file mode 100644 index 00000000..b1bb4f3a --- /dev/null +++ b/src/components/resource-action-dialog/ResourceActionDialog.styles.css @@ -0,0 +1,31 @@ +solid-ui-dialog-footer { + justify-content: flex-end; + flex-wrap: wrap; +} + +solid-ui-dialog-header h2 { + margin: 0; + font: inherit; +} + +solid-ui-dialog-content p { + overflow-wrap: anywhere; + white-space: pre-line; +} + +.resource-action-dialog-emphasis { + display: block; + font-weight: 600; + text-align: center; +} + +solid-ui-button { + min-width: 24px; + min-height: 24px; +} + +solid-ui-button:focus-within { + outline: 1px solid currentColor; + outline-offset: 1px; + border-radius: 4px; +} diff --git a/src/components/resource-action-dialog/ResourceActionDialog.ts b/src/components/resource-action-dialog/ResourceActionDialog.ts new file mode 100644 index 00000000..d977fefc --- /dev/null +++ b/src/components/resource-action-dialog/ResourceActionDialog.ts @@ -0,0 +1,143 @@ +import { html } from 'lit' +import { property } from 'lit/decorators.js' +import { customElement, WebComponent } from 'solid-ui' +import 'solid-ui/components/button' +import 'solid-ui/components/dialog' +import 'solid-ui/components/dialog-content' +import 'solid-ui/components/dialog-footer' +import 'solid-ui/components/dialog-header' +import '~icons/lucide/x' +import styles from './ResourceActionDialog.styles.css' + +@customElement('solid-panes-resource-action-dialog') +export default class ResourceActionDialog extends WebComponent { + static styles = styles + + @property({ type: String }) + accessor title = '' + + @property({ type: String }) + accessor message = '' + + @property({ type: Boolean }) + accessor confirmation = false + + private result: ((value: boolean) => void) | null = null + private returnFocus: HTMLElement | null = null + + public open (): Promise { + let activeElement = this.ownerDocument.activeElement + while (activeElement?.shadowRoot?.activeElement) { + activeElement = activeElement.shadowRoot.activeElement + } + this.returnFocus = activeElement instanceof HTMLElement ? activeElement : null + return new Promise(resolve => { + this.result = resolve + }) + } + + private closeDialog (result: boolean) { + const dialog = this.shadowRoot?.querySelector('solid-ui-dialog') + const nativeDialog = dialog?.shadowRoot?.querySelector('dialog') + this.result?.(result) + this.result = null + if (nativeDialog?.open) { + nativeDialog.close() + } + this.remove() + } + + disconnectedCallback () { + super.disconnectedCallback() + this.result?.(false) + this.result = null + if (this.returnFocus?.isConnected) { + this.returnFocus.focus() + } else { + const main = this.ownerDocument.querySelector('main') + if (main) { + const previousTabIndex = main.getAttribute('tabindex') + main.tabIndex = -1 + main.focus() + if (previousTabIndex === null) main.removeAttribute('tabindex') + else main.setAttribute('tabindex', previousTabIndex) + } + } + this.returnFocus = null + } + + protected async firstUpdated () { + super.firstUpdated() + const dialog = this.shadowRoot?.querySelector('solid-ui-dialog') + await dialog?.updateComplete + const nativeDialog = dialog?.shadowRoot?.querySelector('dialog') + if (!nativeDialog) throw new Error('Internal pane dialog did not render a native dialog') + nativeDialog.setAttribute('aria-label', this.title) + nativeDialog.setAttribute('aria-description', this.message) + nativeDialog.addEventListener('cancel', event => { + event.preventDefault() + this.closeDialog(false) + }) + nativeDialog.addEventListener('close', () => { + if (this.isConnected) this.closeDialog(false) + }) + const initialAction = this.shadowRoot?.querySelector('[data-initial-action]') + await initialAction?.updateComplete + initialAction?.shadowRoot?.querySelector('button')?.focus() + } + + private handleKeyDown (event: KeyboardEvent) { + if (event.key !== 'Tab') return + const buttons = Array.from(this.shadowRoot?.querySelectorAll('solid-ui-button') ?? []) + .map(component => component.shadowRoot?.querySelector('button')) + .filter((button): button is HTMLButtonElement => !!button && !button.disabled) + const focusedIndex = buttons.findIndex(button => { + const root = button.getRootNode() + return root instanceof ShadowRoot && root.activeElement === button + }) + if (event.shiftKey && focusedIndex === 0) { + event.preventDefault() + buttons[buttons.length - 1]?.focus() + } else if (!event.shiftKey && focusedIndex === buttons.length - 1) { + event.preventDefault() + buttons[0]?.focus() + } + } + + protected render () { + const [mainMessage, ...additionalMessages] = this.message.split('\n') + return html` + + +

${this.title}

+ this.closeDialog(false)}> + Close dialog + + +
+ +

+ ${mainMessage} + ${additionalMessages.map(message => html`${message}`)} +

+
+ + ${this.confirmation + ? html` + this.closeDialog(false)}> + Cancel + + this.closeDialog(true)}> + Delete + + ` + : html` + this.closeDialog(false)}> + OK + + `} + +
+ ` + } +} diff --git a/src/components/resource-actions-menu/DeleteResourceDialog.ts b/src/components/resource-actions-menu/DeleteResourceDialog.ts deleted file mode 100644 index 42b1908f..00000000 --- a/src/components/resource-actions-menu/DeleteResourceDialog.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { customElement, DialogComponent } from 'solid-ui' -import { html } from 'lit' -import { property } from 'lit/decorators.js' - -import 'solid-ui/components/button' -import 'solid-ui/components/dialog' -import 'solid-ui/components/dialog-content' -import 'solid-ui/components/dialog-footer' - -@customElement('resource-delete-dialog') -export default class DeleteResourceDialog extends DialogComponent { - @property({ type: String }) - accessor resourceName = 'this resource' - - private cancel = () => this.close(false) - - private confirm = () => this.close(true) - - protected render () { - return html` - - -

Are you sure you want to permanently delete ${this.resourceName}?

-
- - - Go back - - - Yes - - -
- ` - } -} diff --git a/src/components/resource-actions-menu/ResourceActionsMenu.styles.css b/src/components/resource-actions-menu/ResourceActionsMenu.styles.css deleted file mode 100644 index 9b9e7b4d..00000000 --- a/src/components/resource-actions-menu/ResourceActionsMenu.styles.css +++ /dev/null @@ -1,12 +0,0 @@ -:host { - .file-explorer-header-more-button { - width: var(--solid-ui-clickable-area, 42px); - height: var(--solid-ui-clickable-area, 42px); - padding: 0; - } - - .ellipsisIcon { - width: 16px; - height: 16px; - } -} diff --git a/src/components/resource-actions-menu/ResourceActionsMenu.ts b/src/components/resource-actions-menu/ResourceActionsMenu.ts deleted file mode 100644 index 6a37b83c..00000000 --- a/src/components/resource-actions-menu/ResourceActionsMenu.ts +++ /dev/null @@ -1,83 +0,0 @@ -import { WebComponent } from 'solid-ui' -import { customElement, property } from 'lit/decorators.js' -import { html, nothing } from 'lit' -import 'solid-ui/components/button' -import 'solid-ui/components/menu' -import 'solid-ui/components/menu-item' -import '~icons/lucide/ellipsis-vertical' -import '~icons/lucide/user-round-cog' -import '~icons/lucide/pencil' -import { LiveStore } from 'rdflib' -import styles from './ResourceActionsMenu.styles.css' -import { isContainerSubject } from '../../utils/podUtils' -@customElement('resource-actions-menu') -export default class ResourceActionsMenu extends WebComponent { - static styles = styles - - @property({ attribute: false }) - accessor store: LiveStore | undefined - - @property({ type: String }) - accessor subjectUri: string | undefined - - @property({ attribute: false }) - accessor handleAccessClick: (() => void) | undefined = undefined - - @property({ attribute: false }) - accessor handleEditingClick: (() => void) | undefined = undefined - - @property({ type: Boolean }) - accessor paneSupportsEditing = false - - @property({ type: Boolean }) - accessor canEdit = false - - @property({ type: Boolean }) - accessor isMobile = false - - @property({ attribute: false }) - accessor menuItems: Array<{ label: string, icon?: unknown, action: (event: Event) => void }> = [] - - render () { - const isContainerResource = isContainerSubject(this.store, this.subjectUri) - const canEdit = !isContainerResource && this.isMobile && this.paneSupportsEditing && this.canEdit && !!this.handleEditingClick - const canManageAccess = !!this.handleAccessClick - return html` - - - - - ${this.menuItems.map(item => html` - item.action(event)}> - ${item.icon} - ${item.label} - - `)} - ${canEdit - ? html` - - - Edit - - ` - : nothing} - ${!isContainerResource && this.isMobile && canManageAccess - ? html` - - - Manage Access - - ` - : nothing} - ${isContainerResource && canManageAccess - ? html` - - - Manage Access - - ` - : nothing} - - ` - } -} diff --git a/src/dataContentPane.css b/src/dataContentPane.css index ce1c42d4..deb94c08 100644 --- a/src/dataContentPane.css +++ b/src/dataContentPane.css @@ -2,113 +2,121 @@ white-space: pre-wrap; } -div.data-content-pane { +.data-content-pane { + --color-background-row-alternate: var(--solid-ui-color-gray-150, #f0f0f0); + --color-background-row-default: var(--solid-ui-color-white, #ffffff); border: 1px solid var(--solid-ui-color-gray-200, #cbd5e1); - padding: var(--spacing-base, 0.5rem); - margin-bottom: var(--spacing-base, 0.5rem); + padding: 8px 40px; + margin-bottom: 8px; + box-sizing: border-box; } -div.data-content-pane table.data-content-pane__table { +.data-content-pane .data-content-pane__table { width: 100%; border-collapse: separate; border-spacing: 0; } -div.data-content-pane table.data-content-pane__table--root { +.data-content-pane .data-content-pane__table--root { table-layout: auto; } -div.data-content-pane .data-content-pane__row--root { +.data-content-pane .data-content-pane__row--root { display: flex; align-items: flex-start; } -div.data-content-pane .data-content-pane__row--root > td { - vertical-align: top; -} - -div.data-content-pane .data-content-pane__subject-cell { +.data-content-pane .data-content-pane__subject-cell { flex: 0 0 auto; - width: clamp(7rem, 12%, 10rem); - padding-right: 0.8rem; + width: clamp(160px, 18%, 240px); + padding-right: 12.8px; } -div.data-content-pane .data-content-pane__details-cell { +.data-content-pane .data-content-pane__details-cell { flex: 0 1 auto; min-width: 0; } -div.data-content-pane .data-content-pane__subject-cell, -div.data-content-pane td.data-content-pane__predicate-cell, -div.data-content-pane .data-content-pane__row--top-aligned > td:not(.data-content-pane__predicate-cell), -div.data-content-pane .data-content-pane__subject-cell a, -div.data-content-pane td.data-content-pane__predicate-cell a, -div.data-content-pane .data-content-pane__row--top-aligned > td:not(.data-content-pane__predicate-cell) a { +.data-content-pane .data-content-pane__subject-cell, +.data-content-pane .data-content-pane__predicate-cell, +.data-content-pane .data-content-pane__row--top-aligned > td:not(.data-content-pane__predicate-cell), +.data-content-pane .data-content-pane__subject-cell a, +.data-content-pane .data-content-pane__predicate-cell a, +.data-content-pane .data-content-pane__row--top-aligned > td:not(.data-content-pane__predicate-cell) a { white-space: normal; overflow-wrap: anywhere; word-break: break-word; } -div.data-content-pane table.data-content-pane__table--property { +.data-content-pane .data-content-pane__subject-cell, +.data-content-pane .data-content-pane__subject-cell a { + white-space: nowrap; + overflow-wrap: normal; + word-break: normal; +} + +.data-content-pane .data-content-pane__table--property { table-layout: auto; width: auto; max-width: 100%; } +.data-content-pane .data-content-pane__details-cell:has(.data-content-pane__nested-formula) { + flex: 1 1 0; +} + +.data-content-pane .data-content-pane__table--property:has(.data-content-pane__nested-formula) { + width: 100%; + table-layout: fixed; +} + .data-content-pane__nested-formula { - border-top: solid 1px var(--color-data-pane-border-top, black); - border-left: solid 1px var(--color-data-pane-border-top, black); - border-bottom: solid 1px var(--color-data-pane-border-side, #777); - border-right: solid 1px var(--color-data-pane-border-side, #777); - padding: var(--spacing-base, 0.5rem); - border-radius: var(--border-radius-md, 0.5rem); -} - -div.data-content-pane td { - padding-left: var(--spacing-xxxs, 0.2rem); - padding-top: var(--spacing-small, 0.1rem); - padding-right: var(--spacing-xxxs, 0.2rem); - padding-bottom: 0.05rem; - vertical-align: top; + display: block; + container-type: inline-size; + width: 100%; + max-width: 100%; + box-sizing: border-box; + border: 1px solid var(--solid-ui-color-gray-200, #cbd5e1); + padding: 8px; + border-radius: 8px; } -div.data-content-pane table.data-content-pane__table--property td { - padding-top: 0.3rem; - padding-bottom: 0.3rem; +.data-content-pane td, +.data-content-pane th { + padding: 1.6px 3.2px 0.8px; + vertical-align: top; } -div.data-content-pane tr { - margin-bottom: var(--spacing-2xs, 0.625rem); - padding-top: var(--spacing-small, 0.1rem); - padding-bottom: var(--spacing-small, 0.1rem); +.data-content-pane .data-content-pane__table--property td, +.data-content-pane .data-content-pane__table--property th { + padding-top: 4.8px; + padding-bottom: 4.8px; } -.data-content-pane a { - color: var(--color-text-link, #3b5998); - text-decoration: none; - font-weight: bold; +.data-content-pane tr { + margin-bottom: 10px; + padding-top: 1.6px; + padding-bottom: 1.6px; } +.data-content-pane a, .data-content-pane a:link { - color: var(--color-text-link, #3b5998); + color: var(--solid-ui-color-tertiary, #083575); text-decoration: none; - font-weight: bold; + font-weight: 600; } .data-content-pane a:visited { - color: var(--color-text-link-visited, #3b5998); - text-decoration: none; - font-weight: bold; + color: #3b5998; } .data-content-pane a:hover { - color: var(--color-text-link-hover, #3b5998); + color: var(--solid-ui-color-tertiary, #083575); text-decoration: underline; - font-weight: bold; } .data-content-pane a:active { - color: var(--color-text-link-active, #888); + color: var(--solid-ui-color-gray-500, #6a7282); text-decoration: none; } @@ -116,152 +124,206 @@ div.data-content-pane tr { white-space: pre-wrap; } -div.data-content-pane td.data-content-pane__predicate-cell { - min-width: 8.5rem; - width: clamp(8.5rem, 18vw, 12rem); - max-width: 12rem; - padding-right: var(--spacing-base, 0.5rem); +.data-content-pane .data-content-pane__predicate-cell { + min-width: 136px; + width: clamp(136px, 18vw, 192px); + max-width: 192px; + padding-right: 8px; + box-sizing: border-box; + background-color: inherit; +} + +.data-content-pane .data-content-pane__subject-cell { + background-color: inherit; } -div.data-content-pane .data-content-pane__row--top-aligned > td:not(.data-content-pane__predicate-cell) { - padding-left: var(--spacing-xxs, 0.3125rem); +.data-content-pane .data-content-pane__row--top-aligned > td:not(.data-content-pane__predicate-cell) { + padding-left: 5px; } -div.data-content-pane td.data-content-pane__predicate-cell a { - color: var(--color-text-muted, #444); +.data-content-pane .data-content-pane__predicate-cell a { + color: var(--solid-ui-color-gray-600, #4a5565); } -.data-content-pane__row--even { +.data-content-pane__row--even, +.data-content-pane__nested-table--dark { background-color: var(--color-background-row-alternate, #f0f0f0); } -.data-content-pane__row--odd { +.data-content-pane__row--odd, +.data-content-pane__nested-table--light { + background-color: var(--color-background-row-default, white); +} + +.data-content-pane .data-content-pane__table--property > tbody > tr:nth-child(odd), +.data-content-pane .data-content-pane__table--property > tr:nth-child(odd) { background-color: var(--color-background-row-default, white); } +.data-content-pane .data-content-pane__table--property > tbody > tr:nth-child(even), +.data-content-pane .data-content-pane__table--property > tr:nth-child(even) { + background-color: var(--color-background-row-alternate, #f0f0f0); +} + .data-content-pane__row--top-aligned { vertical-align: top; - margin-top: 0; - margin-bottom: 0; - padding-top: 0; - padding-bottom: 0; + margin: 0; + padding: 0; } -.data-content-pane__nested-table--light { - background-color: var(--color-background-row-default, white); +@container (max-width: 560px) { + .data-content-pane .data-content-pane__nested-formula .data-content-pane__row--root, + .data-content-pane .data-content-pane__nested-formula .data-content-pane__table--property, + .data-content-pane .data-content-pane__nested-formula .data-content-pane__table--property > tbody, + .data-content-pane .data-content-pane__nested-formula .data-content-pane__row--property { + display: block; + width: 100%; + box-sizing: border-box; + } + + .data-content-pane .data-content-pane__nested-formula .data-content-pane__subject-cell, + .data-content-pane .data-content-pane__nested-formula .data-content-pane__subject-cell a, + .data-content-pane .data-content-pane__nested-formula .data-content-pane__details-cell, + .data-content-pane .data-content-pane__nested-formula .data-content-pane__predicate-cell, + .data-content-pane .data-content-pane__nested-formula .data-content-pane__value-cell { + display: block; + width: 100%; + min-width: 0; + max-width: none; + box-sizing: border-box; + white-space: normal; + overflow-wrap: anywhere; + } } -.data-content-pane__nested-table--dark { - background-color: var(--color-background-row-alternate, #f0f0f0); +.data-content-pane[data-layout='mobile'] .data-content-pane__row--root { + display: block; + padding-bottom: 12px; } -div.data-content-pane[data-layout='mobile'] .data-content-pane__row--root { - display: flex; - align-items: flex-start; - padding-bottom: var(--spacing-xs, 0.75rem); +.data-content-pane[data-layout='mobile'] { + padding-left: 0; + padding-right: 0; } -div.data-content-pane[data-layout='mobile'] .data-content-pane__subject-cell { - flex: 0 0 40%; - width: 40%; - max-width: 40%; +.data-content-pane[data-layout='mobile'] .data-content-pane__subject-cell { + display: block; + width: 100%; + max-width: 100%; box-sizing: border-box; - padding-right: var(--spacing-xs, 0.75rem); + padding-right: 0; padding-bottom: 0; + white-space: normal; + overflow-wrap: anywhere; + word-break: break-word; } -div.data-content-pane[data-layout='mobile'] .data-content-pane__details-cell { - flex: 0 0 60%; - width: 60%; - max-width: 60%; +.data-content-pane[data-layout='mobile'] .data-content-pane__details-cell { + display: block; + width: 100%; + max-width: 100%; min-width: 0; box-sizing: border-box; } -div.data-content-pane[data-layout='mobile'] table.data-content-pane__table--property > tbody > tr, -div.data-content-pane[data-layout='mobile'] table.data-content-pane__table--property > tr { +.data-content-pane[data-layout='mobile'] .data-content-pane__table--property > tbody > tr, +.data-content-pane[data-layout='mobile'] .data-content-pane__table--property > tr { margin-bottom: 0; } -div.data-content-pane[data-layout='mobile'] .data-content-pane__row--top-aligned + .data-content-pane__row--top-aligned { - margin-top: 0; -} - -div.data-content-pane[data-layout='mobile'] .data-content-pane__row--top-aligned { +.data-content-pane[data-layout='mobile'] .data-content-pane__row--top-aligned { display: block; margin-bottom: 0; padding-top: 0; padding-bottom: 0; } -div.data-content-pane[data-layout='mobile'] table.data-content-pane__table--property, -div.data-content-pane[data-layout='mobile'] table.data-content-pane__table--property > tbody { +.data-content-pane[data-layout='mobile'] .data-content-pane__table--property, +.data-content-pane[data-layout='mobile'] .data-content-pane__table--property > tbody { display: block; width: 100%; } -div.data-content-pane[data-layout='mobile'] table.data-content-pane__table--property td { +.data-content-pane[data-layout='mobile'] .data-content-pane__table--property td { display: block; width: 100%; box-sizing: border-box; } -div.data-content-pane[data-layout='mobile'] table.data-content-pane__table--property td.data-content-pane__predicate-cell { +.data-content-pane[data-layout='mobile'] .data-content-pane__table--property .data-content-pane__predicate-cell { + display: block; width: 100%; min-width: 0; - padding-bottom: 0.1rem; + padding-bottom: 1.6px; } -div.data-content-pane[data-layout='mobile'] table.data-content-pane__table--property td:not(.data-content-pane__predicate-cell) { +.data-content-pane[data-layout='mobile'] .data-content-pane__table--property td:not(.data-content-pane__predicate-cell) { padding-top: 0; - padding-left: 0.85rem; + padding-left: 13.6px; } -@media (max-width: 700px) { - div.data-content-pane .data-content-pane__row--root { - display: flex; - align-items: flex-start; +@media (max-width: 768px) { + .data-content-pane .data-content-pane__nested-formula .data-content-pane__table--property, + .data-content-pane .data-content-pane__nested-formula .data-content-pane__table--property > tbody { + display: block; + width: 100%; + } + + .data-content-pane { + font-size: 14px; + padding-left: 0; + padding-right: 0; + border: none; } - div.data-content-pane .data-content-pane__subject-cell { - flex: 0 0 40%; - width: 40%; - max-width: 40%; - padding-right: var(--spacing-xs, 0.75rem); + .data-content-pane .data-content-pane__row--root { + display: block; + } + + .data-content-pane .data-content-pane__subject-cell { + display: block; + width: 100%; + max-width: 100%; + padding-right: 0; padding-bottom: 0; box-sizing: border-box; } - div.data-content-pane .data-content-pane__details-cell { - flex: 0 0 60%; - width: 60%; - max-width: 60%; + .data-content-pane .data-content-pane__subject-cell a { + white-space: normal; + overflow-wrap: anywhere; + word-break: break-word; + } + + .data-content-pane .data-content-pane__details-cell { + display: block; + width: 100%; + max-width: 100%; box-sizing: border-box; } - div.data-content-pane .data-content-pane__row--top-aligned { + .data-content-pane .data-content-pane__row--top-aligned { display: block; - margin-top: 0; - margin-bottom: 0; - padding-top: 0; - padding-bottom: 0; + margin: 0; + padding: 0; } - div.data-content-pane .data-content-pane__row--top-aligned > td { + .data-content-pane .data-content-pane__row--top-aligned > td, + .data-content-pane .data-content-pane__row--top-aligned > th { display: block; width: 100%; box-sizing: border-box; } - div.data-content-pane .data-content-pane__row--top-aligned > td.data-content-pane__predicate-cell { + .data-content-pane .data-content-pane__row--top-aligned > .data-content-pane__predicate-cell { min-width: 0; max-width: none; width: 100%; - padding-bottom: var(--spacing-small, 0.1rem); + padding-bottom: 1.6px; } - div.data-content-pane .data-content-pane__row--top-aligned > td:not(.data-content-pane__predicate-cell) { + .data-content-pane .data-content-pane__row--top-aligned > td:not(.data-content-pane__predicate-cell) { padding-top: 0; - padding-left: 0.85rem; + padding-left: 13.6px; } } diff --git a/src/dataContentPane.ts b/src/dataContentPane.ts index 085df2f2..8c552449 100644 --- a/src/dataContentPane.ts +++ b/src/dataContentPane.ts @@ -9,8 +9,8 @@ // - Expand automatically all the way down // - original source view? Use ffox view source -import * as UI from 'solid-ui' -import * as $rdf from 'rdflib' +import { icons, log, ns, utils, widgets } from 'solid-ui' +import { Serializer } from 'rdflib' import DOMPurify from 'dompurify' import type { DataBrowserContext, RenderEnvironment } from 'pane-registry' import type { @@ -21,8 +21,6 @@ import type { } from 'rdflib' import './dataContentPane.css' -const ns = UI.ns - type SubjectTerm = NamedNode | BlankNode type ObjectTerm = Statement['object'] | Formula @@ -40,8 +38,24 @@ type DataContentPaneLike = { ) => HTMLTableElement } +let renderInstanceId = 0 + +function openDataContentLink (event: Event): void { + const mouseEvent = event as MouseEvent + if (mouseEvent.metaKey || mouseEvent.ctrlKey || mouseEvent.shiftKey || mouseEvent.altKey) return + const documentWithOutline = typeof document !== 'undefined' + ? document as typeof document & { outlineManager?: unknown } + : undefined + const hasOutlineManager = !!documentWithOutline?.outlineManager + const hasPaneOutliner = typeof window !== 'undefined' && + typeof (window as Window & { panes?: { getOutliner?: () => unknown } }).panes?.getOutliner === 'function' + if (hasOutlineManager || hasPaneOutliner) { + widgets.openHrefInOutlineMode(event) + } +} + export const dataContentPane = { - icon: UI.icons.originalIconBase + 'rdf_flyer.24.gif', + icon: icons.originalIconBase + 'rdf_flyer.24.gif', name: 'dataContents', @@ -63,31 +77,32 @@ export const dataContentPane = { if (n === 0) return null return 'Data (' + n + ')' }, - /* - shouldGetFocus: function(subject) { - return store.whether(subject, UI.ns.rdf('type'), UI.ns.link('RDFDocument')) - }, -*/ statementsAsTables: function statementsAsTables ( sts: Statement[], context: DataBrowserContext, initialRoots?: SubjectTerm[] ): HTMLTableElement { const myDocument = context.dom - // const outliner = context.getOutliner(myDocument) const rep = myDocument.createElement('table') rep.classList.add('data-content-pane__table', 'data-content-pane__table--root') const isMobileLayout = context.environment?.layout === 'mobile' - const sz = $rdf.Serializer(context.session.store) + const sz = Serializer(context.session.store) const res = sz.rootSubjects(sts) as RootSubjectsResult let roots = res.roots const subjects = res.subjects const loopBreakers = res.loopBreakers ?? {} for (const x in loopBreakers) { - console.log('\tdataContentPane: loopbreaker:' + x) + log.debug('\tdataContentPane: loopbreaker:' + x) } const doneBnodes: Record = {} const referencedBnodes: Record = {} + const renderId = ++renderInstanceId + let cellId = 0 + + function nextCellId (prefix: string): string { + cellId++ + return `data-content-${renderId}-${prefix}-${cellId}` + } function propertyTree ( subject: SubjectTerm, @@ -95,6 +110,7 @@ export const dataContentPane = { ): HTMLTableElement { const rep = myDocument.createElement('table') rep.classList.add('data-content-pane__table', 'data-content-pane__table--property') + rep.setAttribute('aria-label', 'Properties') let lastPred: string | null = null const subjectStatements = subjects[sz.toStr(subject)] if (!subjectStatements) { @@ -112,18 +128,16 @@ export const dataContentPane = { if (!isMobileLayout && lastPred && same > 1) { predicateTD?.setAttribute('rowspan', '' + same) } - predicateTD = myDocument.createElement('td') + predicateTD = myDocument.createElement('th') predicateTD.setAttribute('class', 'data-content-pane__predicate-cell') + predicateTD.setAttribute('scope', 'row') + predicateTD.id = nextCellId('predicate') const anchor = myDocument.createElement('a') anchor.setAttribute('href', st.predicate.uri) - anchor.addEventListener( - 'click', - UI.widgets.openHrefInOutlineMode, - true - ) + anchor.addEventListener('click', openDataContentLink, true) anchor.appendChild( myDocument.createTextNode( - UI.utils.predicateLabelForXML(st.predicate) + utils.predicateLabelForXML(st.predicate) ) ) predicateTD.appendChild(anchor) @@ -134,6 +148,7 @@ export const dataContentPane = { same++ const objectTD = myDocument.createElement('td') objectTD.classList.add('data-content-pane__value-cell') + objectTD.setAttribute('headers', predicateTD?.id ?? '') objectTD.appendChild(objectTree(st.object, nestingLevel + 1)) tr.appendChild(objectTD) rep.appendChild(tr) @@ -151,19 +166,16 @@ export const dataContentPane = { case 'NamedNode': anchor = myDocument.createElement('a') anchor.setAttribute('href', obj.uri) - anchor.addEventListener( - 'click', - UI.widgets.openHrefInOutlineMode, - true - ) - anchor.appendChild(myDocument.createTextNode(UI.utils.label(obj))) + anchor.addEventListener('click', openDataContentLink, true) + anchor.appendChild(myDocument.createTextNode(utils.label(obj))) return anchor case 'Literal': - if (!obj.datatype || !obj.datatype.uri) { + if (obj.language || !obj.datatype || !obj.datatype.uri) { res = myDocument.createElement('div') res.classList.add('data-content-pane__literal') res.textContent = obj.value + if (obj.language) res.setAttribute('lang', obj.language) return res } else if ( obj.datatype.uri === @@ -171,6 +183,8 @@ export const dataContentPane = { ) { res = myDocument.createElement('div') res.classList.add('embeddedXHTML') + res.setAttribute('role', 'group') + res.setAttribute('aria-label', 'Embedded HTML content') res.innerHTML = DOMPurify.sanitize(obj.value) return res } @@ -182,6 +196,10 @@ export const dataContentPane = { const referenceAnchor = myDocument.createElement('a') referenceAnchor.setAttribute('href', '#' + obj.toNT().slice(2)) referenceAnchor.setAttribute('class', 'bnodeRef') + referenceAnchor.setAttribute( + 'aria-label', + `Referenced blank node ${obj.toNT().slice(3)}` + ) referenceAnchor.textContent = '*' + obj.toNT().slice(3) return referenceAnchor } @@ -197,12 +215,12 @@ export const dataContentPane = { } case 'Collection': - res = myDocument.createElement('table') + res = myDocument.createElement('ol') res.setAttribute('class', 'collectionAsTables') for (let i = 0; i < obj.elements.length; i++) { - const tr = myDocument.createElement('tr') - res.appendChild(tr) - tr.appendChild(objectTree(obj.elements[i] as ObjectTerm, nestingLevel + 1)) + const item = myDocument.createElement('li') + item.appendChild(objectTree(obj.elements[i] as ObjectTerm, nestingLevel + 1)) + res.appendChild(item) } return res @@ -210,7 +228,7 @@ export const dataContentPane = { res = (context.session.paneRegistry .byName('dataContents') as DataContentPaneLike) .statementsAsTables(obj.statements, context) - res.setAttribute('class', 'data-content-pane__nested-formula') + res.classList.add('data-content-pane__nested-formula') return res case 'Variable': @@ -236,15 +254,18 @@ export const dataContentPane = { 'data-content-pane__row--root' ) rep.appendChild(tr) - const subjectTD = myDocument.createElement('td') + const subjectTD = myDocument.createElement('th') subjectTD.classList.add('data-content-pane__subject-cell') + subjectTD.setAttribute('scope', 'row') + subjectTD.id = nextCellId('subject') tr.appendChild(subjectTD) const TDTree = myDocument.createElement('td') TDTree.classList.add('data-content-pane__details-cell') + TDTree.setAttribute('headers', subjectTD.id) tr.appendChild(TDTree) const root = roots[i] if (root.termType === 'BlankNode') { - subjectTD.appendChild(myDocument.createTextNode(UI.utils.label(root))) + subjectTD.appendChild(myDocument.createTextNode(utils.label(root))) } else { subjectTD.appendChild(objectTree(root, 0)) } @@ -253,11 +274,15 @@ export const dataContentPane = { for (const bNT in referencedBnodes) { const table = doneBnodes[bNT] if (table === true) continue + const caption = myDocument.createElement('caption') const anchor = myDocument.createElement('a') anchor.setAttribute('id', bNT.slice(2)) + anchor.setAttribute('tabindex', '-1') anchor.setAttribute('class', 'bnodeDef') + anchor.setAttribute('aria-label', `Blank node ${bNT.slice(3)}`) anchor.textContent = bNT.slice(3) + ')' - table.insertBefore(anchor, table.firstChild) + caption.appendChild(anchor) + table.insertBefore(caption, table.firstChild) } return rep }, @@ -282,16 +307,16 @@ export const dataContentPane = { if (kb.holds(subject, undefined, undefined, subject)) { initialRoots.push(subject) } - const ps = kb.any(subject, UI.ns.foaf('primaryTopic'), undefined, subject) + const ps = kb.any(subject, ns.foaf('primaryTopic'), undefined, subject) if (ps && (ps.termType === 'NamedNode' || ps.termType === 'BlankNode')) { initialRoots.push(ps as SubjectTerm) } - div.appendChild( - context.session.paneRegistry - .byName('dataContents') - .statementsAsTables(sts, context, initialRoots) - ) + const table = context.session.paneRegistry + .byName('dataContents') + .statementsAsTables(sts, context, initialRoots) + table.setAttribute('aria-label', `Data content for ${utils.label(subject)}`) + div.appendChild(table) } const div = myDocument.createElement('div') diff --git a/src/defaultPane.css b/src/defaultPane.css index bbb216a5..5b885910 100644 --- a/src/defaultPane.css +++ b/src/defaultPane.css @@ -15,15 +15,23 @@ border: 1px solid var(--solid-ui-color-gray-200, #cbd5e1); padding: var(--spacing-base, 0.5rem); margin-bottom: var(--spacing-base, 0.5rem); + min-height: 0; + overflow: auto; + box-sizing: border-box; } -.defaultPane > tr { +/* composeExplorer adds paneDiv to this element after the pane renders. */ +.paneDiv.defaultPane { + padding-inline: 40px; +} + +.defaultPane > div { display: grid; grid-template-columns: minmax(0, var(--default-pane-predicate-column)) minmax(0, 1fr); align-items: flex-start; } -.defaultPane > tr > td.pred { +.defaultPane > div > div.pred { grid-column: 1; display: flex; align-items: flex-start; @@ -32,7 +40,7 @@ min-width: 0; } -.defaultPane > tr > td.pred > .labelTD { +.defaultPane > div > div.pred > .labelTD { flex: 1 1 auto; min-width: 0; margin: 0; @@ -40,61 +48,71 @@ padding-bottom: 0; } -.defaultPane > tr > td.pred > .iconTD { +.defaultPane > div > div.pred > .iconTD { flex: 0 0 auto; width: auto; margin: 0; } -.defaultPane > tr > td.obj { +.defaultPane > div > div.obj { grid-column: 2; min-width: 0; box-sizing: border-box; align-self: start; } -.defaultPane > tr > td[colspan='2'] { +.defaultPane > div > div[colspan='2'] { grid-column: 1 / -1; } -.defaultPane[data-layout='mobile'] > tr { +.defaultPane[data-layout='mobile'] > div { grid-template-columns: minmax(0, 1fr); } -.defaultPane[data-layout='mobile'] > tr > td.pred, -.defaultPane[data-layout='mobile'] > tr > td.obj { +.paneDiv.defaultPane[data-layout='mobile'] { + padding-left: 0; + padding-right: 0; +} + +.defaultPane[data-layout='mobile'] > div > div.pred, +.defaultPane[data-layout='mobile'] > div > div.obj { display: block; grid-column: 1; width: 100%; box-sizing: border-box; } -.defaultPane[data-layout='mobile'] > tr > td.pred { +.defaultPane[data-layout='mobile'] > div > div.pred { padding-bottom: var(--spacing-small, 0.1rem); } -.defaultPane[data-layout='mobile'] > tr > td.obj { +.defaultPane[data-layout='mobile'] > div > div.obj { padding-left: var(--default-pane-object-indent) !important; } @media (max-width: 700px) { - .defaultPane > tr { + .paneDiv.defaultPane { + padding-left: 0; + padding-right: 0; + } + + .defaultPane > div { grid-template-columns: minmax(0, 1fr); } - .defaultPane > tr > td.pred, - .defaultPane > tr > td.obj { + .defaultPane > div > div.pred, + .defaultPane > div > div.obj { display: block; grid-column: 1; width: 100%; box-sizing: border-box; } - .defaultPane > tr > td.pred { + .defaultPane > div > div.pred { padding-bottom: var(--spacing-small, 0.1rem); } - .defaultPane > tr > td.obj { + .defaultPane > div > div.obj { padding-left: var(--default-pane-object-indent) !important; } } diff --git a/src/dokieli/dokieliPane.js b/src/dokieli/dokieliPane.js index 46cf0488..4c5d2ca1 100644 --- a/src/dokieli/dokieliPane.js +++ b/src/dokieli/dokieliPane.js @@ -59,27 +59,17 @@ export default { '

' + encodedTitle + '

' ) // console.log('@@ New HTML for Dok:' + htmlContents) - return new Promise(function (resolve) { - kb.fetcher - .webOperation('PUT', newInstance.uri, { - data: htmlContents, - contentType: 'text/html' - }) - .then(function () { - console.log( - 'new Dokieli document created at ' + newPaneOptions.newInstance - ) - resolve(newPaneOptions) - }) - .catch(function (err) { - console.log( - 'Error creating dokieli doc at ' + - newPaneOptions.newInstance + - ': ' + - err - ) - }) - }) + return kb.fetcher + .webOperation('PUT', newInstance.uri, { + data: htmlContents, + contentType: 'text/html' + }) + .then(function () { + console.log( + 'new Dokieli document created at ' + newPaneOptions.newInstance + ) + return newPaneOptions + }) } // render: removed - now handled by humanReadablePane with appropriate dokieli icon diff --git a/src/humanReadablePane.css b/src/humanReadablePane.css index 0a129b17..c4c82adc 100644 --- a/src/humanReadablePane.css +++ b/src/humanReadablePane.css @@ -1,25 +1,37 @@ .human-readable-pane { - display: block; + display: flex; + flex-direction: column; + flex: 1 1 auto; + height: 100%; + padding: 0 40px; + margin: 0; + min-height: 0; min-width: 0; width: 100%; max-width: 100%; box-sizing: border-box; + overflow: auto; } .human-readable-pane__container { - display: block; + display: flex; + flex: 1 1 auto; + flex-direction: column; + min-height: 0; min-width: 0; width: 100%; max-width: 100%; + margin: 0; + padding: 0; box-sizing: border-box; overflow-x: hidden; } .human-readable-pane__frame { display: block; - border: 1px solid var(--solid-ui-color-gray-200, #cbd5e1); + border: 1px solid var(--solid-ui-color-slate-200, #E2E8F0); padding: 1rem; - height: var(--human-readable-pane-height, 30rem); + height: var(--human-readable-pane-height, 480px); min-width: 0; max-width: 100%; width: 100%; @@ -28,15 +40,57 @@ overflow: auto; } +.human-readable-pane__frame--markdown, +.human-readable-pane__frame--plain-text { + flex: 1 1 auto; + height: auto; + min-height: 100%; + max-height: 100%; + resize: none; +} + .human-readable-pane__frame--iframe { + display: block; padding: 0; overflow: hidden; width: 100%; max-width: 100%; - min-height: 18rem; + min-height: 0; + box-sizing: border-box; background: var(--color-background, white); } +/* Webpages, PDFs and video fill the pane; the framed document scrolls internally. */ +/* Iframe panes fill the explorer and scroll inside the bordered frame, not the pane. */ +.human-readable-pane--iframe, +solid-ui-file-explorer-provider > .paneDiv.human-readable-pane--iframe { + display: flex; + flex: 1 1 0%; + height: 100%; + min-height: 0; + overflow: visible; +} + +.human-readable-pane__container--iframe { + flex: 1 1 auto; + display: flex; + flex-direction: column; + min-height: 0; +} + +.human-readable-pane__container--iframe > .human-readable-pane__frame--iframe { + flex: 1 1 auto; + height: 480px; + min-height: 288px; + resize: none; +} + +.human-readable-pane__frame--markdown, +.human-readable-pane__frame--plain-text { + overflow: visible; + max-height: none; +} + .human-readable-pane__frame--markdown { overflow-wrap: anywhere; word-break: break-word; @@ -95,6 +149,16 @@ min-width: 0; } +.human-readable-pane[data-layout='mobile'] .human-readable-pane__frame--markdown, +.human-readable-pane[data-layout='mobile'] .human-readable-pane__frame--plain-text { + min-height: 100%; + max-height: none; +} + +.human-readable-pane[data-layout='mobile'] { + padding: 0; +} + .human-readable-pane[data-layout='mobile'] .human-readable-pane__frame--markdown, .human-readable-pane[data-layout='mobile'] .human-readable-pane__frame--plain-text { overflow-wrap: anywhere; @@ -104,11 +168,16 @@ .human-readable-pane[data-layout='mobile'] .human-readable-pane__frame--iframe { width: 100%; max-width: 100%; - min-height: 16rem; - height: min(var(--human-readable-pane-height, 30rem), 75vh); + flex: 0 0 auto; + min-height: 100vh; + height: 100vh; } @media (max-width: 576px) { + .human-readable-pane { + padding: 0; + } + .human-readable-pane__frame { padding: 0.75rem; resize: none; @@ -124,7 +193,8 @@ .human-readable-pane__frame--iframe { width: 100%; max-width: 100%; - min-height: 16rem; - height: min(var(--human-readable-pane-height, 30rem), 75vh); + flex: 0 0 auto; + min-height: 100vh; + height: 100vh; } } diff --git a/src/humanReadablePane.ts b/src/humanReadablePane.ts index 49fed334..0c2eba4a 100644 --- a/src/humanReadablePane.ts +++ b/src/humanReadablePane.ts @@ -5,12 +5,21 @@ */ import { icons, ns } from 'solid-ui' import { Util } from 'rdflib' +import { authn } from 'solid-logic' import { marked } from 'marked' import DOMPurify from 'dompurify' import type { DataBrowserContext, RenderEnvironment } from 'pane-registry' import type { NamedNode } from 'rdflib' import './humanReadablePane.css' +function viewerWebId (): string | null { + try { + return authn.currentUser()?.value ?? null + } catch { + return null + } +} + // Helper function to check if a URI has a markdown file extension type DokieliCacheValue = 'dokieli' | 'html' @@ -29,18 +38,707 @@ const isMarkdownFile = (uri?: string | null): boolean => { return /\.(md|markdown|mdown|mkd|mkdn)$/i.test(path) } +const isJsonFile = (uri?: string | null): boolean => { + if (!uri) return false + const path = uri.split('?')[0].split('#')[0] + return /\.json$/i.test(path) +} + // Cache for dokieli detection results (keyed by subject URI) const dokieliCache = new Map() function applyFrameClasses ( frame: HTMLElement, modifier: 'markdown' | 'plain-text' | 'iframe', - lines: number + lines?: number ): void { frame.className = '' frame.classList.add('human-readable-pane__frame') frame.classList.add(`human-readable-pane__frame--${modifier}`) - frame.style.setProperty('--human-readable-pane-height', `${lines}em`) + if (lines !== undefined) { + frame.style.setProperty('--human-readable-pane-height', `${lines * 16}px`) + } +} + +// window.name of preview iframes; initMainPage refuses to boot SolidOS inside such a frame. +export const HUMAN_READABLE_PREVIEW_FRAME_NAME = 'solidos-human-readable-preview' + +// Scripts may run but get an opaque origin, so previewed pages cannot reach the SolidOS session. +const HTML_PREVIEW_SANDBOX = 'allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-modals' + +const isDokieliHtml = (text: string): boolean => + text.includes('` + const withScript = html.replace(/<\/body\s*>/i, `${script}$&`) + return withScript === html ? `${html}${script}` : withScript +} + +function resourceFilename (uri: string): string { + const encodedFilename = uri.split('/').pop() || uri + try { + return decodeURIComponent(encodedFilename) + } catch { + return encodedFilename + } +} + +function documentTitle (html: string, uri: string): string { + const fallback = resourceFilename(uri) + try { + const title = new DOMParser().parseFromString(html, 'text/html').querySelector('title')?.textContent?.trim() + return title || fallback + } catch { + return fallback + } +} + +type PreviewRequest = { + type: 'solidos-preview-request' + nonce: string + id: string + url: string + method: string + headers?: Record + body?: string +} + +type PreviewResponse = { + type: 'solidos-preview-response' + nonce: string + id: string + ok: boolean + status: number + headers: Array<[string, string]> + body: string + error?: string +} + +const PREVIEW_REQUEST_TYPE = 'solidos-preview-request' +const PREVIEW_RESPONSE_TYPE = 'solidos-preview-response' +const PREVIEW_BRIDGE_ATTRIBUTE = 'data-solidos-preview-bridge' +const PREVIEW_READ_METHODS = new Set(['GET', 'HEAD']) +const PREVIEW_WRITE_METHODS = new Set(['PUT', 'PATCH', 'DELETE']) + +function stripPreviewBridgeScripts (html: string | undefined): string | undefined { + if (typeof html !== 'string' || !html.includes(PREVIEW_REQUEST_TYPE)) return html + + const parsed = new DOMParser().parseFromString(html, 'text/html') + let removed = false + for (const script of parsed.querySelectorAll('script')) { + const source = script.textContent || '' + const isPreviewBridge = script.hasAttribute(PREVIEW_BRIDGE_ATTRIBUTE) || + ( + source.includes(PREVIEW_REQUEST_TYPE) && + source.includes(PREVIEW_RESPONSE_TYPE) && + source.includes('const pending = new Map()') + ) + if (isPreviewBridge) { + script.remove() + removed = true + } + } + if (!removed) return html + + const doctype = html.match(/]*>/i)?.[0] + return `${doctype ? `${doctype}\n` : ''}${parsed.documentElement.outerHTML}` +} + +function isSrcdocUrl (url: string): boolean { + return url === 'about:srcdoc' || /^file:\/\/srcdoc\/?(?:[?#].*)?$/i.test(url) +} + +export function previewRequestUrl (url: string, documentUri: string): string { + const resolvedUrl = new URL(url, documentUri).href + return isSrcdocUrl(resolvedUrl) ? documentUri : resolvedUrl +} + +function profileDocumentUrl (webId: string | null | undefined): string | undefined { + if (!webId) return undefined + try { + const url = new URL(webId) + url.hash = '' + return url.href + } catch { + return undefined + } +} + +export function isAllowedPreviewRequest ( + url: string, + method: string, + documentUri: string, + webId: string | null = null +): boolean { + let resolvedUrl: URL + let expectedUrl: URL + try { + resolvedUrl = new URL(previewRequestUrl(url, documentUri)) + expectedUrl = new URL(documentUri) + } catch { + return false + } + + if (resolvedUrl.origin !== expectedUrl.origin) { + return false + } + + const normalizedMethod = method.toUpperCase() + const requestedDocument = new URL(resolvedUrl.href) + requestedDocument.hash = '' + const expectedDocument = new URL(expectedUrl.href) + expectedDocument.hash = '' + const isPreviewDocument = requestedDocument.href === expectedDocument.href + const isExactPreviewDocument = resolvedUrl.href === expectedUrl.href + // Path-based pods keep the viewer profile below the pod path, e.g. /alice/profile/card. + const isApprovedProfileResource = resolvedUrl.pathname === '/profile/card' || + requestedDocument.href === profileDocumentUrl(webId) + return ( + PREVIEW_READ_METHODS.has(normalizedMethod) && + (isPreviewDocument || isApprovedProfileResource) + ) || (isExactPreviewDocument && PREVIEW_WRITE_METHODS.has(normalizedMethod)) +} + +function createPreviewBridge (html: string, uri: string, nonce: string, webId: string | null = null): string { + const bridge = `` + const cleanHtml = stripPreviewBridgeScripts(html) ?? html + return withBaseHref(cleanHtml, uri).replace(/]*)?>/i, match => `${match}${bridge}`) +} + +function mountDokieliBridge ( + frame: HTMLIFrameElement, + uri: string, + html: string, + authenticatedFetch: (url: string, init?: RequestInit) => Promise, + webId: string | null = null +): void { + const ownerWindow = frame.ownerDocument.defaultView + if (!ownerWindow) return + + const randomValues = new Uint32Array(4) + ownerWindow.crypto.getRandomValues(randomValues) + const nonce = Array.from(randomValues, value => value.toString(16)).join('-') + const expectedUri = new URL(uri).href + const listener = (event: MessageEvent) => { + const request = event.data + if ( + event.source !== frame.contentWindow || + !request || + request.type !== PREVIEW_REQUEST_TYPE || + request.nonce !== nonce + ) return + + const respond = (response: PreviewResponse) => { + frame.contentWindow?.postMessage(response, '*') + } + + // Always settle authenticated bridge requests. Dropping a denied request + // leaves the preview awaiting it forever (Dokieli then never leaves Loading…). + if (!isAllowedPreviewRequest(request.url, request.method, expectedUri, webId)) { + respond({ + type: PREVIEW_RESPONSE_TYPE, + nonce, + id: request.id, + ok: false, + status: 403, + headers: [], + body: '', + error: 'Request not permitted by the SolidOS preview' + }) + return + } + const requestUrl = previewRequestUrl(request.url, expectedUri) + + authenticatedFetch(requestUrl, { + method: request.method, + headers: request.headers, + body: PREVIEW_READ_METHODS.has(request.method) + ? undefined + : stripPreviewBridgeScripts(request.body) + }).then(async response => { + respond({ + type: PREVIEW_RESPONSE_TYPE, + nonce, + id: request.id, + ok: response.ok, + status: response.status, + headers: Array.from(response.headers.entries()), + body: await response.text() + }) + }).catch(error => { + respond({ + type: PREVIEW_RESPONSE_TYPE, + nonce, + id: request.id, + ok: false, + status: 0, + headers: [], + body: '', + error: error instanceof Error ? error.message : String(error) + }) + }) + } + + ownerWindow.addEventListener('message', listener) + frame.setAttribute('sandbox', HTML_PREVIEW_SANDBOX) + frame.srcdoc = createPreviewBridge(html, expectedUri, nonce, webId) +} + +function installPreviewAutoSize ( + frame: HTMLIFrameElement, + ownerWindow: Window +): () => void { + const onMessage = (event: MessageEvent<{ type?: string, height?: number }>) => { + const message = event.data + if ( + event.source !== frame.contentWindow || + message?.type !== 'solidos-preview-size' || + typeof message.height !== 'number' || + !Number.isFinite(message.height) + ) return + frame.style.height = `${Math.max(1, Math.ceil(message.height))}px` + frame.style.flexShrink = '0' + } + ownerWindow.addEventListener('message', onMessage) + return () => ownerWindow.removeEventListener('message', onMessage) } const humanReadablePane: HumanReadablePaneDefinition = { @@ -114,9 +812,8 @@ const humanReadablePane: HumanReadablePaneDefinition = { 'text/plain', 'text/html', 'text/markdown', + 'application/json', 'application/xhtml+xml', - 'image/png', - 'image/jpeg', 'application/pdf', 'video/mp4' ] @@ -210,7 +907,7 @@ const humanReadablePane: HumanReadablePaneDefinition = { // Fallback: detect markdown by file extension if content-type is not text/markdown const isMarkdown = ct === 'text/markdown' || isMarkdownFile(subject.uri) - const isPlainText = ct === 'text/plain' + const isPlainText = ct === 'text/plain' || ct === 'application/json' || (!ct && isJsonFile(subject.uri)) if (ct) { // console.log('humanReadablePane: c-t:' + ct) @@ -250,11 +947,6 @@ const humanReadablePane: HumanReadablePaneDefinition = { }) } - const setIframeAttributes = (frame: HTMLIFrameElement, lines: number) => { - frame.setAttribute('src', subject.uri) - applyFrameClasses(frame, 'iframe', lines) - } - if (isMarkdown) { // For markdown, use a DIV element and render the content const frame = myDocument.createElement('div') @@ -272,36 +964,104 @@ const humanReadablePane: HumanReadablePaneDefinition = { frameContainer.appendChild(frame) div.appendChild(frameContainer) } else { - // For other content types, use IFRAME + // For other content types, use IFRAME. + // The iframe's own request would be anonymous (Solid auth is not cookie based), so the + // content is fetched with the authenticated fetcher and handed to the frame directly. const frame = myDocument.createElement('iframe') + frame.name = HUMAN_READABLE_PREVIEW_FRAME_NAME + frame.title = resourceFilename(subject.uri) + applyFrameClasses(frame, 'iframe') + const ownerWindow = myDocument.defaultView + const removePreviewAutoSize = ownerWindow + ? installPreviewAutoSize(frame, ownerWindow) + : () => {} + const isHtml = ct === 'text/html' || ct === 'application/xhtml+xml' + let previewUrl: string | null = null + let disposed = false + let wasConnected = false + const mutationObserver = typeof MutationObserver === 'undefined' + ? null + : new MutationObserver(records => { + const wasAdded = records.some(record => + Array.from(record.addedNodes).some(node => + node === div || (node.nodeType === Node.ELEMENT_NODE && (node as Element).contains(div)) + ) + ) + if (div.isConnected) { + wasConnected = true + } else if (wasConnected || wasAdded) { + disposed = true + if (previewUrl) { + URL.revokeObjectURL(previewUrl) + previewUrl = null + } + removePreviewAutoSize() + mutationObserver?.disconnect() + } + }) + mutationObserver?.observe(myDocument, { childList: true, subtree: true }) - // Apply sandbox for HTML/XHTML - if (ct === 'text/html' || ct === 'application/xhtml+xml') { - frame.setAttribute('sandbox', 'allow-scripts allow-same-origin allow-forms') + const showError = (message: string) => { + frame.removeAttribute('src') + frame.setAttribute('sandbox', '') + frame.srcdoc = `

${escapeAttribute(message)}

` } - // Fetch content to calculate lines dynamically - kb.fetcher.webOperation('GET', subject.uri).then(response => { - const blobText = response.responseText ?? '' - const newLines = blobText.includes(''), + contentType: 'text/html' + }) + }) + + it('rejects when Dokieli cannot write its document', async () => { + const error = new Error('write failed') + const context = { + session: { + store: { + sym: (uri: string) => $rdf.sym(uri), + fetcher: { + webOperation: vi.fn().mockRejectedValue(error) + } + } + } + } + + await expect(dokieliPane.mintNew(context as any, { + newBase: 'https://pod.example/docs/' + })).rejects.toBe(error) + }) + + it('rejects immediately when schedule creation has no user', async () => { + vi.spyOn(authn, 'currentUser').mockReturnValue(null) + const alert = vi.spyOn(globalThis, 'alert').mockImplementation(() => {}) + + await expect(schedulePane.mintNew({ + session: { store: {} } + } as any, { + newBase: 'https://pod.example/schedule/' + })).rejects.toThrow('logged-in user') + + expect(alert).toHaveBeenCalledOnce() + alert.mockRestore() + }) + + it('rejects once and stops the schedule agenda after a data write fails', async () => { + const put = vi.fn((doc, statements, contentType, callback) => { + callback(doc.uri, false, 'write failed') + callback(doc.uri, false, 'write failed again') + }) + const context = { + session: { + store: { + sym: (uri: string) => $rdf.sym(uri), + add: vi.fn(), + statementsMatching: vi.fn().mockReturnValue([]), + any: vi.fn().mockReturnValue(null), + fetcher: { + webCopy: vi.fn(), + webOperation: vi.fn(), + load: vi.fn() + }, + updater: { put } + } + } + } + + await expect(schedulePane.mintNew(context as any, { + newBase: 'https://pod.example/schedule/', + noIndexHTML: true, + me: $rdf.sym('https://pod.example/profile#me') + })).rejects.toThrow('write failed') + + expect(put).toHaveBeenCalledOnce() + expect(context.session.store.fetcher.webOperation).not.toHaveBeenCalled() + }) + + it('rejects Pad minting when its resource write fails', async () => { + const store = { + updater: { + put: vi.fn((_doc, _statements, _contentType, callback) => { + const callbackFn = callback as any + callbackFn( + 'https://pod.example/pad/index.ttl', + false, + 'write failed' + ) + }) + }, + sym: (uri: string) => $rdf.sym(uri), + add: vi.fn(), + statementsMatching: vi.fn().mockReturnValue([]) + } + + await expect((padPane as any).mintNew({ + session: { store } + }, { + newBase: 'https://pod.example/pad/' + })).rejects.toThrow('write failed') + }) +}) diff --git a/test/unit/dataContentPane.test.ts b/test/unit/dataContentPane.test.ts new file mode 100644 index 00000000..b5d8aecc --- /dev/null +++ b/test/unit/dataContentPane.test.ts @@ -0,0 +1,166 @@ +import { describe, expect, it } from 'vitest' +import { Collection, graph, literal, namedNode, parse, sym } from 'rdflib' +import { dataContentPane } from '../../src/dataContentPane' + +function context (store: any) { + return { dom: document, session: { store } } as any +} + +describe('data content pane', () => { + it('preserves responsive table classes when rendering a nested formula', () => { + const store = graph() + parse( + '<#me> <#example> { <#item> <#label> "Nested formula example". }.', + store, 'https://pod.example/card', 'text/n3' + ) + const renderContext = context(store) + renderContext.session.paneRegistry = { byName: () => dataContentPane } + + const table = dataContentPane.statementsAsTables(store.statements, renderContext) + const formula = table.querySelector('.data-content-pane__nested-formula') + + expect(formula).toHaveClass('data-content-pane__table', 'data-content-pane__table--root') + expect(formula).toHaveTextContent('Nested formula example') + }) + + it('keeps header IDs unique across nested and separate renders', () => { + const store = graph() + const subject = namedNode('https://pod.example/item') + const predicate = namedNode('https://pod.example/name') + store.add(subject, predicate, literal('One')) + store.add( + subject, + namedNode('https://pod.example/example'), + store.formula([]) + ) + const renderContext = context(store) + renderContext.session.paneRegistry = { byName: () => dataContentPane } + + const first = dataContentPane.statementsAsTables( + store.statementsMatching(subject), + renderContext + ) + const second = dataContentPane.statementsAsTables( + store.statementsMatching(subject), + renderContext + ) + const ids = [ + ...first.querySelectorAll('[id]'), + ...second.querySelectorAll('[id]') + ].map(element => element.id) + + expect(new Set(ids).size).toBe(ids.length) + for (const valueCell of [ + ...first.querySelectorAll('[headers]'), + ...second.querySelectorAll('[headers]') + ]) { + expect(ids).toContain(valueCell.getAttribute('headers')) + } + }) + + it('exposes RDF relationships and literal language metadata', () => { + const store = graph() + const subject = sym('https://pod.example/item') + const predicate = sym('https://pod.example/name') + store.add(subject, predicate, literal('Bonjour', 'fr')) + store.add(subject, predicate, literal('Au revoir', 'fr')) + + const table = dataContentPane.statementsAsTables( + store.statementsMatching(subject), + context(store) + ) + const value = table.querySelector('.data-content-pane__value-cell') + const predicateHeader = table.querySelector('.data-content-pane__predicate-cell') + + expect(table.querySelector('th[scope="row"]')).toBeTruthy() + expect(predicateHeader).toBeTruthy() + expect(Array.from(table.querySelectorAll('[lang="fr"]')).map(node => node.textContent)) + .toEqual(expect.arrayContaining(['Bonjour', 'Au revoir'])) + expect(predicateHeader).toHaveAttribute('rowspan', '2') + expect(value?.getAttribute('headers')).toBe(predicateHeader?.id) + }) + + it('renders named nodes, collections, and nested blank nodes semantically', () => { + const store = graph() + const subject = namedNode('https://pod.example/item') + const related = namedNode('https://pod.example/related') + const nested = store.bnode('nested') + store.add(subject, namedNode('https://pod.example/links'), related) + store.add(subject, namedNode('https://pod.example/details'), nested) + store.add(subject, namedNode('https://pod.example/otherDetails'), nested) + store.add(nested, namedNode('https://pod.example/label'), literal('Nested')) + const collection = new Collection() + collection.append(related) + collection.append(literal('Second')) + store.add(subject, namedNode('https://pod.example/list'), collection) + + const table = dataContentPane.statementsAsTables( + store.statementsMatching(subject), + context(store) + ) + + expect(table.querySelector(`a[href="${related.uri}"]`)).toBeTruthy() + expect(table.querySelector('ol > li')).toBeTruthy() + expect(table.querySelector('table[aria-label="Properties"]')).toBeTruthy() + expect(table.querySelector('.bnodeDef[tabindex="-1"]')).toBeTruthy() + }) + + it('preserves sanitized XMLLiteral content and labels its embedded region', () => { + const store = graph() + const subject = namedNode('https://pod.example/item') + const xmlLiteral = literal( + '

Safe

Diagram', + namedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral') + ) + store.add(subject, namedNode('https://pod.example/content'), xmlLiteral) + + const table = dataContentPane.statementsAsTables( + store.statementsMatching(subject), + context(store) + ) + const embedded = table.querySelector('[role="group"]') + + expect(embedded).toHaveAttribute('aria-label', 'Embedded HTML content') + expect(embedded).toHaveTextContent('Safe') + expect(embedded?.querySelector('img')).toHaveAttribute('alt', 'Diagram') + expect(embedded?.querySelector('script')).toBeNull() + }) + + it('keeps links usable when no outline manager is available', () => { + const store = graph() + const subject = namedNode('https://pod.example/item') + const target = namedNode('https://pod.example/target') + store.add(subject, namedNode('https://pod.example/related'), target) + const table = dataContentPane.statementsAsTables( + store.statementsMatching(subject), + context(store) + ) + const link = table.querySelector(`a[href="${target.uri}"]`) as HTMLAnchorElement + const event = new MouseEvent('click', { bubbles: true, cancelable: true }) + + link.dispatchEvent(event) + + expect(event.defaultPrevented).toBe(false) + }) + + it('leaves modified clicks to native browser navigation', () => { + const store = graph() + const subject = namedNode('https://pod.example/item') + const target = namedNode('https://pod.example/target') + store.add(subject, namedNode('https://pod.example/related'), target) + const table = dataContentPane.statementsAsTables( + store.statementsMatching(subject), + context(store) + ) + const link = table.querySelector(`a[href="${target.uri}"]`) as HTMLAnchorElement + const event = new MouseEvent('click', { + bubbles: true, + cancelable: true, + ctrlKey: true + }) + + link.dispatchEvent(event) + + expect(event.defaultPrevented).toBe(false) + }) +}) diff --git a/test/unit/humanReadablePane.test.ts b/test/unit/humanReadablePane.test.ts new file mode 100644 index 00000000..3eac9fc7 --- /dev/null +++ b/test/unit/humanReadablePane.test.ts @@ -0,0 +1,427 @@ +import { describe, expect, it, vi } from 'vitest' +import { sym } from 'rdflib' +import { authn } from 'solid-logic' +import humanReadablePane, { + HUMAN_READABLE_PREVIEW_FRAME_NAME, + isAllowedPreviewRequest, + previewRequestUrl, + withBaseHref +} from '../../src/humanReadablePane' + +const uri = 'https://pod.example/docs/page.html' + +function renderWith (contentType: string, fetcher: Record) { + const subject = { uri, doc: () => subject } + const store = { + fetcher: { getHeader: vi.fn().mockReturnValue([contentType]), ...fetcher } + } + const context = { dom: document, session: { store } } as any + return humanReadablePane.render(subject as any, context) +} + +const flush = () => new Promise(resolve => setTimeout(resolve, 0)) + +describe('withBaseHref', () => { + it('inserts a base element at the start of head', () => { + expect(withBaseHref('x', uri)) + .toBe(`x`) + }) + + it('prepends a base element when there is no head', () => { + expect(withBaseHref('

hi

', uri)).toBe(`

hi

`) + }) + + it('keeps an existing base element', () => { + const html = '' + expect(withBaseHref(html, uri)).toBe(html) + }) + + it('resolves a relative existing base element against the resource URI', () => { + const html = '' + expect(withBaseHref(html, uri)) + .toBe('') + }) +}) + +describe('previewRequestUrl', () => { + it.each([ + 'about:srcdoc', + 'file://srcdoc/', + 'file://srcdoc', + 'file://srcdoc/?preview=1', + 'file://srcdoc/#preview' + ])('maps the srcdoc URL variant %s to the preview document', value => { + expect(previewRequestUrl(value, uri)).toBe(uri) + }) + + it('does not rewrite legitimate file URLs', () => { + expect(previewRequestUrl('file:///Users/example/document.html', uri)) + .toBe('file:///Users/example/document.html') + expect(previewRequestUrl('file://srcdoc/other.html', uri)) + .toBe('file://srcdoc/other.html') + }) +}) + +describe('isAllowedPreviewRequest', () => { + it('allows authenticated same-origin reads for related profile resources', () => { + expect(isAllowedPreviewRequest('https://pod.example/profile/card', 'GET', uri)).toBe(true) + expect(isAllowedPreviewRequest('https://pod.example/profile/card', 'HEAD', uri)).toBe(true) + }) + + it('allows the viewer profile document on path-based pods', () => { + const pathPodDocument = 'http://localhost:3100/alice/notes/doc.html' + const webId = 'http://localhost:3100/alice/profile/card#me' + expect(isAllowedPreviewRequest('http://localhost:3100/alice/profile/card', 'GET', pathPodDocument, webId)).toBe(true) + expect(isAllowedPreviewRequest('http://localhost:3100/alice/profile/card#me', 'GET', pathPodDocument, webId)).toBe(true) + expect(isAllowedPreviewRequest('http://localhost:3100/alice/profile/card', 'GET', pathPodDocument)).toBe(false) + expect(isAllowedPreviewRequest('http://localhost:3100/bob/profile/card', 'GET', pathPodDocument, webId)).toBe(false) + expect(isAllowedPreviewRequest('http://localhost:3100/alice/settings/prefs.ttl', 'GET', pathPodDocument, webId)).toBe(false) + expect(isAllowedPreviewRequest('http://localhost:3100/alice/profile/card', 'PUT', pathPodDocument, webId)).toBe(false) + }) + + it('allows writes only to the previewed document', () => { + expect(isAllowedPreviewRequest(uri, 'PUT', uri)).toBe(true) + expect(isAllowedPreviewRequest('https://pod.example/profile/card', 'PUT', uri)).toBe(false) + }) + + it('allows reads of the previewed document with a fragment', () => { + expect(isAllowedPreviewRequest(`${uri}#saved`, 'GET', uri)).toBe(true) + expect(isAllowedPreviewRequest(`${uri}#saved`, 'HEAD', uri)).toBe(true) + expect(isAllowedPreviewRequest(`${uri}#saved`, 'PUT', uri)).toBe(false) + }) + + it('blocks cross-origin reads', () => { + expect(isAllowedPreviewRequest('https://other.example/profile/card', 'GET', uri)).toBe(false) + expect(isAllowedPreviewRequest('https://pod.example/private/data', 'GET', uri)).toBe(false) + expect(isAllowedPreviewRequest('https://pod.example/profile/settings', 'GET', uri)).toBe(false) + }) +}) + +describe('human readable pane iframe rendering', () => { + it('renders JSON as readable text', async () => { + const webOperation = vi.fn().mockResolvedValue({ responseText: '{\n "enabled": true\n}' }) + const pane = renderWith('application/json', { webOperation }) + await flush() + + expect(pane.querySelector('pre')?.textContent).toBe('{\n "enabled": true\n}') + expect(pane.querySelector('iframe')).toBeNull() + expect(webOperation).toHaveBeenCalledWith('GET', uri) + }) + + it('renders HTML from the authenticated fetch instead of letting the iframe request it', async () => { + const webOperation = vi.fn().mockResolvedValue({ responseText: 'Hello' }) + const pane = renderWith('text/html', { webOperation }) + await flush() + + const frame = pane.querySelector('iframe')! + expect(webOperation).toHaveBeenCalledWith('GET', uri) + expect(frame.getAttribute('src')).toBeNull() + expect(frame.srcdoc).toContain('Hello') + expect(frame.srcdoc).toContain(``) + expect(frame.name).toBe(HUMAN_READABLE_PREVIEW_FRAME_NAME) + expect(frame.getAttribute('sandbox')).not.toContain('allow-same-origin') + expect(pane.classList.contains('human-readable-pane--iframe')).toBe(true) + expect(pane.querySelector('a')).toBeNull() + }) + + it('appends the resize script to HTML fragments without a closing body tag', async () => { + const pane = renderWith('text/html', { + webOperation: vi.fn().mockResolvedValue({ responseText: '
Fragment
' }) + }) + await flush() + + expect(pane.querySelector('iframe')?.srcdoc).toContain('solidos-preview-size') + }) + + it('labels an HTML iframe from its fetched title and falls back to its URI filename', async () => { + const titled = renderWith('text/html', { + webOperation: vi.fn().mockResolvedValue({ responseText: ' A useful title ' }) + }) + await flush() + expect(titled.querySelector('iframe')?.title).toBe('A useful title') + + const untitled = renderWith('text/html', { + webOperation: vi.fn().mockResolvedValue({ responseText: 'No title' }) + }) + await flush() + expect(untitled.querySelector('iframe')?.title).toBe('page.html') + }) + + it('keeps Dokieli documents isolated and mediates same-origin reads plus exact-document writes', async () => { + const dokieliUri = `${window.location.origin}/docs/dok.html` + const html = '

Dok

' + const authenticatedFetch = vi.fn().mockResolvedValue(new Response('ok')) + const subject = { uri: dokieliUri, doc: () => subject } + const store = { + fetcher: { + getHeader: vi.fn().mockReturnValue(['text/html']), + webOperation: vi.fn().mockResolvedValue({ responseText: html }), + _fetch: authenticatedFetch + } + } + const pane = humanReadablePane.render(subject as any, { dom: document, session: { store } } as any) + document.body.appendChild(pane) + const frame = pane.querySelector('iframe')! + try { + await flush() + expect(frame.getAttribute('sandbox')).toBe('allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-modals') + expect(frame.srcdoc).toContain('solidos-preview-request') + expect(frame.srcdoc).toContain('dokieli.js') + expect(frame.srcdoc.match(/

Saved

' + } + })) + await flush() + const savedBody = authenticatedFetch.mock.calls[0][1]?.body as string + expect(savedBody).toContain('

Saved

') + expect(savedBody).not.toContain('solidos-preview-bridge') + expect(savedBody).not.toContain('solidos-preview-request') + authenticatedFetch.mockClear() + window.dispatchEvent(new MessageEvent('message', { + source: frame.contentWindow, + data: { + type: 'solidos-preview-request', + nonce: frame.srcdoc.match(/const nonce = "([^"]+)"/)?.[1], + id: 'profile-read', + url: `${window.location.origin}/profile/card`, + method: 'GET' + } + })) + await flush() + expect(authenticatedFetch).toHaveBeenCalledWith(`${window.location.origin}/profile/card`, { + method: 'GET', + headers: undefined, + body: undefined + }) + authenticatedFetch.mockClear() + window.dispatchEvent(new MessageEvent('message', { + source: frame.contentWindow, + data: { + type: 'solidos-preview-request', + nonce: frame.srcdoc.match(/const nonce = "([^"]+)"/)?.[1], + id: 'save-from-srcdoc', + // When history.replaceState is unavailable in the opaque sandbox, + // Dokieli saves to document.location.href, which is about:srcdoc. + url: 'about:srcdoc', + method: 'PUT', + body: 'saved from srcdoc' + } + })) + await flush() + expect(authenticatedFetch).toHaveBeenCalledWith(dokieliUri, { + method: 'PUT', + headers: undefined, + body: 'saved from srcdoc' + }) + authenticatedFetch.mockClear() + window.dispatchEvent(new MessageEvent('message', { + source: frame.contentWindow, + data: { + type: 'solidos-preview-request', + nonce: frame.srcdoc.match(/const nonce = "([^"]+)"/)?.[1], + id: 'save-from-file-srcdoc', + url: 'file://srcdoc/', + method: 'PUT', + body: 'saved from file srcdoc' + } + })) + await flush() + expect(authenticatedFetch).toHaveBeenCalledWith(dokieliUri, { + method: 'PUT', + headers: undefined, + body: 'saved from file srcdoc' + }) + authenticatedFetch.mockClear() + const postToPreview = vi.spyOn(frame.contentWindow!, 'postMessage') + window.dispatchEvent(new MessageEvent('message', { + source: frame.contentWindow, + data: { + type: 'solidos-preview-request', + nonce: frame.srcdoc.match(/const nonce = "([^"]+)"/)?.[1], + id: 'other', + url: 'https://other.example/private/other-user.ttl', + method: 'GET' + } + })) + await flush() + expect(authenticatedFetch).not.toHaveBeenCalled() + // Denied requests are still answered so the preview never waits forever. + expect(postToPreview).toHaveBeenCalledWith(expect.objectContaining({ + type: 'solidos-preview-response', + id: 'other', + ok: false, + status: 403 + }), '*') + } finally { + pane.remove() + } + }) + + it('keeps cross-origin Dokieli documents in the isolated preview', async () => { + const webOperation = vi.fn().mockResolvedValue({ + responseText: '' + }) + const pane = renderWith('text/html', { webOperation }) + await flush() + + const frame = pane.querySelector('iframe')! + expect(frame.getAttribute('sandbox')).toBe('allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-modals') + expect(frame.srcdoc).toContain('dokieli.js') + }) + + it('uses the actual response MIME type to isolate HTML returned for a non-HTML resource', async () => { + const response = new Response('', { + headers: { 'content-type': 'text/html; charset=utf-8' } + }) + const pane = renderWith('image/png', { _fetch: vi.fn().mockResolvedValue(response) }) + await flush() + + const frame = pane.querySelector('iframe')! + expect(frame.getAttribute('sandbox')).toBe('allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-modals') + expect(frame.src).toBe('') + expect(frame.srcdoc).toContain('compromised') + }) + + it('does not sandbox PDF blob previews so the browser viewer can render them', async () => { + const createObjectURL = vi.spyOn(URL, 'createObjectURL').mockReturnValue('blob:https://pod.example/resource') + const response = new Response('pdf data', { + headers: { 'content-type': 'application/pdf' } + }) + const pane = renderWith('application/octet-stream', { _fetch: vi.fn().mockResolvedValue(response) }) + await flush() + + const frame = pane.querySelector('iframe')! + expect(frame.getAttribute('sandbox')).toBeNull() + expect(frame.src).toBe('blob:https://pod.example/resource') + expect(createObjectURL).toHaveBeenCalled() + createObjectURL.mockRestore() + }) + + it('keeps non-PDF blob previews sandboxed', async () => { + const createObjectURL = vi.spyOn(URL, 'createObjectURL').mockReturnValue('blob:https://pod.example/resource') + const response = new Response('', { + headers: { 'content-type': 'image/svg+xml' } + }) + const pane = renderWith('image/svg+xml', { _fetch: vi.fn().mockResolvedValue(response) }) + await flush() + + expect(pane.querySelector('iframe')?.getAttribute('sandbox')) + .toBe('allow-scripts allow-forms allow-popups allow-popups-to-escape-sandbox allow-modals') + createObjectURL.mockRestore() + }) + + it('revokes a blob URL when the preview is removed before fetching completes', async () => { + let resolveResponse!: (response: Response) => void + const responsePromise = new Promise(resolve => { resolveResponse = resolve }) + const createObjectURL = vi.spyOn(URL, 'createObjectURL').mockReturnValue('blob:https://pod.example/resource') + const revokeObjectURL = vi.spyOn(URL, 'revokeObjectURL').mockImplementation(() => {}) + const pane = renderWith('application/pdf', { _fetch: vi.fn().mockReturnValue(responsePromise) }) + document.body.appendChild(pane) + pane.remove() + resolveResponse(new Response('pdf', { + headers: { 'content-type': 'application/pdf' } + })) + await flush() + await flush() + + expect(createObjectURL).toHaveBeenCalled() + expect(revokeObjectURL).toHaveBeenCalledWith('blob:https://pod.example/resource') + createObjectURL.mockRestore() + revokeObjectURL.mockRestore() + }) + + it('shows an error instead of the resource URL when the fetch fails', async () => { + const webOperation = vi.fn().mockRejectedValue(new Error('401')) + vi.spyOn(console, 'error').mockImplementation(() => {}) + const pane = renderWith('text/html', { webOperation }) + await flush() + + const frame = pane.querySelector('iframe')! + expect(frame.getAttribute('src')).toBeNull() + expect(frame.srcdoc).toContain('Error loading content') + }) + + it('falls back to the encoded filename when it is not valid UTF-8', () => { + const invalidUri = 'https://pod.example/docs/file%FF.pdf' + const subject = { uri: invalidUri, doc: () => subject } + const store = { + fetcher: { + getHeader: vi.fn().mockReturnValue(['application/pdf']), + _fetch: vi.fn().mockResolvedValue(new Response('pdf', { + headers: { 'content-type': 'application/pdf' } + })) + } + } + const pane = humanReadablePane.render(subject as any, { dom: document, session: { store } } as any) + + expect(pane.querySelector('iframe')?.title).toBe('file%FF.pdf') + }) + + it('gives Dokieli the signed-in viewer as a bridged session', async () => { + const webId = 'https://pod.example/profile/card#me' + const spy = vi.spyOn(authn, 'currentUser').mockReturnValue(sym(webId) as any) + const dokieliUri = `${window.location.origin}/docs/dok-session.html` + const html = '' + const subject = { uri: dokieliUri, doc: () => subject } + const store = { + fetcher: { + getHeader: vi.fn().mockReturnValue(['text/html']), + webOperation: vi.fn().mockResolvedValue({ responseText: html }), + _fetch: vi.fn() + } + } + try { + const pane = humanReadablePane.render(subject as any, { dom: document, session: { store } } as any) + await flush() + const srcdoc = pane.querySelector('iframe')!.srcdoc + expect(srcdoc).toContain(`const viewerWebId = ${JSON.stringify(webId)}`) + expect(srcdoc).toContain('if (bridgedSession) config.Session = bridgedSession') + expect(srcdoc).toContain('Object.defineProperty(config, \'DocumentURL\'') + expect(srcdoc.indexOf('bridgedSession')).toBeLessThan(srcdoc.indexOf('dokieli.js')) + + spy.mockReturnValue(null) + const loggedOut = humanReadablePane.render(subject as any, { dom: document, session: { store } } as any) + await flush() + expect(loggedOut.querySelector('iframe')!.srcdoc).toContain('const viewerWebId = null') + } finally { + spy.mockRestore() + } + }) +}) diff --git a/test/unit/imagePane.test.ts b/test/unit/imagePane.test.ts new file mode 100644 index 00000000..86aa010a --- /dev/null +++ b/test/unit/imagePane.test.ts @@ -0,0 +1,31 @@ +import { describe, expect, it, vi } from 'vitest' +import { imagePane } from '../../src/imagePane' + +function contextFor (contentType?: string) { + const subject = { uri: 'https://pod.example/image.png' } + const store = { + anyStatementMatching: vi.fn().mockReturnValue(false), + sym: vi.fn((uri: string) => ({ uri })), + fetcher: { + getHeader: vi.fn().mockReturnValue(contentType ? [contentType] : undefined) + } + } + return { + subject, + context: { session: { store } } as any + } +} + +describe('image pane', () => { + it('claims image resources based on their response content type', () => { + const { subject, context } = contextFor('image/png') + + expect(imagePane.label(subject as any, context)).toBe('Image') + }) + + it('does not claim non-image resources without an image RDF type', () => { + const { subject, context } = contextFor('text/html') + + expect(imagePane.label(subject as any, context)).toBeNull() + }) +}) diff --git a/test/unit/internalPane.test.ts b/test/unit/internalPane.test.ts new file mode 100644 index 00000000..669c3362 --- /dev/null +++ b/test/unit/internalPane.test.ts @@ -0,0 +1,173 @@ +import { beforeEach, describe, expect, it, vi } from 'vitest' +import { Fetcher, graph, literal, sym, UpdateManager } from 'rdflib' +import type { DataBrowserContext } from 'pane-registry' +import internalPane from '../../src/internal/internalPane' + +vi.mock('../../src/components/resource-action-dialog/ResourceActionDialog', () => ({})) + +class TestResourceActionDialog extends HTMLElement { + static confirmed = true + + title = '' + message = '' + confirmation = false + + open () { + return Promise.resolve(this.confirmation ? TestResourceActionDialog.confirmed : false) + } +} + +if (!customElements.get('solid-panes-resource-action-dialog')) { + customElements.define('solid-panes-resource-action-dialog', TestResourceActionDialog) +} + +beforeEach(() => { + TestResourceActionDialog.confirmed = true + document.body.replaceChildren() +}) + +async function flushPromises () { + await new Promise(resolve => setTimeout(resolve, 0)) +} + +describe('Under The Hood RDF bookkeeping', () => { + it('keeps display-only statements out of the live store so the document can be unloaded', () => { + const store = graph() + const fetcher = new Fetcher(store) + store.updater = new UpdateManager(store) + const subject = sym('https://example.test/file.ttl') + const predicate = sym('https://example.test/title') + store.add(subject, predicate, literal('A real file'), subject) + const originalStatements = store.statementsMatching(subject).slice() + const appendPropertyTRs = vi.fn() + const context = { + dom: document, + session: { + store, + paneRegistry: { byName: () => internalPane } + }, + getOutliner: () => ({ appendPropertyTRs }) + } as unknown as DataBrowserContext + + internalPane.render(subject, context) + internalPane.render(subject, context) + + const displayedStatements = appendPropertyTRs.mock.calls[0][1] + expect(displayedStatements).toEqual(expect.arrayContaining([ + expect.objectContaining({ + predicate: sym('http://www.w3.org/2007/ont/link#uri'), + object: subject + }) + ])) + const fragment = sym('https://example.test/file.ttl#part') + internalPane.render(fragment, context) + expect(appendPropertyTRs.mock.calls[4][1]).toEqual(expect.arrayContaining([ + expect.objectContaining({ + predicate: sym('http://www.w3.org/2007/ont/link#documentURI'), + object: sym('https://example.test/file.ttl') + }) + ])) + expect(store.statementsMatching(subject)).toEqual(originalStatements) + expect(store.statements).toEqual(originalStatements) + expect(() => fetcher.unload(subject)).not.toThrow() + expect(store.statementsMatching(subject)).toEqual([]) + expect(store.statements).toEqual([]) + }) +}) + +describe('Under The Hood deletion', () => { + function renderDeletionPane () { + const store = graph() + store.fetcher = new Fetcher(store) + store.updater = new UpdateManager(store) + const subject = sym('https://example.test/file.ttl') + const recursiveDelete = vi.fn(() => Promise.resolve()) + const appendPropertyTRs = vi.fn() + const context = { + dom: document, + session: { + store, + logic: { resource: { recursiveDelete } }, + paneRegistry: { byName: () => internalPane } + }, + getOutliner: () => ({ appendPropertyTRs }) + } as unknown as DataBrowserContext + + const pane = internalPane.render(subject, context) + document.body.appendChild(pane) + const deleteButton = pane.querySelector('.internalPaneDeleteButton') as HTMLButtonElement + return { subject, recursiveDelete, deleteButton } + } + + it('deletes the resource once and emits the success event after confirmation', async () => { + const { subject, recursiveDelete, deleteButton } = renderDeletionPane() + const deleted = vi.fn() + document.addEventListener('solid-resource-deleted', deleted) + + deleteButton.click() + await flushPromises() + expect(recursiveDelete).toHaveBeenCalledOnce() + expect(recursiveDelete).toHaveBeenCalledWith(subject) + expect(deleted).toHaveBeenCalledOnce() + expect(deleted).toHaveBeenCalledWith(expect.objectContaining({ + detail: { resource: subject } + })) + expect(deleteButton.disabled).toBe(false) + + document.removeEventListener('solid-resource-deleted', deleted) + }) + + it('does not delete when cancellation is selected', async () => { + TestResourceActionDialog.confirmed = false + const { recursiveDelete, deleteButton } = renderDeletionPane() + + deleteButton.click() + await Promise.resolve() + + expect(recursiveDelete).not.toHaveBeenCalled() + expect(deleteButton.disabled).toBe(false) + }) + + it('shows an error dialog without emitting success when deletion fails', async () => { + const { recursiveDelete, deleteButton } = renderDeletionPane() + const error = new Error('delete failed') + recursiveDelete.mockRejectedValueOnce(error) + const deleted = vi.fn() + document.addEventListener('solid-resource-deleted', deleted) + + deleteButton.click() + await flushPromises() + + const dialogs = Array.from(document.querySelectorAll('solid-panes-resource-action-dialog')) as TestResourceActionDialog[] + expect(recursiveDelete).toHaveBeenCalledOnce() + expect(deleted).not.toHaveBeenCalled() + expect(dialogs.at(-1)).toMatchObject({ + title: 'Unable to delete resource', + message: expect.stringContaining('delete failed') + }) + expect(deleteButton.disabled).toBe(false) + + document.removeEventListener('solid-resource-deleted', deleted) + }) + + it('prevents a second deletion request while the first is pending', async () => { + let resolveDelete: (() => void) | undefined + const deletion = new Promise(resolve => { + resolveDelete = resolve + }) + const { recursiveDelete, deleteButton } = renderDeletionPane() + recursiveDelete.mockReturnValueOnce(deletion) + + deleteButton.click() + await flushPromises() + expect(deleteButton.disabled).toBe(true) + + deleteButton.click() + expect(recursiveDelete).toHaveBeenCalledOnce() + + resolveDelete!() + await deletion + await flushPromises() + expect(deleteButton.disabled).toBe(false) + }) +}) diff --git a/test/unit/mainPage/header.test.ts b/test/unit/mainPage/header.test.ts new file mode 100644 index 00000000..bbdecbdb --- /dev/null +++ b/test/unit/mainPage/header.test.ts @@ -0,0 +1,97 @@ +import { afterEach, describe, expect, it, vi } from 'vitest' +import { authn } from 'solid-logic' +import { sym } from 'rdflib' +import type { NavigationController } from '../../../src/navigation/controller' + +const { getFolderPanes } = vi.hoisted(() => ({ getFolderPanes: vi.fn() })) + +vi.mock('../../../src/utils/paneUtils', () => ({ getFolderPanesFromURI: getFolderPanes })) + +import { createHeader } from '../../../src/mainPage/header' + +afterEach(() => { + vi.restoreAllMocks() + vi.resetAllMocks() + document.body.replaceChildren() +}) + +type MenuItem = { onSelected?: () => unknown } + +describe('account menu', () => { + const viewer = sym('https://viewer.example/profile/card#me') + + async function setup (currentUser: typeof viewer | null, checkUser: typeof viewer | null = null, storages: object[] = []) { + const show = vi.fn().mockResolvedValue(undefined) + vi.spyOn(authn, 'currentUser').mockReturnValue(currentUser) + vi.spyOn(authn, 'checkUser').mockResolvedValue(checkUser) + getFolderPanes.mockResolvedValue(storages) + const header = await createHeader({ show } as NavigationController) as HTMLElement & { menuItems: MenuItem[] } + return { show, header, items: header.menuItems } + } + + it('shows the viewer\'s profile, friends, dashboard and preferences as the account menu', async () => { + const { show, items } = await setup(viewer) + const [profile, friends, dashboard, preferences] = items + + await profile.onSelected?.() + await friends.onSelected?.() + await dashboard.onSelected?.() + await preferences.onSelected?.() + + expect(show.mock.calls.map(call => call[0])).toEqual([ + { kind: 'profile', subject: viewer.value, source: 'accountMenu' }, + { kind: 'friends', subject: viewer.value, source: 'accountMenu' }, + { kind: 'app', pane: 'home', source: 'accountMenu' }, + { kind: 'app', pane: 'basicPreferences', source: 'accountMenu' } + ]) + }) + + it('offers each of the viewer\'s storages, between friends and the dashboard', async () => { + const storage = { paneName: 'folder', label: () => 'Storage' } + const { show, items } = await setup(viewer, null, [storage]) + + expect(items).toHaveLength(5) + expect(getFolderPanes).toHaveBeenCalledWith(viewer) + await items[2].onSelected?.() + + expect(show).toHaveBeenCalledWith({ kind: 'storage', pane: storage, source: 'accountMenu' }) + }) + + it('loads storage choices for a viewer restored by the initial session check', async () => { + const storage = { paneName: 'folder', label: () => 'Storage' } + const { show, items } = await setup(null, viewer, [storage]) + + expect(getFolderPanes).toHaveBeenCalledWith(viewer) + expect(items).toHaveLength(5) + await items[2].onSelected?.() + + expect(show).toHaveBeenCalledWith({ kind: 'storage', pane: storage, source: 'accountMenu' }) + }) + + it.each([ + ['logged in after the header was created', null, viewer, null], + ['restored by a session check', null, null, viewer] + ])('uses the viewer when it was %s', async (_name, atCreation, later, fromCheck) => { + const { show, items } = await setup(atCreation, fromCheck) + vi.mocked(authn.currentUser).mockReturnValue(later) + + await items[0].onSelected?.() + await items[1].onSelected?.() + + expect(show.mock.calls.map(call => call[0].subject)).toEqual([viewer.value, viewer.value]) + }) + + it('does nothing when nobody is logged in', async () => { + const { show, items } = await setup(null, null) + + for (const item of items) await item.onSelected?.() + + expect(show).not.toHaveBeenCalled() + }) + + it('is created once', async () => { + const { header, show } = await setup(viewer) + + expect(await createHeader({ show } as NavigationController)).toBe(header) + }) +}) diff --git a/test/unit/mainPage/index.test.ts b/test/unit/mainPage/index.test.ts new file mode 100644 index 00000000..7778b4f9 --- /dev/null +++ b/test/unit/mainPage/index.test.ts @@ -0,0 +1,385 @@ +import { afterEach, describe, expect, it, vi } from 'vitest' +import { store } from 'solid-logic' + +const { + getOutliner, byName, getProfilePane, getSocialPane, getFolderPane, refreshHeading, selectNavbarPane, isWebId +} = vi.hoisted(() => ({ + getOutliner: vi.fn(), + byName: vi.fn(), + getProfilePane: vi.fn(), + getSocialPane: vi.fn(), + getFolderPane: vi.fn(), + refreshHeading: vi.fn(), + selectNavbarPane: vi.fn(), + isWebId: vi.fn() +})) + +vi.mock('../../../src/index', () => ({ getOutliner })) +vi.mock('pane-registry', () => ({ byName })) +vi.mock('../../../src/mainPage/header', () => ({ createHeader: vi.fn() })) +vi.mock('../../../src/mainPage/navbar', () => ({ createNavbar: vi.fn(), selectNavbarPane })) +vi.mock('../../../src/mainPage/profileHeading', () => ({ + initializeProfileHeading: vi.fn(), + placeProfileHeading: vi.fn(), + refreshProfileHeading: refreshHeading +})) +vi.mock('../../../src/utils/paneUtils', () => ({ + getProfilePaneFromURI: getProfilePane, + getSocialPaneFromURI: getSocialPane, + getFolderPaneForStorage: getFolderPane +})) +vi.mock('../../../src/utils/webIdUtils', () => ({ isWebIdUri: isWebId })) + +import { initMainPage, refreshUI } from '../../../src/mainPage' +import { resolveSource } from '../../../src/navigation/options' + +const navigationListeners: Record void> = {} +Object.defineProperty(window, 'navigation', { + configurable: true, + value: { + addEventListener: (type: string, listener: (event: unknown) => void) => { + navigationListeners[type] = listener + } + } +}) + +afterEach(() => { + vi.resetAllMocks() + document.body.replaceChildren() + window.history.replaceState({}, '', '/') +}) + +const origin = window.location.origin +const environment = { + layout: 'desktop', + layoutPreference: 'auto', + theme: 'light', + inputMode: 'pointer', + viewport: { width: 1280, height: 800 } +} +const urlProfilePane = { + name: 'profile', + paneName: 'profile', + subject: store.sym('https://other.example/profile/card#me') +} + +function setup (state: object, webId = true) { + // Mirrors how the outline manager records the displayed pane in history.state + const GotoSubject = vi.fn((_subject, _expand, pane, _solo, _referrer, _table, options) => { + const next = { ...window.history.state } + if (pane) { + next.paneName = pane.name + if (pane.subject) next.paneUri = pane.subject.value + } + if (resolveSource(options) === 'accountMenu') next.viaAccountMenu = true + else delete next.viaAccountMenu + window.history.replaceState(next, '', window.location.href) + }) + getOutliner.mockReturnValue({ GotoSubject }) + getProfilePane.mockResolvedValue(urlProfilePane) + byName.mockReturnValue({ name: 'folder' }) + isWebId.mockReturnValue(webId) + window.history.replaceState(state, '', webId ? '/other/profile/card#me' : '/other/storage/file.ttl') + return GotoSubject +} + +describe('main page load', () => { + it('loads the URL\'s profile instead of the pane the account menu showed', async () => { + const GotoSubject = setup({ + paneName: 'folder', + paneUri: `${origin}/storage/`, + viaAccountMenu: true, + other: 'kept' + }) + + await initMainPage(store) + + expect(getProfilePane).toHaveBeenCalledWith(store.sym(window.location.href), byName) + expect(byName).not.toHaveBeenCalled() + expect(GotoSubject.mock.calls[0][2]).toBe(urlProfilePane) + expect(window.location.pathname).toBe('/other/profile/card') + }) + + it.each([ + ['social', 'https://other.example/profile/card#me'], + ['folder', 'https://other.example/storage/'] + ])('always shows the profile when a WebID is reloaded after the %s pane was selected', async (paneName, paneUri) => { + const GotoSubject = setup({ paneName, paneUri, other: 'kept' }) + + await initMainPage(store) + + expect(getProfilePane).toHaveBeenCalledWith(store.sym(window.location.href), byName) + expect(byName).not.toHaveBeenCalled() + expect(getSocialPane).not.toHaveBeenCalled() + expect(GotoSubject.mock.calls[0][2]).toBe(urlProfilePane) + expect(window.history.state).toEqual({ + paneName: 'profile', + paneUri: urlProfilePane.subject.value, + other: 'kept' + }) + }) + + it.each([ + ['a storage from the navbar', { paneName: 'folder', paneUri: `${origin}/other/storage/` }], + ['friends from the navbar', { paneName: 'social', paneUri: `${origin}/other/profile/card#me` }], + ['a pane of the application', { paneName: 'home' }] + ])('shows what the URL is on a reload, whatever pane was selected before: %s', async (_name, saved) => { + const GotoSubject = setup({ ...saved, other: 'kept' }, false) + + await initMainPage(store) + + expect(getFolderPane).not.toHaveBeenCalled() + expect(getSocialPane).not.toHaveBeenCalled() + expect(byName).not.toHaveBeenCalled() + expect(GotoSubject.mock.calls[0][2]).toBeUndefined() + expect(window.history.state).toEqual({ other: 'kept' }) + }) + + it('drops account-menu content on a non-WebID page', async () => { + const GotoSubject = setup({ + paneName: 'folder', + paneUri: `${origin}/storage/`, + viaAccountMenu: true + }, false) + + await initMainPage(store) + + expect(byName).not.toHaveBeenCalled() + expect(GotoSubject.mock.calls[0][2]).toBeUndefined() + expect(window.history.state).toEqual({}) + }) +}) + +describe('browser navigation without a reload', () => { + async function setupLoaded (state: object = {}, webId = true) { + const GotoSubject = setup(state, webId) + await initMainPage(store) + GotoSubject.mockClear() + refreshHeading.mockClear() + getProfilePane.mockClear() + selectNavbarPane.mockClear() + return GotoSubject + } + + function enter (overrides: object = {}) { + const intercept = vi.fn() + navigationListeners.navigate({ + canIntercept: true, + userInitiated: true, + navigationType: 'replace', + hashChange: true, + destination: { url: window.location.href, sameDocument: true }, + intercept, + ...overrides + }) + return intercept + } + + function traverse (navigationType = 'traverse') { + navigationListeners.currententrychange({ navigationType }) + } + + it('shows the URL\'s profile, navbar selection and heading when Enter is pressed on the current URL', async () => { + const GotoSubject = await setupLoaded() + window.history.replaceState({ + paneName: 'folder', + paneUri: `${origin}/storage/`, + viaAccountMenu: true + }, '', window.location.href) + + for (const overrides of [ + { userInitiated: false }, + { navigationType: 'push' }, + { canIntercept: false }, + { destination: { url: `${origin}/elsewhere` } } + ]) { + expect(enter(overrides)).not.toHaveBeenCalled() + } + + const intercept = enter() + expect(intercept).toHaveBeenCalledOnce() + await intercept.mock.calls[0][0].handler() + + expect(getProfilePane).toHaveBeenCalledWith(store.sym(window.location.href), byName) + expect(GotoSubject.mock.calls[0][2]).toBe(urlProfilePane) + expect(resolveSource(GotoSubject.mock.calls[0][6])).toBe('default') + expect(selectNavbarPane).toHaveBeenCalledWith('profile', urlProfilePane.subject.value) + expect(window.history.state).toEqual({ paneName: 'profile', paneUri: urlProfilePane.subject.value }) + expect(refreshHeading).toHaveBeenCalledWith(true) + }) + + it('shows a container\'s own default view when Enter is pressed on its URL after a storage was selected', async () => { + const GotoSubject = await setupLoaded({}, false) + window.history.replaceState({ paneName: 'folder', paneUri: `${origin}/other/` }, '', window.location.href) + + const intercept = enter({ + hashChange: false, + destination: { url: window.location.href, sameDocument: false } + }) + expect(intercept).toHaveBeenCalledOnce() + await intercept.mock.calls[0][0].handler() + + expect(getFolderPane).not.toHaveBeenCalled() + expect(GotoSubject.mock.calls[0][2]).toBeUndefined() + expect(window.history.state).toEqual({}) + expect(selectNavbarPane).not.toHaveBeenCalled() + expect(refreshHeading).toHaveBeenCalledWith(true) + }) + + it.each([ + ['an account-menu storage', { paneName: 'folder', paneUri: `${origin}/storage/`, viaAccountMenu: true }], + ['a storage from the navbar', { paneName: 'folder', paneUri: `${origin}/other/storage/` }], + ['friends from the navbar', { paneName: 'social', paneUri: `${origin}/other/profile/card#me` }], + ['an account-menu dashboard', { paneName: 'home', viaAccountMenu: true }] + ])('shows what the URL is on back or forward, not %s the entry displayed', async (_name, saved) => { + const GotoSubject = await setupLoaded() + window.history.replaceState({ ...saved, other: 'kept' }, '', window.location.href) + + traverse() + await vi.waitFor(() => expect(refreshHeading).toHaveBeenCalledWith(true)) + + expect(getFolderPane).not.toHaveBeenCalled() + expect(getSocialPane).not.toHaveBeenCalled() + expect(getProfilePane).toHaveBeenCalledWith(store.sym(window.location.href), byName) + expect(GotoSubject.mock.calls[0][2]).toBe(urlProfilePane) + expect(resolveSource(GotoSubject.mock.calls[0][6])).toBe('default') + expect(selectNavbarPane).toHaveBeenCalledWith('profile', urlProfilePane.subject.value) + expect(window.history.state).toEqual({ + paneName: 'profile', + paneUri: urlProfilePane.subject.value, + other: 'kept' + }) + expect(window.location.pathname).toBe('/other/profile/card') + }) + + it('shows a container\'s own default view on back or forward after a storage was selected', async () => { + const GotoSubject = await setupLoaded({}, false) + window.history.replaceState({ paneName: 'folder', paneUri: `${origin}/other/` }, '', window.location.href) + + traverse() + await vi.waitFor(() => expect(refreshHeading).toHaveBeenCalledWith(true)) + + expect(getFolderPane).not.toHaveBeenCalled() + expect(GotoSubject.mock.calls[0][2]).toBeUndefined() + expect(window.history.state).toEqual({}) + expect(selectNavbarPane).not.toHaveBeenCalled() + }) + + it('ignores entry changes that are not back or forward', async () => { + const GotoSubject = await setupLoaded() + + traverse('replace') + traverse('push') + await new Promise(resolve => setTimeout(resolve, 10)) + + expect(GotoSubject).not.toHaveBeenCalled() + }) + + it('only renders the latest when navigating quickly', async () => { + const GotoSubject = await setupLoaded() + let resolveFirst!: (pane: unknown) => void + getProfilePane.mockReturnValueOnce(new Promise(resolve => { resolveFirst = resolve })) + traverse() + await vi.waitFor(() => expect(getProfilePane).toHaveBeenCalledOnce()) + + traverse() + await vi.waitFor(() => expect(GotoSubject).toHaveBeenCalledOnce()) + resolveFirst({ name: 'profile', paneName: 'profile', subject: urlProfilePane.subject }) + await new Promise(resolve => setTimeout(resolve)) + + expect(GotoSubject).toHaveBeenCalledOnce() + expect(GotoSubject.mock.calls[0][2]).toBe(urlProfilePane) + }) + + it('keeps the URL and account-menu view when the render environment changes', async () => { + const GotoSubject = await setupLoaded() + const navbar = document.createElement('solid-panes-navbar') + document.body.appendChild(navbar) + const storage = `${origin}/storage/` + const storagePane = { name: 'folder', paneName: 'folder', subject: store.sym(storage) } + getFolderPane.mockResolvedValue(storagePane) + window.history.replaceState({ paneName: 'folder', paneUri: storage, viaAccountMenu: true }, '', window.location.href) + const pageUrl = window.location.href + const outliner = getOutliner() + outliner.context = { session: { store }, environment: { ...environment, layout: 'mobile' } } + + await refreshUI(outliner) + + const [subject, , pane, , , , options] = GotoSubject.mock.calls[0] + expect(subject.value).toBe(pageUrl) + expect(pane).toBe(storagePane) + expect(options).toEqual({ source: 'accountMenu', folderView: 'explorer' }) + expect(window.location.href).toBe(pageUrl) + expect(window.history.state).toMatchObject({ paneName: 'folder', paneUri: storage, viaAccountMenu: true }) + expect(navbar).toHaveClass('navbar--hidden') + + await refreshUI(outliner) + expect(GotoSubject).toHaveBeenCalledOnce() + }) + + it('refreshes when the viewport changes within the same layout', async () => { + const GotoSubject = await setupLoaded() + const outliner = getOutliner() + outliner.context = { + session: { store }, + environment: { ...environment, viewport: { width: 1279, height: 800 } } + } + + await refreshUI(outliner) + + expect(GotoSubject).toHaveBeenCalledOnce() + }) + + it('does not re-render when only the viewport height changes', async () => { + const GotoSubject = await setupLoaded() + const outliner = getOutliner() + outliner.__lastRenderEnvSignature = 'desktop|light|pointer|1280' + outliner.context = { + session: { store }, + environment: { ...environment, viewport: { width: 1280, height: 620 } } + } + + await refreshUI(outliner) + + expect(GotoSubject).not.toHaveBeenCalled() + }) + + it('refreshes explorers instead of replacing the page during an active edit', async () => { + const GotoSubject = await setupLoaded() + const main = document.createElement('main') + main.id = 'MainContent' + main.innerHTML = '
' + document.body.append(main) + const outliner = getOutliner() + const refresh = vi.fn() + outliner.refreshActiveExplorerPanes = refresh + outliner.__lastRenderEnvSignature = 'desktop|light|pointer|1280|800' + outliner.context = { + session: { store }, + environment: { ...environment, layout: 'mobile', viewport: { width: 320, height: 800 } } + } + + await refreshUI(outliner) + + expect(refresh).toHaveBeenCalledOnce() + expect(GotoSubject).not.toHaveBeenCalled() + + outliner.context.environment = { ...outliner.context.environment, theme: 'dark' } + await refreshUI(outliner) + expect(GotoSubject).toHaveBeenCalledOnce() + }) + + it('falls back to popstate when the Navigation API is unavailable', async () => { + Reflect.deleteProperty(window, 'navigation') + vi.resetModules() + const { initMainPage: initWithoutNavigationApi } = await import('../../../src/mainPage') + const GotoSubject = setup({}) + await initWithoutNavigationApi(store) + GotoSubject.mockClear() + window.history.replaceState({}, '', window.location.href) + + window.dispatchEvent(new PopStateEvent('popstate')) + await vi.waitFor(() => expect(GotoSubject).toHaveBeenCalledOnce()) + expect(GotoSubject.mock.calls[0][2]).toBe(urlProfilePane) + }) +}) diff --git a/test/unit/mainPage/navbar.test.ts b/test/unit/mainPage/navbar.test.ts new file mode 100644 index 00000000..edb51a1c --- /dev/null +++ b/test/unit/mainPage/navbar.test.ts @@ -0,0 +1,391 @@ +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' +import { authn, store } from 'solid-logic' +import { sym } from 'rdflib' +import type { NavigationController } from '../../../src/navigation/controller' +import type { NavbarMenuItem } from '../../../src/components/navbar/Navbar' +import { getFolderPanesFromURI } from '../../../src/utils/paneUtils' +import { announceNavigation } from '../../../src/navigation/events' +import { resetPodContexts } from '../../../src/navigation/podContext' +import { getPodStorages } from '../../../src/utils/podUtils' + +const { loadProfile } = vi.hoisted(() => ({ loadProfile: vi.fn() })) + +vi.mock('../../../src/utils/paneUtils', () => ({ + getFolderPanesFromURI: vi.fn(async () => []) +})) + +vi.mock('../../../src/utils/podUtils', () => ({ + getPodStorages: vi.fn(async () => []) +})) + +vi.mock('../../../src/utils/webIdUtils', async (importOriginal) => ({ + ...await importOriginal(), + loadProfileFromURI: loadProfile +})) + +import { createNavbar, selectNavbarPane } from '../../../src/mainPage/navbar' +import { createNavigationController } from '../../../src/navigation/controller' +import { registerBrowserNavigation } from '../../../src/navigation/browserEvents' +import OutlineManager from '../../../src/outline/manager' + +// Without a profile of its own, the lookup answers with the URL it was asked about +const noProfile = async (subject: ReturnType) => subject + +function folderPane (storage: ReturnType) { + return { + name: 'folder', + paneName: 'folder', + subject: storage, + label: () => 'Storage', + render: vi.fn(), + shouldGetFocus: () => false, + requireQueryButton: false, + icon: '' + } +} + +afterEach(() => { + vi.restoreAllMocks() + resetPodContexts() + loadProfile.mockReset().mockImplementation(noProfile) + vi.mocked(getFolderPanesFromURI).mockResolvedValue([]) + vi.mocked(getPodStorages).mockReset().mockResolvedValue([]) + document.body.replaceChildren() + window.history.replaceState({}, '', '/') +}) + +describe('page navbar visibility', () => { + const navigation = { show: vi.fn().mockResolvedValue(undefined) } as unknown as NavigationController + + beforeEach(() => { + loadProfile.mockImplementation(noProfile) + }) + + it('selects a menu item by pane name and ignores unknown panes', async () => { + vi.spyOn(authn, 'currentUser').mockReturnValue(null) + window.history.replaceState({ paneName: 'social' }, '', '/other/profile/card#me') + + const navbar = await createNavbar(navigation) as HTMLElement & { navbarItems: NavbarMenuItem[] } + const selected = () => navbar.navbarItems.filter(item => item.selected).map(item => item.paneName) + expect(selected()).toEqual(['social']) + + selectNavbarPane('profile') + expect(selected()).toEqual(['profile']) + + selectNavbarPane('unknown') + expect(selected()).toEqual(['profile']) + }) + + it('selects the storage item matching the pane URI', async () => { + const storages = [1, 2].map(index => sym(`${window.location.origin}/other/storage-${index}/`)) + vi.mocked(getFolderPanesFromURI).mockResolvedValue(storages.map(folderPane)) + window.history.replaceState({}, '', '/other/profile/card#me') + + const navbar = await createNavbar(navigation) as HTMLElement & { navbarItems: NavbarMenuItem[] } + const selected = () => navbar.navbarItems.filter(item => item.selected).map(item => item.paneUri) + + selectNavbarPane('folder', storages[1].value) + expect(selected()).toEqual([storages[1].value]) + + selectNavbarPane('folder', `${window.location.origin}/unknown/`) + expect(selected()).toEqual([storages[0].value]) + }) + + it('associates each storage menu item with its own pane URI', async () => { + const subject = sym(`${window.location.origin}/other/profile/card#me`) + const storages = [1, 2].map(index => sym(`${window.location.origin}/other/storage-${index}/`)) + vi.mocked(getFolderPanesFromURI).mockResolvedValue(storages.map(folderPane)) + window.history.replaceState({ + paneName: 'folder', + paneUri: storages[1].value + }, '', subject.value) + + const navbar = await createNavbar(navigation) as HTMLElement & { navbarItems: NavbarMenuItem[] } + const storageItems = navbar.navbarItems.filter(item => item.paneName === 'folder') + + expect(storageItems.map(item => item.paneUri)).toEqual(storages.map(storage => storage.value)) + expect(storageItems.map(item => item.selected)).toEqual([false, true]) + }) + + it('selects Storage after a Safari-style navigation event during the history write', async () => { + const listeners: Record void> = {} + Object.defineProperty(window, 'navigation', { + configurable: true, + value: { addEventListener: (type: string, listener: (event: unknown) => void) => { listeners[type] = listener } } + }) + try { + const owner = sym(`${window.location.origin}/other/profile/card#me`) + const storage = folderPane(sym(`${window.location.origin}/other/`)) + storage.render.mockImplementation(() => document.createElement('div')) + loadProfile.mockResolvedValue(owner) + vi.mocked(getFolderPanesFromURI).mockResolvedValue([storage]) + vi.spyOn(authn, 'currentUser').mockReturnValue(null) + window.history.replaceState({}, '', owner.uri) + const manager = new OutlineManager({ dom: document, session: { store, paneRegistry: { list: [], byName: () => undefined } } }) + const navigation = createNavigationController({ + store, + outliner: manager, + byName: () => undefined, + effects: { selectNavbarPane, refreshHeading: vi.fn().mockResolvedValue(undefined) } + }) + registerBrowserNavigation(navigation) + const navbar = await createNavbar(navigation) as HTMLElement & { navbarItems: NavbarMenuItem[] } + const original = window.history.replaceState.bind(window.history) + const intercept = vi.fn() + vi.spyOn(window.history, 'replaceState').mockImplementation((state, title, url) => { + listeners.navigate({ + canIntercept: true, + userInitiated: true, + navigationType: 'replace', + destination: { url: window.location.href }, + intercept + }) + original(state, title, url) + }) + + await vi.waitFor(() => expect(navbar.shadowRoot?.querySelectorAll('button')).toHaveLength(3)) + navbar.shadowRoot!.querySelectorAll('button')[2].click() + + await vi.waitFor(() => expect(window.history.state).toMatchObject({ + paneName: 'folder', paneUri: storage.subject.uri + })) + await vi.waitFor(() => { + const buttons = navbar.shadowRoot!.querySelectorAll('button') + expect(buttons[0]).not.toHaveClass('selected') + expect(buttons[2]).toHaveClass('selected') + }) + expect(intercept).not.toHaveBeenCalled() + expect(window.location.href).toBe(owner.uri) + } finally { + Reflect.deleteProperty(window, 'navigation') + } + }) + + it.each(['/profile/card#me', '/profile/card'])('hides a new navbar on the own profile URL %s', async (url) => { + vi.spyOn(authn, 'currentUser').mockReturnValue(sym(`${window.location.origin}/profile/card#me`)) + window.history.replaceState({}, '', url) + + const navbar = await createNavbar(navigation) + + expect(navbar).toHaveClass('navbar--hidden') + }) + + it.each([ + ['/profile/card#me', false], + ['/other/profile/card#me', true], + ['/storage/file.ttl', true], + ['/profile/card#someone-else', true] + ])('keeps the navbar visible for %s when logged in: %s', async (url, loggedIn) => { + vi.spyOn(authn, 'currentUser').mockReturnValue( + loggedIn ? sym(`${window.location.origin}/profile/card#me`) : null + ) + window.history.replaceState({}, '', url) + + const navbar = await createNavbar(navigation) + + expect(navbar).not.toHaveClass('navbar--hidden') + }) + + it.each(['/storage/', '/storage/docs/', '/storage/docs/file.ttl'])('hides the navbar within an owned storage at %s', async url => { + vi.spyOn(authn, 'currentUser').mockReturnValue(sym(`${window.location.origin}/profile/card#me`)) + vi.mocked(getPodStorages).mockResolvedValue([sym(`${window.location.origin}/storage/`)]) + window.history.replaceState({}, '', url) + + expect(await createNavbar(navigation)).toHaveClass('navbar--hidden') + }) + + it('shows the navbar for the same storage resource when logged out', async () => { + vi.spyOn(authn, 'currentUser').mockReturnValue(null) + window.history.replaceState({}, '', '/storage/docs/file.ttl') + + expect(await createNavbar(navigation)).not.toHaveClass('navbar--hidden') + expect(getPodStorages).not.toHaveBeenCalled() + }) + + it('updates visibility for resource links even when the navbar items do not change', async () => { + vi.spyOn(authn, 'currentUser').mockReturnValue(sym(`${window.location.origin}/profile/card#me`)) + vi.mocked(getPodStorages).mockResolvedValue([sym(`${window.location.origin}/storage/owned/`)]) + window.history.replaceState({}, '', '/storage/other/file.ttl') + const navbar = await createNavbar(navigation) as HTMLElement & { navbarItems: NavbarMenuItem[] } + const items = navbar.navbarItems + expect(navbar).not.toHaveClass('navbar--hidden') + + window.history.replaceState({}, '', '/storage/owned/file.ttl') + announceNavigation(document) + await vi.waitFor(() => expect(navbar).toHaveClass('navbar--hidden')) + expect(navbar.navbarItems).toBe(items) + + window.history.replaceState({}, '', '/storage/other/file.ttl') + announceNavigation(document) + await vi.waitFor(() => expect(navbar).not.toHaveClass('navbar--hidden')) + }) + + it('updates an existing navbar when moving to and from the own profile', async () => { + vi.spyOn(authn, 'currentUser').mockReturnValue(sym(`${window.location.origin}/profile/card#me`)) + const navbar = document.createElement('solid-panes-navbar') + document.body.appendChild(navbar) + window.history.replaceState({}, '', '/profile/card#me') + + expect(await createNavbar(navigation)).toBe(navbar) + expect(navbar).toHaveClass('navbar--hidden') + + window.history.replaceState({}, '', '/other/profile/card#me') + expect(await createNavbar(navigation)).toBe(navbar) + expect(navbar).not.toHaveClass('navbar--hidden') + }) + + it('matches the actual WebID rather than assuming a #me fragment', async () => { + vi.spyOn(authn, 'currentUser').mockReturnValue(sym(`${window.location.origin}/identity#person`)) + window.history.replaceState({}, '', '/identity#person') + + const navbar = await createNavbar(navigation) + + expect(navbar).toHaveClass('navbar--hidden') + }) + + describe('built from the pod the page is in', () => { + it('offers Profile and Friends only when the owner of the pod is known', async () => { + window.history.replaceState({}, '', '/other/container/') + + const unknown = await createNavbar(navigation) as HTMLElement & { navbarItems: NavbarMenuItem[] } + expect(unknown.navbarItems.map(item => item.paneName)).toEqual([]) + + document.body.replaceChildren() + resetPodContexts() + window.history.replaceState({}, '', '/other/profile/card#me') + + const known = await createNavbar(navigation) as HTMLElement & { navbarItems: NavbarMenuItem[] } + expect(known.navbarItems.map(item => item.paneName)).toEqual(['profile', 'social']) + }) + + it('selects Profile on the WebID, but nothing on the document that holds it', async () => { + loadProfile.mockResolvedValue(sym(`${window.location.origin}/timea2/profile/card#me`)) + + window.history.replaceState({}, '', '/timea2/profile/card#me') + const onWebId = await createNavbar(navigation) as HTMLElement & { navbarItems: NavbarMenuItem[] } + expect(onWebId.navbarItems.filter(item => item.selected).map(item => item.paneName)).toEqual(['profile']) + + document.body.replaceChildren() + window.history.replaceState({}, '', '/timea2/profile/card') + const onDocument = await createNavbar(navigation) as HTMLElement & { navbarItems: NavbarMenuItem[] } + expect(onDocument.navbarItems.map(item => item.paneName)).toEqual(['profile', 'social']) + expect(onDocument.navbarItems.filter(item => item.selected)).toEqual([]) + }) + + it('selects nothing on other pages of the pod', async () => { + loadProfile.mockResolvedValue(sym(`${window.location.origin}/timea2/profile/card#me`)) + window.history.replaceState({}, '', '/timea2/docs/') + + const navbar = await createNavbar(navigation) as HTMLElement & { navbarItems: NavbarMenuItem[] } + + expect(navbar.navbarItems.map(item => item.paneName)).toEqual(['profile', 'social']) + expect(navbar.navbarItems.filter(item => item.selected)).toEqual([]) + }) + + it('asks the controller to display what is chosen', async () => { + const show = vi.fn().mockResolvedValue(undefined) + const owner = sym(`${window.location.origin}/a/profile/card#me`) + const storage = folderPane(sym(`${window.location.origin}/a/`)) + loadProfile.mockResolvedValue(owner) + vi.mocked(getFolderPanesFromURI).mockResolvedValue([storage]) + window.history.replaceState({}, '', '/a/docs/first') + + const navbar = await createNavbar({ show } as unknown as NavigationController) as HTMLElement & { navbarItems: NavbarMenuItem[] } + for (const item of navbar.navbarItems) { + navbar.dispatchEvent(new CustomEvent('solid-ui-select', { detail: item, bubbles: true })) + } + + await vi.waitFor(() => expect(show).toHaveBeenCalledTimes(3)) + expect(show.mock.calls.map(call => call[0])).toEqual([ + { kind: 'profile', subject: owner.value }, + { kind: 'friends', subject: owner.value }, + { kind: 'storage', pane: storage } + ]) + }) + + describe('when a navigation moves within or between pods', () => { + const ownerOf = (pod: string) => sym(`${window.location.origin}/${pod}/profile/card#me`) + + beforeEach(() => { + loadProfile.mockImplementation(async (subject: ReturnType) => { + const [pod] = new URL(subject.uri).pathname.split('/').filter(Boolean) + return ownerOf(pod) + }) + }) + + it('builds the items again for the new pod, with the selection of the new entry', async () => { + window.history.replaceState({}, '', '/a/profile/card#me') + const navbar = await createNavbar(navigation) as HTMLElement & { navbarItems: NavbarMenuItem[] } + expect(navbar.navbarItems.map(item => item.paneUri)).toEqual([ownerOf('a').value, ownerOf('a').value]) + + window.history.replaceState({ paneName: 'social', paneUri: ownerOf('b').value }, '', '/b/docs/') + announceNavigation(document) + + await vi.waitFor(() => { + expect(navbar.navbarItems.map(item => item.paneUri)).toEqual([ownerOf('b').value, ownerOf('b').value]) + }) + expect(navbar.navbarItems.filter(item => item.selected).map(item => item.paneName)).toEqual(['social']) + }) + + it('keeps the items for another page in the same pod', async () => { + window.history.replaceState({}, '', '/a/profile/card#me') + const navbar = await createNavbar(navigation) as HTMLElement & { navbarItems: NavbarMenuItem[] } + const items = navbar.navbarItems + + window.history.replaceState({}, '', '/a/docs/') + announceNavigation(document) + await vi.waitFor(() => expect(navbar.navbarItems.filter(item => item.selected)).toEqual([])) + + expect(navbar.navbarItems.map(item => item.onSelected)).toEqual(items.map(item => item.onSelected)) + expect(navbar.navbarItems.map(item => item.paneUri)).toEqual(items.map(item => item.paneUri)) + }) + + it.each([ + ['social', undefined, '/a/docs/', ['social']], + ['profile', undefined, '/a/docs/', ['profile']], + ['folder', '/a/storage-2/', '/a/docs/', ['folder']], + ['folder', '/a/unknown/', '/a/docs/', []], + ['unknown', undefined, '/a/docs/', []], + [undefined, undefined, '/a/docs/', []], + [undefined, undefined, '/a/profile/card#me', ['profile']] + ])('updates selection for a same-pod direct navigation to %s at %s (%s)', async (paneName, paneUri, url, selectedPanes) => { + const storages = [1, 2].map(index => sym(`${window.location.origin}/a/storage-${index}/`)) + vi.mocked(getFolderPanesFromURI).mockResolvedValue(storages.map(folderPane)) + window.history.replaceState({ paneName: 'social' }, '', '/a/docs/') + const navbar = await createNavbar(navigation) as HTMLElement & { navbarItems: NavbarMenuItem[] } + const items = navbar.navbarItems + expect(items.filter(item => item.selected).map(item => item.paneName)).toEqual(['social']) + vi.mocked(getFolderPanesFromURI).mockClear() + + window.history.replaceState({ + paneName, + paneUri: paneUri ? `${window.location.origin}${paneUri}` : undefined + }, '', url) + announceNavigation(document) + + await vi.waitFor(() => { + expect(navbar.navbarItems.filter(item => item.selected).map(item => item.paneName)).toEqual(selectedPanes) + }) + if (paneName === 'folder' && selectedPanes.length) { + expect(navbar.navbarItems.filter(item => item.selected).map(item => item.paneUri)).toEqual([storages[1].value]) + } + expect(navbar.navbarItems.map(item => item.onSelected)).toEqual(items.map(item => item.onSelected)) + expect(getFolderPanesFromURI).not.toHaveBeenCalled() + }) + + it('stops following navigations once the navbar is gone', async () => { + window.history.replaceState({}, '', '/a/profile/card#me') + await createNavbar(navigation) + document.body.replaceChildren() + loadProfile.mockClear() + resetPodContexts() + + window.history.replaceState({}, '', '/b/docs/') + announceNavigation(document) + await new Promise(resolve => setTimeout(resolve, 20)) + + expect(loadProfile).not.toHaveBeenCalled() + }) + }) + }) +}) diff --git a/test/unit/mainPage/profileHeading.test.ts b/test/unit/mainPage/profileHeading.test.ts new file mode 100644 index 00000000..25323a6f --- /dev/null +++ b/test/unit/mainPage/profileHeading.test.ts @@ -0,0 +1,948 @@ +import { afterEach, describe, expect, it, vi } from 'vitest' +import { authn, authSession, store } from 'solid-logic' +import { lit, sym } from 'rdflib' +import { ns } from 'solid-ui' +import type { ProfileHeadingEditContext } from '../../../src/components/profile-heading/ProfileHeading' + +const { getViewerModeMock, createHeadingEditDialogMock, getPodContextMock, pod } = vi.hoisted(() => ({ + getViewerModeMock: vi.fn(), + createHeadingEditDialogMock: vi.fn(), + getPodContextMock: vi.fn(), + // What the page knows about the pod it is in + pod: { current: { owner: undefined as string | undefined, storagePanes: [] as Array<{ subject: { value: string } }>, viewerStorages: [] as string[] } } +})) + +vi.mock('../../../src/navigation/podContext', async (importOriginal) => ({ + ...await importOriginal(), + getPodContext: async (url: string) => { + getPodContextMock(url) + return pod.current + } +})) + +vi.mock('../../../src/components/profile-heading/editor/sections/heading/HeadingEditDialog', () => ({ + createHeadingEditDialog: createHeadingEditDialogMock +})) + +vi.mock('../../../src/components/profile-heading/profileHeadingData', async (importOriginal) => { + const actual = await importOriginal() + + return { + ...actual, + getViewerMode: getViewerModeMock + } +}) + +vi.mock('../../../src/utils/webIdUtils', async () => { + const actual = await vi.importActual('../../../src/utils/webIdUtils') + return { + ...actual, + loadProfileFromURI: async (subject: ReturnType) => subject + } +}) + +import { initializeProfileHeading, placeProfileHeading, refreshProfileHeading } from '../../../src/mainPage/profileHeading' +import { announceNavigation } from '../../../src/navigation/events' + +function podOf (owner: string | undefined, ...storages: string[]) { + pod.current = { owner, storagePanes: storages.map(value => ({ subject: { value } })), viewerStorages: [] } +} + +afterEach(() => { + document.body.replaceChildren() + window.history.replaceState({}, '', '/') + podOf(undefined) +}) + +describe('page-level profile heading', () => { + it('renders for the active profile pane after concurrent refresh requests', async () => { + const subject = sym('https://profile-heading.example/profile/card#me') + store.add(subject, ns.vcard('fn'), lit('Profile Heading Test'), subject.doc()) + + const mainContent = document.createElement('main') + mainContent.id = 'MainContent' + const navbar = document.createElement('solid-panes-navbar') + const outline = document.createElement('table') + outline.id = 'OutlineView' + mainContent.append(navbar, outline) + document.body.appendChild(mainContent) + window.history.replaceState({ + paneName: 'profile', + paneUri: subject.value + }, '', '/') + + await Promise.all([refreshProfileHeading(), refreshProfileHeading()]) + + const mount = document.getElementById('profile-heading-mount') + const heading = mount?.querySelector('solid-panes-profile-heading') as (HTMLElement & { + profileData?: { name: string } + updateComplete?: Promise + }) | null + await heading?.updateComplete + + expect(mount?.hidden).toBe(false) + expect(mainContent.firstElementChild).toBe(mount) + expect(heading?.profileData?.name).toBe('Profile Heading Test') + expect(heading?.shadowRoot?.querySelector('h1')?.textContent).toBe('Profile Heading Test') + expect(heading?.shadowRoot?.querySelector('.image-frame')).toHaveClass('image-frame--fallback') + expect(heading?.shadowRoot?.querySelector('.hero-fallback icon-lucide-circle-user-round')).not.toBeNull() + expect(heading?.shadowRoot?.querySelector('.profile__heading-edit-action')).toBeNull() + + const name = heading?.shadowRoot?.querySelector('.name') + const dragData = new Map() + const dragStart = new Event('dragstart', { bubbles: true }) + Object.defineProperty(dragStart, 'dataTransfer', { + value: { setData: (type: string, value: string) => dragData.set(type, value) } + }) + name?.dispatchEvent(dragStart) + expect(name).toHaveAttribute('draggable', 'true') + expect(dragData.get('text/uri-list')).toBe(subject.value) + expect(dragData.get('text/plain')).toBe(subject.value) + }) + + it('opens the heading editor from Edit and announces the save to other views', async () => { + const subject = sym('https://edit-flow.example/profile/card#me') + const profileData = { entryNode: subject, name: 'Profile Heading Test' } + const onSaved = vi.fn() + createHeadingEditDialogMock.mockReset().mockImplementation( + async (_event, _store, _subject, _profile, _viewerMode, saved) => saved() + ) + const heading = document.createElement('solid-panes-profile-heading') as HTMLElement & { + profileData?: typeof profileData + editContext?: unknown + updateComplete?: Promise + } + heading.profileData = profileData + heading.editContext = { subject, profileData, viewerMode: 'owner', onSaved } + document.body.appendChild(heading) + await heading.updateComplete + + const headingSaved = vi.fn() + document.addEventListener('profile-heading-saved', headingSaved) + try { + const desktopEditButton = heading.shadowRoot?.querySelector('.desktop-edit-button') + expect(desktopEditButton).toHaveAttribute('variant', 'tertiary') + const mobileEditButton = heading.shadowRoot?.querySelector('.mobile-edit-button') + expect(mobileEditButton).toHaveAttribute('variant', 'ghost') + expect(mobileEditButton?.querySelector('icon-lucide-pencil')).not.toBeNull() + desktopEditButton?.click() + + await vi.waitFor(() => expect(onSaved).toHaveBeenCalledOnce()) + expect(createHeadingEditDialogMock).toHaveBeenCalledWith( + expect.any(Event), store, subject, profileData, 'owner', expect.any(Function) + ) + expect(headingSaved).toHaveBeenCalledOnce() + expect((headingSaved.mock.calls[0][0] as CustomEvent).detail).toEqual({ subjectUri: subject.value }) + } finally { + document.removeEventListener('profile-heading-saved', headingSaved) + } + }) + + it('does not announce a save when the editor is closed without saving', async () => { + const subject = sym('https://edit-flow-cancel.example/profile/card#me') + const profileData = { entryNode: subject, name: 'Profile Heading Test' } + const onSaved = vi.fn() + createHeadingEditDialogMock.mockReset().mockResolvedValue(undefined) + const heading = document.createElement('solid-panes-profile-heading') as HTMLElement & { + profileData?: typeof profileData + editContext?: unknown + updateComplete?: Promise + } + heading.profileData = profileData + heading.editContext = { subject, profileData, viewerMode: 'owner', onSaved } + document.body.appendChild(heading) + await heading.updateComplete + + const headingSaved = vi.fn() + document.addEventListener('profile-heading-saved', headingSaved) + try { + heading.shadowRoot?.querySelector('.desktop-edit-button')?.click() + await vi.waitFor(() => expect(createHeadingEditDialogMock).toHaveBeenCalledOnce()) + expect(headingSaved).not.toHaveBeenCalled() + expect(onSaved).not.toHaveBeenCalled() + } finally { + document.removeEventListener('profile-heading-saved', headingSaved) + } + }) + + it('renders Lucide icons for profile detail rows', async () => { + const heading = document.createElement('solid-panes-profile-heading') as HTMLElement & { + profileData?: { + name: string + dateOfBirth: string + location: string + primaryPhone: { valueNode: ReturnType } + primaryEmail: { valueNode: ReturnType } + } + updateComplete?: Promise + } + heading.profileData = { + name: 'Profile Heading Test', + dateOfBirth: '2001-02-03', + location: 'Example City', + primaryPhone: { valueNode: lit('tel:+123456789') }, + primaryEmail: { valueNode: lit('mailto:person@example.com') } + } + document.body.appendChild(heading) + await heading.updateComplete + + expect(heading.shadowRoot?.querySelector('.detail-icon icon-lucide-cake')).not.toBeNull() + expect(heading.shadowRoot?.querySelector('.detail-icon icon-lucide-map-pin')).not.toBeNull() + expect(heading.shadowRoot?.querySelector('.detail-icon icon-lucide-phone')).not.toBeNull() + expect(heading.shadowRoot?.querySelector('.detail-icon icon-lucide-mail')).not.toBeNull() + }) + + it('rechecks owner edit access after a restored session', async () => { + getViewerModeMock.mockReset() + const subject = sym('https://profile-heading.example/profile/card#me') + let sessionReady = false + const checkUser = vi.spyOn(authn, 'checkUser').mockImplementation(async () => { + sessionReady = true + return subject + }) + getViewerModeMock.mockImplementation(async () => sessionReady ? 'owner' : 'anonymous') + + const mainContent = document.createElement('main') + mainContent.id = 'MainContent' + document.body.appendChild(mainContent) + window.history.replaceState({ + paneName: 'profile', + paneUri: subject.value + }, '', '/') + + initializeProfileHeading() + await refreshProfileHeading(true) + expect(checkUser).toHaveBeenCalledOnce() + + const getHeading = () => document.querySelector('solid-panes-profile-heading') as (HTMLElement & { + editContext?: unknown + updateComplete?: Promise + }) | null + + await vi.waitFor(async () => { + await getHeading()?.updateComplete + expect(getHeading()?.editContext).toBeTruthy() + }) + + sessionReady = false + authSession.events.emit('logout') + + await vi.waitFor(async () => { + await getHeading()?.updateComplete + expect(getHeading()?.editContext).toBeUndefined() + }) + + checkUser.mockRestore() + }) + + it('uses the shell resource URL on each refresh and defaults back to the page URL', async () => { + let resourceUrl = 'https://heading-shell.example/profile/card#me' + await initializeProfileHeading(() => resourceUrl) + await refreshProfileHeading() + expect(getPodContextMock).toHaveBeenLastCalledWith(resourceUrl) + + resourceUrl = 'https://heading-shell.example/public/' + await refreshProfileHeading(true) + expect(getPodContextMock).toHaveBeenLastCalledWith(resourceUrl) + + await initializeProfileHeading() + await refreshProfileHeading() + expect(getPodContextMock).toHaveBeenLastCalledWith(window.location.href) + }) + + it('hides extra information and editing in compact mode, then restores the full heading', async () => { + const heading = document.createElement('solid-panes-profile-heading') as HTMLElement & { + profileData: { + name: string + jobTitle: string + pronouns: string + dateOfBirth: string + location: string + primaryEmail: { valueNode: ReturnType } + } + compact: boolean + editContext: { + subject: ReturnType + profileData: { entryNode: ReturnType; name: string } + viewerMode: 'owner' + onSaved: () => void + } + updateComplete: Promise + } + heading.profileData = { + name: 'Compact Heading Test', + jobTitle: 'Engineer', + pronouns: 'she/her', + dateOfBirth: '2000-01-02', + location: 'Paris, France', + primaryEmail: { valueNode: sym('mailto:compact@example.com') } + } + heading.editContext = { + subject: sym('https://compact-heading.example/profile/card#me'), + profileData: { + entryNode: sym('https://compact-heading.example/profile/card#me'), + name: 'Compact Heading Test' + }, + viewerMode: 'owner', + onSaved: vi.fn() + } + document.body.appendChild(heading) + await heading.updateComplete + const avatar = heading.shadowRoot?.querySelector('.image-frame') + const details = heading.shadowRoot?.querySelector('.details-collapse') + expect(details).toHaveAttribute('aria-hidden', 'false') + expect(heading.shadowRoot?.querySelector('.pronouns')).not.toHaveAttribute('hidden') + + heading.compact = true + await heading.updateComplete + expect(heading).toHaveAttribute('compact') + expect(details).toHaveAttribute('aria-hidden', 'true') + expect(details).toHaveAttribute('inert') + expect(heading.shadowRoot?.querySelector('.pronouns')).toHaveAttribute('hidden') + expect(heading.shadowRoot?.querySelector('.profile__heading-edit-action')).toBeNull() + expect(heading.shadowRoot?.querySelector('.name')?.textContent).toBe('Compact Heading Test') + expect(heading.shadowRoot?.querySelector('.role')?.textContent).toBe('Engineer') + expect(heading.shadowRoot?.querySelector('.image-frame')).toBe(avatar) + + heading.compact = false + await heading.updateComplete + expect(heading).not.toHaveAttribute('compact') + expect(details).not.toHaveAttribute('inert') + expect(details).toHaveAttribute('aria-hidden', 'false') + expect(heading.shadowRoot?.querySelector('.pronouns')).not.toHaveAttribute('hidden') + expect(heading.shadowRoot?.querySelector('.profile__heading-edit-action')).not.toBeNull() + expect(heading.shadowRoot?.querySelector('.image-frame')).toBe(avatar) + }) + + it('only enables heading editing on the profile pane', async () => { + getViewerModeMock.mockReset().mockResolvedValue('owner') + const subject = sym('https://profile-heading.example/profile/card#me') + store.add(subject, ns.vcard('fn'), lit('Profile Heading Test'), subject.doc()) + + const mainContent = document.createElement('main') + mainContent.id = 'MainContent' + document.body.appendChild(mainContent) + + window.history.replaceState({ + paneName: 'social', + paneUri: subject.value + }, '', '/') + await refreshProfileHeading(true) + + const heading = document.querySelector('solid-panes-profile-heading') as (HTMLElement & { + editContext?: unknown + compact?: boolean + updateComplete?: Promise + }) | null + await heading?.updateComplete + expect(heading?.editContext).toBeUndefined() + expect(heading?.compact).toBe(true) + expect(heading?.shadowRoot?.querySelector('.profile__heading-edit-action')).toBeNull() + + window.history.replaceState({ + paneName: 'profile', + paneUri: subject.value + }, '', '/') + await refreshProfileHeading(true) + await heading?.updateComplete + + expect(heading?.editContext).toBeTruthy() + expect(heading?.compact).toBe(false) + expect(heading?.shadowRoot?.querySelector('.profile__heading-edit-action')).not.toBeNull() + + window.history.replaceState({ + paneName: 'social', + paneUri: subject.value + }, '', '/') + await refreshProfileHeading() + await heading?.updateComplete + + expect(document.querySelector('solid-panes-profile-heading')).toBe(heading) + expect(heading?.compact).toBe(true) + expect(heading?.editContext).toBeUndefined() + }) + + it('refreshes the heading job title when the displayed profile saves resume changes', async () => { + const subject = sym('https://resume-heading.example/profile/card#me') + const membership = sym('https://resume-heading.example/profile/card#role') + const doc = subject.doc() + store.add(subject, ns.vcard('fn'), lit('Resume Heading Test'), doc) + store.add(membership, ns.org('member'), subject, doc) + store.add(membership, ns.rdf('type'), ns.solid('CurrentRole'), doc) + store.add(membership, ns.vcard('role'), lit('Engineer'), doc) + getViewerModeMock.mockResolvedValue('owner') + + const mainContent = document.createElement('main') + mainContent.id = 'MainContent' + const profilePane = document.createElement('div') + mainContent.appendChild(profilePane) + document.body.appendChild(mainContent) + window.history.replaceState({ + paneName: 'profile', + paneUri: subject.value + }, '', '/') + initializeProfileHeading() + await refreshProfileHeading(true) + + const heading = document.querySelector('solid-panes-profile-heading') as HTMLElement & { + updateComplete: Promise + } + await heading.updateComplete + expect(heading.shadowRoot?.querySelector('.role')?.textContent).toBe('Engineer') + + store.removeMany(membership, ns.vcard('role'), null, doc) + store.add(membership, ns.vcard('role'), lit('Staff Engineer'), doc) + + profilePane.dispatchEvent(new CustomEvent('profile-pane-saved', { + bubbles: true, + composed: true, + detail: { subjectUri: 'https://unrelated.example/profile/card#me' } + })) + await Promise.resolve() + expect(heading.shadowRoot?.querySelector('.role')?.textContent).toBe('Engineer') + + profilePane.dispatchEvent(new CustomEvent('profile-pane-saved', { + bubbles: true, + composed: true, + detail: { subjectUri: subject.value } + })) + await vi.waitFor(async () => { + await heading.updateComplete + expect(heading.shadowRoot?.querySelector('.role')?.textContent).toBe('Staff Engineer') + }) + + store.removeMany(membership, ns.vcard('role'), null, doc) + profilePane.dispatchEvent(new CustomEvent('profile-pane-saved', { + bubbles: true, + composed: true, + detail: { subjectUri: subject.value } + })) + await vi.waitFor(async () => { + await heading.updateComplete + expect(heading.shadowRoot?.querySelector('.role')).toBeNull() + }) + }) + + it('refreshes heading contact details after More contacts saves additions, edits, and removals', async () => { + const subject = sym('https://contacts-heading.example/profile/card#me') + const doc = subject.doc() + const phone = sym(`${doc.value}#phone`) + const email = sym(`${doc.value}#email`) + const address = sym(`${doc.value}#address`) + store.add(subject, ns.vcard('fn'), lit('Contacts Heading Test'), doc) + getViewerModeMock.mockResolvedValue('owner') + + const mainContent = document.createElement('main') + mainContent.id = 'MainContent' + const profilePane = document.createElement('div') + mainContent.appendChild(profilePane) + document.body.appendChild(mainContent) + window.history.replaceState({ + paneName: 'profile', + paneUri: subject.value + }, '', '/') + initializeProfileHeading() + await refreshProfileHeading(true) + + const heading = document.querySelector('solid-panes-profile-heading') as HTMLElement & { + updateComplete: Promise + } + const values = () => Array.from( + heading.shadowRoot?.querySelectorAll('.detail-value') ?? [], + element => element.textContent + ) + const notifySaved = () => profilePane.dispatchEvent(new CustomEvent('profile-pane-saved', { + bubbles: true, + composed: true, + detail: { subjectUri: subject.value } + })) + await heading.updateComplete + expect(values()).toEqual([]) + + store.add(subject, ns.vcard('hasTelephone'), phone, doc) + store.add(phone, ns.vcard('value'), sym('tel:+123456789'), doc) + store.add(phone, ns.rdf('type'), ns.vcard('Work'), doc) + store.add(subject, ns.vcard('hasEmail'), email, doc) + store.add(email, ns.vcard('value'), sym('mailto:work@example.com'), doc) + store.add(email, ns.rdf('type'), ns.vcard('Work'), doc) + store.add(subject, ns.vcard('hasAddress'), address, doc) + store.add(address, ns.vcard('locality'), lit('Paris'), doc) + store.add(address, ns.vcard('country-name'), lit('France'), doc) + notifySaved() + await vi.waitFor(async () => { + await heading.updateComplete + expect(values()).toEqual(['Paris, France', '+123456789', 'work@example.com']) + }) + + store.removeMany(phone, ns.vcard('value'), null, doc) + store.add(phone, ns.vcard('value'), sym('tel:+987654321'), doc) + store.removeMany(email, ns.vcard('value'), null, doc) + store.add(email, ns.vcard('value'), sym('mailto:updated@example.com'), doc) + store.removeMany(address, ns.vcard('locality'), null, doc) + store.add(address, ns.vcard('locality'), lit('Lyon'), doc) + notifySaved() + await vi.waitFor(async () => { + await heading.updateComplete + expect(values()).toEqual(['Lyon, France', '+987654321', 'updated@example.com']) + }) + + store.removeMany(subject, ns.vcard('hasTelephone'), null, doc) + store.removeMany(subject, ns.vcard('hasEmail'), null, doc) + store.removeMany(subject, ns.vcard('hasAddress'), null, doc) + notifySaved() + await vi.waitFor(async () => { + await heading.updateComplete + expect(values()).toEqual([]) + }) + }) + + it.each(['owner', 'anonymous'] as const)('uses fresh saved data for the heading and editor in %s mode', async (viewerMode) => { + const subject = sym('https://saved-contacts.example/profile/card#me') + store.add(subject, ns.vcard('fn'), lit('Saved Contacts Test'), subject.doc()) + store.add(subject, ns.vcard('hasEmail'), sym('mailto:old@example.com'), subject.doc()) + getViewerModeMock.mockResolvedValue(viewerMode) + createHeadingEditDialogMock.mockReset().mockResolvedValue(undefined) + + const mainContent = document.createElement('main') + mainContent.id = 'MainContent' + document.body.appendChild(mainContent) + window.history.replaceState({ + paneName: 'profile', + paneUri: subject.value + }, '', '/') + initializeProfileHeading() + await refreshProfileHeading(true) + const heading = document.querySelector('solid-panes-profile-heading') as HTMLElement & { + profileData?: unknown + editContext?: ProfileHeadingEditContext + updateComplete: Promise + } + await heading.updateComplete + expect(heading.shadowRoot?.textContent).toContain('old@example.com') + const previousEditContext = heading.editContext + const profileData = { + entryNode: subject, + name: 'Saved Contacts Test', + primaryPhone: { valueNode: sym('tel:+123456789') }, + primaryEmail: { valueNode: sym('mailto:new@example.com') }, + location: 'Lyon, France', + jobTitle: 'Staff Engineer' + } + + mainContent.dispatchEvent(new CustomEvent('profile-pane-saved', { + bubbles: true, + composed: true, + detail: { + subjectUri: subject.value, + profileData + } + })) + await heading.updateComplete + expect(heading.shadowRoot?.textContent).toContain('new@example.com') + expect(heading.shadowRoot?.textContent).toContain('+123456789') + expect(heading.shadowRoot?.textContent).toContain('Lyon, France') + expect(heading.shadowRoot?.querySelector('.role')?.textContent).toBe('Staff Engineer') + expect(heading.shadowRoot?.textContent).not.toContain('old@example.com') + expect(heading.profileData).toBe(profileData) + if (viewerMode === 'owner') { + expect(previousEditContext).toBeDefined() + expect(heading.editContext).not.toBe(previousEditContext) + expect(heading.editContext).toEqual({ ...previousEditContext, profileData }) + expect(heading.editContext?.profileData).toBe(profileData) + expect(heading.editContext?.onSaved).toBe(previousEditContext?.onSaved) + + heading.shadowRoot?.querySelector('.desktop-edit-button')?.click() + await vi.waitFor(() => expect(createHeadingEditDialogMock).toHaveBeenCalledOnce()) + expect(createHeadingEditDialogMock).toHaveBeenCalledWith( + expect.any(Event), store, subject, profileData, viewerMode, expect.any(Function) + ) + } else { + expect(heading.editContext).toBeUndefined() + expect(heading.shadowRoot?.querySelector('.desktop-edit-button')).toBeNull() + } + }) + + it('keeps another person\'s heading visible on their storage', async () => { + const subject = sym('https://another-profile-heading.example/profile/card#me') + const storage = sym('https://profile-heading.example/storage/') + const viewer = sym('https://viewer.example/profile/card#me') + store.add(subject, ns.vcard('fn'), lit('Another Person'), subject.doc()) + podOf(subject.value, storage.value) + + const currentUser = vi.spyOn(authn, 'currentUser').mockReturnValue(viewer) + const mainContent = document.createElement('main') + mainContent.id = 'MainContent' + document.body.appendChild(mainContent) + window.history.replaceState({ + paneName: 'folder', + paneUri: storage.value + }, '', '/') + + await refreshProfileHeading(true) + + const mount = document.getElementById('profile-heading-mount') + const heading = mount?.querySelector('solid-panes-profile-heading') as (HTMLElement & { + profileData?: { name: string } + editContext?: unknown + compact?: boolean + updateComplete?: Promise + }) | null + await heading?.updateComplete + + expect(mount?.hidden).toBe(false) + expect(heading?.profileData?.name).toBe('Another Person') + expect(heading?.editContext).toBeUndefined() + expect(heading?.compact).toBe(true) + expect(heading?.shadowRoot?.querySelector('.profile__heading-edit-action')).toBeNull() + + currentUser.mockRestore() + }) + + it('hides another person\'s heading when the account menu opens the viewer\'s storage', async () => { + const subject = sym(`${window.location.origin}/other/profile/card#me`) + const viewer = sym(`${window.location.origin}/profile/card#me`) + const viewerStorage = `${window.location.origin}/storage/` + const ownStorages = [1, 2].map(index => `${window.location.origin}/other/storage-${index}/`) + podOf(subject.value, ...ownStorages) + const currentUser = vi.spyOn(authn, 'currentUser').mockReturnValue(viewer) + const mainContent = document.createElement('main') + mainContent.id = 'MainContent' + document.body.appendChild(mainContent) + + try { + window.history.replaceState({ paneName: 'profile', paneUri: subject.value }, '', subject.value) + await refreshProfileHeading(true) + const mount = document.getElementById('profile-heading-mount')! + expect(mount.hidden).toBe(false) + + window.history.replaceState({ paneName: 'folder', paneUri: viewerStorage, viaAccountMenu: true }, '', subject.value) + await refreshProfileHeading() + + expect(window.location.href).toBe(subject.value) + expect(mount.hidden).toBe(true) + expect(mount.firstElementChild).toBeNull() + + // The same storage opened another way is just a view of a page in their pod + window.history.replaceState({ paneName: 'folder', paneUri: viewerStorage }, '', subject.value) + await refreshProfileHeading() + expect(mount.hidden).toBe(false) + + window.history.replaceState({ paneName: 'folder', paneUri: ownStorages[1] }, '', subject.value) + await refreshProfileHeading() + expect(mount.hidden).toBe(false) + expect(mount.firstElementChild).not.toBeNull() + } finally { + currentUser.mockRestore() + } + }) + + it('shows a compact heading for the owner on a container in someone else\'s pod', async () => { + const other = sym(`${window.location.origin}/other/profile/card#me`) + const viewer = sym(`${window.location.origin}/profile/card#me`) + store.add(other, ns.vcard('fn'), lit('Pod Owner'), other.doc()) + podOf(other.value) + const currentUser = vi.spyOn(authn, 'currentUser').mockReturnValue(viewer) + const mainContent = document.createElement('main') + mainContent.id = 'MainContent' + document.body.appendChild(mainContent) + + try { + for (const state of [{}, { paneName: 'folder' }, { paneName: 'source' }]) { + window.history.replaceState(state, '', '/other/container/') + await refreshProfileHeading(true) + + const mount = document.getElementById('profile-heading-mount')! + const heading = mount.querySelector('solid-panes-profile-heading') as HTMLElement & { + profileData?: { name: string } + editContext?: unknown + friendSubject?: unknown + compact?: boolean + updateComplete: Promise + } + await heading.updateComplete + expect(mount.hidden).toBe(false) + expect(heading.profileData?.name).toBe('Pod Owner') + expect(heading.compact).toBe(true) + expect(heading.editContext).toBeUndefined() + expect(heading.friendSubject).toBeUndefined() + } + } finally { + currentUser.mockRestore() + } + }) + + it('shows the heading even when the navbar does not exist yet', async () => { + const other = sym(`${window.location.origin}/other/profile/card#me`) + store.add(other, ns.vcard('fn'), lit('Early Owner'), other.doc()) + podOf(other.value) + const currentUser = vi.spyOn(authn, 'currentUser').mockReturnValue(sym(`${window.location.origin}/profile/card#me`)) + const mainContent = document.createElement('main') + mainContent.id = 'MainContent' + document.body.appendChild(mainContent) + window.history.replaceState({}, '', '/other/container/') + + try { + expect(document.querySelector('solid-panes-navbar')).toBeNull() + await refreshProfileHeading(true) + + expect(document.getElementById('profile-heading-mount')?.hidden).toBe(false) + } finally { + currentUser.mockRestore() + } + }) + + it.each([ + ['the viewer\'s own pod', {}, 'viewer'], + ['an account-menu view', { paneName: 'home', viaAccountMenu: true }, 'other'], + ['an account-menu storage view', { paneName: 'folder', paneUri: 'https://x.example/s/', viaAccountMenu: true }, 'other'], + ['a pod without a known owner', {}, 'unknown'] + ])('hides the heading on a container for %s', async (_name, state, owner) => { + const other = sym(`${window.location.origin}/other/profile/card#me`) + const viewer = sym(`${window.location.origin}/profile/card#me`) + const currentUser = vi.spyOn(authn, 'currentUser').mockReturnValue(viewer) + const mainContent = document.createElement('main') + mainContent.id = 'MainContent' + document.body.appendChild(mainContent) + podOf(owner === 'viewer' ? viewer.value : owner === 'other' ? other.value : undefined) + + try { + window.history.replaceState(state, '', '/other/container/') + await refreshProfileHeading(true) + + expect(document.getElementById('profile-heading-mount')?.hidden).toBe(true) + } finally { + currentUser.mockRestore() + } + }) + + it('hides the mount for panes other than profile and social', async () => { + const mainContent = document.createElement('main') + mainContent.id = 'MainContent' + document.body.appendChild(mainContent) + window.history.replaceState({ paneName: 'folder' }, '', '/') + + await refreshProfileHeading() + + expect(document.getElementById('profile-heading-mount')?.hidden).toBe(true) + }) + + it.each(['profile', 'social'])('animates appearance on %s from a pane without a heading', async (paneName) => { + const subject = sym(`https://show-${paneName}.example/profile/card#me`) + getViewerModeMock.mockResolvedValue('owner') + const mainContent = document.createElement('main') + mainContent.id = 'MainContent' + document.body.appendChild(mainContent) + window.history.replaceState({ paneName: 'folder' }, '', '/') + await refreshProfileHeading(true) + const mount = document.getElementById('profile-heading-mount')! + let complete!: () => void + const finished = new Promise(resolve => { complete = resolve }) + const cancel = vi.fn() + const animate = vi.fn(() => ({ finished, cancel })) + Object.defineProperty(mount, 'animate', { value: animate }) + window.history.replaceState({ paneName, paneUri: subject.value }, '', '/') + await refreshProfileHeading() + await refreshProfileHeading() + + expect(animate).toHaveBeenCalledOnce() + expect(animate).toHaveBeenCalledWith([ + expect.objectContaining({ height: '0px', opacity: 0, marginTop: '0px', marginBottom: '0px' }), + expect.objectContaining({ opacity: 1, marginTop: '18px', marginBottom: '20px' }) + ], { duration: 300, easing: 'ease', fill: 'both' }) + const heading = mount.firstElementChild as HTMLElement & { compact: boolean } + expect(heading.compact).toBe(paneName !== 'profile') + expect(heading.shadowRoot?.querySelector('.profile-heading')).not.toBeNull() + expect(mount.hidden).toBe(false) + expect(mount.inert).toBe(false) + complete() + await finished + expect(cancel).toHaveBeenCalledOnce() + expect(mount.firstElementChild).toBe(heading) + expect(mount.hidden).toBe(false) + }) + + it('cancels appearance when navigating away before it finishes', async () => { + const subject = sym('https://cancel-show.example/profile/card#me') + const mainContent = document.createElement('main') + mainContent.id = 'MainContent' + document.body.appendChild(mainContent) + window.history.replaceState({ paneName: 'folder' }, '', '/') + await refreshProfileHeading(true) + const mount = document.getElementById('profile-heading-mount')! + let completeShow!: () => void + let completeHide!: () => void + const shown = new Promise(resolve => { completeShow = resolve }) + const hidden = new Promise(resolve => { completeHide = resolve }) + const cancelShow = vi.fn() + const animate = vi.fn() + .mockReturnValueOnce({ finished: shown, cancel: cancelShow }) + .mockReturnValueOnce({ finished: hidden, cancel: vi.fn() }) + Object.defineProperty(mount, 'animate', { value: animate }) + window.history.replaceState({ paneName: 'social', paneUri: subject.value }, '', '/') + await refreshProfileHeading() + window.history.replaceState({ paneName: 'folder' }, '', '/') + await refreshProfileHeading() + expect(cancelShow).toHaveBeenCalledOnce() + expect(animate).toHaveBeenCalledTimes(2) + completeShow() + await shown + expect(mount.hidden).toBe(false) + completeHide() + await hidden + expect(mount.hidden).toBe(true) + expect(mount.firstElementChild).toBeNull() + }) + + it.each(['profile', 'social'])('animates disappearance from %s before removing the heading', async (paneName) => { + const subject = sym(`https://hide-${paneName}.example/profile/card#me`) + getViewerModeMock.mockResolvedValue('owner') + const mainContent = document.createElement('main') + mainContent.id = 'MainContent' + document.body.appendChild(mainContent) + window.history.replaceState({ paneName, paneUri: subject.value }, '', '/') + await refreshProfileHeading(true) + + const mount = document.getElementById('profile-heading-mount')! + const heading = mount.firstElementChild + let complete!: () => void + const finished = new Promise(resolve => { complete = resolve }) + const cancel = vi.fn() + const animate = vi.fn(() => ({ finished, cancel })) + Object.defineProperty(mount, 'animate', { value: animate }) + window.history.replaceState({ paneName: 'folder' }, '', '/') + await refreshProfileHeading() + await refreshProfileHeading() + + expect(animate).toHaveBeenCalledOnce() + expect(animate).toHaveBeenCalledWith(expect.arrayContaining([ + expect.objectContaining({ height: '0px', opacity: 0, marginTop: '0px', marginBottom: '0px' }) + ]), { duration: 300, easing: 'ease', fill: 'forwards' }) + expect(mount.hidden).toBe(false) + expect(mount.firstElementChild).toBe(heading) + expect(mount.inert).toBe(true) + expect(mount).toHaveAttribute('aria-hidden', 'true') + + complete() + await finished + expect(mount.hidden).toBe(true) + expect(mount.firstElementChild).toBeNull() + expect(cancel).toHaveBeenCalledOnce() + }) + + it('cancels disappearance when navigating back before it finishes', async () => { + const subject = sym('https://cancel-hide.example/profile/card#me') + getViewerModeMock.mockResolvedValue('owner') + const mainContent = document.createElement('main') + mainContent.id = 'MainContent' + document.body.appendChild(mainContent) + window.history.replaceState({ paneName: 'profile', paneUri: subject.value }, '', '/') + await refreshProfileHeading(true) + + const mount = document.getElementById('profile-heading-mount')! + const heading = mount.firstElementChild + let complete!: () => void + const finished = new Promise(resolve => { complete = resolve }) + const cancel = vi.fn() + Object.defineProperty(mount, 'animate', { value: vi.fn(() => ({ finished, cancel })) }) + window.history.replaceState({ paneName: 'folder' }, '', '/') + await refreshProfileHeading() + window.history.replaceState({ paneName: 'social', paneUri: subject.value }, '', '/') + await refreshProfileHeading() + expect(cancel).toHaveBeenCalledOnce() + expect(mount.inert).toBe(false) + expect(mount).not.toHaveAttribute('aria-hidden') + + complete() + await finished + expect(mount.hidden).toBe(false) + expect(mount.firstElementChild).toBe(heading) + }) + + it('skips appearance and disappearance animations when reduced motion is requested', async () => { + const subject = sym('https://reduced-hide.example/profile/card#me') + const mainContent = document.createElement('main') + mainContent.id = 'MainContent' + document.body.appendChild(mainContent) + window.history.replaceState({ paneName: 'social', paneUri: subject.value }, '', '/') + await refreshProfileHeading(true) + const mount = document.getElementById('profile-heading-mount')! + const animate = vi.fn() + Object.defineProperty(mount, 'animate', { value: animate }) + vi.stubGlobal('matchMedia', vi.fn(() => ({ + matches: true, + media: '(prefers-reduced-motion: reduce)', + onchange: null, + addListener: vi.fn(), + removeListener: vi.fn(), + addEventListener: vi.fn(), + removeEventListener: vi.fn(), + dispatchEvent: vi.fn() + }))) + try { + window.history.replaceState({ paneName: 'folder' }, '', '/') + await refreshProfileHeading() + expect(animate).not.toHaveBeenCalled() + expect(mount.hidden).toBe(true) + expect(mount.firstElementChild).toBeNull() + window.history.replaceState({ paneName: 'social', paneUri: subject.value }, '', '/') + await refreshProfileHeading() + expect(animate).not.toHaveBeenCalled() + expect(mount.hidden).toBe(false) + expect(mount.firstElementChild).not.toBeNull() + } finally { + vi.unstubAllGlobals() + } + }) + + describe('following navigations', () => { + async function setup () { + const subject = sym('https://announced.example/profile/card#me') + store.add(subject, ns.vcard('fn'), lit('Announced Person'), subject.doc()) + const mainContent = document.createElement('main') + mainContent.id = 'MainContent' + document.body.appendChild(mainContent) + initializeProfileHeading() + await refreshProfileHeading(true) + const mount = document.getElementById('profile-heading-mount')! + expect(mount.hidden).toBe(true) + return { subject, mainContent, mount } + } + + it('refreshes when a navigation is announced, whoever made it', async () => { + const { subject, mount } = await setup() + + window.history.replaceState({ paneName: 'profile', paneUri: subject.value }, '', '/') + announceNavigation(document) + + await vi.waitFor(() => expect(mount.hidden).toBe(false)) + const heading = mount.querySelector('solid-panes-profile-heading') as HTMLElement & { profileData?: { name: string } } + expect(heading.profileData?.name).toBe('Announced Person') + }) + + it('does not look at what the page has been changed to without a navigation', async () => { + const { subject, mainContent, mount } = await setup() + window.history.replaceState({ paneName: 'profile', paneUri: subject.value }, '', '/') + announceNavigation(document) + await vi.waitFor(() => expect(mount.hidden).toBe(false)) + + window.history.replaceState({}, '', '/') + mainContent.appendChild(document.createElement('div')) + window.dispatchEvent(new PopStateEvent('popstate')) + await new Promise(resolve => setTimeout(resolve, 20)) + + expect(mount.hidden).toBe(false) + }) + + it('places the heading above a navbar that was added after it', async () => { + const { mainContent, mount } = await setup() + const navbar = document.createElement('solid-panes-navbar') + mainContent.insertBefore(navbar, mainContent.firstChild) + expect(mount.nextElementSibling).not.toBe(navbar) + + placeProfileHeading() + + expect(mount.nextElementSibling).toBe(navbar) + expect(mainContent.firstElementChild).toBe(mount) + }) + }) +}) diff --git a/test/unit/mainPage/profileHeadingData.test.ts b/test/unit/mainPage/profileHeadingData.test.ts new file mode 100644 index 00000000..5a684fd9 --- /dev/null +++ b/test/unit/mainPage/profileHeadingData.test.ts @@ -0,0 +1,56 @@ +import { describe, expect, it, vi } from 'vitest' +import { authn, store } from 'solid-logic' +import { lit, sym } from 'rdflib' +import { ns } from 'solid-ui' +import { getViewerMode, presentProfile } from '../../../src/components/profile-heading/profileHeadingData' + +describe('local profile heading presentation', () => { + it('presents profile and contact data from the local RDF store', () => { + const subject = sym('https://local-profile-heading.example/profile/card#me') + const doc = subject.doc() + const email = sym('https://local-profile-heading.example/profile/card#email') + const address = sym('https://local-profile-heading.example/profile/card#address') + const membership = sym('https://local-profile-heading.example/profile/card#role') + + store.add(subject, ns.vcard('fn'), lit('Local Heading'), doc) + store.add(subject, ns.vcard('nickname'), lit('Local Nickname'), doc) + store.add(subject, ns.vcard('bday'), lit('2000-01-02'), doc) + store.add(subject, ns.solid('preferredSubjectPronoun'), lit('they'), doc) + store.add(subject, ns.solid('preferredObjectPronoun'), lit('them'), doc) + store.add(subject, ns.vcard('hasEmail'), email, doc) + store.add(email, ns.vcard('value'), lit('person@example.com'), doc) + store.add(email, ns.rdf('type'), ns.vcard('Work'), doc) + store.add(subject, ns.vcard('hasAddress'), address, doc) + store.add(address, ns.vcard('locality'), lit('Example City'), doc) + store.add(address, ns.vcard('country-name'), lit('Example Country'), doc) + store.add(membership, ns.org('member'), subject, doc) + store.add(membership, ns.rdf('type'), ns.solid('CurrentRole'), doc) + store.add(membership, ns.vcard('role'), lit('Engineer'), doc) + + const profile = presentProfile(subject, store) + + expect(profile.name).toBe('Local Heading') + expect(profile.nickname).toBe('Local Nickname') + expect(profile.dateOfBirth).toBe('2000-01-02') + expect(profile.pronouns).toBe('they/them') + expect(profile.jobTitle).toBe('Engineer') + expect(profile.primaryEmail?.valueNode.value).toBe('person@example.com') + expect(profile.location).toBe('Example City, Example Country') + expect(profile.entryNode).toBe(subject) + }) + + it('determines anonymous and authenticated viewing modes locally', async () => { + const subject = sym('https://local-viewer-mode.example/profile/card#me') + const currentUser = vi.spyOn(authn, 'currentUser') + + try { + currentUser.mockReturnValue(null) + await expect(getViewerMode(subject)).resolves.toBe('anonymous') + + currentUser.mockReturnValue(sym('https://another-user.example/profile/card#me')) + await expect(getViewerMode(subject)).resolves.toBe('authenticated') + } finally { + currentUser.mockRestore() + } + }) +}) diff --git a/test/unit/mainPage/profileHeadingEditor.test.ts b/test/unit/mainPage/profileHeadingEditor.test.ts new file mode 100644 index 00000000..c7e8c664 --- /dev/null +++ b/test/unit/mainPage/profileHeadingEditor.test.ts @@ -0,0 +1,111 @@ +import { afterAll, afterEach, beforeAll, describe, expect, it, vi } from 'vitest' +import { authn, store } from 'solid-logic' +import { lit, sym } from 'rdflib' +import { ns } from 'solid-ui' +import { createHeadingEditDialog, type ProfileDetails } from '../../../src/components/profile-heading/editor' +import { refreshProfileHeading } from '../../../src/mainPage/profileHeading' +import { + getSharedDialogCancelButton, + getSharedDialogSaveButton +} from '../../../src/components/profile-heading/editor/ui/dialog' + +const attachInternalsDescriptor = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'attachInternals') + +vi.mock('../../../src/utils/webIdUtils', () => ({ + loadProfileFromURI: async (subject: ReturnType) => subject +})) + +beforeAll(() => { + Object.defineProperty(HTMLElement.prototype, 'attachInternals', { + configurable: true, + value: () => ({ + setFormValue: () => undefined, + setValidity: () => undefined, + checkValidity: () => true, + reportValidity: () => true, + validity: {}, + validationMessage: '', + willValidate: false, + states: new Set() + }) + }) +}) + +afterEach(() => { + document.body.replaceChildren() + window.history.replaceState({}, '', '/') + vi.restoreAllMocks() +}) + +afterAll(() => { + if (attachInternalsDescriptor) { + Object.defineProperty(HTMLElement.prototype, 'attachInternals', attachInternalsDescriptor) + } else { + Reflect.deleteProperty(HTMLElement.prototype, 'attachInternals') + } +}) + +describe('local profile heading editor', () => { + it('opens the local dialog when the owner clicks Edit on the mounted heading', async () => { + const subject = sym('https://local-heading-editor.example/profile/card#owner') + store.add(subject, ns.vcard('fn'), lit('Heading Owner'), subject.doc()) + vi.spyOn(authn, 'currentUser').mockReturnValue(subject) + vi.spyOn(store.updater, 'editable').mockReturnValue(true) + const consoleError = vi.spyOn(console, 'error') + + const mainContent = document.createElement('main') + mainContent.id = 'MainContent' + document.body.appendChild(mainContent) + window.history.replaceState({ paneName: 'profile', paneUri: subject.value }, '', '/') + await refreshProfileHeading(true) + + const heading = document.querySelector }>('solid-panes-profile-heading') + await heading?.updateComplete + const editButton = heading?.shadowRoot?.querySelector('.desktop-edit-button') + expect(editButton).not.toBeNull() + editButton?.click() + + await vi.waitFor(() => { + expect(document.querySelector('#profile-modal')).toHaveAttribute('open') + expect(document.querySelector('input[name="name"]')?.value).toBe('Heading Owner') + }) + expect(consoleError).not.toHaveBeenCalled() + + getSharedDialogCancelButton(document)?.click() + await vi.waitFor(() => { + expect(document.querySelector('#profile-modal')).not.toHaveAttribute('open') + }) + }) + + it('validates phone input and closes through the local dialog controls', async () => { + const subject = sym('https://local-heading-editor.example/profile/card#me') + const profileData: ProfileDetails = { + entryNode: subject, + name: 'Jane Doe' + } + const resultPromise = createHeadingEditDialog( + new MouseEvent('click', { bubbles: true, composed: true }), + store, + subject, + profileData, + 'owner' + ) + + await vi.waitFor(() => { + expect(document.querySelector('input[name="phone-value"]')).not.toBeNull() + }) + + const phoneInput = document.querySelector('input[name="phone-value"]')! + phoneInput.value = '555 123 4567' + phoneInput.dispatchEvent(new Event('input', { bubbles: true })) + getSharedDialogSaveButton(document)?.click() + + await vi.waitFor(() => { + expect(document.querySelector('#modal-error')?.textContent) + .toBe('Phone Number 1 should contain only numbers.') + }) + + getSharedDialogCancelButton(document)?.click() + await resultPromise + }) +}) diff --git a/test/unit/mainPage/profileHeadingFriends.test.ts b/test/unit/mainPage/profileHeadingFriends.test.ts new file mode 100644 index 00000000..b1d38c66 --- /dev/null +++ b/test/unit/mainPage/profileHeadingFriends.test.ts @@ -0,0 +1,284 @@ +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' +import { authn, store } from 'solid-logic' +import { lit, st, sym } from 'rdflib' +import { ns } from 'solid-ui' +import ProfileHeading from '../../../src/components/profile-heading/ProfileHeading' +import { refreshProfileHeading } from '../../../src/mainPage/profileHeading' + +vi.mock('../../../src/utils/webIdUtils', () => ({ + loadProfileFromURI: async (subject: ReturnType) => subject +})) + +const viewer = sym('https://friends-viewer.example/profile/card#me') +const subject = sym('https://friends-subject.example/profile/card#me') + +beforeEach(() => { + vi.spyOn(authn, 'currentUser').mockReturnValue(viewer) + vi.spyOn(store.fetcher, 'load').mockResolvedValue(new Response()) + vi.spyOn(store, 'whether').mockReturnValue(0) + vi.spyOn(store.updater, 'update').mockResolvedValue(undefined) +}) + +afterEach(() => { + document.body.replaceChildren() + vi.useRealTimers() + vi.restoreAllMocks() + window.history.replaceState({}, '', '/') +}) + +async function createHeading (friendSubject = subject) { + const heading = document.createElement('solid-panes-profile-heading') as ProfileHeading + heading.profileData = { name: 'Friend Test' } + heading.friendSubject = friendSubject + document.body.appendChild(heading) + await vi.waitFor(() => expect(heading.friendState).not.toBe('loading')) + await heading.updateComplete + return heading +} + +function button (heading: ProfileHeading) { + return heading.shadowRoot?.querySelector('.profile__btn-friends') +} + +describe('profile heading friends', () => { + it.each(['success', 'error'])('dismisses %s feedback after exactly 10 seconds', async (result) => { + const heading = await createHeading() + if (result === 'error') { + vi.mocked(store.updater.update).mockRejectedValueOnce(new Error('Write denied')) + } + vi.useFakeTimers() + button(heading)?.click() + await vi.advanceTimersByTimeAsync(0) + expect(heading.shadowRoot?.querySelector('.friend-message')).not.toBeNull() + await vi.advanceTimersByTimeAsync(9999) + expect(heading.shadowRoot?.querySelector('.friend-message')).not.toBeNull() + await vi.advanceTimersByTimeAsync(1) + expect(heading.shadowRoot?.querySelector('.friend-message')).toBeNull() + expect(heading.friendState).toBe(result === 'success' ? 'exists' : 'error') + }) + + it('restarts the dismissal timer for new feedback', async () => { + const heading = await createHeading() + vi.mocked(store.updater.update).mockRejectedValueOnce(new Error('Write denied')) + vi.useFakeTimers() + button(heading)?.click() + await vi.advanceTimersByTimeAsync(5000) + button(heading)?.click() + await vi.advanceTimersByTimeAsync(0) + expect(heading.friendMessage).toBe('Friend was added!') + await vi.advanceTimersByTimeAsync(5000) + expect(heading.friendMessage).toBe('Friend was added!') + await vi.advanceTimersByTimeAsync(5000) + expect(heading.friendMessage).toBe('') + }) + + it('clears the dismissal timer when disconnected', async () => { + const heading = await createHeading() + vi.useFakeTimers() + button(heading)?.click() + await vi.advanceTimersByTimeAsync(0) + expect(vi.getTimerCount()).toBe(1) + heading.remove() + expect(vi.getTimerCount()).toBe(0) + expect(heading.friendMessage).toBe('') + }) + + it('ignores a pending friend check after disconnection', async () => { + let finish: (() => void) | undefined + vi.mocked(store.fetcher.load).mockImplementationOnce(() => new Promise(resolve => { + finish = () => resolve(new Response()) + })) + const heading = document.createElement('solid-panes-profile-heading') as ProfileHeading + heading.profileData = { name: 'Pending' } + heading.friendSubject = subject + document.body.appendChild(heading) + await heading.updateComplete + heading.remove() + vi.mocked(store.whether).mockReturnValue(1) + finish?.() + await new Promise(resolve => setTimeout(resolve, 0)) + expect(heading.friendState).toBe('loading') + }) + + it('ignores a pending friend addition after disconnection', async () => { + const heading = await createHeading() + let finish: (() => void) | undefined + vi.mocked(store.updater.update).mockImplementationOnce(() => new Promise(resolve => { + finish = () => resolve(undefined) + })) + vi.useFakeTimers() + button(heading)?.click() + await vi.advanceTimersByTimeAsync(0) + expect(heading.friendState).toBe('saving') + heading.remove() + finish?.() + await vi.advanceTimersByTimeAsync(0) + expect(heading.friendState).toBe('saving') + expect(heading.friendMessage).toBe('') + expect(vi.getTimerCount()).toBe(0) + }) + + it('rechecks an interrupted friend request when reconnected', async () => { + const heading = await createHeading() + let finish: (() => void) | undefined + vi.mocked(store.updater.update).mockImplementationOnce(() => new Promise(resolve => { + finish = () => resolve(undefined) + })) + button(heading)?.click() + await vi.waitFor(() => expect(store.updater.update).toHaveBeenCalled()) + heading.remove() + vi.mocked(store.whether).mockReturnValue(1) + finish?.() + document.body.appendChild(heading) + await vi.waitFor(() => expect(heading.friendState).toBe('exists')) + expect(heading.friendMessage).toBe('') + }) + + it('checks the viewer profile and adds foaf:knows in that document', async () => { + const heading = await createHeading() + expect(store.fetcher.load).toHaveBeenCalledWith(viewer) + expect(button(heading)?.textContent).toBe('Add as friend') + expect(button(heading)?.querySelector('icon-lucide-user-round-plus')).toHaveAttribute('slot', 'icon') + button(heading)?.click() + button(heading)?.click() + await vi.waitFor(() => expect(heading.friendState).toBe('exists')) + await heading.updateComplete + expect(button(heading)?.querySelector('icon-lucide-user-round-plus')).toBeNull() + expect(store.updater.update).toHaveBeenCalledExactlyOnceWith( + [], [st(viewer, ns.foaf('knows'), subject, viewer.doc())] + ) + expect(button(heading)).toHaveAttribute('disabled') + expect(button(heading)?.textContent).toBe('Already a friend') + const message = heading.shadowRoot?.querySelector('.friend-message') + expect(message).toHaveAttribute('role', 'status') + expect(message?.textContent).toContain('Friend was added!') + expect(heading.shadowRoot?.activeElement).toBe(message) + }) + + it('disables the button for an existing friend', async () => { + vi.mocked(store.whether).mockReturnValue(1) + const heading = await createHeading() + expect(button(heading)).toHaveAttribute('disabled') + expect(button(heading)?.textContent).toBe('Already a friend') + expect(button(heading)?.querySelector('icon-lucide-user-round-plus')).toBeNull() + button(heading)?.dispatchEvent(new Event('click')) + expect(store.updater.update).not.toHaveBeenCalled() + }) + + it('shows update errors and supports retry without stale feedback', async () => { + vi.mocked(store.updater.update).mockRejectedValueOnce(new Error('Write denied')) + const heading = await createHeading() + button(heading)?.click() + await vi.waitFor(() => expect(heading.friendState).toBe('error')) + await heading.updateComplete + expect(heading.shadowRoot?.querySelector('[role="alert"]')?.textContent).toContain('Write denied') + button(heading)?.click() + await vi.waitFor(() => expect(heading.friendState).toBe('exists')) + await heading.updateComplete + expect(heading.shadowRoot?.querySelector('[role="alert"]')).toBeNull() + expect(heading.friendMessage).toBe('Friend was added!') + }) + + it('shows load errors rather than enabling an unchecked action', async () => { + vi.mocked(store.fetcher.load).mockRejectedValueOnce(new Error('Profile unavailable')) + const heading = await createHeading() + expect(heading.friendState).toBe('error') + expect(heading.shadowRoot?.querySelector('[role="alert"]')?.textContent).toContain('Profile unavailable') + expect(store.updater.update).not.toHaveBeenCalled() + }) + + it('maps unauthenticated update errors to the original login message', async () => { + vi.mocked(store.updater.update).mockRejectedValueOnce(new Error('Unauthenticated')) + const heading = await createHeading() + button(heading)?.click() + await vi.waitFor(() => expect(heading.friendState).toBe('error')) + expect(heading.friendMessage).toBe('Current user not found! Not logged in?') + }) + + it('rejects a friendship that was added after the initial check', async () => { + const heading = await createHeading() + vi.mocked(store.whether).mockReturnValue(1) + button(heading)?.click() + await vi.waitFor(() => expect(heading.friendState).toBe('error')) + expect(heading.friendMessage).toBe('Friend already exists') + expect(store.updater.update).not.toHaveBeenCalled() + }) + + it('does not write if the viewer logs out while loading their profile', async () => { + const heading = await createHeading() + vi.mocked(store.fetcher.load).mockImplementationOnce(async () => { + vi.mocked(authn.currentUser).mockReturnValue(null) + return new Response() + }) + button(heading)?.click() + await vi.waitFor(() => expect(heading.friendState).toBe('error')) + expect(store.updater.update).not.toHaveBeenCalled() + }) + + it('ignores a stale friend check after navigation', async () => { + let finish: (() => void) | undefined + vi.mocked(store.fetcher.load).mockImplementationOnce(() => new Promise(resolve => { + finish = () => resolve(new Response()) + })) + const heading = document.createElement('solid-panes-profile-heading') as ProfileHeading + heading.profileData = { name: 'First' } + heading.friendSubject = subject + document.body.appendChild(heading) + await heading.updateComplete + heading.friendSubject = sym('https://second-friend.example/#me') + await vi.waitFor(() => expect(heading.friendState).toBe('available')) + vi.mocked(store.whether).mockReturnValue(1) + finish?.() + await Promise.resolve() + await heading.updateComplete + expect(heading.friendState).toBe('available') + }) + + it('keeps the friend action but hides Edit in the compact heading', async () => { + const heading = await createHeading() + heading.editContext = { + subject, + profileData: { name: 'Friend Test', entryNode: subject }, + viewerMode: 'owner', + onSaved: vi.fn() + } + heading.compact = true + await heading.updateComplete + expect(button(heading)).not.toBeNull() + expect(heading.shadowRoot?.querySelector('.desktop-edit-button')).toBeNull() + }) + + it('places friends before Edit when both actions are provided', async () => { + const heading = await createHeading() + heading.editContext = { + subject, + profileData: { name: 'Friend Test', entryNode: subject }, + viewerMode: 'owner', + onSaved: vi.fn() + } + await heading.updateComplete + expect(heading.shadowRoot?.querySelector('.profile__actions solid-ui-button')).toBe(button(heading)) + expect(heading.shadowRoot?.querySelector('.desktop-edit-button')).not.toBeNull() + }) + + it.each([ + ['profile', viewer, subject, true], + ['profile', viewer, viewer, false], + ['profile', null, subject, false], + ['social', viewer, subject, true], + ['social', viewer, viewer, false], + ['profile', viewer, sym('https://new-friend.example/#me'), true] + ])('gates the action for pane %s, viewer %s, subject %s', async (paneName, me, viewed, visible) => { + vi.mocked(authn.currentUser).mockReturnValue(me) + store.add(viewed, ns.vcard('fn'), lit('Gating Test'), viewed.doc()) + const main = document.createElement('main') + main.id = 'MainContent' + document.body.appendChild(main) + window.history.replaceState({ paneName, paneUri: viewed.value }, '', '/') + await refreshProfileHeading(true) + const heading = main.querySelector('solid-panes-profile-heading') + await heading?.updateComplete + expect(Boolean(button(heading!))).toBe(visible) + expect(Boolean(heading?.friendSubject)).toBe(visible) + }) +}) diff --git a/test/unit/mainPage/profileHeadingImage.test.ts b/test/unit/mainPage/profileHeadingImage.test.ts new file mode 100644 index 00000000..08a29276 --- /dev/null +++ b/test/unit/mainPage/profileHeadingImage.test.ts @@ -0,0 +1,28 @@ +import { afterEach, describe, expect, it } from 'vitest' +import type ProfileHeading from '../../../src/components/profile-heading/ProfileHeading' +import '../../../src/components/profile-heading/ProfileHeading' + +afterEach(() => { + document.body.replaceChildren() +}) + +describe('profile heading image fallback', () => { + it('retries an image source that failed earlier once the source changes and returns', async () => { + const heading = document.createElement('solid-panes-profile-heading') as ProfileHeading + heading.profileData = { name: 'Image Test', imageSrc: 'https://example.org/a.png' } + document.body.appendChild(heading) + await heading.updateComplete + + heading.shadowRoot?.querySelector('img')?.dispatchEvent(new Event('error')) + await heading.updateComplete + expect(heading.shadowRoot?.querySelector('img')).toBeNull() + + heading.profileData = { name: 'Image Test', imageSrc: 'https://example.org/b.png' } + await heading.updateComplete + expect(heading.shadowRoot?.querySelector('img')?.getAttribute('src')).toBe('https://example.org/b.png') + + heading.profileData = { name: 'Image Test', imageSrc: 'https://example.org/a.png' } + await heading.updateComplete + expect(heading.shadowRoot?.querySelector('img')?.getAttribute('src')).toBe('https://example.org/a.png') + }) +}) diff --git a/test/unit/mainPage/reload.test.ts b/test/unit/mainPage/reload.test.ts new file mode 100644 index 00000000..b0cd8e2a --- /dev/null +++ b/test/unit/mainPage/reload.test.ts @@ -0,0 +1,241 @@ +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' +import { authn, authSession, store } from 'solid-logic' +import { lit, sym } from 'rdflib' +import { ns } from 'solid-ui' + +const { getViewerModeMock, loadProfile, outlinerHolder, byName } = vi.hoisted(() => ({ + getViewerModeMock: vi.fn(), + loadProfile: vi.fn(), + outlinerHolder: { current: undefined as undefined | { GotoSubject: (...args: unknown[]) => void } }, + byName: (name: string) => ({ + name, + icon: '', + label: () => name, + render: (subject: { value: string }) => { + const div = document.createElement('div') + div.textContent = `${name} pane for ${subject.value}` + return div + } + }) +})) + +vi.mock('pane-registry', () => ({ byName })) + +vi.mock('../../../src/components/profile-heading/profileHeadingData', async (importOriginal) => ({ + ...await importOriginal(), + getViewerMode: getViewerModeMock +})) +vi.mock('../../../src/utils/webIdUtils', async (importOriginal) => ({ + ...await importOriginal(), + loadProfileFromURI: loadProfile +})) +vi.mock('../../../src/utils/podUtils', async (importOriginal) => ({ + ...await importOriginal(), + getPodStorages: async () => [], + loadContainerRepresentation: async () => undefined +})) +vi.mock('../../../src/mainPage/header', () => ({ createHeader: vi.fn() })) +vi.mock('../../../src/index', async () => { + const { default: OutlineManager } = await import('../../../src/outline/manager') + const paneRegistry = { list: [], byName } + return { + getOutliner: () => { + const outliner = new OutlineManager({ dom: document, session: { store, paneRegistry } }) + outlinerHolder.current = outliner + return outliner + } + } +}) + +import { initMainPage } from '../../../src/mainPage' +import { resetPodContexts } from '../../../src/navigation/podContext' + +// Without a profile of its own, the lookup answers with the URL it was asked about +const noProfile = async (subject: ReturnType) => subject + +beforeEach(() => { + loadProfile.mockImplementation(noProfile) +}) + +afterEach(() => { + vi.restoreAllMocks() + resetPodContexts() + document.body.replaceChildren() + window.history.replaceState({}, '', '/') +}) + +describe('page reload of a WebID', () => { + it.each([ + ['after using the account menu', (webId: string) => ({ + paneName: 'folder', + paneUri: `${window.location.origin}/storage/`, + viaAccountMenu: true + })], + ['after selecting Friends in the navbar', (webId: string) => ({ paneName: 'social', paneUri: webId })] + ])('shows the profile with the profile selected in the navbar and its heading %s', async (_name, savedState) => { + const viewer = sym(`${window.location.origin}/profile/card#me`) + const other = sym(`${window.location.origin}/other/profile/card#me`) + store.add(other, ns.vcard('fn'), lit('Someone Else'), other.doc()) + vi.spyOn(authn, 'currentUser').mockReturnValue(viewer) + vi.spyOn(authn, 'checkUser').mockResolvedValue(viewer) + vi.spyOn(authSession.events, 'on').mockImplementation(() => {}) + getViewerModeMock.mockResolvedValue('visitor') + window.history.replaceState(savedState(other.value), '', other.value) + + await initMainPage(store) + const mount = document.getElementById('profile-heading-mount')! + await vi.waitFor(() => expect(mount.querySelector('solid-panes-profile-heading')).not.toBeNull()) + const heading = mount.querySelector('solid-panes-profile-heading') as HTMLElement & { + profileData?: { name: string } + } + const navbar = document.querySelector('solid-panes-navbar') as HTMLElement & { + navbarItems: Array<{ paneName?: string, selected?: boolean }> + } + + expect(mount.nextElementSibling).toBe(navbar) + expect(window.location.href).toBe(other.value) + expect(window.history.state).toMatchObject({ paneName: 'profile', paneUri: other.value }) + expect(window.history.state).not.toHaveProperty('viaAccountMenu') + expect(mount.hidden).toBe(false) + expect(heading.profileData?.name).toBe('Someone Else') + expect(navbar).not.toHaveClass('navbar--hidden') + expect(navbar.navbarItems.filter(item => item.selected).map(item => item.paneName)).toEqual(['profile']) + }) +}) + +describe('page reload of the document that holds a WebID', () => { + it('shows the document and its content like any other resource, not the profile', async () => { + const viewer = sym(`${window.location.origin}/profile/card#me`) + const webId = sym(`${window.location.origin}/other/profile/card#me`) + loadProfile.mockResolvedValue(webId) + vi.spyOn(authn, 'currentUser').mockReturnValue(viewer) + vi.spyOn(authn, 'checkUser').mockResolvedValue(viewer) + vi.spyOn(authSession.events, 'on').mockImplementation(() => {}) + window.history.replaceState({ paneName: 'social', paneUri: webId.value }, '', webId.doc().uri) + + await initMainPage(store) + const provider = await vi.waitFor(() => { + const element = document.querySelector('solid-ui-file-explorer-provider') + expect(element).not.toBeNull() + return element! + }) + const navbar = document.querySelector('solid-panes-navbar') as HTMLElement & { + navbarItems: Array<{ paneName?: string, selected?: boolean }> + } + + const mount = document.getElementById('profile-heading-mount')! + await vi.waitFor(() => expect(mount.querySelector('solid-panes-profile-heading')).not.toBeNull()) + expect(mount.hidden).toBe(false) + expect(navbar).not.toHaveClass('navbar--hidden') + expect(window.location.href).toBe(webId.doc().uri) + expect(provider.subjectUri).toBe(webId.doc().uri) + expect(provider.querySelector('solid-ui-file-explorer-header')).not.toBeNull() + expect(provider.pane?.name).not.toBe('profile') + expect(window.history.state?.paneName).toBeUndefined() + expect(navbar.navbarItems.filter(item => item.selected)).toEqual([]) + }) + + it('leaves other pages of the pod showing what they show', async () => { + const viewer = sym(`${window.location.origin}/profile/card#me`) + loadProfile.mockResolvedValue(sym(`${window.location.origin}/other/profile/card#me`)) + vi.spyOn(authn, 'currentUser').mockReturnValue(viewer) + vi.spyOn(authn, 'checkUser').mockResolvedValue(viewer) + vi.spyOn(authSession.events, 'on').mockImplementation(() => {}) + window.history.replaceState({}, '', '/other/docs/') + + await initMainPage(store) + const navbar = document.querySelector('solid-panes-navbar') as HTMLElement & { + navbarItems: Array<{ selected?: boolean }> + } + + expect(window.history.state?.paneName).toBeUndefined() + expect(navbar.navbarItems.filter(item => item.selected)).toEqual([]) + }) + + it.each([ + ['a container', '/other/docs/'], + ['a resource', '/other/docs/notes.ttl'] + ])('shows %s with its file explorer header without session.logic, even after a storage was selected', async (_name, url) => { + const viewer = sym(`${window.location.origin}/profile/card#me`) + loadProfile.mockResolvedValue(sym(`${window.location.origin}/other/profile/card#me`)) + vi.spyOn(authn, 'currentUser').mockReturnValue(viewer) + vi.spyOn(authn, 'checkUser').mockResolvedValue(viewer) + vi.spyOn(authSession.events, 'on').mockImplementation(() => {}) + window.history.replaceState({ paneName: 'folder', paneUri: `${window.location.origin}/other/` }, '', url) + + await initMainPage(store) + const provider = await vi.waitFor(() => { + const element = document.querySelector('solid-ui-file-explorer-provider') + expect(element).not.toBeNull() + return element! + }) + + expect(provider.subjectUri).toBe(`${window.location.origin}${url}`) + expect(provider.querySelector('solid-ui-file-explorer-header')).not.toBeNull() + expect(window.history.state?.paneName).toBeUndefined() + expect(window.location.pathname).toBe(url) + }) +}) + +describe('a link into another pod, made by a package that does not use the controller', () => { + const ownerOf = (pod: string) => sym(`${window.location.origin}/${pod}/profile/card#me`) + + it('brings the heading and the navbar along to the other pod', async () => { + const viewer = sym(`${window.location.origin}/profile/card#me`) + store.add(ownerOf('a'), ns.vcard('fn'), lit('Owner A'), ownerOf('a').doc()) + store.add(ownerOf('b'), ns.vcard('fn'), lit('Owner B'), ownerOf('b').doc()) + loadProfile.mockImplementation(async (subject: ReturnType) => { + const [pod] = new URL(subject.uri).pathname.split('/').filter(Boolean) + return ownerOf(pod) + }) + vi.spyOn(authn, 'currentUser').mockReturnValue(viewer) + vi.spyOn(authn, 'checkUser').mockResolvedValue(viewer) + vi.spyOn(authSession.events, 'on').mockImplementation(() => {}) + getViewerModeMock.mockResolvedValue('visitor') + window.history.replaceState({}, '', ownerOf('a').uri) + + await initMainPage(store) + const mount = document.getElementById('profile-heading-mount')! + const navbar = document.querySelector('solid-panes-navbar') as HTMLElement & { navbarItems: Array<{ paneUri?: string }> } + const heading = () => mount.querySelector('solid-panes-profile-heading') as HTMLElement & { profileData?: { name: string }, compact?: boolean } + await vi.waitFor(() => expect(heading()?.profileData?.name).toBe('Owner A')) + expect(navbar.navbarItems.map(item => item.paneUri)).toEqual([ownerOf('a').value, ownerOf('a').value]) + + // As the links and buttons in solid-ui do + outlinerHolder.current!.GotoSubject(store.sym(`${window.location.origin}/b/docs/`), true, undefined, true) + + await vi.waitFor(() => expect(heading()?.profileData?.name).toBe('Owner B')) + expect(heading().compact).toBe(true) + await vi.waitFor(() => { + expect(navbar.navbarItems.map(item => item.paneUri)).toEqual([ownerOf('b').value, ownerOf('b').value]) + }) + expect(window.location.pathname).toBe('/b/docs/') + }) + + it('takes the navbar back to the first pod when going back', async () => { + const viewer = sym(`${window.location.origin}/profile/card#me`) + store.add(ownerOf('a'), ns.vcard('fn'), lit('Owner A'), ownerOf('a').doc()) + store.add(ownerOf('b'), ns.vcard('fn'), lit('Owner B'), ownerOf('b').doc()) + loadProfile.mockImplementation(async (subject: ReturnType) => { + const [pod] = new URL(subject.uri).pathname.split('/').filter(Boolean) + return ownerOf(pod) + }) + vi.spyOn(authn, 'currentUser').mockReturnValue(viewer) + vi.spyOn(authn, 'checkUser').mockResolvedValue(viewer) + vi.spyOn(authSession.events, 'on').mockImplementation(() => {}) + getViewerModeMock.mockResolvedValue('visitor') + window.history.replaceState({}, '', `${window.location.origin}/a/`) + + await initMainPage(store) + const navbar = document.querySelector('solid-panes-navbar') as HTMLElement & { navbarItems: Array<{ paneUri?: string }> } + const owners = () => navbar.navbarItems.map(item => item.paneUri) + await vi.waitFor(() => expect(owners()).toEqual([ownerOf('a').value, ownerOf('a').value])) + + outlinerHolder.current!.GotoSubject(store.sym(`${window.location.origin}/b/docs/`), true, undefined, true) + await vi.waitFor(() => expect(owners()).toEqual([ownerOf('b').value, ownerOf('b').value])) + + window.history.back() + await vi.waitFor(() => expect(window.location.pathname).toBe('/a/')) + await vi.waitFor(() => expect(owners()).toEqual([ownerOf('a').value, ownerOf('a').value])) + }) +}) diff --git a/test/unit/navigation/browserEvents.test.ts b/test/unit/navigation/browserEvents.test.ts new file mode 100644 index 00000000..a0dd37cb --- /dev/null +++ b/test/unit/navigation/browserEvents.test.ts @@ -0,0 +1,256 @@ +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' +import type { NavigationController } from '../../../src/navigation/controller' + +type Listener = (event: unknown) => void + +const listeners: Record = {} +let show: ReturnType +let controller: NavigationController + +function defineNavigationApi () { + Object.defineProperty(window, 'navigation', { + configurable: true, + value: { addEventListener: (type: string, listener: Listener) => { listeners[type] = listener } } + }) +} + +// The module keeps the listeners it added, so each test starts from a fresh copy of it +async function freshModule () { + vi.resetModules() + return import('../../../src/navigation/browserEvents') +} + +// Enter on a URL ending in #me is a fragment navigation to the same URL +function enter (overrides: object = {}) { + const intercept = vi.fn() + listeners.navigate({ + canIntercept: true, + userInitiated: true, + navigationType: 'replace', + hashChange: true, + destination: { url: window.location.href, sameDocument: true }, + intercept, + ...overrides + }) + return intercept +} + +// What Safari dispatches for history.replaceState during a tap +function historyWrite (intercept: ReturnType) { + listeners.navigate({ + canIntercept: true, + userInitiated: true, + navigationType: 'replace', + hashChange: false, + destination: { url: window.location.href, sameDocument: true }, + intercept + }) +} + +const traverse = (navigationType = 'traverse') => listeners.currententrychange({ navigationType }) +const nextTask = () => new Promise(resolve => setTimeout(resolve, 5)) + +beforeEach(() => { + for (const key of Object.keys(listeners)) delete listeners[key] + show = vi.fn().mockResolvedValue(undefined) + controller = { show } as unknown as NavigationController + defineNavigationApi() + window.history.replaceState({ paneName: 'folder', paneUri: 'https://pod.example/', viaAccountMenu: true, other: 'kept' }, '', '/page') +}) + +afterEach(() => { + vi.restoreAllMocks() + Reflect.deleteProperty(window, 'navigation') + window.history.replaceState(null, '', '/') +}) + +describe('Enter on the current URL', () => { + it('shows what the URL is, after forgetting what the entry displayed', async () => { + const { registerBrowserNavigation } = await freshModule() + registerBrowserNavigation(controller) + + const intercept = enter() + expect(intercept).toHaveBeenCalledOnce() + expect(intercept.mock.calls[0][0]).toMatchObject({ scroll: 'manual', focusReset: 'manual' }) + await intercept.mock.calls[0][0].handler() + + expect(window.history.state).toEqual({ other: 'kept' }) + expect(show).toHaveBeenCalledWith({ kind: 'restore', forceHeading: true }) + }) + + it('also handles Enter on a URL without a fragment, which is a cross-document navigation', async () => { + const { registerBrowserNavigation } = await freshModule() + registerBrowserNavigation(controller) + + expect(enter({ hashChange: false, destination: { url: window.location.href, sameDocument: false } })).toHaveBeenCalledOnce() + }) + + it.each([ + ['not started by the user', { userInitiated: false }], + ['not a replacement of the entry', { navigationType: 'push' }], + ['one that cannot be intercepted', { canIntercept: false }], + ['to another URL', { destination: { url: 'https://elsewhere.example/', sameDocument: false } }], + ['a history API write', { hashChange: false }], + ['a history API write with same-document metadata omitted', { + hashChange: false, + destination: { url: window.location.href, sameDocument: undefined } + }] + ])('leaves a navigation alone when it is %s', async (_name, overrides) => { + const { registerBrowserNavigation } = await freshModule() + registerBrowserNavigation(controller) + + expect(enter(overrides)).not.toHaveBeenCalled() + expect(show).not.toHaveBeenCalled() + expect(window.history.state).toMatchObject({ paneName: 'folder' }) + }) +}) + +describe('application history writes in Safari', () => { + it('keeps a storage selection when replaceState dispatches a user-initiated navigate event', async () => { + const { registerBrowserNavigation } = await freshModule() + const { default: OutlineManager } = await import('../../../src/outline/manager') + const { sym } = await import('rdflib') + registerBrowserNavigation(controller) + window.history.replaceState({}, '', '/other/profile/card#me') + + const original = window.history.replaceState.bind(window.history) + const intercept = vi.fn() + const replace = vi.spyOn(window.history, 'replaceState').mockImplementation((state, title, url) => { + historyWrite(intercept) + original(state, title, url) + }) + const subject = sym(window.location.href) + const storage = sym(`${window.location.origin}/other/`) + const manager = new OutlineManager({ dom: document, session: { paneRegistry: { list: [], byName: () => undefined } } }) + + manager.GotoSubject(subject, false, { name: 'folder', subject: storage }, true) + + expect(replace).toHaveBeenCalledOnce() + expect(intercept).not.toHaveBeenCalled() + expect(show).not.toHaveBeenCalled() + expect(window.history.state).toMatchObject({ paneName: 'folder', paneUri: storage.uri }) + expect(window.location.href).toBe(subject.uri) + document.body.replaceChildren() + }, 15_000) + + it('does not re-intercept the history write while handling address-bar navigation', async () => { + const { registerBrowserNavigation } = await freshModule() + registerBrowserNavigation(controller) + const original = window.history.replaceState.bind(window.history) + const nestedIntercept = vi.fn() + vi.spyOn(window.history, 'replaceState').mockImplementation((state, title, url) => { + historyWrite(nestedIntercept) + original(state, title, url) + }) + + await enter().mock.calls[0][0].handler() + + expect(nestedIntercept).not.toHaveBeenCalled() + expect(window.history.state).toEqual({ other: 'kept' }) + expect(show).toHaveBeenCalledOnce() + }) + + it('keeps the account-menu profile when Safari dispatches the write after it has returned', async () => { + const { registerBrowserNavigation } = await freshModule() + const { writeNavigationHistory } = await import('../../../src/navigation/state') + registerBrowserNavigation(controller) + const profileState = { paneName: 'profile', paneUri: 'https://pod.example/profile/card#me', viaAccountMenu: true } + const intercept = vi.fn() + + writeNavigationHistory(window.history, 'replaceState', profileState, '') + historyWrite(intercept) + + expect(intercept).not.toHaveBeenCalled() + expect(show).not.toHaveBeenCalled() + expect(window.history.state).toEqual(profileState) + }) + + it('clears the write guard even if history throws', async () => { + const { registerBrowserNavigation } = await freshModule() + const { writeNavigationHistory } = await import('../../../src/navigation/state') + registerBrowserNavigation(controller) + vi.spyOn(window.history, 'replaceState').mockImplementation(() => { throw new Error('history failed') }) + + expect(() => writeNavigationHistory(window.history, 'replaceState', {}, '')).toThrow('history failed') + expect(enter()).toHaveBeenCalledOnce() + }) +}) + +describe('back and forward', () => { + it('shows what the URL is, after forgetting what the entry displayed', async () => { + const { registerBrowserNavigation } = await freshModule() + registerBrowserNavigation(controller) + + traverse() + await nextTask() + + expect(window.history.state).toEqual({ other: 'kept' }) + expect(show).toHaveBeenCalledWith({ kind: 'restore', forceHeading: true }) + }) + + it.each(['replace', 'push', 'reload'])('ignores an entry change of type %s', async (type) => { + const { registerBrowserNavigation } = await freshModule() + registerBrowserNavigation(controller) + + traverse(type) + await nextTask() + + expect(show).not.toHaveBeenCalled() + expect(window.history.state).toMatchObject({ paneName: 'folder' }) + }) +}) + +describe('without the Navigation API', () => { + beforeEach(() => { + Reflect.deleteProperty(window, 'navigation') + }) + + it('shows what the URL is on popstate', async () => { + const { registerBrowserNavigation } = await freshModule() + registerBrowserNavigation(controller) + + window.dispatchEvent(new PopStateEvent('popstate')) + await nextTask() + + expect(window.history.state).toEqual({ other: 'kept' }) + expect(show).toHaveBeenCalledOnce() + }) +}) + +describe('whether the page handles browser navigation', () => { + it('says no before the listeners are registered and yes afterwards', async () => { + const { registerBrowserNavigation, isHandlingBrowserNavigation } = await freshModule() + expect(isHandlingBrowserNavigation()).toBe(false) + + registerBrowserNavigation(controller) + + expect(isHandlingBrowserNavigation()).toBe(true) + }) +}) + +describe('registering', () => { + it('adds the listeners once, and uses the controller registered last', async () => { + const { registerBrowserNavigation } = await freshModule() + const addEventListener = vi.spyOn(window.navigation as never as { addEventListener: () => void }, 'addEventListener') + const second = { show: vi.fn().mockResolvedValue(undefined) } + + registerBrowserNavigation(controller) + registerBrowserNavigation(second as unknown as NavigationController) + + expect(addEventListener).toHaveBeenCalledTimes(2) + await enter().mock.calls[0][0].handler() + expect(show).not.toHaveBeenCalled() + expect(second.show).toHaveBeenCalledOnce() + }) + + it('reports a failure to show the page instead of leaving it unhandled', async () => { + const error = vi.spyOn(console, 'error').mockImplementation(() => undefined) + show.mockRejectedValue(new Error('no pane')) + const { registerBrowserNavigation } = await freshModule() + registerBrowserNavigation(controller) + + await enter().mock.calls[0][0].handler() + + expect(error).toHaveBeenCalledWith('Failed to show the page after browser navigation.', expect.any(Error)) + }) +}) diff --git a/test/unit/navigation/chrome.test.ts b/test/unit/navigation/chrome.test.ts new file mode 100644 index 00000000..e95cd406 --- /dev/null +++ b/test/unit/navigation/chrome.test.ts @@ -0,0 +1,254 @@ +import { describe, expect, it } from 'vitest' +import { + deriveExplorerHeader, + deriveHeading, + deriveNavbarSelection, + deriveStorageView, + explorerHeaderForPane, + isNavbarHidden, + isNavbarItemSelected, + isPersonPane, + offersFriendAction, + pickNavbarItem, + type HeadingInput +} from '../../../src/navigation/chrome' +import { viewFromPane } from '../../../src/navigation/state' + +const viewerUri = 'https://pod.example/me/profile/card#me' +const ownerUri = 'https://pod.example/owner/profile/card#me' +const pageUrl = 'https://pod.example/owner/container/' + +const ownerStorage = 'https://pod.example/owner/' + +function heading (overrides: Partial & { pane?: string, subject?: string } = {}) { + const { pane, subject, ...rest } = overrides + return deriveHeading({ + view: viewFromPane(pane, subject), + viaAccountMenu: false, + viewer: viewerUri, + pageUrl, + owner: ownerUri, + storageUris: [ownerStorage], + ...rest + }) +} + +describe('isPersonPane', () => { + it.each([['profile', true], ['social', true], ['folder', false], ['home', false], [undefined, false]])( + '%s -> %s', (pane, expected) => { + expect(isPersonPane(pane)).toBe(expected) + } + ) +}) + +describe('offersFriendAction', () => { + it.each([['profile', true], ['social', true], ['folder', false], [undefined, false]])( + 'the heading over %s offers the friend action: %s', (pane, expected) => { + expect(offersFriendAction(pane)).toBe(expected) + } + ) +}) + +describe('deriveHeading', () => { + describe('profile and friends panes present their own subject', () => { + it('is full for the profile pane and compact for friends', () => { + expect(heading({ pane: 'profile', subject: ownerUri })).toEqual({ mode: 'full', subjectUri: ownerUri, paneName: 'profile' }) + expect(heading({ pane: 'social', subject: ownerUri })).toEqual({ mode: 'compact', subjectUri: ownerUri, paneName: 'social' }) + }) + + it('presents the saved subject, else the navbar entry\'s profile, else the page', () => { + const other = 'https://pod.example/saved/profile/card#me' + expect(heading({ pane: 'profile', subject: other })).toMatchObject({ subjectUri: other }) + expect(heading({ pane: 'profile' })).toMatchObject({ subjectUri: ownerUri }) + expect(heading({ pane: 'profile', owner: undefined })).toMatchObject({ subjectUri: pageUrl }) + }) + + it('does not depend on who is logged in or where the view came from', () => { + const own = heading({ pane: 'profile', subject: viewerUri, viewer: viewerUri, viaAccountMenu: true }) + + expect(own).toEqual({ mode: 'full', subjectUri: viewerUri, paneName: 'profile' }) + }) + }) + + describe('other panes show the owner of the pod the page is in', () => { + it.each([undefined, 'folder', 'source', 'dataContents'])('shows a compact heading for pane %s', pane => { + expect(heading({ pane })).toEqual({ mode: 'compact', subjectUri: ownerUri, paneName: pane }) + }) + + it('is hidden when the owner is the viewer', () => { + expect(heading({ viewer: ownerUri })).toEqual({ mode: 'none' }) + }) + + it('shows the owner to a visitor who is not logged in, but nothing without an owner', () => { + expect(heading({ viewer: undefined })).toMatchObject({ mode: 'compact' }) + expect(heading({ viewer: undefined, owner: undefined })).toEqual({ mode: 'none' }) + }) + + it('is hidden for account-menu views, which show the viewer\'s content', () => { + expect(heading({ pane: 'home', viaAccountMenu: true })).toEqual({ mode: 'none' }) + expect(heading({ viaAccountMenu: true })).toEqual({ mode: 'none' }) + }) + + it('is hidden for the viewer\'s storage opened from the account menu', () => { + expect(heading({ pane: 'folder', subject: 'https://pod.example/me/', viaAccountMenu: true })).toEqual({ mode: 'none' }) + }) + + it('is hidden for the viewer\'s own storage opened from the account menu even when the pod has storages', () => { + expect(heading({ pane: 'folder', subject: 'https://pod.example/me/', viaAccountMenu: true, storageUris: [ownerStorage] })) + .toEqual({ mode: 'none' }) + }) + + it('shows the owner for a storage of the pod, whichever way it was opened', () => { + expect(heading({ pane: 'folder', subject: ownerStorage, viaAccountMenu: true, viewer: viewerUri })) + .toEqual({ mode: 'compact', subjectUri: ownerUri, paneName: 'folder' }) + expect(heading({ pane: 'folder', viaAccountMenu: true })) + .toEqual({ mode: 'compact', subjectUri: ownerUri, paneName: 'folder' }) + }) + + it('shows the owner for a storage the pod does not list, unless the account menu opened it', () => { + expect(heading({ pane: 'folder', subject: 'https://pod.example/elsewhere/' })) + .toEqual({ mode: 'compact', subjectUri: ownerUri, paneName: 'folder' }) + expect(heading({ pane: 'folder', subject: 'https://pod.example/elsewhere/', viaAccountMenu: true })) + .toEqual({ mode: 'none' }) + }) + + it('is hidden without a known owner of the pod', () => { + expect(heading({ owner: undefined })).toEqual({ mode: 'none' }) + expect(heading({ owner: undefined, storageUris: [] })).toEqual({ mode: 'none' }) + }) + }) +}) + +describe('navbar', () => { + describe('deriveNavbarSelection', () => { + it('selects the displayed pane and its subject', () => { + expect(deriveNavbarSelection(viewFromPane('folder', 'https://pod.example/s/'), false)) + .toEqual({ paneName: 'folder', paneUri: 'https://pod.example/s/' }) + }) + + it('selects Profile on a WebID, and nothing on other pages', () => { + expect(deriveNavbarSelection(viewFromPane(), true)).toEqual({ paneName: 'profile', paneUri: undefined }) + expect(deriveNavbarSelection(viewFromPane(), false)).toEqual({ paneName: undefined, paneUri: undefined }) + }) + + it('prefers the displayed pane over the WebID default', () => { + expect(deriveNavbarSelection(viewFromPane('social', ownerUri), true).paneName).toBe('social') + }) + }) + + describe('isNavbarItemSelected', () => { + const storage = { paneName: 'folder', paneUri: 'https://pod.example/a/' } + + it('selects profile and friends by pane alone', () => { + expect(isNavbarItemSelected({ paneName: 'profile' }, { paneName: 'profile' }, 0)).toBe(true) + expect(isNavbarItemSelected({ paneName: 'social' }, { paneName: 'profile' }, 0)).toBe(false) + }) + + it('selects a storage by its URI', () => { + expect(isNavbarItemSelected(storage, { paneName: 'folder', paneUri: storage.paneUri }, 2)).toBe(true) + expect(isNavbarItemSelected(storage, { paneName: 'folder', paneUri: 'https://pod.example/b/' }, 2)).toBe(false) + }) + + it('selects a storage without a URI only when it is the single one', () => { + expect(isNavbarItemSelected(storage, { paneName: 'folder' }, 1)).toBe(true) + expect(isNavbarItemSelected(storage, { paneName: 'folder' }, 2)).toBe(false) + }) + + it('selects nothing when nothing is displayed', () => { + expect(isNavbarItemSelected({ paneName: 'profile' }, {}, 0)).toBe(false) + }) + }) + + describe('pickNavbarItem', () => { + const items = [ + { paneName: 'profile', paneUri: 'p' }, + { paneName: 'folder', paneUri: 'a' }, + { paneName: 'folder', paneUri: 'b' } + ] + + it('prefers the item for that subject, else the first for that pane', () => { + expect(pickNavbarItem(items, 'folder', 'b')).toBe(items[2]) + expect(pickNavbarItem(items, 'folder', 'unknown')).toBe(items[1]) + expect(pickNavbarItem(items, 'folder')).toBe(items[1]) + }) + + it('finds nothing for a pane the navbar does not have', () => { + expect(pickNavbarItem(items, 'social')).toBeUndefined() + }) + }) + + describe('isNavbarHidden', () => { + it.each([ + [false, false, false, false], + [true, false, false, true], + [false, true, false, true], + [true, true, false, true], + [false, false, true, true], + [true, false, true, true] + ])('account menu %s, own profile %s, own pod %s -> hidden %s', (viaAccountMenu, ownProfile, inViewerPod, hidden) => { + expect(isNavbarHidden({ viaAccountMenu, ownProfile, inViewerPod })).toBe(hidden) + }) + }) +}) + +describe('file explorer header', () => { + const resource = { isRootResource: false, isWebId: false, viewerPodOnly: false, inViewerPod: false } + + it('is shown for an ordinary resource', () => { + expect(deriveExplorerHeader(resource)).toBe(true) + }) + + it('is never shown for root resources or WebIDs', () => { + expect(deriveExplorerHeader({ ...resource, isRootResource: true, inViewerPod: true })).toBe(false) + expect(deriveExplorerHeader({ ...resource, isWebId: true, inViewerPod: true })).toBe(false) + }) + + it('is shown for views of the viewer\'s own content only inside the viewer\'s pod', () => { + expect(deriveExplorerHeader({ ...resource, viewerPodOnly: true, inViewerPod: false })).toBe(false) + expect(deriveExplorerHeader({ ...resource, viewerPodOnly: true, inViewerPod: true })).toBe(true) + }) + + it('is never shown over profile or friends panes', () => { + expect(explorerHeaderForPane(true, 'profile')).toBe(false) + expect(explorerHeaderForPane(true, 'social')).toBe(false) + expect(explorerHeaderForPane(true, 'folder')).toBe(false) + expect(explorerHeaderForPane(true, undefined)).toBe(true) + expect(explorerHeaderForPane(false, 'folder')).toBe(false) + }) + + it.each(['basicPreferences', 'home', 'dashboard'])('is never shown over %s', paneName => { + expect(explorerHeaderForPane(true, paneName)).toBe(false) + expect(explorerHeaderForPane(true, paneName, undefined, true)).toBe(false) + }) + + it('is never shown over a storage view, which has its own header or the navbar', () => { + expect(explorerHeaderForPane(true, 'folder', 'explorer')).toBe(false) + expect(explorerHeaderForPane(true, 'folder', 'storage')).toBe(false) + expect(explorerHeaderForPane(true, 'folder', 'container')).toBe(false) + // A pane opened in place of the folder keeps its resource header + expect(explorerHeaderForPane(true, 'source', 'explorer')).toBe(true) + }) + + it('retains the header for slideshow in solo and regular views', () => { + expect(explorerHeaderForPane(true, 'slideshow', undefined, true)).toBe(true) + expect(explorerHeaderForPane(true, 'slideshow')).toBe(true) + }) +}) + +describe('storage view', () => { + it('shows the viewer\'s own storage with the storage header', () => { + expect(deriveStorageView({ viaAccountMenu: false, inViewerPod: true, hasOwner: true })).toBe('explorer') + }) + + it('shows the storage header for the account menu, whatever the page', () => { + expect(deriveStorageView({ viaAccountMenu: true, inViewerPod: false, hasOwner: true })).toBe('explorer') + }) + + it('shows the server root, which nobody owns, with the storage header', () => { + expect(deriveStorageView({ viaAccountMenu: false, inViewerPod: false, hasOwner: false })).toBe('explorer') + }) + + it('shows someone else\'s storage with only the sidebar and content, under their navbar', () => { + expect(deriveStorageView({ viaAccountMenu: false, inViewerPod: false, hasOwner: true })).toBe('storage') + }) +}) diff --git a/test/unit/navigation/controller.test.ts b/test/unit/navigation/controller.test.ts new file mode 100644 index 00000000..0bf69eaf --- /dev/null +++ b/test/unit/navigation/controller.test.ts @@ -0,0 +1,362 @@ +import { afterEach, beforeEach, describe, expect, it, vi, type Mock } from 'vitest' +import { store } from 'solid-logic' +import type { OutlineManager } from '../../../src/outline/manager' +import { + createNavigationController, + type NavigationController, + type NavigationDeps, + type NavigationEffects +} from '../../../src/navigation/controller' +import { resolveSource } from '../../../src/navigation/options' + +const { getProfilePane, getSocialPane, getFolderPane, isWebId } = vi.hoisted(() => ({ + getProfilePane: vi.fn(), + getSocialPane: vi.fn(), + getFolderPane: vi.fn(), + isWebId: vi.fn() +})) + +vi.mock('../../../src/utils/paneUtils', () => ({ + getProfilePaneFromURI: getProfilePane, + getSocialPaneFromURI: getSocialPane, + getFolderPaneForStorage: getFolderPane +})) +vi.mock('../../../src/utils/webIdUtils', () => ({ isWebIdUri: isWebId })) + +const owner = 'https://pod.example/timea/profile/card#me' +const profilePane = { name: 'profile', subject: store.sym(owner) } +const socialPane = { name: 'social', subject: store.sym(owner) } +const storagePane = { name: 'folder', paneName: 'folder', subject: store.sym('https://pod.example/timea/') } +const homePane = { name: 'home' } + +let calls: string[] +let GotoSubject: Mock<(...args: any[]) => void> +let selectNavbarPane: Mock +let refreshHeading: Mock +let byName: Mock +let podContextOf: Mock> +let controller: NavigationController +let navbar: HTMLElement + +beforeEach(() => { + calls = [] + // Records the displayed pane in history.state, as the outline manager does + GotoSubject = vi.fn((_subject, _expand, pane, _solo, _referrer, _table, options) => { + calls.push('GotoSubject') + const next: Record = { ...window.history.state } + if (pane) { + next.paneName = pane.name + if (pane.subject) next.paneUri = pane.subject.value + } + if (resolveSource(options) === 'accountMenu') next.viaAccountMenu = true + else delete next.viaAccountMenu + window.history.replaceState(next, '', window.location.href) + }) + selectNavbarPane = vi.fn(() => { calls.push('select') }) + refreshHeading = vi.fn(async () => { calls.push('heading') }) + byName = vi.fn((name: string) => (name === 'home' ? homePane as never : null)) + podContextOf = vi.fn(async () => ({ owner, storagePanes: [], viewerStorages: [] })) + controller = createNavigationController({ + store, + outliner: { GotoSubject } as unknown as OutlineManager, + byName, + effects: { selectNavbarPane, refreshHeading }, + podContextOf + }) + navbar = document.createElement('solid-panes-navbar') + document.body.appendChild(navbar) + + getProfilePane.mockResolvedValue(profilePane) + getSocialPane.mockResolvedValue(socialPane) + getFolderPane.mockResolvedValue(storagePane) + isWebId.mockReturnValue(false) + window.history.replaceState({}, '', '/timea2/docs/') +}) + +afterEach(() => { + vi.restoreAllMocks() + vi.resetAllMocks() + document.body.replaceChildren() + window.history.replaceState(null, '', '/') +}) + +const sourceOfCall = (index = 0) => resolveSource(GotoSubject.mock.calls[index][6]) + +describe('showing a profile, friends or storage', () => { + it('displays the person\'s pane for the page URL, then selects it in the navbar and refreshes the heading', async () => { + await controller.show({ kind: 'profile', subject: owner }) + + expect(getProfilePane).toHaveBeenCalledWith(store.sym(owner), byName) + expect(GotoSubject).toHaveBeenCalledWith( + store.sym(window.location.href), true, profilePane, true, undefined, undefined, { source: 'default' } + ) + expect(selectNavbarPane).toHaveBeenCalledWith('profile', owner) + expect(refreshHeading).toHaveBeenCalledWith(false) + expect(calls).toEqual(['GotoSubject', 'select', 'heading']) + expect(navbar).not.toHaveClass('navbar--hidden') + }) + + it('does the same for friends and for a storage', async () => { + await controller.show({ kind: 'friends', subject: owner }) + await controller.show({ kind: 'storage', pane: storagePane as never }) + + expect(GotoSubject.mock.calls.map(call => call[2])).toEqual([socialPane, storagePane]) + expect(selectNavbarPane.mock.calls).toEqual([['social', owner], ['folder', 'https://pod.example/timea/']]) + }) + + it('displays a pane of the application by its registry name', async () => { + await controller.show({ kind: 'app', pane: 'home' }) + + expect(byName).toHaveBeenCalledWith('home') + expect(GotoSubject.mock.calls[0][2]).toBe(homePane) + expect(selectNavbarPane).toHaveBeenCalledWith('home', undefined) + }) +}) + +describe('when the account menu asks', () => { + it('hides the navbar, remembers the source and does not select anything in it', async () => { + await controller.show({ kind: 'profile', subject: owner, source: 'accountMenu' }) + + expect(sourceOfCall()).toBe('accountMenu') + expect(window.history.state).toMatchObject({ viaAccountMenu: true }) + expect(navbar).toHaveClass('navbar--hidden') + expect(selectNavbarPane).not.toHaveBeenCalled() + expect(refreshHeading).toHaveBeenCalledWith(false) + }) + + it('hides the navbar before the pane has been resolved', async () => { + let finish!: (pane: unknown) => void + getProfilePane.mockReturnValue(new Promise(resolve => { finish = resolve })) + + const shown = controller.show({ kind: 'profile', subject: owner, source: 'accountMenu' }) + + expect(navbar).toHaveClass('navbar--hidden') + expect(GotoSubject).not.toHaveBeenCalled() + finish(profilePane) + await shown + }) + + it('shows the navbar again for the page\'s own navigation', async () => { + navbar.classList.add('navbar--hidden') + + await controller.show({ kind: 'friends', subject: owner }) + // The outline manager reveals the navbar; the fake outliner here does not, so only check intent + expect(sourceOfCall()).toBe('default') + }) +}) + +describe('when a pane cannot be built', () => { + it('displays nothing rather than the page URL\'s default view, and says so', async () => { + const warn = vi.spyOn(console, 'warn').mockImplementation(() => undefined) + getProfilePane.mockResolvedValue(null) + + await controller.show({ kind: 'profile', subject: owner, source: 'accountMenu' }) + + expect(GotoSubject).not.toHaveBeenCalled() + expect(refreshHeading).not.toHaveBeenCalled() + expect(warn).toHaveBeenCalledOnce() + }) + + it('treats an unknown application pane the same way', async () => { + vi.spyOn(console, 'warn').mockImplementation(() => undefined) + + await controller.show({ kind: 'app', pane: 'unknown' }) + + expect(GotoSubject).not.toHaveBeenCalled() + }) +}) + +describe('restoring a history entry', () => { + it('displays what the current entry displays', async () => { + window.history.replaceState({ paneName: 'social', paneUri: owner }, '', '/timea2/docs/') + + await controller.show({ kind: 'restore' }) + + expect(getSocialPane).toHaveBeenCalledWith(store.sym(owner), byName) + expect(GotoSubject.mock.calls[0][2]).toBe(socialPane) + expect(selectNavbarPane).toHaveBeenCalledWith('social', owner) + expect(refreshHeading).toHaveBeenCalledWith(false) + }) + + it.each([ + ['home', 'a pane of the application', homePane], + ['source', 'a pane the registry does not know', undefined] + ])('restores the registry pane %s without a subject of its own (%s)', async (name, _what, expected) => { + byName.mockImplementation((requested: string) => requested === 'home' ? homePane as never : null) + window.history.replaceState({ paneName: name }, '', '/timea2/docs/') + + await controller.show({ kind: 'restore' }) + + expect(GotoSubject.mock.calls[0][2]).toBe(expected) + }) + + it('shows the profile on a WebID whose entry displayed nothing', async () => { + isWebId.mockReturnValue(true) + window.history.replaceState({}, '', '/timea/profile/card') + + await controller.show({ kind: 'restore' }) + + expect(isWebId).toHaveBeenCalledWith(store.sym(`${window.location.origin}/timea/profile/card`)) + expect(getProfilePane).toHaveBeenCalledWith(store.sym(`${window.location.origin}/timea/profile/card`), byName) + expect(GotoSubject.mock.calls[0][2]).toBe(profilePane) + }) + + it('shows the page\'s default view when nothing was displayed and it is not a WebID', async () => { + await controller.show({ kind: 'restore' }) + + expect(GotoSubject.mock.calls[0][2]).toBeUndefined() + expect(selectNavbarPane).not.toHaveBeenCalled() + expect(refreshHeading).toHaveBeenCalledWith(false) + }) + + it('still shows the default view when the entry names a pane that cannot be built', async () => { + getFolderPane.mockResolvedValue(null) + window.history.replaceState({ paneName: 'folder', paneUri: 'https://pod.example/timea/' }, '', '/timea2/docs/') + + await controller.show({ kind: 'restore' }) + + expect(GotoSubject.mock.calls[0][2]).toBeUndefined() + }) + + it('uses the subject it is given instead of the page URL', async () => { + isWebId.mockReturnValue(true) + + await controller.show({ kind: 'restore', subject: 'https://other.example/profile/card#me' }) + + expect(isWebId).toHaveBeenCalledWith(store.sym('https://other.example/profile/card#me')) + expect(GotoSubject.mock.calls[0][0]).toEqual(store.sym('https://other.example/profile/card#me')) + }) + + it('redoes the heading only when asked to', async () => { + await controller.show({ kind: 'restore', forceHeading: true }) + await controller.show({ kind: 'restore' }) + + expect(refreshHeading.mock.calls).toEqual([[true], [false]]) + }) +}) + +describe('when intents overlap', () => { + it('displays only the latest while an earlier one is still resolving its pane', async () => { + let finishFirst!: (pane: unknown) => void + getProfilePane.mockReturnValueOnce(new Promise(resolve => { finishFirst = resolve })) + + const first = controller.show({ kind: 'profile', subject: owner }) + const second = controller.show({ kind: 'friends', subject: owner }) + await second + finishFirst(profilePane) + await first + + expect(GotoSubject).toHaveBeenCalledOnce() + expect(GotoSubject.mock.calls[0][2]).toBe(socialPane) + expect(refreshHeading).toHaveBeenCalledOnce() + }) + + it('lets an account-menu choice win over a restore that was already under way', async () => { + let finishRestore!: (pane: unknown) => void + getProfilePane.mockReturnValueOnce(new Promise(resolve => { finishRestore = resolve })) + isWebId.mockReturnValue(true) + + const restore = controller.show({ kind: 'restore' }) + await controller.show({ kind: 'storage', pane: storagePane as never, source: 'accountMenu' }) + finishRestore(profilePane) + await restore + + expect(GotoSubject.mock.calls.map(call => call[2])).toEqual([storagePane]) + }) + + it('does not hold up an intent because of an earlier one that already finished', async () => { + await controller.show({ kind: 'profile', subject: owner }) + await controller.show({ kind: 'friends', subject: owner }) + + expect(GotoSubject).toHaveBeenCalledTimes(2) + }) +}) + +describe('how a storage is presented', () => { + const folderViewOfCall = (index = 0) => GotoSubject.mock.calls[index][6]?.folderView + const storageItem = (uri: string) => ({ name: 'folder', paneName: 'folder', subject: store.sym(uri) }) + + it('shows someone else\'s storage from the navbar with only the sidebar and content', async () => { + await controller.show({ kind: 'storage', pane: storagePane as never }) + + expect(podContextOf).toHaveBeenCalledWith('https://pod.example/timea/') + expect(GotoSubject.mock.calls[0][6]).toEqual({ source: 'default', folderView: 'storage' }) + }) + + it('shows a storage from the account menu with the storage header, without looking up its pod', async () => { + await controller.show({ kind: 'storage', pane: storagePane as never, source: 'accountMenu' }) + + expect(podContextOf).not.toHaveBeenCalled() + expect(folderViewOfCall()).toBe('explorer') + }) + + it('shows someone else\'s pod root as their storage, selected in the navbar', async () => { + const root = `${window.location.origin}/timea/` + const rootPane = storageItem(root) + getFolderPane.mockResolvedValue(rootPane) + podContextOf.mockResolvedValue({ owner, storagePanes: [rootPane as never], viewerStorages: [] }) + window.history.replaceState({}, '', '/timea/') + + await controller.show({ kind: 'restore' }) + + expect(getFolderPane).toHaveBeenCalledWith(store.sym(root)) + expect(GotoSubject.mock.calls[0][2]).toBe(rootPane) + expect(folderViewOfCall()).toBe('storage') + expect(selectNavbarPane).toHaveBeenCalledWith('folder', root) + }) + + it('shows the viewer\'s own pod root with the storage header', async () => { + const root = `${window.location.origin}/timea/` + const rootPane = storageItem(root) + getFolderPane.mockResolvedValue(rootPane) + podContextOf.mockResolvedValue({ owner, viewer: owner, storagePanes: [rootPane as never], viewerStorages: [root] }) + window.history.replaceState({}, '', '/timea/') + + await controller.show({ kind: 'restore' }) + + expect(folderViewOfCall()).toBe('explorer') + }) + + it('recognizes the viewer\'s exact storage URL when it is not listed as a storage pane', async () => { + const root = `${window.location.origin}/timea/` + const rootPane = storageItem(root) + getFolderPane.mockResolvedValue(rootPane) + podContextOf.mockResolvedValue({ owner, viewer: owner, storagePanes: [], viewerStorages: [root] }) + window.history.replaceState({}, '', '/timea/') + + await controller.show({ kind: 'restore' }) + + expect(folderViewOfCall()).toBe('explorer') + }) + + it('does not treat a subcontainer of the viewer\'s storage as the storage itself', async () => { + const root = `${window.location.origin}/timea/` + const subcontainer = `${root}documents/` + getFolderPane.mockResolvedValue(storageItem(subcontainer)) + podContextOf.mockResolvedValue({ owner, viewer: owner, storagePanes: [], viewerStorages: [root] }) + window.history.replaceState({}, '', '/timea/documents/') + + await controller.show({ kind: 'restore' }) + + expect(folderViewOfCall()).toBeUndefined() + }) + + it('shows the server root, which nobody owns, with the storage header', async () => { + const root = `${window.location.origin}/` + getFolderPane.mockResolvedValue(storageItem(root)) + podContextOf.mockResolvedValue({ storagePanes: [], viewerStorages: [] }) + window.history.replaceState({}, '', '/') + + await controller.show({ kind: 'restore' }) + + expect(getFolderPane).toHaveBeenCalledWith(store.sym(root)) + expect(folderViewOfCall()).toBe('explorer') + }) + + it('leaves a container that is not a storage to its own default view', async () => { + await controller.show({ kind: 'restore' }) + + expect(getFolderPane).not.toHaveBeenCalled() + expect(GotoSubject.mock.calls[0][6]).toEqual({ source: 'default' }) + }) +}) diff --git a/test/unit/navigation/events.test.ts b/test/unit/navigation/events.test.ts new file mode 100644 index 00000000..a2781851 --- /dev/null +++ b/test/unit/navigation/events.test.ts @@ -0,0 +1,45 @@ +import { afterEach, describe, expect, it, vi } from 'vitest' +import { announceNavigation, NAVIGATED_EVENT, onNavigated, type NavigatedDetail } from '../../../src/navigation/events' + +afterEach(() => { + window.history.replaceState(null, '', '/') +}) + +describe('navigation events', () => { + it('announces the page URL and what the entry displays', () => { + window.history.replaceState({ paneName: 'folder', paneUri: 'https://a.example/', viaAccountMenu: true }, '', '/some/page') + const seen: NavigatedDetail[] = [] + document.addEventListener(NAVIGATED_EVENT, event => seen.push((event as CustomEvent).detail), { once: true }) + + announceNavigation(document) + + expect(seen).toEqual([{ + url: `${window.location.origin}/some/page`, + state: { view: { kind: 'storage', pane: 'folder', subject: 'https://a.example/' }, viaAccountMenu: true } + }]) + }) + + it('announces an entry that displays nothing in particular', () => { + const listener = vi.fn() + const stop = onNavigated(listener) + + announceNavigation(document) + + expect(listener).toHaveBeenCalledWith({ + url: window.location.href, + state: { view: { kind: 'default' }, viaAccountMenu: false } + }) + stop() + }) + + it('stops calling a listener once it has been removed', () => { + const listener = vi.fn() + const stop = onNavigated(listener) + + announceNavigation(document) + stop() + announceNavigation(document) + + expect(listener).toHaveBeenCalledOnce() + }) +}) diff --git a/test/unit/navigation/navbarVisibility.test.ts b/test/unit/navigation/navbarVisibility.test.ts new file mode 100644 index 00000000..fd2b8531 --- /dev/null +++ b/test/unit/navigation/navbarVisibility.test.ts @@ -0,0 +1,48 @@ +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' +import { isPageInViewerPod } from '../../../src/navigation/podContext' +import { refreshNavbarVisibility, setNavbarHidden } from '../../../src/navigation/navbarVisibility' + +vi.mock('../../../src/navigation/podContext', () => ({ + isPageInViewerPod: vi.fn() +})) +vi.mock('../../../src/utils/webIdUtils', () => ({ + isOwnWebIdProfile: () => false +})) + +beforeEach(() => { + document.body.appendChild(document.createElement('solid-panes-navbar')) +}) + +afterEach(() => { + setNavbarHidden(false) + vi.resetAllMocks() + document.body.replaceChildren() +}) + +describe('navbar ownership lookup races', () => { + it('ignores a lookup completed after a newer navigation', async () => { + let finishFirst!: (owned: boolean) => void + vi.mocked(isPageInViewerPod) + .mockReturnValueOnce(new Promise(resolve => { finishFirst = resolve })) + .mockResolvedValueOnce(true) + + const first = refreshNavbarVisibility('https://other.example/file') + await refreshNavbarVisibility('https://own.example/file') + finishFirst(false) + await first + + expect(document.querySelector('solid-panes-navbar')).toHaveClass('navbar--hidden') + }) + + it('does not undo account-menu hiding when an earlier lookup finishes', async () => { + let finish!: (owned: boolean) => void + vi.mocked(isPageInViewerPod).mockReturnValueOnce(new Promise(resolve => { finish = resolve })) + + const pending = refreshNavbarVisibility('https://other.example/file') + setNavbarHidden(true) + finish(false) + await pending + + expect(document.querySelector('solid-panes-navbar')).toHaveClass('navbar--hidden') + }) +}) diff --git a/test/unit/navigation/options.test.ts b/test/unit/navigation/options.test.ts new file mode 100644 index 00000000..4b673a36 --- /dev/null +++ b/test/unit/navigation/options.test.ts @@ -0,0 +1,22 @@ +import { describe, expect, it } from 'vitest' +import { resolveSource } from '../../../src/navigation/options' + +describe('resolveSource', () => { + it.each([ + [undefined, 'default'], + [{}, 'default'], + [{ source: 'default' }, 'default'], + [{ source: 'accountMenu' }, 'accountMenu'] + ] as const)('reads the options %j as %s', (argument, expected) => { + expect(resolveSource(argument)).toBe(expected) + }) + + it('still reads the old showNavbar boolean', () => { + expect(resolveSource(true)).toBe('default') + expect(resolveSource(false)).toBe('accountMenu') + }) + + it('reads any other falsy value like the old default parameter did', () => { + expect(resolveSource(null)).toBe('accountMenu') + }) +}) diff --git a/test/unit/navigation/podContext.test.ts b/test/unit/navigation/podContext.test.ts new file mode 100644 index 00000000..4603f00d --- /dev/null +++ b/test/unit/navigation/podContext.test.ts @@ -0,0 +1,214 @@ +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' +import { sym } from 'rdflib' +import { authn } from 'solid-logic' +import type { PaneItem } from '../../../src/utils/paneUtils' + +const { loadProfile, getFolderPanes, getStorages } = vi.hoisted(() => ({ + loadProfile: vi.fn(), + getFolderPanes: vi.fn(), + getStorages: vi.fn() +})) + +vi.mock('../../../src/utils/webIdUtils', async (importOriginal) => ({ + ...await importOriginal(), + loadProfileFromURI: loadProfile +})) +vi.mock('../../../src/utils/paneUtils', () => ({ getFolderPanesFromURI: getFolderPanes })) +vi.mock('../../../src/utils/podUtils', () => ({ getPodStorages: getStorages })) + +import { + getPodContext, + isInViewerPod, + isPageInViewerPod, + isSamePod, + resetPodContexts, + type PodContext +} from '../../../src/navigation/podContext' + +const owner = sym('https://pod.example/timea/profile/card#me') +const viewer = sym('https://pod.example/other/profile/card#me') +const storage = (uri: string) => ({ subject: sym(uri), paneName: 'folder' }) as unknown as PaneItem + +beforeEach(() => { + resetPodContexts() + loadProfile.mockResolvedValue(owner) + getFolderPanes.mockResolvedValue([storage('https://pod.example/timea/')]) + getStorages.mockResolvedValue([sym('https://pod.example/other/')]) + vi.spyOn(authn, 'currentUser').mockReturnValue(viewer) +}) + +afterEach(() => { + vi.restoreAllMocks() + vi.resetAllMocks() +}) + +describe('getPodContext', () => { + it('describes the pod the page is in and the viewer\'s own storages', async () => { + const context = await getPodContext('https://pod.example/timea/docs/') + + expect(context).toMatchObject({ + viewer: viewer.value, + owner: owner.value, + viewerStorages: ['https://pod.example/other/'] + }) + expect(context.storagePanes.map(pane => pane.subject.value)).toEqual(['https://pod.example/timea/']) + expect(getFolderPanes).toHaveBeenCalledWith(owner) + }) + + it('looks up the storages of a pod and of the viewer once, however many of its pages are asked about', async () => { + await Promise.all([ + getPodContext('https://pod.example/timea/a'), + getPodContext('https://pod.example/timea/b/c'), + getPodContext('https://pod.example/timea/') + ]) + + expect(getFolderPanes).toHaveBeenCalledOnce() + expect(getStorages).toHaveBeenCalledOnce() + }) + + it('looks up the owner once per document, whatever fragment is asked about', async () => { + await Promise.all([ + getPodContext('https://pod.example/timea/a'), + getPodContext('https://pod.example/timea/a#one'), + getPodContext('https://pod.example/timea/a#two') + ]) + await getPodContext('https://pod.example/timea/b') + + expect(loadProfile).toHaveBeenCalledTimes(2) + }) + + it('gives each page its own owner, since the lookup can end with that page\'s own primary topic', async () => { + const alice = sym('https://example.org/people/alice#me') + const bob = sym('https://example.org/people/bob#me') + loadProfile.mockImplementation(async (subject: typeof alice) => subject.uri.includes('alice') ? alice : bob) + + const first = await getPodContext('https://example.org/people/alice') + const second = await getPodContext('https://example.org/people/bob') + + expect([first.owner, second.owner]).toEqual([alice.value, bob.value]) + expect(isSamePod(first, second)).toBe(false) + }) + + it('looks up the storages again for another pod, on the same host or another one', async () => { + await getPodContext('https://pod.example/timea/') + await getPodContext('https://pod.example/timea2/') + await getPodContext('https://elsewhere.example/timea/') + + expect(getFolderPanes).toHaveBeenCalledTimes(3) + expect(loadProfile).toHaveBeenCalledTimes(3) + }) + + it('looks up the viewer\'s storages once per viewer, and the rest is unaffected by who is logged in', async () => { + await getPodContext('https://pod.example/timea/') + vi.mocked(authn.currentUser).mockReturnValue(null) + + const loggedOut = await getPodContext('https://pod.example/timea/') + + expect(loggedOut.viewer).toBeUndefined() + expect(loggedOut.viewerStorages).toEqual([]) + expect(loggedOut.owner).toBe(owner.value) + expect(loadProfile).toHaveBeenCalledOnce() + expect(getStorages).toHaveBeenCalledOnce() + }) + + it('does not remember an unbounded number of documents', async () => { + for (let index = 0; index < 520; index++) await getPodContext(`https://pod.example/timea/doc-${index}`) + loadProfile.mockClear() + + await getPodContext('https://pod.example/timea/doc-519') + expect(loadProfile).not.toHaveBeenCalled() + await getPodContext('https://pod.example/timea/doc-0') + expect(loadProfile).toHaveBeenCalledOnce() + }) + + it('uses the page URL by default', async () => { + window.history.replaceState({}, '', '/timea/docs/') + + await getPodContext() + + expect(loadProfile).toHaveBeenCalledWith(sym(window.location.href)) + window.history.replaceState({}, '', '/') + }) + + describe('when a lookup finds no profile', () => { + it('does not take the URL itself for the owner', async () => { + const page = sym('https://pod.example/files/notes.ttl') + loadProfile.mockResolvedValue(page) + + expect((await getPodContext(page.uri)).owner).toBeUndefined() + }) + + it('does take a WebID for its own owner', async () => { + loadProfile.mockResolvedValue(owner) + + expect((await getPodContext(owner.uri)).owner).toBe(owner.value) + }) + }) + + describe('when a lookup fails', () => { + beforeEach(() => { + vi.spyOn(console, 'warn').mockImplementation(() => undefined) + }) + + it('still describes what could be loaded', async () => { + loadProfile.mockRejectedValue(new Error('offline')) + + const context = await getPodContext('https://pod.example/timea/') + + expect(context.owner).toBeUndefined() + expect(context.storagePanes).toHaveLength(1) + }) + + it('asks again next time instead of remembering the gap', async () => { + loadProfile.mockRejectedValueOnce(new Error('offline')) + + await getPodContext('https://pod.example/timea/') + const retried = await getPodContext('https://pod.example/timea/') + + expect(retried.owner).toBe(owner.value) + expect(loadProfile).toHaveBeenCalledTimes(2) + }) + + it('does not look up the viewer\'s storages when nobody is logged in', async () => { + vi.mocked(authn.currentUser).mockReturnValue(null) + getStorages.mockRejectedValue(new Error('not called')) + + const context = await getPodContext('https://pod.example/timea/') + + expect(context.viewerStorages).toEqual([]) + expect(getStorages).not.toHaveBeenCalled() + }) + }) +}) + +describe('what a context says about a URL', () => { + const context: PodContext = { + viewer: viewer.value, + owner: owner.value, + storagePanes: [], + viewerStorages: ['https://pod.example/other/'] + } + + it.each([ + ['https://pod.example/other/', true], + ['https://pod.example/other/docs/file.ttl', true], + ['https://pod.example/timea/docs/', false], + ['https://pod.example/others/', false] + ])('puts %s in the viewer\'s pod: %s', (url, expected) => { + expect(isInViewerPod(context, url)).toBe(expected) + }) + + it('compares pods by owner, viewer and storages', () => { + const same = { ...context, storagePanes: [storage('https://pod.example/timea/')] } + + expect(isSamePod(same, { ...same })).toBe(true) + expect(isSamePod(same, { ...same, owner: 'https://elsewhere.example/profile/card#me' })).toBe(false) + expect(isSamePod(same, { ...same, viewer: undefined })).toBe(false) + expect(isSamePod(same, { ...same, storagePanes: [] })).toBe(false) + }) + + it('answers for a page URL directly', async () => { + expect(await isPageInViewerPod('https://pod.example/other/docs/')).toBe(true) + expect(await isPageInViewerPod('https://pod.example/timea/')).toBe(false) + }) +}) diff --git a/test/unit/navigation/state.test.ts b/test/unit/navigation/state.test.ts new file mode 100644 index 00000000..d220067c --- /dev/null +++ b/test/unit/navigation/state.test.ts @@ -0,0 +1,140 @@ +import { afterEach, describe, expect, it } from 'vitest' +import { + clearPaneState, + nextHistoryState, + parseNavigationState, + readNavigationState, + viewFromPane, + withoutPaneState +} from '../../../src/navigation/state' + +afterEach(() => { + window.history.replaceState(null, '', '/') +}) + +describe('viewFromPane', () => { + it.each([ + [undefined, undefined, { kind: 'default' }], + ['profile', 'https://a.example/card#me', { kind: 'profile', pane: 'profile', subject: 'https://a.example/card#me' }], + ['social', 'https://a.example/card#me', { kind: 'friends', pane: 'social', subject: 'https://a.example/card#me' }], + ['folder', 'https://a.example/', { kind: 'storage', pane: 'folder', subject: 'https://a.example/' }], + ['folder', undefined, { kind: 'storage', pane: 'folder' }], + ['home', undefined, { kind: 'pane', pane: 'home' }], + ['source', 'https://a.example/file', { kind: 'pane', pane: 'source', subject: 'https://a.example/file' }] + ])('describes pane %s with subject %s', (pane, subject, expected) => { + expect(viewFromPane(pane, subject)).toEqual(expected) + }) +}) + +describe('parseNavigationState', () => { + it.each([null, undefined, 'text', 42, {}])('reads %j as nothing displayed', raw => { + expect(parseNavigationState(raw)).toEqual({ view: { kind: 'default' }, viaAccountMenu: false }) + }) + + it('reads the stored pane fields', () => { + expect(parseNavigationState({ paneName: 'social', paneUri: 'https://a.example/card#me', other: 1 })).toEqual({ + view: { kind: 'friends', pane: 'social', subject: 'https://a.example/card#me' }, + viaAccountMenu: false + }) + }) + + it('ignores empty or mistyped pane fields', () => { + expect(parseNavigationState({ paneName: '', paneUri: 'x' }).view).toEqual({ kind: 'default' }) + expect(parseNavigationState({ paneName: 'profile', paneUri: 5 }).view).toEqual({ kind: 'profile', pane: 'profile' }) + }) + + it('only trusts the account-menu marker when it is exactly true', () => { + expect(parseNavigationState({ viaAccountMenu: true }).viaAccountMenu).toBe(true) + expect(parseNavigationState({ viaAccountMenu: 'yes' }).viaAccountMenu).toBe(false) + }) + + it('reads the current history entry', () => { + window.history.replaceState({ paneName: 'folder', paneUri: 'https://a.example/', viaAccountMenu: true }, '', '/') + + expect(readNavigationState()).toEqual({ + view: { kind: 'storage', pane: 'folder', subject: 'https://a.example/' }, + viaAccountMenu: true + }) + }) +}) + +describe('nextHistoryState', () => { + const storage = { name: 'folder', subject: 'https://a.example/' } + + it('records the displayed pane and its subject', () => { + expect(nextHistoryState({}, { pane: storage, leavingPage: false, viaAccountMenu: false })).toEqual({ + paneName: 'folder', + paneUri: 'https://a.example/' + }) + }) + + it('keeps other keys of the entry', () => { + expect(nextHistoryState({ other: 'kept' }, { pane: storage, leavingPage: false, viaAccountMenu: false })) + .toMatchObject({ other: 'kept', paneName: 'folder' }) + }) + + it('treats a missing or non-object entry as empty', () => { + for (const current of [null, undefined, 'text']) { + expect(nextHistoryState(current, { leavingPage: false, viaAccountMenu: false })).toEqual({}) + } + }) + + it('drops a saved pane URI when the new pane has no subject of its own', () => { + expect(nextHistoryState({ paneName: 'folder', paneUri: 'https://a.example/' }, { + pane: { name: 'home' }, leavingPage: false, viaAccountMenu: false + })).toEqual({ paneName: 'home' }) + expect(nextHistoryState({ paneUri: 'https://a.example/' }, { + pane: { name: 'home', subject: '' }, leavingPage: false, viaAccountMenu: false + })).toEqual({ paneName: 'home' }) + }) + + it('keeps the pane when the same page is rendered again without one', () => { + const current = { paneName: 'profile', paneUri: 'https://a.example/card#me' } + + expect(nextHistoryState(current, { leavingPage: false, viaAccountMenu: false })).toEqual(current) + }) + + it('does not carry pane details into the entry of a different page', () => { + expect(nextHistoryState( + { paneName: 'profile', paneUri: 'https://a.example/card#me', other: 'kept' }, + { leavingPage: true, viaAccountMenu: false } + )).toEqual({ other: 'kept' }) + }) + + it('records a pane for a different page', () => { + expect(nextHistoryState({ paneName: 'profile' }, { pane: storage, leavingPage: true, viaAccountMenu: false })) + .toEqual({ paneName: 'folder', paneUri: 'https://a.example/' }) + }) + + it('marks and unmarks account-menu views', () => { + expect(nextHistoryState({}, { pane: storage, leavingPage: false, viaAccountMenu: true })) + .toMatchObject({ viaAccountMenu: true }) + expect(nextHistoryState({ viaAccountMenu: true }, { pane: storage, leavingPage: false, viaAccountMenu: false })) + .not.toHaveProperty('viaAccountMenu') + }) + + it('does not change the entry it was given', () => { + const current = { paneName: 'profile', viaAccountMenu: true } + + nextHistoryState(current, { leavingPage: true, viaAccountMenu: false }) + + expect(current).toEqual({ paneName: 'profile', viaAccountMenu: true }) + }) +}) + +describe('forgetting the displayed pane', () => { + it('removes only the pane fields', () => { + expect(withoutPaneState({ paneName: 'x', paneUri: 'y', viaAccountMenu: true, other: 'kept' })).toEqual({ other: 'kept' }) + expect(withoutPaneState(null)).toEqual({}) + }) + + it('clears them from the current entry without changing the URL', () => { + window.history.replaceState({ paneName: 'folder', paneUri: 'https://a.example/', viaAccountMenu: true, other: 1 }, '', '/some/page') + + clearPaneState() + + expect(window.history.state).toEqual({ other: 1 }) + expect(window.location.pathname).toBe('/some/page') + expect(readNavigationState()).toEqual({ view: { kind: 'default' }, viaAccountMenu: false }) + }) +}) diff --git a/test/unit/navigation/storagePane.test.ts b/test/unit/navigation/storagePane.test.ts new file mode 100644 index 00000000..e07a6a20 --- /dev/null +++ b/test/unit/navigation/storagePane.test.ts @@ -0,0 +1,36 @@ +import { describe, expect, it, vi } from 'vitest' +import { sym } from 'rdflib' +import { createPaneItem } from '../../../src/utils/paneUtils' + +describe('explicit Storage navigation', () => { + it('keeps the storage shell even when top-level navigation supplies solo and fullView', () => { + const render = vi.fn() + const storage = sym('https://pod.example/storage/') + const pane = createPaneItem({ name: 'folder', render }, storage, 'folder', 'Storage', '') + const context = {} + + pane.render(sym('https://pod.example/questionnaire/'), context, { solo: true, fullView: true }) + + expect(render).toHaveBeenCalledWith(storage, context, { solo: false, fullView: false }) + }) + + it('passes on the folder view the navigation chose', () => { + const render = vi.fn() + const storage = sym('https://pod.example/storage/') + const pane = createPaneItem({ name: 'folder', render }, storage, 'folder', 'Storage', '') + + pane.render(storage, {}, { solo: true, folderView: 'storage' }) + + expect(render).toHaveBeenCalledWith(storage, {}, { solo: false, fullView: false, folderView: 'storage' }) + }) + + it('preserves solo rendering options for non-storage panes', () => { + const render = vi.fn() + const subject = sym('https://pod.example/profile/card#me') + const pane = createPaneItem({ name: 'profile', render }, subject, 'profile', 'Profile', '') + + pane.render(subject, {}, { solo: true }) + + expect(render).toHaveBeenCalledWith(subject, {}, { solo: true }) + }) +}) diff --git a/test/unit/outline/manager.test.ts b/test/unit/outline/manager.test.ts index 693663a4..48db3afb 100644 --- a/test/unit/outline/manager.test.ts +++ b/test/unit/outline/manager.test.ts @@ -1,9 +1,22 @@ -import { beforeAll, beforeEach, describe, expect, it, vi } from 'vitest' +import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest' +import { authn, store } from 'solid-logic' +import type { PaneDefinition } from 'pane-registry' +import * as paneRegistry from 'pane-registry' +import type FileExplorerHeader from 'solid-ui/components/file-explorer-header' + +const { isInViewerPodMock } = vi.hoisted(() => ({ isInViewerPodMock: vi.fn() })) + +vi.mock('../../../src/navigation/podContext', async (importOriginal) => ({ + ...await importOriginal(), + isPageInViewerPod: isInViewerPodMock +})) vi.mock('solid-ui', async () => { const actual = await vi.importActual('solid-ui') return { ...actual, + getRelevantPanes: async (_subject, context) => context.session.paneRegistry.list, + getPreferredPane: (subject, _context, panes) => panes.find(pane => pane.shouldGetFocus?.(subject)) || panes[0], login: { ...actual.login, filterAvailablePanes: async panes => panes @@ -11,13 +24,19 @@ vi.mock('solid-ui', async () => { } }) -import OutlineManager from '../../../src/outline/manager' +vi.mock('pane-registry', () => ({ + byName: vi.fn() +})) + +import OutlineManager, { dismissErrorStateOnClose } from '../../../src/outline/manager' +import { onNavigated, type NavigatedDetail } from '../../../src/navigation/events' import { lit, NamedNode, sym, blankNode } from 'rdflib' import { findByText, getByText } from '@testing-library/dom' const MockPane = { name: 'mock', icon: 'data:image/svg+xml,', + managesUpdates: true, label: () => 'Mock Pane', render: (subject: NamedNode) => { const div = document.createElement('div') @@ -32,6 +51,740 @@ const mockPaneRegistry = { } describe('manager', () => { + describe('navbar visibility during navigation', () => { + beforeEach(() => { + isInViewerPodMock.mockReset().mockResolvedValue(false) + }) + + afterEach(() => { + vi.restoreAllMocks() + document.body.replaceChildren() + }) + + it.each([ + ['https://owner.example/profile/card#me', true], + ['https://owner.example/profile/card', true], + ['https://owner.example/storage/file.ttl', false], + ['https://visitor.example/profile/card#me', false] + ])('sets navbar visibility for %s', async (uri, hidden) => { + vi.spyOn(authn, 'currentUser').mockReturnValue(sym('https://owner.example/profile/card#me')) + const navbar = document.createElement('solid-panes-navbar') + navbar.classList.toggle('navbar--hidden', !hidden) + document.body.appendChild(navbar) + const manager = new OutlineManager({ dom: document, session: { paneRegistry: mockPaneRegistry } }) + + manager.GotoSubject(sym(uri), false) + + await vi.waitFor(() => expect(navbar.classList.contains('navbar--hidden')).toBe(hidden)) + }) + + it('keeps the navbar hidden when a storage link navigates to an owned resource', async () => { + vi.spyOn(authn, 'currentUser').mockReturnValue(sym(`${window.location.origin}/profile/card#me`)) + isInViewerPodMock.mockResolvedValue(true) + const navbar = document.createElement('solid-panes-navbar') + document.body.appendChild(navbar) + const manager = new OutlineManager({ dom: document, session: { paneRegistry: mockPaneRegistry } }) + const uri = `${window.location.origin}/storage/file.ttl` + + manager.GotoSubject(sym(uri), false, undefined, true) + + expect(window.location.href).toBe(uri) + await vi.waitFor(() => expect(navbar).toHaveClass('navbar--hidden')) + expect(isInViewerPodMock).toHaveBeenCalledWith(uri) + window.history.replaceState({}, '', '/') + }) + + it('preserves account-menu hiding when automatic reveal is suppressed', () => { + vi.spyOn(authn, 'currentUser').mockReturnValue(sym('https://owner.example/profile/card#me')) + const navbar = document.createElement('solid-panes-navbar') + navbar.classList.add('navbar--hidden') + document.body.appendChild(navbar) + const manager = new OutlineManager({ dom: document, session: { paneRegistry: mockPaneRegistry } }) + + manager.GotoSubject(sym('https://visitor.example/profile/card#me'), false, undefined, false, undefined, undefined, false) + + expect(navbar).toHaveClass('navbar--hidden') + }) + }) + + describe('account-menu history state', () => { + afterEach(() => { + document.body.replaceChildren() + window.history.replaceState({}, '', '/') + }) + + it.each([ + ['the options form', { source: 'accountMenu' }, true], + ['the old boolean form', false, true], + ['default options', {}, false], + ['the old default', true, false], + ['no options', undefined, false] + ])('marks the entry as opened by the account menu with %s: %s', (_name, options, marked) => { + const manager = new OutlineManager({ dom: document, session: { paneRegistry: mockPaneRegistry } }) + const pane = { ...MockPane, subject: sym(`${window.location.origin}/profile/card#me`) } + window.history.replaceState({ viaAccountMenu: !marked }, '', '/') + + manager.GotoSubject(sym(window.location.href), false, pane, true, undefined, undefined, options as never) + + expect(Boolean(window.history.state.viaAccountMenu)).toBe(marked) + }) + + describe('announcing the navigation', () => { + it('announces once after a solo display, with the entry it wrote', () => { + const manager = new OutlineManager({ dom: document, session: { paneRegistry: mockPaneRegistry } }) + const pane = { ...MockPane, subject: sym(`${window.location.origin}/profile/card#me`) } + const seen: NavigatedDetail[] = [] + const stop = onNavigated(detail => seen.push(detail)) + + manager.GotoSubject(sym(window.location.href), false, pane, true, undefined, undefined, { source: 'accountMenu' }) + stop() + + expect(seen).toEqual([{ + url: window.location.href, + state: { + view: { kind: 'pane', pane: 'mock', subject: `${window.location.origin}/profile/card#me` }, + viaAccountMenu: true + } + }]) + }) + + it('announces the new URL when a different subject is displayed', () => { + const manager = new OutlineManager({ dom: document, session: { paneRegistry: mockPaneRegistry } }) + const target = sym(`${window.location.origin}/elsewhere/`) + const listener = vi.fn() + const stop = onNavigated(listener) + + manager.GotoSubject(target, false, undefined, true) + stop() + + expect(listener).toHaveBeenCalledWith({ + url: target.uri, + state: { view: { kind: 'default' }, viaAccountMenu: false } + }) + }) + + it('does not announce displays inside the page that do not change what is shown as a whole', () => { + const manager = new OutlineManager({ dom: document, session: { paneRegistry: mockPaneRegistry } }) + const listener = vi.fn() + const stop = onNavigated(listener) + + manager.GotoSubject(sym(window.location.href), false, MockPane, false, undefined, document.createElement('table')) + stop() + + expect(listener).not.toHaveBeenCalled() + }) + }) + + it('marks account-menu navigation and clears the mark on other navigation', () => { + const manager = new OutlineManager({ dom: document, session: { paneRegistry: mockPaneRegistry } }) + const pane = { ...MockPane, subject: sym(`${window.location.origin}/profile/card#me`) } + const subject = sym(`${window.location.origin}/other/profile/card#me`) + + manager.GotoSubject(subject, false, pane, true, undefined, undefined, false) + expect(window.history.state).toMatchObject({ paneName: 'mock', viaAccountMenu: true }) + expect(window.location.href).toBe(subject.uri) + + manager.GotoSubject(subject, false, pane, true) + expect(window.history.state).toMatchObject({ paneName: 'mock' }) + expect(window.history.state).not.toHaveProperty('viaAccountMenu') + }) + + it('displays the account-menu pane\'s own subject while the URL stays on the page subject', () => { + const manager = new OutlineManager({ dom: document, session: { paneRegistry: mockPaneRegistry } }) + const container = sym(`${window.location.origin}/other/container/`) + const profile = sym(`${window.location.origin}/profile/card#me`) + window.history.replaceState({}, '', container.uri) + const table = document.createElement('table') + const pane = { ...MockPane, subject: profile } + + manager.GotoSubject(container, false, pane, true, undefined, table, false) + + expect(table.querySelector('.obj')).toHaveAttribute('about', `<${profile.uri}>`) + expect(window.location.href).toBe(container.uri) + expect(window.history.state).toMatchObject({ paneName: 'mock', paneUri: profile.uri, viaAccountMenu: true }) + }) + + it('updates navigation state while preserving the current URL', () => { + const manager = new OutlineManager({ dom: document, session: { paneRegistry: mockPaneRegistry } }) + const shellUrl = `${window.location.origin}/browse.html?uri=${encodeURIComponent(`${window.location.origin}/other/`)}` + const subject = sym(`${window.location.origin}/other/`) + const pane = { ...MockPane, subject } + window.history.replaceState({ existing: true }, '', shellUrl) + + const seen: NavigatedDetail[] = [] + const stop = onNavigated(detail => seen.push(detail)) + manager.GotoSubject(subject, false, pane, true, undefined, undefined, { + folderView: 'explorer', + preserveUrl: true + }) + stop() + + expect(window.location.href).toBe(shellUrl) + expect(window.history.state).toMatchObject({ + existing: true, + paneName: 'mock', + paneUri: subject.uri + }) + expect(seen.at(-1)).toMatchObject({ + url: shellUrl, + state: { + view: { kind: 'pane', pane: 'mock', subject: subject.uri }, + viaAccountMenu: false + } + }) + }) + + it('displays a navbar pane\'s own subject, and the page subject for panes without one', () => { + const manager = new OutlineManager({ dom: document, session: { paneRegistry: mockPaneRegistry } }) + const page = sym(`${window.location.origin}/other/container/sub/`) + const storage = sym(`${window.location.origin}/other/`) + window.history.replaceState({}, '', page.uri) + + const navbarTable = document.createElement('table') + manager.GotoSubject(page, false, { ...MockPane, subject: storage }, true, undefined, navbarTable) + expect(navbarTable.querySelector('.obj')).toHaveAttribute('about', `<${storage.uri}>`) + expect(window.location.href).toBe(page.uri) + expect(window.history.state).toMatchObject({ paneName: 'mock', paneUri: storage.uri }) + + const homeTable = document.createElement('table') + manager.GotoSubject(page, false, MockPane, true, undefined, homeTable, false) + expect(homeTable.querySelector('.obj')).toHaveAttribute('about', `<${page.uri}>`) + }) + + describe('hosting storage independently of the page URL', () => { + const root = `${window.location.origin}/other/` + + function setup () { + const folderPane = { + name: 'folder', + icon: '', + label: () => 'Contents', + render: (subject: { uri: string }) => { + const div = document.createElement('div') + div.textContent = `Storage shell for ${subject.uri}` + return div + } + } + const manager: OutlineManager = new OutlineManager({ + dom: document, + getOutliner: () => manager, + session: { paneRegistry: { list: [folderPane], byName: () => folderPane }, store } + }) + return { manager, folderPane } + } + + async function opened (target: string) { + const { manager, folderPane } = setup() + window.history.replaceState({}, '', target) + const table = document.createElement('table') + document.body.appendChild(table) + manager.GotoSubject(sym(target), true, { ...folderPane, subject: sym(root) }, true, undefined, table) + await vi.waitFor(() => expect(table).toHaveTextContent(`Storage shell for ${root}`)) + return table + } + + it.each([ + `${root}a/b/`, + `${root}a/b/file.ttl`, + root, + `${window.location.origin}/elsewhere/a/` + ])('renders the storage subject while preserving page URL %s', async target => { + const table = await opened(target) + const provider = table.querySelector('solid-ui-file-explorer-provider') + expect(provider?.subjectUri).toBe(root) + expect(provider?.querySelector(':scope > .paneDiv')).toHaveTextContent(`Storage shell for ${root}`) + expect(window.location.href).toBe(target) + expect(window.history.state).toMatchObject({ paneName: 'folder', paneUri: root }) + }) + }) + + it('renders the account-menu profile for the viewer without a file explorer header, even on another person\'s container URL', async () => { + const manager = new OutlineManager({ dom: document, session: { paneRegistry: mockPaneRegistry, store } }) + const container = sym(`${window.location.origin}/other/container/`) + const profile = sym(`${window.location.origin}/me/profile/card#me`) + window.history.replaceState({}, '', container.uri) + const table = document.createElement('table') + document.body.appendChild(table) + const pane = { ...MockPane, name: 'profile', paneName: 'profile', subject: profile } + + manager.GotoSubject(container, true, pane, true, undefined, table, false) + const provider = await vi.waitFor(() => { + const element = table.querySelector('solid-ui-file-explorer-provider') + expect(element).not.toBeNull() + return element! + }) + + expect(provider.subjectUri).toBe(profile.uri) + expect(provider.querySelector('solid-ui-file-explorer-header')).toBeNull() + expect(table).toHaveTextContent(`Mock Pane for ${profile.uri}`) + expect(window.location.href).toBe(container.uri) + }) + + describe('file explorer header', () => { + const container = sym(`${window.location.origin}/other/folder/file.ttl`) + + const findPane = vi.fn() + + function createExplorer ( + pane: Omit & { icon: string | (() => string | Promise) } = MockPane, + options = {}, + subject = container + ) { + const manager = new OutlineManager({ dom: document, session: { paneRegistry: { list: [pane], byName: findPane }, store } }) + const outlineView = document.createElement('div') + outlineView.id = 'OutlineView' + document.body.appendChild(outlineView) + const provider = manager.propertyTable(subject, undefined, pane, options) + outlineView.appendChild(provider) + return provider + } + + beforeEach(() => { + isInViewerPodMock.mockReset() + findPane.mockReset() + }) + + it.each([ + `${window.location.origin}/`, + `${window.location.origin}/profile/card#me` + ])('does not add a resource header for %s', async uri => { + const provider = createExplorer(MockPane, {}, sym(uri)) + await vi.waitFor(() => expect(provider.querySelector('.paneDiv')).not.toBeNull()) + expect(provider.querySelector('solid-ui-file-explorer-header')).toBeNull() + expect(isInViewerPodMock).not.toHaveBeenCalled() + }) + + it('removes the solo access-denied message when it is closed', () => { + const errorState = document.createElement('solid-ui-error-state') + document.body.appendChild(errorState) + dismissErrorStateOnClose(errorState) + + errorState.dispatchEvent(new CustomEvent('close', { bubbles: true, composed: true })) + + expect(document.body.contains(errorState)).toBe(false) + }) + + it('renders pane and header before menu icons resolve', async () => { + let resolveIcon!: (icon: string) => void + const icon = new Promise(resolve => { resolveIcon = resolve }) + const provider = createExplorer({ ...MockPane, icon: () => icon }) + await vi.waitFor(() => expect(provider.querySelector('.paneDiv')).not.toBeNull()) + const header = provider.querySelector('solid-ui-file-explorer-header')! + expect(header).not.toBeNull() + expect(header.menuItems).toEqual([]) + + resolveIcon(MockPane.icon) + await vi.waitFor(() => expect(header.menuItems).toHaveLength(1)) + }) + + it('does not render the same pane again when a related fetch repaints the provider', async () => { + const render = vi.fn(MockPane.render) + const pane = { ...MockPane, render } + const manager = new OutlineManager({ dom: document, session: { paneRegistry: { list: [pane], byName: findPane }, store } }) + const provider = manager.propertyTable(container, undefined, pane, {}) + document.body.appendChild(provider) + await vi.waitFor(() => expect(provider.querySelector('.paneDiv')).not.toBeNull()) + const paneElement = provider.querySelector('.paneDiv') + const menuItems = provider.querySelector('solid-ui-file-explorer-header')!.menuItems + + manager.propertyTable(container, provider, pane, {}) + await vi.waitFor(() => { + const header = provider.querySelector('solid-ui-file-explorer-header') + expect(header?.menuItems).not.toBe(menuItems) + }) + + expect(render).toHaveBeenCalledTimes(1) + expect(provider.querySelector('.paneDiv')).toBe(paneElement) + + manager.propertyTable(container, provider, pane, { refresh: true }) + + await vi.waitFor(() => expect(render).toHaveBeenCalledTimes(2)) + expect(provider.querySelector('.paneDiv')).not.toBe(paneElement) + }) + + it('rerenders panes that do not manage their own updates', async () => { + const render = vi.fn(MockPane.render) + const pane = { ...MockPane, managesUpdates: false, render } + const manager = new OutlineManager({ dom: document, session: { paneRegistry: { list: [pane], byName: findPane }, store } }) + const provider = manager.propertyTable(container, undefined, pane, {}) + document.body.appendChild(provider) + await vi.waitFor(() => expect(provider.querySelector('.paneDiv')).not.toBeNull()) + const paneElement = provider.querySelector('.paneDiv') + + manager.propertyTable(container, provider, pane, {}) + + await vi.waitFor(() => expect(render).toHaveBeenCalledTimes(2)) + expect(provider.querySelector('.paneDiv')).not.toBe(paneElement) + }) + + it('re-renders the selected pane when the layout changes without replacing its explorer', async () => { + const subject = sym(`${window.location.origin}/layout-dependent.ttl`) + const pane = { + ...MockPane, + render: (_subject: NamedNode, context: { environment?: { layout?: string } }) => { + const element = document.createElement('div') + element.className = 'layout-dependent-pane' + element.dataset.layout = context.environment?.layout ?? 'desktop' + return element + } + } + const context = { + dom: document, + session: { paneRegistry: { list: [pane], byName: findPane }, store }, + environment: { layout: 'desktop' } + } + const manager = new OutlineManager(context) + const outlineView = document.createElement('div') + outlineView.id = 'OutlineView' + document.body.appendChild(outlineView) + const provider = manager.propertyTable(subject, undefined, pane, {}) + outlineView.appendChild(provider) + + await vi.waitFor(() => expect(provider.querySelector('.layout-dependent-pane')).not.toBeNull()) + expect(provider.querySelector('.layout-dependent-pane')?.dataset.layout).toBe('desktop') + + context.environment.layout = 'mobile' + manager.refreshActiveExplorerPanes() + + await vi.waitFor(() => expect(provider.querySelector('.layout-dependent-pane')?.dataset.layout).toBe('mobile')) + expect(provider.subjectUri).toBe(subject.uri) + expect(provider.pane).toBe(pane) + }) + + it.each([false, true])('preserves an editing pane and refreshes unrelated panes (nested marker: %s)', async nested => { + const pane = { ...MockPane, render: vi.fn(MockPane.render) } + const manager = new OutlineManager({ + dom: document, + session: { paneRegistry: { list: [pane], byName: findPane }, store }, + environment: { layout: 'desktop' } + }) + const editing = manager.propertyTable(container, undefined, pane, {}) + const unrelated = manager.propertyTable(sym(`${window.location.origin}/other.ttl`), undefined, pane, {}) + document.body.append(editing, unrelated) + await vi.waitFor(() => expect(unrelated.querySelector('.paneDiv')).not.toBeNull()) + const current = editing.querySelector('.paneDiv')! + const other = unrelated.querySelector('.paneDiv') + const marker = nested ? current.appendChild(document.createElement('div')) : current + marker.setAttribute('data-preserve-pane-on-resize', 'true') + const draft = current.appendChild(document.createElement('textarea')) + draft.value = 'unsaved draft' + pane.render.mockClear() + + manager.refreshActiveExplorerPanes() + + expect(editing.querySelector('.paneDiv')).toBe(current) + expect(draft.value).toBe('unsaved draft') + expect(unrelated.querySelector('.paneDiv')).not.toBe(other) + expect(pane.render).toHaveBeenCalledOnce() + + marker.removeAttribute('data-preserve-pane-on-resize') + manager.refreshActiveExplorerPanes() + expect(editing.querySelector('.paneDiv')).not.toBe(current) + }) + + it('does not re-render the folder shell while refreshing a nested resource pane', async () => { + const folderPane = { ...MockPane, name: 'folder', render: vi.fn(MockPane.render) } + const subject = sym(`${window.location.origin}/storage/`) + const manager = new OutlineManager({ + dom: document, + session: { paneRegistry: { list: [folderPane], byName: findPane }, store }, + environment: { layout: 'desktop' } + }) + const provider = manager.propertyTable(subject, undefined, folderPane, {}) + document.body.appendChild(provider) + await vi.waitFor(() => expect(provider.querySelector('.paneDiv')).not.toBeNull()) + + const folderShell = document.createElement('folder-pane-view') + provider.querySelector('.paneDiv')?.appendChild(folderShell) + folderPane.render.mockClear() + + manager.context.environment.layout = 'mobile' + manager.refreshActiveExplorerPanes() + + expect(folderPane.render).not.toHaveBeenCalled() + expect(provider.querySelector('folder-pane-view')).toBe(folderShell) + }) + + it('does not add a resource header for index.ttl#this', async () => { + const provider = createExplorer(MockPane, { solo: true }, sym(`${window.location.origin}/addressbook/index.ttl#this`)) + await vi.waitFor(() => expect(provider.querySelector('.paneDiv')).not.toBeNull()) + expect(provider.querySelector('solid-ui-file-explorer-header')).toBeNull() + }) + + it.each([false, true])('resolves a container index only for direct navigation (explicit pane: %s)', async explicit => { + const subject = sym(`${window.location.origin}/indexed-container/`) + const index = sym(`${subject.uri}index.ttl#this`) + const contains = sym('http://www.w3.org/ns/ldp#contains') + store.add(subject, contains, index.doc(), subject.doc()) + const load = vi.spyOn(store.fetcher, 'load').mockResolvedValue([]) + const resource = { + containerHasIndexDocument: vi.fn(() => true), + getContainerIndexThing: vi.fn(() => index) + } + const manager = new OutlineManager({ + dom: document, + session: { store, logic: { resource }, paneRegistry: mockPaneRegistry } + }) + try { + const provider = manager.propertyTable(subject, undefined, explicit ? MockPane : undefined, { solo: true }) + document.body.appendChild(provider) + await vi.waitFor(() => expect(provider.querySelector('.paneDiv')).not.toBeNull()) + + expect(provider.subjectUri).toBe(explicit ? subject.uri : index.uri) + expect(provider.querySelector('.paneDiv')).toHaveTextContent(`Mock Pane for ${explicit ? subject.uri : index.uri}`) + if (explicit) { + expect(resource.getContainerIndexThing).not.toHaveBeenCalled() + } else { + expect(load).toHaveBeenCalledWith(index.doc()) + expect(provider.querySelector('solid-ui-file-explorer-header')).toBeNull() + } + } finally { + load.mockRestore() + store.removeMany(subject, contains, index.doc(), subject.doc()) + } + }) + + it('resolves an indexed container from its listing when the resource service is unavailable', async () => { + const subject = sym(`${window.location.origin}/indexed-without-resource/`) + const indexDocument = sym(`${subject.uri}index.ttl`) + const index = sym(`${indexDocument.uri}#this`) + const contains = sym('http://www.w3.org/ns/ldp#contains') + store.add(subject, contains, indexDocument, subject.doc()) + const load = vi.spyOn(store.fetcher, 'load').mockResolvedValue([]) + const manager = new OutlineManager({ + dom: document, + session: { store, paneRegistry: mockPaneRegistry } + }) + try { + const provider = manager.propertyTable(subject, undefined, undefined, { solo: true }) + document.body.appendChild(provider) + await vi.waitFor(() => expect(provider.querySelector('.paneDiv')).not.toBeNull()) + + expect(provider.subjectUri).toBe(index.uri) + expect(provider.querySelector('.paneDiv')).toHaveTextContent(`Mock Pane for ${index.uri}`) + expect(load).toHaveBeenCalledWith(index.doc()) + } finally { + load.mockRestore() + store.removeMany(subject, contains, indexDocument, subject.doc()) + } + }) + + it('reports menu failures without removing the rendered pane or header', async () => { + const error = new Error('Unable to resolve pane icon') + const status = document.createElement('div') + status.id = 'status' + document.body.appendChild(status) + const icon = vi.fn() + .mockReturnValueOnce(MockPane.icon) + .mockImplementationOnce(() => { throw error }) + const provider = createExplorer({ + ...MockPane, + icon + }) + await vi.waitFor(() => expect(status).toHaveTextContent('Unable to resolve pane icon')) + expect(provider.querySelector('.paneDiv')).not.toBeNull() + expect(provider.querySelector('solid-ui-file-explorer-header')).not.toBeNull() + }) + + it.each(['profile', 'basicPreferences', 'home', 'dashboard'])('reuses resource visibility and menu items when switching to %s and back', async paneName => { + isInViewerPodMock.mockResolvedValue(true) + const provider = createExplorer(MockPane, { headerOnlyInViewerPod: true }) + await vi.waitFor(() => { + expect(provider.querySelector('solid-ui-file-explorer-header')?.menuItems).toHaveLength(1) + }) + const header = provider.querySelector('solid-ui-file-explorer-header')! + const menuItems = header.menuItems + findPane.mockReturnValue({ ...MockPane, name: paneName }) + menuItems[0].action(new Event('click')) + expect(provider.querySelector('solid-ui-file-explorer-header')).toBeNull() + + findPane.mockReturnValue(MockPane) + menuItems[0].action(new Event('click')) + const restored = provider.querySelector('solid-ui-file-explorer-header')! + expect(restored.menuItems).toBe(menuItems) + expect(isInViewerPodMock).toHaveBeenCalledTimes(1) + }) + + it('does not switch the outer pane for an unhandled nested pane-switch event', async () => { + const provider = createExplorer() + await vi.waitFor(() => expect(provider.querySelector('.paneDiv')).not.toBeNull()) + const paneElement = provider.querySelector('.paneDiv')! + const nested = document.createElement('solid-ui-file-explorer-provider') + paneElement.appendChild(nested) + nested.dispatchEvent(new CustomEvent('solid-ui-file-explorer-open-pane', { + bubbles: true, + composed: true, + detail: { subjectUri: container.uri, paneName: 'profile' } + })) + + expect(findPane).not.toHaveBeenCalled() + expect(provider.querySelector(':scope > .paneDiv')).toBe(paneElement) + }) + + it('switches the originating provider when the same subject appears twice', async () => { + const first = createExplorer() + const second = createExplorer() + await vi.waitFor(() => { + expect(first.querySelector('.paneDiv')).not.toBeNull() + expect(second.querySelector('solid-ui-file-explorer-header')?.menuItems).toHaveLength(1) + }) + const firstContent = first.querySelector('.paneDiv') + const secondContent = second.querySelector('.paneDiv') + findPane.mockReturnValue({ ...MockPane, name: 'other' }) + second.querySelector('solid-ui-file-explorer-header')!.menuItems[0].action(new Event('click')) + + expect(first.querySelector('.paneDiv')).toBe(firstContent) + expect(second.querySelector('.paneDiv')).not.toBe(secondContent) + expect(second.pane.name).toBe('other') + }) + + it('uses the owning provider when opening a pane through the callback', async () => { + const provider = createExplorer() + await vi.waitFor(() => expect(provider.querySelector('.paneDiv')).not.toBeNull()) + const replacement = { ...MockPane, name: 'replacement' } + vi.mocked(paneRegistry.byName).mockReturnValue(replacement as never) + try { + provider.openPane(container, 'replacement') + expect(provider.pane.name).toBe('replacement') + expect(provider.querySelector('.paneDiv')).toHaveTextContent(`Mock Pane for ${container.uri}`) + } finally { + vi.mocked(paneRegistry.byName).mockReset() + } + }) + + it('does not collapse the outer explorer for an unhandled nested Back event', async () => { + const provider = createExplorer() + await vi.waitFor(() => expect(provider.querySelector('.paneDiv')).not.toBeNull()) + const nested = document.createElement('solid-ui-file-explorer-provider') + provider.querySelector('.paneDiv')!.appendChild(nested) + const parent = provider.parentNode + nested.dispatchEvent(new CustomEvent('solid-ui-file-explorer-back', { + bubbles: true, + composed: true, + detail: { subjectUri: container.uri } + })) + + expect(provider.parentNode).toBe(parent) + expect(provider.contains(nested)).toBe(true) + }) + + it('preserves the browser host when collapsing a solo explorer', async () => { + const provider = createExplorer() + await vi.waitFor(() => expect(provider.querySelector('.paneDiv')).not.toBeNull()) + const outlineView = document.createElement('div') + outlineView.id = 'outline' + const subjectBlock = document.createElement('div') + subjectBlock.className = 'outline-subject-block' + const sibling = document.createElement('div') + subjectBlock.appendChild(provider) + outlineView.append(subjectBlock, sibling) + document.body.appendChild(outlineView) + + provider.dispatchEvent(new CustomEvent('solid-ui-file-explorer-back', { + bubbles: true, + composed: true, + detail: { subjectUri: container.uri } + })) + + expect(outlineView.parentNode).toBe(document.body) + expect(outlineView.contains(sibling)).toBe(true) + }) + + async function headerShown (showNavbar: boolean, pane: object = MockPane) { + const manager = new OutlineManager({ dom: document, session: { paneRegistry: mockPaneRegistry, store } }) + window.history.replaceState({}, '', container.uri) + const table = document.createElement('table') + document.body.appendChild(table) + manager.GotoSubject(container, true, pane, true, undefined, table, showNavbar) + const provider = await vi.waitFor(() => { + const element = table.querySelector('solid-ui-file-explorer-provider') + expect(element).not.toBeNull() + return element! + }) + return provider.querySelector('solid-ui-file-explorer-header') !== null + } + + it('is hidden for account-menu views when the URL is not in the viewer\'s pod', async () => { + isInViewerPodMock.mockResolvedValue(false) + + expect(await headerShown(false)).toBe(false) + expect(await headerShown(false, { ...MockPane, subject: sym(`${window.location.origin}/me/storage/docs/`) })).toBe(false) + expect(isInViewerPodMock).toHaveBeenCalledWith(container.uri) + }) + + it('is kept for account-menu views when the URL is in the viewer\'s pod', async () => { + isInViewerPodMock.mockResolvedValue(true) + + expect(await headerShown(false)).toBe(true) + }) + + it.each(['basicPreferences', 'home', 'dashboard'])('is hidden for account-menu %s even inside the viewer\'s pod', async name => { + isInViewerPodMock.mockResolvedValue(true) + + expect(await headerShown(false, { ...MockPane, name })).toBe(false) + }) + + it('is not affected for navbar navigation to a pane without its own subject', async () => { + isInViewerPodMock.mockResolvedValue(false) + + expect(await headerShown(true)).toBe(true) + expect(isInViewerPodMock).not.toHaveBeenCalled() + }) + + it('is hidden for navbar navigation to a pane with its own subject outside the viewer\'s pod', async () => { + isInViewerPodMock.mockResolvedValue(false) + const storage = { ...MockPane, subject: sym(`${window.location.origin}/other/storage/`) } + + expect(await headerShown(true, storage)).toBe(false) + expect(isInViewerPodMock).toHaveBeenCalledWith(container.uri) + }) + + it('is kept for navbar navigation to a pane with its own subject inside the viewer\'s pod', async () => { + isInViewerPodMock.mockResolvedValue(true) + const storage = { ...MockPane, subject: sym(`${window.location.origin}/other/storage/`) } + + expect(await headerShown(true, storage)).toBe(true) + }) + }) + + it('does not carry pane details into the entry of a different subject', () => { + const manager = new OutlineManager({ dom: document, session: { paneRegistry: mockPaneRegistry } }) + const first = sym(`${window.location.origin}/a/profile/card#me`) + const second = sym(`${window.location.origin}/b/profile/card#me`) + window.history.replaceState({ other: 'kept' }, '', first.uri) + manager.GotoSubject(first, false, { ...MockPane, subject: first }, true) + const entries = window.history.length + + manager.GotoSubject(second, false, undefined, true) + + expect(window.history.length).toBe(entries + 1) + expect(window.location.href).toBe(second.uri) + expect(window.history.state).toEqual({ other: 'kept' }) + }) + + it('keeps pane details when the same subject is rendered again without a pane', () => { + const manager = new OutlineManager({ dom: document, session: { paneRegistry: mockPaneRegistry } }) + const subject = sym(`${window.location.origin}/a/profile/card#me`) + window.history.replaceState({}, '', subject.uri) + manager.GotoSubject(subject, false, { ...MockPane, subject }, true) + + manager.GotoSubject(subject, false, undefined, true) + + expect(window.history.state).toEqual({ paneName: 'mock', paneUri: subject.uri }) + }) + + it('replaces a saved pane URI when the new pane does not render another subject', () => { + const manager = new OutlineManager({ dom: document, session: { paneRegistry: mockPaneRegistry } }) + const subject = sym(`${window.location.origin}/a/profile/card#me`) + window.history.replaceState({}, '', subject.uri) + manager.GotoSubject(subject, false, { ...MockPane, subject: sym(`${window.location.origin}/storage/`) }, true) + + manager.GotoSubject(subject, false, { ...MockPane, name: 'other' }, true) + + expect(window.history.state).toEqual({ paneName: 'other' }) + }) + }) + describe('outline object td', () => { describe('for a named node', () => { let result @@ -40,11 +793,11 @@ describe('manager', () => { const row = document.createElement('tr') table.appendChild(row) const manager = new OutlineManager({ dom: document, session: { paneRegistry: mockPaneRegistry } }) - result = manager.outlineObjectTD(sym('https://namednode.example/'), null, null, null) + result = manager.outlineObjectDiv(sym('https://namednode.example/'), null, null, null) row.appendChild(result) }) - it('is a html td element', () => { - expect(result.nodeName).toBe('TD') + it('is a html div element', () => { + expect(result.nodeName).toBe('DIV') }) it('about attribute refers to node', () => { expect(result).toHaveAttribute('about', '') @@ -88,6 +841,96 @@ describe('manager', () => { const error = await findByText(result.parentNode, /Mock Pane/) expect(error).toHaveTextContent('Mock Pane for https://namednode.example/') }) + + it('selects the first property object inside an expanded provider', () => { + const manager = new OutlineManager({ dom: document, session: { paneRegistry: mockPaneRegistry } }) + const outer = manager.outlineObjectDiv(sym('https://outer.example/'), null, null, null) + const provider = document.createElement('solid-ui-file-explorer-provider') + const propertyObject = manager.outlineObjectDiv(sym('https://property.example/'), null, null, null) + provider.appendChild(propertyObject) + outer.appendChild(provider) + document.body.appendChild(outer) + + manager.walk('moveTo', outer) + manager.walk('right') + + expect(manager.getSelection()).toEqual([propertyObject]) + expect(propertyObject).toHaveClass('selected') + expect(outer).not.toHaveClass('selected') + }) + + it('restores the current selection when an expanded provider has no property rows', () => { + const manager = new OutlineManager({ dom: document, session: { paneRegistry: mockPaneRegistry } }) + const outer = manager.outlineObjectDiv(sym('https://outer.example/'), null, null, null) + outer.appendChild(document.createElement('solid-ui-file-explorer-provider')) + document.body.appendChild(outer) + + manager.walk('moveTo', outer) + expect(() => manager.walk('right')).not.toThrow() + + expect(manager.getSelection()).toEqual([outer]) + expect(outer).toHaveClass('selected') + }) + + it('keeps the final statement selected when there is no next row', () => { + const manager = new OutlineManager({ dom: document, session: { paneRegistry: mockPaneRegistry } }) + const outer = manager.outlineObjectDiv(sym('https://final.example/'), null, null, null) + document.body.appendChild(outer) + + manager.walk('moveTo', outer) + expect(() => manager.walk('right')).not.toThrow() + + expect(manager.getSelection()).toEqual([outer]) + }) + + it('walks left to the enclosing expanded object', () => { + const manager = new OutlineManager({ dom: document, session: { paneRegistry: mockPaneRegistry } }) + const outer = manager.outlineObjectDiv(sym('https://outer.example/'), null, null, null) + const provider = document.createElement('solid-ui-file-explorer-provider') + provider.setAttribute('about', '') + const propertyObject = manager.outlineObjectDiv(sym('https://property.example/'), null, null, null) + provider.appendChild(propertyObject) + outer.appendChild(provider) + document.body.appendChild(outer) + + manager.walk('moveTo', propertyObject) + manager.walk('left') + + expect(manager.getSelection()).toEqual([outer]) + }) + + it('does not collapse an unexpanded object without an enclosing provider', () => { + const manager = new OutlineManager({ dom: document, session: { paneRegistry: mockPaneRegistry } }) + const object = manager.outlineObjectDiv(sym('https://property.example/'), null, null, null) + document.body.appendChild(object) + manager.walk('moveTo', object) + const replace = vi.spyOn(manager, 'replaceTD') + + manager.OutlinerKeypressPanel({ keyCode: 37, target: object }) + + expect(replace).not.toHaveBeenCalled() + expect(object).toHaveTextContent('property.example') + }) + + it('refocuses the outer subject wrapper for shift-click expansion', async () => { + const manager = new OutlineManager({ dom: document, session: { paneRegistry: mockPaneRegistry } }) + const subject = sym('https://shift-click.example/resource') + const subjectBlock = document.createElement('div') + subjectBlock.className = 'outline-subject-block' + const object = manager.outlineObjectDiv(subject, null, null, null) + subjectBlock.appendChild(object) + document.body.appendChild(subjectBlock) + + object.firstChild.dispatchEvent(new MouseEvent('click', { bubbles: true, shiftKey: true })) + + await vi.waitFor(() => expect(subjectBlock.querySelector('.paneDiv')).not.toBeNull()) + expect(subjectBlock).toHaveAttribute('about', subject.toNT()) + expect(subjectBlock.querySelector('[data-outline-node="object"]')).toBeNull() + expect(subjectBlock.querySelector('solid-ui-file-explorer-provider')).toHaveAttribute( + 'about', + subject.toNT() + ) + }) }) }) @@ -95,10 +938,10 @@ describe('manager', () => { let result beforeAll(() => { const manager = new OutlineManager({ dom: document }) - result = manager.outlineObjectTD(sym('tel:+1-201-555-0123'), null, null, null) + result = manager.outlineObjectDiv(sym('tel:+1-201-555-0123'), null, null, null) }) - it('is a html td element', () => { - expect(result.nodeName).toBe('TD') + it('is a html div element', () => { + expect(result.nodeName).toBe('DIV') }) it('about attribute refers to tel uri', () => { expect(result).toHaveAttribute('about', '') @@ -142,10 +985,10 @@ describe('manager', () => { let result beforeAll(() => { const manager = new OutlineManager({ dom: document }) - result = manager.outlineObjectTD(lit('some text'), null, null, null) + result = manager.outlineObjectDiv(lit('some text'), null, null, null) }) - it('is a html td element', () => { - expect(result.nodeName).toBe('TD') + it('is a html div element', () => { + expect(result.nodeName).toBe('DIV') }) it('has no about attribute', () => { expect(result).not.toHaveAttribute('about') @@ -172,10 +1015,10 @@ describe('manager', () => { let result beforeAll(() => { const manager = new OutlineManager({ dom: document }) - result = manager.outlineObjectTD(blankNode('blank-node'), null, null, null) + result = manager.outlineObjectDiv(blankNode('blank-node'), null, null, null) }) - it('is a html td element', () => { - expect(result.nodeName).toBe('TD') + it('is a html div element', () => { + expect(result.nodeName).toBe('DIV') }) it('has about attribute', () => { expect(result).toHaveAttribute('about', '_:blank-node') @@ -189,8 +1032,16 @@ describe('manager', () => { it('uses object cell class for layout styling', () => { expect(result).toHaveClass('obj') }) - it('shows 3 dots', () => { - expect(result).toHaveTextContent('...') + }) + + describe('outlineObjectTD compatibility alias', () => { + it('returns the same div-based object block', () => { + const manager = new OutlineManager({ dom: document }) + const result = manager.outlineObjectTD(sym('https://alias.example/'), null, null, null) + + expect(result.nodeName).toBe('DIV') + expect(result).toHaveAttribute('about', '') + expect(result).toHaveClass('obj') }) }) }) diff --git a/test/unit/paneLayout.test.ts b/test/unit/paneLayout.test.ts new file mode 100644 index 00000000..5ddc6f35 --- /dev/null +++ b/test/unit/paneLayout.test.ts @@ -0,0 +1,36 @@ +import { readFileSync } from 'node:fs' +import { resolve } from 'node:path' +import { describe, expect, it } from 'vitest' + +function stylesheet (path: string): string { + return readFileSync(resolve(process.cwd(), 'src', path), 'utf8') +} + +describe('pane content spacing', () => { + it('gives the Notepad pad pane a small top inset', () => { + expect(stylesheet('pad/padPane.css')).toMatch( + /\.pad-layout \{[\s\S]*padding-top: 0\.5rem;/ + ) + }) + + it('keeps a 40px desktop gutter on the About and Data panes', () => { + expect(stylesheet('defaultPane.css')).toMatch( + /\.paneDiv\.defaultPane \{[\s\S]*padding-inline: 40px;/ + ) + expect(stylesheet('dataContentPane.css')).toMatch( + /\.data-content-pane \{[^}]*padding: 8px 40px;/ + ) + expect(stylesheet('dataContentPane.css')).not.toMatch( + /\.data-content-pane__nested-formula[^{]*\{[^}]*40px/ + ) + }) + + it('keeps the Under the Hood pane within its host while adding desktop gutters', () => { + expect(stylesheet('internal/internalPane.css')).toMatch( + /\.internalPaneContent \{[\s\S]*padding: var\(--spacing-xs, 0\.5em\) 40px;[\s\S]*box-sizing: border-box;/ + ) + expect(stylesheet('internal/internalPane.css')).toMatch( + /\.internalPaneControls \{[\s\S]*width: 100%;[\s\S]*margin: var\(--spacing-sm, 1em\) 0;[\s\S]*box-sizing: border-box;/ + ) + }) +}) diff --git a/test/unit/podUtils.test.ts b/test/unit/podUtils.test.ts new file mode 100644 index 00000000..e70efbd8 --- /dev/null +++ b/test/unit/podUtils.test.ts @@ -0,0 +1,27 @@ +import { afterEach, describe, expect, it, vi } from 'vitest' +import { store } from 'solid-logic' +import { ns } from 'solid-ui' +import { sym } from 'rdflib' +import { getPodStorages } from '../../src/utils/podUtils' + +describe('getPodStorages', () => { + const webId = sym('https://pod.example/profile/card#me') + const storage = sym('https://pod.example/') + + afterEach(() => { + vi.restoreAllMocks() + store.removeMatches(webId, ns.space('storage'), null, webId.doc()) + store.removeMatches(storage, null, null, storage.doc()) + }) + + it('uses a storage declared by the WebID profile without requiring a Storage type response', async () => { + vi.spyOn(store.fetcher, 'load').mockImplementation(async () => { + store.add(webId, ns.space('storage'), storage, webId.doc()) + return [] as never + }) + const webOperation = vi.spyOn(store.fetcher, 'webOperation') + + await expect(getPodStorages(webId)).resolves.toEqual([storage]) + expect(webOperation).not.toHaveBeenCalled() + }) +}) diff --git a/test/unit/rdfSerializationPanes.test.ts b/test/unit/rdfSerializationPanes.test.ts new file mode 100644 index 00000000..fa42475b --- /dev/null +++ b/test/unit/rdfSerializationPanes.test.ts @@ -0,0 +1,40 @@ +import { describe, expect, it } from 'vitest' +import { graph, namedNode } from 'rdflib' +import { RDFXMLPane } from '../../src/RDFXMLPane' +import { n3Pane } from '../../src/n3Pane' + +function renderPane (pane: typeof RDFXMLPane | typeof n3Pane) { + const store = graph() + const subject = namedNode('https://pod.example/card') + store.add(subject, namedNode('https://pod.example/name'), namedNode('https://pod.example/name')) + const context = { + dom: document, + session: { store } + } as any + + return pane.render(subject, context).querySelector('solid-panes-editor-card') as HTMLElement & { + contentType?: string + accessibilityLabel?: string + accessibilityDescription?: string + } +} + +describe('RDF serialization panes', () => { + it('labels generated RDF/XML as a read-only serialization for the resource', () => { + const source = renderPane(RDFXMLPane) + + expect(source.contentType).toBe('application/rdf+xml') + expect(source.accessibilityLabel).toBe('Generated RDF/XML for https://pod.example/card') + expect(source.accessibilityDescription) + .toBe('Generated RDF/XML serialization. This content is read-only.') + }) + + it('labels generated N3 as a read-only serialization for the resource', () => { + const source = renderPane(n3Pane) + + expect(source.contentType).toBe('text/n3') + expect(source.accessibilityLabel).toBe('Generated N3 for https://pod.example/card') + expect(source.accessibilityDescription) + .toBe('Generated N3 serialization. This content is read-only.') + }) +}) diff --git a/test/unit/slideshowPane.test.ts b/test/unit/slideshowPane.test.ts new file mode 100644 index 00000000..0b2bd448 --- /dev/null +++ b/test/unit/slideshowPane.test.ts @@ -0,0 +1,51 @@ +import { describe, expect, it, vi } from 'vitest' + +const resource = vi.hoisted(() => ({ + isContainer: vi.fn(() => true), + isImage: vi.fn((file: { image?: boolean }) => file.image === true) +})) + +vi.mock('solid-logic', async importOriginal => { + const actual = await importOriginal() + return { + ...actual, + solidLogicSingleton: { ...actual.solidLogicSingleton, resource } + } +}) + +import { slideshowPane } from '../../src/slideshow/slideshowPane' + +function contextFor (contents: Array<{ uri: string, image?: boolean }>) { + const subject = { uri: 'https://pod.example/photos/' } + const store = { + each: vi.fn(() => contents) + } + return { subject, context: { session: { store } } as any } +} + +describe('slideshow pane', () => { + it('requires at least two images', () => { + const { subject, context } = contextFor([{ uri: 'one.png', image: true }]) + + expect(slideshowPane.label(subject as any, context)).toBeNull() + }) + + it('accepts containers containing multiple images and other resources', () => { + const { subject, context } = contextFor([ + { uri: 'one.png', image: true }, + { uri: 'notes.txt', image: false }, + { uri: 'two.png', image: true } + ]) + + expect(slideshowPane.label(subject as any, context)).toBe('Slideshow') + }) + + it('accepts containers containing multiple images only', () => { + const { subject, context } = contextFor([ + { uri: 'one.png', image: true }, + { uri: 'two.png', image: true } + ]) + + expect(slideshowPane.label(subject as any, context)).toBe('Slideshow') + }) +}) diff --git a/test/unit/social/socialSections.test.ts b/test/unit/social/socialSections.test.ts new file mode 100644 index 00000000..9155b62b --- /dev/null +++ b/test/unit/social/socialSections.test.ts @@ -0,0 +1,204 @@ +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' +import { readFileSync } from 'node:fs' +import { sym } from 'rdflib' +import { store } from 'solid-logic' +import { ns } from 'solid-ui' +import { createAllFriendsSection } from '../../../src/social/socialSections' + +vi.mock('../../../src/social/editProfileDetails', () => ({ + appendProfileLinks: vi.fn() +})) + +const subject = sym('https://friends-test.example/profile/card#me') +const profile = subject.doc() +const firstFriend = sym('https://first-friend.example/profile/card#me') +const secondFriend = sym('https://second-friend.example/profile/card#me') + +function createList (editable = true) { + const result = createAllFriendsSection({ + dom: document, + subject, + profile: editable ? profile : null, + editable, + renderSupportingInfo: () => null, + renderNameSuffix: () => null + }) + document.body.appendChild(result.section) + return result +} + +function drop (target: Element, text: string, type = 'text/uri-list') { + const event = new Event('drop', { bubbles: true, cancelable: true }) + Object.defineProperty(event, 'dataTransfer', { + value: { + types: [type], + getData: () => text, + dropEffect: 'copy' + } + }) + target.dispatchEvent(event) + return event +} + +describe('friends list drop surface', () => { + beforeEach(() => { + vi.spyOn(store.updater, 'update').mockImplementation((deletions, insertions, callback) => { + const removed = Array.isArray(deletions) ? deletions : [deletions] + removed.forEach(statement => store.removeStatement(statement)) + const statements = Array.isArray(insertions) ? insertions : [insertions] + statements.forEach(statement => store.add(statement)) + callback?.(profile.value, true, '') + }) + }) + + afterEach(() => { + store.removeMatches(subject, null, null) + document.body.replaceChildren() + vi.restoreAllMocks() + }) + + it('adds a friend when dropped onto the empty list surface', () => { + const { friendsList } = createList() + const surface = friendsList.querySelector('.social-friends-list-surface')! + expect(surface).toBeVisible() + expect(friendsList.querySelector('button[title="Drop attachments here"]')).toBeNull() + + const event = drop(surface, firstFriend.value) + + expect(event.defaultPrevented).toBe(true) + expect(store.updater.update).toHaveBeenCalledTimes(1) + expect(store.holds(subject, ns.foaf('knows'), firstFriend, profile)).toBe(true) + expect(friendsList.querySelector(`a[href="${firstFriend.value}"]`)).not.toBeNull() + }) + + it('accepts drops onto existing cards and keeps working after refresh', () => { + store.add(subject, ns.foaf('knows'), firstFriend, profile) + const { friendsList } = createList() + const card = friendsList.querySelector(`a[href="${firstFriend.value}"]`)!.closest('tr')! + + drop(card.querySelector('a')!, secondFriend.value) + + expect(store.updater.update).toHaveBeenCalledTimes(1) + expect(store.holds(subject, ns.foaf('knows'), secondFriend, profile)).toBe(true) + const refreshedCard = friendsList.querySelector(`a[href="${secondFriend.value}"]`)!.closest('tr')! + expect(refreshedCard).not.toBeNull() + expect(refreshedCard.querySelector('[title="Remove this friend"]')).not.toBeNull() + drop(refreshedCard, firstFriend.value) + expect(store.updater.update).toHaveBeenCalledTimes(2) + }) + + it('accepts multiple WebIDs and ignores URI-list comments', () => { + const { friendsList } = createList() + drop(friendsList.querySelector('.social-friends-drop-hint')!, + `# Friends\r\n${firstFriend.value}\r\n${secondFriend.value}\r\n`) + + expect(store.updater.update).toHaveBeenCalledTimes(1) + expect(store.each(subject, ns.foaf('knows'))).toHaveLength(2) + }) + + it('accepts a WebID dragged as plain text', () => { + const { friendsList } = createList() + drop(friendsList.querySelector('.social-friends-list-surface')!, + firstFriend.value, 'text/plain') + + expect(store.holds(subject, ns.foaf('knows'), firstFriend, profile)).toBe(true) + }) + + it('does not enable drops or show editable controls on read-only lists', () => { + store.add(subject, ns.foaf('knows'), firstFriend, profile) + const { friendsList } = createList(false) + expect(friendsList.querySelector('.social-friends-drop-hint')).toBeNull() + expect(friendsList.querySelector('button')).toBeNull() + expect(friendsList.querySelector('[title="Remove this friend"]')).toBeNull() + const event = drop(friendsList.querySelector('.social-friends-list-surface')!, + secondFriend.value) + + expect(event.defaultPrevented).toBe(false) + expect(store.updater.update).not.toHaveBeenCalled() + expect(store.holds(subject, ns.foaf('knows'), secondFriend)).toBe(false) + }) + + it('sizes and right-aligns the navigation icon like the remove icon only in all friends', () => { + store.add(subject, ns.foaf('knows'), firstFriend, profile) + const { section, friendsList } = createList() + const style = document.createElement('style') + style.textContent = readFileSync('src/social/socialPane.css', 'utf8') + document.body.appendChild(style) + const link = friendsList.querySelector(`a[href="${firstFriend.value}"]`)! + const image = link.querySelector('icon-lucide-square-arrow-out-up-right')! + const remove = friendsList.querySelector('[title="Remove this friend"]')! + + expect(getComputedStyle(image).width).toBe(getComputedStyle(remove).width) + expect(getComputedStyle(image).height).toBe(getComputedStyle(remove).height) + expect(getComputedStyle(image).margin).toBe(getComputedStyle(remove).margin) + expect(getComputedStyle(link).float).toBe(getComputedStyle(remove).float) + expect(getComputedStyle(link).clear).toBe('right') + expect(link.querySelector('img')).toBeNull() + expect(link.getAttribute('aria-label')).toBe('Open resource') + expect(getComputedStyle(image).color).toBe('var(--color-text-secondary, #4A5565)') + + section.classList.remove('social-pane__all-friends') + expect(getComputedStyle(image).margin).toBe('0.2em') + expect(getComputedStyle(link).float).not.toBe('right') + }) + + it('renders shared Lucide icons immediately after attachmentList refreshes its rows', () => { + const { friendsList } = createList() + drop(friendsList.querySelector('.social-friends-list-surface')!, firstFriend.value) + + const link = friendsList.querySelector(`a[href="${firstFriend.value}"]`)! + expect(link.querySelector('icon-lucide-square-arrow-out-up-right')).not.toBeNull() + expect(link.querySelector('img')).toBeNull() + }) + + it('shows confirmation outside a single friend card and cancels without deleting', () => { + store.add(subject, ns.foaf('knows'), firstFriend, profile) + const { section, friendsList } = createList() + const pane = document.body.appendChild(document.createElement('div')) + pane.className = 'social-pane' + pane.appendChild(section) + const style = document.createElement('style') + style.textContent = readFileSync('src/social/socialPane.css', 'utf8') + document.body.appendChild(style) + friendsList.querySelector('[title="Remove this friend"]')!.click() + + const confirmation = section.querySelector('[role="dialog"]')! + expect(confirmation.parentElement).toBe(section.querySelector('.social-friends-delete-confirmation')) + expect(friendsList.contains(confirmation)).toBe(false) + expect(confirmation.closest('.social-friends-grid')).toBeNull() + const overlay = confirmation.parentElement! + expect(getComputedStyle(section).position).toBe('relative') + expect(getComputedStyle(overlay).position).toBe('absolute') + expect(getComputedStyle(overlay).inset).toBe('0px') + expect(getComputedStyle(overlay).placeItems).toBe('center') + expect(getComputedStyle(overlay).zIndex).toBe('10') + expect(getComputedStyle(confirmation).width).toBe('max-content') + expect(getComputedStyle(confirmation).pointerEvents).toBe('auto') + const cancel = Array.from(confirmation.querySelectorAll('button')) + .find(button => button.textContent === 'Cancel')! + expect(document.activeElement).toBe(cancel) + cancel.click() + + expect(section.querySelector('[role="dialog"]')).toBeNull() + expect(store.updater.update).not.toHaveBeenCalled() + expect(store.holds(subject, ns.foaf('knows'), firstFriend, profile)).toBe(true) + }) + + it('confirms removal of the last friend using the original widget handler', () => { + store.add(subject, ns.foaf('knows'), firstFriend, profile) + const { section, friendsList } = createList() + const remove = friendsList.querySelector('[title="Remove this friend"]')! + remove.click() + remove.click() + expect(section.querySelectorAll('[role="dialog"]')).toHaveLength(1) + const confirmation = section.querySelector('[role="dialog"]')! + Array.from(confirmation.querySelectorAll('button')) + .find(button => button.textContent === 'Remove this friend')!.click() + + expect(store.updater.update).toHaveBeenCalledTimes(1) + expect(store.holds(subject, ns.foaf('knows'), firstFriend, profile)).toBe(false) + expect(friendsList.querySelector(`a[href="${firstFriend.value}"]`)).toBeNull() + expect(section.querySelector('[role="dialog"]')).toBeNull() + expect(friendsList.querySelector('.social-friends-drop-hint')).not.toBeNull() + }) +}) diff --git a/vite.config.mts b/vite.config.mts index b9def924..e3272f70 100644 --- a/vite.config.mts +++ b/vite.config.mts @@ -16,6 +16,8 @@ if (isWatch && build && Array.isArray(build.rolldownOptions?.output)) { build.rolldownOptions.output = build.rolldownOptions.output.filter( (o: { format?: string }) => o.format === 'es', ) + + build.watch = { exclude: ['**/dist/**'] } } type ConcretePlugin = Extract