@firebase-oss/ui-translations 0.0.1 → 0.0.2-exp.ed61394

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/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- 'use strict';var a={errors:{userNotFound:"No account found with this email address",wrongPassword:"Incorrect password",invalidEmail:"Please enter a valid email address",userDisabled:"This account has been disabled",networkRequestFailed:"Unable to connect to the server. Please check your internet connection",tooManyRequests:"Too many failed attempts. Please try again later",emailAlreadyInUse:"An account already exists with this email",weakPassword:"Password should be at least 8 characters",operationNotAllowed:"Email/password accounts are not enabled. Please contact support.",invalidPhoneNumber:"The phone number is invalid",missingPhoneNumber:"Please provide a phone number",quotaExceeded:"SMS quota exceeded. Please try again later",codeExpired:"The verification code has expired",captchaCheckFailed:"reCAPTCHA verification failed. Please try again.",missingVerificationId:"Please complete the reCAPTCHA verification first.",missingEmail:"Please provide an email address",invalidActionCode:"The password reset link is invalid or has expired",credentialAlreadyInUse:"An account already exists with this email. Please sign in with that account.",requiresRecentLogin:"This operation requires a recent login. Please sign in again.",providerAlreadyLinked:"This phone number is already linked to another account",invalidVerificationCode:"Invalid verification code. Please try again",unknownError:"An unexpected error occurred",popupClosed:"The sign-in popup was closed. Please try again.",accountExistsWithDifferentCredential:"An account already exists with this email. Please sign in with the original provider.",displayNameRequired:"Please provide a display name",secondFactorAlreadyInUse:"This phone number is already enrolled with this account."},messages:{passwordResetEmailSent:"Password reset email sent successfully",signInLinkSent:"Sign-in link sent successfully",verificationCodeFirst:"Please request a verification code first",checkEmailForReset:"Check your email for password reset instructions",dividerOr:"or",termsAndPrivacy:"By continuing, you agree to our {tos} and {privacy}."},labels:{emailAddress:"Email Address",password:"Password",displayName:"Display Name",forgotPassword:"Forgot Password?",signUp:"Sign Up",signIn:"Sign In",resetPassword:"Reset Password",createAccount:"Create Account",backToSignIn:"Back to Sign In",signInWithPhone:"Sign in with Phone",phoneNumber:"Phone Number",verificationCode:"Verification Code",sendCode:"Send Code",verifyCode:"Verify Code",signInWithGoogle:"Sign in with Google",signInWithFacebook:"Sign in with Facebook",signInWithApple:"Sign in with Apple",signInWithMicrosoft:"Sign in with Microsoft",signInWithGitHub:"Sign in with GitHub",signInWithTwitter:"Sign in with Twitter",signInWithEmailLink:"Sign in with Email Link",sendSignInLink:"Send Sign-in Link",termsOfService:"Terms of Service",privacyPolicy:"Privacy Policy",resendCode:"Resend Code",sending:"Sending...",multiFactorEnrollment:"Multi-factor Enrollment",mfaTotpVerification:"TOTP Verification",mfaSmsVerification:"SMS Verification",generateQrCode:"Generate QR Code"},prompts:{noAccount:"Don't have an account?",haveAccount:"Already have an account?",enterEmailToReset:"Enter your email address to reset your password",signInToAccount:"Sign in to your account",enterDetailsToCreate:"Enter your details to create a new account",enterPhoneNumber:"Enter your phone number",enterVerificationCode:"Enter the verification code",enterEmailForLink:"Enter your email to receive a sign-in link",mfaEnrollmentPrompt:"Select a new multi-factor enrollment method"}};var h={"auth/user-not-found":"userNotFound","auth/wrong-password":"wrongPassword","auth/invalid-email":"invalidEmail","auth/user-disabled":"userDisabled","auth/network-request-failed":"networkRequestFailed","auth/too-many-requests":"tooManyRequests","auth/email-already-in-use":"emailAlreadyInUse","auth/weak-password":"weakPassword","auth/operation-not-allowed":"operationNotAllowed","auth/invalid-phone-number":"invalidPhoneNumber","auth/missing-phone-number":"missingPhoneNumber","auth/quota-exceeded":"quotaExceeded","auth/code-expired":"codeExpired","auth/captcha-check-failed":"captchaCheckFailed","auth/missing-verification-id":"missingVerificationId","auth/missing-email":"missingEmail","auth/invalid-action-code":"invalidActionCode","auth/credential-already-in-use":"credentialAlreadyInUse","auth/requires-recent-login":"requiresRecentLogin","auth/provider-already-linked":"providerAlreadyLinked","auth/invalid-verification-code":"invalidVerificationCode","auth/account-exists-with-different-credential":"accountExistsWithDifferentCredential","auth/display-name-required":"displayNameRequired","auth/second-factor-already-in-use":"secondFactorAlreadyInUse"};function o(e,i,n){let t=e.translations[i]?.[n];if(t)return t;if(e.fallback){let r=o(e.fallback,i,n);if(r)return r}return a[i][n]}function s(e,i,n){return {locale:e,translations:i,fallback:n}}var g=s("en-US",a);exports.ERROR_CODE_MAP=h;exports.enUs=g;exports.getTranslation=o;exports.registerLocale=s;//# sourceMappingURL=index.cjs.map
1
+ 'use strict';var o={errors:{userNotFound:"No account found with this email address",wrongPassword:"Incorrect password",invalidEmail:"Please enter a valid email address",userDisabled:"This account has been disabled",networkRequestFailed:"Unable to connect to the server. Please check your internet connection",tooManyRequests:"Too many failed attempts. Please try again later",missingVerificationCode:"Please enter the verification code",emailAlreadyInUse:"An account already exists with this email",invalidCredential:"The provided credentials are invalid.",weakPassword:"Password should be at least 8 characters",unverifiedEmail:"Please verify your email address to continue.",operationNotAllowed:"This operation is not allowed. Please contact support.",invalidPhoneNumber:"The phone number is invalid",missingPhoneNumber:"Please provide a phone number",quotaExceeded:"SMS quota exceeded. Please try again later",codeExpired:"The verification code has expired",captchaCheckFailed:"reCAPTCHA verification failed. Please try again.",missingVerificationId:"Please complete the reCAPTCHA verification first.",missingEmail:"Please provide an email address",invalidActionCode:"The password reset link is invalid or has expired",credentialAlreadyInUse:"An account already exists with this email. Please sign in with that account.",requiresRecentLogin:"This operation requires a recent login. Please sign in again.",providerAlreadyLinked:"This phone number is already linked to another account",invalidVerificationCode:"Invalid verification code. Please try again",unknownError:"An unexpected error occurred",popupClosed:"The sign-in popup was closed. Please try again.",accountExistsWithDifferentCredential:"An account already exists with this email. Please sign in with the original provider.",displayNameRequired:"Please provide a display name",secondFactorAlreadyInUse:"This phone number is already enrolled with this account."},messages:{passwordResetEmailSent:"Password reset email sent successfully",signInLinkSent:"Sign-in link sent successfully",verificationCodeFirst:"Please request a verification code first",checkEmailForReset:"Check your email for password reset instructions",dividerOr:"or",termsAndPrivacy:"By continuing, you agree to our {tos} and {privacy}.",mfaSmsAssertionPrompt:"A verification code will be sent to {phoneNumber} to complete the authentication process."},labels:{emailAddress:"Email Address",password:"Password",displayName:"Display Name",forgotPassword:"Forgot Password?",signUp:"Sign Up",signIn:"Sign In",resetPassword:"Reset Password",createAccount:"Create Account",backToSignIn:"Back to Sign In",signInWithPhone:"Sign in with Phone",phoneNumber:"Phone Number",verificationCode:"Verification Code",sendCode:"Send Code",verifyCode:"Verify Code",signInWithGoogle:"Sign in with Google",signInWithFacebook:"Sign in with Facebook",signInWithApple:"Sign in with Apple",signInWithMicrosoft:"Sign in with Microsoft",signInWithGitHub:"Sign in with GitHub",signInWithTwitter:"Sign in with X",signInWithEmailLink:"Sign in with Email Link",sendSignInLink:"Send Sign-in Link",termsOfService:"Terms of Service",privacyPolicy:"Privacy Policy",resendCode:"Resend Code",sending:"Sending...",multiFactorEnrollment:"Multi-factor Enrollment",multiFactorAssertion:"Multi-factor Authentication",mfaTotpVerification:"TOTP Verification",mfaSmsVerification:"SMS Verification",generateQrCode:"Generate QR Code"},prompts:{noAccount:"Don't have an account?",haveAccount:"Already have an account?",enterEmailToReset:"Enter your email address to reset your password",signInToAccount:"Sign in to your account",smsVerificationPrompt:"Enter the verification code sent to your phone number",enterDetailsToCreate:"Enter your details to create a new account",enterPhoneNumber:"Enter your phone number",enterVerificationCode:"Enter the verification code",enterEmailForLink:"Enter your email to receive a sign-in link",mfaEnrollmentPrompt:"Select a new multi-factor enrollment method",mfaAssertionPrompt:"Please complete the multi-factor authentication process",mfaAssertionFactorPrompt:"Please choose a multi-factor authentication method",mfaTotpQrCodePrompt:"Scan this QR code with your authenticator app",mfaTotpEnrollmentVerificationPrompt:"Add the code generated by your authenticator app"}};var p={"auth/user-not-found":"userNotFound","auth/wrong-password":"wrongPassword","auth/invalid-email":"invalidEmail","auth/unverified-email":"unverifiedEmail","auth/user-disabled":"userDisabled","auth/missing-code":"missingVerificationCode","auth/invalid-credential":"invalidCredential","auth/network-request-failed":"networkRequestFailed","auth/too-many-requests":"tooManyRequests","auth/email-already-in-use":"emailAlreadyInUse","auth/weak-password":"weakPassword","auth/operation-not-allowed":"operationNotAllowed","auth/invalid-phone-number":"invalidPhoneNumber","auth/missing-phone-number":"missingPhoneNumber","auth/quota-exceeded":"quotaExceeded","auth/code-expired":"codeExpired","auth/captcha-check-failed":"captchaCheckFailed","auth/missing-verification-id":"missingVerificationId","auth/missing-email":"missingEmail","auth/invalid-action-code":"invalidActionCode","auth/credential-already-in-use":"credentialAlreadyInUse","auth/requires-recent-login":"requiresRecentLogin","auth/provider-already-linked":"providerAlreadyLinked","auth/invalid-verification-code":"invalidVerificationCode","auth/account-exists-with-different-credential":"accountExistsWithDifferentCredential","auth/display-name-required":"displayNameRequired","auth/second-factor-already-in-use":"secondFactorAlreadyInUse"};function d(i,t,n,r){let s=i.translations[t]?.[n],e;if(s)e=s;else if(i.fallback){let a=d(i.fallback,t,n);a&&(e=a);}else e=o[t][n];return r&&(e=e?.replace(/{(\w+)}/g,(a,l)=>r[l]||a)),e||""}function c(i,t,n){return {locale:i,translations:t,fallback:n}}var y=c("en-US",o);exports.ERROR_CODE_MAP=p;exports.enUs=y;exports.getTranslation=d;exports.registerLocale=c;//# sourceMappingURL=index.cjs.map
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/locales/en-us.ts","../src/mapping.ts","../src/index.ts"],"names":["enUS","ERROR_CODE_MAP","getTranslation","locale","category","key","translatedString","fallbackTranslation","registerLocale","translations","fallback","enUs"],"mappings":"aAmBO,IAAMA,CAAAA,CAAO,CAClB,MAAA,CAAQ,CACN,YAAA,CAAc,0CAAA,CACd,aAAA,CAAe,oBAAA,CACf,YAAA,CAAc,oCAAA,CACd,YAAA,CAAc,gCAAA,CACd,qBAAsB,wEAAA,CACtB,eAAA,CAAiB,kDAAA,CACjB,iBAAA,CAAmB,2CAAA,CACnB,YAAA,CAAc,0CAAA,CACd,mBAAA,CAAqB,kEAAA,CACrB,kBAAA,CAAoB,6BAAA,CACpB,kBAAA,CAAoB,+BAAA,CACpB,aAAA,CAAe,4CAAA,CACf,WAAA,CAA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L,CAAAA,CAAeC,CAAAA,CAAO,SAAUC,CAAAA,CAAUC,CAAG,CAAA,CAEzE,GAAIE,CAAAA,CACF,OAAOA,CAEX,CAIA,OAD+BP,CAAAA,CAAKI,CAAQ,CAAA,CACdC,CAAG,CACnC,CCjDO,SAASG,EACdL,CAAAA,CACAM,CAAAA,CACAC,CAAAA,CACkB,CAClB,OAAO,CACL,MAAA,CAAAP,CAAAA,CACA,aAAAM,CAAAA,CACA,QAAA,CAAAC,CACF,CACF,CAEO,IAAMC,CAAAA,CAAOH,CAAAA,CAAe,QAASR,CAAI","file":"index.cjs","sourcesContent":["/**\n * Copyright 2025 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { type Translations } from \"../types\";\n\n// TODO: Should this be required or optional?\nexport const enUS = {\n errors: {\n userNotFound: \"No account found with this email address\",\n wrongPassword: \"Incorrect password\",\n invalidEmail: \"Please enter a valid email address\",\n userDisabled: \"This account has been disabled\",\n networkRequestFailed: \"Unable to connect to the server. Please check your internet connection\",\n tooManyRequests: \"Too many failed attempts. Please try again later\",\n emailAlreadyInUse: \"An account already exists with this email\",\n weakPassword: \"Password should be at least 8 characters\",\n operationNotAllowed: \"Email/password accounts are not enabled. Please contact support.\",\n invalidPhoneNumber: \"The phone number is invalid\",\n missingPhoneNumber: \"Please provide a phone number\",\n quotaExceeded: \"SMS quota exceeded. Please try again later\",\n codeExpired: \"The verification code has expired\",\n captchaCheckFailed: \"reCAPTCHA verification failed. Please try again.\",\n missingVerificationId: \"Please complete the reCAPTCHA verification first.\",\n missingEmail: \"Please provide an email address\",\n invalidActionCode: \"The password reset link is invalid or has expired\",\n credentialAlreadyInUse: \"An account already exists with this email. Please sign in with that account.\",\n requiresRecentLogin: \"This operation requires a recent login. Please sign in again.\",\n providerAlreadyLinked: \"This phone number is already linked to another account\",\n invalidVerificationCode: \"Invalid verification code. Please try again\",\n unknownError: \"An unexpected error occurred\",\n popupClosed: \"The sign-in popup was closed. Please try again.\",\n accountExistsWithDifferentCredential:\n \"An account already exists with this email. Please sign in with the original provider.\",\n displayNameRequired: \"Please provide a display name\",\n secondFactorAlreadyInUse: \"This phone number is already enrolled with this account.\",\n },\n messages: {\n passwordResetEmailSent: \"Password reset email sent successfully\",\n signInLinkSent: \"Sign-in link sent successfully\",\n verificationCodeFirst: \"Please request a verification code first\",\n checkEmailForReset: \"Check your email for password reset instructions\",\n dividerOr: \"or\",\n termsAndPrivacy: \"By continuing, you agree to our {tos} and {privacy}.\",\n },\n labels: {\n emailAddress: \"Email Address\",\n password: \"Password\",\n displayName: \"Display Name\",\n forgotPassword: \"Forgot Password?\",\n signUp: \"Sign Up\",\n signIn: \"Sign In\",\n resetPassword: \"Reset Password\",\n createAccount: \"Create Account\",\n backToSignIn: \"Back to Sign In\",\n signInWithPhone: \"Sign in with Phone\",\n phoneNumber: \"Phone Number\",\n verificationCode: \"Verification Code\",\n sendCode: \"Send Code\",\n verifyCode: \"Verify Code\",\n signInWithGoogle: \"Sign in with Google\",\n signInWithFacebook: \"Sign in with Facebook\",\n signInWithApple: \"Sign in with Apple\",\n signInWithMicrosoft: \"Sign in with Microsoft\",\n signInWithGitHub: \"Sign in with GitHub\",\n signInWithTwitter: \"Sign in with Twitter\",\n signInWithEmailLink: \"Sign in with Email Link\",\n sendSignInLink: \"Send Sign-in Link\",\n termsOfService: \"Terms of Service\",\n privacyPolicy: \"Privacy Policy\",\n resendCode: \"Resend Code\",\n sending: \"Sending...\",\n multiFactorEnrollment: \"Multi-factor Enrollment\",\n mfaTotpVerification: \"TOTP Verification\",\n mfaSmsVerification: \"SMS Verification\",\n generateQrCode: \"Generate QR Code\",\n },\n prompts: {\n noAccount: \"Don't have an account?\",\n haveAccount: \"Already have an account?\",\n enterEmailToReset: \"Enter your email address to reset your password\",\n signInToAccount: \"Sign in to your account\",\n enterDetailsToCreate: \"Enter your details to create a new account\",\n enterPhoneNumber: \"Enter your phone number\",\n enterVerificationCode: \"Enter the verification code\",\n enterEmailForLink: \"Enter your email to receive a sign-in link\",\n mfaEnrollmentPrompt: \"Select a new multi-factor enrollment method\",\n },\n} satisfies Translations;\n","/**\n * Copyright 2025 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { enUS } from \"./locales/en-us\";\nimport { type RegisteredLocale } from \".\";\nimport type { ErrorKey, TranslationCategory, TranslationKey, TranslationSet } from \"./types\";\n\nexport const ERROR_CODE_MAP = {\n \"auth/user-not-found\": \"userNotFound\",\n \"auth/wrong-password\": \"wrongPassword\",\n \"auth/invalid-email\": \"invalidEmail\",\n \"auth/user-disabled\": \"userDisabled\",\n \"auth/network-request-failed\": \"networkRequestFailed\",\n \"auth/too-many-requests\": \"tooManyRequests\",\n \"auth/email-already-in-use\": \"emailAlreadyInUse\",\n \"auth/weak-password\": \"weakPassword\",\n \"auth/operation-not-allowed\": \"operationNotAllowed\",\n \"auth/invalid-phone-number\": \"invalidPhoneNumber\",\n \"auth/missing-phone-number\": \"missingPhoneNumber\",\n \"auth/quota-exceeded\": \"quotaExceeded\",\n \"auth/code-expired\": \"codeExpired\",\n \"auth/captcha-check-failed\": \"captchaCheckFailed\",\n \"auth/missing-verification-id\": \"missingVerificationId\",\n \"auth/missing-email\": \"missingEmail\",\n \"auth/invalid-action-code\": \"invalidActionCode\",\n \"auth/credential-already-in-use\": \"credentialAlreadyInUse\",\n \"auth/requires-recent-login\": \"requiresRecentLogin\",\n \"auth/provider-already-linked\": \"providerAlreadyLinked\",\n \"auth/invalid-verification-code\": \"invalidVerificationCode\",\n \"auth/account-exists-with-different-credential\": \"accountExistsWithDifferentCredential\",\n \"auth/display-name-required\": \"displayNameRequired\",\n \"auth/second-factor-already-in-use\": \"secondFactorAlreadyInUse\",\n} satisfies Record<string, ErrorKey>;\n\nexport type ErrorCode = keyof typeof ERROR_CODE_MAP;\n\nexport function getTranslation<T extends TranslationCategory>(\n locale: RegisteredLocale,\n category: T,\n key: TranslationKey<T>\n): string {\n const userTranslationSet = locale.translations[category] as TranslationSet<T> | undefined;\n const translatedString = userTranslationSet?.[key];\n\n if (translatedString) {\n return translatedString;\n }\n\n // Check fallback locale if it exists\n if (locale.fallback) {\n const fallbackTranslation = getTranslation(locale.fallback, category, key);\n\n if (fallbackTranslation) {\n return fallbackTranslation;\n }\n }\n\n // Fall back to English translations\n const fallbackTranslationSet = enUS[category] as TranslationSet<T>;\n return fallbackTranslationSet[key];\n}\n","/**\n * Copyright 2025 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { enUS } from \"./locales/en-us\";\nimport { type Translations } from \"./types\";\n\nexport type * from \"./types\";\nexport * from \"./mapping\";\n\nexport type Locale = \"en-US\" | `${string}-${string}` | string;\n\nexport function registerLocale(\n locale: Locale,\n translations: Translations,\n fallback?: RegisteredLocale\n): RegisteredLocale {\n return {\n locale,\n translations,\n fallback,\n };\n}\n\nexport const enUs = registerLocale(\"en-US\", enUS);\n\nexport type RegisteredLocale = {\n locale: Locale;\n translations: Translations;\n fallback?: RegisteredLocale;\n};\n"]}
1
+ {"version":3,"sources":["../src/locales/en-us.ts","../src/mapping.ts","../src/index.ts"],"names":["enUS","ERROR_CODE_MAP","getTranslation","locale","category","key","replacements","translatedString","str","fallbackTranslation","match","p1","registerLocale","translations","fallback","enUs"],"mappings":"aAmBO,IAAMA,CAAAA,CAAO,CAClB,MAAA,CAAQ,CACN,aAAc,0CAAA,CACd,aAAA,CAAe,oBAAA,CACf,YAAA,CAAc,qCACd,YAAA,CAAc,gCAAA,CACd,oBAAA,CAAsB,wEAAA,CACtB,gBAAiB,kDAAA,CACjB,uBAAA,CAAyB,oCAAA,CACzB,iBAAA,CAAmB,4CACnB,iBAAA,CAAmB,uCAAA,CACnB,YAAA,CAAc,0CAAA,CACd,gBAAiB,+CAAA,CACjB,mBAAA,CAAqB,wDAAA,CACrB,kBAAA,CAAoB,8BACpB,kBAAA,CAAoB,+BAAA,CACpB,aAAA,CAAe,4CAAA,CACf,YAAa,mCAAA,CACb,kBAAA,CAAoB,kDAAA,CACpB,qBAAA,CAAuB,oDACvB,YAAA,CAAc,iCAAA,CACd,iBAAA,CAAmB,mDAAA,CACnB,uBAAwB,8EAAA,CACxB,mBAAA,CAAqB,+DAAA,CACrB,qBAAA,CAAuB,yDACvB,uBAAA,CAAyB,6CAAA,CACzB,YAAA,CAAc,8BAAA,CACd,YAAa,iDAAA,CACb,oCAAA,CACE,uFAAA,CACF,mBAAA,CAAqB,gCACrB,wBAAA,CAA0B,0DAC5B,CAAA,CACA,QAAA,CAAU,CACR,sBAAA,CAAwB,wCAAA,CACxB,cAAA,CAAgB,gCAAA,CAChB,sBAAuB,0CAAA,CACvB,kBAAA,CAAoB,kDAAA,CACpB,SAAA,CAAW,KACX,eAAA,CAAiB,sDAAA,CACjB,qBAAA,CAAuB,2FACzB,CAAA,CACA,MAAA,CAAQ,CACN,YAAA,CAAc,gBACd,QAAA,CAAU,UAAA,CACV,W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kB,CAClB,OAAO,CACL,MAAA,CAAAX,EACA,YAAA,CAAAU,CAAAA,CACA,QAAA,CAAAC,CACF,CACF,CAGO,IAAMC,CAAAA,CAAOH,CAAAA,CAAe,QAASZ,CAAI","file":"index.cjs","sourcesContent":["/**\n * Copyright 2025 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { type Translations } from \"../types\";\n\n/** English US (en-US) translation set with all default translations. */\nexport const enUS = {\n errors: {\n userNotFound: \"No account found with this email address\",\n wrongPassword: \"Incorrect password\",\n invalidEmail: \"Please enter a valid email address\",\n userDisabled: \"This account has been disabled\",\n networkRequestFailed: \"Unable to connect to the server. Please check your internet connection\",\n tooManyRequests: \"Too many failed attempts. Please try again later\",\n missingVerificationCode: \"Please enter the verification code\",\n emailAlreadyInUse: \"An account already exists with this email\",\n invalidCredential: \"The provided credentials are invalid.\",\n weakPassword: \"Password should be at least 8 characters\",\n unverifiedEmail: \"Please verify your email address to continue.\",\n operationNotAllowed: \"This operation is not allowed. Please contact support.\",\n invalidPhoneNumber: \"The phone number is invalid\",\n missingPhoneNumber: \"Please provide a phone number\",\n quotaExceeded: \"SMS quota exceeded. Please try again later\",\n codeExpired: \"The verification code has expired\",\n captchaCheckFailed: \"reCAPTCHA verification failed. Please try again.\",\n missingVerificationId: \"Please complete the reCAPTCHA verification first.\",\n missingEmail: \"Please provide an email address\",\n invalidActionCode: \"The password reset link is invalid or has expired\",\n credentialAlreadyInUse: \"An account already exists with this email. Please sign in with that account.\",\n requiresRecentLogin: \"This operation requires a recent login. Please sign in again.\",\n providerAlreadyLinked: \"This phone number is already linked to another account\",\n invalidVerificationCode: \"Invalid verification code. Please try again\",\n unknownError: \"An unexpected error occurred\",\n popupClosed: \"The sign-in popup was closed. Please try again.\",\n accountExistsWithDifferentCredential:\n \"An account already exists with this email. Please sign in with the original provider.\",\n displayNameRequired: \"Please provide a display name\",\n secondFactorAlreadyInUse: \"This phone number is already enrolled with this account.\",\n },\n messages: {\n passwordResetEmailSent: \"Password reset email sent successfully\",\n signInLinkSent: \"Sign-in link sent successfully\",\n verificationCodeFirst: \"Please request a verification code first\",\n checkEmailForReset: \"Check your email for password reset instructions\",\n dividerOr: \"or\",\n termsAndPrivacy: \"By continuing, you agree to our {tos} and {privacy}.\",\n mfaSmsAssertionPrompt: \"A verification code will be sent to {phoneNumber} to complete the authentication process.\",\n },\n labels: {\n emailAddress: \"Email Address\",\n password: \"Password\",\n displayName: \"Display Name\",\n forgotPassword: \"Forgot Password?\",\n signUp: \"Sign Up\",\n signIn: \"Sign In\",\n resetPassword: \"Reset Password\",\n createAccount: \"Create Account\",\n backToSignIn: \"Back to Sign In\",\n signInWithPhone: \"Sign in with Phone\",\n phoneNumber: \"Phone Number\",\n verificationCode: \"Verification Code\",\n sendCode: \"Send Code\",\n verifyCode: \"Verify Code\",\n signInWithGoogle: \"Sign in with Google\",\n signInWithFacebook: \"Sign in with Facebook\",\n signInWithApple: \"Sign in with Apple\",\n signInWithMicrosoft: \"Sign in with Microsoft\",\n signInWithGitHub: \"Sign in with GitHub\",\n signInWithTwitter: \"Sign in with X\",\n signInWithEmailLink: \"Sign in with Email Link\",\n sendSignInLink: \"Send Sign-in Link\",\n termsOfService: \"Terms of Service\",\n privacyPolicy: \"Privacy Policy\",\n resendCode: \"Resend Code\",\n sending: \"Sending...\",\n multiFactorEnrollment: \"Multi-factor Enrollment\",\n multiFactorAssertion: \"Multi-factor Authentication\",\n mfaTotpVerification: \"TOTP Verification\",\n mfaSmsVerification: \"SMS Verification\",\n generateQrCode: \"Generate QR Code\",\n },\n prompts: {\n noAccount: \"Don't have an account?\",\n haveAccount: \"Already have an account?\",\n enterEmailToReset: \"Enter your email address to reset your password\",\n signInToAccount: \"Sign in to your account\",\n smsVerificationPrompt: \"Enter the verification code sent to your phone number\",\n enterDetailsToCreate: \"Enter your details to create a new account\",\n enterPhoneNumber: \"Enter your phone number\",\n enterVerificationCode: \"Enter the verification code\",\n enterEmailForLink: \"Enter your email to receive a sign-in link\",\n mfaEnrollmentPrompt: \"Select a new multi-factor enrollment method\",\n mfaAssertionPrompt: \"Please complete the multi-factor authentication process\",\n mfaAssertionFactorPrompt: \"Please choose a multi-factor authentication method\",\n mfaTotpQrCodePrompt: \"Scan this QR code with your authenticator app\",\n mfaTotpEnrollmentVerificationPrompt: \"Add the code generated by your authenticator app\",\n },\n} satisfies Translations;\n","/**\n * Copyright 2025 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { enUS } from \"./locales/en-us\";\nimport { type RegisteredLocale } from \".\";\nimport type { ErrorKey, TranslationCategory, TranslationKey, TranslationSet } from \"./types\";\n\n/** Maps Firebase authentication error codes to translation keys. */\nexport const ERROR_CODE_MAP = {\n \"auth/user-not-found\": \"userNotFound\",\n \"auth/wrong-password\": \"wrongPassword\",\n \"auth/invalid-email\": \"invalidEmail\",\n \"auth/unverified-email\": \"unverifiedEmail\",\n \"auth/user-disabled\": \"userDisabled\",\n \"auth/missing-code\": \"missingVerificationCode\",\n \"auth/invalid-credential\": \"invalidCredential\",\n \"auth/network-request-failed\": \"networkRequestFailed\",\n \"auth/too-many-requests\": \"tooManyRequests\",\n \"auth/email-already-in-use\": \"emailAlreadyInUse\",\n \"auth/weak-password\": \"weakPassword\",\n \"auth/operation-not-allowed\": \"operationNotAllowed\",\n \"auth/invalid-phone-number\": \"invalidPhoneNumber\",\n \"auth/missing-phone-number\": \"missingPhoneNumber\",\n \"auth/quota-exceeded\": \"quotaExceeded\",\n \"auth/code-expired\": \"codeExpired\",\n \"auth/captcha-check-failed\": \"captchaCheckFailed\",\n \"auth/missing-verification-id\": \"missingVerificationId\",\n \"auth/missing-email\": \"missingEmail\",\n \"auth/invalid-action-code\": \"invalidActionCode\",\n \"auth/credential-already-in-use\": \"credentialAlreadyInUse\",\n \"auth/requires-recent-login\": \"requiresRecentLogin\",\n \"auth/provider-already-linked\": \"providerAlreadyLinked\",\n \"auth/invalid-verification-code\": \"invalidVerificationCode\",\n \"auth/account-exists-with-different-credential\": \"accountExistsWithDifferentCredential\",\n \"auth/display-name-required\": \"displayNameRequired\",\n \"auth/second-factor-already-in-use\": \"secondFactorAlreadyInUse\",\n} satisfies Record<string, ErrorKey>;\n\n/** Firebase authentication error code type. */\nexport type ErrorCode = keyof typeof ERROR_CODE_MAP;\n\n/**\n * Retrieves a translation string for a given locale, category, and key.\n *\n * Falls back to the locale's fallback locale or English US if the translation is not found.\n * Supports string replacements using {placeholder} syntax.\n *\n * @param locale - The registered locale to get the translation from.\n * @param category - The translation category (e.g., \"errors\", \"labels\").\n * @param key - The translation key within the category.\n * @param replacements - Optional object with replacement values for placeholders in the translation string.\n * @returns The translated string, or an empty string if not found.\n */\nexport function getTranslation<T extends TranslationCategory>(\n locale: RegisteredLocale,\n category: T,\n key: TranslationKey<T>,\n replacements?: Record<string, string>\n): string {\n const userTranslationSet = locale.translations[category] as TranslationSet<T> | undefined;\n const translatedString = userTranslationSet?.[key];\n\n let str: string | undefined;\n\n if (translatedString) {\n str = translatedString;\n } else if (locale.fallback) {\n const fallbackTranslation = getTranslation(locale.fallback, category, key);\n\n if (fallbackTranslation) {\n str = fallbackTranslation;\n }\n } else {\n const fallbackTranslationSet = enUS[category] as TranslationSet<T>;\n str = fallbackTranslationSet[key];\n }\n\n if (replacements) {\n str = str?.replace(/{(\\w+)}/g, (match, p1) => replacements[p1] || match);\n }\n\n return str || \"\";\n}\n","/**\n * Copyright 2025 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { enUS } from \"./locales/en-us\";\nimport { type Translations } from \"./types\";\n\nexport type * from \"./types\";\nexport * from \"./mapping\";\n\n/** Locale identifier string. Supports BCP 47 format (e.g., \"en-US\") or any string. */\nexport type Locale = \"en-US\" | `${string}-${string}` | string;\n\n/**\n * Registers a locale with its translations and optional fallback locale.\n *\n * @param locale - The locale identifier (e.g., \"en-US\", \"fr-FR\").\n * @param translations - The translation object for this locale.\n * @param fallback - Optional fallback locale to use when a translation is missing.\n * @returns A registered locale object.\n */\nexport function registerLocale(\n locale: Locale,\n translations: Translations,\n fallback?: RegisteredLocale\n): RegisteredLocale {\n return {\n locale,\n translations,\n fallback,\n };\n}\n\n/** Pre-registered English US locale with default translations. */\nexport const enUs = registerLocale(\"en-US\", enUS);\n\n/** A registered locale with its translations and optional fallback. */\nexport type RegisteredLocale = {\n /** The locale identifier. */\n locale: Locale;\n /** The translation object for this locale. */\n translations: Translations;\n /** Optional fallback locale to use when a translation is missing. */\n fallback?: RegisteredLocale;\n};\n"]}
package/dist/index.d.cts CHANGED
@@ -13,93 +13,197 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ /** Category keys for translation sets (e.g., "errors", "messages", "labels", "prompts"). */
16
17
  type TranslationCategory = keyof Required<Translations>;
