@molecule/app-angular 3.5.0 → 3.6.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 +262 -84
- package/dist/chat.d.ts.map +1 -1
- package/dist/chat.js +3 -2
- package/dist/chat.js.map +1 -1
- package/dist/hooks/use-ai-models.d.ts +10 -3
- package/dist/hooks/use-ai-models.d.ts.map +1 -1
- package/dist/hooks/use-ai-models.js +40 -15
- package/dist/hooks/use-ai-models.js.map +1 -1
- package/dist/hooks/use-async.d.ts +10 -6
- package/dist/hooks/use-async.d.ts.map +1 -1
- package/dist/hooks/use-async.js +38 -33
- package/dist/hooks/use-async.js.map +1 -1
- package/dist/hooks/use-auth-flows.d.ts +40 -21
- package/dist/hooks/use-auth-flows.d.ts.map +1 -1
- package/dist/hooks/use-auth-flows.js +59 -38
- package/dist/hooks/use-auth-flows.js.map +1 -1
- package/dist/hooks/use-auth.d.ts +7 -2
- package/dist/hooks/use-auth.d.ts.map +1 -1
- package/dist/hooks/use-auth.js +24 -9
- package/dist/hooks/use-auth.js.map +1 -1
- package/dist/hooks/use-forms.d.ts +8 -11
- package/dist/hooks/use-forms.d.ts.map +1 -1
- package/dist/hooks/use-forms.js +89 -53
- package/dist/hooks/use-forms.js.map +1 -1
- package/dist/hooks/use-http.d.ts +40 -32
- package/dist/hooks/use-http.d.ts.map +1 -1
- package/dist/hooks/use-http.js +79 -93
- package/dist/hooks/use-http.js.map +1 -1
- package/dist/hooks/use-native.d.ts +7 -2
- package/dist/hooks/use-native.d.ts.map +1 -1
- package/dist/hooks/use-native.js +27 -12
- package/dist/hooks/use-native.js.map +1 -1
- package/dist/hooks/use-router.d.ts +11 -4
- package/dist/hooks/use-router.d.ts.map +1 -1
- package/dist/hooks/use-router.js +21 -6
- package/dist/hooks/use-router.js.map +1 -1
- package/dist/hooks/use-storage.d.ts +20 -6
- package/dist/hooks/use-storage.d.ts.map +1 -1
- package/dist/hooks/use-storage.js +147 -65
- package/dist/hooks/use-storage.js.map +1 -1
- package/dist/hooks/use-store.d.ts +10 -3
- package/dist/hooks/use-store.d.ts.map +1 -1
- package/dist/hooks/use-store.js +49 -9
- package/dist/hooks/use-store.js.map +1 -1
- package/dist/hooks/use-translation.d.ts +7 -2
- package/dist/hooks/use-translation.d.ts.map +1 -1
- package/dist/hooks/use-translation.js +11 -5
- package/dist/hooks/use-translation.js.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/link.d.ts +63 -0
- package/dist/link.d.ts.map +1 -0
- package/dist/link.js +82 -0
- package/dist/link.js.map +1 -0
- package/dist/maybe-signal.d.ts +26 -0
- package/dist/maybe-signal.d.ts.map +1 -0
- package/dist/maybe-signal.js +20 -0
- package/dist/maybe-signal.js.map +1 -0
- package/package.json +2 -2
- package/dist/site.d.ts +0 -51
- package/dist/site.d.ts.map +0 -1
- package/dist/site.js +0 -69
- package/dist/site.js.map +0 -1
package/dist/hooks/use-store.js
CHANGED
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @module
|
|
6
6
|
*/
|
|
7
|
-
import { inject } from '@angular/core';
|
|
7
|
+
import { effect, inject, untracked } from '@angular/core';
|
|
8
8
|
import { t } from '@molecule/app-i18n';
|
|
9
|
+
import { readMaybeSignal } from '../maybe-signal.js';
|
|
9
10
|
import { STATE_PROVIDER } from '../tokens.js';
|
|
10
11
|
import { useExternalStore } from './external-store.js';
|
|
11
12
|
/**
|
|
@@ -51,27 +52,66 @@ export function useStateProvider() {
|
|
|
51
52
|
* `createStoreWithActions()` / `createStore()` a provider package exports — is
|
|
52
53
|
* therefore as valid here as one `@molecule/app-state`'s `createStore()` made.
|
|
53
54
|
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
55
|
+
* The arguments may be signals: a new store is subscribed in place of the old
|
|
56
|
+
* one (the old subscription is dropped first) and new options are applied on
|
|
57
|
+
* the next read, the way React re-renders `useStore` with new arguments. The
|
|
58
|
+
* previous selected value the equality function compares survives the change,
|
|
59
|
+
* as React's ref does.
|
|
60
|
+
*
|
|
61
|
+
* @param store - The store to subscribe to (or a signal of it).
|
|
62
|
+
* @param options - Hook options (`selector`, `equalityFn`), or a signal of them.
|
|
56
63
|
* @returns A signal of the selected state.
|
|
57
64
|
*/
|
|
58
65
|
export function useStore(store, options) {
|
|
59
|
-
const
|
|
66
|
+
const initialOptions = readMaybeSignal(options);
|
|
67
|
+
let currentStore = readMaybeSignal(store);
|
|
68
|
+
let currentSelector = initialOptions?.selector;
|
|
69
|
+
let currentEquality = initialOptions?.equalityFn;
|
|
60
70
|
// The previous selected value for the equality comparison, exactly like
|
|
61
71
|
// React's ref: an equal selection keeps the previous result (its identity).
|
|
62
72
|
let prevSelected;
|
|
63
73
|
const read = () => {
|
|
64
|
-
const state =
|
|
65
|
-
const selected =
|
|
66
|
-
if (
|
|
67
|
-
if (
|
|
74
|
+
const state = currentStore.getState();
|
|
75
|
+
const selected = currentSelector ? currentSelector(state) : state;
|
|
76
|
+
if (currentEquality && prevSelected !== undefined) {
|
|
77
|
+
if (currentEquality(prevSelected, selected)) {
|
|
68
78
|
return prevSelected;
|
|
69
79
|
}
|
|
70
80
|
}
|
|
71
81
|
prevSelected = selected;
|
|
72
82
|
return selected;
|
|
73
83
|
};
|
|
74
|
-
|
|
84
|
+
// The store's notifications feed the external-store bridge's own callback
|
|
85
|
+
// (its read discipline); the subscription is re-keyed when the store source
|
|
86
|
+
// changes, as React's useSyncExternalStore re-subscribes when its store
|
|
87
|
+
// does.
|
|
88
|
+
let notifyStore = null;
|
|
89
|
+
let stop = null;
|
|
90
|
+
const state = useExternalStore(read, (notify) => {
|
|
91
|
+
notifyStore = notify;
|
|
92
|
+
stop = currentStore.subscribe(() => notify());
|
|
93
|
+
return () => stop?.();
|
|
94
|
+
});
|
|
95
|
+
effect(() => {
|
|
96
|
+
const nextStore = readMaybeSignal(store);
|
|
97
|
+
const nextOptions = readMaybeSignal(options);
|
|
98
|
+
const nextSelector = nextOptions?.selector;
|
|
99
|
+
const nextEquality = nextOptions?.equalityFn;
|
|
100
|
+
if (nextStore === currentStore &&
|
|
101
|
+
nextSelector === currentSelector &&
|
|
102
|
+
nextEquality === currentEquality) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
currentStore = nextStore;
|
|
106
|
+
currentSelector = nextSelector;
|
|
107
|
+
currentEquality = nextEquality;
|
|
108
|
+
untracked(() => {
|
|
109
|
+
stop?.();
|
|
110
|
+
stop = currentStore.subscribe(() => notifyStore?.());
|
|
111
|
+
notifyStore?.();
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
return state;
|
|
75
115
|
}
|
|
76
116
|
/**
|
|
77
117
|
* The store's `setState` function. Call it in an injection context.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-store.js","sourceRoot":"","sources":["../../src/hooks/use-store.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAe,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"use-store.js","sourceRoot":"","sources":["../../src/hooks/use-store.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAe,SAAS,EAAE,MAAM,eAAe,CAAA;AAEtE,OAAO,EAAE,CAAC,EAAE,MAAM,oBAAoB,CAAA;AAGtC,OAAO,EAAoB,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAqBtD;;;;;GAKG;AACH,MAAM,kBAAkB,GACtB,oEAAoE;IACpE,6DAA6D;IAC7D,yEAAyE;IACzE,0EAA0E;IAC1E,4DAA4D;IAC5D,wFAAwF;IACxF,0CAA0C,CAAA;AAE5C;;;;;;;;;;GAUG;AACH,MA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AAU,EAAK,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,IAAI,CAAC,CAAA;AAC9E,CAAC"}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { type Signal } from '@angular/core';
|
|
9
9
|
import type { DateFormatOptions, I18nProvider, InterpolationValues, NumberFormatOptions, TranslateOptions } from '@molecule/app-i18n';
|
|
10
|
+
import { type MaybeSignal } from '../maybe-signal.js';
|
|
10
11
|
/**
|
|
11
12
|
* The i18n provider registered by `provideMolecule({ i18n })` or
|
|
12
13
|
* `provideI18n`, otherwise the bonded `@molecule/app-i18n` provider — the one
|
|
@@ -79,8 +80,12 @@ export declare function useDirection(): Signal<'ltr' | 'rtl'>;
|
|
|
79
80
|
* the default value); a plain `Error` returns its message unchanged; no error
|
|
80
81
|
* returns `null`. Call it in an injection context.
|
|
81
82
|
*
|
|
82
|
-
*
|
|
83
|
+
* The error may be a signal: the message then follows a changed error on the
|
|
84
|
+
* same component, the way React re-renders `useI18nError` with a new argument.
|
|
85
|
+
*
|
|
86
|
+
* @param error - The error to translate, or `null`/`undefined` (or a signal of
|
|
87
|
+
* it).
|
|
83
88
|
* @returns A signal of the error's display text, or `null`.
|
|
84
89
|
*/
|
|
85
|
-
export declare function useI18nError(error: Error | null | undefined): Signal<string | null>;
|
|
90
|
+
export declare function useI18nError(error: MaybeSignal<Error | null | undefined>): Signal<string | null>;
|
|
86
91
|
//# sourceMappingURL=use-translation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-translation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-translation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAgC,KAAK,MAAM,EAAU,MAAM,eAAe,CAAA;AAEjF,OAAO,KAAK,EACV,iBAAiB,EACjB,YAAY,EACZ,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,E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GAaG;AACH,wBAAgB,IAAI,IAAI,CACtB,GAAG,EAAE,MAAM,EACX,eAAe,CAAC,EAAE,mBAAmB,GAAG,MAAM,EAC9C,OAAO,CAAC,EAAE,gBAAgB,KACvB,MAAM,CAcV;AAED;;;;GAIG;AACH,wBAAgB,SAAS,IAAI,MAAM,CAAC,MAAM,CAAC,CAE1C;AAED;;;;GAIG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC,CAEpD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,WAAW,CAAC,KAAK,GAAG,IAAI,GAAG,SAAS,CAAC,GAAG,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,CAchG"}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { computed, DestroyRef, inject, signal } from '@angular/core';
|
|
9
9
|
import { getProvider, I18nError } from '@molecule/app-i18n';
|
|
10
|
+
import { readMaybeSignal } from '../maybe-signal.js';
|
|
10
11
|
import { I18N_PROVIDER } from '../tokens.js';
|
|
11
12
|
/**
|
|
12
13
|
* The i18n provider registered by `provideMolecule({ i18n })` or
|
|
@@ -125,7 +126,11 @@ export function useDirection() {
|
|
|
125
126
|
* the default value); a plain `Error` returns its message unchanged; no error
|
|
126
127
|
* returns `null`. Call it in an injection context.
|
|
127
128
|
*
|
|
128
|
-
*
|
|
129
|
+
* The error may be a signal: the message then follows a changed error on the
|
|
130
|
+
* same component, the way React re-renders `useI18nError` with a new argument.
|
|
131
|
+
*
|
|
132
|
+
* @param error - The error to translate, or `null`/`undefined` (or a signal of
|
|
133
|
+
* it).
|
|
129
134
|
* @returns A signal of the error's display text, or `null`.
|
|
130
135
|
*/
|
|
131
136
|
export function useI18nError(error) {
|
|
@@ -135,12 +140,13 @@ export function useI18nError(error) {
|
|
|
135
140
|
// The notification count is the recompute key: the provider is read live
|
|
136
141
|
// inside, so the text follows locale changes like React's render-time read.
|
|
137
142
|
void notifications();
|
|
138
|
-
|
|
143
|
+
const current = readMaybeSignal(error);
|
|
144
|
+
if (!current)
|
|
139
145
|
return null;
|
|
140
|
-
if (
|
|
141
|
-
return provider.t(
|
|
146
|
+
if (current instanceof I18nError) {
|
|
147
|
+
return provider.t(current.i18nKey, current.i18nValues, { defaultValue: current.message });
|
|
142
148
|
}
|
|
143
|
-
return
|
|
149
|
+
return current.message;
|
|
144
150
|
});
|
|
145
151
|
}
|
|
146
152
|
//# sourceMappingURL=use-translation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-translation.js","sourceRoot":"","sources":["../../src/hooks/use-translation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAe,MAAM,EAAE,MAAM,eAAe,CAAA;AASjF,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAE3D,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAE5C;;;;;;GAMG;AACH,MAAM,UAAU,eAAe;IAC7B,MAAM,QAAQ,GAAG,MAAM,CAAC,aAAa,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;IAC1D,OAAO,QAAQ,IAAI,WAAW,EAAE,CAAA;AAClC,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,sBAAsB,CAAC,QAAsB;IACpD,MAAM,aAAa,GAAG,MAAM,CAAC,CAAC;sFAAC,CAAA;IAC/B,MAAM,IAAI,GAAG,QAAQ,CAAC,cAAc,CAAC,GAAG,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAA;IACtF,MAAM,CAAC,UAAU,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;IAClC,OAAO,aAAa,CAAC,UAAU,EAAE,CAAA;AACnC,CAAC;AA2BD;;;;;GAKG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AAC,QAAQ,CAAC,CAAC,CAAC,GAAG,EAAE,eAAe,EAAE,OAAO,CAAC,CAAA;IAC/C,CAAC,CAAA;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,SAAS;IACvB,OAAO,cAAc,EAAE,CAAC,MAAM,CAAA;AAChC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY;IAC1B,OAAO,cAAc,EAAE,CAAC,SAAS,CAAA;AACnC,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,YAAY,CAAC,KAA4C;IACvE,MAAM,QAAQ,GAAG,eAAe,EAAE,CAAA;IAClC,MAAM,aAAa,GAAG,sBAAsB,CAAC,QAAQ,CAAC,CAAA;IACtD,OAAO,QAAQ,CAAC,GAAG,EAAE;QACnB,yEAAyE;QACzE,4EAA4E;QAC5E,KAAK,aAAa,EAAE,CAAA;QACpB,MAAM,OAAO,GAAG,eAAe,CAAC,KAAK,CAAC,CAAA;QACtC,IAAI,CAAC,OAAO;YAAE,OAAO,IAAI,CAAA;QACzB,IAAI,OAAO,YAAY,SAAS,EAAE,CAAC;YACjC,OAAO,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU,EAAE,EAAE,YAAY,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAA;QAC3F,CAAC;QACD,OAAO,OAAO,CAAC,OAAO,CAAA;IACxB,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -73,6 +73,10 @@
|
|
|
73
73
|
* Molecule service whose token was never provided fails at DI time.
|
|
74
74
|
* Per-concern helpers (`provideAuth`, `provideTheme`, ...) exist for
|
|
75
75
|
* piecemeal setup.
|
|
76
|
+
* - In-app links use the `Link` directive (`<a molLink="/settings">`, `imports: [Link]`): it
|
|
77
|
+
* navigates through the molecule router with react-router `<Link>`'s click rules. A bare
|
|
78
|
+
* `<a href>` reloads the page; a hand-written `(click)` handler that calls `navigate()`
|
|
79
|
+
* breaks ctrl/cmd-click (new tab) unless it repeats those rules.
|
|
76
80
|
*
|
|
77
81
|
* @module
|
|
78
82
|
*/
|
|
@@ -80,6 +84,8 @@ export * from './agent-identity.js';
|
|
|
80
84
|
export * from './chat.js';
|
|
81
85
|
export * from './hooks/index.js';
|
|
82
86
|
export * from './i18n-reactive.js';
|
|
87
|
+
export * from './link.js';
|
|
88
|
+
export * from './maybe-signal.js';
|
|
83
89
|
export * from './providers.js';
|
|
84
90
|
export * from './services/index.js';
|
|
85
91
|
export * from './session-ready.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
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiFG;AAEH,cAAc,qBAAqB,CAAA;AACnC,cAAc,WAAW,CAAA;AACzB,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,WAAW,CAAA;AACzB,cAAc,mBAAmB,CAAA;AACjC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA;AAClC,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -73,6 +73,10 @@
|
|
|
73
73
|
* Molecule service whose token was never provided fails at DI time.
|
|
74
74
|
* Per-concern helpers (`provideAuth`, `provideTheme`, ...) exist for
|
|
75
75
|
* piecemeal setup.
|
|
76
|
+
* - In-app links use the `Link` directive (`<a molLink="/settings">`, `imports: [Link]`): it
|
|
77
|
+
* navigates through the molecule router with react-router `<Link>`'s click rules. A bare
|
|
78
|
+
* `<a href>` reloads the page; a hand-written `(click)` handler that calls `navigate()`
|
|
79
|
+
* breaks ctrl/cmd-click (new tab) unless it repeats those rules.
|
|
76
80
|
*
|
|
77
81
|
* @module
|
|
78
82
|
*/
|
|
@@ -80,6 +84,8 @@ export * from './agent-identity.js';
|
|
|
80
84
|
export * from './chat.js';
|
|
81
85
|
export * from './hooks/index.js';
|
|
82
86
|
export * from './i18n-reactive.js';
|
|
87
|
+
export * from './link.js';
|
|
88
|
+
export * from './maybe-signal.js';
|
|
83
89
|
export * from './providers.js';
|
|
84
90
|
export * from './services/index.js';
|
|
85
91
|
export * from './session-ready.js';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiFG;AAEH,cAAc,qBAAqB,CAAA;AACnC,cAAc,WAAW,CAAA;AACzB,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,WAAW,CAAA;AACzB,cAAc,mBAAmB,CAAA;AACjC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA;AAClC,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA"}
|
package/dist/link.d.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `Link` (`<a molLink="/path">`): an in-app anchor for Angular, the counterpart
|
|
3
|
+
* of react-router's `<Link>`.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import { type OnInit } from '@angular/core';
|
|
8
|
+
import * as i0 from "@angular/core";
|
|
9
|
+
/**
|
|
10
|
+
* `<a molLink="/settings">`: sets the anchor's `href` and navigates in-app
|
|
11
|
+
* through the molecule router, with react-router `<Link>`'s rules
|
|
12
|
+
* (`followRouterLink` from `@molecule/app-routing`): a plain primary click
|
|
13
|
+
* navigates without a page load; a ctrl/cmd, shift or alt click, a `target`
|
|
14
|
+
* other than `_self`, a click the template's own `(click)` handler prevented,
|
|
15
|
+
* and a URL on another origin are left to the browser.
|
|
16
|
+
*
|
|
17
|
+
* Inputs: `molLink` (the destination: an app path or a URL), `replace` (replace
|
|
18
|
+
* the current history entry; when unset, a link to the location already shown
|
|
19
|
+
* replaces it and any other link pushes, as with react-router's `<Link>`), and
|
|
20
|
+
* `state` (stored with the new entry). Every other attribute (`class`,
|
|
21
|
+
* `target`, `rel`) is written on the anchor as usual.
|
|
22
|
+
*
|
|
23
|
+
* Use it for every internal link instead of an anchor with a `(click)` handler
|
|
24
|
+
* that calls `navigate()`. Needs the router from `provideMolecule({ router })`.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* import { Component } from '@angular/core'
|
|
29
|
+
* import { Link } from '@molecule/app-angular'
|
|
30
|
+
*
|
|
31
|
+
* @Component({
|
|
32
|
+
* selector: 'app-nav',
|
|
33
|
+
* standalone: true,
|
|
34
|
+
* imports: [Link],
|
|
35
|
+
* template: `
|
|
36
|
+
* <a molLink="/projects" class="nav-link">Projects</a>
|
|
37
|
+
* <a molLink="/login" [replace]="true" [state]="{ from: '/projects' }">Log in</a>
|
|
38
|
+
* `,
|
|
39
|
+
* })
|
|
40
|
+
* export class NavComponent {}
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare class Link implements OnInit {
|
|
44
|
+
/** The destination: an app path (`/settings?tab=billing#plan`) or a URL. */
|
|
45
|
+
molLink: string;
|
|
46
|
+
/** Replace the current history entry instead of pushing one. */
|
|
47
|
+
replace?: boolean;
|
|
48
|
+
/** State stored with the new history entry. */
|
|
49
|
+
state?: unknown;
|
|
50
|
+
private readonly router;
|
|
51
|
+
private readonly element;
|
|
52
|
+
private readonly renderer;
|
|
53
|
+
private readonly destroyRef;
|
|
54
|
+
/**
|
|
55
|
+
* Starts handling clicks. The listener is added here, after the template
|
|
56
|
+
* created this anchor's own `(click)` listeners, so those run first and can
|
|
57
|
+
* prevent the navigation (react-router calls `onClick` first too).
|
|
58
|
+
*/
|
|
59
|
+
ngOnInit(): void;
|
|
60
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<Link, never>;
|
|
61
|
+
static ɵdir: i0.ɵɵDirectiveDeclaration<Link, "a[molLink]", never, { "molLink": { "alias": "molLink"; "required": false; }; "replace": { "alias": "replace"; "required": false; }; "state": { "alias": "state"; "required": false; }; }, {}, never, never, true, never>;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=link.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../src/link.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAA6C,KAAK,MAAM,EAAa,MAAM,eAAe,CAAA;;AAMjG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,qBAMa,IAAK,YAAW,MAAM;IACjC,4EAA4E;IAC5E,OAAO,SAAK;IACZ,gEAAgE;IAChE,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,+CAA+C;IAC/C,KAAK,CAAC,EAAE,OAAO,CAAA;IAEf,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAsB;IAC7C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoD;IAC5E,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAoB;IAC7C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAqB;IAEhD;;;;OAIG;IACH,QAAQ,IAAI,IAAI;yCAlBL,IAAI;2CAAJ,IAAI;CA2BhB"}
|
package/dist/link.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `Link` (`<a molLink="/path">`): an in-app anchor for Angular, the counterpart
|
|
3
|
+
* of react-router's `<Link>`.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import { DestroyRef, Directive, ElementRef, inject, Renderer2 } from '@angular/core';
|
|
8
|
+
import { followRouterLink } from '@molecule/app-routing';
|
|
9
|
+
import { useRouterInstance } from './hooks/use-router.js';
|
|
10
|
+
import * as i0 from "@angular/core";
|
|
11
|
+
/**
|
|
12
|
+
* `<a molLink="/settings">`: sets the anchor's `href` and navigates in-app
|
|
13
|
+
* through the molecule router, with react-router `<Link>`'s rules
|
|
14
|
+
* (`followRouterLink` from `@molecule/app-routing`): a plain primary click
|
|
15
|
+
* navigates without a page load; a ctrl/cmd, shift or alt click, a `target`
|
|
16
|
+
* other than `_self`, a click the template's own `(click)` handler prevented,
|
|
17
|
+
* and a URL on another origin are left to the browser.
|
|
18
|
+
*
|
|
19
|
+
* Inputs: `molLink` (the destination: an app path or a URL), `replace` (replace
|
|
20
|
+
* the current history entry; when unset, a link to the location already shown
|
|
21
|
+
* replaces it and any other link pushes, as with react-router's `<Link>`), and
|
|
22
|
+
* `state` (stored with the new entry). Every other attribute (`class`,
|
|
23
|
+
* `target`, `rel`) is written on the anchor as usual.
|
|
24
|
+
*
|
|
25
|
+
* Use it for every internal link instead of an anchor with a `(click)` handler
|
|
26
|
+
* that calls `navigate()`. Needs the router from `provideMolecule({ router })`.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
* import { Component } from '@angular/core'
|
|
31
|
+
* import { Link } from '@molecule/app-angular'
|
|
32
|
+
*
|
|
33
|
+
* @Component({
|
|
34
|
+
* selector: 'app-nav',
|
|
35
|
+
* standalone: true,
|
|
36
|
+
* imports: [Link],
|
|
37
|
+
* template: `
|
|
38
|
+
* <a molLink="/projects" class="nav-link">Projects</a>
|
|
39
|
+
* <a molLink="/login" [replace]="true" [state]="{ from: '/projects' }">Log in</a>
|
|
40
|
+
* `,
|
|
41
|
+
* })
|
|
42
|
+
* export class NavComponent {}
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export class Link {
|
|
46
|
+
constructor() {
|
|
47
|
+
/** The destination: an app path (`/settings?tab=billing#plan`) or a URL. */
|
|
48
|
+
this.molLink = '';
|
|
49
|
+
this.router = useRouterInstance();
|
|
50
|
+
this.element = inject(ElementRef);
|
|
51
|
+
this.renderer = inject(Renderer2);
|
|
52
|
+
this.destroyRef = inject(DestroyRef);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Starts handling clicks. The listener is added here, after the template
|
|
56
|
+
* created this anchor's own `(click)` listeners, so those run first and can
|
|
57
|
+
* prevent the navigation (react-router calls `onClick` first too).
|
|
58
|
+
*/
|
|
59
|
+
ngOnInit() {
|
|
60
|
+
const stop = this.renderer.listen(this.element.nativeElement, 'click', (event) => {
|
|
61
|
+
followRouterLink(event, this.molLink, this.router, {
|
|
62
|
+
replace: this.replace,
|
|
63
|
+
state: this.state,
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
this.destroyRef.onDestroy(stop);
|
|
67
|
+
}
|
|
68
|
+
static { this.ɵfac = function Link_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || Link)(); }; }
|
|
69
|
+
static { this.ɵdir = /*@__PURE__*/ i0.ɵɵdefineDirective({ type: Link, selectors: [["a", "molLink", ""]], hostVars: 1, hostBindings: function Link_HostBindings(rf, ctx) { if (rf & 2) {
|
|
70
|
+
i0.ɵɵattribute("href", ctx.molLink, i0.ɵɵsanitizeUrlOrResourceUrl);
|
|
71
|
+
} }, inputs: { molLink: "molLink", replace: "replace", state: "state" } }); }
|
|
72
|
+
}
|
|
73
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(Link, [{
|
|
74
|
+
type: Directive,
|
|
75
|
+
args: [{
|
|
76
|
+
selector: 'a[molLink]',
|
|
77
|
+
standalone: true,
|
|
78
|
+
inputs: ['molLink', 'replace', 'state'],
|
|
79
|
+
host: { '[attr.href]': 'molLink' },
|
|
80
|
+
}]
|
|
81
|
+
}], null, null); })();
|
|
82
|
+
//# sourceMappingURL=link.js.map
|
package/dist/link.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"link.js","sourceRoot":"","sources":["../src/link.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAe,SAAS,EAAE,MAAM,eAAe,CAAA;AAEjG,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAExD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;;AAEzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAOH,MAAM,OAAO,IAAI;IANjB;QAOE,4EAA4E;QAC5E,YAAO,GAAG,EAAE,CAAA;QAMK,WAAM,GAAG,iBAAiB,EAAE,CAAA;QAC5B,YAAO,GAAG,MAAM,CAAgC,UAAU,CAAC,CAAA;QAC3D,aAAQ,GAAG,MAAM,CAAC,SAAS,CAAC,CAAA;QAC5B,eAAU,GAAG,MAAM,CAAC,UAAU,CAAC,CAAA;KAgBjD;IAdC;;;;OAIG;IACH,QAAQ;QACN,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,OAAO,EAAE,CAAC,KAAiB,EAAE,EAAE;YAC3F,gBAAgB,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE;gBACjD,OAAO,EAAE,IAAI,CAAC,OAAO;gBACrB,KAAK,EAAE,IAAI,CAAC,KAAK;aAClB,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;QACF,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;IACjC,CAAC;qGA1BU,IAAI;oEAAJ,IAAI;;;;iFAAJ,IAAI;cANhB,SAAS;eAAC;gBACT,QAAQ,EAAE,YAAY;gBACtB,UAAU,EAAE,IAAI;gBAChB,MAAM,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,CAAC;gBACvC,IAAI,EAAE,EAAE,aAAa,EAAE,SAAS,EAAE;aACnC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A plain value or a signal holding it: what the injection-context hooks
|
|
3
|
+
* accept for every argument, so a hook can follow its arguments the way
|
|
4
|
+
* React's hook follows a re-render with new arguments.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import { type Signal } from '@angular/core';
|
|
9
|
+
/**
|
|
10
|
+
* A hook argument: the plain value, or a signal holding the value the hook
|
|
11
|
+
* should currently use. A signal holding `undefined` means the argument was
|
|
12
|
+
* omitted, exactly like a missing plain argument: the default applies.
|
|
13
|
+
*
|
|
14
|
+
* @template T - The argument's shape.
|
|
15
|
+
*/
|
|
16
|
+
export type MaybeSignal<T> = T | Signal<T>;
|
|
17
|
+
/**
|
|
18
|
+
* Reads a hook argument's current value. Inside a `computed` or `effect` this
|
|
19
|
+
* TRACKS a signal argument, so the reader re-runs when the argument changes;
|
|
20
|
+
* outside one it is a plain read.
|
|
21
|
+
*
|
|
22
|
+
* @param value - The argument as the hook received it.
|
|
23
|
+
* @returns The argument's current value.
|
|
24
|
+
*/
|
|
25
|
+
export declare function readMaybeSignal<T>(value: MaybeSignal<T>): T;
|
|
26
|
+
//# sourceMappingURL=maybe-signal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"maybe-signal.d.ts","sourceRoot":"","sources":["../src/maybe-signal.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAY,KAAK,MAAM,EAAE,MAAM,eAAe,CAAA;AAErD;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAA;AAE1C;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,CAE3D"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A plain value or a signal holding it: what the injection-context hooks
|
|
3
|
+
* accept for every argument, so a hook can follow its arguments the way
|
|
4
|
+
* React's hook follows a re-render with new arguments.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import { isSignal } from '@angular/core';
|
|
9
|
+
/**
|
|
10
|
+
* Reads a hook argument's current value. Inside a `computed` or `effect` this
|
|
11
|
+
* TRACKS a signal argument, so the reader re-runs when the argument changes;
|
|
12
|
+
* outside one it is a plain read.
|
|
13
|
+
*
|
|
14
|
+
* @param value - The argument as the hook received it.
|
|
15
|
+
* @returns The argument's current value.
|
|
16
|
+
*/
|
|
17
|
+
export function readMaybeSignal(value) {
|
|
18
|
+
return isSignal(value) ? value() : value;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=maybe-signal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"maybe-signal.js","sourceRoot":"","sources":["../src/maybe-signal.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAe,MAAM,eAAe,CAAA;AAWrD;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAI,KAAqB;IACtD,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAA;AAC1C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/app-angular",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.0",
|
|
4
4
|
"description": "Angular framework bindings for molecule.dev",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@molecule/app-logger": "^1.0.1",
|
|
36
36
|
"@molecule/app-platform": "^1.0.1",
|
|
37
37
|
"@molecule/app-push": "^1.0.1",
|
|
38
|
-
"@molecule/app-routing": "^1.
|
|
38
|
+
"@molecule/app-routing": "^1.3.0",
|
|
39
39
|
"@molecule/app-state": "^1.2.0",
|
|
40
40
|
"@molecule/app-storage": "^1.1.1",
|
|
41
41
|
"@molecule/app-theme": "^1.0.1",
|
package/dist/site.d.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Hook-site lanes: state a hook keeps across a re-mount of the same site.
|
|
3
|
-
*
|
|
4
|
-
* React keeps a hook's state for as long as its component instance lives; an
|
|
5
|
-
* argument change RE-RENDERS the same instance, so an in-flight request, a
|
|
6
|
-
* pending save or a form draft survives it. In Angular a hook function runs
|
|
7
|
-
* once per component instantiation, and new arguments arrive by re-creating
|
|
8
|
-
* the component — so the hooks whose state must survive an argument change
|
|
9
|
-
* (`useHttp`, `useOptimisticValue`, `useForm`) keep that state in a LANE: a
|
|
10
|
-
* module-level record the destroyed instance parks and the next instance of
|
|
11
|
-
* the same hook kind adopts when it mounts in the same place.
|
|
12
|
-
*
|
|
13
|
-
* A lane is parked only while the site is plausibly being re-created: the
|
|
14
|
-
* park records the host element's container, and a microtask — which runs
|
|
15
|
-
* after the synchronously-removed container of a real unmount, but before the
|
|
16
|
-
* awaited re-creation of an argument change — drops the lane when that
|
|
17
|
-
* container has left the document. A site that went away starts fresh.
|
|
18
|
-
*
|
|
19
|
-
* @module
|
|
20
|
-
*/
|
|
21
|
-
/**
|
|
22
|
-
* Adopts this hook kind's parked lane, if the site was re-created rather than
|
|
23
|
-
* closed.
|
|
24
|
-
*
|
|
25
|
-
* @param kind - The hook kind (`'useHttp'`); one lane per kind and site.
|
|
26
|
-
* @returns The parked lane, or `undefined` when the site starts fresh.
|
|
27
|
-
*/
|
|
28
|
-
export declare function adoptLane<T>(kind: string): T | undefined;
|
|
29
|
-
/**
|
|
30
|
-
* Parks this hook kind's lane for the next instance at the same site.
|
|
31
|
-
*
|
|
32
|
-
* @param kind - The hook kind (`'useHttp'`).
|
|
33
|
-
* @param lane - The lane to hand over.
|
|
34
|
-
* @param site - The site {@link captureSite} recorded (the host's container);
|
|
35
|
-
* `null` drops the lane.
|
|
36
|
-
*/
|
|
37
|
-
export declare function parkLane(kind: string, lane: unknown, site: Element | null): void;
|
|
38
|
-
/**
|
|
39
|
-
* Records the site's container element: the host's parent once the host is in
|
|
40
|
-
* the document. A hook runs during component creation, BEFORE the caller
|
|
41
|
-
* appends the host, and the host is detached again before `onDestroy` runs —
|
|
42
|
-
* so the only reliable moment to read the parent is a microtask after mount.
|
|
43
|
-
* The container (not the host) is the right anchor: it survives a re-mount of
|
|
44
|
-
* the host at the same site and leaves the document only when the site closes.
|
|
45
|
-
*
|
|
46
|
-
* @param host - The host element (`inject(ElementRef).nativeElement`).
|
|
47
|
-
* @param onSite - Receives the container once the host is attached (or `null`
|
|
48
|
-
* when the host never gets one).
|
|
49
|
-
*/
|
|
50
|
-
export declare function captureSite(host: HTMLElement, onSite: (site: Element | null) => void): void;
|
|
51
|
-
//# sourceMappingURL=site.d.ts.map
|
package/dist/site.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"site.d.ts","sourceRoot":"","sources":["../src/site.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAKH;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAIxD;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,GAAG,IAAI,GAAG,IAAI,CAOhF;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,KAAK,IAAI,GAAG,IAAI,CAE3F"}
|
package/dist/site.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Hook-site lanes: state a hook keeps across a re-mount of the same site.
|
|
3
|
-
*
|
|
4
|
-
* React keeps a hook's state for as long as its component instance lives; an
|
|
5
|
-
* argument change RE-RENDERS the same instance, so an in-flight request, a
|
|
6
|
-
* pending save or a form draft survives it. In Angular a hook function runs
|
|
7
|
-
* once per component instantiation, and new arguments arrive by re-creating
|
|
8
|
-
* the component — so the hooks whose state must survive an argument change
|
|
9
|
-
* (`useHttp`, `useOptimisticValue`, `useForm`) keep that state in a LANE: a
|
|
10
|
-
* module-level record the destroyed instance parks and the next instance of
|
|
11
|
-
* the same hook kind adopts when it mounts in the same place.
|
|
12
|
-
*
|
|
13
|
-
* A lane is parked only while the site is plausibly being re-created: the
|
|
14
|
-
* park records the host element's container, and a microtask — which runs
|
|
15
|
-
* after the synchronously-removed container of a real unmount, but before the
|
|
16
|
-
* awaited re-creation of an argument change — drops the lane when that
|
|
17
|
-
* container has left the document. A site that went away starts fresh.
|
|
18
|
-
*
|
|
19
|
-
* @module
|
|
20
|
-
*/
|
|
21
|
-
/** One parked lane per hook kind; the newest park wins. */
|
|
22
|
-
const parked = new Map();
|
|
23
|
-
/**
|
|
24
|
-
* Adopts this hook kind's parked lane, if the site was re-created rather than
|
|
25
|
-
* closed.
|
|
26
|
-
*
|
|
27
|
-
* @param kind - The hook kind (`'useHttp'`); one lane per kind and site.
|
|
28
|
-
* @returns The parked lane, or `undefined` when the site starts fresh.
|
|
29
|
-
*/
|
|
30
|
-
export function adoptLane(kind) {
|
|
31
|
-
const lane = parked.get(kind);
|
|
32
|
-
if (lane !== undefined)
|
|
33
|
-
parked.delete(kind);
|
|
34
|
-
return lane;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Parks this hook kind's lane for the next instance at the same site.
|
|
38
|
-
*
|
|
39
|
-
* @param kind - The hook kind (`'useHttp'`).
|
|
40
|
-
* @param lane - The lane to hand over.
|
|
41
|
-
* @param site - The site {@link captureSite} recorded (the host's container);
|
|
42
|
-
* `null` drops the lane.
|
|
43
|
-
*/
|
|
44
|
-
export function parkLane(kind, lane, site) {
|
|
45
|
-
parked.set(kind, lane);
|
|
46
|
-
queueMicrotask(() => {
|
|
47
|
-
if (parked.get(kind) !== lane)
|
|
48
|
-
return;
|
|
49
|
-
// Adopted already, or a newer park replaced this one.
|
|
50
|
-
if (!site || !site.isConnected)
|
|
51
|
-
parked.delete(kind);
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Records the site's container element: the host's parent once the host is in
|
|
56
|
-
* the document. A hook runs during component creation, BEFORE the caller
|
|
57
|
-
* appends the host, and the host is detached again before `onDestroy` runs —
|
|
58
|
-
* so the only reliable moment to read the parent is a microtask after mount.
|
|
59
|
-
* The container (not the host) is the right anchor: it survives a re-mount of
|
|
60
|
-
* the host at the same site and leaves the document only when the site closes.
|
|
61
|
-
*
|
|
62
|
-
* @param host - The host element (`inject(ElementRef).nativeElement`).
|
|
63
|
-
* @param onSite - Receives the container once the host is attached (or `null`
|
|
64
|
-
* when the host never gets one).
|
|
65
|
-
*/
|
|
66
|
-
export function captureSite(host, onSite) {
|
|
67
|
-
queueMicrotask(() => onSite(host.parentElement));
|
|
68
|
-
}
|
|
69
|
-
//# sourceMappingURL=site.js.map
|
package/dist/site.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"site.js","sourceRoot":"","sources":["../src/site.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,2DAA2D;AAC3D,MAAM,MAAM,GAAG,IAAI,GAAG,EAAmB,CAAA;AAEzC;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAI,IAAY;IACvC,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IAC7B,IAAI,IAAI,KAAK,SAAS;QAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAC3C,OAAO,IAAqB,CAAA;AAC9B,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAY,EAAE,IAAa,EAAE,IAAoB;IACxE,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IACtB,cAAc,CAAC,GAAG,EAAE;QAClB,IAAI,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,IAAI;YAAE,OAAM;QACrC,sDAAsD;QACtD,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,WAAW;YAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACrD,CAAC,CAAC,CAAA;AACJ,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,WAAW,CAAC,IAAiB,EAAE,MAAsC;IACnF,cAAc,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAA;AAClD,CAAC"}
|