craft-native 0.0.139 → 0.0.141
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/CraftNative.kt.template +137 -0
- package/dist/android/templates/MainActivityNative.kt.template +822 -87
- package/dist/cli.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/ios/src/index.js +1 -0
- package/dist/ios/templates/CraftApp.swift +14 -482
- package/dist/ios/templates/CraftHealth.swift +551 -0
- package/dist/ios/templates/CraftNativeActions.swift +11 -0
- package/dist/ios/templates/CraftNativeScreen.swift +763 -54
- package/package.json +1 -1
|
@@ -35,6 +35,7 @@ import com.google.mlkit.vision.objects.defaults.ObjectDetectorOptions
|
|
|
35
35
|
import com.google.mlkit.vision.text.TextRecognition
|
|
36
36
|
import com.google.mlkit.vision.text.latin.TextRecognizerOptions
|
|
37
37
|
import org.json.JSONArray
|
|
38
|
+
import kotlin.math.roundToInt
|
|
38
39
|
import androidx.biometric.BiometricManager
|
|
39
40
|
import androidx.biometric.BiometricPrompt
|
|
40
41
|
import androidx.fragment.app.FragmentActivity
|
|
@@ -231,6 +232,54 @@ object CraftNative {
|
|
|
231
232
|
private external fun nativeGetDeviceInfo(activity: Activity): String?
|
|
232
233
|
private external fun nativeGetMemoryUsage(): String?
|
|
233
234
|
private external fun nativeLog(message: String): Boolean
|
|
235
|
+
private external fun nativeFlexRow(
|
|
236
|
+
available: Float,
|
|
237
|
+
gap: Float,
|
|
238
|
+
justify: Int,
|
|
239
|
+
basis: FloatArray,
|
|
240
|
+
grow: FloatArray,
|
|
241
|
+
shrink: FloatArray,
|
|
242
|
+
min: FloatArray,
|
|
243
|
+
max: FloatArray,
|
|
244
|
+
margins: FloatArray,
|
|
245
|
+
): FloatArray?
|
|
246
|
+
private external fun nativeFlexLineBreaks(
|
|
247
|
+
available: Float,
|
|
248
|
+
gap: Float,
|
|
249
|
+
wrap: Int,
|
|
250
|
+
basis: FloatArray,
|
|
251
|
+
margins: FloatArray,
|
|
252
|
+
): FloatArray?
|
|
253
|
+
private external fun nativeFlexLineDistribution(
|
|
254
|
+
available: Float,
|
|
255
|
+
gap: Float,
|
|
256
|
+
alignment: Int,
|
|
257
|
+
lineCrosses: FloatArray,
|
|
258
|
+
): FloatArray?
|
|
259
|
+
private external fun nativeCrossAxisPosition(
|
|
260
|
+
available: Float,
|
|
261
|
+
size: Float,
|
|
262
|
+
leading: Float,
|
|
263
|
+
trailing: Float,
|
|
264
|
+
alignment: Int,
|
|
265
|
+
): Float
|
|
266
|
+
private external fun nativeGrid(
|
|
267
|
+
availableWidth: Float,
|
|
268
|
+
availableHeight: Float,
|
|
269
|
+
columns: Int,
|
|
270
|
+
columnGap: Float,
|
|
271
|
+
rowGap: Float,
|
|
272
|
+
intrinsicWidth: FloatArray,
|
|
273
|
+
intrinsicHeight: FloatArray,
|
|
274
|
+
explicitWidth: FloatArray,
|
|
275
|
+
explicitHeight: FloatArray,
|
|
276
|
+
minWidth: FloatArray,
|
|
277
|
+
maxWidth: FloatArray,
|
|
278
|
+
minHeight: FloatArray,
|
|
279
|
+
maxHeight: FloatArray,
|
|
280
|
+
margins: FloatArray,
|
|
281
|
+
flags: FloatArray,
|
|
282
|
+
): FloatArray?
|
|
234
283
|
private external fun nativeClipboardRead(activity: Activity): String?
|
|
235
284
|
private external fun nativeClipboardWrite(activity: Activity, text: String): Boolean
|
|
236
285
|
private external fun nativeOpenUrl(activity: Activity, url: String): Boolean
|
|
@@ -386,6 +435,94 @@ object CraftNative {
|
|
|
386
435
|
}
|
|
387
436
|
}
|
|
388
437
|
|
|
438
|
+
/** Resolve a flex line in Zig, or null for the Kotlin fallback. */
|
|
439
|
+
fun flexRow(
|
|
440
|
+
available: Float,
|
|
441
|
+
gap: Float,
|
|
442
|
+
justify: Int,
|
|
443
|
+
basis: FloatArray,
|
|
444
|
+
grow: FloatArray,
|
|
445
|
+
shrink: FloatArray,
|
|
446
|
+
min: FloatArray,
|
|
447
|
+
max: FloatArray,
|
|
448
|
+
margins: FloatArray,
|
|
449
|
+
): FloatArray? {
|
|
450
|
+
if (!isAvailable) return null
|
|
451
|
+
return try {
|
|
452
|
+
// The shared result stores widths in the first half and the
|
|
453
|
+
// corresponding main-axis positions in the second half.
|
|
454
|
+
nativeFlexRow(available, gap, justify, basis, grow, shrink, min, max, margins)
|
|
455
|
+
?.takeIf { it.size >= basis.size && it.all { value -> value.isFinite() } }
|
|
456
|
+
} catch (e: UnsatisfiedLinkError) {
|
|
457
|
+
null
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
/** Form wrapped flex lines in Zig, or null for the Kotlin fallback. */
|
|
462
|
+
fun flexLines(available: Float, gap: Float, wrap: Boolean, basis: FloatArray, margins: FloatArray): IntArray? {
|
|
463
|
+
if (!isAvailable) return null
|
|
464
|
+
return try {
|
|
465
|
+
nativeFlexLineBreaks(available, gap, if (wrap) 1 else 0, basis, margins)
|
|
466
|
+
?.takeIf { it.size >= basis.size && it.all { value -> value.isFinite() } }
|
|
467
|
+
?.map { it.roundToInt() }
|
|
468
|
+
?.toIntArray()
|
|
469
|
+
} catch (e: UnsatisfiedLinkError) {
|
|
470
|
+
null
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
/** Distribute wrapped flex lines in Zig, or null for the Kotlin fallback. */
|
|
475
|
+
fun flexLineDistribution(available: Float, gap: Float, alignment: Int, lineCrosses: FloatArray): Pair<FloatArray, FloatArray>? {
|
|
476
|
+
if (!isAvailable || lineCrosses.isEmpty()) return null
|
|
477
|
+
return try {
|
|
478
|
+
nativeFlexLineDistribution(available, gap, alignment, lineCrosses)
|
|
479
|
+
?.takeIf { it.size >= lineCrosses.size * 2 && it.all { value -> value.isFinite() } }
|
|
480
|
+
?.let { flattened ->
|
|
481
|
+
flattened.copyOfRange(0, lineCrosses.size) to flattened.copyOfRange(lineCrosses.size, lineCrosses.size * 2)
|
|
482
|
+
}
|
|
483
|
+
} catch (e: UnsatisfiedLinkError) {
|
|
484
|
+
null
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/** Resolve one flex item's cross-axis offset in Zig, or null for fallback. */
|
|
489
|
+
fun crossAxisPosition(available: Float, size: Float, leading: Float, trailing: Float, alignment: Int): Float? {
|
|
490
|
+
if (!isAvailable) return null
|
|
491
|
+
return try {
|
|
492
|
+
nativeCrossAxisPosition(available, size, leading, trailing, alignment)
|
|
493
|
+
.takeIf { it.isFinite() }
|
|
494
|
+
} catch (e: UnsatisfiedLinkError) {
|
|
495
|
+
null
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
/** Resolve equal-track grid frames in Zig, or null for Kotlin fallback. */
|
|
500
|
+
fun grid(
|
|
501
|
+
availableWidth: Float,
|
|
502
|
+
availableHeight: Float,
|
|
503
|
+
columns: Int,
|
|
504
|
+
columnGap: Float,
|
|
505
|
+
rowGap: Float,
|
|
506
|
+
intrinsicWidth: FloatArray,
|
|
507
|
+
intrinsicHeight: FloatArray,
|
|
508
|
+
explicitWidth: FloatArray,
|
|
509
|
+
explicitHeight: FloatArray,
|
|
510
|
+
minWidth: FloatArray,
|
|
511
|
+
maxWidth: FloatArray,
|
|
512
|
+
minHeight: FloatArray,
|
|
513
|
+
maxHeight: FloatArray,
|
|
514
|
+
margins: FloatArray,
|
|
515
|
+
flags: FloatArray,
|
|
516
|
+
): FloatArray? {
|
|
517
|
+
if (!isAvailable) return null
|
|
518
|
+
return try {
|
|
519
|
+
nativeGrid(availableWidth, availableHeight, columns, columnGap, rowGap, intrinsicWidth, intrinsicHeight, explicitWidth, explicitHeight, minWidth, maxWidth, minHeight, maxHeight, margins, flags)
|
|
520
|
+
?.takeIf { it.size >= intrinsicWidth.size * 4 && it.all { value -> value.isFinite() } }
|
|
521
|
+
} catch (e: UnsatisfiedLinkError) {
|
|
522
|
+
null
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
|
|
389
526
|
/**
|
|
390
527
|
* The clipboard's text, or null to use the Kotlin implementation.
|
|
391
528
|
*
|