Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
feat[ios]: share target (#2984)
Peter Chinman607b950575d2
diff --git a/js/app/bun.lock b/js/app/bun.locknew file mode 100644index 0000000000..e69de29bb2diff --git a/js/app/package.json b/js/app/package.jsonindex 3dbb8e7718..de2e51bae5 100644--- a/js/app/package.json+++ b/js/app/package.json@@ -108,7 +108,7 @@"tabbable": "^6.2.0","tailwind-merge": "^3.4.0","tailwindcss": "^4.2.4",- "tauri-plugin-safe-area-insets": "^0.1.0",+"tauri-plugin-safe-area-insets": "^0.1.0","ts-pattern": "^5.9.0","unicode-emoji-json": "^0.8.0","uuid": "^10.0.0",diff --git a/js/app/packages/app/component/Layout.tsx b/js/app/packages/app/component/Layout.tsxindex 5c3b459d6c..4df293ccec 100644--- a/js/app/packages/app/component/Layout.tsx+++ b/js/app/packages/app/component/Layout.tsx@@ -20,6 +20,7 @@ import { BundleUpdateProgressBar } from './BundleUpdateProgressBar';import { DevStatusBar } from './DevStatusBar';import { GlobalBulkEditEntityModal } from './bulk-edit-entity/BulkEditEntityModal';import { GlobalShareModal } from './global-share-modal/GlobalShareModal';+import { IosShareSheet } from './ios-share-sheet/IosShareSheet';import { MacroMcpSetupModal } from './macro-mcp-setup-modal/MacroMcpSetupModal';import { CommandMenu } from './command';import GlobalShortcuts from './GlobalHotkeys';@@ -136,6 +137,7 @@ function LayoutInner(props: RouteSectionProps) {</Suspense><GlobalBulkEditEntityModal /><GlobalShareModal />+ <IosShareSheet /><MacroMcpSetupModal /></Show><Showdiff --git a/js/app/packages/app/component/ios-share-sheet/IosShareSheet.tsx b/js/app/packages/app/component/ios-share-sheet/IosShareSheet.tsxnew file mode 100644index 0000000000..ccf116019a--- /dev/null+++ b/js/app/packages/app/component/ios-share-sheet/IosShareSheet.tsx@@ -0,0 +1,538 @@+import { MobileDrawer } from '@app/component/mobile/MobileDrawer';+import { MarkdownShell } from '@core/component/LexicalMarkdown/builder/MarkdownShell';+import { useUserId } from '@core/context/user';+import { isMobile } from '@core/mobile/isMobile';+import { RecipientSelector } from '@core/component/RecipientSelector';+import { toast } from '@core/component/Toast/Toast';+import { useCombinedRecipients } from '@core/signal/useCombinedRecipient';+import type { WithCustomUserInput } from '@core/user';+import { invalidateContacts } from '@core/user/contactService';+import { getDestinationFromOptions } from '@core/util/destination';+import { isErr, throwOnErr } from '@core/util/maybeResult';+import {+ chatRuleset,+ handleFileFolderDrop,+ uploadFile,+} from '@core/util/upload';+import { Button } from '@ui/components/Button';+import {+ FormatButtons,+ Input,+ applyInlineFormat,+ applyNodeFormat,+ createConfiguredChannelMarkdownEditor,+ createInputAttachmentTracker,+ createInputState,+ createMentionsTracker,+ uploadInputAttachments,+ type InputAttachmentData,+ type InputAttachmentKind,+ type InputAttachmentTracker,+ type InputSnapshot,+} from '@channel/Input';+import { ChannelInputContainer } from '@channel/Input/ChannelInputContainer';+import { buildPostMessageRequest } from '@channel/Input/message-payload';+import { hasSendableInputContent } from '@channel/Input/utils/sendable-content';+import { getAttachmentKindFromFile } from '@channel/Input/utils/file-helpers';+import type {+ PendingShareFile,+ UploadPendingShareFileArgs,+} from '@macro/tauri';+import { useShareTarget, useTauri } from '@macro/tauri';+import { invalidateListChannels } from '@queries/channel/channels';+import { commsServiceClient } from '@service-comms/client';+import { staticFileClient } from '@service-static-files/client';+import { isIOS } from '@solid-primitives/platform';+import {+ ErrorBoundary,+ createEffect,+ createSignal,+ on,+ onCleanup,+ type Accessor,+ Show,+} from 'solid-js';++// Use the current staged file tokens as the share-session identity.+function pendingShareBatchKey(files: readonly PendingShareFile[]): string {+ return files.map((file) => file.token).join('|');+}++function getPendingShareAttachmentKind(+ file: Pick<PendingShareFile, 'name' | 'mimeType'>+): InputAttachmentKind {+ return getAttachmentKindFromFile({+ name: file.name,+ type: file.mimeType,+ });+}++type ShareSheetAttachmentKind = Extract<InputAttachmentKind, 'image' | 'video'>;++function buildPendingAttachment(+ file: PendingShareFile,+ pendingId: string,+ kind: ShareSheetAttachmentKind+): InputAttachmentData {+ return {+ id: pendingId,+ name: file.name,+ kind,+ pending: true,+ previewSrc: kind === 'image' ? file.previewSrc : undefined,+ };+}++function buildUploadedAttachment(+ file: PendingShareFile,+ staticFileId: string,+ kind: ShareSheetAttachmentKind+): InputAttachmentData {+ return {+ id: staticFileId,+ name: file.name,+ kind,+ previewSrc: file.previewSrc,+ };+}++async function uploadPendingShareAttachment(options: {+ file: PendingShareFile;+ tracker: InputAttachmentTracker;+ uploadPendingShareFile:+ | ((args: UploadPendingShareFileArgs) => Promise<void>)+ | undefined;+ isActive: () => boolean;+}) {+ const kind = getPendingShareAttachmentKind(options.file);+ // The iOS share extension only hands the app images and videos today, and+ // this upload path only creates static-file attachments for those media types.+ if (kind === 'document') {+ toast.failure(`Can't share ${options.file.name} from iOS yet`);+ return;+ }++ const pendingId = `pending-share:${options.file.token}`;++ options.tracker.addAttachment(+ buildPendingAttachment(options.file, pendingId, kind)+ );++ try {+ const result = await throwOnErr(() =>+ staticFileClient.makePresignedUrl({+ file_name: options.file.name,+ content_type: options.file.mimeType,+ })+ );++ if (!options.uploadPendingShareFile) {+ throw new Error('Missing native shared file uploader');+ }++ await options.uploadPendingShareFile({+ token: options.file.token,+ uploadUrl: result.upload_url,+ mimeType: options.file.mimeType,+ });++ if (!options.isActive()) return;++ options.tracker.removeAttachment(pendingId);+ options.tracker.addAttachment(+ buildUploadedAttachment(options.file, result.id, kind)+ );+ } catch (error) {+ if (!options.isActive()) return;++ options.tracker.removeAttachment(pendingId);+ console.error('failed to upload iOS shared file', {+ file: options.file,+ error,+ });+ toast.failure(`Failed to upload ${options.file.name}`);+ }+}++function ShareSheetHeaderActions(props: {+ canSend: Accessor<boolean>;+ handleCancel: () => void;+ handleSend: () => void;+}) {+ return (+ <div class="shrink-0 flex items-center justify-between px-3 pb-3 text-sm font-medium text-ink min-h-11">+ <Button+ variant="ghost"+ size="sm"+ onClick={props.handleCancel}+ class="pl-0"+ >+ Cancel+ </Button>+ <Button+ variant="ghost"+ size="sm"+ class="shrink-0 ml-2 pl-2 disabled:text-ink-muted text-accent"+ disabled={!props.canSend()}+ onClick={(event) => {+ event.preventDefault();+ props.handleSend();+ }}+ >+ Send+ </Button>+ </div>+ );+}++function ShareSheetComposerError(_props: { error: unknown }) {+ return (+ <div class="macro-message-width flex min-h-32 w-full flex-col items-center justify-center gap-2 rounded-[5px] border border-edge-muted bg-input px-4 py-6 text-center">+ <p class="text-sm text-ink">Couldn't load the composer.</p>+ <p class="text-xs text-ink-muted">+ Close the sheet and try sharing again.+ </p>+ </div>+ );+}++function IosShareSheetComposer(props: {+ batchKey: string;+ handleCancel: () => void;+}) {+ const shareTarget = useShareTarget();+ const userId = useUserId();+ const { all: destinationOptions } = useCombinedRecipients();+ const attachmentTracker = createInputAttachmentTracker();+ const composerId = crypto.randomUUID();+ const mentionsTracker = createMentionsTracker();+ const [scrollContainer, setScrollContainer] = createSignal<HTMLElement>();+ let clearComposer = () => {};++ const [selectedOptions, setSelectedOptions] = createSignal<+ WithCustomUserInput<'user' | 'contact' | 'channel'>[]+ >([]);++ createEffect(+ on(+ () => props.batchKey,+ () => {+ const files = shareTarget?.pendingShareFiles() ?? [];+ if (files.length === 0) return;++ let active = true;+ onCleanup(() => {+ active = false;+ });++ void (async () => {+ await Promise.allSettled(+ files.map((file) =>+ uploadPendingShareAttachment({+ file,+ tracker: attachmentTracker,+ uploadPendingShareFile: shareTarget?.uploadPendingShareFile,+ isActive: () => active,+ })+ )+ );+ })();+ }+ )+ );++ const resolveDestinationChannelId = async () => {+ const options = selectedOptions();++ if (options.length === 0) {+ toast.failure('Select a recipient');+ throw new Error('No recipient selected for iOS share sheet');+ }++ const destination = getDestinationFromOptions(options);++ if (destination.type === 'channel') {+ return destination.id;+ }++ if (destination.users.length === 0) {+ toast.failure('Select a valid recipient');+ throw new Error('No valid recipients selected for iOS share sheet');+ }++ const result =+ destination.users.length === 1+ ? await commsServiceClient.getOrCreateDirectMessage({+ recipient_id: destination.users[0],+ })+ : await commsServiceClient.getOrCreatePrivateChannel({+ recipients: destination.users,+ });++ if (isErr(result)) {+ toast.failure('Failed to open channel');+ throw new Error('Failed to resolve share destination channel');+ }++ return result[1].channel_id;+ };++ const handleSend = async (snapshot: InputSnapshot) => {+ const senderId = userId();+ if (!senderId) {+ toast.failure('Failed to send message');+ throw new Error('Missing sender id for iOS share sheet send');+ }++ const channelId = await resolveDestinationChannelId();+ const message = buildPostMessageRequest({ snapshot });++ const result = await commsServiceClient.postMessage({+ channel_id: channelId,+ message,+ });++ if (isErr(result)) {+ toast.failure('Failed to send message');+ throw new Error('Failed to post shared message');+ }++ invalidateListChannels();+ invalidateContacts();++ void shareTarget?.clearPendingShareFiles();+ };++ const inputState = createInputState({+ initialInput: {+ mode: 'channel',+ id: `ios-share-input-${composerId}`,+ placeholder: 'Add a message',+ },+ mentions: mentionsTracker.mentions,+ attachmentTracker,+ clearComposer: () => clearComposer(),+ attachFiles: async (files) => {+ await uploadInputAttachments({+ files,+ tracker: attachmentTracker,+ uploadFile: async (file) =>+ uploadFile(file, chatRuleset, { hideProgressIndicator: true }),+ });+ },+ clearInput: () => markdownEditor.controls.clear(),+ callbacks: { onSend: handleSend },+ });++ const markdownEditor = createConfiguredChannelMarkdownEditor({+ namespace: `ios-share-input-${composerId}`,+ enableMentions: true,+ scrollContainer,+ onMentionCreate: (mention) => {+ mentionsTracker.onMentionCreate(mention);+ },+ onMentionRemove: (mention) => {+ mentionsTracker.onMentionRemove(mention);+ },+ onChange: (markdown) => {+ inputState.setValue(markdown);+ },+ onEnter: () => {+ if (isMobile()) return false;+ void inputState.commands.send();+ return true;+ },+ onPasteFilesAndDirs: (files, directories) => {+ void handleFileFolderDrop(files, directories, (entries) =>+ inputState.commands.attachFiles(entries.map((entry) => entry.file))+ );+ },+ onAttachFromDisk: (files) => inputState.commands.attachFiles(files),+ });++ clearComposer = () => {+ if (isIOS) {+ markdownEditor.controls.blur();+ markdownEditor.controls.clear();+ requestAnimationFrame(() => markdownEditor.controls.focus());+ } else {+ markdownEditor.controls.clear();+ }+ };++ const canSend = () =>+ selectedOptions().length > 0 &&+ !inputState.view().hasPendingAttachments &&+ hasSendableInputContent(inputState.view());++ const handleHeaderSend = () => {+ void inputState.commands.send().catch((error) => {+ console.error('failed to send from iOS share sheet header action', error);+ });+ };++ return (+ <div class="flex h-full flex-col">+ <ErrorBoundary+ fallback={(error) => <ShareSheetComposerError error={error} />}+ >+ <ShareSheetHeaderActions+ canSend={canSend}+ handleCancel={props.handleCancel}+ handleSend={handleHeaderSend}+ />+ <MobileDrawer.Label>Recipients</MobileDrawer.Label>+ <MobileDrawer.Section>+ <div class="shrink-0 px-2 py-2">+ <RecipientSelector<'user' | 'contact' | 'channel'>+ placeholder="To: Email or group"+ setSelectedOptions={setSelectedOptions}+ selectedOptions={selectedOptions()}+ options={destinationOptions}+ triggerMode="input"+ noBrackets+ hideBorder+ noPadding+ focusOnMount+ />+ </div>+ </MobileDrawer.Section>++ <MobileDrawer.Section class="min-h-0 flex-1 overflow-y-auto my-3">+ <Input.Root+ input={inputState.view()}+ commands={inputState.commands}+ class="bg-transparent border-none rounded-none"+ >+ <ChannelInputContainer>+ <Input.DropZone+ onDragStart={(valid) => inputState.setIsDraggedOver(valid)}+ onDragEnd={() => inputState.setIsDraggedOver(false)}+ >+ <Input.Layout>+ <Input.DropOverlay />+ <Input.FormatRibbon>+ <FormatButtons+ selectionState={() => markdownEditor.selection}+ onInlineFormat={(format) =>+ applyInlineFormat(markdownEditor.lexical, format)+ }+ onNodeFormat={(format) =>+ applyNodeFormat(markdownEditor.lexical, format)+ }+ />+ </Input.FormatRibbon>+ <Input.EditorShell+ ref={setScrollContainer}+ onClick={(event) => {+ if (!isMobile()) {+ event.stopPropagation();+ markdownEditor.controls.focus();+ }+ }}+ >+ <Input.Editor>+ <MarkdownShell+ config={markdownEditor}+ placeholder={inputState.view().placeholder}+ initialValue={inputState.view().value}+ autofocus={false}+ class="text-sm"+ />+ </Input.Editor>+ </Input.EditorShell>+ <Input.Attachments kind="media" />+ <Input.Attachments kind="document" />+ <Input.Footer>+ <Input.Actions>+ <Input.Actions.Left>+ <Input.AttachFilesAction />+ <Input.ToggleFormatAction />+ </Input.Actions.Left>+ </Input.Actions>+ </Input.Footer>+ </Input.Layout>+ </Input.DropZone>+ </ChannelInputContainer>+ </Input.Root>+ </MobileDrawer.Section>+ </ErrorBoundary>+ </div>+ );+}++export function IosShareSheet() {+ const tauri = useTauri();+ const shareTarget = useShareTarget();++ const pendingFiles = () => shareTarget?.pendingShareFiles() ?? [];+ const shareBatchKey = () => pendingShareBatchKey(pendingFiles());+ const isOpen = () => pendingFiles().length > 0 && tauri?.os === 'ios';+ const [awaitingFirstInteraction, setAwaitingFirstInteraction] =+ createSignal(false);++ createEffect(+ on(isOpen, (open) => {+ if (!open) {+ setAwaitingFirstInteraction(false);+ return;+ }++ setAwaitingFirstInteraction(true);++ const releaseDismissGuard = () => {+ setAwaitingFirstInteraction(false);+ };++ window.addEventListener('pointerdown', releaseDismissGuard, true);+ window.addEventListener('keydown', releaseDismissGuard, true);++ onCleanup(() => {+ window.removeEventListener('pointerdown', releaseDismissGuard, true);+ window.removeEventListener('keydown', releaseDismissGuard, true);+ });+ })+ );++ const handleCancel = () => {+ void shareTarget?.clearPendingShareFiles();+ };++ return (+ <Show when={tauri?.os === 'ios'}>+ <MobileDrawer+ side="bottom"+ open={isOpen()}+ closeOnOutsidePointerStrategy="pointerdown"+ closeOnOutsideFocus={false}+ preventScroll={false}+ preventScrollbarShift={false}+ restoreFocus={false}+ noOutsidePointerEvents={false}+ onOpenChange={(open) => {+ const closeGuardActive =+ !open && isOpen() && awaitingFirstInteraction();++ if (closeGuardActive) return;++ if (!open && isOpen()) handleCancel();+ }}+ >+ <MobileDrawer.Portal>+ <MobileDrawer.Overlay class="fixed inset-0 z-modal-overlay bg-modal-overlay" />+ <MobileDrawer.Content aria-label="Share to Macro">+ <MobileDrawer.Handle />+ <Show when={isOpen() ? shareBatchKey() : undefined} keyed>+ {(batchKey) => (+ <IosShareSheetComposer+ batchKey={batchKey}+ handleCancel={handleCancel}+ />+ )}+ </Show>+ </MobileDrawer.Content>+ </MobileDrawer.Portal>+ </MobileDrawer>+ </Show>+ );+}diff --git a/js/app/packages/app/component/mobile/MobileDrawer.tsx b/js/app/packages/app/component/mobile/MobileDrawer.tsxindex ab0de98569..a364eb6f33 100644--- a/js/app/packages/app/component/mobile/MobileDrawer.tsx+++ b/js/app/packages/app/component/mobile/MobileDrawer.tsx@@ -75,27 +75,43 @@ function MobileDrawerContent(props: ComponentProps<typeof Drawer.Content>) {);}-type MobileDrawerSectionProps<T extends ValidComponent = 'div'> =- ComponentProps<T> & {- as?: T;- };+type ExtendDiv<T extends ValidComponent = 'div'> = ComponentProps<T> & {+ as?: T;+};++/**+ * Component for rendering style Drawer Section Labels.+ */+function MobileDrawerSectionLabel<T extends ValidComponent = 'div'>(+ props: ExtendDiv<T>+) {+ const [local, rest] = splitProps(props, ['as', 'class', 'children']);+ return (+ <Dynamic+ component={local.as ?? 'div'}+ class={cn(+ 'px-3 pb-2 text-xs font-medium text-ink-muted uppercase tracking-wide',+ local.class+ )}+ {...rest}+ >+ {local.children}+ </Dynamic>+ );+}/*** Component for rendering styled Drawer sections.*/function MobileDrawerSection<T extends ValidComponent = 'div'>(- props: MobileDrawerSectionProps<T>+ props: ExtendDiv<T>) {- const [local, rest] = splitProps(props as MobileDrawerSectionProps, [- 'as',- 'class',- 'children',- ]);+ const [local, rest] = splitProps(props, ['as', 'class', 'children']);return (<Layer depth={2}><Dynamiccomponent={(local.as ?? 'div') as ValidComponent}- class={cn('rounded-2xl mx-3 overflow-clip', local.class as string)}+ class={cn('rounded-2xl mx-3 overflow-clip', local.class)}{...rest}>{local.children}@@ -104,6 +120,25 @@ function MobileDrawerSection<T extends ValidComponent = 'div'>();}+/**+ * Component for rendering the standard mobile drawer drag handle.+ */+function MobileDrawerHandle<T extends ValidComponent = 'div'>(+ props: ExtendDiv<T>+) {+ const [local, rest] = splitProps(props, ['as', 'class', 'children']);++ return (+ <Dynamic+ component={local.as ?? 'div'}+ class={cn('flex justify-center pt-3 pb-2 shrink-0', local.class)}+ {...rest}+ >+ {local.children ?? <div class="w-10 h-1 rounded-full bg-edge-muted" />}+ </Dynamic>+ );+}+/*** Wrapper around Corvu's Drawer for mobile. Handles styling and input/virtual keyboard behaviour.*/@@ -123,6 +158,8 @@ export const MobileDrawer = Object.assign(Overlay: Drawer.Overlay,Content: MobileDrawerContent,Close: Drawer.Close,+ Handle: MobileDrawerHandle,Section: MobileDrawerSection,+ Label: MobileDrawerSectionLabel,});diff --git a/js/app/packages/app/component/next-soup/soup-view/SoupEntityActionDrawer.tsx b/js/app/packages/app/component/next-soup/soup-view/SoupEntityActionDrawer.tsxindex a78f1e8cf5..d200d46a97 100644--- a/js/app/packages/app/component/next-soup/soup-view/SoupEntityActionDrawer.tsx+++ b/js/app/packages/app/component/next-soup/soup-view/SoupEntityActionDrawer.tsx@@ -46,10 +46,7 @@ export function SoupEntityActionDrawer() {<MobileDrawer.Portal><MobileDrawer.Overlay class="fixed inset-0 z-modal-overlay bg-modal-overlay pattern-diagonal-4 pattern-edge-muted" /><MobileDrawer.Content aria-label="Entity actions">- {/* Drag handle */}- <div class="flex justify-center pt-3 pb-2 shrink-0">- <div class="w-10 h-1 rounded-full bg-edge-muted" />- </div>+ <MobileDrawer.Handle />{/* Entity preview */}<Show when={drawerState.entity()}>diff --git a/js/app/packages/app/component/next-soup/soup-view/filters-bar/mobile-filter-drawer.tsx b/js/app/packages/app/component/next-soup/soup-view/filters-bar/mobile-filter-drawer.tsxindex c54d0eff73..b4538fe86b 100644--- a/js/app/packages/app/component/next-soup/soup-view/filters-bar/mobile-filter-drawer.tsx+++ b/js/app/packages/app/component/next-soup/soup-view/filters-bar/mobile-filter-drawer.tsx@@ -219,10 +219,7 @@ export const MobileFilterDrawer = () => {<MobileDrawer.Portal><MobileDrawer.Overlay class="fixed inset-0 z-modal-overlay bg-modal-overlay pattern-diagonal-4 pattern-edge-muted" /><MobileDrawer.Content aria-label="Filters" class="h-[80vh]">- {/* Drag handle */}- <div class="flex justify-center pt-3 pb-1 shrink-0">- <div class="w-10 h-1 rounded-full bg-edge-muted" />- </div>+ <MobileDrawer.Handle class="pb-1" />{/* Scrollable filter list */}<div class="relative flex-1 min-h-0">@@ -238,14 +235,9 @@ export const MobileFilterDrawer = () => {>{/* Sort section */}<Show when={sortOptions().length > 0}>- <div class="px-4 pb-2">- <span- id="sort-section-label"- class="text-xs font-medium text-ink-muted uppercase tracking-wide"- >- Sort- </span>- </div>+ <MobileDrawer.Label id="sort-section-label">+ Sort+ </MobileDrawer.Label><MobileDrawer.Sectionrole="radiogroup"aria-labelledby="sort-section-label"@@ -295,11 +287,9 @@ export const MobileFilterDrawer = () => {>{/* Filter section */}<Show when={categories().length > 0 || isTasksView()}>- <div class="px-4 pt-4 pb-2">- <span class="text-xs font-medium text-ink-muted uppercase tracking-wide">- Filters- </span>- </div>+ <MobileDrawer.Label class="pt-4">+ Filters+ </MobileDrawer.Label></Show><div class="flex flex-col">diff --git a/js/app/packages/channel/Input/Attachments.tsx b/js/app/packages/channel/Input/Attachments.tsxindex 67e51a4caf..a329193309 100644--- a/js/app/packages/channel/Input/Attachments.tsx+++ b/js/app/packages/channel/Input/Attachments.tsx@@ -1,23 +1,23 @@+import { MediaImage } from '@channel/Media/MediaImage';+import { MediaVideo } from '@channel/Media/MediaVideo';+import { EntityIcon } from '@core/component/EntityIcon';import {staticFileIdEndpoint,staticFileSizedEndpoint,} from '@core/constant/servers';-import { EntityIcon } from '@core/component/EntityIcon';import SpinnerIcon from '@icon/bold/spinner-gap-bold.svg';import XIcon from '@icon/regular/x.svg';-import { MediaImage } from '@channel/Media/MediaImage';-import { MediaVideo } from '@channel/Media/MediaVideo';import { cn } from '@ui/utils/classname';import {children,createMemo,createSignal,For,+ type JSX,Match,Show,- splitProps,Switch,- type JSX,+ splitProps,} from 'solid-js';import { MediaViewerDialog } from '@channel/Media/MediaViewerDialog';import type { MediaItem } from '@channel/Media/media-items';@@ -61,61 +61,70 @@ function MediaAttachmentItem(props: {onRemove: (attachment: InputAttachmentData) => void;onOpen?: () => void;}) {+ const isPending = () => !!props.attachment.pending;const mediaSrc = () =>props.attachment.kind === 'image'? staticFileSizedEndpoint(props.attachment.id, 'medium'): staticFileIdEndpoint(props.attachment.id);+ const removeButton = () => (+ <RemoveButton+ attachment={props.attachment}+ onRemove={props.onRemove}+ class="absolute -top-2 -right-2 z-[10] rounded-full bg-menu border border-edge-muted opacity-0 group-hover:opacity-100 focus-visible:opacity-100 [@media(hover:none)]:opacity-100"+ />+ );++ const pendingOverlay = () => (+ <Show when={isPending()}>+ <div class="absolute inset-0 flex items-center justify-center rounded-2xl">+ <SpinnerIcon class="w-4 h-4 animate-spin" />+ </div>+ </Show>+ );+return (<div class="ph-no-capture relative group">- <Show- when={!props.attachment.pending && props.attachment.kind === 'image'}+ <Switchfallback={- <Show- when={- !props.attachment.pending && props.attachment.kind === 'video'- }- fallback={- <div class="flex flex-col items-center justify-center gap-2 w-[60px] h-[60px] border border-edge-muted rounded-md bg-menu">- <SpinnerIcon class="w-4 h-4 animate-spin" />- </div>- }- >- <button type="button" onClick={() => props.onOpen?.()}>- <MediaVideo.Root class="size-23 group overflow-hidden border border-edge bg-menu">- <MediaVideo.Preview- src={mediaSrc()}- class="size-full object-cover"- />- <MediaVideo.PlayOverlay />- </MediaVideo.Root>- </button>- <RemoveButton- attachment={props.attachment}- onRemove={props.onRemove}- class="absolute -top-2 -right-2 z-10 rounded-full bg-menu border border-edge-muted opacity-0 group-hover:opacity-100 focus-visible:opacity-100 [@media(hover:none)]:opacity-100"- />- </Show>+ <div class="size-23 rounded-2xl border border-edge bg-menu" />}>- <MediaImage.Root>+ <Match+ when={+ props.attachment.kind === 'image' &&+ (!isPending() || props.attachment.previewSrc)+ }+ >+ <MediaImage.Root>+ <button type="button" onClick={() => props.onOpen?.()}>+ <MediaImage.Image+ src={mediaSrc()}+ previewSrc={props.attachment.previewSrc}+ class="size-23 select-none rounded-2xl border border-edge object-cover"+ width={92}+ height={92}+ loading="lazy"+ fallback={<MediaImage.Fallback square />}+ />+ </button>+ </MediaImage.Root>+ </Match>++ <Match when={props.attachment.kind === 'video' && !isPending()}><button type="button" onClick={() => props.onOpen?.()}>- <MediaImage.Image- src={mediaSrc()}- class="size-23 select-none rounded-2xl border border-edge object-cover"- width={92}- height={92}- loading="lazy"- fallback={<MediaImage.Fallback square />}- />+ <MediaVideo.Root class="size-23 group overflow-hidden border border-edge bg-menu">+ <MediaVideo.Preview+ src={mediaSrc()}+ class="size-full object-cover"+ />+ <MediaVideo.PlayOverlay />+ </MediaVideo.Root></button>- <RemoveButton- attachment={props.attachment}- onRemove={props.onRemove}- class="absolute -top-2 -right-2 z-10 rounded-full bg-menu border border-edge-muted opacity-0 group-hover:opacity-100 focus-visible:opacity-100 [@media(hover:none)]:opacity-100"- />- </MediaImage.Root>- </Show>+ </Match>+ </Switch>+ {pendingOverlay()}+ {removeButton()}</div>);}diff --git a/js/app/packages/channel/Input/types.ts b/js/app/packages/channel/Input/types.tsindex cc695f90a8..c118973101 100644--- a/js/app/packages/channel/Input/types.ts+++ b/js/app/packages/channel/Input/types.ts@@ -11,6 +11,8 @@ export type InputAttachmentData = {kind: InputAttachmentKind;iconType?: EntityIconSelector;pending?: boolean;+ /** Preview URL used while uploading or until the final media source has loaded. */+ previewSrc?: string;/** Image/video width in pixels (set after upload). */width?: number;/** Image/video height in pixels (set after upload). */diff --git a/js/app/packages/channel/Media/MediaImage.tsx b/js/app/packages/channel/Media/MediaImage.tsxindex 08121d5448..3832692c06 100644--- a/js/app/packages/channel/Media/MediaImage.tsx+++ b/js/app/packages/channel/Media/MediaImage.tsx@@ -1,7 +1,14 @@import Spinner from '@phosphor-icons/core/bold/spinner-gap-bold.svg?component-solid';import { cn } from '@ui/utils/classname';import { internalDrag } from '@core/directive/internalDragState';-import { type ParentProps, type JSX, Show, createSignal } from 'solid-js';+import {+ type ParentProps,+ type JSX,+ Show,+ createEffect,+ createSignal,+ on,+} from 'solid-js';false && internalDrag;const ATTACHMENT_TILE_SIZE = 92;@@ -51,6 +58,8 @@ function Fallback(props: {function Image(props: {src: string;+ // A source for image preview, e.g. used when we have a local url we can display while the image gets uploaded, as in iOS when sharing images.+ previewSrc?: string;onOpen?: () => void;class?: string;width?: number;@@ -61,9 +70,33 @@ function Image(props: {}) {const [loaded, setLoaded] = createSignal(false);+ createEffect(+ on(+ () => props.src,+ () => {+ setLoaded(false);+ }+ )+ );+return (<>- <Show when={!loaded()}>{props.fallback}</Show>+ <Show when={!loaded()}>+ <Show when={props.previewSrc} fallback={props.fallback}>+ {(previewSrc) => (+ <img+ class={cn(props.class, props.onOpen && 'cursor-pointer')}+ src={previewSrc()}+ alt="preview"+ width={props.width}+ height={props.height}+ style={props.style}+ loading={props.loading}+ onClick={() => props.onOpen?.()}+ />+ )}+ </Show>+ </Show><imgclass={cn(props.class, props.onOpen && 'cursor-pointer')}classList={{ invisible: !loaded(), absolute: !loaded() }}diff --git a/js/app/packages/tauri/src/ShareTargetProvider.tsx b/js/app/packages/tauri/src/ShareTargetProvider.tsxnew file mode 100644index 0000000000..cdd0028fa6--- /dev/null+++ b/js/app/packages/tauri/src/ShareTargetProvider.tsx@@ -0,0 +1,209 @@+import { convertFileSrc, invoke } from '@tauri-apps/api/core';+import { listen } from '@tauri-apps/api/event';+import type { OsType } from '@tauri-apps/plugin-os';+import {+ type Accessor,+ createContext,+ createSignal,+ type JSX,+ onCleanup,+ onMount,+ useContext,+} from 'solid-js';++interface StagedSharedFileData {+ token: string;+ name: string;+ mime_type: string;+ size: number;+ preview_path?: string | null;+}++export interface PendingShareFile {+ token: string;+ name: string;+ mimeType: string;+ size: number;+ previewSrc?: string;+}++export interface UploadPendingShareFileArgs {+ token: string;+ uploadUrl: string;+ mimeType: string;+}++interface ShareFilesReadyPayload {+ filenames: string[];+}++function shareFileNamesMatch(+ left: readonly string[],+ right: readonly string[]+): boolean {+ return (+ left.length === right.length &&+ left.every((name, index) => name === right[index])+ );+}++async function getPendingShareFilenames(): Promise<string[]> {+ return invoke<string[]>('get_pending_share_filenames');+}++async function popSharedFiles(+ filenames: string[]+): Promise<PendingShareFile[]> {+ const results = await invoke<StagedSharedFileData[]>('pop_shared_files', {+ filenames,+ });+ return results.map(({ token, name, mime_type, size, preview_path }) => ({+ token,+ name,+ mimeType: mime_type,+ size,+ previewSrc: preview_path ? convertFileSrc(preview_path) : undefined,+ }));+}++async function clearSharedFiles(tokens: string[]): Promise<void> {+ await invoke('clear_shared_files', { tokens });+}++async function uploadPendingShareFile(+ args: UploadPendingShareFileArgs+): Promise<void> {+ await invoke('upload_shared_file_to_presigned_url', {+ token: args.token,+ uploadUrl: args.uploadUrl,+ mimeType: args.mimeType,+ });+}++interface ShareTargetContextValue {+ pendingShareFiles: Accessor<PendingShareFile[]>;+ uploadPendingShareFile: (args: UploadPendingShareFileArgs) => Promise<void>;+ clearPendingShareFiles: () => Promise<void>;+}++const ShareTargetContext = createContext<ShareTargetContextValue | undefined>(+ undefined+);++export function ShareTargetProvider(props: {+ os: OsType;+ children: JSX.Element;+}) {+ const [pendingShareFiles, setPendingShareFiles] = createSignal<+ PendingShareFile[]+ >([]);+ const [pendingShareFileNames, setPendingShareFileNames] = createSignal<+ string[]+ >([]);++ const clearPendingShareFiles = async () => {+ const files = pendingShareFiles();+ setPendingShareFiles([]);+ setPendingShareFileNames([]);++ if (files.length === 0) {+ return;+ }++ try {+ await clearSharedFiles(files.map((file) => file.token));+ } catch (error) {+ console.error('failed to clear shared files', error);+ }+ };++ const clearLoadedPendingShare = (files: readonly PendingShareFile[]) => {+ setPendingShareFiles([]);+ setPendingShareFileNames([]);++ if (files.length > 0) {+ void clearSharedFiles(files.map((file) => file.token)).catch(() => {});+ }+ };++ onMount(() => {+ if (props.os !== 'ios') {+ return;+ }++ let nextRequestId = 0;++ const loadPendingShareFiles = async (filenames: string[]) => {+ if (filenames.length === 0) return;++ const requestId = ++nextRequestId;++ const previousFilenames = pendingShareFileNames();+ const previousFiles = pendingShareFiles();+ const isSamePendingShare = shareFileNamesMatch(+ previousFilenames,+ filenames+ );++ if (isSamePendingShare && pendingShareFiles().length > 0) {+ return;+ }++ try {+ const files = await popSharedFiles(filenames);++ if (requestId !== nextRequestId) return;++ if (files.length === 0) {+ clearLoadedPendingShare(previousFiles);+ return;+ }++ setPendingShareFiles(files);+ setPendingShareFileNames(filenames);+ if (previousFiles.length > 0 && !isSamePendingShare) {+ void clearSharedFiles(previousFiles.map((file) => file.token)).catch(+ () => {}+ );+ }+ } catch (error) {+ if (requestId !== nextRequestId) return;+ clearLoadedPendingShare(previousFiles);+ console.error('failed to load pending share files', error);+ }+ };++ const unlisten = listen<ShareFilesReadyPayload>(+ 'share-files-ready',+ (event) => void loadPendingShareFiles(event.payload.filenames)+ );++ void (async () => {+ try {+ await unlisten;+ const filenames = await getPendingShareFilenames();+ await loadPendingShareFiles(filenames);+ } catch (error) {+ console.error('failed to initialize iOS share target', error);+ }+ })();++ onCleanup(() => void unlisten.then((fn) => fn()));+ });++ const value: ShareTargetContextValue = {+ pendingShareFiles,+ uploadPendingShareFile,+ clearPendingShareFiles,+ };++ return (+ <ShareTargetContext.Provider value={value}>+ {props.children}+ </ShareTargetContext.Provider>+ );+}++export function useShareTarget() {+ return useContext(ShareTargetContext);+}diff --git a/js/app/packages/tauri/src/TauriProvider.tsx b/js/app/packages/tauri/src/TauriProvider.tsxindex f56cb7a086..acf673aa4d 100644--- a/js/app/packages/tauri/src/TauriProvider.tsx+++ b/js/app/packages/tauri/src/TauriProvider.tsx@@ -19,6 +19,7 @@ import { invoke } from '@tauri-apps/api/core';import { listen } from '@tauri-apps/api/event';import { useTauriNavigationEffect } from './navigation';import { MaybePushNotificationRegistration } from './PushNotification';+import { ShareTargetProvider } from './ShareTargetProvider';type NotAndroid = 'not-android';@@ -46,9 +47,7 @@ function TauriProvider(props: { children: JSX.Element }) {// we only care about this value on android.// ios should use the env(safe-area-inset-top) css properties// this css is not reliably set on android- const [insets, setInsets] = createSignal<NotAndroid | Insets>(- 'not-android' as const- );+ const [insets, setInsets] = createSignal<NotAndroid | Insets>('not-android');const [bundleUpdateStatus, setBundleUpdateStatus] =createSignal<BundleUpdateStatus>({ status: 'Idle' });const [waitingForWifi, setWaitingForWifi] = createSignal(false);@@ -204,7 +203,7 @@ function TauriProvider(props: { children: JSX.Element }) {return (<TauriContext.Provider value={value}>- {props.children}+ <ShareTargetProvider os={value.os}>{props.children}</ShareTargetProvider></TauriContext.Provider>);}diff --git a/js/app/packages/tauri/src/index.ts b/js/app/packages/tauri/src/index.tsindex 14400dbc5f..620ba68464 100644--- a/js/app/packages/tauri/src/index.ts+++ b/js/app/packages/tauri/src/index.ts@@ -1,2 +1,12 @@-export { MaybeTauriProvider, useTauri } from './TauriProvider';+export {+ MaybeTauriProvider,+ useTauri,+ useExpectTauri,+ TauriRouteListener,+} from './TauriProvider';+export { useShareTarget } from './ShareTargetProvider';+export type {+ PendingShareFile,+ UploadPendingShareFileArgs,+} from './ShareTargetProvider';export type { BundleUpdateStatus } from './TauriProvider';diff --git a/js/app/tauri/Cargo.lock b/js/app/tauri/Cargo.lockindex 3f40adc3f8..f3c265c0fe 100644--- a/js/app/tauri/Cargo.lock+++ b/js/app/tauri/Cargo.lock@@ -97,6 +97,7 @@ dependencies = ["mime_guess","navigation_plugin","nom",+ "objc2 0.5.2","reqwest","rootcause","serde",@@ -126,6 +127,7 @@ dependencies = ["tracing-subscriber","url","urlencoding",+ "uuid",][[package]]@@ -417,7 +419,7 @@ version = "0.6.2"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "cdeb9d870516001442e364c5220d3574d2da8dc765554b4a617230d33fa58ef5"dependencies = [- "objc2",+ "objc2 0.6.4",][[package]]@@ -1205,7 +1207,7 @@ dependencies = ["bitflags 2.11.1","block2","libc",- "objc2",+ "objc2 0.6.4",][[package]]@@ -2167,6 +2169,12 @@ dependencies = ["pin-project-lite",]+[[package]]+name = "http-range"+version = "0.1.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "21dec9db110f5f872ed9699c3ecf50cf16f423502706ba5c72462e28d3157573"+[[package]]name = "httparse"version = "1.10.1"@@ -2246,7 +2254,7 @@ dependencies = ["js-sys","log","wasm-bindgen",- "windows-core 0.57.0",+ "windows-core 0.61.2",][[package]]@@ -2764,7 +2772,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "29a16783dd1a47849b8c8133c9cd3eb2112cfbc6901670af3dba47c8bbfb07d3"dependencies = ["cc",- "objc2",+ "objc2 0.6.4","objc2-foundation","time",]@@ -2918,7 +2926,7 @@ dependencies = ["dpi","gtk","keyboard-types",- "objc2",+ "objc2 0.6.4","objc2-app-kit","objc2-core-foundation","objc2-foundation",@@ -3170,6 +3178,22 @@ dependencies = ["libc",]+[[package]]+name = "objc-sys"+version = "0.3.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "cdb91bdd390c7ce1a8607f35f3ca7151b65afc0ff5ff3b34fa350f7d7c7e4310"++[[package]]+name = "objc2"+version = "0.5.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "46a785d4eeff09c14c487497c162e92766fbb3e4059a71840cecc03d9a50b804"+dependencies = [+ "objc-sys",+ "objc2-encode",+]+[[package]]name = "objc2"version = "0.6.4"@@ -3188,7 +3212,7 @@ checksum = "d49e936b501e5c5bf01fda3a9452ff86dc3ea98ad5f283e1455153142d97518c"dependencies = ["bitflags 2.11.1","block2",- "objc2",+ "objc2 0.6.4","objc2-core-foundation","objc2-foundation",]@@ -3200,7 +3224,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "73ad74d880bb43877038da939b7427bba67e9dd42004a18b809ba7d87cee241c"dependencies = ["bitflags 2.11.1",- "objc2",+ "objc2 0.6.4","objc2-foundation",]@@ -3210,7 +3234,7 @@ version = "0.3.2"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "0b402a653efbb5e82ce4df10683b6b28027616a2715e90009947d50b8dd298fa"dependencies = [- "objc2",+ "objc2 0.6.4","objc2-foundation",]@@ -3222,7 +3246,7 @@ checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536"dependencies = ["bitflags 2.11.1","dispatch2",- "objc2",+ "objc2 0.6.4",][[package]]@@ -3233,7 +3257,7 @@ checksum = "e022c9d066895efa1345f8e33e584b9f958da2fd4cd116792e15e07e4720a807"dependencies = ["bitflags 2.11.1","dispatch2",- "objc2",+ "objc2 0.6.4","objc2-core-foundation","objc2-io-surface",]@@ -3244,7 +3268,7 @@ version = "0.3.2"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "e5d563b38d2b97209f8e861173de434bd0214cf020e3423a52624cd1d989f006"dependencies = [- "objc2",+ "objc2 0.6.4","objc2-foundation",]@@ -3254,7 +3278,7 @@ version = "0.3.2"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "ca347214e24bc973fc025fd0d36ebb179ff30536ed1f80252706db19ee452009"dependencies = [- "objc2",+ "objc2 0.6.4","objc2-foundation",]@@ -3265,7 +3289,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "0cde0dfb48d25d2b4862161a4d5fcc0e3c24367869ad306b0c9ec0073bfed92d"dependencies = ["bitflags 2.11.1",- "objc2",+ "objc2 0.6.4","objc2-core-foundation","objc2-core-graphics",]@@ -3294,7 +3318,7 @@ dependencies = ["bitflags 2.11.1","block2","libc",- "objc2",+ "objc2 0.6.4","objc2-core-foundation",]@@ -3305,7 +3329,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "180788110936d59bab6bd83b6060ffdfffb3b922ba1396b312ae795e1de9d81d"dependencies = ["bitflags 2.11.1",- "objc2",+ "objc2 0.6.4","objc2-core-foundation",]@@ -3316,7 +3340,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "96c1358452b371bf9f104e21ec536d37a650eb10f7ee379fff67d2e08d537f1f"dependencies = ["bitflags 2.11.1",- "objc2",+ "objc2 0.6.4","objc2-core-foundation","objc2-foundation",]@@ -3329,7 +3353,7 @@ checksum = "d87d638e33c06f577498cbcc50491496a3ed4246998a7fbba7ccb98b1e7eab22"dependencies = ["bitflags 2.11.1","block2",- "objc2",+ "objc2 0.6.4","objc2-cloud-kit","objc2-core-data","objc2-core-foundation",@@ -3348,7 +3372,7 @@ version = "0.3.2"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "9df9128cbbfef73cda168416ccf7f837b62737d748333bfe9ab71c245d76613e"dependencies = [- "objc2",+ "objc2 0.6.4","objc2-foundation",]@@ -3360,7 +3384,7 @@ checksum = "b2e5aaab980c433cf470df9d7af96a7b46a9d892d521a2cbbb2f8a4c16751e7f"dependencies = ["bitflags 2.11.1","block2",- "objc2",+ "objc2 0.6.4","objc2-app-kit","objc2-core-foundation","objc2-foundation",@@ -3425,7 +3449,7 @@ dependencies = ["android_system_properties","log","nix 0.30.1",- "objc2",+ "objc2 0.6.4","objc2-foundation","objc2-ui-kit","serde",@@ -4255,6 +4279,7 @@ dependencies = ["cookie","cookie_store","encoding_rs",+ "futures-channel","futures-core","futures-util","h2",@@ -4921,7 +4946,7 @@ dependencies = ["bytemuck","js-sys","ndk",- "objc2",+ "objc2 0.6.4","objc2-core-foundation","objc2-core-graphics","objc2-foundation",@@ -5201,7 +5226,7 @@ dependencies = ["log","ndk","ndk-sys",- "objc2",+ "objc2 0.6.4","objc2-app-kit","objc2-foundation","objc2-ui-kit",@@ -5257,12 +5282,13 @@ dependencies = ["gtk","heck 0.5.0","http",+ "http-range","jni","libc","log","mime","muda",- "objc2",+ "objc2 0.6.4","objc2-app-kit","objc2-foundation","objc2-ui-kit",@@ -5498,7 +5524,7 @@ dependencies = ["byte-unit","fern","log",- "objc2",+ "objc2 0.6.4","objc2-foundation","serde","serde_json",@@ -5649,7 +5675,7 @@ dependencies = ["gtk","http","jni",- "objc2",+ "objc2 0.6.4","objc2-ui-kit","objc2-web-kit","raw-window-handle",@@ -5672,7 +5698,7 @@ dependencies = ["http","jni","log",- "objc2",+ "objc2 0.6.4","objc2-app-kit","once_cell","percent-encoding",@@ -6215,7 +6241,7 @@ dependencies = ["dirs","libappindicator","muda",- "objc2",+ "objc2 0.6.4","objc2-app-kit","objc2-core-foundation","objc2-core-graphics",@@ -6794,7 +6820,7 @@ version = "0.6.0"source = "registry+https://github.com/rust-lang/crates.io-index"checksum = "d9bec5a31f3f9362f2258fd0e9c9dd61a9ca432e7306cc78c444258f0dce9a9c"dependencies = [- "objc2",+ "objc2 0.6.4","objc2-app-kit","objc2-core-foundation","objc2-foundation",@@ -7527,7 +7553,7 @@ dependencies = ["jni","libc","ndk",- "objc2",+ "objc2 0.6.4","objc2-app-kit","objc2-core-foundation","objc2-foundation",diff --git a/js/app/tauri/src-tauri/Cargo.toml b/js/app/tauri/src-tauri/Cargo.tomlindex 6fdae7b8bd..450b46fea1 100644--- a/js/app/tauri/src-tauri/Cargo.toml+++ b/js/app/tauri/src-tauri/Cargo.toml@@ -31,9 +31,11 @@ serde_json = "1.0"tracing-oslog = { version = "0.3" }nom = "8.0.0"-reqwest = { workspace = true, features = ["cookies"] }+reqwest = { workspace = true, features = [+ "blocking",+ "cookies"] }serde_qs = "0.15.0"-tauri = { workspace = true, features = [] }+tauri = { workspace = true, features = ["protocol-asset"] }tauri-plugin-deep-link = "=2.4.5"tauri-plugin-http = { git = "https://github.com/seanaye/plugins-workspace", branch = "seanaye/feat/websocket-cookies", features = ["unsafe-headers",@@ -48,6 +50,7 @@ tracing = { workspace = true }tracing-subscriber = { version = "0.3.20", features = ["env-filter"] }url = { workspace = true }urlencoding = "2.1.3"+uuid = { version = "1.18.1", features = ["v4"] }# system notifications for when the app is opentauri-plugin-notification = "2"# push notifications for mobile (when app is closed)@@ -68,3 +71,6 @@ tauri-plugin-haptics = "2"[target.'cfg(target_os = "ios")'.dependencies]tauri-plugin-input-accessory = { path = "../input_accessory_plugin" }+# Used to call NSFileManager from Rust to get the App Group container path.+# This version is already in the dependency tree via wry/tao.+objc2 = "0.5"diff --git a/js/app/tauri/src-tauri/Info.ios.plist b/js/app/tauri/src-tauri/Info.ios.plistindex 35c391411f..54753189ad 100644--- a/js/app/tauri/src-tauri/Info.ios.plist+++ b/js/app/tauri/src-tauri/Info.ios.plist@@ -2,6 +2,10 @@<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plist version="1.0"><dict>+ <key>LSApplicationQueriesSchemes</key>+ <array>+ <string>macro</string>+ </array><key>NSCameraUsageDescription</key><string>This app needs access to the camera to take photos and videos for attachments.</string><key>NSMicrophoneUsageDescription</key>diff --git a/js/app/tauri/src-tauri/capabilities/mobile.json b/js/app/tauri/src-tauri/capabilities/mobile.jsonindex d4dc448d89..f902f77085 100644--- a/js/app/tauri/src-tauri/capabilities/mobile.json+++ b/js/app/tauri/src-tauri/capabilities/mobile.json@@ -16,4 +16,4 @@"auth:allow-authenticate","device-info:default"]-}\ No newline at end of file+}diff --git a/js/app/tauri/src-tauri/gen/apple/NotificationServiceExtension/Info.plist b/js/app/tauri/src-tauri/gen/apple/NotificationServiceExtension/Info.plistindex 27767e9023..d64f9adfd8 100644--- a/js/app/tauri/src-tauri/gen/apple/NotificationServiceExtension/Info.plist+++ b/js/app/tauri/src-tauri/gen/apple/NotificationServiceExtension/Info.plist@@ -15,7 +15,7 @@<key>CFBundleName</key><string>$(PRODUCT_NAME)</string><key>CFBundlePackageType</key>- <string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>+ <string>XPC!</string><key>CFBundleShortVersionString</key><string>$(MARKETING_VERSION)</string><key>CFBundleVersion</key>diff --git a/js/app/tauri/src-tauri/gen/apple/ShareExtension/Info.plist b/js/app/tauri/src-tauri/gen/apple/ShareExtension/Info.plistnew file mode 100644index 0000000000..fa15514f34--- /dev/null+++ b/js/app/tauri/src-tauri/gen/apple/ShareExtension/Info.plist@@ -0,0 +1,45 @@+<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">+<plist version="1.0">+<dict>+ <key>CFBundleDevelopmentRegion</key>+ <string>$(DEVELOPMENT_LANGUAGE)</string>+ <key>CFBundleDisplayName</key>+ <string>Share to Macro</string>+ <key>CFBundleExecutable</key>+ <string>$(EXECUTABLE_NAME)</string>+ <key>CFBundleIdentifier</key>+ <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>+ <key>CFBundleInfoDictionaryVersion</key>+ <string>6.0</string>+ <key>CFBundleName</key>+ <string>$(PRODUCT_NAME)</string>+ <key>CFBundlePackageType</key>+ <string>XPC!</string>+ <key>CFBundleShortVersionString</key>+ <string>2.0.2</string>+ <key>CFBundleVersion</key>+ <string>142</string>+ <key>LSApplicationQueriesSchemes</key>+ <array>+ <string>macro</string>+ </array>+ <key>NSExtension</key>+ <dict>+ <key>NSExtensionAttributes</key>+ <dict>+ <key>NSExtensionActivationRule</key>+ <dict>+ <key>NSExtensionActivationSupportsImageWithMaxCount</key>+ <integer>10</integer>+ <key>NSExtensionActivationSupportsMovieWithMaxCount</key>+ <integer>5</integer>+ </dict>+ </dict>+ <key>NSExtensionPointIdentifier</key>+ <string>com.apple.share-services</string>+ <key>NSExtensionPrincipalClass</key>+ <string>$(PRODUCT_MODULE_NAME).ShareViewController</string>+ </dict>+</dict>+</plist>diff --git a/js/app/tauri/src-tauri/gen/apple/ShareExtension/ShareExtension.entitlements b/js/app/tauri/src-tauri/gen/apple/ShareExtension/ShareExtension.entitlementsnew file mode 100644index 0000000000..108042a9ac--- /dev/null+++ b/js/app/tauri/src-tauri/gen/apple/ShareExtension/ShareExtension.entitlements@@ -0,0 +1,10 @@+<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">+<plist version="1.0">+<dict>+ <key>com.apple.security.application-groups</key>+ <array>+ <string>group.com.macro.app.prod</string>+ </array>+</dict>+</plist>diff --git a/js/app/tauri/src-tauri/gen/apple/ShareExtension/ShareViewController.swift b/js/app/tauri/src-tauri/gen/apple/ShareExtension/ShareViewController.swiftnew file mode 100644index 0000000000..bcce1cf28d--- /dev/null+++ b/js/app/tauri/src-tauri/gen/apple/ShareExtension/ShareViewController.swift@@ -0,0 +1,167 @@+import UIKit+import UniformTypeIdentifiers++class ShareViewController: UIViewController {++ private let appGroupId = "group.com.macro.app.prod"+ private let appURLScheme = "macro"++ // MARK: - Lifecycle++ override func viewDidLoad() {+ super.viewDidLoad()+ // A fully transparent view can cause the system to dismiss the extension+ // before it has a chance to do anything. Use a near-transparent scrim instead.+ view.backgroundColor = UIColor.black.withAlphaComponent(0.01)++ DispatchQueue.main.asyncAfter(deadline: .now() + 15) { [weak self] in+ self?.complete()+ }++ processSharedItems()+ }++ // MARK: - Main flow++ private func processSharedItems() {+ guard+ let extensionItem = extensionContext?.inputItems.first as? NSExtensionItem,+ let attachments = extensionItem.attachments,+ !attachments.isEmpty+ else {+ complete()+ return+ }++ let group = DispatchGroup()+ var savedFilenames: [String] = []+ let lock = NSLock()++ for provider in attachments {+ let imageType = UTType.image.identifier+ let movieType = UTType.movie.identifier++ if provider.hasItemConformingToTypeIdentifier(imageType) {+ group.enter()+ loadData(from: provider, typeIdentifier: imageType, defaultExt: "jpg") { [weak self] data, ext in+ defer { group.leave() }+ if let data, let name = self?.saveToAppGroup(data: data, ext: ext) {+ lock.withLock { savedFilenames.append(name) }+ }+ }+ } else if provider.hasItemConformingToTypeIdentifier(movieType) {+ group.enter()+ loadData(from: provider, typeIdentifier: movieType, defaultExt: "mp4") { [weak self] data, ext in+ defer { group.leave() }+ if let data, let name = self?.saveToAppGroup(data: data, ext: ext) {+ lock.withLock { savedFilenames.append(name) }+ }+ }+ }+ }++ group.notify(queue: .main) { [weak self] in+ guard let self else { return }+ if savedFilenames.isEmpty {+ self.complete()+ } else {+ self.openMainApp(filenames: savedFilenames)+ }+ }+ }++ // MARK: - Data loading++ /// Load raw data from an NSItemProvider.+ /// Uses loadDataRepresentation (designed for Share Extensions) and falls back+ /// to loadItem if that fails.+ private func loadData(+ from provider: NSItemProvider,+ typeIdentifier: String,+ defaultExt: String,+ completion: @escaping (Data?, String) -> Void+ ) {+ provider.loadDataRepresentation(forTypeIdentifier: typeIdentifier) { data, _ in+ if let data {+ completion(data, defaultExt)+ return+ }++ // Fallback: loadItem covers UIImage / NSURL paths+ provider.loadItem(forTypeIdentifier: typeIdentifier, options: nil) { item, _ in+ if let url = item as? URL, url.isFileURL {+ let ext = url.pathExtension.isEmpty ? defaultExt : url.pathExtension+ completion(try? Data(contentsOf: url), ext)+ } else if let image = item as? UIImage {+ completion(image.jpegData(compressionQuality: 0.9), "jpg")+ } else if let rawData = item as? Data {+ completion(rawData, defaultExt)+ } else {+ completion(nil, defaultExt)+ }+ }+ }+ }++ // MARK: - App Group storage++ private func saveToAppGroup(data: Data, ext: String) -> String? {+ guard let container = FileManager.default.containerURL(+ forSecurityApplicationGroupIdentifier: appGroupId+ ) else {+ return nil+ }++ let filename = "share_\(UUID().uuidString).\(ext)"+ let fileURL = container.appendingPathComponent(filename)+ do {+ try data.write(to: fileURL)+ return filename+ } catch {+ return nil+ }+ }++ // MARK: - Opening the main app++ private func openMainApp(filenames: [String]) {+ var components = URLComponents()+ components.scheme = appURLScheme+ components.host = "share"+ components.queryItems = [+ URLQueryItem(name: "files", value: filenames.joined(separator: ","))+ ]++ guard let url = components.url else {+ complete()+ return+ }++ // Walk up the responder chain looking for the UIApplication instance.+ var foundViaChain = false+ var responder: UIResponder? = self+ while let r = responder {+ if let app = r as? UIApplication {+ app.open(url, options: [:], completionHandler: nil)+ foundViaChain = true+ break+ }+ responder = r.next+ }++ // Fallback: use extensionContext to open the URL.+ // UIApplication.shared is unavailable in extensions; extensionContext?.open+ // is the supported API for launching the host app from any extension type.+ if !foundViaChain {+ extensionContext?.open(url, completionHandler: nil)+ }++ complete()+ }++ // MARK: - Helpers++ private func complete() {+ extensionContext?.completeRequest(returningItems: [], completionHandler: nil)+ }+}diff --git a/js/app/tauri/src-tauri/gen/apple/app.xcodeproj/project.pbxproj b/js/app/tauri/src-tauri/gen/apple/app.xcodeproj/project.pbxprojindex 0b2d943511..35f7f9917f 100644--- a/js/app/tauri/src-tauri/gen/apple/app.xcodeproj/project.pbxproj+++ b/js/app/tauri/src-tauri/gen/apple/app.xcodeproj/project.pbxproj@@ -3,46 +3,57 @@archiveVersion = 1;classes = {};- objectVersion = 63;+ objectVersion = 77;objects = {/* Begin PBXBuildFile section */299814393FFBF154FAD94CA8 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F3673D372C5ABDD1AD6E7067 /* QuartzCore.framework */; };+ 2FBDFDC47F5358109C23AF80 /* ShareExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = F2F6B23901C11426024E1D4E /* ShareExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };3036F7131E55779ABF15BD58 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 02B7F8347F94B067E6B27396 /* LaunchScreen.storyboard */; };31585529C029A01BE249A285 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1E81BD6B453D87B7F7B1597B /* CoreGraphics.framework */; };324A1E9A4258E7911D4DAC39 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9FACFFCB6E3743955F72464C /* Security.framework */; };+ 36C1893A7382FCD5A6A74845 /* libapp.a in Resources */ = {isa = PBXBuildFile; fileRef = CF674524E34966183631754E /* libapp.a */; };+ 395DAD80D2F1C1FDEB4ACA2D /* ShareViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = DE016BCDACB745FDB90321AF /* ShareViewController.swift */; };53CDD0ACFBE8BDF1550B2E53 /* main.mm in Sources */ = {isa = PBXBuildFile; fileRef = 682535EEFE1DA20BE07B123C /* main.mm */; };5C516481BCA83A182C2BCC94 /* assets in Resources */ = {isa = PBXBuildFile; fileRef = 3842AE2A64FB9933D0400EA4 /* assets */; };618672DC8A5E0605441C9935 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0E2B15F176E4B041AE33EEEA /* UIKit.framework */; };836D84C5F07860664DAF79C8 /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D8F57162F5CC7AEDD55F173D /* WebKit.framework */; };+ 84C06806528EC8D5602FB113 /* NotificationService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0EAE3E64C98FE3472A9133C6 /* NotificationService.swift */; };+ 9AEF994676AC5641057C794B /* NotificationServiceExtension.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = FA2CD6184313364E14B6F84E /* NotificationServiceExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };9D59FB167BB4E699DA17D1E9 /* MetalKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 04B56F58E2E44DDE1D67E7B7 /* MetalKit.framework */; };C6BD59C055C986EA4A77FDA2 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = AF1DE57E7D9CF13BB2E0E038 /* Assets.xcassets */; };C869023DDFE275D42F3FBF29 /* libapp.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 39EEC6A55698228E08917A52 /* libapp.a */; };E68F6CFDAED6503ABB4044A5 /* Metal.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CE1209BFDECB28E00189B168 /* Metal.framework */; };- NSE00000001 /* NotificationService.swift in Sources */ = {isa = PBXBuildFile; fileRef = NSE00000002 /* NotificationService.swift */; };- NSE00000003 /* NotificationServiceExtension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = NSE00000004 /* NotificationServiceExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };/* End PBXBuildFile section *//* Begin PBXContainerItemProxy section */- NSE00000005 /* PBXContainerItemProxy */ = {+ 260E1148C62E6A5410483AAF /* PBXContainerItemProxy */ = {isa = PBXContainerItemProxy;containerPortal = A9B1B09F1872768368ACECE2 /* Project object */;proxyType = 1;- remoteGlobalIDString = NSE00000006;+ remoteGlobalIDString = 017A206CDE07C3F290D7A4FA;+ remoteInfo = ShareExtension;+ };+ 2E13E6104415D7AA47EE3C78 /* PBXContainerItemProxy */ = {+ isa = PBXContainerItemProxy;+ containerPortal = A9B1B09F1872768368ACECE2 /* Project object */;+ proxyType = 1;+ remoteGlobalIDString = 097A73617A3B881FE560AF51;remoteInfo = NotificationServiceExtension;};/* End PBXContainerItemProxy section *//* Begin PBXCopyFilesBuildPhase section */- NSE00000007 /* Embed App Extensions */ = {+ 84895F3D2512B6F87AA9E1B3 /* Embed Foundation Extensions */ = {isa = PBXCopyFilesBuildPhase;buildActionMask = 2147483647;dstPath = "";dstSubfolderSpec = 13;files = (- NSE00000003 /* NotificationServiceExtension.appex in Embed App Extensions */,+ 9AEF994676AC5641057C794B /* NotificationServiceExtension.appex in Embed Foundation Extensions */,+ 2FBDFDC47F5358109C23AF80 /* ShareExtension.appex in Embed Foundation Extensions */,);- name = "Embed App Extensions";+ name = "Embed Foundation Extensions";runOnlyForDeploymentPostprocessing = 0;};/* End PBXCopyFilesBuildPhase section */@@ -51,27 +62,31 @@007E478DB8BC37A788C4730F /* app_iOS.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = app_iOS.entitlements; sourceTree = "<group>"; };02B7F8347F94B067E6B27396 /* LaunchScreen.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = LaunchScreen.storyboard; sourceTree = "<group>"; };04B56F58E2E44DDE1D67E7B7 /* MetalKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MetalKit.framework; path = System/Library/Frameworks/MetalKit.framework; sourceTree = SDKROOT; };+ 0534025E6A6DC9BF45F0EC3E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };0E2B15F176E4B041AE33EEEA /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };- 1631E4CFBB715FFDBF919C8C /* main.rs */ = {isa = PBXFileReference; lastKnownFileType = text; path = main.rs; sourceTree = "<group>"; };- 17B52554D60D361AFE791C3E /* lib.rs */ = {isa = PBXFileReference; lastKnownFileType = text; path = lib.rs; sourceTree = "<group>"; };+ 0EAE3E64C98FE3472A9133C6 /* NotificationService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationService.swift; sourceTree = "<group>"; };+ 1631E4CFBB715FFDBF919C8C /* main.rs */ = {isa = PBXFileReference; path = main.rs; sourceTree = "<group>"; };+ 17B52554D60D361AFE791C3E /* lib.rs */ = {isa = PBXFileReference; path = lib.rs; sourceTree = "<group>"; };1E81BD6B453D87B7F7B1597B /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };306B9C1792E7B1C53FA262A6 /* bindings.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = bindings.h; sourceTree = "<group>"; };3842AE2A64FB9933D0400EA4 /* assets */ = {isa = PBXFileReference; lastKnownFileType = folder; path = assets; sourceTree = SOURCE_ROOT; };39EEC6A55698228E08917A52 /* libapp.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libapp.a; sourceTree = "<group>"; };+ 4E0D7F48FDCCC9975129FB20 /* ShareExtension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = ShareExtension.entitlements; sourceTree = "<group>"; };+ 5116F21CDEA54A9508733EFB /* NotificationServiceExtension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = NotificationServiceExtension.entitlements; sourceTree = "<group>"; };682535EEFE1DA20BE07B123C /* main.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = main.mm; sourceTree = "<group>"; };81E326B61ED92E1D1EECF952 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };- 9625271C5AAE7E545027267A /* debug.rs */ = {isa = PBXFileReference; lastKnownFileType = text; path = debug.rs; sourceTree = "<group>"; };+ 9625271C5AAE7E545027267A /* debug.rs */ = {isa = PBXFileReference; path = debug.rs; sourceTree = "<group>"; };+ 9D39399531526740F7E44FFB /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };9FACFFCB6E3743955F72464C /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };AF1DE57E7D9CF13BB2E0E038 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };CE1209BFDECB28E00189B168 /* Metal.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Metal.framework; path = System/Library/Frameworks/Metal.framework; sourceTree = SDKROOT; };+ CF674524E34966183631754E /* libapp.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libapp.a; sourceTree = "<group>"; };D8F57162F5CC7AEDD55F173D /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; };+ DE016BCDACB745FDB90321AF /* ShareViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ShareViewController.swift; sourceTree = "<group>"; };+ F2F6B23901C11426024E1D4E /* ShareExtension.appex */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "wrapper.app-extension"; path = ShareExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; };F3673D372C5ABDD1AD6E7067 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };- FBC720DFA1D01F55B0A32344 /* app_iOS.app */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = wrapper.application; name = app_iOS.app; path = macro.app; sourceTree = BUILT_PRODUCTS_DIR; };- FC8F21D1B3C54F48FD8FA060 /* logger.rs */ = {isa = PBXFileReference; lastKnownFileType = file; path = logger.rs; sourceTree = "<group>"; };- NSE00000002 /* NotificationService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NotificationService.swift; sourceTree = "<group>"; };- NSE00000004 /* NotificationServiceExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = NotificationServiceExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; };- NSE00000008 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };- NSE00000009 /* NotificationServiceExtension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = NotificationServiceExtension.entitlements; sourceTree = "<group>"; };+ FA2CD6184313364E14B6F84E /* NotificationServiceExtension.appex */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "wrapper.app-extension"; path = NotificationServiceExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; };+ FBC720DFA1D01F55B0A32344 /* app_iOS.app */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = wrapper.application; path = app_iOS.app; sourceTree = BUILT_PRODUCTS_DIR; };/* End PBXFileReference section *//* Begin PBXFrameworksBuildPhase section */@@ -90,13 +105,6 @@);runOnlyForDeploymentPostprocessing = 0;};- NSE0000000A /* Frameworks */ = {- isa = PBXFrameworksBuildPhase;- buildActionMask = 2147483647;- files = (- );- runOnlyForDeploymentPostprocessing = 0;- };/* End PBXFrameworksBuildPhase section *//* Begin PBXGroup section */@@ -115,6 +123,16 @@name = Frameworks;sourceTree = "<group>";};+ 1C4105EF6E39BF7F1E4019F3 /* ShareExtension */ = {+ isa = PBXGroup;+ children = (+ 0534025E6A6DC9BF45F0EC3E /* Info.plist */,+ 4E0D7F48FDCCC9975129FB20 /* ShareExtension.entitlements */,+ DE016BCDACB745FDB90321AF /* ShareViewController.swift */,+ );+ path = ShareExtension;+ sourceTree = "<group>";+ };2867E55E70187711EE923EBD /* app_iOS */ = {isa = PBXGroup;children = (@@ -132,6 +150,22 @@path = bindings;sourceTree = "<group>";};+ 5F72359403FB561BE1489F63 /* debug */ = {+ isa = PBXGroup;+ children = (+ CF674524E34966183631754E /* libapp.a */,+ );+ path = debug;+ sourceTree = "<group>";+ };+ 70DD658F1D4B0FED51A79854 /* arm64 */ = {+ isa = PBXGroup;+ children = (+ 5F72359403FB561BE1489F63 /* debug */,+ );+ path = arm64;+ sourceTree = "<group>";+ };78CBE3E5873199C0066F12DF /* Sources */ = {isa = PBXGroup;children = (@@ -140,12 +174,21 @@path = Sources;sourceTree = "<group>";};+ 83291B4320BCCBF029F53A03 /* NotificationServiceExtension */ = {+ isa = PBXGroup;+ children = (+ 9D39399531526740F7E44FFB /* Info.plist */,+ 0EAE3E64C98FE3472A9133C6 /* NotificationService.swift */,+ 5116F21CDEA54A9508733EFB /* NotificationServiceExtension.entitlements */,+ );+ path = NotificationServiceExtension;+ sourceTree = "<group>";+ };855775165ACE55D883F89EB3 /* src */ = {isa = PBXGroup;children = (9625271C5AAE7E545027267A /* debug.rs */,17B52554D60D361AFE791C3E /* lib.rs */,- FC8F21D1B3C54F48FD8FA060 /* logger.rs */,1631E4CFBB715FFDBF919C8C /* main.rs */,);name = src;@@ -159,8 +202,9 @@AF1DE57E7D9CF13BB2E0E038 /* Assets.xcassets */,02B7F8347F94B067E6B27396 /* LaunchScreen.storyboard */,2867E55E70187711EE923EBD /* app_iOS */,- NSE0000000B /* NotificationServiceExtension */,BAFB695BB8415511FEC74542 /* Externals */,+ 83291B4320BCCBF029F53A03 /* NotificationServiceExtension */,+ 1C4105EF6E39BF7F1E4019F3 /* ShareExtension */,78CBE3E5873199C0066F12DF /* Sources */,855775165ACE55D883F89EB3 /* src */,1BBF8C620E54F8C028CA130C /* Frameworks */,@@ -171,6 +215,7 @@BAFB695BB8415511FEC74542 /* Externals */ = {isa = PBXGroup;children = (+ 70DD658F1D4B0FED51A79854 /* arm64 */,);path = Externals;sourceTree = "<group>";@@ -179,7 +224,8 @@isa = PBXGroup;children = (FBC720DFA1D01F55B0A32344 /* app_iOS.app */,- NSE00000004 /* NotificationServiceExtension.appex */,+ FA2CD6184313364E14B6F84E /* NotificationServiceExtension.appex */,+ F2F6B23901C11426024E1D4E /* ShareExtension.appex */,);name = Products;sourceTree = "<group>";@@ -193,57 +239,73 @@path = app;sourceTree = "<group>";};- NSE0000000B /* NotificationServiceExtension */ = {+ "TEMP_A189466E-4111-45C1-A5D0-39E07CC21F79" /* x86_64 */ = {isa = PBXGroup;children = (- NSE00000002 /* NotificationService.swift */,- NSE00000008 /* Info.plist */,- NSE00000009 /* NotificationServiceExtension.entitlements */,);- path = NotificationServiceExtension;+ path = x86_64;sourceTree = "<group>";};/* End PBXGroup section *//* Begin PBXNativeTarget section */- E86255CB8A1836C0BF0C0E14 /* app_iOS */ = {+ 017A206CDE07C3F290D7A4FA /* ShareExtension */ = {isa = PBXNativeTarget;- buildConfigurationList = CDCB6DFA1AEBFEE3F608BA27 /* Build configuration list for PBXNativeTarget "app_iOS" */;+ buildConfigurationList = 8A2E9A4D95CB0514AE563D19 /* Build configuration list for PBXNativeTarget "ShareExtension" */;buildPhases = (- E028F843270D8815FCE2B491 /* Build Rust Code */,- 81BE6BC5B603407AF570E994 /* Sources */,- 2FBCB8C3ED193E9C4A9FDB59 /* Resources */,- 4825CF6C55516D374210C8E1 /* Frameworks */,- NSE00000007 /* Embed App Extensions */,+ FE63E34751325C81C3A23A80 /* Sources */,);buildRules = ();dependencies = (- NSE0000000C /* PBXTargetDependency */,);- name = app_iOS;+ name = ShareExtension;packageProductDependencies = ();- productName = app_iOS;- productReference = FBC720DFA1D01F55B0A32344 /* app_iOS.app */;- productType = "com.apple.product-type.application";+ productName = ShareExtension;+ productReference = F2F6B23901C11426024E1D4E /* ShareExtension.appex */;+ productType = "com.apple.product-type.app-extension";};- NSE00000006 /* NotificationServiceExtension */ = {+ 097A73617A3B881FE560AF51 /* NotificationServiceExtension */ = {isa = PBXNativeTarget;- buildConfigurationList = NSE0000000D /* Build configuration list for PBXNativeTarget "NotificationServiceExtension" */;+ buildConfigurationList = AF4E0B9FC00510C98D436C9E /* Build configuration list for PBXNativeTarget "NotificationServiceExtension" */;buildPhases = (- NSE0000000E /* Sources */,- NSE0000000A /* Frameworks */,+ 0EB31E4617FF6899A92515ED /* Sources */,);buildRules = ();dependencies = ();name = NotificationServiceExtension;+ packageProductDependencies = (+ );productName = NotificationServiceExtension;- productReference = NSE00000004 /* NotificationServiceExtension.appex */;+ productReference = FA2CD6184313364E14B6F84E /* NotificationServiceExtension.appex */;productType = "com.apple.product-type.app-extension";};+ E86255CB8A1836C0BF0C0E14 /* app_iOS */ = {+ isa = PBXNativeTarget;+ buildConfigurationList = CDCB6DFA1AEBFEE3F608BA27 /* Build configuration list for PBXNativeTarget "app_iOS" */;+ buildPhases = (+ E028F843270D8815FCE2B491 /* Build Rust Code */,+ 81BE6BC5B603407AF570E994 /* Sources */,+ 2FBCB8C3ED193E9C4A9FDB59 /* Resources */,+ 4825CF6C55516D374210C8E1 /* Frameworks */,+ 84895F3D2512B6F87AA9E1B3 /* Embed Foundation Extensions */,+ );+ buildRules = (+ );+ dependencies = (+ A799E95821B7D09E2D27220C /* PBXTargetDependency */,+ 997D6CAD31DB7465F1C4512E /* PBXTargetDependency */,+ );+ name = app_iOS;+ packageProductDependencies = (+ );+ productName = app_iOS;+ productReference = FBC720DFA1D01F55B0A32344 /* app_iOS.app */;+ productType = "com.apple.product-type.application";+ };/* End PBXNativeTarget section *//* Begin PBXProject section */@@ -252,6 +314,20 @@attributes = {BuildIndependentTargetsInParallel = YES;LastUpgradeCheck = 1430;+ TargetAttributes = {+ 017A206CDE07C3F290D7A4FA = {+ DevelopmentTeam = TY74Q77JBD;+ ProvisioningStyle = Automatic;+ };+ 097A73617A3B881FE560AF51 = {+ DevelopmentTeam = TY74Q77JBD;+ ProvisioningStyle = Automatic;+ };+ E86255CB8A1836C0BF0C0E14 = {+ DevelopmentTeam = TY74Q77JBD;+ ProvisioningStyle = Automatic;+ };+ };};buildConfigurationList = B302E784349268C93E6F0A36 /* Build configuration list for PBXProject "app" */;compatibilityVersion = "Xcode 14.0";@@ -263,11 +339,13 @@);mainGroup = 87648061424F20D5D4871E9E;minimizedProjectReferenceProxies = 1;+ preferredProjectObjectVersion = 77;projectDirPath = "";projectRoot = "";targets = (+ 097A73617A3B881FE560AF51 /* NotificationServiceExtension */,+ 017A206CDE07C3F290D7A4FA /* ShareExtension */,E86255CB8A1836C0BF0C0E14 /* app_iOS */,- NSE00000006 /* NotificationServiceExtension */,);};/* End PBXProject section */@@ -280,6 +358,7 @@C6BD59C055C986EA4A77FDA2 /* Assets.xcassets in Resources */,3036F7131E55779ABF15BD58 /* LaunchScreen.storyboard in Resources */,5C516481BCA83A182C2BCC94 /* assets in Resources */,+ 36C1893A7382FCD5A6A74845 /* libapp.a in Resources */,);runOnlyForDeploymentPostprocessing = 0;};@@ -304,12 +383,20 @@"$(SRCROOT)/Externals/arm64/${CONFIGURATION}/libapp.a",);runOnlyForDeploymentPostprocessing = 0;- shellPath = /bin/zsh;- shellScript = "cargo tauri ios xcode-script -v --platform ${PLATFORM_DISPLAY_NAME:?} --sdk-root ${SDKROOT:?} --framework-search-paths \"${FRAMEWORK_SEARCH_PATHS:?}\" --header-search-paths \"${HEADER_SEARCH_PATHS:?}\" --gcc-preprocessor-definitions \"${GCC_PREPROCESSOR_DEFINITIONS:-}\" --configuration ${CONFIGURATION:?} ${FORCE_COLOR} ${ARCHS:?}\n";+ shellPath = /bin/sh;+ shellScript = "export PATH=\"$PATH:$HOME/.cargo/bin\" && cargo tauri ios xcode-script -v --platform ${PLATFORM_DISPLAY_NAME:?} --sdk-root ${SDKROOT:?} --framework-search-paths \"${FRAMEWORK_SEARCH_PATHS:?}\" --header-search-paths \"${HEADER_SEARCH_PATHS:?}\" --gcc-preprocessor-definitions \"${GCC_PREPROCESSOR_DEFINITIONS:-}\" --configuration ${CONFIGURATION:?} ${FORCE_COLOR} ${ARCHS:?}";};/* End PBXShellScriptBuildPhase section *//* Begin PBXSourcesBuildPhase section */+ 0EB31E4617FF6899A92515ED /* Sources */ = {+ isa = PBXSourcesBuildPhase;+ buildActionMask = 2147483647;+ files = (+ 84C06806528EC8D5602FB113 /* NotificationService.swift in Sources */,+ );+ runOnlyForDeploymentPostprocessing = 0;+ };81BE6BC5B603407AF570E994 /* Sources */ = {isa = PBXSourcesBuildPhase;buildActionMask = 2147483647;@@ -318,34 +405,66 @@);runOnlyForDeploymentPostprocessing = 0;};- NSE0000000E /* Sources */ = {+ FE63E34751325C81C3A23A80 /* Sources */ = {isa = PBXSourcesBuildPhase;buildActionMask = 2147483647;files = (- NSE00000001 /* NotificationService.swift in Sources */,+ 395DAD80D2F1C1FDEB4ACA2D /* ShareViewController.swift in Sources */,);runOnlyForDeploymentPostprocessing = 0;};/* End PBXSourcesBuildPhase section *//* Begin PBXTargetDependency section */- NSE0000000C /* PBXTargetDependency */ = {+ 997D6CAD31DB7465F1C4512E /* PBXTargetDependency */ = {isa = PBXTargetDependency;- target = NSE00000006 /* NotificationServiceExtension */;- targetProxy = NSE00000005 /* PBXContainerItemProxy */;+ target = 017A206CDE07C3F290D7A4FA /* ShareExtension */;+ targetProxy = 260E1148C62E6A5410483AAF /* PBXContainerItemProxy */;+ };+ A799E95821B7D09E2D27220C /* PBXTargetDependency */ = {+ isa = PBXTargetDependency;+ target = 097A73617A3B881FE560AF51 /* NotificationServiceExtension */;+ targetProxy = 2E13E6104415D7AA47EE3C78 /* PBXContainerItemProxy */;};/* End PBXTargetDependency section *//* Begin XCBuildConfiguration section */+ 0D89F95331257BD1D5BB26A7 /* release */ = {+ isa = XCBuildConfiguration;+ buildSettings = {+ ARCHS = (+ arm64,+ );+ CODE_SIGN_ALLOW_ENTITLEMENTS_MODIFICATION = YES;+ CODE_SIGN_STYLE = Automatic;+ DEVELOPMENT_TEAM = TY74Q77JBD;+ "EXCLUDED_ARCHS[sdk=iphoneos*]" = x86_64;+ INFOPLIST_FILE = NotificationServiceExtension/Info.plist;+ LD_RUNPATH_SEARCH_PATHS = (+ "$(inherited)",+ "@executable_path/Frameworks",+ "@executable_path/../../Frameworks",+ );+ PRODUCT_BUNDLE_IDENTIFIER = com.macro.app.prod.NotificationServiceExtension;+ SDKROOT = iphoneos;+ TARGETED_DEVICE_FAMILY = "1,2";+ VALID_ARCHS = arm64;+ };+ name = release;+ };1B9D5B8D34E6E0C88D0207F2 /* release */ = {isa = XCBuildConfiguration;buildSettings = {ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;- ARCHS = arm64;+ ARCHS = (+ arm64,+ );ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;+ CODE_SIGN_ALLOW_ENTITLEMENTS_MODIFICATION = YES;CODE_SIGN_ENTITLEMENTS = app_iOS/app_iOS.entitlements;CODE_SIGN_IDENTITY = "iPhone Developer";- DEVELOPMENT_TEAM = "TY74Q77JBD";+ CODE_SIGN_STYLE = Automatic;+ DEVELOPMENT_TEAM = TY74Q77JBD;ENABLE_BITCODE = NO;"EXCLUDED_ARCHS[sdk=iphoneos*]" = x86_64;FRAMEWORK_SEARCH_PATHS = (@@ -357,20 +476,8 @@"$(inherited)","@executable_path/Frameworks",);- "LIBRARY_SEARCH_PATHS[arch=arm64]" = (- "$(inherited)",- "$(PROJECT_DIR)/Externals/arm64/$(CONFIGURATION)",- "$(SDKROOT)/usr/lib/swift",- "$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)",- "$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)",- );- "LIBRARY_SEARCH_PATHS[arch=x86_64]" = (- "$(inherited)",- "$(PROJECT_DIR)/Externals/x86_64/$(CONFIGURATION)",- "$(SDKROOT)/usr/lib/swift",- "$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)",- "$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)",- );+ "LIBRARY_SEARCH_PATHS[arch=arm64]" = "$(inherited) $(PROJECT_DIR)/Externals/arm64/$(CONFIGURATION) $(SDKROOT)/usr/lib/swift $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)";+ "LIBRARY_SEARCH_PATHS[arch=x86_64]" = "$(inherited) $(PROJECT_DIR)/Externals/x86_64/$(CONFIGURATION) $(SDKROOT)/usr/lib/swift $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)";PRODUCT_BUNDLE_IDENTIFIER = com.macro.app.prod;PRODUCT_NAME = "macro";SDKROOT = iphoneos;@@ -379,6 +486,30 @@};name = release;};+ 237E1C2FEE5E746F82DC5D1F /* debug */ = {+ isa = XCBuildConfiguration;+ buildSettings = {+ ARCHS = (+ arm64,+ );+ CODE_SIGN_ALLOW_ENTITLEMENTS_MODIFICATION = YES;+ CODE_SIGN_ENTITLEMENTS = ShareExtension/ShareExtension.entitlements;+ CODE_SIGN_STYLE = Automatic;+ DEVELOPMENT_TEAM = TY74Q77JBD;+ "EXCLUDED_ARCHS[sdk=iphoneos*]" = x86_64;+ INFOPLIST_FILE = ShareExtension/Info.plist;+ LD_RUNPATH_SEARCH_PATHS = (+ "$(inherited)",+ "@executable_path/Frameworks",+ "@executable_path/../../Frameworks",+ );+ PRODUCT_BUNDLE_IDENTIFIER = com.macro.app.prod.ShareExtension;+ SDKROOT = iphoneos;+ TARGETED_DEVICE_FAMILY = "1,2";+ VALID_ARCHS = arm64;+ };+ name = debug;+ };3C6497CF9EADFA373F12EF5C /* release */ = {isa = XCBuildConfiguration;buildSettings = {@@ -439,11 +570,15 @@isa = XCBuildConfiguration;buildSettings = {ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;- ARCHS = arm64;+ ARCHS = (+ arm64,+ );ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;+ CODE_SIGN_ALLOW_ENTITLEMENTS_MODIFICATION = YES;CODE_SIGN_ENTITLEMENTS = app_iOS/app_iOS.entitlements;CODE_SIGN_IDENTITY = "iPhone Developer";- DEVELOPMENT_TEAM = "TY74Q77JBD";+ CODE_SIGN_STYLE = Automatic;+ DEVELOPMENT_TEAM = TY74Q77JBD;ENABLE_BITCODE = NO;"EXCLUDED_ARCHS[sdk=iphoneos*]" = x86_64;FRAMEWORK_SEARCH_PATHS = (@@ -455,22 +590,57 @@"$(inherited)","@executable_path/Frameworks",);- "LIBRARY_SEARCH_PATHS[arch=arm64]" = (+ "LIBRARY_SEARCH_PATHS[arch=arm64]" = "$(inherited) $(PROJECT_DIR)/Externals/arm64/$(CONFIGURATION) $(SDKROOT)/usr/lib/swift $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)";+ "LIBRARY_SEARCH_PATHS[arch=x86_64]" = "$(inherited) $(PROJECT_DIR)/Externals/x86_64/$(CONFIGURATION) $(SDKROOT)/usr/lib/swift $(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME) $(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)";+ PRODUCT_BUNDLE_IDENTIFIER = com.macro.app.prod;+ PRODUCT_NAME = "macro";+ SDKROOT = iphoneos;+ TARGETED_DEVICE_FAMILY = "1,2";+ VALID_ARCHS = arm64;+ };+ name = debug;+ };+ 74B0F2249ADD36E1D4250615 /* release */ = {+ isa = XCBuildConfiguration;+ buildSettings = {+ ARCHS = (+ arm64,+ );+ CODE_SIGN_ALLOW_ENTITLEMENTS_MODIFICATION = YES;+ CODE_SIGN_ENTITLEMENTS = ShareExtension/ShareExtension.entitlements;+ CODE_SIGN_STYLE = Automatic;+ DEVELOPMENT_TEAM = TY74Q77JBD;+ "EXCLUDED_ARCHS[sdk=iphoneos*]" = x86_64;+ INFOPLIST_FILE = ShareExtension/Info.plist;+ LD_RUNPATH_SEARCH_PATHS = ("$(inherited)",- "$(PROJECT_DIR)/Externals/arm64/$(CONFIGURATION)",- "$(SDKROOT)/usr/lib/swift",- "$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)",- "$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)",+ "@executable_path/Frameworks",+ "@executable_path/../../Frameworks",+ );+ PRODUCT_BUNDLE_IDENTIFIER = com.macro.app.prod.ShareExtension;+ SDKROOT = iphoneos;+ TARGETED_DEVICE_FAMILY = "1,2";+ VALID_ARCHS = arm64;+ };+ name = release;+ };+ 78C1D6E8B4148D7C937F041B /* debug */ = {+ isa = XCBuildConfiguration;+ buildSettings = {+ ARCHS = (+ arm64,);- "LIBRARY_SEARCH_PATHS[arch=x86_64]" = (+ CODE_SIGN_ALLOW_ENTITLEMENTS_MODIFICATION = YES;+ CODE_SIGN_STYLE = Automatic;+ DEVELOPMENT_TEAM = TY74Q77JBD;+ "EXCLUDED_ARCHS[sdk=iphoneos*]" = x86_64;+ INFOPLIST_FILE = NotificationServiceExtension/Info.plist;+ LD_RUNPATH_SEARCH_PATHS = ("$(inherited)",- "$(PROJECT_DIR)/Externals/x86_64/$(CONFIGURATION)",- "$(SDKROOT)/usr/lib/swift",- "$(TOOLCHAIN_DIR)/usr/lib/swift/$(PLATFORM_NAME)",- "$(TOOLCHAIN_DIR)/usr/lib/swift-5.0/$(PLATFORM_NAME)",+ "@executable_path/Frameworks",+ "@executable_path/../../Frameworks",);- PRODUCT_BUNDLE_IDENTIFIER = com.macro.app.prod;- PRODUCT_NAME = "macro";+ PRODUCT_BUNDLE_IDENTIFIER = com.macro.app.prod.NotificationServiceExtension;SDKROOT = iphoneos;TARGETED_DEVICE_FAMILY = "1,2";VALID_ARCHS = arm64;@@ -540,90 +710,41 @@};name = debug;};- NSE0000000F /* debug */ = {- isa = XCBuildConfiguration;- buildSettings = {- ARCHS = arm64;- CODE_SIGN_ENTITLEMENTS = NotificationServiceExtension/NotificationServiceExtension.entitlements;- CODE_SIGN_IDENTITY = "iPhone Developer";- CODE_SIGN_STYLE = Automatic;- CURRENT_PROJECT_VERSION = 100;- DEVELOPMENT_TEAM = TY74Q77JBD;- GENERATE_INFOPLIST_FILE = NO;- INFOPLIST_FILE = NotificationServiceExtension/Info.plist;- IPHONEOS_DEPLOYMENT_TARGET = 14.0;- LD_RUNPATH_SEARCH_PATHS = (- "$(inherited)",- "@executable_path/Frameworks",- "@executable_path/../../Frameworks",- );- MARKETING_VERSION = 1.0;- PRODUCT_BUNDLE_IDENTIFIER = com.macro.app.prod.NotificationServiceExtension;- PRODUCT_NAME = "$(TARGET_NAME)";- SDKROOT = iphoneos;- SKIP_INSTALL = YES;- SWIFT_EMIT_LOC_STRINGS = YES;- SWIFT_VERSION = 5.0;- TARGETED_DEVICE_FAMILY = "1,2";- VALID_ARCHS = arm64;- };- name = debug;- };- NSE00000010 /* release */ = {- isa = XCBuildConfiguration;- buildSettings = {- ARCHS = arm64;- CODE_SIGN_ENTITLEMENTS = NotificationServiceExtension/NotificationServiceExtension.entitlements;- CODE_SIGN_IDENTITY = "iPhone Developer";- CODE_SIGN_STYLE = Automatic;- CURRENT_PROJECT_VERSION = 100;- DEVELOPMENT_TEAM = TY74Q77JBD;- GENERATE_INFOPLIST_FILE = NO;- INFOPLIST_FILE = NotificationServiceExtension/Info.plist;- IPHONEOS_DEPLOYMENT_TARGET = 14.0;- LD_RUNPATH_SEARCH_PATHS = (- "$(inherited)",- "@executable_path/Frameworks",- "@executable_path/../../Frameworks",- );- MARKETING_VERSION = 1.0;- PRODUCT_BUNDLE_IDENTIFIER = com.macro.app.prod.NotificationServiceExtension;- PRODUCT_NAME = "$(TARGET_NAME)";- SDKROOT = iphoneos;- SKIP_INSTALL = YES;- SWIFT_EMIT_LOC_STRINGS = YES;- SWIFT_VERSION = 5.0;- TARGETED_DEVICE_FAMILY = "1,2";- VALID_ARCHS = arm64;- };- name = release;- };/* End XCBuildConfiguration section *//* Begin XCConfigurationList section */- B302E784349268C93E6F0A36 /* Build configuration list for PBXProject "app" */ = {+ 8A2E9A4D95CB0514AE563D19 /* Build configuration list for PBXNativeTarget "ShareExtension" */ = {isa = XCConfigurationList;buildConfigurations = (- CAA806262C53A2E15E5DB0CA /* debug */,- 3C6497CF9EADFA373F12EF5C /* release */,+ 237E1C2FEE5E746F82DC5D1F /* debug */,+ 74B0F2249ADD36E1D4250615 /* release */,);defaultConfigurationIsVisible = 0;defaultConfigurationName = debug;};- CDCB6DFA1AEBFEE3F608BA27 /* Build configuration list for PBXNativeTarget "app_iOS" */ = {+ AF4E0B9FC00510C98D436C9E /* Build configuration list for PBXNativeTarget "NotificationServiceExtension" */ = {isa = XCConfigurationList;buildConfigurations = (- 4AC19FD47C6011940ACEB467 /* debug */,- 1B9D5B8D34E6E0C88D0207F2 /* release */,+ 78C1D6E8B4148D7C937F041B /* debug */,+ 0D89F95331257BD1D5BB26A7 /* release */,);defaultConfigurationIsVisible = 0;defaultConfigurationName = debug;};- NSE0000000D /* Build configuration list for PBXNativeTarget "NotificationServiceExtension" */ = {+ B302E784349268C93E6F0A36 /* Build configuration list for PBXProject "app" */ = {isa = XCConfigurationList;buildConfigurations = (- NSE0000000F /* debug */,- NSE00000010 /* release */,+ CAA806262C53A2E15E5DB0CA /* debug */,+ 3C6497CF9EADFA373F12EF5C /* release */,+ );+ defaultConfigurationIsVisible = 0;+ defaultConfigurationName = debug;+ };+ CDCB6DFA1AEBFEE3F608BA27 /* Build configuration list for PBXNativeTarget "app_iOS" */ = {+ isa = XCConfigurationList;+ buildConfigurations = (+ 4AC19FD47C6011940ACEB467 /* debug */,+ 1B9D5B8D34E6E0C88D0207F2 /* release */,);defaultConfigurationIsVisible = 0;defaultConfigurationName = debug;diff --git a/js/app/tauri/src-tauri/gen/apple/app_iOS/Info.plist b/js/app/tauri/src-tauri/gen/apple/app_iOS/Info.plistindex fa0e509c8d..fdc77d8181 100644--- a/js/app/tauri/src-tauri/gen/apple/app_iOS/Info.plist+++ b/js/app/tauri/src-tauri/gen/apple/app_iOS/Info.plist@@ -16,10 +16,36 @@<string>APPL</string><key>CFBundleShortVersionString</key><string>2.0.2</string>+ <key>CFBundleURLTypes</key>+ <array>+ <dict>+ <key>CFBundleURLSchemes</key>+ <array>+ <string>macro</string>+ </array>+ <key>CFBundleURLName</key>+ <string>macro</string>+ </dict>+ </array><key>CFBundleVersion</key><string>142</string>+ <key>LSApplicationQueriesSchemes</key>+ <array>+ <string>macro</string>+ </array><key>LSRequiresIPhoneOS</key><true/>+ <key>NSCameraUsageDescription</key>+ <string>This app needs access to the camera to take photos and videos for attachments.</string>+ <key>NSMicrophoneUsageDescription</key>+ <string>This app needs access to the microphone to record videos for attachments.</string>+ <key>NSPhotoLibraryUsageDescription</key>+ <string>This app needs access to your photo library to upload attachments.</string>+ <key>NSUserActivityTypes</key>+ <array>+ <string>INSendMessageIntent</string>+ <string>NSUserActivityTypeBrowsingWeb</string>+ </array><key>UILaunchStoryboardName</key><string>LaunchScreen</string><key>UIRequiredDeviceCapabilities</key>@@ -38,27 +64,5 @@<string>UIInterfaceOrientationLandscapeLeft</string><string>UIInterfaceOrientationLandscapeRight</string></array>- <key>CFBundleURLTypes</key>- <array>- <dict>- <key>CFBundleURLSchemes</key>- <array>- <string>macro</string>- </array>- <key>CFBundleURLName</key>- <string>macro</string>- </dict>- </array>- <key>NSUserActivityTypes</key>- <array>- <string>INSendMessageIntent</string>- <string>NSUserActivityTypeBrowsingWeb</string>- </array>- <key>NSCameraUsageDescription</key>- <string>This app needs access to the camera to take photos and videos for attachments.</string>- <key>NSMicrophoneUsageDescription</key>- <string>This app needs access to the microphone to record videos for attachments.</string>- <key>NSPhotoLibraryUsageDescription</key>- <string>This app needs access to your photo library to upload attachments.</string></dict></plist>\ No newline at end of filediff --git a/js/app/tauri/src-tauri/gen/apple/app_iOS/app_iOS.entitlements b/js/app/tauri/src-tauri/gen/apple/app_iOS/app_iOS.entitlementsindex c79912518f..d7476690d3 100644--- a/js/app/tauri/src-tauri/gen/apple/app_iOS/app_iOS.entitlements+++ b/js/app/tauri/src-tauri/gen/apple/app_iOS/app_iOS.entitlements@@ -14,5 +14,9 @@<true/><key>com.apple.developer.usernotifications.time-sensitive</key><true/>+ <key>com.apple.security.application-groups</key>+ <array>+ <string>group.com.macro.app.prod</string>+ </array></dict></plist>\ No newline at end of filediff --git a/js/app/tauri/src-tauri/gen/apple/project.yml b/js/app/tauri/src-tauri/gen/apple/project.ymlindex 4148eb8ae4..9dc9ce0fc5 100644--- a/js/app/tauri/src-tauri/gen/apple/project.yml+++ b/js/app/tauri/src-tauri/gen/apple/project.yml@@ -1,6 +1,6 @@name: appoptions:- bundleIdPrefix: com.macro.dev+ bundleIdPrefix: com.macro.app.proddeploymentTarget:iOS: 14.0fileGroups: [../../src]@@ -11,7 +11,10 @@ settingGroups:app:base:PRODUCT_NAME: macro- PRODUCT_BUNDLE_IDENTIFIER: com.macro.dev+ PRODUCT_BUNDLE_IDENTIFIER: com.macro.app.prod+ DEVELOPMENT_TEAM: TY74Q77JBD+ CODE_SIGN_STYLE: Automatic+ CODE_SIGN_ALLOW_ENTITLEMENTS_MODIFICATION: YEStargetTemplates:app:type: application@@ -44,8 +47,6 @@ targets:UIRequiredDeviceCapabilities: [arm64, metal]UISupportedInterfaceOrientations:- UIInterfaceOrientationPortrait- - UIInterfaceOrientationLandscapeLeft- - UIInterfaceOrientationLandscapeRightUISupportedInterfaceOrientations~ipad:- UIInterfaceOrientationPortrait- UIInterfaceOrientationPortraitUpsideDown@@ -53,8 +54,30 @@ targets:- UIInterfaceOrientationLandscapeRightCFBundleShortVersionString: 2.0.2CFBundleVersion: "142"+ CFBundleURLTypes:+ - CFBundleURLSchemes:+ - macro+ CFBundleURLName: macro+ NSUserActivityTypes:+ - INSendMessageIntent+ - NSUserActivityTypeBrowsingWeb+ NSCameraUsageDescription: "This app needs access to the camera to take photos and videos for attachments."+ NSMicrophoneUsageDescription: "This app needs access to the microphone to record videos for attachments."+ NSPhotoLibraryUsageDescription: "This app needs access to your photo library to upload attachments."+ LSApplicationQueriesSchemes:+ - macroentitlements:path: app_iOS/app_iOS.entitlements+ properties:+ aps-environment: production+ com.apple.developer.associated-domains:+ - applinks:macro.com+ - applinks:dev.macro.com+ - applinks:staging.macro.com+ com.apple.developer.usernotifications.communication: true+ com.apple.developer.usernotifications.time-sensitive: true+ com.apple.security.application-groups:+ - group.com.macro.app.prodscheme:environmentVariables:RUST_BACKTRACE: full@@ -72,6 +95,8 @@ targets:dependencies:- target: NotificationServiceExtensionembed: true+ - target: ShareExtension+ embed: true- framework: libapp.aembed: false- sdk: CoreGraphics.framework@@ -82,12 +107,46 @@ targets:- sdk: UIKit.framework- sdk: WebKit.frameworkpreBuildScripts:- - script: cargo tauri ios xcode-script -v --platform ${PLATFORM_DISPLAY_NAME:?} --sdk-root ${SDKROOT:?} --framework-search-paths "${FRAMEWORK_SEARCH_PATHS:?}" --header-search-paths "${HEADER_SEARCH_PATHS:?}" --gcc-preprocessor-definitions "${GCC_PREPROCESSOR_DEFINITIONS:-}" --configuration ${CONFIGURATION:?} ${FORCE_COLOR} ${ARCHS:?}+ - script: export PATH="$PATH:$HOME/.cargo/bin" && cargo tauri ios xcode-script -v --platform ${PLATFORM_DISPLAY_NAME:?} --sdk-root ${SDKROOT:?} --framework-search-paths "${FRAMEWORK_SEARCH_PATHS:?}" --header-search-paths "${HEADER_SEARCH_PATHS:?}" --gcc-preprocessor-definitions "${GCC_PREPROCESSOR_DEFINITIONS:-}" --configuration ${CONFIGURATION:?} ${FORCE_COLOR} ${ARCHS:?}name: Build Rust CodebasedOnDependencyAnalysis: falseoutputFiles:- $(SRCROOT)/Externals/x86_64/${CONFIGURATION}/libapp.a- $(SRCROOT)/Externals/arm64/${CONFIGURATION}/libapp.a+ ShareExtension:+ type: app-extension+ platform: iOS+ sources:+ - path: ShareExtension+ info:+ path: ShareExtension/Info.plist+ properties:+ CFBundleDisplayName: Share to Macro+ CFBundleShortVersionString: 2.0.2+ CFBundleVersion: "142"+ LSApplicationQueriesSchemes:+ - macro+ NSExtension:+ NSExtensionAttributes:+ NSExtensionActivationRule:+ NSExtensionActivationSupportsImageWithMaxCount: 10+ NSExtensionActivationSupportsMovieWithMaxCount: 5+ NSExtensionPointIdentifier: com.apple.share-services+ NSExtensionPrincipalClass: $(PRODUCT_MODULE_NAME).ShareViewController+ entitlements:+ path: ShareExtension/ShareExtension.entitlements+ properties:+ com.apple.security.application-groups:+ - group.com.macro.app.prod+ settings:+ base:+ PRODUCT_BUNDLE_IDENTIFIER: com.macro.app.prod.ShareExtension+ DEVELOPMENT_TEAM: TY74Q77JBD+ CODE_SIGN_STYLE: Automatic+ CODE_SIGN_ALLOW_ENTITLEMENTS_MODIFICATION: YES+ ARCHS: [arm64]+ VALID_ARCHS: arm64+ EXCLUDED_ARCHS[sdk=iphoneos*]: x86_64NotificationServiceExtension:type: app-extensionplatform: iOS@@ -96,11 +155,18 @@ targets:info:path: NotificationServiceExtension/Info.plistproperties:- CFBundleShortVersionString: 2.0.2+ CFBundleDisplayName: NotificationServiceExtension+ CFBundleShortVersionString: $(MARKETING_VERSION)CFBundleVersion: "142"+ NSExtension:+ NSExtensionPointIdentifier: com.apple.usernotifications.service+ NSExtensionPrincipalClass: $(PRODUCT_MODULE_NAME).NotificationServicesettings:base:- PRODUCT_BUNDLE_IDENTIFIER: com.macro.dev.NotificationServiceExtension+ PRODUCT_BUNDLE_IDENTIFIER: com.macro.app.prod.NotificationServiceExtension+ DEVELOPMENT_TEAM: TY74Q77JBD+ CODE_SIGN_STYLE: Automatic+ CODE_SIGN_ALLOW_ENTITLEMENTS_MODIFICATION: YESARCHS: [arm64]VALID_ARCHS: arm64EXCLUDED_ARCHS[sdk=iphoneos*]: x86_64\ No newline at end of filediff --git a/js/app/tauri/src-tauri/src/lib.rs b/js/app/tauri/src-tauri/src/lib.rsindex 2dfb274be4..2f16f076aa 100644--- a/js/app/tauri/src-tauri/src/lib.rs+++ b/js/app/tauri/src-tauri/src/lib.rs@@ -6,15 +6,25 @@ use reqwest::cookie::CookieStore;use reqwest::header::{COOKIE, ORIGIN};use rootcause::{Report, report};use serde::Serialize;+#[cfg(target_os = "ios")]+use share_target::cleanup_stale_staged_shared_files;+use share_target::{+ PendingShareFilesState, clear_shared_files, get_pending_share_filenames,+ maybe_handle_share_deep_link, pop_shared_files, upload_shared_file_to_presigned_url,+};use tauri::http::{HeaderMap, HeaderValue};use tauri::{AppHandle, Emitter, Manager, RunEvent, Runtime};mod tauri_protocol;++pub(crate) const APP_SCHEME: &str = "macro";use tauri_plugin_deep_link::{DeepLinkExt, OpenUrlEvent};use tracing_subscriber::layer::SubscriberExt;use tracing_subscriber::util::SubscriberInitExt;use url::Url;+mod share_target;+/// This module provides debuging utilities and should not be compiled in prodiction builds#[cfg(debug_assertions)] // do not remove thismod debug;@@ -171,12 +181,17 @@ pub fn run() {h(ctx.webview_label(), request, responder);}})+ .manage(PendingShareFilesState::default()).invoke_handler(tauri::generate_handler![macro_bundle_updater_plugin::inbound::plugin::grant_bundle_update,macro_bundle_updater_plugin::inbound::plugin::perform_update,macro_bundle_updater_plugin::inbound::plugin::check_for_update,macro_bundle_updater_plugin::inbound::plugin::get_bundle_update_status,- macro_bundle_updater_plugin::inbound::plugin::clear_bundle+ macro_bundle_updater_plugin::inbound::plugin::clear_bundle,+ get_pending_share_filenames,+ pop_shared_files,+ clear_shared_files,+ upload_shared_file_to_presigned_url,]).setup(|app| {// Restore persisted bundle root on startup@@ -203,6 +218,8 @@ pub fn run() {}app.chain(attach_deep_link_handler);+ #[cfg(target_os = "ios")]+ cleanup_stale_staged_shared_files(&app.handle());Ok(())})@@ -292,9 +309,13 @@ fn attach_deep_link_handler(app: &mut tauri::App) {.next().ok_or_else(|| report!("expected at least 1 url"))?;+ if maybe_handle_share_deep_link(handle, &url) {+ return Ok(());+ }+// Universal/App links come in as https:// URLs, custom scheme links come in as macro://let macro_scheme = match url.scheme() {- "macro" => MacroScheme::new(url)?,+ s if s == APP_SCHEME => MacroScheme::new(url)?,"http" | "https" => MacroScheme::from_url(&url)?,scheme => {return Err(report!("unexpected deep link scheme: {}", scheme));diff --git a/js/app/tauri/src-tauri/src/share_target.rs b/js/app/tauri/src-tauri/src/share_target.rsnew file mode 100644index 0000000000..d8fc3ab34d--- /dev/null+++ b/js/app/tauri/src-tauri/src/share_target.rs@@ -0,0 +1,580 @@+#[cfg(target_os = "ios")]+use crate::APP_SCHEME;+use serde::Serialize;+use std::sync::Mutex;+use tauri::AppHandle;+#[cfg(target_os = "ios")]+use tauri::Emitter;+#[cfg(target_os = "ios")]+use tauri::Manager;+#[cfg(target_os = "ios")]+use tauri_plugin_deep_link::DeepLinkExt;+use url::Url;+#[cfg(target_os = "ios")]+use uuid::Uuid;++#[derive(Default)]+pub(crate) struct PendingShareFilesState {+ filenames: Mutex<Vec<String>>,+}++#[cfg(target_os = "ios")]+#[derive(Clone, Serialize)]+struct ShareFilesReadyPayload {+ filenames: Vec<String>,+}++#[cfg(target_os = "ios")]+const SHARED_FILE_STAGING_DIR_NAME: &str = "ios-share-staging";+#[cfg(target_os = "ios")]+const STALE_SHARED_FILE_TTL_SECS: u64 = 60 * 60 * 24;+#[cfg(any(target_os = "ios", test))]+const STAGED_SHARED_FILE_NOT_FOUND_ERROR: &str = "staged shared file not found";++#[derive(Serialize)]+pub(crate) struct StagedSharedFile {+ token: String,+ name: String,+ mime_type: String,+ size: u64,+ preview_path: Option<String>,+}++fn lock_pending_share_filenames(+ state: &PendingShareFilesState,+) -> std::sync::MutexGuard<'_, Vec<String>> {+ match state.filenames.lock() {+ Ok(guard) => guard,+ Err(poisoned) => poisoned.into_inner(),+ }+}++#[cfg(target_os = "ios")]+fn replace_pending_share_filenames(state: &PendingShareFilesState, filenames: Vec<String>) {+ *lock_pending_share_filenames(state) = filenames;+}++#[cfg(test)]+fn remaining_pending_share_filenames(+ pending_filenames: &[String],+ consumed_filenames: &[String],+) -> Vec<String> {+ pending_filenames+ .iter()+ .filter(|name| !consumed_filenames.contains(name))+ .cloned()+ .collect()+}++#[cfg(target_os = "ios")]+fn consume_pending_share_filenames(+ container_path: &std::path::Path,+ state: &PendingShareFilesState,+ filenames: &[String],+) {+ let filenames: Vec<String> = filenames+ .iter()+ .filter_map(|name| sanitize_shared_filename(name).map(str::to_owned))+ .collect();++ {+ let mut pending_filenames = lock_pending_share_filenames(state);+ pending_filenames.retain(|name| !filenames.contains(name));+ }++ for name in filenames {+ let path = container_path.join(name);+ if let Err(error) = std::fs::remove_file(&path) {+ if error.kind() != std::io::ErrorKind::NotFound {+ tracing::warn!(+ "failed to delete consumed shared file {}: {}",+ path.display(),+ error+ );+ }+ }+ }+}++/// Returns the filesystem path of the shared App Group container used to+/// exchange files between the Share Extension and the main app.+/// Calls NSFileManager directly via the objc2 runtime — no FFI to main.mm needed.+#[cfg(target_os = "ios")]+fn ios_app_group_container_path() -> Option<String> {+ use objc2::rc::autoreleasepool;+ use objc2::runtime::AnyObject;+ use objc2::{class, msg_send};+ use std::ffi::{CStr, CString};+ use std::os::raw::c_char;++ autoreleasepool(|_| unsafe {+ let manager: *mut AnyObject = msg_send![class!(NSFileManager), defaultManager];++ let c_group = CString::new("group.com.macro.app.prod").ok()?;+ let group_ns: *mut AnyObject = msg_send![+ class!(NSString),+ stringWithUTF8String: c_group.as_ptr() as *const c_char+ ];++ let url: *mut AnyObject = msg_send![+ manager,+ containerURLForSecurityApplicationGroupIdentifier: group_ns+ ];+ if url.is_null() {+ return None;+ }++ let path_obj: *mut AnyObject = msg_send![url, path];+ if path_obj.is_null() {+ return None;+ }++ let c_path: *const c_char = msg_send![path_obj, UTF8String];+ if c_path.is_null() {+ return None;+ }++ CStr::from_ptr(c_path).to_str().ok().map(|s| s.to_string())+ })+}++#[cfg(target_os = "ios")]+fn shared_file_staging_dir(app: &AppHandle) -> Result<std::path::PathBuf, String> {+ let dir = app+ .path()+ .app_cache_dir()+ .map_err(|error| format!("failed to resolve app cache directory: {error}"))?+ .join(SHARED_FILE_STAGING_DIR_NAME);+ std::fs::create_dir_all(&dir)+ .map_err(|error| format!("failed to create shared file staging directory: {error}"))?;+ Ok(dir)+}++#[cfg(target_os = "ios")]+fn next_shared_file_stage_token() -> String {+ format!("share-stage-{}", Uuid::new_v4().simple())+}++#[cfg(target_os = "ios")]+fn sanitize_shared_file_stage_token(token: &str) -> Option<&str> {+ let valid = !token.is_empty()+ && token.len() <= 128+ && token.bytes().all(|byte| {+ matches!(+ byte,+ b'0'..=b'9' | b'a'..=b'z' | b'A'..=b'Z' | b'-' | b'_'+ )+ });+ valid.then_some(token)+}++#[cfg(target_os = "ios")]+fn staged_shared_file_path_for_name(+ app: &AppHandle,+ token: &str,+ source_name: &str,+) -> Result<std::path::PathBuf, String> {+ let token = sanitize_shared_file_stage_token(token)+ .ok_or_else(|| "invalid shared file staging token".to_string())?;+ let source_name = sanitize_shared_filename(source_name)+ .ok_or_else(|| "invalid shared file staging source name".to_string())?;+ Ok(shared_file_staging_dir(app)?.join(format!("{token}-{source_name}")))+}++#[cfg(target_os = "ios")]+fn staged_shared_file_path(app: &AppHandle, token: &str) -> Result<std::path::PathBuf, String> {+ let token = sanitize_shared_file_stage_token(token)+ .ok_or_else(|| "invalid shared file staging token".to_string())?;+ let staging_dir = shared_file_staging_dir(app)?;+ let legacy_path = staging_dir.join(token);+ if legacy_path.is_file() {+ return Ok(legacy_path);+ }++ let prefix = format!("{token}-");+ let entries = std::fs::read_dir(&staging_dir)+ .map_err(|error| format!("failed to read shared file staging directory: {error}"))?;++ for entry in entries {+ let entry =+ entry.map_err(|error| format!("failed to inspect staged shared file: {error}"))?;+ let file_name = entry.file_name();+ if file_name.to_string_lossy().starts_with(&prefix) {+ return Ok(entry.path());+ }+ }++ Err(STAGED_SHARED_FILE_NOT_FOUND_ERROR.to_string())+}++#[cfg(any(target_os = "ios", test))]+fn is_staged_shared_file_not_found_error(error: &str) -> bool {+ error == STAGED_SHARED_FILE_NOT_FOUND_ERROR+}++#[cfg(target_os = "ios")]+fn move_file_to_path(source: &std::path::Path, target: &std::path::Path) -> std::io::Result<()> {+ match std::fs::rename(source, target) {+ Ok(()) => Ok(()),+ Err(_) => {+ std::fs::copy(source, target)?;+ std::fs::remove_file(source)+ }+ }+}++#[cfg(target_os = "ios")]+fn stage_shared_file(+ app: &AppHandle,+ source_path: &std::path::Path,+ source_name: &str,+) -> Result<StagedSharedFile, String> {+ let token = next_shared_file_stage_token();+ let staged_path = staged_shared_file_path_for_name(app, &token, source_name)?;+ let mime_type = mime_type_from_path(source_path).to_string();+ let size = std::fs::metadata(source_path)+ .map_err(|error| format!("failed to read shared file metadata: {error}"))?+ .len();+ let preview_path = mime_type+ .starts_with("image/")+ .then(|| staged_path.to_string_lossy().into_owned());++ move_file_to_path(source_path, &staged_path)+ .map_err(|error| format!("failed to stage shared file: {error}"))?;++ Ok(StagedSharedFile {+ token,+ name: source_name.to_string(),+ mime_type,+ size,+ preview_path,+ })+}++#[cfg(target_os = "ios")]+pub(crate) fn cleanup_stale_staged_shared_files(app: &AppHandle) {+ let Ok(staging_dir) = app+ .path()+ .app_cache_dir()+ .map(|dir| dir.join(SHARED_FILE_STAGING_DIR_NAME))+ else {+ return;+ };++ let Ok(entries) = std::fs::read_dir(&staging_dir) else {+ return;+ };++ let cutoff = std::time::SystemTime::now()+ .checked_sub(std::time::Duration::from_secs(STALE_SHARED_FILE_TTL_SECS))+ .unwrap_or(std::time::UNIX_EPOCH);++ for entry in entries.flatten() {+ let Ok(metadata) = entry.metadata() else {+ continue;+ };++ if !metadata.is_file() {+ continue;+ }++ let modified = metadata.modified().or_else(|_| metadata.created());+ let should_remove = modified.map(|time| time < cutoff).unwrap_or(false);++ if should_remove {+ let _ = std::fs::remove_file(entry.path());+ }+ }++ let _ = std::fs::remove_dir(staging_dir);+}++#[cfg(any(target_os = "ios", test))]+fn sanitize_shared_filename(name: &str) -> Option<&str> {+ let path = std::path::Path::new(name);+ match path.file_name().and_then(|file_name| file_name.to_str()) {+ Some(file_name) if file_name == name && file_name.starts_with("share_") => Some(file_name),+ _ => None,+ }+}++#[cfg(any(target_os = "ios", test))]+fn share_filenames_from_url(url: &Url) -> Vec<String> {+ url.query_pairs()+ .filter(|(key, _)| key == "files")+ .flat_map(|(_, value)| {+ value+ .split(',')+ .filter_map(|name| sanitize_shared_filename(name).map(str::to_owned))+ .collect::<Vec<_>>()+ })+ .collect()+}++#[cfg(target_os = "ios")]+fn mime_type_from_path(path: &std::path::Path) -> &'static str {+ let ext = path+ .extension()+ .and_then(|ext| ext.to_str())+ .unwrap_or("")+ .to_lowercase();++ match ext.as_str() {+ "jpg" | "jpeg" => "image/jpeg",+ "png" => "image/png",+ "gif" => "image/gif",+ "webp" => "image/webp",+ "heic" | "heif" => "image/heic",+ "mov" => "video/quicktime",+ "mp4" => "video/mp4",+ _ => "application/octet-stream",+ }+}++#[tauri::command]+pub(crate) fn get_pending_share_filenames(+ app: tauri::AppHandle,+ state: tauri::State<'_, PendingShareFilesState>,+) -> Vec<String> {+ #[cfg(not(target_os = "ios"))]+ let _ = &app;++ let pending = lock_pending_share_filenames(&state).clone();++ #[cfg(not(target_os = "ios"))]+ if !pending.is_empty() {+ return pending;+ }++ #[cfg(target_os = "ios")]+ {+ if !pending.is_empty() {+ if let Some(container_path) = ios_app_group_container_path() {+ let container_path = std::path::Path::new(&container_path);+ let existing_pending: Vec<String> = pending+ .into_iter()+ .filter(|name| container_path.join(name).is_file())+ .collect();++ replace_pending_share_filenames(&state, existing_pending.clone());++ if !existing_pending.is_empty() {+ return existing_pending;+ }+ } else {+ return pending;+ }+ }++ match app.deep_link().get_current() {+ Ok(Some(urls)) => {+ if let Some(url) = urls.first() {+ if url.scheme() == APP_SCHEME+ && url.host_str() == Some("share")+ {+ let filenames = share_filenames_from_url(url);+ replace_pending_share_filenames(&state, filenames.clone());+ return filenames;+ }+ }+ }+ Ok(None) | Err(_) => {}+ }+ }++ Vec::new()+}++/// Tauri command: move files saved by the Share Extension out of the shared+/// App Group container into the app's own staging directory and return their+/// metadata. Successfully staged files are consumed from the native+/// pending-share queue so they are not replayed on the next app launch.+#[tauri::command]+pub(crate) fn pop_shared_files(+ app: tauri::AppHandle,+ filenames: Vec<String>,+ state: tauri::State<'_, PendingShareFilesState>,+) -> Vec<StagedSharedFile> {+ #[cfg(not(target_os = "ios"))]+ {+ let _ = (app, filenames, state);+ return vec![];+ }++ #[cfg(target_os = "ios")]+ {+ let container_path = match ios_app_group_container_path() {+ Some(p) => p,+ None => return vec![],+ };++ let container_path = std::path::PathBuf::from(container_path);+ let mut files = Vec::with_capacity(filenames.len());+ let mut consumed_filenames = Vec::new();+ for name in filenames {+ let Some(name) = sanitize_shared_filename(&name).map(str::to_owned) else {+ continue;+ };++ let path = container_path.join(&name);+ if !path.exists() {+ consumed_filenames.push(name);+ continue;+ }++ match stage_shared_file(&app, &path, &name) {+ Ok(staged_file) => {+ files.push(staged_file);+ consumed_filenames.push(name);+ }+ Err(error) => {+ tracing::warn!(+ "failed to stage shared file {}: {}",+ path.display(),+ error+ );+ }+ }+ }++ if !consumed_filenames.is_empty() {+ consume_pending_share_filenames(&container_path, &state, &consumed_filenames);+ }++ files+ }+}++/// Tauri command: delete staged share files after the frontend is finished with+/// them (for example after cancel or successful send).+#[tauri::command]+pub(crate) fn clear_shared_files(app: tauri::AppHandle, tokens: Vec<String>) -> Result<(), String> {+ #[cfg(target_os = "ios")]+ {+ for token in tokens {+ let path = match staged_shared_file_path(&app, &token) {+ Ok(path) => path,+ Err(error) if is_staged_shared_file_not_found_error(&error) => continue,+ Err(error) => return Err(error),+ };+ if let Err(error) = std::fs::remove_file(path) {+ if error.kind() != std::io::ErrorKind::NotFound {+ return Err(format!("failed to delete staged shared file: {error}"));+ }+ }+ }+ Ok(())+ }++ #[cfg(not(target_os = "ios"))]+ {+ let _ = (app, tokens);+ Ok(())+ }+}++/// Tauri command: upload a staged shared file directly to a presigned URL+/// without copying the file through JS memory.+#[tauri::command]+pub(crate) async fn upload_shared_file_to_presigned_url(+ app: tauri::AppHandle,+ token: String,+ upload_url: String,+ mime_type: String,+) -> Result<(), String> {+ #[cfg(not(target_os = "ios"))]+ {+ let _ = (app, token, upload_url, mime_type);+ return Ok(());+ }++ #[cfg(target_os = "ios")]+ {+ use reqwest::header::CONTENT_TYPE;++ let upload_url = Url::parse(&upload_url)+ .map_err(|error| format!("invalid shared file upload URL: {error}"))?;+ if !matches!(upload_url.scheme(), "http" | "https") {+ return Err("invalid shared file upload URL scheme".to_string());+ }++ let path = staged_shared_file_path(&app, &token)?;+ let upload_url = upload_url.to_string();++ tokio::task::spawn_blocking(move || -> Result<(), String> {+ let file = std::fs::File::open(&path)+ .map_err(|error| format!("failed to open staged shared file: {error}"))?;+ let size = file+ .metadata()+ .map_err(|error| format!("failed to read staged shared file metadata: {error}"))?+ .len();++ let body = reqwest::blocking::Body::sized(file, size);+ let client = reqwest::blocking::Client::builder()+ .connect_timeout(std::time::Duration::from_secs(30))+ .timeout(std::time::Duration::from_secs(300))+ .build()+ .map_err(|error| format!("failed to build HTTP client: {error}"))?;+ let mut request = client.put(upload_url).body(body);++ if !mime_type.is_empty() {+ request = request.header(CONTENT_TYPE, mime_type);+ }++ let response = request+ .send()+ .map_err(|error| format!("failed to upload staged shared file: {error}"))?;++ let status = response.status();+ if !status.is_success() {+ let detail = response.text().unwrap_or_default();+ if detail.trim().is_empty() {+ return Err(format!(+ "failed to upload staged shared file: HTTP {status}"+ ));+ }+ return Err(format!(+ "failed to upload staged shared file: HTTP {status}: {}",+ detail.trim()+ ));+ }++ if let Err(error) = std::fs::remove_file(&path) {+ if error.kind() != std::io::ErrorKind::NotFound {+ tracing::warn!(+ "failed to delete staged shared file after upload {}: {}",+ path.display(),+ error+ );+ }+ }++ Ok(())+ })+ .await+ .map_err(|error| format!("failed to join staged shared file upload task: {error}"))?+ }+}++pub(crate) fn maybe_handle_share_deep_link(handle: &AppHandle, url: &Url) -> bool {+ #[cfg(target_os = "ios")]+ {+ if url.scheme() == APP_SCHEME && url.host_str() == Some("share") {+ let filenames = share_filenames_from_url(url);+ replace_pending_share_filenames(+ &handle.state::<PendingShareFilesState>(),+ filenames.clone(),+ );+ let _ = handle.emit("share-files-ready", ShareFilesReadyPayload { filenames });+ return true;+ }+ }++ #[cfg(not(target_os = "ios"))]+ let _ = (handle, url);++ false+}++#[cfg(test)]+mod tests;diff --git a/js/app/tauri/src-tauri/src/share_target/tests.rs b/js/app/tauri/src-tauri/src/share_target/tests.rsnew file mode 100644index 0000000000..ea37e44d9d--- /dev/null+++ b/js/app/tauri/src-tauri/src/share_target/tests.rs@@ -0,0 +1,52 @@+use super::*;++#[test]+fn share_filenames_from_url_preserves_order() {+ let url = Url::parse("macro://share?files=share_one.jpg,share_two.mp4").unwrap();++ assert_eq!(+ share_filenames_from_url(&url),+ vec!["share_one.jpg".to_string(), "share_two.mp4".to_string()]+ );+}++#[test]+fn share_filenames_from_url_rejects_invalid_names() {+ let url = Url::parse(+ "macro://share?files=share_ok.png,../bad.mov,not_shared.jpg,share_nested%2Fbad.mp4",+ )+ .unwrap();++ assert_eq!(+ share_filenames_from_url(&url),+ vec!["share_ok.png".to_string()]+ );+}++#[test]+fn remaining_pending_share_filenames_only_removes_consumed_entries() {+ let pending = vec![+ "share_old.jpg".to_string(),+ "share_current.mp4".to_string(),+ "share_next.png".to_string(),+ ];+ let consumed = vec![+ "share_current.mp4".to_string(),+ "share_missing.mov".to_string(),+ ];++ assert_eq!(+ remaining_pending_share_filenames(&pending, &consumed),+ vec!["share_old.jpg".to_string(), "share_next.png".to_string()]+ );+}++#[test]+fn staged_shared_file_not_found_error_matches_helper() {+ assert!(is_staged_shared_file_not_found_error(+ STAGED_SHARED_FILE_NOT_FOUND_ERROR+ ));+ assert!(!is_staged_shared_file_not_found_error(+ "failed to read shared file staging directory"+ ));+}diff --git a/js/app/tauri/src-tauri/tauri.conf.json b/js/app/tauri/src-tauri/tauri.conf.jsonindex 7c631bdede..573a8555a1 100644--- a/js/app/tauri/src-tauri/tauri.conf.json+++ b/js/app/tauri/src-tauri/tauri.conf.json@@ -20,7 +20,16 @@}],"security": {- "csp": null+ "csp": null,+ "assetProtocol": {+ "enable": true,+ "scope": {+ "allow": [+ "$APPCACHE/ios-share-staging/**"+ ],+ "deny": []+ }+ }}},"bundle": {