peachsim 0.1.1716 → 0.1.1738
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -3
- package/cli/app-bundle-resources.ts +2 -1
- package/cli/app-fonts.ts +4 -4
- package/cli/app-splash.ts +4 -4
- package/cli/app-stubs.ts +17 -0
- package/cli/command-registry.ts +1 -0
- package/cli/commands/control.ts +83 -822
- package/cli/commands/coverage-swift.ts +112 -4
- package/cli/commands/daemon.ts +8 -0
- package/cli/commands/detox.ts +3 -0
- package/cli/commands/doctor.ts +19 -2
- package/cli/commands/inspect/actions.ts +74 -14
- package/cli/commands/inspect/core.ts +5 -1
- package/cli/commands/inspect/settling.ts +5 -2
- package/cli/commands/inspect/wait-ready.ts +6 -0
- package/cli/commands/inspect.ts +48 -45
- package/cli/commands/kotlin.ts +12 -2
- package/cli/commands/package.ts +760 -0
- package/cli/commands/serve.ts +6 -0
- package/cli/commands/shell-url.ts +838 -0
- package/cli/commands/swift.ts +42 -102
- package/cli/commands/test.ts +20 -0
- package/cli/commands/upload.ts +1 -1
- package/cli/device-option.ts +1 -1
- package/cli/main.ts +13 -1
- package/cli/native-input.ts +199 -0
- package/cli/outbound-endpoints.ts +26 -1
- package/cli/packaged-app-launcher.ts +95 -0
- package/cli/scene-video.ts +36 -12
- package/detox/index.ts +196 -24
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/attached-projects.cjs +5 -2
- package/dist-lib/auth/shared-session.cjs +5 -2
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +1 -1
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +1 -1
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +1 -1
- package/dist-lib/bundle-channel.cjs +39889 -31873
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +1 -1
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +1 -1
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +1 -1
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/config.mjs +1 -1
- package/dist-lib/detox/index.cjs +195 -63
- package/dist-lib/dev-bundle-resolution.cjs +14 -13
- package/dist-lib/expo-swift-bundle.cjs +18507 -11835
- package/dist-lib/expo-swift-metadata.cjs +4 -1
- package/dist-lib/expo-swift-metadata.mjs +3 -1
- package/dist-lib/home-paths.cjs +27 -3
- package/dist-lib/host/bridge-host.cjs +28373 -24090
- package/dist-lib/host/fetch-proxy-handler.cjs +235 -225
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
- package/dist-lib/host/replacement-module-handler.cjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +915 -399
- package/dist-lib/jump-to-source-babel.cjs +1 -1
- package/dist-lib/jump-to-source-native.cjs +1 -1
- package/dist-lib/kotlin-host.cjs +335 -47
- package/dist-lib/menu.cjs +13 -1
- package/dist-lib/menu.mjs +13 -1
- package/dist-lib/metro-fingerprint-registry.cjs +1 -1
- package/dist-lib/metro-fingerprint-registry.mjs +1 -1
- package/dist-lib/metro-production-bundle.cjs +1 -1
- package/dist-lib/metro-production-bundle.mjs +1 -1
- package/dist-lib/metro.cjs +918 -411
- package/dist-lib/native-app-identity-project.cjs +703 -283
- package/dist-lib/native-app-identity-project.mjs +500 -87
- package/dist-lib/native-app-identity.cjs +13 -2
- package/dist-lib/native-app-identity.mjs +13 -2
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +1 -1
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +1 -1
- package/dist-lib/profiles.cjs +5 -2
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/public-origins-lib-esm.json +28 -23
- package/dist-lib/public-origins-lib.json +418 -224
- package/dist-lib/react-native-host-modules.cjs +35 -2
- package/dist-lib/react-native-host-modules.mjs +35 -2
- package/dist-lib/reap-browser.cjs +12 -4
- package/dist-lib/scripts/dev-server-scanner.cjs +15 -8
- package/dist-lib/sdk.cjs +17 -7
- package/dist-lib/sdk.mjs +16 -7
- package/dist-lib/skills.cjs +44825 -29141
- package/dist-lib/swift-compile.cjs +616 -400
- package/dist-lib/swift-compile.mjs +528 -315
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +1 -1
- package/dist-lib/swift-submit.cjs +2 -2
- package/dist-lib/swift-submit.mjs +2 -2
- package/dist-lib/swift-toolchain.cjs +105 -17
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +4660 -2252
- package/dist-lib/vite.cjs +248 -234
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +1 -1
- package/dist-types/packages/peach-compat/src/stubs/native-seams/react-native-cookies.d.ts +17 -8
- package/dist-types/packages/peach-engine/src/engine/canvaskit-renderer.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/engine/font-config.d.ts +7 -4
- package/dist-types/packages/peach-engine/src/engine/image-loader.d.ts +9 -6
- package/dist-types/packages/peach-engine/src/engine/liquid-glass.d.ts +0 -5
- package/dist-types/packages/peach-engine/src/engine/memory-counts.d.ts +11 -1
- package/dist-types/packages/peach-engine/src/engine/node.d.ts +5 -12
- package/dist-types/packages/peach-engine/src/engine/render-damage.d.ts +2 -2
- package/dist-types/packages/peach-engine/src/engine/text-first-baseline.d.ts +5 -0
- package/dist-types/packages/peach-engine/src/engine/text-paragraph.d.ts +1 -0
- package/dist-types/packages/peach-engine/src/engine/types.d.ts +3 -0
- package/dist-types/packages/peach-engine/src/native-preview-bundle.d.ts +2 -0
- package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +9 -0
- package/dist-types/packages/peach-engine/src/render-worker/host-service-protocol.d.ts +3 -0
- package/dist-types/packages/peach-engine/src/render-worker/native-ui-commandContract.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/render-worker/protocol.d.ts +7 -2
- package/dist-types/packages/peach-engine/src/render-worker/shell-protocol.d.ts +5 -0
- package/dist-types/packages/peach-engine/src/render-worker/tree-sync-port.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/render-worker/worklet-runtime.d.ts +36 -2
- package/dist-types/packages/peach-engine/src/shell-events.d.ts +1 -0
- package/dist-types/packages/peach-globals/src/audioBridgeContract.d.ts +5 -0
- package/dist-types/packages/peach-globals/src/index.d.ts +1 -1
- package/dist-types/packages/peach-globals/src/keyboardBridgeContract.d.ts +11 -0
- package/dist-types/packages/peach-globals/src/shellBridgeContract.d.ts +1 -0
- package/dist-types/packages/peach-globals/src/testBridgeContract.d.ts +9 -2
- package/dist-types/packages/peach-kit/src/capabilities.d.ts +1 -0
- package/kotlin/README.md +3 -0
- package/kotlin/sdk.tar.gz +0 -0
- package/package.json +1 -1
- package/runtime-companion.json +1 -1
- package/scripts/dev-server-scanner.ts +12 -25
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACAccount.h +55 -0
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACAccountCredential.h +35 -0
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACAccountStore.h +94 -0
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACAccountType.h +53 -0
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/ACError.h +37 -0
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/Accounts.h +13 -0
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Headers/AccountsDefines.h +13 -0
- package/sdk/ios/System/Library/Frameworks/Accounts.framework/Modules/module.modulemap +5 -0
- package/sdk/ios/System/Library/Frameworks/AuthenticationServices.framework/Headers/ASFoundation.h +52 -0
- package/sdk/ios/System/Library/Frameworks/AuthenticationServices.framework/Headers/ASWebAuthenticationSession.h +128 -0
- package/sdk/ios/System/Library/Frameworks/AuthenticationServices.framework/Headers/ASWebAuthenticationSessionCallback.h +35 -0
- package/sdk/ios/System/Library/Frameworks/AuthenticationServices.framework/Headers/AuthenticationServices.h +3 -0
- package/sdk/ios/System/Library/Frameworks/AuthenticationServices.framework/Modules/module.modulemap +5 -0
- package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Headers/CFHTTPMessage.h +724 -0
- package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Headers/CFNetwork.h +4 -0
- package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Headers/CFNetworkDefs.h +27 -0
- package/sdk/ios/System/Library/Frameworks/CFNetwork.framework/Modules/module.modulemap +5 -0
- package/sdk/ios/System/Library/Frameworks/CoreFoundation.framework/Headers/CFURL.h +1301 -0
- package/sdk/ios/System/Library/Frameworks/CoreGraphics.framework/Headers/CoreGraphics.h +3 -1
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLLocationManager.h +21 -50
- package/sdk/ios/System/Library/Frameworks/CoreLocation.framework/Headers/CLRegion.h +6 -6
- package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/Foundation.apinotes +58 -3
- package/sdk/ios/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h +711 -46
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIApplication.h +12 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIInterface.h +23 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h +7 -9
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIOrientation.h +14 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIStringDrawing.h +12 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIView.h +14 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIViewAnimating.h +12 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIViewController.h +16 -0
- package/sdk/ios/System/Library/Frameworks/UIKit.framework/Headers/UIWindow.h +2 -0
- package/sdk/ios/usr/include/ConditionalMacros.h +619 -0
- package/sdk/ios/usr/include/module.modulemap +1 -0
- package/sdk/ios/usr/include/objc/objc-sync.h +59 -0
- package/sdk/ios/usr/include/os/signpost.h +414 -0
- package/sdk/ios/usr/include/os.modulemap +10 -0
- package/sdk/ios/usr/include/sys/cdefs.h +5 -0
- package/sdk/ios/usr/include/sys/ioccom.h +99 -0
- package/sdk/ios/usr/include/sys/syslog.h +236 -0
- package/sdk/ios/usr/include/syslog.h +24 -0
- package/sdk/ios/wasm/include/errno.h +4 -20
- package/sdk/ios/wasm/include/fcntl.h +4 -2
- package/sdk/ios/wasm/include/pthread.h +3 -0
- package/sdk/ios/wasm/include/setjmp.h +57 -0
- package/sdk/ios/wasm/include/stdio.h +24 -0
- package/sdk/ios/wasm/include/stdlib.h +32 -7
- package/sdk/ios/wasm/include/sys/file.h +7 -0
- package/sdk/ios/wasm/include/sys/ioctl.h +6 -0
- package/sdk/ios/wasm/include/sys/resource.h +2 -2
- package/sdk/ios/wasm/include/sys/syscall.h +9 -0
- package/sdk/ios/wasm/include/sys/time.h +10 -0
- package/sdk/ios/wasm/include/unistd.h +12 -3
- package/sdk/native-hashes.json +4 -3
- package/skills/contrast/SKILL.md +2 -1
- package/skills/peach-debug/SKILL.md +0 -1
- package/skills/peach-perf/SKILL.md +0 -1
- package/skills/peach-setup/SKILL.md +0 -1
- package/skills/peach-test/SKILL.md +7 -4
- package/skills/peach-visual/SKILL.md +0 -1
- package/src/admitted-mac-build.ts +3 -0
- package/src/android-app-identity.ts +18 -0
- package/src/android-autolinking.ts +1 -0
- package/src/android-bridge-packages.ts +279 -0
- package/src/android-root-module.ts +9 -9
- package/src/appPackageContract.ts +83 -0
- package/src/bridge-contract.ts +50 -0
- package/src/bundle-channel.mjs +41 -6
- package/src/cli-runtime.ts +9 -5
- package/src/dev-bundle-resolution.ts +7 -27
- package/src/dom-source-reference.ts +15 -0
- package/src/expo-discovery-cache.ts +134 -26
- package/src/expo-kotlin-host.ts +97 -26
- package/src/expo-manifest-body.ts +33 -0
- package/src/expo-native-workspace.ts +158 -38
- package/src/expo-swift-host.ts +350 -75
- package/src/expo-swift-ready.ts +5 -1
- package/src/expoKotlinContract.ts +12 -2
- package/src/expoSwiftContract.ts +10 -0
- package/src/generated/swift-c-predefines.json +1 -1
- package/src/home-paths.ts +41 -2
- package/src/host/app-package-handler.ts +47 -0
- package/src/host/bridge-host.ts +8 -0
- package/src/host/fetch-proxy-handler.ts +10 -0
- package/src/host/staged-host-files.ts +18 -0
- package/src/index.ts +3 -0
- package/src/kotlin-host.ts +225 -48
- package/src/kotlin-instance-source.ts +126 -0
- package/src/kotlinSdkContract.ts +2 -1
- package/src/menu.ts +14 -0
- package/src/native-app-identity-project.ts +7 -2
- package/src/native-app-identity.ts +11 -0
- package/src/native-firebase-config.ts +24 -1
- package/src/native-prebuilt.ts +154 -0
- package/src/nitro-adapter.lock.json +270 -270
- package/src/nitro-adapter.ts +56 -50
- package/src/nitro-bundle.ts +92 -74
- package/src/nitro-compile.ts +45 -14
- package/src/nitro-dependencies.ts +63 -46
- package/src/nitro-source.ts +64 -26
- package/src/nitroAdapterContract.ts +146 -98
- package/src/nitroContract.ts +71 -21
- package/src/react-native-bridge-modules.ts +70 -42
- package/src/react-native-host-modules.ts +34 -1
- package/src/reactNativeConfigurationContract.ts +14 -0
- package/src/reap-browser.ts +15 -3
- package/src/sdk.ts +5 -0
- package/src/settingsContract.ts +38 -1
- package/src/sim-client.ts +4 -1
- package/src/storageSnapshotContract.ts +32 -81
- package/src/swift-compile.ts +268 -89
- package/src/swift-coverage/indexdump.ts +22 -6
- package/src/swift-coverage/indexing.ts +4 -4
- package/src/swift-coverage/provenance.ts +1 -0
- package/src/swift-coverage/sdk.ts +104 -20
- package/src/swift-coverage/types.ts +34 -0
- package/src/swift-coverage/xcode-asset-symbols.ts +922 -0
- package/src/swift-coverage/xcode-assets.ts +89 -131
- package/src/swift-coverage/xcode.ts +10 -2
- package/src/swift-cxx-reachable.ts +2 -1
- package/src/swift-distribution.lock.json +20 -16
- package/src/swift-host.ts +98 -22
- package/src/swift-icu.ts +1 -1
- package/src/swift-link-roots.ts +118 -0
- package/src/swift-objc-compile.ts +144 -22
- package/src/swift-objc-import.ts +6 -0
- package/src/swift-objc-standin.ts +2 -14
- package/src/swift-package-manifest.ts +14 -6
- package/src/swift-packages.ts +75 -11
- package/src/swift-pdf-raster.ts +1 -0
- package/src/swift-root-lock.ts +17 -1
- package/src/swift-source-pods.ts +2 -10
- package/src/swift-standin-emit.ts +597 -57
- package/src/swift-standins.ts +599 -56
- package/src/swift-submit.ts +7 -1
- package/src/swift-toolchain.ts +140 -17
- package/src/turbo-bundle.ts +81 -0
- package/src/turbo-codegen-intake.ts +91 -0
- package/src/turbo-compile.ts +120 -0
- package/src/turbo-runtime.lock.json +69 -0
- package/src/turbo-source.ts +754 -0
- package/src/vite-plugin-one.ts +17 -12
- package/src/vite-plugin.ts +28 -15
- package/src/xcode-project.ts +223 -22
package/src/vite-plugin-one.ts
CHANGED
|
@@ -47,6 +47,11 @@ import type { PeachPluginOptions } from './vite'
|
|
|
47
47
|
import type { IncomingMessage, ServerResponse } from 'node:http'
|
|
48
48
|
import type { Plugin } from 'vite'
|
|
49
49
|
|
|
50
|
+
function requestAuthority(req: IncomingMessage): string | undefined {
|
|
51
|
+
const authority = req.headers[':authority']
|
|
52
|
+
return req.headers.host ?? (typeof authority === 'string' ? authority : undefined)
|
|
53
|
+
}
|
|
54
|
+
|
|
50
55
|
// a shell on another origin reads only the response headers it is told about
|
|
51
56
|
function exposeHeader(res: ServerResponse, name: string) {
|
|
52
57
|
const exposed = res.getHeader('access-control-expose-headers')
|
|
@@ -151,7 +156,6 @@ export function peachPlugin(options: PeachPluginOptions = {}): Plugin {
|
|
|
151
156
|
address.address === '::' || address.address === '0.0.0.0'
|
|
152
157
|
? '127.0.0.1'
|
|
153
158
|
: address.address
|
|
154
|
-
const authority = req.headers[':authority']
|
|
155
159
|
const options: https.RequestOptions = {
|
|
156
160
|
host: loopback,
|
|
157
161
|
port: address.port,
|
|
@@ -161,8 +165,7 @@ export function peachPlugin(options: PeachPluginOptions = {}): Plugin {
|
|
|
161
165
|
...Object.fromEntries(
|
|
162
166
|
Object.entries(req.headers).filter(([key]) => !key.startsWith(':')),
|
|
163
167
|
),
|
|
164
|
-
host:
|
|
165
|
-
req.headers.host ?? (typeof authority === 'string' ? authority : undefined),
|
|
168
|
+
host: requestAuthority(req),
|
|
166
169
|
'accept-encoding': 'identity',
|
|
167
170
|
[BUNDLE_SOURCE_REQUEST_HEADER]: '1',
|
|
168
171
|
},
|
|
@@ -186,15 +189,16 @@ export function peachPlugin(options: PeachPluginOptions = {}): Plugin {
|
|
|
186
189
|
res.statusCode === 200
|
|
187
190
|
? forwardRolldownBundleResponse(upstream, res)
|
|
188
191
|
: pipeline(upstream, res)
|
|
189
|
-
forward.catch((error: unknown) =>
|
|
190
|
-
|
|
191
|
-
|
|
192
|
+
forward.catch((error: unknown) => {
|
|
193
|
+
console.error('[peach] bundle forward failed', error)
|
|
194
|
+
res.destroy(error instanceof Error ? error : new Error(String(error)))
|
|
195
|
+
})
|
|
192
196
|
}
|
|
193
197
|
const upstreamReq = server.config.server.https
|
|
194
198
|
? https.request(options, respond)
|
|
195
199
|
: http.request(options, respond)
|
|
196
200
|
upstreamReq.once('error', next)
|
|
197
|
-
|
|
201
|
+
res.once('close', () => {
|
|
198
202
|
if (!res.writableFinished) upstreamReq.destroy()
|
|
199
203
|
})
|
|
200
204
|
upstreamReq.end()
|
|
@@ -288,7 +292,7 @@ export function peachPlugin(options: PeachPluginOptions = {}): Plugin {
|
|
|
288
292
|
const requestOrigin = (req: IncomingMessage): string =>
|
|
289
293
|
new URL(
|
|
290
294
|
req.url || '/',
|
|
291
|
-
`${server.config.server.https ? 'https' : 'http'}://${req
|
|
295
|
+
`${server.config.server.https ? 'https' : 'http'}://${requestAuthority(req)}`,
|
|
292
296
|
).origin
|
|
293
297
|
const sendSwiftChange = (change: object) => {
|
|
294
298
|
const message = JSON.stringify(change)
|
|
@@ -464,8 +468,9 @@ export function peachPlugin(options: PeachPluginOptions = {}): Plugin {
|
|
|
464
468
|
lock && isDaemonLockfileFresh(lock) && lock.bridgePort > 0
|
|
465
469
|
? lock.bridgePort
|
|
466
470
|
: DEFAULT_SOOTSIM_BRIDGE_PORT
|
|
467
|
-
// inject the bridge port + a default bundle
|
|
468
|
-
//
|
|
471
|
+
// inject the bridge port + a default bundle for guest app launches.
|
|
472
|
+
// embedded demo apps select shell content instead of a guest bundle.
|
|
473
|
+
// preserve explicit bundles and the existing query.
|
|
469
474
|
// preserving the query is essential: `peach open` stamps the open URL
|
|
470
475
|
// with `inspectOpen=<token>` and matches the registered sim by that
|
|
471
476
|
// token (waitForSimMatch). the old code forced `?bundle=` only and
|
|
@@ -474,7 +479,7 @@ export function peachPlugin(options: PeachPluginOptions = {}): Plugin {
|
|
|
474
479
|
const inject =
|
|
475
480
|
`<script>(function(){var u=new URL(location.href);` +
|
|
476
481
|
`var b=${JSON.stringify(bundleForOrigin(origin))};` +
|
|
477
|
-
`if(!u.searchParams.has('bundle'))u.searchParams.set('bundle',b);` +
|
|
482
|
+
`if(!u.searchParams.has('bundle')&&!u.searchParams.get('demoApp')?.trim())u.searchParams.set('bundle',b);` +
|
|
478
483
|
`window.__sootsimBridgePort=${bridgePort};` +
|
|
479
484
|
`window.__peachPageServingAuthority='contributor';` +
|
|
480
485
|
`history.replaceState(null,'','${prefix}/'+u.search)})()</script>`
|
|
@@ -558,7 +563,7 @@ export function peachPlugin(options: PeachPluginOptions = {}): Plugin {
|
|
|
558
563
|
if (serveBrowserProxyRoute(req, res)) return
|
|
559
564
|
const url = req.url || ''
|
|
560
565
|
const pathname = url.split('?')[0]
|
|
561
|
-
const runtimeRoot = resolveRuntimeRootForRequestHost(req
|
|
566
|
+
const runtimeRoot = resolveRuntimeRootForRequestHost(requestAuthority(req))
|
|
562
567
|
|
|
563
568
|
if (!runtimeRoot) {
|
|
564
569
|
if (
|
package/src/vite-plugin.ts
CHANGED
|
@@ -49,6 +49,7 @@ import {
|
|
|
49
49
|
assertPeachPortEnvironment,
|
|
50
50
|
resolveSootsimBridgePort,
|
|
51
51
|
} from './bridge-constants.ts'
|
|
52
|
+
import { DOM_SOURCE_ROOT, domSourceFilename } from './dom-source-reference.ts'
|
|
52
53
|
import { isRecord } from './is-record.ts'
|
|
53
54
|
import {
|
|
54
55
|
SHELL_BRIDGE_IDENTITY_PATH,
|
|
@@ -2465,6 +2466,7 @@ export function expoDomComponentsPlugin(
|
|
|
2465
2466
|
const domHashMap = new Map<string, string>()
|
|
2466
2467
|
const domWebModuleIds = new Set<string>()
|
|
2467
2468
|
const deliveredSources = new Map<string, string>()
|
|
2469
|
+
const portableDomReferencePrefix = `${pathToFileURL(DOM_SOURCE_ROOT).href}/`
|
|
2468
2470
|
let sourcesLoaded = false
|
|
2469
2471
|
|
|
2470
2472
|
function loadDeliveredSources() {
|
|
@@ -2478,7 +2480,10 @@ export function expoDomComponentsPlugin(
|
|
|
2478
2480
|
}
|
|
2479
2481
|
const localUrl = pathToFileURL(path.resolve(projectRoot, relativePath)).href
|
|
2480
2482
|
deliveredSources.set(reference, localUrl)
|
|
2481
|
-
domHashMap.set(
|
|
2483
|
+
domHashMap.set(
|
|
2484
|
+
crypto.createHash('md5').update(reference).digest('hex'),
|
|
2485
|
+
reference,
|
|
2486
|
+
)
|
|
2482
2487
|
}
|
|
2483
2488
|
}
|
|
2484
2489
|
sourcesLoaded = true
|
|
@@ -2584,15 +2589,13 @@ export function expoDomComponentsPlugin(
|
|
|
2584
2589
|
},
|
|
2585
2590
|
generateBundle() {
|
|
2586
2591
|
const sources = Object.fromEntries(
|
|
2587
|
-
[...
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
reference
|
|
2591
|
-
path
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
.join('/'),
|
|
2595
|
-
]),
|
|
2592
|
+
[...deliveredSources.keys()].sort().map((reference) => [
|
|
2593
|
+
reference,
|
|
2594
|
+
path
|
|
2595
|
+
.relative(projectRoot, fileURLToPath(deliveredSources.get(reference)!))
|
|
2596
|
+
.split(path.sep)
|
|
2597
|
+
.join('/'),
|
|
2598
|
+
]),
|
|
2596
2599
|
)
|
|
2597
2600
|
this.emitFile({
|
|
2598
2601
|
type: 'asset',
|
|
@@ -2936,10 +2939,15 @@ export default NoopMetroHMRClient;
|
|
|
2936
2939
|
const params = new URLSearchParams(query)
|
|
2937
2940
|
loadDeliveredSources()
|
|
2938
2941
|
const reference = params.get('file')
|
|
2939
|
-
|
|
2940
|
-
if (!fileUrl) {
|
|
2942
|
+
if (!reference) {
|
|
2941
2943
|
throw new Error(`Missing file query param in DOM component entry: ${id}`)
|
|
2942
2944
|
}
|
|
2945
|
+
// a portable reference names no checkout path: only the delivered
|
|
2946
|
+
// manifest or this server's own transforms can resolve it.
|
|
2947
|
+
const fileUrl = deliveredSources.get(reference) ?? reference
|
|
2948
|
+
if (fileUrl === reference && reference.startsWith(portableDomReferencePrefix)) {
|
|
2949
|
+
throw new Error(`DOM component source is not delivered: ${reference}`)
|
|
2950
|
+
}
|
|
2943
2951
|
let targetPath: string
|
|
2944
2952
|
try {
|
|
2945
2953
|
targetPath = fileUrl.startsWith('file:') ? fileURLToPath(fileUrl) : fileUrl
|
|
@@ -3032,12 +3040,14 @@ registerDOMComponent(Component);
|
|
|
3032
3040
|
'babel-preset-expo/build/plugins/use-dom-directive-plugin',
|
|
3033
3041
|
)
|
|
3034
3042
|
|
|
3035
|
-
const
|
|
3043
|
+
const filename = domSourceFilename(projectRoot, cleanId)
|
|
3044
|
+
const fileUrl = pathToFileURL(filename).href
|
|
3036
3045
|
const hash = crypto.createHash('md5').update(fileUrl).digest('hex')
|
|
3037
3046
|
domHashMap.set(hash, fileUrl)
|
|
3047
|
+
deliveredSources.set(fileUrl, pathToFileURL(cleanId).href)
|
|
3038
3048
|
|
|
3039
3049
|
const result = await transformAsync(code, {
|
|
3040
|
-
filename
|
|
3050
|
+
filename,
|
|
3041
3051
|
babelrc: false,
|
|
3042
3052
|
configFile: false,
|
|
3043
3053
|
sourceMaps: true,
|
|
@@ -3045,7 +3055,10 @@ registerDOMComponent(Component);
|
|
|
3045
3055
|
name: 'peachsim',
|
|
3046
3056
|
platform: 'ios',
|
|
3047
3057
|
isDev: !isProduction,
|
|
3048
|
-
projectRoot
|
|
3058
|
+
projectRoot:
|
|
3059
|
+
cleanId.includes(projectRoot) && !cleanId.includes('node_modules')
|
|
3060
|
+
? DOM_SOURCE_ROOT
|
|
3061
|
+
: '',
|
|
3049
3062
|
},
|
|
3050
3063
|
presets: isTS
|
|
3051
3064
|
? [
|
package/src/xcode-project.ts
CHANGED
|
@@ -46,6 +46,24 @@ import {
|
|
|
46
46
|
// project without IPHONEOS_DEPLOYMENT_TARGET, printed 27.0 beside SDK_VERSION 27.1).
|
|
47
47
|
const XCODE_DEFAULT_IOS_DEPLOYMENT_TARGET = '27.0'
|
|
48
48
|
|
|
49
|
+
// clang.xcspec's CLANG_CXX_LANGUAGE_STANDARD values: c++0x keeps its old
|
|
50
|
+
// spelling, and these standards leave c++ modules off unless modules are on.
|
|
51
|
+
const CXX_STANDARD_ALIASES: Record<string, string> = {
|
|
52
|
+
'c++0x': 'c++11',
|
|
53
|
+
'gnu++0x': 'gnu++11',
|
|
54
|
+
}
|
|
55
|
+
const PRE_CXX20_STANDARDS = new Set([
|
|
56
|
+
'c++98',
|
|
57
|
+
'gnu++98',
|
|
58
|
+
'c++0x',
|
|
59
|
+
'gnu++0x',
|
|
60
|
+
'c++14',
|
|
61
|
+
'gnu++14',
|
|
62
|
+
'c++17',
|
|
63
|
+
'gnu++17',
|
|
64
|
+
'compiler-default',
|
|
65
|
+
])
|
|
66
|
+
|
|
49
67
|
export interface XcodeModuleTarget {
|
|
50
68
|
name: string
|
|
51
69
|
/** the module name the target's sources compile as. */
|
|
@@ -73,6 +91,8 @@ export interface XcodeModuleTarget {
|
|
|
73
91
|
flags: string[]
|
|
74
92
|
includePaths: string[]
|
|
75
93
|
compatibility: {
|
|
94
|
+
/** true when xcode derives the products from the framework layout, without a phase. */
|
|
95
|
+
framework: boolean
|
|
76
96
|
moduleMap: string
|
|
77
97
|
umbrella: string
|
|
78
98
|
outputModuleMap: string
|
|
@@ -124,12 +144,16 @@ export interface XcodeAppTarget extends XcodeModuleTarget {
|
|
|
124
144
|
infoPlist: string | null
|
|
125
145
|
infoPlistFile: string | null
|
|
126
146
|
appIconName: string
|
|
147
|
+
/** the app project PBXProject developmentRegion, xcode's "en" when it declares none. */
|
|
148
|
+
developmentRegion: string
|
|
127
149
|
/**
|
|
128
150
|
* framework and library targets of any project in the workspace that the
|
|
129
151
|
* app depends on or links, dependencies first. xcode builds them into one
|
|
130
152
|
* products directory, so every one is importable from every other.
|
|
131
153
|
*/
|
|
132
154
|
frameworks: XcodeModuleTarget[]
|
|
155
|
+
/** built resource products copied by the selected targets, at bundle-relative destinations. */
|
|
156
|
+
resourceProducts: { path: string; resources: string[]; infoPlist: string }[]
|
|
133
157
|
/** package products the app and its frameworks link, with the package each names. */
|
|
134
158
|
linkedProducts: SwiftLinkedProduct[]
|
|
135
159
|
/** local package directories the workspace or a project references. */
|
|
@@ -156,6 +180,7 @@ export interface XcodeAppTarget extends XcodeModuleTarget {
|
|
|
156
180
|
}
|
|
157
181
|
|
|
158
182
|
const APPLICATION = 'com.apple.product-type.application'
|
|
183
|
+
const RESOURCE_BUNDLE = 'com.apple.product-type.bundle'
|
|
159
184
|
// product types xcode builds as a .framework bundle with Headers and Modules.
|
|
160
185
|
const FRAMEWORK_PRODUCTS = new Set([
|
|
161
186
|
'com.apple.product-type.framework',
|
|
@@ -494,7 +519,7 @@ function targetSettings(
|
|
|
494
519
|
ref: TargetRef,
|
|
495
520
|
configuration: string,
|
|
496
521
|
builtins: Record<string, string>,
|
|
497
|
-
options: { requireSources?: boolean } = {},
|
|
522
|
+
options: { requireSources?: boolean; environment?: Record<string, string> } = {},
|
|
498
523
|
overrides: Record<string, string> = {},
|
|
499
524
|
): { get: (key: string) => string; keys: Set<string>; xcconfigs: string[] } {
|
|
500
525
|
const { project, target } = ref
|
|
@@ -588,7 +613,7 @@ function targetSettings(
|
|
|
588
613
|
return teamPrefix()
|
|
589
614
|
return Object.hasOwn(derivedSettings, key)
|
|
590
615
|
? derivedSettings[key]!()
|
|
591
|
-
: (process.env[key] ?? '')
|
|
616
|
+
: (options.environment?.[key] ?? process.env[key] ?? '')
|
|
592
617
|
}
|
|
593
618
|
return {
|
|
594
619
|
get,
|
|
@@ -1254,6 +1279,7 @@ export function readXcodeAppTarget(
|
|
|
1254
1279
|
options: {
|
|
1255
1280
|
requireSources?: boolean
|
|
1256
1281
|
prepareGeneratedSources?: boolean
|
|
1282
|
+
environment?: Record<string, string>
|
|
1257
1283
|
/** build the CocoaPods project `pod install` generated, as Xcode does. */
|
|
1258
1284
|
installedPods?: boolean
|
|
1259
1285
|
} = {},
|
|
@@ -1344,6 +1370,7 @@ export function readXcodeAppTarget(
|
|
|
1344
1370
|
return found.filter(
|
|
1345
1371
|
(candidate) =>
|
|
1346
1372
|
candidate.target.isa === 'PBXAggregateTarget' ||
|
|
1373
|
+
candidate.target.productType === RESOURCE_BUNDLE ||
|
|
1347
1374
|
MODULE_PRODUCTS.has(str(candidate.target.productType) ?? ''),
|
|
1348
1375
|
)
|
|
1349
1376
|
}
|
|
@@ -1488,6 +1515,8 @@ export function readXcodeAppTarget(
|
|
|
1488
1515
|
'$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)',
|
|
1489
1516
|
BUILT_PRODUCTS_DIR: '$(CONFIGURATION_BUILD_DIR)',
|
|
1490
1517
|
TARGET_BUILD_DIR: '$(CONFIGURATION_BUILD_DIR)',
|
|
1518
|
+
UNLOCALIZED_RESOURCES_FOLDER_PATH:
|
|
1519
|
+
str(ref.project.object(str(ref.target.productReference))?.path) ?? '',
|
|
1491
1520
|
PROJECT_TEMP_DIR: '$(OBJROOT)/$(PROJECT_NAME).build',
|
|
1492
1521
|
CONFIGURATION_TEMP_DIR:
|
|
1493
1522
|
'$(PROJECT_TEMP_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)',
|
|
@@ -1496,6 +1525,11 @@ export function readXcodeAppTarget(
|
|
|
1496
1525
|
TEMP_FILES_DIR: '$(TEMP_DIR)',
|
|
1497
1526
|
TEMP_FILE_DIR: '$(TEMP_DIR)',
|
|
1498
1527
|
TEMP_ROOT: '$(OBJROOT)',
|
|
1528
|
+
OBJECT_FILE_DIR: '$(TARGET_TEMP_DIR)/Objects',
|
|
1529
|
+
// the per-variant object directory carries no arch: xcode defines
|
|
1530
|
+
// OBJECT_FILE_DIR_normal as OBJECT_FILE_DIR-normal, and the target
|
|
1531
|
+
// appends $(CURRENT_ARCH) itself for the per-arch directory.
|
|
1532
|
+
OBJECT_FILE_DIR_normal: '$(OBJECT_FILE_DIR)-normal',
|
|
1499
1533
|
DERIVED_FILE_DIR: '$(TARGET_TEMP_DIR)/DerivedSources',
|
|
1500
1534
|
DERIVED_FILES_DIR: '$(DERIVED_FILE_DIR)',
|
|
1501
1535
|
DERIVED_SOURCES_DIR: '$(DERIVED_FILE_DIR)',
|
|
@@ -1656,6 +1690,45 @@ export function readXcodeAppTarget(
|
|
|
1656
1690
|
(settings('DEFINES_MODULE') === 'YES' || !framework) && settings('MODULEMAP_FILE')
|
|
1657
1691
|
? absolute(settings('MODULEMAP_FILE'))
|
|
1658
1692
|
: null
|
|
1693
|
+
// a framework Swift pod has no compatibility phase; xcode derives the
|
|
1694
|
+
// same products from its module map, CocoaPods umbrella and product
|
|
1695
|
+
// layout. without the map pair on disk there is nothing to derive.
|
|
1696
|
+
const frameworkUmbrella =
|
|
1697
|
+
!compatibility && framework && members.sources.length > 0 && moduleMap
|
|
1698
|
+
? path.join(path.dirname(moduleMap), `${moduleName}-umbrella.h`)
|
|
1699
|
+
: null
|
|
1700
|
+
const frameworkCompatibility =
|
|
1701
|
+
frameworkUmbrella &&
|
|
1702
|
+
moduleMap &&
|
|
1703
|
+
fs.existsSync(moduleMap) &&
|
|
1704
|
+
fs.existsSync(frameworkUmbrella)
|
|
1705
|
+
? {
|
|
1706
|
+
framework: true,
|
|
1707
|
+
moduleMap,
|
|
1708
|
+
umbrella: frameworkUmbrella,
|
|
1709
|
+
outputModuleMap: path.join(wrapper, 'Modules', 'module.modulemap'),
|
|
1710
|
+
outputUmbrella: path.join(
|
|
1711
|
+
wrapper,
|
|
1712
|
+
'Headers',
|
|
1713
|
+
path.basename(frameworkUmbrella),
|
|
1714
|
+
),
|
|
1715
|
+
outputHeader: path.join(
|
|
1716
|
+
wrapper,
|
|
1717
|
+
'Headers',
|
|
1718
|
+
settings('SWIFT_OBJC_INTERFACE_HEADER_NAME') || `${moduleName}-Swift.h`,
|
|
1719
|
+
),
|
|
1720
|
+
}
|
|
1721
|
+
: null
|
|
1722
|
+
const swiftCompatibility = compatibility
|
|
1723
|
+
? {
|
|
1724
|
+
framework: false,
|
|
1725
|
+
moduleMap: compatibility.moduleMap,
|
|
1726
|
+
umbrella: compatibility.umbrella,
|
|
1727
|
+
outputModuleMap: compatibility.outputModuleMap,
|
|
1728
|
+
outputUmbrella: compatibility.outputUmbrella,
|
|
1729
|
+
outputHeader: compatibility.outputHeader,
|
|
1730
|
+
}
|
|
1731
|
+
: frameworkCompatibility
|
|
1659
1732
|
const podHeaders =
|
|
1660
1733
|
!framework &&
|
|
1661
1734
|
isPodsProject(ref.project.xcodeproj) &&
|
|
@@ -1687,6 +1760,8 @@ export function readXcodeAppTarget(
|
|
|
1687
1760
|
)
|
|
1688
1761
|
}
|
|
1689
1762
|
}
|
|
1763
|
+
const cStandard = settings('GCC_C_LANGUAGE_STANDARD')
|
|
1764
|
+
const cxxStandard = settings('CLANG_CXX_LANGUAGE_STANDARD')
|
|
1690
1765
|
return {
|
|
1691
1766
|
settings,
|
|
1692
1767
|
keys,
|
|
@@ -1713,15 +1788,7 @@ export function readXcodeAppTarget(
|
|
|
1713
1788
|
swift: {
|
|
1714
1789
|
flags: settingList(settings('OTHER_SWIFT_FLAGS')),
|
|
1715
1790
|
includePaths: settingList(settings('SWIFT_INCLUDE_PATHS')).map(absolute),
|
|
1716
|
-
compatibility:
|
|
1717
|
-
? {
|
|
1718
|
-
moduleMap: compatibility.moduleMap,
|
|
1719
|
-
umbrella: compatibility.umbrella,
|
|
1720
|
-
outputModuleMap: compatibility.outputModuleMap,
|
|
1721
|
-
outputUmbrella: compatibility.outputUmbrella,
|
|
1722
|
-
outputHeader: compatibility.outputHeader,
|
|
1723
|
-
}
|
|
1724
|
-
: null,
|
|
1791
|
+
compatibility: swiftCompatibility,
|
|
1725
1792
|
},
|
|
1726
1793
|
}
|
|
1727
1794
|
: {}),
|
|
@@ -1783,8 +1850,8 @@ export function readXcodeAppTarget(
|
|
|
1783
1850
|
? ['-fobjc-weak']
|
|
1784
1851
|
: []),
|
|
1785
1852
|
...(settings('CLANG_ENABLE_MODULES') === 'YES' ? ['-fmodules'] : []),
|
|
1786
|
-
...(
|
|
1787
|
-
? [`-std=${
|
|
1853
|
+
...(cStandard && cStandard !== 'compiler-default'
|
|
1854
|
+
? [`-std=${cStandard}`]
|
|
1788
1855
|
: []),
|
|
1789
1856
|
...settingList(settings('GCC_PREPROCESSOR_DEFINITIONS')).map(
|
|
1790
1857
|
(value) => `-D${value}`,
|
|
@@ -1792,8 +1859,16 @@ export function readXcodeAppTarget(
|
|
|
1792
1859
|
...settingList(settings('OTHER_CFLAGS')),
|
|
1793
1860
|
],
|
|
1794
1861
|
cxxFlags: [
|
|
1795
|
-
...(
|
|
1796
|
-
? [`-std=${
|
|
1862
|
+
...(cxxStandard && cxxStandard !== 'compiler-default'
|
|
1863
|
+
? [`-std=${CXX_STANDARD_ALIASES[cxxStandard] ?? cxxStandard}`]
|
|
1864
|
+
: []),
|
|
1865
|
+
// clang.xcspec's hidden CLANG_DISABLE_CXX_MODULES (default
|
|
1866
|
+
// YES) keeps c++ and objective-c++ units out of modules when
|
|
1867
|
+
// modules are on or the standard is c++20 or later.
|
|
1868
|
+
...(settings('CLANG_DISABLE_CXX_MODULES') !== 'NO' &&
|
|
1869
|
+
(settings('CLANG_ENABLE_MODULES') === 'YES' ||
|
|
1870
|
+
!PRE_CXX20_STANDARDS.has(cxxStandard || 'compiler-default'))
|
|
1871
|
+
? ['-fno-cxx-modules']
|
|
1797
1872
|
: []),
|
|
1798
1873
|
...settingList(settings('OTHER_CPLUSPLUSFLAGS')),
|
|
1799
1874
|
],
|
|
@@ -1825,6 +1900,40 @@ export function readXcodeAppTarget(
|
|
|
1825
1900
|
],
|
|
1826
1901
|
],
|
|
1827
1902
|
),
|
|
1903
|
+
// a copy files phase into the products directory, as
|
|
1904
|
+
// cocoapods writes for each header_mappings_dir folder.
|
|
1905
|
+
...list(ref.target.buildPhases).flatMap((phaseId) => {
|
|
1906
|
+
const phase = ref.project.object(phaseId)
|
|
1907
|
+
if (
|
|
1908
|
+
phase?.isa !== 'PBXCopyFilesBuildPhase' ||
|
|
1909
|
+
str(phase.dstSubfolderSpec) !== '16'
|
|
1910
|
+
)
|
|
1911
|
+
return []
|
|
1912
|
+
const destination = expand(str(phase.dstPath) ?? '', (name) =>
|
|
1913
|
+
name === 'PUBLIC_HEADERS_FOLDER_PATH'
|
|
1914
|
+
? path.join(wrapper, 'Headers')
|
|
1915
|
+
: name === 'PRIVATE_HEADERS_FOLDER_PATH'
|
|
1916
|
+
? path.join(wrapper, 'PrivateHeaders')
|
|
1917
|
+
: settings(name),
|
|
1918
|
+
)
|
|
1919
|
+
return list(phase.files).flatMap((id) => {
|
|
1920
|
+
const file = ref.project.resolvePath(
|
|
1921
|
+
str(ref.project.object(id)?.fileRef) ?? '',
|
|
1922
|
+
)
|
|
1923
|
+
return file && HEADER_FILE.test(file)
|
|
1924
|
+
? [
|
|
1925
|
+
[
|
|
1926
|
+
path.resolve(
|
|
1927
|
+
settings('BUILT_PRODUCTS_DIR'),
|
|
1928
|
+
destination,
|
|
1929
|
+
path.basename(file),
|
|
1930
|
+
),
|
|
1931
|
+
file,
|
|
1932
|
+
],
|
|
1933
|
+
]
|
|
1934
|
+
: []
|
|
1935
|
+
})
|
|
1936
|
+
}),
|
|
1828
1937
|
...(moduleMap
|
|
1829
1938
|
? [[path.join(wrapper, 'Modules', 'module.modulemap'), moduleMap]]
|
|
1830
1939
|
: []),
|
|
@@ -1842,7 +1951,7 @@ export function readXcodeAppTarget(
|
|
|
1842
1951
|
const { settings, keys: settingKeys, module } = builtTargets.at(-1)!
|
|
1843
1952
|
const frameworkTargets = builtTargets
|
|
1844
1953
|
.slice(0, -1)
|
|
1845
|
-
.filter(({ ref }) => ref.target.
|
|
1954
|
+
.filter(({ ref }) => MODULE_PRODUCTS.has(str(ref.target.productType) ?? ''))
|
|
1846
1955
|
.map(({ ref, module }) => ({ ref, framework: module }))
|
|
1847
1956
|
const frameworks = frameworkTargets.map(({ framework }) => framework)
|
|
1848
1957
|
// a development pod's sources sit outside the sandbox, where its podspec is
|
|
@@ -1854,20 +1963,98 @@ export function readXcodeAppTarget(
|
|
|
1854
1963
|
: [],
|
|
1855
1964
|
)
|
|
1856
1965
|
|
|
1857
|
-
const expandValue = (
|
|
1966
|
+
const expandValue = (
|
|
1967
|
+
value: plist.PlistValue,
|
|
1968
|
+
settings: (key: string) => string,
|
|
1969
|
+
): plist.PlistValue => {
|
|
1858
1970
|
if (typeof value === 'string') return expand(value, settings)
|
|
1859
|
-
if (Array.isArray(value)) return value.map(expandValue)
|
|
1971
|
+
if (Array.isArray(value)) return value.map((item) => expandValue(item, settings))
|
|
1860
1972
|
if (
|
|
1861
1973
|
typeof value === 'object' &&
|
|
1862
1974
|
!(value instanceof Date) &&
|
|
1863
1975
|
!Buffer.isBuffer(value)
|
|
1864
1976
|
) {
|
|
1865
1977
|
return Object.fromEntries(
|
|
1866
|
-
Object.entries(value).map(([key, value]) => [key, expandValue(value)]),
|
|
1978
|
+
Object.entries(value).map(([key, value]) => [key, expandValue(value, settings)]),
|
|
1867
1979
|
)
|
|
1868
1980
|
}
|
|
1869
1981
|
return value
|
|
1870
1982
|
}
|
|
1983
|
+
const resourceProducts: XcodeAppTarget['resourceProducts'] = []
|
|
1984
|
+
const bundleTargets = builtTargets.filter(
|
|
1985
|
+
({ ref }) => ref.target.productType === RESOURCE_BUNDLE,
|
|
1986
|
+
)
|
|
1987
|
+
for (const owner of options.installedPods ? builtTargets : []) {
|
|
1988
|
+
for (const phaseId of list(owner.ref.target.buildPhases)) {
|
|
1989
|
+
const phase = owner.ref.project.object(phaseId)
|
|
1990
|
+
if (
|
|
1991
|
+
phase?.isa !== 'PBXShellScriptBuildPhase' ||
|
|
1992
|
+
str(phase.name) !== '[CP] Copy Pods Resources'
|
|
1993
|
+
)
|
|
1994
|
+
continue
|
|
1995
|
+
const absolute = (raw: string) =>
|
|
1996
|
+
path.resolve(owner.ref.project.projectDir, expand(raw, owner.settings))
|
|
1997
|
+
const entries = (paths: string[]) =>
|
|
1998
|
+
paths.flatMap((raw) => {
|
|
1999
|
+
const file = absolute(raw)
|
|
2000
|
+
xcconfigs.add(file)
|
|
2001
|
+
return fileListEntries(file, absolute)
|
|
2002
|
+
})
|
|
2003
|
+
const inputs = entries(list(phase.inputFileListPaths)).filter((file) =>
|
|
2004
|
+
file.endsWith('.bundle'),
|
|
2005
|
+
)
|
|
2006
|
+
const outputs = entries(list(phase.outputFileListPaths)).filter((file) =>
|
|
2007
|
+
file.endsWith('.bundle'),
|
|
2008
|
+
)
|
|
2009
|
+
if (inputs.length !== outputs.length)
|
|
2010
|
+
throw new Error(`${owner.module.name}: resource bundle copy lists differ`)
|
|
2011
|
+
const destinationRoot = path.join(
|
|
2012
|
+
owner.settings('TARGET_BUILD_DIR'),
|
|
2013
|
+
owner.settings('UNLOCALIZED_RESOURCES_FOLDER_PATH'),
|
|
2014
|
+
)
|
|
2015
|
+
for (const [index, input] of inputs.entries()) {
|
|
2016
|
+
const product = bundleTargets.find((target) => {
|
|
2017
|
+
const file = str(
|
|
2018
|
+
target.ref.project.object(str(target.ref.target.productReference))?.path,
|
|
2019
|
+
)
|
|
2020
|
+
return file && path.join(target.settings('TARGET_BUILD_DIR'), file) === input
|
|
2021
|
+
})
|
|
2022
|
+
if (!product)
|
|
2023
|
+
throw new Error(
|
|
2024
|
+
`${owner.module.name}: resource bundle input has no selected producer: ${input}`,
|
|
2025
|
+
)
|
|
2026
|
+
const destination = path.relative(destinationRoot, outputs[index]!)
|
|
2027
|
+
if (
|
|
2028
|
+
destination === '..' ||
|
|
2029
|
+
destination.startsWith(`..${path.sep}`) ||
|
|
2030
|
+
path.isAbsolute(destination) ||
|
|
2031
|
+
path.basename(input) !== path.basename(destination)
|
|
2032
|
+
)
|
|
2033
|
+
throw new Error(
|
|
2034
|
+
`${owner.module.name}: invalid resource bundle copy destination`,
|
|
2035
|
+
)
|
|
2036
|
+
const infoFile = path.resolve(
|
|
2037
|
+
product.ref.project.projectDir,
|
|
2038
|
+
product.settings('INFOPLIST_FILE'),
|
|
2039
|
+
)
|
|
2040
|
+
xcconfigs.add(infoFile)
|
|
2041
|
+
const parsed = plist.parse(fs.readFileSync(infoFile, 'utf8'))
|
|
2042
|
+
const infoPlist = plist.build(expandValue(parsed, product.settings))
|
|
2043
|
+
const prefix =
|
|
2044
|
+
owner.ref === app ? '' : `Frameworks/${owner.module.moduleName}.framework/`
|
|
2045
|
+
const bundlePath = prefix + destination.split(path.sep).join('/')
|
|
2046
|
+
if (resourceProducts.some((resource) => resource.path === bundlePath))
|
|
2047
|
+
throw new Error(
|
|
2048
|
+
`${owner.module.name}: duplicate resource bundle destination ${bundlePath}`,
|
|
2049
|
+
)
|
|
2050
|
+
resourceProducts.push({
|
|
2051
|
+
path: bundlePath,
|
|
2052
|
+
resources: product.module.resources,
|
|
2053
|
+
infoPlist,
|
|
2054
|
+
})
|
|
2055
|
+
}
|
|
2056
|
+
}
|
|
2057
|
+
}
|
|
1871
2058
|
const infoPlistFile = settings('INFOPLIST_FILE')
|
|
1872
2059
|
? path.resolve(app.project.projectDir, settings('INFOPLIST_FILE'))
|
|
1873
2060
|
: null
|
|
@@ -1887,7 +2074,8 @@ export function readXcodeAppTarget(
|
|
|
1887
2074
|
throw new Error(`${module.name} Info.plist must contain a dictionary`)
|
|
1888
2075
|
}
|
|
1889
2076
|
const info: Record<string, plist.PlistValue> = {}
|
|
1890
|
-
for (const [key, value] of Object.entries(sourceInfo))
|
|
2077
|
+
for (const [key, value] of Object.entries(sourceInfo))
|
|
2078
|
+
info[key] = expandValue(value, settings)
|
|
1891
2079
|
for (const key of settingKeys) {
|
|
1892
2080
|
if (!key.startsWith('INFOPLIST_KEY_') || key.endsWith('_Generation')) continue
|
|
1893
2081
|
const value = settings(key)
|
|
@@ -2057,15 +2245,26 @@ export function readXcodeAppTarget(
|
|
|
2057
2245
|
const fileId = str(project.object(buildFileId)?.fileRef)
|
|
2058
2246
|
const file = project.object(fileId)
|
|
2059
2247
|
const tree = str(file?.sourceTree)
|
|
2060
|
-
const
|
|
2248
|
+
const rawPath = str(file?.path) ?? ''
|
|
2249
|
+
const name = /([^/]+)\.(xc)?framework$/.exec(rawPath)?.[1]
|
|
2061
2250
|
if (file?.isa !== 'PBXFileReference' || !name) continue
|
|
2062
2251
|
if (
|
|
2063
2252
|
tree === 'BUILT_PRODUCTS_DIR' ||
|
|
2064
2253
|
tree === 'SDKROOT' ||
|
|
2065
|
-
tree === 'DEVELOPER_DIR'
|
|
2254
|
+
tree === 'DEVELOPER_DIR' ||
|
|
2255
|
+
// a path into the sdk's own frameworks folder is the sdk's own
|
|
2256
|
+
// however it is rooted: xcode links -framework <name> from the sdk
|
|
2257
|
+
// and a stale group-relative path to it contributes nothing.
|
|
2258
|
+
/\/System\/Library\/Frameworks\/[^/]+$/.test(`/${rawPath}`) ||
|
|
2259
|
+
// a target in the workspace builds it, so it exists only after that build
|
|
2260
|
+
byProduct.has(path.basename(rawPath))
|
|
2066
2261
|
)
|
|
2067
2262
|
continue
|
|
2068
2263
|
const resolved = fileId ? project.resolvePath(fileId) : null
|
|
2264
|
+
if (fileId && resolved !== null && !fs.existsSync(resolved))
|
|
2265
|
+
throw new Error(
|
|
2266
|
+
`${str(target.name) ?? 'target'}: linked framework ${name} (${fileId}) points at missing ${resolved} in ${project.projectFile}`,
|
|
2267
|
+
)
|
|
2069
2268
|
if (!binaryFrameworks.get(name)) binaryFrameworks.set(name, resolved)
|
|
2070
2269
|
}
|
|
2071
2270
|
}
|
|
@@ -2139,7 +2338,9 @@ export function readXcodeAppTarget(
|
|
|
2139
2338
|
appIconName: settings('ASSETCATALOG_COMPILER_APPICON_NAME'),
|
|
2140
2339
|
infoPlist: infoPlistPending ? null : plist.build(info),
|
|
2141
2340
|
infoPlistFile,
|
|
2341
|
+
developmentRegion: str(app.project.project.developmentRegion) ?? 'en',
|
|
2142
2342
|
frameworks,
|
|
2343
|
+
resourceProducts,
|
|
2143
2344
|
linkedProducts,
|
|
2144
2345
|
localPackageDirs: [
|
|
2145
2346
|
...new Set(localPackageDirs.map((dir) => fs.realpathSync(dir))),
|