@swiftbrowser/web 0.18.3 → 0.21.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/src/symbols.ts CHANGED
@@ -294,6 +294,7 @@ import {
294
294
  Puzzle,
295
295
  QrCode,
296
296
  Rabbit,
297
+ Rainbow,
297
298
  Radio,
298
299
  RectangleHorizontal,
299
300
  RectangleVertical,
@@ -748,6 +749,9 @@ export const SF_SYMBOLS: Readonly<Record<string, SymbolGlyph>> = {
748
749
  bolt: outline(Zap),
749
750
  'bolt.fill': solid(Zap),
750
751
  sparkles: outline(Sparkles),
752
+ // Apple Intelligence's mark: the sparkles stand in for it.
753
+ 'apple.intelligence': outline(Sparkles),
754
+ rainbow: outline(Rainbow),
751
755
 
752
756
  // Chevrons and arrows
753
757
  'chevron.left': outline(ChevronLeft),
@@ -773,6 +777,7 @@ export const SF_SYMBOLS: Readonly<Record<string, SymbolGlyph>> = {
773
777
  'arrow.left.circle': outline(CircleArrowLeft),
774
778
  'arrow.right.circle': outline(CircleArrowRight),
775
779
  'arrow.up.circle': outline(CircleArrowUp),
780
+ 'arrow.up.circle.fill': knockout(CircleArrowUp),
776
781
  'arrow.down.circle': outline(CircleArrowDown),
777
782
  'arrow.down.to.line': outline(ArrowDownToLine),
778
783
  'arrow.up.to.line': outline(ArrowUpFromLine),
@@ -898,6 +903,7 @@ export const SF_SYMBOLS: Readonly<Record<string, SymbolGlyph>> = {
898
903
  'pause.circle': outline(CirclePause),
899
904
  'pause.circle.fill': knockout(CirclePause),
900
905
  'stop.circle': outline(CircleStop),
906
+ 'stop.circle.fill': knockout(CircleStop),
901
907
  pause: outline(Pause),
902
908
  'pause.fill': solid(Pause),
903
909
  stop: outline(Square),
@@ -0,0 +1,58 @@
1
+ /**
2
+ * The page's half of `ViewRegistry` (docs/ops-protocol.md, "Registered
3
+ * views"): a view a package draws itself, by name, which the `registered`
4
+ * element kind names. A native app registers a SwiftUI view under the same
5
+ * name (SwiftBrowserNative's `ViewRegistry`), so one component
6
+ * (`RegisteredView` in @swiftbrowser/react) is a SwiftUI view in the app and
7
+ * the package's own DOM on a page, drawing what never crosses the bridge
8
+ * (an audio node's frames, a map's tiles).
9
+ *
10
+ * ```ts
11
+ * ViewRegistry.register('Meter', (context) => {
12
+ * const element = document.createElement('canvas');
13
+ * return { element, update: (props) => …, dispose: () => … };
14
+ * });
15
+ * ```
16
+ */
17
+
18
+ /** What a builder gets: the element's id, its props as the app wrote them, and a way to answer (`onEvent`). */
19
+ export interface RegisteredViewContext {
20
+ readonly id: number;
21
+ readonly props: Record<string, unknown>;
22
+ /** Sends a value to the element's `onEvent` in the app. */
23
+ send(value: unknown): void;
24
+ }
25
+
26
+ /** A built view: its element, which fills the box the layout gives it, and what to do as props change or it goes. */
27
+ export interface RegisteredViewInstance {
28
+ readonly element: HTMLElement;
29
+ update?(props: Record<string, unknown>): void;
30
+ dispose?(): void;
31
+ }
32
+
33
+ export type RegisteredViewBuilder = (context: RegisteredViewContext) => RegisteredViewInstance | HTMLElement;
34
+
35
+ const builders = new Map<string, RegisteredViewBuilder>();
36
+
37
+ export const ViewRegistry = {
38
+ /** Registers `builder` under `name`, replacing one registered before; elements made after use it. */
39
+ register(name: string, builder: RegisteredViewBuilder): void {
40
+ builders.set(name, builder);
41
+ },
42
+
43
+ unregister(name: string): void {
44
+ builders.delete(name);
45
+ },
46
+
47
+ isRegistered(name: string): boolean {
48
+ return builders.has(name);
49
+ },
50
+
51
+ /** The view registered under `name`, built; undefined when there is none. */
52
+ make(name: string, context: RegisteredViewContext): RegisteredViewInstance | undefined {
53
+ const builder = builders.get(name);
54
+ if (!builder) return undefined;
55
+ const made = builder(context);
56
+ return made instanceof HTMLElement ? { element: made } : made;
57
+ },
58
+ };