@swiftbrowser/react 0.19.0 → 0.23.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 CHANGED
@@ -200,7 +200,11 @@ layout hints (`aspectRatio`, `scaledToFit`, `position`, `zIndex`,
200
200
  `alignmentGuide`, `ignoresSafeArea`, `allowsHitTesting`, `lineLimit` ranges)
201
201
  and the lifecycle (`onAppear`, `task` with an `AbortSignal` for
202
202
  cancellation, `onChangeOf`) are modifiers too, as are `draggable` and
203
- `dropDestination`.
203
+ `dropDestination` (what another `draggable` lifted, and from outside the
204
+ app what `accepts` takes: text, links, and files as `File`s, a dropped
205
+ folder as its files named by their paths in it, the folder's name first,
206
+ as `fileImporter` names a picked folder's; natively the files stay on disk
207
+ and are read when asked).
204
208
 
205
209
  Values are plain data: colors by name (`"red"`, `"secondary"`,
206
210
  `"secondarySystemBackground"`) or through `Color` (`Color.opacity('black',
@@ -235,7 +239,11 @@ Italic, Underline) comes back into the text. A `selection` binding, on a
235
239
  plain or an attributed editor, gets the viewer's selection in UTF-16
236
240
  offsets, so a Bold button can set `AttributedText.settingAttributes(text,
237
241
  start, end, { bold: true })` on it; a selection the app sets moves the
238
- caret (when the app focuses the editor, if it is not focused).
242
+ caret (when the app focuses the editor, if it is not focused). A text the
243
+ app sets that is not the echo of what the viewer typed (another person's
244
+ edit) keeps the caret in place: the app's `selection` is applied even when
245
+ its numbers did not change, and without one the caret is moved past the
246
+ change.
239
247
  `.scrollDisabled` makes an editor as tall as its lines, for one in a
240
248
  scrolling page:
241
249
 
@@ -664,7 +672,13 @@ autofill, without capitals.
664
672
  `fileImporter` is the browser's file chooser, opened when `isPresented`
665
673
  turns true; set it from a button's action, since a browser opens a chooser
666
674
  only within a tap. `onCompletion` gets the chosen `File`s, and a dismissed
667
- chooser calls `onCancellation`:
675
+ chooser calls `onCancellation`. With `'public.folder'` among the types it
676
+ is the folder chooser, and the files come named by their paths in the
677
+ folder, the folder's name first (`Photos/2025/a.jpg`). A `File` is what
678
+ the browser holds, not its bytes: a native app's picked files stay on disk
679
+ too, read through `arrayBuffer()` or a `slice` when asked, so a folder of
680
+ large files costs no memory until a file is read, and `fileManager.write`
681
+ copies one on disk rather than through memory:
668
682
 
669
683
  ```tsx
670
684
  <Button title="Upload Logo" action={() => setImporting(true)}
@@ -814,8 +828,11 @@ has there: `/data/Documents`, `/data/Library/Application Support`,
814
828
  `/data/Library/Caches`, and `/tmp` for the session); in a SwiftBrowser
815
829
  Native app they are the app's sandbox. Paths are `file:` URLs, made with
816
830
  `url(directory, path)`. The calls are Swift's, asynchronous on both sides
817
- since the page's storage is: `contents`, `text`, `write` (bytes, a Blob or
818
- text; the directory must exist), `contentsOfDirectory`, `createDirectory`
831
+ since the page's storage is: `contents` (the whole file, or a `range`
832
+ `{ start, end }` of it, read without the rest: a `Blob` slice on a page,
833
+ `FileHandle` natively), `text`, `write` (bytes, a Blob or text; the
834
+ directory must exist; a `Blob` or `File` is kept as it is, so a picked or
835
+ dropped file is stored without passing through memory), `contentsOfDirectory`, `createDirectory`
819
836
  (with its parents), `fileExists`, `attributesOfItem` (size, the modification
820
837
  and creation times, the MIME type the extension names), `moveItem`,
821
838
  `copyItem`, `removeItem`. Failures say what went wrong first: `notFound:`,
