@solidnative-dev/cli 0.0.0-stage → 0.1.0-beta.0
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/LICENSE +21 -0
- package/README.md +841 -2
- package/dist/android-apk-signing.d.ts +36 -0
- package/dist/android-apk-signing.d.ts.map +1 -0
- package/dist/android-apk-signing.js +292 -0
- package/dist/android-apk-signing.js.map +1 -0
- package/dist/android-bundle-signing.d.ts +34 -0
- package/dist/android-bundle-signing.d.ts.map +1 -0
- package/dist/android-bundle-signing.js +167 -0
- package/dist/android-bundle-signing.js.map +1 -0
- package/dist/android-causal-debug.d.ts +38 -0
- package/dist/android-causal-debug.d.ts.map +1 -0
- package/dist/android-causal-debug.js +239 -0
- package/dist/android-causal-debug.js.map +1 -0
- package/dist/android-device-proof.d.ts +58 -0
- package/dist/android-device-proof.d.ts.map +1 -0
- package/dist/android-device-proof.js +554 -0
- package/dist/android-device-proof.js.map +1 -0
- package/dist/android-logs.d.ts +50 -0
- package/dist/android-logs.d.ts.map +1 -0
- package/dist/android-logs.js +253 -0
- package/dist/android-logs.js.map +1 -0
- package/dist/android-release-signing.d.ts +12 -0
- package/dist/android-release-signing.d.ts.map +1 -0
- package/dist/android-release-signing.js +165 -0
- package/dist/android-release-signing.js.map +1 -0
- package/dist/android-run-lease.d.ts +15 -0
- package/dist/android-run-lease.d.ts.map +1 -0
- package/dist/android-run-lease.js +333 -0
- package/dist/android-run-lease.js.map +1 -0
- package/dist/android-run-preflight.d.ts +45 -0
- package/dist/android-run-preflight.d.ts.map +1 -0
- package/dist/android-run-preflight.js +183 -0
- package/dist/android-run-preflight.js.map +1 -0
- package/dist/android-signing-shared.d.ts +38 -0
- package/dist/android-signing-shared.d.ts.map +1 -0
- package/dist/android-signing-shared.js +210 -0
- package/dist/android-signing-shared.js.map +1 -0
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +4530 -0
- package/dist/bin.js.map +1 -0
- package/dist/bundle-artifacts.d.ts +48 -0
- package/dist/bundle-artifacts.d.ts.map +1 -0
- package/dist/bundle-artifacts.js +427 -0
- package/dist/bundle-artifacts.js.map +1 -0
- package/dist/causal-debug-compare.d.ts +81 -0
- package/dist/causal-debug-compare.d.ts.map +1 -0
- package/dist/causal-debug-compare.js +238 -0
- package/dist/causal-debug-compare.js.map +1 -0
- package/dist/causal-debug-report.d.ts +33 -0
- package/dist/causal-debug-report.d.ts.map +1 -0
- package/dist/causal-debug-report.js +979 -0
- package/dist/causal-debug-report.js.map +1 -0
- package/dist/causal-debug-watch.d.ts +33 -0
- package/dist/causal-debug-watch.d.ts.map +1 -0
- package/dist/causal-debug-watch.js +92 -0
- package/dist/causal-debug-watch.js.map +1 -0
- package/dist/causal-debug.d.ts +131 -0
- package/dist/causal-debug.d.ts.map +1 -0
- package/dist/causal-debug.js +503 -0
- package/dist/causal-debug.js.map +1 -0
- package/dist/compatibility-catalog.d.ts +88 -0
- package/dist/compatibility-catalog.d.ts.map +1 -0
- package/dist/compatibility-catalog.js +344 -0
- package/dist/compatibility-catalog.js.map +1 -0
- package/dist/deep-link.d.ts +90 -0
- package/dist/deep-link.d.ts.map +1 -0
- package/dist/deep-link.js +346 -0
- package/dist/deep-link.js.map +1 -0
- package/dist/device-proof-signatures.d.ts +307 -0
- package/dist/device-proof-signatures.d.ts.map +1 -0
- package/dist/device-proof-signatures.js +1024 -0
- package/dist/device-proof-signatures.js.map +1 -0
- package/dist/fingerprint.d.ts +35 -0
- package/dist/fingerprint.d.ts.map +1 -0
- package/dist/fingerprint.js +454 -0
- package/dist/fingerprint.js.map +1 -0
- package/dist/index.d.ts +388 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2996 -0
- package/dist/index.js.map +1 -0
- package/dist/ios-causal-debug.d.ts +39 -0
- package/dist/ios-causal-debug.d.ts.map +1 -0
- package/dist/ios-causal-debug.js +318 -0
- package/dist/ios-causal-debug.js.map +1 -0
- package/dist/ios-logs.d.ts +58 -0
- package/dist/ios-logs.d.ts.map +1 -0
- package/dist/ios-logs.js +269 -0
- package/dist/ios-logs.js.map +1 -0
- package/dist/ios-process.d.ts +69 -0
- package/dist/ios-process.d.ts.map +1 -0
- package/dist/ios-process.js +389 -0
- package/dist/ios-process.js.map +1 -0
- package/dist/ios-run-preflight.d.ts +35 -0
- package/dist/ios-run-preflight.d.ts.map +1 -0
- package/dist/ios-run-preflight.js +172 -0
- package/dist/ios-run-preflight.js.map +1 -0
- package/dist/live-causal-debug-report.d.ts +49 -0
- package/dist/live-causal-debug-report.d.ts.map +1 -0
- package/dist/live-causal-debug-report.js +123 -0
- package/dist/live-causal-debug-report.js.map +1 -0
- package/dist/local-symbolication.d.ts +35 -0
- package/dist/local-symbolication.d.ts.map +1 -0
- package/dist/local-symbolication.js +89 -0
- package/dist/local-symbolication.js.map +1 -0
- package/dist/native-archive.d.ts +15 -0
- package/dist/native-archive.d.ts.map +1 -0
- package/dist/native-archive.js +441 -0
- package/dist/native-archive.js.map +1 -0
- package/dist/native-test.d.ts +43 -0
- package/dist/native-test.d.ts.map +1 -0
- package/dist/native-test.js +209 -0
- package/dist/native-test.js.map +1 -0
- package/dist/package-add.d.ts +56 -0
- package/dist/package-add.d.ts.map +1 -0
- package/dist/package-add.js +764 -0
- package/dist/package-add.js.map +1 -0
- package/dist/react-native-upgrade.d.ts +96 -0
- package/dist/react-native-upgrade.d.ts.map +1 -0
- package/dist/react-native-upgrade.js +882 -0
- package/dist/react-native-upgrade.js.map +1 -0
- package/dist/release-device-correlation.d.ts +40 -0
- package/dist/release-device-correlation.d.ts.map +1 -0
- package/dist/release-device-correlation.js +113 -0
- package/dist/release-device-correlation.js.map +1 -0
- package/dist/release-signatures.d.ts +168 -0
- package/dist/release-signatures.d.ts.map +1 -0
- package/dist/release-signatures.js +677 -0
- package/dist/release-signatures.js.map +1 -0
- package/dist/release.d.ts +88 -0
- package/dist/release.d.ts.map +1 -0
- package/dist/release.js +771 -0
- package/dist/release.js.map +1 -0
- package/dist/signature-utilities.d.ts +16 -0
- package/dist/signature-utilities.d.ts.map +1 -0
- package/dist/signature-utilities.js +114 -0
- package/dist/signature-utilities.js.map +1 -0
- package/dist/solid-diagnostics-correlation.d.ts +11 -0
- package/dist/solid-diagnostics-correlation.d.ts.map +1 -0
- package/dist/solid-diagnostics-correlation.js +78 -0
- package/dist/solid-diagnostics-correlation.js.map +1 -0
- package/dist/solid-diagnostics-debug.d.ts +15 -0
- package/dist/solid-diagnostics-debug.d.ts.map +1 -0
- package/dist/solid-diagnostics-debug.js +93 -0
- package/dist/solid-diagnostics-debug.js.map +1 -0
- package/dist/solid-diagnostics-inspection.d.ts +41 -0
- package/dist/solid-diagnostics-inspection.d.ts.map +1 -0
- package/dist/solid-diagnostics-inspection.js +196 -0
- package/dist/solid-diagnostics-inspection.js.map +1 -0
- package/dist/source-map.d.ts +36 -0
- package/dist/source-map.d.ts.map +1 -0
- package/dist/source-map.js +488 -0
- package/dist/source-map.js.map +1 -0
- package/dist/stack-symbolication.d.ts +56 -0
- package/dist/stack-symbolication.d.ts.map +1 -0
- package/dist/stack-symbolication.js +310 -0
- package/dist/stack-symbolication.js.map +1 -0
- package/dist/symbolication.d.ts +27 -0
- package/dist/symbolication.d.ts.map +1 -0
- package/dist/symbolication.js +75 -0
- package/dist/symbolication.js.map +1 -0
- package/dist/tree-debug.d.ts +53 -0
- package/dist/tree-debug.d.ts.map +1 -0
- package/dist/tree-debug.js +283 -0
- package/dist/tree-debug.js.map +1 -0
- package/dist/versions.d.ts +13 -0
- package/dist/versions.d.ts.map +1 -0
- package/dist/versions.js +14 -0
- package/dist/versions.js.map +1 -0
- package/package.json +46 -3
- package/templates/react-native-0.88/README.md +328 -0
- package/templates/react-native-0.88/android/CMakeLists.txt +27 -0
- package/templates/react-native-0.88/android/MainActivity.kt +123 -0
- package/templates/react-native-0.88/android/MainApplication.kt +43 -0
- package/templates/react-native-0.88/android/OnLoad.cpp +60 -0
- package/templates/react-native-0.88/index.js +1 -0
- package/templates/react-native-0.88/ios/AppDelegate.swift +190 -0
- package/templates/react-native-0.88/metro.config.js +16 -0
- package/templates/react-native-0.88/specs/NativeSolidNativeDebug.ts +16 -0
- package/templates/react-native-0.88/specs/NativeSolidNativePlatformAndroid.ts +14 -0
- package/templates/react-native-0.88/src/App.tsx +161 -0
- package/templates/react-native-0.88/src/main.tsx +88 -0
- package/templates/react-native-0.88/test/App.test.tsx +152 -0
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import UIKit
|
|
2
|
+
import React
|
|
3
|
+
import React_RCTAppDelegate
|
|
4
|
+
import ReactAppDependencyProvider
|
|
5
|
+
import SolidNativeFabric
|
|
6
|
+
|
|
7
|
+
@main
|
|
8
|
+
class AppDelegate: UIResponder, UIApplicationDelegate {
|
|
9
|
+
var window: UIWindow?
|
|
10
|
+
|
|
11
|
+
private var reactNativeDelegate: ReactNativeDelegate?
|
|
12
|
+
private var reactNativeFactory: RCTReactNativeFactory?
|
|
13
|
+
private var solidNativeApplication: SolidNativeFabricApplication?
|
|
14
|
+
private var pendingLaunchOptions: [UIApplication.LaunchOptionsKey: Any]?
|
|
15
|
+
private var pendingLaunchURL: URL?
|
|
16
|
+
|
|
17
|
+
func application(
|
|
18
|
+
_ application: UIApplication,
|
|
19
|
+
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
|
|
20
|
+
) -> Bool {
|
|
21
|
+
pendingLaunchOptions = launchOptions
|
|
22
|
+
return true
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
func connectScene(
|
|
26
|
+
_ scene: UIWindowScene,
|
|
27
|
+
options: UIScene.ConnectionOptions
|
|
28
|
+
) -> UIWindow? {
|
|
29
|
+
guard window == nil else { return nil }
|
|
30
|
+
var runtimeLaunchOptions = pendingLaunchOptions ?? [:]
|
|
31
|
+
if let context = options.urlContexts.first {
|
|
32
|
+
runtimeLaunchOptions[.url] = context.url
|
|
33
|
+
runtimeLaunchOptions[.sourceApplication] = context.options.sourceApplication
|
|
34
|
+
runtimeLaunchOptions[.annotation] = context.options.annotation
|
|
35
|
+
} else if let activity = options.userActivities.first(where: {
|
|
36
|
+
$0.activityType == NSUserActivityTypeBrowsingWeb && $0.webpageURL != nil
|
|
37
|
+
}) {
|
|
38
|
+
runtimeLaunchOptions[.url] = activity.webpageURL
|
|
39
|
+
}
|
|
40
|
+
if let requestURL = runtimeLaunchOptions[.url] as? URL,
|
|
41
|
+
SolidNativeDebugRequest.handle(url: requestURL)
|
|
42
|
+
{
|
|
43
|
+
runtimeLaunchOptions.removeValue(forKey: .url)
|
|
44
|
+
}
|
|
45
|
+
let delegate = ReactNativeDelegate()
|
|
46
|
+
delegate.dependencyProvider = RCTAppDependencyProvider()
|
|
47
|
+
let factory = RCTReactNativeFactory(delegate: delegate)
|
|
48
|
+
reactNativeDelegate = delegate
|
|
49
|
+
reactNativeFactory = factory
|
|
50
|
+
|
|
51
|
+
let window = UIWindow(windowScene: scene)
|
|
52
|
+
self.window = window
|
|
53
|
+
let controller = SolidNativeRootViewController()
|
|
54
|
+
controller.view.backgroundColor = .systemBackground
|
|
55
|
+
window.rootViewController = controller
|
|
56
|
+
window.makeKeyAndVisible()
|
|
57
|
+
pendingLaunchOptions = runtimeLaunchOptions
|
|
58
|
+
return window
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
func activateScene(_ scene: UIScene) {
|
|
62
|
+
guard window?.windowScene === scene else { return }
|
|
63
|
+
startSolidApplicationIfNeeded()
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
func disconnectScene(_ scene: UIScene) {
|
|
67
|
+
guard window?.windowScene === scene else { return }
|
|
68
|
+
solidNativeApplication?.stop()
|
|
69
|
+
solidNativeApplication = nil
|
|
70
|
+
reactNativeFactory = nil
|
|
71
|
+
reactNativeDelegate = nil
|
|
72
|
+
pendingLaunchOptions = nil
|
|
73
|
+
pendingLaunchURL = nil
|
|
74
|
+
window = nil
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
func application(
|
|
78
|
+
_ application: UIApplication,
|
|
79
|
+
open url: URL,
|
|
80
|
+
options: [UIApplication.OpenURLOptionsKey: Any] = [:]
|
|
81
|
+
) -> Bool {
|
|
82
|
+
if SolidNativeDebugRequest.handle(url: url) {
|
|
83
|
+
return true
|
|
84
|
+
}
|
|
85
|
+
if solidNativeApplication == nil {
|
|
86
|
+
pendingLaunchURL = url
|
|
87
|
+
return true
|
|
88
|
+
}
|
|
89
|
+
return RCTLinkingManager.application(application, open: url, options: options)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
func applicationWillTerminate(_ application: UIApplication) {
|
|
93
|
+
solidNativeApplication?.stop()
|
|
94
|
+
solidNativeApplication = nil
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
private func startSolidApplicationIfNeeded() {
|
|
98
|
+
guard solidNativeApplication == nil,
|
|
99
|
+
let factory = reactNativeFactory,
|
|
100
|
+
let containerView = window?.rootViewController?.view
|
|
101
|
+
else { return }
|
|
102
|
+
|
|
103
|
+
var launchOptions = pendingLaunchOptions ?? [:]
|
|
104
|
+
if let pendingLaunchURL {
|
|
105
|
+
launchOptions[.url] = pendingLaunchURL
|
|
106
|
+
}
|
|
107
|
+
pendingLaunchOptions = nil
|
|
108
|
+
pendingLaunchURL = nil
|
|
109
|
+
solidNativeApplication = SolidNativeFabricApplication.start(
|
|
110
|
+
withFactory: factory,
|
|
111
|
+
containerView: containerView,
|
|
112
|
+
launchOptions: launchOptions.isEmpty ? nil : launchOptions
|
|
113
|
+
) { status, error in
|
|
114
|
+
if let error {
|
|
115
|
+
NSLog("SOLID_NATIVE_%@: %@", status.uppercased(), error.localizedDescription)
|
|
116
|
+
if status.hasSuffix("-failed") {
|
|
117
|
+
SolidNativeStartupFailureView.show(in: containerView, error: error)
|
|
118
|
+
}
|
|
119
|
+
} else {
|
|
120
|
+
NSLog("SOLID_NATIVE_%@", status.uppercased())
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// One scene owns one native application. Backgrounding retains it; disconnecting
|
|
127
|
+
// releases the surface and runtime before a later scene connection can restart.
|
|
128
|
+
class SolidNativeSceneDelegate: UIResponder, UIWindowSceneDelegate {
|
|
129
|
+
var window: UIWindow?
|
|
130
|
+
|
|
131
|
+
private var applicationDelegate: AppDelegate? {
|
|
132
|
+
UIApplication.shared.delegate as? AppDelegate
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
func scene(
|
|
136
|
+
_ scene: UIScene,
|
|
137
|
+
willConnectTo session: UISceneSession,
|
|
138
|
+
options connectionOptions: UIScene.ConnectionOptions
|
|
139
|
+
) {
|
|
140
|
+
guard session.role == .windowApplication,
|
|
141
|
+
let windowScene = scene as? UIWindowScene
|
|
142
|
+
else { return }
|
|
143
|
+
window = applicationDelegate?.connectScene(windowScene, options: connectionOptions)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
func sceneDidBecomeActive(_ scene: UIScene) {
|
|
147
|
+
applicationDelegate?.activateScene(scene)
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
func sceneDidDisconnect(_ scene: UIScene) {
|
|
151
|
+
applicationDelegate?.disconnectScene(scene)
|
|
152
|
+
window = nil
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
func scene(_ scene: UIScene, openURLContexts contexts: Set<UIOpenURLContext>) {
|
|
156
|
+
guard window?.windowScene === scene else { return }
|
|
157
|
+
for context in contexts {
|
|
158
|
+
var options: [UIApplication.OpenURLOptionsKey: Any] = [
|
|
159
|
+
.openInPlace: context.options.openInPlace
|
|
160
|
+
]
|
|
161
|
+
options[.sourceApplication] = context.options.sourceApplication
|
|
162
|
+
options[.annotation] = context.options.annotation
|
|
163
|
+
_ = applicationDelegate?.application(
|
|
164
|
+
UIApplication.shared, open: context.url, options: options
|
|
165
|
+
)
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
|
|
170
|
+
guard window?.windowScene === scene,
|
|
171
|
+
userActivity.activityType == NSUserActivityTypeBrowsingWeb,
|
|
172
|
+
let url = userActivity.webpageURL
|
|
173
|
+
else { return }
|
|
174
|
+
_ = applicationDelegate?.application(UIApplication.shared, open: url)
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
private final class ReactNativeDelegate: RCTDefaultReactNativeFactoryDelegate {
|
|
179
|
+
override func sourceURL(for bridge: RCTBridge) -> URL? {
|
|
180
|
+
bundleURL()
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
override func bundleURL() -> URL? {
|
|
184
|
+
#if DEBUG
|
|
185
|
+
RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index")
|
|
186
|
+
#else
|
|
187
|
+
Bundle.main.url(forResource: "main", withExtension: "jsbundle")
|
|
188
|
+
#endif
|
|
189
|
+
}
|
|
190
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
const { getDefaultConfig, mergeConfig } = require("@react-native/metro-config");
|
|
2
|
+
const {
|
|
3
|
+
createSolidNativeFullReloadPattern,
|
|
4
|
+
createSolidNativeMetroResolver,
|
|
5
|
+
solidNativeTransformWorkerPath,
|
|
6
|
+
} = require("@solidnative-dev/metro");
|
|
7
|
+
|
|
8
|
+
module.exports = mergeConfig(getDefaultConfig(__dirname), {
|
|
9
|
+
transformerPath: solidNativeTransformWorkerPath,
|
|
10
|
+
resolver: {
|
|
11
|
+
resolveRequest: createSolidNativeMetroResolver(__dirname),
|
|
12
|
+
unstable_forceFullRefreshPatterns: [
|
|
13
|
+
createSolidNativeFullReloadPattern(__dirname),
|
|
14
|
+
],
|
|
15
|
+
},
|
|
16
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CodegenTypes, TurboModule } from "react-native";
|
|
2
|
+
import { TurboModuleRegistry } from "react-native";
|
|
3
|
+
|
|
4
|
+
export type NativeDebugRequest = {
|
|
5
|
+
requestId: string;
|
|
6
|
+
operation: string;
|
|
7
|
+
sessionId?: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export interface Spec extends TurboModule {
|
|
11
|
+
readonly onSnapshotRequest: CodegenTypes.EventEmitter<NativeDebugRequest>;
|
|
12
|
+
setSnapshotListenerReady(ready: boolean): void;
|
|
13
|
+
publishSnapshot(requestId: string, payload: string): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default TurboModuleRegistry.getEnforcing<Spec>("SolidNativeDebug");
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CodegenTypes, TurboModule } from "react-native";
|
|
2
|
+
import { TurboModuleRegistry } from "react-native";
|
|
3
|
+
|
|
4
|
+
export type MemoryWarningEvent = {
|
|
5
|
+
level: CodegenTypes.Int32;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export interface Spec extends TurboModule {
|
|
9
|
+
readonly onMemoryWarning: CodegenTypes.EventEmitter<MemoryWarningEvent>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default TurboModuleRegistry.getEnforcing<Spec>(
|
|
13
|
+
"SolidNativePlatformAndroid",
|
|
14
|
+
);
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/** @jsxImportSource @solidnative-dev/core */
|
|
2
|
+
import { createUIWorkletGraph } from "@solidnative-dev/animation";
|
|
3
|
+
import { createNativeViewAnimation } from "@solidnative-dev/animation/native";
|
|
4
|
+
import { Button, StyleSheet, Text, View } from "@solidnative-dev/core";
|
|
5
|
+
import type {
|
|
6
|
+
NetworkService,
|
|
7
|
+
NetworkTextRequestHandle,
|
|
8
|
+
} from "@solidnative-dev/networking";
|
|
9
|
+
import { createNetworkController } from "@solidnative-dev/networking/solid";
|
|
10
|
+
import { createSignal } from "solid-js";
|
|
11
|
+
|
|
12
|
+
const STARTER_NETWORK_URL = "https://example.com/";
|
|
13
|
+
|
|
14
|
+
export interface AppProps {
|
|
15
|
+
readonly network: NetworkService;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const cardGraph = createUIWorkletGraph(
|
|
19
|
+
{ progress: 0 },
|
|
20
|
+
({ progress }, { interpolate }) => ({
|
|
21
|
+
translateY: interpolate(progress, [0, 1], [0, -16]),
|
|
22
|
+
scaleX: interpolate(progress, [0, 1], [1, 1.04]),
|
|
23
|
+
scaleY: interpolate(progress, [0, 1], [1, 1.04]),
|
|
24
|
+
rotation: interpolate(progress, [0, 1], [0, -2]),
|
|
25
|
+
}),
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
const styles = StyleSheet.create({
|
|
29
|
+
root: {
|
|
30
|
+
alignItems: "center",
|
|
31
|
+
backgroundColor: "#f7f8fa",
|
|
32
|
+
flex: 1,
|
|
33
|
+
gap: 20,
|
|
34
|
+
justifyContent: "center",
|
|
35
|
+
padding: 24,
|
|
36
|
+
},
|
|
37
|
+
heading: { color: "#111827", fontSize: 30 },
|
|
38
|
+
description: { color: "#4b5563", fontSize: 17, textAlign: "center" },
|
|
39
|
+
card: {
|
|
40
|
+
backgroundColor: "#dbeafe",
|
|
41
|
+
borderRadius: 14,
|
|
42
|
+
paddingHorizontal: 22,
|
|
43
|
+
paddingVertical: 18,
|
|
44
|
+
},
|
|
45
|
+
cardText: { color: "#1e3a8a", fontSize: 17 },
|
|
46
|
+
button: {
|
|
47
|
+
borderRadius: 10,
|
|
48
|
+
paddingHorizontal: 20,
|
|
49
|
+
paddingVertical: 14,
|
|
50
|
+
},
|
|
51
|
+
buttonText: { color: "#ffffff", fontSize: 17, margin: 0 },
|
|
52
|
+
count: { color: "#374151", fontSize: 16 },
|
|
53
|
+
status: { color: "#4b5563", fontSize: 15, textAlign: "center" },
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
export function App(props: AppProps) {
|
|
57
|
+
const [count, setCount] = createSignal(0, { name: "starter.press-count" });
|
|
58
|
+
const [networkStatus, setNetworkStatus] = createSignal(
|
|
59
|
+
"Native network check not started.",
|
|
60
|
+
{ name: "starter.network-status" },
|
|
61
|
+
);
|
|
62
|
+
const [raised, setRaised] = createSignal(false, {
|
|
63
|
+
name: "starter.card-raised",
|
|
64
|
+
});
|
|
65
|
+
const cardAnimation = createNativeViewAnimation(cardGraph);
|
|
66
|
+
const network = createNetworkController(props.network);
|
|
67
|
+
let activeRequest: NetworkTextRequestHandle | undefined;
|
|
68
|
+
|
|
69
|
+
const toggleCard = async (): Promise<void> => {
|
|
70
|
+
if (!(await cardAnimation.ready)) return;
|
|
71
|
+
const next = !raised();
|
|
72
|
+
cardAnimation.animate(
|
|
73
|
+
{ progress: next ? 1 : 0 },
|
|
74
|
+
{ durationMilliseconds: 240, easing: "ease-in-out" },
|
|
75
|
+
);
|
|
76
|
+
setRaised(next);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const checkNativeNetwork = (): void => {
|
|
80
|
+
activeRequest?.cancel();
|
|
81
|
+
setNetworkStatus("Starting bounded native request…");
|
|
82
|
+
const request = network.requestText(
|
|
83
|
+
{
|
|
84
|
+
url: STARTER_NETWORK_URL,
|
|
85
|
+
headers: { Accept: "text/html" },
|
|
86
|
+
timeoutMilliseconds: 10_000,
|
|
87
|
+
maxResponseCharacters: 131_072,
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
onResponse(response) {
|
|
91
|
+
setNetworkStatus(
|
|
92
|
+
`Native response status: ${String(response.status)}`,
|
|
93
|
+
);
|
|
94
|
+
},
|
|
95
|
+
onChunk(chunk) {
|
|
96
|
+
setNetworkStatus(
|
|
97
|
+
`Native chunk ${String(chunk.sequence)}: ${String(chunk.text.length)} characters`,
|
|
98
|
+
);
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
);
|
|
102
|
+
activeRequest = request;
|
|
103
|
+
void request.result.then(
|
|
104
|
+
() => {
|
|
105
|
+
if (activeRequest === request) activeRequest = undefined;
|
|
106
|
+
},
|
|
107
|
+
() => {
|
|
108
|
+
if (activeRequest !== request) return;
|
|
109
|
+
activeRequest = undefined;
|
|
110
|
+
setNetworkStatus("Native request failed or was cancelled.");
|
|
111
|
+
},
|
|
112
|
+
);
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
return (
|
|
116
|
+
<View style={styles.root}>
|
|
117
|
+
<Text accessibilityRole="header" style={styles.heading}>
|
|
118
|
+
{__APP_TITLE_LITERAL__}
|
|
119
|
+
</Text>
|
|
120
|
+
<Text style={styles.description}>
|
|
121
|
+
Solid owns this native Fabric tree directly.
|
|
122
|
+
</Text>
|
|
123
|
+
<View ref={cardAnimation.ref} style={styles.card}>
|
|
124
|
+
<Text style={styles.cardText}>
|
|
125
|
+
Typed graph, native UI-thread frames
|
|
126
|
+
</Text>
|
|
127
|
+
</View>
|
|
128
|
+
<Button
|
|
129
|
+
accessibilityLabel="Toggle native animation"
|
|
130
|
+
onPress={toggleCard}
|
|
131
|
+
title={raised() ? "Lower native card" : "Lift native card"}
|
|
132
|
+
style={[styles.button, { backgroundColor: "#0f766e" }]}
|
|
133
|
+
textStyle={styles.buttonText}
|
|
134
|
+
/>
|
|
135
|
+
<Button
|
|
136
|
+
accessibilityLabel="Increment counter"
|
|
137
|
+
onPress={() => setCount((value) => value + 1)}
|
|
138
|
+
title="Increment count"
|
|
139
|
+
style={[styles.button, { backgroundColor: "#2563eb" }]}
|
|
140
|
+
textStyle={styles.buttonText}
|
|
141
|
+
/>
|
|
142
|
+
<Text
|
|
143
|
+
accessibilityLabel={`Press count: ${count()}`}
|
|
144
|
+
accessibilityLiveRegion="polite"
|
|
145
|
+
style={styles.count}
|
|
146
|
+
>
|
|
147
|
+
{"Press count: " + String(count())}
|
|
148
|
+
</Text>
|
|
149
|
+
<Button
|
|
150
|
+
accessibilityLabel="Check native network"
|
|
151
|
+
onPress={checkNativeNetwork}
|
|
152
|
+
title="Check native network"
|
|
153
|
+
style={[styles.button, { backgroundColor: "#7c3aed" }]}
|
|
154
|
+
textStyle={styles.buttonText}
|
|
155
|
+
/>
|
|
156
|
+
<Text accessibilityLiveRegion="polite" style={styles.status}>
|
|
157
|
+
{networkStatus()}
|
|
158
|
+
</Text>
|
|
159
|
+
</View>
|
|
160
|
+
);
|
|
161
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/** @jsxImportSource @solidnative-dev/core */
|
|
2
|
+
import "react-native/setup-env";
|
|
3
|
+
|
|
4
|
+
import { CORE_COMPONENT_DESCRIPTORS } from "@solidnative-dev/core";
|
|
5
|
+
import { createInspectableNetworkService } from "@solidnative-dev/devtools/network-service";
|
|
6
|
+
import { DevelopmentRoot } from "@solidnative-dev/devtools/root";
|
|
7
|
+
import { createDevelopmentSolidDiagnosticsController } from "@solidnative-dev/devtools/solid-diagnostics";
|
|
8
|
+
import { createReactNativeNetworkService } from "@solidnative-dev/networking/react-native";
|
|
9
|
+
import {
|
|
10
|
+
createCausalTelemetry,
|
|
11
|
+
createCausalTimeline,
|
|
12
|
+
} from "@solidnative-dev/observability";
|
|
13
|
+
import {
|
|
14
|
+
getNativeHostBinding,
|
|
15
|
+
startNativeApplication,
|
|
16
|
+
} from "@solidnative-dev/runtime";
|
|
17
|
+
import { createReactNativeCausalDebugTransport } from "@solidnative-dev/runtime/react-native-causal-debug";
|
|
18
|
+
|
|
19
|
+
import { App } from "./App";
|
|
20
|
+
|
|
21
|
+
const binding = getNativeHostBinding();
|
|
22
|
+
const network = createInspectableNetworkService(
|
|
23
|
+
createReactNativeNetworkService(),
|
|
24
|
+
);
|
|
25
|
+
const causalTimeline = __DEV__
|
|
26
|
+
? createCausalTimeline({ capacity: 2_000 })
|
|
27
|
+
: undefined;
|
|
28
|
+
const telemetry =
|
|
29
|
+
causalTimeline === undefined
|
|
30
|
+
? undefined
|
|
31
|
+
: createCausalTelemetry({ sink: causalTimeline.sink });
|
|
32
|
+
const solidDiagnostics =
|
|
33
|
+
causalTimeline === undefined
|
|
34
|
+
? undefined
|
|
35
|
+
: createDevelopmentSolidDiagnosticsController();
|
|
36
|
+
let activeApplication:
|
|
37
|
+
Awaited<ReturnType<typeof startNativeApplication>> | undefined;
|
|
38
|
+
const snapshotTree =
|
|
39
|
+
causalTimeline === undefined
|
|
40
|
+
? undefined
|
|
41
|
+
: () =>
|
|
42
|
+
activeApplication === undefined || activeApplication.root.disposed
|
|
43
|
+
? undefined
|
|
44
|
+
: activeApplication.root.snapshotTree();
|
|
45
|
+
const measureTreeNode =
|
|
46
|
+
causalTimeline === undefined
|
|
47
|
+
? undefined
|
|
48
|
+
: (handle: number) =>
|
|
49
|
+
activeApplication === undefined || activeApplication.root.disposed
|
|
50
|
+
? undefined
|
|
51
|
+
: activeApplication.root.measureNodeByHandle(handle);
|
|
52
|
+
if (causalTimeline !== undefined) {
|
|
53
|
+
createReactNativeCausalDebugTransport(causalTimeline, {
|
|
54
|
+
reportError: (error) =>
|
|
55
|
+
console.error("Solid Native causal-debug transport failed.", error),
|
|
56
|
+
solidDiagnostics,
|
|
57
|
+
snapshotTree,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
void startNativeApplication(
|
|
62
|
+
() => (
|
|
63
|
+
<DevelopmentRoot
|
|
64
|
+
causalTimeline={causalTimeline}
|
|
65
|
+
measureTreeNode={measureTreeNode}
|
|
66
|
+
networkInspector={network.inspector}
|
|
67
|
+
snapshotTree={snapshotTree}
|
|
68
|
+
solidDiagnostics={solidDiagnostics}
|
|
69
|
+
>
|
|
70
|
+
<App network={network.service} />
|
|
71
|
+
</DevelopmentRoot>
|
|
72
|
+
),
|
|
73
|
+
{
|
|
74
|
+
binding,
|
|
75
|
+
descriptors: CORE_COMPONENT_DESCRIPTORS,
|
|
76
|
+
surface: { name: "main" },
|
|
77
|
+
telemetry,
|
|
78
|
+
},
|
|
79
|
+
)
|
|
80
|
+
.then((application) => {
|
|
81
|
+
activeApplication = application;
|
|
82
|
+
})
|
|
83
|
+
.catch((error: unknown) => {
|
|
84
|
+
console.error("Solid Native application startup failed.", error);
|
|
85
|
+
void Promise.resolve().then(() => {
|
|
86
|
+
throw error instanceof Error ? error : new Error(String(error));
|
|
87
|
+
});
|
|
88
|
+
});
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/** @jsxImportSource @solidnative-dev/core */
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import test from "node:test";
|
|
4
|
+
|
|
5
|
+
import type {
|
|
6
|
+
NetworkService,
|
|
7
|
+
NetworkTextObserver,
|
|
8
|
+
NetworkTextRequest,
|
|
9
|
+
NetworkTextResult,
|
|
10
|
+
} from "@solidnative-dev/networking";
|
|
11
|
+
import { renderNative, type NativeTestRender } from "@solidnative-dev/testing";
|
|
12
|
+
import {
|
|
13
|
+
captureNativeDiagnostics,
|
|
14
|
+
expectNativeCommitBudget,
|
|
15
|
+
expectNoDiagnostics,
|
|
16
|
+
expectNoWaste,
|
|
17
|
+
expectRerunBudget,
|
|
18
|
+
} from "@solidnative-dev/testing/diagnostics";
|
|
19
|
+
import { DEV } from "solid-js";
|
|
20
|
+
|
|
21
|
+
import { App } from "../src/App.tsx";
|
|
22
|
+
|
|
23
|
+
let capturedRequest: NetworkTextRequest | undefined;
|
|
24
|
+
let observer: NetworkTextObserver | undefined;
|
|
25
|
+
let resolveRequest!: (result: NetworkTextResult) => void;
|
|
26
|
+
let cancellationCount = 0;
|
|
27
|
+
|
|
28
|
+
const testNetwork: NetworkService = {
|
|
29
|
+
platform: "android",
|
|
30
|
+
requestText(request, nextObserver) {
|
|
31
|
+
capturedRequest = request;
|
|
32
|
+
observer = nextObserver;
|
|
33
|
+
const result = new Promise<NetworkTextResult>((resolve) => {
|
|
34
|
+
resolveRequest = resolve;
|
|
35
|
+
});
|
|
36
|
+
return {
|
|
37
|
+
result,
|
|
38
|
+
cancel() {
|
|
39
|
+
cancellationCount += 1;
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
async function exerciseApplication(screen: NativeTestRender): Promise<void> {
|
|
46
|
+
screen.getByLabelText("Press count: 0");
|
|
47
|
+
const counterCheckpoint = screen.commitCheckpoint();
|
|
48
|
+
await screen.press(screen.getByRole("button", { name: "Increment counter" }));
|
|
49
|
+
assert.equal(
|
|
50
|
+
screen.getByLabelText("Press count: 1").textContent,
|
|
51
|
+
"Press count: 1",
|
|
52
|
+
);
|
|
53
|
+
const counterCommit = screen.getCommit({
|
|
54
|
+
afterSequence: counterCheckpoint,
|
|
55
|
+
priority: "user-blocking",
|
|
56
|
+
mutationTypes: ["update-text", "update-props"],
|
|
57
|
+
});
|
|
58
|
+
assert.equal(
|
|
59
|
+
screen.getMutation({
|
|
60
|
+
type: "update-text",
|
|
61
|
+
afterSequence: counterCheckpoint,
|
|
62
|
+
}).commit.sequence,
|
|
63
|
+
counterCommit.sequence,
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
const requestCheckpoint = screen.commitCheckpoint();
|
|
67
|
+
await screen.press(
|
|
68
|
+
screen.getByRole("button", { name: "Check native network" }),
|
|
69
|
+
);
|
|
70
|
+
screen.getByText("Starting bounded native request…");
|
|
71
|
+
screen.getMutation({
|
|
72
|
+
type: "update-text",
|
|
73
|
+
afterSequence: requestCheckpoint,
|
|
74
|
+
priority: "user-blocking",
|
|
75
|
+
});
|
|
76
|
+
assert.equal(capturedRequest?.url, "https://example.com/");
|
|
77
|
+
assert.equal(capturedRequest?.maxResponseCharacters, 131_072);
|
|
78
|
+
|
|
79
|
+
const activeObserver = observer;
|
|
80
|
+
assert.ok(activeObserver);
|
|
81
|
+
const response = {
|
|
82
|
+
status: 200,
|
|
83
|
+
url: "https://example.com/",
|
|
84
|
+
headers: { "content-type": "text/plain" },
|
|
85
|
+
};
|
|
86
|
+
const responseCheckpoint = screen.commitCheckpoint();
|
|
87
|
+
const responseVisible = screen.findByText("Native response status: 200");
|
|
88
|
+
queueMicrotask(() => activeObserver.onResponse?.(response));
|
|
89
|
+
await responseVisible;
|
|
90
|
+
screen.getMutation({
|
|
91
|
+
type: "update-text",
|
|
92
|
+
afterSequence: responseCheckpoint,
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
const chunkCheckpoint = screen.commitCheckpoint();
|
|
96
|
+
const chunkVisible = screen.findByText("Native chunk 1: 12 characters");
|
|
97
|
+
queueMicrotask(() =>
|
|
98
|
+
activeObserver.onChunk?.({
|
|
99
|
+
sequence: 1,
|
|
100
|
+
text: "hello native",
|
|
101
|
+
loaded: 12,
|
|
102
|
+
total: 12,
|
|
103
|
+
}),
|
|
104
|
+
);
|
|
105
|
+
await chunkVisible;
|
|
106
|
+
screen.getMutation({
|
|
107
|
+
type: "update-text",
|
|
108
|
+
afterSequence: chunkCheckpoint,
|
|
109
|
+
});
|
|
110
|
+
resolveRequest({
|
|
111
|
+
response,
|
|
112
|
+
chunkCount: 1,
|
|
113
|
+
receivedCharacters: 12,
|
|
114
|
+
});
|
|
115
|
+
await Promise.resolve();
|
|
116
|
+
await Promise.resolve();
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
test("updates and streams through the Solid-owned native application", async () => {
|
|
120
|
+
if (DEV === undefined) {
|
|
121
|
+
const screen = await renderNative(() => <App network={testNetwork} />);
|
|
122
|
+
try {
|
|
123
|
+
await exerciseApplication(screen);
|
|
124
|
+
} finally {
|
|
125
|
+
await screen.cleanup();
|
|
126
|
+
}
|
|
127
|
+
assert.equal(cancellationCount, 0);
|
|
128
|
+
screen.assertDisposed();
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const { artifact, result: screen } = await captureNativeDiagnostics(
|
|
133
|
+
async ({ render }) => {
|
|
134
|
+
const rendered = await render(() => <App network={testNetwork} />);
|
|
135
|
+
await exerciseApplication(rendered);
|
|
136
|
+
return rendered;
|
|
137
|
+
},
|
|
138
|
+
{ scenario: "starter counter and native network stream" },
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
assert.equal(cancellationCount, 0);
|
|
142
|
+
screen.assertDisposed();
|
|
143
|
+
expectNoDiagnostics(artifact.solid);
|
|
144
|
+
expectNoWaste(artifact.solid);
|
|
145
|
+
expectRerunBudget(artifact.solid, 6);
|
|
146
|
+
expectNativeCommitBudget(artifact, {
|
|
147
|
+
maxCommits: 6,
|
|
148
|
+
maxMutations: 105,
|
|
149
|
+
maxCommitsPerRender: 6,
|
|
150
|
+
maxMutationsPerCommit: 48,
|
|
151
|
+
});
|
|
152
|
+
});
|