craft-native 0.0.395 → 0.0.396
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/CraftNativeFlatList.kt.template +7 -0
- package/dist/android/templates/CraftNativeMapGoogle.kt.template +3 -0
- package/dist/android/templates/CraftNativeMapLibre.kt.template +3 -0
- package/dist/android/templates/CraftNativeRefreshableFlatList.kt.template +9 -0
- package/dist/android/templates/MainActivityNative.kt.template +317 -20
- package/dist/cli.js +1 -1
- package/dist/components/index.d.ts +16 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/ios/templates/CraftNativeFlatList.swift +4 -0
- package/dist/ios/templates/CraftNativeMutation.swift +27 -2
- package/dist/ios/templates/CraftNativeScreen.swift +292 -44
- package/dist/macos/templates/CraftNativeMutation.swift +27 -2
- package/package.json +1 -1
|
@@ -55,10 +55,14 @@ export interface FlexStyle {
|
|
|
55
55
|
/** Column gap */
|
|
56
56
|
columnGap?: number;
|
|
57
57
|
}
|
|
58
|
+
/** Hit targeting at an authored native component boundary. */
|
|
59
|
+
export type PointerEvents = 'auto' | 'none' | 'box-none' | 'box-only';
|
|
58
60
|
/**
|
|
59
61
|
* Layout style properties.
|
|
60
62
|
*/
|
|
61
63
|
export interface LayoutStyle {
|
|
64
|
+
/** Native pointer policy; a non-null prop overrides this style value. */
|
|
65
|
+
pointerEvents?: PointerEvents | null;
|
|
62
66
|
/** Width */
|
|
63
67
|
width?: number | string;
|
|
64
68
|
/** Height */
|
|
@@ -281,7 +285,13 @@ export type TextStyle = ViewStyle & TextStyleProps;
|
|
|
281
285
|
/**
|
|
282
286
|
* Image-specific style properties.
|
|
283
287
|
*/
|
|
288
|
+
/** Explicit CSS-facing native image sizing. Legacy resizeMode remains unchanged. */
|
|
289
|
+
export type ImageObjectFit = 'fill' | 'contain' | 'cover' | 'none' | 'scale-down';
|
|
284
290
|
export interface ImageStyleProps {
|
|
291
|
+
/** Explicit fit; null clears the style value. */
|
|
292
|
+
objectFit?: ImageObjectFit | null;
|
|
293
|
+
/** One/two alignment keywords or percentages; defaults to center. */
|
|
294
|
+
objectPosition?: string | null;
|
|
285
295
|
/** Resize mode */
|
|
286
296
|
resizeMode?: 'cover' | 'contain' | 'stretch' | 'center';
|
|
287
297
|
/** Tint color */
|
|
@@ -297,6 +307,8 @@ export type StyleValue<T> = T | StyleValue<T>[] | null | false | undefined;
|
|
|
297
307
|
* Base props for all components.
|
|
298
308
|
*/
|
|
299
309
|
export interface BaseProps {
|
|
310
|
+
/** Native hit targeting. Null clears the override and falls back to style. */
|
|
311
|
+
pointerEvents?: PointerEvents | null;
|
|
300
312
|
/** Unique identifier */
|
|
301
313
|
id?: string;
|
|
302
314
|
/** Test ID for testing */
|
|
@@ -422,6 +434,10 @@ export interface ImageErrorEvent {
|
|
|
422
434
|
* Image component props.
|
|
423
435
|
*/
|
|
424
436
|
export interface ImageProps extends BaseProps {
|
|
437
|
+
/** Non-null props override style; removing both restores legacy resizeMode. */
|
|
438
|
+
objectFit?: ImageObjectFit | null;
|
|
439
|
+
/** One/two alignment keywords or percentages, e.g. "right top" or "25% 75%". */
|
|
440
|
+
objectPosition?: string | null;
|
|
425
441
|
/** Image source */
|
|
426
442
|
source: ImageSource;
|
|
427
443
|
/** Style object or array */
|
package/dist/index.cjs
CHANGED
package/dist/index.d.cts
CHANGED
|
@@ -30,7 +30,7 @@ export * from './utils/index.js';
|
|
|
30
30
|
export * from './api/index.js';
|
|
31
31
|
export * as components from './components/index.js';
|
|
32
32
|
export { createTahoeSidebar, createArcSidebar, createOrbStackSidebar, sidebarItem, sidebarSection, sidebarSeparator, tahoeStyle, arcStyle, orbstackStyle, createSplitView, SplitViewInstance, createFileBrowser, FileBrowserInstance, createOutlineView, OutlineViewInstance, createTableView, TableViewInstance, showQuickLook, hideQuickLook, canQuickLook, showColorPicker, showFontPicker, showDatePicker, createProgress, ProgressInstance, setToolbar, updateToolbarItem, setToolbarVisible, setTouchBar, updateTouchBarItem, StyleSheet, Animated, } from './components/index.js';
|
|
33
|
-
export type { ContextMenuItem, SidebarStyle, SidebarPosition, SidebarHeaderConfig, SidebarFooterConfig, SidebarEventType, SidebarEventMap, SidebarEventHandler, ComponentProps, ComponentInstance, SplitViewOrientation, SplitViewDividerStyle, SplitViewConfig, FileBrowserConfig, FileBrowserSelection, OutlineItem, OutlineViewConfig, TableRow, TableViewConfig, QuickLookConfig, ColorPickerConfig, FontPickerConfig, FontResult, DatePickerConfig, ProgressConfig, ToolbarItem, ToolbarConfig, TouchBarConfig, FlexStyle, LayoutStyle, SpacingStyle, BorderStyle, ColorStyle, ShadowStyle, TransformStyle, ViewStyle, TextStyleProps, TextStyle, ImageStyleProps, ImageStyle, BaseProps, ViewProps, SafeAreaViewProps, KeyboardAvoidingViewProps, StatusBarProps, RefreshControlProps, TextProps, ButtonProps, LinkProps, TouchableOpacityProps, TouchableHighlightProps, ImageSource, ImageProps, ImageBackgroundProps, SvgPaintProps, SvgProps, GProps, SvgShapeProps, PathProps, LineProps, RectProps, CircleProps, EllipseProps, PolylineProps, PolygonProps, SvgTextProps, IconProps, VideoProps, MapRegion, MapProps, MapPolylineOverlay, MapMarkerOverlay, MapPolylineProps, MapPolygonProps, MapMarkerProps, ScrollViewProps, PressableProps, TextInputProps, KeyboardType, ReturnKeyType, SwitchProps, CheckboxProps, SliderProps, PickerOption, PickerProps, DatePickerChange, DatePickerProps, ActivityIndicatorProps, FlatListProps, SectionListSection, SectionListProps, ModalProps, LayoutEvent, ScrollEvent, } from './components/index.js';
|
|
33
|
+
export type { ContextMenuItem, SidebarStyle, SidebarPosition, SidebarHeaderConfig, SidebarFooterConfig, SidebarEventType, SidebarEventMap, SidebarEventHandler, ComponentProps, ComponentInstance, SplitViewOrientation, SplitViewDividerStyle, SplitViewConfig, FileBrowserConfig, FileBrowserSelection, OutlineItem, OutlineViewConfig, TableRow, TableViewConfig, QuickLookConfig, ColorPickerConfig, FontPickerConfig, FontResult, DatePickerConfig, ProgressConfig, ToolbarItem, ToolbarConfig, TouchBarConfig, FlexStyle, LayoutStyle, SpacingStyle, BorderStyle, ColorStyle, ShadowStyle, TransformStyle, ViewStyle, TextStyleProps, TextStyle, ImageObjectFit, ImageStyleProps, ImageStyle, BaseProps, ViewProps, SafeAreaViewProps, KeyboardAvoidingViewProps, StatusBarProps, RefreshControlProps, TextProps, ButtonProps, LinkProps, TouchableOpacityProps, TouchableHighlightProps, ImageSource, ImageProps, ImageBackgroundProps, SvgPaintProps, SvgProps, GProps, SvgShapeProps, PathProps, LineProps, RectProps, CircleProps, EllipseProps, PolylineProps, PolygonProps, SvgTextProps, IconProps, VideoProps, MapRegion, MapProps, MapPolylineOverlay, MapMarkerOverlay, MapPolylineProps, MapPolygonProps, MapMarkerProps, ScrollViewProps, PressableProps, TextInputProps, KeyboardType, ReturnKeyType, SwitchProps, CheckboxProps, SliderProps, PickerOption, PickerProps, DatePickerChange, DatePickerProps, ActivityIndicatorProps, FlatListProps, SectionListSection, SectionListProps, ModalProps, LayoutEvent, ScrollEvent, } from './components/index.js';
|
|
34
34
|
export * from './styles/headwind.js';
|
|
35
35
|
export * from './styles/index.js';
|
|
36
36
|
export * from './optimizations/index.js';
|
package/dist/index.d.ts
CHANGED
|
@@ -30,7 +30,7 @@ export * from './utils/index.js';
|
|
|
30
30
|
export * from './api/index.js';
|
|
31
31
|
export * as components from './components/index.js';
|
|
32
32
|
export { createTahoeSidebar, createArcSidebar, createOrbStackSidebar, sidebarItem, sidebarSection, sidebarSeparator, tahoeStyle, arcStyle, orbstackStyle, createSplitView, SplitViewInstance, createFileBrowser, FileBrowserInstance, createOutlineView, OutlineViewInstance, createTableView, TableViewInstance, showQuickLook, hideQuickLook, canQuickLook, showColorPicker, showFontPicker, showDatePicker, createProgress, ProgressInstance, setToolbar, updateToolbarItem, setToolbarVisible, setTouchBar, updateTouchBarItem, StyleSheet, Animated, } from './components/index.js';
|
|
33
|
-
export type { ContextMenuItem, SidebarStyle, SidebarPosition, SidebarHeaderConfig, SidebarFooterConfig, SidebarEventType, SidebarEventMap, SidebarEventHandler, ComponentProps, ComponentInstance, SplitViewOrientation, SplitViewDividerStyle, SplitViewConfig, FileBrowserConfig, FileBrowserSelection, OutlineItem, OutlineViewConfig, TableRow, TableViewConfig, QuickLookConfig, ColorPickerConfig, FontPickerConfig, FontResult, DatePickerConfig, ProgressConfig, ToolbarItem, ToolbarConfig, TouchBarConfig, FlexStyle, LayoutStyle, SpacingStyle, BorderStyle, ColorStyle, ShadowStyle, TransformStyle, ViewStyle, TextStyleProps, TextStyle, ImageStyleProps, ImageStyle, BaseProps, ViewProps, SafeAreaViewProps, KeyboardAvoidingViewProps, StatusBarProps, RefreshControlProps, TextProps, ButtonProps, LinkProps, TouchableOpacityProps, TouchableHighlightProps, ImageSource, ImageProps, ImageBackgroundProps, SvgPaintProps, SvgProps, GProps, SvgShapeProps, PathProps, LineProps, RectProps, CircleProps, EllipseProps, PolylineProps, PolygonProps, SvgTextProps, IconProps, VideoProps, MapRegion, MapProps, MapPolylineOverlay, MapMarkerOverlay, MapPolylineProps, MapPolygonProps, MapMarkerProps, ScrollViewProps, PressableProps, TextInputProps, KeyboardType, ReturnKeyType, SwitchProps, CheckboxProps, SliderProps, PickerOption, PickerProps, DatePickerChange, DatePickerProps, ActivityIndicatorProps, FlatListProps, SectionListSection, SectionListProps, ModalProps, LayoutEvent, ScrollEvent, } from './components/index.js';
|
|
33
|
+
export type { ContextMenuItem, SidebarStyle, SidebarPosition, SidebarHeaderConfig, SidebarFooterConfig, SidebarEventType, SidebarEventMap, SidebarEventHandler, ComponentProps, ComponentInstance, SplitViewOrientation, SplitViewDividerStyle, SplitViewConfig, FileBrowserConfig, FileBrowserSelection, OutlineItem, OutlineViewConfig, TableRow, TableViewConfig, QuickLookConfig, ColorPickerConfig, FontPickerConfig, FontResult, DatePickerConfig, ProgressConfig, ToolbarItem, ToolbarConfig, TouchBarConfig, FlexStyle, LayoutStyle, SpacingStyle, BorderStyle, ColorStyle, ShadowStyle, TransformStyle, ViewStyle, TextStyleProps, TextStyle, ImageObjectFit, ImageStyleProps, ImageStyle, BaseProps, ViewProps, SafeAreaViewProps, KeyboardAvoidingViewProps, StatusBarProps, RefreshControlProps, TextProps, ButtonProps, LinkProps, TouchableOpacityProps, TouchableHighlightProps, ImageSource, ImageProps, ImageBackgroundProps, SvgPaintProps, SvgProps, GProps, SvgShapeProps, PathProps, LineProps, RectProps, CircleProps, EllipseProps, PolylineProps, PolygonProps, SvgTextProps, IconProps, VideoProps, MapRegion, MapProps, MapPolylineOverlay, MapMarkerOverlay, MapPolylineProps, MapPolygonProps, MapMarkerProps, ScrollViewProps, PressableProps, TextInputProps, KeyboardType, ReturnKeyType, SwitchProps, CheckboxProps, SliderProps, PickerOption, PickerProps, DatePickerChange, DatePickerProps, ActivityIndicatorProps, FlatListProps, SectionListSection, SectionListProps, ModalProps, LayoutEvent, ScrollEvent, } from './components/index.js';
|
|
34
34
|
export * from './styles/headwind.js';
|
|
35
35
|
export * from './styles/index.js';
|
|
36
36
|
export * from './optimizations/index.js';
|
package/dist/index.js
CHANGED
|
@@ -42,6 +42,10 @@ private final class CraftNativeFlatListLayout: UICollectionViewFlowLayout {
|
|
|
42
42
|
/// The screen controller owns rendered row state; this view owns collection
|
|
43
43
|
/// diffs, viewport state, and UICollectionView cell reuse.
|
|
44
44
|
final class CraftNativeFlatList: UICollectionView, UICollectionViewDelegateFlowLayout, UIGestureRecognizerDelegate {
|
|
45
|
+
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
|
|
46
|
+
craftPointerHitTest(point, with: event) { super.hitTest(point, with: event) }
|
|
47
|
+
}
|
|
48
|
+
|
|
45
49
|
typealias RenderItem = (_ node: [String: Any], _ identity: String, _ previous: UIView?) -> UIView
|
|
46
50
|
|
|
47
51
|
private final class Cell: UICollectionViewCell {
|
|
@@ -35,6 +35,9 @@ final class CraftNativeMutationDocument {
|
|
|
35
35
|
var style: [String: Any]
|
|
36
36
|
var events: [String: Any]
|
|
37
37
|
var text: [String]
|
|
38
|
+
// Legacy snapshots may interleave bare text and native children.
|
|
39
|
+
// Keep each text fragment's slot among the child nodes on import.
|
|
40
|
+
var textPositions: [Int]? = nil
|
|
38
41
|
var children: [String]
|
|
39
42
|
var parent: String?
|
|
40
43
|
}
|
|
@@ -43,6 +46,11 @@ final class CraftNativeMutationDocument {
|
|
|
43
46
|
private var rootId: String?
|
|
44
47
|
private(set) var revision = 0
|
|
45
48
|
|
|
49
|
+
/// The normalized committed tree, whose root need not be named "root".
|
|
50
|
+
var document: [String: Any]? {
|
|
51
|
+
rootId.flatMap { materialize($0, nodes: nodes) }
|
|
52
|
+
}
|
|
53
|
+
|
|
46
54
|
func replace(with document: [String: Any]) {
|
|
47
55
|
var replacement: [String: Node] = [:]
|
|
48
56
|
let root = importNode(document, preferredId: "root", parent: nil, nodes: &replacement)
|
|
@@ -217,6 +225,7 @@ final class CraftNativeMutationDocument {
|
|
|
217
225
|
if patch.keys.contains("events") { mergePatch(patch["events"], into: &node.events) }
|
|
218
226
|
if patch.keys.contains("children") || patch.keys.contains("text") {
|
|
219
227
|
node.text = try textChildren(patch["children"] ?? patch["text"])
|
|
228
|
+
node.textPositions = nil
|
|
220
229
|
}
|
|
221
230
|
nodes[id] = node
|
|
222
231
|
}
|
|
@@ -422,9 +431,18 @@ final class CraftNativeMutationDocument {
|
|
|
422
431
|
"events": node.events,
|
|
423
432
|
]
|
|
424
433
|
if let key = node.key { value["key"] = key }
|
|
425
|
-
let text: [Any] = node.text
|
|
426
434
|
let children: [Any] = node.children.compactMap { materialize($0, nodes: nodes) }
|
|
427
|
-
|
|
435
|
+
var content: [Any] = []
|
|
436
|
+
var textIndex = 0
|
|
437
|
+
for index in 0...children.count {
|
|
438
|
+
while textIndex < node.text.count,
|
|
439
|
+
min(node.textPositions?[textIndex] ?? 0, children.count) == index {
|
|
440
|
+
content.append(node.text[textIndex])
|
|
441
|
+
textIndex += 1
|
|
442
|
+
}
|
|
443
|
+
if index < children.count { content.append(children[index]) }
|
|
444
|
+
}
|
|
445
|
+
value["children"] = content
|
|
428
446
|
return value
|
|
429
447
|
}
|
|
430
448
|
|
|
@@ -440,6 +458,12 @@ final class CraftNativeMutationDocument {
|
|
|
440
458
|
var id = explicit ?? key.map { "\(parent ?? "root")/key:\($0)" } ?? preferredId
|
|
441
459
|
if nodes[id] != nil { id = "\(preferredId)#\(nodes.count)" }
|
|
442
460
|
let children = value["children"] as? [Any] ?? []
|
|
461
|
+
var textPositions: [Int] = []
|
|
462
|
+
var childCount = 0
|
|
463
|
+
for child in children {
|
|
464
|
+
if child is String { textPositions.append(childCount) }
|
|
465
|
+
else if child is [String: Any] { childCount += 1 }
|
|
466
|
+
}
|
|
443
467
|
nodes[id] = Node(
|
|
444
468
|
id: id,
|
|
445
469
|
key: value["key"] as? String,
|
|
@@ -448,6 +472,7 @@ final class CraftNativeMutationDocument {
|
|
|
448
472
|
style: dictionary(value["style"]),
|
|
449
473
|
events: dictionary(value["events"]),
|
|
450
474
|
text: children.compactMap { $0 as? String },
|
|
475
|
+
textPositions: textPositions,
|
|
451
476
|
children: [],
|
|
452
477
|
parent: parent
|
|
453
478
|
)
|