@strands.gg/accui 2.17.56 → 2.17.57
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/package.json +1 -1
- package/dist/StrandsUIPlugin-CiAAY2sN.cjs.js +0 -143
- package/dist/StrandsUIPlugin-Dar_Az2V.es.js +0 -20430
- package/dist/StrandsUIPlugin-fHS0GmiX.cjs.js +0 -143
- package/dist/StrandsUIPlugin-hYC1FxeG.es.js +0 -20577
- package/dist/accui.css +0 -1
- package/dist/index.cjs.js +0 -5
- package/dist/index.es.js +0 -12931
- package/dist/nuxt/module.cjs.js +0 -23
- package/dist/nuxt/module.es.js +0 -182
- package/dist/nuxt/runtime/composables/useAuthenticatedFetch.cjs.js +0 -1
- package/dist/nuxt/runtime/composables/useAuthenticatedFetch.es.js +0 -103
- package/dist/nuxt/runtime/composables/useStrandsAuth.cjs.js +0 -1
- package/dist/nuxt/runtime/composables/useStrandsAuth.d.ts +0 -111
- package/dist/nuxt/runtime/composables/useStrandsAuth.es.js +0 -100
- package/dist/nuxt/runtime/composables/useStrandsOAuth.d.ts +0 -8
- package/dist/nuxt/runtime/middleware/auth.global.cjs.js +0 -1
- package/dist/nuxt/runtime/middleware/auth.global.es.js +0 -35
- package/dist/nuxt/runtime/plugin.client.cjs.js +0 -1
- package/dist/nuxt/runtime/plugin.client.es.js +0 -21
- package/dist/nuxt/runtime/plugin.server.cjs.js +0 -1
- package/dist/nuxt/runtime/plugin.server.es.js +0 -15
- package/dist/nuxt/runtime/plugins/auth-interceptor.client.cjs.js +0 -1
- package/dist/nuxt/runtime/plugins/auth-interceptor.client.d.ts +0 -9
- package/dist/nuxt/runtime/plugins/auth-interceptor.client.es.js +0 -46
- package/dist/nuxt/types.d.ts +0 -51
- package/dist/nuxt.cjs.js +0 -1
- package/dist/nuxt.es.js +0 -11
- package/dist/robots.txt +0 -4
- package/dist/shared/defaults.d.ts +0 -2
- package/dist/sitemap.xml +0 -9
- package/dist/types/composables.d.ts +0 -97
- package/dist/types/index.d.ts +0 -263
- package/dist/types/oauth.d.ts +0 -420
- package/dist/useDarkMode-BdG1G2mj.es.js +0 -102
- package/dist/useDarkMode-BvBnG5kF.cjs.js +0 -1
- package/dist/useDarkMode-Dd0Q5Nnz.cjs.js +0 -1
- package/dist/useDarkMode-FTkHLBsX.es.js +0 -102
- package/dist/useDarkMode-OZ_A8-6H.es.js +0 -102
- package/dist/useStrandsAuth-CetpoBNk.cjs.js +0 -1
- package/dist/useStrandsAuth-DEWj1bFC.cjs.js +0 -1
- package/dist/useStrandsAuth-DTJ5fn33.es.js +0 -666
- package/dist/useStrandsAuth-Z7P9ujqQ.es.js +0 -666
- package/dist/useStrandsAuth-wzl2F9DE.es.js +0 -702
- package/dist/useStrandsConfig-B2UXxIbT.es.js +0 -213
- package/dist/useStrandsConfig-BGJg1LlC.es.js +0 -213
- package/dist/useStrandsConfig-BYOAEt9d.cjs.js +0 -1
- package/dist/vite.cjs.js +0 -29
- package/dist/vite.es.js +0 -92
- package/dist/vue/components/index.d.ts +0 -29
- package/dist/vue/composables/useAuthenticatedFetch.d.ts +0 -22
- package/dist/vue/composables/useDarkMode.d.ts +0 -53
- package/dist/vue/composables/useStrandsOAuth.d.ts +0 -10
- package/dist/vue/ui/UiButton/index.d.ts +0 -11
- package/dist/vue/ui/UiMegaMenu/index.d.ts +0 -4
- package/dist/vue/ui/index.d.ts +0 -62
package/dist/types/oauth.d.ts
DELETED
|
@@ -1,420 +0,0 @@
|
|
|
1
|
-
import type { ComputedRef, Ref } from 'vue';
|
|
2
|
-
import type { User } from './index';
|
|
3
|
-
/**
|
|
4
|
-
* Configuration for OAuth2 client integration
|
|
5
|
-
*/
|
|
6
|
-
export interface StrandsOAuthConfig {
|
|
7
|
-
/**
|
|
8
|
-
* OAuth2 client ID registered with Strands Auth
|
|
9
|
-
*/
|
|
10
|
-
clientId: string;
|
|
11
|
-
/**
|
|
12
|
-
* Redirect URI for OAuth2 callback
|
|
13
|
-
* Must match the URI registered with the OAuth2 application
|
|
14
|
-
*/
|
|
15
|
-
redirectUri: string;
|
|
16
|
-
/**
|
|
17
|
-
* OAuth2 scopes to request
|
|
18
|
-
* @default ['openid', 'profile', 'email']
|
|
19
|
-
*/
|
|
20
|
-
scopes?: string[];
|
|
21
|
-
/**
|
|
22
|
-
* Base URL for Strands Auth server
|
|
23
|
-
* @default 'https://sessions.strands.gg'
|
|
24
|
-
*/
|
|
25
|
-
authServerUrl?: string;
|
|
26
|
-
/**
|
|
27
|
-
* Storage type for tokens
|
|
28
|
-
* - 'localStorage': Persist tokens in localStorage (default)
|
|
29
|
-
* - 'memory': Store tokens in memory only (more secure, lost on refresh)
|
|
30
|
-
* @default 'localStorage'
|
|
31
|
-
*/
|
|
32
|
-
tokenStorage?: 'localStorage' | 'memory';
|
|
33
|
-
/**
|
|
34
|
-
* Enable automatic token refresh before expiry
|
|
35
|
-
* @default true
|
|
36
|
-
*/
|
|
37
|
-
autoRefresh?: boolean;
|
|
38
|
-
/**
|
|
39
|
-
* Callback when authentication succeeds
|
|
40
|
-
*/
|
|
41
|
-
onSuccess?: (session: OAuth2Session) => void;
|
|
42
|
-
/**
|
|
43
|
-
* Callback when authentication fails
|
|
44
|
-
*/
|
|
45
|
-
onError?: (error: OAuth2Error) => void;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* PKCE challenge pair for secure OAuth2 flow
|
|
49
|
-
*/
|
|
50
|
-
export interface PKCEChallenge {
|
|
51
|
-
/**
|
|
52
|
-
* Code verifier - random string stored locally
|
|
53
|
-
*/
|
|
54
|
-
codeVerifier: string;
|
|
55
|
-
/**
|
|
56
|
-
* Code challenge - SHA-256 hash of verifier, sent to auth server
|
|
57
|
-
*/
|
|
58
|
-
codeChallenge: string;
|
|
59
|
-
/**
|
|
60
|
-
* Challenge method - always 'S256' for SHA-256
|
|
61
|
-
*/
|
|
62
|
-
codeChallengeMethod: 'S256';
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Response from OAuth2 token endpoint
|
|
66
|
-
*/
|
|
67
|
-
export interface OAuth2TokenResponse {
|
|
68
|
-
/**
|
|
69
|
-
* Access token for API requests
|
|
70
|
-
*/
|
|
71
|
-
access_token: string;
|
|
72
|
-
/**
|
|
73
|
-
* Token type (typically 'Bearer')
|
|
74
|
-
*/
|
|
75
|
-
token_type: string;
|
|
76
|
-
/**
|
|
77
|
-
* Access token expiry in seconds
|
|
78
|
-
*/
|
|
79
|
-
expires_in: number;
|
|
80
|
-
/**
|
|
81
|
-
* Refresh token for obtaining new access tokens
|
|
82
|
-
*/
|
|
83
|
-
refresh_token?: string;
|
|
84
|
-
/**
|
|
85
|
-
* Granted scopes (space-separated)
|
|
86
|
-
*/
|
|
87
|
-
scope?: string;
|
|
88
|
-
/**
|
|
89
|
-
* ID token (if 'openid' scope was requested)
|
|
90
|
-
*/
|
|
91
|
-
id_token?: string;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Error response from OAuth2 endpoints
|
|
95
|
-
*/
|
|
96
|
-
export interface OAuth2Error {
|
|
97
|
-
/**
|
|
98
|
-
* Error code as defined by OAuth2 spec
|
|
99
|
-
*/
|
|
100
|
-
error: string;
|
|
101
|
-
/**
|
|
102
|
-
* Human-readable error description
|
|
103
|
-
*/
|
|
104
|
-
error_description?: string;
|
|
105
|
-
/**
|
|
106
|
-
* URI with additional error information
|
|
107
|
-
*/
|
|
108
|
-
error_uri?: string;
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* User info from OIDC userinfo endpoint
|
|
112
|
-
*/
|
|
113
|
-
export interface OAuth2UserInfo {
|
|
114
|
-
/**
|
|
115
|
-
* Subject identifier - unique user ID
|
|
116
|
-
*/
|
|
117
|
-
sub: string;
|
|
118
|
-
/**
|
|
119
|
-
* User's email address
|
|
120
|
-
*/
|
|
121
|
-
email?: string;
|
|
122
|
-
/**
|
|
123
|
-
* Whether email has been verified
|
|
124
|
-
*/
|
|
125
|
-
email_verified?: boolean;
|
|
126
|
-
/**
|
|
127
|
-
* User's full name
|
|
128
|
-
*/
|
|
129
|
-
name?: string;
|
|
130
|
-
/**
|
|
131
|
-
* User's given name (first name)
|
|
132
|
-
*/
|
|
133
|
-
given_name?: string;
|
|
134
|
-
/**
|
|
135
|
-
* User's family name (last name)
|
|
136
|
-
*/
|
|
137
|
-
family_name?: string;
|
|
138
|
-
/**
|
|
139
|
-
* User's preferred username
|
|
140
|
-
*/
|
|
141
|
-
preferred_username?: string;
|
|
142
|
-
/**
|
|
143
|
-
* URL of user's profile picture
|
|
144
|
-
*/
|
|
145
|
-
picture?: string;
|
|
146
|
-
/**
|
|
147
|
-
* User's locale
|
|
148
|
-
*/
|
|
149
|
-
locale?: string;
|
|
150
|
-
/**
|
|
151
|
-
* Time when user info was last updated (Unix timestamp)
|
|
152
|
-
*/
|
|
153
|
-
updated_at?: number;
|
|
154
|
-
}
|
|
155
|
-
/**
|
|
156
|
-
* OAuth2 session state maintained by the client
|
|
157
|
-
*/
|
|
158
|
-
export interface OAuth2Session {
|
|
159
|
-
/**
|
|
160
|
-
* Access token for API requests
|
|
161
|
-
*/
|
|
162
|
-
accessToken: string;
|
|
163
|
-
/**
|
|
164
|
-
* Refresh token (if available)
|
|
165
|
-
*/
|
|
166
|
-
refreshToken?: string;
|
|
167
|
-
/**
|
|
168
|
-
* ID token (if OIDC scope was requested)
|
|
169
|
-
*/
|
|
170
|
-
idToken?: string;
|
|
171
|
-
/**
|
|
172
|
-
* Token expiry timestamp
|
|
173
|
-
*/
|
|
174
|
-
expiresAt: Date;
|
|
175
|
-
/**
|
|
176
|
-
* Granted scopes
|
|
177
|
-
*/
|
|
178
|
-
scopes: string[];
|
|
179
|
-
/**
|
|
180
|
-
* User information from userinfo endpoint
|
|
181
|
-
*/
|
|
182
|
-
user?: OAuth2UserInfo;
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* State parameter for CSRF protection during OAuth2 flow
|
|
186
|
-
*/
|
|
187
|
-
export interface OAuth2State {
|
|
188
|
-
/**
|
|
189
|
-
* Random state value
|
|
190
|
-
*/
|
|
191
|
-
state: string;
|
|
192
|
-
/**
|
|
193
|
-
* Original URL to redirect back to after auth
|
|
194
|
-
*/
|
|
195
|
-
returnTo?: string;
|
|
196
|
-
/**
|
|
197
|
-
* Timestamp when state was created
|
|
198
|
-
*/
|
|
199
|
-
createdAt: number;
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* Parameters for OAuth2 authorization request
|
|
203
|
-
*/
|
|
204
|
-
export interface OAuth2AuthorizeParams {
|
|
205
|
-
/**
|
|
206
|
-
* OAuth2 response type
|
|
207
|
-
* @default 'code'
|
|
208
|
-
*/
|
|
209
|
-
response_type: 'code';
|
|
210
|
-
/**
|
|
211
|
-
* OAuth2 client ID
|
|
212
|
-
*/
|
|
213
|
-
client_id: string;
|
|
214
|
-
/**
|
|
215
|
-
* Redirect URI after authorization
|
|
216
|
-
*/
|
|
217
|
-
redirect_uri: string;
|
|
218
|
-
/**
|
|
219
|
-
* Requested scopes (space-separated)
|
|
220
|
-
*/
|
|
221
|
-
scope: string;
|
|
222
|
-
/**
|
|
223
|
-
* State parameter for CSRF protection
|
|
224
|
-
*/
|
|
225
|
-
state: string;
|
|
226
|
-
/**
|
|
227
|
-
* PKCE code challenge
|
|
228
|
-
*/
|
|
229
|
-
code_challenge: string;
|
|
230
|
-
/**
|
|
231
|
-
* PKCE code challenge method
|
|
232
|
-
*/
|
|
233
|
-
code_challenge_method: 'S256';
|
|
234
|
-
/**
|
|
235
|
-
* Optional prompt parameter
|
|
236
|
-
* - 'none': No UI shown, fail if not authenticated
|
|
237
|
-
* - 'login': Force re-authentication
|
|
238
|
-
* - 'consent': Force consent screen
|
|
239
|
-
*/
|
|
240
|
-
prompt?: 'none' | 'login' | 'consent';
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* Response from OAuth2 callback (authorization code grant)
|
|
244
|
-
*/
|
|
245
|
-
export interface OAuth2CallbackParams {
|
|
246
|
-
/**
|
|
247
|
-
* Authorization code to exchange for tokens
|
|
248
|
-
*/
|
|
249
|
-
code?: string;
|
|
250
|
-
/**
|
|
251
|
-
* State parameter for CSRF validation
|
|
252
|
-
*/
|
|
253
|
-
state?: string;
|
|
254
|
-
/**
|
|
255
|
-
* Error code (if authorization failed)
|
|
256
|
-
*/
|
|
257
|
-
error?: string;
|
|
258
|
-
/**
|
|
259
|
-
* Error description
|
|
260
|
-
*/
|
|
261
|
-
error_description?: string;
|
|
262
|
-
}
|
|
263
|
-
/**
|
|
264
|
-
* Props for StrandsOAuthButton component
|
|
265
|
-
*/
|
|
266
|
-
export interface StrandsOAuthButtonProps {
|
|
267
|
-
/**
|
|
268
|
-
* OAuth2 client ID
|
|
269
|
-
*/
|
|
270
|
-
clientId: string;
|
|
271
|
-
/**
|
|
272
|
-
* Redirect URI for callback
|
|
273
|
-
*/
|
|
274
|
-
redirectUri: string;
|
|
275
|
-
/**
|
|
276
|
-
* Scopes to request
|
|
277
|
-
* @default ['openid', 'profile', 'email']
|
|
278
|
-
*/
|
|
279
|
-
scopes?: string[];
|
|
280
|
-
/**
|
|
281
|
-
* Button size
|
|
282
|
-
* @default 'md'
|
|
283
|
-
*/
|
|
284
|
-
size?: 'sm' | 'md' | 'lg';
|
|
285
|
-
/**
|
|
286
|
-
* Button variant
|
|
287
|
-
* @default 'primary'
|
|
288
|
-
*/
|
|
289
|
-
variant?: 'primary' | 'outline' | 'ghost';
|
|
290
|
-
/**
|
|
291
|
-
* Custom button text
|
|
292
|
-
* @default 'Sign in with Strands'
|
|
293
|
-
*/
|
|
294
|
-
text?: string;
|
|
295
|
-
/**
|
|
296
|
-
* Show Strands logo
|
|
297
|
-
* @default true
|
|
298
|
-
*/
|
|
299
|
-
showLogo?: boolean;
|
|
300
|
-
/**
|
|
301
|
-
* Disabled state
|
|
302
|
-
* @default false
|
|
303
|
-
*/
|
|
304
|
-
disabled?: boolean;
|
|
305
|
-
/**
|
|
306
|
-
* Auth server URL
|
|
307
|
-
* @default 'https://sessions.strands.gg'
|
|
308
|
-
*/
|
|
309
|
-
authServerUrl?: string;
|
|
310
|
-
/**
|
|
311
|
-
* Full width button
|
|
312
|
-
* @default false
|
|
313
|
-
*/
|
|
314
|
-
fullWidth?: boolean;
|
|
315
|
-
}
|
|
316
|
-
/**
|
|
317
|
-
* Props for StrandsOAuthCallback component
|
|
318
|
-
*/
|
|
319
|
-
export interface StrandsOAuthCallbackProps {
|
|
320
|
-
/**
|
|
321
|
-
* OAuth2 client ID
|
|
322
|
-
*/
|
|
323
|
-
clientId: string;
|
|
324
|
-
/**
|
|
325
|
-
* Redirect URI (must match the one used in auth request)
|
|
326
|
-
*/
|
|
327
|
-
redirectUri: string;
|
|
328
|
-
/**
|
|
329
|
-
* URL to redirect to on success
|
|
330
|
-
*/
|
|
331
|
-
successRedirect?: string;
|
|
332
|
-
/**
|
|
333
|
-
* URL to redirect to on error
|
|
334
|
-
*/
|
|
335
|
-
errorRedirect?: string;
|
|
336
|
-
/**
|
|
337
|
-
* Auth server URL
|
|
338
|
-
* @default 'https://sessions.strands.gg'
|
|
339
|
-
*/
|
|
340
|
-
authServerUrl?: string;
|
|
341
|
-
/**
|
|
342
|
-
* Whether to automatically fetch user info after token exchange
|
|
343
|
-
* @default true
|
|
344
|
-
*/
|
|
345
|
-
fetchUserInfo?: boolean;
|
|
346
|
-
}
|
|
347
|
-
/**
|
|
348
|
-
* Return type for useStrandsOAuth composable
|
|
349
|
-
*/
|
|
350
|
-
export interface UseStrandsOAuthReturn {
|
|
351
|
-
/**
|
|
352
|
-
* Current OAuth2 session (null if not authenticated)
|
|
353
|
-
*/
|
|
354
|
-
session: ComputedRef<OAuth2Session | null>;
|
|
355
|
-
/**
|
|
356
|
-
* Current user info from OAuth2 session
|
|
357
|
-
*/
|
|
358
|
-
user: ComputedRef<OAuth2UserInfo | null>;
|
|
359
|
-
/**
|
|
360
|
-
* Whether user is authenticated via OAuth2
|
|
361
|
-
*/
|
|
362
|
-
isAuthenticated: ComputedRef<boolean>;
|
|
363
|
-
/**
|
|
364
|
-
* Whether an OAuth2 operation is in progress
|
|
365
|
-
*/
|
|
366
|
-
isLoading: ComputedRef<boolean>;
|
|
367
|
-
/**
|
|
368
|
-
* Current error (if any)
|
|
369
|
-
*/
|
|
370
|
-
error: Ref<OAuth2Error | null>;
|
|
371
|
-
/**
|
|
372
|
-
* Start OAuth2 authorization flow
|
|
373
|
-
* @param returnTo Optional URL to return to after auth
|
|
374
|
-
*/
|
|
375
|
-
startAuth: (returnTo?: string) => void;
|
|
376
|
-
/**
|
|
377
|
-
* Handle OAuth2 callback (exchange code for tokens)
|
|
378
|
-
* @param params Callback parameters from URL
|
|
379
|
-
* @returns OAuth2 session or throws error
|
|
380
|
-
*/
|
|
381
|
-
handleCallback: (params: OAuth2CallbackParams) => Promise<OAuth2Session>;
|
|
382
|
-
/**
|
|
383
|
-
* Refresh the access token using refresh token
|
|
384
|
-
* @returns Whether refresh was successful
|
|
385
|
-
*/
|
|
386
|
-
refreshTokens: () => Promise<boolean>;
|
|
387
|
-
/**
|
|
388
|
-
* Fetch user info from userinfo endpoint
|
|
389
|
-
* @returns User info or throws error
|
|
390
|
-
*/
|
|
391
|
-
fetchUserInfo: () => Promise<OAuth2UserInfo>;
|
|
392
|
-
/**
|
|
393
|
-
* Sign out and clear session
|
|
394
|
-
* @param revokeTokens Whether to revoke tokens on the server
|
|
395
|
-
*/
|
|
396
|
-
signOut: (revokeTokens?: boolean) => Promise<void>;
|
|
397
|
-
/**
|
|
398
|
-
* Get authorization headers for API requests
|
|
399
|
-
*/
|
|
400
|
-
getAuthHeaders: () => Record<string, string>;
|
|
401
|
-
/**
|
|
402
|
-
* Convert OAuth2 user info to Strands User type
|
|
403
|
-
*/
|
|
404
|
-
toStrandsUser: (info: OAuth2UserInfo) => User;
|
|
405
|
-
}
|
|
406
|
-
/**
|
|
407
|
-
* OAuth2 well-known configuration (OpenID Connect Discovery)
|
|
408
|
-
*/
|
|
409
|
-
export interface OAuth2WellKnownConfig {
|
|
410
|
-
issuer: string;
|
|
411
|
-
authorization_endpoint: string;
|
|
412
|
-
token_endpoint: string;
|
|
413
|
-
userinfo_endpoint: string;
|
|
414
|
-
revocation_endpoint?: string;
|
|
415
|
-
jwks_uri: string;
|
|
416
|
-
scopes_supported: string[];
|
|
417
|
-
response_types_supported: string[];
|
|
418
|
-
grant_types_supported: string[];
|
|
419
|
-
code_challenge_methods_supported: string[];
|
|
420
|
-
}
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { computed as u, getCurrentInstance as w, onMounted as p, ref as h, watch as S } from "vue";
|
|
2
|
-
const n = h("system"), l = h(!1), c = "strands-ui-theme";
|
|
3
|
-
function b() {
|
|
4
|
-
return typeof window > "u" ? !1 : window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
5
|
-
}
|
|
6
|
-
function T() {
|
|
7
|
-
if (typeof window > "u") return "system";
|
|
8
|
-
try {
|
|
9
|
-
const e = localStorage.getItem(c);
|
|
10
|
-
if (e && ["light", "dark", "system"].includes(e))
|
|
11
|
-
return e;
|
|
12
|
-
} catch (e) {
|
|
13
|
-
console.warn("Failed to read theme preference from localStorage:", e);
|
|
14
|
-
}
|
|
15
|
-
return "system";
|
|
16
|
-
}
|
|
17
|
-
function E(e) {
|
|
18
|
-
if (!(typeof window > "u"))
|
|
19
|
-
try {
|
|
20
|
-
localStorage.setItem(c, e);
|
|
21
|
-
} catch (s) {
|
|
22
|
-
console.warn("Failed to save theme preference to localStorage:", s);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
function f(e) {
|
|
26
|
-
typeof document > "u" || (e ? (document.documentElement.setAttribute("data-theme", "dark"), document.documentElement.classList.add("dark")) : (document.documentElement.setAttribute("data-theme", "light"), document.documentElement.classList.remove("dark")));
|
|
27
|
-
}
|
|
28
|
-
function L(e = {}) {
|
|
29
|
-
const { skipAutoInit: s = !1 } = e, a = u(() => n.value === "dark" ? !0 : n.value === "light" ? !1 : l.value), g = u(() => {
|
|
30
|
-
switch (n.value) {
|
|
31
|
-
case "light":
|
|
32
|
-
return "Light";
|
|
33
|
-
case "dark":
|
|
34
|
-
return "Dark";
|
|
35
|
-
case "system":
|
|
36
|
-
return "System";
|
|
37
|
-
default:
|
|
38
|
-
return "System";
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
function r(t) {
|
|
42
|
-
n.value = t, E(t);
|
|
43
|
-
}
|
|
44
|
-
function y() {
|
|
45
|
-
const t = a.value ? "light" : "dark";
|
|
46
|
-
r(t);
|
|
47
|
-
}
|
|
48
|
-
function k() {
|
|
49
|
-
switch (n.value) {
|
|
50
|
-
case "light":
|
|
51
|
-
r("dark");
|
|
52
|
-
break;
|
|
53
|
-
case "dark":
|
|
54
|
-
r("system");
|
|
55
|
-
break;
|
|
56
|
-
case "system":
|
|
57
|
-
r("light");
|
|
58
|
-
break;
|
|
59
|
-
default:
|
|
60
|
-
r("light");
|
|
61
|
-
break;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
function d() {
|
|
65
|
-
if (typeof window > "u") return;
|
|
66
|
-
l.value = b();
|
|
67
|
-
const t = window.matchMedia("(prefers-color-scheme: dark)"), m = (i) => {
|
|
68
|
-
l.value = i.matches;
|
|
69
|
-
};
|
|
70
|
-
t.addEventListener ? t.addEventListener("change", m) : t.addListener(m);
|
|
71
|
-
const v = T();
|
|
72
|
-
n.value = v, f(a.value), S(a, (i) => {
|
|
73
|
-
f(i);
|
|
74
|
-
}, { immediate: !1 });
|
|
75
|
-
}
|
|
76
|
-
return !s && w() && p(() => {
|
|
77
|
-
d();
|
|
78
|
-
}), {
|
|
79
|
-
// State
|
|
80
|
-
currentTheme: u(() => n.value),
|
|
81
|
-
isDark: a,
|
|
82
|
-
themeLabel: g,
|
|
83
|
-
// Actions
|
|
84
|
-
setTheme: r,
|
|
85
|
-
toggle: y,
|
|
86
|
-
cycleTheme: k,
|
|
87
|
-
initialize: d,
|
|
88
|
-
// Theme options for UI
|
|
89
|
-
themeOptions: [
|
|
90
|
-
{ value: "light", label: "Light", icon: "sun" },
|
|
91
|
-
{ value: "dark", label: "Dark", icon: "moon" },
|
|
92
|
-
{ value: "system", label: "System", icon: "monitor" }
|
|
93
|
-
]
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
let o = null;
|
|
97
|
-
function D() {
|
|
98
|
-
return o || (o = L({ skipAutoInit: !0 }), typeof window < "u" && (localStorage.getItem(c) === null && (n.value = "system"), o.initialize())), o;
|
|
99
|
-
}
|
|
100
|
-
export {
|
|
101
|
-
D as u
|
|
102
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const r=require("vue"),n=r.ref("system"),u=r.ref(!1),l="strands-ui-theme";function y(){return typeof window>"u"?!1:window.matchMedia("(prefers-color-scheme: dark)").matches}function k(){if(typeof window>"u")return"system";try{const e=localStorage.getItem(l);if(e&&["light","dark","system"].includes(e))return e}catch(e){console.warn("Failed to read theme preference from localStorage:",e)}return"system"}function v(e){if(!(typeof window>"u"))try{localStorage.setItem(l,e)}catch(s){console.warn("Failed to save theme preference to localStorage:",s)}}function m(e){typeof document>"u"||(e?(document.documentElement.setAttribute("data-theme","dark"),document.documentElement.classList.add("dark")):(document.documentElement.setAttribute("data-theme","light"),document.documentElement.classList.remove("dark")))}function w(){const e=r.computed(()=>n.value==="dark"?!0:n.value==="light"?!1:u.value),s=r.computed(()=>{switch(n.value){case"light":return"Light";case"dark":return"Dark";case"system":return"System";default:return"System"}});function a(t){n.value=t,v(t)}function f(){const t=e.value?"light":"dark";a(t)}function h(){switch(n.value){case"light":a("dark");break;case"dark":a("system");break;case"system":a("light");break;default:a("light");break}}function c(){if(typeof window>"u")return;u.value=y();const t=window.matchMedia("(prefers-color-scheme: dark)"),d=i=>{u.value=i.matches};t.addEventListener?t.addEventListener("change",d):t.addListener(d);const g=k();n.value=g,m(e.value),r.watch(e,i=>{m(i)},{immediate:!1})}return r.getCurrentInstance()&&r.onMounted(()=>{c()}),{currentTheme:r.computed(()=>n.value),isDark:e,themeLabel:s,setTheme:a,toggle:f,cycleTheme:h,initialize:c,themeOptions:[{value:"light",label:"Light",icon:"sun"},{value:"dark",label:"Dark",icon:"moon"},{value:"system",label:"System",icon:"monitor"}]}}let o=null;function p(){return o||(o=w(),typeof window<"u"&&(localStorage.getItem(l)===null&&(n.value="system"),o.initialize())),o}exports.useGlobalDarkMode=p;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const r=require("vue"),n=r.ref("system"),l=r.ref(!1),c="strands-ui-theme";function v(){return typeof window>"u"?!1:window.matchMedia("(prefers-color-scheme: dark)").matches}function w(){if(typeof window>"u")return"system";try{const e=localStorage.getItem(c);if(e&&["light","dark","system"].includes(e))return e}catch(e){console.warn("Failed to read theme preference from localStorage:",e)}return"system"}function p(e){if(!(typeof window>"u"))try{localStorage.setItem(c,e)}catch(i){console.warn("Failed to save theme preference to localStorage:",i)}}function f(e){typeof document>"u"||(e?(document.documentElement.setAttribute("data-theme","dark"),document.documentElement.classList.add("dark")):(document.documentElement.setAttribute("data-theme","light"),document.documentElement.classList.remove("dark")))}function b(e={}){const{skipAutoInit:i=!1}=e,o=r.computed(()=>n.value==="dark"?!0:n.value==="light"?!1:l.value),h=r.computed(()=>{switch(n.value){case"light":return"Light";case"dark":return"Dark";case"system":return"System";default:return"System"}});function a(t){n.value=t,p(t)}function g(){const t=o.value?"light":"dark";a(t)}function y(){switch(n.value){case"light":a("dark");break;case"dark":a("system");break;case"system":a("light");break;default:a("light");break}}function d(){if(typeof window>"u")return;l.value=v();const t=window.matchMedia("(prefers-color-scheme: dark)"),m=u=>{l.value=u.matches};t.addEventListener?t.addEventListener("change",m):t.addListener(m);const k=w();n.value=k,f(o.value),r.watch(o,u=>{f(u)},{immediate:!1})}return!i&&r.getCurrentInstance()&&r.onMounted(()=>{d()}),{currentTheme:r.computed(()=>n.value),isDark:o,themeLabel:h,setTheme:a,toggle:g,cycleTheme:y,initialize:d,themeOptions:[{value:"light",label:"Light",icon:"sun"},{value:"dark",label:"Dark",icon:"moon"},{value:"system",label:"System",icon:"monitor"}]}}let s=null;function S(){return s||(s=b({skipAutoInit:!0}),typeof window<"u"&&(localStorage.getItem(c)===null&&(n.value="system"),s.initialize())),s}exports.useGlobalDarkMode=S;
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { ref as f, computed as i, getCurrentInstance as k, onMounted as v, watch as w } from "vue";
|
|
2
|
-
const n = f("system"), l = f(!1), u = "strands-ui-theme";
|
|
3
|
-
function p() {
|
|
4
|
-
return typeof window > "u" ? !1 : window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
5
|
-
}
|
|
6
|
-
function S() {
|
|
7
|
-
if (typeof window > "u") return "system";
|
|
8
|
-
try {
|
|
9
|
-
const e = localStorage.getItem(u);
|
|
10
|
-
if (e && ["light", "dark", "system"].includes(e))
|
|
11
|
-
return e;
|
|
12
|
-
} catch (e) {
|
|
13
|
-
console.warn("Failed to read theme preference from localStorage:", e);
|
|
14
|
-
}
|
|
15
|
-
return "system";
|
|
16
|
-
}
|
|
17
|
-
function b(e) {
|
|
18
|
-
if (!(typeof window > "u"))
|
|
19
|
-
try {
|
|
20
|
-
localStorage.setItem(u, e);
|
|
21
|
-
} catch (o) {
|
|
22
|
-
console.warn("Failed to save theme preference to localStorage:", o);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
function m(e) {
|
|
26
|
-
typeof document > "u" || (e ? (document.documentElement.setAttribute("data-theme", "dark"), document.documentElement.classList.add("dark")) : (document.documentElement.setAttribute("data-theme", "light"), document.documentElement.classList.remove("dark")));
|
|
27
|
-
}
|
|
28
|
-
function T() {
|
|
29
|
-
const e = i(() => n.value === "dark" ? !0 : n.value === "light" ? !1 : l.value), o = i(() => {
|
|
30
|
-
switch (n.value) {
|
|
31
|
-
case "light":
|
|
32
|
-
return "Light";
|
|
33
|
-
case "dark":
|
|
34
|
-
return "Dark";
|
|
35
|
-
case "system":
|
|
36
|
-
return "System";
|
|
37
|
-
default:
|
|
38
|
-
return "System";
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
function r(t) {
|
|
42
|
-
n.value = t, b(t);
|
|
43
|
-
}
|
|
44
|
-
function h() {
|
|
45
|
-
const t = e.value ? "light" : "dark";
|
|
46
|
-
r(t);
|
|
47
|
-
}
|
|
48
|
-
function g() {
|
|
49
|
-
switch (n.value) {
|
|
50
|
-
case "light":
|
|
51
|
-
r("dark");
|
|
52
|
-
break;
|
|
53
|
-
case "dark":
|
|
54
|
-
r("system");
|
|
55
|
-
break;
|
|
56
|
-
case "system":
|
|
57
|
-
r("light");
|
|
58
|
-
break;
|
|
59
|
-
default:
|
|
60
|
-
r("light");
|
|
61
|
-
break;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
function c() {
|
|
65
|
-
if (typeof window > "u") return;
|
|
66
|
-
l.value = p();
|
|
67
|
-
const t = window.matchMedia("(prefers-color-scheme: dark)"), d = (s) => {
|
|
68
|
-
l.value = s.matches;
|
|
69
|
-
};
|
|
70
|
-
t.addEventListener ? t.addEventListener("change", d) : t.addListener(d);
|
|
71
|
-
const y = S();
|
|
72
|
-
n.value = y, m(e.value), w(e, (s) => {
|
|
73
|
-
m(s);
|
|
74
|
-
}, { immediate: !1 });
|
|
75
|
-
}
|
|
76
|
-
return k() && v(() => {
|
|
77
|
-
c();
|
|
78
|
-
}), {
|
|
79
|
-
// State
|
|
80
|
-
currentTheme: i(() => n.value),
|
|
81
|
-
isDark: e,
|
|
82
|
-
themeLabel: o,
|
|
83
|
-
// Actions
|
|
84
|
-
setTheme: r,
|
|
85
|
-
toggle: h,
|
|
86
|
-
cycleTheme: g,
|
|
87
|
-
initialize: c,
|
|
88
|
-
// Theme options for UI
|
|
89
|
-
themeOptions: [
|
|
90
|
-
{ value: "light", label: "Light", icon: "sun" },
|
|
91
|
-
{ value: "dark", label: "Dark", icon: "moon" },
|
|
92
|
-
{ value: "system", label: "System", icon: "monitor" }
|
|
93
|
-
]
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
let a = null;
|
|
97
|
-
function L() {
|
|
98
|
-
return a || (a = T(), typeof window < "u" && (localStorage.getItem(u) === null && (n.value = "system"), a.initialize())), a;
|
|
99
|
-
}
|
|
100
|
-
export {
|
|
101
|
-
L as u
|
|
102
|
-
};
|