@@ -1 +1 @@
1
- {"version":3,"file":"lists.d.ts","sourceRoot":"","sources":["../../src/components/lists.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAA2D,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEhG,OAAO,EAAe,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAE5D,OAAO,EAA4C,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAW5F,gEAAgE;AAChE,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;AAE7C,MAAM,WAAW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,EAAE,SAAS,CAAC;CACtB;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,YAAY,GAAG,SAAS,CAyBtD"}
@@ -1 +1 @@
1
- {"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../src/components/navigation.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA8B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACnE,OAAO,EAAe,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAG5D,OAAO,EAA4C,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAI5F,MAAM,WAAW,oBAAqB,SAAQ,aAAa;IACzD,mDAAmD;IACnD,IAAI,CAAC,EAAE,YAAY,CAAC,SAAS,OAAO,EAAE,CAAC,CAAC;IACxC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,OAAO,EAAE,KAAK,IAAI,CAAC;IAClD,8DAA8D;IAC9D,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,SAAS,CAAC;IAC1C,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAUD,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,GAAG,SAAS,CAMtE;AA0DD,MAAM,WAAW,mBAAoB,SAAQ,aAAa;IACxD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qEAAqE;IACrE,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,0BAA0B;IAC1B,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,SAAS,CAepE"}
1
+ {"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../src/components/navigation.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA0C,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAC/E,OAAO,EAAe,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAG5D,OAAO,EAA4C,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAM5F,MAAM,WAAW,oBAAqB,SAAQ,aAAa;IACzD,mDAAmD;IACnD,IAAI,CAAC,EAAE,YAAY,CAAC,SAAS,OAAO,EAAE,CAAC,CAAC;IACxC,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,OAAO,EAAE,KAAK,IAAI,CAAC;IAClD,8DAA8D;IAC9D,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,SAAS,CAAC;IAC1C,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAUD,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,GAAG,SAAS,CAMtE;AA0DD,MAAM,WAAW,mBAAoB,SAAQ,aAAa;IACxD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,qEAAqE;IACrE,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,0BAA0B;IAC1B,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,SAAS,CA4BpE"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * `RegisteredView`: a view a package draws itself, named as the package
3
+ * registered it with `ViewRegistry`: in a native app a SwiftUI view
4
+ * (SwiftBrowserNative's `ViewRegistry.register(name) { context in … }`), on
5
+ * a page the package's own DOM (`ViewRegistry.register(name, (context) =>
6
+ * …)`, from @swiftbrowser/web). One element on both, for what a package
7
+ * draws from data that never crosses the bridge: an audio node's frames
8
+ * (`ScopeView` in @swiftbrowser/dsp), a map's tiles, a camera's preview.
9
+ * It takes the size it is given (`frame`, a stack's proposal), as
10
+ * `GeometryReader` does.
11
+ *
12
+ * ```tsx
13
+ * <RegisteredView name="Meter" props={{ level }} onEvent={(value) => …} frame={{ height: 40 }} />
14
+ * ```
15
+ */
16
+ import type { ReactNode } from 'react';
17
+ import { type ViewModifiers } from '../modifiers';
18
+ export { ViewRegistry, type RegisteredViewBuilder, type RegisteredViewContext, type RegisteredViewInstance } from '@swiftbrowser/web/src/viewRegistry';
19
+ export interface RegisteredViewProps extends ViewModifiers {
20
+ /** The name the view is registered under, on each platform. */
21
+ name: string;
22
+ /** JSON-serializable props for the view. */
23
+ props?: Record<string, unknown>;
24
+ /** A value the view sent (`context.send(value)`). */
25
+ onEvent?: (value: unknown) => void;
26
+ /** Views for the native view to place (`context.content`); a page's view has none. */
27
+ children?: ReactNode;
28
+ }
29
+ export declare function RegisteredView(all: RegisteredViewProps): ReactNode;
30
+ //# sourceMappingURL=registered.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registered.d.ts","sourceRoot":"","sources":["../../src/components/registered.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,EAA8B,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAE9E,OAAO,EAAE,YAAY,EAAE,KAAK,qBAAqB,EAAE,KAAK,qBAAqB,EAAE,KAAK,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAEvJ,MAAM,WAAW,mBAAoB,SAAQ,aAAa;IACxD,+DAA+D;IAC/D,IAAI,EAAE,MAAM,CAAC;IACb,4CAA4C;IAC5C,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,qDAAqD;IACrD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACnC,sFAAsF;IACtF,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,mBAAmB,GAAG,SAAS,CAIlE"}
@@ -31,7 +31,7 @@ export declare function NavigationSplitView(props: NavigationSplitViewProps): Re
31
31
  * sidebar has a selection. A list without a selection binding (a `Form`, a
32
32
  * plain list) passes `active: false` and says nothing.
33
33
  */
34
- export declare function useReportSplitSelection(split: SplitSelection | null, selected: boolean, clear: () => void, active?: boolean): void;
34
+ export declare function useReportSplitSelection(split: SplitSelection | null, selected: boolean, clear: () => void, active?: boolean): (selected: boolean, clear: () => void) => void;
35
35
  /** Presented content (a sheet, a popover, an inspector) is outside its presenter's split column. */
36
36
  export declare function OutsideSplit({ children }: {
37
37
  children?: ReactNode;
@@ -1 +1 @@
1
- {"version":3,"file":"split.d.ts","sourceRoot":"","sources":["../../src/components/split.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAoE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AACzG,OAAO,EAAe,KAAK,YAAY,EAAE,MAAM,YAAY,CAAC;AAI5D,OAAO,EAA8B,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAI9E,MAAM,MAAM,6BAA6B,GAAG,WAAW,GAAG,KAAK,GAAG,cAAc,GAAG,YAAY,CAAC;AAEhG;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IAChE,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,eAAO,MAAM,qBAAqB,gDAA6C,CAAC;AAEhF,MAAM,WAAW,wBAAyB,SAAQ,aAAa;IAC7D,OAAO,EAAE,SAAS,CAAC;IACnB,MAAM,EAAE,SAAS,CAAC;IAClB,gBAAgB,CAAC,EAAE,YAAY,CAAC,6BAA6B,CAAC,CAAC;IAC/D,wBAAwB,CAAC,EAAE,CAAC,UAAU,EAAE,6BAA6B,KAAK,IAAI,CAAC;CAChF;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,GAAG,SAAS,CAqD9E;AAwCD;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI,EAAE,QAAQ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GAAG;IAAE,QAAQ,CAAC,EAAE,SAAS,CAAA;CAAE,GAAG,SAAS,CAoBxI"}
@@ -10,7 +10,12 @@ import { type ReactNode } from 'react';
10
10
  import { type BindingValue } from './binding';
11
11
  export interface FileImporterModifier {
12
12
  isPresented: BindingValue<boolean>;
13
- /** What the chooser offers (its `accept`): MIME types, patterns (`image/*`) or extensions (`.svg`); any file when empty. */
13
+ /**
14
+ * What the chooser offers (its `accept`): MIME types, patterns (`image/*`) or extensions (`.svg`); any file when
15
+ * empty. `'public.folder'` (SwiftUI's `.folder`) makes it a folder chooser: `onCompletion` then gets the folder's
16
+ * files, at any depth, that the other types allow, each named by its path from the folder, the folder's name first
17
+ * (`Bank/Leads/Saw.fxp`).
18
+ */
14
19
  allowedContentTypes: string[];
15
20
  allowsMultipleSelection?: boolean;
16
21
  onCompletion: (files: File[]) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"fileImporter.d.ts","sourceRoot":"","sources":["../src/fileImporter.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAA2B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,EAAe,KAAK,YAAY,EAAE,MAAM,WAAW,CAAC;AAE3D,MAAM,WAAW,oBAAoB;IACnC,WAAW,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;IACnC,4HAA4H;IAC5H,mBAAmB,EAAE,MAAM,EAAE,CAAC;IAC9B,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,YAAY,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,IAAI,CAAC;IACtC,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;CAC7B;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,oBAAoB,GAAG,SAAS,CAuB3E"}
1
+ {"version":3,"file":"fileImporter.d.ts","sourceRoot":"","sources":["../src/fileImporter.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAA2B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,EAAe,KAAK,YAAY,EAAE,MAAM,WAAW,CAAC;AAE3D,MAAM,WAAW,oBAAoB;IACnC,WAAW,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC;IACnC;;;;;OAKG;IACH,mBAAmB,EAAE,MAAM,EAAE,CAAC;IAC9B,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,YAAY,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,IAAI,CAAC;IACtC,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;CAC7B;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,oBAAoB,GAAG,SAAS,CAuB3E"}
@@ -13,8 +13,18 @@
13
13
  */
14
14
  import type { FileAttributes, FileDirectories, FilesHost } from '@swiftbrowser/web/src/files';
15
15
  export type { FileAttributes, FileDirectories };
16
- /** What `write` takes: bytes, a Blob or a File, or text (written as UTF-8). */
16
+ /**
17
+ * What `write` takes: bytes, a Blob or a File, or text (written as UTF-8). A
18
+ * Blob or File is handed to the host as it is, so a picked or dropped file
19
+ * is kept without passing through memory (IndexedDB stores the Blob; the
20
+ * native app copies the file on disk).
21
+ */
17
22
  export type FileContents = Uint8Array | ArrayBuffer | Blob | string;
23
+ /** A byte range of a file: from `start` up to `end` (exclusive, clamped to the file's size). */
24
+ export interface FileRange {
25
+ start: number;
26
+ end: number;
27
+ }
18
28
  export interface FileManager {
19
29
  /** Whether this page or app keeps files; the calls below fail `unsupported: …` where it does not. */
20
30
  readonly available: boolean;
@@ -28,11 +38,19 @@ export interface FileManager {
28
38
  readonly temporaryDirectory: string;
29
39
  /** `url.appending(path:)`: the `file:` URL of `path` below `directory`. */
30
40
  url(directory: string, path: string): string;
31
- /** `Data(contentsOf:)`: the file's bytes. */
32
- contents(url: string): Promise<Uint8Array>;
41
+ /**
42
+ * `Data(contentsOf:)`: the file's bytes; with `range`, only those from
43
+ * `range.start` up to `range.end`, read without the rest where the host can
44
+ * (`FileHandle` natively, a `Blob` slice on a page), so a large file is read
45
+ * a piece at a time.
46
+ */
47
+ contents(url: string, range?: FileRange): Promise<Uint8Array>;
33
48
  /** `String(contentsOf:)`: the file as UTF-8 text. */
34
49
  text(url: string): Promise<string>;
35
- /** `Data.write(to:)`: writes the file, replacing one there; its directory must exist. */
50
+ /**
51
+ * `Data.write(to:)`: writes the file, replacing one there; its directory
52
+ * must exist. A `Blob` or `File` is kept as it is (see `FileContents`).
53
+ */
36
54
  write(url: string, contents: FileContents): Promise<void>;
37
55
  /** `contentsOfDirectory(at:)`: the URLs of what the directory holds, by name. */
38
56
  contentsOfDirectory(url: string): Promise<string[]>;
@@ -1 +1 @@
1
- {"version":3,"file":"fileManager.d.ts","sourceRoot":"","sources":["../src/fileManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAI9F,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,CAAC;AAEhD,+EAA+E;AAC/E,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,WAAW,GAAG,IAAI,GAAG,MAAM,CAAC;AAEpE,MAAM,WAAW,WAAW;IAC1B,qGAAqG;IACrG,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5B,2EAA2E;IAC3E,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IACpC,mFAAmF;IACnF,QAAQ,CAAC,2BAA2B,EAAE,MAAM,CAAC;IAC7C,qDAAqD;IACrD,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,+DAA+D;IAC/D,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;IACpC,2EAA2E;IAC3E,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7C,6CAA6C;IAC7C,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OA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olocationOptions, type Geol
32
32
  export { useSpeechSynthesis, useSpeechRecognition, type SpeakOptions, type SpeechSynthesisState, type SpeechRecognitionOptions, type SpeechRecognitionState } from './speech';
33
33
  export { useAppStorage, appStorage, type AppStorageOptions, type AppStorageSetter, type AppStorageStore } from './appStorage';
34
34
  export { useFileStorage, type FileStorageOptions, type FileStorageSetter, type FileStorageStatus } from './fileStorage';
35
- export { fileManager, createFileManager, type FileAttributes, type FileContents, type FileDirectories, type FileManager } from './fileManager';
35
+ export { fileManager, createFileManager, type FileAttributes, type FileContents, type FileDirectories, type FileManager, type FileRange } from './fileManager';
36
36
  export { UndoManager, UndoManagerContext, useUndoManager, type UndoHost, type UndoManagerOptions, type UndoOptions, type UndoState } from './undo';
37
37
  export * from './components/stacks';
38
38
  export * from './components/text';
@@ -42,6 +42,7 @@ export * from './components/navigation';
42
42
  export * from './components/tabs';
43
43
  export * from './components/shapes';
44
44
  export * from './components/host';
45
+ export * from './components/registered';
45
46
  export * from './components/geometry';
46
47
  export * from './components/menus';
47
48
  export * from './components/images';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,aAAa,EAAE,KAAK,2BAA2B,EAAE,KAAK,WAAW,EAAE,KAAK,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAClK,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,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cAAc,mBAAmB,CAAC;AAClC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,KAAK,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACtD,cAAc,yBAAyB,CAAC;AACxC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,OAAO,EAAE,YAAY,EAAE,KAAK,gBAAgB,EAAE,KAAK,aAAa,EAAE,KAAK,QAAQ,EAAE,KAAK,kBAAkB,EAAE,KAAK,eAAe,EAAE,KAAK,oBAAoB,EAAE,MAAM,WAAW,CAAC"}
package/dist/index.js CHANGED
@@ -14,6 +14,7 @@ import { fileURL } from "@swiftbrowser/web/src/files";
14
14
  import { registerHostContent, notifyHostContentChange, unregisterHostContent } from "@swiftbrowser/web/src/hostContent";
15
15
  import { createRoot } from "react-dom/client";
16
16
  import { flushSync } from "react-dom";
17
+ import { ViewRegistry } from "@swiftbrowser/web/src/viewRegistry";
17
18
  import { chooseColor } from "@swiftbrowser/web/src/colorPicker";
18
19
  import { base64Encode } from "@swiftbrowser/web/src/base64";
19
20
  import { timingFor } from "@swiftbrowser/web/src/animation";
@@ -647,6 +648,7 @@ function mount(screen, element, options = {}) {
647
648
  let renderer = null;
648
649
  const root = createSwiftUIRoot((ops) => renderer?.applyOps(ops));
649
650
  renderer = new Renderer(screen, (event) => root.dispatch(event));
651
+ renderer.fileDrops = "reference";
650
652
  const measurer = (text, font2, width) => renderer.measureText(text, font2, width);
651
653
  installTextMeasurer(measurer);
652
654
  let pageScheme = options.colorScheme ?? "light";
@@ -1072,10 +1074,21 @@ function itemValue(item) {
1072
1074
  }
1073
1075
  return item.text;
1074
1076
  }
1077
+ const name = item.path ?? item.name ?? "file";
1078
+ if (item.file) {
1079
+ const file = item.file;
1080
+ return item.path !== void 0 && item.path !== file.name ? new File([file], item.path, { type: file.type, lastModified: file.lastModified }) : file;
1081
+ }
1082
+ if (item.url !== void 0 && item.data === void 0) {
1083
+ const fromReference = browserEnvironment.fileFromReference;
1084
+ if (fromReference) {
1085
+ return fromReference({ type: item.type, name, url: item.url, ...item.path !== void 0 ? { path: item.path } : {}, ...item.size !== void 0 ? { size: item.size } : {} });
1086
+ }
1087
+ }
1075
1088
  const binary = atob(item.data ?? "");
1076
1089
  const bytes = new Uint8Array(binary.length);
1077
1090
  for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
1078
- return typeof File !== "undefined" ? new File([bytes], item.name ?? "file", { type: item.type }) : bytes;
1091
+ return typeof File !== "undefined" ? new File([bytes], name, { type: item.type }) : bytes;
1079
1092
  }
1080
1093
  function DropDestination({ action, isTargeted, accepts, children }) {
1081
1094
  return sb(
@@ -1177,6 +1190,34 @@ function FileExporterPresenter(spec) {
1177
1190
  }, [presented, setPresented]);
1178
1191
  return null;
1179
1192
  }
1193
+ const ListSelectionContext = createContext(null);
1194
+ function Row({ tag, onDelete, deletable, onMove, movable, index, containerIndex, children }) {
1195
+ const selection = useContext(ListSelectionContext);
1196
+ const selectable = selection !== null && tag !== void 0;
1197
+ const canDelete = onDelete !== void 0 && deletable !== false;
1198
+ const canMove = onMove !== void 0 && movable !== false;
1199
+ if (!selectable && !canDelete && !canMove) return children;
1200
+ const props = {};
1201
+ if (selectable) {
1202
+ props["selectable"] = true;
1203
+ props["selected"] = selection.isSelected(tag);
1204
+ }
1205
+ if (canDelete) props["deletable"] = true;
1206
+ if (canMove) props["movable"] = true;
1207
+ return sb(
1208
+ "listrow",
1209
+ props,
1210
+ {
1211
+ tap: () => selectable && selection.select(tag),
1212
+ delete: () => onDelete?.(),
1213
+ move: (event) => {
1214
+ const start = (containerIndex ?? index ?? 0) - (index ?? 0);
1215
+ onMove?.(Math.max(0, event.to - start));
1216
+ }
1217
+ },
1218
+ children
1219
+ );
1220
+ }
1180
1221
  const isPoint = (value) => typeof value === "object" && value !== null && ("x" in value || "y" in value);
1181
1222
  function command(request) {
1182
1223
  return request.axes ? { anchor: request.anchor, serial: request.serial, axes: request.axes } : { anchor: request.anchor, serial: request.serial };
@@ -1303,34 +1344,6 @@ function marginedContent(children, margins, axis) {
1303
1344
  const content = list.length === 1 ? list[0] : sb(axis === "horizontal" ? "hstack" : "vstack", { spacing: null, alignment: "center" }, void 0, children);
1304
1345
  return sb("styled", { style: { padding: margins } }, void 0, content);
1305
1346
  }
1306
- const ListSelectionContext = createContext(null);
1307
- function Row({ tag, onDelete, deletable, onMove, movable, index, containerIndex, children }) {
1308
- const selection = useContext(ListSelectionContext);
1309
- const selectable = selection !== null && tag !== void 0;
1310
- const canDelete = onDelete !== void 0 && deletable !== false;
1311
- const canMove = onMove !== void 0 && movable !== false;
1312
- if (!selectable && !canDelete && !canMove) return children;
1313
- const props = {};
1314
- if (selectable) {
1315
- props["selectable"] = true;
1316
- props["selected"] = selection.isSelected(tag);
1317
- }
1318
- if (canDelete) props["deletable"] = true;
1319
- if (canMove) props["movable"] = true;
1320
- return sb(
1321
- "listrow",
1322
- props,
1323
- {
1324
- tap: () => selectable && selection.select(tag),
1325
- delete: () => onDelete?.(),
1326
- move: (event) => {
1327
- const start = (containerIndex ?? index ?? 0) - (index ?? 0);
1328
- onMove?.(Math.max(0, event.to - start));
1329
- }
1330
- },
1331
- children
1332
- );
1333
- }
1334
1347
  const LAZY_BATCH = 12;
1335
1348
  const LazyContext = createContext(null);
1336
1349
  function LazyGroup({ rows, start = 0, wrap: wrap2 }) {
@@ -1801,13 +1814,20 @@ function NavigationLink(props) {
1801
1814
  const navigation = useNavigation();
1802
1815
  const environment = useViewEnvironment();
1803
1816
  const label = own.title !== void 0 ? /* @__PURE__ */ jsx(Text, { children: own.title }) : own.children;
1817
+ const listSelection = useContext(ListSelectionContext);
1818
+ const sidebar = useContext(SplitSelectionContext) !== null && listSelection !== null && own.destination === void 0 && own.value !== void 0;
1804
1819
  const tap = () => {
1820
+ if (sidebar) {
1821
+ listSelection.select(own.value);
1822
+ return;
1823
+ }
1805
1824
  if (!navigation) return;
1806
1825
  if (own.destination !== void 0) navigation.push({ view: own.destination });
1807
1826
  else navigation.push(own.value);
1808
1827
  };
1809
1828
  const style = takeModifier(modifiers, "buttonStyle") ?? environment.buttonStyle;
1810
1829
  const linkProps = style === "plain" ? { style: "plain" } : {};
1830
+ if (sidebar) linkProps["selects"] = true;
1811
1831
  return applyModifiers(sb("navlink", linkProps, { tap }, label), modifiers);
1812
1832
  }
1813
1833
  const SplitSelectionContext = createContext(null);
@@ -1816,8 +1836,8 @@ function NavigationSplitView(props) {
1816
1836
  const sizeClass = useHorizontalSizeClass();
1817
1837
  const [selected, setSelected] = useState(false);
1818
1838
  const reporters = useRef(/* @__PURE__ */ new Map());
1839
+ const settle = () => setSelected([...reporters.current.values()].some((entry) => entry.selected));
1819
1840
  const [report] = useState(() => {
1820
- const settle = () => setSelected([...reporters.current.values()].some((entry) => entry.selected));
1821
1841
  return {
1822
1842
  report: (key, nowSelected, clear2) => {
1823
1843
  reporters.current.set(key, { selected: nowSelected, clear: clear2 });
@@ -1829,15 +1849,17 @@ function NavigationSplitView(props) {
1829
1849
  };
1830
1850
  });
1831
1851
  const clear = () => {
1832
- for (const entry of reporters.current.values()) if (entry.selected) entry.clear();
1852
+ for (const entry of reporters.current.values()) {
1853
+ if (!entry.selected) continue;
1854
+ entry.clear();
1855
+ entry.selected = false;
1856
+ }
1857
+ settle();
1833
1858
  };
1834
1859
  const [internal, setInternal] = useState("automatic");
1835
1860
  const [visibility, setVisibility] = own.columnVisibility !== void 0 ? readBinding(own.columnVisibility, own.onColumnVisibilityChange) : [internal, setInternal];
1836
1861
  if (sizeClass === "compact") {
1837
- return applyModifiers(
1838
- /* @__PURE__ */ jsx(SplitSelectionContext.Provider, { value: report, children: /* @__PURE__ */ jsx(CompactSplit, { sidebar: own.sidebar, detail: own.detail, selected, clear }) }),
1839
- modifiers
1840
- );
1862
+ return applyModifiers(/* @__PURE__ */ jsx(CompactSplit, { sidebar: own.sidebar, detail: own.detail, report, selected, clear }), modifiers);
1841
1863
  }
1842
1864
  const sidebarVisible = visibility !== "detailOnly";
1843
1865
  const toggle = () => withAnimation(() => setVisibility(sidebarVisible ? "detailOnly" : "all"));
@@ -1853,11 +1875,17 @@ function NavigationSplitView(props) {
1853
1875
  function SplitColumn({ report, children }) {
1854
1876
  return /* @__PURE__ */ jsx(NavigationContext.Provider, { value: null, children: /* @__PURE__ */ jsx(SplitSelectionContext.Provider, { value: report, children }) });
1855
1877
  }
1856
- function CompactSplit({ sidebar, detail, selected, clear }) {
1878
+ function CompactSplit({
1879
+ sidebar,
1880
+ detail,
1881
+ report,
1882
+ selected,
1883
+ clear
1884
+ }) {
1857
1885
  const [internal, setInternal] = useState([]);
1858
1886
  const detailStack = isValidElement(detail) && detail.type === NavigationStack ? detail.props : null;
1859
1887
  const [extra, setExtra] = detailStack?.path !== void 0 ? readBinding(detailStack.path, detailStack.onPathChange) : [internal, setInternal];
1860
- const base = selected ? [{ view: /* @__PURE__ */ jsx(DetailScope, { children: detail }) }] : [];
1888
+ const base = selected ? [{ view: detail }] : [];
1861
1889
  const path = [...base, ...extra];
1862
1890
  const setPath = (next) => {
1863
1891
  if (selected && next.length === 0) {
@@ -1867,10 +1895,7 @@ function CompactSplit({ sidebar, detail, selected, clear }) {
1867
1895
  }
1868
1896
  setExtra(next.slice(base.length));
1869
1897
  };
1870
- return /* @__PURE__ */ jsx(NavigationContext.Provider, { value: null, children: /* @__PURE__ */ jsx(NavigationStack, { path: [path, setPath], children: sidebar }) });
1871
- }
1872
- function DetailScope({ children }) {
1873
- return /* @__PURE__ */ jsx(SplitSelectionContext.Provider, { value: null, children });
1898
+ return /* @__PURE__ */ jsx(NavigationContext.Provider, { value: null, children: /* @__PURE__ */ jsx(SplitSelectionContext.Provider, { value: null, children: /* @__PURE__ */ jsx(NavigationStack, { path: [path, setPath], children: /* @__PURE__ */ jsx(SplitSelectionContext.Provider, { value: report, children: sidebar }) }) }) });
1874
1899
  }
1875
1900
  function useReportSplitSelection(split, selected, clear, active2 = true) {
1876
1901
  const key = useRef({}).current;
@@ -1879,6 +1904,9 @@ function useReportSplitSelection(split, selected, clear, active2 = true) {
1879
1904
  else split?.retract(key);
1880
1905
  });
1881
1906
  useLayoutEffect(() => () => split?.retract(key), [split, key]);
1907
+ return (nowSelected, nowClear) => {
1908
+ if (active2) split?.report(key, nowSelected, nowClear);
1909
+ };
1882
1910
  }
1883
1911
  function OutsideSplit({ children }) {
1884
1912
  return /* @__PURE__ */ jsx(SplitSelectionContext.Provider, { value: null, children });
@@ -2158,6 +2186,7 @@ const MODIFIER_KEYS = /* @__PURE__ */ new Set([
2158
2186
  "cornerRadius",
2159
2187
  "clipShape",
2160
2188
  "clipped",
2189
+ "compositingGroup",
2161
2190
  "opacity",
2162
2191
  "disabled",
2163
2192
  "hidden",
@@ -2406,6 +2435,7 @@ const STYLED_KEYS = /* @__PURE__ */ new Set([
2406
2435
  "cornerRadius",
2407
2436
  "clipShape",
2408
2437
  "clipped",
2438
+ "compositingGroup",
2409
2439
  "opacity",
2410
2440
  "disabled",
2411
2441
  "hidden",
@@ -2519,6 +2549,8 @@ function apply(key, value, node, sides) {
2519
2549
  }
2520
2550
  case "clipped":
2521
2551
  return value ? styled({ clipped: true }, node) : node;
2552
+ case "compositingGroup":
2553
+ return value ? styled({ compositingGroup: true }, node) : node;
2522
2554
  case "opacity":
2523
2555
  return styled({ opacity: value }, node);
2524
2556
  case "disabled":
@@ -5182,13 +5214,11 @@ const NONE = {
5182
5214
  caches: "file:///data/Library/Caches",
5183
5215
  temporary: "file:///tmp"
5184
5216
  };
5185
- async function bytesOf(contents) {
5217
+ function hostData(contents) {
5186
5218
  if (typeof contents === "string") return new TextEncoder().encode(contents);
5187
5219
  if (contents instanceof Uint8Array) return contents;
5188
5220
  if (contents instanceof ArrayBuffer) return new Uint8Array(contents);
5189
- const blob = contents;
5190
- if (typeof blob.bytes === "function") return await blob.bytes();
5191
- return new Uint8Array(await blob.arrayBuffer());
5221
+ return contents;
5192
5222
  }
5193
5223
  function createFileManager(host) {
5194
5224
  const required = () => {
@@ -5214,9 +5244,16 @@ function createFileManager(host) {
5214
5244
  return directories().temporary;
5215
5245
  },
5216
5246
  url: (directory, path) => fileURL(directory, path),
5217
- contents: async (url) => required().read(url),
5247
+ contents: async (url, range) => {
5248
+ const files = required();
5249
+ if (!range) return files.read(url);
5250
+ if (files.readRange) return files.readRange(url, range.start, range.end);
5251
+ const all = await files.read(url);
5252
+ const start = Math.min(Math.max(0, range.start), all.byteLength);
5253
+ return all.subarray(start, Math.min(Math.max(start, range.end), all.byteLength));
5254
+ },
5218
5255
  text: async (url) => new TextDecoder().decode(await required().read(url)),
5219
- write: async (url, contents) => required().write(url, await bytesOf(contents)),
5256
+ write: async (url, contents) => required().write(url, hostData(contents)),
5220
5257
  contentsOfDirectory: async (url) => required().list(url),
5221
5258
  createDirectory: async (url) => required().createDirectory(url),
5222
5259
  fileExists: async (url) => await required().attributes(url) !== null,
@@ -5323,6 +5360,8 @@ function List(props) {
5323
5360
  if (editing) listProps["editing"] = true;
5324
5361
  let selection = null;
5325
5362
  const split = useContext(SplitSelectionContext);
5363
+ let reportNow = () => {
5364
+ };
5326
5365
  let selected = false;
5327
5366
  let clearSelection = NO_CLEAR;
5328
5367
  if (own.selection !== void 0) {
@@ -5339,13 +5378,16 @@ function List(props) {
5339
5378
  if (next.has(tag)) next.delete(tag);
5340
5379
  else next.add(tag);
5341
5380
  setValue(next);
5381
+ reportNow(next.size > 0, () => setValue(/* @__PURE__ */ new Set()));
5342
5382
  } else {
5343
- setValue(editing && Object.is(value, tag) ? null : tag);
5383
+ const next = editing && Object.is(value, tag) ? null : tag;
5384
+ setValue(next);
5385
+ reportNow(next !== null, () => setValue(null));
5344
5386
  }
5345
5387
  }
5346
5388
  };
5347
5389
  }
5348
- useReportSplitSelection(split, selected, clearSelection, own.selection !== void 0);
5390
+ reportNow = useReportSplitSelection(split, selected, clearSelection, own.selection !== void 0);
5349
5391
  const refresh = useRefreshable(takeModifier(modifiers, "refreshable"));
5350
5392
  Object.assign(listProps, refresh.props);
5351
5393
  const ownSettings = takeScrollSettings(modifiers);
@@ -5371,9 +5413,9 @@ function Section(props) {
5371
5413
  if (pinned?.includes("sectionHeaders") && header.text !== null && !header.view) header = { text: null, view: /* @__PURE__ */ jsx(Text, { children: header.text }) };
5372
5414
  if (pinned?.includes("sectionFooters") && footer.text !== null && !footer.view) footer = { text: null, view: /* @__PURE__ */ jsx(Text, { children: footer.text }) };
5373
5415
  const children = [];
5374
- if (header.view) children.push(sb("sectionheader", {}, void 0, header.view));
5375
- if (own.children !== void 0) children.push(wrapRows(own.children));
5376
- if (footer.view) children.push(sb("sectionfooter", {}, void 0, footer.view));
5416
+ if (header.view) children.push(/* @__PURE__ */ jsx(Fragment, { children: sb("sectionheader", {}, void 0, header.view) }, "header"));
5417
+ if (own.children !== void 0) children.push(/* @__PURE__ */ jsx(Fragment, { children: wrapRows(own.children) }, "rows"));
5418
+ if (footer.view) children.push(/* @__PURE__ */ jsx(Fragment, { children: sb("sectionfooter", {}, void 0, footer.view) }, "footer"));
5377
5419
  return applyModifiers(
5378
5420
  sb(
5379
5421
  "section",
@@ -5490,6 +5532,11 @@ function Host(props) {
5490
5532
  );
5491
5533
  return applyModifiers(sb("host", { content: key, sizing }), modifiers);
5492
5534
  }
5535
+ function RegisteredView(all) {
5536
+ const { own, modifiers } = splitProps(all);
5537
+ const on = own.onEvent ? { registered: (event) => own.onEvent(event.value) } : void 0;
5538
+ return applyModifiers(sb("registered", { name: own.name, props: own.props ?? {} }, on, own.children), modifiers);
5539
+ }
5493
5540
  function Menu(props) {
5494
5541
  const { own, modifiers } = splitProps(props);
5495
5542
  const label = own.title !== void 0 ? /* @__PURE__ */ jsx(Text, { children: own.title }) : own.label;
@@ -6900,6 +6947,7 @@ export {
6900
6947
  ProgressView,
6901
6948
  RadialGradient,
6902
6949
  Rectangle,
6950
+ RegisteredView,
6903
6951
  ResponseStream,
6904
6952
  RoundedRectangle,
6905
6953
  Row,
@@ -6933,6 +6981,7 @@ export {
6933
6981
  UnevenRoundedRectangle,
6934
6982
  VStack,
6935
6983
  VideoPlayer,
6984
+ ViewRegistry,
6936
6985
  ViewThatFits,
6937
6986
  VisualEffect,
6938
6987
  ZStack,