feat: OS Share Target for recipe URLs (v0.67.0)
Declares share_target in manifest.ts (action /recipes, GET, title/text/url params). recipes/page.tsx extracts the shared link -- preferring the url param, falling back to the first http(s) URL found inside text since senders vary on where they put it -- and passes it to RecipesHeader as sharedUrl. UrlImportDialog gained initialUrl/autoImport props so the existing import-from-URL flow opens pre-filled and fires immediately instead of requiring the user to paste the link back in. Chromium/Android only -- Safari has no Share Target API at all, same restriction already documented for the install-prompt banner. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,11 @@
|
|||||||
|
|
||||||
All notable changes to Epicure are documented here. This file is mirrored in-app at `/changelog` (and in the admin dashboard) via `apps/web/lib/changelog.ts` — update both together.
|
All notable changes to Epicure are documented here. This file is mirrored in-app at `/changelog` (and in the admin dashboard) via `apps/web/lib/changelog.ts` — update both together.
|
||||||
|
|
||||||
|
## 0.67.0 — 2026-07-21 09:30
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Epicure now registers as an OS share target (Chromium/Android, once installed): share a recipe link from another app's share sheet and it opens straight into the URL-import flow, pre-filled and auto-imported. Safari has no equivalent API — Chromium/Android only, same restriction as the install-prompt banner.
|
||||||
|
|
||||||
## 0.66.0 — 2026-07-21 09:00
|
## 0.66.0 — 2026-07-21 09:00
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|||||||
+2
-2
@@ -130,7 +130,7 @@ Status legend: **Exists** (fully working) · **Partial** (works but with a real
|
|||||||
| Push (client + server) | Exists end-to-end | Real subscribe/unsubscribe with correct state sync, VAPID, multiple triggers wired | `apps/web/lib/push.ts` |
|
| Push (client + server) | Exists end-to-end | Real subscribe/unsubscribe with correct state sync, VAPID, multiple triggers wired | `apps/web/lib/push.ts` |
|
||||||
| Voice control | **Exists** | Web Speech API in cooking mode (this was previously assumed missing — it isn't) | `apps/web/components/cooking-mode/cooking-mode.tsx` |
|
| Voice control | **Exists** | Web Speech API in cooking mode (this was previously assumed missing — it isn't) | `apps/web/components/cooking-mode/cooking-mode.tsx` |
|
||||||
| Barcode scanning | **Exists** (pantry only) | `BarcodeDetector` isn't used, but a manual-entry-triggered Open Food Facts API lookup covers the same use case | `apps/web/app/api/v1/pantry/scan/barcode` |
|
| Barcode scanning | **Exists** (pantry only) | `BarcodeDetector` isn't used, but a manual-entry-triggered Open Food Facts API lookup covers the same use case | `apps/web/app/api/v1/pantry/scan/barcode` |
|
||||||
| OS Share Target (share a URL into Epicure from another app) | **Missing** | No `share_target` in the manifest | — |
|
| OS Share Target (share a URL into Epicure from another app) | Exists (Chromium/Android only) | Manifest `share_target` → `/recipes?title&text&url`; extracts the shared link from either `url` or a URL substring in `text` (senders vary), auto-opens the existing import-from-URL dialog pre-filled and auto-imports. Safari has no Share Target API at all — same Apple-restriction story as install prompts. | `apps/web/app/manifest.ts`, `apps/web/app/(app)/recipes/page.tsx`, `apps/web/components/recipe/url-import-dialog.tsx` |
|
||||||
| Home-screen widgets, Siri/Assistant shortcuts | **Missing**, expected — N/A for a pure PWA without a native shell | — |
|
| Home-screen widgets, Siri/Assistant shortcuts | **Missing**, expected — N/A for a pure PWA without a native shell | — |
|
||||||
| Native mobile app (React Native/Capacitor/Expo) | **Missing** | Confirmed PWA-only, no native project anywhere in the monorepo | — |
|
| Native mobile app (React Native/Capacitor/Expo) | **Missing** | Confirmed PWA-only, no native project anywhere in the monorepo | — |
|
||||||
|
|
||||||
@@ -144,7 +144,7 @@ Ranked roughly by likely value:
|
|||||||
2. **Recipe video** — no support at all.
|
2. **Recipe video** — no support at all.
|
||||||
3. **Nutrition trend/history view** — diary is single-day only, no multi-day chart.
|
3. **Nutrition trend/history view** — diary is single-day only, no multi-day chart.
|
||||||
4. **USDA/nutrition-database lookup** — all nutrition numbers are AI-estimated; barcode scan only gets product name, not nutrition facts.
|
4. **USDA/nutrition-database lookup** — all nutrition numbers are AI-estimated; barcode scan only gets product name, not nutrition facts.
|
||||||
5. **OS Share Target** — can't share a recipe link into Epicure from another app's share sheet.
|
5. ~~OS Share Target~~ — closed 2026-07-21 (Chromium/Android only, no Safari equivalent exists).
|
||||||
6. ~~Push click-through handling~~ — closed 2026-07-21 (`push`/`notificationclick` listeners added to `sw.js`).
|
6. ~~Push click-through handling~~ — closed 2026-07-21 (`push`/`notificationclick` listeners added to `sw.js`).
|
||||||
7. **Anonymous public link for meal plans** — shopping lists have this, meal plans don't.
|
7. **Anonymous public link for meal plans** — shopping lists have this, meal plans don't.
|
||||||
8. **Grocery delivery/live pricing** beyond the Instacart stub (which needs a partnership agreement to go live).
|
8. **Grocery delivery/live pricing** beyond the Instacart stub (which needs a partnership agreement to go live).
|
||||||
|
|||||||
@@ -24,8 +24,25 @@ type SearchParams = Promise<{
|
|||||||
page?: string;
|
page?: string;
|
||||||
batchCook?: string;
|
batchCook?: string;
|
||||||
recipeType?: string;
|
recipeType?: string;
|
||||||
|
// OS Share Target params (manifest.ts's share_target) — a browser share
|
||||||
|
// sheet navigates here with these appended.
|
||||||
|
url?: string;
|
||||||
|
text?: string;
|
||||||
|
title?: string;
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
|
const URL_PATTERN = /https?:\/\/\S+/;
|
||||||
|
|
||||||
|
/** Web Share Target's GET params vary by sender: some apps put the shared
|
||||||
|
* link in `url`, others (notably many Android apps) put it inside `text`
|
||||||
|
* alongside other text. Prefer `url`, fall back to extracting the first
|
||||||
|
* http(s) URL out of `text`. */
|
||||||
|
function extractSharedUrl(params: { url?: string; text?: string }): string | undefined {
|
||||||
|
if (params.url && URL_PATTERN.test(params.url)) return params.url;
|
||||||
|
const match = params.text?.match(URL_PATTERN);
|
||||||
|
return match?.[0];
|
||||||
|
}
|
||||||
|
|
||||||
const SORT_MAP = {
|
const SORT_MAP = {
|
||||||
updated_desc: desc(recipes.updatedAt),
|
updated_desc: desc(recipes.updatedAt),
|
||||||
updated_asc: asc(recipes.updatedAt),
|
updated_asc: asc(recipes.updatedAt),
|
||||||
@@ -43,7 +60,8 @@ export default async function RecipesPage({ searchParams }: { searchParams: Sear
|
|||||||
const m = getMessages((session.user as { locale?: string }).locale);
|
const m = getMessages((session.user as { locale?: string }).locale);
|
||||||
const featurePrefs = await getFeaturePrefs(session.user.id);
|
const featurePrefs = await getFeaturePrefs(session.user.id);
|
||||||
|
|
||||||
const { q, sort, visibility, difficulty, tag, page: pageParam, batchCook, recipeType } = await searchParams;
|
const { q, sort, visibility, difficulty, tag, page: pageParam, batchCook, recipeType, url, text } = await searchParams;
|
||||||
|
const sharedUrl = extractSharedUrl({ url, text });
|
||||||
const query = (q ?? "").trim().slice(0, 200);
|
const query = (q ?? "").trim().slice(0, 200);
|
||||||
const sortKey: SortKey = (sort && sort in SORT_MAP ? sort : "updated_desc") as SortKey;
|
const sortKey: SortKey = (sort && sort in SORT_MAP ? sort : "updated_desc") as SortKey;
|
||||||
const tagFilter = tag?.trim().slice(0, 50) || undefined;
|
const tagFilter = tag?.trim().slice(0, 50) || undefined;
|
||||||
@@ -140,6 +158,7 @@ export default async function RecipesPage({ searchParams }: { searchParams: Sear
|
|||||||
initialTag={tagFilter ?? ""}
|
initialTag={tagFilter ?? ""}
|
||||||
initialBatchCook={batchCookFilter ?? ""}
|
initialBatchCook={batchCookFilter ?? ""}
|
||||||
initialRecipeType={recipeTypeFilter ?? ""}
|
initialRecipeType={recipeTypeFilter ?? ""}
|
||||||
|
sharedUrl={sharedUrl}
|
||||||
/>
|
/>
|
||||||
<RecipesEmptyState query={query} count={total} />
|
<RecipesEmptyState query={query} count={total} />
|
||||||
<RecipesGrid key={`${query}-${sortKey}-${visibilityFilter}-${difficultyFilter}-${tagFilter}-${batchCookFilter}-${recipeTypeFilter}-${page}`} recipes={recipesWithFavorites} />
|
<RecipesGrid key={`${query}-${sortKey}-${visibilityFilter}-${difficultyFilter}-${tagFilter}-${batchCookFilter}-${recipeTypeFilter}-${page}`} recipes={recipesWithFavorites} />
|
||||||
|
|||||||
@@ -15,5 +15,18 @@ export default function manifest(): MetadataRoute.Manifest {
|
|||||||
{ src: "/icon-512.svg", sizes: "512x512", type: "image/svg+xml", purpose: "any" },
|
{ src: "/icon-512.svg", sizes: "512x512", type: "image/svg+xml", purpose: "any" },
|
||||||
{ src: "/icon-512.svg", sizes: "512x512", type: "image/svg+xml", purpose: "maskable" },
|
{ src: "/icon-512.svg", sizes: "512x512", type: "image/svg+xml", purpose: "maskable" },
|
||||||
],
|
],
|
||||||
|
// Registers Epicure as a share target in the OS share sheet (Chromium
|
||||||
|
// on Android/desktop once installed — Safari has no equivalent API).
|
||||||
|
// Sharing a recipe link from another app opens /recipes with these
|
||||||
|
// query params, which auto-opens the URL-import dialog pre-filled.
|
||||||
|
share_target: {
|
||||||
|
action: "/recipes",
|
||||||
|
method: "GET",
|
||||||
|
params: {
|
||||||
|
title: "title",
|
||||||
|
text: "text",
|
||||||
|
url: "url",
|
||||||
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ export function RecipesHeader({
|
|||||||
initialTag = "",
|
initialTag = "",
|
||||||
initialBatchCook = "",
|
initialBatchCook = "",
|
||||||
initialRecipeType = "",
|
initialRecipeType = "",
|
||||||
|
sharedUrl,
|
||||||
}: {
|
}: {
|
||||||
count: number;
|
count: number;
|
||||||
initialQuery?: string;
|
initialQuery?: string;
|
||||||
@@ -96,13 +97,19 @@ export function RecipesHeader({
|
|||||||
initialTag?: string;
|
initialTag?: string;
|
||||||
initialBatchCook?: string;
|
initialBatchCook?: string;
|
||||||
initialRecipeType?: string;
|
initialRecipeType?: string;
|
||||||
|
/** A link shared into the installed PWA via the OS share sheet (Web Share
|
||||||
|
* Target, Chromium/Android only) — see manifest.ts's share_target and
|
||||||
|
* page.tsx's read of the `url`/`text` params it's redirected here with.
|
||||||
|
* Auto-opens the import dialog pre-filled instead of requiring the user
|
||||||
|
* to paste the link again. */
|
||||||
|
sharedUrl?: string;
|
||||||
}) {
|
}) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
const t = useTranslations("recipes");
|
const t = useTranslations("recipes");
|
||||||
const tRecipe = useTranslations("recipe");
|
const tRecipe = useTranslations("recipe");
|
||||||
const [aiOpen, setAiOpen] = useState(false);
|
const [aiOpen, setAiOpen] = useState(false);
|
||||||
const [urlOpen, setUrlOpen] = useState(false);
|
const [urlOpen, setUrlOpen] = useState(!!sharedUrl);
|
||||||
const [query, setQuery] = useState(initialQuery);
|
const [query, setQuery] = useState(initialQuery);
|
||||||
const [, startTransition] = useTransition();
|
const [, startTransition] = useTransition();
|
||||||
|
|
||||||
@@ -314,7 +321,7 @@ export function RecipesHeader({
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<AiGenerateDialog open={aiOpen} onOpenChange={setAiOpen} />
|
<AiGenerateDialog open={aiOpen} onOpenChange={setAiOpen} />
|
||||||
<UrlImportDialog open={urlOpen} onOpenChange={setUrlOpen} />
|
<UrlImportDialog open={urlOpen} onOpenChange={setUrlOpen} initialUrl={sharedUrl} autoImport={!!sharedUrl} />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useState } from "react";
|
import { useEffect, useRef, useState } from "react";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import { Link2, Loader2 } from "lucide-react";
|
import { Link2, Loader2 } from "lucide-react";
|
||||||
@@ -25,15 +25,23 @@ type ImportedRecipe = {
|
|||||||
export function UrlImportDialog({
|
export function UrlImportDialog({
|
||||||
open,
|
open,
|
||||||
onOpenChange,
|
onOpenChange,
|
||||||
|
initialUrl,
|
||||||
|
autoImport,
|
||||||
}: {
|
}: {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
onOpenChange: (open: boolean) => void;
|
onOpenChange: (open: boolean) => void;
|
||||||
|
/** Prefills (and, with autoImport, triggers) the import — used by the OS
|
||||||
|
* Share Target flow (apps/web/app/(app)/recipes/page.tsx) so sharing a
|
||||||
|
* link into the installed PWA lands here already filled in. */
|
||||||
|
initialUrl?: string;
|
||||||
|
autoImport?: boolean;
|
||||||
}) {
|
}) {
|
||||||
const t = useTranslations("recipe");
|
const t = useTranslations("recipe");
|
||||||
const tCommon = useTranslations("common");
|
const tCommon = useTranslations("common");
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [url, setUrl] = useState("");
|
const [url, setUrl] = useState(initialUrl ?? "");
|
||||||
const [importing, setImporting] = useState(false);
|
const [importing, setImporting] = useState(false);
|
||||||
|
const autoImportFired = useRef(false);
|
||||||
|
|
||||||
async function handleImport() {
|
async function handleImport() {
|
||||||
if (!url.trim()) return;
|
if (!url.trim()) return;
|
||||||
@@ -77,6 +85,14 @@ export function UrlImportDialog({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (open && autoImport && initialUrl?.trim() && !autoImportFired.current) {
|
||||||
|
autoImportFired.current = true;
|
||||||
|
void handleImport();
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [open, autoImport, initialUrl]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||||
<DialogContent className="max-w-xl">
|
<DialogContent className="max-w-xl">
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// Mirrors CHANGELOG.md at the repo root — update both together.
|
// Mirrors CHANGELOG.md at the repo root — update both together.
|
||||||
export const APP_VERSION = "0.66.0";
|
export const APP_VERSION = "0.67.0";
|
||||||
|
|
||||||
export type ChangelogEntry = {
|
export type ChangelogEntry = {
|
||||||
version: string;
|
version: string;
|
||||||
@@ -11,6 +11,13 @@ export type ChangelogEntry = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const CHANGELOG: ChangelogEntry[] = [
|
export const CHANGELOG: ChangelogEntry[] = [
|
||||||
|
{
|
||||||
|
version: "0.67.0",
|
||||||
|
date: "2026-07-21 09:30",
|
||||||
|
added: [
|
||||||
|
"Epicure now registers as an OS share target (Chromium/Android, once installed): share a recipe link from another app's share sheet and it opens straight into the URL-import flow, pre-filled and auto-imported. Safari has no equivalent API — Chromium/Android only, same restriction as the install-prompt banner.",
|
||||||
|
],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
version: "0.66.0",
|
version: "0.66.0",
|
||||||
date: "2026-07-21 09:00",
|
date: "2026-07-21 09:00",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@epicure/web",
|
"name": "@epicure/web",
|
||||||
"version": "0.66.0",
|
"version": "0.67.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev",
|
"dev": "next dev",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "epicure",
|
"name": "epicure",
|
||||||
"version": "0.66.0",
|
"version": "0.67.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "pnpm --filter web dev",
|
"dev": "pnpm --filter web dev",
|
||||||
|
|||||||
Reference in New Issue
Block a user