craft-native 0.0.142 → 0.0.143
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/dist/android/templates/MainActivityNative.kt.template +20 -9
- package/dist/cli.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/ios/templates/CraftNativeActions.swift +18 -1
- package/dist/ios/templates/CraftNativeFlatList.swift +1 -1
- package/dist/ios/templates/CraftNativeScreen.swift +2 -2
- package/package.json +1 -1
|
@@ -1928,6 +1928,7 @@ class MainActivity : AppCompatActivity() {
|
|
|
1928
1928
|
if (!screen.controls.containsKey("id:$target")) return false
|
|
1929
1929
|
makeView(screen, document, target, screen.controls)
|
|
1930
1930
|
val updated = screen.controls["id:$target"] ?: return false
|
|
1931
|
+
screen.lastLayoutBounds.remove(updated)
|
|
1931
1932
|
if (!updateParentLayoutStyle(updated, document.optJSONObject("style") ?: JSONObject())) return false
|
|
1932
1933
|
}
|
|
1933
1934
|
if (applied.isNotEmpty()) {
|
|
@@ -1940,14 +1941,16 @@ class MainActivity : AppCompatActivity() {
|
|
|
1940
1941
|
if (!screen.active) return
|
|
1941
1942
|
val observer = screen.view.viewTreeObserver
|
|
1942
1943
|
if (observer.isAlive) {
|
|
1943
|
-
val listener = object : ViewTreeObserver.
|
|
1944
|
-
override fun
|
|
1945
|
-
if (observer.isAlive) observer.
|
|
1944
|
+
val listener = object : ViewTreeObserver.OnPreDrawListener {
|
|
1945
|
+
override fun onPreDraw(): Boolean {
|
|
1946
|
+
if (observer.isAlive) observer.removeOnPreDrawListener(this)
|
|
1946
1947
|
if (screen.active) emitLayoutEvents(screen)
|
|
1948
|
+
return true
|
|
1947
1949
|
}
|
|
1948
1950
|
}
|
|
1949
|
-
observer.
|
|
1951
|
+
observer.addOnPreDrawListener(listener)
|
|
1950
1952
|
}
|
|
1953
|
+
screen.view.forceLayout()
|
|
1951
1954
|
screen.view.requestLayout()
|
|
1952
1955
|
// A tree that is already settled may not produce a global-layout
|
|
1953
1956
|
// callback; keep the event path live for that case as well.
|
|
@@ -1961,15 +1964,23 @@ class MainActivity : AppCompatActivity() {
|
|
|
1961
1964
|
*/
|
|
1962
1965
|
private fun updateParentLayoutStyle(view: View, style: JSONObject): Boolean {
|
|
1963
1966
|
var parent = view.parent
|
|
1967
|
+
var found = false
|
|
1964
1968
|
while (parent != null) {
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
+
when (parent) {
|
|
1970
|
+
is CraftNativeFlexLayout -> {
|
|
1971
|
+
if (!found) parent.setChildStyle(view, style, resources.displayMetrics.density)
|
|
1972
|
+
parent.forceLayout()
|
|
1973
|
+
parent.requestLayout()
|
|
1974
|
+
found = true
|
|
1975
|
+
}
|
|
1976
|
+
is CraftNativeScrollView -> {
|
|
1977
|
+
parent.forceLayout()
|
|
1978
|
+
parent.requestLayout()
|
|
1979
|
+
}
|
|
1969
1980
|
}
|
|
1970
1981
|
parent = parent.parent
|
|
1971
1982
|
}
|
|
1972
|
-
return
|
|
1983
|
+
return found
|
|
1973
1984
|
}
|
|
1974
1985
|
|
|
1975
1986
|
private fun renderCommitted(screen: Screen, document: JSONObject) {
|
package/dist/cli.js
CHANGED
|
@@ -3303,7 +3303,7 @@ function pinCraftNativeDependency(packagePath, craftVersion) {
|
|
|
3303
3303
|
`);
|
|
3304
3304
|
}
|
|
3305
3305
|
// package.json
|
|
3306
|
-
var version = "0.0.
|
|
3306
|
+
var version = "0.0.143";
|
|
3307
3307
|
|
|
3308
3308
|
// bin/cli.ts
|
|
3309
3309
|
var spawnedFrom = process6.env[CRAFT_CLI_SPAWN_MARKER];
|
package/dist/index.cjs
CHANGED
package/dist/index.js
CHANGED
|
@@ -38,7 +38,7 @@ enum CraftNativeActions {
|
|
|
38
38
|
private static let sqliteTransient = unsafeBitCast(-1, to: sqlite3_destructor_type.self)
|
|
39
39
|
|
|
40
40
|
static func capabilities(config: CraftConfig) -> [String] {
|
|
41
|
-
var values = ["device", "clipboard", "haptics", "storage", "lifecycle", "fetch"]
|
|
41
|
+
var values = ["device", "clipboard", "haptics", "storage", "lifecycle", "fetch", "dialog"]
|
|
42
42
|
if config.enableBiometric { values.append("biometric") }
|
|
43
43
|
if config.enableSecureStorage { values.append("secureStorage") }
|
|
44
44
|
if config.enableLocalDatabase { values.append("database") }
|
|
@@ -146,6 +146,23 @@ enum CraftNativeActions {
|
|
|
146
146
|
}
|
|
147
147
|
databaseQueue.async { complete(requestToken, database(method: method, args: args), completion) }
|
|
148
148
|
return
|
|
149
|
+
case ("Dialog", _):
|
|
150
|
+
// The system's own alert, confirmation and action sheet, the same
|
|
151
|
+
// ones a page gets (CraftNativeUI.swift), over the native screen.
|
|
152
|
+
let body = args.first as? [String: Any] ?? [:]
|
|
153
|
+
DispatchQueue.main.async {
|
|
154
|
+
switch method {
|
|
155
|
+
case "alert":
|
|
156
|
+
CraftDialogs.alert(body, from: nil) { complete(requestToken, .success(NSNull()), completion) }
|
|
157
|
+
case "confirm":
|
|
158
|
+
CraftDialogs.confirm(body, from: nil) { complete(requestToken, .success($0), completion) }
|
|
159
|
+
case "actionSheet":
|
|
160
|
+
CraftDialogs.actionSheet(body, from: nil) { complete(requestToken, .success($0 ?? NSNull()), completion) }
|
|
161
|
+
default:
|
|
162
|
+
complete(requestToken, failure("UNKNOWN_ACTION", "Unsupported Dialog method"), completion)
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return
|
|
149
166
|
case ("Health", _):
|
|
150
167
|
// Apple Health, the same as a page's `craft.health` (CraftHealth.swift).
|
|
151
168
|
guard config.enableHealthKit else {
|
|
@@ -525,7 +525,7 @@ final class CraftNativeFlatList: UICollectionView, UICollectionViewDelegateFlowL
|
|
|
525
525
|
|
|
526
526
|
private static func identity(for node: [String: Any]) -> String? {
|
|
527
527
|
let props = node["props"] as? [String: Any] ?? [:]
|
|
528
|
-
return [node["
|
|
528
|
+
return [node["key"], props["key"], props["testID"], node["id"]]
|
|
529
529
|
.compactMap { $0 as? String }
|
|
530
530
|
.first { !$0.isEmpty }
|
|
531
531
|
}
|
|
@@ -3528,7 +3528,7 @@ final class CraftNativeScreenController: UIViewController, UIScrollViewDelegate,
|
|
|
3528
3528
|
private func explicitKey(_ node: [String: Any], props: [String: Any]) -> String? {
|
|
3529
3529
|
// The current @stacksjs/stx native compiler emits key in props; accept the IR
|
|
3530
3530
|
// field too so keyed children keep working when the compiler adopts it.
|
|
3531
|
-
[node["
|
|
3531
|
+
[node["key"], props["key"], props["testID"], node["id"]]
|
|
3532
3532
|
.compactMap { $0 as? String }
|
|
3533
3533
|
.first { !$0.isEmpty }
|
|
3534
3534
|
}
|
|
@@ -4328,7 +4328,7 @@ final class CraftNativeScreenController: UIViewController, UIScrollViewDelegate,
|
|
|
4328
4328
|
view.accessibilityValue = nil
|
|
4329
4329
|
}
|
|
4330
4330
|
let role = props["accessibilityRole"] as? String
|
|
4331
|
-
view.isAccessibilityElement = role != "none" && (view.accessibilityLabel != nil || role != nil || ["Text", "Button", "Link", "Image", "TextInput", "Picker", "Switch", "Slider"].contains(type))
|
|
4331
|
+
view.isAccessibilityElement = role != "none" && (view.accessibilityLabel != nil || role != nil || ["Text", "Button", "Link", "Image", "Video", "TextInput", "Picker", "Switch", "Slider"].contains(type))
|
|
4332
4332
|
var traits: UIAccessibilityTraits = []
|
|
4333
4333
|
switch role ?? type.lowercased() {
|
|
4334
4334
|
case "button": traits.insert(.button)
|