接入移动壳文本文件导出能力

Expo 移动壳通过文件系统写入缓存文本并调用系统分享保存面板

补充移动壳导出能力依赖、配置守卫和 HostBridge 单测

更新宿主壳能力协议、方案文档和共享决策记录
This commit is contained in:
2026-06-17 23:32:00 +08:00
parent 87cdb8bfba
commit eb9981e67d
9 changed files with 209 additions and 7 deletions

View File

@@ -15,8 +15,10 @@
"@expo/metro-runtime": "^56.0.15", "@expo/metro-runtime": "^56.0.15",
"expo": "^56.0.12", "expo": "^56.0.12",
"expo-clipboard": "^56.0.4", "expo-clipboard": "^56.0.4",
"expo-file-system": "^56.0.8",
"expo-haptics": "^56.0.3", "expo-haptics": "^56.0.3",
"expo-linking": "^56.0.14", "expo-linking": "^56.0.14",
"expo-sharing": "^56.0.18",
"expo-status-bar": "^56.0.4", "expo-status-bar": "^56.0.4",
"react": "^19.0.0", "react": "^19.0.0",
"react-native": "^0.86.0", "react-native": "^0.86.0",

View File

@@ -6,6 +6,10 @@ const appConfigPath = new URL('../app.json', import.meta.url);
const appConfig = JSON.parse(fs.readFileSync(appConfigPath, 'utf8')).expo; const appConfig = JSON.parse(fs.readFileSync(appConfigPath, 'utf8')).expo;
const appPath = new URL('../App.tsx', import.meta.url); const appPath = new URL('../App.tsx', import.meta.url);
const appSource = fs.readFileSync(appPath, 'utf8'); const appSource = fs.readFileSync(appPath, 'utf8');
const bridgePath = new URL('../src/mobileHostBridge.ts', import.meta.url);
const bridgeSource = fs.readFileSync(bridgePath, 'utf8');
const packagePath = new URL('../package.json', import.meta.url);
const packageConfig = JSON.parse(fs.readFileSync(packagePath, 'utf8'));
const iconPath = new URL('../assets/icon.png', import.meta.url); const iconPath = new URL('../assets/icon.png', import.meta.url);
const icon = PNG.sync.read(fs.readFileSync(iconPath)); const icon = PNG.sync.read(fs.readFileSync(iconPath));
@@ -48,3 +52,19 @@ for (const snippet of [
throw new Error(`mobile shell App missing ${snippet}`); throw new Error(`mobile shell App missing ${snippet}`);
} }
} }
for (const dependency of ['expo-file-system', 'expo-sharing']) {
if (!packageConfig.dependencies?.[dependency]) {
throw new Error(`mobile shell package missing ${dependency}`);
}
}
for (const snippet of [
'file.exportText',
'Sharing.shareAsync',
'normalizeHostBridgeExportFileName',
]) {
if (!bridgeSource.includes(snippet)) {
throw new Error(`mobile shell HostBridge missing ${snippet}`);
}
}

View File

