@symbiote-native/navigation 2.0.3 → 2.2.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 +42 -12
- package/build/angular/drawer/index.js +29 -13
- package/build/angular/index.d.ts +4 -4
- package/build/angular/injectors/inject-navigation.js +1 -1
- package/build/angular/navigation-scope.directive.js +1 -1
- package/build/angular/search-bar-ref.directive.js +1 -1
- package/build/angular/stack/index.d.ts +2 -0
- package/build/angular/stack/index.js +43 -9
- package/build/angular/tabs/index.d.ts +1 -1
- package/build/angular/tabs/index.js +40 -13
- package/build/core/drawer-options/index.js +19 -5
- package/build/core/drawer-router-state/index.js +8 -2
- package/build/core/guards.js +3 -1
- package/build/core/header-bar-buttons.js +14 -4
- package/build/core/index.d.ts +6 -5
- package/build/core/index.js +7 -3
- package/build/core/navigator-state/index.js +12 -4
- package/build/core/render-drawer.js +4 -1
- package/build/core/render-stack.js +13 -4
- package/build/core/screen-options.js +1 -1
- package/build/core/search-bar-commands.js +1 -1
- package/build/core/stack-router-state/index.d.ts +2 -0
- package/build/core/stack-router-state/index.js +44 -0
- package/build/core/state-persistence/index.js +6 -2
- package/build/core/tab-router-state/index.d.ts +1 -0
- package/build/core/tab-router-state/index.js +27 -2
- package/build/react/drawer/index.js +59 -26
- package/build/react/index.d.ts +7 -7
- package/build/react/index.js +2 -2
- package/build/react/stack/index.js +47 -10
- package/build/react/tabs/index.js +36 -12
- package/build/solid/drawer/index.d.ts +22 -0
- package/build/solid/drawer/index.js +394 -0
- package/build/solid/drawer-screen-props.d.ts +13 -0
- package/build/solid/drawer-screen-props.js +2 -0
- package/build/solid/host.d.ts +2 -0
- package/build/solid/host.js +23 -0
- package/build/solid/index.d.ts +19 -0
- package/build/solid/index.js +24 -0
- package/build/solid/linking.d.ts +3 -0
- package/build/solid/linking.js +55 -0
- package/build/solid/navigation-context.d.ts +13 -0
- package/build/solid/navigation-context.js +37 -0
- package/build/solid/primitives/create-focus-effect.d.ts +1 -0
- package/build/solid/primitives/create-focus-effect.js +30 -0
- package/build/solid/primitives/create-is-focused.d.ts +2 -0
- package/build/solid/primitives/create-is-focused.js +31 -0
- package/build/solid/primitives/create-navigation-state.d.ts +3 -0
- package/build/solid/primitives/create-navigation-state.js +30 -0
- package/build/solid/primitives/index.d.ts +12 -0
- package/build/solid/primitives/index.js +8 -0
- package/build/solid/primitives/use-drawer-navigation.d.ts +5 -0
- package/build/solid/primitives/use-drawer-navigation.js +15 -0
- package/build/solid/primitives/use-navigation.d.ts +8 -0
- package/build/solid/primitives/use-navigation.js +23 -0
- package/build/solid/primitives/use-route.d.ts +3 -0
- package/build/solid/primitives/use-route.js +14 -0
- package/build/solid/primitives/use-stack-navigation.d.ts +5 -0
- package/build/solid/primitives/use-stack-navigation.js +19 -0
- package/build/solid/primitives/use-tab-navigation.d.ts +5 -0
- package/build/solid/primitives/use-tab-navigation.js +15 -0
- package/build/solid/screen-props.d.ts +19 -0
- package/build/solid/screen-props.js +9 -0
- package/build/solid/screen-registry.d.ts +31 -0
- package/build/solid/screen-registry.js +86 -0
- package/build/solid/screen.d.ts +6 -0
- package/build/solid/screen.js +69 -0
- package/build/solid/stack/index.d.ts +15 -0
- package/build/solid/stack/index.js +348 -0
- package/build/solid/tab-screen-props.d.ts +13 -0
- package/build/solid/tab-screen-props.js +3 -0
- package/build/solid/tabs/index.d.ts +14 -0
- package/build/solid/tabs/index.js +228 -0
- package/build/svelte/attachments.d.ts +5 -0
- package/build/svelte/attachments.js +61 -0
- package/build/svelte/descriptor-subtree.d.ts +3 -0
- package/build/svelte/descriptor-subtree.js +39 -0
- package/build/svelte/drawer/drawer-props.d.ts +14 -0
- package/build/svelte/drawer/drawer-props.js +3 -0
- package/build/svelte/drawer/index.d.ts +10 -0
- package/build/svelte/drawer/index.js +6 -0
- package/build/svelte/drawer/index.svelte +559 -0
- package/build/svelte/drawer/index.svelte.d.ts +10 -0
- package/build/svelte/drawer-screen-props.d.ts +13 -0
- package/build/svelte/drawer-screen-props.js +4 -0
- package/build/svelte/drawer-screen.svelte +25 -0
- package/build/svelte/drawer-screen.svelte.d.ts +4 -0
- package/build/svelte/index.d.ts +21 -0
- package/build/svelte/index.js +20 -0
- package/build/svelte/linking.svelte.d.ts +2 -0
- package/build/svelte/linking.svelte.js +55 -0
- package/build/svelte/navigation-context.d.ts +14 -0
- package/build/svelte/navigation-context.js +44 -0
- package/build/svelte/navigation-scope.svelte +27 -0
- package/build/svelte/navigation-scope.svelte.d.ts +9 -0
- package/build/svelte/registry-host.d.ts +1 -0
- package/build/svelte/registry-host.js +26 -0
- package/build/svelte/runes/index.d.ts +12 -0
- package/build/svelte/runes/index.js +12 -0
- package/build/svelte/runes/use-drawer-navigation.svelte.d.ts +6 -0
- package/build/svelte/runes/use-drawer-navigation.svelte.js +19 -0
- package/build/svelte/runes/use-focus-effect.svelte.d.ts +1 -0
- package/build/svelte/runes/use-focus-effect.svelte.js +31 -0
- package/build/svelte/runes/use-is-focused.svelte.d.ts +3 -0
- package/build/svelte/runes/use-is-focused.svelte.js +34 -0
- package/build/svelte/runes/use-navigation-state.svelte.d.ts +4 -0
- package/build/svelte/runes/use-navigation-state.svelte.js +39 -0
- package/build/svelte/runes/use-navigation.svelte.d.ts +9 -0
- package/build/svelte/runes/use-navigation.svelte.js +26 -0
- package/build/svelte/runes/use-route.svelte.d.ts +4 -0
- package/build/svelte/runes/use-route.svelte.js +12 -0
- package/build/svelte/runes/use-stack-navigation.svelte.d.ts +6 -0
- package/build/svelte/runes/use-stack-navigation.svelte.js +22 -0
- package/build/svelte/runes/use-tab-navigation.svelte.d.ts +6 -0
- package/build/svelte/runes/use-tab-navigation.svelte.js +19 -0
- package/build/svelte/screen-props.d.ts +21 -0
- package/build/svelte/screen-props.js +6 -0
- package/build/svelte/screen-registry.d.ts +17 -0
- package/build/svelte/screen-registry.js +57 -0
- package/build/svelte/screen.svelte +28 -0
- package/build/svelte/screen.svelte.d.ts +4 -0
- package/build/svelte/stack/index.d.ts +14 -0
- package/build/svelte/stack/index.js +7 -0
- package/build/svelte/stack/index.svelte +261 -0
- package/build/svelte/stack/index.svelte.d.ts +15 -0
- package/build/svelte/stack/stack-props.d.ts +20 -0
- package/build/svelte/stack/stack-props.js +4 -0
- package/build/svelte/stack/stack-screen.svelte +205 -0
- package/build/svelte/stack/stack-screen.svelte.d.ts +4 -0
- package/build/svelte/tab-screen-props.d.ts +13 -0
- package/build/svelte/tab-screen-props.js +4 -0
- package/build/svelte/tab-screen.svelte +26 -0
- package/build/svelte/tab-screen.svelte.d.ts +4 -0
- package/build/svelte/tabs/index.d.ts +8 -0
- package/build/svelte/tabs/index.js +6 -0
- package/build/svelte/tabs/index.svelte +269 -0
- package/build/svelte/tabs/index.svelte.d.ts +8 -0
- package/build/svelte/tabs/tab-props.d.ts +7 -0
- package/build/svelte/tabs/tab-props.js +3 -0
- package/build/vue/composables/use-navigation.js +5 -1
- package/build/vue/drawer/index.js +36 -13
- package/build/vue/index.d.ts +3 -3
- package/build/vue/navigation-context.js +1 -1
- package/build/vue/stack/index.js +43 -18
- package/build/vue/tabs/index.js +65 -39
- package/build-ngc/angular/drawer/index.js +40 -18
- package/build-ngc/angular/drawer/index.js.map +1 -1
- package/build-ngc/angular/drawer-screen.directive.js +3 -3
- package/build-ngc/angular/index.d.ts +4 -4
- package/build-ngc/angular/index.js.map +1 -1
- package/build-ngc/angular/injectors/inject-focus-effect.js.map +1 -1
- package/build-ngc/angular/injectors/inject-is-focused.js.map +1 -1
- package/build-ngc/angular/injectors/inject-navigation-state.js.map +1 -1
- package/build-ngc/angular/injectors/inject-navigation.js +1 -1
- package/build-ngc/angular/injectors/inject-navigation.js.map +1 -1
- package/build-ngc/angular/linking.js.map +1 -1
- package/build-ngc/angular/navigation-context.service.js +3 -3
- package/build-ngc/angular/navigation-context.service.js.map +1 -1
- package/build-ngc/angular/navigation-scope.directive.js +4 -4
- package/build-ngc/angular/navigation-scope.directive.js.map +1 -1
- package/build-ngc/angular/screen.directive.js +3 -3
- package/build-ngc/angular/screen.directive.js.map +1 -1
- package/build-ngc/angular/search-bar-ref.directive.js +4 -4
- package/build-ngc/angular/search-bar-ref.directive.js.map +1 -1
- package/build-ngc/angular/stack/index.d.ts +2 -0
- package/build-ngc/angular/stack/index.js +52 -14
- package/build-ngc/angular/stack/index.js.map +1 -1
- package/build-ngc/angular/tab-screen.directive.js +3 -3
- package/build-ngc/angular/tab-screen.directive.js.map +1 -1
- package/build-ngc/angular/tabs/index.d.ts +1 -1
- package/build-ngc/angular/tabs/index.js +43 -16
- package/build-ngc/angular/tabs/index.js.map +1 -1
- package/build-ngc/core/constants.js.map +1 -1
- package/build-ngc/core/drawer-options/index.js +19 -5
- package/build-ngc/core/drawer-options/index.js.map +1 -1
- package/build-ngc/core/drawer-router-state/index.js +8 -2
- package/build-ngc/core/drawer-router-state/index.js.map +1 -1
- package/build-ngc/core/guards.js +3 -1
- package/build-ngc/core/guards.js.map +1 -1
- package/build-ngc/core/header-bar-buttons.js +14 -4
- package/build-ngc/core/header-bar-buttons.js.map +1 -1
- package/build-ngc/core/index.d.ts +6 -5
- package/build-ngc/core/index.js +7 -3
- package/build-ngc/core/index.js.map +1 -1
- package/build-ngc/core/linking-config/index.js.map +1 -1
- package/build-ngc/core/navigation-events/index.js.map +1 -1
- package/build-ngc/core/navigator-handles/index.js.map +1 -1
- package/build-ngc/core/navigator-state/index.js +12 -4
- package/build-ngc/core/navigator-state/index.js.map +1 -1
- package/build-ngc/core/render-drawer.js +4 -1
- package/build-ngc/core/render-drawer.js.map +1 -1
- package/build-ngc/core/render-stack.js +13 -4
- package/build-ngc/core/render-stack.js.map +1 -1
- package/build-ngc/core/render-tabs.js.map +1 -1
- package/build-ngc/core/screen-options.js +1 -1
- package/build-ngc/core/screen-options.js.map +1 -1
- package/build-ngc/core/search-bar-commands.js +1 -1
- package/build-ngc/core/search-bar-commands.js.map +1 -1
- package/build-ngc/core/stack-router-state/index.d.ts +2 -0
- package/build-ngc/core/stack-router-state/index.js +45 -0
- package/build-ngc/core/stack-router-state/index.js.map +1 -0
- package/build-ngc/core/state-persistence/index.js +6 -2
- package/build-ngc/core/state-persistence/index.js.map +1 -1
- package/build-ngc/core/tab-router-state/index.d.ts +1 -0
- package/build-ngc/core/tab-router-state/index.js +27 -2
- package/build-ngc/core/tab-router-state/index.js.map +1 -1
- package/package.json +44 -16
- package/src/angular/drawer/index.ts +75 -29
- package/src/angular/index.ts +20 -4
- package/src/angular/injectors/inject-focus-effect.ts +8 -2
- package/src/angular/injectors/inject-is-focused.ts +6 -4
- package/src/angular/injectors/inject-navigation-state.ts +7 -4
- package/src/angular/injectors/inject-navigation.ts +12 -3
- package/src/angular/linking.ts +4 -1
- package/src/angular/navigation-context.service.ts +5 -2
- package/src/angular/navigation-scope.directive.ts +6 -2
- package/src/angular/screen.directive.ts +13 -3
- package/src/angular/search-bar-ref.directive.ts +10 -2
- package/src/angular/stack/index.ts +91 -24
- package/src/angular/tab-screen.directive.ts +3 -1
- package/src/angular/tabs/index.ts +54 -16
- package/src/core/constants.ts +6 -3
- package/src/core/drawer-options/index.ts +40 -13
- package/src/core/drawer-router-state/index.ts +11 -3
- package/src/core/guards.ts +3 -1
- package/src/core/header-bar-buttons.ts +41 -12
- package/src/core/index.ts +29 -5
- package/src/core/linking-config/index.ts +31 -10
- package/src/core/navigation-events/index.ts +8 -2
- package/src/core/navigator-handles/index.ts +8 -3
- package/src/core/navigator-props.ts +13 -4
- package/src/core/navigator-state/index.ts +24 -7
- package/src/core/render-drawer.ts +24 -9
- package/src/core/render-stack.ts +52 -13
- package/src/core/render-tabs.ts +24 -6
- package/src/core/screen-options.ts +15 -5
- package/src/core/search-bar-commands.ts +12 -3
- package/src/core/stack-router-state/index.ts +52 -0
- package/src/core/state-persistence/index.ts +13 -3
- package/src/core/tab-router-state/index.ts +35 -3
- package/src/react/drawer/index.ts +409 -330
- package/src/react/drawer-screen.ts +8 -2
- package/src/react/hooks/use-focus-effect.ts +8 -2
- package/src/react/hooks/use-is-focused.ts +6 -2
- package/src/react/hooks/use-navigation.ts +8 -2
- package/src/react/index.ts +37 -7
- package/src/react/linking.ts +4 -1
- package/src/react/navigation-context.ts +6 -2
- package/src/react/screen.ts +12 -3
- package/src/react/stack/index.ts +297 -220
- package/src/react/tab-screen.ts +3 -1
- package/src/react/tabs/index.ts +202 -139
- package/src/solid/drawer/index.ts +570 -0
- package/src/solid/drawer-screen-props.ts +24 -0
- package/src/solid/host.ts +29 -0
- package/src/solid/index.ts +87 -0
- package/src/solid/linking.ts +74 -0
- package/src/solid/navigation-context.ts +56 -0
- package/src/solid/primitives/create-focus-effect.ts +41 -0
- package/src/solid/primitives/create-is-focused.ts +41 -0
- package/src/solid/primitives/create-navigation-state.ts +44 -0
- package/src/solid/primitives/index.ts +12 -0
- package/src/solid/primitives/use-drawer-navigation.ts +25 -0
- package/src/solid/primitives/use-navigation.ts +44 -0
- package/src/solid/primitives/use-route.ts +18 -0
- package/src/solid/primitives/use-stack-navigation.ts +29 -0
- package/src/solid/primitives/use-tab-navigation.ts +25 -0
- package/src/solid/screen-props.ts +51 -0
- package/src/solid/screen-registry.ts +159 -0
- package/src/solid/screen.ts +80 -0
- package/src/solid/stack/index.ts +528 -0
- package/src/solid/tab-screen-props.ts +21 -0
- package/src/solid/tabs/index.ts +327 -0
- package/src/svelte/attachments.ts +70 -0
- package/src/svelte/descriptor-subtree.ts +51 -0
- package/src/svelte/drawer/drawer-props.ts +28 -0
- package/src/svelte/drawer/index.svelte +559 -0
- package/src/svelte/drawer/index.ts +10 -0
- package/src/svelte/drawer-screen-props.ts +26 -0
- package/src/svelte/drawer-screen.svelte +25 -0
- package/src/svelte/fabric-tree.test-helper.ts +95 -0
- package/src/svelte/index.ts +83 -0
- package/src/svelte/linking.svelte.ts +72 -0
- package/src/svelte/navigation-context.ts +62 -0
- package/src/svelte/navigation-scope.svelte +27 -0
- package/src/svelte/registry-host.ts +26 -0
- package/src/svelte/runes/index.ts +17 -0
- package/src/svelte/runes/use-drawer-navigation.svelte.ts +31 -0
- package/src/svelte/runes/use-focus-effect.svelte.ts +41 -0
- package/src/svelte/runes/use-is-focused.svelte.ts +38 -0
- package/src/svelte/runes/use-navigation-state.svelte.ts +48 -0
- package/src/svelte/runes/use-navigation.svelte.ts +49 -0
- package/src/svelte/runes/use-route.svelte.ts +16 -0
- package/src/svelte/runes/use-stack-navigation.svelte.ts +34 -0
- package/src/svelte/runes/use-tab-navigation.svelte.ts +29 -0
- package/src/svelte/screen-props.ts +50 -0
- package/src/svelte/screen-registry.ts +98 -0
- package/src/svelte/screen.svelte +28 -0
- package/src/svelte/stack/index.svelte +261 -0
- package/src/svelte/stack/index.ts +11 -0
- package/src/svelte/stack/stack-props.ts +31 -0
- package/src/svelte/stack/stack-screen.svelte +205 -0
- package/src/svelte/svelte-ambient.d.ts +6 -0
- package/src/svelte/svelte-compile.test-helper.ts +147 -0
- package/src/svelte/tab-screen-props.ts +22 -0
- package/src/svelte/tab-screen.svelte +26 -0
- package/src/svelte/tabs/index.svelte +269 -0
- package/src/svelte/tabs/index.ts +10 -0
- package/src/svelte/tabs/tab-props.ts +13 -0
- package/src/vue/composables/use-navigation-state.ts +7 -4
- package/src/vue/composables/use-navigation.ts +13 -3
- package/src/vue/drawer/index.ts +128 -41
- package/src/vue/drawer-screen.ts +12 -5
- package/src/vue/index.ts +15 -3
- package/src/vue/linking.ts +7 -2
- package/src/vue/navigation-context.ts +17 -5
- package/src/vue/screen.ts +7 -2
- package/src/vue/stack/index.ts +108 -43
- package/src/vue/tab-screen.ts +3 -1
- package/src/vue/tabs/index.ts +109 -68
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
// Tab, the Solid lifecycle half. The focused-index router (tab-router-state) and the tab-bar
|
|
2
|
+
// Descriptor builder (render-tabs) live in @symbiote-native/navigation core, shared verbatim with
|
|
3
|
+
// every other adapter; here Solid supplies the lifecycle - a signal for the dispatched router
|
|
4
|
+
// state, a callback `ref` for the jumpTo/setParams handle - plus the descriptor bridge for the
|
|
5
|
+
// tab-bar leaf. Unlike Stack, a bottom-tabs bar is a PURE-JS UI painting ordinary
|
|
6
|
+
// `symbiote-view`/`symbiote-text` primitives, so there is no react-native-screens ViewConfig to
|
|
7
|
+
// register here.
|
|
8
|
+
//
|
|
9
|
+
// TWO SOLID-ONLY REBUILD BOUNDARIES, both invisible in every other adapter:
|
|
10
|
+
//
|
|
11
|
+
// 1. THE TAB BAR'S SHAPE FOLLOWS ITS DATA. renderTabBar emits one child per item, and each item
|
|
12
|
+
// emits an icon wrapper only when it has an icon or a badge - so adding a screen, or a badge
|
|
13
|
+
// appearing, CHANGES the Descriptor's shape, which descriptorToSolid's shape guard rejects by
|
|
14
|
+
// design (it builds once and updates props in place). `barSignature` captures exactly the parts
|
|
15
|
+
// of the data the shape depends on, and the bar is rebuilt when that string changes and only
|
|
16
|
+
// then. Every other adapter re-renders the whole bar every time and never meets this.
|
|
17
|
+
//
|
|
18
|
+
// 2. ONLY THE FOCUSED SCREEN IS MOUNTED, so a focus change is a genuine rebuild while a
|
|
19
|
+
// `setParams` on the focused route must NOT be. The content memo therefore depends on the
|
|
20
|
+
// focused route KEY and its component identity alone, with the build `untrack`ed
|
|
21
|
+
// (.claude/rules/solid-descriptor-bridge.md §5); the route object itself reaches the screen
|
|
22
|
+
// through the scope accessor, which is what keeps useRoute() live without rebuilding anything.
|
|
23
|
+
import { createEffect, createMemo, createSignal, untrack } from 'solid-js';
|
|
24
|
+
import { descriptorToSolid } from '@symbiote-native/solid';
|
|
25
|
+
// createComponent from solid-js, insert from the renderer - see stack/index.ts's note.
|
|
26
|
+
import { createComponent } from 'solid-js';
|
|
27
|
+
import { insert } from '@symbiote-native/solid/renderer';
|
|
28
|
+
import { dlog } from '@symbiote-native/engine';
|
|
29
|
+
import { NAVIGATION_EVENT_BLUR, NAVIGATION_EVENT_FOCUS, createInitialTabState, createNavigationEmitter, diffFocusedRoute, isFocusedRoute, reconcileTabRoutes, renderTabBar, tabRouterReducer, } from '../../core/index.js';
|
|
30
|
+
import { hostElement } from '../host.js';
|
|
31
|
+
import { NavigationScopeProvider, useNavigationScope, } from '../navigation-context.js';
|
|
32
|
+
import { ScreenCollectorProvider, createScreenSignal, toRegistry, } from '../screen-registry.js';
|
|
33
|
+
import { TabScreen } from '../screen.js';
|
|
34
|
+
const TAB_CONTENT_STYLE = { flex: 1 };
|
|
35
|
+
const TAB_ROOT_STYLE = { flex: 1 };
|
|
36
|
+
let navigatorSequence = 0;
|
|
37
|
+
function resolveTabOptions(entry, args, screenOptions) {
|
|
38
|
+
const own = typeof entry.options === 'function' ? entry.options(args) : entry.options;
|
|
39
|
+
return { ...screenOptions, ...own };
|
|
40
|
+
}
|
|
41
|
+
// A Descriptor icon is spliced into the bar verbatim, so only its ROOT type is visible here - an
|
|
42
|
+
// app that swaps one Descriptor icon for another of the same type but a different child count
|
|
43
|
+
// would still trip the bridge's shape guard, with the guard's own message. That is the honest
|
|
44
|
+
// boundary: this signature covers the shape decisions render-tabs.ts itself makes.
|
|
45
|
+
function iconKind(icon) {
|
|
46
|
+
if (icon === undefined)
|
|
47
|
+
return '-';
|
|
48
|
+
return typeof icon === 'string' ? 'glyph' : icon.type;
|
|
49
|
+
}
|
|
50
|
+
function barSignature(items) {
|
|
51
|
+
return items
|
|
52
|
+
.map(item => `${item.key}:${iconKind(item.icon)}:${item.badge === undefined ? 0 : 1}`)
|
|
53
|
+
.join('|');
|
|
54
|
+
}
|
|
55
|
+
function TabImpl(props) {
|
|
56
|
+
// Read BEFORE this Tab provides its own per-screen scope - becomes the `parent` link a nested
|
|
57
|
+
// screen's useNavigation().getParent() walks. undefined when this Tab is the nesting root.
|
|
58
|
+
const parentScope = useNavigationScope();
|
|
59
|
+
const { screens, collector } = createScreenSignal('tab');
|
|
60
|
+
const registry = createMemo(() => toRegistry(screens()));
|
|
61
|
+
navigatorSequence += 1;
|
|
62
|
+
const routeIdPrefix = `tab-${navigatorSequence}`;
|
|
63
|
+
// Route keys are derived from the screen NAME, never a counter: a Tab's route list is rebuilt
|
|
64
|
+
// from the registry on every registration change, and a counter would mint a fresh key each time,
|
|
65
|
+
// re-mounting every screen for an unrelated marker edit.
|
|
66
|
+
const routes = createMemo(() => [...registry().entries()].map(([name, entry]) => ({
|
|
67
|
+
key: `${routeIdPrefix}-${name}`,
|
|
68
|
+
name,
|
|
69
|
+
params: entry.initialParams,
|
|
70
|
+
})));
|
|
71
|
+
// `null` means nothing has dispatched yet, which is what keeps initialRouteName honored when the
|
|
72
|
+
// markers arrive after the body has already run (screen-registry.ts).
|
|
73
|
+
const [dispatched, setDispatched] = createSignal(null);
|
|
74
|
+
const state = createMemo(() => {
|
|
75
|
+
const current = routes();
|
|
76
|
+
const previous = dispatched();
|
|
77
|
+
return previous === null
|
|
78
|
+
? createInitialTabState(current, props.initialRouteName)
|
|
79
|
+
: reconcileTabRoutes(previous, current);
|
|
80
|
+
});
|
|
81
|
+
function dispatch(action) {
|
|
82
|
+
setDispatched(tabRouterReducer(state(), action));
|
|
83
|
+
}
|
|
84
|
+
const jumpTo = (name, params) => dispatch({ type: 'jumpTo', name, params });
|
|
85
|
+
const setParams = (params, key) => dispatch({ type: 'setParams', key, params });
|
|
86
|
+
const handle = { jumpTo, setParams };
|
|
87
|
+
props.ref?.(handle);
|
|
88
|
+
// One emitter per route.key, created lazily and cached for the navigator's whole lifetime. Emitter
|
|
89
|
+
// IDENTITY (stable, looked up by key) is deliberately decoupled from emit TIMING (deferred below):
|
|
90
|
+
// a scheme that recreated the emitter on each focus change raced the build of the very screen that
|
|
91
|
+
// was supposed to subscribe to it.
|
|
92
|
+
const emitters = new Map();
|
|
93
|
+
function emitterFor(routeKey) {
|
|
94
|
+
let emitter = emitters.get(routeKey);
|
|
95
|
+
if (emitter === undefined) {
|
|
96
|
+
emitter = createNavigationEmitter();
|
|
97
|
+
emitters.set(routeKey, emitter);
|
|
98
|
+
}
|
|
99
|
+
return emitter;
|
|
100
|
+
}
|
|
101
|
+
const focusedKey = createMemo(() => {
|
|
102
|
+
const current = state();
|
|
103
|
+
return current.routes[current.index]?.key;
|
|
104
|
+
});
|
|
105
|
+
// Tab paints its own bar in pure JS - there is no native onAppear/onDisappear to hook (unlike
|
|
106
|
+
// Stack's RNSScreen), so focus/blur is synthesized here. The emit is deferred to a microtask,
|
|
107
|
+
// which resolves only after Solid's whole effect flush has drained - including the build of the
|
|
108
|
+
// newly focused screen and the subscriptions createIsFocused/createFocusEffect register inside
|
|
109
|
+
// it. Emitting inline would reach zero subscribers.
|
|
110
|
+
let lastFocusedKey;
|
|
111
|
+
createEffect(() => {
|
|
112
|
+
const nextKey = focusedKey();
|
|
113
|
+
const { blurKey, focusKey } = diffFocusedRoute(lastFocusedKey, nextKey);
|
|
114
|
+
if (blurKey === undefined && focusKey === undefined)
|
|
115
|
+
return;
|
|
116
|
+
lastFocusedKey = nextKey;
|
|
117
|
+
queueMicrotask(() => {
|
|
118
|
+
if (blurKey !== undefined) {
|
|
119
|
+
dlog(`Tab: route "${blurKey}" blurred at t=${Date.now()}`);
|
|
120
|
+
emitterFor(blurKey).emit(NAVIGATION_EVENT_BLUR);
|
|
121
|
+
}
|
|
122
|
+
if (focusKey !== undefined) {
|
|
123
|
+
dlog(`Tab: route "${focusKey}" focused at t=${Date.now()}`);
|
|
124
|
+
emitterFor(focusKey).emit(NAVIGATION_EVENT_FOCUS);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
const items = createMemo(() => {
|
|
129
|
+
const current = state();
|
|
130
|
+
const entries = registry();
|
|
131
|
+
return current.routes.map((route, index) => {
|
|
132
|
+
const entry = entries.get(route.name);
|
|
133
|
+
const focused = isFocusedRoute(index, current.index);
|
|
134
|
+
if (entry === undefined) {
|
|
135
|
+
dlog(`Tab: no screen registered for route name "${route.name}"`);
|
|
136
|
+
return { key: route.key, focused, label: route.name, passthrough: {} };
|
|
137
|
+
}
|
|
138
|
+
const options = resolveTabOptions(entry, { route, navigation: handle }, props.screenOptions);
|
|
139
|
+
return {
|
|
140
|
+
key: route.key,
|
|
141
|
+
focused,
|
|
142
|
+
label: options.tabBarLabel ?? options.title ?? route.name,
|
|
143
|
+
icon: options.tabBarIcon,
|
|
144
|
+
badge: options.tabBarBadge,
|
|
145
|
+
activeTintColor: options.tabBarActiveTintColor,
|
|
146
|
+
inactiveTintColor: options.tabBarInactiveTintColor,
|
|
147
|
+
passthrough: {
|
|
148
|
+
onPress: () => jumpTo(route.name),
|
|
149
|
+
accessibilityRole: 'tab',
|
|
150
|
+
accessibilityState: { selected: focused },
|
|
151
|
+
},
|
|
152
|
+
};
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
const focusedOptions = createMemo(() => {
|
|
156
|
+
const current = state();
|
|
157
|
+
const route = current.routes[current.index];
|
|
158
|
+
const entry = route === undefined ? undefined : registry().get(route.name);
|
|
159
|
+
if (entry === undefined || route === undefined)
|
|
160
|
+
return props.screenOptions;
|
|
161
|
+
return resolveTabOptions(entry, { route, navigation: handle }, props.screenOptions);
|
|
162
|
+
});
|
|
163
|
+
// Header note 1: the bar is rebuilt only when its Descriptor SHAPE would change; every tint,
|
|
164
|
+
// label and badge-value change flows through descriptorToSolid's prop diff on the live nodes.
|
|
165
|
+
const barShape = createMemo(() => barSignature(items()));
|
|
166
|
+
const tabBar = createMemo(() => {
|
|
167
|
+
barShape();
|
|
168
|
+
return untrack(() => descriptorToSolid(() => renderTabBar({
|
|
169
|
+
items: items(),
|
|
170
|
+
style: focusedOptions()?.tabBarStyle,
|
|
171
|
+
passthrough: {},
|
|
172
|
+
})));
|
|
173
|
+
});
|
|
174
|
+
// Header note 2. Only the focused route's screen is ever mounted (unlike Stack, which keeps every
|
|
175
|
+
// pushed route alive), so the previous screen's whole subtree - and every listener it registered
|
|
176
|
+
// - is torn down by Solid's ordinary disposal when focus moves on.
|
|
177
|
+
const focusedComponent = createMemo(() => {
|
|
178
|
+
const current = state();
|
|
179
|
+
const route = current.routes[current.index];
|
|
180
|
+
return route === undefined
|
|
181
|
+
? undefined
|
|
182
|
+
: registry().get(route.name)?.component;
|
|
183
|
+
});
|
|
184
|
+
const content = createMemo(() => {
|
|
185
|
+
const routeKey = focusedKey();
|
|
186
|
+
const Component = focusedComponent();
|
|
187
|
+
return untrack(() => {
|
|
188
|
+
if (routeKey === undefined || Component === undefined)
|
|
189
|
+
return undefined;
|
|
190
|
+
const scope = () => ({
|
|
191
|
+
route: routeFor(routeKey),
|
|
192
|
+
navigation: handle,
|
|
193
|
+
emitter: emitterFor(routeKey),
|
|
194
|
+
parent: parentScope?.(),
|
|
195
|
+
});
|
|
196
|
+
return createComponent(NavigationScopeProvider, {
|
|
197
|
+
value: scope,
|
|
198
|
+
// No route/navigation props: the screen reads both through the primitives off the scope
|
|
199
|
+
// provided here (useRoute / useTabNavigation).
|
|
200
|
+
get children() {
|
|
201
|
+
return createComponent(Component, {});
|
|
202
|
+
},
|
|
203
|
+
});
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
// Reads the CURRENT object for a key rather than closing over the one that was focused at build
|
|
207
|
+
// time - the accessor is what makes `setParams` reach a mounted screen's useRoute().
|
|
208
|
+
function routeFor(routeKey) {
|
|
209
|
+
const found = state().routes.find(route => route.key === routeKey);
|
|
210
|
+
return found ?? { key: routeKey, name: '', params: undefined };
|
|
211
|
+
}
|
|
212
|
+
const contentHost = hostElement('symbiote-view', () => ({
|
|
213
|
+
style: TAB_CONTENT_STYLE,
|
|
214
|
+
}));
|
|
215
|
+
insert(contentHost, content);
|
|
216
|
+
const root = hostElement('symbiote-view', () => ({ style: TAB_ROOT_STYLE }));
|
|
217
|
+
// ONE array insert rather than two: a second `insert` on the same parent would find the first
|
|
218
|
+
// child already there and REPLACE it (solid-js/universal's insertExpression), while an array is
|
|
219
|
+
// reconciled by identity - contentHost keeps its node, only the bar is swapped when it rebuilds.
|
|
220
|
+
insert(root, () => [contentHost, tabBar()]);
|
|
221
|
+
return createComponent(ScreenCollectorProvider, {
|
|
222
|
+
value: collector,
|
|
223
|
+
get children() {
|
|
224
|
+
return [props.children, root];
|
|
225
|
+
},
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
export const Tab = Object.assign(TabImpl, { Screen: TabScreen });
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ISearchBarCommands } from '../core';
|
|
2
|
+
export declare function hostProps(props: Record<string, unknown>): (node: unknown) => void;
|
|
3
|
+
export declare function searchBarRef(ref: {
|
|
4
|
+
current: ISearchBarCommands | null;
|
|
5
|
+
} | undefined): (node: unknown) => (() => void) | void;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// Svelte attachments (`{@attach ...}`) for the react-native-screens native leaves.
|
|
2
|
+
//
|
|
3
|
+
// WHY THESE EXIST AT ALL: every react-native-screens Fabric view name is capitalized and
|
|
4
|
+
// un-hyphenated (RNSScreen, RNSScreenStack, RNSScreenStackHeaderConfig, RNSSearchBar, ...), so a
|
|
5
|
+
// literal `<RNSScreen>` in a Svelte template parses as a COMPONENT reference, not an element -
|
|
6
|
+
// the same wall @symbiote-native/slider's 'RNCSlider' leaf hit. Slider sidestepped it by mounting
|
|
7
|
+
// the whole leaf through the Descriptor bridge, which works because that leaf carries no live
|
|
8
|
+
// framework children. A stack screen DOES (the app's own screen component lives inside
|
|
9
|
+
// RNSScreenContentWrapper), so the bridge is not an option here.
|
|
10
|
+
//
|
|
11
|
+
// The way through is `<svelte:element this={'RNSScreen'}>`: it creates the element via
|
|
12
|
+
// `document.createElement(tag)` with a plain runtime string the compiler never inspects, and it
|
|
13
|
+
// accepts ordinary framework children. Its one catch is documented in svelte-adapter-dom-shim
|
|
14
|
+
// skill §15 - a dynamic tag compiles through Svelte's generic setAttribute/property-diffing
|
|
15
|
+
// codegen, NOT the custom-element `p=` property-SET path, so writing `p={bag}` as an ATTRIBUTE on
|
|
16
|
+
// it silently fails. An attachment bypasses that entirely: it is handed the raw element and
|
|
17
|
+
// assigns the property from plain JS, then re-runs whenever the props it read change. Verified
|
|
18
|
+
// against the real compiler + the real shim before this was built on.
|
|
19
|
+
import { dlog, isSymbioteNode } from '@symbiote-native/engine';
|
|
20
|
+
import { buildSearchBarHandle } from '../core/index.js';
|
|
21
|
+
// `unknown` rather than `Element`: the value Svelte hands an attachment is one of the DOM shim's
|
|
22
|
+
// own element classes, not a real DOM Element, and a function accepting `unknown` is still
|
|
23
|
+
// assignable everywhere Svelte expects `(element: Element) => ...`.
|
|
24
|
+
function isShimElement(value) {
|
|
25
|
+
return typeof value === 'object' && value !== null && 'engineNode' in value;
|
|
26
|
+
}
|
|
27
|
+
// The object-bag prop set, the same entry point every adapter's props go through (routeProp).
|
|
28
|
+
// Re-runs on every change of `props`, and the shim's own `p` setter diffs per key from there.
|
|
29
|
+
export function hostProps(props) {
|
|
30
|
+
return node => {
|
|
31
|
+
if (!isShimElement(node)) {
|
|
32
|
+
dlog('navigation: hostProps attached to a non-shim element, ignored');
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
node.p = props;
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
// The Svelte twin of Angular's SearchBarRefDirective / React's and Vue's callback `ref` on the
|
|
39
|
+
// RNSSearchBar element: fills the app-supplied cell once the native node exists and clears it on
|
|
40
|
+
// teardown. buildSearchBarHandle's own getter is LAZY, so handing it the node here is safe even
|
|
41
|
+
// before the first commit.
|
|
42
|
+
export function searchBarRef(ref) {
|
|
43
|
+
return node => {
|
|
44
|
+
if (ref === undefined)
|
|
45
|
+
return;
|
|
46
|
+
if (!isShimElement(node)) {
|
|
47
|
+
ref.current = null;
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const engineNode = node.engineNode;
|
|
51
|
+
if (!isSymbioteNode(engineNode)) {
|
|
52
|
+
dlog('navigation: search bar attachment ran before the shim went live');
|
|
53
|
+
ref.current = null;
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
ref.current = buildSearchBarHandle(() => engineNode);
|
|
57
|
+
return () => {
|
|
58
|
+
ref.current = null;
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// A shape-CHANGE-tolerant wrapper over @symbiote-native/svelte's Descriptor bridge.
|
|
2
|
+
//
|
|
3
|
+
// `mountDescriptorChildren` (svelte-adapter-dom-shim skill §19) is deliberately shape-stable: it
|
|
4
|
+
// builds each shim node once and only re-sets props thereafter, throwing if the tree shape ever
|
|
5
|
+
// changes, because every `core/components` render-*.ts produces a constant shape. The navigation
|
|
6
|
+
// package's tab bar is the exception - `renderTabBar` emits one child per registered route, and
|
|
7
|
+
// that count genuinely varies (it is 0 until the `<Tab.Screen>` markers have registered, and
|
|
8
|
+
// changes again if a screen is added or removed). Same situation @symbiote-native/slider's own
|
|
9
|
+
// steps-indicator overlay is in, and the same resolution: keep the fast path for the common
|
|
10
|
+
// "same shape, new prop values" case and rebuild only when the shape actually changed.
|
|
11
|
+
//
|
|
12
|
+
// The shape signature covers types and nesting, not just the top-level count, because a tab bar
|
|
13
|
+
// item's own children vary too (an item gains an icon wrapper only when it has an icon or badge).
|
|
14
|
+
import { mountDescriptorChildren } from '@symbiote-native/svelte/native-view-bridge';
|
|
15
|
+
const TEXT_CHILD_MARK = '#';
|
|
16
|
+
function shapeOf(children) {
|
|
17
|
+
return children
|
|
18
|
+
.map(child => typeof child === 'string'
|
|
19
|
+
? TEXT_CHILD_MARK
|
|
20
|
+
: `${child.type}(${shapeOf(child.children)})`)
|
|
21
|
+
.join(',');
|
|
22
|
+
}
|
|
23
|
+
export function createDescriptorSubtreeSync() {
|
|
24
|
+
let mounted;
|
|
25
|
+
let shape;
|
|
26
|
+
return (host, children) => {
|
|
27
|
+
if (host === null)
|
|
28
|
+
return;
|
|
29
|
+
const nextShape = shapeOf(children);
|
|
30
|
+
if (mounted === undefined || nextShape !== shape) {
|
|
31
|
+
for (const child of host.children.slice())
|
|
32
|
+
host.removeChild(child);
|
|
33
|
+
mounted = mountDescriptorChildren(host, children);
|
|
34
|
+
shape = nextShape;
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
mounted.update(children);
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { IStyleProp, IViewStyle } from '@symbiote-native/engine';
|
|
3
|
+
import type { IDrawerDescriptorMap, IDrawerNavigatorHandle, IDrawerOptions, IDrawerRouterState } from '../../core';
|
|
4
|
+
export type IDrawerContentSlotProps = {
|
|
5
|
+
state: IDrawerRouterState;
|
|
6
|
+
descriptors: IDrawerDescriptorMap;
|
|
7
|
+
navigation: IDrawerNavigatorHandle;
|
|
8
|
+
};
|
|
9
|
+
export type IDrawerProps = IDrawerOptions & {
|
|
10
|
+
initialRouteName?: string;
|
|
11
|
+
drawerStyle?: IStyleProp<IViewStyle>;
|
|
12
|
+
children?: Snippet;
|
|
13
|
+
drawerContent?: Snippet<[IDrawerContentSlotProps]>;
|
|
14
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const Drawer: import("svelte").Component<import("./drawer-props").IDrawerProps, {
|
|
2
|
+
openDrawer: () => void;
|
|
3
|
+
closeDrawer: () => void;
|
|
4
|
+
toggleDrawer: () => void;
|
|
5
|
+
jumpTo: (name: string) => void;
|
|
6
|
+
}, ""> & {
|
|
7
|
+
Screen: import("svelte").Component<import("..").IDrawerScreenProps, {}, "">;
|
|
8
|
+
};
|
|
9
|
+
export type { IDrawerNavigatorHandle, IDrawerDescriptorMap } from '../../core';
|
|
10
|
+
export type { IDrawerContentSlotProps, IDrawerProps } from './drawer-props';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// `Drawer.Screen` alongside the standalone `DrawerScreen` export, matching React's and Vue's
|
|
2
|
+
// barrels - see ../stack/index.ts for why Object.assign is the right mechanism on a compiled
|
|
3
|
+
// Svelte component.
|
|
4
|
+
import DrawerImpl from './index.svelte';
|
|
5
|
+
import DrawerScreen from '../drawer-screen.svelte';
|
|
6
|
+
export const Drawer = Object.assign(DrawerImpl, { Screen: DrawerScreen });
|