@jgb-solutions/kit 0.4.1 → 0.4.3

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/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  All notable changes to `@jgb-solutions/kit`. Versions follow semver.
4
4
 
5
+ ## 0.4.3
6
+
7
+ - `@jgb-solutions/kit/i18n`: `defaultLocaleRedirect(path)` gives the unprefixed address for a path that spells out English (`/en/privacy?x=1` → `/privacy?x=1`, `/en` → `/`), for the site's 301; null for every other path.
8
+
9
+ ## 0.4.2
10
+
11
+ - Dependency update: `jose` 6.2.18 to 6.2.19 (patch).
12
+
5
13
  ## 0.4.1
6
14
 
7
15
  - `toAuthUser` adds `createdAt` (ISO 8601) when the session's user has it, for a "Member since" line on account screens. Better Auth sends a `Date` on the server and a string once serialized; both are accepted, and an invalid or missing value leaves `createdAt` out. `AuthUser.createdAt` is optional, so code that builds an `AuthUser` by hand keeps compiling.
package/README.md CHANGED
@@ -184,7 +184,7 @@ const offer = suggestLocale({ acceptLanguage: request.headers.get('accept-langua
184
184
  // null: no bar. 'es': show "View this page in Español?", and on a click set the LOCALE_COOKIE cookie and go to localizedPath(path, 'es').
185
185
  ```
186
186
 
187
- Also: `localeFromPath`, `stripLocale`, `isLocale`, `negotiate`, `LOCALES`, `LOCALE_NAMES` (each language in its own words). Placeholders are `{name}`; a plural leaf has `one` and `other` (plus `zero`, `two`, `few`, `many` where a language needs them) and takes `count`. Keep the catalogs honest in a test with `checkCatalog(en, fr)`: it lists missing and extra keys, empty strings, plurals without `other`, and placeholders that differ from English.
187
+ Also: `localeFromPath`, `stripLocale`, `defaultLocaleRedirect` (the 301 target for an `/en/…` address), `isLocale`, `negotiate`, `LOCALES`, `LOCALE_NAMES` (each language in its own words). Placeholders are `{name}`; a plural leaf has `one` and `other` (plus `zero`, `two`, `few`, `many` where a language needs them) and takes `count`. Keep the catalogs honest in a test with `checkCatalog(en, fr)`: it lists missing and extra keys, empty strings, plurals without `other`, and placeholders that differ from English.
188
188
 
189
189
  ### `@jgb-solutions/kit/admin`: the admin panel (React 19)
190
190
 
package/dist/i18n.d.ts CHANGED
@@ -18,6 +18,12 @@ export declare function isLocale(value: unknown): value is Locale;
18
18
  export declare function localeFromPath(path: string): Locale;
19
19
  /** The path without its /fr, /es or /ht prefix (query and hash kept). Always starts with "/". */
20
20
  export declare function stripLocale(path: string): string;
21
+ /**
22
+ * Where an address that spells out English should go: "/en/privacy?x=1" → "/privacy?x=1", "/en" → "/".
23
+ * English has no prefix, so a site answers /en/… with a 301 to this address. Null for every other
24
+ * path ("/fr/a", "/english", "/"), which needs no redirect.
25
+ */
26
+ export declare function defaultLocaleRedirect(path: string): string | null;
21
27
  /** The path in another language: any prefix is replaced; English has none. Query and hash kept. */
22
28
  export declare function localizedPath(path: string, locale: Locale): string;
23
29
  /** hreflang alternates for a page's <head>: one per language, then x-default (English). */
package/dist/i18n.js CHANGED
@@ -34,6 +34,12 @@ function stripLocale(path) {
34
34
  return pathname + rest;
35
35
  return (pathname.slice(segment.length + 1) || "/") + rest;
36
36
  }
37
+ function defaultLocaleRedirect(path) {
38
+ const { pathname, rest } = splitPath(path);
39
+ if (firstSegment(pathname) !== DEFAULT_LOCALE)
40
+ return null;
41
+ return (pathname.slice(DEFAULT_LOCALE.length + 1) || "/") + rest;
42
+ }
37
43
  function localizedPath(path, locale) {
38
44
  const stripped = stripLocale(path);
39
45
  if (locale === DEFAULT_LOCALE)
@@ -208,6 +214,7 @@ export {
208
214
  alternates,
209
215
  checkCatalog,
210
216
  createTranslator,
217
+ defaultLocaleRedirect,
211
218
  defineCatalog,
212
219
  isLocale,
213
220
  localeFromPath,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jgb-solutions/kit",
3
- "version": "0.4.1",
3
+ "version": "0.4.3",
4
4
  "description": "One package for JGB Solutions apps, in tree-shakable namespaces: Cloudflare Access, Better Auth (kit/access, kit/auth\u2026) and the admin panel kit (kit/admin, React 19). An app bundles only the subpaths it imports.",
5
5
  "license": "MIT",
6
6
  "author": "JGB Solutions",
@@ -94,7 +94,7 @@
94
94
  "screenshots": "bun --bun playwright test e2e/screenshots.spec.ts"
95
95
  },
96
96
  "dependencies": {
97
- "jose": "6.2.18"
97
+ "jose": "6.2.19"
98
98
  },
99
99
  "peerDependencies": {
100
100
  "better-auth": ">=1.7.22 <2",
@@ -121,14 +121,14 @@
121
121
  }
122
122
  },
123
123
  "devDependencies": {
124
- "@axe-core/playwright": "4.14.0",
125
- "@better-auth/passkey": "1.7.27",
126
- "@orpc/server": "2.0.0-beta.52",
127
- "@playwright/test": "1.64.1",
124
+ "@axe-core/playwright": "4.14.1",
125
+ "@better-auth/passkey": "1.7.29",
126
+ "@orpc/server": "2.0.0-beta.53",
127
+ "@playwright/test": "1.65.1",
128
128
  "@types/bun": "1.4.5",
129
- "@types/react": "19.3.0",
129
+ "@types/react": "19.3.3",
130
130
  "@types/react-dom": "19.3.0",
131
- "better-auth": "1.7.27",
131
+ "better-auth": "1.7.29",
132
132
  "react": "19.3.1",
133
133
  "react-dom": "19.3.1",
134
134
  "typescript": "6.0.3"