@@ -1,4 +1,5 @@
import * as Linking from 'expo-linking'; import * as Linking from 'expo-linking';
import * as Sharing from 'expo-sharing';
import { Share } from 'react-native'; import { Share } from 'react-native';
import { afterEach, describe, expect, test, vi } from 'vitest'; import { afterEach, describe, expect, test, vi } from 'vitest';
@@ -19,6 +20,30 @@ vi.mock('expo-clipboard', () => ({
setStringAsync: vi.fn(), setStringAsync: vi.fn(),
})); }));
const writtenFiles = vi.hoisted(
() => [] as { uri: string; content: string }[],
);
vi.mock('expo-file-system', () => ({
Paths: {
cache: 'file:///cache/',
},
File: class MockFile {
uri: string;
constructor(_base: string, fileName: string) {
this.uri = `file:///cache/${fileName}`;
}
write(content: string) {
writtenFiles.push({
uri: this.uri,
content,
});
}
},
}));
vi.mock('expo-haptics', () => ({ vi.mock('expo-haptics', () => ({
ImpactFeedbackStyle: { ImpactFeedbackStyle: {
Heavy: 'heavy', Heavy: 'heavy',
@@ -32,6 +57,11 @@ vi.mock('expo-linking', () => ({
openURL: vi.fn(), openURL: vi.fn(),
})); }));
vi.mock('expo-sharing', () => ({
isAvailableAsync: vi.fn(async () => true),
shareAsync: vi.fn(),
}));
vi.mock('react-native', () => ({ vi.mock('react-native', () => ({
Platform: { Platform: {
OS: 'ios', OS: 'ios',
@@ -87,7 +117,11 @@ function expectFailed(response: HostBridgeResponse) {
afterEach(() => { afterEach(() => {
vi.mocked(Linking.openURL).mockReset(); vi.mocked(Linking.openURL).mockReset();
vi.mocked(Sharing.isAvailableAsync).mockReset();
vi.mocked(Sharing.isAvailableAsync).mockResolvedValue(true);
vi.mocked(Sharing.shareAsync).mockReset();
vi.mocked(Share.share).mockReset(); vi.mocked(Share.share).mockReset();
writtenFiles.length = 0;
resetMobileHostBridgeForTest(); resetMobileHostBridgeForTest();
}); });
@@ -104,6 +138,9 @@ describe('handleMobileHostBridgeMessage', () => {
expect( expect(
(okResponse.result as { capabilities: string[] }).capabilities, (okResponse.result as { capabilities: string[] }).capabilities,
).toContain('navigation.openNativePage'); ).toContain('navigation.openNativePage');
expect(
(okResponse.result as { capabilities: string[] }).capabilities,
).toContain('file.exportText');
expect( expect(
(okResponse.result as { capabilities: string[] }).capabilities, (okResponse.result as { capabilities: string[] }).capabilities,
).toEqual( ).toEqual(
@@ -237,7 +274,41 @@ describe('handleMobileHostBridgeMessage', () => {
expect(Share.share).not.toHaveBeenCalled(); expect(Share.share).not.toHaveBeenCalled();
}); });
test('移动壳未接入真实导出能力时明确返回 unsupported', async () => { test('file.exportText 写入缓存文件并调起系统分享', async () => {
const response = await send(
request('file.exportText', {
fileName: ' ../作品:记录?.txt ',
content: '暖灯猫街',
mimeType: 'text/markdown',
}),
);
const okResponse = expectOk(response);
expect(okResponse.result).toEqual({
action: 'saved',
fileName: '作品-记录-.txt',
bytes: 12,
});
expect(writtenFiles).toEqual([
{
uri: 'file:///cache/作品-记录-.txt',
content: '暖灯猫街',
},
]);
expect(Sharing.shareAsync).toHaveBeenCalledWith(
'file:///cache/作品-记录-.txt',
{
mimeType: 'text/markdown',
UTI: 'public.plain-text',
dialogTitle: '作品-记录-.txt',
},
);
});
test('file.exportText 在系统分享不可用时明确返回 unsupported capability', async () => {
vi.mocked(Sharing.isAvailableAsync).mockResolvedValue(false);
const response = await send( const response = await send(
request('file.exportText', { request('file.exportText', {
fileName: '作品记录.txt', fileName: '作品记录.txt',
@@ -247,6 +318,23 @@ describe('handleMobileHostBridgeMessage', () => {
const failedResponse = expectFailed(response); const failedResponse = expectFailed(response);
expect(failedResponse.error.code).toBe('unsupported_method'); expect(failedResponse.error.code).toBe('unsupported_capability');
expect(writtenFiles).toEqual([]);
expect(Sharing.shareAsync).not.toHaveBeenCalled();
});
test('file.exportText 拒绝超出上限的文本内容', async () => {
const response = await send(
request('file.exportText', {
fileName: '作品记录.txt',
content: 'a'.repeat(5 * 1024 * 1024 + 1),
}),
);
const failedResponse = expectFailed(response);
expect(failedResponse.error.code).toBe('invalid_request');
expect(writtenFiles).toEqual([]);
expect(Sharing.shareAsync).not.toHaveBeenCalled();
}); });
}); });

View File

@@ -1,10 +1,14 @@
import * as Clipboard from 'expo-clipboard'; import * as Clipboard from 'expo-clipboard';
import { File, Paths } from 'expo-file-system';
import * as Haptics from 'expo-haptics'; import * as Haptics from 'expo-haptics';
import * as Linking from 'expo-linking'; import * as Linking from 'expo-linking';
import * as Sharing from 'expo-sharing';
import { Platform, Share } from 'react-native'; import { Platform, Share } from 'react-native';
import { import {
type ClipboardWriteTextPayload, type ClipboardWriteTextPayload,
type FileExportTextPayload,
type FileExportTextResult,
type HapticsImpactPayload, type HapticsImpactPayload,
HOST_BRIDGE_PROTOCOL, HOST_BRIDGE_PROTOCOL,
HOST_BRIDGE_VERSION, HOST_BRIDGE_VERSION,
@@ -14,6 +18,7 @@ import {
type HostBridgeRequest, type HostBridgeRequest,
type HostBridgeResponse, type HostBridgeResponse,
type NavigateNativePagePayload, type NavigateNativePagePayload,
normalizeHostBridgeExportFileName,
normalizeHostBridgeExternalUrl, normalizeHostBridgeExternalUrl,
type OpenExternalUrlPayload, type OpenExternalUrlPayload,
type ShareOpenPayload, type ShareOpenPayload,
@@ -21,6 +26,7 @@ import {
import { resolveMobileShellWebViewUrl } from './mobileShellNavigation'; import { resolveMobileShellWebViewUrl } from './mobileShellNavigation';
const WEB_APP_ORIGIN = 'https://app.genarrative.world'; const WEB_APP_ORIGIN = 'https://app.genarrative.world';
const EXPORT_TEXT_MAX_BYTES = 5 * 1024 * 1024;
export const MOBILE_HOST_CAPABILITIES: HostBridgeCapability[] = [ export const MOBILE_HOST_CAPABILITIES: HostBridgeCapability[] = [
'host.getRuntime', 'host.getRuntime',
@@ -31,6 +37,7 @@ export const MOBILE_HOST_CAPABILITIES: HostBridgeCapability[] = [
'navigation.canGoBack', 'navigation.canGoBack',
'app.openExternalUrl', 'app.openExternalUrl',
'clipboard.writeText', 'clipboard.writeText',
'file.exportText',
'haptics.impact', 'haptics.impact',
]; ];
@@ -62,6 +69,23 @@ function invalidRequest(message: string): HostBridgeError {
}; };
} }
function utf8ByteLength(value: string) {
let bytes = 0;
for (const character of value) {
const codePoint = character.codePointAt(0) ?? 0;
if (codePoint <= 0x7f) {
bytes += 1;
} else if (codePoint <= 0x7ff) {
bytes += 2;
} else if (codePoint <= 0xffff) {
bytes += 3;
} else {
bytes += 4;
}
}
return bytes;
}
function isHostBridgeRequest(value: unknown): value is HostBridgeRequest { function isHostBridgeRequest(value: unknown): value is HostBridgeRequest {
if (!value || typeof value !== 'object') { if (!value || typeof value !== 'object') {
return false; return false;
@@ -132,6 +156,43 @@ async function writeClipboard(payload: unknown) {
return true; return true;
} }
async function exportTextFile(payload: unknown): Promise<FileExportTextResult> {
const exportPayload = payload as FileExportTextPayload | undefined;
const content = exportPayload?.content;
if (typeof content !== 'string') {
throw invalidRequest('content is required');
}
const bytes = utf8ByteLength(content);
if (bytes > EXPORT_TEXT_MAX_BYTES) {
throw invalidRequest('content exceeds file export size limit');
}
const isSharingAvailable = await Sharing.isAvailableAsync();
if (!isSharingAvailable) {
throw {
code: 'unsupported_capability',
message: 'file sharing is unavailable in mobile shell',
} satisfies HostBridgeError;
}
const fileName = normalizeHostBridgeExportFileName(exportPayload?.fileName);
const mimeType = exportPayload?.mimeType || 'text/plain';
const file = new File(Paths.cache, fileName);
file.write(content);
await Sharing.shareAsync(file.uri, {
mimeType,
UTI: 'public.plain-text',
dialogTitle: fileName,
});
return {
action: 'saved',
fileName,
bytes,
};
}
async function runHaptics(payload: unknown) { async function runHaptics(payload: unknown) {
const style = (payload as HapticsImpactPayload | undefined)?.style; const style = (payload as HapticsImpactPayload | undefined)?.style;
const impactStyle = const impactStyle =
@@ -259,6 +320,8 @@ async function handleRequest(request: HostBridgeRequest) {
return ok(request, await openExternalUrl(request.payload)); return ok(request, await openExternalUrl(request.payload));
case 'clipboard.writeText': case 'clipboard.writeText':
return ok(request, await writeClipboard(request.payload)); return ok(request, await writeClipboard(request.payload));
case 'file.exportText':
return ok(request, await exportTextFile(request.payload));
case 'haptics.impact': case 'haptics.impact':
return ok(request, await runHaptics(request.payload)); return ok(request, await runHaptics(request.payload));
case 'share.open': case 'share.open':
@@ -273,7 +336,6 @@ async function handleRequest(request: HostBridgeRequest) {
return ok(request, openNativePage(request.payload)); return ok(request, openNativePage(request.payload));
case 'auth.requestLogin': case 'auth.requestLogin':
case 'payment.request': case 'payment.request':
case 'file.exportText':
return failure(request, unsupported(request.method)); return failure(request, unsupported(request.method));
default: default:
return failure(request, unsupported(request.method)); return failure(request, unsupported(request.method));

View File

@@ -20,7 +20,7 @@
- 背景:后续需要移动端 App 和桌面端 App但现有主站、固定玩法 runtime、小程序壳和未来 AI H5 sandbox 已经以 H5 为主线;如果移动端重写 React Native UI、桌面端重写 Rust/Tauri UI会形成玩法、登录、支付、分享和运行态的多套实现。 - 背景:后续需要移动端 App 和桌面端 App但现有主站、固定玩法 runtime、小程序壳和未来 AI H5 sandbox 已经以 H5 为主线;如果移动端重写 React Native UI、桌面端重写 Rust/Tauri UI会形成玩法、登录、支付、分享和运行态的多套实现。
- 决策:移动端原生壳采用 `Expo + React Native`,桌面端壳采用 `Tauri`。两者都只作为 `native_app` 宿主壳和 HostBridge adapter不重写现有 React H5 主站,不把固定内置玩法迁到 React Native / Rust UI也不让 AI 生成 H5 游戏直接访问完整 HostBridge。Expo 壳通过 `react-native-webview` 承接 H5 与 native 通信Tauri 壳通过受控 command 和 capabilities 承接桌面能力;新增能力必须先进入 HostBridge 契约和测试。 - 决策:移动端原生壳采用 `Expo + React Native`,桌面端壳采用 `Tauri`。两者都只作为 `native_app` 宿主壳和 HostBridge adapter不重写现有 React H5 主站,不把固定内置玩法迁到 React Native / Rust UI也不让 AI 生成 H5 游戏直接访问完整 HostBridge。Expo 壳通过 `react-native-webview` 承接 H5 与 native 通信Tauri 壳通过受控 command 和 capabilities 承接桌面能力;新增能力必须先进入 HostBridge 契约和测试。
- 2026-06-17 首轮落地:新增 `packages/shared/src/contracts/hostBridge.ts``src/services/host-bridge/nativeAppHostBridge.ts``apps/mobile-shell/``apps/desktop-shell/`。壳只声明并实现真实可用能力;移动壳使用真实品牌图标资产并支持 `genarrative://`、iOS associated domain、Android app link 到同源 H5 路径,`navigation.openNativePage` 只接受同源 H5 route 并切换 WebView URL不伪造尚未存在的原生页面且通过 `host.events` 注入 `navigation.canGoBack` 返回栈状态事件,`share.setTarget` / `share.open` 解析统一分享目标并调用 React Native 系统分享面板;`app.openExternalUrl` 在 Expo 与 Tauri 两端都只允许 `http:``https:``mailto:``tel:` 外链协议;桌面壳已通过 Tauri clipboard-manager 接入 `clipboard.writeText`,将 `navigation.openNativePage` 实现为 `https://app.genarrative.world` 同源 H5 route 的主窗口受控跳转,并将 `share.setTarget` / `share.open` 实现为复制非空分享文本到系统剪贴板,`app.setTitle` 通过主窗口 API 同步非空窗口标题;桌面 `file.exportText` 通过 Tauri dialog 插件打开系统保存对话框并由 Rust 写入文本文件,但不把 dialog / fs 插件 command 直接暴露给 H5成功只返回文件名和字节数用户取消返回 `cancelled`;登录、支付、原生系统分享面板等未接入真实 SDK / 插件前必须返回 unsupported 并让 H5 fallback生产代码禁止 mock 成功。 - 2026-06-17 首轮落地:新增 `packages/shared/src/contracts/hostBridge.ts``src/services/host-bridge/nativeAppHostBridge.ts``apps/mobile-shell/``apps/desktop-shell/`。壳只声明并实现真实可用能力;移动壳使用真实品牌图标资产并支持 `genarrative://`、iOS associated domain、Android app link 到同源 H5 路径,`navigation.openNativePage` 只接受同源 H5 route 并切换 WebView URL不伪造尚未存在的原生页面且通过 `host.events` 注入 `navigation.canGoBack` 返回栈状态事件,`share.setTarget` / `share.open` 解析统一分享目标并调用 React Native 系统分享面板`file.exportText` 写入 Expo 缓存文本文件后交给系统分享 / 保存面板,成功只返回文件名和字节数`app.openExternalUrl` 在 Expo 与 Tauri 两端都只允许 `http:``https:``mailto:``tel:` 外链协议;桌面壳已通过 Tauri clipboard-manager 接入 `clipboard.writeText`,将 `navigation.openNativePage` 实现为 `https://app.genarrative.world` 同源 H5 route 的主窗口受控跳转,并将 `share.setTarget` / `share.open` 实现为复制非空分享文本到系统剪贴板,`app.setTitle` 通过主窗口 API 同步非空窗口标题;桌面 `file.exportText` 通过 Tauri dialog 插件打开系统保存对话框并由 Rust 写入文本文件,但不把 dialog / fs 插件 command 直接暴露给 H5成功只返回文件名和字节数用户取消返回 `cancelled`;登录、支付、原生系统分享面板等未接入真实 SDK / 插件前必须返回 unsupported 并让 H5 fallback生产代码禁止 mock 成功。
- 影响范围:`src/services/host-bridge/`、未来 `apps/mobile-shell/`、未来 `apps/desktop-shell/`、移动端支付 / 分享 / 深链 / 推送、桌面端系统能力、AI H5 sandbox 的 GameBridge 边界。 - 影响范围:`src/services/host-bridge/`、未来 `apps/mobile-shell/`、未来 `apps/desktop-shell/`、移动端支付 / 分享 / 深链 / 推送、桌面端系统能力、AI H5 sandbox 的 GameBridge 边界。
- 验证方式普通浏览器、小程序、Expo 壳、Tauri 壳都能返回正确 `getHostRuntime()`;未支持能力能回退 H5固定玩法在各宿主中读取同一作品数据和运行态 snapshotAI sandbox 无法直接调用 HostBridgeTauri release 不允许任意远端页面调用桌面命令。 - 验证方式普通浏览器、小程序、Expo 壳、Tauri 壳都能返回正确 `getHostRuntime()`;未支持能力能回退 H5固定玩法在各宿主中读取同一作品数据和运行态 snapshotAI sandbox 无法直接调用 HostBridgeTauri release 不允许任意远端页面调用桌面命令。
- 关联文档:`docs/【前端架构】ExpoReactNative与Tauri宿主壳方案-2026-06-17.md``docs/【前端架构】宿主壳能力统一协议-2026-06-17.md` - 关联文档:`docs/【前端架构】ExpoReactNative与Tauri宿主壳方案-2026-06-17.md``docs/【前端架构】宿主壳能力统一协议-2026-06-17.md`

View File

@@ -120,7 +120,7 @@ type HostBridgeEvent = {
| `app.openExternalUrl` | 用系统浏览器打开外链 | 支持白名单协议 | 支持白名单协议 | | `app.openExternalUrl` | 用系统浏览器打开外链 | 支持白名单协议 | 支持白名单协议 |
| `app.setTitle` | 同步宿主窗口标题 | 不声明 | 支持 | | `app.setTitle` | 同步宿主窗口标题 | 不声明 | 支持 |
| `clipboard.writeText` | 写剪贴板 | 可选 | 可选 | | `clipboard.writeText` | 写剪贴板 | 可选 | 可选 |
| `file.exportText` | 导出文本到用户选择的本地文件 | 不声明 | 支持 | | `file.exportText` | 导出文本到用户选择的本地文件 | 支持系统分享 / 保存面板 | 支持系统保存对话框 |
| `haptics.impact` | 轻量触感反馈 | 可选 | 不支持 | | `haptics.impact` | 轻量触感反馈 | 可选 | 不支持 |
每个 method 都必须有明确 payload schema、超时、错误码和能力开关H5 看到不支持时回退到现有浏览器路径。 每个 method 都必须有明确 payload schema、超时、错误码和能力开关H5 看到不支持时回退到现有浏览器路径。
@@ -241,7 +241,7 @@ GameBridge 禁止:
- iOS / Android 深链打开作品详情、创作页和邀请码。 - iOS / Android 深链打开作品详情、创作页和邀请码。
- 登录和支付先 fallback 到 H5只把能力边界跑通。 - 登录和支付先 fallback 到 H5只把能力边界跑通。
当前状态:已新增 `apps/mobile-shell/`,通过 Expo development build 运行,`react-native-webview` 加载 H5 URL 并附加 `native_app` 宿主 query。移动壳使用真实品牌图标资产已接入 `genarrative://` scheme、iOS associated domain 和 Android app link filter启动和运行时 deep link 只会映射到同源 H5 路径并继续附加 HostBridge 上下文,外域和危险协议回退到默认主站入口。首轮真实能力包括 `host.getRuntime``host.events``share.open``share.setTarget``navigation.openNativePage``navigation.canGoBack``app.openExternalUrl``clipboard.writeText``haptics.impact` 和 Android 返回键回退;其中 `share.setTarget` / `share.open` 会解析统一分享目标里的 `title``message``url``work``path``targetPath` 并调用 React Native 系统分享面板;`navigation.openNativePage` 在 Expo 壳内只接受同源 H5 route 并切换 WebView URL不伪造尚未存在的登录、支付或其它原生页面`navigation.canGoBack` 由 WebView 导航状态变化实时注入 H5`app.openExternalUrl` 只允许 `http:``https:``mailto:``tel:` 外链协议。登录支付和本地文件导出尚未接入渠道 SDK / 原生文档能力时明确返回 unsupported让 H5 fallback 承接。 当前状态:已新增 `apps/mobile-shell/`,通过 Expo development build 运行,`react-native-webview` 加载 H5 URL 并附加 `native_app` 宿主 query。移动壳使用真实品牌图标资产已接入 `genarrative://` scheme、iOS associated domain 和 Android app link filter启动和运行时 deep link 只会映射到同源 H5 路径并继续附加 HostBridge 上下文,外域和危险协议回退到默认主站入口。首轮真实能力包括 `host.getRuntime``host.events``share.open``share.setTarget``navigation.openNativePage``navigation.canGoBack``app.openExternalUrl``clipboard.writeText``file.exportText``haptics.impact` 和 Android 返回键回退;其中 `share.setTarget` / `share.open` 会解析统一分享目标里的 `title``message``url``work``path``targetPath` 并调用 React Native 系统分享面板;`navigation.openNativePage` 在 Expo 壳内只接受同源 H5 route 并切换 WebView URL不伪造尚未存在的登录、支付或其它原生页面`navigation.canGoBack` 由 WebView 导航状态变化实时注入 H5`app.openExternalUrl` 只允许 `http:``https:``mailto:``tel:` 外链协议`file.exportText` 通过 Expo 文件系统写入缓存文本文件,再交给系统分享 / 保存面板,文件名必须清洗,单次文本不超过 5 MiB成功只返回文件名和字节数。登录支付尚未接入渠道 SDK / 原生页面时明确返回 unsupported让 H5 fallback 承接。
### Phase 3Tauri 桌面壳 MVP ### Phase 3Tauri 桌面壳 MVP

View File

@@ -45,7 +45,7 @@ AI H5 sandbox
- `setHostShareTarget()`:把当前公开作品分享目标同步给宿主。 - `setHostShareTarget()`:把当前公开作品分享目标同步给宿主。
- `openHostShareGrid()`:微信小程序九宫格切图页。 - `openHostShareGrid()`:微信小程序九宫格切图页。
- `navigateHostNativePage()`:受控跳转宿主页,供订阅授权、支付、登录等 adapter 复用。Expo 移动壳首版只接受同源 H5 route 并切换 WebView URLTauri 桌面壳同样只接受 `https://app.genarrative.world` 同源 H5 route 并在主窗口内跳转。真正原生页面、登录和支付能力必须等对应 SDK / 页面接入后再声明支持。 - `navigateHostNativePage()`:受控跳转宿主页,供订阅授权、支付、登录等 adapter 复用。Expo 移动壳首版只接受同源 H5 route 并切换 WebView URLTauri 桌面壳同样只接受 `https://app.genarrative.world` 同源 H5 route 并在主窗口内跳转。真正原生页面、登录和支付能力必须等对应 SDK / 页面接入后再声明支持。
- `exportHostTextFile()`:原生 App 宿主的受控文本导出入口。Tauri 桌面壳通过 `file.exportText` 打开系统保存对话框并写入用户选择的文件文件名必须清洗,单次文本不超过 5 MiB成功只返回文件名和字节数。Expo 移动壳当前不声明本地文件导出能力,误调时返回 unsupported由 H5 浏览器下载或后续真实原生文档能力承接。 - `exportHostTextFile()`:原生 App 宿主的受控文本导出入口。Expo 移动壳通过 `file.exportText` 写入缓存文本文件并交给系统分享 / 保存面板;Tauri 桌面壳通过 `file.exportText` 打开系统保存对话框并写入用户选择的文件文件名必须清洗,单次文本不超过 5 MiB成功只返回文件名和字节数,不把本机绝对路径暴露给 H5系统分享不可用或用户取消时返回明确错误由 H5 fallback 承接。
## 迁移顺序 ## 迁移顺序

28
package-lock.json generated
View File

@@ -17,8 +17,10 @@
"dotenv": "^17.2.3", "dotenv": "^17.2.3",
"expo": "^56.0.12", "expo": "^56.0.12",
"expo-clipboard": "^56.0.4", "expo-clipboard": "^56.0.4",
"expo-file-system": "^56.0.8",
"expo-haptics": "^56.0.3", "expo-haptics": "^56.0.3",
"expo-linking": "^56.0.14", "expo-linking": "^56.0.14",
"expo-sharing": "^56.0.18",
"expo-status-bar": "^56.0.4", "expo-status-bar": "^56.0.4",
"lucide-react": "^0.546.0", "lucide-react": "^0.546.0",
"motion": "^12.23.24", "motion": "^12.23.24",
@@ -6451,6 +6453,22 @@
"node": ">=20.16.0" "node": ">=20.16.0"
} }
}, },
"node_modules/expo-sharing": {
"version": "56.0.18",
"resolved": "https://registry.npmjs.org/expo-sharing/-/expo-sharing-56.0.18.tgz",
"integrity": "sha512-45w4BWNFmdTczp+fJX6YfwJrn9sX+VeRWz2VWLhauygcCrym44HtVDXX5yVYPB9TW9ZesLcEI+CCrCBNWL7smQ==",
"license": "MIT",
"dependencies": {
"@expo/config-plugins": "^56.0.9",
"@expo/config-types": "^56.0.6",
"@expo/plist": "^0.7.0"
},
"peerDependencies": {
"expo": "*",
"react": "*",
"react-native": "*"
}
},
"node_modules/expo-status-bar": { "node_modules/expo-status-bar": {
"version": "56.0.4", "version": "56.0.4",
"resolved": "https://registry.npmjs.org/expo-status-bar/-/expo-status-bar-56.0.4.tgz", "resolved": "https://registry.npmjs.org/expo-status-bar/-/expo-status-bar-56.0.4.tgz",
@@ -17307,6 +17325,16 @@
"resolved": "https://registry.npmjs.org/expo-server/-/expo-server-56.0.5.tgz", "resolved": "https://registry.npmjs.org/expo-server/-/expo-server-56.0.5.tgz",
"integrity": "sha512-SmM2p2g3Jrktpiazcst+OxhjSzOHXKAY4BPURHYHXvApzzoybMmrNF4IEZ8DKZ145BhSe4ydAmlEFCRTsdtgUQ==" "integrity": "sha512-SmM2p2g3Jrktpiazcst+OxhjSzOHXKAY4BPURHYHXvApzzoybMmrNF4IEZ8DKZ145BhSe4ydAmlEFCRTsdtgUQ=="
}, },
"expo-sharing": {
"version": "56.0.18",
"resolved": "https://registry.npmjs.org/expo-sharing/-/expo-sharing-56.0.18.tgz",
"integrity": "sha512-45w4BWNFmdTczp+fJX6YfwJrn9sX+VeRWz2VWLhauygcCrym44HtVDXX5yVYPB9TW9ZesLcEI+CCrCBNWL7smQ==",
"requires": {
"@expo/config-plugins": "^56.0.9",
"@expo/config-types": "^56.0.6",
"@expo/plist": "^0.7.0"
}
},
"expo-status-bar": { "expo-status-bar": {
"version": "56.0.4", "version": "56.0.4",
"resolved": "https://registry.npmjs.org/expo-status-bar/-/expo-status-bar-56.0.4.tgz", "resolved": "https://registry.npmjs.org/expo-status-bar/-/expo-status-bar-56.0.4.tgz",

View File

@@ -86,8 +86,10 @@
"dotenv": "^17.2.3", "dotenv": "^17.2.3",
"expo": "^56.0.12", "expo": "^56.0.12",
"expo-clipboard": "^56.0.4", "expo-clipboard": "^56.0.4",
"expo-file-system": "^56.0.8",
"expo-haptics": "^56.0.3", "expo-haptics": "^56.0.3",
"expo-linking": "^56.0.14", "expo-linking": "^56.0.14",
"expo-sharing": "^56.0.18",
"expo-status-bar": "^56.0.4", "expo-status-bar": "^56.0.4",
"lucide-react": "^0.546.0", "lucide-react": "^0.546.0",
"motion": "^12.23.24", "motion": "^12.23.24",