Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion apps/mobile/app/_layout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import '@/platform/polyfills'
import '../global.css'

import { useLinkingURL } from 'expo-linking'
Expand Down
2 changes: 2 additions & 0 deletions apps/mobile/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import './src/platform/polyfills'
import 'expo-router/entry'
6 changes: 4 additions & 2 deletions apps/mobile/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
{
"name": "vibeface-mobile",
"private": true,
"main": "expo-router/entry",
"main": "./index.ts",
"scripts": {
"start": "expo start",
"ios": "expo run:ios",
"android": "expo run:android",
"typecheck": "tsc --noEmit"
"typecheck": "tsc --noEmit",
"test:polyfills": "node scripts/check-polyfills.mjs"
},
"dependencies": {
"@bacons/text-decoder": "0.0.0",
"@expo-google-fonts/geist": "^0.4.2",
"@expo-google-fonts/geist-mono": "^0.4.3",
"@rn-primitives/slot": "^1.5.2",
Expand Down
68 changes: 68 additions & 0 deletions apps/mobile/scripts/check-polyfills.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import assert from 'node:assert/strict'
import { webcrypto, randomUUID } from 'node:crypto'
import { existsSync, readFileSync } from 'node:fs'
import { createRequire } from 'node:module'
import { dirname, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
import vm from 'node:vm'
import ts from 'typescript'

const app = fileURLToPath(new URL('..', import.meta.url))
const packageFile = resolve(app, 'package.json')
const expoRequire = createRequire(createRequire(packageFile).resolve('expo/package.json'))
const { transformSync } = expoRequire('@babel/core')

function bootstrap(existing) {
const context = vm.createContext({ TextEncoder, ArrayBuffer, DataView, Uint8Array, console, __DEV__: false })
context.global = context
if (existing) context.TextDecoder = existing
const modules = new Map()
function load(specifier, parent) {
if (specifier === 'react-native-url-polyfill/auto') return {}
if (specifier === 'expo-crypto') return {
CryptoDigestAlgorithm: { SHA256: 'SHA-256' },
digest: (algorithm, data) => webcrypto.subtle.digest(algorithm, data),
getRandomValues: data => webcrypto.getRandomValues(data), randomUUID,
}
if (specifier === 'expo-router/entry') {
assert.equal(typeof load('../../packages/client/src/lib/transport.ts', packageFile).createTransport, 'function')
assert.equal(typeof load('../../packages/client/src/lib/secure.ts', packageFile).secureKit, 'function')
return {}
}
const typescript = resolve(dirname(parent), `${specifier}.ts`)
const filename = specifier.startsWith('.') && existsSync(typescript) ? typescript : createRequire(parent).resolve(specifier)
if (modules.has(filename)) return modules.get(filename).exports
const source = readFileSync(filename, 'utf8')
const code = filename.endsWith('.ts')
? ts.transpileModule(source, { compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2022 } }).outputText
: transformSync(source, { filename, babelrc: false, configFile: false, plugins: [expoRequire.resolve('@babel/plugin-transform-flow-strip-types'), expoRequire.resolve('@babel/plugin-transform-modules-commonjs')] }).code
const module = { exports: {} }
modules.set(filename, module)
vm.runInContext(`(function(require, module, exports) {${code}\n})`, context, { filename })(value => load(value, filename), module, module.exports)
return module.exports
}
load(JSON.parse(readFileSync(packageFile, 'utf8')).main, packageFile)
return context.TextDecoder
}

const Decoder = bootstrap()
const decoder = new Decoder('utf-8', { fatal: true })
const encoder = new TextEncoder()
assert.equal(decoder.fatal, true)
assert.equal(decoder.decode(encoder.encode('中文 😀')), '中文 😀')
assert.equal(decoder.decode(Uint8Array.of(0xef, 0xbb, 0xbf, 0x61)), 'a')
assert.equal(new Decoder('utf-8', { ignoreBOM: true }).decode(Uint8Array.of(0xef, 0xbb, 0xbf, 0x61)), '\ufeffa')
const padded = Uint8Array.of(0xff, 0x61, 0x62, 0xff)
assert.equal(decoder.decode(padded.subarray(1, 3)), 'ab')
assert.equal(decoder.decode(new DataView(padded.buffer, 1, 2)), 'ab')
assert.equal(decoder.decode(encoder.encode('again').buffer), 'again')
for (const bytes of [[0x80], [0xc0, 0xaf], [0xe2, 0x82], [0xed, 0xa0, 0x80], [0xf4, 0x90, 0x80, 0x80]]) {
assert.throws(() => decoder.decode(Uint8Array.from(bytes)), { name: 'TypeError' })
assert.equal(decoder.decode(encoder.encode('recovered')), 'recovered')
}
assert.equal(new Decoder().decode(Uint8Array.of(0x80)), '\ufffd')
const stream = new Decoder('utf-8', { fatal: true })
assert.equal(stream.decode(Uint8Array.of(0xe4, 0xb8), { stream: true }), '')
assert.equal(stream.decode(Uint8Array.of(0xad)), '中')
assert.equal(bootstrap(TextDecoder), TextDecoder)
console.log('Mobile bootstrap and strict UTF-8 decoding passed (missing and existing TextDecoder).')
1 change: 1 addition & 0 deletions apps/mobile/src/platform/polyfills.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import '@bacons/text-decoder/install'
import 'react-native-url-polyfill/auto'
import { CryptoDigestAlgorithm, digest, getRandomValues, randomUUID } from 'expo-crypto'

Expand Down
4 changes: 4 additions & 0 deletions packages/docs/e2e.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,3 +214,7 @@ native config 默认关闭 trace 和整段 video。原始日志、自动失败
项目已配置 Codex、Claude Code 和 Cursor 的 e2e MCP。安装依赖后重新打开可信项目会话。编写或运行测试前,读取 [e2e skill](../../.agents/skills/e2e/SKILL.md)。

当前未选择 AI 模型。需要 `agent.act` 时,先选择订阅、API 或本地模型,再按 `pnpm exec e2e guide setup` 配置 provider。ChatGPT 订阅的登录命令为 `pnpm exec e2e login openai`,完成登录后再运行模型测试。不要把凭证写入仓库;CI 保持不调用真实模型。

## 真机启动检查

真机安装应覆盖现有 App,保留数据和钥匙串。安装成功后还须确认 Release App 显示正常界面且进程仍存活;`devicectl` 返回启动成功并不证明 JavaScript 初始化成功。若 App 立即退出,先用 `devicectl device process launch --console` 抓取异常,不要通过卸载或清空数据排查。
12 changes: 12 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading