@zachhandley/ez-i18n 0.3.13 → 0.3.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +11 -18
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -896,31 +896,24 @@ function __deepMerge(target, ...sources) {
896
896
  function getPublicLoaderCode() {
897
897
  return `
898
898
  async function __loadPublicJson(url, absolutePath) {
899
- // Browser environment - use fetch with relative URL
899
+ // Browser - use fetch with relative URL
900
900
  if (typeof window !== 'undefined') {
901
901
  return fetch(url).then(r => r.json());
902
902
  }
903
903
 
904
- // Edge runtime detection (Cloudflare Workers, Vercel Edge, Deno, etc.)
905
- // These environments have fetch but no filesystem access
906
- const isEdgeRuntime = typeof globalThis.caches !== 'undefined' || // CF Workers / Service Workers
907
- typeof globalThis.EdgeRuntime !== 'undefined' || // Vercel Edge
908
- typeof Deno !== 'undefined' || // Deno
909
- !globalThis.process?.versions?.node; // No Node.js process
904
+ // Get origin from Astro site config or middleware-set value
905
+ const origin = import.meta.env.SITE?.replace(/\\/$/, '') ||
906
+ globalThis.__EZ_I18N_ORIGIN__ ||
907
+ '';
910
908
 
911
- if (isEdgeRuntime) {
912
- // Edge runtime - need absolute URL for fetch
913
- // Priority: Astro site config > middleware-set origin > relative (hope for the best)
914
- const origin = import.meta.env.SITE?.replace(/\\/$/, '') ||
915
- globalThis.__EZ_I18N_ORIGIN__ ||
916
- '';
917
- const fetchUrl = origin ? origin + url : url;
918
- return fetch(fetchUrl).then(r => r.json());
909
+ // If we have an origin, use fetch (works in CF Workers, Vercel Edge, etc.)
910
+ if (origin) {
911
+ return fetch(origin + url).then(r => r.json());
919
912
  }
920
913
 
921
- // Traditional Node.js SSR - read from filesystem
922
- const fs = await import('node:fs');
923
- const content = fs.readFileSync(absolutePath, 'utf-8');
914
+ // No origin - try filesystem (traditional Node.js SSR)
915
+ const { readFileSync } = await import('node:fs');
916
+ const content = readFileSync(absolutePath, 'utf-8');
924
917
  return JSON.parse(content);
925
918
  }`;
926
919
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zachhandley/ez-i18n",
3
- "version": "0.3.13",
3
+ "version": "0.3.14",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },