@protobase/ui 0.62.4 → 0.63.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/account/account-page.js +3 -0
  2. package/dist/account/blocks/connected-accounts-block.js +1 -1
  3. package/dist/account/blocks/personal-mail-block.js +36 -0
  4. package/dist/account/messages.js +4 -0
  5. package/dist/account/sign-in-providers-section.js +3 -3
  6. package/dist/app/app.d.ts +1 -1
  7. package/dist/app/app.js +22 -5
  8. package/dist/app/pages/render-node.js +2 -0
  9. package/dist/auth/auth-provider.js +7 -0
  10. package/dist/calls/call-check.js +2 -2
  11. package/dist/calls/call-controls.js +16 -4
  12. package/dist/calls/call-guests-panel.js +200 -0
  13. package/dist/calls/call-lobby-notice.js +34 -0
  14. package/dist/calls/call-message.js +4 -3
  15. package/dist/calls/call-people.js +3 -2
  16. package/dist/calls/call-stage.js +4 -2
  17. package/dist/calls/call-view.d.ts +9 -3
  18. package/dist/calls/call-view.js +37 -6
  19. package/dist/calls/call-waiting.js +20 -0
  20. package/dist/calls/guest-admission.js +40 -0
  21. package/dist/calls/guest-call-link.js +19 -0
  22. package/dist/calls/guest-call-page.js +82 -0
  23. package/dist/calls/messages.js +69 -3
  24. package/dist/calls/use-call-session.d.ts +7 -0
  25. package/dist/calls/use-call-session.js +27 -2
  26. package/dist/calls/use-guest-request.js +24 -0
  27. package/dist/data/api-provider.d.ts +8 -0
  28. package/dist/index.js +1 -1
  29. package/dist/organizations/messages.js +6 -0
  30. package/dist/organizations/organization-page.js +33 -1
  31. package/dist/package.js +1 -1
  32. package/dist/shell/assets/app-CKCVGFSR.js +9 -0
  33. package/dist/shell/assets/calls-DRnrKDC9.js +2 -0
  34. package/dist/shell/assets/{index-D8oHLXjS.js → index-BK-wuwB0.js} +2 -2
  35. package/dist/shell/assets/index-Be8nCyRW.css +2 -0
  36. package/dist/shell/assets/{records-map-DOXcutuQ.js → records-map-Bd5scHzJ.js} +2 -2
  37. package/dist/shell/assets/shared-protobase-ui-CU8QfOuc.js +2 -0
  38. package/dist/shell/index.html +4 -4
  39. package/dist/shell/protobase.shell.json +2 -2
  40. package/dist/shell/protobase.sw.js +2 -2
  41. package/dist/shell-source-maps/assets/app-CKCVGFSR.js.map +1 -0
  42. package/dist/shell-source-maps/assets/calls-DRnrKDC9.js.map +1 -0
  43. package/dist/shell-source-maps/assets/{index-D8oHLXjS.js.map → index-BK-wuwB0.js.map} +1 -1
  44. package/dist/shell-source-maps/assets/{records-map-DOXcutuQ.js.map → records-map-Bd5scHzJ.js.map} +1 -1
  45. package/dist/shell-source-maps/assets/shared-protobase-ui-CU8QfOuc.js.map +1 -0
  46. package/package.json +4 -4
  47. package/dist/shell/assets/app-B_ojAtG3.js +0 -9
  48. package/dist/shell/assets/calls-C63xSTRj.js +0 -2
  49. package/dist/shell/assets/index-BgcF_WZ0.css +0 -2
  50. package/dist/shell/assets/shared-protobase-ui-CX80Ectk.js +0 -2
  51. package/dist/shell-source-maps/assets/app-B_ojAtG3.js.map +0 -1
  52. package/dist/shell-source-maps/assets/calls-C63xSTRj.js.map +0 -1
  53. package/dist/shell-source-maps/assets/shared-protobase-ui-CX80Ectk.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calls-DRnrKDC9.js","names":["newPeerConnection","createPeerConnection","newPeerConnection","createPeerConnection","guestCallsPath","GuestRefused","reason","guestRequests","pending","ask","send","message","expiresAt","request","PublishRefused","createPeerConnection","configuration","statsOf","stats","report","transport","stat","pair","lost","received","roundTrip","connectionOf","state","pc","member","midsByStreamId","mids","section","sdp","mid","stream","firefoxMade","inFirefox","politeTo","offer","peer","peerLink","createPeerConnection$2","peers","local","remote","publishing","publishes","sendOn","track","receivedTrack","sid","transceiver","emitTracks","onTracks","open","making","event","source","sending","connect","self","renew","disconnect","signal","from","description","collision","candidate","error","receive","present","publishNow","added","tracks","answered","next","sender","muted","negotiation","inFlight","again","waiting","start","settle","resolve","simulcastLayers","singleBitrate","trackRequest","layers","simulcast","layer","width","height","sendEncodings","sfuLink","createPeerConnection$1","early","offerId","offers","negotiate","key","restartIce","stopSending","i","onUnpublished","options","encodings","sids","backoff","attempt","socketUrl","resolved","url","leftCodes","failedCodes","joinCall","WebSocketOf","retryDelay","maxRetries","socket","link","participant","callId","members","ended","rejoin","opened","resumedSinceOpen","failures","chain","joined","result","requests","guest","setState","end","newLink","input","handle","before","call","resume","mode","closed","left","code","publishOptions","size","LobbyRefused","status","guestLobby","fetchOf","lobby","systemPath","response","init","bearer","token"],"sources":["../../../../client/src/calls/guest-requests.ts","../../../../client/src/calls/publish-refused.ts","../../../../client/src/calls/media-link.ts","../../../../client/src/calls/connection-stats.ts","../../../../client/src/calls/msid-tracks.ts","../../../../client/src/calls/peer-link.ts","../../../../client/src/calls/negotiation.ts","../../../../client/src/calls/sfu-link.ts","../../../../client/src/calls/join-call.ts","../../../../client/src/calls/guest-lobby.ts"],"sourcesContent":["import type { CallClientMessage, CallGuestLink, CallGuestRefusal, CallServerMessage, CallTrackSource } from '@protobase/schema/internal'\n\n/** A guest request the server did not do, with why: see `CallGuestRefusal`. */\nexport class GuestRefused extends Error {\n constructor(readonly reason: CallGuestRefusal) {\n super(`The guest request was refused: ${reason}`)\n this.name = 'GuestRefused'\n }\n}\n\n/** What a member who invites does with the call's guests. Each rejects with `GuestRefused` when the server did not. */\nexport type CallGuests = {\n /** A new link to the call that lets a guest send these sources, until `expiresAt` or the call's end; its token once. */\n link: (options: { publish: CallTrackSource[]; expiresAt?: Date }) => Promise<{ link: CallGuestLink; token: string }>\n /** Revokes a link: its guests are out of the call, and nobody else waits on it. */\n revoke: (link: string) => Promise<void>\n admit: (guest: string) => Promise<void>\n deny: (guest: string) => Promise<void>\n /** Takes a guest out of the call, for good. */\n remove: (guest: string) => Promise<void>\n}\n\ntype Pending = { resolve: (value: never) => void; reject: (error: unknown) => void }\n\n/**\n * The member's guest requests over the call's socket: the server answers each once, in order, so the answers are paired\n * with the requests in the order they were sent. A request whose socket closed before its answer rejects.\n */\nexport const guestRequests = (send: (message: CallClientMessage) => void) => {\n const pending: Pending[] = []\n const ask = <T>(message: CallClientMessage) =>\n new Promise<T>((resolve, reject) => {\n pending.push({ resolve: resolve as (value: never) => void, reject })\n send(message)\n })\n const guests: CallGuests = {\n link: ({ publish, expiresAt }) => ask({ type: 'guest-link', publish, ...(expiresAt && { expires_at: expiresAt.toISOString() }) }),\n revoke: (link) => ask({ type: 'guest-link-revoke', link }),\n admit: (guest) => ask({ type: 'guest-decide', guest, admit: true }),\n deny: (guest) => ask({ type: 'guest-decide', guest, admit: false }),\n remove: (guest) => ask({ type: 'guest-remove', guest }),\n }\n return {\n guests,\n /** Whether the message answered a request, which it then settles. */\n receive: (message: CallServerMessage) => {\n if (message.type !== 'guest-link' && message.type !== 'guest-done' && message.type !== 'guest-refused') return false\n const request = pending.shift()\n if (message.type === 'guest-refused') request?.reject(new GuestRefused(message.reason))\n else request?.resolve((message.type === 'guest-link' ? { link: message.link, token: message.token } : undefined) as never)\n return true\n },\n /** The socket closed: the requests on it are not answered. */\n lost: () => {\n for (const request of pending.splice(0)) request.reject(new Error('The link to the call was lost before the server answered'))\n },\n }\n}\n","/** The server refused tracks the member may not send, such as a camera for a member who may only listen. */\nexport class PublishRefused extends Error {\n constructor(reason: string) {\n super(reason)\n this.name = 'PublishRefused'\n }\n}\n","import type { CallConnection } from './connection-stats'\nimport type { CallClientMessage, CallRemoteTrack, CallResume, CallServerMessage, CallTrackSource } from '@protobase/schema/internal'\n\n/** A track of another member, with its media once the browser receives it. */\nexport type CallTrack = CallRemoteTrack & { track?: MediaStreamTrack }\n\n/** How a published video track is sent: with a media server, simulcast sends it in three sizes the server picks from. */\nexport type PublishOptions = { simulcast?: boolean }\n\n/** What a media link is made with: how it talks to Protobase and what it tells the page. */\nexport type MediaLinkInput = {\n iceServers: RTCIceServer[]\n send: (message: CallClientMessage) => void\n onTracks: (tracks: CallTrack[]) => void\n /** The media server stopped sending one of the member's tracks, such as after a demotion. */\n onUnpublished: (source: CallTrackSource) => void\n createPeerConnection?: (configuration: RTCConfiguration) => RTCPeerConnection\n}\n\n/**\n * One member's media in a call, over plain `RTCPeerConnection`s: to a media server (`sfuLink`) or to each other member\n * (`peerLink`). Both take the same messages and do the same things for the call; they differ in who answers an offer.\n */\nexport type MediaLink = {\n /** A message of the server; one at a time, in order. */\n receive: (message: CallServerMessage) => Promise<void>\n publish: (tracks: Partial<Record<CallTrackSource, MediaStreamTrack>>, options?: PublishOptions) => Promise<void>\n unpublish: (source: CallTrackSource) => Promise<void>\n mute: (source: CallTrackSource, muted: boolean) => void\n restartIce: () => Promise<void>\n /** What a new server session needs to resume the link; `undefined` when it cannot, and the member joins anew. */\n resumeState: (participant: string) => Promise<Omit<CallResume, 'call'> | undefined>\n /** After a resume: offers what changed while the session was lost. */\n resumed: () => Promise<void>\n /** How each of the member's connections fares now. */\n connections: () => Promise<CallConnection[]>\n /** The tracks the member sends, by source, to publish again after a rejoin. */\n sending: () => Map<CallTrackSource, { track: MediaStreamTrack; simulcast: boolean }>\n close: () => void\n}\n\nexport const createPeerConnection = (configuration: RTCConfiguration) => new RTCPeerConnection(configuration)\n","/**\n * How one of the member's connections fares: to another member (`member`), or to the media server (no `member`). Its\n * state, and once connected, the round trip of its network path and the share of the media it received that was lost.\n */\nexport type CallConnection = { member?: string; state: RTCPeerConnectionState; roundTripMs?: number; lostRatio?: number }\n\ntype Stat = { type: string; id: string; [field: string]: unknown }\n\n/** What `connectionOf` reads of a connection's stats: the selected candidate pair's round trip, and the received media's losses. */\nexport const statsOf = (report: Iterable<Stat>): Pick<CallConnection, 'roundTripMs' | 'lostRatio'> => {\n const stats = [...report]\n const transport = stats.find((stat) => stat.type === 'transport' && typeof stat.selectedCandidatePairId === 'string')\n // Firefox names no selected pair on its transport: it marks the pair itself.\n const pair = stats.find((stat) => stat.type === 'candidate-pair' && (stat.id === transport?.selectedCandidatePairId || (!transport && stat.selected === true) || (!transport && stat.nominated === true && stat.state === 'succeeded')))\n let lost = 0\n let received = 0\n for (const stat of stats) {\n if (stat.type !== 'inbound-rtp') continue\n lost += Math.max(0, Number(stat.packetsLost ?? 0))\n received += Number(stat.packetsReceived ?? 0)\n }\n const roundTrip = typeof pair?.currentRoundTripTime === 'number' ? pair.currentRoundTripTime * 1000 : undefined\n return { ...(roundTrip !== undefined && { roundTripMs: roundTrip }), ...(lost + received > 0 && { lostRatio: lost / (lost + received) }) }\n}\n\n/** How the connection fares now, as `CallConnection`. */\nexport const connectionOf = async (pc: RTCPeerConnection, member?: string): Promise<CallConnection> => {\n const state = pc.connectionState\n const report = state === 'connected' ? statsOf((await pc.getStats()).values() as Iterable<Stat>) : {}\n return { ...(member !== undefined && { member }), state, ...report }\n}\n","/**\n * The `mid` of each media section of a description by the sending browser's track id, which its `a=msid` line names: a\n * receiver's own track may have another id, when the browser reused one of its transceivers for the section.\n */\nexport const midsByTrackId = (sdp: string) => {\n const mids = new Map<string, string>()\n for (const section of sdp.split(/\\r?\\nm=/).slice(1)) {\n const mid = /^a=mid:(\\S+)/m.exec(section)?.[1]\n const track = /^a=msid:\\S+ (\\S+)/m.exec(section)?.[1]\n if (mid !== undefined && track !== undefined) mids.set(track, mid)\n }\n return mids\n}\n\n/**\n * The `mid` of each media section of a description by the id of the stream its `a=msid` line names. Unlike the track\n * id there, which Firefox makes up for each sender, both browsers write the sending page's stream id.\n */\nexport const midsByStreamId = (sdp: string) => {\n const mids = new Map<string, string>()\n for (const section of sdp.split(/\\r?\\nm=/).slice(1)) {\n const mid = /^a=mid:(\\S+)/m.exec(section)?.[1]\n const stream = /^a=msid:(\\S+) \\S+/m.exec(section)?.[1]\n if (mid !== undefined && stream !== undefined && stream !== '-') mids.set(stream, mid)\n }\n return mids\n}\n","import { PublishRefused } from './publish-refused'\nimport type { CallCandidate, CallDescription, CallRemoteTrack, CallServerMessage, CallTrackSource } from '@protobase/schema/internal'\nimport { createPeerConnection as newPeerConnection, type MediaLink, type MediaLinkInput } from './media-link'\nimport { connectionOf } from './connection-stats'\nimport { midsByStreamId } from './msid-tracks'\n\n// `makingOffer` is the local offer being set, while it is.\ntype Peer = { pc: RTCPeerConnection; polite: boolean; makingOffer?: Promise<void>; ignoreOffer: boolean; senders: Map<CallTrackSource, RTCRtpSender> }\n// Each sent track on a stream of its own, whose id names it: the receiving browser reads it in the description's msid.\ntype LocalTrack = { track: MediaStreamTrack; sid: string; stream: MediaStream }\n\n// Whether a description was made by Firefox, whose session lines name it, and whether this browser is Firefox.\nconst firefoxMade = (sdp: string) => /^o=mozilla/m.test(sdp)\nconst inFirefox = typeof navigator !== 'undefined' && /Firefox\\//.test(navigator.userAgent)\n\n/**\n * Who gives way when this side's offer crosses the other's: Firefox, when only one of the two is, since an offer\n * Chromium rolls back for Firefox's leaves their header extension ids clashing and Chromium's next offer fails;\n * otherwise the member whose id sorts first.\n */\nconst politeTo = (peer: { polite: boolean }, offer: string) => (inFirefox === firefoxMade(offer) ? peer.polite : inFirefox)\n\n/**\n * The media link without a media server: one `RTCPeerConnection` to each other member, whose browser answers, so either\n * side may offer. Protobase passes the descriptions and candidates between the two (\"perfect negotiation\": the member\n * whose id sorts first gives way when both offer at once, or Firefox to Chromium) and says who is in the call and which tracks each member\n * hears. A track goes by the id of the stream the sending browser sends it on, which the receiving browser sees too.\n */\nexport const peerLink = (self: string, { iceServers, send, onTracks, createPeerConnection = newPeerConnection }: MediaLinkInput): MediaLink => {\n const peers = new Map<string, Peer>()\n const local = new Map<CallTrackSource, LocalTrack>()\n let remote: CallRemoteTrack[] = []\n let publishing: { resolve: () => void; reject: (error: Error) => void } | undefined\n let publishes: Promise<unknown> = Promise.resolve()\n\n // Each sent track on a transceiver of its own: one the other side's offer made would keep that offer's msid, and the\n // other browser could not tell which track it carries.\n const sendOn = (pc: RTCPeerConnection, { track, stream }: LocalTrack) => pc.addTransceiver(track, { direction: 'sendonly', streams: [stream] }).sender\n\n const receivedTrack = ({ member, sid }: CallRemoteTrack) => {\n const pc = peers.get(member)?.pc\n const mid = pc?.remoteDescription && midsByStreamId(pc.remoteDescription.sdp).get(sid)\n return mid === undefined ? undefined : pc!.getTransceivers().find((transceiver) => transceiver.mid === mid)?.receiver.track\n }\n const emitTracks = () => onTracks(remote.map((track) => ({ ...track, ...(receivedTrack(track) && { track: receivedTrack(track) }) })))\n\n // The peer's connection, new, sending this member's tracks; the one before it, if any, is closed by the caller.\n const open = (member: string, peer: Peer) => {\n const pc = createPeerConnection({ iceServers })\n peer.pc = pc\n peer.senders = new Map()\n pc.onnegotiationneeded = async () => {\n const making = pc.setLocalDescription()\n peer.makingOffer = making\n try {\n await making\n if (peer.pc === pc) send({ type: 'signal', to: member, description: pc.localDescription!.toJSON() as CallDescription })\n } finally {\n if (peer.makingOffer === making) peer.makingOffer = undefined\n }\n }\n pc.onicecandidate = (event) => {\n if (event.candidate && peer.pc === pc) send({ type: 'signal', to: member, candidate: event.candidate.toJSON() as CallCandidate })\n }\n pc.oniceconnectionstatechange = () => {\n if (pc.iceConnectionState === 'failed') pc.restartIce()\n }\n pc.ontrack = () => emitTracks()\n for (const [source, sending] of local) peer.senders.set(source, sendOn(pc, sending))\n }\n const connect = (member: string) => {\n const peer = { polite: self < member, ignoreOffer: false } as Peer\n peers.set(member, peer)\n open(member, peer)\n return peer\n }\n /**\n * Chromium sometimes gathers no candidates on a connection whose first offer it rolled back, so neither side ever\n * checks: the side that gives way on a connection never negotiated starts on a new one instead, once its offer is set.\n */\n const renew = async (member: string, peer: Peer) => {\n await peer.makingOffer\n peer.pc.close()\n open(member, peer)\n }\n const disconnect = (member: string) => {\n peers.get(member)?.pc.close()\n peers.delete(member)\n }\n\n const signal = async (from: string, description?: CallDescription, candidate?: CallCandidate) => {\n // The other member may reach this browser before the list that names them does.\n const peer = peers.get(from) ?? connect(from)\n if (description) {\n const collision = description.type === 'offer' && (peer.makingOffer !== undefined || peer.pc.signalingState !== 'stable')\n peer.ignoreOffer = !politeTo(peer, description.sdp) && collision\n if (peer.ignoreOffer) return\n if (collision && !peer.pc.currentRemoteDescription) await renew(from, peer)\n }\n const { pc } = peer\n if (description) {\n await pc.setRemoteDescription(description)\n if (description.type === 'offer') {\n await pc.setLocalDescription()\n send({ type: 'signal', to: from, description: pc.localDescription!.toJSON() as CallDescription })\n }\n emitTracks()\n }\n // A candidate of an offer this side gave way on belongs to nothing here.\n if (candidate) {\n await pc.addIceCandidate(candidate).catch((error: unknown) => {\n if (!peer.ignoreOffer) throw error\n })\n }\n }\n\n const receive = async (message: CallServerMessage) => {\n switch (message.type) {\n case 'peers': {\n const present = new Set(message.members)\n for (const member of peers.keys()) if (!present.has(member)) disconnect(member)\n for (const member of present) if (!peers.has(member)) connect(member)\n return\n }\n case 'signal':\n return signal(message.from, message.description, message.candidate)\n case 'tracks':\n remote = message.tracks\n emitTracks()\n return\n case 'published':\n publishing?.resolve()\n return\n case 'publish-refused':\n publishing?.reject(new PublishRefused(message.reason))\n return\n }\n }\n\n const publishNow = async (tracks: Partial<Record<CallTrackSource, MediaStreamTrack>>) => {\n const added = Object.entries(tracks) as [CallTrackSource, MediaStreamTrack][]\n for (const [source] of added) if (local.has(source)) throw new Error(`The call already sends a ${source} track: unpublish it first`)\n if (added.length === 0) return\n const sending = added.map(([source, track]): [CallTrackSource, LocalTrack] => {\n const stream = new MediaStream([track])\n return [source, { track, sid: stream.id, stream }]\n })\n const answered = new Promise<void>((resolve, reject) => (publishing = { resolve, reject }))\n send({ type: 'publish', tracks: sending.map(([source, { track, sid }]) => ({ cid: sid, kind: track.kind as 'audio' | 'video', source })) })\n try {\n await answered\n } finally {\n publishing = undefined\n }\n for (const [source, track] of sending) {\n local.set(source, track)\n for (const peer of peers.values()) peer.senders.set(source, sendOn(peer.pc, track))\n }\n }\n\n return {\n receive,\n publish: (tracks) => {\n const next = publishes.then(() => publishNow(tracks))\n publishes = next.catch(() => {})\n return next\n },\n unpublish: async (source) => {\n const sending = local.get(source)\n if (!sending) return\n local.delete(source)\n for (const peer of peers.values()) {\n const sender = peer.senders.get(source)\n if (sender && peer.pc.signalingState !== 'closed') peer.pc.removeTrack(sender)\n peer.senders.delete(source)\n }\n send({ type: 'unpublish', sid: sending.sid })\n },\n mute: (source, muted) => {\n const sending = local.get(source)\n if (!sending) return\n sending.track.enabled = !muted\n send({ type: 'mute', sid: sending.sid, muted })\n },\n restartIce: async () => {\n for (const peer of peers.values()) peer.pc.restartIce()\n },\n // The browsers' connections outlast the server's session: a new one only needs the member's tracks.\n resumeState: async (participant) => ({\n participant,\n tracks: [...local].map(([source, { track, sid }]) => ({ cid: sid, sid, kind: track.kind as 'audio' | 'video', source })),\n }),\n resumed: async () => {},\n sending: () => new Map([...local].map(([source, { track }]) => [source, { track, simulcast: false }])),\n connections: () => Promise.all([...peers].map(([member, peer]) => connectionOf(peer.pc, member))),\n close: () => {\n publishing?.reject(new Error('The call ended'))\n for (const member of [...peers.keys()]) disconnect(member)\n },\n }\n}\n","/**\n * One offer in flight at a time: a change while an offer waits for its answer offers once more after it. `settled`\n * resolves once no offer is in flight or queued, so a caller can wait for its change to be agreed.\n */\nexport const negotiation = (offer: () => Promise<void>) => {\n let inFlight = false\n let again = false\n const waiting: (() => void)[] = []\n\n const start = async () => {\n inFlight = true\n again = false\n await offer()\n }\n const settle = () => {\n for (const resolve of waiting.splice(0)) resolve()\n }\n\n return {\n /** Offers now, or once the offer in flight is answered. */\n request: async () => {\n if (inFlight) {\n again = true\n return\n }\n await start()\n },\n /** The answer to the offer in flight arrived: offers again when a change came meanwhile. */\n answered: async () => {\n inFlight = false\n if (again) return start()\n settle()\n },\n /** The offer in flight will not be answered, such as on a lost session: it is made again by the next `request`. */\n abandon: () => {\n if (inFlight) again = true\n inFlight = false\n },\n /** Whether an offer waits to be made again after `abandon`. */\n get pending() {\n return again\n },\n settled: () => (inFlight || again ? new Promise<void>((resolve) => waiting.push(resolve)) : Promise.resolve()),\n /** Forgets every offer, for a new peer connection; whoever waited is let go. */\n reset: () => {\n inFlight = false\n again = false\n settle()\n },\n }\n}\n","import { PublishRefused } from './publish-refused'\nimport type { CallCandidate, CallRemoteTrack, CallResume, CallServerMessage, CallTrackRequest, CallTrackSource, CallVideoLayer } from '@protobase/schema/internal'\nimport { connectionOf } from './connection-stats'\nimport { createPeerConnection as newPeerConnection, type MediaLink, type MediaLinkInput, type PublishOptions } from './media-link'\nimport { negotiation } from './negotiation'\n\ntype LocalTrack = { source: CallTrackSource; track: MediaStreamTrack; transceiver: RTCRtpTransceiver; sid?: string; simulcast: boolean }\n\n// Simulcast in a quarter, half and full size: what the media server forwards to each member depends on how they show it.\nconst simulcastLayers = [\n { rid: 'q', quality: 'low', scale: 4, maxBitrate: 150_000 },\n { rid: 'h', quality: 'medium', scale: 2, maxBitrate: 500_000 },\n { rid: 'f', quality: 'high', scale: 1, maxBitrate: 1_200_000 },\n] as const\nconst singleBitrate = 1_200_000\n\nconst trackRequest = (source: CallTrackSource, track: MediaStreamTrack, simulcast: boolean): CallTrackRequest => {\n if (track.kind === 'audio') return { cid: track.id, kind: 'audio', source }\n const { width = 0, height = 0 } = track.getSettings()\n const layers: CallVideoLayer[] = simulcast\n ? simulcastLayers.map((layer) => ({ quality: layer.quality, width: Math.round(width / layer.scale), height: Math.round(height / layer.scale), bitrate: layer.maxBitrate }))\n : []\n return { cid: track.id, kind: 'video', source, width, height, ...(simulcast && { layers }) }\n}\n\nconst sendEncodings = (track: MediaStreamTrack, simulcast: boolean): RTCRtpEncodingParameters[] | undefined => {\n if (track.kind === 'audio') return undefined\n if (!simulcast) return [{ maxBitrate: singleBitrate }]\n return simulcastLayers.map((layer) => ({ rid: layer.rid, scaleResolutionDownBy: layer.scale, maxBitrate: layer.maxBitrate }))\n}\n\n/**\n * The media link to a media server, over a single `RTCPeerConnection`: the browser always offers, one offer at a time,\n * and the server's answer maps each receiving section's `mid` to the track it carries. The link holds no media library;\n * everything it says goes through `send` to Protobase, which speaks to the media server.\n */\nexport const sfuLink = ({ iceServers, send, onTracks, onUnpublished, createPeerConnection = newPeerConnection }: MediaLinkInput): MediaLink => {\n const pc = createPeerConnection({ iceServers, bundlePolicy: 'max-bundle' })\n const local = new Map<CallTrackSource, LocalTrack>()\n // Candidates that arrive before the first answer wait for it.\n const early: CallCandidate[] = []\n let mids: Record<string, string> = {}\n let remote: CallRemoteTrack[] = []\n let offerId = 0\n let publishing: { resolve: (tracks: { cid: string; sid: string }[]) => void; reject: (error: Error) => void } | undefined\n let publishes: Promise<unknown> = Promise.resolve()\n\n const offers = negotiation(async () => {\n const offer = await pc.createOffer()\n await pc.setLocalDescription(offer)\n send({ type: 'offer', sdp: offer.sdp!, id: ++offerId })\n })\n // Chrome refuses an offer with nothing in it: a member who only listens waits for the server's `sections`. Messages\n // from the server only start an offer, since its answer is a later message.\n const offer = async () => {\n if (pc.getTransceivers().length > 0) await offers.request()\n }\n const negotiate = async () => {\n await offer()\n await offers.settled()\n }\n\n const receivedTrack = (sid: string) => {\n const mid = Object.keys(mids).find((key) => mids[key] === sid)\n return mid === undefined ? undefined : pc.getTransceivers().find((transceiver) => transceiver.mid === mid)?.receiver.track\n }\n const emitTracks = () => onTracks(remote.map((track) => ({ ...track, ...(receivedTrack(track.sid) && { track: receivedTrack(track.sid) }) })))\n\n pc.onicecandidate = (event) => {\n if (event.candidate) send({ type: 'candidate', candidate: event.candidate.toJSON() as CallCandidate })\n }\n // A path that failed, such as after a network change, gets new ICE credentials.\n pc.oniceconnectionstatechange = () => {\n if (pc.iceConnectionState === 'failed') void restartIce()\n }\n pc.ontrack = () => emitTracks()\n\n const restartIce = async () => {\n pc.restartIce()\n await negotiate()\n }\n\n const stopSending = (source: CallTrackSource) => {\n const sending = local.get(source)\n if (!sending) return false\n local.delete(source)\n if (pc.signalingState !== 'closed') pc.removeTrack(sending.transceiver.sender)\n return true\n }\n\n const receive = async (message: CallServerMessage) => {\n switch (message.type) {\n case 'answer': {\n if (message.id !== offerId) return\n mids = { ...mids, ...message.mids }\n await pc.setRemoteDescription({ type: 'answer', sdp: message.sdp })\n for (const candidate of early.splice(0)) await pc.addIceCandidate(candidate)\n emitTracks()\n await offers.answered()\n return\n }\n case 'candidate':\n if (pc.remoteDescription) await pc.addIceCandidate(message.candidate)\n else early.push(message.candidate)\n return\n case 'sections':\n for (let i = 0; i < message.audio; i++) pc.addTransceiver('audio', { direction: 'recvonly' })\n for (let i = 0; i < message.video; i++) pc.addTransceiver('video', { direction: 'recvonly' })\n await offer()\n return\n case 'tracks':\n remote = message.tracks\n emitTracks()\n return\n case 'unpublished': {\n const sending = [...local.values()].find((track) => track.sid === message.sid)\n if (!sending) return\n stopSending(sending.source)\n await offer()\n onUnpublished(sending.source)\n return\n }\n case 'published':\n publishing?.resolve(message.tracks)\n return\n case 'publish-refused':\n publishing?.reject(new PublishRefused(message.reason))\n return\n }\n }\n\n const publishNow = async (tracks: Partial<Record<CallTrackSource, MediaStreamTrack>>, options: PublishOptions) => {\n const added = (Object.entries(tracks) as [CallTrackSource, MediaStreamTrack][]).map(([source, track]) => {\n if (local.has(source)) throw new Error(`The call already sends a ${source} track: unpublish it first`)\n const simulcast = track.kind === 'video' && Boolean(options.simulcast)\n const encodings = sendEncodings(track, simulcast)\n const transceiver = pc.addTransceiver(track, { direction: 'sendonly', ...(encodings && { sendEncodings: encodings }) })\n return { source, track, transceiver, simulcast } satisfies LocalTrack\n })\n if (added.length === 0) return\n const answered = new Promise<{ cid: string; sid: string }[]>((resolve, reject) => (publishing = { resolve, reject }))\n send({ type: 'publish', tracks: added.map((track) => trackRequest(track.source, track.track, track.simulcast)) })\n try {\n const sids = await answered\n for (const track of added) local.set(track.source, { ...track, sid: sids.find((sid) => sid.cid === track.track.id)!.sid })\n } catch (error) {\n for (const track of added) track.transceiver.stop()\n throw error\n } finally {\n publishing = undefined\n }\n await negotiate()\n }\n\n return {\n receive,\n /** Sends the tracks, under the sources they carry; rejects when the member may not send them. One publish at a time. */\n publish: (tracks: Partial<Record<CallTrackSource, MediaStreamTrack>>, options: PublishOptions = {}) => {\n const next = publishes.then(() => publishNow(tracks, options))\n publishes = next.catch(() => {})\n return next\n },\n /** Stops sending the source's track; the track itself goes on until the app stops it. */\n unpublish: async (source: CallTrackSource) => {\n if (stopSending(source)) await negotiate()\n },\n mute: (source: CallTrackSource, muted: boolean) => {\n const sending = local.get(source)\n if (!sending?.sid) return\n sending.track.enabled = !muted\n send({ type: 'mute', sid: sending.sid, muted })\n },\n restartIce,\n /** What a new server session needs to resume this link, after an offer still in flight is taken back. */\n resumeState: async (participant: string): Promise<Omit<CallResume, 'call'> | undefined> => {\n if (pc.signalingState === 'have-local-offer') {\n await pc.setLocalDescription({ type: 'rollback' })\n offers.abandon()\n }\n if (!pc.localDescription || !pc.remoteDescription) return undefined\n const tracks = [...local.values()].flatMap((track) => (track.sid ? [{ cid: track.track.id, sid: track.sid, kind: track.track.kind as 'audio' | 'video', source: track.source }] : []))\n return { participant, offer: pc.localDescription.sdp, answer: pc.remoteDescription.sdp, tracks }\n },\n /** After a resume: offers what changed while the session was lost. */\n resumed: async () => {\n if (offers.pending) await offer()\n },\n /** The tracks the member sends, by source, to publish again after a rejoin. */\n sending: () => new Map([...local.values()].map((track) => [track.source, { track: track.track, simulcast: track.simulcast }])),\n connections: async () => [await connectionOf(pc)],\n close: () => {\n publishing?.reject(new Error('The call ended'))\n offers.reset()\n pc.close()\n },\n }\n}\n","import type { CallClientMessage, CallGuestLink, CallLeftReason, CallLobbyGuest, CallRosterMember, CallServerMessage, CallTrackSource } from '@protobase/schema/internal'\nimport type { CallConnection } from './connection-stats'\nimport { guestRequests, type CallGuests } from './guest-requests'\nimport type { CallTrack, MediaLink, MediaLinkInput, PublishOptions } from './media-link'\nimport { peerLink } from './peer-link'\nimport { sfuLink } from './sfu-link'\n\n/** Where a call stands: `resuming` while the link to Protobase is restored, with media still flowing. */\nexport type CallState = { state: 'connecting' } | { state: 'joined' } | { state: 'resuming' } | { state: 'left'; reason: CallLeftReason; error?: unknown }\n\nexport type JoinCallOptions = {\n /**\n * The socket of the app's function that admits the member, such as `/api/functions/meeting?call=42`: a path on the\n * page's origin, or an absolute `http(s)` or `ws(s)` URL. The browser sends its session cookie with it.\n */\n url: string\n /** A guest's token from `guestLobby`, with the lobby's `socketUrl` as `url`: the guest joins as themselves, whom no cookie names. */\n guest?: string\n /** With a member who may invite: who waits in the call's lobby, and its guest links, whenever that changes. */\n onLobby?: (lobby: { guests: CallLobbyGuest[]; links: CallGuestLink[] }) => void\n /** Every track of other members the member hears, whenever one comes, goes or its media arrives. */\n onTracks?: (tracks: CallTrack[]) => void\n /** Everyone in the call, the member too, in the order they came, whenever that changes. */\n onMembers?: (members: CallRosterMember[]) => void\n /** Who speaks how loudly, from 0 to 1, for the members whose level changed. */\n onSpeakers?: (speakers: { member: string; level: number }[]) => void\n onState?: (state: CallState) => void\n /** The media server stopped one of the member's own tracks, such as after a demotion. */\n onUnpublished?: (source: CallTrackSource) => void\n /** How long to wait before the `attempt`th try to restore a lost link. */\n retryDelayMs?: (attempt: number) => number\n /** How many tries in a row to restore a lost link, or to get in while the server fails, before the call is left. Default 8. */\n maxRetries?: number\n WebSocket?: typeof WebSocket\n createPeerConnection?: (configuration: RTCConfiguration) => RTCPeerConnection\n}\n\nexport type Call = {\n /** The call, as the record's calls list it and `calls.remove` takes it. */\n readonly id: string\n /** The member's participant in the media server. */\n readonly participant: string\n /** Everyone in the call now, the member too. */\n members: () => CallRosterMember[]\n /** Sends tracks under the sources they carry, such as `{ camera, microphone }`; rejects when the member may not. */\n publish: (tracks: Partial<Record<CallTrackSource, MediaStreamTrack>>, options?: PublishOptions) => Promise<void>\n unpublish: (source: CallTrackSource) => Promise<void>\n mute: (source: CallTrackSource, muted: boolean) => void\n /** How large remote video tracks are shown, so the media server sends a layer that fits, or `hidden` for none. */\n view: (sids: string[], size: { width: number; height: number } | 'hidden') => void\n /** New ICE credentials, such as after a network change; a failed connection restarts by itself. */\n restartIce: () => Promise<void>\n leave: () => void\n /** The tracks of other members the member hears now. */\n tracks: () => CallTrack[]\n /** How each of the member's connections fares now: to each other member, or to the media server. */\n connections: () => Promise<CallConnection[]>\n /** With a member who may invite: guest links, and letting the lobby's guests in. */\n guests: CallGuests\n}\n\nconst backoff = (attempt: number) => Math.min(10_000, 500 * 2 ** attempt)\n\nconst socketUrl = (url: string) => {\n const resolved = new URL(url, globalThis.location?.href)\n resolved.protocol = resolved.protocol.replace(/^http/, 'ws')\n return resolved.href\n}\n\n/** Close codes after which the member is out of the call: left, or refused by the app. */\nconst leftCodes: Record<number, CallLeftReason> = { 1000: 'ended', 1008: 'removed' }\n/** Close codes of a server that failed, or was too busy, for now: getting in is tried again. */\nconst failedCodes = new Set([1011, 1013])\n\n/**\n * Joins a call through the app's function socket and resolves once the member is in it. Media flows over plain\n * `RTCPeerConnection`s, to the media server or straight to the other members, as the app's calls are configured;\n * Protobase relays their offers and answers and decides who is in the call and who hears whom. A lost socket, such as during a deploy, is restored with the browser's own state while\n * media keeps flowing; when the media server no longer knows the member, the call is joined again with the same tracks.\n */\nexport const joinCall = (options: JoinCallOptions): Promise<Call> => {\n const WebSocketOf = options.WebSocket ?? WebSocket\n const retryDelay = options.retryDelayMs ?? backoff\n const maxRetries = options.maxRetries ?? 8\n const url = socketUrl(options.url)\n\n let socket: WebSocket\n let link: MediaLink | undefined\n let participant = ''\n let callId = ''\n let members: CallRosterMember[] = []\n let remote: CallTrack[] = []\n let ended = false\n let rejoin = false\n // Whether the socket reached the server, and whether the server took the resume it sent.\n let opened = false\n let resumedSinceOpen = false\n let failures = 0\n let chain: Promise<void> = Promise.resolve()\n let joined: { resolve: (call: Call) => void; reject: (error: unknown) => void }\n const result = new Promise<Call>((resolve, reject) => (joined = { resolve, reject }))\n\n const send = (message: CallClientMessage) => {\n if (socket.readyState === WebSocketOf.OPEN) socket.send(JSON.stringify(message))\n }\n const requests = guestRequests(send)\n const guest = options.guest !== undefined ? { guest: options.guest } : {}\n const setState = (state: CallState) => options.onState?.(state)\n\n const end = (reason: CallLeftReason, error?: unknown) => {\n if (ended) return\n ended = true\n link?.close()\n link = undefined\n if (socket.readyState === WebSocketOf.OPEN || socket.readyState === WebSocketOf.CONNECTING) socket.close(1000)\n joined.reject(error ?? new Error(`The call was left: ${reason}`))\n setState({ state: 'left', reason, ...(error !== undefined && { error }) })\n }\n\n // The link the call's mode needs: to a media server, or to each other member.\n const newLink = (joined: Extract<CallServerMessage, { type: 'joined' }>) => {\n const input: MediaLinkInput = {\n iceServers: joined.iceServers,\n send,\n onTracks: (tracks) => {\n remote = tracks\n options.onTracks?.(tracks)\n },\n onUnpublished: (source) => options.onUnpublished?.(source),\n ...(options.createPeerConnection && { createPeerConnection: options.createPeerConnection }),\n }\n return joined.mode === 'peer' ? peerLink(joined.participant, input) : sfuLink(input)\n }\n\n const handle = async (message: CallServerMessage) => {\n switch (message.type) {\n case 'joined': {\n const before = link?.sending()\n link?.close()\n participant = message.participant\n callId = message.call\n link = newLink(message)\n failures = 0\n setState({ state: 'joined' })\n joined.resolve(call)\n // A rejoin sends the same tracks again, outside the message chain, since its answer is a later message.\n for (const [source, { track, simulcast }] of before ?? []) void call.publish({ [source]: track }, { simulcast }).catch((error: unknown) => end('ended', error))\n return\n }\n case 'resumed':\n resumedSinceOpen = true\n failures = 0\n setState({ state: 'joined' })\n await link?.resumed()\n return\n case 'speakers':\n options.onSpeakers?.(message.speakers)\n return\n case 'members':\n members = message.members\n options.onMembers?.(members)\n return\n case 'left':\n if (message.reason === 'rejoin') rejoin = true\n else end(message.reason)\n return\n case 'lobby':\n options.onLobby?.({ guests: message.guests, links: message.links })\n return\n default:\n if (requests.receive(message)) return\n await link?.receive(message)\n }\n }\n\n const connect = (mode: 'join' | 'resume') => {\n opened = false\n resumedSinceOpen = false\n socket = new WebSocketOf(url)\n socket.onopen = () => {\n opened = true\n chain = chain.then(async () => {\n const resume = mode === 'resume' && link ? await link.resumeState(participant) : undefined\n send(resume ? { type: 'resume', call: callId, ...resume, ...guest } : { type: 'join', ...guest })\n })\n }\n socket.onmessage = (event) => {\n const message = JSON.parse(String(event.data)) as CallServerMessage\n chain = chain.then(() => handle(message)).catch((error: unknown) => end('ended', error))\n }\n socket.onclose = (event) => {\n requests.lost()\n chain = chain.then(() => closed(mode, event.code))\n }\n }\n\n const closed = (mode: 'join' | 'resume', code: number) => {\n if (ended) return\n if (rejoin) {\n rejoin = false\n return connect('join')\n }\n const left = leftCodes[code]\n if (left) return end(left)\n if (!participant && !failedCodes.has(code)) return end('refused')\n failures++\n if (failures > maxRetries) return end(participant ? 'ended' : 'unavailable')\n setState(participant ? { state: 'resuming' } : { state: 'connecting' })\n // A resume the server got but did not take is not tried again: the member joins anew with the same tracks. One that\n // never reached a server, such as during a deploy, is tried again.\n const next = mode === 'resume' && opened && !resumedSinceOpen ? 'join' : 'resume'\n setTimeout(() => {\n if (!ended) connect(next)\n }, retryDelay(failures - 1))\n }\n\n const call: Call = {\n get id() {\n return callId\n },\n get participant() {\n return participant\n },\n members: () => members,\n publish: async (tracks, publishOptions) => {\n if (!link) throw new Error('The call was left')\n await link.publish(tracks, publishOptions)\n },\n unpublish: async (source) => {\n await link?.unpublish(source)\n },\n mute: (source, muted) => link?.mute(source, muted),\n view: (sids, size) => send(size === 'hidden' ? { type: 'view', sids, width: 0, height: 0, hidden: true } : { type: 'view', sids, ...size }),\n restartIce: async () => {\n await link?.restartIce()\n },\n leave: () => {\n if (ended) return\n send({ type: 'leave' })\n end('ended')\n },\n tracks: () => remote,\n connections: async () => (link ? link.connections() : []),\n guests: requests.guests,\n }\n\n setState({ state: 'connecting' })\n connect('join')\n return result\n}\n","import { guestCallsPath, type CallGuestState, type CallTrackSource } from '@protobase/schema/internal'\n\n/** A guest's wait in the lobby, as the server tells it: once let in, the call and what the guest may send. */\nexport type GuestWait = { state: CallGuestState; call?: string; publish?: CallTrackSource[] }\n\n/** Why the lobby did not answer: no live link, too many tries for now, or a name it does not take. */\nexport class LobbyRefused extends Error {\n constructor(\n readonly status: number,\n message: string,\n ) {\n super(message)\n this.name = 'LobbyRefused'\n }\n}\n\nexport type GuestLobbyOptions = {\n /** The API's system path on the page's origin, `/api` by default. */\n systemPath?: string\n fetch?: typeof fetch\n}\n\n/**\n * The lobby a guest of a call waits in, with no account: `enter` with the link's token and the guest's name gives the\n * guest's own token, which `wait` and `leave` send, and which `joinCall` takes as `guest` at `socketUrl` once a member\n * let them in. No cookie is sent or kept.\n */\nexport const guestLobby = ({ systemPath = '/api', fetch: fetchOf = globalThis.fetch }: GuestLobbyOptions = {}) => {\n const lobby = guestCallsPath(systemPath, 'lobby')\n const ask = async (init: RequestInit) => {\n const response = await fetchOf(lobby, { ...init, credentials: 'omit', cache: 'no-store' })\n if (!response.ok) throw new LobbyRefused(response.status, ((await response.json().catch(() => undefined)) as { detail?: string } | undefined)?.detail ?? response.statusText)\n return response\n }\n const bearer = (token: string) => ({ authorization: `Bearer ${token}` })\n return {\n /** The guest's call socket, for `joinCall`'s `url`. */\n socketUrl: guestCallsPath(systemPath, 'socket'),\n enter: async (link: string, name: string) => (await (await ask({ method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ link, name }) })).json()) as { guest: string; token: string },\n wait: async (token: string) => (await (await ask({ method: 'GET', headers: bearer(token) })).json()) as GuestWait,\n leave: async (token: string) => {\n await ask({ method: 'DELETE', headers: bearer(token) })\n },\n }\n}\n"],"mappings":"uCAGA,IAAaK,EAAb,cAAkC,KAAM,CACjB,OAArB,YAAY,EAAmC,CAC7C,MAAM,kCAAkCC,GAAQ,EAD7B,KAAA,OAAAA,EAEnB,KAAK,KAAO,cACd,CACF,EAoBaC,EAAiB,GAA+C,CAC3E,IAAMC,EAAqB,CAAC,EACtBC,EAAU,GACd,IAAI,SAAY,EAAS,IAAW,CAClCD,EAAQ,KAAK,CAAW,UAAmC,QAAO,CAAC,EACnEE,EAAKC,CAAO,CACd,CAAC,EAQH,MAAO,CACL,OAAA,CAPA,MAAO,CAAE,UAAS,eAAgBF,EAAI,CAAE,KAAM,aAAc,UAAS,GAAIG,GAAa,CAAE,WAAYA,EAAU,YAAY,CAAE,CAAG,CAAC,EAChI,OAA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,EAAOC,CAAK,CAAE,CAAC,EAAA,CAAG,KAAK,EAClG,MAAO,KAAO,IAAkB,CAC9B,MAAMrJ,EAAI,CAAE,OAAQ,SAAU,QAASoJ,EAAOC,CAAK,CAAE,CAAC,CACxD,CACF,CACF","debugId":"d19eb283-0bd4-4d89-8e31-8694ba2d4ec1"}
@@ -1 +1 @@
1
- {"version":3,"file":"index-D8oHLXjS.js","names":["createRoot","StrictMode","projectUi","__exportAll","__toESM","require_react","require_client","require_jsx_runtime","uiFromModule","nativeBridgeOf","App","relList","link","processPreload","mutation","mutations","node","getFetchOpts","fetchOpts","import_react","import_client","_virtual_protobase_project_ui_exports","_virtual_protobase_project_ui_default","apiOriginMeta","showKeyboardAccessoryBar","bridge","nativeViewport","content","part","applyNativeViewport","meta","doc","apiOriginOf","contents","value","url","pageApiOrigin","import_jsx_runtime","root","nativeBridge","browserLocale"],"sources":["../../../../schema/src/api-origin-meta.ts","../../../src/app/native-keyboard.ts","../../../src/app/native-viewport.ts","../../../src/app/page-api-origin.ts","../../../src/app/main.tsx"],"sourcesContent":["/**\n * The `<meta name>` whose `content` names the origin of the API the shell calls, such as `https://shop.example.com`, for\n * a page served from elsewhere: `protobase mobile` writes it into the app's `index.html`. Without it, the shell calls\n * the API on its own origin.\n */\nexport const apiOriginMeta = 'protobase-api-origin'\n","import type { NativeBridge } from './native-auth-fetch'\n\n/**\n * Gives the iOS app's keyboard back the bar above it, with the arrows to the previous and next field and Done, which\n * Capacitor's keyboard plugin hides when it loads and has no setting for. A binary built before it had the plugin,\n * and Android, which has no such bar, are left as they are.\n */\nexport const showKeyboardAccessoryBar = async (bridge: NativeBridge) => {\n if (bridge.getPlatform() !== 'ios' || !bridge.isPluginAvailable('Keyboard')) return\n await bridge.nativePromise('Keyboard', 'setAccessoryBarVisible', { isVisible: true })\n}\n","/**\n * The viewport of the iOS and Android app: as the page's, at a scale of one. Safari on iOS zooms into an input whose\n * text is smaller than 16px when it is focused, and in the app the page then stays zoomed with its right side cut off;\n * an app does not zoom, so its viewport stays at that scale, under a pinch too. The page in a browser keeps its zoom.\n */\nexport const nativeViewport = (content: string) => {\n const kept = content.split(',').map((part) => part.trim()).filter((part) => part && !/^maximum-scale\\s*=/.test(part))\n return [...kept, 'maximum-scale=1'].join(', ')\n}\n\n/** Gives the document's viewport the app's scale; a document without a viewport tag needs none. */\nexport const applyNativeViewport = (doc: Document) => {\n const meta = doc.querySelector('meta[name=\"viewport\"]')\n if (!meta) return\n meta.setAttribute('content', nativeViewport(meta.getAttribute('content') ?? ''))\n}\n","import { apiOriginMeta } from '@protobase/schema/internal'\n\n/**\n * The API origin the page's `<meta name=\"protobase-api-origin\">` tags name: `undefined` without one. Anything but one\n * tag holding exactly an http or https origin, such as `https://shop.example.com`, is an error.\n */\nexport const apiOriginOf = (contents: string[]) => {\n if (contents.length === 0) return undefined\n if (contents.length > 1) throw new Error(`The page has ${contents.length} ${apiOriginMeta} meta tags; it may have one`)\n const value = contents[0]!\n const url = URL.canParse(value) ? new URL(value) : undefined\n if (!url || (url.protocol !== 'http:' && url.protocol !== 'https:') || url.origin !== value) {\n throw new Error(`The page's ${apiOriginMeta} meta tag holds \"${value}\", which is not an http or https origin such as https://shop.example.com`)\n }\n return value\n}\n\n/** The API origin this page names in its `<meta name=\"protobase-api-origin\">` (see `apiOriginOf`). */\nexport const pageApiOrigin = () =>\n apiOriginOf([...document.querySelectorAll<HTMLMetaElement>(`meta[name=\"${apiOriginMeta}\"]`)].map((meta) => meta.content))\n","import { StrictMode } from 'react'\nimport { createRoot } from 'react-dom/client'\nimport * as projectUi from 'virtual:protobase-project-ui'\nimport '../styles.css'\nimport { browserLocale } from '../locale/active-locale'\nimport { App } from './app'\nimport { nativeBridgeOf, type NativeBridge } from './native-auth-fetch'\nimport { showKeyboardAccessoryBar } from './native-keyboard'\nimport { applyNativeViewport } from './native-viewport'\nimport { pageApiOrigin } from './page-api-origin'\nimport { uiFromModule } from './pages/ui-from-module'\n\nconst root = document.getElementById('root')\nif (!root) throw new Error('index.html needs an element with id \"root\"')\n\nconst nativeBridge = nativeBridgeOf(window as { Capacitor?: NativeBridge })\nif (nativeBridge) {\n applyNativeViewport(document)\n void showKeyboardAccessoryBar(nativeBridge)\n}\n\ncreateRoot(root).render(\n <StrictMode>\n <App baseUrl={`${pageApiOrigin() ?? ''}/api/v1`} ui={uiFromModule(projectUi)} locale={browserLocale()} nativeBridge={nativeBridge} />\n </StrictMode>,\n)\n"],"mappings":"85BAKauB,EAAgB,uBCEhBC,EAA2B,KAAO,IAAyB,CAClEC,EAAO,YAAY,IAAM,OAAUA,EAAO,kBAAkB,UAAU,GAC1E,MAAMA,EAAO,cAAc,WAAY,yBAA0B,CAAE,UAAW,EAAK,CAAC,CACtF,ECLaC,EAAkB,GAEtB,CAAC,GADKC,EAAQ,MAAM,GAAG,CAAC,CAAC,IAAK,GAASC,EAAK,KAAK,CAAC,CAAC,CAAC,OAAQ,GAASA,GAAQ,CAAC,qBAAqB,KAAKA,CAAI,CACxG,EAAM,iBAAiB,CAAC,CAAC,KAAK,IAAI,EAIlCC,EAAuB,GAAkB,CACpD,IAAMC,EAAOC,EAAI,cAAc,uBAAuB,EACjDD,GACLA,EAAK,aAAa,UAAWJ,EAAeI,EAAK,aAAa,SAAS,GAAK,EAAE,CAAC,CACjF,ECTaE,EAAe,GAAuB,CACjD,GAAIC,EAAS,SAAW,EAAG,OAC3B,GAAIA,EAAS,OAAS,EAAG,MAAU,MAAM,gBAAgBA,EAAS,OAAO,GAAGV,EAAc,4BAA4B,EACtH,IAAMW,EAAQD,EAAS,GACjBE,EAAM,IAAI,SAASD,CAAK,EAAI,IAAI,IAAIA,CAAK,EAAI,IAAA,GACnD,GAAI,CAACC,GAAQA,EAAI,WAAa,SAAWA,EAAI,WAAa,UAAaA,EAAI,SAAWD,EACpF,MAAU,MAAM,cAAcX,EAAc,mBAAmBW,EAAM,yEAAyE,EAEhJ,OAAOA,CACT,EAGaE,MACXJ,EAAY,CAAC,GAAG,SAAS,iBAAkC,cAAcT,EAAc,GAAG,CAAC,CAAC,CAAC,IAAK,GAASO,EAAK,OAAO,CAAC,aCPpHQ,EAAO,SAAS,eAAe,MAAM,EAC3C,GAAI,CAACA,EAAM,MAAU,MAAM,4CAA4C,EAEvE,IAAMC,EAAe9B,EAAe,MAAsC,EACtE8B,IACFV,EAAoB,QAAQ,EAC5BL,EAA8Be,CAAY,IAG5CvC,EAAAA,EAAAA,WAAAA,CAAWsC,CAAI,CAAC,CAAC,QACf,EAAAD,EAAA,IAAA,CAACpC,EAAAA,WAAD,CAAA,UACE,EAAAoC,EAAA,IAAA,CAAC3B,EAAD,CAAK,QAAS,GAAG0B,EAAc,GAAK,GAAG,SAAU,GAAI5B,EAAaN,CAAS,EAAG,OAAQsC,EAAc,EAAiB,cAAe,CAAA,CAC1H,CAAA,CACd","debugId":"fca072d7-8d2d-4053-964b-21232cbc9045"}
1
+ {"version":3,"file":"index-BK-wuwB0.js","names":["createRoot","StrictMode","projectUi","__exportAll","__toESM","require_react","require_client","require_jsx_runtime","nativeBridgeOf","App","uiFromModule","relList","link","processPreload","mutation","mutations","node","getFetchOpts","fetchOpts","import_react","import_client","_virtual_protobase_project_ui_exports","_virtual_protobase_project_ui_default","apiOriginMeta","showKeyboardAccessoryBar","bridge","nativeViewport","content","part","applyNativeViewport","meta","doc","apiOriginOf","contents","value","url","pageApiOrigin","import_jsx_runtime","root","nativeBridge","browserLocale"],"sources":["../../../../schema/src/api-origin-meta.ts","../../../src/app/native-keyboard.ts","../../../src/app/native-viewport.ts","../../../src/app/page-api-origin.ts","../../../src/app/main.tsx"],"sourcesContent":["/**\n * The `<meta name>` whose `content` names the origin of the API the shell calls, such as `https://shop.example.com`, for\n * a page served from elsewhere: `protobase mobile` writes it into the app's `index.html`. Without it, the shell calls\n * the API on its own origin.\n */\nexport const apiOriginMeta = 'protobase-api-origin'\n","import type { NativeBridge } from './native-auth-fetch'\n\n/**\n * Gives the iOS app's keyboard back the bar above it, with the arrows to the previous and next field and Done, which\n * Capacitor's keyboard plugin hides when it loads and has no setting for. A binary built before it had the plugin,\n * and Android, which has no such bar, are left as they are.\n */\nexport const showKeyboardAccessoryBar = async (bridge: NativeBridge) => {\n if (bridge.getPlatform() !== 'ios' || !bridge.isPluginAvailable('Keyboard')) return\n await bridge.nativePromise('Keyboard', 'setAccessoryBarVisible', { isVisible: true })\n}\n","/**\n * The viewport of the iOS and Android app: as the page's, at a scale of one. Safari on iOS zooms into an input whose\n * text is smaller than 16px when it is focused, and in the app the page then stays zoomed with its right side cut off;\n * an app does not zoom, so its viewport stays at that scale, under a pinch too. The page in a browser keeps its zoom.\n */\nexport const nativeViewport = (content: string) => {\n const kept = content.split(',').map((part) => part.trim()).filter((part) => part && !/^maximum-scale\\s*=/.test(part))\n return [...kept, 'maximum-scale=1'].join(', ')\n}\n\n/** Gives the document's viewport the app's scale; a document without a viewport tag needs none. */\nexport const applyNativeViewport = (doc: Document) => {\n const meta = doc.querySelector('meta[name=\"viewport\"]')\n if (!meta) return\n meta.setAttribute('content', nativeViewport(meta.getAttribute('content') ?? ''))\n}\n","import { apiOriginMeta } from '@protobase/schema/internal'\n\n/**\n * The API origin the page's `<meta name=\"protobase-api-origin\">` tags name: `undefined` without one. Anything but one\n * tag holding exactly an http or https origin, such as `https://shop.example.com`, is an error.\n */\nexport const apiOriginOf = (contents: string[]) => {\n if (contents.length === 0) return undefined\n if (contents.length > 1) throw new Error(`The page has ${contents.length} ${apiOriginMeta} meta tags; it may have one`)\n const value = contents[0]!\n const url = URL.canParse(value) ? new URL(value) : undefined\n if (!url || (url.protocol !== 'http:' && url.protocol !== 'https:') || url.origin !== value) {\n throw new Error(`The page's ${apiOriginMeta} meta tag holds \"${value}\", which is not an http or https origin such as https://shop.example.com`)\n }\n return value\n}\n\n/** The API origin this page names in its `<meta name=\"protobase-api-origin\">` (see `apiOriginOf`). */\nexport const pageApiOrigin = () =>\n apiOriginOf([...document.querySelectorAll<HTMLMetaElement>(`meta[name=\"${apiOriginMeta}\"]`)].map((meta) => meta.content))\n","import { StrictMode } from 'react'\nimport { createRoot } from 'react-dom/client'\nimport * as projectUi from 'virtual:protobase-project-ui'\nimport '../styles.css'\nimport { browserLocale } from '../locale/active-locale'\nimport { App } from './app'\nimport { nativeBridgeOf, type NativeBridge } from './native-auth-fetch'\nimport { showKeyboardAccessoryBar } from './native-keyboard'\nimport { applyNativeViewport } from './native-viewport'\nimport { pageApiOrigin } from './page-api-origin'\nimport { uiFromModule } from './pages/ui-from-module'\n\nconst root = document.getElementById('root')\nif (!root) throw new Error('index.html needs an element with id \"root\"')\n\nconst nativeBridge = nativeBridgeOf(window as { Capacitor?: NativeBridge })\nif (nativeBridge) {\n applyNativeViewport(document)\n void showKeyboardAccessoryBar(nativeBridge)\n}\n\ncreateRoot(root).render(\n <StrictMode>\n <App baseUrl={`${pageApiOrigin() ?? ''}/api/v1`} ui={uiFromModule(projectUi)} locale={browserLocale()} nativeBridge={nativeBridge} />\n </StrictMode>,\n)\n"],"mappings":"85BAKauB,EAAgB,uBCEhBC,EAA2B,KAAO,IAAyB,CAClEC,EAAO,YAAY,IAAM,OAAUA,EAAO,kBAAkB,UAAU,GAC1E,MAAMA,EAAO,cAAc,WAAY,yBAA0B,CAAE,UAAW,EAAK,CAAC,CACtF,ECLaC,EAAkB,GAEtB,CAAC,GADKC,EAAQ,MAAM,GAAG,CAAC,CAAC,IAAK,GAASC,EAAK,KAAK,CAAC,CAAC,CAAC,OAAQ,GAASA,GAAQ,CAAC,qBAAqB,KAAKA,CAAI,CACxG,EAAM,iBAAiB,CAAC,CAAC,KAAK,IAAI,EAIlCC,EAAuB,GAAkB,CACpD,IAAMC,EAAOC,EAAI,cAAc,uBAAuB,EACjDD,GACLA,EAAK,aAAa,UAAWJ,EAAeI,EAAK,aAAa,SAAS,GAAK,EAAE,CAAC,CACjF,ECTaE,EAAe,GAAuB,CACjD,GAAIC,EAAS,SAAW,EAAG,OAC3B,GAAIA,EAAS,OAAS,EAAG,MAAU,MAAM,gBAAgBA,EAAS,OAAO,GAAGV,EAAc,4BAA4B,EACtH,IAAMW,EAAQD,EAAS,GACjBE,EAAM,IAAI,SAASD,CAAK,EAAI,IAAI,IAAIA,CAAK,EAAI,IAAA,GACnD,GAAI,CAACC,GAAQA,EAAI,WAAa,SAAWA,EAAI,WAAa,UAAaA,EAAI,SAAWD,EACpF,MAAU,MAAM,cAAcX,EAAc,mBAAmBW,EAAM,yEAAyE,EAEhJ,OAAOA,CACT,EAGaE,MACXJ,EAAY,CAAC,GAAG,SAAS,iBAAkC,cAAcT,EAAc,GAAG,CAAC,CAAC,CAAC,IAAK,GAASO,EAAK,OAAO,CAAC,aCPpHQ,EAAO,SAAS,eAAe,MAAM,EAC3C,GAAI,CAACA,EAAM,MAAU,MAAM,4CAA4C,EAEvE,IAAMC,EAAe/B,EAAe,MAAsC,EACtE+B,IACFV,EAAoB,QAAQ,EAC5BL,EAA8Be,CAAY,IAG5CvC,EAAAA,EAAAA,WAAAA,CAAWsC,CAAI,CAAC,CAAC,QACf,EAAAD,EAAA,IAAA,CAACpC,EAAAA,WAAD,CAAA,UACE,EAAAoC,EAAA,IAAA,CAAC5B,EAAD,CAAK,QAAS,GAAG2B,EAAc,GAAK,GAAG,SAAU,GAAI1B,EAAaR,CAAS,EAAG,OAAQsC,EAAc,EAAiB,cAAe,CAAA,CAC1H,CAAA,CACd","debugId":"4afb0bb0-0741-4ddf-9e36-5849c6648a15"}
@@ -1 +1 @@
1
- {"version":3,"file":"records-map-DOXcutuQ.js","names":["useRef","useState","__toESM","require_react","require_jsx_runtime","cachedFormat","groupPoints","MapPin","Source","MapLayerSwitch","Marker","Layer","Map","mapLib","cn","import_react","worldPixels","mercatorLimit","fadeFrom","zooms","zoom","positionsOf","geometry","mercatorY","radians","latitude","zoomZeroSpan","positions","longitudes","longitude","ys","width","height","areaFeatures","features","points","point","kind","selected","feature","fadeIn","full","import_jsx_runtime","areaLayerId","polygons","lines","chosen","yes","no","PositionAreas","data","color","colors","themeColor","probe","token","element","resolved","canvas","context","red","green","blue","alpha","groupRadius","fitOptions","bucketOptions","markerHeight","compact","tag","corners","bounds","RecordsMap","ref","groups","setGroups","setColors","byKey","pointKeys","fitKey","fit","regroup","map","report","center","onMove","fitNow","onFitted","chosenAt","group","key","at","covered","open","y","style","initial","container","onClear","NavigationControl","buckets","bucket","bucketLabel","event","approximate","markerLabel","onSelect"],"sources":["../../../src/app/map/area-features.ts","../../../src/app/map/position-areas.tsx","../../../src/app/map/theme-color.ts","../../../src/app/map/records-map.tsx"],"sourcesContent":["import type { ExpressionSpecification } from 'maplibre-gl'\nimport type { MapPoint } from '../displays/map-groups'\nimport type { AreaGeometry } from './approximate-position'\n\n/** An area as the map's GeoJSON source holds it: whose it is, whether it is filled or a line, its size, and whether its record is chosen. */\nexport type AreaFeature = {\n type: 'Feature'\n geometry: AreaGeometry\n properties: { key: string; kind: 'polygon' | 'line'; span: number; chosen: boolean }\n}\n\n// MapLibre draws the whole world 512 pixels across at zoom 0, each zoom level twice as wide as the one before.\nconst worldPixels = 512\n// The furthest north and south Web Mercator draws.\nconst mercatorLimit = 85.051129\n// An area fades in as it grows from about half a marker to a marker and a half across, smaller it says nothing the marker does not.\nconst fadeFrom = 16\nconst fadeTo = 48\nconst zooms = Array.from({ length: 23 }, (_, zoom) => zoom)\n\nconst positionsOf = (geometry: AreaGeometry): [number, number][] => {\n if (geometry.type === 'LineString') return geometry.coordinates\n if (geometry.type === 'MultiPolygon') return geometry.coordinates.flat(2)\n return geometry.coordinates.flat()\n}\n\n// How far down the world a latitude is drawn, from 0 at the top to 1 at the bottom.\nconst mercatorY = (latitude: number) => {\n const radians = (Math.max(-mercatorLimit, Math.min(mercatorLimit, latitude)) * Math.PI) / 180\n return 0.5 - Math.log(Math.tan(Math.PI / 4 + radians / 2)) / (2 * Math.PI)\n}\n\n/** How many pixels across the area is drawn at zoom 0, the larger of its width and height; twice as many each zoom level in. */\nexport const zoomZeroSpan = (geometry: AreaGeometry) => {\n const positions = positionsOf(geometry)\n const longitudes = positions.map(([longitude]) => longitude)\n const ys = positions.map(([, latitude]) => mercatorY(latitude))\n const width = ((Math.max(...longitudes) - Math.min(...longitudes)) / 360) * worldPixels\n const height = (Math.max(...ys) - Math.min(...ys)) * worldPixels\n return Math.max(width, height)\n}\n\n/** The areas of the points that have one, those of the chosen records last so they are drawn on top. */\nexport const areaFeatures = (points: MapPoint[], selected: string[] | undefined): { type: 'FeatureCollection'; features: AreaFeature[] } => {\n const features = points.flatMap((point): AreaFeature[] => {\n if (!point.area) return []\n const kind = point.area.type === 'LineString' || point.area.type === 'MultiLineString' ? 'line' : 'polygon'\n return [{ type: 'Feature', geometry: point.area, properties: { key: point.key, kind, span: zoomZeroSpan(point.area), chosen: selected?.includes(point.key) ?? false } }]\n })\n return { type: 'FeatureCollection', features: [...features.filter((feature) => !feature.properties.chosen), ...features.filter((feature) => feature.properties.chosen)] }\n}\n\n/**\n * An opacity of `full` for an area drawn large enough to mean something at the zoom, fading in as it grows to that\n * size: at each whole zoom level its share of `full` follows from its span, and MapLibre blends between the levels.\n */\nexport const fadeIn = (full: number | ExpressionSpecification): ExpressionSpecification =>\n [\n 'interpolate',\n ['linear'],\n ['zoom'],\n ...zooms.flatMap((zoom) => [zoom, ['*', full, ['min', 1, ['max', 0, ['/', ['-', ['*', ['get', 'span'], 2 ** zoom], fadeFrom], fadeTo - fadeFrom]]]]]),\n ] as ExpressionSpecification\n","import type { ExpressionSpecification, FilterSpecification } from 'maplibre-gl'\nimport { Layer, Source } from 'react-map-gl/maplibre'\nimport type { MapPoint } from '../displays/map-groups'\nimport { areaFeatures, fadeIn } from './area-features'\n\n/** The colours of the areas, as MapLibre reads them: the markers' own, and the chosen marker's. */\nexport type AreaColors = { area: string; chosen: string }\n\n/** The areas' lowest layer, which a layer of tiles goes under. */\nexport const areaLayerId = 'position-area-fills'\n\nconst polygons: FilterSpecification = ['==', ['get', 'kind'], 'polygon']\nconst lines: FilterSpecification = ['==', ['get', 'kind'], 'line']\nconst chosen = (yes: number, no: number): ExpressionSpecification => ['case', ['get', 'chosen'], yes, no]\n\n/**\n * The areas around the approximate positions among `points`, drawn under the markers in the markers' colour: a polygon\n * filled faintly within a dashed outline, a line such as a street as a wide stroke. Each fades in as the map zooms close\n * enough for it to be larger than a marker, and the chosen records' areas are drawn darker. Nothing without areas.\n */\nexport const PositionAreas = ({ points, selected, colors }: { points: MapPoint[]; selected: string[] | undefined; colors: AreaColors }) => {\n const data = areaFeatures(points, selected)\n if (data.features.length === 0) return null\n const color: ExpressionSpecification = ['case', ['get', 'chosen'], colors.chosen, colors.area]\n return (\n <Source id=\"position-areas\" type=\"geojson\" data={data}>\n <Layer id={areaLayerId} type=\"fill\" filter={polygons} paint={{ 'fill-color': color, 'fill-opacity': fadeIn(chosen(0.15, 0.1)) }} />\n <Layer id=\"position-area-outlines\" type=\"line\" filter={polygons} paint={{ 'line-color': color, 'line-width': 1.5, 'line-dasharray': [3, 2], 'line-opacity': fadeIn(0.8) }} />\n <Layer id=\"position-area-lines\" type=\"line\" filter={lines} layout={{ 'line-cap': 'round', 'line-join': 'round' }} paint={{ 'line-color': color, 'line-width': 6, 'line-opacity': fadeIn(chosen(0.6, 0.35)) }} />\n </Source>\n )\n}\n","/**\n * The colour a theme token such as `--primary` holds where `element` is, as `rgba()`, which MapLibre's paint reads\n * whatever the theme writes it in: the browser resolves the token, and a pixel painted with it gives its channels.\n */\nexport const themeColor = (element: HTMLElement, token: string) => {\n const probe = document.createElement('span')\n probe.style.color = `var(${token})`\n element.append(probe)\n const resolved = getComputedStyle(probe).color\n probe.remove()\n const canvas = document.createElement('canvas')\n canvas.width = 1\n canvas.height = 1\n const context = canvas.getContext('2d', { willReadFrequently: true })\n if (!context) return resolved\n context.fillStyle = resolved\n context.fillRect(0, 0, 1, 1)\n const [red, green, blue, alpha] = context.getImageData(0, 0, 1, 1).data\n return `rgba(${red}, ${green}, ${blue}, ${alpha! / 255})`\n}\n","import { useEffect, useRef, useState } from 'react'\nimport { MapPin } from 'lucide-react'\nimport { Map, Marker, NavigationControl, type MapRef } from 'react-map-gl/maplibre'\nimport type { MapBounds, MapBucket, MapLayerModel } from '@protobase/client'\nimport type { MapView } from '@protobase/schema'\nimport { cn } from '../../lib/cn'\nimport { groupPoints, type MapGroup, type MapPoint } from '../displays/map-groups'\nimport type { MapArea } from './map-area'\nimport { MapLayerSwitch } from './map-layer-switch'\nimport { mapLib } from './maplibre'\nimport { areaLayerId, PositionAreas, type AreaColors } from './position-areas'\nimport { themeColor } from './theme-color'\nimport { cachedFormat } from '../../format/intl-cache'\n\n// How close, in pixels, records are drawn under one marker, about a marker's width.\nconst groupRadius = 28\nconst fitOptions = { padding: 48, maxZoom: 15, duration: 0 }\n// A bucket opens far enough in for the server to send its records: it does from zoom 16 on.\nconst bucketOptions = { padding: 48, maxZoom: 16, duration: 300 }\nconst markerHeight = 32\nconst compact = () => cachedFormat('compact', (tag) => new Intl.NumberFormat(tag, { notation: 'compact', maximumFractionDigits: 1 }))\n\nconst corners = (bounds: MapBounds): [[number, number], [number, number]] => [\n [bounds.west, bounds.south],\n [bounds.east, bounds.north],\n]\n\ntype RecordsMapProps = {\n style: string\n /** The layers the map may switch to in place of the style's. */\n layers?: MapLayerModel[]\n /** Where the map looks when it opens; the whole world without it. */\n initial: MapView | undefined\n points: MapPoint[]\n /** Counts of records in parts of the map, drawn as circles in place of their records. */\n buckets: MapBucket[]\n /** Bounds to move the map to, each time they change; `onFitted` says it moved there. */\n fit: MapBounds | undefined\n onFitted: () => void\n /** The map's area and view, each time it comes to rest. */\n onMove: (area: MapArea, view: MapView) => void\n /** The records whose marker is chosen, if any. */\n selected: string[] | undefined\n /** How many pixels at the map's bottom something covers, such as the chosen record's card. */\n covered: number\n onSelect: (keys: string[]) => void\n onClear: () => void\n /** What a marker for these records says to a screen reader. */\n markerLabel: (keys: string[]) => string\n /** What a bucket of this many records says to a screen reader. */\n bucketLabel: (count: number) => string\n}\n\n/**\n * A map of `style` with a marker for each group of records that lie close together at the zoom, showing how many it\n * stands for, and a circle with the count of each bucket, which zooms in on its records when chosen. A marker whose\n * records' positions are all approximate is drawn hollow with a dashed edge, over the areas around them. Choosing a\n * marker selects its records; choosing the map elsewhere clears the selection. A chosen marker the covered bottom would\n * hide moves up into the open part of the map.\n */\nexport const RecordsMap = ({ style, layers, initial, points, buckets, fit, onFitted, onMove, selected, covered, onSelect, onClear, markerLabel, bucketLabel }: RecordsMapProps) => {\n const ref = useRef<MapRef>(null)\n const [groups, setGroups] = useState<MapGroup[]>([])\n const [colors, setColors] = useState<AreaColors>()\n const byKey = new globalThis.Map(points.map((point) => [point.key, point]))\n const pointKeys = points.map((point) => point.key).join(',')\n const fitKey = fit && JSON.stringify(fit)\n\n // The groups as the map is drawn now: only the zoom changes which records lie close together\n const regroup = () => {\n const map = ref.current?.getMap()\n if (!map) return\n setGroups(\n groupPoints(\n points.map((point) => ({ key: point.key, ...map.project([point.longitude, point.latitude]) })),\n groupRadius,\n ),\n )\n }\n\n const report = () => {\n const map = ref.current?.getMap()\n if (!map) return\n const bounds = map.getBounds()\n const center = map.getCenter()\n onMove({ bounds: { south: bounds.getSouth(), west: bounds.getWest(), north: bounds.getNorth(), east: bounds.getEast() }, zoom: map.getZoom() }, { latitude: center.lat, longitude: center.lng, zoom: map.getZoom() })\n }\n\n const fitNow = () => {\n const map = ref.current?.getMap()\n if (!map || !fit) return\n map.fitBounds(corners(fit), fitOptions)\n onFitted()\n report()\n }\n\n // Other records are grouped at the zoom the map is at\n useEffect(regroup, [pointKeys])\n useEffect(fitNow, [fitKey])\n\n // The chosen marker in view above what covers the map's bottom\n const chosenAt = groups.find((group) => selected !== undefined && group.keys.some((key) => selected.includes(key)))?.at\n useEffect(() => {\n const map = ref.current?.getMap()\n const at = chosenAt === undefined ? undefined : byKey.get(chosenAt)\n if (!map || !at || covered === 0) return\n const { y } = map.project([at.longitude, at.latitude])\n const open = map.getContainer().clientHeight - covered\n if (y > markerHeight && y < open) return\n map.easeTo({ center: [at.longitude, at.latitude], offset: [0, (markerHeight - covered) / 2], duration: 300 })\n // A new choice or a new cover moves the map, not every new group\n }, [chosenAt, covered])\n\n return (\n <Map\n ref={ref}\n mapLib={mapLib}\n mapStyle={style}\n initialViewState={initial ?? { latitude: 0, longitude: 0, zoom: 1 }}\n style={{ width: '100%', height: '100%' }}\n onLoad={() => {\n const container = ref.current!.getMap().getContainer()\n setColors({ area: themeColor(container, '--primary'), chosen: themeColor(container, '--foreground') })\n regroup()\n if (fit) fitNow()\n else report()\n }}\n onZoomEnd={regroup}\n onMoveEnd={report}\n onClick={onClear}\n >\n <NavigationControl showCompass={false} />\n <MapLayerSwitch layers={layers} below={areaLayerId} />\n {colors && <PositionAreas points={points} selected={selected} colors={colors} />}\n {buckets.map((bucket) => (\n <Marker key={`${bucket.latitude},${bucket.longitude}`} latitude={bucket.latitude} longitude={bucket.longitude} anchor=\"center\">\n <button\n type=\"button\"\n aria-label={bucketLabel(bucket.count)}\n className=\"flex size-10 cursor-pointer items-center justify-center rounded-full border-2 border-background bg-primary text-xs font-semibold text-primary-foreground tabular-nums shadow\"\n onClick={(event) => {\n event.stopPropagation()\n ref.current?.getMap().fitBounds(corners(bucket.bounds), bucketOptions)\n }}\n >\n {compact().format(bucket.count)}\n </button>\n </Marker>\n ))}\n {groups.map((group) => {\n const at = byKey.get(group.at)\n if (!at) return null\n const chosen = selected !== undefined && group.keys.some((key) => selected.includes(key))\n const approximate = group.keys.every((key) => byKey.get(key)?.approximate)\n return (\n <Marker key={group.at} latitude={at.latitude} longitude={at.longitude} anchor=\"bottom\" style={{ zIndex: chosen ? 1 : 0 }}>\n <button\n type=\"button\"\n aria-label={markerLabel(group.keys)}\n aria-pressed={chosen}\n className=\"relative block cursor-pointer\"\n onClick={(event) => {\n event.stopPropagation()\n onSelect(group.keys)\n }}\n >\n <MapPin\n aria-hidden\n data-approximate={approximate || undefined}\n className={cn('size-8 drop-shadow', approximate ? (chosen ? 'fill-background text-foreground' : 'fill-background text-primary') : chosen ? 'fill-foreground text-background' : 'fill-primary text-primary-foreground')}\n strokeWidth={approximate ? 2 : 1.5}\n strokeDasharray={approximate ? '3 2' : undefined}\n />\n {group.keys.length > 1 && (\n <span className=\"absolute -right-2 -top-1 min-w-5 rounded-full border border-background bg-foreground px-1 text-center text-[11px] font-medium leading-4 text-background tabular-nums\">\n {group.keys.length}\n </span>\n )}\n </button>\n </Marker>\n )\n })}\n </Map>\n )\n}\n"],"mappings":"2RAYMgB,EAAc,IAEdC,EAAgB,UAEhBC,EAAW,GAEXC,EAAQ,MAAM,KAAK,CAAE,OAAQ,EAAG,GAAI,EAAG,IAASC,CAAI,EAEpDC,EAAe,GACfC,EAAS,OAAS,aAAqBA,EAAS,YAChDA,EAAS,OAAS,eAAuBA,EAAS,YAAY,KAAK,CAAC,EACjEA,EAAS,YAAY,KAAK,EAI7BC,EAAa,GAAqB,CACtC,IAAMC,EAAW,KAAK,IAAI,WAAgB,KAAK,IAAIP,EAAeQ,CAAQ,CAAC,EAAI,KAAK,GAAM,IAC1F,MAAO,IAAM,KAAK,IAAI,KAAK,IAAI,KAAK,GAAK,EAAID,EAAU,CAAC,CAAC,GAAK,EAAI,KAAK,GACzE,EAGaE,EAAgB,GAA2B,CACtD,IAAMC,EAAYN,EAAYC,CAAQ,EAChCM,EAAaD,EAAU,KAAK,CAACE,KAAeA,CAAS,EACrDC,EAAKH,EAAU,KAAK,EAAGF,KAAcF,EAAUE,CAAQ,CAAC,EACxDM,GAAU,KAAK,IAAI,GAAGH,CAAU,EAAI,KAAK,IAAI,GAAGA,CAAU,GAAK,IAAOZ,EACtEgB,GAAU,KAAK,IAAI,GAAGF,CAAE,EAAI,KAAK,IAAI,GAAGA,CAAE,GAAKd,EACrD,OAAO,KAAK,IAAIe,EAAOC,CAAM,CAC/B,EAGaC,GAAgB,EAAoB,IAA2F,CAC1I,IAAMC,EAAWC,EAAO,QAAS,GAAyB,CACxD,GAAI,CAACC,EAAM,KAAM,MAAO,CAAC,EACzB,IAAMC,EAAOD,EAAM,K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AAcf,EAAM,KAAK,MAAO,GAAQZ,EAAM,IAAIa,CAAG,CAAC,EAAE,WAAW,EACzE,OACE,EAAAhD,EAAA,IAAA,CAAChC,EAAD,CAAuB,SAAUiF,EAAG,SAAU,UAAWA,EAAG,UAAW,OAAO,SAAS,MAAO,CAAE,OAAQ,IAAe,EACrH,UAAA,EAAAjD,EAAA,KAAA,CAAC,SAAD,CACE,KAAK,SACL,aAAY+D,EAAYhB,EAAM,IAAI,EAClC,eAAc3C,EACd,UAAU,gCACV,QAAU,GAAU,CAClByD,EAAM,gBAAgB,EACtBG,EAASjB,EAAM,IAAI,CACrB,EARF,SAAA,EAUE,EAAA/C,EAAA,IAAA,CAACnC,EAAD,CACE,cAAA,GACA,mBAAkBiG,GAAe,IAAA,GACjC,UAAW1F,EAAG,qBAAsB0F,EAAe1D,EAAS,kCAAoC,+BAAkCA,EAAS,kCAAoC,sCAAsC,EACrN,YAAa0D,EAAc,EAAI,IAC/B,gBAAiBA,EAAc,MAAQ,IAAA,EACxC,CAAA,EACAf,EAAM,KAAK,OAAS,IACnB,EAAA/C,EAAA,IAAA,CAAC,OAAD,CAAM,UAAU,uKACb,SAAA+C,EAAM,KAAK,MACR,CAAA,CAEF,GACF,EAxBKA,EAAM,EAwBX,CAEZ,CAAC,CACE,GAET","debugId":"ce5dcbad-b90d-4e79-ac65-8118db586b9c"}
1
+ {"version":3,"file":"records-map-Bd5scHzJ.js","names":["useRef","useState","__toESM","require_react","require_jsx_runtime","groupPoints","cachedFormat","MapPin","Source","MapLayerSwitch","Marker","Layer","Map","mapLib","cn","import_react","worldPixels","mercatorLimit","fadeFrom","zooms","zoom","positionsOf","geometry","mercatorY","radians","latitude","zoomZeroSpan","positions","longitudes","longitude","ys","width","height","areaFeatures","features","points","point","kind","selected","feature","fadeIn","full","import_jsx_runtime","areaLayerId","polygons","lines","chosen","yes","no","PositionAreas","data","color","colors","themeColor","probe","token","element","resolved","canvas","context","red","green","blue","alpha","groupRadius","fitOptions","bucketOptions","markerHeight","compact","tag","corners","bounds","RecordsMap","ref","groups","setGroups","setColors","byKey","pointKeys","fitKey","fit","regroup","map","report","center","onMove","fitNow","onFitted","chosenAt","group","key","at","covered","open","y","style","initial","container","onClear","NavigationControl","buckets","bucket","bucketLabel","event","approximate","markerLabel","onSelect"],"sources":["../../../src/app/map/area-features.ts","../../../src/app/map/position-areas.tsx","../../../src/app/map/theme-color.ts","../../../src/app/map/records-map.tsx"],"sourcesContent":["import type { ExpressionSpecification } from 'maplibre-gl'\nimport type { MapPoint } from '../displays/map-groups'\nimport type { AreaGeometry } from './approximate-position'\n\n/** An area as the map's GeoJSON source holds it: whose it is, whether it is filled or a line, its size, and whether its record is chosen. */\nexport type AreaFeature = {\n type: 'Feature'\n geometry: AreaGeometry\n properties: { key: string; kind: 'polygon' | 'line'; span: number; chosen: boolean }\n}\n\n// MapLibre draws the whole world 512 pixels across at zoom 0, each zoom level twice as wide as the one before.\nconst worldPixels = 512\n// The furthest north and south Web Mercator draws.\nconst mercatorLimit = 85.051129\n// An area fades in as it grows from about half a marker to a marker and a half across, smaller it says nothing the marker does not.\nconst fadeFrom = 16\nconst fadeTo = 48\nconst zooms = Array.from({ length: 23 }, (_, zoom) => zoom)\n\nconst positionsOf = (geometry: AreaGeometry): [number, number][] => {\n if (geometry.type === 'LineString') return geometry.coordinates\n if (geometry.type === 'MultiPolygon') return geometry.coordinates.flat(2)\n return geometry.coordinates.flat()\n}\n\n// How far down the world a latitude is drawn, from 0 at the top to 1 at the bottom.\nconst mercatorY = (latitude: number) => {\n const radians = (Math.max(-mercatorLimit, Math.min(mercatorLimit, latitude)) * Math.PI) / 180\n return 0.5 - Math.log(Math.tan(Math.PI / 4 + radians / 2)) / (2 * Math.PI)\n}\n\n/** How many pixels across the area is drawn at zoom 0, the larger of its width and height; twice as many each zoom level in. */\nexport const zoomZeroSpan = (geometry: AreaGeometry) => {\n const positions = positionsOf(geometry)\n const longitudes = positions.map(([longitude]) => longitude)\n const ys = positions.map(([, latitude]) => mercatorY(latitude))\n const width = ((Math.max(...longitudes) - Math.min(...longitudes)) / 360) * worldPixels\n const height = (Math.max(...ys) - Math.min(...ys)) * worldPixels\n return Math.max(width, height)\n}\n\n/** The areas of the points that have one, those of the chosen records last so they are drawn on top. */\nexport const areaFeatures = (points: MapPoint[], selected: string[] | undefined): { type: 'FeatureCollection'; features: AreaFeature[] } => {\n const features = points.flatMap((point): AreaFeature[] => {\n if (!point.area) return []\n const kind = point.area.type === 'LineString' || point.area.type === 'MultiLineString' ? 'line' : 'polygon'\n return [{ type: 'Feature', geometry: point.area, properties: { key: point.key, kind, span: zoomZeroSpan(point.area), chosen: selected?.includes(point.key) ?? false } }]\n })\n return { type: 'FeatureCollection', features: [...features.filter((feature) => !feature.properties.chosen), ...features.filter((feature) => feature.properties.chosen)] }\n}\n\n/**\n * An opacity of `full` for an area drawn large enough to mean something at the zoom, fading in as it grows to that\n * size: at each whole zoom level its share of `full` follows from its span, and MapLibre blends between the levels.\n */\nexport const fadeIn = (full: number | ExpressionSpecification): ExpressionSpecification =>\n [\n 'interpolate',\n ['linear'],\n ['zoom'],\n ...zooms.flatMap((zoom) => [zoom, ['*', full, ['min', 1, ['max', 0, ['/', ['-', ['*', ['get', 'span'], 2 ** zoom], fadeFrom], fadeTo - fadeFrom]]]]]),\n ] as ExpressionSpecification\n","import type { ExpressionSpecification, FilterSpecification } from 'maplibre-gl'\nimport { Layer, Source } from 'react-map-gl/maplibre'\nimport type { MapPoint } from '../displays/map-groups'\nimport { areaFeatures, fadeIn } from './area-features'\n\n/** The colours of the areas, as MapLibre reads them: the markers' own, and the chosen marker's. */\nexport type AreaColors = { area: string; chosen: string }\n\n/** The areas' lowest layer, which a layer of tiles goes under. */\nexport const areaLayerId = 'position-area-fills'\n\nconst polygons: FilterSpecification = ['==', ['get', 'kind'], 'polygon']\nconst lines: FilterSpecification = ['==', ['get', 'kind'], 'line']\nconst chosen = (yes: number, no: number): ExpressionSpecification => ['case', ['get', 'chosen'], yes, no]\n\n/**\n * The areas around the approximate positions among `points`, drawn under the markers in the markers' colour: a polygon\n * filled faintly within a dashed outline, a line such as a street as a wide stroke. Each fades in as the map zooms close\n * enough for it to be larger than a marker, and the chosen records' areas are drawn darker. Nothing without areas.\n */\nexport const PositionAreas = ({ points, selected, colors }: { points: MapPoint[]; selected: string[] | undefined; colors: AreaColors }) => {\n const data = areaFeatures(points, selected)\n if (data.features.length === 0) return null\n const color: ExpressionSpecification = ['case', ['get', 'chosen'], colors.chosen, colors.area]\n return (\n <Source id=\"position-areas\" type=\"geojson\" data={data}>\n <Layer id={areaLayerId} type=\"fill\" filter={polygons} paint={{ 'fill-color': color, 'fill-opacity': fadeIn(chosen(0.15, 0.1)) }} />\n <Layer id=\"position-area-outlines\" type=\"line\" filter={polygons} paint={{ 'line-color': color, 'line-width': 1.5, 'line-dasharray': [3, 2], 'line-opacity': fadeIn(0.8) }} />\n <Layer id=\"position-area-lines\" type=\"line\" filter={lines} layout={{ 'line-cap': 'round', 'line-join': 'round' }} paint={{ 'line-color': color, 'line-width': 6, 'line-opacity': fadeIn(chosen(0.6, 0.35)) }} />\n </Source>\n )\n}\n","/**\n * The colour a theme token such as `--primary` holds where `element` is, as `rgba()`, which MapLibre's paint reads\n * whatever the theme writes it in: the browser resolves the token, and a pixel painted with it gives its channels.\n */\nexport const themeColor = (element: HTMLElement, token: string) => {\n const probe = document.createElement('span')\n probe.style.color = `var(${token})`\n element.append(probe)\n const resolved = getComputedStyle(probe).color\n probe.remove()\n const canvas = document.createElement('canvas')\n canvas.width = 1\n canvas.height = 1\n const context = canvas.getContext('2d', { willReadFrequently: true })\n if (!context) return resolved\n context.fillStyle = resolved\n context.fillRect(0, 0, 1, 1)\n const [red, green, blue, alpha] = context.getImageData(0, 0, 1, 1).data\n return `rgba(${red}, ${green}, ${blue}, ${alpha! / 255})`\n}\n","import { useEffect, useRef, useState } from 'react'\nimport { MapPin } from 'lucide-react'\nimport { Map, Marker, NavigationControl, type MapRef } from 'react-map-gl/maplibre'\nimport type { MapBounds, MapBucket, MapLayerModel } from '@protobase/client'\nimport type { MapView } from '@protobase/schema'\nimport { cn } from '../../lib/cn'\nimport { groupPoints, type MapGroup, type MapPoint } from '../displays/map-groups'\nimport type { MapArea } from './map-area'\nimport { MapLayerSwitch } from './map-layer-switch'\nimport { mapLib } from './maplibre'\nimport { areaLayerId, PositionAreas, type AreaColors } from './position-areas'\nimport { themeColor } from './theme-color'\nimport { cachedFormat } from '../../format/intl-cache'\n\n// How close, in pixels, records are drawn under one marker, about a marker's width.\nconst groupRadius = 28\nconst fitOptions = { padding: 48, maxZoom: 15, duration: 0 }\n// A bucket opens far enough in for the server to send its records: it does from zoom 16 on.\nconst bucketOptions = { padding: 48, maxZoom: 16, duration: 300 }\nconst markerHeight = 32\nconst compact = () => cachedFormat('compact', (tag) => new Intl.NumberFormat(tag, { notation: 'compact', maximumFractionDigits: 1 }))\n\nconst corners = (bounds: MapBounds): [[number, number], [number, number]] => [\n [bounds.west, bounds.south],\n [bounds.east, bounds.north],\n]\n\ntype RecordsMapProps = {\n style: string\n /** The layers the map may switch to in place of the style's. */\n layers?: MapLayerModel[]\n /** Where the map looks when it opens; the whole world without it. */\n initial: MapView | undefined\n points: MapPoint[]\n /** Counts of records in parts of the map, drawn as circles in place of their records. */\n buckets: MapBucket[]\n /** Bounds to move the map to, each time they change; `onFitted` says it moved there. */\n fit: MapBounds | undefined\n onFitted: () => void\n /** The map's area and view, each time it comes to rest. */\n onMove: (area: MapArea, view: MapView) => void\n /** The records whose marker is chosen, if any. */\n selected: string[] | undefined\n /** How many pixels at the map's bottom something covers, such as the chosen record's card. */\n covered: number\n onSelect: (keys: string[]) => void\n onClear: () => void\n /** What a marker for these records says to a screen reader. */\n markerLabel: (keys: string[]) => string\n /** What a bucket of this many records says to a screen reader. */\n bucketLabel: (count: number) => string\n}\n\n/**\n * A map of `style` with a marker for each group of records that lie close together at the zoom, showing how many it\n * stands for, and a circle with the count of each bucket, which zooms in on its records when chosen. A marker whose\n * records' positions are all approximate is drawn hollow with a dashed edge, over the areas around them. Choosing a\n * marker selects its records; choosing the map elsewhere clears the selection. A chosen marker the covered bottom would\n * hide moves up into the open part of the map.\n */\nexport const RecordsMap = ({ style, layers, initial, points, buckets, fit, onFitted, onMove, selected, covered, onSelect, onClear, markerLabel, bucketLabel }: RecordsMapProps) => {\n const ref = useRef<MapRef>(null)\n const [groups, setGroups] = useState<MapGroup[]>([])\n const [colors, setColors] = useState<AreaColors>()\n const byKey = new globalThis.Map(points.map((point) => [point.key, point]))\n const pointKeys = points.map((point) => point.key).join(',')\n const fitKey = fit && JSON.stringify(fit)\n\n // The groups as the map is drawn now: only the zoom changes which records lie close together\n const regroup = () => {\n const map = ref.current?.getMap()\n if (!map) return\n setGroups(\n groupPoints(\n points.map((point) => ({ key: point.key, ...map.project([point.longitude, point.latitude]) })),\n groupRadius,\n ),\n )\n }\n\n const report = () => {\n const map = ref.current?.getMap()\n if (!map) return\n const bounds = map.getBounds()\n const center = map.getCenter()\n onMove({ bounds: { south: bounds.getSouth(), west: bounds.getWest(), north: bounds.getNorth(), east: bounds.getEast() }, zoom: map.getZoom() }, { latitude: center.lat, longitude: center.lng, zoom: map.getZoom() })\n }\n\n const fitNow = () => {\n const map = ref.current?.getMap()\n if (!map || !fit) return\n map.fitBounds(corners(fit), fitOptions)\n onFitted()\n report()\n }\n\n // Other records are grouped at the zoom the map is at\n useEffect(regroup, [pointKeys])\n useEffect(fitNow, [fitKey])\n\n // The chosen marker in view above what covers the map's bottom\n const chosenAt = groups.find((group) => selected !== undefined && group.keys.some((key) => selected.includes(key)))?.at\n useEffect(() => {\n const map = ref.current?.getMap()\n const at = chosenAt === undefined ? undefined : byKey.get(chosenAt)\n if (!map || !at || covered === 0) return\n const { y } = map.project([at.longitude, at.latitude])\n const open = map.getContainer().clientHeight - covered\n if (y > markerHeight && y < open) return\n map.easeTo({ center: [at.longitude, at.latitude], offset: [0, (markerHeight - covered) / 2], duration: 300 })\n // A new choice or a new cover moves the map, not every new group\n }, [chosenAt, covered])\n\n return (\n <Map\n ref={ref}\n mapLib={mapLib}\n mapStyle={style}\n initialViewState={initial ?? { latitude: 0, longitude: 0, zoom: 1 }}\n style={{ width: '100%', height: '100%' }}\n onLoad={() => {\n const container = ref.current!.getMap().getContainer()\n setColors({ area: themeColor(container, '--primary'), chosen: themeColor(container, '--foreground') })\n regroup()\n if (fit) fitNow()\n else report()\n }}\n onZoomEnd={regroup}\n onMoveEnd={report}\n onClick={onClear}\n >\n <NavigationControl showCompass={false} />\n <MapLayerSwitch layers={layers} below={areaLayerId} />\n {colors && <PositionAreas points={points} selected={selected} colors={colors} />}\n {buckets.map((bucket) => (\n <Marker key={`${bucket.latitude},${bucket.longitude}`} latitude={bucket.latitude} longitude={bucket.longitude} anchor=\"center\">\n <button\n type=\"button\"\n aria-label={bucketLabel(bucket.count)}\n className=\"flex size-10 cursor-pointer items-center justify-center rounded-full border-2 border-background bg-primary text-xs font-semibold text-primary-foreground tabular-nums shadow\"\n onClick={(event) => {\n event.stopPropagation()\n ref.current?.getMap().fitBounds(corners(bucket.bounds), bucketOptions)\n }}\n >\n {compact().format(bucket.count)}\n </button>\n </Marker>\n ))}\n {groups.map((group) => {\n const at = byKey.get(group.at)\n if (!at) return null\n const chosen = selected !== undefined && group.keys.some((key) => selected.includes(key))\n const approximate = group.keys.every((key) => byKey.get(key)?.approximate)\n return (\n <Marker key={group.at} latitude={at.latitude} longitude={at.longitude} anchor=\"bottom\" style={{ zIndex: chosen ? 1 : 0 }}>\n <button\n type=\"button\"\n aria-label={markerLabel(group.keys)}\n aria-pressed={chosen}\n className=\"relative block cursor-pointer\"\n onClick={(event) => {\n event.stopPropagation()\n onSelect(group.keys)\n }}\n >\n <MapPin\n aria-hidden\n data-approximate={approximate || undefined}\n className={cn('size-8 drop-shadow', approximate ? (chosen ? 'fill-background text-foreground' : 'fill-background text-primary') : chosen ? 'fill-foreground text-background' : 'fill-primary text-primary-foreground')}\n strokeWidth={approximate ? 2 : 1.5}\n strokeDasharray={approximate ? '3 2' : undefined}\n />\n {group.keys.length > 1 && (\n <span className=\"absolute -right-2 -top-1 min-w-5 rounded-full border border-background bg-foreground px-1 text-center text-[11px] font-medium leading-4 text-background tabular-nums\">\n {group.keys.length}\n </span>\n )}\n </button>\n </Marker>\n )\n })}\n </Map>\n )\n}\n"],"mappings":"2RAYMgB,EAAc,IAEdC,EAAgB,UAEhBC,EAAW,GAEXC,EAAQ,MAAM,KAAK,CAAE,OAAQ,EAAG,GAAI,EAAG,IAASC,CAAI,EAEpDC,EAAe,GACfC,EAAS,OAAS,aAAqBA,EAAS,YAChDA,EAAS,OAAS,eAAuBA,EAAS,YAAY,KAAK,CAAC,EACjEA,EAAS,YAAY,KAAK,EAI7BC,EAAa,GAAqB,CACtC,IAAMC,EAAW,KAAK,IAAI,WAAgB,KAAK,IAAIP,EAAeQ,CAAQ,CAAC,EAAI,KAAK,GAAM,IAC1F,MAAO,IAAM,KAAK,IAAI,KAAK,IAAI,KAAK,GAAK,EAAID,EAAU,CAAC,CAAC,GAAK,EAAI,KAAK,GACzE,EAGaE,EAAgB,GAA2B,CACtD,IAAMC,EAAYN,EAAYC,CAAQ,EAChCM,EAAaD,EAAU,KAAK,CAACE,KAAeA,CAAS,EACrDC,EAAKH,EAAU,KAAK,EAAGF,KAAcF,EAAUE,CAAQ,CAAC,EACxDM,GAAU,KAAK,IAAI,GAAGH,CAAU,EAAI,KAAK,IAAI,GAAGA,CAAU,GAAK,IAAOZ,EACtEgB,GAAU,KAAK,IAAI,GAAGF,CAAE,EAAI,KAAK,IAAI,GAAGA,CAAE,GAAKd,EACrD,OAAO,KAAK,IAAIe,EAAOC,CAAM,CAC/B,EAGaC,GAAgB,EAAoB,IAA2F,CAC1I,IAAMC,EAAWC,EAAO,QAAS,GAAyB,CACxD,GAAI,CAACC,EAAM,KAAM,MAAO,CAAC,EACzB,IAAMC,EAAOD,EAAM,KAAK,OAAS,cAAgBA,EAAM,KAAK,OAAS,kBAAoB,O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,CAAG,CAAC,EAAE,WAAW,EACzE,OACE,EAAAhD,EAAA,IAAA,CAAChC,EAAD,CAAuB,SAAUiF,EAAG,SAAU,UAAWA,EAAG,UAAW,OAAO,SAAS,MAAO,CAAE,OAAQ,IAAe,EACrH,UAAA,EAAAjD,EAAA,KAAA,CAAC,SAAD,CACE,KAAK,SACL,aAAY+D,EAAYhB,EAAM,IAAI,EAClC,eAAc3C,EACd,UAAU,gCACV,QAAU,GAAU,CAClByD,EAAM,gBAAgB,EACtBG,EAASjB,EAAM,IAAI,CACrB,EARF,SAAA,EAUE,EAAA/C,EAAA,IAAA,CAACnC,EAAD,CACE,cAAA,GACA,mBAAkBiG,GAAe,IAAA,GACjC,UAAW1F,EAAG,qBAAsB0F,EAAe1D,EAAS,kCAAoC,+BAAkCA,EAAS,kCAAoC,sCAAsC,EACrN,YAAa0D,EAAc,EAAI,IAC/B,gBAAiBA,EAAc,MAAQ,IAAA,EACxC,CAAA,EACAf,EAAM,KAAK,OAAS,IACnB,EAAA/C,EAAA,IAAA,CAAC,OAAD,CAAM,UAAU,uKACb,SAAA+C,EAAM,KAAK,MACR,CAAA,CAEF,GACF,EAxBKA,EAAM,EAwBX,CAEZ,CAAC,CACE,GAET","debugId":"5de6c707-cc9a-4fab-98be-67bbf8306260"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared-protobase-ui-CU8QfOuc.js","names":["useMemo","text","_Fragment","useState","__toESM","require_react","require_jsx_runtime","keepPreviousData","useQuery","useQueryClient","CarouselControls","text","useFieldControl","CodeForm","Spinner","Composer","AppLink","mentionedIds","Section","emptyDraft","shownImage","pluginApi","ResponsiveDialog","useGuardedPress","keys","allowDelayMs","ApiProvider","protobaseVersion","Dialog","callsChannelEvent","AuthLayout","useOptionalAuth","usePlugin","Button","text$1","dayIn","useRecord","viewerZone","ChatThread","Field","useApiToken","CarouselTrack","mergeUi","buttonClass","SidePanel","Textarea","MentionBox","RouteLink","isFramed","useClient","ResendCodeButton","useMeta","useArmedAfterFocus","useResourceClient","useOptionalListDisplay","useListDisplay","useCarousel","diffStats","useMembers","useMarkNotificationsRead","useFacets","FieldList","useStatuses","usePresence","useLayoutRecord","useAssistant","Token","SignInPrompt","AssistantDock","FileImage","DiffView","defineUi","StepList","definePlugin","useInbox","fetchLabels","CallView","formatWeekdayDate","ChatMessage","Input","Form","ActionInputError","PartView","RelationPicker","isConflict","StatusMark","useUnreadNotifications","useHistogram","useBackendData","OtpInput","MenuSelect","useUpdateRecord","LogoMark","usePushNotifications","useSeries","App","AvailabilityMark","useAssistantClient","Markdown","parseDiff","statusRefreshMs","MentionedText","useAppAddress","ActionCard","useList","CompactTable","useOwnStatus","uiFromModule","useAdminMeta","Segmented","createLucideIcon","cn","__iconData","Phone","dayBefore","day","sameChatDay","a","zone","b","chatDayLabel","time","today","now","import_jsx_runtime","ChatDivider","shown","label","line","tone","RecordLink","rest","display","around","name","resource","row","recordKey","import_react","signedInUserOf","state","useSignedInUser","useRecordCallAddress","joining","address","target","to","open","href","RecordCall","useRecordCalls","client","queryClient","key","query","queryKey","channel","offCalls","message","offStatus","status","call","CallMark","isPending","ongoing","join","className","count","box","carouselSlides","images","image","Carousel","slides","carousel","fit","Choices","options","option","value","onChange","usePickedLabels","sorted","ids","view","RecordPicker","resources","props","views","known","setKnown","fetched","labelOf","remember","current","chosen"],"sources":["../../../../../node_modules/.bun/lucide-react@1.52.0+0ac650c021fb1b59/node_modules/lucide-react/dist/esm/icons/phone.mjs","../../../src/chat/chat-day.ts","../../../src/chat/chat-divider.tsx","../../../src/app/displays/record-link.tsx","../../../src/auth/use-signed-in-user.ts","../../../src/calls/use-record-call-address.ts","../../../src/calls/record-call.tsx","../../../src/calls/use-record-calls.ts","../../../src/calls/call-mark.tsx","../../../src/carousel/carousel-images.ts","../../../src/carousel/carousel.tsx","../../../src/primitives/choices.tsx","../../../src/app/use-picked-labels.ts","../../../src/app/record-picker.tsx"],"sourcesContent":["/**\n * @license lucide-react v1.52.0 - ISC\n *\n * This source code is licensed under the ISC license.\n * See the LICENSE file in the root directory of this source tree.\n */\n\nimport createLucideIcon from '../createLucideIcon.mjs';\n\nconst __iconData = {\n name: \"phone\",\n size: 24,\n node: [\n [\n \"path\",\n {\n d: \"M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384\",\n key: \"9njp5v\"\n }\n ]\n ]\n};\n__iconData.node;\nconst Phone = createLucideIcon(__iconData);\n\nexport { __iconData, Phone as default };\n//# sourceMappingURL=phone.mjs.map\n","import { formatWeekdayDate } from '../format/date'\nimport { dayIn, viewerZone } from '../format/zone'\nimport { text } from './messages'\n\nconst dayBefore = (day: string) => new Date(Date.parse(`${day}T00:00:00Z`) - 86_400_000).toISOString().slice(0, 10)\n\n/** Whether two ISO timestamps fall on the same day in `zone`, the viewer's unless given: a day divider goes between two messages that do not. */\nexport const sameChatDay = (a: string, b: string, zone = viewerZone()) => dayIn(Date.parse(a), zone) === dayIn(Date.parse(b), zone)\n\n/** The label of the divider above a day's first message, sent at `time`: \"Today\", \"Yesterday\" or \"Mon, 26 Oct 2026\", as the viewer's calendar in `zone` has it. */\nexport const chatDayLabel = (time: string, now = Date.now(), zone = viewerZone()) => {\n const day = dayIn(Date.parse(time), zone)\n const today = dayIn(now, zone)\n if (day === today) return text('today')\n if (day === dayBefore(today)) return text('yesterday')\n return formatWeekdayDate(Date.parse(`${day}T00:00:00Z`))\n}\n","import { cn } from '../lib/cn'\nimport { text } from './messages'\n\nexport type ChatDividerProps =\n /** A muted line between the messages of two days, labelled with the later one, such as by `chatDayLabel`. */\n | { tone?: 'day'; label: string }\n /** A line above the first message the reader has not seen, \"New messages\" unless labelled otherwise. */\n | { tone: 'new'; label?: string }\n\n/**\n * A line across a chat with a label in its middle, between the messages of two days or above the new ones. Marked\n * `data-chat-divider`, so a thread keeps the reader's place on the message below it, not on the divider.\n */\nexport const ChatDivider = ({ tone = 'day', label }: ChatDividerProps) => {\n const shown = label ?? text('newMessages')\n const line = cn('h-px flex-1', tone === 'new' ? 'bg-danger' : 'bg-border')\n return (\n <div role=\"separator\" aria-label={shown} data-tone={tone} data-chat-divider=\"\" className=\"flex items-center gap-3 text-xs font-medium\">\n <span className={line} />\n <span className={tone === 'new' ? 'text-danger' : 'text-muted-foreground'}>{shown}</span>\n <span className={line} />\n </div>\n )\n}\n","import type { AnchorHTMLAttributes } from 'react'\nimport type { KeyValue } from '@protobase/schema'\nimport { useLayoutRecord } from '../pages/record-scope'\nimport { AppLink } from '../use-app-address'\nimport { useOptionalListDisplay } from './display-context'\nimport type { ListDisplayRow } from './list-displays'\n\ntype Target = { row: ListDisplayRow; resource?: never; recordKey?: never } | { row?: never; resource?: string; recordKey: KeyValue | readonly KeyValue[] }\n\n/**\n * A link to a record's page, through the app's addresses: a list display's `row`, or a `recordKey` of `resource`. The\n * resource defaults to the list display's or the record's around it, so a custom component never writes a path.\n */\nexport const RecordLink = ({ row, resource, recordKey, ...rest }: AnchorHTMLAttributes<HTMLAnchorElement> & Target) => {\n const display = useOptionalListDisplay()\n const around = useLayoutRecord()\n const name = resource ?? display?.resource ?? around?.model.name\n if (name === undefined) throw new Error('RecordLink needs a resource outside a list display or a record')\n return <AppLink to={{ kind: 'record', resource: name, key: row ? row.key : recordKey }} {...rest} />\n}\n","import { useMemo } from 'react'\nimport { useOptionalAuth, type AuthState } from './auth-provider'\n\n/** Who is signed in: their user id, the id `.author()` stores and mentions hold, and their name. */\nexport type SignedInUser = { id: string; name?: string }\n\n/** The signed-in person of an auth state; none while it loads, for a visitor, and before the sign-in finished. */\nexport const signedInUserOf = (state: AuthState | undefined): SignedInUser | undefined => {\n if (state?.kind !== 'signed-in') return\n const { id, name } = state.user\n return { id, ...(name && { name }) }\n}\n\n/**\n * The signed-in person, from the session the app already holds, such as for a filter on their own user id;\n * `undefined` while the session loads, for a visitor and when nobody is signed in.\n */\nexport const useSignedInUser = (): SignedInUser | undefined => {\n const state = useOptionalAuth()?.state\n return useMemo(() => signedInUserOf(state), [state])\n}\n","import { useAppAddress } from '../app/use-app-address'\n\n/**\n * A record's call as the app's address holds it: whether the page joins it (`call=join`), the link that joins it, as a\n * ring's Accept and a call mark's Join open it, and the link back to the record without the call, as Leave opens it.\n */\nexport const useRecordCallAddress = (resource: string, recordKey: string) => {\n const { address, href, open } = useAppAddress()\n const joining = address?.kind === 'record' && address.resource === resource && address.key === recordKey && address.call === 'join'\n const target = (to: string) => ({ href: to, onFollow: () => open(to) })\n return { joining, join: target(href({ kind: 'record', resource, key: recordKey, call: 'join' })), leave: target(href({ kind: 'record', resource, key: recordKey })) }\n}\n","import { CallView, type CallViewProps } from './call-view'\nimport { useRecordCallAddress } from './use-record-call-address'\n\nexport type RecordCallProps = Omit<CallViewProps, 'leave'> & { resource: string; recordKey: string }\n\n/**\n * The record's call view while the app's address joins it (`call=join`, as Accept and Join open it), and nothing\n * otherwise: put it beside the record's own content, such as on a full-area record page. Leave goes back to the record.\n */\nexport const RecordCall = ({ resource, recordKey, ...rest }: RecordCallProps) => {\n const { joining, leave } = useRecordCallAddress(resource, recordKey)\n if (!joining) return null\n return <CallView key={`${resource}/${recordKey}`} leave={leave} {...rest} />\n}\n","import { useQuery, useQueryClient } from '@tanstack/react-query'\nimport { useEffect } from 'react'\nimport type { RecordCall } from '@protobase/client'\nimport { callsChannelEvent } from '@protobase/schema/internal'\nimport { useClient } from '../data/api-provider'\nimport { keys } from '../data/query-keys'\n\n/**\n * A record's latest calls, the one going on first, kept current over the record's channel, on the one socket the page\n * shares for every channel it holds: the server sends the calls there whenever they change, so following a record's\n * calls opens no connection of its own on a page that holds a channel already. Read again whenever the channel joins,\n * as after a lost connection.\n */\nexport const useRecordCalls = (resource: string, recordKey: string) => {\n const client = useClient()\n const queryClient = useQueryClient()\n const key = keys.recordCalls(resource, recordKey)\n const query = useQuery({ queryKey: key, queryFn: () => client.calls(resource, recordKey) })\n\n useEffect(() => {\n const queryKey = keys.recordCalls(resource, recordKey)\n const channel = client.channel(resource, recordKey)\n // Only the server's own message: anyone on the channel can broadcast under the same event.\n const offCalls = channel.on(callsChannelEvent, (message) => message.server && queryClient.setQueryData<RecordCall[]>(queryKey, (message.payload as { items: RecordCall[] }).items))\n const offStatus = channel.onStatus((status) => status.state === 'joined' && void queryClient.invalidateQueries({ queryKey }))\n return () => {\n offCalls()\n offStatus()\n channel.leave()\n }\n }, [client, queryClient, resource, recordKey])\n\n return { ...query, ongoing: query.data?.find((call) => call.ended_at === null) }\n}\n","import { Phone } from 'lucide-react'\nimport { cn } from '../lib/cn'\nimport { buttonClass } from '../primitives/button'\nimport { RouteLink } from '../primitives/route-link'\nimport { text } from './messages'\nimport { useRecordCalls } from './use-record-calls'\nimport { useRecordCallAddress } from './use-record-call-address'\n\nexport type CallMarkProps = { resource: string; recordKey: string; className?: string }\n\n/**\n * A record's call, for the app to place where it wants, such as a conversation's header: Start call while there is\n * none, and \"Call in progress · 3 · Join\" while one goes on, live. Start call and Join are links to the record's page\n * that joins its call (`call=join`); on that page itself, Join is left out.\n */\nexport const CallMark = ({ resource, recordKey, className }: CallMarkProps) => {\n const { ongoing, isPending } = useRecordCalls(resource, recordKey)\n const { joining, join } = useRecordCallAddress(resource, recordKey)\n if (isPending) return null\n if (!ongoing) {\n if (joining) return null\n return (\n <RouteLink to={join} className={cn(buttonClass({ size: 'sm' }), className)}>\n <Phone className=\"size-3.5\" />\n {text('startCall')}\n </RouteLink>\n )\n }\n const count = ongoing.members.length\n return (\n <span role=\"status\" className={cn('inline-flex items-center gap-1.5 rounded-md bg-success-soft px-2 py-0.5 text-body text-foreground', className)}>\n <Phone className=\"size-3.5 text-success\" />\n {text('inProgress')}\n <span aria-hidden>·</span>\n <span aria-label={text('people', count)}>{count}</span>\n {!joining && (\n <>\n <span aria-hidden>·</span>\n <RouteLink to={join} className={buttonClass({ variant: 'primary', size: 'sm' })}>\n {text('join')}\n </RouteLink>\n </>\n )}\n </span>\n )\n}\n","import type { StoredFile } from '@protobase/client'\nimport { shownImage } from '../live/file-values'\n\n/** An image a carousel shows: a link with what it shows, or a file field's value, as records carry it. */\nexport type CarouselImage = { src: string; alt: string } | (StoredFile & { alt?: string })\n\n// A frame up to about half a page wide: of a file's variants, the smallest that covers it is drawn, the file itself when none does\nconst box = { width: 640, height: 480 }\n\n/** What each slide draws, in order: a file that is missing or is no raster image is left out. */\nexport const carouselSlides = (images: readonly CarouselImage[]) =>\n images.flatMap((image) => {\n if ('src' in image) return [{ image: { url: image.src }, alt: image.alt }]\n const shown = shownImage(image, box)\n return shown ? [{ image: shown, alt: image.alt ?? '' }] : []\n })\n","import { cn } from '../lib/cn'\nimport { FileImage } from '../live/file-image'\nimport { CarouselControls } from './carousel-controls'\nimport { carouselSlides, type CarouselImage } from './carousel-images'\nimport { CarouselTrack } from './carousel-track'\nimport { useCarousel } from './use-carousel'\n\nexport type CarouselProps = {\n /** The images in order: links with what each shows, or file field values. */\n images: readonly CarouselImage[]\n /** What the images are, read out with the carousel. */\n label?: string\n /** `cover` fills the frame and crops what overflows it, the default; `contain` shows each image whole. */\n fit?: 'cover' | 'contain'\n /** Whether a swipe steps through the images; off, it scrolls what the carousel sits in, such as a row that scrolls sideways. */\n swipe?: boolean\n /** The frame's classes, such as its aspect ratio, border and rounding. */\n className?: string\n}\n\n/**\n * Images side by side in a frame that snaps image by image, swiped on a touch screen or moved by arrows on hover, with\n * dots marking the one in view; the record cards' photos step the same way. A single image shows without arrows or dots.\n */\nexport const Carousel = ({ images, label, fit = 'cover', swipe = true, className }: CarouselProps) => {\n const slides = carouselSlides(images)\n const carousel = useCarousel(slides.length)\n return (\n <div role=\"group\" aria-roledescription=\"carousel\" aria-label={label} className={cn('group/carousel relative overflow-hidden', className)}>\n <CarouselTrack\n data-carousel-track\n carousel={carousel}\n swipe={swipe}\n slides={slides.map(({ image, alt }) => (\n <FileImage image={image} alt={alt} loading=\"lazy\" className={cn('size-full', fit === 'cover' ? 'object-cover' : 'object-contain')} />\n ))}\n />\n <CarouselControls carousel={carousel} count={slides.length} swipe={swipe} reveal=\"group-hover/carousel:opacity-100\" className=\"inset-0\" />\n </div>\n )\n}\n","import type { ReactNode } from 'react'\nimport { cn } from '../lib/cn'\n\nexport type ChoiceOption<T extends string> = { value: T; label: string; description?: ReactNode; disabled?: boolean }\n\n/**\n * `name` groups the radio buttons, so that the arrow keys move between them; `label` names the group for screen\n * readers. A disabled option shows and cannot be chosen.\n */\nexport type ChoicesProps<T extends string> = { name: string; label?: string; options: Array<ChoiceOption<T>>; value: T | undefined; onChange: (value: T) => void }\n\n/** One of a few options, each a card of its own row with a line that says what it means; the chosen one is outlined. */\nexport const Choices = <T extends string>({ name, label, options, value, onChange }: ChoicesProps<T>) => (\n <div role=\"radiogroup\" aria-label={label} className=\"flex flex-col gap-2\">\n {options.map((option) => (\n <label\n key={option.value}\n className={cn(\n 'block rounded-lg border p-3 transition-colors has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-offset-2 has-[:focus-visible]:outline-primary',\n option.disabled ? 'cursor-default bg-background opacity-60' : option.value === value ? 'cursor-pointer border-primary bg-primary-soft' : 'cursor-pointer bg-background hover:bg-surface',\n )}\n >\n <input type=\"radio\" name={name} value={option.value} checked={option.value === value} disabled={option.disabled} onChange={() => onChange(option.value)} className=\"sr-only\" />\n <span className={cn('block font-medium', option.value === value && 'text-primary-text')}>{option.label}</span>\n {option.description && <span className=\"mt-0.5 block text-xs leading-snug text-muted-foreground\">{option.description}</span>}\n </label>\n ))}\n </div>\n)\n","import { keepPreviousData, useQuery, useQueryClient } from '@tanstack/react-query'\nimport type { ResourceModel, ViewModel } from '@protobase/schema'\nimport { useClient } from '../data/api-provider'\nimport { keys } from '../data/query-keys'\nimport { fetchLabels, type Labels } from '../live/relation-labels'\n\n/** The names of the chosen records, fetched in one list call; the previous names stay while the next ones load. */\nexport const usePickedLabels = (target: ResourceModel, view: ViewModel | undefined, ids: string[]): Labels => {\n const client = useClient()\n const queryClient = useQueryClient()\n const sorted = [...new Set(ids)].sort()\n const labels = useQuery({\n queryKey: keys.pickedLabels(target.name, sorted.join(',')),\n enabled: sorted.length > 0,\n placeholderData: keepPreviousData,\n queryFn: () => fetchLabels(queryClient, client, target, sorted, view),\n })\n return labels.data ?? new Map()\n}\n","import { useState } from 'react'\nimport { Token } from '../primitives/token'\nimport { useAdminMeta } from './meta-gate'\nimport { RelationPicker } from './relation-picker'\nimport { usePickedLabels } from './use-picked-labels'\n\ntype One = {\n multiple?: false\n /** The chosen record's key, as text; `undefined` for none. */\n value: string | undefined\n onChange: (key: string) => void\n}\n\ntype Several = {\n multiple: true\n /** The chosen records' keys, as text. */\n value: string[]\n onChange: (keys: string[]) => void\n}\n\nexport type RecordPickerProps = (One | Several) & {\n /** The name of the resource whose records it picks. */\n resource: string\n invalid?: boolean\n}\n\n/**\n * Picks records of a resource of the app with the create form's relation picker: type to narrow them by their search\n * fields or title, scroll for more, choose with the mouse or the keyboard. With `multiple`, each choice is added as a\n * token that can be taken off again, and choosing a chosen record takes it off.\n */\nexport const RecordPicker = (props: RecordPickerProps) => {\n const { resources, views } = useAdminMeta()\n const target = resources[props.resource]\n if (!target) throw new Error(`RecordPicker: the app has no resource named \"${props.resource}\"`)\n if (target.primaryKey.length !== 1) throw new Error(`RecordPicker: \"${props.resource}\" has a composite key, which a picker cannot name`)\n const view = views[props.resource]\n const keys = props.multiple ? props.value : props.value === undefined ? [] : [props.value]\n // The names of records chosen here, so a choice shows its name before the names are fetched.\n const [known, setKnown] = useState<Record<string, string>>({})\n const fetched = usePickedLabels(target, view, keys)\n const labelOf = (key: string) => known[key] ?? fetched.get(key) ?? key\n const remember = (key: string, label: string) => setKnown((current) => ({ ...current, [key]: label }))\n\n if (!props.multiple) {\n const { value, onChange } = props\n return (\n <RelationPicker\n target={target}\n view={view}\n value={value ?? ''}\n label={value === undefined ? undefined : labelOf(value)}\n invalid={props.invalid}\n onChange={(key, label) => {\n remember(key, label)\n onChange(key)\n }}\n />\n )\n }\n\n const { value, onChange } = props\n return (\n <div className=\"flex flex-col gap-2\">\n <RelationPicker\n target={target}\n view={view}\n value=\"\"\n chosen={value}\n several\n invalid={props.invalid}\n onChange={(key, label) => {\n remember(key, label)\n onChange(value.includes(key) ? value.filter((chosen) => chosen !== key) : [...value, key])\n }}\n />\n {value.length > 0 && (\n <div className=\"flex flex-wrap gap-1\">\n {value.map((key) => (\n <Token key={key} label={labelOf(key)} onRemove={() => onChange(value.filter((chosen) => chosen !== key))} />\n ))}\n </div>\n )}\n </div>\n )\n}\n"],"ignoreList":[0],"mappings":"sjCASA,IAAMgH,EAAa,CACjB,KAAM,QACN,KAAM,GACN,KAAM,CACJ,CACE,OACA,CACE,EAAG,wNACH,IAAK,QACP,CACF,CACF,CACF,EACAA,EAAW,KACX,IAAMC,EAAQH,GAAiBE,CAAU,ECnBnCE,GAAa,GAAgB,IAAI,KAAK,KAAK,MAAM,GAAGC,EAAI,WAAW,EAAI,KAAU,CAAA,CAAE,YAAY,CAAC,CAAC,MAAM,EAAG,EAAE,EAGrGC,IAAe,EAAW,EAAW,EAAO/E,EAAW,IAAMF,EAAM,KAAK,MAAMkF,CAAC,EAAGC,CAAI,IAAMnF,EAAM,KAAK,MAAMoF,CAAC,EAAGD,CAAI,EAGrHE,IAAgB,EAAc,EAAM,KAAK,IAAI,EAAG,EAAOnF,EAAW,IAAM,CACnF,IAAM8E,EAAMhF,EAAM,KAAK,MAAMsF,CAAI,EAAGH,CAAI,EAClCI,EAAQvF,EAAMwF,EAAKL,CAAI,EAG7B,OAFIH,IAAQO,EAAc/G,EAAK,OAAO,EAClCwG,IAAQD,GAAUQ,CAAK,EAAU/G,EAAK,WAAW,EAC9CkE,GAAkB,KAAK,MAAM,GAAGsC,EAAI,WAAW,CAAC,CACzD,aCHaU,IAAe,CAAE,OAAO,MAAO,WAA8B,CACx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CACE,CAAA,CAEJ,GAET","debugId":"94f107ce-b9ce-47c9-b9c7-75a002514f16"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@protobase/ui",
3
- "version": "0.62.4",
3
+ "version": "0.63.0",
4
4
  "description": "The Protobase admin app and the React hooks and components for custom UI.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -39,9 +39,9 @@
39
39
  "dependencies": {
40
40
  "@dnd-kit/core": "^6.3.1",
41
41
  "@dnd-kit/sortable": "^10.0.0",
42
- "@protobase/client": "0.62.4",
43
- "@protobase/layout": "0.62.4",
44
- "@protobase/schema": "0.62.4",
42
+ "@protobase/client": "0.63.0",
43
+ "@protobase/layout": "0.63.0",
44
+ "@protobase/schema": "0.63.0",
45
45
  "@sentry/browser": "^11.7.0",
46
46
  "@tanstack/react-query": "^5.104.1",
47
47
  "@tanstack/react-table": "^9.2.6",