@3lineas/groovepack 1.2.0 → 1.3.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 +21 -12
- package/dist/api-action/index.d.ts +1 -4
- package/dist/api-action/index.js +2 -3
- package/dist/api-action/index.js.map +1 -1
- package/dist/api-toast/index.d.ts +21 -32
- package/dist/api-toast/index.js +78 -28
- package/dist/api-toast/index.js.map +1 -1
- package/dist/{chunk-3FQ5C44Y.js → chunk-OSPD6EX4.js} +5 -14
- package/dist/chunk-OSPD6EX4.js.map +1 -0
- package/dist/i18n/index.d.ts +8 -17
- package/dist/i18n/index.js +3 -5
- package/dist/vite/index.d.ts +34 -0
- package/dist/vite/index.js +78 -0
- package/dist/vite/index.js.map +1 -0
- package/package.json +5 -1
- package/dist/chunk-3FQ5C44Y.js.map +0 -1
- package/dist/groovepack-locale.type-CaXo9vLj.d.ts +0 -3
package/README.md
CHANGED
|
@@ -48,6 +48,7 @@ Install only what your app actually uses:
|
|
|
48
48
|
| `/api-action` | *None (0 deps)* | React, Astro, Next.js, Node |
|
|
49
49
|
| `/api-client` | `hono >= 4.0.0` *(only if using `createHonoClient`)* | Frontend / Edge |
|
|
50
50
|
| `/api-toast` | `@base-ui/react >= 1.0.0` (Shadcn v4 `toast`) | React / Browser |
|
|
51
|
+
| `/vite` | *None (0 deps)* | Vite `vite.config.ts` |
|
|
51
52
|
|
|
52
53
|
---
|
|
53
54
|
|
|
@@ -250,24 +251,32 @@ export async function createProductAction(
|
|
|
250
251
|
|
|
251
252
|
## 6. `@3lineas/groovepack/api-toast`
|
|
252
253
|
|
|
253
|
-
Orchestrates async actions with **Shadcn
|
|
254
|
+
Orchestrates async actions with **Shadcn Toast** loading, success, and error toasts, returning the resolved `ActionResponse<T>`. Automatically resolves `toastManager` from `/src/components/ui/toast` (or `GROOVEPACK_SHADCN_PATH` / `NEXT_PUBLIC_GROOVEPACK_SHADCN_PATH`), and reads the active language strictly from `GROOVEPACK_LOCALE` / `NEXT_PUBLIC_GROOVEPACK_LOCALE` (defaulting to `"en"`).
|
|
254
255
|
|
|
255
256
|
```typescript
|
|
256
|
-
import { apiToast
|
|
257
|
-
import { toastManager } from "@/components/ui/toast";
|
|
257
|
+
import { apiToast } from "@3lineas/groovepack/api-toast";
|
|
258
258
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
259
|
+
await apiToast({
|
|
260
|
+
action: () => loginAction(values),
|
|
261
|
+
onSuccess: () => {
|
|
262
|
+
router.push("/dashboard");
|
|
263
|
+
router.refresh();
|
|
264
|
+
},
|
|
263
265
|
});
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
### Vite Plugin (`@3lineas/groovepack/vite`)
|
|
264
269
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
+
For Vite apps, register `groovepack()` in `vite.config.ts` so `${shadcnPath}/toast` is statically resolved in both `vite dev` and `vite build`:
|
|
271
|
+
|
|
272
|
+
```typescript
|
|
273
|
+
import { defineConfig } from "vite";
|
|
274
|
+
import { groovepack } from "@3lineas/groovepack/vite";
|
|
275
|
+
|
|
276
|
+
export default defineConfig({
|
|
277
|
+
plugins: [groovepack()],
|
|
270
278
|
});
|
|
279
|
+
```
|
|
271
280
|
|
|
272
281
|
// Or passing the toast manager directly per call
|
|
273
282
|
await apiToast({
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { A as ActionResponse } from '../action-response.type-XlzII9Lr.js';
|
|
2
|
-
import { G as GroovepackLocale } from '../groovepack-locale.type-CaXo9vLj.js';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* Minimal `Response`-like contract compatible with `fetch`, Hono `ClientResponse`,
|
|
@@ -27,8 +26,6 @@ type ErrorLogger = (message: string, context?: Record<string, unknown>) => void;
|
|
|
27
26
|
interface ApiActionOptions<T = unknown> {
|
|
28
27
|
/** Async call returning either a `Response`/`ClientResponse` or an `ActionResponse<T>`. */
|
|
29
28
|
apiCall: () => Promise<ApiCallResult<T>>;
|
|
30
|
-
/** Optional locale override (`"en" | "es" | "pt" | "it" | "fr"`). */
|
|
31
|
-
locale?: GroovepackLocale;
|
|
32
29
|
/** Default fallback error message when the server does not provide one. */
|
|
33
30
|
defaultErrorMessage?: string;
|
|
34
31
|
/** Optional logger for unexpected exceptions or malformed payloads. */
|
|
@@ -39,6 +36,6 @@ interface ApiActionOptions<T = unknown> {
|
|
|
39
36
|
* Universal wrapper for API calls (Hono RPC, `fetch`, or Server Actions)
|
|
40
37
|
* guaranteeing a standardized `ActionResponse<T>` without throwing uncaught errors.
|
|
41
38
|
*/
|
|
42
|
-
declare function apiAction<T = unknown>({ apiCall,
|
|
39
|
+
declare function apiAction<T = unknown>({ apiCall, defaultErrorMessage, onError, }: ApiActionOptions<T>): Promise<ActionResponse<T>>;
|
|
43
40
|
|
|
44
41
|
export { ActionResponse, type ApiActionOptions, type ApiCallResult, type ErrorLogger, type MinimalResponse, apiAction };
|
package/dist/api-action/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveLocaleMessages
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-OSPD6EX4.js";
|
|
4
4
|
|
|
5
5
|
// src/api-action/default-error-logger.ts
|
|
6
6
|
var defaultErrorLogger = (message, context) => {
|
|
@@ -66,11 +66,10 @@ async function handleHttpResponse(response, fallbackErrorMessage, serverRequestF
|
|
|
66
66
|
// src/api-action/index.ts
|
|
67
67
|
async function apiAction({
|
|
68
68
|
apiCall,
|
|
69
|
-
locale,
|
|
70
69
|
defaultErrorMessage,
|
|
71
70
|
onError = defaultErrorLogger
|
|
72
71
|
}) {
|
|
73
|
-
const messages = resolveLocaleMessages(
|
|
72
|
+
const messages = resolveLocaleMessages();
|
|
74
73
|
const resolvedDefaultError = defaultErrorMessage ?? messages.unexpectedError;
|
|
75
74
|
try {
|
|
76
75
|
const actionResult = await apiCall();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/api-action/default-error-logger.ts","../../src/api-action/is-minimal-response.ts","../../src/api-action/is-action-response.ts","../../src/api-action/try-parse-json.ts","../../src/api-action/handle-http-response.ts","../../src/api-action/index.ts"],"sourcesContent":["import type { ErrorLogger } from \"@/types/api-action/error-logger.type\";\n\n/**\n * Default error logger used when `onError` is not provided to `apiAction`.\n */\nexport const defaultErrorLogger: ErrorLogger = (message, context) => {\n if (context) {\n console.error(`[apiAction] ${message}`, context);\n return;\n }\n console.error(`[apiAction] ${message}`);\n};\n","import type { MinimalResponse } from \"@/types/api-action/minimal-response.type\";\n\n/**\n * Type guard verifying whether a value implements `MinimalResponse`.\n */\nexport function isMinimalResponse(\n candidateValue: unknown,\n): candidateValue is MinimalResponse {\n return (\n typeof candidateValue === \"object\" &&\n candidateValue !== null &&\n \"ok\" in candidateValue &&\n typeof candidateValue.ok === \"boolean\" &&\n \"status\" in candidateValue &&\n typeof candidateValue.status === \"number\" &&\n \"json\" in candidateValue &&\n typeof candidateValue.json === \"function\"\n );\n}\n","import type { ActionResponse } from \"@/types/common/action-response.type\";\n\n/**\n * Type guard verifying whether a value implements `ActionResponse<T>`.\n */\nexport function isActionResponse<T>(\n candidateValue: unknown,\n): candidateValue is ActionResponse<T> {\n return (\n typeof candidateValue === \"object\" &&\n candidateValue !== null &&\n \"success\" in candidateValue &&\n typeof candidateValue.success === \"boolean\"\n );\n}\n","/**\n * Safely parses JSON from a `MinimalResponse`, returning `null` if parsing fails.\n */\nexport async function tryParseJson(\n response: { json: () => Promise<unknown> },\n): Promise<Record<string, unknown> | null> {\n try {\n const parsed = await response.json();\n if (typeof parsed === \"object\" && parsed !== null) {\n return parsed as Record<string, unknown>;\n }\n return null;\n } catch {\n return null;\n }\n}\n","import type { ActionResponse } from \"@/types/common/action-response.type\";\nimport type { ErrorLogger } from \"@/types/api-action/error-logger.type\";\nimport type { MinimalResponse } from \"@/types/api-action/minimal-response.type\";\nimport { isActionResponse } from \"@/api-action/is-action-response\";\nimport { tryParseJson } from \"@/api-action/try-parse-json\";\n\n/**\n * Normalizes a `MinimalResponse` (Fetch / Hono RPC) into an `ActionResponse<T>`.\n */\nexport async function handleHttpResponse<T>(\n response: MinimalResponse,\n fallbackErrorMessage: string,\n serverRequestFailedMessage: string,\n logError: ErrorLogger,\n): Promise<ActionResponse<T>> {\n const payload = await tryParseJson(response);\n\n if (!response.ok) {\n const serverError =\n payload && typeof payload[\"error\"] === \"string\"\n ? payload[\"error\"]\n : undefined;\n const serverMessage =\n payload && typeof payload[\"message\"] === \"string\"\n ? payload[\"message\"]\n : undefined;\n\n return {\n success: false,\n error: serverError ?? serverMessage ?? fallbackErrorMessage,\n };\n }\n\n if (isActionResponse<T>(payload)) {\n return payload;\n }\n\n if (payload !== null) {\n return {\n success: true,\n data: payload as T,\n };\n }\n\n logError(\"Received non-JSON 2xx response from server\", {\n status: response.status,\n });\n\n return {\n success: false,\n error: serverRequestFailedMessage,\n };\n}\n","import type { ActionResponse } from \"@/types/common/action-response.type\";\nimport type { ApiActionOptions } from \"@/types/api-action/api-action-options.type\";\nimport { resolveLocaleMessages } from \"@/i18n/resolve-locale-messages\";\nimport { defaultErrorLogger } from \"@/api-action/default-error-logger\";\nimport { isMinimalResponse } from \"@/api-action/is-minimal-response\";\nimport { isActionResponse } from \"@/api-action/is-action-response\";\nimport { handleHttpResponse } from \"@/api-action/handle-http-response\";\n\nexport type { ActionResponse } from \"@/types/common/action-response.type\";\nexport type { MinimalResponse } from \"@/types/api-action/minimal-response.type\";\nexport type { ErrorLogger } from \"@/types/api-action/error-logger.type\";\nexport type { ApiCallResult } from \"@/types/api-action/api-call-result.type\";\nexport type { ApiActionOptions } from \"@/types/api-action/api-action-options.type\";\n\n/**\n * Universal wrapper for API calls (Hono RPC, `fetch`, or Server Actions)\n * guaranteeing a standardized `ActionResponse<T>` without throwing uncaught errors.\n */\nexport async function apiAction<T = unknown>({\n apiCall,\n
|
|
1
|
+
{"version":3,"sources":["../../src/api-action/default-error-logger.ts","../../src/api-action/is-minimal-response.ts","../../src/api-action/is-action-response.ts","../../src/api-action/try-parse-json.ts","../../src/api-action/handle-http-response.ts","../../src/api-action/index.ts"],"sourcesContent":["import type { ErrorLogger } from \"@/types/api-action/error-logger.type\";\n\n/**\n * Default error logger used when `onError` is not provided to `apiAction`.\n */\nexport const defaultErrorLogger: ErrorLogger = (message, context) => {\n if (context) {\n console.error(`[apiAction] ${message}`, context);\n return;\n }\n console.error(`[apiAction] ${message}`);\n};\n","import type { MinimalResponse } from \"@/types/api-action/minimal-response.type\";\n\n/**\n * Type guard verifying whether a value implements `MinimalResponse`.\n */\nexport function isMinimalResponse(\n candidateValue: unknown,\n): candidateValue is MinimalResponse {\n return (\n typeof candidateValue === \"object\" &&\n candidateValue !== null &&\n \"ok\" in candidateValue &&\n typeof candidateValue.ok === \"boolean\" &&\n \"status\" in candidateValue &&\n typeof candidateValue.status === \"number\" &&\n \"json\" in candidateValue &&\n typeof candidateValue.json === \"function\"\n );\n}\n","import type { ActionResponse } from \"@/types/common/action-response.type\";\n\n/**\n * Type guard verifying whether a value implements `ActionResponse<T>`.\n */\nexport function isActionResponse<T>(\n candidateValue: unknown,\n): candidateValue is ActionResponse<T> {\n return (\n typeof candidateValue === \"object\" &&\n candidateValue !== null &&\n \"success\" in candidateValue &&\n typeof candidateValue.success === \"boolean\"\n );\n}\n","/**\n * Safely parses JSON from a `MinimalResponse`, returning `null` if parsing fails.\n */\nexport async function tryParseJson(\n response: { json: () => Promise<unknown> },\n): Promise<Record<string, unknown> | null> {\n try {\n const parsed = await response.json();\n if (typeof parsed === \"object\" && parsed !== null) {\n return parsed as Record<string, unknown>;\n }\n return null;\n } catch {\n return null;\n }\n}\n","import type { ActionResponse } from \"@/types/common/action-response.type\";\nimport type { ErrorLogger } from \"@/types/api-action/error-logger.type\";\nimport type { MinimalResponse } from \"@/types/api-action/minimal-response.type\";\nimport { isActionResponse } from \"@/api-action/is-action-response\";\nimport { tryParseJson } from \"@/api-action/try-parse-json\";\n\n/**\n * Normalizes a `MinimalResponse` (Fetch / Hono RPC) into an `ActionResponse<T>`.\n */\nexport async function handleHttpResponse<T>(\n response: MinimalResponse,\n fallbackErrorMessage: string,\n serverRequestFailedMessage: string,\n logError: ErrorLogger,\n): Promise<ActionResponse<T>> {\n const payload = await tryParseJson(response);\n\n if (!response.ok) {\n const serverError =\n payload && typeof payload[\"error\"] === \"string\"\n ? payload[\"error\"]\n : undefined;\n const serverMessage =\n payload && typeof payload[\"message\"] === \"string\"\n ? payload[\"message\"]\n : undefined;\n\n return {\n success: false,\n error: serverError ?? serverMessage ?? fallbackErrorMessage,\n };\n }\n\n if (isActionResponse<T>(payload)) {\n return payload;\n }\n\n if (payload !== null) {\n return {\n success: true,\n data: payload as T,\n };\n }\n\n logError(\"Received non-JSON 2xx response from server\", {\n status: response.status,\n });\n\n return {\n success: false,\n error: serverRequestFailedMessage,\n };\n}\n","import type { ActionResponse } from \"@/types/common/action-response.type\";\nimport type { ApiActionOptions } from \"@/types/api-action/api-action-options.type\";\nimport { resolveLocaleMessages } from \"@/i18n/resolve-locale-messages\";\nimport { defaultErrorLogger } from \"@/api-action/default-error-logger\";\nimport { isMinimalResponse } from \"@/api-action/is-minimal-response\";\nimport { isActionResponse } from \"@/api-action/is-action-response\";\nimport { handleHttpResponse } from \"@/api-action/handle-http-response\";\n\nexport type { ActionResponse } from \"@/types/common/action-response.type\";\nexport type { MinimalResponse } from \"@/types/api-action/minimal-response.type\";\nexport type { ErrorLogger } from \"@/types/api-action/error-logger.type\";\nexport type { ApiCallResult } from \"@/types/api-action/api-call-result.type\";\nexport type { ApiActionOptions } from \"@/types/api-action/api-action-options.type\";\n\n/**\n * Universal wrapper for API calls (Hono RPC, `fetch`, or Server Actions)\n * guaranteeing a standardized `ActionResponse<T>` without throwing uncaught errors.\n */\nexport async function apiAction<T = unknown>({\n apiCall,\n defaultErrorMessage,\n onError = defaultErrorLogger,\n}: ApiActionOptions<T>): Promise<ActionResponse<T>> {\n const messages = resolveLocaleMessages();\n const resolvedDefaultError = defaultErrorMessage ?? messages.unexpectedError;\n\n try {\n const actionResult = await apiCall();\n\n if (isMinimalResponse(actionResult)) {\n return await handleHttpResponse<T>(\n actionResult,\n resolvedDefaultError,\n messages.serverRequestFailed,\n onError,\n );\n }\n\n if (isActionResponse<T>(actionResult)) {\n return actionResult;\n }\n\n return {\n success: true,\n data: actionResult as T,\n };\n } catch (caughtError) {\n onError(\"Unexpected error in apiAction\", {\n error:\n caughtError instanceof Error ? caughtError.message : String(caughtError),\n });\n\n return {\n success: false,\n error: resolvedDefaultError,\n };\n }\n}\n"],"mappings":";;;;;AAKO,IAAM,qBAAkC,CAAC,SAAS,YAAY;AACnE,MAAI,SAAS;AACX,YAAQ,MAAM,eAAe,OAAO,IAAI,OAAO;AAC/C;AAAA,EACF;AACA,UAAQ,MAAM,eAAe,OAAO,EAAE;AACxC;;;ACNO,SAAS,kBACd,gBACmC;AACnC,SACE,OAAO,mBAAmB,YAC1B,mBAAmB,QACnB,QAAQ,kBACR,OAAO,eAAe,OAAO,aAC7B,YAAY,kBACZ,OAAO,eAAe,WAAW,YACjC,UAAU,kBACV,OAAO,eAAe,SAAS;AAEnC;;;ACbO,SAAS,iBACd,gBACqC;AACrC,SACE,OAAO,mBAAmB,YAC1B,mBAAmB,QACnB,aAAa,kBACb,OAAO,eAAe,YAAY;AAEtC;;;ACXA,eAAsB,aACpB,UACyC;AACzC,MAAI;AACF,UAAM,SAAS,MAAM,SAAS,KAAK;AACnC,QAAI,OAAO,WAAW,YAAY,WAAW,MAAM;AACjD,aAAO;AAAA,IACT;AACA,WAAO;AAAA,EACT,QAAQ;AACN,WAAO;AAAA,EACT;AACF;;;ACNA,eAAsB,mBACpB,UACA,sBACA,4BACA,UAC4B;AAC5B,QAAM,UAAU,MAAM,aAAa,QAAQ;AAE3C,MAAI,CAAC,SAAS,IAAI;AAChB,UAAM,cACJ,WAAW,OAAO,QAAQ,OAAO,MAAM,WACnC,QAAQ,OAAO,IACf;AACN,UAAM,gBACJ,WAAW,OAAO,QAAQ,SAAS,MAAM,WACrC,QAAQ,SAAS,IACjB;AAEN,WAAO;AAAA,MACL,SAAS;AAAA,MACT,OAAO,eAAe,iBAAiB;AAAA,IACzC;AAAA,EACF;AAEA,MAAI,iBAAoB,OAAO,GAAG;AAChC,WAAO;AAAA,EACT;AAEA,MAAI,YAAY,MAAM;AACpB,WAAO;AAAA,MACL,SAAS;AAAA,MACT,MAAM;AAAA,IACR;AAAA,EACF;AAEA,WAAS,8CAA8C;AAAA,IACrD,QAAQ,SAAS;AAAA,EACnB,CAAC;AAED,SAAO;AAAA,IACL,SAAS;AAAA,IACT,OAAO;AAAA,EACT;AACF;;;AClCA,eAAsB,UAAuB;AAAA,EAC3C;AAAA,EACA;AAAA,EACA,UAAU;AACZ,GAAoD;AAClD,QAAM,WAAW,sBAAsB;AACvC,QAAM,uBAAuB,uBAAuB,SAAS;AAE7D,MAAI;AACF,UAAM,eAAe,MAAM,QAAQ;AAEnC,QAAI,kBAAkB,YAAY,GAAG;AACnC,aAAO,MAAM;AAAA,QACX;AAAA,QACA;AAAA,QACA,SAAS;AAAA,QACT;AAAA,MACF;AAAA,IACF;AAEA,QAAI,iBAAoB,YAAY,GAAG;AACrC,aAAO;AAAA,IACT;AAEA,WAAO;AAAA,MACL,SAAS;AAAA,MACT,MAAM;AAAA,IACR;AAAA,EACF,SAAS,aAAa;AACpB,YAAQ,iCAAiC;AAAA,MACvC,OACE,uBAAuB,QAAQ,YAAY,UAAU,OAAO,WAAW;AAAA,IAC3E,CAAC;AAED,WAAO;AAAA,MACL,SAAS;AAAA,MACT,OAAO;AAAA,IACT;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1,23 +1,4 @@
|
|
|
1
1
|
import { A as ActionResponse } from '../action-response.type-XlzII9Lr.js';
|
|
2
|
-
import { G as GroovepackLocale } from '../groovepack-locale.type-CaXo9vLj.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Toast payload accepted by `@base-ui/react/toast` (`Toast.createToastManager()`).
|
|
6
|
-
*/
|
|
7
|
-
interface BaseUiToastPayload {
|
|
8
|
-
title?: string;
|
|
9
|
-
description?: string;
|
|
10
|
-
type?: "loading" | "success" | "error" | "info" | "warning" | (string & {});
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Contract for `@base-ui/react/toast` manager (`Toast.createToastManager()`).
|
|
15
|
-
*/
|
|
16
|
-
interface BaseUiToastManager {
|
|
17
|
-
add: (options: BaseUiToastPayload) => string;
|
|
18
|
-
update: (id: string, updates: BaseUiToastPayload) => void;
|
|
19
|
-
close: (id: string) => void;
|
|
20
|
-
}
|
|
21
2
|
|
|
22
3
|
/**
|
|
23
4
|
* Options for `apiToast`.
|
|
@@ -25,10 +6,6 @@ interface BaseUiToastManager {
|
|
|
25
6
|
interface ApiToastOptions<T = unknown> {
|
|
26
7
|
/** Async action returning an `ActionResponse<T>`. */
|
|
27
8
|
action: () => Promise<ActionResponse<T>>;
|
|
28
|
-
/** Optional `@base-ui/react/toast` manager instance from `@/components/ui/toast`. */
|
|
29
|
-
toast?: BaseUiToastManager;
|
|
30
|
-
/** Optional locale override (`"en" | "es" | "pt" | "it" | "fr"`). */
|
|
31
|
-
locale?: GroovepackLocale;
|
|
32
9
|
/** Message displayed while the action is pending. */
|
|
33
10
|
loadingMessage?: string;
|
|
34
11
|
/** Fallback message displayed when `action` succeeds without a `message` field. */
|
|
@@ -45,10 +22,6 @@ interface ApiToastOptions<T = unknown> {
|
|
|
45
22
|
* Default configuration for `createApiToast`.
|
|
46
23
|
*/
|
|
47
24
|
interface ApiToastDefaults {
|
|
48
|
-
/** Optional `@base-ui/react/toast` manager instance from `@/components/ui/toast`. */
|
|
49
|
-
toast?: BaseUiToastManager;
|
|
50
|
-
/** Optional locale override (`"en" | "es" | "pt" | "it" | "fr"`). */
|
|
51
|
-
locale?: GroovepackLocale;
|
|
52
25
|
/** Default loading message when not specified per call. */
|
|
53
26
|
defaultLoadingMessage?: string;
|
|
54
27
|
/** Default success message when not specified per call. */
|
|
@@ -58,8 +31,6 @@ interface ApiToastDefaults {
|
|
|
58
31
|
}
|
|
59
32
|
type ToastedOptions<T = unknown> = {
|
|
60
33
|
action: () => Promise<ActionResponse<T>>;
|
|
61
|
-
toast?: BaseUiToastManager;
|
|
62
|
-
locale?: GroovepackLocale;
|
|
63
34
|
loadingMessage?: string;
|
|
64
35
|
successMessage?: string;
|
|
65
36
|
errorMessage?: string;
|
|
@@ -68,13 +39,31 @@ type ToastedOptions<T = unknown> = {
|
|
|
68
39
|
};
|
|
69
40
|
|
|
70
41
|
/**
|
|
71
|
-
*
|
|
42
|
+
* Toast payload accepted by `@base-ui/react/toast` (`Toast.createToastManager()`).
|
|
43
|
+
*/
|
|
44
|
+
interface BaseUiToastPayload {
|
|
45
|
+
title?: string;
|
|
46
|
+
description?: string;
|
|
47
|
+
type?: "loading" | "success" | "error" | "info" | "warning" | (string & {});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Contract for `@base-ui/react/toast` manager (`Toast.createToastManager()`).
|
|
52
|
+
*/
|
|
53
|
+
interface BaseUiToastManager {
|
|
54
|
+
add: (options: BaseUiToastPayload) => string;
|
|
55
|
+
update: (id: string, updates: BaseUiToastPayload) => void;
|
|
56
|
+
close: (id: string) => void;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Factory creating a pre-configured `apiToast` helper backed by Shadcn Toast.
|
|
72
61
|
*/
|
|
73
|
-
declare function createApiToast(defaults?: ApiToastDefaults): <T = unknown>({ action,
|
|
62
|
+
declare function createApiToast(defaults?: ApiToastDefaults): <T = unknown>({ action, loadingMessage, successMessage, errorMessage, onSuccess, onError, }: ApiToastOptions<T>) => Promise<ActionResponse<T>>;
|
|
74
63
|
|
|
75
64
|
/**
|
|
76
65
|
* Wraps an `ActionResponse<T>` promise with Shadcn v4 (`@base-ui/react/toast`) loading, success, and error states.
|
|
77
66
|
*/
|
|
78
|
-
declare const apiToast: <T = unknown>({ action,
|
|
67
|
+
declare const apiToast: <T = unknown>({ action, loadingMessage, successMessage, errorMessage, onSuccess, onError, }: ApiToastOptions<T>) => Promise<ActionResponse<T>>;
|
|
79
68
|
|
|
80
69
|
export { ActionResponse, type ApiToastDefaults, type ApiToastOptions, type BaseUiToastManager, type BaseUiToastPayload, type ToastedOptions, apiToast, createApiToast };
|
package/dist/api-toast/index.js
CHANGED
|
@@ -1,10 +1,55 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveLocaleMessages
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-OSPD6EX4.js";
|
|
4
|
+
|
|
5
|
+
// src/api-toast/read-shadcn-ui-path.ts
|
|
6
|
+
var DEFAULT_SHADCN_UI_PATH = "/src/components/ui";
|
|
7
|
+
var ENV_SHADCN_PATH_KEYS = [
|
|
8
|
+
"GROOVEPACK_SHADCN_PATH",
|
|
9
|
+
"NEXT_PUBLIC_GROOVEPACK_SHADCN_PATH"
|
|
10
|
+
];
|
|
11
|
+
function normalizePath(candidate) {
|
|
12
|
+
if (typeof candidate !== "string") {
|
|
13
|
+
return void 0;
|
|
14
|
+
}
|
|
15
|
+
const trimmed = candidate.trim().replace(/\/+$/, "");
|
|
16
|
+
return trimmed.length > 0 ? trimmed : void 0;
|
|
17
|
+
}
|
|
18
|
+
function readShadcnPathFromProcessEnv() {
|
|
19
|
+
const globalRecord = globalThis;
|
|
20
|
+
const processValue = globalRecord["process"];
|
|
21
|
+
if (typeof processValue !== "object" || processValue === null) {
|
|
22
|
+
return void 0;
|
|
23
|
+
}
|
|
24
|
+
const envValue = processValue["env"];
|
|
25
|
+
if (typeof envValue !== "object" || envValue === null) {
|
|
26
|
+
return void 0;
|
|
27
|
+
}
|
|
28
|
+
const record = envValue;
|
|
29
|
+
for (const key of ENV_SHADCN_PATH_KEYS) {
|
|
30
|
+
const normalized = normalizePath(record[key]);
|
|
31
|
+
if (normalized) {
|
|
32
|
+
return normalized;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return void 0;
|
|
36
|
+
}
|
|
37
|
+
function readShadcnPathFromImportMeta() {
|
|
38
|
+
try {
|
|
39
|
+
return normalizePath(import.meta.env?.GROOVEPACK_SHADCN_PATH) ?? normalizePath(import.meta.env?.NEXT_PUBLIC_GROOVEPACK_SHADCN_PATH);
|
|
40
|
+
} catch {
|
|
41
|
+
return void 0;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function readShadcnUiPath() {
|
|
45
|
+
return readShadcnPathFromProcessEnv() ?? readShadcnPathFromImportMeta() ?? DEFAULT_SHADCN_UI_PATH;
|
|
46
|
+
}
|
|
4
47
|
|
|
5
48
|
// src/api-toast/resolve-toast-manager.ts
|
|
6
|
-
var
|
|
7
|
-
|
|
49
|
+
var toastManagerCache = /* @__PURE__ */ new Map();
|
|
50
|
+
function buildMissingShadcnToastMessage(toastModulePath) {
|
|
51
|
+
return `[@3lineas/groovepack/api-toast] Could not load a valid Shadcn toastManager from "${toastModulePath}". Run "pnpm dlx shadcn@latest add toast" or set GROOVEPACK_SHADCN_PATH / NEXT_PUBLIC_GROOVEPACK_SHADCN_PATH to your Shadcn UI directory.`;
|
|
52
|
+
}
|
|
8
53
|
function isValidToastManager(candidate) {
|
|
9
54
|
if (typeof candidate !== "object" || candidate === null) {
|
|
10
55
|
return false;
|
|
@@ -12,32 +57,39 @@ function isValidToastManager(candidate) {
|
|
|
12
57
|
const record = candidate;
|
|
13
58
|
return typeof record["add"] === "function" && typeof record["update"] === "function";
|
|
14
59
|
}
|
|
15
|
-
|
|
16
|
-
if (
|
|
17
|
-
|
|
18
|
-
console.error(MISSING_SHADCN_TOAST_MESSAGE);
|
|
19
|
-
throw new Error(MISSING_SHADCN_TOAST_MESSAGE);
|
|
20
|
-
}
|
|
21
|
-
return customToast;
|
|
60
|
+
function extractToastManager(loadedModule) {
|
|
61
|
+
if (typeof loadedModule !== "object" || loadedModule === null) {
|
|
62
|
+
return void 0;
|
|
22
63
|
}
|
|
23
|
-
|
|
24
|
-
|
|
64
|
+
const record = loadedModule;
|
|
65
|
+
const candidate = record["toastManager"] ?? record["toast"] ?? record["default"];
|
|
66
|
+
return isValidToastManager(candidate) ? candidate : void 0;
|
|
67
|
+
}
|
|
68
|
+
async function resolveToastManager() {
|
|
69
|
+
const toastModulePath = `${readShadcnUiPath()}/toast`;
|
|
70
|
+
const cached = toastManagerCache.get(toastModulePath);
|
|
71
|
+
if (cached) {
|
|
72
|
+
return cached;
|
|
25
73
|
}
|
|
74
|
+
const missingMessage = buildMissingShadcnToastMessage(toastModulePath);
|
|
26
75
|
try {
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
76
|
+
const loadedModule = await import(
|
|
77
|
+
/* @vite-ignore */
|
|
78
|
+
toastModulePath
|
|
79
|
+
);
|
|
80
|
+
const manager = extractToastManager(loadedModule);
|
|
81
|
+
if (!manager) {
|
|
82
|
+
console.error(missingMessage);
|
|
83
|
+
throw new Error(missingMessage);
|
|
31
84
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
85
|
+
toastManagerCache.set(toastModulePath, manager);
|
|
86
|
+
return manager;
|
|
87
|
+
} catch (caughtError) {
|
|
88
|
+
if (caughtError instanceof Error && caughtError.message === missingMessage) {
|
|
89
|
+
throw caughtError;
|
|
35
90
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
} catch {
|
|
39
|
-
console.error(MISSING_SHADCN_TOAST_MESSAGE);
|
|
40
|
-
throw new Error(MISSING_SHADCN_TOAST_MESSAGE);
|
|
91
|
+
console.error(missingMessage);
|
|
92
|
+
throw new Error(missingMessage);
|
|
41
93
|
}
|
|
42
94
|
}
|
|
43
95
|
|
|
@@ -45,16 +97,14 @@ async function resolveToastManager(customToast) {
|
|
|
45
97
|
function createApiToast(defaults = {}) {
|
|
46
98
|
return async function configuredApiToast({
|
|
47
99
|
action,
|
|
48
|
-
toast = defaults.toast,
|
|
49
|
-
locale = defaults.locale,
|
|
50
100
|
loadingMessage,
|
|
51
101
|
successMessage,
|
|
52
102
|
errorMessage,
|
|
53
103
|
onSuccess,
|
|
54
104
|
onError
|
|
55
105
|
}) {
|
|
56
|
-
const toastManager = await resolveToastManager(
|
|
57
|
-
const messages = resolveLocaleMessages(
|
|
106
|
+
const toastManager = await resolveToastManager();
|
|
107
|
+
const messages = resolveLocaleMessages();
|
|
58
108
|
const resolvedLoading = loadingMessage ?? defaults.defaultLoadingMessage ?? messages.loading;
|
|
59
109
|
const resolvedSuccess = successMessage ?? defaults.defaultSuccessMessage ?? messages.success;
|
|
60
110
|
const resolvedError = errorMessage ?? defaults.defaultErrorMessage ?? messages.operationFailed;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/api-toast/resolve-toast-manager.ts","../../src/api-toast/create-api-toast.ts","../../src/api-toast/index.ts"],"sourcesContent":["import type { BaseUiToastManager } from \"@/types/api-toast/base-ui-toast-manager.type\";\n\nconst MISSING_SHADCN_TOAST_MESSAGE =\n '[@3lineas/groovepack/api-toast] Shadcn Toast (@base-ui/react/toast) is not installed or configured. Run \"pnpm dlx shadcn@latest add toast\" and ensure \"@base-ui/react\" is installed.';\n\nlet defaultToastManager: BaseUiToastManager | undefined;\n\nfunction isValidToastManager(\n candidate: unknown,\n): candidate is BaseUiToastManager {\n if (typeof candidate !== \"object\" || candidate === null) {\n return false;\n }\n\n const record = candidate as Record<string, unknown>;\n return (\n typeof record[\"add\"] === \"function\" &&\n typeof record[\"update\"] === \"function\"\n );\n}\n\n/**\n * Resolves the active `@base-ui/react/toast` manager or throws a descriptive\n * error when Shadcn Toast (`@base-ui/react/toast`) is not installed.\n */\nexport async function resolveToastManager(\n customToast?: BaseUiToastManager,\n): Promise<BaseUiToastManager> {\n if (customToast !== undefined) {\n if (!isValidToastManager(customToast)) {\n console.error(MISSING_SHADCN_TOAST_MESSAGE);\n throw new Error(MISSING_SHADCN_TOAST_MESSAGE);\n }\n\n return customToast;\n }\n\n if (defaultToastManager) {\n return defaultToastManager;\n }\n\n try {\n const baseUiToastModule = (await import(\"@base-ui/react/toast\")) as {\n Toast?: { createToastManager?: () => BaseUiToastManager };\n createToastManager?: () => BaseUiToastManager;\n };\n const factory =\n baseUiToastModule.Toast?.createToastManager ??\n baseUiToastModule.createToastManager;\n\n if (typeof factory !== \"function\") {\n throw new Error(MISSING_SHADCN_TOAST_MESSAGE);\n }\n\n const created = factory();\n if (!isValidToastManager(created)) {\n throw new Error(MISSING_SHADCN_TOAST_MESSAGE);\n }\n\n defaultToastManager = created;\n return defaultToastManager;\n } catch {\n console.error(MISSING_SHADCN_TOAST_MESSAGE);\n throw new Error(MISSING_SHADCN_TOAST_MESSAGE);\n }\n}\n","import type { ActionResponse } from \"@/types/common/action-response.type\";\nimport type { ApiToastDefaults } from \"@/types/api-toast/api-toast-defaults.type\";\nimport type { ApiToastOptions } from \"@/types/api-toast/api-toast-options.type\";\nimport { resolveToastManager } from \"@/api-toast/resolve-toast-manager\";\nimport { resolveLocaleMessages } from \"@/i18n/resolve-locale-messages\";\n\n/**\n * Factory creating a pre-configured `apiToast` helper backed by Shadcn v4 (`@base-ui/react/toast`).\n */\nexport function createApiToast(defaults: ApiToastDefaults = {}) {\n return async function configuredApiToast<T = unknown>({\n action,\n toast = defaults.toast,\n locale = defaults.locale,\n loadingMessage,\n successMessage,\n errorMessage,\n onSuccess,\n onError,\n }: ApiToastOptions<T>): Promise<ActionResponse<T>> {\n const toastManager = await resolveToastManager(toast);\n const messages = resolveLocaleMessages(locale);\n const resolvedLoading =\n loadingMessage ?? defaults.defaultLoadingMessage ?? messages.loading;\n const resolvedSuccess =\n successMessage ?? defaults.defaultSuccessMessage ?? messages.success;\n const resolvedError =\n errorMessage ?? defaults.defaultErrorMessage ?? messages.operationFailed;\n\n const toastId = toastManager.add({\n title: resolvedLoading,\n type: \"loading\",\n });\n\n try {\n const actionResult = await action();\n\n if (actionResult.success) {\n const displayMessage = actionResult.message ?? resolvedSuccess;\n toastManager.update(toastId, {\n title: displayMessage,\n type: \"success\",\n });\n onSuccess?.(actionResult.data, actionResult);\n return actionResult;\n }\n\n const displayError =\n actionResult.error ?? actionResult.message ?? resolvedError;\n toastManager.update(toastId, {\n title: displayError,\n type: \"error\",\n });\n onError?.(displayError, actionResult);\n return actionResult;\n } catch (caughtError) {\n const fallbackError =\n caughtError instanceof Error ? caughtError.message : resolvedError;\n toastManager.update(toastId, {\n title: fallbackError,\n type: \"error\",\n });\n onError?.(fallbackError);\n\n return {\n success: false,\n error: fallbackError,\n };\n }\n };\n}\n","import { createApiToast } from \"@/api-toast/create-api-toast\";\n\nexport type { ActionResponse } from \"@/types/common/action-response.type\";\nexport type { ApiToastOptions } from \"@/types/api-toast/api-toast-options.type\";\nexport type {\n ApiToastDefaults,\n ToastedOptions,\n} from \"@/types/api-toast/api-toast-defaults.type\";\nexport type { BaseUiToastManager } from \"@/types/api-toast/base-ui-toast-manager.type\";\nexport type { BaseUiToastPayload } from \"@/types/api-toast/base-ui-toast-payload.type\";\nexport { createApiToast } from \"@/api-toast/create-api-toast\";\n\n/**\n * Wraps an `ActionResponse<T>` promise with Shadcn v4 (`@base-ui/react/toast`) loading, success, and error states.\n */\nexport const apiToast = createApiToast();\n"],"mappings":";;;;;AAEA,IAAM,+BACJ;AAEF,IAAI;AAEJ,SAAS,oBACP,WACiC;AACjC,MAAI,OAAO,cAAc,YAAY,cAAc,MAAM;AACvD,WAAO;AAAA,EACT;AAEA,QAAM,SAAS;AACf,SACE,OAAO,OAAO,KAAK,MAAM,cACzB,OAAO,OAAO,QAAQ,MAAM;AAEhC;AAMA,eAAsB,oBACpB,aAC6B;AAC7B,MAAI,gBAAgB,QAAW;AAC7B,QAAI,CAAC,oBAAoB,WAAW,GAAG;AACrC,cAAQ,MAAM,4BAA4B;AAC1C,YAAM,IAAI,MAAM,4BAA4B;AAAA,IAC9C;AAEA,WAAO;AAAA,EACT;AAEA,MAAI,qBAAqB;AACvB,WAAO;AAAA,EACT;AAEA,MAAI;AACF,UAAM,oBAAqB,MAAM,OAAO,sBAAsB;AAI9D,UAAM,UACJ,kBAAkB,OAAO,sBACzB,kBAAkB;AAEpB,QAAI,OAAO,YAAY,YAAY;AACjC,YAAM,IAAI,MAAM,4BAA4B;AAAA,IAC9C;AAEA,UAAM,UAAU,QAAQ;AACxB,QAAI,CAAC,oBAAoB,OAAO,GAAG;AACjC,YAAM,IAAI,MAAM,4BAA4B;AAAA,IAC9C;AAEA,0BAAsB;AACtB,WAAO;AAAA,EACT,QAAQ;AACN,YAAQ,MAAM,4BAA4B;AAC1C,UAAM,IAAI,MAAM,4BAA4B;AAAA,EAC9C;AACF;;;ACxDO,SAAS,eAAe,WAA6B,CAAC,GAAG;AAC9D,SAAO,eAAe,mBAAgC;AAAA,IACpD;AAAA,IACA,QAAQ,SAAS;AAAA,IACjB,SAAS,SAAS;AAAA,IAClB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAAmD;AACjD,UAAM,eAAe,MAAM,oBAAoB,KAAK;AACpD,UAAM,WAAW,sBAAsB,MAAM;AAC7C,UAAM,kBACJ,kBAAkB,SAAS,yBAAyB,SAAS;AAC/D,UAAM,kBACJ,kBAAkB,SAAS,yBAAyB,SAAS;AAC/D,UAAM,gBACJ,gBAAgB,SAAS,uBAAuB,SAAS;AAE3D,UAAM,UAAU,aAAa,IAAI;AAAA,MAC/B,OAAO;AAAA,MACP,MAAM;AAAA,IACR,CAAC;AAED,QAAI;AACF,YAAM,eAAe,MAAM,OAAO;AAElC,UAAI,aAAa,SAAS;AACxB,cAAM,iBAAiB,aAAa,WAAW;AAC/C,qBAAa,OAAO,SAAS;AAAA,UAC3B,OAAO;AAAA,UACP,MAAM;AAAA,QACR,CAAC;AACD,oBAAY,aAAa,MAAM,YAAY;AAC3C,eAAO;AAAA,MACT;AAEA,YAAM,eACJ,aAAa,SAAS,aAAa,WAAW;AAChD,mBAAa,OAAO,SAAS;AAAA,QAC3B,OAAO;AAAA,QACP,MAAM;AAAA,MACR,CAAC;AACD,gBAAU,cAAc,YAAY;AACpC,aAAO;AAAA,IACT,SAAS,aAAa;AACpB,YAAM,gBACJ,uBAAuB,QAAQ,YAAY,UAAU;AACvD,mBAAa,OAAO,SAAS;AAAA,QAC3B,OAAO;AAAA,QACP,MAAM;AAAA,MACR,CAAC;AACD,gBAAU,aAAa;AAEvB,aAAO;AAAA,QACL,SAAS;AAAA,QACT,OAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF;;;ACvDO,IAAM,WAAW,eAAe;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/api-toast/read-shadcn-ui-path.ts","../../src/api-toast/resolve-toast-manager.ts","../../src/api-toast/create-api-toast.ts","../../src/api-toast/index.ts"],"sourcesContent":["const DEFAULT_SHADCN_UI_PATH = \"/src/components/ui\";\n\nconst ENV_SHADCN_PATH_KEYS = [\n \"GROOVEPACK_SHADCN_PATH\",\n \"NEXT_PUBLIC_GROOVEPACK_SHADCN_PATH\",\n] as const;\n\nfunction normalizePath(candidate: unknown): string | undefined {\n if (typeof candidate !== \"string\") {\n return undefined;\n }\n\n const trimmed = candidate.trim().replace(/\\/+$/, \"\");\n return trimmed.length > 0 ? trimmed : undefined;\n}\n\nfunction readShadcnPathFromProcessEnv(): string | undefined {\n const globalRecord = globalThis as Record<string, unknown>;\n const processValue = globalRecord[\"process\"];\n if (typeof processValue !== \"object\" || processValue === null) {\n return undefined;\n }\n\n const envValue = (processValue as Record<string, unknown>)[\"env\"];\n if (typeof envValue !== \"object\" || envValue === null) {\n return undefined;\n }\n\n const record = envValue as Record<string, unknown>;\n for (const key of ENV_SHADCN_PATH_KEYS) {\n const normalized = normalizePath(record[key]);\n if (normalized) {\n return normalized;\n }\n }\n\n return undefined;\n}\n\nfunction readShadcnPathFromImportMeta(): string | undefined {\n try {\n return (\n normalizePath(import.meta.env?.GROOVEPACK_SHADCN_PATH) ??\n normalizePath(import.meta.env?.NEXT_PUBLIC_GROOVEPACK_SHADCN_PATH)\n );\n } catch {\n return undefined;\n }\n}\n\n/**\n * Resolves the Shadcn UI base directory from `GROOVEPACK_SHADCN_PATH` or\n * `NEXT_PUBLIC_GROOVEPACK_SHADCN_PATH`, defaulting to `\"/src/components/ui\"`.\n */\nexport function readShadcnUiPath(): string {\n return (\n readShadcnPathFromProcessEnv() ??\n readShadcnPathFromImportMeta() ??\n DEFAULT_SHADCN_UI_PATH\n );\n}\n","import type { BaseUiToastManager } from \"@/types/api-toast/base-ui-toast-manager.type\";\nimport { readShadcnUiPath } from \"@/api-toast/read-shadcn-ui-path\";\n\nconst toastManagerCache = new Map<string, BaseUiToastManager>();\n\nfunction buildMissingShadcnToastMessage(toastModulePath: string): string {\n return (\n `[@3lineas/groovepack/api-toast] Could not load a valid Shadcn toastManager from \"${toastModulePath}\". ` +\n 'Run \"pnpm dlx shadcn@latest add toast\" or set GROOVEPACK_SHADCN_PATH / NEXT_PUBLIC_GROOVEPACK_SHADCN_PATH to your Shadcn UI directory.'\n );\n}\n\nfunction isValidToastManager(\n candidate: unknown,\n): candidate is BaseUiToastManager {\n if (typeof candidate !== \"object\" || candidate === null) {\n return false;\n }\n\n const record = candidate as Record<string, unknown>;\n return (\n typeof record[\"add\"] === \"function\" &&\n typeof record[\"update\"] === \"function\"\n );\n}\n\nfunction extractToastManager(loadedModule: unknown): BaseUiToastManager | undefined {\n if (typeof loadedModule !== \"object\" || loadedModule === null) {\n return undefined;\n }\n\n const record = loadedModule as Record<string, unknown>;\n const candidate = record[\"toastManager\"] ?? record[\"toast\"] ?? record[\"default\"];\n\n return isValidToastManager(candidate) ? candidate : undefined;\n}\n\n/**\n * Automatically resolves the Shadcn `toastManager` from `${shadcnPath}/toast`\n * (default `\"/src/components/ui/toast\"`) or throws a descriptive error.\n */\nexport async function resolveToastManager(): Promise<BaseUiToastManager> {\n const toastModulePath = `${readShadcnUiPath()}/toast`;\n const cached = toastManagerCache.get(toastModulePath);\n if (cached) {\n return cached;\n }\n\n const missingMessage = buildMissingShadcnToastMessage(toastModulePath);\n\n try {\n const loadedModule: unknown = await import(/* @vite-ignore */ toastModulePath);\n const manager = extractToastManager(loadedModule);\n\n if (!manager) {\n console.error(missingMessage);\n throw new Error(missingMessage);\n }\n\n toastManagerCache.set(toastModulePath, manager);\n return manager;\n } catch (caughtError) {\n if (caughtError instanceof Error && caughtError.message === missingMessage) {\n throw caughtError;\n }\n\n console.error(missingMessage);\n throw new Error(missingMessage);\n }\n}\n","import type { ActionResponse } from \"@/types/common/action-response.type\";\nimport type { ApiToastDefaults } from \"@/types/api-toast/api-toast-defaults.type\";\nimport type { ApiToastOptions } from \"@/types/api-toast/api-toast-options.type\";\nimport { resolveToastManager } from \"@/api-toast/resolve-toast-manager\";\nimport { resolveLocaleMessages } from \"@/i18n/resolve-locale-messages\";\n\n/**\n * Factory creating a pre-configured `apiToast` helper backed by Shadcn Toast.\n */\nexport function createApiToast(defaults: ApiToastDefaults = {}) {\n return async function configuredApiToast<T = unknown>({\n action,\n loadingMessage,\n successMessage,\n errorMessage,\n onSuccess,\n onError,\n }: ApiToastOptions<T>): Promise<ActionResponse<T>> {\n const toastManager = await resolveToastManager();\n const messages = resolveLocaleMessages();\n const resolvedLoading =\n loadingMessage ?? defaults.defaultLoadingMessage ?? messages.loading;\n const resolvedSuccess =\n successMessage ?? defaults.defaultSuccessMessage ?? messages.success;\n const resolvedError =\n errorMessage ?? defaults.defaultErrorMessage ?? messages.operationFailed;\n\n const toastId = toastManager.add({\n title: resolvedLoading,\n type: \"loading\",\n });\n\n try {\n const actionResult = await action();\n\n if (actionResult.success) {\n const displayMessage = actionResult.message ?? resolvedSuccess;\n toastManager.update(toastId, {\n title: displayMessage,\n type: \"success\",\n });\n onSuccess?.(actionResult.data, actionResult);\n return actionResult;\n }\n\n const displayError =\n actionResult.error ?? actionResult.message ?? resolvedError;\n toastManager.update(toastId, {\n title: displayError,\n type: \"error\",\n });\n onError?.(displayError, actionResult);\n return actionResult;\n } catch (caughtError) {\n const fallbackError =\n caughtError instanceof Error ? caughtError.message : resolvedError;\n toastManager.update(toastId, {\n title: fallbackError,\n type: \"error\",\n });\n onError?.(fallbackError);\n\n return {\n success: false,\n error: fallbackError,\n };\n }\n };\n}\n","import { createApiToast } from \"@/api-toast/create-api-toast\";\n\nexport type { ActionResponse } from \"@/types/common/action-response.type\";\nexport type { ApiToastOptions } from \"@/types/api-toast/api-toast-options.type\";\nexport type {\n ApiToastDefaults,\n ToastedOptions,\n} from \"@/types/api-toast/api-toast-defaults.type\";\nexport type { BaseUiToastManager } from \"@/types/api-toast/base-ui-toast-manager.type\";\nexport type { BaseUiToastPayload } from \"@/types/api-toast/base-ui-toast-payload.type\";\nexport { createApiToast } from \"@/api-toast/create-api-toast\";\n\n/**\n * Wraps an `ActionResponse<T>` promise with Shadcn v4 (`@base-ui/react/toast`) loading, success, and error states.\n */\nexport const apiToast = createApiToast();\n"],"mappings":";;;;;AAAA,IAAM,yBAAyB;AAE/B,IAAM,uBAAuB;AAAA,EAC3B;AAAA,EACA;AACF;AAEA,SAAS,cAAc,WAAwC;AAC7D,MAAI,OAAO,cAAc,UAAU;AACjC,WAAO;AAAA,EACT;AAEA,QAAM,UAAU,UAAU,KAAK,EAAE,QAAQ,QAAQ,EAAE;AACnD,SAAO,QAAQ,SAAS,IAAI,UAAU;AACxC;AAEA,SAAS,+BAAmD;AAC1D,QAAM,eAAe;AACrB,QAAM,eAAe,aAAa,SAAS;AAC3C,MAAI,OAAO,iBAAiB,YAAY,iBAAiB,MAAM;AAC7D,WAAO;AAAA,EACT;AAEA,QAAM,WAAY,aAAyC,KAAK;AAChE,MAAI,OAAO,aAAa,YAAY,aAAa,MAAM;AACrD,WAAO;AAAA,EACT;AAEA,QAAM,SAAS;AACf,aAAW,OAAO,sBAAsB;AACtC,UAAM,aAAa,cAAc,OAAO,GAAG,CAAC;AAC5C,QAAI,YAAY;AACd,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO;AACT;AAEA,SAAS,+BAAmD;AAC1D,MAAI;AACF,WACE,cAAc,YAAY,KAAK,sBAAsB,KACrD,cAAc,YAAY,KAAK,kCAAkC;AAAA,EAErE,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAMO,SAAS,mBAA2B;AACzC,SACE,6BAA6B,KAC7B,6BAA6B,KAC7B;AAEJ;;;ACzDA,IAAM,oBAAoB,oBAAI,IAAgC;AAE9D,SAAS,+BAA+B,iBAAiC;AACvE,SACE,oFAAoF,eAAe;AAGvG;AAEA,SAAS,oBACP,WACiC;AACjC,MAAI,OAAO,cAAc,YAAY,cAAc,MAAM;AACvD,WAAO;AAAA,EACT;AAEA,QAAM,SAAS;AACf,SACE,OAAO,OAAO,KAAK,MAAM,cACzB,OAAO,OAAO,QAAQ,MAAM;AAEhC;AAEA,SAAS,oBAAoB,cAAuD;AAClF,MAAI,OAAO,iBAAiB,YAAY,iBAAiB,MAAM;AAC7D,WAAO;AAAA,EACT;AAEA,QAAM,SAAS;AACf,QAAM,YAAY,OAAO,cAAc,KAAK,OAAO,OAAO,KAAK,OAAO,SAAS;AAE/E,SAAO,oBAAoB,SAAS,IAAI,YAAY;AACtD;AAMA,eAAsB,sBAAmD;AACvE,QAAM,kBAAkB,GAAG,iBAAiB,CAAC;AAC7C,QAAM,SAAS,kBAAkB,IAAI,eAAe;AACpD,MAAI,QAAQ;AACV,WAAO;AAAA,EACT;AAEA,QAAM,iBAAiB,+BAA+B,eAAe;AAErE,MAAI;AACF,UAAM,eAAwB,MAAM;AAAA;AAAA,MAA0B;AAAA;AAC9D,UAAM,UAAU,oBAAoB,YAAY;AAEhD,QAAI,CAAC,SAAS;AACZ,cAAQ,MAAM,cAAc;AAC5B,YAAM,IAAI,MAAM,cAAc;AAAA,IAChC;AAEA,sBAAkB,IAAI,iBAAiB,OAAO;AAC9C,WAAO;AAAA,EACT,SAAS,aAAa;AACpB,QAAI,uBAAuB,SAAS,YAAY,YAAY,gBAAgB;AAC1E,YAAM;AAAA,IACR;AAEA,YAAQ,MAAM,cAAc;AAC5B,UAAM,IAAI,MAAM,cAAc;AAAA,EAChC;AACF;;;AC5DO,SAAS,eAAe,WAA6B,CAAC,GAAG;AAC9D,SAAO,eAAe,mBAAgC;AAAA,IACpD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,GAAmD;AACjD,UAAM,eAAe,MAAM,oBAAoB;AAC/C,UAAM,WAAW,sBAAsB;AACvC,UAAM,kBACJ,kBAAkB,SAAS,yBAAyB,SAAS;AAC/D,UAAM,kBACJ,kBAAkB,SAAS,yBAAyB,SAAS;AAC/D,UAAM,gBACJ,gBAAgB,SAAS,uBAAuB,SAAS;AAE3D,UAAM,UAAU,aAAa,IAAI;AAAA,MAC/B,OAAO;AAAA,MACP,MAAM;AAAA,IACR,CAAC;AAED,QAAI;AACF,YAAM,eAAe,MAAM,OAAO;AAElC,UAAI,aAAa,SAAS;AACxB,cAAM,iBAAiB,aAAa,WAAW;AAC/C,qBAAa,OAAO,SAAS;AAAA,UAC3B,OAAO;AAAA,UACP,MAAM;AAAA,QACR,CAAC;AACD,oBAAY,aAAa,MAAM,YAAY;AAC3C,eAAO;AAAA,MACT;AAEA,YAAM,eACJ,aAAa,SAAS,aAAa,WAAW;AAChD,mBAAa,OAAO,SAAS;AAAA,QAC3B,OAAO;AAAA,QACP,MAAM;AAAA,MACR,CAAC;AACD,gBAAU,cAAc,YAAY;AACpC,aAAO;AAAA,IACT,SAAS,aAAa;AACpB,YAAM,gBACJ,uBAAuB,QAAQ,YAAY,UAAU;AACvD,mBAAa,OAAO,SAAS;AAAA,QAC3B,OAAO;AAAA,QACP,MAAM;AAAA,MACR,CAAC;AACD,gBAAU,aAAa;AAEvB,aAAO;AAAA,QACL,SAAS;AAAA,QACT,OAAO;AAAA,MACT;AAAA,IACF;AAAA,EACF;AACF;;;ACrDO,IAAM,WAAW,eAAe;","names":[]}
|
|
@@ -51,16 +51,8 @@ function readEnvLocale() {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
// src/i18n/locale-state.ts
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
if (locale === void 0) {
|
|
57
|
-
configuredLocale = void 0;
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
configuredLocale = normalizeSupportedLocale(locale);
|
|
61
|
-
}
|
|
62
|
-
function getGroovepackLocale(overrideLocale) {
|
|
63
|
-
return normalizeSupportedLocale(overrideLocale) ?? configuredLocale ?? readEnvLocale() ?? "en";
|
|
54
|
+
function getGroovepackLocale() {
|
|
55
|
+
return readEnvLocale() ?? "en";
|
|
64
56
|
}
|
|
65
57
|
|
|
66
58
|
// src/i18n/messages.ts
|
|
@@ -103,17 +95,16 @@ var GROOVEPACK_MESSAGES = {
|
|
|
103
95
|
};
|
|
104
96
|
|
|
105
97
|
// src/i18n/resolve-locale-messages.ts
|
|
106
|
-
function resolveLocaleMessages(
|
|
107
|
-
const activeLocale = getGroovepackLocale(
|
|
98
|
+
function resolveLocaleMessages() {
|
|
99
|
+
const activeLocale = getGroovepackLocale();
|
|
108
100
|
return GROOVEPACK_MESSAGES[activeLocale];
|
|
109
101
|
}
|
|
110
102
|
|
|
111
103
|
export {
|
|
112
104
|
normalizeSupportedLocale,
|
|
113
105
|
readEnvLocale,
|
|
114
|
-
setGroovepackLocale,
|
|
115
106
|
getGroovepackLocale,
|
|
116
107
|
GROOVEPACK_MESSAGES,
|
|
117
108
|
resolveLocaleMessages
|
|
118
109
|
};
|
|
119
|
-
//# sourceMappingURL=chunk-
|
|
110
|
+
//# sourceMappingURL=chunk-OSPD6EX4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/i18n/is-supported-locale.ts","../src/i18n/read-env-locale.ts","../src/i18n/locale-state.ts","../src/i18n/messages.ts","../src/i18n/resolve-locale-messages.ts"],"sourcesContent":["import type { GroovepackLocale } from \"@/types/i18n/groovepack-locale.type\";\n\nconst SUPPORTED_LOCALE_SET = new Set<string>([\"en\", \"es\", \"pt\", \"it\", \"fr\"]);\n\n/**\n * Normalizes a candidate locale string (e.g. \"es-AR\" -> \"es\") and returns\n * a supported `GroovepackLocale`, or `undefined` if unsupported.\n */\nexport function normalizeSupportedLocale(\n candidate: unknown,\n): GroovepackLocale | undefined {\n if (typeof candidate !== \"string\") {\n return undefined;\n }\n\n const trimmed = candidate.trim().toLowerCase();\n if (trimmed.length === 0) {\n return undefined;\n }\n\n const baseTag = trimmed.split(/[-_]/)[0];\n if (!baseTag || !SUPPORTED_LOCALE_SET.has(baseTag)) {\n return undefined;\n }\n\n return baseTag as GroovepackLocale;\n}\n","import type { GroovepackLocale } from \"@/types/i18n/groovepack-locale.type\";\nimport { normalizeSupportedLocale } from \"@/i18n/is-supported-locale\";\n\nconst ENV_LOCALE_KEYS = [\n \"GROOVEPACK_LOCALE\",\n \"NEXT_PUBLIC_GROOVEPACK_LOCALE\",\n] as const;\n\nfunction readLocaleFromProcessEnv(): GroovepackLocale | undefined {\n const globalRecord = globalThis as Record<string, unknown>;\n const processValue = globalRecord[\"process\"];\n if (typeof processValue !== \"object\" || processValue === null) {\n return undefined;\n }\n\n const envValue = (processValue as Record<string, unknown>)[\"env\"];\n if (typeof envValue !== \"object\" || envValue === null) {\n return undefined;\n }\n\n const record = envValue as Record<string, unknown>;\n for (const key of ENV_LOCALE_KEYS) {\n const normalized = normalizeSupportedLocale(record[key]);\n if (normalized) {\n return normalized;\n }\n }\n\n return undefined;\n}\n\nfunction readLocaleFromImportMeta(): GroovepackLocale | undefined {\n try {\n return (\n normalizeSupportedLocale(import.meta.env?.GROOVEPACK_LOCALE) ??\n normalizeSupportedLocale(import.meta.env?.NEXT_PUBLIC_GROOVEPACK_LOCALE)\n );\n } catch {\n return undefined;\n }\n}\n\n/**\n * Safely reads `GROOVEPACK_LOCALE` or `NEXT_PUBLIC_GROOVEPACK_LOCALE` in Vinext\n * (Cloudflare Workers + Vite 8 `ModuleRunner`) without dynamic `import.meta.env` access.\n */\nexport function readEnvLocale(): GroovepackLocale | undefined {\n return readLocaleFromProcessEnv() ?? readLocaleFromImportMeta();\n}\n","import type { GroovepackLocale } from \"@/types/i18n/groovepack-locale.type\";\nimport { readEnvLocale } from \"@/i18n/read-env-locale\";\n\n/**\n * Resolves the active locale strictly from environment variables\n * (`GROOVEPACK_LOCALE` or `NEXT_PUBLIC_GROOVEPACK_LOCALE`), defaulting to `\"en\"`.\n */\nexport function getGroovepackLocale(): GroovepackLocale {\n return readEnvLocale() ?? \"en\";\n}\n","import type { GroovepackLocale } from \"@/types/i18n/groovepack-locale.type\";\nimport type { GroovepackLocaleMessages } from \"@/types/i18n/locale-messages.type\";\n\nexport const GROOVEPACK_MESSAGES = {\n en: {\n loading: \"Processing...\",\n success: \"Operation completed successfully.\",\n unexpectedError:\n \"An unexpected error occurred while processing your request. Please try again.\",\n serverRequestFailed:\n \"Could not process the request on the server. Please try again.\",\n operationFailed: \"The operation could not be completed.\",\n },\n es: {\n loading: \"Procesando...\",\n success: \"Operación completada con éxito.\",\n unexpectedError:\n \"Ocurrió un error inesperado al procesar la solicitud. Por favor, intenta de nuevo.\",\n serverRequestFailed:\n \"No se pudo procesar la solicitud en el servidor. Por favor, intenta de nuevo.\",\n operationFailed: \"La operación no se pudo completar.\",\n },\n pt: {\n loading: \"Processando...\",\n success: \"Operação concluída com sucesso.\",\n unexpectedError:\n \"Ocorreu um erro inesperado ao processar a solicitação. Por favor, tente novamente.\",\n serverRequestFailed:\n \"Não foi possível processar a solicitação no servidor. Por favor, tente novamente.\",\n operationFailed: \"Não foi possível concluir a operação.\",\n },\n it: {\n loading: \"Elaborazione in corso...\",\n success: \"Operazione completata con successo.\",\n unexpectedError:\n \"Si è verificato un errore imprevisto durante l'elaborazione della richiesta. Riprova.\",\n serverRequestFailed:\n \"Impossibile elaborare la richiesta sul server. Riprova.\",\n operationFailed: \"Impossibile completare l'operazione.\",\n },\n fr: {\n loading: \"Traitement en cours...\",\n success: \"Opération terminée avec succès.\",\n unexpectedError:\n \"Une erreur inattendue s'est produite lors du traitement de la demande. Veuillez réessayer.\",\n serverRequestFailed:\n \"Impossible de traiter la demande sur le serveur. Veuillez réessayer.\",\n operationFailed: \"L'opération n'a pas pu être terminée.\",\n },\n} as const satisfies Record<GroovepackLocale, GroovepackLocaleMessages>;\n","import type { GroovepackLocaleMessages } from \"@/types/i18n/locale-messages.type\";\nimport { getGroovepackLocale } from \"@/i18n/locale-state\";\nimport { GROOVEPACK_MESSAGES } from \"@/i18n/messages\";\n\n/**\n * Returns the localized message dictionary resolved from environment variables\n * or the default `\"en\"` locale.\n */\nexport function resolveLocaleMessages(): GroovepackLocaleMessages {\n const activeLocale = getGroovepackLocale();\n return GROOVEPACK_MESSAGES[activeLocale];\n}\n"],"mappings":";AAEA,IAAM,uBAAuB,oBAAI,IAAY,CAAC,MAAM,MAAM,MAAM,MAAM,IAAI,CAAC;AAMpE,SAAS,yBACd,WAC8B;AAC9B,MAAI,OAAO,cAAc,UAAU;AACjC,WAAO;AAAA,EACT;AAEA,QAAM,UAAU,UAAU,KAAK,EAAE,YAAY;AAC7C,MAAI,QAAQ,WAAW,GAAG;AACxB,WAAO;AAAA,EACT;AAEA,QAAM,UAAU,QAAQ,MAAM,MAAM,EAAE,CAAC;AACvC,MAAI,CAAC,WAAW,CAAC,qBAAqB,IAAI,OAAO,GAAG;AAClD,WAAO;AAAA,EACT;AAEA,SAAO;AACT;;;ACvBA,IAAM,kBAAkB;AAAA,EACtB;AAAA,EACA;AACF;AAEA,SAAS,2BAAyD;AAChE,QAAM,eAAe;AACrB,QAAM,eAAe,aAAa,SAAS;AAC3C,MAAI,OAAO,iBAAiB,YAAY,iBAAiB,MAAM;AAC7D,WAAO;AAAA,EACT;AAEA,QAAM,WAAY,aAAyC,KAAK;AAChE,MAAI,OAAO,aAAa,YAAY,aAAa,MAAM;AACrD,WAAO;AAAA,EACT;AAEA,QAAM,SAAS;AACf,aAAW,OAAO,iBAAiB;AACjC,UAAM,aAAa,yBAAyB,OAAO,GAAG,CAAC;AACvD,QAAI,YAAY;AACd,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO;AACT;AAEA,SAAS,2BAAyD;AAChE,MAAI;AACF,WACE,yBAAyB,YAAY,KAAK,iBAAiB,KAC3D,yBAAyB,YAAY,KAAK,6BAA6B;AAAA,EAE3E,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAMO,SAAS,gBAA8C;AAC5D,SAAO,yBAAyB,KAAK,yBAAyB;AAChE;;;ACzCO,SAAS,sBAAwC;AACtD,SAAO,cAAc,KAAK;AAC5B;;;ACNO,IAAM,sBAAsB;AAAA,EACjC,IAAI;AAAA,IACF,SAAS;AAAA,IACT,SAAS;AAAA,IACT,iBACE;AAAA,IACF,qBACE;AAAA,IACF,iBAAiB;AAAA,EACnB;AAAA,EACA,IAAI;AAAA,IACF,SAAS;AAAA,IACT,SAAS;AAAA,IACT,iBACE;AAAA,IACF,qBACE;AAAA,IACF,iBAAiB;AAAA,EACnB;AAAA,EACA,IAAI;AAAA,IACF,SAAS;AAAA,IACT,SAAS;AAAA,IACT,iBACE;AAAA,IACF,qBACE;AAAA,IACF,iBAAiB;AAAA,EACnB;AAAA,EACA,IAAI;AAAA,IACF,SAAS;AAAA,IACT,SAAS;AAAA,IACT,iBACE;AAAA,IACF,qBACE;AAAA,IACF,iBAAiB;AAAA,EACnB;AAAA,EACA,IAAI;AAAA,IACF,SAAS;AAAA,IACT,SAAS;AAAA,IACT,iBACE;AAAA,IACF,qBACE;AAAA,IACF,iBAAiB;AAAA,EACnB;AACF;;;ACzCO,SAAS,wBAAkD;AAChE,QAAM,eAAe,oBAAoB;AACzC,SAAO,oBAAoB,YAAY;AACzC;","names":[]}
|
package/dist/i18n/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
type GroovepackLocale = "en" | "es" | "pt" | "it" | "fr";
|
|
2
2
|
|
|
3
3
|
interface GroovepackLocaleMessages {
|
|
4
4
|
readonly loading: string;
|
|
@@ -59,24 +59,15 @@ declare function normalizeSupportedLocale(candidate: unknown): GroovepackLocale
|
|
|
59
59
|
declare function readEnvLocale(): GroovepackLocale | undefined;
|
|
60
60
|
|
|
61
61
|
/**
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
* variables or `"en"`.
|
|
62
|
+
* Resolves the active locale strictly from environment variables
|
|
63
|
+
* (`GROOVEPACK_LOCALE` or `NEXT_PUBLIC_GROOVEPACK_LOCALE`), defaulting to `"en"`.
|
|
65
64
|
*/
|
|
66
|
-
declare function
|
|
67
|
-
/**
|
|
68
|
-
* Resolves the active locale using precedence:
|
|
69
|
-
* 1. Explicit `overrideLocale`
|
|
70
|
-
* 2. Runtime locale set via `setGroovepackLocale()`
|
|
71
|
-
* 3. Environment variable (`GROOVEPACK_LOCALE` / framework-prefixed)
|
|
72
|
-
* 4. Default `"en"`
|
|
73
|
-
*/
|
|
74
|
-
declare function getGroovepackLocale(overrideLocale?: GroovepackLocale): GroovepackLocale;
|
|
65
|
+
declare function getGroovepackLocale(): GroovepackLocale;
|
|
75
66
|
|
|
76
67
|
/**
|
|
77
|
-
* Returns the localized message dictionary
|
|
78
|
-
* or the
|
|
68
|
+
* Returns the localized message dictionary resolved from environment variables
|
|
69
|
+
* or the default `"en"` locale.
|
|
79
70
|
*/
|
|
80
|
-
declare function resolveLocaleMessages(
|
|
71
|
+
declare function resolveLocaleMessages(): GroovepackLocaleMessages;
|
|
81
72
|
|
|
82
|
-
export { GROOVEPACK_MESSAGES, GroovepackLocale, type GroovepackLocaleMessages, getGroovepackLocale, normalizeSupportedLocale, readEnvLocale, resolveLocaleMessages
|
|
73
|
+
export { GROOVEPACK_MESSAGES, type GroovepackLocale, type GroovepackLocaleMessages, getGroovepackLocale, normalizeSupportedLocale, readEnvLocale, resolveLocaleMessages };
|
package/dist/i18n/index.js
CHANGED
|
@@ -3,15 +3,13 @@ import {
|
|
|
3
3
|
getGroovepackLocale,
|
|
4
4
|
normalizeSupportedLocale,
|
|
5
5
|
readEnvLocale,
|
|
6
|
-
resolveLocaleMessages
|
|
7
|
-
|
|
8
|
-
} from "../chunk-3FQ5C44Y.js";
|
|
6
|
+
resolveLocaleMessages
|
|
7
|
+
} from "../chunk-OSPD6EX4.js";
|
|
9
8
|
export {
|
|
10
9
|
GROOVEPACK_MESSAGES,
|
|
11
10
|
getGroovepackLocale,
|
|
12
11
|
normalizeSupportedLocale,
|
|
13
12
|
readEnvLocale,
|
|
14
|
-
resolveLocaleMessages
|
|
15
|
-
setGroovepackLocale
|
|
13
|
+
resolveLocaleMessages
|
|
16
14
|
};
|
|
17
15
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for the `@3lineas/groovepack/vite` plugin.
|
|
3
|
+
*/
|
|
4
|
+
interface GroovepackVitePluginOptions {
|
|
5
|
+
/** Custom Shadcn UI directory (defaults to env vars or `"/src/components/ui"`). */
|
|
6
|
+
shadcnPath?: string;
|
|
7
|
+
}
|
|
8
|
+
interface GroovepackViteResolvedConfig {
|
|
9
|
+
root?: string;
|
|
10
|
+
}
|
|
11
|
+
interface GroovepackVitePlugin {
|
|
12
|
+
name: string;
|
|
13
|
+
enforce?: "pre" | "post";
|
|
14
|
+
config?: () => {
|
|
15
|
+
optimizeDeps?: {
|
|
16
|
+
exclude?: string[];
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
configResolved?: (config: GroovepackViteResolvedConfig) => void;
|
|
20
|
+
resolveId?: (source: string) => string | undefined;
|
|
21
|
+
load?: (id: string) => string | undefined;
|
|
22
|
+
transform?: (code: string, id: string) => {
|
|
23
|
+
code: string;
|
|
24
|
+
map: null;
|
|
25
|
+
} | undefined;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Optional Vite plugin for `@3lineas/groovepack/api-toast`.
|
|
30
|
+
* Statically resolves `${shadcnPath}/toast` in both `vite dev` and `vite build`.
|
|
31
|
+
*/
|
|
32
|
+
declare function groovepack(options?: GroovepackVitePluginOptions): GroovepackVitePlugin;
|
|
33
|
+
|
|
34
|
+
export { type GroovepackVitePlugin, type GroovepackVitePluginOptions, type GroovepackViteResolvedConfig, groovepack };
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// src/vite/groovepack-plugin.ts
|
|
2
|
+
import { existsSync } from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
var DEFAULT_SHADCN_UI_PATH = "/src/components/ui";
|
|
5
|
+
var VIRTUAL_MISSING_TOAST_ID = "\0groovepack-missing-toast";
|
|
6
|
+
var DYNAMIC_IMPORT_PATTERN = /import\(\s*\/\*\s*@vite-ignore\s*\*\/\s*[^)]+\)/g;
|
|
7
|
+
var TOAST_EXTENSIONS = [
|
|
8
|
+
"",
|
|
9
|
+
".ts",
|
|
10
|
+
".tsx",
|
|
11
|
+
".js",
|
|
12
|
+
".jsx",
|
|
13
|
+
"/index.ts",
|
|
14
|
+
"/index.tsx"
|
|
15
|
+
];
|
|
16
|
+
function resolveShadcnPath(options) {
|
|
17
|
+
const candidate = options?.shadcnPath ?? process.env["GROOVEPACK_SHADCN_PATH"] ?? process.env["NEXT_PUBLIC_GROOVEPACK_SHADCN_PATH"] ?? DEFAULT_SHADCN_UI_PATH;
|
|
18
|
+
return candidate.trim().replace(/\/+$/, "") || DEFAULT_SHADCN_UI_PATH;
|
|
19
|
+
}
|
|
20
|
+
function hasToastModuleOnDisk(rootDir, shadcnPath) {
|
|
21
|
+
const relativeBase = shadcnPath.startsWith("/") ? shadcnPath.slice(1) : shadcnPath;
|
|
22
|
+
const baseTarget = path.resolve(rootDir, relativeBase, "toast");
|
|
23
|
+
return TOAST_EXTENSIONS.some((ext) => existsSync(`${baseTarget}${ext}`));
|
|
24
|
+
}
|
|
25
|
+
function groovepack(options) {
|
|
26
|
+
let rootDir = process.cwd();
|
|
27
|
+
const shadcnPath = resolveShadcnPath(options);
|
|
28
|
+
const toastImportTarget = `${shadcnPath}/toast`;
|
|
29
|
+
return {
|
|
30
|
+
name: "groovepack",
|
|
31
|
+
enforce: "pre",
|
|
32
|
+
config() {
|
|
33
|
+
return {
|
|
34
|
+
optimizeDeps: {
|
|
35
|
+
exclude: ["@3lineas/groovepack"]
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
configResolved(resolvedConfig) {
|
|
40
|
+
if (resolvedConfig.root) {
|
|
41
|
+
rootDir = resolvedConfig.root;
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
resolveId(source) {
|
|
45
|
+
if (source === VIRTUAL_MISSING_TOAST_ID) {
|
|
46
|
+
return VIRTUAL_MISSING_TOAST_ID;
|
|
47
|
+
}
|
|
48
|
+
return void 0;
|
|
49
|
+
},
|
|
50
|
+
load(id) {
|
|
51
|
+
if (id === VIRTUAL_MISSING_TOAST_ID) {
|
|
52
|
+
return "export default undefined;";
|
|
53
|
+
}
|
|
54
|
+
return void 0;
|
|
55
|
+
},
|
|
56
|
+
transform(code, id) {
|
|
57
|
+
if (!id.includes("groovepack") || !id.includes("api-toast")) {
|
|
58
|
+
return void 0;
|
|
59
|
+
}
|
|
60
|
+
const target = hasToastModuleOnDisk(rootDir, shadcnPath) ? toastImportTarget : VIRTUAL_MISSING_TOAST_ID;
|
|
61
|
+
const transformed = code.replace(
|
|
62
|
+
DYNAMIC_IMPORT_PATTERN,
|
|
63
|
+
`import(${JSON.stringify(target)})`
|
|
64
|
+
);
|
|
65
|
+
if (transformed === code) {
|
|
66
|
+
return void 0;
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
code: transformed,
|
|
70
|
+
map: null
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
export {
|
|
76
|
+
groovepack
|
|
77
|
+
};
|
|
78
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/vite/groovepack-plugin.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type {\n GroovepackVitePlugin,\n GroovepackVitePluginOptions,\n GroovepackViteResolvedConfig,\n} from \"@/types/vite/vite-plugin.type\";\n\nconst DEFAULT_SHADCN_UI_PATH = \"/src/components/ui\";\nconst VIRTUAL_MISSING_TOAST_ID = \"\\0groovepack-missing-toast\";\nconst DYNAMIC_IMPORT_PATTERN =\n /import\\(\\s*\\/\\*\\s*@vite-ignore\\s*\\*\\/\\s*[^)]+\\)/g;\nconst TOAST_EXTENSIONS = [\n \"\",\n \".ts\",\n \".tsx\",\n \".js\",\n \".jsx\",\n \"/index.ts\",\n \"/index.tsx\",\n] as const;\n\nfunction resolveShadcnPath(options?: GroovepackVitePluginOptions): string {\n const candidate =\n options?.shadcnPath ??\n process.env[\"GROOVEPACK_SHADCN_PATH\"] ??\n process.env[\"NEXT_PUBLIC_GROOVEPACK_SHADCN_PATH\"] ??\n DEFAULT_SHADCN_UI_PATH;\n\n return candidate.trim().replace(/\\/+$/, \"\") || DEFAULT_SHADCN_UI_PATH;\n}\n\nfunction hasToastModuleOnDisk(rootDir: string, shadcnPath: string): boolean {\n const relativeBase = shadcnPath.startsWith(\"/\")\n ? shadcnPath.slice(1)\n : shadcnPath;\n const baseTarget = path.resolve(rootDir, relativeBase, \"toast\");\n\n return TOAST_EXTENSIONS.some((ext) => existsSync(`${baseTarget}${ext}`));\n}\n\n/**\n * Optional Vite plugin for `@3lineas/groovepack/api-toast`.\n * Statically resolves `${shadcnPath}/toast` in both `vite dev` and `vite build`.\n */\nexport function groovepack(\n options?: GroovepackVitePluginOptions,\n): GroovepackVitePlugin {\n let rootDir = process.cwd();\n const shadcnPath = resolveShadcnPath(options);\n const toastImportTarget = `${shadcnPath}/toast`;\n\n return {\n name: \"groovepack\",\n enforce: \"pre\",\n config() {\n return {\n optimizeDeps: {\n exclude: [\"@3lineas/groovepack\"],\n },\n };\n },\n configResolved(resolvedConfig: GroovepackViteResolvedConfig) {\n if (resolvedConfig.root) {\n rootDir = resolvedConfig.root;\n }\n },\n resolveId(source: string) {\n if (source === VIRTUAL_MISSING_TOAST_ID) {\n return VIRTUAL_MISSING_TOAST_ID;\n }\n\n return undefined;\n },\n load(id: string) {\n if (id === VIRTUAL_MISSING_TOAST_ID) {\n return \"export default undefined;\";\n }\n\n return undefined;\n },\n transform(code: string, id: string) {\n if (!id.includes(\"groovepack\") || !id.includes(\"api-toast\")) {\n return undefined;\n }\n\n const target = hasToastModuleOnDisk(rootDir, shadcnPath)\n ? toastImportTarget\n : VIRTUAL_MISSING_TOAST_ID;\n\n const transformed = code.replace(\n DYNAMIC_IMPORT_PATTERN,\n `import(${JSON.stringify(target)})`,\n );\n\n if (transformed === code) {\n return undefined;\n }\n\n return {\n code: transformed,\n map: null,\n };\n },\n };\n}\n"],"mappings":";AAAA,SAAS,kBAAkB;AAC3B,OAAO,UAAU;AAOjB,IAAM,yBAAyB;AAC/B,IAAM,2BAA2B;AACjC,IAAM,yBACJ;AACF,IAAM,mBAAmB;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,SAAS,kBAAkB,SAA+C;AACxE,QAAM,YACJ,SAAS,cACT,QAAQ,IAAI,wBAAwB,KACpC,QAAQ,IAAI,oCAAoC,KAChD;AAEF,SAAO,UAAU,KAAK,EAAE,QAAQ,QAAQ,EAAE,KAAK;AACjD;AAEA,SAAS,qBAAqB,SAAiB,YAA6B;AAC1E,QAAM,eAAe,WAAW,WAAW,GAAG,IAC1C,WAAW,MAAM,CAAC,IAClB;AACJ,QAAM,aAAa,KAAK,QAAQ,SAAS,cAAc,OAAO;AAE9D,SAAO,iBAAiB,KAAK,CAAC,QAAQ,WAAW,GAAG,UAAU,GAAG,GAAG,EAAE,CAAC;AACzE;AAMO,SAAS,WACd,SACsB;AACtB,MAAI,UAAU,QAAQ,IAAI;AAC1B,QAAM,aAAa,kBAAkB,OAAO;AAC5C,QAAM,oBAAoB,GAAG,UAAU;AAEvC,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IACT,SAAS;AACP,aAAO;AAAA,QACL,cAAc;AAAA,UACZ,SAAS,CAAC,qBAAqB;AAAA,QACjC;AAAA,MACF;AAAA,IACF;AAAA,IACA,eAAe,gBAA8C;AAC3D,UAAI,eAAe,MAAM;AACvB,kBAAU,eAAe;AAAA,MAC3B;AAAA,IACF;AAAA,IACA,UAAU,QAAgB;AACxB,UAAI,WAAW,0BAA0B;AACvC,eAAO;AAAA,MACT;AAEA,aAAO;AAAA,IACT;AAAA,IACA,KAAK,IAAY;AACf,UAAI,OAAO,0BAA0B;AACnC,eAAO;AAAA,MACT;AAEA,aAAO;AAAA,IACT;AAAA,IACA,UAAU,MAAc,IAAY;AAClC,UAAI,CAAC,GAAG,SAAS,YAAY,KAAK,CAAC,GAAG,SAAS,WAAW,GAAG;AAC3D,eAAO;AAAA,MACT;AAEA,YAAM,SAAS,qBAAqB,SAAS,UAAU,IACnD,oBACA;AAEJ,YAAM,cAAc,KAAK;AAAA,QACvB;AAAA,QACA,UAAU,KAAK,UAAU,MAAM,CAAC;AAAA,MAClC;AAEA,UAAI,gBAAgB,MAAM;AACxB,eAAO;AAAA,MACT;AAEA,aAAO;AAAA,QACL,MAAM;AAAA,QACN,KAAK;AAAA,MACP;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@3lineas/groovepack",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Zero-dependency & modular infrastructure primitives for TypeScript, Cloudflare Workers (D1, Hono), React, and Astro.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -36,6 +36,10 @@
|
|
|
36
36
|
"./i18n": {
|
|
37
37
|
"types": "./dist/i18n/index.d.ts",
|
|
38
38
|
"import": "./dist/i18n/index.js"
|
|
39
|
+
},
|
|
40
|
+
"./vite": {
|
|
41
|
+
"types": "./dist/vite/index.d.ts",
|
|
42
|
+
"import": "./dist/vite/index.js"
|
|
39
43
|
}
|
|
40
44
|
},
|
|
41
45
|
"publishConfig": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/i18n/is-supported-locale.ts","../src/i18n/read-env-locale.ts","../src/i18n/locale-state.ts","../src/i18n/messages.ts","../src/i18n/resolve-locale-messages.ts"],"sourcesContent":["import type { GroovepackLocale } from \"@/types/i18n/groovepack-locale.type\";\n\nconst SUPPORTED_LOCALE_SET = new Set<string>([\"en\", \"es\", \"pt\", \"it\", \"fr\"]);\n\n/**\n * Normalizes a candidate locale string (e.g. \"es-AR\" -> \"es\") and returns\n * a supported `GroovepackLocale`, or `undefined` if unsupported.\n */\nexport function normalizeSupportedLocale(\n candidate: unknown,\n): GroovepackLocale | undefined {\n if (typeof candidate !== \"string\") {\n return undefined;\n }\n\n const trimmed = candidate.trim().toLowerCase();\n if (trimmed.length === 0) {\n return undefined;\n }\n\n const baseTag = trimmed.split(/[-_]/)[0];\n if (!baseTag || !SUPPORTED_LOCALE_SET.has(baseTag)) {\n return undefined;\n }\n\n return baseTag as GroovepackLocale;\n}\n","import type { GroovepackLocale } from \"@/types/i18n/groovepack-locale.type\";\nimport { normalizeSupportedLocale } from \"@/i18n/is-supported-locale\";\n\nconst ENV_LOCALE_KEYS = [\n \"GROOVEPACK_LOCALE\",\n \"NEXT_PUBLIC_GROOVEPACK_LOCALE\",\n] as const;\n\nfunction readLocaleFromProcessEnv(): GroovepackLocale | undefined {\n const globalRecord = globalThis as Record<string, unknown>;\n const processValue = globalRecord[\"process\"];\n if (typeof processValue !== \"object\" || processValue === null) {\n return undefined;\n }\n\n const envValue = (processValue as Record<string, unknown>)[\"env\"];\n if (typeof envValue !== \"object\" || envValue === null) {\n return undefined;\n }\n\n const record = envValue as Record<string, unknown>;\n for (const key of ENV_LOCALE_KEYS) {\n const normalized = normalizeSupportedLocale(record[key]);\n if (normalized) {\n return normalized;\n }\n }\n\n return undefined;\n}\n\nfunction readLocaleFromImportMeta(): GroovepackLocale | undefined {\n try {\n return (\n normalizeSupportedLocale(import.meta.env?.GROOVEPACK_LOCALE) ??\n normalizeSupportedLocale(import.meta.env?.NEXT_PUBLIC_GROOVEPACK_LOCALE)\n );\n } catch {\n return undefined;\n }\n}\n\n/**\n * Safely reads `GROOVEPACK_LOCALE` or `NEXT_PUBLIC_GROOVEPACK_LOCALE` in Vinext\n * (Cloudflare Workers + Vite 8 `ModuleRunner`) without dynamic `import.meta.env` access.\n */\nexport function readEnvLocale(): GroovepackLocale | undefined {\n return readLocaleFromProcessEnv() ?? readLocaleFromImportMeta();\n}\n","import type { GroovepackLocale } from \"@/types/i18n/groovepack-locale.type\";\nimport { normalizeSupportedLocale } from \"@/i18n/is-supported-locale\";\nimport { readEnvLocale } from \"@/i18n/read-env-locale\";\n\nlet configuredLocale: GroovepackLocale | undefined;\n\n/**\n * Sets the global runtime locale for `@3lineas/groovepack` fallback messages.\n * Pass `undefined` to clear the runtime override and fall back to environment\n * variables or `\"en\"`.\n */\nexport function setGroovepackLocale(locale: GroovepackLocale | undefined): void {\n if (locale === undefined) {\n configuredLocale = undefined;\n return;\n }\n\n configuredLocale = normalizeSupportedLocale(locale);\n}\n\n/**\n * Resolves the active locale using precedence:\n * 1. Explicit `overrideLocale`\n * 2. Runtime locale set via `setGroovepackLocale()`\n * 3. Environment variable (`GROOVEPACK_LOCALE` / framework-prefixed)\n * 4. Default `\"en\"`\n */\nexport function getGroovepackLocale(\n overrideLocale?: GroovepackLocale,\n): GroovepackLocale {\n return (\n normalizeSupportedLocale(overrideLocale) ??\n configuredLocale ??\n readEnvLocale() ??\n \"en\"\n );\n}\n","import type { GroovepackLocale } from \"@/types/i18n/groovepack-locale.type\";\nimport type { GroovepackLocaleMessages } from \"@/types/i18n/locale-messages.type\";\n\nexport const GROOVEPACK_MESSAGES = {\n en: {\n loading: \"Processing...\",\n success: \"Operation completed successfully.\",\n unexpectedError:\n \"An unexpected error occurred while processing your request. Please try again.\",\n serverRequestFailed:\n \"Could not process the request on the server. Please try again.\",\n operationFailed: \"The operation could not be completed.\",\n },\n es: {\n loading: \"Procesando...\",\n success: \"Operación completada con éxito.\",\n unexpectedError:\n \"Ocurrió un error inesperado al procesar la solicitud. Por favor, intenta de nuevo.\",\n serverRequestFailed:\n \"No se pudo procesar la solicitud en el servidor. Por favor, intenta de nuevo.\",\n operationFailed: \"La operación no se pudo completar.\",\n },\n pt: {\n loading: \"Processando...\",\n success: \"Operação concluída com sucesso.\",\n unexpectedError:\n \"Ocorreu um erro inesperado ao processar a solicitação. Por favor, tente novamente.\",\n serverRequestFailed:\n \"Não foi possível processar a solicitação no servidor. Por favor, tente novamente.\",\n operationFailed: \"Não foi possível concluir a operação.\",\n },\n it: {\n loading: \"Elaborazione in corso...\",\n success: \"Operazione completata con successo.\",\n unexpectedError:\n \"Si è verificato un errore imprevisto durante l'elaborazione della richiesta. Riprova.\",\n serverRequestFailed:\n \"Impossibile elaborare la richiesta sul server. Riprova.\",\n operationFailed: \"Impossibile completare l'operazione.\",\n },\n fr: {\n loading: \"Traitement en cours...\",\n success: \"Opération terminée avec succès.\",\n unexpectedError:\n \"Une erreur inattendue s'est produite lors du traitement de la demande. Veuillez réessayer.\",\n serverRequestFailed:\n \"Impossible de traiter la demande sur le serveur. Veuillez réessayer.\",\n operationFailed: \"L'opération n'a pas pu être terminée.\",\n },\n} as const satisfies Record<GroovepackLocale, GroovepackLocaleMessages>;\n","import type { GroovepackLocale } from \"@/types/i18n/groovepack-locale.type\";\nimport type { GroovepackLocaleMessages } from \"@/types/i18n/locale-messages.type\";\nimport { getGroovepackLocale } from \"@/i18n/locale-state\";\nimport { GROOVEPACK_MESSAGES } from \"@/i18n/messages\";\n\n/**\n * Returns the localized message dictionary for the given override locale,\n * or the active runtime/environment/default (`\"en\"`) locale.\n */\nexport function resolveLocaleMessages(\n overrideLocale?: GroovepackLocale,\n): GroovepackLocaleMessages {\n const activeLocale = getGroovepackLocale(overrideLocale);\n return GROOVEPACK_MESSAGES[activeLocale];\n}\n"],"mappings":";AAEA,IAAM,uBAAuB,oBAAI,IAAY,CAAC,MAAM,MAAM,MAAM,MAAM,IAAI,CAAC;AAMpE,SAAS,yBACd,WAC8B;AAC9B,MAAI,OAAO,cAAc,UAAU;AACjC,WAAO;AAAA,EACT;AAEA,QAAM,UAAU,UAAU,KAAK,EAAE,YAAY;AAC7C,MAAI,QAAQ,WAAW,GAAG;AACxB,WAAO;AAAA,EACT;AAEA,QAAM,UAAU,QAAQ,MAAM,MAAM,EAAE,CAAC;AACvC,MAAI,CAAC,WAAW,CAAC,qBAAqB,IAAI,OAAO,GAAG;AAClD,WAAO;AAAA,EACT;AAEA,SAAO;AACT;;;ACvBA,IAAM,kBAAkB;AAAA,EACtB;AAAA,EACA;AACF;AAEA,SAAS,2BAAyD;AAChE,QAAM,eAAe;AACrB,QAAM,eAAe,aAAa,SAAS;AAC3C,MAAI,OAAO,iBAAiB,YAAY,iBAAiB,MAAM;AAC7D,WAAO;AAAA,EACT;AAEA,QAAM,WAAY,aAAyC,KAAK;AAChE,MAAI,OAAO,aAAa,YAAY,aAAa,MAAM;AACrD,WAAO;AAAA,EACT;AAEA,QAAM,SAAS;AACf,aAAW,OAAO,iBAAiB;AACjC,UAAM,aAAa,yBAAyB,OAAO,GAAG,CAAC;AACvD,QAAI,YAAY;AACd,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO;AACT;AAEA,SAAS,2BAAyD;AAChE,MAAI;AACF,WACE,yBAAyB,YAAY,KAAK,iBAAiB,KAC3D,yBAAyB,YAAY,KAAK,6BAA6B;AAAA,EAE3E,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAMO,SAAS,gBAA8C;AAC5D,SAAO,yBAAyB,KAAK,yBAAyB;AAChE;;;AC5CA,IAAI;AAOG,SAAS,oBAAoB,QAA4C;AAC9E,MAAI,WAAW,QAAW;AACxB,uBAAmB;AACnB;AAAA,EACF;AAEA,qBAAmB,yBAAyB,MAAM;AACpD;AASO,SAAS,oBACd,gBACkB;AAClB,SACE,yBAAyB,cAAc,KACvC,oBACA,cAAc,KACd;AAEJ;;;ACjCO,IAAM,sBAAsB;AAAA,EACjC,IAAI;AAAA,IACF,SAAS;AAAA,IACT,SAAS;AAAA,IACT,iBACE;AAAA,IACF,qBACE;AAAA,IACF,iBAAiB;AAAA,EACnB;AAAA,EACA,IAAI;AAAA,IACF,SAAS;AAAA,IACT,SAAS;AAAA,IACT,iBACE;AAAA,IACF,qBACE;AAAA,IACF,iBAAiB;AAAA,EACnB;AAAA,EACA,IAAI;AAAA,IACF,SAAS;AAAA,IACT,SAAS;AAAA,IACT,iBACE;AAAA,IACF,qBACE;AAAA,IACF,iBAAiB;AAAA,EACnB;AAAA,EACA,IAAI;AAAA,IACF,SAAS;AAAA,IACT,SAAS;AAAA,IACT,iBACE;AAAA,IACF,qBACE;AAAA,IACF,iBAAiB;AAAA,EACnB;AAAA,EACA,IAAI;AAAA,IACF,SAAS;AAAA,IACT,SAAS;AAAA,IACT,iBACE;AAAA,IACF,qBACE;AAAA,IACF,iBAAiB;AAAA,EACnB;AACF;;;ACxCO,SAAS,sBACd,gBAC0B;AAC1B,QAAM,eAAe,oBAAoB,cAAc;AACvD,SAAO,oBAAoB,YAAY;AACzC;","names":[]}
|