Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(mobile): 为 iOS 分享接收和唤起失败提供明确反馈 (#4987)
Dashbaf3f41300e6
diff --git a/apps/mobile/plugins/incoming-share-feedback.swift b/apps/mobile/plugins/incoming-share-feedback.swiftnew file mode 100644index 0000000000..bb9eeaaf76--- /dev/null+++ b/apps/mobile/plugins/incoming-share-feedback.swift@@ -0,0 +1,39 @@+// Appended to Expo's generated controller by with-incoming-share-feedback.js.+// UIKit's standard alert owns Light/Dark colors, Dynamic Type and accessibility.+private extension ShareIntoViewController {+ func finishOpening(opened: Bool) {+ guard !shareClosed, !openResultHandled else { return }+ openResultHandled = true+ if opened {+ close()+ } else {+ // The payload remains in the existing App Group slot for manual opening.+ showShareFeedback(received: true)+ }+ }++ func showShareFeedback(received: Bool) {+ guard !shareClosed else { return }+ let prefix = received ? "received" : "failed"+ let alert = UIAlertController(+ title: shareString(prefix + "Title"),+ message: shareString(prefix + "Message"),+ preferredStyle: .alert+ )+ alert.addAction(UIAlertAction(title: shareString("done"), style: .default) { [weak self] _ in+ self?.close()+ })+ present(alert, animated: true)+ }++ func shareString(_ key: String) -> String {+ let locale = Bundle.preferredLocalizations(+ from: Self.shareStrings.keys.sorted(), forPreferences: Locale.preferredLanguages+ ).first ?? "en"+ return Self.shareStrings[locale]?[key] ?? Self.shareStrings["en"]![key]!+ }++ static let shareStrings: [String: [String: String]] = [+/* LOCALIZED_STRINGS */+ ]+}diff --git a/apps/mobile/plugins/incoming-share-strings.json b/apps/mobile/plugins/incoming-share-strings.jsonnew file mode 100644index 0000000000..6e0508a517--- /dev/null+++ b/apps/mobile/plugins/incoming-share-strings.json@@ -0,0 +1,37 @@+{+ "en": {+ "receivedTitle": "Files received",+ "receivedMessage": "Open Cindy manually to continue.",+ "failedTitle": "Couldn’t receive files",+ "failedMessage": "Share the files again.",+ "done": "Close Share"+ },+ "zh-Hans": {+ "receivedTitle": "文件已接收",+ "receivedMessage": "请手动打开 Cindy 继续。",+ "failedTitle": "未能接收文件",+ "failedMessage": "请重新分享文件。",+ "done": "关闭分享"+ },+ "zh-Hant": {+ "receivedTitle": "已接收檔案",+ "receivedMessage": "請手動開啟 Cindy 繼續。",+ "failedTitle": "無法接收檔案",+ "failedMessage": "請重新分享檔案。",+ "done": "關閉分享"+ },+ "ja": {+ "receivedTitle": "ファイルを受け取りました",+ "receivedMessage": "Cindy を手動で開いて続けてください。",+ "failedTitle": "ファイルを受け取れませんでした",+ "failedMessage": "もう一度ファイルを共有してください。",+ "done": "共有を閉じる"+ },+ "ko": {+ "receivedTitle": "파일을 받았어요",+ "receivedMessage": "Cindy를 직접 열어 계속해 주세요.",+ "failedTitle": "파일을 받지 못했어요",+ "failedMessage": "파일을 다시 공유해 주세요.",+ "done": "공유 닫기"+ }+}diff --git a/apps/mobile/plugins/with-incoming-share-feedback.js b/apps/mobile/plugins/with-incoming-share-feedback.jsnew file mode 100644index 0000000000..ea17a83a87--- /dev/null+++ b/apps/mobile/plugins/with-incoming-share-feedback.js@@ -0,0 +1,94 @@+const fs = require("node:fs");+const path = require("node:path");+const strings = require("./incoming-share-strings.json");++// Runs after the file-ownership patch. Keep the upstream launch strategy, but+// never finish the extension before knowing whether it opened the containing app.+function patchShareFeedback(source) {+ const replace = (from, to, count = 1) => {+ if (source.split(from).length - 1 !== count) {+ throw new Error(+ "expo-sharing template changed; review incoming-share feedback patch",+ );+ }+ source = source.split(from).join(to);+ };+ replace(+ " private var shareStarted = false",+ " private var shareStarted = false\n private var shareClosed = false\n private var openResultHandled = false",+ );+ // Alerts need a presenter that is already on screen (including very fast failures).+ replace("viewWillAppear", "viewDidAppear", 3);+ replace(+ " handleShare()\n super.viewDidAppear(animated)",+ " super.viewDidAppear(animated)\n handleShare()",+ );+ replace(+ " self.extensionContext?.completeRequest(returningItems: nil)",+ " showShareFeedback(received: false)",+ );+ replace(+ " if !payload.isEmpty {",+ " guard !shareClosed else { return }\n if !payload.isEmpty {",+ );+ replace(+ " self.close()\n return",+ " showShareFeedback(received: false)\n return",+ );+ replace(+ " self.extensionContext?.completeRequest(returningItems: nil, completionHandler: nil)",+ " showShareFeedback(received: false)",+ );+ replace(+ " openURL(url)\n self.close()",+ ` // Some hosts never call the open completion. Bound the wait without retrying.+ DispatchQueue.main.asyncAfter(deadline: .now() + 3) { [weak self] in+ self?.finishOpening(opened: false)+ }+ openURL(url)`,+ );+ replace(+ " application.open(url, options: [:], completionHandler: nil)",+ ` application.open(url, options: [:]) { [weak self] opened in+ DispatchQueue.main.async { self?.finishOpening(opened: opened) }+ }+ return`,+ );+ replace(+ " responder = responder?.next\n }\n }",+ " responder = responder?.next\n }\n finishOpening(opened: false)\n }",+ );+ replace(+ " private func close() {",+ ` override func didSelectCancel() {+ close()+ }++ private func close() {+ guard !shareClosed else { return }+ shareClosed = true`,+ );+ const swiftStrings = Object.entries(strings)+ .map(+ ([locale, values]) =>+ ` ${JSON.stringify(locale)}: [${Object.entries(values)+ .map(+ ([key, value]) =>+ `${JSON.stringify(key)}: ${JSON.stringify(value)}`,+ )+ .join(", ")}]`,+ )+ .join(",\n");+ return (+ source ++ "\n" ++ fs+ .readFileSync(+ path.join(__dirname, "incoming-share-feedback.swift"),+ "utf8",+ )+ .replace("/* LOCALIZED_STRINGS */", swiftStrings)+ );+}++module.exports = { patchShareFeedback };diff --git a/apps/mobile/plugins/with-incoming-share-files.js b/apps/mobile/plugins/with-incoming-share-files.jsindex d6e12a3bd1..d39c74ed16 100644--- a/apps/mobile/plugins/with-incoming-share-files.js+++ b/apps/mobile/plugins/with-incoming-share-files.js@@ -1,6 +1,7 @@-const fs = require('node:fs');-const path = require('node:path');-const { withXcodeProject } = require('@expo/config-plugins');+const fs = require("node:fs");+const path = require("node:path");+const { withXcodeProject } = require("@expo/config-plugins");+const { patchShareFeedback } = require("./with-incoming-share-feedback");// expo-sharing 57 copies files to AppGroup/<basename>, overwriting same-name// files even within one share. Keep each input in its own directory, retaining@@ -8,35 +9,79 @@ const { withXcodeProject } = require('@expo/config-plugins');function patchShareExtension(source) {const replace = (from, to, count) => {if (source.split(from).length - 1 !== count) {- throw new Error('expo-sharing template changed; review incoming-file ownership patch');+ throw new Error(+ "expo-sharing template changed; review incoming-file ownership patch",+ );}source = source.split(from).join(to);};- replace(' private func handleShare() {',- ' private var shareStarted = false\n\n private func handleShare() {\n guard !shareStarted else { return }\n shareStarted = true', 1);- replace(' let destinationURL = containerURL.appendingPathComponent(fileName)',- ' let directory = containerURL.appendingPathComponent("cindy-share-" + UUID().uuidString, isDirectory: true)\n let destinationURL = directory.appendingPathComponent(fileName)', 2);- replace(' if FileManager.default.fileExists(atPath: destinationURL.path) {\n try FileManager.default.removeItem(at: destinationURL)\n }',- ' try FileManager.default.createDirectory(at: directory, withIntermediateDirectories: true)', 1);- replace(' try data.write(to: destinationURL)',- ' try FileManager.default.createDirectory(at: directory, withIntermediateDirectories: true)\n try data.write(to: destinationURL)', 1);- replace(' userDefaults.set(encoded, forKey: SHARE_INTO_DEFAULTS_KEY)\n userDefaults.synchronize()',- ' do {\n try IncomingShareSlot.write(encoded, group: appGroupId)\n return true\n } catch {\n print("Error: incoming share could not be saved")\n return false\n }', 1);- replace(' saveToUserDefaults(payload)',- ' guard saveToUserDefaults(payload) else {\n self.close()\n return\n }', 1);- replace(' private func saveToUserDefaults(_ payload: [SharePayload]) {',- ' private func saveToUserDefaults(_ payload: [SharePayload]) -> Bool {', 1);- replace(' guard let userDefaults = UserDefaults(suiteName: appGroupId) else {\n print("Error: Expo-sharing could not initialize UserDefaults with group: \\(appGroupId)")\n return\n }', '', 1);- replace(' print("Error: Expo-sharing has failed to serialize shared data to JSON")',- ' print("Error: Expo-sharing has failed to serialize shared data to JSON")\n return false', 1);- return source + '\n' + fs.readFileSync(path.join(__dirname,- '../modules/cindy-incoming-share/ios/IncomingShareSlot.swift'), 'utf8');+ replace(+ " private func handleShare() {",+ " private var shareStarted = false\n\n private func handleShare() {\n guard !shareStarted else { return }\n shareStarted = true",+ 1,+ );+ replace(+ " let destinationURL = containerURL.appendingPathComponent(fileName)",+ ' let directory = containerURL.appendingPathComponent("cindy-share-" + UUID().uuidString, isDirectory: true)\n let destinationURL = directory.appendingPathComponent(fileName)',+ 2,+ );+ replace(+ " if FileManager.default.fileExists(atPath: destinationURL.path) {\n try FileManager.default.removeItem(at: destinationURL)\n }",+ " try FileManager.default.createDirectory(at: directory, withIntermediateDirectories: true)",+ 1,+ );+ replace(+ " try data.write(to: destinationURL)",+ " try FileManager.default.createDirectory(at: directory, withIntermediateDirectories: true)\n try data.write(to: destinationURL)",+ 1,+ );+ replace(+ " userDefaults.set(encoded, forKey: SHARE_INTO_DEFAULTS_KEY)\n userDefaults.synchronize()",+ ' do {\n try IncomingShareSlot.write(encoded, group: appGroupId)\n return true\n } catch {\n print("Error: incoming share could not be saved")\n return false\n }',+ 1,+ );+ replace(+ " saveToUserDefaults(payload)",+ " guard saveToUserDefaults(payload) else {\n self.close()\n return\n }",+ 1,+ );+ replace(+ " private func saveToUserDefaults(_ payload: [SharePayload]) {",+ " private func saveToUserDefaults(_ payload: [SharePayload]) -> Bool {",+ 1,+ );+ replace(+ ' guard let userDefaults = UserDefaults(suiteName: appGroupId) else {\n print("Error: Expo-sharing could not initialize UserDefaults with group: \\(appGroupId)")\n return\n }',+ "",+ 1,+ );+ replace(+ ' print("Error: Expo-sharing has failed to serialize shared data to JSON")',+ ' print("Error: Expo-sharing has failed to serialize shared data to JSON")\n return false',+ 1,+ );+ return (+ patchShareFeedback(source) ++ "\n" ++ fs.readFileSync(+ path.join(+ __dirname,+ "../modules/cindy-incoming-share/ios/IncomingShareSlot.swift",+ ),+ "utf8",+ )+ );}-module.exports = config => withXcodeProject(config, mod => {- // Xcode mods run after expo-sharing's dangerous mod writes the fresh template.- const file = path.join(mod.modRequest.platformProjectRoot, 'expo-sharing-extension', 'ShareIntoViewController.swift');- fs.writeFileSync(file, patchShareExtension(fs.readFileSync(file, 'utf8')));- return mod;-});+module.exports = (config) =>+ withXcodeProject(config, (mod) => {+ // Xcode mods run after expo-sharing's dangerous mod writes the fresh template.+ const file = path.join(+ mod.modRequest.platformProjectRoot,+ "expo-sharing-extension",+ "ShareIntoViewController.swift",+ );+ fs.writeFileSync(file, patchShareExtension(fs.readFileSync(file, "utf8")));+ return mod;+ });module.exports.patchShareExtension = patchShareExtension;diff --git a/apps/mobile/scripts/test-incoming-share-feedback.mjs b/apps/mobile/scripts/test-incoming-share-feedback.mjsnew file mode 100644index 0000000000..4c2d7c31d7--- /dev/null+++ b/apps/mobile/scripts/test-incoming-share-feedback.mjs@@ -0,0 +1,144 @@+// Executes the generated Swift launch/feedback methods with deterministic UIKit+// and clock doubles. Requires macOS + Swift; no simulator or signing is needed.+import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";+import { tmpdir } from "node:os";+import { dirname, join } from "node:path";+import { createRequire } from "node:module";+import { execFileSync } from "node:child_process";+const require = createRequire(import.meta.url);+const { patchShareExtension } = require("../plugins/with-incoming-share-files");+const template = readFileSync(+ join(+ dirname(require.resolve("expo-sharing/package.json")),+ "plugin/template-files/ios/ShareIntoViewController.swift",+ ),+ "utf8",+);+const source = patchShareExtension(template);++function method(signature) {+ const start = source.indexOf(signature);+ if (start < 0) throw new Error(`Missing Swift method: ${signature}`);+ const body = source.indexOf("{", start);+ let depth = 1;+ let end = body + 1;+ for (; depth && end < source.length; end++) {+ if (source[end] === "{") depth++;+ if (source[end] === "}") depth--;+ }+ return source.slice(start, end).replace(/^private /, "").replace(/^override /, "");+}++const harness = `+import Foundation+class UIResponder { var next: UIResponder? }+class UIApplication: UIResponder {+ var calls = 0+ var reply: ((Bool) -> Void)?+ func open(_ url: URL, options: [String: String], completionHandler: @escaping (Bool) -> Void) {+ precondition(url.absoluteString == "cindy://expo-sharing")+ calls += 1+ reply = completionHandler+ }+}+enum Style { case alert, \`default\` }+class UIAlertAction {+ let handler: (UIAlertAction) -> Void+ init(title: String, style: Style, handler: @escaping (UIAlertAction) -> Void) { self.handler = handler }+}+class UIAlertController {+ let title: String+ var actions: [UIAlertAction] = []+ init(title: String, message: String, preferredStyle: Style) { self.title = title }+ func addAction(_ action: UIAlertAction) { actions.append(action) }+}+extension Double { static func now() -> Double { 0 } }+class TestQueue {+ var callbacks: [() -> Void] = []+ var deadlines: [() -> Void] = []+ func async(execute: @escaping () -> Void) { callbacks.append(execute) }+ func asyncAfter(deadline: Double, execute: @escaping () -> Void) { deadlines.append(execute) }+ func flush() { let jobs = callbacks; callbacks = []; jobs.forEach { $0() } }+ func expire() { let jobs = deadlines; deadlines = []; jobs.forEach { $0() } }+}+enum DispatchQueue { static let main = TestQueue() }+class Context {+ var completions = 0+ func completeRequest(returningItems: [String]?, completionHandler: (() -> Void)?) { completions += 1 }+}+class ShareIntoViewController: UIResponder {+ let hostAppScheme = "cindy"+ var shareClosed = false+ var openResultHandled = false+ var extensionContext: Context? = Context()+ var alerts: [UIAlertController] = []+ func present(_ alert: UIAlertController, animated: Bool) { alerts.append(alert) }+ func shareString(_ key: String) -> String { key }+ ${method("func openParentApp()")}+ ${method("private func openURL(")}+ ${method("private func close()")}+ ${method("func finishOpening(")}+ ${method("func showShareFeedback(")}+ ${method("override func didSelectCancel(")}+}+func check(_ condition: @autoclosure () -> Bool) { precondition(condition()) }+func make() -> (ShareIntoViewController, UIApplication) {+ let controller = ShareIntoViewController()+ let app = UIApplication()+ controller.next = app+ controller.openParentApp()+ check(app.calls == 1)+ check(controller.extensionContext!.completions == 0)+ check(controller.alerts.isEmpty)+ return (controller, app)+}+// A successful open closes only on callback, with no message; timeout cannot undo it.+do {+ let (controller, app) = make()+ app.reply!(true); DispatchQueue.main.flush(); DispatchQueue.main.expire()+ check(controller.extensionContext!.completions == 1)+ check(controller.alerts.isEmpty)+}+// Failed open stays visible until Done; duplicate and late callbacks cannot dismiss it.+do {+ let (controller, app) = make()+ app.reply!(false); DispatchQueue.main.flush()+ app.reply!(true); DispatchQueue.main.flush(); DispatchQueue.main.expire()+ check(controller.extensionContext!.completions == 0)+ check(controller.alerts.count == 1 && controller.alerts[0].title == "receivedTitle")+ let action = controller.alerts[0].actions[0]; action.handler(action)+ check(controller.extensionContext!.completions == 1)+}+// Missing responder and a missing completion both produce the manual-open fallback.+do {+ let controller = ShareIntoViewController(); controller.openParentApp()+ check(controller.alerts.count == 1)+ DispatchQueue.main.expire(); check(controller.alerts.count == 1)+ let (waiting, _) = make(); DispatchQueue.main.expire()+ check(waiting.alerts.count == 1 && waiting.extensionContext!.completions == 0)+}+// Cancel is terminal, including timeout and late callback after cancellation.+do {+ let (controller, app) = make(); controller.didSelectCancel()+ app.reply!(false); DispatchQueue.main.flush(); DispatchQueue.main.expire()+ check(controller.alerts.isEmpty && controller.extensionContext!.completions == 1)+}+// Reception failure uses its own message, and does not close until Done.+do {+ let controller = ShareIntoViewController(); controller.showShareFeedback(received: false)+ check(controller.alerts[0].title == "failedTitle")+ check(controller.extensionContext!.completions == 0)+ let action = controller.alerts[0].actions[0]; action.handler(action)+ check(controller.extensionContext!.completions == 1)+}+print("PASS: generated Swift share feedback (success, failure, timeout, missing responder, duplicate/late reply, cancel, Done)")+`;+const dir = mkdtempSync(join(tmpdir(), "cindy-share-feedback-test-"));+try {+ const file = join(dir, "main.swift");+ writeFileSync(file, harness);+ execFileSync("swiftc", [file, "-o", join(dir, "test")], { stdio: "inherit" });+ execFileSync(join(dir, "test"), [], { stdio: "inherit" });+} finally {+ rmSync(dir, { recursive: true, force: true });+}diff --git a/apps/mobile/src/__tests__/incomingShareNativePlugin.test.ts b/apps/mobile/src/__tests__/incomingShareNativePlugin.test.tsindex 7fb6a16b31..25187de098 100644--- a/apps/mobile/src/__tests__/incomingShareNativePlugin.test.ts+++ b/apps/mobile/src/__tests__/incomingShareNativePlugin.test.ts@@ -1,29 +1,132 @@-import { createRequire } from 'node:module';-import { readFileSync } from 'node:fs';-import { dirname, join } from 'node:path';-import { describe, expect, it } from 'vitest';+import { execFileSync, spawnSync } from "node:child_process";+import { createRequire } from "node:module";+import { readFileSync } from "node:fs";+import { dirname, join } from "node:path";+import { fileURLToPath } from "node:url";+import { describe, expect, it } from "vitest";const require = createRequire(import.meta.url);-const { patchShareExtension } = require('../../plugins/with-incoming-share-files.js');-const template = readFileSync(join(dirname(require.resolve('expo-sharing/package.json')),- 'plugin/template-files/ios/ShareIntoViewController.swift'), 'utf8');+const {+ patchShareExtension,+} = require("../../plugins/with-incoming-share-files.js");+const template = readFileSync(+ join(+ dirname(require.resolve("expo-sharing/package.json")),+ "plugin/template-files/ios/ShareIntoViewController.swift",+ ),+ "utf8",+);-describe('incoming share native file ownership', () => {- it('isolates both file-copy and raw-image paths without changing display names', () => {+it("runs the generated Swift launch and feedback behavior", () => {+ if (spawnSync("swiftc", ["--version"], { encoding: "utf8" }).status !== 0)+ return;+ const script = join(+ dirname(fileURLToPath(import.meta.url)),+ "../../scripts/test-incoming-share-feedback.mjs",+ );+ const output = execFileSync(process.execPath, [script], {+ encoding: "utf8",+ timeout: 60_000,+ });+ expect(output).toContain("PASS: generated Swift share feedback");+}, 60_000);++describe("incoming share native file ownership", () => {+ it("isolates both file-copy and raw-image paths without changing display names", () => {const patched = patchShareExtension(template);- expect(patched.match(/"cindy-share-" \+ UUID\(\).uuidString/g)).toHaveLength(2);+ expect(+ patched.match(/"cindy-share-" \+ UUID\(\).uuidString/g),+ ).toHaveLength(2);expect(patched.match(/createDirectory\(at: directory/g)).toHaveLength(2);- expect(patched.match(/directory.appendingPathComponent\(fileName\)/g)).toHaveLength(2);- expect(patched).not.toContain('removeItem(at: destinationURL)');- expect(patched).toContain('guard !shareStarted else { return }');- expect(patched).toContain('try IncomingShareSlot.write(encoded, group: appGroupId)');- expect(patched).toContain('guard saveToUserDefaults(payload) else');- expect(patched).toContain('enum IncomingShareSlot');- expect(patched).not.toContain('userDefaults.set(encoded');+ expect(+ patched.match(/directory.appendingPathComponent\(fileName\)/g),+ ).toHaveLength(2);+ expect(patched).not.toContain("removeItem(at: destinationURL)");+ expect(patched).toContain("guard !shareStarted else { return }");+ expect(patched).toContain(+ "try IncomingShareSlot.write(encoded, group: appGroupId)",+ );+ expect(patched).toContain("guard saveToUserDefaults(payload) else");+ expect(patched).toContain("enum IncomingShareSlot");+ expect(patched).not.toContain("userDefaults.set(encoded");+ });++ it("fails prebuild when upstream changes the copy contract", () => {+ expect(() =>+ patchShareExtension(+ template.replaceAll(+ "containerURL.appendingPathComponent(fileName)",+ "newCopyStrategy()",+ ),+ ),+ ).toThrow("expo-sharing template changed");+ });++ it("keeps the extension alive until launch succeeds or the user dismisses feedback", () => {+ const patched = patchShareExtension(template);+ expect(patched).not.toContain("openURL(url)\n self.close()");+ expect(patched).toContain(+ "application.open(url, options: [:]) { [weak self] opened in",+ );+ expect(patched).toContain("self?.finishOpening(opened: opened)");+ expect(patched).toContain(+ "DispatchQueue.main.asyncAfter(deadline: .now() + 3)",+ );+ expect(patched).toContain(+ "guard !shareClosed, !openResultHandled else { return }",+ );+ expect(patched).toContain(+ "super.viewDidAppear(animated)\n handleShare()",+ );+ expect(patched).toContain(+ "guard !shareClosed else { return }\n if !payload.isEmpty",+ );+ expect(patched).toContain("override func didSelectCancel()");+ // Invalid input, an empty parsed payload and a failed persistent write all+ // report reception failure, not "received" or silent completeRequest.+ expect(patched.match(/showShareFeedback\(received: false\)/g)).toHaveLength(+ 3,+ );+ expect(patched.match(/completeRequest\(returningItems:/g)).toHaveLength(1);+ expect(patched).toContain(+ "guard saveToUserDefaults(payload) else {\n showShareFeedback(received: false)",+ );+ });++ it("embeds complete localized feedback in the extension, without relying on the JS app", () => {+ const strings = require("../../plugins/incoming-share-strings.json");+ expect(Object.keys(strings).sort()).toEqual([+ "en",+ "ja",+ "ko",+ "zh-Hans",+ "zh-Hant",+ ]);+ for (const values of Object.values(strings) as Array<+ Record<string, string>+ >) {+ expect(Object.keys(values).sort()).toEqual([+ "done",+ "failedMessage",+ "failedTitle",+ "receivedMessage",+ "receivedTitle",+ ]);+ expect(+ Object.values(values).every((value) => value.trim().length > 0),+ ).toBe(true);+ }+ const patched = patchShareExtension(template);+ expect(patched).not.toContain("/* LOCALIZED_STRINGS */");+ expect(patched).toContain("UIAlertController(");+ expect(patched).toContain("preferredStyle: .alert");});- it('fails prebuild when upstream changes the copy contract', () => {- expect(() => patchShareExtension(template.replaceAll('containerURL.appendingPathComponent(fileName)', 'newCopyStrategy()')))- .toThrow('expo-sharing template changed');+ it("fails prebuild if upstream changes its launch lifecycle", () => {+ expect(() =>+ patchShareExtension(+ template.replace(" self.close()\n }", " finishEarly()\n }"),+ ),+ ).toThrow("expo-sharing template changed");});});