@molecule/app-angular 3.3.1 → 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 +4049 -1255
- package/dist/chat.d.ts.map +1 -1
- package/dist/chat.js +3 -2
- package/dist/chat.js.map +1 -1
- package/dist/hooks/external-store.d.ts +32 -0
- package/dist/hooks/external-store.d.ts.map +1 -0
- package/dist/hooks/external-store.js +62 -0
- package/dist/hooks/external-store.js.map +1 -0
- package/dist/hooks/index.d.ts +24 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +24 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/use-ai-models.d.ts +53 -0
- package/dist/hooks/use-ai-models.d.ts.map +1 -0
- package/dist/hooks/use-ai-models.js +167 -0
- package/dist/hooks/use-ai-models.js.map +1 -0
- package/dist/hooks/use-async.d.ts +129 -0
- package/dist/hooks/use-async.d.ts.map +1 -0
- package/dist/hooks/use-async.js +194 -0
- package/dist/hooks/use-async.js.map +1 -0
- package/dist/hooks/use-auth-flows.d.ts +226 -0
- package/dist/hooks/use-auth-flows.d.ts.map +1 -0
- package/dist/hooks/use-auth-flows.js +481 -0
- package/dist/hooks/use-auth-flows.js.map +1 -0
- package/dist/hooks/use-auth.d.ts +85 -0
- package/dist/hooks/use-auth.d.ts.map +1 -0
- package/dist/hooks/use-auth.js +104 -0
- package/dist/hooks/use-auth.js.map +1 -0
- package/dist/hooks/use-forms.d.ts +174 -0
- package/dist/hooks/use-forms.d.ts.map +1 -0
- package/dist/hooks/use-forms.js +221 -0
- package/dist/hooks/use-forms.js.map +1 -0
- package/dist/hooks/use-http.d.ts +163 -0
- package/dist/hooks/use-http.d.ts.map +1 -0
- package/dist/hooks/use-http.js +198 -0
- package/dist/hooks/use-http.js.map +1 -0
- package/dist/hooks/use-ide.d.ts +208 -0
- package/dist/hooks/use-ide.d.ts.map +1 -0
- package/dist/hooks/use-ide.js +217 -0
- package/dist/hooks/use-ide.js.map +1 -0
- package/dist/hooks/use-logger.d.ts +40 -0
- package/dist/hooks/use-logger.d.ts.map +1 -0
- package/dist/hooks/use-logger.js +56 -0
- package/dist/hooks/use-logger.js.map +1 -0
- package/dist/hooks/use-native.d.ts +218 -0
- package/dist/hooks/use-native.d.ts.map +1 -0
- package/dist/hooks/use-native.js +173 -0
- package/dist/hooks/use-native.js.map +1 -0
- package/dist/hooks/use-profile-form.d.ts +113 -0
- package/dist/hooks/use-profile-form.d.ts.map +1 -0
- package/dist/hooks/use-profile-form.js +253 -0
- package/dist/hooks/use-profile-form.js.map +1 -0
- package/dist/hooks/use-router.d.ts +219 -0
- package/dist/hooks/use-router.d.ts.map +1 -0
- package/dist/hooks/use-router.js +266 -0
- package/dist/hooks/use-router.js.map +1 -0
- package/dist/hooks/use-storage.d.ts +142 -0
- package/dist/hooks/use-storage.d.ts.map +1 -0
- package/dist/hooks/use-storage.js +299 -0
- package/dist/hooks/use-storage.js.map +1 -0
- package/dist/hooks/use-store.d.ts +81 -0
- package/dist/hooks/use-store.d.ts.map +1 -0
- package/dist/hooks/use-store.js +143 -0
- package/dist/hooks/use-store.js.map +1 -0
- package/dist/hooks/use-theme.d.ts +59 -0
- package/dist/hooks/use-theme.d.ts.map +1 -0
- package/dist/hooks/use-theme.js +117 -0
- package/dist/hooks/use-theme.js.map +1 -0
- package/dist/hooks/use-translation.d.ts +91 -0
- package/dist/hooks/use-translation.d.ts.map +1 -0
- package/dist/hooks/use-translation.js +152 -0
- package/dist/hooks/use-translation.js.map +1 -0
- package/dist/hooks/use-verify-payment-return.d.ts +86 -0
- package/dist/hooks/use-verify-payment-return.d.ts.map +1 -0
- package/dist/hooks/use-verify-payment-return.js +167 -0
- package/dist/hooks/use-verify-payment-return.js.map +1 -0
- package/dist/hooks/use-version.d.ts +49 -0
- package/dist/hooks/use-version.d.ts.map +1 -0
- package/dist/hooks/use-version.js +70 -0
- package/dist/hooks/use-version.js.map +1 -0
- package/dist/i18n-reactive.d.ts +2 -5
- package/dist/i18n-reactive.d.ts.map +1 -1
- package/dist/i18n-reactive.js.map +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/inject.d.ts +24 -0
- package/dist/inject.d.ts.map +1 -0
- package/dist/inject.js +33 -0
- package/dist/inject.js.map +1 -0
- 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/dist/providers.d.ts +24 -0
- package/dist/providers.d.ts.map +1 -1
- package/dist/providers.js +44 -3
- package/dist/providers.js.map +1 -1
- package/dist/session-ready.d.ts +41 -0
- package/dist/session-ready.d.ts.map +1 -0
- package/dist/session-ready.js +79 -0
- package/dist/session-ready.js.map +1 -0
- package/dist/tokens.d.ts +15 -0
- package/dist/tokens.d.ts.map +1 -1
- package/dist/tokens.js +12 -0
- package/dist/tokens.js.map +1 -1
- package/dist/types.d.ts +14 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Angular function for version and update management, mirroring `useVersion`
|
|
3
|
+
* from `@molecule/app-react`.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import { type Signal } from '@angular/core';
|
|
8
|
+
import type { UpdateCheckOptions, VersionState } from '@molecule/app-version';
|
|
9
|
+
/**
|
|
10
|
+
* What {@link useVersion} returns: every state field as a signal and every
|
|
11
|
+
* update action as a plain function.
|
|
12
|
+
*/
|
|
13
|
+
export interface UseVersionResult {
|
|
14
|
+
/** The full version state. */
|
|
15
|
+
readonly state: Signal<VersionState>;
|
|
16
|
+
/** Whether an update is available. */
|
|
17
|
+
readonly isUpdateAvailable: Signal<boolean>;
|
|
18
|
+
/** Whether an update check is running. */
|
|
19
|
+
readonly isChecking: Signal<boolean>;
|
|
20
|
+
/** Whether a service worker waits to activate. */
|
|
21
|
+
readonly isServiceWorkerWaiting: Signal<boolean>;
|
|
22
|
+
/** The version an available update reports. */
|
|
23
|
+
readonly newVersion: Signal<string | undefined>;
|
|
24
|
+
/** Runs one update check; resolves with whether one was found. */
|
|
25
|
+
checkForUpdates: () => Promise<boolean>;
|
|
26
|
+
/** Applies the update (the provider reloads the page). */
|
|
27
|
+
applyUpdate: (options?: {
|
|
28
|
+
force?: boolean;
|
|
29
|
+
}) => void;
|
|
30
|
+
/** Hides the update notice until the next check finds one. */
|
|
31
|
+
dismissUpdate: () => void;
|
|
32
|
+
/** Starts periodic update checks. */
|
|
33
|
+
startPeriodicChecks: (options?: UpdateCheckOptions) => void;
|
|
34
|
+
/** Stops periodic update checks. */
|
|
35
|
+
stopPeriodicChecks: () => void;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Version state and update actions. Call it in an injection context (a
|
|
39
|
+
* component field initializer or constructor).
|
|
40
|
+
*
|
|
41
|
+
* Uses module-level `getProvider()` — version is a singleton, not
|
|
42
|
+
* registration-provided. The state snapshot is cached field-wise (like React's
|
|
43
|
+
* hook), so a provider that builds a fresh object per read keeps the snapshot
|
|
44
|
+
* stable between notifications.
|
|
45
|
+
*
|
|
46
|
+
* @returns Version state as signals and the update actions.
|
|
47
|
+
*/
|
|
48
|
+
export declare function useVersion(): UseVersionResult;
|
|
49
|
+
//# sourceMappingURL=use-version.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-version.d.ts","sourceRoot":"","sources":["../../src/hooks/use-version.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAY,KAAK,MAAM,EAAE,MAAM,eAAe,CAAA;AAErD,OAAO,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAK7E;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,8BAA8B;IAC9B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,YAAY,CAAC,CAAA;IACpC,sCAAsC;IACtC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC,OAAO,CAAC,CAAA;IAC3C,0CAA0C;IAC1C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,OAAO,CAAC,CAAA;IACpC,kDAAkD;IAClD,QAAQ,CAAC,sBAAsB,EAAE,MAAM,CAAC,OAAO,CAAC,CAAA;IAChD,+CAA+C;IAC/C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;IAC/C,kEAAkE;IAClE,eAAe,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAA;IACvC,0DAA0D;IAC1D,WAAW,EAAE,CAAC,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAA;IACpD,8DAA8D;IAC9D,aAAa,EAAE,MAAM,IAAI,CAAA;IACzB,qCAAqC;IACrC,mBAAmB,EAAE,CAAC,OAAO,CAAC,EAAE,kBAAkB,KAAK,IAAI,CAAA;IAC3D,oCAAoC;IACpC,kBAAkB,EAAE,MAAM,IAAI,CAAA;CAC/B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,IAAI,gBAAgB,CAwD7C"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Angular function for version and update management, mirroring `useVersion`
|
|
3
|
+
* from `@molecule/app-react`.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import { computed } from '@angular/core';
|
|
8
|
+
import { getProvider } from '@molecule/app-version';
|
|
9
|
+
import { useExternalStore } from './external-store.js';
|
|
10
|
+
/**
|
|
11
|
+
* Version state and update actions. Call it in an injection context (a
|
|
12
|
+
* component field initializer or constructor).
|
|
13
|
+
*
|
|
14
|
+
* Uses module-level `getProvider()` — version is a singleton, not
|
|
15
|
+
* registration-provided. The state snapshot is cached field-wise (like React's
|
|
16
|
+
* hook), so a provider that builds a fresh object per read keeps the snapshot
|
|
17
|
+
* stable between notifications.
|
|
18
|
+
*
|
|
19
|
+
* @returns Version state as signals and the update actions.
|
|
20
|
+
*/
|
|
21
|
+
export function useVersion() {
|
|
22
|
+
const provider = getProvider();
|
|
23
|
+
// Cached snapshot for stability: a provider may build a fresh object per
|
|
24
|
+
// getState() call; the fields decide whether anything changed.
|
|
25
|
+
let cachedState = null;
|
|
26
|
+
const read = () => {
|
|
27
|
+
const next = provider.getState();
|
|
28
|
+
const prev = cachedState;
|
|
29
|
+
if (prev !== null &&
|
|
30
|
+
prev.isUpdateAvailable === next.isUpdateAvailable &&
|
|
31
|
+
prev.isChecking === next.isChecking &&
|
|
32
|
+
prev.isServiceWorkerWaiting === next.isServiceWorkerWaiting &&
|
|
33
|
+
prev.newVersion === next.newVersion &&
|
|
34
|
+
prev.buildId === next.buildId &&
|
|
35
|
+
prev.version === next.version) {
|
|
36
|
+
return prev;
|
|
37
|
+
}
|
|
38
|
+
cachedState = next;
|
|
39
|
+
return next;
|
|
40
|
+
};
|
|
41
|
+
const state = useExternalStore(read, (onStateChange) => {
|
|
42
|
+
const unsubs = [
|
|
43
|
+
provider.on('update-available', onStateChange),
|
|
44
|
+
provider.on('service-worker-waiting', onStateChange),
|
|
45
|
+
provider.on('service-worker-activated', onStateChange),
|
|
46
|
+
provider.on('check-start', onStateChange),
|
|
47
|
+
provider.on('check-complete', onStateChange),
|
|
48
|
+
provider.on('check-error', onStateChange),
|
|
49
|
+
];
|
|
50
|
+
return () => unsubs.forEach((unsub) => unsub());
|
|
51
|
+
});
|
|
52
|
+
const checkForUpdates = () => provider.checkForUpdates();
|
|
53
|
+
const applyUpdate = (options) => provider.applyUpdate(options);
|
|
54
|
+
const dismissUpdate = () => provider.dismissUpdate();
|
|
55
|
+
const startPeriodicChecks = (options) => provider.startPeriodicChecks(options);
|
|
56
|
+
const stopPeriodicChecks = () => provider.stopPeriodicChecks();
|
|
57
|
+
return {
|
|
58
|
+
state,
|
|
59
|
+
isUpdateAvailable: computed(() => state().isUpdateAvailable),
|
|
60
|
+
isChecking: computed(() => state().isChecking),
|
|
61
|
+
isServiceWorkerWaiting: computed(() => state().isServiceWorkerWaiting),
|
|
62
|
+
newVersion: computed(() => state().newVersion),
|
|
63
|
+
checkForUpdates,
|
|
64
|
+
applyUpdate,
|
|
65
|
+
dismissUpdate,
|
|
66
|
+
startPeriodicChecks,
|
|
67
|
+
stopPeriodicChecks,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=use-version.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-version.js","sourceRoot":"","sources":["../../src/hooks/use-version.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAe,MAAM,eAAe,CAAA;AAGrD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAEnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AA6BtD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,UAAU;IACxB,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAA;IAE9B,yEAAyE;IACzE,+DAA+D;IAC/D,IAAI,WAAW,GAAwB,IAAI,CAAA;IAE3C,MAAM,IAAI,GAAG,GAAiB,EAAE;QAC9B,MAAM,IAAI,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAA;QAChC,MAAM,IAAI,GAAG,WAAW,CAAA;QACxB,IACE,IAAI,KAAK,IAAI;YACb,IAAI,CAAC,iBAAiB,KAAK,IAAI,CAAC,iBAAiB;YACjD,IAAI,CAAC,UAAU,KAAK,IAAI,CAAC,UAAU;YACnC,IAAI,CAAC,sBAAsB,KAAK,IAAI,CAAC,sBAAsB;YAC3D,IAAI,CAAC,U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Q,CAAC,kBAAkB,EAAE,CAAA;IAEpE,OAAO;QACL,KAAK;QACL,iBAAiB,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,iBAAiB,CAAC;QAC5D,UAAU,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,UAAU,CAAC;QAC9C,sBAAsB,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,sBAAsB,CAAC;QACtE,UAAU,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,UAAU,CAAC;QAC9C,eAAe;QACf,WAAW;QACX,aAAa;QACb,mBAAmB;QACnB,kBAAkB;KACnB,CAAA;AACH,CAAC"}
|
package/dist/i18n-reactive.d.ts
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*
|
|
12
12
|
* @module
|
|
13
13
|
*/
|
|
14
|
-
import type { InterpolationValues } from '@molecule/app-i18n';
|
|
14
|
+
import type { InterpolationValues, TranslateOptions } from '@molecule/app-i18n';
|
|
15
15
|
/**
|
|
16
16
|
* Bump the locale version signal, causing all template bindings that use
|
|
17
17
|
* the reactive `t()` to re-evaluate on the next change detection cycle.
|
|
@@ -34,8 +34,5 @@ export declare function bumpLocaleVersion(): void;
|
|
|
34
34
|
* @param options.count - Pluralization count.
|
|
35
35
|
* @returns Translated string
|
|
36
36
|
*/
|
|
37
|
-
export declare const t: (key: string, values?: InterpolationValues, options?:
|
|
38
|
-
defaultValue?: string;
|
|
39
|
-
count?: number;
|
|
40
|
-
}) => string;
|
|
37
|
+
export declare const t: (key: string, values?: InterpolationValues, options?: TranslateOptions) => string;
|
|
41
38
|
//# sourceMappingURL=i18n-reactive.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n-reactive.d.ts","sourceRoot":"","sources":["../src/i18n-reactive.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"i18n-reactive.d.ts","sourceRoot":"","sources":["../src/i18n-reactive.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAK/E;;;;;GAKG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAExC;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,CAAC,GACZ,KAAK,MAAM,EACX,SAAS,mBAAmB,EAC5B,UAAU,gBAAgB,KACzB,MAGF,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n-reactive.js","sourceRoot":"","sources":["../src/i18n-reactive.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAGtC,OAAO,EAAE,CAAC,IAAI,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAEnD,MAAM,aAAa,GAAG,MAAM,CAAC,CAAC;kFAAC,CAAA;AAE/B;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB;IAC/B,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;AACpC,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,CAAC,GAAG,CACf,GAAW,EACX,MAA4B,EAC5B,
|
|
1
|
+
{"version":3,"file":"i18n-reactive.js","sourceRoot":"","sources":["../src/i18n-reactive.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAGtC,OAAO,EAAE,CAAC,IAAI,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAEnD,MAAM,aAAa,GAAG,MAAM,CAAC,CAAC;kFAAC,CAAA;AAE/B;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB;IAC/B,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;AACpC,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,CAAC,GAAG,CACf,GAAW,EACX,MAA4B,EAC5B,OAA0B,EAClB,EAAE;IACV,aAAa,EAAE,CAAA,CAAC,uDAAuD;IACvE,OAAO,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;AACxC,CAAC,CAAA"}
|
package/dist/index.d.ts
CHANGED
|
@@ -73,14 +73,22 @@
|
|
|
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
|
*/
|
|
79
83
|
export * from './agent-identity.js';
|
|
80
84
|
export * from './chat.js';
|
|
85
|
+
export * from './hooks/index.js';
|
|
81
86
|
export * from './i18n-reactive.js';
|
|
87
|
+
export * from './link.js';
|
|
88
|
+
export * from './maybe-signal.js';
|
|
82
89
|
export * from './providers.js';
|
|
83
90
|
export * from './services/index.js';
|
|
91
|
+
export * from './session-ready.js';
|
|
84
92
|
export * from './tokens.js';
|
|
85
93
|
export * from './types.js';
|
|
86
94
|
//# sourceMappingURL=index.d.ts.map
|
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,14 +73,22 @@
|
|
|
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
|
*/
|
|
79
83
|
export * from './agent-identity.js';
|
|
80
84
|
export * from './chat.js';
|
|
85
|
+
export * from './hooks/index.js';
|
|
81
86
|
export * from './i18n-reactive.js';
|
|
87
|
+
export * from './link.js';
|
|
88
|
+
export * from './maybe-signal.js';
|
|
82
89
|
export * from './providers.js';
|
|
83
90
|
export * from './services/index.js';
|
|
91
|
+
export * from './session-ready.js';
|
|
84
92
|
export * from './tokens.js';
|
|
85
93
|
export * from './types.js';
|
|
86
94
|
//# sourceMappingURL=index.js.map
|
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/inject.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared injection helpers for the React-parity hook functions.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { type InjectionToken } from '@angular/core';
|
|
7
|
+
/**
|
|
8
|
+
* Reads a service token registered by `provideMolecule` (or a `provide*`
|
|
9
|
+
* helper), throwing React's provider-missing error when it is absent.
|
|
10
|
+
*
|
|
11
|
+
* Angular's own missing-token failure is a `NullInjectorError`; React's hooks
|
|
12
|
+
* throw a plain `Error` whose message goes through i18n, so this reproduces
|
|
13
|
+
* React's contract under this package's error-key namespace
|
|
14
|
+
* (`react.error.useAuthOutsideProvider` becomes
|
|
15
|
+
* `angular.error.useAuthOutsideProvider`).
|
|
16
|
+
*
|
|
17
|
+
* @param token - The injection token (`AUTH_CLIENT`, `THEME_PROVIDER`, …).
|
|
18
|
+
* @param key - The error key's suffix after `angular.error.` (React's suffix).
|
|
19
|
+
* @param defaultValue - React's English error text.
|
|
20
|
+
* @returns The service.
|
|
21
|
+
* @throws {Error} When no provider registered the token.
|
|
22
|
+
*/
|
|
23
|
+
export declare function injectProvider<T>(token: InjectionToken<T>, key: string, defaultValue: string): T;
|
|
24
|
+
//# sourceMappingURL=inject.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inject.d.ts","sourceRoot":"","sources":["../src/inject.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAU,KAAK,cAAc,EAAE,MAAM,eAAe,CAAA;AAI3D;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,CAAC,CAUhG"}
|
package/dist/inject.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared injection helpers for the React-parity hook functions.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { inject } from '@angular/core';
|
|
7
|
+
import { t } from '@molecule/app-i18n';
|
|
8
|
+
/**
|
|
9
|
+
* Reads a service token registered by `provideMolecule` (or a `provide*`
|
|
10
|
+
* helper), throwing React's provider-missing error when it is absent.
|
|
11
|
+
*
|
|
12
|
+
* Angular's own missing-token failure is a `NullInjectorError`; React's hooks
|
|
13
|
+
* throw a plain `Error` whose message goes through i18n, so this reproduces
|
|
14
|
+
* React's contract under this package's error-key namespace
|
|
15
|
+
* (`react.error.useAuthOutsideProvider` becomes
|
|
16
|
+
* `angular.error.useAuthOutsideProvider`).
|
|
17
|
+
*
|
|
18
|
+
* @param token - The injection token (`AUTH_CLIENT`, `THEME_PROVIDER`, …).
|
|
19
|
+
* @param key - The error key's suffix after `angular.error.` (React's suffix).
|
|
20
|
+
* @param defaultValue - React's English error text.
|
|
21
|
+
* @returns The service.
|
|
22
|
+
* @throws {Error} When no provider registered the token.
|
|
23
|
+
*/
|
|
24
|
+
export function injectProvider(token, key, defaultValue) {
|
|
25
|
+
const provider = inject(token, { optional: true });
|
|
26
|
+
if (!provider) {
|
|
27
|
+
throw new Error(t(`angular.error.${key}`, undefined, {
|
|
28
|
+
defaultValue,
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
return provider;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=inject.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inject.js","sourceRoot":"","sources":["../src/inject.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAuB,MAAM,eAAe,CAAA;AAE3D,OAAO,EAAE,CAAC,EAAE,MAAM,oBAAoB,CAAA;AAEtC;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,cAAc,CAAI,KAAwB,EAAE,GAAW,EAAE,YAAoB;IAC3F,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;IAClD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CACb,CAAC,CAAC,iBAAiB,GAAG,EAAE,EAAE,SAAS,EAAE;YACnC,YAAY;SACb,CAAC,CACH,CAAA;IACH,CAAC;IACD,OAAO,QAAQ,CAAA;AACjB,CAAC"}
|
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/dist/providers.d.ts
CHANGED
|
@@ -6,8 +6,11 @@
|
|
|
6
6
|
import type { EnvironmentProviders } from '@angular/core';
|
|
7
7
|
import type { ChatProvider } from '@molecule/app-ai-chat';
|
|
8
8
|
import type { AuthClient } from '@molecule/app-auth';
|
|
9
|
+
import type { EditorProvider } from '@molecule/app-code-editor';
|
|
9
10
|
import type { HttpClient } from '@molecule/app-http';
|
|
10
11
|
import type { I18nProvider } from '@molecule/app-i18n';
|
|
12
|
+
import type { WorkspaceProvider } from '@molecule/app-ide';
|
|
13
|
+
import type { PreviewProvider } from '@molecule/app-live-preview';
|
|
11
14
|
import type { LoggerProvider } from '@molecule/app-logger';
|
|
12
15
|
import type { Router } from '@molecule/app-routing';
|
|
13
16
|
import type { StateProvider } from '@molecule/app-state';
|
|
@@ -77,6 +80,27 @@ export declare function provideLogger(provider: LoggerProvider): EnvironmentProv
|
|
|
77
80
|
* @returns Environment providers
|
|
78
81
|
*/
|
|
79
82
|
export declare function provideChat(provider: ChatProvider): EnvironmentProviders;
|
|
83
|
+
/**
|
|
84
|
+
* Registers the IDE workspace provider useWorkspace and useWorkspaceProvider use.
|
|
85
|
+
*
|
|
86
|
+
* @param provider - Workspace provider
|
|
87
|
+
* @returns Environment providers
|
|
88
|
+
*/
|
|
89
|
+
export declare function provideWorkspace(provider: WorkspaceProvider): EnvironmentProviders;
|
|
90
|
+
/**
|
|
91
|
+
* Registers the code editor provider useEditor and useEditorProvider use.
|
|
92
|
+
*
|
|
93
|
+
* @param provider - Editor provider
|
|
94
|
+
* @returns Environment providers
|
|
95
|
+
*/
|
|
96
|
+
export declare function provideEditor(provider: EditorProvider): EnvironmentProviders;
|
|
97
|
+
/**
|
|
98
|
+
* Registers the live preview provider usePreview and usePreviewProvider use.
|
|
99
|
+
*
|
|
100
|
+
* @param provider - Preview provider
|
|
101
|
+
* @returns Environment providers
|
|
102
|
+
*/
|
|
103
|
+
export declare function providePreview(provider: PreviewProvider): EnvironmentProviders;
|
|
80
104
|
/**
|
|
81
105
|
* Provide all molecule services at once.
|
|
82
106
|
*
|
package/dist/providers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../src/providers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAY,MAAM,eAAe,CAAA;A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|
* @module
|
|
5
5
|
*/
|
|
6
6
|
import { DestroyRef, inject, makeEnvironmentProviders, provideAppInitializer, provideEnvironmentInitializer, } from '@angular/core';
|
|
7
|
+
import { getProvider as getStateProvider, hasProvider as hasStateProvider, } from '@molecule/app-state';
|
|
7
8
|
import { bumpLocaleVersion } from './i18n-reactive.js';
|
|
8
|
-
import { AUTH_CLIENT, CHAT_PROVIDER, HTTP_CLIENT, I18N_PROVIDER, LOGGER_PROVIDER, ROUTER, STATE_PROVIDER, STORAGE_PROVIDER, THEME_PROVIDER, } from './tokens.js';
|
|
9
|
+
import { AUTH_CLIENT, CHAT_PROVIDER, EDITOR_PROVIDER, HTTP_CLIENT, I18N_PROVIDER, LOGGER_PROVIDER, PREVIEW_PROVIDER, ROUTER, STATE_PROVIDER, STORAGE_PROVIDER, THEME_PROVIDER, WORKSPACE_PROVIDER, } from './tokens.js';
|
|
9
10
|
/**
|
|
10
11
|
* Provide state management.
|
|
11
12
|
*
|
|
@@ -87,6 +88,33 @@ export function provideLogger(provider) {
|
|
|
87
88
|
export function provideChat(provider) {
|
|
88
89
|
return makeEnvironmentProviders([{ provide: CHAT_PROVIDER, useValue: provider }]);
|
|
89
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Registers the IDE workspace provider useWorkspace and useWorkspaceProvider use.
|
|
93
|
+
*
|
|
94
|
+
* @param provider - Workspace provider
|
|
95
|
+
* @returns Environment providers
|
|
96
|
+
*/
|
|
97
|
+
export function provideWorkspace(provider) {
|
|
98
|
+
return makeEnvironmentProviders([{ provide: WORKSPACE_PROVIDER, useValue: provider }]);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Registers the code editor provider useEditor and useEditorProvider use.
|
|
102
|
+
*
|
|
103
|
+
* @param provider - Editor provider
|
|
104
|
+
* @returns Environment providers
|
|
105
|
+
*/
|
|
106
|
+
export function provideEditor(provider) {
|
|
107
|
+
return makeEnvironmentProviders([{ provide: EDITOR_PROVIDER, useValue: provider }]);
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Registers the live preview provider usePreview and usePreviewProvider use.
|
|
111
|
+
*
|
|
112
|
+
* @param provider - Preview provider
|
|
113
|
+
* @returns Environment providers
|
|
114
|
+
*/
|
|
115
|
+
export function providePreview(provider) {
|
|
116
|
+
return makeEnvironmentProviders([{ provide: PREVIEW_PROVIDER, useValue: provider }]);
|
|
117
|
+
}
|
|
90
118
|
/**
|
|
91
119
|
* Provide all molecule services at once.
|
|
92
120
|
*
|
|
@@ -112,8 +140,12 @@ export function provideChat(provider) {
|
|
|
112
140
|
*/
|
|
113
141
|
export function provideMolecule(config) {
|
|
114
142
|
const providers = [];
|
|
115
|
-
|
|
116
|
-
|
|
143
|
+
// Like React's MoleculeProvider: fall back to the provider bonded under
|
|
144
|
+
// `@molecule/app-state` (the singleton every `createStore()` reads), so a
|
|
145
|
+
// scaffolded app needs no `state` option; an explicit `state` wins.
|
|
146
|
+
const stateProvider = config.state ?? (hasStateProvider() ? getStateProvider() : undefined);
|
|
147
|
+
if (stateProvider) {
|
|
148
|
+
providers.push({ provide: STATE_PROVIDER, useValue: stateProvider });
|
|
117
149
|
}
|
|
118
150
|
if (config.auth) {
|
|
119
151
|
providers.push({ provide: AUTH_CLIENT, useValue: config.auth });
|
|
@@ -149,6 +181,15 @@ export function provideMolecule(config) {
|
|
|
149
181
|
if (config.chat) {
|
|
150
182
|
providers.push({ provide: CHAT_PROVIDER, useValue: config.chat });
|
|
151
183
|
}
|
|
184
|
+
if (config.workspace) {
|
|
185
|
+
providers.push({ provide: WORKSPACE_PROVIDER, useValue: config.workspace });
|
|
186
|
+
}
|
|
187
|
+
if (config.editor) {
|
|
188
|
+
providers.push({ provide: EDITOR_PROVIDER, useValue: config.editor });
|
|
189
|
+
}
|
|
190
|
+
if (config.preview) {
|
|
191
|
+
providers.push({ provide: PREVIEW_PROVIDER, useValue: config.preview });
|
|
192
|
+
}
|
|
152
193
|
if (config.awaitSession && config.auth) {
|
|
153
194
|
const client = config.auth;
|
|
154
195
|
providers.push(
|