@edgestore/react 0.1.5-alpha.10 → 0.1.5-alpha.13

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.
@@ -1 +1 @@
1
- {"version":3,"file":"contextProvider.d.ts","sourceRoot":"","sources":["../src/contextProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAmB,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAO1E,KAAK,qBAAqB,CAAC,OAAO,SAAS,SAAS,IAAI;IACtD,SAAS,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC;IACpC;;;;;OAKG;IACH,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B;;;;;OAKG;IACH,KAAK,EAAE,aAAa,CAAC;CACtB,CAAC;AAEF,wBAAgB,uBAAuB,CAAC,OAAO,SAAS,SAAS,EAAE,IAAI,CAAC,EAAE;IACxE;;;;;;OAMG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;;kBASa,MAAM,SAAS;QACzB;;;;;;WAMG;;;;EAgCN;AAED,KAAK,aAAa,GACd;IACE,OAAO,EAAE,IAAI,CAAC;IACd,WAAW,EAAE,KAAK,CAAC;IACnB,KAAK,EAAE,KAAK,CAAC;CACd,GACD;IACE,OAAO,EAAE,KAAK,CAAC;IACf,WAAW,EAAE,KAAK,CAAC;IACnB,KAAK,EAAE,IAAI,CAAC;CACb,GACD;IACE,OAAO,EAAE,KAAK,CAAC;IACf,WAAW,EAAE,IAAI,CAAC;IAClB,KAAK,EAAE,KAAK,CAAC;CACd,CAAC"}
1
+ {"version":3,"file":"contextProvider.d.ts","sourceRoot":"","sources":["../src/contextProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAmB,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAU1E,KAAK,qBAAqB,CAAC,OAAO,SAAS,SAAS,IAAI;IACtD,SAAS,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC;IACpC;;;;;OAKG;IACH,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B;;;;;OAKG;IACH,KAAK,EAAE,aAAa,CAAC;CACtB,CAAC;AAEF,wBAAgB,uBAAuB,CAAC,OAAO,SAAS,SAAS,EAAE,IAAI,CAAC,EAAE;IACxE;;;;;;OAMG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;;kBASa,MAAM,SAAS;QACzB;;;;;;WAMG;;;;EAgCN;AAED,KAAK,aAAa,GACd;IACE,OAAO,EAAE,IAAI,CAAC;IACd,WAAW,EAAE,KAAK,CAAC;IACnB,KAAK,EAAE,KAAK,CAAC;CACd,GACD;IACE,OAAO,EAAE,KAAK,CAAC;IACf,WAAW,EAAE,KAAK,CAAC;IACnB,KAAK,EAAE,IAAI,CAAC;CACb,GACD;IACE,OAAO,EAAE,KAAK,CAAC;IACf,WAAW,EAAE,IAAI,CAAC;IAClB,KAAK,EAAE,KAAK,CAAC;CACd,CAAC"}
package/dist/index.js CHANGED
@@ -145,7 +145,8 @@ async function uploadFile({ file, input, onProgressChange, options }, { apiPath,
145
145
  * Since third party cookies doesn't work on localhost,
146
146
  * we need to proxy the file through the server.
147
147
  */ function getUrl(url, apiPath) {
148
- if (process.env.NODE_ENV === 'development' && !url.includes('/_public/')) {
148
+ const mode = process !== undefined ? process.env.NODE_ENV : undefined?.DEV ? 'development' : 'production';
149
+ if (mode === 'development' && !url.includes('/_public/')) {
149
150
  const proxyUrl = new URL(window.location.origin);
150
151
  proxyUrl.pathname = `${apiPath}/proxy-file`;
151
152
  proxyUrl.search = new URLSearchParams({
@@ -310,7 +311,7 @@ async function queuedPromises({ items, fn, maxParallel, maxRetries = 0 }) {
310
311
  return results;
311
312
  }
312
313
 
313
- const DEFAULT_BASE_URL = process.env.NEXT_PUBLIC_EDGE_STORE_BASE_URL ?? 'https://files.edgestore.dev';
314
+ const DEFAULT_BASE_URL = (process !== undefined ? process.env.NEXT_PUBLIC_EDGE_STORE_BASE_URL : undefined?.EDGE_STORE_BASE_URL) ?? 'https://files.edgestore.dev';
314
315
  function createEdgeStoreProvider(opts) {
315
316
  const EdgeStoreContext = /*#__PURE__*/ React__namespace.createContext(undefined);
316
317
  const EdgeStoreProvider = ({ children, basePath })=>{
package/dist/index.mjs CHANGED
@@ -121,7 +121,8 @@ async function uploadFile({ file, input, onProgressChange, options }, { apiPath,
121
121
  * Since third party cookies doesn't work on localhost,
122
122
  * we need to proxy the file through the server.
123
123
  */ function getUrl(url, apiPath) {
124
- if (process.env.NODE_ENV === 'development' && !url.includes('/_public/')) {
124
+ const mode = process !== undefined ? process.env.NODE_ENV : import.meta.env?.DEV ? 'development' : 'production';
125
+ if (mode === 'development' && !url.includes('/_public/')) {
125
126
  const proxyUrl = new URL(window.location.origin);
126
127
  proxyUrl.pathname = `${apiPath}/proxy-file`;
127
128
  proxyUrl.search = new URLSearchParams({
@@ -286,7 +287,7 @@ async function queuedPromises({ items, fn, maxParallel, maxRetries = 0 }) {
286
287
  return results;
287
288
  }
288
289
 
289
- const DEFAULT_BASE_URL = process.env.NEXT_PUBLIC_EDGE_STORE_BASE_URL ?? 'https://files.edgestore.dev';
290
+ const DEFAULT_BASE_URL = (process !== undefined ? process.env.NEXT_PUBLIC_EDGE_STORE_BASE_URL : import.meta.env?.EDGE_STORE_BASE_URL) ?? 'https://files.edgestore.dev';
290
291
  function createEdgeStoreProvider(opts) {
291
292
  const EdgeStoreContext = /*#__PURE__*/ React.createContext(undefined);
292
293
  const EdgeStoreProvider = ({ children, basePath })=>{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edgestore/react",
3
- "version": "0.1.5-alpha.10",
3
+ "version": "0.1.5-alpha.13",
4
4
  "description": "Upload files with ease from React/Next.js",
5
5
  "homepage": "https://edgestore.dev",
6
6
  "repository": "https://github.com/edgestorejs/edgestore.git",
@@ -60,14 +60,14 @@
60
60
  "uuid": "^9.0.0"
61
61
  },
62
62
  "peerDependencies": {
63
- "@edgestore/server": "0.1.5-alpha.10",
63
+ "@edgestore/server": "0.1.5-alpha.13",
64
64
  "next": "*",
65
65
  "react": ">=16.8.0",
66
66
  "react-dom": ">=16.8.0",
67
67
  "zod": ">=3.0.0"
68
68
  },
69
69
  "devDependencies": {
70
- "@edgestore/server": "0.1.5-alpha.10",
70
+ "@edgestore/server": "0.1.5-alpha.13",
71
71
  "@types/cookie": "^0.5.1",
72
72
  "@types/node": "^18.11.18",
73
73
  "@types/uuid": "^9.0.1",
@@ -77,5 +77,5 @@
77
77
  "typescript": "^5.1.6",
78
78
  "zod": "^3.21.4"
79
79
  },
80
- "gitHead": "6cf9f5bbea5c1cf990b8b8caa70bc4341e046e59"
80
+ "gitHead": "64bc4bbb47d646747a5e0bd9ed15032430ee408d"
81
81
  }
@@ -5,7 +5,10 @@ import EdgeStoreClientError from './libs/errors/EdgeStoreClientError';
5
5
  import { handleError } from './libs/errors/handleError';
6
6
 
7
7
  const DEFAULT_BASE_URL =
8
- process.env.NEXT_PUBLIC_EDGE_STORE_BASE_URL ?? 'https://files.edgestore.dev';
8
+ (process !== undefined
9
+ ? process.env.NEXT_PUBLIC_EDGE_STORE_BASE_URL
10
+ : // @ts-expect-error - In Vite, the env variables are available on `import.meta`.
11
+ import.meta.env?.EDGE_STORE_BASE_URL) ?? 'https://files.edgestore.dev';
9
12
 
10
13
  type EdgeStoreContextValue<TRouter extends AnyRouter> = {
11
14
  edgestore: BucketFunctions<TRouter>;
@@ -201,7 +201,14 @@ async function uploadFile(
201
201
  * we need to proxy the file through the server.
202
202
  */
203
203
  function getUrl(url: string, apiPath: string) {
204
- if (process.env.NODE_ENV === 'development' && !url.includes('/_public/')) {
204
+ const mode =
205
+ process !== undefined
206
+ ? process.env.NODE_ENV
207
+ : // @ts-expect-error - DEV is injected by Vite
208
+ import.meta.env?.DEV
209
+ ? 'development'
210
+ : 'production';
211
+ if (mode === 'development' && !url.includes('/_public/')) {
205
212
  const proxyUrl = new URL(window.location.origin);
206
213
  proxyUrl.pathname = `${apiPath}/proxy-file`;
207
214
  proxyUrl.search = new URLSearchParams({