peachsim 0.1.658 → 0.1.660
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/cli-update.ts +53 -21
- package/cli/commands/compat.ts +6 -2
- package/cli/commands/control.ts +12 -3
- package/cli/commands/inspect.ts +16 -14
- package/cli/commands/upgrade.ts +4 -2
- package/cli/current-sim.ts +4 -0
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/agent-identity.cjs +1 -1
- package/dist-lib/agent-sessions.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/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +1 -1
- package/dist-lib/cli-constants.cjs +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/detox/index.cjs +2 -2
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +1 -1
- package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
- 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 +5 -1
- 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 +11 -1
- 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 +1 -1
- package/dist-lib/native-app-identity.cjs +1 -1
- package/dist-lib/native-app-identity.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/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +1 -1
- package/dist-lib/render-mode.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +1 -1
- package/dist-lib/skills.cjs +15 -11
- package/dist-lib/swift-compile.cjs +1 -1
- package/dist-lib/swift-compile.mjs +1 -1
- 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.cjs +1 -1
- package/dist-lib/vite-swift.cjs +1 -1
- package/dist-lib/vite.cjs +1 -1
- package/kotlin/AppSources/android/app/Activity.kt +90 -1
- package/kotlin/AppSources/android/app/Application.kt +4 -0
- package/kotlin/AppSources/android/content/res/Configuration.kt +4 -0
- package/kotlin/AppSources/android/content/res/Resources.kt +3 -1
- package/kotlin/AppSources/android/os/Bundle.kt +9 -3
- package/kotlin/AppSources/androidx/activity/BackEventCompat.kt +17 -0
- package/kotlin/AppSources/androidx/activity/Cancellable.kt +5 -0
- package/kotlin/AppSources/androidx/activity/ComponentActivity.kt +58 -6
- package/kotlin/AppSources/androidx/activity/OnBackPressedCallback.kt +28 -0
- package/kotlin/AppSources/androidx/activity/OnBackPressedDispatcher.kt +144 -0
- package/kotlin/AppSources/androidx/activity/OnBackPressedDispatcherOwner.kt +7 -0
- package/kotlin/AppSources/androidx/activity/compose/BackHandler.kt +55 -0
- package/kotlin/AppSources/dev/peach/app/PeachApp.kt +231 -47
- package/kotlin/AppSources/java/lang/Runnable.kt +6 -0
- package/kotlin/ComposeSources/PeachComposeHost.kt +15 -3
- package/kotlin/fork/README.md +1 -0
- package/kotlin/fork/compose-worker-globals.patch +26 -0
- package/kotlin/fork/fork.json +1 -1
- package/kotlin/toolchain.json +3 -3
- package/package.json +1 -1
- package/src/kotlin-app.ts +18 -0
- package/src/kotlin-host.ts +10 -0
package/dist-lib/plist.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.660 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
package/dist-lib/plist.mjs
CHANGED
package/dist-lib/profiles.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.660 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.660 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.660 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
package/dist-lib/render-mode.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.660 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.660 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
package/dist-lib/sdk.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.660 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
package/dist-lib/sdk.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.660 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
4
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
package/dist-lib/skills.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.660 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
@@ -58,7 +58,7 @@ function processIdentity(pid) {
|
|
|
58
58
|
}
|
|
59
59
|
function softwareChromeAllowed(runtime = currentRuntime()) {
|
|
60
60
|
if (runtime.platform !== "linux") return false;
|
|
61
|
-
return runtime.env.GITHUB_ACTIONS === "true" && runtime.env.RUNNER_OS === "Linux" || runtime.env.CONTRAST_CF_FACTORY_CONTAINER === "1";
|
|
61
|
+
return runtime.env.GITHUB_ACTIONS === "true" && runtime.env.RUNNER_OS === "Linux" || runtime.env.CONTRAST_CF_FACTORY_CONTAINER === "1" || runtime.env.PEACH_NATIVE_COMPOSITOR === "1";
|
|
62
62
|
}
|
|
63
63
|
function isSoftwareRendererArgument(value) {
|
|
64
64
|
const arg = String(value);
|
|
@@ -8896,16 +8896,16 @@ var init_registry = __esm({
|
|
|
8896
8896
|
{
|
|
8897
8897
|
range: ">=2.0.0 <3.0.0",
|
|
8898
8898
|
coverage: 0,
|
|
8899
|
-
note: "native seam: published JavaScript
|
|
8900
|
-
working: "
|
|
8901
|
-
missing: "
|
|
8899
|
+
note: "native seam: published JavaScript runs over the Compressor Nitro object; worker WebCodecs and a lazy container backend export H.264 MP4 and AAC M4A files",
|
|
8900
|
+
working: "image encoding; video/audio transcoding to writable file URIs; native bitrate, resize, quality, sample rate and channel options; progress and UUID cancellation; real metadata; 512px thumbnails; fetch upload/download and cache utilities",
|
|
8901
|
+
missing: "PhotoKit assets, EXIF preservation, UIApplication background assertions; encoding depends on browser H.264/AAC codec availability"
|
|
8902
8902
|
},
|
|
8903
8903
|
{
|
|
8904
8904
|
range: ">=1.0.0 <2.0.0",
|
|
8905
8905
|
coverage: 0.78,
|
|
8906
|
-
note: "native
|
|
8907
|
-
working: "Image.compress
|
|
8908
|
-
missing: "
|
|
8906
|
+
note: "native seam: published JavaScript runs over the browser-backed Compressor TurboModule; worker media decoding and H.264/AAC export use the v1 native bitrate and resize rules",
|
|
8907
|
+
working: "Image.compress resizes/re-encodes jpg/png and returns URI/base64; video/audio export writes MP4/M4A files; video progress and UUID cancellation; missing metadata rejects -15; real dimensions, duration and size; 512px thumbnails; cache, upload and download operations",
|
|
8908
|
+
missing: "EXIF preservation, PhotoKit assets, granular upload byte progress and UIApplication background assertions; encoding depends on browser H.264/AAC codec availability"
|
|
8909
8909
|
}
|
|
8910
8910
|
]
|
|
8911
8911
|
},
|
|
@@ -31488,6 +31488,10 @@ var init_current_sim = __esm({
|
|
|
31488
31488
|
// claude code, if ever set
|
|
31489
31489
|
"CODEX_THREAD_ID",
|
|
31490
31490
|
// codex / openai agent thread, stable across tool invocations
|
|
31491
|
+
// a Team Machine session, per agent run. its other runners set no session
|
|
31492
|
+
// variable of their own, and the terminal variables below are inherited from
|
|
31493
|
+
// whatever shell started the daemon, so every such agent would share one key.
|
|
31494
|
+
"TM_SESSION",
|
|
31491
31495
|
"TERM_SESSION_ID",
|
|
31492
31496
|
// macOS Terminal.app + iTerm2
|
|
31493
31497
|
"ITERM_SESSION_ID",
|
|
@@ -36840,7 +36844,7 @@ async function runUseLikeCommand(args, opts = {}) {
|
|
|
36840
36844
|
try {
|
|
36841
36845
|
const sims = await bridge.listSims();
|
|
36842
36846
|
const target = resolveTargetSim(sims, parsed.positional[0] || parsed.simId);
|
|
36843
|
-
if (target.lockedBy && target.lockExpiresAt && target.lockExpiresAt > Date.now()) {
|
|
36847
|
+
if (target.lockedBy && !target.lockedByMe && target.lockExpiresAt && target.lockExpiresAt > Date.now()) {
|
|
36844
36848
|
const secs = Math.max(0, Math.round((target.lockExpiresAt - Date.now()) / 1e3));
|
|
36845
36849
|
if (target.lockedByKind === "user-active") {
|
|
36846
36850
|
console.error(
|
|
@@ -36851,7 +36855,7 @@ async function runUseLikeCommand(args, opts = {}) {
|
|
|
36851
36855
|
}
|
|
36852
36856
|
if (!force) {
|
|
36853
36857
|
console.error(
|
|
36854
|
-
` refused: ${target.id} is leased by ${target.lockedBy} (${secs}s)`
|
|
36858
|
+
` refused: ${target.id} is leased by ${formatLockOwner(target.lockedBy)} (${secs}s)`
|
|
36855
36859
|
);
|
|
36856
36860
|
console.error(
|
|
36857
36861
|
` \`peach use ${target.id} --force\` to take it, or \`peach open --new\` for a fresh sim`
|
|
@@ -36891,7 +36895,7 @@ async function runClaimCommand(args, opts = {}) {
|
|
|
36891
36895
|
try {
|
|
36892
36896
|
const sims = await bridge.listSims();
|
|
36893
36897
|
const target = resolveTargetSim(sims, parsed.positional[0] || parsed.simId);
|
|
36894
|
-
const priorHolder = force && target.lockedBy && target.lockedByKind !== "user-active" ? target.lockedBy : null;
|
|
36898
|
+
const priorHolder = force && target.lockedBy && !target.lockedByMe && target.lockedByKind !== "user-active" ? target.lockedBy : null;
|
|
36895
36899
|
const result = await bridge.claim(target.id, { force });
|
|
36896
36900
|
saveCurrentSimId(target.id);
|
|
36897
36901
|
const ttl = Math.max(0, Math.round((result.lockExpiresAt - Date.now()) / 1e3));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.660 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.660 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.660 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
package/dist-lib/swift.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.660 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __defProp = Object.defineProperty;
|
package/dist-lib/vite-swift.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.660 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
package/dist-lib/vite.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! rnx v0.1.
|
|
1
|
+
/*! rnx v0.1.660 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
@@ -3,6 +3,7 @@ package android.app
|
|
|
3
3
|
import android.content.ComponentName
|
|
4
4
|
import android.content.ContextWrapper
|
|
5
5
|
import android.content.Intent
|
|
6
|
+
import android.content.res.Configuration
|
|
6
7
|
import android.os.Bundle
|
|
7
8
|
import android.util.SuperNotCalledException
|
|
8
9
|
import android.view.View
|
|
@@ -28,11 +29,28 @@ open class Activity : ContextWrapper() {
|
|
|
28
29
|
// still names the alias
|
|
29
30
|
val componentName: ComponentName get() = checkNotNull(attachedComponent)
|
|
30
31
|
|
|
31
|
-
|
|
32
|
+
// what the activity this one replaces returned from
|
|
33
|
+
// onRetainNonConfigurationInstance, across a configuration relaunch
|
|
34
|
+
var lastNonConfigurationInstance: Any? = null
|
|
35
|
+
private set
|
|
36
|
+
|
|
37
|
+
// true from the start of a configuration relaunch until this instance is
|
|
38
|
+
// destroyed, so its owners keep what the next instance takes over
|
|
39
|
+
var isChangingConfigurations = false
|
|
40
|
+
internal set
|
|
41
|
+
|
|
42
|
+
internal fun attach(
|
|
43
|
+
application: Application,
|
|
44
|
+
component: ComponentName,
|
|
45
|
+
intent: Intent,
|
|
46
|
+
window: Window,
|
|
47
|
+
lastNonConfigurationInstance: Any?,
|
|
48
|
+
) {
|
|
32
49
|
attachedApplication = application
|
|
33
50
|
attachedComponent = component
|
|
34
51
|
attachedIntent = intent
|
|
35
52
|
attachedWindow = window
|
|
53
|
+
this.lastNonConfigurationInstance = lastNonConfigurationInstance
|
|
36
54
|
}
|
|
37
55
|
|
|
38
56
|
open fun setContentView(view: View) {
|
|
@@ -48,12 +66,40 @@ open class Activity : ContextWrapper() {
|
|
|
48
66
|
protected open fun onPostCreate(savedInstanceState: Bundle?) { called = true }
|
|
49
67
|
protected open fun onResume() { called = true }
|
|
50
68
|
protected open fun onPostResume() { called = true }
|
|
69
|
+
protected open fun onPause() { called = true }
|
|
70
|
+
protected open fun onStop() { called = true }
|
|
71
|
+
protected open fun onRestart() { called = true }
|
|
72
|
+
|
|
73
|
+
protected open fun onDestroy() { called = true }
|
|
74
|
+
|
|
75
|
+
// a configuration change the manifest's configChanges lets it handle
|
|
76
|
+
// itself, without a relaunch
|
|
77
|
+
open fun onConfigurationChanged(newConfig: Configuration) { called = true }
|
|
78
|
+
|
|
79
|
+
// Activity's own save and restore carry the window's view hierarchy state;
|
|
80
|
+
// the decor window here holds no view state of its own
|
|
81
|
+
protected open fun onSaveInstanceState(outState: Bundle) {}
|
|
82
|
+
protected open fun onRestoreInstanceState(savedInstanceState: Bundle) {}
|
|
83
|
+
|
|
84
|
+
open fun onRetainNonConfigurationInstance(): Any? = null
|
|
85
|
+
|
|
86
|
+
// a back the window's callbacks left: the activity asks the task manager,
|
|
87
|
+
// which moves a root launcher task to the back rather than finishing it
|
|
88
|
+
// (from Android 12). the only activity Peach runs is that task's root.
|
|
89
|
+
open fun onBackPressed() {
|
|
90
|
+
movedTaskToBack = true
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
internal var movedTaskToBack = false
|
|
51
94
|
|
|
52
95
|
// ActivityLifecycleCallbacks' post events; ComponentActivity's lifecycle
|
|
53
96
|
// moves on these, as its ReportFragment does from API 29.
|
|
54
97
|
internal open fun dispatchActivityPostCreated() {}
|
|
55
98
|
internal open fun dispatchActivityPostStarted() {}
|
|
56
99
|
internal open fun dispatchActivityPostResumed() {}
|
|
100
|
+
internal open fun dispatchActivityPrePaused() {}
|
|
101
|
+
internal open fun dispatchActivityPreStopped() {}
|
|
102
|
+
internal open fun dispatchActivityPreDestroyed() {}
|
|
57
103
|
|
|
58
104
|
private fun require(method: String, call: () -> Unit) {
|
|
59
105
|
called = false
|
|
@@ -77,6 +123,49 @@ open class Activity : ContextWrapper() {
|
|
|
77
123
|
require("onPostCreate") { onPostCreate(icicle) }
|
|
78
124
|
}
|
|
79
125
|
|
|
126
|
+
internal fun performPause() {
|
|
127
|
+
dispatchActivityPrePaused()
|
|
128
|
+
require("onPause") { onPause() }
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
private var stopped = false
|
|
132
|
+
|
|
133
|
+
internal fun performStop() {
|
|
134
|
+
dispatchActivityPreStopped()
|
|
135
|
+
require("onStop") { onStop() }
|
|
136
|
+
stopped = true
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
internal fun performSaveInstanceState(outState: Bundle) {
|
|
140
|
+
onSaveInstanceState(outState)
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// ActivityThread restores after onStart, only with saved state
|
|
144
|
+
internal fun performRestoreInstanceState(savedInstanceState: Bundle) {
|
|
145
|
+
onRestoreInstanceState(savedInstanceState)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// ActivityThread collects what the next instance keeps before onDestroy
|
|
149
|
+
internal fun retainNonConfigurationInstances(): Any? = onRetainNonConfigurationInstance()
|
|
150
|
+
|
|
151
|
+
internal fun performDestroy() {
|
|
152
|
+
dispatchActivityPreDestroyed()
|
|
153
|
+
require("onDestroy") { onDestroy() }
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
internal fun performConfigurationChanged(newConfig: Configuration) {
|
|
157
|
+
require("onConfigurationChanged") { onConfigurationChanged(newConfig) }
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// ActivityThread brings a stopped activity back with onRestart, then
|
|
161
|
+
// onStart; one that never stopped has nothing to restart
|
|
162
|
+
internal fun performRestart() {
|
|
163
|
+
if (!stopped) return
|
|
164
|
+
stopped = false
|
|
165
|
+
require("onRestart") { onRestart() }
|
|
166
|
+
performStart()
|
|
167
|
+
}
|
|
168
|
+
|
|
80
169
|
internal fun performResume() {
|
|
81
170
|
require("onResume") { onResume() }
|
|
82
171
|
require("onPostResume") { onPostResume() }
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
package android.app
|
|
2
2
|
|
|
3
3
|
import android.content.ContextWrapper
|
|
4
|
+
import android.content.res.Configuration
|
|
4
5
|
|
|
5
6
|
open class Application : ContextWrapper() {
|
|
6
7
|
open fun onCreate() {}
|
|
8
|
+
|
|
9
|
+
// the process's configuration changed, before any activity relaunches
|
|
10
|
+
open fun onConfigurationChanged(newConfig: Configuration) {}
|
|
7
11
|
}
|
|
@@ -5,6 +5,10 @@ package android.content.res
|
|
|
5
5
|
class Configuration {
|
|
6
6
|
var uiMode: Int = UI_MODE_TYPE_NORMAL or UI_MODE_NIGHT_NO
|
|
7
7
|
|
|
8
|
+
fun setTo(other: Configuration) {
|
|
9
|
+
uiMode = other.uiMode
|
|
10
|
+
}
|
|
11
|
+
|
|
8
12
|
companion object {
|
|
9
13
|
const val UI_MODE_TYPE_MASK = 0x0f
|
|
10
14
|
const val UI_MODE_TYPE_NORMAL = 0x01
|
|
@@ -3,5 +3,7 @@ package android.content.res
|
|
|
3
3
|
class Resources internal constructor(val configuration: Configuration)
|
|
4
4
|
|
|
5
5
|
// the app process's resources, set once the device configuration is known at
|
|
6
|
-
// cold start; every context in the process reads the same configuration
|
|
6
|
+
// cold start; every context in the process reads the same configuration, which
|
|
7
|
+
// a configuration change updates in place, as ResourcesManager does, so a
|
|
8
|
+
// Resources or Configuration an app holds reads the new values
|
|
7
9
|
internal lateinit var processResources: Resources
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
package android.os
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import androidx.savedstate.SavedState
|
|
4
|
+
import androidx.savedstate.savedState
|
|
5
|
+
|
|
6
|
+
// on Android androidx's SavedState is Bundle; here a Bundle holds the
|
|
7
|
+
// multiplatform SavedState that a save writes into. a cold start has no saved
|
|
8
|
+
// instance state, so the launcher receives null.
|
|
9
|
+
class Bundle internal constructor(internal val state: SavedState) {
|
|
10
|
+
constructor() : this(savedState())
|
|
11
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
package androidx.activity
|
|
2
|
+
|
|
3
|
+
// androidx.activity's BackEventCompat: one predictive back gesture sample
|
|
4
|
+
class BackEventCompat(
|
|
5
|
+
val touchX: Float,
|
|
6
|
+
val touchY: Float,
|
|
7
|
+
val progress: Float,
|
|
8
|
+
val swipeEdge: Int,
|
|
9
|
+
) {
|
|
10
|
+
override fun toString(): String =
|
|
11
|
+
"BackEventCompat{touchX=$touchX, touchY=$touchY, progress=$progress, swipeEdge=$swipeEdge}"
|
|
12
|
+
|
|
13
|
+
companion object {
|
|
14
|
+
const val EDGE_LEFT = 0
|
|
15
|
+
const val EDGE_RIGHT = 1
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -21,15 +21,32 @@ import androidx.savedstate.SavedStateRegistryOwner
|
|
|
21
21
|
|
|
22
22
|
// androidx.activity's ComponentActivity owners, on the multiplatform
|
|
23
23
|
// lifecycle, viewmodel and savedstate libraries: the registry attaches in the
|
|
24
|
-
// constructor and restores in onCreate before super, the lifecycle moves on
|
|
25
|
-
// the post callbacks
|
|
24
|
+
// constructor and restores in onCreate before super, the lifecycle moves up on
|
|
25
|
+
// the post callbacks and down on the pre callbacks, as ReportFragment does from
|
|
26
|
+
// API 29, and destroy clears the view model store.
|
|
26
27
|
open class ComponentActivity : Activity(), LifecycleOwner, ViewModelStoreOwner,
|
|
27
|
-
HasDefaultViewModelProviderFactory, SavedStateRegistryOwner {
|
|
28
|
+
HasDefaultViewModelProviderFactory, SavedStateRegistryOwner, OnBackPressedDispatcherOwner {
|
|
28
29
|
private val lifecycleRegistry = LifecycleRegistry(this)
|
|
29
30
|
private val savedStateRegistryController = SavedStateRegistryController.create(this)
|
|
30
31
|
|
|
32
|
+
// the last instance's store after a configuration relaunch, else a new one
|
|
33
|
+
private var _viewModelStore: ViewModelStore? = null
|
|
34
|
+
|
|
35
|
+
private class NonConfigurationInstances(val custom: Any?, val viewModelStore: ViewModelStore?)
|
|
36
|
+
|
|
31
37
|
override val lifecycle: Lifecycle get() = lifecycleRegistry
|
|
32
|
-
override val viewModelStore: ViewModelStore
|
|
38
|
+
override val viewModelStore: ViewModelStore
|
|
39
|
+
get() {
|
|
40
|
+
ensureViewModelStore()
|
|
41
|
+
return checkNotNull(_viewModelStore)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
private fun ensureViewModelStore() {
|
|
45
|
+
if (_viewModelStore == null) {
|
|
46
|
+
_viewModelStore = (lastNonConfigurationInstance as? NonConfigurationInstances)?.viewModelStore
|
|
47
|
+
?: ViewModelStore()
|
|
48
|
+
}
|
|
49
|
+
}
|
|
33
50
|
override val savedStateRegistry: SavedStateRegistry get() = savedStateRegistryController.savedStateRegistry
|
|
34
51
|
override val defaultViewModelProviderFactory = SavedStateViewModelFactory()
|
|
35
52
|
override val defaultViewModelCreationExtras: CreationExtras
|
|
@@ -40,18 +57,53 @@ open class ComponentActivity : Activity(), LifecycleOwner, ViewModelStoreOwner,
|
|
|
40
57
|
|
|
41
58
|
init {
|
|
42
59
|
lifecycleRegistry.addObserver(LifecycleEventObserver { _, event ->
|
|
43
|
-
if (event == Lifecycle.Event.ON_DESTROY) viewModelStore.clear()
|
|
60
|
+
if (event == Lifecycle.Event.ON_DESTROY && !isChangingConfigurations) viewModelStore.clear()
|
|
44
61
|
})
|
|
45
62
|
savedStateRegistryController.performAttach()
|
|
46
63
|
enableSavedStateHandles()
|
|
47
64
|
}
|
|
48
65
|
|
|
49
66
|
override fun onCreate(savedInstanceState: Bundle?) {
|
|
50
|
-
savedStateRegistryController.performRestore(
|
|
67
|
+
savedStateRegistryController.performRestore(savedInstanceState?.state)
|
|
51
68
|
super.onCreate(savedInstanceState)
|
|
52
69
|
}
|
|
53
70
|
|
|
71
|
+
@Suppress("DEPRECATION")
|
|
72
|
+
final override fun onRetainNonConfigurationInstance(): Any? {
|
|
73
|
+
val custom = onRetainCustomNonConfigurationInstance()
|
|
74
|
+
val viewModelStore = _viewModelStore
|
|
75
|
+
?: (lastNonConfigurationInstance as? NonConfigurationInstances)?.viewModelStore
|
|
76
|
+
if (viewModelStore == null && custom == null) return null
|
|
77
|
+
return NonConfigurationInstances(custom, viewModelStore)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
@Deprecated("Use a ViewModel to store non config state.")
|
|
81
|
+
open fun onRetainCustomNonConfigurationInstance(): Any? = null
|
|
82
|
+
|
|
83
|
+
@Deprecated("Use a ViewModel to store non config state.")
|
|
84
|
+
open val lastCustomNonConfigurationInstance: Any?
|
|
85
|
+
get() = (lastNonConfigurationInstance as? NonConfigurationInstances)?.custom
|
|
86
|
+
|
|
87
|
+
override fun onSaveInstanceState(outState: Bundle) {
|
|
88
|
+
lifecycleRegistry.currentState = Lifecycle.State.CREATED
|
|
89
|
+
super.onSaveInstanceState(outState)
|
|
90
|
+
savedStateRegistryController.performSave(outState.state)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// the dispatcher gets the back first; without an enabled callback it falls
|
|
94
|
+
// back to Activity's own
|
|
95
|
+
override fun onBackPressed() {
|
|
96
|
+
onBackPressedDispatcher.onBackPressed()
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
final override val onBackPressedDispatcher: OnBackPressedDispatcher by lazy {
|
|
100
|
+
OnBackPressedDispatcher { super@ComponentActivity.onBackPressed() }
|
|
101
|
+
}
|
|
102
|
+
|
|
54
103
|
override fun dispatchActivityPostCreated() = lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_CREATE)
|
|
55
104
|
override fun dispatchActivityPostStarted() = lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_START)
|
|
56
105
|
override fun dispatchActivityPostResumed() = lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_RESUME)
|
|
106
|
+
override fun dispatchActivityPrePaused() = lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_PAUSE)
|
|
107
|
+
override fun dispatchActivityPreStopped() = lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_STOP)
|
|
108
|
+
override fun dispatchActivityPreDestroyed() = lifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_DESTROY)
|
|
57
109
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
package androidx.activity
|
|
2
|
+
|
|
3
|
+
// androidx.activity 1.9.3's OnBackPressedCallback
|
|
4
|
+
abstract class OnBackPressedCallback(enabled: Boolean) {
|
|
5
|
+
var isEnabled: Boolean = enabled
|
|
6
|
+
set(value) {
|
|
7
|
+
field = value
|
|
8
|
+
enabledChangedCallback?.invoke()
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
private val cancellables = mutableListOf<Cancellable>()
|
|
12
|
+
internal var enabledChangedCallback: (() -> Unit)? = null
|
|
13
|
+
|
|
14
|
+
fun remove() = cancellables.toList().forEach { it.cancel() }
|
|
15
|
+
|
|
16
|
+
open fun handleOnBackStarted(backEvent: BackEventCompat) {}
|
|
17
|
+
open fun handleOnBackProgressed(backEvent: BackEventCompat) {}
|
|
18
|
+
abstract fun handleOnBackPressed()
|
|
19
|
+
open fun handleOnBackCancelled() {}
|
|
20
|
+
|
|
21
|
+
internal fun addCancellable(cancellable: Cancellable) {
|
|
22
|
+
cancellables.add(cancellable)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
internal fun removeCancellable(cancellable: Cancellable) {
|
|
26
|
+
cancellables.remove(cancellable)
|
|
27
|
+
}
|
|
28
|
+
}
|