Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Fixes Spree 6 beta scaffold via CLI (#14654)

Damian Legawiecd62c45393e52
diff --git a/packages/admin-sdk/CHANGELOG.md b/packages/admin-sdk/CHANGELOG.md
index dfdabdae20..3b2c571778 100644
--- a/packages/admin-sdk/CHANGELOG.md
+++ b/packages/admin-sdk/CHANGELOG.md
@@ -1,6 +1,6 @@
# @spree/admin-sdk
-## 1.0.0
+## 1.0.0-beta.1
### Major Changes
diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md
index c7878ed881..28aab4d6aa 100644
--- a/packages/cli/CHANGELOG.md
+++ b/packages/cli/CHANGELOG.md
@@ -1,5 +1,15 @@
# @spree/cli
+## 3.0.1
+
+### Patch Changes
+
+- Fixed first-run setup failing partway through, and scaffolded both admin apps.
+
+ Several failures could leave a new project unusable: minting the CLI's API key raised "Name has already been taken" on any re-run, so a setup interrupted for any reason could never be completed; Mailpit's ports were not probed like the web port, so another Spree project or a local mail catcher failed `docker compose up` with a raw Docker daemon error; sample data was loaded before first-run setup created an admin to own it, aborting the run; and a failed key mint reported that the stack was not running, sending operators after a stack that was running fine.
+
+ Scaffolds also create `apps/seller-dashboard` alongside `apps/dashboard` (`spree add seller-dashboard` adds it to an existing project). The React Dashboard is the admin in Spree 6, so it is no longer opt-in behind a flag, and first-run setup no longer prompts for an admin email and password — the account is created on the dashboard's own setup screen, which the browser opens automatically.
+
## 3.0.0
### Major Changes
diff --git a/packages/cli/package.json b/packages/cli/package.json
index 37d43b6ceb..09cf25a68d 100644
--- a/packages/cli/package.json
+++ b/packages/cli/package.json
@@ -1,6 +1,6 @@
{
"name": "@spree/cli",
- "version": "3.0.0",
+ "version": "3.0.1",
"description": "CLI for managing Spree Commerce projects",
"type": "module",
"bin": {
diff --git a/packages/cli/src/commands/dev.ts b/packages/cli/src/commands/dev.ts
index a45739ca02..c3306c6eb2 100644
--- a/packages/cli/src/commands/dev.ts
+++ b/packages/cli/src/commands/dev.ts
@@ -95,7 +95,7 @@ export function registerDevCommand(program: Command): void {
'',
...(withDashboard
? [
- pc.bold('Admin Dashboard (React, Developer Preview)'),
+ pc.bold('Admin Dashboard'),
` ${pc.cyan(`http://localhost:${DASHBOARD_PORT}`)}`,
...adminIdentityLines(ctx.projectDir),
` ${pc.dim('Live-reloading from apps/dashboard/')}`,
diff --git a/packages/cli/src/commands/init.ts b/packages/cli/src/commands/init.ts
index bebe539c54..cd71c78b55 100644
--- a/packages/cli/src/commands/init.ts
+++ b/packages/cli/src/commands/init.ts
@@ -171,7 +171,7 @@ export async function runFirstRunSetup(flags: {
const adminBlock = dashboardRunnable
? [
- pc.bold('Admin Dashboard (React, Developer Preview)'),
+ pc.bold('Admin Dashboard'),
` ${pc.cyan(`http://localhost:${DASHBOARD_PORT}`)}`,
...credentialLines,
` ${pc.dim('Live-reloading from apps/dashboard/')}`,
@@ -341,49 +341,19 @@ export function updateStorefrontEnv(projectDir: string, apiKey: string): void {
}
/**
- * Flags win; otherwise an interactive terminal prompts (Medusa-style). A
- * non-interactive run with no flags seeds no admin at all — the setup link
- * printed by the seed claims the installation instead, so an automated
- * install never mints a well-known password.
+ * Admin credentials come from flags only, for scripted installs that want a
+ * known account. Without them no admin is seeded and the first one is created
+ * in the dashboard's own setup screen, which the seed's one-time link opens —
+ * so no install, automated or not, mints a well-known password.
*/
async function resolveAdminCredentials(flags: {
adminEmail?: string
adminPassword?: string
}): Promise<{ adminEmail?: string; adminPassword?: string }> {
- let adminEmail = flags.adminEmail
- let adminPassword = flags.adminPassword
-
- if ((!adminEmail || !adminPassword) && process.stdin.isTTY) {
- p.log.step('Create your admin account')
-
- if (!adminEmail) {
- const answer = await p.text({
- message: 'Admin email',
- initialValue: '[email protected]',
- validate: (value) => (value?.includes('@') ? undefined : 'Enter a valid email address'),
- })
- if (p.isCancel(answer)) {
- p.cancel('Setup cancelled.')
- process.exit(1)
- }
- adminEmail = answer
- }
-
- if (!adminPassword) {
- const answer = await p.password({
- message: 'Admin password (min. 8 characters)',
- validate: (value) => ((value ?? '').length >= 8 ? undefined : 'Use at least 8 characters'),
- })
- if (p.isCancel(answer)) {
- p.cancel('Setup cancelled.')
- process.exit(1)
- }
- adminPassword = answer
- }
- }
+ const { adminEmail, adminPassword } = flags
- // Flag values skip the prompt validators, so check them here too — the
- // alternative is failing after Docker start and seeding, minutes later.
+ // Validate before Docker starts — the alternative is failing after the
+ // image pull and seed, minutes later.
if (adminEmail && !adminEmail.includes('@')) {
p.cancel(`Invalid --admin-email: ${adminEmail}`)
process.exit(1)
diff --git a/packages/cli/src/config.ts b/packages/cli/src/config.ts
index c34b982d5d..bb34c4c771 100644
--- a/packages/cli/src/config.ts
+++ b/packages/cli/src/config.ts
@@ -249,11 +249,24 @@ export async function mintProjectCredentials(
NAME: '@spree/cli (auto)',
KEY_TYPE: 'secret',
SCOPES: 'read_all',
+ // The name is fixed, and names are unique among a store's active keys —
+ // so without this a second mint fails on "Name has already been taken".
+ // That is the normal case, not an edge one: an interrupted setup, a
+ // `spree init` re-run, or a lost credentials.json all mint again. The
+ // task revokes the previous key and creates the replacement in one
+ // transaction, so a failure never leaves the project with neither.
+ REPLACE: 'true',
})
} catch (error) {
- const detail = error instanceof Error ? error.message.split('\n')[0] : String(error)
+ // Surface what the task actually said. The old message blamed a stopped
+ // stack for every failure, which sent operators after a stack that was
+ // running fine while the real cause (a validation error) scrolled past.
+ const output = error instanceof Error ? error.message : String(error)
+ const railsError = output.match(/^\w*(?:::\w+)*(?:Error|Invalid):.*$/m)?.[0]
throw new CredentialError(
- `Could not mint an API key via the dev stack. Is it running? Start it with \`spree dev\`.\n${pc.dim(detail)}`,
+ railsError
+ ? `Could not mint an API key.\n${pc.dim(railsError)}`
+ : `Could not mint an API key via the dev stack. Is it running? Start it with \`spree dev\`.\n${pc.dim(output.split('\n')[0])}`,
)
}
diff --git a/packages/cli/src/docker.ts b/packages/cli/src/docker.ts
index e54fd01cc2..1385d7e261 100644
--- a/packages/cli/src/docker.ts
+++ b/packages/cli/src/docker.ts
@@ -261,8 +261,36 @@ export async function dockerComposeCapture(
}
args.push(service, ...argv)
- const { stdout } = await execa('docker', args, { cwd: projectDir })
- return stdout
+ // `compose up -d` can recreate a container moments before this runs — a
+ // recovering project does exactly that — and `exec` into a container that
+ // is still starting fails with "not running". That is transient, but the
+ // error it surfaces ("Is it running? Start it with `spree dev`") sends the
+ // operator after a stack that IS running, so retry briefly before failing.
+ let lastError: unknown
+ for (let attempt = 0; attempt < 5; attempt++) {
+ try {
+ const { stdout } = await execa('docker', args, { cwd: projectDir })
+ return stdout
+ } catch (error) {
+ lastError = error
+ if (!isContainerNotReady(error)) throw error
+ await new Promise((resolve) => setTimeout(resolve, 2000))
+ }
+ }
+ throw lastError
+}
+
+/**
+ * A compose `exec` that lost the race with a starting container, as opposed
+ * to a command that ran and failed — only the former is worth retrying.
+ */
+function isContainerNotReady(error: unknown): boolean {
+ const message = error instanceof Error ? error.message : String(error)
+ return (
+ /is not running/i.test(message) ||
+ /no such container/i.test(message) ||
+ /container .* is restarting/i.test(message)
+ )
}
export async function streamLogs(service: string, projectDir: string): Promise<void> {
diff --git a/packages/create-spree-app/CHANGELOG.md b/packages/create-spree-app/CHANGELOG.md
index b6298976a2..c3bdbd19d7 100644
--- a/packages/create-spree-app/CHANGELOG.md
+++ b/packages/create-spree-app/CHANGELOG.md
@@ -1,5 +1,15 @@
# create-spree-app
+## 2.0.1
+
+### Patch Changes
+
+- Fixed first-run setup failing partway through, and scaffolded both admin apps.
+
+ Several failures could leave a new project unusable: minting the CLI's API key raised "Name has already been taken" on any re-run, so a setup interrupted for any reason could never be completed; Mailpit's ports were not probed like the web port, so another Spree project or a local mail catcher failed `docker compose up` with a raw Docker daemon error; sample data was loaded before first-run setup created an admin to own it, aborting the run; and a failed key mint reported that the stack was not running, sending operators after a stack that was running fine.
+
+ Scaffolds also create `apps/seller-dashboard` alongside `apps/dashboard` (`spree add seller-dashboard` adds it to an existing project). The React Dashboard is the admin in Spree 6, so it is no longer opt-in behind a flag, and first-run setup no longer prompts for an admin email and password — the account is created on the dashboard's own setup screen, which the browser opens automatically.
+
## 2.0.0
### Major Changes
diff --git a/packages/create-spree-app/package.json b/packages/create-spree-app/package.json
index 925ccf0107..70efb18ab8 100644
--- a/packages/create-spree-app/package.json
+++ b/packages/create-spree-app/package.json
@@ -1,6 +1,6 @@
{
"name": "create-spree-app",
- "version": "2.0.0",
+ "version": "2.0.1",
"description": "Create a new Spree Commerce project with a single command",
"type": "module",
"bin": "./dist/index.js",
diff --git a/packages/create-spree-app/src/constants.ts b/packages/create-spree-app/src/constants.ts
index 90e93ab47b..bfc008e2b7 100644
--- a/packages/create-spree-app/src/constants.ts
+++ b/packages/create-spree-app/src/constants.ts
@@ -1,6 +1,8 @@
export const DEFAULT_SPREE_PORT = 3000
export const STOREFRONT_PORT = 3001
export const DASHBOARD_PORT = 5173
+// Seller panel dev server; 5174 matches @spree/cli's own default.
+export const SELLER_DASHBOARD_PORT = 5174
export const STOREFRONT_REPO = 'https://github.com/spree/storefront.git'
diff --git a/packages/create-spree-app/src/index.ts b/packages/create-spree-app/src/index.ts
index d809fcbe8e..fe142dd0fe 100644
--- a/packages/create-spree-app/src/index.ts
+++ b/packages/create-spree-app/src/index.ts
@@ -15,9 +15,8 @@ const program = new Command()
.option('--no-storefront', 'skip Next.js storefront setup')
.option(
'--react-dashboard',
- 'include the React Dashboard (Developer Preview — work in progress; also available later via `spree add dashboard`)',
+ 'no-op: the React Dashboard is always included (kept so existing scripts keep working)',
)
- .option('--no-sample-data', 'skip loading sample data')
.option('--no-start', 'do not start Docker services')
.option('--port <number>', 'port for the Spree server', String(DEFAULT_SPREE_PORT))
.option('--use-npm', 'use npm as package manager')
@@ -41,7 +40,6 @@ const program = new Command()
directory,
noStorefront: flags.storefront === false ? true : undefined,
reactDashboard: flags.reactDashboard === true,
- noSampleData: flags.sampleData === false ? true : undefined,
noStart: flags.start === false ? true : undefined,
packageManager,
})
@@ -52,7 +50,24 @@ const program = new Command()
p.log.warn(`Port ${preferred} is in use, using port ${pc.bold(String(port))} instead.`)
}
- await scaffold({ ...options, port })
+ // Mailpit publishes both ports on the host, so another Spree project or
+ // any local mail catcher takes them. Compose fails on a bound port with
+ // a raw daemon error minutes into the run — after the image pull — so
+ // probe them here like the web port rather than letting that happen.
+ const mailpitSmtpPort = await getPort({ port: portNumbers(1025, 1125) })
+ const mailpitUiPort = await getPort({ port: portNumbers(8025, 8125) })
+ for (const [label, preferredPort, resolved] of [
+ ['Mailpit SMTP', 1025, mailpitSmtpPort],
+ ['Mailpit UI', 8025, mailpitUiPort],
+ ] as const) {
+ if (resolved !== preferredPort) {
+ p.log.warn(
+ `${label} port ${preferredPort} is in use, using port ${pc.bold(String(resolved))} instead.`,
+ )
+ }
+ }
+
+ await scaffold({ ...options, port, mailpitSmtpPort, mailpitUiPort })
p.outro('Happy selling!')
} catch (err) {
diff --git a/packages/create-spree-app/src/prompts.ts b/packages/create-spree-app/src/prompts.ts
index acaafc1de6..2b46bbc687 100644
--- a/packages/create-spree-app/src/prompts.ts
+++ b/packages/create-spree-app/src/prompts.ts
@@ -5,12 +5,13 @@ interface PromptFlags {
directory?: string
noStorefront?: boolean
reactDashboard?: boolean
- noSampleData?: boolean
noStart?: boolean
packageManager?: PackageManager
}
-export async function runPrompts(flags: PromptFlags): Promise<Omit<ScaffoldOptions, 'port'>> {
+export async function runPrompts(
+ flags: PromptFlags,
+): Promise<Omit<ScaffoldOptions, 'port' | 'mailpitSmtpPort' | 'mailpitUiPort'>> {
const directory =
flags.directory ??
((await p.text({
@@ -44,27 +45,11 @@ export async function runPrompts(flags: PromptFlags): Promise<Omit<ScaffoldOptio
storefront = storefrontResult
}
- // Deliberately not prompted: the React Dashboard is a work-in-progress
- // Developer Preview, and a yes/no prompt reads as a recommendation. It's
- // opt-in via --react-dashboard (or later via `spree add dashboard`) until
- // it's ready for prime time.
- const dashboard = flags.reactDashboard ?? false
-
- let sampleData: boolean
- if (flags.noSampleData !== undefined) {
- sampleData = !flags.noSampleData
- } else {
- const sampleResult = await p.confirm({
- message: 'Include sample data? (products, categories, images)',
- initialValue: true,
- })
-
- if (p.isCancel(sampleResult)) {
- p.cancel('Setup cancelled.')
- process.exit(0)
- }
- sampleData = sampleResult
- }
+ // Always scaffolded, never prompted: from Spree 6 the React Dashboard IS
+ // the admin (the Rails admin engine is gone), so a project without one has
+ // no back office at all. The marketplace Seller Panel ships alongside it so
+ // the pair stays consistent with what the starter's Docker image bakes.
+ const dashboard = true
let start: boolean
if (flags.noStart !== undefined) {
@@ -86,7 +71,6 @@ export async function runPrompts(flags: PromptFlags): Promise<Omit<ScaffoldOptio
directory,
storefront,
dashboard,
- sampleData,
start,
packageManager: flags.packageManager ?? 'npm',
}
diff --git a/packages/create-spree-app/src/scaffold.ts b/packages/create-spree-app/src/scaffold.ts
index 3ccf7a0668..54d20589c2 100644
--- a/packages/create-spree-app/src/scaffold.ts
+++ b/packages/create-spree-app/src/scaffold.ts
@@ -3,7 +3,7 @@ import path from 'node:path'
import * as p from '@clack/prompts'
import { execa } from 'execa'
import pc from 'picocolors'
-import { DASHBOARD_PORT, STOREFRONT_PORT, STOREFRONT_REPO } from './constants.js'
+import { DASHBOARD_PORT, STOREFRONT_REPO } from './constants.js'
import { scaffoldDashboard } from './dashboard.js'
import { downloadServer } from './server.js'
import {
@@ -87,7 +87,7 @@ export async function scaffold(options: ScaffoldOptions): Promise<void> {
fs.writeFileSync(
path.join(projectDir, '.env'),
- envContent(generateSecretKeyBase(), port, options.sampleData),
+ envContent(generateSecretKeyBase(), port, options.mailpitSmtpPort, options.mailpitUiPort),
)
fs.writeFileSync(
path.join(projectDir, 'package.json'),
@@ -117,10 +117,7 @@ export async function scaffold(options: ScaffoldOptions): Promise<void> {
await downloadStorefront(projectDir)
s.stop('Storefront template downloaded.')
- // Sample data seeds the whole wholesale demo (gated channel, buyer,
- // trade prices), so those scaffolds get the portal enabled up front —
- // first-run setup fills in the channel-bound key.
- writeStorefrontEnv(projectDir, port, options.sampleData)
+ writeStorefrontEnv(projectDir, port)
s.start('Installing storefront dependencies...')
await installStorefrontDeps(projectDir, options.packageManager)
@@ -137,7 +134,7 @@ export async function scaffold(options: ScaffoldOptions): Promise<void> {
}
}
- // Phase 3b: the admin SPAs (optional, Developer Preview) — the Dashboard
+ // Phase 3b: the admin SPAs — the Dashboard
// and the marketplace Seller Panel. Delegates to the project-local
// `npx spree add <component>` — @spree/cli is already installed (root deps,
// above) and bundles both starter templates. It reads the port from the
@@ -181,8 +178,11 @@ export async function scaffold(options: ScaffoldOptions): Promise<void> {
// Phase 4: Initialize and start services
if (options.start) {
- const initArgs = ['spree', 'init']
- if (!options.sampleData) initArgs.push('--no-sample-data')
+ // Sample data is never part of a scaffold: first-run setup configures the
+ // store through the dashboard, and the sample-data import needs an admin
+ // that setup has not created yet — loading it here failed the whole init.
+ // The CLI still offers it on demand via `spree sample-data`.
+ const initArgs = ['spree', 'init', '--no-sample-data']
try {
await execa(runCommand(options.packageManager), initArgs, {
@@ -201,11 +201,6 @@ export async function scaffold(options: ScaffoldOptions): Promise<void> {
p.log.info(
`${pc.bold('Storefront')}: ${pc.cyan(`cd ${projectName}/apps/storefront && ${storefrontPm(options.packageManager)} run dev`)}`,
)
- if (options.sampleData) {
- p.log.info(
- `${pc.bold('Wholesale portal')}: ${pc.cyan(`http://localhost:${STOREFRONT_PORT}/wholesale`)} — register a buyer, then approve them in the admin (add to the ${pc.bold('Wholesale')} customer group)`,
- )
- }
}
// No dashboard line here — with the dashboard chosen, `spree init`'s
// summary already leads with it (served at /dashboard, plus the
@@ -217,7 +212,6 @@ export async function scaffold(options: ScaffoldOptions): Promise<void> {
dashboardReady,
port,
options.packageManager,
- options.sampleData,
)
}
}
@@ -228,7 +222,6 @@ function printSuccessWithoutDocker(
hasDashboard: boolean,
port: number,
pm: PackageManager,
- sampleData: boolean,
): void {
const run = runCommand(pm)
const lines: string[] = [
@@ -247,11 +240,6 @@ function printSuccessWithoutDocker(
` ${installCommand(pm)}`,
` ${pm} run dev`,
)
- if (sampleData) {
- lines.push(
- ` ${pc.dim(`# Wholesale B2B portal: http://localhost:${STOREFRONT_PORT}/wholesale (approve buyers via the "Wholesale" customer group)`)}`,
- )
- }
}
// With the React Dashboard chosen, its dev server IS the admin — and
@@ -260,11 +248,10 @@ function printSuccessWithoutDocker(
if (hasDashboard) {
lines.push(
'',
- `${pc.bold('Admin Dashboard (React, Developer Preview)')}`,
+ `${pc.bold('Admin Dashboard')}`,
` http://localhost:${DASHBOARD_PORT}`,
` ${pc.dim('# started automatically by `spree dev`, live-reloading from apps/dashboard/')}`,
` ${pc.dim("# you'll create the admin account on first run")}`,
- ` ${pc.dim(`Classic admin: http://localhost:${port}/admin`)}`,
'',
)
} else {
diff --git a/packages/create-spree-app/src/storefront.ts b/packages/create-spree-app/src/storefront.ts
index 54adb4b379..1231228caf 100644
--- a/packages/create-spree-app/src/storefront.ts
+++ b/packages/create-spree-app/src/storefront.ts
@@ -143,7 +143,7 @@ export async function installStorefrontDeps(projectDir: string, pm: PackageManag
await execa(cmd, args, { cwd: storefrontDir, stdio: 'ignore' })
}
-export function writeStorefrontEnv(projectDir: string, port: number, wholesale = false): void {
+export function writeStorefrontEnv(projectDir: string, port: number): void {
const envPath = path.join(projectDir, 'apps', 'storefront', '.env.local')
- fs.writeFileSync(envPath, storefrontEnvContent(port, wholesale))
+ fs.writeFileSync(envPath, storefrontEnvContent(port))
}
diff --git a/packages/create-spree-app/src/templates/claude-md.ts b/packages/create-spree-app/src/templates/claude-md.ts
index fe4161bde7..4f5e001064 100644
--- a/packages/create-spree-app/src/templates/claude-md.ts
+++ b/packages/create-spree-app/src/templates/claude-md.ts
@@ -47,7 +47,8 @@ export function rootClaudeMdContent(
}
if (hasDashboard) {
- lines.push('| `apps/dashboard/` | React Dashboard — admin SPA (Developer Preview) |')
+ lines.push('| `apps/dashboard/` | React Dashboard — admin SPA |')
+ lines.push('| `apps/seller-dashboard/` | Seller Panel — marketplace seller SPA |')
}
lines.push(
diff --git a/packages/create-spree-app/src/templates/dependabot.ts b/packages/create-spree-app/src/templates/dependabot.ts
index 835bb9bbbd..9a953c0d88 100644
--- a/packages/create-spree-app/src/templates/dependabot.ts
+++ b/packages/create-spree-app/src/templates/dependabot.ts
@@ -73,7 +73,7 @@ export function dependabotContent(hasStorefront: boolean, hasDashboard = false):
if (hasDashboard) {
ecosystems.push({
- comment: 'React Dashboard (Developer Preview)',
+ comment: 'React Dashboard',
ecosystem: 'npm',
directory: '/apps/dashboard',
group: 'dashboard',
diff --git a/packages/create-spree-app/src/templates/env.ts b/packages/create-spree-app/src/templates/env.ts
index f01659eae7..0388ecd853 100644
--- a/packages/create-spree-app/src/templates/env.ts
+++ b/packages/create-spree-app/src/templates/env.ts
@@ -1,30 +1,25 @@
/**
- * The project root `.env`: Rails secret, server port, image tag, and the
- * persisted sample-data choice (`SPREE_SAMPLE_DATA`) that first-run setup
- * reads back when it runs deferred (through `spree dev`).
+ * The project root `.env`: Rails secret, ports and image tag. The Mailpit
+ * ports are written even when they are the defaults, so compose never falls
+ * back to a value the scaffold did not check was free.
*/
-export function envContent(secretKeyBase: string, port: number, sampleData: boolean): string {
+export function envContent(
+ secretKeyBase: string,
+ port: number,
+ mailpitSmtpPort: number,
+ mailpitUiPort: number,
+): string {
return `SECRET_KEY_BASE=${secretKeyBase}
SPREE_PORT=${port}
SPREE_VERSION_TAG=latest
-# Whether first-run setup loads demo products and orders.
-SPREE_SAMPLE_DATA=${sampleData}
+MAILPIT_SMTP_PORT=${mailpitSmtpPort}
+MAILPIT_UI_PORT=${mailpitUiPort}
`
}
-export function storefrontEnvContent(port: number, wholesale = false): string {
- let content = `SPREE_API_URL=http://localhost:${port}
+export function storefrontEnvContent(port: number): string {
+ const content = `SPREE_API_URL=http://localhost:${port}
SPREE_PUBLISHABLE_KEY=pk_REPLACE_ME_AFTER_DOCKER_START
`
- if (wholesale) {
- content += `
-# Wholesale B2B portal (/wholesale) — the gated channel and trade price list
-# ship with sample data. Buyers self-register; approve one by adding them to
-# the "Wholesale" customer group in the admin. The portal uses
-# SPREE_PUBLISHABLE_KEY (the channel header selects the channel); set
-# SPREE_WHOLESALE_PUBLISHABLE_KEY only to pin a channel-bound key.
-SPREE_WHOLESALE_CHANNEL=wholesale
-`
- }
return content
}
diff --git a/packages/create-spree-app/src/templates/package-json.ts b/packages/create-spree-app/src/templates/package-json.ts
index 1384b98a0b..ac8664fd56 100644
--- a/packages/create-spree-app/src/templates/package-json.ts
+++ b/packages/create-spree-app/src/templates/package-json.ts
@@ -32,12 +32,15 @@ export function rootPackageJsonContent(name: string, pm: PackageManager = 'pnpm'
},
dependencies: {
// The floor matches the CLI behavior this scaffold relies on (the
- // --quiet delegation, dev co-run, first-run setup) — an older resolve
- // would reject the flags and silently drop the dashboard phase.
+ // --quiet delegation, dev co-run, first-run setup, and `spree add
+ // seller-dashboard`) — an older resolve rejects the flags and silently
+ // drops an admin app. Bump it in lockstep with any new CLI capability
+ // the scaffold calls, or the scaffold asks for something the pinned CLI
+ // has never heard of.
// SPREE_CLI_VERSION overrides the spec for testing unreleased CLIs —
// a range, or a `file:`/`link:` path to a packed tarball / checkout
// (mirrors the starter Dockerfile's ARG of the same name).
- '@spree/cli': process.env.SPREE_CLI_VERSION ?? '^2.4.4',
+ '@spree/cli': process.env.SPREE_CLI_VERSION ?? '^3.0.0',
'@spree/docs': 'latest',
},
}
diff --git a/packages/create-spree-app/src/templates/readme.ts b/packages/create-spree-app/src/templates/readme.ts
index d418e74f37..003687b512 100644
--- a/packages/create-spree-app/src/templates/readme.ts
+++ b/packages/create-spree-app/src/templates/readme.ts
@@ -1,4 +1,4 @@
-import { DASHBOARD_PORT, STOREFRONT_PORT } from '../constants.js'
+import { DASHBOARD_PORT, SELLER_DASHBOARD_PORT, STOREFRONT_PORT } from '../constants.js'
import type { PackageManager } from '../types.js'
import { globalAddCommand, runCommand, storefrontPm } from '../utils.js'
@@ -40,11 +40,10 @@ Wait for the services to be healthy, then open:
${
hasDashboard
- ? `- **Admin Dashboard (React, Developer Preview):** http://localhost:${DASHBOARD_PORT} — started automatically by \`spree dev\`
- - You choose the admin email and password during the first run
- - Classic admin: http://localhost:${port}/admin (same credentials)`
- : `- **Admin Dashboard:** http://localhost:${port}/admin
- - You choose the admin email and password during the first run`
+ ? `- **Admin Dashboard:** http://localhost:${DASHBOARD_PORT} — started automatically by \`spree dev\`
+ - The first run opens a setup link where you create the admin account
+- **Seller Panel (marketplace):** http://localhost:${SELLER_DASHBOARD_PORT} — run it with \`cd apps/seller-dashboard && pnpm dev\``
+ : `- **Admin Dashboard:** run \`spree add dashboard\` to scaffold it`
}
- **Store API:** http://localhost:${port}/api/v3/store
`
@@ -66,7 +65,7 @@ Open http://localhost:${STOREFRONT_PORT}
if (hasDashboard) {
content += `
-### The React Dashboard (Developer Preview)
+### The React Dashboard
\`apps/dashboard/\` is your admin — a customizable React SPA (plugins, your
own pages, table tweaks) with live reload. \`spree dev\` starts it
diff --git a/packages/create-spree-app/src/types.ts b/packages/create-spree-app/src/types.ts
index b4b87486e9..cdfa9b53af 100644
--- a/packages/create-spree-app/src/types.ts
+++ b/packages/create-spree-app/src/types.ts
@@ -4,8 +4,9 @@ export interface ScaffoldOptions {
directory: string
storefront: boolean
dashboard: boolean
- sampleData: boolean
start: boolean
packageManager: PackageManager
port: number
+ mailpitSmtpPort: number
+ mailpitUiPort: number
}
diff --git a/packages/create-spree-app/tests/dashboard.test.ts b/packages/create-spree-app/tests/dashboard.test.ts
new file mode 100644
index 0000000000..6482c5f3da
--- /dev/null
+++ b/packages/create-spree-app/tests/dashboard.test.ts
@@ -0,0 +1,60 @@
+import { beforeEach, describe, expect, it, vi } from 'vitest'
+
+vi.mock('execa', () => ({ execa: vi.fn() }))
+
+import { execa } from 'execa'
+import { scaffoldDashboard } from '../src/dashboard'
+
+// Both admin SPAs ship in every project: from Spree 6 the Dashboard IS the
+// admin, and the starter's Dockerfile bakes whichever of the two it finds
+// under apps/. A scaffold that silently produced only one would leave either
+// no back office or no seller panel in the built image.
+describe('scaffoldDashboard', () => {
+ beforeEach(() => vi.mocked(execa).mockClear())
+
+ function componentsScaffoldedInto(projectDir: string): string[] {
+ return vi
+ .mocked(execa)
+ .mock.calls.filter(([, args]) => (args as string[])?.[0] === 'spree')
+ .filter(([, , opts]) => (opts as { cwd?: string })?.cwd === projectDir)
+ .map(([, args]) => (args as string[])[2])
+ }
+
+ it('scaffolds both the dashboard and the seller panel', async () => {
+ await scaffoldDashboard('/tmp/project', { install: true, packageManager: 'pnpm' })
+
+ expect(componentsScaffoldedInto('/tmp/project')).toEqual(['dashboard', 'seller-dashboard'])
+ })
+
+ it('runs each through the project-local CLI, quietly', async () => {
+ await scaffoldDashboard('/tmp/project', { install: true, packageManager: 'npm' })
+
+ // npm reaches the local CLI through npx; --quiet suppresses the command's
+ // own summary because the scaffold prints its own.
+ for (const [cmd, args, opts] of vi.mocked(execa).mock.calls) {
+ expect(cmd).toBe('npx')
+ expect(args).toContain('--quiet')
+ expect((opts as { cwd?: string }).cwd).toBe('/tmp/project')
+ }
+ })
+
+ it('passes --no-install through to both apps when installing is skipped', async () => {
+ await scaffoldDashboard('/tmp/project', { install: false, packageManager: 'pnpm' })
+
+ const calls = vi.mocked(execa).mock.calls
+ expect(calls).toHaveLength(2)
+ for (const [, args] of calls) {
+ expect(args).toContain('--no-install')
+ }
+ })
+
+ it('stops at the first failure rather than leaving a half-scaffolded pair', async () => {
+ vi.mocked(execa).mockRejectedValueOnce(new Error('spree add dashboard failed'))
+
+ await expect(
+ scaffoldDashboard('/tmp/project', { install: true, packageManager: 'pnpm' }),
+ ).rejects.toThrow('spree add dashboard failed')
+
+ expect(componentsScaffoldedInto('/tmp/project')).toEqual(['dashboard'])
+ })
+})
diff --git a/packages/create-spree-app/tests/prompts.test.ts b/packages/create-spree-app/tests/prompts.test.ts
new file mode 100644
index 0000000000..f467054557
--- /dev/null
+++ b/packages/create-spree-app/tests/prompts.test.ts
@@ -0,0 +1,42 @@
+import { describe, expect, it, vi } from 'vitest'
+
+vi.mock('@clack/prompts', () => ({
+ text: vi.fn(),
+ confirm: vi.fn(),
+ cancel: vi.fn(),
+ isCancel: () => false,
+}))
+
+import { runPrompts } from '../src/prompts'
+
+// Flags cover every question, so runPrompts returns without touching @clack.
+const ANSWERED = {
+ directory: './my-store',
+ noStorefront: true,
+ noStart: true,
+ packageManager: 'pnpm',
+} as const
+
+describe('runPrompts', () => {
+ // From Spree 6 the React Dashboard IS the admin — the Rails admin engine is
+ // gone — so a scaffold without one has no back office. It is therefore not
+ // a question, and `--react-dashboard` is a no-op rather than a gate.
+ it('always includes the admin apps, with no prompt and regardless of flags', async () => {
+ const { confirm } = await import('@clack/prompts')
+
+ expect((await runPrompts({ ...ANSWERED })).dashboard).toBe(true)
+ expect((await runPrompts({ ...ANSWERED, reactDashboard: false })).dashboard).toBe(true)
+ expect((await runPrompts({ ...ANSWERED, reactDashboard: true })).dashboard).toBe(true)
+
+ expect(vi.mocked(confirm)).not.toHaveBeenCalled()
+ })
+
+ // Sample data is loaded on demand with `spree sample-data`, never as part of
+ // the scaffold: the seed runs before the store is configured through the
+ // first-run setup UI.
+ it('never asks about sample data', async () => {
+ const options = await runPrompts({ ...ANSWERED })
+
+ expect(options).not.toHaveProperty('sampleData')
+ })
+})
diff --git a/packages/create-spree-app/tests/scaffold.test.ts b/packages/create-spree-app/tests/scaffold.test.ts
index 2910a99105..4344a1a2e0 100644
--- a/packages/create-spree-app/tests/scaffold.test.ts
+++ b/packages/create-spree-app/tests/scaffold.test.ts
@@ -75,6 +75,14 @@ vi.mock('../src/dashboard', () => ({
scaffoldDashboard: vi.fn(),
}))
+// `spree init` is shelled out to; the scaffold only decides its arguments.
+vi.mock('execa', () => ({ execa: vi.fn() }))
+
+vi.mock('../src/utils', async (importOriginal) => {
+ const mod = await importOriginal<typeof import('../src/utils')>()
+ return { ...mod, isDockerRunning: vi.fn(async () => true) }
+})
+
vi.mock('../src/server', () => ({
downloadServer: vi.fn(async (projectDir: string) => {
// Simulate what downloadServer does: create server/ with compose files
@@ -113,7 +121,6 @@ describe('scaffold (no-start)', () => {
directory: projectDir,
storefront: true,
dashboard: false,
- sampleData: false,
start: false,
packageManager: 'npm',
port: 3000,
@@ -127,30 +134,26 @@ describe('scaffold (no-start)', () => {
expect(fs.existsSync(path.join(projectDir, '.gitignore'))).toBe(true)
})
- it('enables the wholesale portal in the storefront env only with sample data', async () => {
- const { writeStorefrontEnv } = await import('../src/storefront')
+ // Sample data must never ride along with first-run setup: setup configures
+ // the store through the dashboard, and the sample-data import needs an admin
+ // that setup has not created yet. `spree init` also mints credentials.json
+ // BEFORE loading sample data, so a failure there leaves a project that later
+ // runs read as "already set up" and can never finish setup.
+ it('runs first-run setup with sample data opted out', async () => {
+ const { execa } = await import('execa')
+ vi.mocked(execa).mockClear()
await scaffold({
directory: getTempProjectDir(),
- storefront: true,
- dashboard: false,
- sampleData: true,
- start: false,
- packageManager: 'npm',
+ storefront: false,
+ dashboard: true,
+ start: true,
+ packageManager: 'pnpm',
port: 3000,
})
- expect(writeStorefrontEnv).toHaveBeenLastCalledWith(expect.any(String), 3000, true)
- await scaffold({
- directory: getTempProjectDir(),
- storefront: true,
- dashboard: false,
- sampleData: false,
- start: false,
- packageManager: 'npm',
- port: 3000,
- })
- expect(writeStorefrontEnv).toHaveBeenLastCalledWith(expect.any(String), 3000, false)
+ const init = vi.mocked(execa).mock.calls.find(([, args]) => (args as string[])?.[1] === 'init')
+ expect(init?.[1]).toEqual(['spree', 'init', '--no-sample-data'])
})
it('copies docker-compose.yml from server template', async () => {
@@ -160,7 +163,6 @@ describe('scaffold (no-start)', () => {
directory: projectDir,
storefront: true,
dashboard: false,
- sampleData: false,
start: false,
packageManager: 'npm',
port: 3000,
@@ -179,7 +181,6 @@ describe('scaffold (no-start)', () => {
directory: projectDir,
storefront: true,
dashboard: false,
- sampleData: false,
start: false,
packageManager: 'npm',
port: 3000,
@@ -197,7 +198,6 @@ describe('scaffold (no-start)', () => {
directory: projectDir,
storefront: true,
dashboard: false,
- sampleData: false,
start: false,
packageManager: 'npm',
port: 3000,
@@ -217,7 +217,6 @@ describe('scaffold (no-start)', () => {
directory: projectDir,
storefront: true,
dashboard: false,
- sampleData: false,
start: false,
packageManager: 'npm',
port: 4567,
@@ -235,7 +234,6 @@ describe('scaffold (no-start)', () => {
directory: projectDir,
storefront: true,
dashboard: false,
- sampleData: false,
start: false,
packageManager: 'npm',
port: 3000,
@@ -255,7 +253,6 @@ describe('scaffold (no-start)', () => {
directory: projectDir,
storefront: false,
dashboard: true,
- sampleData: false,
start: false,
packageManager: 'npm',
port: 4567,
@@ -279,7 +276,6 @@ describe('scaffold (no-start)', () => {
directory: projectDir,
storefront: false,
dashboard: false,
- sampleData: false,
start: false,
packageManager: 'npm',
port: 3000,
@@ -304,7 +300,6 @@ describe('scaffold (no-start)', () => {
await expect(
scaffold({
directory: projectDir,
- sampleData: false,
start: false,
packageManager: 'npm',
port: 3000,
diff --git a/packages/create-spree-app/tests/templates.test.ts b/packages/create-spree-app/tests/templates.test.ts
index 271c1c6328..3c7a1ea34c 100644
--- a/packages/create-spree-app/tests/templates.test.ts
+++ b/packages/create-spree-app/tests/templates.test.ts
@@ -8,23 +8,28 @@ import { readmeContent } from '../src/templates/readme'
describe('envContent', () => {
it('includes the provided secret key', () => {
- const content = envContent('my-secret-123', 3000, true)
+ const content = envContent('my-secret-123', 3000, 1025, 8025)
expect(content).toContain('SECRET_KEY_BASE=my-secret-123')
})
it('includes SPREE_PORT', () => {
- const content = envContent('any', 3000, true)
+ const content = envContent('any', 3000, 1025, 8025)
expect(content).toContain('SPREE_PORT=3000')
})
it('uses custom port value', () => {
- const content = envContent('any', 4567, true)
+ const content = envContent('any', 4567, 1025, 8025)
expect(content).toContain('SPREE_PORT=4567')
})
- it('persists the sample-data choice', () => {
- expect(envContent('any', 3000, true)).toContain('SPREE_SAMPLE_DATA=true')
- expect(envContent('any', 3000, false)).toContain('SPREE_SAMPLE_DATA=false')
+ // Mailpit publishes both ports on the host, so a second Spree project or any
+ // local mail catcher takes them. The scaffold probes them and writes the
+ // result, so compose never falls back to a default nobody checked was free.
+ it('pins the probed Mailpit ports', () => {
+ const content = envContent('any', 3000, 1026, 8026)
+
+ expect(content).toContain('MAILPIT_SMTP_PORT=1026')
+ expect(content).toContain('MAILPIT_UI_PORT=8026')
})
})
@@ -48,11 +53,6 @@ describe('storefrontEnvContent', () => {
const content = storefrontEnvContent(3000)
expect(content).not.toContain('SPREE_WHOLESALE_CHANNEL')
})
-
- it('enables the wholesale portal when requested', () => {
- const content = storefrontEnvContent(3000, true)
- expect(content).toMatch(/^SPREE_WHOLESALE_CHANNEL=wholesale$/m)
- })
})
describe('rootPackageJsonContent', () => {
@@ -75,7 +75,9 @@ describe('rootPackageJsonContent', () => {
delete process.env.SPREE_CLI_VERSION
}
const pkg = JSON.parse(rootPackageJsonContent('my-store'))
- expect(pkg.dependencies['@spree/cli']).toBe('^2.4.4')
+ // The floor must admit every CLI capability the scaffold calls — the
+ // seller-dashboard component landed in 3.0.
+ expect(pkg.dependencies['@spree/cli']).toBe('^3.0.0')
})
it('includes convenience scripts using spree cli', () => {
@@ -128,8 +130,8 @@ describe('readmeContent', () => {
// during first run, so the README points there instead of printing a
// well-known email and password.
it('points at first-run setup instead of printing credentials', () => {
- const content = readmeContent('my-store', true, 3000)
- expect(content).toContain('admin email and password during the first run')
+ const content = readmeContent('my-store', true, 3000, true)
+ expect(content).toContain('setup link where you create the admin account')
expect(content).not.toContain('[email protected]')
expect(content).not.toContain('spree123')
})
@@ -160,7 +162,6 @@ describe('readmeContent', () => {
it('uses custom port in URLs', () => {
const content = readmeContent('my-store', true, 4567)
- expect(content).toContain('http://localhost:4567/admin')
expect(content).toContain('http://localhost:4567/api/v3/store')
})
@@ -189,10 +190,12 @@ describe('readmeContent', () => {
it('includes the React Dashboard section when included', () => {
const content = readmeContent('my-store', true, 3000, true)
- expect(content).toContain('### The React Dashboard (Developer Preview)')
- // The dashboard's dev server IS the admin; the classic admin is a pointer.
+ expect(content).toContain('### The React Dashboard')
+ // The dashboard's dev server IS the admin in Spree 6 — the Rails admin
+ // engine is gone, so the README must not point at /admin.
expect(content).toContain('http://localhost:5173')
- expect(content).toContain('Classic admin: http://localhost:3000/admin')
+ expect(content).not.toContain('Classic admin')
+ expect(content).toContain('Seller Panel')
expect(content).toContain('docs/developer/dashboard')
})
diff --git a/packages/dashboard-core/CHANGELOG.md b/packages/dashboard-core/CHANGELOG.md
index 28ad2b82e6..242df5ce39 100644
--- a/packages/dashboard-core/CHANGELOG.md
+++ b/packages/dashboard-core/CHANGELOG.md
@@ -1,6 +1,8 @@
# @spree/dashboard-core
-## 1.0.0
+## 1.0.0-beta.2
+
+## 1.0.0-beta.1
### Major Changes
diff --git a/packages/dashboard-core/package.json b/packages/dashboard-core/package.json
index 59654f440e..4f69481438 100644
--- a/packages/dashboard-core/package.json
+++ b/packages/dashboard-core/package.json
@@ -1,7 +1,7 @@
{
"name": "@spree/dashboard-core",
"license": "MIT",
- "version": "1.0.0-beta.1",
+ "version": "1.0.0-beta.2",
"description": "Spree Dashboard framework — registries (table, nav, slot, settings-nav), providers (auth, permission, store), admin SDK client, generic infra hooks, and the defineDashboardPlugin extension API. Developer Preview.",
"author": "Vendo Connect Inc.",
"homepage": "https://spreecommerce.org",
diff --git a/packages/dashboard-ui/CHANGELOG.md b/packages/dashboard-ui/CHANGELOG.md
index 8d6d5260ac..37d4ff4669 100644
--- a/packages/dashboard-ui/CHANGELOG.md
+++ b/packages/dashboard-ui/CHANGELOG.md
@@ -1,6 +1,16 @@
# @spree/dashboard-ui
-## 1.0.0
+## 1.0.0-beta.2
+
+### Minor Changes
+
+- Removed the address map from the design system.
+
+ The map was rendered on one card — a seller's billing and returns addresses — and could not plot anything, because Spree addresses carry no coordinates. It also cost every dashboard user around a megabyte of MapLibre in the main bundle.
+
+ Its `?worker&url` import made the package impossible to install, too: Vite's dependency optimizer cannot resolve that specifier inside `node_modules`, so any project depending on `@spree/dashboard-ui` failed to start its dev server. Projects on the previous release should upgrade.
+
+## 1.0.0-beta.1
### Minor Changes
diff --git a/packages/dashboard-ui/package.json b/packages/dashboard-ui/package.json
index 9e60972efa..5952fc024b 100644
--- a/packages/dashboard-ui/package.json
+++ b/packages/dashboard-ui/package.json
@@ -1,7 +1,7 @@
{
"name": "@spree/dashboard-ui",
"license": "MIT",
- "version": "1.0.0-beta.1",
+ "version": "1.0.0-beta.2",
"description": "Spree Dashboard design system — shadcn primitives, headless composed components, and design tokens. Source-only package; consumers compile via their own Vite/Tailwind setup. Developer Preview.",
"author": "Vendo Connect Inc.",
"homepage": "https://spreecommerce.org",
@@ -73,7 +73,6 @@
"date-fns-tz": "^3.2.0",
"flag-icons": "^7.5.0",
"lucide-react": "^1.14.0",
- "maplibre-gl": "6.4.1",
"react-colorful": "^5.7.0",
"react-day-picker": "^9.14.0",
"recharts": "^3.8.1",
@@ -82,7 +81,6 @@
"tw-animate-css": "^1.4.0"
},
"devDependencies": {
- "@types/geojson": "^7946.0.16",
"@types/react": "^19.2.14",
"@types/react-dom": "^19.2.3",
"tailwindcss": "^4.2.4",
diff --git a/packages/dashboard-ui/src/index.ts b/packages/dashboard-ui/src/index.ts
index 43e132d68c..b10bf9f285 100644
--- a/packages/dashboard-ui/src/index.ts
+++ b/packages/dashboard-ui/src/index.ts
@@ -31,7 +31,6 @@ export { requiredMessage } from './lib/validation-messages'
// ---------------------------------------------------------------------------
export * from './spree/address-block'
export * from './spree/address-book-row'
-export * from './spree/address-map'
export * from './spree/back-button'
export * from './spree/bulk-dialog'
export * from './spree/bulk-price-table'
diff --git a/packages/dashboard-ui/src/spree/address-map.tsx b/packages/dashboard-ui/src/spree/address-map.tsx
deleted file mode 100644
index 8438694438..0000000000
--- a/packages/dashboard-ui/src/spree/address-map.tsx
+++ /dev/null
@@ -1,62 +0,0 @@
-import { lazy, Suspense } from 'react'
-import { useTranslation } from 'react-i18next'
-
-/**
- * Structural shape `<AddressMap>` needs. Declared here rather than imported
- * so the design system stays decoupled from any SDK's `Address` type — the
- * same reason `<AddressBlock>` carries its own.
- */
-export interface AddressMapValue {
- latitude?: number | null
- longitude?: number | null
-}
-
-// MapLibre and its styles are a few megabytes for a map that appears on one
-// card of a page, so it is loaded on demand and every other screen is spared.
-const LazyMap = lazy(async () => ({ default: (await import('../ui/map')).Map }))
-const LazyMapControls = lazy(async () => ({ default: (await import('../ui/map')).MapControls }))
-const LazyMapMarker = lazy(async () => ({ default: (await import('../ui/map')).MapMarker }))
-const LazyMarkerContent = lazy(async () => ({ default: (await import('../ui/map')).MarkerContent }))
-const LazyMarkerTooltip = lazy(async () => ({ default: (await import('../ui/map')).MarkerTooltip }))
-
-/**
- * Where an address actually is, beside the lines that describe it — a returns
- * address is what shoppers are told to post to, so it is worth seeing on a map
- * rather than trusting as typed.
- *
- * Coordinates are geocoded in the background after an address is saved, so a
- * freshly entered one has none yet; the map is simply absent until then rather
- * than showing the middle of the ocean.
- */
-export function AddressMap({
- address,
- label,
- className,
-}: {
- address: AddressMapValue
- /** Names whose address the pin marks — a seller, a customer, a branch. */
- label?: string
- className?: string
-}) {
- const { t } = useTranslation()
- const { latitude, longitude } = address
-
- if (latitude == null || longitude == null) {
- return <p className="text-muted-foreground text-xs">{t('admin.address.not_located_yet')}</p>
- }
-
- return (
- <div className={className ?? 'h-40 overflow-hidden rounded-md border'}>
- <Suspense fallback={<div className="size-full animate-pulse bg-muted" />}>
- <LazyMap center={[longitude, latitude]} zoom={13}>
- <LazyMapControls />
- <LazyMapMarker longitude={longitude} latitude={latitude}>
- {/* The default pin; the tooltip names whose address it is. */}
- <LazyMarkerContent />
- {label && <LazyMarkerTooltip>{label}</LazyMarkerTooltip>}
- </LazyMapMarker>
- </LazyMap>
- </Suspense>
- </div>
- )
-}
diff --git a/packages/dashboard-ui/src/ui/map.tsx b/packages/dashboard-ui/src/ui/map.tsx
deleted file mode 100644
index 0783c95916..0000000000
--- a/packages/dashboard-ui/src/ui/map.tsx
+++ /dev/null
@@ -1,2110 +0,0 @@
-'use client'
-
-import type { MarkerOptions, PopupOptions } from 'maplibre-gl'
-import * as MapLibreGL from 'maplibre-gl'
-import 'maplibre-gl/dist/maplibre-gl.css'
-
-import type * as GeoJSON from 'geojson'
-// `?worker&url` hands the file to the bundler, which emits it as its own chunk
-// with the shared code it needs and gives back a same-origin URL.
-import workerUrl from 'maplibre-gl/dist/maplibre-gl-worker.mjs?worker&url'
-import {
- createContext,
- forwardRef,
- type ReactNode,
- useCallback,
- useContext,
- useEffect,
- useId,
- useImperativeHandle,
- useMemo,
- useRef,
- useState,
-} from 'react'
-import { createPortal } from 'react-dom'
-import { cn } from '../lib/utils'
-import { Loader2, Locate, Maximize, Minus, Plus, X } from '../spree/icons'
-
-// The worker ships in the package, so it is bundled and served from this
-// origin. The registry's default fetches it from unpkg at runtime, which means
-// executing third-party code the deploy never reviewed, a map that breaks when
-// that CDN is unreachable, and a CSP that has to allow it.
-if (typeof window !== 'undefined' && !MapLibreGL.getWorkerUrl()) {
- MapLibreGL.setWorkerUrl(workerUrl)
-}
-
-const defaultStyles = {
- dark: 'https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json',
- light: 'https://basemaps.cartocdn.com/gl/positron-gl-style/style.json',
-}
-
-// A tile-less, dependency-free style with a transparent background. Use it for
-// data visualizations (choropleths, world arcs, dot maps) where you draw your
-// own layers and don't need a street basemap. The easiest way to opt in is the
-// `blank` prop:
-// <Map blank>...</Map>
-// The transparent background lets the themed container show through.
-const blankMapStyle: MapLibreGL.StyleSpecification = {
- version: 8,
- sources: {},
- layers: [
- {
- id: 'background',
- type: 'background',
- paint: { 'background-color': 'rgba(0, 0, 0, 0)' },
- },
- ],
-}
-
-// Prevent equivalent inline style objects from triggering a full map style reload.
-function useStableValue<T>(value: T): T {
- const key = useMemo(() => JSON.stringify(value) ?? '', [value])
- // eslint-disable-next-line react-hooks/exhaustive-deps
- return useMemo(() => value, [key])
-}
-
-function mergeHoverPaint<T extends Record<string, unknown>>(
- paint: T,
- hoverPaint: T | undefined,
-): T {
- if (!hoverPaint) return paint
- const merged: Record<string, unknown> = { ...paint }
- for (const [key, hoverValue] of Object.entries(hoverPaint)) {
- if (hoverValue === undefined) continue
- const baseValue = merged[key]
- merged[key] =
- baseValue === undefined
- ? hoverValue
- : ['case', ['boolean', ['feature-state', 'hover'], false], hoverValue, baseValue]
- }
- return merged as T
-}
-
-type Theme = 'light' | 'dark'
-
-// Check the document for an explicit theme (works with next-themes, etc.).
-// Covers both `attribute="class"` (the default) and `attribute="data-theme"`.
-function getDocumentTheme(): Theme | null {
- if (typeof document === 'undefined') return null
- const root = document.documentElement
- if (root.classList.contains('dark')) return 'dark'
- if (root.classList.contains('light')) return 'light'
- const dataTheme = root.dataset.theme
- if (dataTheme === 'dark' || dataTheme === 'light') return dataTheme
- return null
-}
-
-// Get system preference
-function getSystemTheme(): Theme {
- if (typeof window === 'undefined') return 'light'
- return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
-}
-
-function useResolvedTheme(themeProp?: 'light' | 'dark'): Theme {
- const [detectedTheme, setDetectedTheme] = useState<Theme>(
- () => getDocumentTheme() ?? getSystemTheme(),
- )
-
- useEffect(() => {
- if (themeProp) return // Skip detection if theme is provided via prop
-
- // Watch for document theme changes (e.g., next-themes toggling the class
- // or the data-theme attribute).
- const observer = new MutationObserver(() => {
- const docTheme = getDocumentTheme()
- if (docTheme) {
- setDetectedTheme(docTheme)
- }
- })
- observer.observe(document.documentElement, {
- attributes: true,
- attributeFilter: ['class', 'data-theme'],
- })
-
- // Also watch for system preference changes
- const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)')
- const handleSystemChange = (e: MediaQueryListEvent) => {
- // Only use system preference if no document class is set
- if (!getDocumentTheme()) {
- setDetectedTheme(e.matches ? 'dark' : 'light')
- }
- }
- mediaQuery.addEventListener('change', handleSystemChange)
-
- return () => {
- observer.disconnect()
- mediaQuery.removeEventListener('change', handleSystemChange)
- }
- }, [themeProp])
-
- return themeProp ?? detectedTheme
-}
-
-type MapContextValue = {
- map: MapLibreGL.Map | null
- isLoaded: boolean
- resolvedTheme: Theme
-}
-
-const MapContext = createContext<MapContextValue | null>(null)
-
-function useMap() {
- const context = useContext(MapContext)
- if (!context) {
- throw new Error('useMap must be used within a Map component')
- }
- return context
-}
-
-/** Map viewport state */
-type MapViewport = {
- /** Center coordinates [longitude, latitude] */
- center: [number, number]
- /** Zoom level */
- zoom: number
- /** Bearing (rotation) in degrees */
- bearing: number
- /** Pitch (tilt) in degrees */
- pitch: number
-}
-
-type MapStyleOption = string | MapLibreGL.StyleSpecification
-
-type MapRef = MapLibreGL.Map
-
-type MapProps = {
- children?: ReactNode
- /** Additional CSS classes for the map container */
- className?: string
- /**
- * Theme for the map. If not provided, automatically detects system preference.
- * Pass your theme value here.
- */
- theme?: Theme
- /** Custom map styles for light and dark themes. Overrides the default Carto styles. */
- styles?: {
- light?: MapStyleOption
- dark?: MapStyleOption
- }
- /**
- * Use a transparent, tile-less basemap instead of the default Carto street
- * basemap — a blank canvas. Used alone it renders nothing; add your own
- * layers on top (`<MapGeoJSON>`, `<MapArc>`, markers, etc.). Ideal for data
- * visualizations (choropleths, arcs, dot maps).
- * Ignored when an explicit `styles` prop is provided.
- */
- blank?: boolean
- /** Map projection type. Use `{ type: "globe" }` for 3D globe view. */
- projection?: MapLibreGL.ProjectionSpecification
- /**
- * Controlled viewport. When provided with onViewportChange,
- * the map becomes controlled and viewport is driven by this prop.
- */
- viewport?: Partial<MapViewport>
- /**
- * Callback fired continuously as the viewport changes (pan, zoom, rotate, pitch).
- * Can be used standalone to observe changes, or with `viewport` prop
- * to enable controlled mode where the map viewport is driven by your state.
- */
- onViewportChange?: (viewport: MapViewport) => void
- /** Show a loading indicator on the map */
- loading?: boolean
-} & Omit<MapLibreGL.MapOptions, 'container' | 'style'>
-
-function DefaultLoader() {
- return (
- <div className="bg-background/50 absolute inset-0 z-10 flex items-center justify-center backdrop-blur-xs">
- <div className="flex gap-1">
- <span className="bg-muted-foreground/60 size-1.5 animate-pulse rounded-full" />
- <span className="bg-muted-foreground/60 size-1.5 animate-pulse rounded-full [animation-delay:150ms]" />
- <span className="bg-muted-foreground/60 size-1.5 animate-pulse rounded-full [animation-delay:300ms]" />
- </div>
- </div>
- )
-}
-
-function getViewport(map: MapLibreGL.Map): MapViewport {
- const center = map.getCenter()
- return {
- center: [center.lng, center.lat],
- zoom: map.getZoom(),
- bearing: map.getBearing(),
- pitch: map.getPitch(),
- }
-}
-
-const Map = forwardRef<MapRef, MapProps>(function Map(
- {
- children,
- className,
- theme: themeProp,
- styles,
- blank = false,
- projection,
- viewport,
- onViewportChange,
- loading = false,
- ...props
- },
- ref,
-) {
- const containerRef = useRef<HTMLDivElement>(null)
- const [mapInstance, setMapInstance] = useState<MapLibreGL.Map | null>(null)
- const [isLoaded, setIsLoaded] = useState(false)
- const [isStyleLoaded, setIsStyleLoaded] = useState(false)
- const [pendingStyle, setPendingStyle] = useState<MapStyleOption | null>(null)
- const currentStyleRef = useRef<MapStyleOption | null>(null)
- const styleSwapInFlightRef = useRef(false)
- const internalUpdateRef = useRef(false)
- const resolvedTheme = useResolvedTheme(themeProp)
-
- const isControlled = viewport !== undefined && onViewportChange !== undefined
-
- const onViewportChangeRef = useRef(onViewportChange)
- onViewportChangeRef.current = onViewportChange
-
- const stableStyles = useStableValue(styles)
-
- const mapStyles = useMemo(() => {
- // Explicit styles win. Otherwise `blank` opts into the transparent
- // tile-less basemap; with neither, fall back to the Carto defaults.
- if (stableStyles) {
- return {
- dark: stableStyles.dark ?? defaultStyles.dark,
- light: stableStyles.light ?? defaultStyles.light,
- }
- }
- if (blank) {
- return { dark: blankMapStyle, light: blankMapStyle }
- }
- return defaultStyles
- }, [stableStyles, blank])
-
- // Expose the map instance to the parent component
- useImperativeHandle(ref, () => mapInstance as MapLibreGL.Map, [mapInstance])
-
- // Initialize the map
- useEffect(() => {
- if (!containerRef.current) return
-
- const initialStyle = resolvedTheme === 'dark' ? mapStyles.dark : mapStyles.light
- currentStyleRef.current = initialStyle
-
- const map = new MapLibreGL.Map({
- container: containerRef.current,
- style: initialStyle,
- renderWorldCopies: false,
- attributionControl: {
- compact: true,
- },
- ...props,
- ...viewport,
- })
-
- const styleLoadHandler = () => {
- styleSwapInFlightRef.current = false
- setIsStyleLoaded(true)
- }
- const loadHandler = () => setIsLoaded(true)
-
- // Viewport change handler - skip if triggered by internal update
- const handleMove = () => {
- if (internalUpdateRef.current) return
- onViewportChangeRef.current?.(getViewport(map))
- }
-
- map.on('load', loadHandler)
- map.on('style.load', styleLoadHandler)
- map.on('move', handleMove)
- setMapInstance(map)
-
- return () => {
- map.off('load', loadHandler)
- map.off('style.load', styleLoadHandler)
- map.off('move', handleMove)
- map.remove()
- setIsLoaded(false)
- setIsStyleLoaded(false)
- setMapInstance(null)
- }
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [])
-
- // Sync controlled viewport to map
- useEffect(() => {
- if (!mapInstance || !isControlled || !viewport) return
- if (mapInstance.isMoving()) return
-
- const current = getViewport(mapInstance)
- const next = {
- center: viewport.center ?? current.center,
- zoom: viewport.zoom ?? current.zoom,
- bearing: viewport.bearing ?? current.bearing,
- pitch: viewport.pitch ?? current.pitch,
- }
-
- if (
- next.center[0] === current.center[0] &&
- next.center[1] === current.center[1] &&
- next.zoom === current.zoom &&
- next.bearing === current.bearing &&
- next.pitch === current.pitch
- ) {
- return
- }
-
- internalUpdateRef.current = true
- mapInstance.jumpTo(next)
- internalUpdateRef.current = false
- }, [mapInstance, isControlled, viewport])
-
- // Handle style change: close the gate (so layer children tear down and
- // re-add on the incoming style) - the swap itself is staged to the effect below.
- useEffect(() => {
- if (!mapInstance || !resolvedTheme) return
-
- const newStyle = resolvedTheme === 'dark' ? mapStyles.dark : mapStyles.light
-
- if (currentStyleRef.current === newStyle) return
-
- currentStyleRef.current = newStyle
- setIsStyleLoaded(false)
- setPendingStyle(newStyle)
- }, [mapInstance, resolvedTheme, mapStyles])
-
- useEffect(() => {
- if (!mapInstance || !pendingStyle) return
-
- setPendingStyle(null)
- styleSwapInFlightRef.current = true
- // Full reload (no diff) so `style.load` fires deterministically. A
- // successful diff would never fire it, leaving isStyleLoaded stuck false.
- mapInstance.setStyle(pendingStyle, { diff: false })
- }, [mapInstance, pendingStyle])
-
- // Sync projection when the prop changes after mount.
- useEffect(() => {
- if (!mapInstance || !isStyleLoaded || !projection) return
- if (styleSwapInFlightRef.current) return
- mapInstance.setProjection(projection)
- }, [mapInstance, isStyleLoaded, projection])
-
- const contextValue = useMemo(
- () => ({
- map: mapInstance,
- isLoaded: isLoaded && isStyleLoaded,
- resolvedTheme,
- }),
- [mapInstance, isLoaded, isStyleLoaded, resolvedTheme],
- )
-
- return (
- <MapContext.Provider value={contextValue}>
- <div ref={containerRef} className={cn('relative h-full w-full', className)}>
- {(!isLoaded || loading) && <DefaultLoader />}
- {/* SSR-safe: children render only when map is loaded on client */}
- {mapInstance && children}
- </div>
- </MapContext.Provider>
- )
-})
-
-type MarkerContextValue = {
- marker: MapLibreGL.Marker
- map: MapLibreGL.Map | null
-}
-
-const MarkerContext = createContext<MarkerContextValue | null>(null)
-
-function useMarkerContext() {
- const context = useContext(MarkerContext)
- if (!context) {
- throw new Error('Marker components must be used within MapMarker')
- }
- return context
-}
-
-type MapMarkerProps = {
- /** Longitude coordinate for marker position */
- longitude: number
- /** Latitude coordinate for marker position */
- latitude: number
- /** Marker subcomponents (MarkerContent, MarkerPopup, MarkerTooltip, MarkerLabel) */
- children: ReactNode
- /** Callback when marker is clicked */
- onClick?: (e: MouseEvent) => void
- /** Callback when mouse enters marker */
- onMouseEnter?: (e: MouseEvent) => void
- /** Callback when mouse leaves marker */
- onMouseLeave?: (e: MouseEvent) => void
- /** Callback when marker drag starts (requires draggable: true) */
- onDragStart?: (lngLat: { lng: number; lat: number }) => void
- /** Callback during marker drag (requires draggable: true) */
- onDrag?: (lngLat: { lng: number; lat: number }) => void
- /** Callback when marker drag ends (requires draggable: true) */
- onDragEnd?: (lngLat: { lng: number; lat: number }) => void
-} & Omit<MarkerOptions, 'element'>
-
-function MapMarker({
- longitude,
- latitude,
- children,
- onClick,
- onMouseEnter,
- onMouseLeave,
- onDragStart,
- onDrag,
- onDragEnd,
- draggable = false,
- ...markerOptions
-}: MapMarkerProps) {
- const { map } = useMap()
-
- const callbacksRef = useRef({
- onClick,
- onMouseEnter,
- onMouseLeave,
- onDragStart,
- onDrag,
- onDragEnd,
- })
- callbacksRef.current = {
- onClick,
- onMouseEnter,
- onMouseLeave,
- onDragStart,
- onDrag,
- onDragEnd,
- }
-
- const marker = useMemo(() => {
- const markerInstance = new MapLibreGL.Marker({
- ...markerOptions,
- element: document.createElement('div'),
- draggable,
- }).setLngLat([longitude, latitude])
-
- const handleClick = (e: MouseEvent) => callbacksRef.current.onClick?.(e)
- const handleMouseEnter = (e: MouseEvent) => callbacksRef.current.onMouseEnter?.(e)
- const handleMouseLeave = (e: MouseEvent) => callbacksRef.current.onMouseLeave?.(e)
-
- markerInstance.getElement()?.addEventListener('click', handleClick)
- markerInstance.getElement()?.addEventListener('mouseenter', handleMouseEnter)
- markerInstance.getElement()?.addEventListener('mouseleave', handleMouseLeave)
-
- const handleDragStart = () => {
- const lngLat = markerInstance.getLngLat()
- callbacksRef.current.onDragStart?.({ lng: lngLat.lng, lat: lngLat.lat })
- }
- const handleDrag = () => {
- const lngLat = markerInstance.getLngLat()
- callbacksRef.current.onDrag?.({ lng: lngLat.lng, lat: lngLat.lat })
- }
- const handleDragEnd = () => {
- const lngLat = markerInstance.getLngLat()
- callbacksRef.current.onDragEnd?.({ lng: lngLat.lng, lat: lngLat.lat })
- }
-
- markerInstance.on('dragstart', handleDragStart)
- markerInstance.on('drag', handleDrag)
- markerInstance.on('dragend', handleDragEnd)
-
- return markerInstance
-
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [])
-
- useEffect(() => {
- if (!map) return
-
- marker.addTo(map)
-
- return () => {
- marker.remove()
- }
-
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [map])
-
- const { offset, rotation, rotationAlignment, pitchAlignment } = markerOptions
-
- useEffect(() => {
- const current = marker.getLngLat()
- if (current.lng !== longitude || current.lat !== latitude) {
- marker.setLngLat([longitude, latitude])
- }
-
- if (marker.isDraggable() !== draggable) {
- marker.setDraggable(draggable)
- }
-
- const currentOffset = marker.getOffset()
- const newOffset = offset ?? [0, 0]
- const [newOffsetX, newOffsetY] = Array.isArray(newOffset)
- ? newOffset
- : [newOffset.x, newOffset.y]
- if (currentOffset.x !== newOffsetX || currentOffset.y !== newOffsetY) {
- marker.setOffset(newOffset)
- }
-
- if (marker.getRotation() !== (rotation ?? 0)) {
- marker.setRotation(rotation ?? 0)
- }
- if (marker.getRotationAlignment() !== (rotationAlignment ?? 'auto')) {
- marker.setRotationAlignment(rotationAlignment ?? 'auto')
- }
- if (marker.getPitchAlignment() !== (pitchAlignment ?? 'auto')) {
- marker.setPitchAlignment(pitchAlignment ?? 'auto')
- }
- }, [marker, longitude, latitude, draggable, offset, rotation, rotationAlignment, pitchAlignment])
-
- return <MarkerContext.Provider value={{ marker, map }}>{children}</MarkerContext.Provider>
-}
-
-type MarkerContentProps = {
- /** Custom marker content. Defaults to a blue dot if not provided */
- children?: ReactNode
- /** Additional CSS classes for the marker container */
- className?: string
-}
-
-function MarkerContent({ children, className }: MarkerContentProps) {
- const { marker } = useMarkerContext()
-
- return createPortal(
- <div className={cn('relative cursor-pointer', className)}>
- {children || <DefaultMarkerIcon />}
- </div>,
- marker.getElement(),
- )
-}
-
-function DefaultMarkerIcon() {
- return (
- <div className="relative h-4 w-4 rounded-full border-2 border-white bg-blue-500 shadow-lg" />
- )
-}
-
-function PopupCloseButton({ onClick }: { onClick: () => void }) {
- return (
- <button
- type="button"
- onClick={onClick}
- aria-label="Close popup"
- className="focus-visible:ring-ring hover:bg-accent text-foreground absolute top-1 right-1 z-10 inline-flex size-5 cursor-pointer items-center justify-center rounded-sm transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-inset"
- >
- <X className="size-3.5" />
- </button>
- )
-}
-
-type MarkerPopupProps = {
- /** Popup content */
- children: ReactNode
- /** Additional CSS classes for the popup container */
- className?: string
- /** Show a close button in the popup (default: false) */
- closeButton?: boolean
-} & Omit<PopupOptions, 'className' | 'closeButton'>
-
-function MarkerPopup({
- children,
- className,
- closeButton = false,
- ...popupOptions
-}: MarkerPopupProps) {
- const { marker, map } = useMarkerContext()
- const container = useMemo(() => document.createElement('div'), [])
- const { offset, maxWidth } = popupOptions
-
- const popup = useMemo(() => {
- const popupInstance = new MapLibreGL.Popup({
- offset: 16,
- ...popupOptions,
- closeButton: false,
- })
- .setMaxWidth('none')
- .setDOMContent(container)
-
- return popupInstance
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [])
-
- useEffect(() => {
- if (!map) return
-
- popup.setDOMContent(container)
- marker.setPopup(popup)
-
- return () => {
- marker.setPopup(null)
- }
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [map])
-
- // Sync popup options when they change.
- useEffect(() => {
- popup.setOffset(offset ?? 16)
- if (maxWidth) {
- popup.setMaxWidth(maxWidth)
- }
- }, [popup, offset, maxWidth])
-
- const handleClose = () => popup.remove()
-
- return createPortal(
- <div
- className={cn(
- 'bg-popover text-popover-foreground relative max-w-62 rounded-md border p-3 shadow-md',
- 'animate-in fade-in-0 zoom-in-95 duration-200 ease-out',
- className,
- )}
- >
- {closeButton && <PopupCloseButton onClick={handleClose} />}
- {children}
- </div>,
- container,
- )
-}
-
-type MarkerTooltipProps = {
- /** Tooltip content */
- children: ReactNode
- /** Additional CSS classes for the tooltip container */
- className?: string
-} & Omit<PopupOptions, 'className' | 'closeButton' | 'closeOnClick'>
-
-function MarkerTooltip({ children, className, ...popupOptions }: MarkerTooltipProps) {
- const { marker, map } = useMarkerContext()
- const container = useMemo(() => document.createElement('div'), [])
- const { offset, maxWidth } = popupOptions
-
- const tooltip = useMemo(() => {
- const tooltipInstance = new MapLibreGL.Popup({
- offset: 16,
- ...popupOptions,
- closeOnClick: true,
- closeButton: false,
- }).setMaxWidth('none')
-
- return tooltipInstance
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [])
-
- useEffect(() => {
- if (!map) return
-
- tooltip.setDOMContent(container)
-
- const handleMouseEnter = () => {
- tooltip.setLngLat(marker.getLngLat()).addTo(map)
- }
- const handleMouseLeave = () => tooltip.remove()
-
- marker.getElement()?.addEventListener('mouseenter', handleMouseEnter)
- marker.getElement()?.addEventListener('mouseleave', handleMouseLeave)
-
- return () => {
- marker.getElement()?.removeEventListener('mouseenter', handleMouseEnter)
- marker.getElement()?.removeEventListener('mouseleave', handleMouseLeave)
- tooltip.remove()
- }
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [map])
-
- // Sync tooltip options when they change.
- useEffect(() => {
- tooltip.setOffset(offset ?? 16)
- if (maxWidth) {
- tooltip.setMaxWidth(maxWidth)
- }
- }, [tooltip, offset, maxWidth])
-
- return createPortal(
- <div
- className={cn(
- 'bg-foreground text-background pointer-events-none rounded-md px-2 py-1 text-xs text-balance shadow-md',
- 'animate-in fade-in-0 zoom-in-95 duration-200 ease-out',
- className,
- )}
- >
- {children}
- </div>,
- container,
- )
-}
-
-type MarkerLabelProps = {
- /** Label text content */
- children: ReactNode
- /** Additional CSS classes for the label */
- className?: string
- /** Position of the label relative to the marker (default: "top") */
- position?: 'top' | 'bottom'
-}
-
-function MarkerLabel({ children, className, position = 'top' }: MarkerLabelProps) {
- const positionClasses = {
- top: 'bottom-full mb-1',
- bottom: 'top-full mt-1',
- }
-
- return (
- <div
- className={cn(
- 'absolute left-1/2 -translate-x-1/2 whitespace-nowrap',
- 'text-foreground text-[10px] font-medium',
- positionClasses[position],
- className,
- )}
- >
- {children}
- </div>
- )
-}
-
-type MapControlsProps = {
- /** Position of the controls on the map (default: "bottom-right") */
- position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'
- /** Show zoom in/out buttons (default: true) */
- showZoom?: boolean
- /** Show compass button to reset bearing (default: false) */
- showCompass?: boolean
- /** Show locate button to find user's location (default: false) */
- showLocate?: boolean
- /** Show fullscreen toggle button (default: false) */
- showFullscreen?: boolean
- /** Additional CSS classes for the controls container */
- className?: string
- /** Callback with user coordinates when located */
- onLocate?: (coords: { longitude: number; latitude: number }) => void
-}
-
-const positionClasses = {
- 'top-left': 'top-2 left-2',
- 'top-right': 'top-2 right-2',
- 'bottom-left': 'bottom-2 left-2',
- 'bottom-right': 'bottom-10 right-2',
-}
-
-function ControlGroup({ children }: { children: React.ReactNode }) {
- return (
- <div className="border-border bg-background [&>button:not(:last-child)]:border-border flex flex-col overflow-hidden rounded-md border shadow-sm [&>button:not(:last-child)]:border-b">
- {children}
- </div>
- )
-}
-
-function ControlButton({
- onClick,
- label,
- children,
- disabled = false,
-}: {
- onClick: () => void
- label: string
- children: React.ReactNode
- disabled?: boolean
-}) {
- return (
- <button
- onClick={onClick}
- aria-label={label}
- type="button"
- className={cn(
- 'flex size-8 items-center justify-center transition-colors',
- 'first:rounded-t-md last:rounded-b-md',
- 'hover:bg-accent dark:hover:bg-accent/40',
- 'focus-visible:ring-ring focus-visible:ring-2 focus-visible:outline-none focus-visible:ring-inset',
- 'disabled:pointer-events-none disabled:opacity-50',
- )}
- disabled={disabled}
- >
- {children}
- </button>
- )
-}
-
-function MapControls({
- position = 'bottom-right',
- showZoom = true,
- showCompass = false,
- showLocate = false,
- showFullscreen = false,
- className,
- onLocate,
-}: MapControlsProps) {
- const { map } = useMap()
- const [waitingForLocation, setWaitingForLocation] = useState(false)
-
- const handleZoomIn = useCallback(() => {
- map?.zoomTo(map.getZoom() + 1, { duration: 300 })
- }, [map])
-
- const handleZoomOut = useCallback(() => {
- map?.zoomTo(map.getZoom() - 1, { duration: 300 })
- }, [map])
-
- const handleResetBearing = useCallback(() => {
- map?.resetNorthPitch({ duration: 300 })
- }, [map])
-
- const handleLocate = useCallback(() => {
- if (!('geolocation' in navigator)) return
- setWaitingForLocation(true)
- navigator.geolocation.getCurrentPosition(
- (pos) => {
- const coords = {
- longitude: pos.coords.longitude,
- latitude: pos.coords.latitude,
- }
- map?.flyTo({
- center: [coords.longitude, coords.latitude],
- zoom: 14,
- duration: 1500,
- })
- onLocate?.(coords)
- setWaitingForLocation(false)
- },
- (error) => {
- console.error('Error getting location:', error)
- setWaitingForLocation(false)
- },
- // Without a timeout the spec default is Infinity: a dismissed permission
- // prompt would leave the button disabled forever.
- { timeout: 10000 },
- )
- }, [map, onLocate])
-
- const handleFullscreen = useCallback(() => {
- const container = map?.getContainer()
- if (!container) return
- if (document.fullscreenElement) {
- document.exitFullscreen()
- } else {
- container.requestFullscreen()
- }
- }, [map])
-
- return (
- <div
- className={cn('absolute z-10 flex flex-col gap-1.5', positionClasses[position], className)}
- >
- {showZoom && (
- <ControlGroup>
- <ControlButton onClick={handleZoomIn} label="Zoom in">
- <Plus className="size-4" />
- </ControlButton>
- <ControlButton onClick={handleZoomOut} label="Zoom out">
- <Minus className="size-4" />
- </ControlButton>
- </ControlGroup>
- )}
- {showCompass && (
- <ControlGroup>
- <CompassButton onClick={handleResetBearing} />
- </ControlGroup>
- )}
- {showLocate && (
- <ControlGroup>
- <ControlButton
- onClick={handleLocate}
- label="Find my location"
- disabled={waitingForLocation}
- >
- {waitingForLocation ? (
- <Loader2 className="size-4 animate-spin" />
- ) : (
- <Locate className="size-4" />
- )}
- </ControlButton>
- </ControlGroup>
- )}
- {showFullscreen && (
- <ControlGroup>
- <ControlButton onClick={handleFullscreen} label="Toggle fullscreen">
- <Maximize className="size-4" />
- </ControlButton>
- </ControlGroup>
- )}
- </div>
- )
-}
-
-function CompassButton({ onClick }: { onClick: () => void }) {
- const { map } = useMap()
- const compassRef = useRef<SVGSVGElement>(null)
-
- useEffect(() => {
- if (!map || !compassRef.current) return
-
- const compass = compassRef.current
-
- const updateRotation = () => {
- const bearing = map.getBearing()
- const pitch = map.getPitch()
- compass.style.transform = `rotateX(${pitch}deg) rotateZ(${-bearing}deg)`
- }
-
- map.on('rotate', updateRotation)
- map.on('pitch', updateRotation)
- updateRotation()
-
- return () => {
- map.off('rotate', updateRotation)
- map.off('pitch', updateRotation)
- }
- }, [map])
-
- return (
- <ControlButton onClick={onClick} label="Reset bearing to north">
- <svg
- ref={compassRef}
- viewBox="0 0 24 24"
- className="size-5"
- style={{ transformStyle: 'preserve-3d' }}
- >
- <path d="M12 2L16 12H12V2Z" className="fill-red-500" />
- <path d="M12 2L8 12H12V2Z" className="fill-red-300" />
- <path d="M12 22L16 12H12V22Z" className="fill-muted-foreground/60" />
- <path d="M12 22L8 12H12V22Z" className="fill-muted-foreground/30" />
- </svg>
- </ControlButton>
- )
-}
-
-type MapPopupProps = {
- /** Longitude coordinate for popup position */
- longitude: number
- /** Latitude coordinate for popup position */
- latitude: number
- /** Callback when popup is closed */
- onClose?: () => void
- /** Popup content */
- children: ReactNode
- /** Additional CSS classes for the popup container */
- className?: string
- /** Show a close button in the popup (default: false) */
- closeButton?: boolean
-} & Omit<PopupOptions, 'className' | 'closeButton'>
-
-function MapPopup({
- longitude,
- latitude,
- onClose,
- children,
- className,
- closeButton = false,
- ...popupOptions
-}: MapPopupProps) {
- const { map } = useMap()
- const onCloseRef = useRef(onClose)
- onCloseRef.current = onClose
- const container = useMemo(() => document.createElement('div'), [])
- const { offset, maxWidth } = popupOptions
-
- const popup = useMemo(() => {
- const popupInstance = new MapLibreGL.Popup({
- offset: 16,
- ...popupOptions,
- closeButton: false,
- })
- .setMaxWidth('none')
- .setLngLat([longitude, latitude])
-
- return popupInstance
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [])
-
- useEffect(() => {
- if (!map) return
-
- const onCloseProp = () => onCloseRef.current?.()
-
- popup.on('close', onCloseProp)
-
- popup.setDOMContent(container)
- popup.addTo(map)
-
- return () => {
- popup.off('close', onCloseProp)
- if (popup.isOpen()) {
- popup.remove()
- }
- }
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [map])
-
- // Sync popup position and options when they change.
- useEffect(() => {
- const current = popup.getLngLat()
- if (!current || current.lng !== longitude || current.lat !== latitude) {
- popup.setLngLat([longitude, latitude])
- }
- popup.setOffset(offset ?? 16)
- if (maxWidth) {
- popup.setMaxWidth(maxWidth)
- }
- }, [popup, longitude, latitude, offset, maxWidth])
-
- const handleClose = () => {
- popup.remove()
- }
-
- return createPortal(
- <div
- className={cn(
- 'bg-popover text-popover-foreground relative max-w-62 rounded-md border p-3 shadow-md',
- 'animate-in fade-in-0 zoom-in-95 duration-200 ease-out',
- className,
- )}
- >
- {closeButton && <PopupCloseButton onClick={handleClose} />}
- {children}
- </div>,
- container,
- )
-}
-
-type MapRouteProps = {
- /** Optional unique identifier for the route layer */
- id?: string
- /** Array of [longitude, latitude] coordinate pairs defining the route */
- coordinates: [number, number][]
- /** Line color as CSS color value (default: "#4285F4") */
- color?: string
- /** Line width in pixels (default: 3) */
- width?: number
- /** Line opacity from 0 to 1 (default: 0.8) */
- opacity?: number
- /** Dash pattern [dash length, gap length] for dashed lines */
- dashArray?: [number, number]
- /** Callback when the route line is clicked */
- onClick?: () => void
- /** Callback when mouse enters the route line */
- onMouseEnter?: () => void
- /** Callback when mouse leaves the route line */
- onMouseLeave?: () => void
- /** Whether the route is interactive - shows pointer cursor on hover (default: true) */
- interactive?: boolean
-}
-
-function MapRoute({
- id: propId,
- coordinates,
- color = '#4285F4',
- width = 3,
- opacity = 0.8,
- dashArray,
- onClick,
- onMouseEnter,
- onMouseLeave,
- interactive = true,
-}: MapRouteProps) {
- const { map, isLoaded } = useMap()
- const autoId = useId()
- const id = propId ?? autoId
- const sourceId = `route-source-${id}`
- const layerId = `route-layer-${id}`
-
- // Add source and layer on mount
- useEffect(() => {
- if (!isLoaded || !map) return
-
- map.addSource(sourceId, {
- type: 'geojson',
- data: {
- type: 'Feature',
- properties: {},
- geometry: { type: 'LineString', coordinates: [] },
- },
- })
-
- map.addLayer({
- id: layerId,
- type: 'line',
- source: sourceId,
- layout: { 'line-join': 'round', 'line-cap': 'round' },
- paint: {
- 'line-color': color,
- 'line-width': width,
- 'line-opacity': opacity,
- ...(dashArray && { 'line-dasharray': dashArray }),
- },
- })
-
- return () => {
- try {
- if (map.getLayer(layerId)) map.removeLayer(layerId)
- if (map.getSource(sourceId)) map.removeSource(sourceId)
- } catch {
- // ignore
- }
- }
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [isLoaded, map])
-
- // When coordinates change, update the source data
- useEffect(() => {
- if (!isLoaded || !map || coordinates.length < 2) return
-
- const source = map.getSource(sourceId) as MapLibreGL.GeoJSONSource
- if (source) {
- source.setData({
- type: 'Feature',
- properties: {},
- geometry: { type: 'LineString', coordinates },
- })
- }
- }, [isLoaded, map, coordinates, sourceId])
-
- useEffect(() => {
- if (!isLoaded || !map || !map.getLayer(layerId)) return
-
- map.setPaintProperty(layerId, 'line-color', color)
- map.setPaintProperty(layerId, 'line-width', width)
- map.setPaintProperty(layerId, 'line-opacity', opacity)
- map.setPaintProperty(layerId, 'line-dasharray', dashArray)
- }, [isLoaded, map, layerId, color, width, opacity, dashArray])
-
- // Handle click and hover events
- useEffect(() => {
- if (!isLoaded || !map || !interactive) return
-
- const handleClick = () => {
- onClick?.()
- }
- const handleMouseEnter = () => {
- map.getCanvas().style.cursor = 'pointer'
- onMouseEnter?.()
- }
- const handleMouseLeave = () => {
- map.getCanvas().style.cursor = ''
- onMouseLeave?.()
- }
-
- map.on('click', layerId, handleClick)
- map.on('mouseenter', layerId, handleMouseEnter)
- map.on('mouseleave', layerId, handleMouseLeave)
-
- return () => {
- map.off('click', layerId, handleClick)
- map.off('mouseenter', layerId, handleMouseEnter)
- map.off('mouseleave', layerId, handleMouseLeave)
- }
- }, [isLoaded, map, layerId, onClick, onMouseEnter, onMouseLeave, interactive])
-
- return null
-}
-
-type MapGeoJSONData<P extends GeoJSON.GeoJsonProperties = GeoJSON.GeoJsonProperties> =
- | GeoJSON.FeatureCollection<GeoJSON.Geometry, P>
- | GeoJSON.Feature<GeoJSON.Geometry, P>
- | GeoJSON.Geometry
- | string
-
-type MapFillPaint = NonNullable<MapLibreGL.FillLayerSpecification['paint']>
-type MapLinePaint = NonNullable<MapLibreGL.LineLayerSpecification['paint']>
-
-/** A rendered feature with strongly-typed `properties`. */
-type MapGeoJSONFeature<P extends GeoJSON.GeoJsonProperties = GeoJSON.GeoJsonProperties> = Omit<
- MapLibreGL.MapGeoJSONFeature,
- 'properties'
-> & { properties: P }
-
-/** Event payload passed to MapGeoJSON interaction callbacks. */
-type MapGeoJSONEvent<P extends GeoJSON.GeoJsonProperties = GeoJSON.GeoJsonProperties> = {
- /** The feature under the cursor, with its typed GeoJSON properties. */
- feature: MapGeoJSONFeature<P>
- /** Longitude of the cursor at the time of the event. */
- longitude: number
- /** Latitude of the cursor at the time of the event. */
- latitude: number
- /** The underlying MapLibre mouse event for advanced use cases. */
- originalEvent: MapLibreGL.MapLayerMouseEvent
-}
-
-type MapGeoJSONProps<P extends GeoJSON.GeoJsonProperties = GeoJSON.GeoJsonProperties> = {
- /** GeoJSON data (FeatureCollection, Feature, Geometry) or a URL to fetch it from. */
- data: MapGeoJSONData<P>
- /** Optional unique identifier prefix for the source/layers. Auto-generated if not provided. */
- id?: string
- /**
- * Feature property to promote to the feature `id`. Required for hover
- * feature-state (`fillHoverPaint`) and stable `onHover`/`onClick` payloads.
- */
- promoteId?: string
- /**
- * Paint for the polygon fill layer. Merged on top of a theme-aware monochrome
- * surface tone (`fill-color`). Pass `false` to omit the fill layer entirely
- * (e.g. outlines only).
- */
- fillPaint?: MapFillPaint | false
- /**
- * Paint for the outline layer. Merged on top of a hairline default
- * (`line-color` = a near-surface neutral, `line-width` = 0.5) for thin
- * separators. Override `line-color` if your container differs, or pass
- * `false` to omit the layer.
- */
- linePaint?: MapLinePaint | false
- /**
- * Paint merged onto the fill layer for the feature under the cursor, applied
- * as a `case` expression keyed on hover feature-state. Requires `promoteId`.
- */
- fillHoverPaint?: MapFillPaint
- /** Callback when a feature is clicked. */
- onClick?: (e: MapGeoJSONEvent<P>) => void
- /** Callback fired when the hovered feature changes; `null` when the cursor leaves. */
- onHover?: (e: MapGeoJSONEvent<P> | null) => void
- /** Whether features respond to mouse events (default: false). */
- interactive?: boolean
- /** Optional MapLibre layer id to insert the layers before (z-order control). */
- beforeId?: string
-}
-
-// Monochrome defaults: a neutral-gray fill (hex of the grayscale chart tokens)
-// with a fixed near-surface line for thin separators. Colors are hardcoded (not
-// theme tokens), tuned for a typical light/dark surface. Override via
-// `fillPaint` / `linePaint`.
-const GEOJSON_DEFAULT_COLORS = {
- light: { fill: '#d4d4d4', line: '#ffffff' },
- dark: { fill: '#404040', line: '#171717' },
-} satisfies Record<Theme, { fill: string; line: string }>
-
-/**
- * Renders arbitrary GeoJSON as fill + outline layers on the map. Composes like
- * `MapRoute` / `MapArc` — drop it inside `<Map>` (typically with `blank`) for
- * choropleths and region/data maps. For full control over expressions and
- * multiple layers, manage layers directly via `useMap()` instead.
- */
-function MapGeoJSON<P extends GeoJSON.GeoJsonProperties = GeoJSON.GeoJsonProperties>({
- data,
- id: propId,
- promoteId,
- fillPaint,
- linePaint,
- fillHoverPaint,
- onClick,
- onHover,
- interactive = false,
- beforeId,
-}: MapGeoJSONProps<P>) {
- const { map, isLoaded, resolvedTheme } = useMap()
- const autoId = useId()
- const id = propId ?? autoId
- const sourceId = `geojson-source-${id}`
- const fillLayerId = `geojson-fill-${id}`
- const lineLayerId = `geojson-line-${id}`
-
- const defaults = GEOJSON_DEFAULT_COLORS[resolvedTheme]
-
- const showFill = fillPaint !== false
- const showLine = linePaint !== false
-
- const mergedFillPaint = useMemo(
- () => mergeHoverPaint({ 'fill-color': defaults.fill, ...(fillPaint || {}) }, fillHoverPaint),
- [defaults.fill, fillPaint, fillHoverPaint],
- )
- const mergedLinePaint = useMemo(
- () => ({
- 'line-color': defaults.line,
- 'line-width': 0.5,
- ...(linePaint || {}),
- }),
- [defaults.line, linePaint],
- )
- const latestRef = useRef({ onClick, onHover })
- latestRef.current = { onClick, onHover }
-
- // Add source on mount.
- useEffect(() => {
- if (!isLoaded || !map) return
-
- map.addSource(sourceId, {
- type: 'geojson',
- data,
- ...(promoteId ? { promoteId } : {}),
- })
-
- return () => {
- try {
- if (map.getLayer(lineLayerId)) map.removeLayer(lineLayerId)
- if (map.getLayer(fillLayerId)) map.removeLayer(fillLayerId)
- if (map.getSource(sourceId)) map.removeSource(sourceId)
- } catch {
- // style may be mid-reload
- }
- }
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [isLoaded, map])
-
- // Sync data when it changes.
- useEffect(() => {
- if (!isLoaded || !map) return
- const source = map.getSource(sourceId) as MapLibreGL.GeoJSONSource | undefined
- source?.setData(data as never)
- }, [isLoaded, map, data, sourceId])
-
- // Sync layers and paint when visibility or styling changes.
- useEffect(() => {
- if (!isLoaded || !map) return
-
- const source = map.getSource(sourceId)
- if (!source) return
-
- if (showFill && !map.getLayer(fillLayerId)) {
- map.addLayer(
- {
- id: fillLayerId,
- type: 'fill',
- source: sourceId,
- paint: mergedFillPaint,
- },
- beforeId,
- )
- } else if (!showFill && map.getLayer(fillLayerId)) {
- map.removeLayer(fillLayerId)
- }
-
- if (showLine && !map.getLayer(lineLayerId)) {
- map.addLayer(
- {
- id: lineLayerId,
- type: 'line',
- source: sourceId,
- paint: mergedLinePaint,
- },
- beforeId,
- )
- } else if (!showLine && map.getLayer(lineLayerId)) {
- map.removeLayer(lineLayerId)
- }
-
- if (showFill && map.getLayer(fillLayerId)) {
- for (const [key, value] of Object.entries(mergedFillPaint)) {
- map.setPaintProperty(fillLayerId, key as keyof MapFillPaint, value as never)
- }
- }
- if (showLine && map.getLayer(lineLayerId)) {
- for (const [key, value] of Object.entries(mergedLinePaint)) {
- map.setPaintProperty(lineLayerId, key as keyof MapLinePaint, value as never)
- }
- }
- }, [
- isLoaded,
- map,
- sourceId,
- fillLayerId,
- lineLayerId,
- showFill,
- showLine,
- mergedFillPaint,
- mergedLinePaint,
- beforeId,
- ])
-
- // Interaction handlers (bound to the fill layer).
- useEffect(() => {
- if (!isLoaded || !map || !interactive || !showFill) return
-
- let hoveredId: string | number | null = null
-
- const setHover = (next: string | number | null) => {
- if (next === hoveredId) return
- const sourceExists = !!map.getSource(sourceId)
- if (hoveredId != null && sourceExists) {
- map.setFeatureState({ source: sourceId, id: hoveredId }, { hover: false })
- }
- hoveredId = next
- if (next != null && sourceExists) {
- map.setFeatureState({ source: sourceId, id: next }, { hover: true })
- }
- }
-
- const handleMouseMove = (e: MapLibreGL.MapLayerMouseEvent) => {
- const feature = e.features?.[0]
- if (!feature) return
- map.getCanvas().style.cursor = 'pointer'
-
- const featureId = feature.id
- if (featureId === hoveredId) return
- setHover(featureId ?? null)
- latestRef.current.onHover?.({
- feature: feature as unknown as MapGeoJSONFeature<P>,
- longitude: e.lngLat.lng,
- latitude: e.lngLat.lat,
- originalEvent: e,
- })
- }
-
- const handleMouseLeave = () => {
- setHover(null)
- map.getCanvas().style.cursor = ''
- latestRef.current.onHover?.(null)
- }
-
- const handleClick = (e: MapLibreGL.MapLayerMouseEvent) => {
- const feature = e.features?.[0]
- if (!feature) return
- latestRef.current.onClick?.({
- feature: feature as unknown as MapGeoJSONFeature<P>,
- longitude: e.lngLat.lng,
- latitude: e.lngLat.lat,
- originalEvent: e,
- })
- }
-
- map.on('mousemove', fillLayerId, handleMouseMove)
- map.on('mouseleave', fillLayerId, handleMouseLeave)
- map.on('click', fillLayerId, handleClick)
-
- return () => {
- map.off('mousemove', fillLayerId, handleMouseMove)
- map.off('mouseleave', fillLayerId, handleMouseLeave)
- map.off('click', fillLayerId, handleClick)
- setHover(null)
- map.getCanvas().style.cursor = ''
- }
- }, [isLoaded, map, fillLayerId, sourceId, interactive, showFill])
-
- return null
-}
-
-/** A single arc to render inside <MapArc data={...}>. */
-type MapArcDatum = {
- /** Unique identifier for this arc. Required for hover state tracking and event payloads. */
- id: string | number
- /** Start coordinate as [longitude, latitude]. */
- from: [number, number]
- /** End coordinate as [longitude, latitude]. */
- to: [number, number]
-}
-
-/** Event payload passed to MapArc interaction callbacks. */
-type MapArcEvent<T extends MapArcDatum = MapArcDatum> = {
- /** The arc datum that was hovered or clicked. */
- arc: T
- /** Longitude of the cursor at the time of the event. */
- longitude: number
- /** Latitude of the cursor at the time of the event. */
- latitude: number
- /** The underlying MapLibre mouse event for advanced use cases. */
- originalEvent: MapLibreGL.MapMouseEvent
-}
-
-type MapArcLinePaint = NonNullable<MapLibreGL.LineLayerSpecification['paint']>
-type MapArcLineLayout = NonNullable<MapLibreGL.LineLayerSpecification['layout']>
-
-type MapArcProps<T extends MapArcDatum = MapArcDatum> = {
- /** Array of arcs to render. Each arc must have a unique `id`. */
- data: T[]
- /** Optional unique identifier prefix for the arc source/layers. Auto-generated if not provided. */
- id?: string
- /**
- * How far each arc bows away from a straight line. `0` renders straight
- * lines; higher values bend further. Negative values bend to the opposite
- * side. Arcs are computed as a quadratic Bézier in lng/lat space; the
- * destination longitude is unwrapped relative to the origin so that arcs
- * cross the antimeridian via the shorter great-circle direction. (default: 0.2)
- */
- curvature?: number
- /** Number of samples used to render each curve. Higher = smoother. (default: 64) */
- samples?: number
- /**
- * MapLibre paint properties for the arc layer. Merged on top of sensible
- * defaults (`line-color: #4285F4`, `line-width: 2`, `line-opacity: 0.85`).
- * Any value can be a MapLibre expression for per-feature styling, every
- * field on each arc datum (besides `from`/`to`) is exposed via `["get", ...]`.
- */
- paint?: MapArcLinePaint
- /** MapLibre layout properties for the arc layer. Defaults to rounded joins/caps. */
- layout?: MapArcLineLayout
- /**
- * Paint properties applied to the arc currently under the cursor. Each key
- * is merged into `paint` as a `case` expression keyed on per-feature hover
- * state, so only the hovered arc changes appearance.
- */
- hoverPaint?: MapArcLinePaint
- /** Callback when an arc is clicked. */
- onClick?: (e: MapArcEvent<T>) => void
- /**
- * Callback fired when the hovered arc changes. Receives the cursor's
- * lng/lat at the moment of entry, and `null` when the cursor leaves the
- * last hovered arc.
- */
- onHover?: (e: MapArcEvent<T> | null) => void
- /** Whether arcs respond to mouse events (default: true). */
- interactive?: boolean
- /** Optional MapLibre layer id to insert the arc layers before (z-order control). */
- beforeId?: string
-}
-
-const DEFAULT_ARC_CURVATURE = 0.2
-const DEFAULT_ARC_SAMPLES = 64
-const ARC_HIT_MIN_WIDTH = 12
-const ARC_HIT_PADDING = 6
-
-const DEFAULT_ARC_PAINT: MapArcLinePaint = {
- 'line-color': '#4285F4',
- 'line-width': 2,
- 'line-opacity': 0.85,
-}
-
-const DEFAULT_ARC_LAYOUT: MapArcLineLayout = {
- 'line-join': 'round',
- 'line-cap': 'round',
-}
-
-function buildArcCoordinates(
- from: [number, number],
- to: [number, number],
- curvature: number,
- samples: number,
-): [number, number][] {
- const [x0, y0] = from
- const [xTo, y2] = to
- // Unwrap the destination longitude so |dx| <= 180. This makes arcs that
- // straddle the antimeridian (e.g. Tokyo -> San Francisco) bow the short way
- // across the Pacific instead of the long way around the globe. Resulting
- // longitudes may fall outside [-180, 180]; MapLibre renders them correctly
- // on the globe projection, and on mercator when world copies are enabled.
- const rawDx = xTo - x0
- const x2 = rawDx > 180 ? xTo - 360 : rawDx < -180 ? xTo + 360 : xTo
- const dx = x2 - x0
- const dy = y2 - y0
- const distance = Math.hypot(dx, dy)
-
- if (distance === 0 || curvature === 0) return [from, [x2, y2]]
-
- const mx = (x0 + x2) / 2
- const my = (y0 + y2) / 2
- const nx = -dy / distance
- const ny = dx / distance
- const offset = distance * curvature
- const cx = mx + nx * offset
- const cy = my + ny * offset
-
- const points: [number, number][] = []
- const segments = Math.max(2, Math.floor(samples))
- for (let i = 0; i <= segments; i += 1) {
- const t = i / segments
- const inv = 1 - t
- const x = inv * inv * x0 + 2 * inv * t * cx + t * t * x2
- const y = inv * inv * y0 + 2 * inv * t * cy + t * t * y2
- points.push([x, y])
- }
- return points
-}
-
-function MapArc<T extends MapArcDatum = MapArcDatum>({
- data,
- id: propId,
- curvature = DEFAULT_ARC_CURVATURE,
- samples = DEFAULT_ARC_SAMPLES,
- paint,
- layout,
- hoverPaint,
- onClick,
- onHover,
- interactive = true,
- beforeId,
-}: MapArcProps<T>) {
- const { map, isLoaded } = useMap()
- const autoId = useId()
- const id = propId ?? autoId
- const sourceId = `arc-source-${id}`
- const layerId = `arc-layer-${id}`
- const hitLayerId = `arc-hit-layer-${id}`
-
- const mergedPaint = useMemo(
- () => mergeHoverPaint({ ...DEFAULT_ARC_PAINT, ...paint }, hoverPaint),
- [paint, hoverPaint],
- )
- const mergedLayout = useMemo(() => ({ ...DEFAULT_ARC_LAYOUT, ...layout }), [layout])
-
- const hitWidth = useMemo(() => {
- const w = paint?.['line-width'] ?? DEFAULT_ARC_PAINT['line-width']
- const base = typeof w === 'number' ? w : ARC_HIT_MIN_WIDTH
- return Math.max(base + ARC_HIT_PADDING, ARC_HIT_MIN_WIDTH)
- }, [paint])
-
- const geoJSON = useMemo<GeoJSON.FeatureCollection<GeoJSON.LineString>>(
- () => ({
- type: 'FeatureCollection',
- features: data.map((arc) => {
- const { from, to, ...properties } = arc
- return {
- type: 'Feature',
- properties,
- geometry: {
- type: 'LineString',
- coordinates: buildArcCoordinates(from, to, curvature, samples),
- },
- }
- }),
- }),
- [data, curvature, samples],
- )
-
- const latestRef = useRef({ data, onClick, onHover })
- latestRef.current = { data, onClick, onHover }
-
- // Add source and layers on mount.
- useEffect(() => {
- if (!isLoaded || !map) return
-
- map.addSource(sourceId, {
- type: 'geojson',
- data: geoJSON,
- promoteId: 'id',
- })
-
- map.addLayer(
- {
- id: hitLayerId,
- type: 'line',
- source: sourceId,
- layout: DEFAULT_ARC_LAYOUT,
- paint: {
- 'line-color': 'rgba(0, 0, 0, 0)',
- 'line-width': hitWidth,
- 'line-opacity': 1,
- },
- },
- beforeId,
- )
-
- map.addLayer(
- {
- id: layerId,
- type: 'line',
- source: sourceId,
- layout: mergedLayout,
- paint: mergedPaint,
- },
- beforeId,
- )
-
- return () => {
- try {
- if (map.getLayer(layerId)) map.removeLayer(layerId)
- if (map.getLayer(hitLayerId)) map.removeLayer(hitLayerId)
- if (map.getSource(sourceId)) map.removeSource(sourceId)
- } catch {
- // ignore
- }
- }
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [isLoaded, map])
-
- // Sync features when data / curvature / samples change.
- useEffect(() => {
- if (!isLoaded || !map) return
- const source = map.getSource(sourceId) as MapLibreGL.GeoJSONSource | undefined
- source?.setData(geoJSON)
- }, [isLoaded, map, geoJSON, sourceId])
-
- // Sync paint/layout when they change.
- useEffect(() => {
- if (!isLoaded || !map || !map.getLayer(layerId)) return
- for (const [key, value] of Object.entries(mergedPaint)) {
- map.setPaintProperty(layerId, key as keyof MapArcLinePaint, value as never)
- }
- for (const [key, value] of Object.entries(mergedLayout)) {
- map.setLayoutProperty(layerId, key as keyof MapArcLineLayout, value as never)
- }
- if (map.getLayer(hitLayerId)) {
- map.setPaintProperty(hitLayerId, 'line-width', hitWidth)
- }
- }, [isLoaded, map, layerId, hitLayerId, mergedPaint, mergedLayout, hitWidth])
-
- // Interaction handlers
- useEffect(() => {
- if (!isLoaded || !map || !interactive) return
-
- let hoveredId: string | number | null = null
-
- const setHover = (next: string | number | null) => {
- if (next === hoveredId) return
- const sourceExists = !!map.getSource(sourceId)
- if (hoveredId != null && sourceExists) {
- map.setFeatureState({ source: sourceId, id: hoveredId }, { hover: false })
- }
- hoveredId = next
- if (next != null && sourceExists) {
- map.setFeatureState({ source: sourceId, id: next }, { hover: true })
- }
- }
-
- const findArc = (featureId: string | number | undefined) =>
- featureId == null
- ? undefined
- : latestRef.current.data.find((arc) => String(arc.id) === String(featureId))
-
- const handleMouseMove = (e: MapLibreGL.MapLayerMouseEvent) => {
- const featureId = e.features?.[0]?.id as string | number | undefined
- if (featureId == null || featureId === hoveredId) return
-
- setHover(featureId)
- map.getCanvas().style.cursor = 'pointer'
-
- const arc = findArc(featureId)
- if (arc) {
- latestRef.current.onHover?.({
- arc: arc as T,
- longitude: e.lngLat.lng,
- latitude: e.lngLat.lat,
- originalEvent: e,
- })
- }
- }
-
- const handleMouseLeave = () => {
- setHover(null)
- map.getCanvas().style.cursor = ''
- latestRef.current.onHover?.(null)
- }
-
- const handleClick = (e: MapLibreGL.MapLayerMouseEvent) => {
- const arc = findArc(e.features?.[0]?.id as string | number | undefined)
- if (!arc) return
- latestRef.current.onClick?.({
- arc: arc as T,
- longitude: e.lngLat.lng,
- latitude: e.lngLat.lat,
- originalEvent: e,
- })
- }
-
- map.on('mousemove', hitLayerId, handleMouseMove)
- map.on('mouseleave', hitLayerId, handleMouseLeave)
- map.on('click', hitLayerId, handleClick)
-
- return () => {
- map.off('mousemove', hitLayerId, handleMouseMove)
- map.off('mouseleave', hitLayerId, handleMouseLeave)
- map.off('click', hitLayerId, handleClick)
- setHover(null)
- map.getCanvas().style.cursor = ''
- }
- }, [isLoaded, map, hitLayerId, sourceId, interactive])
-
- return null
-}
-
-type MapClusterLayerProps<P extends GeoJSON.GeoJsonProperties = GeoJSON.GeoJsonProperties> = {
- /** GeoJSON FeatureCollection data or URL to fetch GeoJSON from */
- data: string | GeoJSON.FeatureCollection<GeoJSON.Point, P>
- /** Maximum zoom level to cluster points on (default: 14) */
- clusterMaxZoom?: number
- /** Radius of each cluster when clustering points in pixels (default: 50) */
- clusterRadius?: number
- /** Colors for cluster circles: [small, medium, large] based on point count (default: ["#3b82f6", "#1d4ed8", "#1e3a8a"]) */
- clusterColors?: [string, string, string]
- /** Point count thresholds for color/size steps: [medium, large] (default: [100, 750]) */
- clusterThresholds?: [number, number]
- /** Color for unclustered individual points (default: "#3b82f6") */
- pointColor?: string
- /** Callback when an unclustered point is clicked */
- onPointClick?: (feature: GeoJSON.Feature<GeoJSON.Point, P>, coordinates: [number, number]) => void
- /** Callback when a cluster is clicked. If not provided, zooms into the cluster */
- onClusterClick?: (clusterId: number, coordinates: [number, number], pointCount: number) => void
-}
-
-const DEFAULT_CLUSTER_COLORS: [string, string, string] = ['#3b82f6', '#1d4ed8', '#1e3a8a']
-const DEFAULT_CLUSTER_THRESHOLDS: [number, number] = [100, 750]
-
-function MapClusterLayer<P extends GeoJSON.GeoJsonProperties = GeoJSON.GeoJsonProperties>({
- data,
- clusterMaxZoom = 14,
- clusterRadius = 50,
- clusterColors = DEFAULT_CLUSTER_COLORS,
- clusterThresholds = DEFAULT_CLUSTER_THRESHOLDS,
- pointColor = '#3b82f6',
- onPointClick,
- onClusterClick,
-}: MapClusterLayerProps<P>) {
- const { map, isLoaded } = useMap()
- const id = useId()
- const sourceId = `cluster-source-${id}`
- const clusterLayerId = `clusters-${id}`
- const clusterCountLayerId = `cluster-count-${id}`
- const unclusteredLayerId = `unclustered-point-${id}`
-
- const stylePropsRef = useRef({
- clusterColors,
- clusterThresholds,
- pointColor,
- })
-
- // Add source and layers on mount
- useEffect(() => {
- if (!isLoaded || !map) return
-
- // Add clustered GeoJSON source
- map.addSource(sourceId, {
- type: 'geojson',
- data,
- cluster: true,
- clusterMaxZoom,
- clusterRadius,
- })
-
- // Add cluster circles layer
- map.addLayer({
- id: clusterLayerId,
- type: 'circle',
- source: sourceId,
- filter: ['has', 'point_count'],
- paint: {
- 'circle-color': [
- 'step',
- ['get', 'point_count'],
- clusterColors[0],
- clusterThresholds[0],
- clusterColors[1],
- clusterThresholds[1],
- clusterColors[2],
- ],
- 'circle-radius': [
- 'step',
- ['get', 'point_count'],
- 20,
- clusterThresholds[0],
- 30,
- clusterThresholds[1],
- 40,
- ],
- 'circle-stroke-width': 0.75,
- 'circle-stroke-color': '#fff',
- 'circle-opacity': 0.85,
- },
- })
-
- // Add cluster count text layer
- map.addLayer({
- id: clusterCountLayerId,
- type: 'symbol',
- source: sourceId,
- filter: ['has', 'point_count'],
- layout: {
- 'text-field': '{point_count_abbreviated}',
- 'text-font': ['Open Sans Semibold'],
- 'text-size': 12,
- },
- paint: {
- 'text-color': '#fff',
- },
- })
-
- // Add unclustered point layer
- map.addLayer({
- id: unclusteredLayerId,
- type: 'circle',
- source: sourceId,
- filter: ['!', ['has', 'point_count']],
- paint: {
- 'circle-color': pointColor,
- 'circle-radius': 5,
- 'circle-stroke-width': 2,
- 'circle-stroke-color': '#fff',
- },
- })
-
- return () => {
- try {
- if (map.getLayer(clusterCountLayerId)) map.removeLayer(clusterCountLayerId)
- if (map.getLayer(unclusteredLayerId)) map.removeLayer(unclusteredLayerId)
- if (map.getLayer(clusterLayerId)) map.removeLayer(clusterLayerId)
- if (map.getSource(sourceId)) map.removeSource(sourceId)
- } catch {
- // ignore
- }
- }
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [isLoaded, map, sourceId])
-
- // Update source data when data prop changes (only for non-URL data)
- useEffect(() => {
- if (!isLoaded || !map || typeof data === 'string') return
-
- const source = map.getSource(sourceId) as MapLibreGL.GeoJSONSource
- if (source) {
- source.setData(data)
- }
- }, [isLoaded, map, data, sourceId])
-
- // Update layer styles when props change
- useEffect(() => {
- if (!isLoaded || !map) return
-
- const prev = stylePropsRef.current
- const colorsChanged =
- prev.clusterColors !== clusterColors || prev.clusterThresholds !== clusterThresholds
-
- // Update cluster layer colors and sizes
- if (map.getLayer(clusterLayerId) && colorsChanged) {
- map.setPaintProperty(clusterLayerId, 'circle-color', [
- 'step',
- ['get', 'point_count'],
- clusterColors[0],
- clusterThresholds[0],
- clusterColors[1],
- clusterThresholds[1],
- clusterColors[2],
- ])
- map.setPaintProperty(clusterLayerId, 'circle-radius', [
- 'step',
- ['get', 'point_count'],
- 20,
- clusterThresholds[0],
- 30,
- clusterThresholds[1],
- 40,
- ])
- }
-
- // Update unclustered point layer color
- if (map.getLayer(unclusteredLayerId) && prev.pointColor !== pointColor) {
- map.setPaintProperty(unclusteredLayerId, 'circle-color', pointColor)
- }
-
- stylePropsRef.current = { clusterColors, clusterThresholds, pointColor }
- }, [
- isLoaded,
- map,
- clusterLayerId,
- unclusteredLayerId,
- clusterColors,
- clusterThresholds,
- pointColor,
- ])
-
- // Handle click events
- useEffect(() => {
- if (!isLoaded || !map) return
-
- // Cluster click handler - zoom into cluster
- const handleClusterClick = async (
- e: MapLibreGL.MapMouseEvent & {
- features?: MapLibreGL.MapGeoJSONFeature[]
- },
- ) => {
- const features = map.queryRenderedFeatures(e.point, {
- layers: [clusterLayerId],
- })
- if (!features.length) return
-
- const feature = features[0]
- const clusterId = feature.properties?.cluster_id as number
- const pointCount = feature.properties?.point_count as number
- const coordinates = (feature.geometry as GeoJSON.Point).coordinates as [number, number]
-
- if (onClusterClick) {
- onClusterClick(clusterId, coordinates, pointCount)
- } else {
- // Default behavior: zoom to cluster expansion zoom
- const source = map.getSource(sourceId) as MapLibreGL.GeoJSONSource
- const zoom = await source.getClusterExpansionZoom(clusterId)
- map.easeTo({
- center: coordinates,
- zoom,
- })
- }
- }
-
- // Unclustered point click handler
- const handlePointClick = (
- e: MapLibreGL.MapMouseEvent & {
- features?: MapLibreGL.MapGeoJSONFeature[]
- },
- ) => {
- if (!onPointClick || !e.features?.length) return
-
- const feature = e.features[0]
- const coordinates = (feature.geometry as GeoJSON.Point).coordinates.slice() as [
- number,
- number,
- ]
-
- // Handle world copies
- while (Math.abs(e.lngLat.lng - coordinates[0]) > 180) {
- coordinates[0] += e.lngLat.lng > coordinates[0] ? 360 : -360
- }
-
- onPointClick(feature as unknown as GeoJSON.Feature<GeoJSON.Point, P>, coordinates)
- }
-
- // Cursor style handlers
- const handleMouseEnterCluster = () => {
- map.getCanvas().style.cursor = 'pointer'
- }
- const handleMouseLeaveCluster = () => {
- map.getCanvas().style.cursor = ''
- }
- const handleMouseEnterPoint = () => {
- if (onPointClick) {
- map.getCanvas().style.cursor = 'pointer'
- }
- }
- const handleMouseLeavePoint = () => {
- map.getCanvas().style.cursor = ''
- }
-
- map.on('click', clusterLayerId, handleClusterClick)
- map.on('click', unclusteredLayerId, handlePointClick)
- map.on('mouseenter', clusterLayerId, handleMouseEnterCluster)
- map.on('mouseleave', clusterLayerId, handleMouseLeaveCluster)
- map.on('mouseenter', unclusteredLayerId, handleMouseEnterPoint)
- map.on('mouseleave', unclusteredLayerId, handleMouseLeavePoint)
-
- return () => {
- map.off('click', clusterLayerId, handleClusterClick)
- map.off('click', unclusteredLayerId, handlePointClick)
- map.off('mouseenter', clusterLayerId, handleMouseEnterCluster)
- map.off('mouseleave', clusterLayerId, handleMouseLeaveCluster)
- map.off('mouseenter', unclusteredLayerId, handleMouseEnterPoint)
- map.off('mouseleave', unclusteredLayerId, handleMouseLeavePoint)
- }
- }, [isLoaded, map, clusterLayerId, unclusteredLayerId, sourceId, onClusterClick, onPointClick])
-
- return null
-}
-
-export type {
- MapArcDatum,
- MapArcEvent,
- MapArcProps,
- MapClusterLayerProps,
- MapControlsProps,
- MapGeoJSONData,
- MapGeoJSONEvent,
- MapGeoJSONFeature,
- MapGeoJSONProps,
- MapMarkerProps,
- MapPopupProps,
- MapProps,
- MapRef,
- MapRouteProps,
- MapStyleOption,
- MapViewport,
- MarkerContentProps,
- MarkerLabelProps,
- MarkerPopupProps,
- MarkerTooltipProps,
-}
-export {
- Map,
- MapArc,
- MapClusterLayer,
- MapControls,
- MapGeoJSON,
- MapMarker,
- MapPopup,
- MapRoute,
- MarkerContent,
- MarkerLabel,
- MarkerPopup,
- MarkerTooltip,
- useMap,
-}
diff --git a/packages/dashboard/CHANGELOG.md b/packages/dashboard/CHANGELOG.md
index 5c284cf46e..a9beac17c4 100644
--- a/packages/dashboard/CHANGELOG.md
+++ b/packages/dashboard/CHANGELOG.md
@@ -1,6 +1,22 @@
# @spree/dashboard
-## 1.0.0
+## 1.0.0-beta.2
+
+### Minor Changes
+
+- Removed the address map from the design system.
+
+ The map was rendered on one card — a seller's billing and returns addresses — and could not plot anything, because Spree addresses carry no coordinates. It also cost every dashboard user around a megabyte of MapLibre in the main bundle.
+
+ Its `?worker&url` import made the package impossible to install, too: Vite's dependency optimizer cannot resolve that specifier inside `node_modules`, so any project depending on `@spree/dashboard-ui` failed to start its dev server. Projects on the previous release should upgrade.
+
+### Patch Changes
+
+- Updated dependencies []:
+
+## 1.0.0-beta.1
### Major Changes
@@ -114,9 +130,9 @@
The rich-text cell was treating TipTap's mount-time paragraph wrap as an unsaved change against descriptions stored as plain text. Translation queries now share one cache prefix so saving a translation, editing the source record, or importing a translations CSV invalidates the coverage grid instead of leaving it stale.
- Updated dependencies [[`9cee487`](https://github.com/spree/spree/commit/9cee487fdce34c5f2ec873fc1d965196bd716663), [`4df88ac`](https://github.com/spree/spree/commit/4df88ac684688e65623703544686c6043a8ed816), [`6d4fe64`](https://github.com/spree/spree/commit/6d4fe64a1444bc42338942025a4ed1d5788cb9d7), [`67594a5`](https://github.com/spree/spree/commit/67594a56921fbc5d584b371ede94b0b83f2035ea), [`a8b11ec`](https://github.com/spree/spree/commit/a8b11ecb409a04c8d48ec6d64892ffa3bd6dacf7), [`fdd88eb`](https://github.com/spree/spree/commit/fdd88eb3d2d7ac36a710a2af38593a8f4c83f2bf), [`c0f6ccd`](https://github.com/spree/spree/commit/c0f6ccd1c5e9df5d1dbb93d1aff9e4180d3979ea), [`99573b0`](https://github.com/spree/spree/commit/99573b0c717225e652e6d449b4b85f1e10f3600b), [`3a1ac28`](https://github.com/spree/spree/commit/3a1ac2851a59cf0e498af27a60e70caac3a5788e), [`027ed08`](https://github.com/spree/spree/commit/027ed08056df9608554c80e343cdf24d6699d9f5), [`226557b`](https://github.com/spree/spree/commit/226557b21cc0870ee3803cdc617a2735311d9d9f), [`eb59f05`](https://github.com/spree/spree/commit/eb59f05f18dc98b62413ca80cc0061dfafd08ef7), [`9a4eb46`](https://github.com/spree/spree/commit/9a4eb466c2698d15d735c06e4b5faf984bb63dd2), [`38207ce`](https://github.com/spree/spree/commit/38207ceca55aaa1ac7606a2aca3098c441c77758), [`889a8cf`](https://github.com/spree/spree/commit/889a8cfd24443710cfff5a7d30fbe83d65148cac), [`8e5dc20`](https://github.com/spree/spree/commit/8e5dc20147ff24f53dd73b506c3f06a074d3d302), [`676aa0d`](https://github.com/spree/spree/commit/676aa0dee62a26944cb0a2c83273b149ba922b8a), [`9b8a7d5`](https://github.com/spree/spree/commit/9b8a7d57967ec31659959547555dde6780e8ef10), [`be76364`](https://github.com/spree/spree/commit/be76364d999fcffeeedd8f980da1a581db62f4a1), [`7e35951`](https://github.com/spree/spree/commit/7e35951361a6cee7b735640b0228710928719fee), [`496431d`](https://github.com/spree/spree/commit/496431d8e902269b8a5b05c9f2393eafc7e6b78b), [`a52a6da`](https://github.com/spree/spree/commit/a52a6da42f5c456e889f8bba12ee7194934289b1), [`0f22450`](https://github.com/spree/spree/commit/0f224508b3d270aaa9899a508966a27c37f873ed), [`da49f27`](https://github.com/spree/spree/commit/da49f27a5da1e40dbd4ce0901f8d4b21573d98df), [`32d4db9`](https://github.com/spree/spree/commit/32d4db9cdb027d9fb59e18807b26c0aa6ceb48ad), [`abc6e22`](https://github.com/spree/spree/commit/abc6e22cb60ea305a83583ded0b999458b2c9cbd), [`3473696`](https://github.com/spree/spree/commit/3473696bb08408addca8ef4665748c694b64b6d1), [`4156d50`](https://github.com/spree/spree/commit/4156d50a142497858377e3159a1c2c28182cb978)]:
## 0.13.1
diff --git a/packages/dashboard/package.json b/packages/dashboard/package.json
index ebfba71113..ce50b3b89c 100644
--- a/packages/dashboard/package.json
+++ b/packages/dashboard/package.json
@@ -1,7 +1,7 @@
{
"name": "@spree/dashboard",
"license": "MIT",
- "version": "1.0.0-beta.1",
+ "version": "1.0.0-beta.2",
"description": "Spree Dashboard app shell — the next-gen React admin for Spree Commerce. Routes, resource hooks, schemas, locales, and the <Dashboard /> component. Source-only package; hosts compile it via @spree/dashboard/vite. Developer Preview.",
"author": "Vendo Connect Inc.",
"homepage": "https://spreecommerce.org",
diff --git a/packages/dashboard/src/components/spree/sellers/seller-address-card.tsx b/packages/dashboard/src/components/spree/sellers/seller-address-card.tsx
index d364b8db4f..6a0b824af8 100644
--- a/packages/dashboard/src/components/spree/sellers/seller-address-card.tsx
+++ b/packages/dashboard/src/components/spree/sellers/seller-address-card.tsx
@@ -2,7 +2,6 @@ import type { Seller } from '@spree/admin-sdk'
import { AddressFormDialog } from '@spree/dashboard-core'
import {
AddressBlock,
- AddressMap,
Badge,
Button,
Card,
@@ -21,11 +20,8 @@ type AddressKey = 'billing_address' | 'returns_address'
/**
* One of a seller's two addresses — where they are invoiced, and where
- * customer returns go — with the map the legacy admin showed beside it.
- *
- * A returns address is what a shopper is told to post to, and a billing
- * address is what a commission invoice is addressed to, so both are worth
- * seeing on a map rather than trusting as typed.
+ * customer returns go. A returns address is what a shopper is told to post
+ * to, and a billing address is what a commission invoice is addressed to.
*
* Only the billing address is editable here. A seller's returns address is
* derived from their default stock location, so it is written through that
@@ -75,11 +71,8 @@ export function SellerAddressCard({
</CardHeader>
<CardContent className="flex flex-col gap-3">
{address ? (
- <>
- {/* No title: the card header already names it. */}
- <AddressBlock address={address} />
- <AddressMap address={address} label={seller.name} />
- </>
+ // No title: the card header already names it.
+ <AddressBlock address={address} />
) : (
<p className="py-4 text-center text-muted-foreground text-sm">
{t('admin.sellers.address.not_provided_by_seller')}
diff --git a/packages/sdk/CHANGELOG.md b/packages/sdk/CHANGELOG.md
index aebe6fde5b..8beb92cba4 100644
--- a/packages/sdk/CHANGELOG.md
+++ b/packages/sdk/CHANGELOG.md
@@ -1,6 +1,6 @@
# @spree/sdk
-## 2.0.0
+## 2.0.0-beta.1
### Major Changes
diff --git a/packages/seller-dashboard/CHANGELOG.md b/packages/seller-dashboard/CHANGELOG.md
index bd0397abb3..c65378c221 100644
--- a/packages/seller-dashboard/CHANGELOG.md
+++ b/packages/seller-dashboard/CHANGELOG.md
@@ -1,12 +1,28 @@
# @spree/seller-dashboard
-## 0.1.1
+## 1.0.0-beta.2
+
+### Minor Changes
+
+- Removed the address map from the design system.
+
+ The map was rendered on one card — a seller's billing and returns addresses — and could not plot anything, because Spree addresses carry no coordinates. It also cost every dashboard user around a megabyte of MapLibre in the main bundle.
+
+ Its `?worker&url` import made the package impossible to install, too: Vite's dependency optimizer cannot resolve that specifier inside `node_modules`, so any project depending on `@spree/dashboard-ui` failed to start its dev server. Projects on the previous release should upgrade.
+
+### Patch Changes
+
+- Updated dependencies []:
+
+## 1.0.0-beta.1
### Patch Changes
- [#14635](https://github.com/spree/spree/pull/14635) [`496431d`](https://github.com/spree/spree/commit/496431d8e902269b8a5b05c9f2393eafc7e6b78b) Thanks [@damianlegawiec](https://github.com/damianlegawiec)! - Added a settings overview page to the seller panel, matching the operator dashboard's card grid of reachable settings areas.
- Updated dependencies [[`9cee487`](https://github.com/spree/spree/commit/9cee487fdce34c5f2ec873fc1d965196bd716663), [`67594a5`](https://github.com/spree/spree/commit/67594a56921fbc5d584b371ede94b0b83f2035ea), [`fdd88eb`](https://github.com/spree/spree/commit/fdd88eb3d2d7ac36a710a2af38593a8f4c83f2bf), [`c0f6ccd`](https://github.com/spree/spree/commit/c0f6ccd1c5e9df5d1dbb93d1aff9e4180d3979ea), [`99573b0`](https://github.com/spree/spree/commit/99573b0c717225e652e6d449b4b85f1e10f3600b), [`3a1ac28`](https://github.com/spree/spree/commit/3a1ac2851a59cf0e498af27a60e70caac3a5788e), [`027ed08`](https://github.com/spree/spree/commit/027ed08056df9608554c80e343cdf24d6699d9f5), [`226557b`](https://github.com/spree/spree/commit/226557b21cc0870ee3803cdc617a2735311d9d9f), [`eb59f05`](https://github.com/spree/spree/commit/eb59f05f18dc98b62413ca80cc0061dfafd08ef7), [`38207ce`](https://github.com/spree/spree/commit/38207ceca55aaa1ac7606a2aca3098c441c77758), [`8e5dc20`](https://github.com/spree/spree/commit/8e5dc20147ff24f53dd73b506c3f06a074d3d302), [`9b8a7d5`](https://github.com/spree/spree/commit/9b8a7d57967ec31659959547555dde6780e8ef10), [`be76364`](https://github.com/spree/spree/commit/be76364d999fcffeeedd8f980da1a581db62f4a1), [`496431d`](https://github.com/spree/spree/commit/496431d8e902269b8a5b05c9f2393eafc7e6b78b), [`0f22450`](https://github.com/spree/spree/commit/0f224508b3d270aaa9899a508966a27c37f873ed), [`da49f27`](https://github.com/spree/spree/commit/da49f27a5da1e40dbd4ce0901f8d4b21573d98df), [`3473696`](https://github.com/spree/spree/commit/3473696bb08408addca8ef4665748c694b64b6d1), [`4156d50`](https://github.com/spree/spree/commit/4156d50a142497858377e3159a1c2c28182cb978)]:
diff --git a/packages/seller-dashboard/package.json b/packages/seller-dashboard/package.json
index 7c93aa579c..c87e0da261 100644
--- a/packages/seller-dashboard/package.json
+++ b/packages/seller-dashboard/package.json
@@ -1,6 +1,6 @@
{
"name": "@spree/seller-dashboard",
- "version": "1.0.0-beta.1",
+ "version": "1.0.0-beta.2",
"license": "MIT",
"type": "module",
"description": "Spree marketplace seller panel — the seller-facing counterpart to the admin dashboard.",
diff --git a/packages/seller-sdk/CHANGELOG.md b/packages/seller-sdk/CHANGELOG.md
index acded8a6a3..d305723e93 100644
--- a/packages/seller-sdk/CHANGELOG.md
+++ b/packages/seller-sdk/CHANGELOG.md
@@ -1,6 +1,12 @@
# @spree/seller-sdk
-## 0.1.1
+## 1.0.0-beta.2
+
+### Patch Changes
+
+- Released alongside the dashboard packages it is versioned with.
+
+## 1.0.0-beta.1
### Patch Changes
diff --git a/packages/seller-sdk/package.json b/packages/seller-sdk/package.json
index b4bb977571..a1dbb0bd07 100644
--- a/packages/seller-sdk/package.json
+++ b/packages/seller-sdk/package.json
@@ -1,6 +1,6 @@
{
"name": "@spree/seller-sdk",
- "version": "1.0.0-beta.1",
+ "version": "1.0.0-beta.2",
"description": "TypeScript client for the Spree Seller API — the marketplace seller panel.",
"type": "module",
"main": "./dist/index.cjs",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 7d0a025bbe..ab0a0285da 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -29,7 +29,6 @@ overrides:
'@tiptap/extension-placeholder': 3.31.3
prosemirror-model: 1.25.11
prosemirror-view: 1.42.3
- maplibre-gl: 6.4.1
'@vitest/mocker': ^4.1.11
baseline-browser-mapping: ^2.11.0
browserslist: ^4.28.7
@@ -578,9 +577,6 @@ importers:
lucide-react:
specifier: ^1.14.0
version: 1.14.0([email protected])
- maplibre-gl:
- specifier: 6.4.1
- version: 6.4.1
react:
specifier: ^19.2.6
version: 19.2.6
@@ -612,9 +608,6 @@ importers:
specifier: ^1.4.0
version: 1.4.0
devDependencies:
- '@types/geojson':
- specifier: ^7946.0.16
- version: 7946.0.16
'@types/react':
specifier: ^19.2.14
version: 19.2.14
@@ -1475,35 +1468,6 @@ packages:
'@manypkg/[email protected]':
resolution: {integrity: sha512-fo+QhuU3qE/2TQMQmbVMqaQ6EWbMhi4ABWP+O4AM1NqPBuy0OrApV5LO6BrrgnhtAHS2NH6RrVk9OL181tTi8A==}
- '@mapbox/[email protected]':
- resolution: {integrity: sha512-0SElaV0uMxEnxzBhhX9WTuPyUeMsAN/SS0i16tjuba4/mio63MG9khjC1a0JAiPGXAwvwm4UfHJURCN7nyudQg==}
- engines: {node: '>= 22'}
-
- '@mapbox/[email protected]':
- resolution: {integrity: sha512-YGcBz1cg4ATXDCM/71L9xveh4dynfGmcLDqufR+nQQy3fKwsAZsWd/x4621/6uJaeB9mwOHE6hPeDgXz9uViUQ==}
-
- '@mapbox/[email protected]':
- resolution: {integrity: sha512-LVL4wgI9YAum5V+LNVQO6QgFBPw7/MIIY4XJPNsPDMrjEwcE+JfKk1LuIl8GnF197ejVdC9QdPaxrx5gfgdGXg==}
-
- '@mapbox/[email protected]':
- resolution: {integrity: sha512-fqd515fjBmANKGGsQ286E2Wvj/XvDFpGzwJxq4CI6jMQue6Oy04uCKp+JWKF00xRTmk6cEu1jPJ9p3xqH8YWqQ==}
-
- '@mapbox/[email protected]':
- resolution: {integrity: sha512-Qf10S1uIHMk20ri/IVBnpS+esUEkVaR5Hftmz88jTInrpmWgPGJfPe3LVjjlE77trLx8tH6qjTG7uWH9hIq/0Q==}
-
- '@maplibre/[email protected]':
- resolution: {integrity: sha512-FVMOcmSP/yqol45t7StApEyTL5/vmqBCuFhH9n+fFuINenhaX+YgHHIt1yJ86S8kln3uJLcMvmEU2cfn6E2eCQ==}
-
- '@maplibre/[email protected]':
- resolution: {integrity: sha512-6J0vZqMZvRAJKtdWJdDGHEh1YJ2ZHG08/GOur8gCArYhO8ZkM//OXqtI2AAEz4jc2G+Wq4MfcePg8qNK5TZ4Kg==}
- hasBin: true
-
- '@maplibre/[email protected]':
- resolution: {integrity: sha512-5n5dgolE2EYxwCKgx8vlwURCB8A+kyfJJyThlYimjlGgOcOe2Bhw9VxxnnHC91OC9PgHg+nVdgVPTYPkIo62vg==}
-
- '@maplibre/[email protected]':
- resolution: {integrity: sha512-j6p0AdjvAR19Z3XaCysle7A4ZSo08tYOzxD0Y9NQylwPAkwJJeYub5b2eVucdeDh7erhv69DahoLOevDRERRUw==}
-
'@modelcontextprotocol/[email protected]':
resolution: {integrity: sha512-zo37mZA9hJWpULgkRpowewez1y6ML5GsXJPY8FI0tBBCd77HEvza4jDqRKOXgHNn867PVGCyTdzqpz0izu5ZjQ==}
engines: {node: '>=18'}
@@ -2458,9 +2422,6 @@ packages:
resolution: {integrity: sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==}
- '@types/[email protected]':
- resolution: {integrity: sha512-6C8nqWur3j98U6+lXDfTUWIfgvZU+EumvpHKcYjujKH7woYyLj2sUmff0tRhrqM7BohUw7Pz3ZB1jj2gW9Fvmg==}
-
resolution: {integrity: sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ==}
@@ -2962,9 +2923,6 @@ packages:
resolution: {integrity: sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==}
engines: {node: '>= 0.4'}
- resolution: {integrity: sha512-vnS4AVwp1KHAF13i1vp1/2D5evWy3k5u/iW/B81QVsUZtV8cv2tU0b2VNFlqvh4kYwrFMDdjPCfAmfyJW9y14Q==}
-
resolution: {integrity: sha512-wG99Zcfcys9fZux7Cft8BAX/YrOJLJSZ3jyYPfhZHqN2E+Ffx+QXBDsv3gubEgPtV6dTzJMSQUwk1H98/t/0wQ==}
engines: {bun: '>=1', deno: '>=2', node: '>=16'}
@@ -3214,9 +3172,6 @@ packages:
resolution: {integrity: sha512-7tN6rFgBlMgpBML5j8typ92BKFi2sFQvIdpAqLA2beia5avZDrMs0FLZiM5etShWq5irVyGcGMEA1jcDaK7A/Q==}
- resolution: {integrity: sha512-latSnyDNt/8zYUB6VIJ6PCh2jBjJX6gnDsoCZ7LyW7GkqrD51EWwa9qCoGixj8YqBtETQK/xY7OmpTF8xz1DdQ==}
-
resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==}
engines: {node: '>= 6'}
@@ -3467,9 +3422,6 @@ packages:
resolution: {integrity: sha512-fQhoXdcvc3V28x7C7BMs4P5+kNlgUURe2jmUT1T//oBRMDrqy1QPelJimwZGo7Hg9VPV3EQV5Bnq4hbFy2vetA==}
- resolution: {integrity: sha512-3CNZ2DnrpByG9Nqj6Xo8vqbjT4F6N+tb4Gb28ESAZjYZ5yqvmc56J+/kuIwkaAMOyblTQhUW7PxMkUb8Q36N3Q==}
-
resolution: {integrity: sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==}
engines: {node: '>=6'}
@@ -3481,9 +3433,6 @@ packages:
resolution: {integrity: sha512-zwOTdL3rFQ/lRdBnntKVOX6k5cKJwEc1HdilT71BWEu7J41gXIB2MRp+vxduPSwZJPWBxEzv4yH1wYLJGUHX4Q==}
- resolution: {integrity: sha512-e9vurzrXJQrFX6ckpHP3bvj5l+9CnYzkxDNnNQ1h2QTqdWsUAJgXiKdGNcOa1EY85dU8KbQ+z/FdQdB7P+9yfQ==}
-
resolution: {integrity: sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==}
engines: {node: '>=6'}
@@ -3614,10 +3563,6 @@ packages:
resolution: {integrity: sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==}
engines: {node: '>=10'}
- resolution: {integrity: sha512-KzxQKtfBu/pSz1C+yW1hNS9eyj2h2lC7ufdAi6/SEt177n3oAfDfmUmslRfJdXY7ReAFBcnvwsqmiyoDhtA9GQ==}
- engines: {node: '>=16.14.0', npm: '>=8.1.0'}
-
resolution: {integrity: sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==}
engines: {node: '>= 0.4'}
@@ -3684,9 +3629,6 @@ packages:
typescript:
optional: true
- resolution: {integrity: sha512-TvmkNhkv8yct0SVBSy+o8wYzXjE4Zz3PCesbfs8HiCXXdcTuocApFv11UWlNFWKYsP2okqrhb7JNlSm9InBhIw==}
-
resolution: {integrity: sha512-dkEJPVvun4FryqBmZ5KhDo0K9iDXAwn08tMLDinNdRBNPcYEDiWYysLcc6k3mjTMlbP9KyylvRpd4wFtwrT9rw==}
engines: {node: ^20.17.0 || >=22.9.0}
@@ -3848,10 +3790,6 @@ packages:
resolution: {integrity: sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==}
- resolution: {integrity: sha512-mnvGdvOrIvJOBGUEdGkrVXjN8E/VkIJCkf2eS1DH2yv82ORUlLttmDt0rWY38yYZmVwciZwBUvHM20qxBZf40w==}
- hasBin: true
-
resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==}
@@ -3910,9 +3848,6 @@ packages:
resolution: {integrity: sha512-u82N74LFzG8ca+dD8puPnplTXoGH4fTPpVGuIbt36G3qvNlkvfD0lEAZSxaly3KX8TS/L1A1gsCEmvKmBcVbkQ==}
engines: {node: ^10 || ^12 || >=14}
- resolution: {integrity: sha512-pcaShQc1Shq0y+E7GqJqvZj8DTthWV1KeHGdi0Z6IAin2Oi3JnLCOfwnCo84qc+HAp52wT9nK9H7FAJp5a44GQ==}
-
resolution: {integrity: sha512-dM0jVuXJPsDN6DvRpea484tCUaMiXWjuCn++HGTqUWzGDjv5tZkEZldAJ/UMlqRYGFrD/etByo4/xOuC/snX2A==}
engines: {node: '>=20'}
@@ -3974,9 +3909,6 @@ packages:
resolution: {integrity: sha512-oTN7EtH+CpwxU9NrwEYWd0UZ4JUx7l048l5A2Xppm4p/60isZYLnth9QVQmC3VRIvdrIWCxwZSd+Uz791G31/w==}
- resolution: {integrity: sha512-VG2K63Igkiv9p76tk1lilczEK1cT+kCjKtkdhw1dQZV3k3IXJbd3o6Ho8b9zJZaHSnT2hKe4I+ObmX9w6m5SmQ==}
-
resolution: {integrity: sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==}
engines: {node: '>= 0.10'}
@@ -3991,9 +3923,6 @@ packages:
resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==}
- resolution: {integrity: sha512-XdjUArbK4Bm5fLLvlm5KpTFOiOThgfWWI4axAZDWg4E/0mKdZyI9tNEfds27qCi1ze/vwTR16kvmmGhRra3c2g==}
-
resolution: {integrity: sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==}
engines: {node: '>= 0.6'}
@@ -4144,9 +4073,6 @@ packages:
resolution: {integrity: sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==}
- resolution: {integrity: sha512-kI5ffTiZWmJaS/huM8wZfEMer1eRd7oJQhDuxeCLe3t7N7mX3z94CN0xPxBQxFYQTSNz9T0i+v6inKqSdK8xrQ==}
-
resolution: {integrity: sha512-oMA2dcrw6u0YfxJQXm342bFKX/E4sG9rbTzO9ptUcR/e8A33cHuvStiYOwH7fszkZlZ1z/ta9AAoPk2F4qIOHA==}
engines: {node: '>=18'}
@@ -4404,9 +4330,6 @@ packages:
resolution: {integrity: sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==}
engines: {node: '>=12.0.0'}
- resolution: {integrity: sha512-gRa9gwYU3ECmQYv3lslts5hxuIa90veaEcxDYuu3QGOIAEM2mOZkVHp48ANJuu1CURtRdHKUBY5Lm1tHV+sD4g==}
-
resolution: {integrity: sha512-Bf+ILmBgretUrdJxzXM0SgXLZ3XfiaUuOj/IKQHuTXip+05Xn+uyEYdVg0kYDipTBcLrCVyUzAPz7QmArb0mmw==}
engines: {node: '>=14.0.0'}
@@ -5435,43 +5358,6 @@ snapshots:
globby: 11.1.0
read-yaml-file: 2.1.0
- '@mapbox/[email protected]': {}
-
- '@mapbox/[email protected]': {}
-
- '@mapbox/[email protected]': {}
-
- '@mapbox/[email protected]': {}
-
- '@mapbox/[email protected]':
- dependencies:
- '@mapbox/point-geometry': 1.1.0
- '@types/geojson': 7946.0.16
- pbf: 5.1.2
-
- '@maplibre/[email protected]':
- dependencies:
- kdbush: 4.1.0
-
- '@maplibre/[email protected]':
- dependencies:
- '@mapbox/jsonlint-lines-primitives': 2.0.3
- '@mapbox/unitbezier': 1.0.0
- json-stringify-pretty-compact: 4.0.0
- minimist: 1.2.8
- quickselect: 3.0.0
- tinyqueue: 3.0.0
-
- '@maplibre/[email protected]':
- dependencies:
- '@mapbox/point-geometry': 1.1.0
-
- '@maplibre/[email protected]':
- dependencies:
- '@mapbox/point-geometry': 1.1.0
- '@types/geojson': 7946.0.16
- pbf: 5.1.2
-
'@modelcontextprotocol/[email protected]([email protected])':
dependencies:
'@hono/node-server': 1.19.17([email protected])
@@ -6283,8 +6169,6 @@ snapshots:
'@types/[email protected]': {}
- '@types/[email protected]': {}
-
'@types/[email protected]': {}
@@ -6730,8 +6614,6 @@ snapshots:
es-errors: 1.3.0
gopd: 1.2.0
-
dependencies:
'@ecies/ciphers': 0.2.6(@noble/[email protected])
@@ -7032,8 +6914,6 @@ snapshots:
dependencies:
resolve-pkg-maps: 1.0.0
-
dependencies:
is-glob: 4.0.3
@@ -7212,8 +7092,6 @@ snapshots:
-
@@ -7226,8 +7104,6 @@ snapshots:
optionalDependencies:
graceful-fs: 4.2.11
-
@@ -7326,26 +7202,6 @@ snapshots:
dependencies:
semver: 7.7.4
- dependencies:
- '@mapbox/point-geometry': 1.1.0
- '@mapbox/tiny-sdf': 2.2.0
- '@mapbox/unitbezier': 1.0.0
- '@mapbox/vector-tile': 3.0.0
- '@maplibre/geojson-vt': 6.1.1
- '@maplibre/maplibre-gl-style-spec': 26.4.2
- '@maplibre/mlt': 1.2.1
- '@maplibre/vt-pbf': 4.3.2
- '@types/geojson': 7946.0.16
- earcut: 3.2.3
- gl-matrix: 3.4.4
- kdbush: 4.1.0
- murmurhash-js: 1.0.0
- pbf: 5.1.2
- potpack: 2.1.0
- quickselect: 3.0.0
- tinyqueue: 3.0.0
-
@@ -7413,8 +7269,6 @@ snapshots:
transitivePeerDependencies:
- '@types/node'
-
@@ -7551,10 +7405,6 @@ snapshots:
- dependencies:
- resolve-protobuf-schema: 2.1.0
-
@@ -7599,8 +7449,6 @@ snapshots:
picocolors: 1.1.1
source-map-js: 1.2.1
-
@@ -7690,8 +7538,6 @@ snapshots:
prosemirror-state: 1.4.4
prosemirror-transform: 1.12.0
-
dependencies:
forwarded: 0.2.0
@@ -7706,8 +7552,6 @@ snapshots:
-
@@ -7847,10 +7691,6 @@ snapshots:
- dependencies:
- protocol-buffers-schema: 3.6.1
-
dependencies:
onetime: 7.0.0
@@ -8174,8 +8014,6 @@ snapshots:
fdir: 6.5.0([email protected])
picomatch: 4.0.4
-
diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml
index b2af172558..af77ec3ff1 100644
--- a/pnpm-workspace.yaml
+++ b/pnpm-workspace.yaml
@@ -79,7 +79,7 @@ overrides:
# @tiptap/react stayed on 3.22, which still imports cancelPositionCheck
# and schedulePositionCheck — exports 3.31 removed. Pin the family
# together on the patched line (prototype pollution <3.30.4, Markdown
- # ReDoS <3.30.5). maplibre-gl is exact: ^6.4.1 resolved to 6.9.
+ # ReDoS <3.30.5).
'@tiptap/core': 3.31.3
'@tiptap/pm': 3.31.3
'@tiptap/react': 3.31.3
@@ -93,7 +93,6 @@ overrides:
# line. Two copies make wrapInList throw, so list toolbar buttons no-op.
prosemirror-model: 1.25.11
prosemirror-view: 1.42.3
- maplibre-gl: 6.4.1
'@vitest/mocker': ^4.1.11
baseline-browser-mapping: ^2.11.0
browserslist: ^4.28.7
@@ -122,7 +121,6 @@ minimumReleaseAgeExclude:
- '@vitest/[email protected]'