18
+ /** Generic type for translation keys within a specific category. */
17
19
  type TranslationKey<T extends TranslationCategory> = keyof Required<Translations>[T];
20
+ /** Record type representing a complete set of translations for a specific category. */
18
21
  type TranslationSet<T extends TranslationCategory> = Record<TranslationKey<T>, string>;
22
+ /** Keys for error translation messages. */
19
23
  type ErrorKey = keyof Required<Translations>["errors"];
24
+ /** Keys for informational message translations. */
20
25
  type MessageKey = keyof Required<Translations>["messages"];
26
+ /** Keys for UI label translations. */
21
27
  type LabelKey = keyof Required<Translations>["labels"];
28
+ /** Keys for prompt/instruction translations. */
22
29
  type PromptKey = keyof Required<Translations>["prompts"];
30
+ /** Configuration type for translations, mapping locale identifiers to partial translation objects. */
23
31
  type TranslationsConfig = Partial<Record<string, Partial<Translations>>>;
32
+ /** Complete translations interface containing all translation categories and their keys. */
24
33
  type Translations = {
34
+ /** Error message translations. */
25
35
  errors?: {
36
+ /** Translation for when a user is not found. */
26
37
  userNotFound?: string;
38
+ /** Translation for incorrect password. */
27
39
  wrongPassword?: string;
40
+ /** Translation for invalid email address. */
28
41
  invalidEmail?: string;
42
+ /** Translation for disabled user account. */
29
43
  userDisabled?: string;
44
+ /** Translation for unverified email address. */
45
+ unverifiedEmail?: string;
46
+ /** Translation for network request failure. */
30
47
  networkRequestFailed?: string;
48
+ /** Translation for too many requests. */
31
49
  tooManyRequests?: string;
50
+ /** Translation for email already in use. */
32
51
  emailAlreadyInUse?: string;
52
+ /** Translation for missing verification code. */
53
+ missingVerificationCode?: string;
54
+ /** Translation for invalid credentials. */
55
+ invalidCredential?: string;
56
+ /** Translation for weak password. */
33
57
  weakPassword?: string;
58
+ /** Translation for operation not allowed. */
34
59
  operationNotAllowed?: string;
60
+ /** Translation for invalid phone number. */
35
61
  invalidPhoneNumber?: string;
62
+ /** Translation for missing phone number. */
36
63
  missingPhoneNumber?: string;
64
+ /** Translation for SMS quota exceeded. */
37
65
  quotaExceeded?: string;
66
+ /** Translation for expired verification code. */
38
67
  codeExpired?: string;
68
+ /** Translation for reCAPTCHA check failure. */
39
69
  captchaCheckFailed?: string;
70
+ /** Translation for missing verification ID. */
40
71
  missingVerificationId?: string;
72
+ /** Translation for missing email address. */
41
73
  missingEmail?: string;
74
+ /** Translation for required display name. */
42
75
  displayNameRequired?: string;
76
+ /** Translation for invalid action code. */
43
77
  invalidActionCode?: string;
78
+ /** Translation for credential already in use. */
44
79
  credentialAlreadyInUse?: string;
80
+ /** Translation for operation requiring recent login. */
45
81
  requiresRecentLogin?: string;
82
+ /** Translation for provider already linked. */
46
83
  providerAlreadyLinked?: string;
84
+ /** Translation for invalid verification code. */
47
85
  invalidVerificationCode?: string;
86
+ /** Translation for unknown error. */
48
87
  unknownError?: string;
88
+ /** Translation for popup closed by user. */
49
89
  popupClosed?: string;
90
+ /** Translation for account existing with different credential. */
50
91
  accountExistsWithDifferentCredential?: string;
92
+ /** Translation for second factor already in use. */
51
93
  secondFactorAlreadyInUse?: string;
52
94
  };
95
+ /** Informational message translations. */
53
96
  messages?: {
97
+ /** Translation for password reset email sent confirmation. */
54
98
  passwordResetEmailSent?: string;
99
+ /** Translation for sign-in link sent confirmation. */
55
100
  signInLinkSent?: string;
101
+ /** Translation for verification code required first. */
56
102
  verificationCodeFirst?: string;
103
+ /** Translation for checking email for reset instructions. */
57
104
  checkEmailForReset?: string;
105
+ /** Translation for "or" divider text. */
58
106
  dividerOr?: string;
107
+ /** Translation for terms and privacy policy notice. */
59
108
  termsAndPrivacy?: string;
109
+ /** Translation for MFA SMS assertion prompt message. */
110
+ mfaSmsAssertionPrompt?: string;
60
111
  };
112
+ /** UI label translations. */
61
113
  labels?: {
114
+ /** Translation for email address label. */
62
115
  emailAddress?: string;
116
+ /** Translation for password label. */
63
117
  password?: string;
118
+ /** Translation for display name label. */
64
119
  displayName?: string;
120
+ /** Translation for forgot password link. */
65
121
  forgotPassword?: string;
122
+ /** Translation for sign up button/link. */
66
123
  signUp?: string;
124
+ /** Translation for sign in button/link. */
67
125
  signIn?: string;
126
+ /** Translation for reset password button. */
68
127
  resetPassword?: string;
128
+ /** Translation for create account button. */
69
129
  createAccount?: string;
130
+ /** Translation for back to sign in link. */
70
131
  backToSignIn?: string;
132
+ /** Translation for sign in with phone button. */
71
133
  signInWithPhone?: string;
134
+ /** Translation for phone number label. */
72
135
  phoneNumber?: string;
136
+ /** Translation for verification code label. */
73
137
  verificationCode?: string;
138
+ /** Translation for send code button. */
74
139
  sendCode?: string;
140
+ /** Translation for verify code button. */
75
141
  verifyCode?: string;
142
+ /** Translation for sign in with Google button. */
76
143
  signInWithGoogle?: string;
144
+ /** Translation for sign in with Facebook button. */
77
145
  signInWithFacebook?: string;
146
+ /** Translation for sign in with Apple button. */
78
147
  signInWithApple?: string;
148
+ /** Translation for sign in with Twitter/X button. */
79
149
  signInWithTwitter?: string;
150
+ /** Translation for sign in with Microsoft button. */
80
151
  signInWithMicrosoft?: string;
152
+ /** Translation for sign in with GitHub button. */
81
153
  signInWithGitHub?: string;
154
+ /** Translation for sign in with email link button. */
82
155
  signInWithEmailLink?: string;
156
+ /** Translation for send sign-in link button. */
83
157
  sendSignInLink?: string;
158
+ /** Translation for terms of service link. */
84
159
  termsOfService?: string;
160
+ /** Translation for privacy policy link. */
85
161
  privacyPolicy?: string;
162
+ /** Translation for resend code button. */
86
163
  resendCode?: string;
164
+ /** Translation for sending state text. */
87
165
  sending?: string;
166
+ /** Translation for multi-factor enrollment label. */
88
167
  multiFactorEnrollment?: string;
168
+ /** Translation for multi-factor assertion label. */
169
+ multiFactorAssertion?: string;
170
+ /** Translation for TOTP verification label. */
89
171
  mfaTotpVerification?: string;
172
+ /** Translation for SMS verification label. */
90
173
  mfaSmsVerification?: string;
174
+ /** Translation for generate QR code button. */
91
175
  generateQrCode?: string;
92
176
  };
177
+ /** Prompt and instruction translations. */
93
178
  prompts?: {
179
+ /** Translation for "don't have an account" prompt. */
94
180
  noAccount?: string;
181
+ /** Translation for "already have an account" prompt. */
95
182
  haveAccount?: string;
183
+ /** Translation for enter email to reset password prompt. */
96
184
  enterEmailToReset?: string;
185
+ /** Translation for sign in to account prompt. */
97
186
  signInToAccount?: string;
187
+ /** Translation for enter details to create account prompt. */
98
188
  enterDetailsToCreate?: string;
189
+ /** Translation for SMS verification code prompt. */
190
+ smsVerificationPrompt?: string;
191
+ /** Translation for enter phone number prompt. */
99
192
  enterPhoneNumber?: string;
193
+ /** Translation for enter verification code prompt. */
100
194
  enterVerificationCode?: string;
195
+ /** Translation for enter email for link prompt. */
101
196
  enterEmailForLink?: string;
197
+ /** Translation for MFA enrollment prompt. */
102
198
  mfaEnrollmentPrompt?: string;
199
+ /** Translation for MFA assertion prompt. */
200
+ mfaAssertionPrompt?: string;
201
+ /** Translation for MFA assertion factor selection prompt. */
202
+ mfaAssertionFactorPrompt?: string;
203
+ /** Translation for TOTP QR code prompt. */
204
+ mfaTotpQrCodePrompt?: string;
205
+ /** Translation for TOTP enrollment verification prompt. */
206
+ mfaTotpEnrollmentVerificationPrompt?: string;
103
207
  };
104
208
  };
