@molecule/app-solid 1.0.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.
Files changed (107) hide show
  1. package/LICENSE +115 -0
  2. package/README.md +2543 -0
  3. package/dist/context.d.ts +82 -0
  4. package/dist/context.d.ts.map +1 -0
  5. package/dist/context.js +141 -0
  6. package/dist/context.js.map +1 -0
  7. package/dist/index.d.ts +61 -0
  8. package/dist/index.d.ts.map +1 -0
  9. package/dist/index.js +61 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/primitives/async-state.d.ts +46 -0
  12. package/dist/primitives/async-state.d.ts.map +1 -0
  13. package/dist/primitives/async-state.js +83 -0
  14. package/dist/primitives/async-state.js.map +1 -0
  15. package/dist/primitives/auth.d.ts +85 -0
  16. package/dist/primitives/auth.d.ts.map +1 -0
  17. package/dist/primitives/auth.js +147 -0
  18. package/dist/primitives/auth.js.map +1 -0
  19. package/dist/primitives/capacitor-app.d.ts +46 -0
  20. package/dist/primitives/capacitor-app.d.ts.map +1 -0
  21. package/dist/primitives/capacitor-app.js +57 -0
  22. package/dist/primitives/capacitor-app.js.map +1 -0
  23. package/dist/primitives/change-password.d.ts +36 -0
  24. package/dist/primitives/change-password.d.ts.map +1 -0
  25. package/dist/primitives/change-password.js +32 -0
  26. package/dist/primitives/change-password.js.map +1 -0
  27. package/dist/primitives/device.d.ts +48 -0
  28. package/dist/primitives/device.d.ts.map +1 -0
  29. package/dist/primitives/device.js +47 -0
  30. package/dist/primitives/device.js.map +1 -0
  31. package/dist/primitives/forms.d.ts +193 -0
  32. package/dist/primitives/forms.d.ts.map +1 -0
  33. package/dist/primitives/forms.js +309 -0
  34. package/dist/primitives/forms.js.map +1 -0
  35. package/dist/primitives/http.d.ts +176 -0
  36. package/dist/primitives/http.d.ts.map +1 -0
  37. package/dist/primitives/http.js +254 -0
  38. package/dist/primitives/http.js.map +1 -0
  39. package/dist/primitives/i18n.d.ts +146 -0
  40. package/dist/primitives/i18n.d.ts.map +1 -0
  41. package/dist/primitives/i18n.js +223 -0
  42. package/dist/primitives/i18n.js.map +1 -0
  43. package/dist/primitives/index.d.ts +27 -0
  44. package/dist/primitives/index.d.ts.map +1 -0
  45. package/dist/primitives/index.js +27 -0
  46. package/dist/primitives/index.js.map +1 -0
  47. package/dist/primitives/logger.d.ts +143 -0
  48. package/dist/primitives/logger.d.ts.map +1 -0
  49. package/dist/primitives/logger.js +165 -0
  50. package/dist/primitives/logger.js.map +1 -0
  51. package/dist/primitives/login.d.ts +37 -0
  52. package/dist/primitives/login.d.ts.map +1 -0
  53. package/dist/primitives/login.js +32 -0
  54. package/dist/primitives/login.js.map +1 -0
  55. package/dist/primitives/oauth.d.ts +102 -0
  56. package/dist/primitives/oauth.d.ts.map +1 -0
  57. package/dist/primitives/oauth.js +232 -0
  58. package/dist/primitives/oauth.js.map +1 -0
  59. package/dist/primitives/password-reset.d.ts +46 -0
  60. package/dist/primitives/password-reset.d.ts.map +1 -0
  61. package/dist/primitives/password-reset.js +49 -0
  62. package/dist/primitives/password-reset.js.map +1 -0
  63. package/dist/primitives/platform.d.ts +48 -0
  64. package/dist/primitives/platform.d.ts.map +1 -0
  65. package/dist/primitives/platform.js +47 -0
  66. package/dist/primitives/platform.js.map +1 -0
  67. package/dist/primitives/promise.d.ts +46 -0
  68. package/dist/primitives/promise.d.ts.map +1 -0
  69. package/dist/primitives/promise.js +104 -0
  70. package/dist/primitives/promise.js.map +1 -0
  71. package/dist/primitives/push.d.ts +52 -0
  72. package/dist/primitives/push.d.ts.map +1 -0
  73. package/dist/primitives/push.js +72 -0
  74. package/dist/primitives/push.js.map +1 -0
  75. package/dist/primitives/router.d.ts +170 -0
  76. package/dist/primitives/router.d.ts.map +1 -0
  77. package/dist/primitives/router.js +251 -0
  78. package/dist/primitives/router.js.map +1 -0
  79. package/dist/primitives/signup.d.ts +37 -0
  80. package/dist/primitives/signup.d.ts.map +1 -0
  81. package/dist/primitives/signup.js +32 -0
  82. package/dist/primitives/signup.js.map +1 -0
  83. package/dist/primitives/state.d.ts +132 -0
  84. package/dist/primitives/state.d.ts.map +1 -0
  85. package/dist/primitives/state.js +167 -0
  86. package/dist/primitives/state.js.map +1 -0
  87. package/dist/primitives/storage.d.ts +132 -0
  88. package/dist/primitives/storage.d.ts.map +1 -0
  89. package/dist/primitives/storage.js +275 -0
  90. package/dist/primitives/storage.js.map +1 -0
  91. package/dist/primitives/theme.d.ts +106 -0
  92. package/dist/primitives/theme.d.ts.map +1 -0
  93. package/dist/primitives/theme.js +187 -0
  94. package/dist/primitives/theme.js.map +1 -0
  95. package/dist/primitives/version.d.ts +50 -0
  96. package/dist/primitives/version.d.ts.map +1 -0
  97. package/dist/primitives/version.js +62 -0
  98. package/dist/primitives/version.js.map +1 -0
  99. package/dist/provider.d.ts +36 -0
  100. package/dist/provider.d.ts.map +1 -0
  101. package/dist/provider.jsx +71 -0
  102. package/dist/provider.jsx.map +1 -0
  103. package/dist/types.d.ts +82 -0
  104. package/dist/types.d.ts.map +1 -0
  105. package/dist/types.js +7 -0
  106. package/dist/types.js.map +1 -0
  107. package/package.json +58 -0
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Solid.js context utilities for molecule.dev framework bindings.
3
+ *
4
+ * @module
5
+ */
6
+ import type { AuthClient } from '@molecule/app-auth';
7
+ import type { HttpClient } from '@molecule/app-http';
8
+ import type { I18nProvider } from '@molecule/app-i18n';
9
+ import type { LoggerProvider } from '@molecule/app-logger';
10
+ import type { Router } from '@molecule/app-routing';
11
+ import type { StateProvider } from '@molecule/app-state';
12
+ import type { StorageProvider } from '@molecule/app-storage';
13
+ import type { ThemeProvider } from '@molecule/app-theme';
14
+ /**
15
+ * Internal contexts for molecule providers.
16
+ */
17
+ declare const StateContext: import("solid-js").Context<StateProvider | undefined>;
18
+ declare const AuthContext: import("solid-js").Context<AuthClient<unknown> | undefined>;
19
+ declare const ThemeContext: import("solid-js").Context<ThemeProvider | undefined>;
20
+ declare const RouterContext: import("solid-js").Context<Router | undefined>;
21
+ declare const I18nContext: import("solid-js").Context<I18nProvider | undefined>;
22
+ declare const HttpContext: import("solid-js").Context<HttpClient | undefined>;
23
+ declare const StorageContext: import("solid-js").Context<StorageProvider | undefined>;
24
+ declare const LoggerContext: import("solid-js").Context<LoggerProvider | undefined>;
25
+ /**
26
+ * Get the state provider from context.
27
+ *
28
+ * @returns The state provider instance.
29
+ * @throws {Error} If used outside MoleculeProvider.
30
+ */
31
+ export declare function getStateProvider(): StateProvider;
32
+ /**
33
+ * Get the auth client from context.
34
+ *
35
+ * @returns The auth client instance.
36
+ * @throws {Error} If used outside MoleculeProvider.
37
+ */
38
+ export declare function getAuthClient<T = unknown>(): AuthClient<T>;
39
+ /**
40
+ * Get the theme provider from context.
41
+ *
42
+ * @returns The theme provider instance.
43
+ * @throws {Error} If used outside MoleculeProvider.
44
+ */
45
+ export declare function getThemeProvider(): ThemeProvider;
46
+ /**
47
+ * Get the router from context.
48
+ *
49
+ * @returns The router instance.
50
+ * @throws {Error} If used outside MoleculeProvider.
51
+ */
52
+ export declare function getRouter(): Router;
53
+ /**
54
+ * Get the i18n provider from context.
55
+ *
56
+ * @returns The i18n provider instance.
57
+ * @throws {Error} If used outside MoleculeProvider.
58
+ */
59
+ export declare function getI18nProvider(): I18nProvider;
60
+ /**
61
+ * Get the HTTP client from context.
62
+ *
63
+ * @returns The HTTP client instance.
64
+ * @throws {Error} If used outside MoleculeProvider.
65
+ */
66
+ export declare function getHttpClient(): HttpClient;
67
+ /**
68
+ * Get the storage provider from context.
69
+ *
70
+ * @returns The storage provider instance.
71
+ * @throws {Error} If used outside MoleculeProvider.
72
+ */
73
+ export declare function getStorageProvider(): StorageProvider;
74
+ /**
75
+ * Get the logger provider from context.
76
+ *
77
+ * @returns The logger provider instance.
78
+ * @throws {Error} If used outside MoleculeProvider.
79
+ */
80
+ export declare function getLoggerProvider(): LoggerProvider;
81
+ export { AuthContext, HttpContext, I18nContext, LoggerContext, RouterContext, StateContext, StorageContext, ThemeContext, };
82
+ //# sourceMappingURL=context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAEtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAExD;;GAEG;AACH,QAAA,MAAM,YAAY,uDAAiC,CAAA;AACnD,QAAA,MAAM,WAAW,6DAAuC,CAAA;AACxD,QAAA,MAAM,YAAY,uDAAiC,CAAA;AACnD,QAAA,MAAM,aAAa,gDAA0B,CAAA;AAC7C,QAAA,MAAM,WAAW,sDAAgC,CAAA;AACjD,QAAA,MAAM,WAAW,oDAA8B,CAAA;AAC/C,QAAA,MAAM,cAAc,yDAAmC,CAAA;AACvD,QAAA,MAAM,aAAa,wDAAkC,CAAA;AAErD;;;;;GAKG;AACH,wBAAgB,gBAAgB,IAAI,aAAa,CAWhD;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,CAAC,GAAG,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,CAU1D;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,IAAI,aAAa,CAWhD;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,IAAI,MAAM,CAUlC;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,IAAI,YAAY,CAU9C;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,IAAI,UAAU,CAU1C;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,IAAI,eAAe,CAWpD;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,IAAI,cAAc,CAWlD;AAGD,OAAO,EACL,WAAW,EACX,WAAW,EACX,WAAW,EACX,aAAa,EACb,aAAa,EACb,YAAY,EACZ,cAAc,EACd,YAAY,GACb,CAAA"}
@@ -0,0 +1,141 @@
1
+ /**
2
+ * Solid.js context utilities for molecule.dev framework bindings.
3
+ *
4
+ * @module
5
+ */
6
+ import { createContext, useContext } from 'solid-js';
7
+ import { t } from '@molecule/app-i18n';
8
+ /**
9
+ * Internal contexts for molecule providers.
10
+ */
11
+ const StateContext = createContext();
12
+ const AuthContext = createContext();
13
+ const ThemeContext = createContext();
14
+ const RouterContext = createContext();
15
+ const I18nContext = createContext();
16
+ const HttpContext = createContext();
17
+ const StorageContext = createContext();
18
+ const LoggerContext = createContext();
19
+ /**
20
+ * Get the state provider from context.
21
+ *
22
+ * @returns The state provider instance.
23
+ * @throws {Error} If used outside MoleculeProvider.
24
+ */
25
+ export function getStateProvider() {
26
+ const ctx = useContext(StateContext);
27
+ if (!ctx) {
28
+ throw new Error(t('solid.error.stateOutsideProvider', undefined, {
29
+ defaultValue: 'getStateProvider must be used within a MoleculeProvider with state configured',
30
+ }));
31
+ }
32
+ return ctx;
33
+ }
34
+ /**
35
+ * Get the auth client from context.
36
+ *
37
+ * @returns The auth client instance.
38
+ * @throws {Error} If used outside MoleculeProvider.
39
+ */
40
+ export function getAuthClient() {
41
+ const ctx = useContext(AuthContext);
42
+ if (!ctx) {
43
+ throw new Error(t('solid.error.authOutsideProvider', undefined, {
44
+ defaultValue: 'getAuthClient must be used within a MoleculeProvider with auth configured',
45
+ }));
46
+ }
47
+ return ctx;
48
+ }
49
+ /**
50
+ * Get the theme provider from context.
51
+ *
52
+ * @returns The theme provider instance.
53
+ * @throws {Error} If used outside MoleculeProvider.
54
+ */
55
+ export function getThemeProvider() {
56
+ const ctx = useContext(ThemeContext);
57
+ if (!ctx) {
58
+ throw new Error(t('solid.error.themeOutsideProvider', undefined, {
59
+ defaultValue: 'getThemeProvider must be used within a MoleculeProvider with theme configured',
60
+ }));
61
+ }
62
+ return ctx;
63
+ }
64
+ /**
65
+ * Get the router from context.
66
+ *
67
+ * @returns The router instance.
68
+ * @throws {Error} If used outside MoleculeProvider.
69
+ */
70
+ export function getRouter() {
71
+ const ctx = useContext(RouterContext);
72
+ if (!ctx) {
73
+ throw new Error(t('solid.error.routerOutsideProvider', undefined, {
74
+ defaultValue: 'getRouter must be used within a MoleculeProvider with router configured',
75
+ }));
76
+ }
77
+ return ctx;
78
+ }
79
+ /**
80
+ * Get the i18n provider from context.
81
+ *
82
+ * @returns The i18n provider instance.
83
+ * @throws {Error} If used outside MoleculeProvider.
84
+ */
85
+ export function getI18nProvider() {
86
+ const ctx = useContext(I18nContext);
87
+ if (!ctx) {
88
+ throw new Error(t('solid.error.i18nOutsideProvider', undefined, {
89
+ defaultValue: 'getI18nProvider must be used within a MoleculeProvider with i18n configured',
90
+ }));
91
+ }
92
+ return ctx;
93
+ }
94
+ /**
95
+ * Get the HTTP client from context.
96
+ *
97
+ * @returns The HTTP client instance.
98
+ * @throws {Error} If used outside MoleculeProvider.
99
+ */
100
+ export function getHttpClient() {
101
+ const ctx = useContext(HttpContext);
102
+ if (!ctx) {
103
+ throw new Error(t('solid.error.httpOutsideProvider', undefined, {
104
+ defaultValue: 'getHttpClient must be used within a MoleculeProvider with http configured',
105
+ }));
106
+ }
107
+ return ctx;
108
+ }
109
+ /**
110
+ * Get the storage provider from context.
111
+ *
112
+ * @returns The storage provider instance.
113
+ * @throws {Error} If used outside MoleculeProvider.
114
+ */
115
+ export function getStorageProvider() {
116
+ const ctx = useContext(StorageContext);
117
+ if (!ctx) {
118
+ throw new Error(t('solid.error.storageOutsideProvider', undefined, {
119
+ defaultValue: 'getStorageProvider must be used within a MoleculeProvider with storage configured',
120
+ }));
121
+ }
122
+ return ctx;
123
+ }
124
+ /**
125
+ * Get the logger provider from context.
126
+ *
127
+ * @returns The logger provider instance.
128
+ * @throws {Error} If used outside MoleculeProvider.
129
+ */
130
+ export function getLoggerProvider() {
131
+ const ctx = useContext(LoggerContext);
132
+ if (!ctx) {
133
+ throw new Error(t('solid.error.loggerOutsideProvider', undefined, {
134
+ defaultValue: 'getLoggerProvider must be used within a MoleculeProvider with logger configured',
135
+ }));
136
+ }
137
+ return ctx;
138
+ }
139
+ // Export contexts for advanced use cases
140
+ export { AuthContext, HttpContext, I18nContext, LoggerContext, RouterContext, StateContext, StorageContext, ThemeContext, };
141
+ //# sourceMappingURL=context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Solid.js framework bindings for molecule.dev.
3
+ *
4
+ * Provides Solid-specific implementations of molecule.dev core interfaces
5
+ * using Solid's reactive primitives (signals, effects, resources): wrap the
6
+ * app in `MoleculeProvider` with a `config` of providers, then consume them
7
+ * through `createAuth`, `createTheme`, `createRouter`, `createI18n`, and the
8
+ * other primitives.
9
+ *
10
+ * @example
11
+ * ```tsx
12
+ * import { MoleculeProvider, createAuth, createTheme } from '@molecule/app-solid'
13
+ * import { Show } from 'solid-js'
14
+ * import { provider as stateProvider } from '@molecule/app-state-zustand'
15
+ * import { provider as themeProvider } from '@molecule/app-theme-css-variables'
16
+ * import { createJWTAuthClient } from '@molecule/app-auth'
17
+ *
18
+ * const authClient = createJWTAuthClient({ baseURL: '/api' })
19
+ *
20
+ * function UserProfile() {
21
+ * const { user, isAuthenticated, logout } = createAuth<{ name?: string }>()
22
+ * const { theme, toggleTheme } = createTheme()
23
+ *
24
+ * return (
25
+ * <Show when={isAuthenticated()} fallback={<a href="/login">Log in</a>}>
26
+ * <div style={{ background: theme().colors.background }}>
27
+ * <h1>Welcome, {user()?.name}</h1>
28
+ * <button onClick={toggleTheme}>Toggle Theme</button>
29
+ * <button onClick={() => logout()}>Logout</button>
30
+ * </div>
31
+ * </Show>
32
+ * )
33
+ * }
34
+ *
35
+ * function App() {
36
+ * return (
37
+ * <MoleculeProvider config={{ state: stateProvider, auth: authClient, theme: themeProvider }}>
38
+ * <UserProfile />
39
+ * </MoleculeProvider>
40
+ * )
41
+ * }
42
+ * ```
43
+ *
44
+ * @remarks
45
+ * - **Primitives throw outside `MoleculeProvider` — and per missing service.** `config` wires
46
+ * ONLY the services you pass; calling `createAuth()` in a tree whose config lacks `auth`
47
+ * throws "getAuthClient must be used within a MoleculeProvider with auth configured". Fix the
48
+ * config, don't catch the error.
49
+ * - Primitive results are Solid accessors — call them (`isAuthenticated()`, `theme()`,
50
+ * `user()`), never read them bare; a bare `theme.colors` is a type error, and a bare
51
+ * `isAuthenticated` is always truthy.
52
+ * - Call primitives at component setup (top level of the component function), not inside JSX
53
+ * callbacks, so subscriptions are established once.
54
+ *
55
+ * @module
56
+ */
57
+ export * from './context.js';
58
+ export * from './primitives/index.js';
59
+ export * from './provider.jsx';
60
+ export * from './types.js';
61
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AAEH,cAAc,cAAc,CAAA;AAC5B,cAAc,uBAAuB,CAAA;AACrC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Solid.js framework bindings for molecule.dev.
3
+ *
4
+ * Provides Solid-specific implementations of molecule.dev core interfaces
5
+ * using Solid's reactive primitives (signals, effects, resources): wrap the
6
+ * app in `MoleculeProvider` with a `config` of providers, then consume them
7
+ * through `createAuth`, `createTheme`, `createRouter`, `createI18n`, and the
8
+ * other primitives.
9
+ *
10
+ * @example
11
+ * ```tsx
12
+ * import { MoleculeProvider, createAuth, createTheme } from '@molecule/app-solid'
13
+ * import { Show } from 'solid-js'
14
+ * import { provider as stateProvider } from '@molecule/app-state-zustand'
15
+ * import { provider as themeProvider } from '@molecule/app-theme-css-variables'
16
+ * import { createJWTAuthClient } from '@molecule/app-auth'
17
+ *
18
+ * const authClient = createJWTAuthClient({ baseURL: '/api' })
19
+ *
20
+ * function UserProfile() {
21
+ * const { user, isAuthenticated, logout } = createAuth<{ name?: string }>()
22
+ * const { theme, toggleTheme } = createTheme()
23
+ *
24
+ * return (
25
+ * <Show when={isAuthenticated()} fallback={<a href="/login">Log in</a>}>
26
+ * <div style={{ background: theme().colors.background }}>
27
+ * <h1>Welcome, {user()?.name}</h1>
28
+ * <button onClick={toggleTheme}>Toggle Theme</button>
29
+ * <button onClick={() => logout()}>Logout</button>
30
+ * </div>
31
+ * </Show>
32
+ * )
33
+ * }
34
+ *
35
+ * function App() {
36
+ * return (
37
+ * <MoleculeProvider config={{ state: stateProvider, auth: authClient, theme: themeProvider }}>
38
+ * <UserProfile />
39
+ * </MoleculeProvider>
40
+ * )
41
+ * }
42
+ * ```
43
+ *
44
+ * @remarks
45
+ * - **Primitives throw outside `MoleculeProvider` — and per missing service.** `config` wires
46
+ * ONLY the services you pass; calling `createAuth()` in a tree whose config lacks `auth`
47
+ * throws "getAuthClient must be used within a MoleculeProvider with auth configured". Fix the
48
+ * config, don't catch the error.
49
+ * - Primitive results are Solid accessors — call them (`isAuthenticated()`, `theme()`,
50
+ * `user()`), never read them bare; a bare `theme.colors` is a type error, and a bare
51
+ * `isAuthenticated` is always truthy.
52
+ * - Call primitives at component setup (top level of the component function), not inside JSX
53
+ * callbacks, so subscriptions are established once.
54
+ *
55
+ * @module
56
+ */
57
+ export * from './context.js';
58
+ export * from './primitives/index.js';
59
+ export * from './provider.jsx';
60
+ export * from './types.js';
61
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AAEH,cAAc,cAAc,CAAA;AAC5B,cAAc,uBAAuB,CAAA;AACrC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Return type for createAsyncState.
3
+ */
4
+ export interface CreateAsyncStateReturn<T> {
5
+ state: () => T;
6
+ setState: (value: T | ((prev: T) => T) | Promise<T | ((prev: T) => T)>) => void;
7
+ extendState: (partial: Partial<T> | ((prev: T) => Partial<T>) | Promise<Partial<T> | ((prev: T) => Partial<T>)>) => void;
8
+ }
9
+ /**
10
+ * Primitive like createSignal but accepts Promises and supports partial state extension.
11
+ *
12
+ * @param initialState - Initial state value
13
+ *
14
+ * @example
15
+ * ```tsx
16
+ * import { createAsyncState } from '@molecule/app-solid'
17
+ *
18
+ * interface State {
19
+ * foo: string
20
+ * bar: string
21
+ * }
22
+ *
23
+ * function MyComponent() {
24
+ * const { state, setState, extendState } = createAsyncState<State>({
25
+ * foo: 'foo',
26
+ * bar: 'bar',
27
+ * })
28
+ *
29
+ * // Synchronous usage
30
+ * setState({ foo: 'Hello', bar: 'World!' })
31
+ * setState((prev) => ({ ...prev, foo: prev.foo.toUpperCase() }))
32
+ *
33
+ * // Async usage
34
+ * setState(fetchData())
35
+ *
36
+ * // Partial updates
37
+ * extendState({ foo: 'Hello' })
38
+ * extendState(fetchPartialData())
39
+ *
40
+ * return <div>{state().foo} {state().bar}</div>
41
+ * }
42
+ * ```
43
+ * @returns The created instance.
44
+ */
45
+ export declare function createAsyncState<T>(initialState: T): CreateAsyncStateReturn<T>;
46
+ //# sourceMappingURL=async-state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"async-state.d.ts","sourceRoot":"","sources":["../../src/primitives/async-state.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,MAAM,WAAW,sBAAsB,CAAC,CAAC;IACvC,KAAK,EAAE,MAAM,CAAC,CAAA;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI,CAAA;IAC/E,WAAW,EAAE,CACX,OAAO,EACL,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,KACvF,IAAI,CAAA;CACV;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,GAAG,sBAAsB,CAAC,CAAC,CAAC,CAgD9E"}
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Solid.js primitive for async-capable state management.
3
+ *
4
+ * @module
5
+ */
6
+ import { createSignal } from 'solid-js';
7
+ /**
8
+ * Primitive like createSignal but accepts Promises and supports partial state extension.
9
+ *
10
+ * @param initialState - Initial state value
11
+ *
12
+ * @example
13
+ * ```tsx
14
+ * import { createAsyncState } from '@molecule/app-solid'
15
+ *
16
+ * interface State {
17
+ * foo: string
18
+ * bar: string
19
+ * }
20
+ *
21
+ * function MyComponent() {
22
+ * const { state, setState, extendState } = createAsyncState<State>({
23
+ * foo: 'foo',
24
+ * bar: 'bar',
25
+ * })
26
+ *
27
+ * // Synchronous usage
28
+ * setState({ foo: 'Hello', bar: 'World!' })
29
+ * setState((prev) => ({ ...prev, foo: prev.foo.toUpperCase() }))
30
+ *
31
+ * // Async usage
32
+ * setState(fetchData())
33
+ *
34
+ * // Partial updates
35
+ * extendState({ foo: 'Hello' })
36
+ * extendState(fetchPartialData())
37
+ *
38
+ * return <div>{state().foo} {state().bar}</div>
39
+ * }
40
+ * ```
41
+ * @returns The created instance.
42
+ */
43
+ export function createAsyncState(initialState) {
44
+ const [state, setSignal] = createSignal(initialState);
45
+ const setState = async (nextState) => {
46
+ try {
47
+ if (nextState instanceof Promise) {
48
+ nextState = await nextState;
49
+ }
50
+ setSignal((prev) => {
51
+ if (typeof nextState === 'function') {
52
+ return nextState(prev);
53
+ }
54
+ return nextState;
55
+ });
56
+ }
57
+ catch (_error) {
58
+ // Silently swallow errors from resolved Promises to avoid unhandled rejections
59
+ }
60
+ };
61
+ const extendState = async (partial) => {
62
+ try {
63
+ if (partial instanceof Promise) {
64
+ partial = await partial;
65
+ }
66
+ setSignal((prev) => {
67
+ let resolved;
68
+ if (typeof partial === 'function') {
69
+ resolved = partial(prev);
70
+ }
71
+ else {
72
+ resolved = partial;
73
+ }
74
+ return { ...prev, ...resolved };
75
+ });
76
+ }
77
+ catch (_error) {
78
+ // Silently swallow errors from resolved Promises to avoid unhandled rejections
79
+ }
80
+ };
81
+ return { state, setState, extendState };
82
+ }
83
+ //# sourceMappingURL=async-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"async-state.js","sourceRoot":"","sources":["../../src/primitives/async-state.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAcvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,UAAU,gBAAgB,CAAI,YAAe;IACjD,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC,GAAG,YAAY,CAAI,YAAY,CAAC,CAAA;IAExD,MAAM,QAAQ,GAAG,KAAK,EACpB,SAA+D,EAChD,EAAE;QACjB,IAAI,CAAC;YACH,IAAI,SAAS,YAAY,OAAO,EAAE,CAAC;gBACjC,SAAS,GAAG,MAAM,SAAS,CAAA;YAC7B,CAAC;YAED,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE;gBACjB,IAAI,OAAO,SAAS,KAAK,UAAU,EAAE,CAAC;oBACpC,OAAQ,SAA4B,CAAC,IAAI,CAAC,CAAA;gBAC5C,CAAC;gBACD,OAAO,SAAc,CAAA;YACvB,CAAC,CAAC,CAAA;QACJ,CAAC;QAAC,OAAO,MAAM,EAAE,CAAC;YAChB,+EAA+E;QACjF,CAAC;IACH,CAAC,CAAA;IAED,MAAM,WAAW,GAAG,KAAK,EACvB,OAC0F,EAC3E,EAAE;QACjB,IAAI,CAAC;YACH,IAAI,OAAO,YAAY,OAAO,EAAE,CAAC;gBAC/B,OAAO,GAAG,MAAM,OAAO,CAAA;YACzB,CAAC;YAED,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE;gBACjB,IAAI,QAAoB,CAAA;gBAExB,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE,CAAC;oBAClC,QAAQ,GAAI,OAAmC,CAAC,IAAI,CAAC,CAAA;gBACvD,CAAC;qBAAM,CAAC;oBACN,QAAQ,GAAG,OAAqB,CAAA;gBAClC,CAAC;gBAED,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,QAAQ,EAAE,CAAA;YACjC,CAAC,CAAC,CAAA;QACJ,CAAC;QAAC,OAAO,MAAM,EAAE,CAAC;YAChB,+EAA+E;QACjF,CAAC;IACH,CAAC,CAAA;IAED,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAA;AACzC,CAAC"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Solid.js primitives for authentication.
3
+ *
4
+ * @module
5
+ */
6
+ import { type Accessor } from 'solid-js';
7
+ import type { AuthClient, AuthResult, LoginCredentials, RegisterData } from '@molecule/app-auth';
8
+ import type { AuthPrimitives } from '../types.js';
9
+ /**
10
+ * Create auth primitives for authentication state and actions.
11
+ *
12
+ * @returns Auth primitives object
13
+ *
14
+ * @example
15
+ * ```tsx
16
+ * import { createAuth } from '@molecule/app-solid'
17
+ *
18
+ * function LoginButton() {
19
+ * const { isAuthenticated, user, login, logout } = createAuth()
20
+ *
21
+ * return (
22
+ * <Show
23
+ * when={isAuthenticated()}
24
+ * fallback={
25
+ * <button onClick={() => login({ email: '...', password: '...' })}>
26
+ * Login
27
+ * </button>
28
+ * }
29
+ * >
30
+ * <div>
31
+ * <span>Welcome, {user()?.name}</span>
32
+ * <button onClick={() => logout()}>Logout</button>
33
+ * </div>
34
+ * </Show>
35
+ * )
36
+ * }
37
+ * ```
38
+ */
39
+ export declare function createAuth<T = unknown>(): AuthPrimitives<T>;
40
+ /**
41
+ * Create a guard primitive that redirects unauthenticated users.
42
+ *
43
+ * @param redirectTo - Path to redirect to
44
+ * @returns Accessor indicating if user is allowed
45
+ *
46
+ * @example
47
+ * ```tsx
48
+ * function ProtectedPage() {
49
+ * const isAllowed = createAuthGuard('/login')
50
+ *
51
+ * return (
52
+ * <Show when={isAllowed()} fallback={<div>Redirecting...</div>}>
53
+ * <ProtectedContent />
54
+ * </Show>
55
+ * )
56
+ * }
57
+ * ```
58
+ */
59
+ export declare function createAuthGuard(redirectTo: string): Accessor<boolean>;
60
+ /**
61
+ * Create auth helpers from context.
62
+ *
63
+ * @returns Auth helper functions
64
+ */
65
+ /**
66
+ * Creates a auth helpers.
67
+ * @returns The created result.
68
+ */
69
+ export declare function createAuthHelpers<T = unknown>(): {
70
+ login: (credentials: LoginCredentials) => Promise<AuthResult<T>>;
71
+ logout: () => Promise<void>;
72
+ register: (data: RegisterData) => Promise<AuthResult<T>>;
73
+ refresh: () => Promise<AuthResult<T>>;
74
+ getUser: () => T | null;
75
+ getToken: () => string | null;
76
+ isAuthenticated: () => boolean;
77
+ };
78
+ /**
79
+ * Create auth primitives from a specific client.
80
+ *
81
+ * @param client - Auth client
82
+ * @returns Auth primitives
83
+ */
84
+ export declare function createAuthFromClient<T = unknown>(client: AuthClient<T>): AuthPrimitives<T>;
85
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/primitives/auth.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,QAAQ,EAAyC,MAAM,UAAU,CAAA;AAE/E,OAAO,KAAK,EACV,UAAU,EACV,UAAU,EAEV,gBAAgB,EAChB,YAAY,EACb,MAAM,oBAAoB,CAAA;AAG3B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAEjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,UAAU,CAAC,CAAC,GAAG,OAAO,KAAK,cAAc,CAAC,CAAC,CAAC,CAmC3D;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,CAUrE;AAED;;;;GAIG;AAEH;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,GAAG,OAAO,KAAK;IAChD,KAAK,EAAE,CAAC,WAAW,EAAE,gBAAgB,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;IAChE,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;IAC3B,QAAQ,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;IACxD,OAAO,EAAE,MAAM,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;IACrC,OAAO,EAAE,MAAM,CAAC,GAAG,IAAI,CAAA;IACvB,QAAQ,EAAE,MAAM,MAAM,GAAG,IAAI,CAAA;IAC7B,eAAe,EAAE,MAAM,OAAO,CAAA;CAC/B,CAYA;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC,CA2B1F"}