peachsim 0.1.1655 → 0.1.1660
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/cli/app-config.ts +4 -0
- package/cli/app-stubs.ts +43 -6
- package/cli/commands/inspect/shared.ts +5 -2
- package/cli/commands/inspect/url.ts +2 -1
- package/cli/commands/screenshot.ts +5 -5
- package/cli/commands/state.ts +9 -6
- package/cli/outbound-endpoints.ts +9 -1
- package/cli/output-redaction.ts +49 -0
- package/detox/index.ts +0 -1
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- 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 +12772 -1132
- 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 +29 -5
- package/dist-lib/config.mjs +29 -5
- package/dist-lib/detox/index.cjs +19 -6
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/expo-swift-bundle.cjs +10411 -73
- package/dist-lib/expo-swift-metadata.cjs +1 -1
- package/dist-lib/expo-swift-metadata.mjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +11220 -670
- package/dist-lib/host/fetch-proxy-handler.cjs +260 -197
- 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 +653 -338
- 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 +443 -312
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +1 -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 +548 -163
- package/dist-lib/native-app-identity-project.cjs +179 -33
- package/dist-lib/native-app-identity-project.mjs +179 -33
- package/dist-lib/native-app-identity.cjs +1 -1
- package/dist-lib/native-app-identity.mjs +1 -1
- 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 +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/public-origins-lib-esm.json +23 -23
- package/dist-lib/public-origins-lib.json +96 -63
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +2 -2
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +1 -1
- package/dist-lib/skills.cjs +12193 -1448
- package/dist-lib/swift-compile.cjs +10348 -172
- package/dist-lib/swift-compile.mjs +10348 -172
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +1 -1
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +1 -1
- package/dist-lib/swift-toolchain.cjs +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vite-swift.cjs +10411 -73
- package/dist-lib/vite.cjs +149 -163
- 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-gesture-handler.d.ts +2 -0
- package/dist-types/packages/peach-engine/src/engine/app-font-registry.d.ts +14 -0
- package/dist-types/packages/peach-engine/src/engine/image-loader.d.ts +8 -0
- package/dist-types/packages/peach-engine/src/engine/node.d.ts +3 -0
- package/dist-types/packages/peach-engine/src/render-worker/compositor-protocol.d.ts +21 -0
- package/dist-types/packages/peach-engine/src/render-worker/gesture-seam-protocol.d.ts +2 -1
- package/dist-types/packages/peach-engine/src/render-worker/test-bridge-protocol.d.ts +1 -1
- package/dist-types/packages/peach-engine/src/rolldown-bundle-inventory.d.ts +1 -0
- package/dist-types/packages/peach-globals/src/index.d.ts +34 -0
- package/kotlin/README.md +38 -23
- package/kotlin/sdk.tar.gz +0 -0
- package/package.json +2 -12
- package/runtime-companion.json +1 -1
- package/src/bundleGlobalFooter.ts +0 -2
- package/src/config.ts +54 -2
- package/src/configured-bundle-producer.ts +7 -1
- package/src/host/fetch-proxy-handler.ts +14 -50
- package/src/host/rolldown-bundle-forward.ts +71 -0
- package/src/installed-package-versions.ts +54 -2
- package/src/kotlin-host.ts +138 -285
- package/src/kotlin-module.ts +4 -7
- package/src/kotlin-sdk.ts +81 -0
- package/src/kotlin-toolchain.ts +152 -0
- package/src/kotlin-view-models.ts +1 -1
- package/src/kotlinSdkContract.ts +113 -0
- package/src/nitro-adapter.lock.json +3 -3
- package/src/nitro-bundle.ts +18 -4
- package/src/nitro-compile.ts +5 -1
- package/src/nitro-source.ts +112 -28
- package/src/nitroContract.ts +16 -4
- package/src/stub-pattern-matcher.ts +4 -0
- package/src/swift-compile.ts +44 -14
- package/src/swift-host.ts +2 -1
- package/src/swift-objc-compile.ts +117 -4
- package/src/swift-objc-sdk.ts +10215 -59
- package/src/swift-objc-standin.ts +5 -2
- package/src/vite-plugin-one.ts +73 -134
- package/src/worker-system-chunks.ts +14 -4
- package/src/xcode-project.ts +261 -34
- package/kotlin/AndroidViewSources/android/content/Context.kt +0 -22
- package/kotlin/AndroidViewSources/android/content/res/Configuration.kt +0 -25
- package/kotlin/AndroidViewSources/android/content/res/Resources.kt +0 -72
- package/kotlin/AndroidViewSources/android/graphics/Canvas.kt +0 -22
- package/kotlin/AndroidViewSources/android/graphics/Color.kt +0 -13
- package/kotlin/AndroidViewSources/android/graphics/Paint.kt +0 -18
- package/kotlin/AndroidViewSources/android/util/DisplayMetrics.kt +0 -12
- package/kotlin/AndroidViewSources/android/view/View.kt +0 -211
- package/kotlin/AndroidViewSources/android/widget/FrameLayout.kt +0 -61
- package/kotlin/AndroidViewSources/android/widget/LinearLayout.kt +0 -49
- package/kotlin/AndroidViewSources/dev/peach/app/JavaFormat.kt +0 -272
- package/kotlin/AppSources/android/app/Activity.kt +0 -174
- package/kotlin/AppSources/android/app/Application.kt +0 -11
- package/kotlin/AppSources/android/app/UiModeManager.kt +0 -9
- package/kotlin/AppSources/android/content/Intent.kt +0 -16
- package/kotlin/AppSources/android/os/Bundle.kt +0 -11
- package/kotlin/AppSources/android/util/SuperNotCalledException.kt +0 -3
- package/kotlin/AppSources/android/view/Window.kt +0 -182
- package/kotlin/AppSources/android/view/WindowInsets.kt +0 -9
- package/kotlin/AppSources/android/view/WindowInsetsController.kt +0 -17
- package/kotlin/AppSources/android/view/WindowManager.kt +0 -16
- package/kotlin/AppSources/android/window/BackEvent.kt +0 -24
- package/kotlin/AppSources/android/window/OnBackAnimationCallback.kt +0 -7
- package/kotlin/AppSources/android/window/OnBackInvokedDispatcher.kt +0 -84
- package/kotlin/AppSources/androidx/activity/ActivityFlags.kt +0 -9
- package/kotlin/AppSources/androidx/activity/ActivityViewModelLazy.kt +0 -21
- package/kotlin/AppSources/androidx/activity/BackEventCompat.kt +0 -43
- package/kotlin/AppSources/androidx/activity/ComponentActivity.kt +0 -122
- package/kotlin/AppSources/androidx/activity/EdgeToEdge.kt +0 -75
- package/kotlin/AppSources/androidx/activity/ExperimentalActivityApi.kt +0 -6
- package/kotlin/AppSources/androidx/activity/OnBackPressedCallback.kt +0 -69
- package/kotlin/AppSources/androidx/activity/OnBackPressedDispatcher.kt +0 -144
- package/kotlin/AppSources/androidx/activity/OnBackPressedDispatcherOwner.kt +0 -7
- package/kotlin/AppSources/androidx/activity/compose/BackHandler.kt +0 -86
- package/kotlin/AppSources/androidx/activity/compose/ComponentActivity.kt +0 -29
- package/kotlin/AppSources/androidx/activity/compose/internal/BackHandlerCompat.kt +0 -38
- package/kotlin/AppSources/androidx/activity/compose/internal/BackHandlerDispatcherCompat.kt +0 -27
- package/kotlin/AppSources/androidx/compose/foundation/layout/WindowInsets.kt +0 -15
- package/kotlin/AppSources/androidx/compose/ui/platform/AndroidCompositionLocals.kt +0 -27
- package/kotlin/AppSources/androidx/compose/ui/platform/ComposeView.kt +0 -68
- package/kotlin/AppSources/androidx/compose/ui/res/ColorResources.kt +0 -16
- package/kotlin/AppSources/androidx/compose/ui/res/PainterResources.kt +0 -70
- package/kotlin/AppSources/androidx/compose/ui/res/StringResources.kt +0 -38
- package/kotlin/AppSources/androidx/core/view/WindowCompat.kt +0 -32
- package/kotlin/AppSources/androidx/lifecycle/AndroidViewModel.kt +0 -10
- package/kotlin/AppSources/dev/peach/app/PeachApp.kt +0 -388
- package/kotlin/AppSources/dev/peach/app/PeachDrawable.kt +0 -102
- package/kotlin/AppSources/dev/peach/app/PeachWindowHost.kt +0 -14
- package/kotlin/CompilerSources/META-INF/services/org.jetbrains.kotlin.compiler.plugin.CompilerPluginRegistrar +0 -1
- package/kotlin/CompilerSources/PeachJniIncoming.kt +0 -243
- package/kotlin/CompilerSources/PeachJniPlugin.kt +0 -116
- package/kotlin/ComposeSources/PeachComposeHost.kt +0 -724
- package/kotlin/ComposeSources/PeachMagnifier.kt +0 -185
- package/kotlin/ComposeSources/PeachSemantics.kt +0 -127
- package/kotlin/ExpoComposeSources/PeachAndroidView.kt +0 -103
- package/kotlin/ExpoComposeSources/PeachExpoViewMount.kt +0 -24
- package/kotlin/ExpoComposeSources/dev/peach/expo/PeachExpoCompose.kt +0 -28
- package/kotlin/ExpoComposeSources/expo/modules/kotlin/views/ExpoComposeView.kt +0 -70
- package/kotlin/ExpoSources/dev/peach/expo/PeachExpoRuntime.kt +0 -516
- package/kotlin/ExpoSources/dev/peach/expo/PeachExpoTypes.kt +0 -173
- package/kotlin/ExpoSources/expo/modules/kotlin/AppContext.kt +0 -20
- package/kotlin/ExpoSources/expo/modules/kotlin/Promise.kt +0 -19
- package/kotlin/ExpoSources/expo/modules/kotlin/classcomponent/ClassComponentBuilder.kt +0 -198
- package/kotlin/ExpoSources/expo/modules/kotlin/exception/CodedException.kt +0 -126
- package/kotlin/ExpoSources/expo/modules/kotlin/functions/Functions.kt +0 -132
- package/kotlin/ExpoSources/expo/modules/kotlin/jni/JavaScriptTypedArray.kt +0 -81
- package/kotlin/ExpoSources/expo/modules/kotlin/modules/Module.kt +0 -98
- package/kotlin/ExpoSources/expo/modules/kotlin/objects/ObjectDefinitionBuilder.kt +0 -236
- package/kotlin/ExpoSources/expo/modules/kotlin/records/Record.kt +0 -12
- package/kotlin/ExpoSources/expo/modules/kotlin/runtime/Runtime.kt +0 -9
- package/kotlin/ExpoSources/expo/modules/kotlin/sharedobjects/SharedObject.kt +0 -50
- package/kotlin/ExpoSources/expo/modules/kotlin/sharedobjects/SharedObjectRegistry.kt +0 -57
- package/kotlin/ExpoSources/expo/modules/kotlin/sharedobjects/SharedRef.kt +0 -19
- package/kotlin/ExpoSources/expo/modules/kotlin/typedarray/ConcreteTypedArrays.kt +0 -158
- package/kotlin/ExpoSources/expo/modules/kotlin/typedarray/GenericTypedArray.kt +0 -8
- package/kotlin/ExpoSources/expo/modules/kotlin/typedarray/TypedArray.kt +0 -29
- package/kotlin/ExpoSources/expo/modules/kotlin/typedarray/TypedArrayIterator.kt +0 -9
- package/kotlin/ExpoSources/expo/modules/kotlin/types/AnyType.kt +0 -155
- package/kotlin/ExpoSources/expo/modules/kotlin/types/Either.kt +0 -91
- package/kotlin/ExpoSources/expo/modules/kotlin/types/Enumerable.kt +0 -6
- package/kotlin/ExpoSources/expo/modules/kotlin/viewevent/ViewEvent.kt +0 -68
- package/kotlin/ExpoSources/expo/modules/kotlin/views/ExpoView.kt +0 -20
- package/kotlin/ExpoSources/expo/modules/kotlin/views/ViewDefinitionBuilder.kt +0 -72
- package/kotlin/ExpoSources/expo/modules/kotlin/views/ViewProps.kt +0 -36
- package/kotlin/JniPlatformSources/androidx/annotation/CallSuper.kt +0 -5
- package/kotlin/JniPlatformSources/com/facebook/proguard/annotations/DoNotStrip.kt +0 -5
- package/kotlin/JniPlatformSources/dalvik/annotation/optimization/FastNative.kt +0 -5
- package/kotlin/JniPlatformSources/kotlin/Synchronized.kt +0 -6
- package/kotlin/JniPlatformSources/kotlin/jvm/JvmField.kt +0 -5
- package/kotlin/JniPlatformSources/kotlin/jvm/JvmStatic.kt +0 -5
- package/kotlin/JniSources/com/facebook/jni/HybridData.kt +0 -66
- package/kotlin/JniSources/dev/peach/jni/IncomingBindings.kt +0 -157
- package/kotlin/JniSources/dev/peach/jni/NativeBindings.kt +0 -77
- package/kotlin/JniTransportSources/dev/peach/jni/integration/JniTransport.kt +0 -89
- package/kotlin/Sources/android/os/Build.kt +0 -17
- package/kotlin/Sources/android/os/Handler.kt +0 -35
- package/kotlin/Sources/android/os/Looper.kt +0 -17
- package/kotlin/Sources/android/os/MessageQueue.kt +0 -56
- package/kotlin/Sources/android/os/SystemClock.kt +0 -14
- package/kotlin/Sources/android/util/Log.kt +0 -64
- package/kotlin/Sources/androidx/annotation/DrawableRes.kt +0 -14
- package/kotlin/Sources/androidx/annotation/Keep.kt +0 -4
- package/kotlin/Sources/dev/onejs/one/OneNativeSourceDispatch.kt +0 -7
- package/kotlin/Sources/dev/onejs/one/OneNativeSourceViewDispatch.kt +0 -13
- package/kotlin/Sources/dev/onejs/one/source/OneModule.kt +0 -4
- package/kotlin/Sources/java/lang/Runnable.kt +0 -6
- package/kotlin/Sources/java/security/MessageDigest.kt +0 -114
- package/kotlin/Sources/java/util/IllegalFormatCodePointException.kt +0 -10
- package/kotlin/Sources/java/util/IllegalFormatException.kt +0 -5
- package/kotlin/Sources/kotlin/text/StringFormat.kt +0 -9
- package/kotlin/Sources/org/json/JSON.kt +0 -307
- package/kotlin/tools/abi-classes.main.kts +0 -41
- package/kotlin/tools/expo-types.main.kts +0 -127
package/src/xcode-project.ts
CHANGED
|
@@ -61,6 +61,14 @@ export interface XcodeModuleTarget {
|
|
|
61
61
|
flags: string[]
|
|
62
62
|
cxxFlags: string[]
|
|
63
63
|
fileFlags: Record<string, string[]>
|
|
64
|
+
/**
|
|
65
|
+
* the header maps xcode generates for the target, in search order: the
|
|
66
|
+
* own-target map as `-I`, then the project map as `-iquote`. a value is
|
|
67
|
+
* an absolute header or a framework include `Product/Header.h`.
|
|
68
|
+
*/
|
|
69
|
+
headerMaps: { flag: '-I' | '-iquote'; entries: [string, string][] }[]
|
|
70
|
+
/** what xcode publishes in the target's framework product: product path to original file. */
|
|
71
|
+
productHeaders: Record<string, string>
|
|
64
72
|
}
|
|
65
73
|
}
|
|
66
74
|
|
|
@@ -97,9 +105,24 @@ export interface XcodeAppTarget extends XcodeModuleTarget {
|
|
|
97
105
|
configuration: string
|
|
98
106
|
/** target-level build settings query function. */
|
|
99
107
|
settings: (key: string) => string
|
|
108
|
+
/** the installed CocoaPods sandbox the workspace builds, when it has one. */
|
|
109
|
+
cocoapods: {
|
|
110
|
+
podfileLock: string
|
|
111
|
+
manifestLock: string
|
|
112
|
+
/** each installed pod's specification checksum, as the lock records it. */
|
|
113
|
+
specChecksums: Record<string, string>
|
|
114
|
+
/** the specifications of pods installed from a local path or a repository. */
|
|
115
|
+
localPodspecs: string[]
|
|
116
|
+
} | null
|
|
100
117
|
}
|
|
101
118
|
|
|
102
119
|
const APPLICATION = 'com.apple.product-type.application'
|
|
120
|
+
// product types xcode builds as a .framework bundle with Headers and Modules.
|
|
121
|
+
const FRAMEWORK_PRODUCTS = new Set([
|
|
122
|
+
'com.apple.product-type.framework',
|
|
123
|
+
'com.apple.product-type.framework.static',
|
|
124
|
+
])
|
|
125
|
+
const HEADER_FILE = /\.(h|hh|hpp|hxx|pch)$/
|
|
103
126
|
// product types a dependent target imports as a module from the products directory.
|
|
104
127
|
const MODULE_PRODUCTS = new Set([
|
|
105
128
|
'com.apple.product-type.framework',
|
|
@@ -382,12 +405,14 @@ function defaultConfiguration(project: LoadedProject): string {
|
|
|
382
405
|
// the build settings of one target in `configuration`, evaluated as xcode
|
|
383
406
|
// does: project then target level, each an xcconfig under its own settings;
|
|
384
407
|
// `$(inherited)` reads the level below and an undefined setting is empty. a
|
|
385
|
-
// list without that configuration builds its default one.
|
|
408
|
+
// list without that configuration builds its default one. overrides outrank
|
|
409
|
+
// every level, as the build location xcode chooses for a workspace does.
|
|
386
410
|
function targetSettings(
|
|
387
411
|
ref: TargetRef,
|
|
388
412
|
configuration: string,
|
|
389
413
|
builtins: Record<string, string>,
|
|
390
414
|
options: { requireSources?: boolean } = {},
|
|
415
|
+
overrides: Record<string, string> = {},
|
|
391
416
|
): { get: (key: string) => string; keys: Set<string>; xcconfigs: string[] } {
|
|
392
417
|
const { project, target } = ref
|
|
393
418
|
const xcconfigs: string[] = []
|
|
@@ -440,6 +465,7 @@ function targetSettings(
|
|
|
440
465
|
{ ...builtins, CONFIGURATION: configuration },
|
|
441
466
|
...level(str(project.project.buildConfigurationList)),
|
|
442
467
|
...level(str(target.buildConfigurationList)),
|
|
468
|
+
overrides,
|
|
443
469
|
]
|
|
444
470
|
const resolving = new Set<string>()
|
|
445
471
|
const valueAt = (key: string, top: number): string => {
|
|
@@ -798,23 +824,80 @@ function commonAncestor(dirs: string[]): string {
|
|
|
798
824
|
return common
|
|
799
825
|
}
|
|
800
826
|
|
|
827
|
+
// cocoapods' generated project, Pods/Pods.xcodeproj beside the sandbox's Manifest.lock.
|
|
828
|
+
const isPodsProject = (xcodeproj: string) =>
|
|
829
|
+
path.basename(xcodeproj) === 'Pods.xcodeproj' &&
|
|
830
|
+
path.basename(path.dirname(xcodeproj)) === 'Pods'
|
|
831
|
+
|
|
832
|
+
// the sandbox exactly as `pod install` left it, refused as its own
|
|
833
|
+
// "[CP] Check Pods Manifest.lock" phase refuses a stale one.
|
|
834
|
+
function installedPodsSandbox(pods: string): NonNullable<XcodeAppTarget['cocoapods']> {
|
|
835
|
+
const podfileLock = path.join(path.dirname(pods), 'Podfile.lock')
|
|
836
|
+
const manifestLock = path.join(pods, 'Manifest.lock')
|
|
837
|
+
if (!fs.existsSync(podfileLock))
|
|
838
|
+
throw new Error(
|
|
839
|
+
`${pods} has no ${podfileLock}: run \`pod install\` in ${path.dirname(pods)}`,
|
|
840
|
+
)
|
|
841
|
+
if (
|
|
842
|
+
!fs.existsSync(manifestLock) ||
|
|
843
|
+
!fs.readFileSync(manifestLock).equals(fs.readFileSync(podfileLock))
|
|
844
|
+
)
|
|
845
|
+
throw new Error(
|
|
846
|
+
`The sandbox is not in sync with the Podfile.lock: ${manifestLock} differs from ${podfileLock}. Run \`pod install\` in ${path.dirname(pods)}`,
|
|
847
|
+
)
|
|
848
|
+
const specChecksums: Record<string, string> = {}
|
|
849
|
+
const lines = fs.readFileSync(manifestLock, 'utf8').split('\n')
|
|
850
|
+
const start = lines.indexOf('SPEC CHECKSUMS:')
|
|
851
|
+
for (const line of start === -1 ? [] : lines.slice(start + 1)) {
|
|
852
|
+
const entry = /^ {2}"?([^":]+)"?: ([0-9a-f]+)$/.exec(line)
|
|
853
|
+
if (!entry) break
|
|
854
|
+
specChecksums[entry[1]!] = entry[2]!
|
|
855
|
+
}
|
|
856
|
+
const specs = path.join(pods, 'Local Podspecs')
|
|
857
|
+
return {
|
|
858
|
+
podfileLock,
|
|
859
|
+
manifestLock,
|
|
860
|
+
specChecksums,
|
|
861
|
+
localPodspecs: isDirectory(specs)
|
|
862
|
+
? fs
|
|
863
|
+
.readdirSync(specs)
|
|
864
|
+
.filter((name) => name.endsWith('.podspec.json'))
|
|
865
|
+
.sort()
|
|
866
|
+
.map((name) => path.join(specs, name))
|
|
867
|
+
: [],
|
|
868
|
+
}
|
|
869
|
+
}
|
|
870
|
+
|
|
801
871
|
// every project a workspace or project builds: listed ones and the projects
|
|
802
|
-
// nested in them.
|
|
803
|
-
//
|
|
804
|
-
function workspaceProjects(
|
|
872
|
+
// nested in them. a build read includes the installed cocoapods project and
|
|
873
|
+
// refuses a missing or stale one; metadata reads never open it.
|
|
874
|
+
function workspaceProjects(
|
|
875
|
+
xcodeprojOrWorkspace: string,
|
|
876
|
+
installedPods = false,
|
|
877
|
+
): {
|
|
805
878
|
listed: string[]
|
|
806
879
|
projects: LoadedProject[]
|
|
807
880
|
projectAt: Map<string, LoadedProject>
|
|
881
|
+
cocoapods: XcodeAppTarget['cocoapods']
|
|
808
882
|
} {
|
|
809
883
|
const listed = xcodeprojOrWorkspace.endsWith('.xcworkspace')
|
|
810
884
|
? workspaceReferences(xcodeprojOrWorkspace)
|
|
811
885
|
: [xcodeprojOrWorkspace]
|
|
812
886
|
const projects: LoadedProject[] = []
|
|
813
887
|
const projectAt = new Map<string, LoadedProject>()
|
|
888
|
+
let cocoapods: XcodeAppTarget['cocoapods'] = null
|
|
814
889
|
const addProject = (xcodeproj: string) => {
|
|
815
|
-
if (!xcodeProjectFile(xcodeproj))
|
|
890
|
+
if (!xcodeProjectFile(xcodeproj)) {
|
|
891
|
+
if (installedPods && isPodsProject(xcodeproj))
|
|
892
|
+
throw new Error(
|
|
893
|
+
`${path.basename(xcodeprojOrWorkspace)} builds ${xcodeproj}, which is not installed: run \`pod install\` in ${path.dirname(path.dirname(xcodeproj))}`,
|
|
894
|
+
)
|
|
895
|
+
return
|
|
896
|
+
}
|
|
816
897
|
const key = fs.realpathSync(xcodeproj)
|
|
817
|
-
if (projectAt.has(key) || key.split(path.sep).includes('Pods'))
|
|
898
|
+
if (projectAt.has(key) || (!installedPods && key.split(path.sep).includes('Pods')))
|
|
899
|
+
return
|
|
900
|
+
if (isPodsProject(key)) cocoapods = installedPodsSandbox(path.dirname(key))
|
|
818
901
|
const project = loadProject(key)
|
|
819
902
|
projectAt.set(key, project)
|
|
820
903
|
projects.push(project)
|
|
@@ -832,7 +915,13 @@ function workspaceProjects(xcodeprojOrWorkspace: string): {
|
|
|
832
915
|
if (projects.length === 0) {
|
|
833
916
|
throw new Error(`${path.basename(xcodeprojOrWorkspace)} lists no Xcode project`)
|
|
834
917
|
}
|
|
835
|
-
|
|
918
|
+
// a Podfile beside the container whose workspace builds no Pods project was never installed
|
|
919
|
+
const podfile = path.join(path.dirname(xcodeprojOrWorkspace), 'Podfile')
|
|
920
|
+
if (installedPods && !cocoapods && fs.existsSync(podfile))
|
|
921
|
+
throw new Error(
|
|
922
|
+
`${podfile} is not installed into ${path.basename(xcodeprojOrWorkspace)}: run \`pod install\` in ${path.dirname(podfile)} and open the workspace it writes`,
|
|
923
|
+
)
|
|
924
|
+
return { listed, projects, projectAt, cocoapods }
|
|
836
925
|
}
|
|
837
926
|
|
|
838
927
|
// one ref per target, so a target reached by a dependency and a link is visited once
|
|
@@ -972,14 +1061,22 @@ export function readXcodeAppTarget(
|
|
|
972
1061
|
input: string,
|
|
973
1062
|
targetName?: string,
|
|
974
1063
|
configurationName?: string,
|
|
975
|
-
options: {
|
|
1064
|
+
options: {
|
|
1065
|
+
requireSources?: boolean
|
|
1066
|
+
prepareGeneratedSources?: boolean
|
|
1067
|
+
/** build the CocoaPods project `pod install` generated, as Xcode does. */
|
|
1068
|
+
installedPods?: boolean
|
|
1069
|
+
} = {},
|
|
976
1070
|
): XcodeAppTarget {
|
|
977
1071
|
// canonical, so every path returned agrees with the host's realpath checks
|
|
978
1072
|
const xcodeprojOrWorkspace = fs.realpathSync(input)
|
|
979
1073
|
const workspace = xcodeprojOrWorkspace.endsWith('.xcworkspace')
|
|
980
1074
|
? xcodeprojOrWorkspace
|
|
981
1075
|
: null
|
|
982
|
-
const { listed, projects, projectAt } = workspaceProjects(
|
|
1076
|
+
const { listed, projects, projectAt, cocoapods } = workspaceProjects(
|
|
1077
|
+
xcodeprojOrWorkspace,
|
|
1078
|
+
options.installedPods,
|
|
1079
|
+
)
|
|
983
1080
|
const allTargets = projects.flatMap(nativeTargets)
|
|
984
1081
|
const appTargets = allTargets.filter((ref) => isIosAppTarget(ref, options))
|
|
985
1082
|
const appTargetNames = appTargets.map((ref) => str(ref.target.name) ?? ref.id)
|
|
@@ -1068,7 +1165,77 @@ export function readXcodeAppTarget(
|
|
|
1068
1165
|
}
|
|
1069
1166
|
visit(app)
|
|
1070
1167
|
|
|
1168
|
+
// a target's headers build phase, each header with the visibility it publishes.
|
|
1169
|
+
const headerPhase = (
|
|
1170
|
+
ref: TargetRef,
|
|
1171
|
+
): { file: string; visibility: 'Public' | 'Private' | 'Project' }[] =>
|
|
1172
|
+
list(ref.target.buildPhases).flatMap((phaseId) => {
|
|
1173
|
+
const phase = ref.project.object(phaseId)
|
|
1174
|
+
if (phase?.isa !== 'PBXHeadersBuildPhase') return []
|
|
1175
|
+
return list(phase.files).flatMap((id) => {
|
|
1176
|
+
const file = ref.project.object(id)
|
|
1177
|
+
const resolved = ref.project.resolvePath(str(file?.fileRef) ?? '')
|
|
1178
|
+
const attributes = isDict(file?.settings) ? list(file.settings.ATTRIBUTES) : []
|
|
1179
|
+
if (!resolved) return []
|
|
1180
|
+
return [
|
|
1181
|
+
{
|
|
1182
|
+
file: resolved,
|
|
1183
|
+
visibility: attributes.includes('Public')
|
|
1184
|
+
? 'Public'
|
|
1185
|
+
: attributes.includes('Private')
|
|
1186
|
+
? 'Private'
|
|
1187
|
+
: 'Project',
|
|
1188
|
+
},
|
|
1189
|
+
]
|
|
1190
|
+
})
|
|
1191
|
+
})
|
|
1192
|
+
const productName = (ref: TargetRef) =>
|
|
1193
|
+
targetSettings(
|
|
1194
|
+
ref,
|
|
1195
|
+
configuration,
|
|
1196
|
+
{ TARGET_NAME: str(ref.target.name) ?? ref.id },
|
|
1197
|
+
options,
|
|
1198
|
+
).get('PRODUCT_NAME')
|
|
1199
|
+
// xcode's project header map: every header the project references, by
|
|
1200
|
+
// name, as the framework include a target publishes it under or its path.
|
|
1201
|
+
// a name two targets publish takes the earlier target's header.
|
|
1202
|
+
const projectHeaderMaps = new Map<LoadedProject, [string, string][]>()
|
|
1203
|
+
const projectHeaderMap = (project: LoadedProject): [string, string][] => {
|
|
1204
|
+
const cached = projectHeaderMaps.get(project)
|
|
1205
|
+
if (cached) return cached
|
|
1206
|
+
const entries = new Map<string, string>()
|
|
1207
|
+
for (const ref of nativeTargets(project)) {
|
|
1208
|
+
const framework = FRAMEWORK_PRODUCTS.has(str(ref.target.productType) ?? '')
|
|
1209
|
+
const product = framework ? productName(ref) : ''
|
|
1210
|
+
for (const { file, visibility } of headerPhase(ref)) {
|
|
1211
|
+
const name = path.basename(file)
|
|
1212
|
+
if (!entries.has(name))
|
|
1213
|
+
entries.set(
|
|
1214
|
+
name,
|
|
1215
|
+
framework && visibility !== 'Project' ? `${product}/${name}` : file,
|
|
1216
|
+
)
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
for (const id of Object.keys(project.objects)) {
|
|
1220
|
+
if (project.object(id)?.isa !== 'PBXFileReference') continue
|
|
1221
|
+
const file = project.resolvePath(id)
|
|
1222
|
+
if (file && HEADER_FILE.test(file) && !entries.has(path.basename(file)))
|
|
1223
|
+
entries.set(path.basename(file), file)
|
|
1224
|
+
}
|
|
1225
|
+
const map = [...entries]
|
|
1226
|
+
projectHeaderMaps.set(project, map)
|
|
1227
|
+
return map
|
|
1228
|
+
}
|
|
1071
1229
|
const xcconfigs = new Set<string>()
|
|
1230
|
+
const buildDir = (project: LoadedProject) =>
|
|
1231
|
+
path.join(project.projectDir, '.build/peach-xcode/Build')
|
|
1232
|
+
// a workspace build writes every pod into the app's build directory, where
|
|
1233
|
+
// the pods' xcconfigs and the app's find each other's frameworks, whatever
|
|
1234
|
+
// SYMROOT the generated project names.
|
|
1235
|
+
const podsBuild = {
|
|
1236
|
+
SYMROOT: path.join(buildDir(app.project), 'Products'),
|
|
1237
|
+
OBJROOT: path.join(buildDir(app.project), 'Intermediates.noindex'),
|
|
1238
|
+
}
|
|
1072
1239
|
const moduleTarget = (ref: TargetRef) => {
|
|
1073
1240
|
const name = str(ref.target.name) ?? ref.id
|
|
1074
1241
|
const {
|
|
@@ -1084,12 +1251,9 @@ export function readXcodeAppTarget(
|
|
|
1084
1251
|
SRCROOT: ref.project.projectDir,
|
|
1085
1252
|
SOURCE_ROOT: ref.project.projectDir,
|
|
1086
1253
|
PROJECT_DIR: ref.project.projectDir,
|
|
1087
|
-
SYMROOT: path.join(ref.project
|
|
1254
|
+
SYMROOT: path.join(buildDir(ref.project), 'Products'),
|
|
1088
1255
|
BUILD_DIR: '$(SYMROOT)',
|
|
1089
|
-
OBJROOT: path.join(
|
|
1090
|
-
ref.project.projectDir,
|
|
1091
|
-
'.build/peach-xcode/Build/Intermediates.noindex',
|
|
1092
|
-
),
|
|
1256
|
+
OBJROOT: path.join(buildDir(ref.project), 'Intermediates.noindex'),
|
|
1093
1257
|
CONFIGURATION_BUILD_DIR:
|
|
1094
1258
|
'$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)',
|
|
1095
1259
|
BUILT_PRODUCTS_DIR: '$(CONFIGURATION_BUILD_DIR)',
|
|
@@ -1108,6 +1272,7 @@ export function readXcodeAppTarget(
|
|
|
1108
1272
|
DEVELOPMENT_LANGUAGE: str(ref.project.project.developmentRegion) ?? 'en',
|
|
1109
1273
|
},
|
|
1110
1274
|
options,
|
|
1275
|
+
isPodsProject(ref.project.xcodeproj) ? podsBuild : {},
|
|
1111
1276
|
)
|
|
1112
1277
|
for (const file of read) xcconfigs.add(file)
|
|
1113
1278
|
const swiftVersion = Number.parseFloat(settings('SWIFT_VERSION') || '5')
|
|
@@ -1117,6 +1282,25 @@ export function readXcodeAppTarget(
|
|
|
1117
1282
|
/\.(c|cc|cpp|cxx|m|mm)$/.test(file),
|
|
1118
1283
|
)
|
|
1119
1284
|
const absolute = (file: string) => path.resolve(ref.project.projectDir, file)
|
|
1285
|
+
const framework = FRAMEWORK_PRODUCTS.has(str(ref.target.productType) ?? '')
|
|
1286
|
+
const product = settings('PRODUCT_NAME')
|
|
1287
|
+
const headerFiles = headerPhase(ref)
|
|
1288
|
+
// the own-target map: a published header by its framework include, a
|
|
1289
|
+
// project header by its path under both its name and the framework's.
|
|
1290
|
+
const ownHeaders = new Map<string, string>()
|
|
1291
|
+
for (const { file, visibility } of headerFiles) {
|
|
1292
|
+
const name = path.basename(file)
|
|
1293
|
+
const published = framework && visibility !== 'Project'
|
|
1294
|
+
if (!ownHeaders.has(name))
|
|
1295
|
+
ownHeaders.set(name, published ? `${product}/${name}` : file)
|
|
1296
|
+
if (framework && !published && !ownHeaders.has(`${product}/${name}`))
|
|
1297
|
+
ownHeaders.set(`${product}/${name}`, file)
|
|
1298
|
+
}
|
|
1299
|
+
const wrapper = path.join(settings('BUILT_PRODUCTS_DIR'), `${product}.framework`)
|
|
1300
|
+
const moduleMap =
|
|
1301
|
+
settings('DEFINES_MODULE') === 'YES' && settings('MODULEMAP_FILE')
|
|
1302
|
+
? absolute(settings('MODULEMAP_FILE'))
|
|
1303
|
+
: null
|
|
1120
1304
|
const fileFlags: Record<string, string[]> = {}
|
|
1121
1305
|
for (const phaseId of list(ref.target.buildPhases)) {
|
|
1122
1306
|
const phase = ref.project.object(phaseId)
|
|
@@ -1148,26 +1332,15 @@ export function readXcodeAppTarget(
|
|
|
1148
1332
|
...(implementations.some((file) => /\.mm?$/.test(file))
|
|
1149
1333
|
? {
|
|
1150
1334
|
objc: {
|
|
1151
|
-
publicHeaders:
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
return list(phase.files).flatMap((id) => {
|
|
1155
|
-
const file = ref.project.object(id)
|
|
1156
|
-
const attributes = isDict(file?.settings)
|
|
1157
|
-
? list(file.settings.ATTRIBUTES)
|
|
1158
|
-
: []
|
|
1159
|
-
const resolved = ref.project.resolvePath(str(file?.fileRef) ?? '')
|
|
1160
|
-
return attributes.includes('Public') && resolved ? [resolved] : []
|
|
1161
|
-
})
|
|
1162
|
-
}),
|
|
1335
|
+
publicHeaders: headerFiles.flatMap(({ file, visibility }) =>
|
|
1336
|
+
visibility === 'Public' ? [file] : [],
|
|
1337
|
+
),
|
|
1163
1338
|
headers: [
|
|
1164
1339
|
...new Set([
|
|
1165
1340
|
...headers,
|
|
1166
1341
|
...Object.keys(ref.project.objects).flatMap((id) => {
|
|
1167
1342
|
const file = ref.project.resolvePath(id)
|
|
1168
|
-
return file &&
|
|
1169
|
-
/\.(h|hh|hpp|hxx|pch)$/.test(file) &&
|
|
1170
|
-
fs.existsSync(file)
|
|
1343
|
+
return file && HEADER_FILE.test(file) && fs.existsSync(file)
|
|
1171
1344
|
? [file]
|
|
1172
1345
|
: []
|
|
1173
1346
|
}),
|
|
@@ -1183,9 +1356,13 @@ export function readXcodeAppTarget(
|
|
|
1183
1356
|
...settingList(settings('HEADER_SEARCH_PATHS')),
|
|
1184
1357
|
...settingList(settings('USER_HEADER_SEARCH_PATHS')),
|
|
1185
1358
|
].flatMap((raw) => expandSearchPath(absolute(raw), searchRules)),
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1359
|
+
// xcode searches the target's own products directory first
|
|
1360
|
+
frameworkSearchPaths: [
|
|
1361
|
+
settings('BUILT_PRODUCTS_DIR'),
|
|
1362
|
+
...settingList(settings('FRAMEWORK_SEARCH_PATHS')).flatMap((raw) =>
|
|
1363
|
+
expandSearchPath(absolute(raw), searchRules),
|
|
1364
|
+
),
|
|
1365
|
+
],
|
|
1189
1366
|
flags: [
|
|
1190
1367
|
settings('CLANG_ENABLE_OBJC_ARC') === 'YES'
|
|
1191
1368
|
? '-fobjc-arc'
|
|
@@ -1209,6 +1386,37 @@ export function readXcodeAppTarget(
|
|
|
1209
1386
|
...settingList(settings('OTHER_CPLUSPLUSFLAGS')),
|
|
1210
1387
|
],
|
|
1211
1388
|
fileFlags,
|
|
1389
|
+
headerMaps:
|
|
1390
|
+
settings('USE_HEADERMAP') === 'NO'
|
|
1391
|
+
? []
|
|
1392
|
+
: [
|
|
1393
|
+
{ flag: '-I', entries: [...ownHeaders] },
|
|
1394
|
+
{
|
|
1395
|
+
flag: '-iquote',
|
|
1396
|
+
entries: projectHeaderMap(ref.project),
|
|
1397
|
+
},
|
|
1398
|
+
],
|
|
1399
|
+
productHeaders: framework
|
|
1400
|
+
? Object.fromEntries([
|
|
1401
|
+
...headerFiles.flatMap(({ file, visibility }) =>
|
|
1402
|
+
visibility === 'Project'
|
|
1403
|
+
? []
|
|
1404
|
+
: [
|
|
1405
|
+
[
|
|
1406
|
+
path.join(
|
|
1407
|
+
wrapper,
|
|
1408
|
+
visibility === 'Public' ? 'Headers' : 'PrivateHeaders',
|
|
1409
|
+
path.basename(file),
|
|
1410
|
+
),
|
|
1411
|
+
file,
|
|
1412
|
+
],
|
|
1413
|
+
],
|
|
1414
|
+
),
|
|
1415
|
+
...(moduleMap
|
|
1416
|
+
? [[path.join(wrapper, 'Modules', 'module.modulemap'), moduleMap]]
|
|
1417
|
+
: []),
|
|
1418
|
+
])
|
|
1419
|
+
: {},
|
|
1212
1420
|
},
|
|
1213
1421
|
}
|
|
1214
1422
|
: {}),
|
|
@@ -1216,7 +1424,18 @@ export function readXcodeAppTarget(
|
|
|
1216
1424
|
}
|
|
1217
1425
|
}
|
|
1218
1426
|
const { settings, keys: settingKeys, module } = moduleTarget(app)
|
|
1219
|
-
const
|
|
1427
|
+
const frameworkTargets = order
|
|
1428
|
+
.slice(0, -1)
|
|
1429
|
+
.map((ref) => ({ ref, framework: moduleTarget(ref).module }))
|
|
1430
|
+
const frameworks = frameworkTargets.map(({ framework }) => framework)
|
|
1431
|
+
// a development pod's sources sit outside the sandbox, where its podspec is
|
|
1432
|
+
const podSourceDirs = frameworkTargets.flatMap(({ ref, framework }) =>
|
|
1433
|
+
isPodsProject(ref.project.xcodeproj)
|
|
1434
|
+
? [...framework.allSources, ...(framework.objc?.headers ?? [])]
|
|
1435
|
+
.map((file) => path.dirname(file))
|
|
1436
|
+
.filter((dir) => fs.existsSync(dir))
|
|
1437
|
+
: [],
|
|
1438
|
+
)
|
|
1220
1439
|
|
|
1221
1440
|
const expandValue = (value: plist.PlistValue): plist.PlistValue => {
|
|
1222
1441
|
if (typeof value === 'string') return expand(value, settings)
|
|
@@ -1397,10 +1616,17 @@ export function readXcodeAppTarget(
|
|
|
1397
1616
|
...linkedProducts.flatMap(({ source }) =>
|
|
1398
1617
|
source.kind === 'local' && fs.existsSync(source.dir) ? [source.dir] : [],
|
|
1399
1618
|
),
|
|
1619
|
+
...new Set(podSourceDirs),
|
|
1400
1620
|
].map((dir) => fs.realpathSync(dir)),
|
|
1401
1621
|
),
|
|
1402
1622
|
projectFiles: [
|
|
1403
|
-
...new Set([
|
|
1623
|
+
...new Set([
|
|
1624
|
+
...used.map((project) => project.projectFile),
|
|
1625
|
+
...xcconfigs,
|
|
1626
|
+
...(cocoapods
|
|
1627
|
+
? [cocoapods.podfileLock, cocoapods.manifestLock, ...cocoapods.localPodspecs]
|
|
1628
|
+
: []),
|
|
1629
|
+
]),
|
|
1404
1630
|
].sort(),
|
|
1405
1631
|
appIconName: settings('ASSETCATALOG_COMPILER_APPICON_NAME'),
|
|
1406
1632
|
infoPlist: plist.build(info),
|
|
@@ -1417,5 +1643,6 @@ export function readXcodeAppTarget(
|
|
|
1417
1643
|
appTargets: appTargetNames,
|
|
1418
1644
|
configuration,
|
|
1419
1645
|
settings,
|
|
1646
|
+
cocoapods,
|
|
1420
1647
|
}
|
|
1421
1648
|
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
package android.content
|
|
2
|
-
|
|
3
|
-
import android.content.res.Resources
|
|
4
|
-
import android.content.res.processResources
|
|
5
|
-
|
|
6
|
-
abstract class Context {
|
|
7
|
-
abstract val resources: Resources
|
|
8
|
-
|
|
9
|
-
abstract val theme: Resources.Theme
|
|
10
|
-
|
|
11
|
-
fun getColor(id: Int): Int = resources.getColor(id, theme)
|
|
12
|
-
|
|
13
|
-
fun getString(resId: Int): String = resources.getString(resId)
|
|
14
|
-
|
|
15
|
-
fun getString(resId: Int, vararg formatArgs: Any?): String = resources.getString(resId, *formatArgs)
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
open class ContextWrapper : Context() {
|
|
19
|
-
override val resources: Resources get() = processResources
|
|
20
|
-
|
|
21
|
-
override val theme: Resources.Theme = Resources.Theme()
|
|
22
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
package android.content.res
|
|
2
|
-
|
|
3
|
-
// the device configuration an app reads through its resources: a phone's
|
|
4
|
-
// normal ui mode type, night or not as the device's dark theme is set, and
|
|
5
|
-
// the device locale's language tag
|
|
6
|
-
class Configuration {
|
|
7
|
-
var uiMode: Int = UI_MODE_TYPE_NORMAL or UI_MODE_NIGHT_NO
|
|
8
|
-
internal var localeTag: String = ""
|
|
9
|
-
|
|
10
|
-
internal fun isNight() = uiMode and UI_MODE_NIGHT_MASK == UI_MODE_NIGHT_YES
|
|
11
|
-
|
|
12
|
-
fun setTo(other: Configuration) {
|
|
13
|
-
uiMode = other.uiMode
|
|
14
|
-
localeTag = other.localeTag
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
companion object {
|
|
18
|
-
const val UI_MODE_TYPE_MASK = 0x0f
|
|
19
|
-
const val UI_MODE_TYPE_NORMAL = 0x01
|
|
20
|
-
const val UI_MODE_NIGHT_MASK = 0x30
|
|
21
|
-
const val UI_MODE_NIGHT_UNDEFINED = 0x00
|
|
22
|
-
const val UI_MODE_NIGHT_NO = 0x10
|
|
23
|
-
const val UI_MODE_NIGHT_YES = 0x20
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
package android.content.res
|
|
2
|
-
|
|
3
|
-
import android.util.DisplayMetrics
|
|
4
|
-
import dev.peach.app.javaFormat
|
|
5
|
-
|
|
6
|
-
class Resources internal constructor(
|
|
7
|
-
val configuration: Configuration,
|
|
8
|
-
val displayMetrics: DisplayMetrics,
|
|
9
|
-
private val strings: Map<Int, Map<String, String>>,
|
|
10
|
-
private val plurals: Map<Int, Map<String, Map<String, String>>>,
|
|
11
|
-
private val arrays: Map<Int, Map<String, List<String>>>,
|
|
12
|
-
private val colors: Map<Int, IntArray>,
|
|
13
|
-
) {
|
|
14
|
-
class NotFoundException(name: String) : RuntimeException(name)
|
|
15
|
-
|
|
16
|
-
// a context's theme; app color resources are plain values, so getColor
|
|
17
|
-
// reads none of it
|
|
18
|
-
class Theme internal constructor()
|
|
19
|
-
|
|
20
|
-
fun getString(id: Int): String =
|
|
21
|
-
resolve(strings[id]) ?: throw NotFoundException("String resource ID #0x${id.toString(16)}")
|
|
22
|
-
|
|
23
|
-
fun getString(id: Int, vararg formatArgs: Any?): String =
|
|
24
|
-
javaFormat(configuration.localeTag, getString(id), formatArgs)
|
|
25
|
-
|
|
26
|
-
// ResourcesImpl.getQuantityText: the item the locale's plural rule
|
|
27
|
-
// selects for the quantity, then the other item
|
|
28
|
-
fun getQuantityString(id: Int, quantity: Int): String {
|
|
29
|
-
val items = resolve(plurals[id])
|
|
30
|
-
?: throw NotFoundException("Plural resource ID #0x${id.toString(16)}")
|
|
31
|
-
val rule = pluralRule(configuration.localeTag, quantity)
|
|
32
|
-
return items[rule] ?: items["other"]
|
|
33
|
-
?: throw NotFoundException("Plural resource ID #0x${id.toString(16)} quantity=$quantity item=$rule")
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
fun getQuantityString(id: Int, quantity: Int, vararg formatArgs: Any?): String =
|
|
37
|
-
javaFormat(configuration.localeTag, getQuantityString(id, quantity), formatArgs)
|
|
38
|
-
|
|
39
|
-
fun getStringArray(id: Int): Array<String> =
|
|
40
|
-
resolve(arrays[id])?.toTypedArray()
|
|
41
|
-
?: throw NotFoundException("String array resource ID #0x${id.toString(16)}")
|
|
42
|
-
|
|
43
|
-
// the color the configuration's night mode selects, values-night over
|
|
44
|
-
// values
|
|
45
|
-
fun getColor(id: Int, theme: Theme?): Int {
|
|
46
|
-
val values = colors[id] ?: throw NotFoundException("Resource ID #0x${id.toString(16)}")
|
|
47
|
-
return values[if (configuration.isNight()) 1 else 0]
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
@Deprecated("Use getColor(int, Theme) instead.")
|
|
51
|
-
fun getColor(id: Int): Int = getColor(id, null)
|
|
52
|
-
|
|
53
|
-
// the value the configuration's locale selects: its language and region,
|
|
54
|
-
// then its language, then the default values, as the resource table
|
|
55
|
-
// matches a locale qualifier. a plurals or array resource resolves whole
|
|
56
|
-
private fun <Value> resolve(values: Map<String, Value>?): Value? {
|
|
57
|
-
if (values == null) return null
|
|
58
|
-
val tag = configuration.localeTag
|
|
59
|
-
return values[tag] ?: values[tag.substringBefore('-')] ?: values[""]
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// ICU's PluralRules.forLocale(locale).select(quantity); Intl reads the same
|
|
64
|
-
// CLDR plural rules
|
|
65
|
-
private fun pluralRule(locale: String, quantity: Int): String =
|
|
66
|
-
js("new Intl.PluralRules(locale || undefined).select(quantity)")
|
|
67
|
-
|
|
68
|
-
// the app process's resources, set once the device configuration is known at
|
|
69
|
-
// cold start; every context in the process reads the same configuration, which
|
|
70
|
-
// a configuration change updates in place, as ResourcesManager does, so a
|
|
71
|
-
// Resources or Configuration an app holds reads the new values
|
|
72
|
-
internal lateinit var processResources: Resources
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
package android.graphics
|
|
2
|
-
|
|
3
|
-
// the Android view's canvas draws into its existing native scene. module-only
|
|
4
|
-
// processes carry this contract without linking a renderer.
|
|
5
|
-
internal interface ViewCanvas {
|
|
6
|
-
fun drawColor(color: Int)
|
|
7
|
-
fun drawCircle(cx: Float, cy: Float, radius: Float, paint: Paint)
|
|
8
|
-
fun save(): Int
|
|
9
|
-
fun restoreToCount(count: Int)
|
|
10
|
-
fun translate(dx: Float, dy: Float)
|
|
11
|
-
fun clipRect(left: Float, top: Float, right: Float, bottom: Float): Boolean
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
class Canvas internal constructor(private val target: ViewCanvas) {
|
|
15
|
-
fun drawColor(color: Int) = target.drawColor(color)
|
|
16
|
-
fun drawCircle(cx: Float, cy: Float, radius: Float, paint: Paint) = target.drawCircle(cx, cy, radius, paint)
|
|
17
|
-
fun save(): Int = target.save()
|
|
18
|
-
fun restoreToCount(saveCount: Int) = target.restoreToCount(saveCount)
|
|
19
|
-
fun translate(dx: Float, dy: Float) = target.translate(dx, dy)
|
|
20
|
-
fun clipRect(left: Float, top: Float, right: Float, bottom: Float): Boolean = target.clipRect(left, top, right, bottom)
|
|
21
|
-
fun clipRect(left: Int, top: Int, right: Int, bottom: Int): Boolean = clipRect(left.toFloat(), top.toFloat(), right.toFloat(), bottom.toFloat())
|
|
22
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
package android.graphics
|
|
2
|
-
|
|
3
|
-
// the packed ARGB ints android.graphics.Color names and builds
|
|
4
|
-
object Color {
|
|
5
|
-
const val BLACK = -0x1000000
|
|
6
|
-
const val WHITE = -0x1
|
|
7
|
-
const val TRANSPARENT = 0
|
|
8
|
-
|
|
9
|
-
fun argb(alpha: Int, red: Int, green: Int, blue: Int): Int =
|
|
10
|
-
(alpha shl 24) or (red shl 16) or (green shl 8) or blue
|
|
11
|
-
|
|
12
|
-
fun alpha(color: Int): Int = color ushr 24
|
|
13
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
package android.graphics
|
|
2
|
-
|
|
3
|
-
// android API 31+ enables antialiasing in Paint(), while Paint(0) clears it.
|
|
4
|
-
class Paint(flags: Int) {
|
|
5
|
-
constructor() : this(ANTI_ALIAS_FLAG)
|
|
6
|
-
|
|
7
|
-
enum class Style { FILL, STROKE, FILL_AND_STROKE }
|
|
8
|
-
|
|
9
|
-
var color: Int = 0xff000000.toInt()
|
|
10
|
-
var style: Style = Style.FILL
|
|
11
|
-
var strokeWidth: Float = 0f
|
|
12
|
-
set(value) { if (value >= 0f) field = value }
|
|
13
|
-
var isAntiAlias: Boolean = flags and ANTI_ALIAS_FLAG != 0
|
|
14
|
-
|
|
15
|
-
companion object {
|
|
16
|
-
const val ANTI_ALIAS_FLAG = 0x01
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
package android.util
|
|
2
|
-
|
|
3
|
-
// the display's density as resources read it: densityDpi is the bucketless
|
|
4
|
-
// dots per inch and density its scale over the 160 dpi baseline
|
|
5
|
-
class DisplayMetrics {
|
|
6
|
-
var density: Float = 0f
|
|
7
|
-
var densityDpi: Int = 0
|
|
8
|
-
|
|
9
|
-
companion object {
|
|
10
|
-
const val DENSITY_DEFAULT = 160
|
|
11
|
-
}
|
|
12
|
-
}
|