@swiftbrowser/react 0.0.0-stage → 0.4.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/README.md +435 -2
- package/dist/binding.d.ts +9 -0
- package/dist/binding.d.ts.map +1 -0
- package/dist/bridge.d.ts +17 -0
- package/dist/bridge.d.ts.map +1 -0
- package/dist/components/animators.d.ts +40 -0
- package/dist/components/animators.d.ts.map +1 -0
- package/dist/components/canvas.d.ts +138 -0
- package/dist/components/canvas.d.ts.map +1 -0
- package/dist/components/charts.d.ts +100 -0
- package/dist/components/charts.d.ts.map +1 -0
- package/dist/components/containers.d.ts +78 -0
- package/dist/components/containers.d.ts.map +1 -0
- package/dist/components/controls.d.ts +106 -0
- package/dist/components/controls.d.ts.map +1 -0
- package/dist/components/geometry.d.ts +131 -0
- package/dist/components/geometry.d.ts.map +1 -0
- package/dist/components/host.d.ts +24 -0
- package/dist/components/host.d.ts.map +1 -0
- package/dist/components/images.d.ts +18 -0
- package/dist/components/images.d.ts.map +1 -0
- package/dist/components/lists.d.ts +26 -0
- package/dist/components/lists.d.ts.map +1 -0
- package/dist/components/media.d.ts +105 -0
- package/dist/components/media.d.ts.map +1 -0
- package/dist/components/menus.d.ts +20 -0
- package/dist/components/menus.d.ts.map +1 -0
- package/dist/components/navigation.d.ts +22 -0
- package/dist/components/navigation.d.ts.map +1 -0
- package/dist/components/row.d.ts +34 -0
- package/dist/components/row.d.ts.map +1 -0
- package/dist/components/shapes.d.ts +107 -0
- package/dist/components/shapes.d.ts.map +1 -0
- package/dist/components/split.d.ts +25 -0
- package/dist/components/split.d.ts.map +1 -0
- package/dist/components/stacks.d.ts +138 -0
- package/dist/components/stacks.d.ts.map +1 -0
- package/dist/components/system.d.ts +25 -0
- package/dist/components/system.d.ts.map +1 -0
- package/dist/components/table.d.ts +36 -0
- package/dist/components/table.d.ts.map +1 -0
- package/dist/components/tabs.d.ts +20 -0
- package/dist/components/tabs.d.ts.map +1 -0
- package/dist/components/text.d.ts +63 -0
- package/dist/components/text.d.ts.map +1 -0
- package/dist/coordinateSpace.d.ts +20 -0
- package/dist/coordinateSpace.d.ts.map +1 -0
- package/dist/dragDrop.d.ts +16 -0
- package/dist/dragDrop.d.ts.map +1 -0
- package/dist/environment.d.ts +54 -0
- package/dist/environment.d.ts.map +1 -0
- package/dist/host/instance.d.ts +67 -0
- package/dist/host/instance.d.ts.map +1 -0
- package/dist/host/reconciler.d.ts +9 -0
- package/dist/host/reconciler.d.ts.map +1 -0
- package/dist/host/root.d.ts +29 -0
- package/dist/host/root.d.ts.map +1 -0
- package/dist/host/sb.d.ts +5 -0
- package/dist/host/sb.d.ts.map +1 -0
- package/dist/host/tree.d.ts +35 -0
- package/dist/host/tree.d.ts.map +1 -0
- package/dist/index.d.ts +41 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4038 -0
- package/dist/index.js.map +1 -0
- package/dist/inspector.d.ts +11 -0
- package/dist/inspector.d.ts.map +1 -0
- package/dist/island.d.ts +25 -0
- package/dist/island.d.ts.map +1 -0
- package/dist/lazy.d.ts +19 -0
- package/dist/lazy.d.ts.map +1 -0
- package/dist/lifecycle.d.ts +11 -0
- package/dist/lifecycle.d.ts.map +1 -0
- package/dist/modifiers.d.ts +330 -0
- package/dist/modifiers.d.ts.map +1 -0
- package/dist/mount.d.ts +41 -0
- package/dist/mount.d.ts.map +1 -0
- package/dist/navigation-context.d.ts +15 -0
- package/dist/navigation-context.d.ts.map +1 -0
- package/dist/path.d.ts +48 -0
- package/dist/path.d.ts.map +1 -0
- package/dist/pointer.d.ts +65 -0
- package/dist/pointer.d.ts.map +1 -0
- package/dist/presentation.d.ts +38 -0
- package/dist/presentation.d.ts.map +1 -0
- package/dist/scrollReader.d.ts +27 -0
- package/dist/scrollReader.d.ts.map +1 -0
- package/dist/values.d.ts +118 -0
- package/dist/values.d.ts.map +1 -0
- package/package.json +47 -4
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment values: what a modifier on a container passes to the views
|
|
3
|
+
* below it (`.buttonStyle`, `.controlSize`…), and the device environment the
|
|
4
|
+
* page sets (color scheme, Dynamic Type size).
|
|
5
|
+
*/
|
|
6
|
+
import type { ButtonStyle, ColorScheme, DynamicTypeSize, PickerStyle } from '@swiftbrowser/web/src/protocol';
|
|
7
|
+
import { type ReactNode } from 'react';
|
|
8
|
+
export type ControlSize = 'mini' | 'small' | 'regular' | 'large' | 'extraLarge';
|
|
9
|
+
export interface ViewEnvironment {
|
|
10
|
+
buttonStyle?: ButtonStyle;
|
|
11
|
+
controlSize?: ControlSize;
|
|
12
|
+
pickerStyle?: PickerStyle;
|
|
13
|
+
labelsHidden?: boolean;
|
|
14
|
+
/** `.refreshable`: the nearest `List` or `ScrollView` below runs it on a pull. */
|
|
15
|
+
refresh?: () => unknown;
|
|
16
|
+
/** `.submitLabel`: the return key's label of the text fields below. */
|
|
17
|
+
submitLabel?: string;
|
|
18
|
+
/** `.labelStyle`: how the `Label`s below draw. */
|
|
19
|
+
labelStyle?: 'automatic' | 'titleAndIcon' | 'titleOnly' | 'iconOnly';
|
|
20
|
+
/** `.redacted(reason: .placeholder)`: text and images below draw as placeholder shapes. */
|
|
21
|
+
redacted?: boolean;
|
|
22
|
+
/** `.textCase(_:)` for the texts below. */
|
|
23
|
+
textCase?: 'uppercase' | 'lowercase' | null;
|
|
24
|
+
/** Inside an alert's actions: tapping a button also dismisses the alert. */
|
|
25
|
+
dismissAlert?: () => void;
|
|
26
|
+
}
|
|
27
|
+
export declare const ViewEnvironmentContext: import("react").Context<ViewEnvironment>;
|
|
28
|
+
export declare function useViewEnvironment(): ViewEnvironment;
|
|
29
|
+
/** Wrap `children` in an environment with `values` added. */
|
|
30
|
+
export declare function withEnvironment(values: ViewEnvironment, children: ReactNode): ReactNode;
|
|
31
|
+
export type HorizontalSizeClass = 'compact' | 'regular';
|
|
32
|
+
export interface Environment {
|
|
33
|
+
colorScheme: ColorScheme;
|
|
34
|
+
dynamicTypeSize: DynamicTypeSize;
|
|
35
|
+
/** `compact` below 700 points of width (an iPhone), `regular` from it (an iPad, a desktop window). */
|
|
36
|
+
horizontalSizeClass: HorizontalSizeClass;
|
|
37
|
+
}
|
|
38
|
+
export declare const EnvironmentContext: import("react").Context<Environment>;
|
|
39
|
+
export declare function EnvironmentProvider({ value, children }: {
|
|
40
|
+
value: Environment;
|
|
41
|
+
children?: ReactNode;
|
|
42
|
+
}): ReactNode;
|
|
43
|
+
/** `@Environment(\.colorScheme)` */
|
|
44
|
+
export declare function useColorScheme(): ColorScheme;
|
|
45
|
+
/** `@Environment(\.dynamicTypeSize)` */
|
|
46
|
+
export declare function useDynamicTypeSize(): DynamicTypeSize;
|
|
47
|
+
/** `@Environment(\.dismiss)`: set by sheets and pushed screens. */
|
|
48
|
+
export declare const DismissContext: import("react").Context<(() => void) | null>;
|
|
49
|
+
export declare function useDismiss(): () => void;
|
|
50
|
+
/** `@Environment(\.horizontalSizeClass)` */
|
|
51
|
+
export declare function useHorizontalSizeClass(): HorizontalSizeClass;
|
|
52
|
+
/** `@Environment(\.redactionReasons)`: whether the views below are placeholders. */
|
|
53
|
+
export declare function useRedacted(): boolean;
|
|
54
|
+
//# sourceMappingURL=environment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"environment.d.ts","sourceRoot":"","sources":["../src/environment.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7G,OAAO,EAA4C,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEjF,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,OAAO,GAAG,YAAY,CAAC;AAEhF,MAAM,WAAW,eAAe;IAC9B,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,WAAW,CAAC,EAAE,WAAW,CAAC;I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B,UAAU,IAAI,MAAM,IAAI,CAGvC;AAED,4CAA4C;AAC5C,wBAAgB,sBAAsB,IAAI,mBAAmB,CAE5D;AAED,oFAAoF;AACpF,wBAAgB,WAAW,IAAI,OAAO,CAErC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The host tree the reconciler mutates: one `Instance` per host element. A
|
|
3
|
+
* host element is always the intrinsic type `sb` with a `kind` (an element
|
|
4
|
+
* kind of the ops protocol, or one of the two virtual kinds below) and the
|
|
5
|
+
* element's `props`; the React components in ../components render nothing
|
|
6
|
+
* else.
|
|
7
|
+
*/
|
|
8
|
+
import type { RendererEvent } from '@swiftbrowser/web/src/protocol';
|
|
9
|
+
import type { ReactNode } from 'react';
|
|
10
|
+
export type EventType = RendererEvent['type'];
|
|
11
|
+
export type EventOf<K extends EventType> = Extract<RendererEvent, {
|
|
12
|
+
type: K;
|
|
13
|
+
}>;
|
|
14
|
+
/** The renderer's events an element answers, by type. */
|
|
15
|
+
export type EventHandlers = {
|
|
16
|
+
[K in EventType]?: (event: EventOf<K>) => void;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Where a virtual element acts: the nearest enclosing `navscreen` or `sheet`
|
|
20
|
+
* element, or the root container.
|
|
21
|
+
*/
|
|
22
|
+
export type HoistTarget = 'navscreen' | 'sheet' | 'root';
|
|
23
|
+
/**
|
|
24
|
+
* A preference: not an element itself; its `props` are merged into the
|
|
25
|
+
* target's props (`.navigationTitle` sets the enclosing screen's `title`,
|
|
26
|
+
* `.presentationDetents` the enclosing sheet's `detents`).
|
|
27
|
+
*/
|
|
28
|
+
export declare const PREF_KIND = "$pref";
|
|
29
|
+
/**
|
|
30
|
+
* A hoist: not an element itself; its children become children of the target
|
|
31
|
+
* after the target's own (`.toolbar` items join the screen, `.sheet` content
|
|
32
|
+
* becomes a root-level `sheet` element).
|
|
33
|
+
*/
|
|
34
|
+
export declare const HOIST_KIND = "$hoist";
|
|
35
|
+
export interface HostProps {
|
|
36
|
+
kind: string;
|
|
37
|
+
props?: Record<string, unknown>;
|
|
38
|
+
on?: EventHandlers;
|
|
39
|
+
target?: HoistTarget;
|
|
40
|
+
children?: ReactNode;
|
|
41
|
+
}
|
|
42
|
+
export interface Instance {
|
|
43
|
+
/** The element id in the ops protocol; stable for the instance's life. */
|
|
44
|
+
id: number;
|
|
45
|
+
kind: string;
|
|
46
|
+
props: Record<string, unknown>;
|
|
47
|
+
on: EventHandlers | undefined;
|
|
48
|
+
target: HoistTarget | undefined;
|
|
49
|
+
/** The children as React currently has them (virtual kinds included). */
|
|
50
|
+
children: Instance[];
|
|
51
|
+
/** Hidden by Suspense: left out of the emitted tree. */
|
|
52
|
+
hidden: boolean;
|
|
53
|
+
/** Whether a `create` op was emitted for the current id. */
|
|
54
|
+
created: boolean;
|
|
55
|
+
committedProps: Record<string, unknown> | null;
|
|
56
|
+
committedParent: TreeNode | null;
|
|
57
|
+
committedChildren: Instance[];
|
|
58
|
+
}
|
|
59
|
+
/** The root container, element id 0. */
|
|
60
|
+
export interface RootNode {
|
|
61
|
+
id: 0;
|
|
62
|
+
kind: 'root';
|
|
63
|
+
children: Instance[];
|
|
64
|
+
committedChildren: Instance[];
|
|
65
|
+
}
|
|
66
|
+
export type TreeNode = Instance | RootNode;
|
|
67
|
+
//# sourceMappingURL=instance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"instance.d.ts","sourceRoot":"","sources":["../../src/host/instance.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,MAAM,SAAS,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;AAC9C,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,SAAS,IAAI,OAAO,CAAC,aAAa,EAAE;IAAE,IAAI,EAAE,CAA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AE,MAAM,CAAC;IACb,QAAQ,EAAE,QAAQ,EAAE,CAAC;IACrB,iBAAiB,EAAE,QAAQ,EAAE,CAAC;CAC/B;AAED,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The react-reconciler host config: React mutates `Instance` trees, and
|
|
3
|
+
* `resetAfterCommit` asks the `HostTree` for the ops of the pass.
|
|
4
|
+
*/
|
|
5
|
+
import Reconciler from 'react-reconciler';
|
|
6
|
+
import type { Instance } from './instance';
|
|
7
|
+
import type { HostTree } from './tree';
|
|
8
|
+
export declare const reconciler: Reconciler.Reconciler<HostTree, Instance, never, never, never, Instance>;
|
|
9
|
+
//# sourceMappingURL=reconciler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reconciler.d.ts","sourceRoot":"","sources":["../../src/host/reconciler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,UAAU,MAAM,kBAAkB,CAAC;AAE1C,OAAO,KAAK,EAAa,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AA2JvC,eAAO,MAAM,UAAU,0EAAyB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A SwiftUI root: renders a React element tree into a stream of render ops.
|
|
3
|
+
* The page gives the ops to a `Renderer` (@swiftbrowser/web) and feeds the
|
|
4
|
+
* renderer's events back through `dispatch`; headless code (tests) records
|
|
5
|
+
* the ops instead.
|
|
6
|
+
*/
|
|
7
|
+
import type { Animation, ColorScheme, DynamicTypeSize, Op, RendererEvent } from '@swiftbrowser/web/src/protocol';
|
|
8
|
+
import { type ReactNode } from 'react';
|
|
9
|
+
import { type Environment } from '../environment';
|
|
10
|
+
import { type OpsSink } from './tree';
|
|
11
|
+
export interface SwiftUIRoot {
|
|
12
|
+
/** Render (or re-render) the tree; the ops of the pass reach the sink before this returns. */
|
|
13
|
+
render(element: ReactNode): void;
|
|
14
|
+
unmount(): void;
|
|
15
|
+
/** A renderer event (a tap, a toggle…) for the element it names. */
|
|
16
|
+
dispatch(event: RendererEvent): void;
|
|
17
|
+
/** The device environment the tree reads through `useColorScheme` and friends. */
|
|
18
|
+
setEnvironment(environment: Partial<Environment>): void;
|
|
19
|
+
}
|
|
20
|
+
export declare function createSwiftUIRoot(sink: OpsSink): SwiftUIRoot;
|
|
21
|
+
export type { ColorScheme, DynamicTypeSize, Op };
|
|
22
|
+
/**
|
|
23
|
+
* `withAnimation { }`: the state changes `body` makes render in one pass whose
|
|
24
|
+
* `commit` carries the animation, so the renderer animates every frame and
|
|
25
|
+
* style change of the pass.
|
|
26
|
+
*/
|
|
27
|
+
export declare function withAnimation<T>(animation: Animation | undefined, body: () => T): T;
|
|
28
|
+
export declare function withAnimation<T>(body: () => T): T;
|
|
29
|
+
//# sourceMappingURL=root.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"root.d.ts","sourceRoot":"","sources":["../../src/host/root.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,eAAe,EAAE,EAAE,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AACjH,OAAO,EAAiB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,EAAuB,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAEvE,OAAO,EAAY,KAAK,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEhD,MAAM,WAAW,WAAW;IAC1B,8FAA8F;IAC9F,MAAM,CAAC,OAAO,EAAE,SAAS,GAAG,IAAI,CAAC;IACjC,OAAO,IAAI,IAAI,CAAC;IAChB,oEAAoE;IACpE,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,CAAC;IACrC,kFAAkF;IAClF,cAAc,CAAC,WAAW,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC;CACzD;AAMD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,GAAG,WAAW,CA4C5D;AAED,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,EAAE,EAAE,CAAC;AAEjD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;AACrF,wBAAgB,aAAa,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type ReactElement, type ReactNode } from 'react';
|
|
2
|
+
import type { EventHandlers, HoistTarget } from './instance';
|
|
3
|
+
/** A host element: the intrinsic `sb` with a protocol kind and props. */
|
|
4
|
+
export declare function sb(kind: string, props?: Record<string, unknown>, on?: EventHandlers, children?: ReactNode, target?: HoistTarget): ReactElement;
|
|
5
|
+
//# sourceMappingURL=sb.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sb.d.ts","sourceRoot":"","sources":["../../src/host/sb.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,YAAY,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAa,MAAM,YAAY,CAAC;AAExE,yEAAyE;AACzE,wBAAgB,EAAE,CAChB,IAAI,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,EAAE,CAAC,EAAE,aAAa,EAClB,QAAQ,CAAC,EAAE,SAAS,EACpB,MAAM,CAAC,EAAE,WAAW,GACnB,YAAY,CAMd"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Turns the host tree into ops. The reconciler mutates `Instance.children`
|
|
3
|
+
* freely during a React commit; `flush` then resolves the virtual kinds
|
|
4
|
+
* (preferences and hoists), diffs the result against what was emitted last
|
|
5
|
+
* time and produces one render pass: creates and updates, inserts (parents
|
|
6
|
+
* before children, as the Swift core orders them), removes, `commit`.
|
|
7
|
+
*/
|
|
8
|
+
import type { Animation, Op, RendererEvent } from '@swiftbrowser/web/src/protocol';
|
|
9
|
+
import { type HostProps, type Instance, type RootNode } from './instance';
|
|
10
|
+
export type OpsSink = (ops: Op[]) => void;
|
|
11
|
+
export declare class HostTree {
|
|
12
|
+
private readonly sink;
|
|
13
|
+
readonly root: RootNode;
|
|
14
|
+
private nextId;
|
|
15
|
+
/** Emitted elements by id, for event dispatch. */
|
|
16
|
+
private readonly live;
|
|
17
|
+
private committedLive;
|
|
18
|
+
/** Ids whose element changed kind: removed at the end of the next flush. */
|
|
19
|
+
private retired;
|
|
20
|
+
/** `withAnimation`: stamped on the next `commit`. */
|
|
21
|
+
pendingAnimation: Animation | undefined;
|
|
22
|
+
/** The root's `colorScheme` last sent (`.preferredColorScheme`); undefined while none was. */
|
|
23
|
+
private committedColorScheme;
|
|
24
|
+
constructor(sink: OpsSink);
|
|
25
|
+
createInstance(props: HostProps): Instance;
|
|
26
|
+
updateInstance(instance: Instance, next: HostProps): void;
|
|
27
|
+
/** Emit the ops for everything that changed since the last commit. */
|
|
28
|
+
commit(): void;
|
|
29
|
+
flush(): Op[];
|
|
30
|
+
/** Hand a renderer event to the element's handler for its type. */
|
|
31
|
+
dispatch(event: RendererEvent): void;
|
|
32
|
+
}
|
|
33
|
+
/** Structural equality of JSON-like values. */
|
|
34
|
+
export declare function deepEqual(a: unknown, b: unknown): boolean;
|
|
35
|
+
//# sourceMappingURL=tree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["../../src/host/tree.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AACnF,OAAO,EAAyB,KAAK,SAAS,EAAE,KAAK,QAAQ,EAAE,KAAK,QAAQ,EAAiB,MAAM,YAAY,CAAC;AAEhH,MAAM,MAAM,OAAO,GAAG,CAAC,GAAG,EAAE,EAAE,EAAE,KAAK,IAAI,CAAC;AAc1C,qBAAa,QAAQ;IAaP,OAAO,CAAC,QAAQ,CAAC,IAAI;IAZjC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAgE;IACvF,OAAO,CAAC,MAAM,CAAK;IACnB,kDAAkD;IAClD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA+B;IACpD,OAAO,CAAC,aAAa,CAAuB;IAC5C,4EAA4E;IAC5E,OAAO,CAAC,OAAO,CAAgB;IAC/B,qDAAqD;IACrD,gBAAgB,EAAE,SAAS,GAAG,SAAS,CAAC;IACxC,8FAA8F;IAC9F,OAAO,CAAC,oBAAoB,CAAsC;gBAErC,IAAI,EAAE,OAAO;IAE1C,cAAc,CAAC,KAAK,EAAE,SAAS,GAAG,QAAQ;IAgB1C,cAAc,CAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,GAAG,IAAI;IAoBzD,sEAAsE;IACtE,MAAM,IAAI,IAAI;IAKd,KAAK,IAAI,EAAE,EAAE;IA2Gb,mEAAmE;IACnE,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI;CAUrC;AAED,+CAA+C;AAC/C,wBAAgB,SAAS,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAazD"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @swiftbrowser/react: SwiftUI's components for React. The components render
|
|
3
|
+
* SwiftBrowser's render ops; `createSwiftUIRoot` hands them to the renderer
|
|
4
|
+
* of @swiftbrowser/web, which draws them with its iOS layout engine.
|
|
5
|
+
*/
|
|
6
|
+
export { createSwiftUIRoot, withAnimation, type SwiftUIRoot } from './host/root';
|
|
7
|
+
export { mount, type MountOptions, type Mounted } from './mount';
|
|
8
|
+
export { SwiftUIView, type SwiftUIViewProps } from './island';
|
|
9
|
+
export { useContextBridge } from './bridge';
|
|
10
|
+
export type { Binding, BindingValue } from './binding';
|
|
11
|
+
export { readBinding } from './binding';
|
|
12
|
+
export { useColorScheme, useDynamicTypeSize, useHorizontalSizeClass, useRedacted, type HorizontalSizeClass, useDismiss, useViewEnvironment, type ControlSize, type Environment, type ViewEnvironment, } from './environment';
|
|
13
|
+
export { useNavigation } from './navigation-context';
|
|
14
|
+
export type { ViewModifiers, BackgroundValue, SearchableModifier, ToolbarItemPlacementName, DragGestureModifier, DragValue, SwipeActionsModifier, AlignmentGuideName, DropDestinationModifier, InspectorModifier, } from './modifiers';
|
|
15
|
+
export type { SheetModifier, AlertModifier, DetentValue } from './presentation';
|
|
16
|
+
export * from './values';
|
|
17
|
+
export { Path, type CGRect, type Point } from './path';
|
|
18
|
+
export { ScrollViewReader, type ScrollViewProxy } from './scrollReader';
|
|
19
|
+
export { useCoordinateSpaces } from './coordinateSpace';
|
|
20
|
+
export * from './components/stacks';
|
|
21
|
+
export * from './components/text';
|
|
22
|
+
export * from './components/controls';
|
|
23
|
+
export * from './components/lists';
|
|
24
|
+
export * from './components/navigation';
|
|
25
|
+
export * from './components/tabs';
|
|
26
|
+
export * from './components/shapes';
|
|
27
|
+
export * from './components/host';
|
|
28
|
+
export * from './components/geometry';
|
|
29
|
+
export * from './components/menus';
|
|
30
|
+
export * from './components/images';
|
|
31
|
+
export * from './components/charts';
|
|
32
|
+
export { Row, type RowProps } from './components/row';
|
|
33
|
+
export * from './components/containers';
|
|
34
|
+
export * from './components/split';
|
|
35
|
+
export * from './components/table';
|
|
36
|
+
export * from './components/system';
|
|
37
|
+
export * from './components/canvas';
|
|
38
|
+
export * from './components/media';
|
|
39
|
+
export * from './components/animators';
|
|
40
|
+
export { useNamespace, type KeyboardShortcut, type KeyEquivalent, type KeyPress, type OnKeyPressModifier, type SensoryFeedback, type SymbolEffectModifier } from './pointer';
|
|
41
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,EAAE,KAAK,EAAE,KAAK,YAAY,EAAE,KAAK,OAAO,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAC5C,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,sBAAsB,EACtB,WAAW,EACX,KAAK,mBAAmB,EACxB,UAAU,EACV,kBAAkB,EAClB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,eAAe,GACrB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,YAAY,EACV,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,wBAAwB,EACxB,mBAAmB,EACnB,SAAS,EACT,oBAAoB,EACpB,kBAAkB,EAClB,uBAAuB,EACvB,iBAAiB,GAClB,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAChF,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,IAAI,EAAE,KAAK,MAAM,EAAE,KAAK,KAAK,EAAE,MAAM,QAAQ,CAA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