105
209
 
@@ -119,11 +223,15 @@ type Translations = {
119
223
  * limitations under the License.
120
224
  */
121
225
 
226
+ /** Maps Firebase authentication error codes to translation keys. */
122
227
  declare const ERROR_CODE_MAP: {
123
228
  "auth/user-not-found": "userNotFound";
124
229
  "auth/wrong-password": "wrongPassword";
125
230
  "auth/invalid-email": "invalidEmail";
231
+ "auth/unverified-email": "unverifiedEmail";
126
232
  "auth/user-disabled": "userDisabled";
233
+ "auth/missing-code": "missingVerificationCode";
234
+ "auth/invalid-credential": "invalidCredential";
127
235
  "auth/network-request-failed": "networkRequestFailed";
128
236
  "auth/too-many-requests": "tooManyRequests";
129
237
  "auth/email-already-in-use": "emailAlreadyInUse";
@@ -145,8 +253,21 @@ declare const ERROR_CODE_MAP: {
145
253
  "auth/display-name-required": "displayNameRequired";
146
254
  "auth/second-factor-already-in-use": "secondFactorAlreadyInUse";
147
255
  };
256
+ /** Firebase authentication error code type. */
148
257
  type ErrorCode = keyof typeof ERROR_CODE_MAP;
149
- declare function getTranslation<T extends TranslationCategory>(locale: RegisteredLocale, category: T, key: TranslationKey<T>): string;
258
+ /**
259
+ * Retrieves a translation string for a given locale, category, and key.
260
+ *
261
+ * Falls back to the locale's fallback locale or English US if the translation is not found.
262
+ * Supports string replacements using {placeholder} syntax.
263
+ *
264
+ * @param locale - The registered locale to get the translation from.
265
+ * @param category - The translation category (e.g., "errors", "labels").
266
+ * @param key - The translation key within the category.
267
+ * @param replacements - Optional object with replacement values for placeholders in the translation string.
268
+ * @returns The translated string, or an empty string if not found.
269
+ */
270
+ declare function getTranslation<T extends TranslationCategory>(locale: RegisteredLocale, category: T, key: TranslationKey<T>, replacements?: Record<string, string>): string;
150
271
 
151
272
  /**
152
273
  * Copyright 2025 Google LLC
@@ -164,12 +285,26 @@ declare function getTranslation<T extends TranslationCategory>(locale: Registere
164
285
  * limitations under the License.
165
286
  */
166
287
 
288
+ /** Locale identifier string. Supports BCP 47 format (e.g., "en-US") or any string. */
167
289
  type Locale = "en-US" | `${string}-${string}` | string;
290
+ /**
291
+ * Registers a locale with its translations and optional fallback locale.
292
+ *
293
+ * @param locale - The locale identifier (e.g., "en-US", "fr-FR").
294
+ * @param translations - The translation object for this locale.
295
+ * @param fallback - Optional fallback locale to use when a translation is missing.
296
+ * @returns A registered locale object.
297
+ */
168
298
  declare function registerLocale(locale: Locale, translations: Translations, fallback?: RegisteredLocale): RegisteredLocale;
299
+ /** Pre-registered English US locale with default translations. */
169
300
  declare const enUs: RegisteredLocale;
301
+ /** A registered locale with its translations and optional fallback. */
170
302
  type RegisteredLocale = {
303
+ /** The locale identifier. */
171
304
  locale: Locale;
305
+ /** The translation object for this locale. */
172
306
  translations: Translations;
307
+ /** Optional fallback locale to use when a translation is missing. */
173
308
  fallback?: RegisteredLocale;
174
309
  };
175
310
 
package/dist/index.d.ts CHANGED
@@ -13,93 +13,197 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
+ /** Category keys for translation sets (e.g., "errors", "messages", "labels", "prompts"). */
16
17
  type TranslationCategory = keyof Required<Translations>;
18
+ /** Generic type for translation keys within a specific category. */
17
19
  type TranslationKey<T extends TranslationCategory> = keyof Required<Translations>[T];
20
+ /** Record type representing a complete set of translations for a specific category. */
18
21
  type TranslationSet<T extends TranslationCategory> = Record<TranslationKey<T>, string>;
22
+ /** Keys for error translation messages. */
19
23
  type ErrorKey = keyof Required<Translations>["errors"];
24
+ /** Keys for informational message translations. */
20
25
  type MessageKey = keyof Required<Translations>["messages"];
26
+ /** Keys for UI label translations. */
21
27
  type LabelKey = keyof Required<Translations>["labels"];
28
+ /** Keys for prompt/instruction translations. */
22
29
  type PromptKey = keyof Required<Translations>["prompts"];
30
+ /** Configuration type for translations, mapping locale identifiers to partial translation objects. */
23
31
  type TranslationsConfig = Partial<Record<string, Partial<Translations>>>;
32
+ /** Complete translations interface containing all translation categories and their keys. */
24
33
  type Translations = {
34
+ /** Error message translations. */
25
35
  errors?: {
36
+ /** Translation for when a user is not found. */
26
37
  userNotFound?: string;
38
+ /** Translation for incorrect password. */
27
39
  wrongPassword?: string;
40
+ /** Translation for invalid email address. */
28
41
  invalidEmail?: string;
42
+ /** Translation for disabled user account. */
29
43
  userDisabled?: string;
44
+ /** Translation for unverified email address. */
45
+ unverifiedEmail?: string;
46
+ /** Translation for network request failure. */
30
47
  networkRequestFailed?: string;
48
+ /** Translation for too many requests. */
31
49
  tooManyRequests?: string;
50
+ /** Translation for email already in use. */
32
51
  emailAlreadyInUse?: string;
52
+ /** Translation for missing verification code. */
53
+ missingVerificationCode?: string;
54
+ /** Translation for invalid credentials. */
55
+ invalidCredential?: string;
56
+ /** Translation for weak password. */
33
57
  weakPassword?: string;
58
+ /** Translation for operation not allowed. */
34
59
  operationNotAllowed?: string;
60
+ /** Translation for invalid phone number. */
35
61
  invalidPhoneNumber?: string;
62
+ /** Translation for missing phone number. */
36
63
  missingPhoneNumber?: string;
64
+ /** Translation for SMS quota exceeded. */
37
65
  quotaExceeded?: string;
66
+ /** Translation for expired verification code. */
38
67
  codeExpired?: string;
68
+ /** Translation for reCAPTCHA check failure. */
39
69
  captchaCheckFailed?: string;
70
+ /** Translation for missing verification ID. */
40
71
  missingVerificationId?: string;
72
+ /** Translation for missing email address. */
41
73
  missingEmail?: string;
74
+ /** Translation for required display name. */
42
75
  displayNameRequired?: string;
76
+ /** Translation for invalid action code. */
43
77
  invalidActionCode?: string;
78
+ /** Translation for credential already in use. */
44
79
  credentialAlreadyInUse?: string;
80
+ /** Translation for operation requiring recent login. */
45
81
  requiresRecentLogin?: string;
82
+ /** Translation for provider already linked. */
46
83
  providerAlreadyLinked?: string;
84
+ /** Translation for invalid verification code. */
47
85
  invalidVerificationCode?: string;
86
+ /** Translation for unknown error. */
48
87
  unknownError?: string;
88
+ /** Translation for popup closed by user. */
49
89
  popupClosed?: string;
90
+ /** Translation for account existing with different credential. */
50
91
  accountExistsWithDifferentCredential?: string;
92
+ /** Translation for second factor already in use. */
51
93
  secondFactorAlreadyInUse?: string;
52
94
  };
95
+ /** Informational message translations. */
53
96
  messages?: {
97
+ /** Translation for password reset email sent confirmation. */
54
98
  passwordResetEmailSent?: string;
99
+ /** Translation for sign-in link sent confirmation. */
55
100
  signInLinkSent?: string;
101
+ /** Translation for verification code required first. */
56
102
  verificationCodeFirst?: string;
103
+ /** Translation for checking email for reset instructions. */
57
104
  checkEmailForReset?: string;
105
+ /** Translation for "or" divider text. */
58
106
  dividerOr?: string;
107
+ /** Translation for terms and privacy policy notice. */
59
108
  termsAndPrivacy?: string;
109
+ /** Translation for MFA SMS assertion prompt message. */
110
+ mfaSmsAssertionPrompt?: string;
60
111
  };
112
+ /** UI label translations. */
61
113
  labels?: {
114
+ /** Translation for email address label. */
62
115
  emailAddress?: string;
116
+ /** Translation for password label. */
63
117
  password?: string;
118
+ /** Translation for display name label. */
64
119
  displayName?: string;
120
+ /** Translation for forgot password link. */
65
121
  forgotPassword?: string;
122
+ /** Translation for sign up button/link. */
66
123
  signUp?: string;
124
+ /** Translation for sign in button/link. */
67
125
  signIn?: string;
126
+ /** Translation for reset password button. */
68
127
  resetPassword?: string;
128
+ /** Translation for create account button. */
69
129
  createAccount?: string;
130
+ /** Translation for back to sign in link. */
70
131
  backToSignIn?: string;
132
+ /** Translation for sign in with phone button. */
71
133
  signInWithPhone?: string;
134
+ /** Translation for phone number label. */
72
135
  phoneNumber?: string;
136
+ /** Translation for verification code label. */
73
137
  verificationCode?: string;
138
+ /** Translation for send code button. */
74
139
  sendCode?: string;
140
+ /** Translation for verify code button. */
75
141
  verifyCode?: string;
142
+ /** Translation for sign in with Google button. */
76
143
  signInWithGoogle?: string;
144
+ /** Translation for sign in with Facebook button. */
77
145
  signInWithFacebook?: string;
146
+ /** Translation for sign in with Apple button. */
78
147
  signInWithApple?: string;
148
+ /** Translation for sign in with Twitter/X button. */
79
149
  signInWithTwitter?: string;
150
+ /** Translation for sign in with Microsoft button. */
80
151
  signInWithMicrosoft?: string;
152
+ /** Translation for sign in with GitHub button. */
81
153
  signInWithGitHub?: string;
154
+ /** Translation for sign in with email link button. */
82
155
  signInWithEmailLink?: string;
156
+ /** Translation for send sign-in link button. */
83
157
  sendSignInLink?: string;
158
+ /** Translation for terms of service link. */
84
159
  termsOfService?: string;
160
+ /** Translation for privacy policy link. */
85
161
  privacyPolicy?: string;
162
+ /** Translation for resend code button. */
86
163
  resendCode?: string;
164
+ /** Translation for sending state text. */
87
165
  sending?: string;
166
+ /** Translation for multi-factor enrollment label. */
88
167
  multiFactorEnrollment?: string;
168
+ /** Translation for multi-factor assertion label. */
169
+ multiFactorAssertion?: string;
170
+ /** Translation for TOTP verification label. */
89
171
  mfaTotpVerification?: string;
172
+ /** Translation for SMS verification label. */
90
173
  mfaSmsVerification?: string;
174
+ /** Translation for generate QR code button. */
91
175
  generateQrCode?: string;
92
176
  };
177
+ /** Prompt and instruction translations. */
93
178
  prompts?: {
179
+ /** Translation for "don't have an account" prompt. */
94
180
  noAccount?: string;
181
+ /** Translation for "already have an account" prompt. */
95
182
  haveAccount?: string;
183
+ /** Translation for enter email to reset password prompt. */
96
184
  enterEmailToReset?: string;
185
+ /** Translation for sign in to account prompt. */
97
186
  signInToAccount?: string;
187
+ /** Translation for enter details to create account prompt. */
98
188
  enterDetailsToCreate?: string;
189
+ /** Translation for SMS verification code prompt. */
190
+ smsVerificationPrompt?: string;
191
+ /** Translation for enter phone number prompt. */
99
192
  enterPhoneNumber?: string;
193
+ /** Translation for enter verification code prompt. */
100
194
  enterVerificationCode?: string;
195
+ /** Translation for enter email for link prompt. */
101
196
  enterEmailForLink?: string;
197
+ /** Translation for MFA enrollment prompt. */
102
198
  mfaEnrollmentPrompt?: string;
199
+ /** Translation for MFA assertion prompt. */
200
+ mfaAssertionPrompt?: string;
201
+ /** Translation for MFA assertion factor selection prompt. */
202
+ mfaAssertionFactorPrompt?: string;
203
+ /** Translation for TOTP QR code prompt. */
204
+ mfaTotpQrCodePrompt?: string;
205
+ /** Translation for TOTP enrollment verification prompt. */
206
+ mfaTotpEnrollmentVerificationPrompt?: string;
103
207
  };
104
208
  };
105
209
 
@@ -119,11 +223,15 @@ type Translations = {
119
223
  * limitations under the License.
120
224
  */
121
225
 
226
+ /** Maps Firebase authentication error codes to translation keys. */
122
227
  declare const ERROR_CODE_MAP: {
123
228
  "auth/user-not-found": "userNotFound";
124
229
  "auth/wrong-password": "wrongPassword";
125
230
  "auth/invalid-email": "invalidEmail";
231
+ "auth/unverified-email": "unverifiedEmail";
126
232
  "auth/user-disabled": "userDisabled";
233
+ "auth/missing-code": "missingVerificationCode";
234
+ "auth/invalid-credential": "invalidCredential";
127
235
  "auth/network-request-failed": "networkRequestFailed";
128
236
  "auth/too-many-requests": "tooManyRequests";
129
237
  "auth/email-already-in-use": "emailAlreadyInUse";
@@ -145,8 +253,21 @@ declare const ERROR_CODE_MAP: {
145
253
  "auth/display-name-required": "displayNameRequired";
146
254
  "auth/second-factor-already-in-use": "secondFactorAlreadyInUse";
147
255
  };
256
+ /** Firebase authentication error code type. */
148
257
  type ErrorCode = keyof typeof ERROR_CODE_MAP;
149
- declare function getTranslation<T extends TranslationCategory>(locale: RegisteredLocale, category: T, key: TranslationKey<T>): string;
258
+ /**
259
+ * Retrieves a translation string for a given locale, category, and key.
260
+ *
261
+ * Falls back to the locale's fallback locale or English US if the translation is not found.
262
+ * Supports string replacements using {placeholder} syntax.
263
+ *
264
+ * @param locale - The registered locale to get the translation from.
265
+ * @param category - The translation category (e.g., "errors", "labels").
266
+ * @param key - The translation key within the category.
267
+ * @param replacements - Optional object with replacement values for placeholders in the translation string.
268
+ * @returns The translated string, or an empty string if not found.
269
+ */
270
+ declare function getTranslation<T extends TranslationCategory>(locale: RegisteredLocale, category: T, key: TranslationKey<T>, replacements?: Record<string, string>): string;
150
271
 
151
272
  /**
152
273
  * Copyright 2025 Google LLC
@@ -164,12 +285,26 @@ declare function getTranslation<T extends TranslationCategory>(locale: Registere
164
285
  * limitations under the License.
165
286
  */
166
287
 
288
+ /** Locale identifier string. Supports BCP 47 format (e.g., "en-US") or any string. */
167
289
  type Locale = "en-US" | `${string}-${string}` | string;
290
+ /**
291
+ * Registers a locale with its translations and optional fallback locale.
292
+ *
293
+ * @param locale - The locale identifier (e.g., "en-US", "fr-FR").
294
+ * @param translations - The translation object for this locale.
295
+ * @param fallback - Optional fallback locale to use when a translation is missing.
296
+ * @returns A registered locale object.
297
+ */
168
298
  declare function registerLocale(locale: Locale, translations: Translations, fallback?: RegisteredLocale): RegisteredLocale;
299
+ /** Pre-registered English US locale with default translations. */
169
300
  declare const enUs: RegisteredLocale;
301
+ /** A registered locale with its translations and optional fallback. */
170
302
  type RegisteredLocale = {
303
+ /** The locale identifier. */
171
304
  locale: Locale;
305
+ /** The translation object for this locale. */
172
306
  translations: Translations;
307
+ /** Optional fallback locale to use when a translation is missing. */
173
308
  fallback?: RegisteredLocale;
174
309
  };
175
310
 
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- var a={errors:{userNotFound:"No account found with this email address",wrongPassword:"Incorrect password",invalidEmail:"Please enter a valid email address",userDisabled:"This account has been disabled",networkRequestFailed:"Unable to connect to the server. Please check your internet connection",tooManyRequests:"Too many failed attempts. Please try again later",emailAlreadyInUse:"An account already exists with this email",weakPassword:"Password should be at least 8 characters",operationNotAllowed:"Email/password accounts are not enabled. Please contact support.",invalidPhoneNumber:"The phone number is invalid",missingPhoneNumber:"Please provide a phone number",quotaExceeded:"SMS quota exceeded. Please try again later",codeExpired:"The verification code has expired",captchaCheckFailed:"reCAPTCHA verification failed. Please try again.",missingVerificationId:"Please complete the reCAPTCHA verification first.",missingEmail:"Please provide an email address",invalidActionCode:"The password reset link is invalid or has expired",credentialAlreadyInUse:"An account already exists with this email. Please sign in with that account.",requiresRecentLogin:"This operation requires a recent login. Please sign in again.",providerAlreadyLinked:"This phone number is already linked to another account",invalidVerificationCode:"Invalid verification code. Please try again",unknownError:"An unexpected error occurred",popupClosed:"The sign-in popup was closed. Please try again.",accountExistsWithDifferentCredential:"An account already exists with this email. Please sign in with the original provider.",displayNameRequired:"Please provide a display name",secondFactorAlreadyInUse:"This phone number is already enrolled with this account."},messages:{passwordResetEmailSent:"Password reset email sent successfully",signInLinkSent:"Sign-in link sent successfully",verificationCodeFirst:"Please request a verification code first",checkEmailForReset:"Check your email for password reset instructions",dividerOr:"or",termsAndPrivacy:"By continuing, you agree to our {tos} and {privacy}."},labels:{emailAddress:"Email Address",password:"Password",displayName:"Display Name",forgotPassword:"Forgot Password?",signUp:"Sign Up",signIn:"Sign In",resetPassword:"Reset Password",createAccount:"Create Account",backToSignIn:"Back to Sign In",signInWithPhone:"Sign in with Phone",phoneNumber:"Phone Number",verificationCode:"Verification Code",sendCode:"Send Code",verifyCode:"Verify Code",signInWithGoogle:"Sign in with Google",signInWithFacebook:"Sign in with Facebook",signInWithApple:"Sign in with Apple",signInWithMicrosoft:"Sign in with Microsoft",signInWithGitHub:"Sign in with GitHub",signInWithTwitter:"Sign in with Twitter",signInWithEmailLink:"Sign in with Email Link",sendSignInLink:"Send Sign-in Link",termsOfService:"Terms of Service",privacyPolicy:"Privacy Policy",resendCode:"Resend Code",sending:"Sending...",multiFactorEnrollment:"Multi-factor Enrollment",mfaTotpVerification:"TOTP Verification",mfaSmsVerification:"SMS Verification",generateQrCode:"Generate QR Code"},prompts:{noAccount:"Don't have an account?",haveAccount:"Already have an account?",enterEmailToReset:"Enter your email address to reset your password",signInToAccount:"Sign in to your account",enterDetailsToCreate:"Enter your details to create a new account",enterPhoneNumber:"Enter your phone number",enterVerificationCode:"Enter the verification code",enterEmailForLink:"Enter your email to receive a sign-in link",mfaEnrollmentPrompt:"Select a new multi-factor enrollment method"}};var h={"auth/user-not-found":"userNotFound","auth/wrong-password":"wrongPassword","auth/invalid-email":"invalidEmail","auth/user-disabled":"userDisabled","auth/network-request-failed":"networkRequestFailed","auth/too-many-requests":"tooManyRequests","auth/email-already-in-use":"emailAlreadyInUse","auth/weak-password":"weakPassword","auth/operation-not-allowed":"operationNotAllowed","auth/invalid-phone-number":"invalidPhoneNumber","auth/missing-phone-number":"missingPhoneNumber","auth/quota-exceeded":"quotaExceeded","auth/code-expired":"codeExpired","auth/captcha-check-failed":"captchaCheckFailed","auth/missing-verification-id":"missingVerificationId","auth/missing-email":"missingEmail","auth/invalid-action-code":"invalidActionCode","auth/credential-already-in-use":"credentialAlreadyInUse","auth/requires-recent-login":"requiresRecentLogin","auth/provider-already-linked":"providerAlreadyLinked","auth/invalid-verification-code":"invalidVerificationCode","auth/account-exists-with-different-credential":"accountExistsWithDifferentCredential","auth/display-name-required":"displayNameRequired","auth/second-factor-already-in-use":"secondFactorAlreadyInUse"};function o(e,i,n){let t=e.translations[i]?.[n];if(t)return t;if(e.fallback){let r=o(e.fallback,i,n);if(r)return r}return a[i][n]}function s(e,i,n){return {locale:e,translations:i,fallback:n}}var g=s("en-US",a);export{h as ERROR_CODE_MAP,g as enUs,o as getTranslation,s as registerLocale};//# sourceMappingURL=index.js.map
1
+ var o={errors:{userNotFound:"No account found with this email address",wrongPassword:"Incorrect password",invalidEmail:"Please enter a valid email address",userDisabled:"This account has been disabled",networkRequestFailed:"Unable to connect to the server. Please check your internet connection",tooManyRequests:"Too many failed attempts. Please try again later",missingVerificationCode:"Please enter the verification code",emailAlreadyInUse:"An account already exists with this email",invalidCredential:"The provided credentials are invalid.",weakPassword:"Password should be at least 8 characters",unverifiedEmail:"Please verify your email address to continue.",operationNotAllowed:"This operation is not allowed. Please contact support.",invalidPhoneNumber:"The phone number is invalid",missingPhoneNumber:"Please provide a phone number",quotaExceeded:"SMS quota exceeded. Please try again later",codeExpired:"The verification code has expired",captchaCheckFailed:"reCAPTCHA verification failed. Please try again.",missingVerificationId:"Please complete the reCAPTCHA verification first.",missingEmail:"Please provide an email address",invalidActionCode:"The password reset link is invalid or has expired",credentialAlreadyInUse:"An account already exists with this email. Please sign in with that account.",requiresRecentLogin:"This operation requires a recent login. Please sign in again.",providerAlreadyLinked:"This phone number is already linked to another account",invalidVerificationCode:"Invalid verification code. Please try again",unknownError:"An unexpected error occurred",popupClosed:"The sign-in popup was closed. Please try again.",accountExistsWithDifferentCredential:"An account already exists with this email. Please sign in with the original provider.",displayNameRequired:"Please provide a display name",secondFactorAlreadyInUse:"This phone number is already enrolled with this account."},messages:{passwordResetEmailSent:"Password reset email sent successfully",signInLinkSent:"Sign-in link sent successfully",verificationCodeFirst:"Please request a verification code first",checkEmailForReset:"Check your email for password reset instructions",dividerOr:"or",termsAndPrivacy:"By continuing, you agree to our {tos} and {privacy}.",mfaSmsAssertionPrompt:"A verification code will be sent to {phoneNumber} to complete the authentication process."},labels:{emailAddress:"Email Address",password:"Password",displayName:"Display Name",forgotPassword:"Forgot Password?",signUp:"Sign Up",signIn:"Sign In",resetPassword:"Reset Password",createAccount:"Create Account",backToSignIn:"Back to Sign In",signInWithPhone:"Sign in with Phone",phoneNumber:"Phone Number",verificationCode:"Verification Code",sendCode:"Send Code",verifyCode:"Verify Code",signInWithGoogle:"Sign in with Google",signInWithFacebook:"Sign in with Facebook",signInWithApple:"Sign in with Apple",signInWithMicrosoft:"Sign in with Microsoft",signInWithGitHub:"Sign in with GitHub",signInWithTwitter:"Sign in with X",signInWithEmailLink:"Sign in with Email Link",sendSignInLink:"Send Sign-in Link",termsOfService:"Terms of Service",privacyPolicy:"Privacy Policy",resendCode:"Resend Code",sending:"Sending...",multiFactorEnrollment:"Multi-factor Enrollment",multiFactorAssertion:"Multi-factor Authentication",mfaTotpVerification:"TOTP Verification",mfaSmsVerification:"SMS Verification",generateQrCode:"Generate QR Code"},prompts:{noAccount:"Don't have an account?",haveAccount:"Already have an account?",enterEmailToReset:"Enter your email address to reset your password",signInToAccount:"Sign in to your account",smsVerificationPrompt:"Enter the verification code sent to your phone number",enterDetailsToCreate:"Enter your details to create a new account",enterPhoneNumber:"Enter your phone number",enterVerificationCode:"Enter the verification code",enterEmailForLink:"Enter your email to receive a sign-in link",mfaEnrollmentPrompt:"Select a new multi-factor enrollment method",mfaAssertionPrompt:"Please complete the multi-factor authentication process",mfaAssertionFactorPrompt:"Please choose a multi-factor authentication method",mfaTotpQrCodePrompt:"Scan this QR code with your authenticator app",mfaTotpEnrollmentVerificationPrompt:"Add the code generated by your authenticator app"}};var p={"auth/user-not-found":"userNotFound","auth/wrong-password":"wrongPassword","auth/invalid-email":"invalidEmail","auth/unverified-email":"unverifiedEmail","auth/user-disabled":"userDisabled","auth/missing-code":"missingVerificationCode","auth/invalid-credential":"invalidCredential","auth/network-request-failed":"networkRequestFailed","auth/too-many-requests":"tooManyRequests","auth/email-already-in-use":"emailAlreadyInUse","auth/weak-password":"weakPassword","auth/operation-not-allowed":"operationNotAllowed","auth/invalid-phone-number":"invalidPhoneNumber","auth/missing-phone-number":"missingPhoneNumber","auth/quota-exceeded":"quotaExceeded","auth/code-expired":"codeExpired","auth/captcha-check-failed":"captchaCheckFailed","auth/missing-verification-id":"missingVerificationId","auth/missing-email":"missingEmail","auth/invalid-action-code":"invalidActionCode","auth/credential-already-in-use":"credentialAlreadyInUse","auth/requires-recent-login":"requiresRecentLogin","auth/provider-already-linked":"providerAlreadyLinked","auth/invalid-verification-code":"invalidVerificationCode","auth/account-exists-with-different-credential":"accountExistsWithDifferentCredential","auth/display-name-required":"displayNameRequired","auth/second-factor-already-in-use":"secondFactorAlreadyInUse"};function d(i,t,n,r){let s=i.translations[t]?.[n],e;if(s)e=s;else if(i.fallback){let a=d(i.fallback,t,n);a&&(e=a);}else e=o[t][n];return r&&(e=e?.replace(/{(\w+)}/g,(a,l)=>r[l]||a)),e||""}function c(i,t,n){return {locale:i,translations:t,fallback:n}}var y=c("en-US",o);export{p as ERROR_CODE_MAP,y as enUs,d as getTranslation,c as registerLocale};//# sourceMappingURL=index.js.map
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/locales/en-us.ts","../src/mapping.ts","../src/index.ts"],"names":["enUS","ERROR_CODE_MAP","getTranslation","locale","category","key","translatedString","fallbackTranslation","registerLocale","translations","fallback","enUs"],"mappings":"AAmBO,IAAMA,CAAAA,CAAO,CAClB,MAAA,CAAQ,CACN,YAAA,CAAc,0CAAA,CACd,aAAA,CAAe,oBAAA,CACf,YAAA,CAAc,oCAAA,CACd,YAAA,CAAc,gCAAA,CACd,qBAAsB,wEAAA,CACtB,eAAA,CAAiB,kDAAA,CACjB,iBAAA,CAAmB,2CAAA,CACnB,YAAA,CAAc,0CAAA,CACd,mBAAA,CAAqB,kEAAA,CACrB,kBAAA,CAAoB,6BAAA,CACpB,kBAAA,CAAoB,+BAAA,CACpB,aAAA,CAAe,4CAAA,CACf,WAAA,CAAa,oCACb,kBAAA,CAAoB,kDAAA,CACpB,qBAAA,CAAuB,mDAAA,CACvB,YAAA,CAAc,iCAAA,CACd,iBAAA,CAAmB,mDAAA,CACnB,sBAAA,CAAwB,8EAAA,CACxB,mBAAA,CAAqB,+DAAA,CACrB,qBAAA,CAAuB,wDAAA,CACvB,uBAAA,CAAyB,6CAAA,CACzB,aAAc,8BAAA,CACd,WAAA,CAAa,iDAAA,CACb,oCAAA,CACE,uFAAA,CACF,mBAAA,CA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CACF,CAEO,IAAMC,CAAAA,CAAOH,CAAAA,CAAe,QAASR,CAAI","file":"index.js","sourcesContent":["/**\n * Copyright 2025 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { type Translations } from \"../types\";\n\n// TODO: Should this be required or optional?\nexport const enUS = {\n errors: {\n userNotFound: \"No account found with this email address\",\n wrongPassword: \"Incorrect password\",\n invalidEmail: \"Please enter a valid email address\",\n userDisabled: \"This account has been disabled\",\n networkRequestFailed: \"Unable to connect to the server. Please check your internet connection\",\n tooManyRequests: \"Too many failed attempts. Please try again later\",\n emailAlreadyInUse: \"An account already exists with this email\",\n weakPassword: \"Password should be at least 8 characters\",\n operationNotAllowed: \"Email/password accounts are not enabled. Please contact support.\",\n invalidPhoneNumber: \"The phone number is invalid\",\n missingPhoneNumber: \"Please provide a phone number\",\n quotaExceeded: \"SMS quota exceeded. Please try again later\",\n codeExpired: \"The verification code has expired\",\n captchaCheckFailed: \"reCAPTCHA verification failed. Please try again.\",\n missingVerificationId: \"Please complete the reCAPTCHA verification first.\",\n missingEmail: \"Please provide an email address\",\n invalidActionCode: \"The password reset link is invalid or has expired\",\n credentialAlreadyInUse: \"An account already exists with this email. Please sign in with that account.\",\n requiresRecentLogin: \"This operation requires a recent login. Please sign in again.\",\n providerAlreadyLinked: \"This phone number is already linked to another account\",\n invalidVerificationCode: \"Invalid verification code. Please try again\",\n unknownError: \"An unexpected error occurred\",\n popupClosed: \"The sign-in popup was closed. Please try again.\",\n accountExistsWithDifferentCredential:\n \"An account already exists with this email. Please sign in with the original provider.\",\n displayNameRequired: \"Please provide a display name\",\n secondFactorAlreadyInUse: \"This phone number is already enrolled with this account.\",\n },\n messages: {\n passwordResetEmailSent: \"Password reset email sent successfully\",\n signInLinkSent: \"Sign-in link sent successfully\",\n verificationCodeFirst: \"Please request a verification code first\",\n checkEmailForReset: \"Check your email for password reset instructions\",\n dividerOr: \"or\",\n termsAndPrivacy: \"By continuing, you agree to our {tos} and {privacy}.\",\n },\n labels: {\n emailAddress: \"Email Address\",\n password: \"Password\",\n displayName: \"Display Name\",\n forgotPassword: \"Forgot Password?\",\n signUp: \"Sign Up\",\n signIn: \"Sign In\",\n resetPassword: \"Reset Password\",\n createAccount: \"Create Account\",\n backToSignIn: \"Back to Sign In\",\n signInWithPhone: \"Sign in with Phone\",\n phoneNumber: \"Phone Number\",\n verificationCode: \"Verification Code\",\n sendCode: \"Send Code\",\n verifyCode: \"Verify Code\",\n signInWithGoogle: \"Sign in with Google\",\n signInWithFacebook: \"Sign in with Facebook\",\n signInWithApple: \"Sign in with Apple\",\n signInWithMicrosoft: \"Sign in with Microsoft\",\n signInWithGitHub: \"Sign in with GitHub\",\n signInWithTwitter: \"Sign in with Twitter\",\n signInWithEmailLink: \"Sign in with Email Link\",\n sendSignInLink: \"Send Sign-in Link\",\n termsOfService: \"Terms of Service\",\n privacyPolicy: \"Privacy Policy\",\n resendCode: \"Resend Code\",\n sending: \"Sending...\",\n multiFactorEnrollment: \"Multi-factor Enrollment\",\n mfaTotpVerification: \"TOTP Verification\",\n mfaSmsVerification: \"SMS Verification\",\n generateQrCode: \"Generate QR Code\",\n },\n prompts: {\n noAccount: \"Don't have an account?\",\n haveAccount: \"Already have an account?\",\n enterEmailToReset: \"Enter your email address to reset your password\",\n signInToAccount: \"Sign in to your account\",\n enterDetailsToCreate: \"Enter your details to create a new account\",\n enterPhoneNumber: \"Enter your phone number\",\n enterVerificationCode: \"Enter the verification code\",\n enterEmailForLink: \"Enter your email to receive a sign-in link\",\n mfaEnrollmentPrompt: \"Select a new multi-factor enrollment method\",\n },\n} satisfies Translations;\n","/**\n * Copyright 2025 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { enUS } from \"./locales/en-us\";\nimport { type RegisteredLocale } from \".\";\nimport type { ErrorKey, TranslationCategory, TranslationKey, TranslationSet } from \"./types\";\n\nexport const ERROR_CODE_MAP = {\n \"auth/user-not-found\": \"userNotFound\",\n \"auth/wrong-password\": \"wrongPassword\",\n \"auth/invalid-email\": \"invalidEmail\",\n \"auth/user-disabled\": \"userDisabled\",\n \"auth/network-request-failed\": \"networkRequestFailed\",\n \"auth/too-many-requests\": \"tooManyRequests\",\n \"auth/email-already-in-use\": \"emailAlreadyInUse\",\n \"auth/weak-password\": \"weakPassword\",\n \"auth/operation-not-allowed\": \"operationNotAllowed\",\n \"auth/invalid-phone-number\": \"invalidPhoneNumber\",\n \"auth/missing-phone-number\": \"missingPhoneNumber\",\n \"auth/quota-exceeded\": \"quotaExceeded\",\n \"auth/code-expired\": \"codeExpired\",\n \"auth/captcha-check-failed\": \"captchaCheckFailed\",\n \"auth/missing-verification-id\": \"missingVerificationId\",\n \"auth/missing-email\": \"missingEmail\",\n \"auth/invalid-action-code\": \"invalidActionCode\",\n \"auth/credential-already-in-use\": \"credentialAlreadyInUse\",\n \"auth/requires-recent-login\": \"requiresRecentLogin\",\n \"auth/provider-already-linked\": \"providerAlreadyLinked\",\n \"auth/invalid-verification-code\": \"invalidVerificationCode\",\n \"auth/account-exists-with-different-credential\": \"accountExistsWithDifferentCredential\",\n \"auth/display-name-required\": \"displayNameRequired\",\n \"auth/second-factor-already-in-use\": \"secondFactorAlreadyInUse\",\n} satisfies Record<string, ErrorKey>;\n\nexport type ErrorCode = keyof typeof ERROR_CODE_MAP;\n\nexport function getTranslation<T extends TranslationCategory>(\n locale: RegisteredLocale,\n category: T,\n key: TranslationKey<T>\n): string {\n const userTranslationSet = locale.translations[category] as TranslationSet<T> | undefined;\n const translatedString = userTranslationSet?.[key];\n\n if (translatedString) {\n return translatedString;\n }\n\n // Check fallback locale if it exists\n if (locale.fallback) {\n const fallbackTranslation = getTranslation(locale.fallback, category, key);\n\n if (fallbackTranslation) {\n return fallbackTranslation;\n }\n }\n\n // Fall back to English translations\n const fallbackTranslationSet = enUS[category] as TranslationSet<T>;\n return fallbackTranslationSet[key];\n}\n","/**\n * Copyright 2025 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { enUS } from \"./locales/en-us\";\nimport { type Translations } from \"./types\";\n\nexport type * from \"./types\";\nexport * from \"./mapping\";\n\nexport type Locale = \"en-US\" | `${string}-${string}` | string;\n\nexport function registerLocale(\n locale: Locale,\n translations: Translations,\n fallback?: RegisteredLocale\n): RegisteredLocale {\n return {\n locale,\n translations,\n fallback,\n };\n}\n\nexport const enUs = registerLocale(\"en-US\", enUS);\n\nexport type RegisteredLocale = {\n locale: Locale;\n translations: Translations;\n fallback?: RegisteredLocale;\n};\n"]}
1
+ {"version":3,"sources":["../src/locales/en-us.ts","../src/mapping.ts","../src/index.ts"],"names":["enUS","ERROR_CODE_MAP","getTranslation","locale","category","key","replacements","translatedString","str","fallbackTranslation","match","p1","registerLocale","translations","fallback","enUs"],"mappings":"AAmBO,IAAMA,CAAAA,CAAO,CAClB,MAAA,CAAQ,CACN,aAAc,0CAAA,CACd,aAAA,C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A,CAChC,oBAAA,CAAsB,eACtB,0BAAA,CAA4B,mBAAA,CAC5B,gCAAA,CAAkC,wBAAA,CAClC,6BAA8B,qBAAA,CAC9B,8BAAA,CAAgC,uBAAA,CAChC,gCAAA,CAAkC,0BAClC,+CAAA,CAAiD,sCAAA,CACjD,4BAAA,CAA8B,qBAAA,CAC9B,oCAAqC,0BACvC,EAiBO,SAASC,CAAAA,CACdC,EACAC,CAAAA,CACAC,CAAAA,CACAC,CAAAA,CACQ,CAER,IAAMC,CAAAA,CADqBJ,CAAAA,CAAO,YAAA,CAAaC,CAAQ,IACTC,CAAG,CAAA,CAE7CG,CAAAA,CAEJ,GAAID,EACFC,CAAAA,CAAMD,CAAAA,CAAAA,KAAAA,GACGJ,CAAAA,CAAO,QAAA,CAAU,CAC1B,IAAMM,CAAAA,CAAsBP,CAAAA,CAAeC,CAAAA,CAAO,SAAUC,CAAAA,CAAUC,CAAG,CAAA,CAErEI,CAAAA,GACFD,EAAMC,CAAAA,EAEV,CAAA,KAEED,CAAAA,CAD+BR,CAAAA,CAAKI,CAAQ,CAAA,CACfC,CAAG,CAAA,CAGlC,OAAIC,IACFE,CAAAA,CAAMA,CAAAA,EAAK,OAAA,CAAQ,UAAA,CAAY,CAACE,CAAAA,CAAOC,CAAAA,GAAOL,CAAAA,CAAaK,CAAE,GAAKD,CAAK,CAAA,CAAA,CAGlEF,CAAAA,EAAO,EAChB,CC9DO,SAASI,CAAAA,CACdT,CAAAA,CACAU,CAAAA,CACAC,EACkB,CAClB,OAAO,CACL,MAAA,CAAAX,EACA,YAAA,CAAAU,CAAAA,CACA,QAAA,CAAAC,CACF,CACF,CAGO,IAAMC,CAAAA,CAAOH,CAAAA,CAAe,QAASZ,CAAI","file":"index.js","sourcesContent":["/**\n * Copyright 2025 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { type Translations } from \"../types\";\n\n/** English US (en-US) translation set with all default translations. */\nexport const enUS = {\n errors: {\n userNotFound: \"No account found with this email address\",\n wrongPassword: \"Incorrect password\",\n invalidEmail: \"Please enter a valid email address\",\n userDisabled: \"This account has been disabled\",\n networkRequestFailed: \"Unable to connect to the server. Please check your internet connection\",\n tooManyRequests: \"Too many failed attempts. Please try again later\",\n missingVerificationCode: \"Please enter the verification code\",\n emailAlreadyInUse: \"An account already exists with this email\",\n invalidCredential: \"The provided credentials are invalid.\",\n weakPassword: \"Password should be at least 8 characters\",\n unverifiedEmail: \"Please verify your email address to continue.\",\n operationNotAllowed: \"This operation is not allowed. Please contact support.\",\n invalidPhoneNumber: \"The phone number is invalid\",\n missingPhoneNumber: \"Please provide a phone number\",\n quotaExceeded: \"SMS quota exceeded. Please try again later\",\n codeExpired: \"The verification code has expired\",\n captchaCheckFailed: \"reCAPTCHA verification failed. Please try again.\",\n missingVerificationId: \"Please complete the reCAPTCHA verification first.\",\n missingEmail: \"Please provide an email address\",\n invalidActionCode: \"The password reset link is invalid or has expired\",\n credentialAlreadyInUse: \"An account already exists with this email. Please sign in with that account.\",\n requiresRecentLogin: \"This operation requires a recent login. Please sign in again.\",\n providerAlreadyLinked: \"This phone number is already linked to another account\",\n invalidVerificationCode: \"Invalid verification code. Please try again\",\n unknownError: \"An unexpected error occurred\",\n popupClosed: \"The sign-in popup was closed. Please try again.\",\n accountExistsWithDifferentCredential:\n \"An account already exists with this email. Please sign in with the original provider.\",\n displayNameRequired: \"Please provide a display name\",\n secondFactorAlreadyInUse: \"This phone number is already enrolled with this account.\",\n },\n messages: {\n passwordResetEmailSent: \"Password reset email sent successfully\",\n signInLinkSent: \"Sign-in link sent successfully\",\n verificationCodeFirst: \"Please request a verification code first\",\n checkEmailForReset: \"Check your email for password reset instructions\",\n dividerOr: \"or\",\n termsAndPrivacy: \"By continuing, you agree to our {tos} and {privacy}.\",\n mfaSmsAssertionPrompt: \"A verification code will be sent to {phoneNumber} to complete the authentication process.\",\n },\n labels: {\n emailAddress: \"Email Address\",\n password: \"Password\",\n displayName: \"Display Name\",\n forgotPassword: \"Forgot Password?\",\n signUp: \"Sign Up\",\n signIn: \"Sign In\",\n resetPassword: \"Reset Password\",\n createAccount: \"Create Account\",\n backToSignIn: \"Back to Sign In\",\n signInWithPhone: \"Sign in with Phone\",\n phoneNumber: \"Phone Number\",\n verificationCode: \"Verification Code\",\n sendCode: \"Send Code\",\n verifyCode: \"Verify Code\",\n signInWithGoogle: \"Sign in with Google\",\n signInWithFacebook: \"Sign in with Facebook\",\n signInWithApple: \"Sign in with Apple\",\n signInWithMicrosoft: \"Sign in with Microsoft\",\n signInWithGitHub: \"Sign in with GitHub\",\n signInWithTwitter: \"Sign in with X\",\n signInWithEmailLink: \"Sign in with Email Link\",\n sendSignInLink: \"Send Sign-in Link\",\n termsOfService: \"Terms of Service\",\n privacyPolicy: \"Privacy Policy\",\n resendCode: \"Resend Code\",\n sending: \"Sending...\",\n multiFactorEnrollment: \"Multi-factor Enrollment\",\n multiFactorAssertion: \"Multi-factor Authentication\",\n mfaTotpVerification: \"TOTP Verification\",\n mfaSmsVerification: \"SMS Verification\",\n generateQrCode: \"Generate QR Code\",\n },\n prompts: {\n noAccount: \"Don't have an account?\",\n haveAccount: \"Already have an account?\",\n enterEmailToReset: \"Enter your email address to reset your password\",\n signInToAccount: \"Sign in to your account\",\n smsVerificationPrompt: \"Enter the verification code sent to your phone number\",\n enterDetailsToCreate: \"Enter your details to create a new account\",\n enterPhoneNumber: \"Enter your phone number\",\n enterVerificationCode: \"Enter the verification code\",\n enterEmailForLink: \"Enter your email to receive a sign-in link\",\n mfaEnrollmentPrompt: \"Select a new multi-factor enrollment method\",\n mfaAssertionPrompt: \"Please complete the multi-factor authentication process\",\n mfaAssertionFactorPrompt: \"Please choose a multi-factor authentication method\",\n mfaTotpQrCodePrompt: \"Scan this QR code with your authenticator app\",\n mfaTotpEnrollmentVerificationPrompt: \"Add the code generated by your authenticator app\",\n },\n} satisfies Translations;\n","/**\n * Copyright 2025 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { enUS } from \"./locales/en-us\";\nimport { type RegisteredLocale } from \".\";\nimport type { ErrorKey, TranslationCategory, TranslationKey, TranslationSet } from \"./types\";\n\n/** Maps Firebase authentication error codes to translation keys. */\nexport const ERROR_CODE_MAP = {\n \"auth/user-not-found\": \"userNotFound\",\n \"auth/wrong-password\": \"wrongPassword\",\n \"auth/invalid-email\": \"invalidEmail\",\n \"auth/unverified-email\": \"unverifiedEmail\",\n \"auth/user-disabled\": \"userDisabled\",\n \"auth/missing-code\": \"missingVerificationCode\",\n \"auth/invalid-credential\": \"invalidCredential\",\n \"auth/network-request-failed\": \"networkRequestFailed\",\n \"auth/too-many-requests\": \"tooManyRequests\",\n \"auth/email-already-in-use\": \"emailAlreadyInUse\",\n \"auth/weak-password\": \"weakPassword\",\n \"auth/operation-not-allowed\": \"operationNotAllowed\",\n \"auth/invalid-phone-number\": \"invalidPhoneNumber\",\n \"auth/missing-phone-number\": \"missingPhoneNumber\",\n \"auth/quota-exceeded\": \"quotaExceeded\",\n \"auth/code-expired\": \"codeExpired\",\n \"auth/captcha-check-failed\": \"captchaCheckFailed\",\n \"auth/missing-verification-id\": \"missingVerificationId\",\n \"auth/missing-email\": \"missingEmail\",\n \"auth/invalid-action-code\": \"invalidActionCode\",\n \"auth/credential-already-in-use\": \"credentialAlreadyInUse\",\n \"auth/requires-recent-login\": \"requiresRecentLogin\",\n \"auth/provider-already-linked\": \"providerAlreadyLinked\",\n \"auth/invalid-verification-code\": \"invalidVerificationCode\",\n \"auth/account-exists-with-different-credential\": \"accountExistsWithDifferentCredential\",\n \"auth/display-name-required\": \"displayNameRequired\",\n \"auth/second-factor-already-in-use\": \"secondFactorAlreadyInUse\",\n} satisfies Record<string, ErrorKey>;\n\n/** Firebase authentication error code type. */\nexport type ErrorCode = keyof typeof ERROR_CODE_MAP;\n\n/**\n * Retrieves a translation string for a given locale, category, and key.\n *\n * Falls back to the locale's fallback locale or English US if the translation is not found.\n * Supports string replacements using {placeholder} syntax.\n *\n * @param locale - The registered locale to get the translation from.\n * @param category - The translation category (e.g., \"errors\", \"labels\").\n * @param key - The translation key within the category.\n * @param replacements - Optional object with replacement values for placeholders in the translation string.\n * @returns The translated string, or an empty string if not found.\n */\nexport function getTranslation<T extends TranslationCategory>(\n locale: RegisteredLocale,\n category: T,\n key: TranslationKey<T>,\n replacements?: Record<string, string>\n): string {\n const userTranslationSet = locale.translations[category] as TranslationSet<T> | undefined;\n const translatedString = userTranslationSet?.[key];\n\n let str: string | undefined;\n\n if (translatedString) {\n str = translatedString;\n } else if (locale.fallback) {\n const fallbackTranslation = getTranslation(locale.fallback, category, key);\n\n if (fallbackTranslation) {\n str = fallbackTranslation;\n }\n } else {\n const fallbackTranslationSet = enUS[category] as TranslationSet<T>;\n str = fallbackTranslationSet[key];\n }\n\n if (replacements) {\n str = str?.replace(/{(\\w+)}/g, (match, p1) => replacements[p1] || match);\n }\n\n return str || \"\";\n}\n","/**\n * Copyright 2025 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { enUS } from \"./locales/en-us\";\nimport { type Translations } from \"./types\";\n\nexport type * from \"./types\";\nexport * from \"./mapping\";\n\n/** Locale identifier string. Supports BCP 47 format (e.g., \"en-US\") or any string. */\nexport type Locale = \"en-US\" | `${string}-${string}` | string;\n\n/**\n * Registers a locale with its translations and optional fallback locale.\n *\n * @param locale - The locale identifier (e.g., \"en-US\", \"fr-FR\").\n * @param translations - The translation object for this locale.\n * @param fallback - Optional fallback locale to use when a translation is missing.\n * @returns A registered locale object.\n */\nexport function registerLocale(\n locale: Locale,\n translations: Translations,\n fallback?: RegisteredLocale\n): RegisteredLocale {\n return {\n locale,\n translations,\n fallback,\n };\n}\n\n/** Pre-registered English US locale with default translations. */\nexport const enUs = registerLocale(\"en-US\", enUS);\n\n/** A registered locale with its translations and optional fallback. */\nexport type RegisteredLocale = {\n /** The locale identifier. */\n locale: Locale;\n /** The translation object for this locale. */\n translations: Translations;\n /** Optional fallback locale to use when a translation is missing. */\n fallback?: RegisteredLocale;\n};\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@firebase-oss/ui-translations",
3
- "version": "0.0.1",
3
+ "version": "0.0.2-exp.ed61394",
4
4
  "description": "Translations for Firebase UI",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -26,7 +26,9 @@
26
26
  "clean": "rimraf dist",
27
27
  "test": "vitest run",
28
28
  "test:watch": "vitest",
29
+ "version:bump": "pnpm version patch",
29
30
  "publish:tags": "sh -c 'TAG=\"${npm_package_name}@${npm_package_version}\"; git tag --list \"$TAG\" | grep . || git tag \"$TAG\"; git push origin \"$TAG\"'",
31
+ "publish:npm": "../../publish.sh",
30
32
  "release": "npm run build && pnpm pack --pack-destination ../../releases/"
31
33
  },
32
34
  "devDependencies": {