@molecule/app-svelte 3.9.0 → 3.10.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 +18 -3
- package/dist/context.d.ts +11 -3
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +14 -8
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/providers/Provided.svelte +12 -4
- package/dist/providers/Provided.svelte.d.ts +3 -2
- package/dist/providers/Provided.svelte.d.ts.map +1 -1
- package/dist/providers/RouterProvider.svelte +8 -5
- package/dist/providers/RouterProvider.svelte.d.ts.map +1 -1
- package/dist/routed-view/RoutedView.svelte +13 -0
- package/dist/routed-view/RoutedView.svelte.d.ts +19 -0
- package/dist/routed-view/RoutedView.svelte.d.ts.map +1 -0
- package/dist/routed-view/index.d.ts +8 -0
- package/dist/routed-view/index.d.ts.map +1 -0
- package/dist/routed-view/index.js +7 -0
- package/dist/routed-view-context.d.ts +25 -0
- package/dist/routed-view-context.d.ts.map +1 -0
- package/dist/routed-view-context.js +34 -0
- package/dist/types.d.ts +8 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
|
|
|
3
3
|
Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
|
|
4
4
|
Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
|
|
5
5
|
To change this document, edit the module-level JSDoc in src/index.ts.
|
|
6
|
-
Generated: 2026-11-
|
|
6
|
+
Generated: 2026-11-22T07:13:44.407Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/app-svelte
|
|
@@ -2399,6 +2399,13 @@ Props for the `RouterProvider` component.
|
|
|
2399
2399
|
```typescript
|
|
2400
2400
|
interface RouterProviderProps extends ProviderProps {
|
|
2401
2401
|
router: Router
|
|
2402
|
+
/**
|
|
2403
|
+
* The component that renders the matched child route where a layout or guard puts it, so
|
|
2404
|
+
* `<RoutedView />` works under any routing bond. A routing bond passes it; leave it out when
|
|
2405
|
+
* the bond has none (SvelteKit gives a layout its page as `children`), and `<RoutedView />`
|
|
2406
|
+
* then throws an error saying so.
|
|
2407
|
+
*/
|
|
2408
|
+
routedView?: Component
|
|
2402
2409
|
}
|
|
2403
2410
|
```
|
|
2404
2411
|
|
|
@@ -2825,15 +2832,17 @@ function setThemeContext(provider: ThemeProvider): void
|
|
|
2825
2832
|
|
|
2826
2833
|
- `provider` — The theme provider to store in Svelte context.
|
|
2827
2834
|
|
|
2828
|
-
#### `setRouterContext(router)`
|
|
2835
|
+
#### `setRouterContext(router, options)`
|
|
2829
2836
|
|
|
2830
2837
|
Sets the router context.
|
|
2831
2838
|
|
|
2832
2839
|
```typescript
|
|
2833
|
-
function setRouterContext(router: Router): void
|
|
2840
|
+
function setRouterContext(router: Router, options?: { routedView?: Component }): void
|
|
2834
2841
|
```
|
|
2835
2842
|
|
|
2836
2843
|
- `router` — The router instance to store in Svelte context.
|
|
2844
|
+
- `options` — From a routing bond: its routed view (see `RoutedView`). Given, it is set too (`null` without `routedView`).
|
|
2845
|
+
- `options.routedView` — The component that renders the matched child route.
|
|
2837
2846
|
|
|
2838
2847
|
#### `setI18nContext(provider)`
|
|
2839
2848
|
|
|
@@ -4873,6 +4882,12 @@ function createVersionStores(): {
|
|
|
4873
4882
|
const Link: LegacyComponentType
|
|
4874
4883
|
```
|
|
4875
4884
|
|
|
4885
|
+
#### `RoutedView`
|
|
4886
|
+
|
|
4887
|
+
```typescript
|
|
4888
|
+
const RoutedView: LegacyComponentType
|
|
4889
|
+
```
|
|
4890
|
+
|
|
4876
4891
|
#### `SessionReady`
|
|
4877
4892
|
|
|
4878
4893
|
```typescript
|
package/dist/context.d.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
|
+
import type { Component } from 'svelte';
|
|
6
7
|
import type { ChatProvider } from '@molecule/app-ai-chat';
|
|
7
8
|
import type { AuthClient, RegisterExtraShape } from '@molecule/app-auth';
|
|
8
9
|
import type { EditorProvider } from '@molecule/app-code-editor';
|
|
@@ -61,8 +62,13 @@ export declare function setThemeContext(provider: ThemeProvider): void;
|
|
|
61
62
|
/**
|
|
62
63
|
* Sets the router context.
|
|
63
64
|
* @param router - The router instance to store in Svelte context.
|
|
65
|
+
* @param options - From a routing bond: its routed view (see `RoutedView`). Given, it is set
|
|
66
|
+
* too (`null` without `routedView`).
|
|
67
|
+
* @param options.routedView - The component that renders the matched child route.
|
|
64
68
|
*/
|
|
65
|
-
export declare function setRouterContext(router: Router
|
|
69
|
+
export declare function setRouterContext(router: Router, options?: {
|
|
70
|
+
routedView?: Component;
|
|
71
|
+
}): void;
|
|
66
72
|
/**
|
|
67
73
|
* Sets the i18n context.
|
|
68
74
|
* @param provider - The i18n provider to store in Svelte context.
|
|
@@ -124,7 +130,8 @@ export declare function getThemeProvider(): ThemeProvider;
|
|
|
124
130
|
/**
|
|
125
131
|
* Gets the router from Svelte context.
|
|
126
132
|
* @returns The router instance.
|
|
127
|
-
* @throws {
|
|
133
|
+
* @throws {I18nError} If no router has been set in context: mount the routing bond's
|
|
134
|
+
* `MoleculeRouterProvider` in the root `+layout.svelte`, or call `setMoleculeContext({ router })`.
|
|
128
135
|
*/
|
|
129
136
|
export declare function getRouter(): Router;
|
|
130
137
|
/**
|
|
@@ -207,7 +214,8 @@ export declare function useThemeProvider(): ThemeProvider;
|
|
|
207
214
|
/**
|
|
208
215
|
* Gets the router from Svelte context under the React hook's name.
|
|
209
216
|
* @returns The router instance.
|
|
210
|
-
* @throws {
|
|
217
|
+
* @throws {I18nError} If no router has been set in context: mount the routing bond's
|
|
218
|
+
* `MoleculeRouterProvider` in the root `+layout.svelte`, or call `setMoleculeContext({ router })`.
|
|
211
219
|
*/
|
|
212
220
|
export declare function useRouterInstance(): Router;
|
|
213
221
|
/**
|
package/dist/context.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAGvC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AACxE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAGxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAgBhD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,cAAc,GAAG,IAAI,CAgB/D;AAGD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI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|
7
|
-
import { getProvider as getBondedI18nProvider, t } from '@molecule/app-i18n';
|
|
7
|
+
import { getProvider as getBondedI18nProvider, I18nError, t } from '@molecule/app-i18n';
|
|
8
8
|
import { getProvider as getBondedStateProvider, hasProvider as hasBondedStateProvider, } from '@molecule/app-state';
|
|
9
|
+
import { setRoutedViewContext } from './routed-view-context.js';
|
|
9
10
|
// Context keys
|
|
10
11
|
const STATE_KEY = Symbol('molecule-state');
|
|
11
12
|
const AUTH_KEY = Symbol('molecule-auth');
|
|
@@ -99,9 +100,14 @@ export function setThemeContext(provider) {
|
|
|
99
100
|
/**
|
|
100
101
|
* Sets the router context.
|
|
101
102
|
* @param router - The router instance to store in Svelte context.
|
|
103
|
+
* @param options - From a routing bond: its routed view (see `RoutedView`). Given, it is set
|
|
104
|
+
* too (`null` without `routedView`).
|
|
105
|
+
* @param options.routedView - The component that renders the matched child route.
|
|
102
106
|
*/
|
|
103
|
-
export function setRouterContext(router) {
|
|
107
|
+
export function setRouterContext(router, options) {
|
|
104
108
|
setContext(ROUTER_KEY, router);
|
|
109
|
+
if (options)
|
|
110
|
+
setRoutedViewContext(options.routedView ?? null);
|
|
105
111
|
}
|
|
106
112
|
/**
|
|
107
113
|
* Sets the i18n context.
|
|
@@ -202,12 +208,13 @@ export function getThemeProvider() {
|
|
|
202
208
|
/**
|
|
203
209
|
* Gets the router from Svelte context.
|
|
204
210
|
* @returns The router instance.
|
|
205
|
-
* @throws {
|
|
211
|
+
* @throws {I18nError} If no router has been set in context: mount the routing bond's
|
|
212
|
+
* `MoleculeRouterProvider` in the root `+layout.svelte`, or call `setMoleculeContext({ router })`.
|
|
206
213
|
*/
|
|
207
214
|
export function getRouter() {
|
|
208
215
|
const router = getContext(ROUTER_KEY);
|
|
209
216
|
if (!router)
|
|
210
|
-
throw new
|
|
217
|
+
throw new I18nError('svelte.error.noRouter', undefined, 'No router here. Mount `MoleculeRouterProvider` from the routing bond (`@molecule/app-routing-sveltekit`) in the root `+layout.svelte`, or call `setMoleculeContext({ router })` there.');
|
|
211
218
|
return router;
|
|
212
219
|
}
|
|
213
220
|
/**
|
|
@@ -362,14 +369,13 @@ export function useThemeProvider() {
|
|
|
362
369
|
/**
|
|
363
370
|
* Gets the router from Svelte context under the React hook's name.
|
|
364
371
|
* @returns The router instance.
|
|
365
|
-
* @throws {
|
|
372
|
+
* @throws {I18nError} If no router has been set in context: mount the routing bond's
|
|
373
|
+
* `MoleculeRouterProvider` in the root `+layout.svelte`, or call `setMoleculeContext({ router })`.
|
|
366
374
|
*/
|
|
367
375
|
export function useRouterInstance() {
|
|
368
376
|
const router = getContext(ROUTER_KEY);
|
|
369
377
|
if (!router)
|
|
370
|
-
throw new
|
|
371
|
-
defaultValue: 'useRouterInstance must be used within a RouterProvider',
|
|
372
|
-
}));
|
|
378
|
+
throw new I18nError('svelte.error.useRouterOutsideProvider', undefined, 'No router here. Mount `MoleculeRouterProvider` from the routing bond (`@molecule/app-routing-sveltekit`) in the root `+layout.svelte`, or call `setMoleculeContext({ router })` there.');
|
|
373
379
|
return router;
|
|
374
380
|
}
|
|
375
381
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -141,6 +141,7 @@ export * from './context.js';
|
|
|
141
141
|
export * from './hooks/index.js';
|
|
142
142
|
export * from './link/index.js';
|
|
143
143
|
export * from './providers/index.js';
|
|
144
|
+
export * from './routed-view/index.js';
|
|
144
145
|
export * from './session-ready/index.js';
|
|
145
146
|
export * from './stores/index.js';
|
|
146
147
|
export * from './types.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyIG;AAEH,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,sBAAsB,CAAA;AACpC,cAAc,0BAA0B,CAAA;AACxC,cAAc,mBAAmB,CAAA;AACjC,cAAc,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyIG;AAEH,cAAc,qBAAqB,CAAA;AACnC,cAAc,cAAc,CAAA;AAC5B,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,sBAAsB,CAAA;AACpC,cAAc,wBAAwB,CAAA;AACtC,cAAc,0BAA0B,CAAA;AACxC,cAAc,mBAAmB,CAAA;AACjC,cAAc,YAAY,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -141,6 +141,7 @@ export * from './context.js';
|
|
|
141
141
|
export * from './hooks/index.js';
|
|
142
142
|
export * from './link/index.js';
|
|
143
143
|
export * from './providers/index.js';
|
|
144
|
+
export * from './routed-view/index.js';
|
|
144
145
|
export * from './session-ready/index.js';
|
|
145
146
|
export * from './stores/index.js';
|
|
146
147
|
export * from './types.js';
|
|
@@ -4,16 +4,24 @@
|
|
|
4
4
|
`{#key servicesKey(services)}`, so a replaced service initializes it again.
|
|
5
5
|
-->
|
|
6
6
|
<script lang="ts">
|
|
7
|
-
import { type Snippet, untrack } from 'svelte'
|
|
7
|
+
import { type Component, type Snippet, untrack } from 'svelte'
|
|
8
8
|
|
|
9
|
+
import { setRoutedViewContext } from '../routed-view-context.js'
|
|
9
10
|
import type { MoleculeConfig } from '../types.js'
|
|
10
11
|
import { setServiceContexts } from './services.js'
|
|
11
12
|
|
|
12
|
-
let {
|
|
13
|
+
let {
|
|
14
|
+
services,
|
|
15
|
+
routedView,
|
|
16
|
+
children,
|
|
17
|
+
}: { services: MoleculeConfig; routedView?: Component | null; children?: Snippet } = $props()
|
|
13
18
|
|
|
14
19
|
// Context is set once, at initialization; the parent's `{#key}` re-creates this
|
|
15
|
-
// component when a service changes.
|
|
16
|
-
untrack(() =>
|
|
20
|
+
// component when a service changes. `routedView` is set only by RouterProvider.
|
|
21
|
+
untrack(() => {
|
|
22
|
+
setServiceContexts(services)
|
|
23
|
+
if (routedView !== undefined) setRoutedViewContext(routedView)
|
|
24
|
+
})
|
|
17
25
|
</script>
|
|
18
26
|
|
|
19
27
|
{@render children?.()}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { type Snippet } from 'svelte';
|
|
1
|
+
import { type Component, type Snippet } from 'svelte';
|
|
2
2
|
import type { MoleculeConfig } from '../types.js';
|
|
3
3
|
type $$ComponentProps = {
|
|
4
4
|
services: MoleculeConfig;
|
|
5
|
+
routedView?: Component | null;
|
|
5
6
|
children?: Snippet;
|
|
6
7
|
};
|
|
7
|
-
declare const Provided:
|
|
8
|
+
declare const Provided: Component<$$ComponentProps, {}, "">;
|
|
8
9
|
type Provided = ReturnType<typeof Provided>;
|
|
9
10
|
export default Provided;
|
|
10
11
|
//# sourceMappingURL=Provided.svelte.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Provided.svelte.d.ts","sourceRoot":"","sources":["../../src/providers/Provided.svelte"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,OAAO,EAAW,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"Provided.svelte.d.ts","sourceRoot":"","sources":["../../src/providers/Provided.svelte"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,OAAO,EAAW,MAAM,QAAQ,CAAA;AAG9D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAGhD,KAAK,gBAAgB,GAAI;IAAE,QAAQ,EAAE,cAAc,CAAC;IAAC,UAAU,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AA2B1G,QAAA,MAAM,QAAQ,qCAAwC,CAAC;AACvD,KAAK,QAAQ,GAAG,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC;AAC5C,eAAe,QAAQ,CAAC"}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
<!--
|
|
2
|
-
Provider for routing, as @molecule/app-react's RouterProvider
|
|
2
|
+
Provider for routing, as @molecule/app-react's RouterProvider: the router and, from a routing
|
|
3
|
+
bond that has one, the routed view RoutedView renders (none without one).
|
|
3
4
|
-->
|
|
4
5
|
<script lang="ts">
|
|
5
6
|
import type { RouterProviderProps } from '../types.js'
|
|
6
7
|
import Provided from './Provided.svelte'
|
|
7
8
|
|
|
8
|
-
let { router, children }: RouterProviderProps = $props()
|
|
9
|
+
let { router, routedView, children }: RouterProviderProps = $props()
|
|
9
10
|
</script>
|
|
10
11
|
|
|
11
12
|
{#key router}
|
|
12
|
-
|
|
13
|
-
{
|
|
14
|
-
|
|
13
|
+
{#key routedView}
|
|
14
|
+
<Provided services={{ router }} routedView={routedView ?? null}>
|
|
15
|
+
{@render children?.()}
|
|
16
|
+
</Provided>
|
|
17
|
+
{/key}
|
|
15
18
|
{/key}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RouterProvider.svelte.d.ts","sourceRoot":"","sources":["../../src/providers/RouterProvider.svelte"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"RouterProvider.svelte.d.ts","sourceRoot":"","sources":["../../src/providers/RouterProvider.svelte"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAA;AAqBtD,QAAA,MAAM,cAAc,yDAAwC,CAAC;AAC7D,KAAK,cAAc,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AACxD,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Renders the matched child route, as @molecule/app-react's RoutedView, through whichever routing
|
|
3
|
+
bond the app wired. A layout or guard renders it where its page goes when it was given no
|
|
4
|
+
children. It throws when the routing bond has no routed view (SvelteKit gives a layout its page
|
|
5
|
+
as `children`): rendering nothing there would show a blank page with no error.
|
|
6
|
+
-->
|
|
7
|
+
<script lang="ts">
|
|
8
|
+
import { routedViewOrThrow } from '../routed-view-context.js'
|
|
9
|
+
|
|
10
|
+
const View = routedViewOrThrow()
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<View />
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
+
$$bindings?: Bindings;
|
|
4
|
+
} & Exports;
|
|
5
|
+
(internal: unknown, props: {
|
|
6
|
+
$$events?: Events;
|
|
7
|
+
$$slots?: Slots;
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
11
|
+
};
|
|
12
|
+
z_$$bindings?: Bindings;
|
|
13
|
+
}
|
|
14
|
+
declare const RoutedView: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
15
|
+
[evt: string]: CustomEvent<any>;
|
|
16
|
+
}, {}, {}, string>;
|
|
17
|
+
type RoutedView = InstanceType<typeof RoutedView>;
|
|
18
|
+
export default RoutedView;
|
|
19
|
+
//# sourceMappingURL=RoutedView.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RoutedView.svelte.d.ts","sourceRoot":"","sources":["../../src/routed-view/RoutedView.svelte"],"names":[],"mappings":"AAgBA,UAAU,kCAAkC,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,OAAO,GAAG,EAAE,EAAE,QAAQ,GAAG,MAAM;IACpM,KAAK,OAAO,EAAE,OAAO,QAAQ,EAAE,2BAA2B,CAAC,KAAK,CAAC,GAAG,OAAO,QAAQ,EAAE,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,GAAG;QAAE,UAAU,CAAC,EAAE,QAAQ,CAAA;KAAE,GAAG,OAAO,CAAC;IACjK,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,KAAK,CAAA;KAAC,GAAG,OAAO,GAAG;QAAE,IAAI,CAAC,EAAE,GAAG,CAAC;QAAC,GAAG,CAAC,EAAE,GAAG,CAAA;KAAE,CAAC;IACtG,YAAY,CAAC,EAAE,QAAQ,CAAC;CAC3B;AAKD,QAAA,MAAM,UAAU;;kBAA+E,CAAC;AAC9E,KAAK,UAAU,GAAG,YAAY,CAAC,OAAO,UAAU,CAAC,CAAC;AACpD,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/routed-view/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,qBAAqB,CAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The routed view's Svelte context. Kept out of the package's exports, as in
|
|
3
|
+
* `@molecule/app-react`: a routed view is provided only with a router (`RouterProvider`'s
|
|
4
|
+
* `routedView`, or `setRouterContext(router, { routedView })`).
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import type { Component } from 'svelte';
|
|
9
|
+
/**
|
|
10
|
+
* Sets the component the routing bond renders where the matched child route goes. Call it
|
|
11
|
+
* during component initialization.
|
|
12
|
+
*
|
|
13
|
+
* @param view - The routed view, or `null` when the routing bond has none.
|
|
14
|
+
*/
|
|
15
|
+
export declare function setRoutedViewContext(view: Component | null): void;
|
|
16
|
+
/**
|
|
17
|
+
* The routed view from Svelte context, for `RoutedView`. Call it during component
|
|
18
|
+
* initialization.
|
|
19
|
+
*
|
|
20
|
+
* @returns The routing bond's routed view.
|
|
21
|
+
* @throws {I18nError} When the routing bond has none (SvelteKit gives a layout its page as
|
|
22
|
+
* `children`).
|
|
23
|
+
*/
|
|
24
|
+
export declare function routedViewOrThrow(): Component;
|
|
25
|
+
//# sourceMappingURL=routed-view-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routed-view-context.d.ts","sourceRoot":"","sources":["../src/routed-view-context.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAOvC;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI,GAAG,IAAI,CAEjE;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,IAAI,SAAS,CAU7C"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The routed view's Svelte context. Kept out of the package's exports, as in
|
|
3
|
+
* `@molecule/app-react`: a routed view is provided only with a router (`RouterProvider`'s
|
|
4
|
+
* `routedView`, or `setRouterContext(router, { routedView })`).
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import { getContext, setContext } from 'svelte';
|
|
9
|
+
import { I18nError } from '@molecule/app-i18n';
|
|
10
|
+
const ROUTED_VIEW_KEY = Symbol('molecule-routed-view');
|
|
11
|
+
/**
|
|
12
|
+
* Sets the component the routing bond renders where the matched child route goes. Call it
|
|
13
|
+
* during component initialization.
|
|
14
|
+
*
|
|
15
|
+
* @param view - The routed view, or `null` when the routing bond has none.
|
|
16
|
+
*/
|
|
17
|
+
export function setRoutedViewContext(view) {
|
|
18
|
+
setContext(ROUTED_VIEW_KEY, view);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The routed view from Svelte context, for `RoutedView`. Call it during component
|
|
22
|
+
* initialization.
|
|
23
|
+
*
|
|
24
|
+
* @returns The routing bond's routed view.
|
|
25
|
+
* @throws {I18nError} When the routing bond has none (SvelteKit gives a layout its page as
|
|
26
|
+
* `children`).
|
|
27
|
+
*/
|
|
28
|
+
export function routedViewOrThrow() {
|
|
29
|
+
const view = getContext(ROUTED_VIEW_KEY);
|
|
30
|
+
if (!view) {
|
|
31
|
+
throw new I18nError('svelte.error.noRoutedView', undefined, 'No routed view here. SvelteKit gives a layout its page as `children`: pass `{@render children()}` inside this component.');
|
|
32
|
+
}
|
|
33
|
+
return view;
|
|
34
|
+
}
|
package/dist/types.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
|
-
import type { Snippet } from 'svelte';
|
|
6
|
+
import type { Component, Snippet } from 'svelte';
|
|
7
7
|
import type { Readable, Writable } from 'svelte/store';
|
|
8
8
|
import type { ChatProvider } from '@molecule/app-ai-chat';
|
|
9
9
|
import type { AuthClient, AuthState } from '@molecule/app-auth';
|
|
@@ -92,6 +92,13 @@ export interface ThemeProviderProps extends ProviderProps {
|
|
|
92
92
|
*/
|
|
93
93
|
export interface RouterProviderProps extends ProviderProps {
|
|
94
94
|
router: Router;
|
|
95
|
+
/**
|
|
96
|
+
* The component that renders the matched child route where a layout or guard puts it, so
|
|
97
|
+
* `<RoutedView />` works under any routing bond. A routing bond passes it; leave it out when
|
|
98
|
+
* the bond has none (SvelteKit gives a layout its page as `children`), and `<RoutedView />`
|
|
99
|
+
* then throws an error saying so.
|
|
100
|
+
*/
|
|
101
|
+
routedView?: Component;
|
|
95
102
|
}
|
|
96
103
|
/**
|
|
97
104
|
* Props for the `I18nProvider` component.
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAEtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACxF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAA;AACjE,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,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