@edgestore/react 0.1.5-alpha.16 → 0.1.5-alpha.18

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.js CHANGED
@@ -92,6 +92,7 @@ async function uploadFile({ file, input, onProgressChange, options }, { apiPath,
92
92
  onProgressChange?.(0);
93
93
  const res = await fetch(`${apiPath}/request-upload`, {
94
94
  method: 'POST',
95
+ credentials: 'include',
95
96
  body: JSON.stringify({
96
97
  bucketName,
97
98
  input,
@@ -146,7 +147,7 @@ async function uploadFile({ file, input, onProgressChange, options }, { apiPath,
146
147
  * Since third party cookies doesn't work on localhost,
147
148
  * we need to proxy the file through the server.
148
149
  */ function getUrl(url, apiPath) {
149
- const mode = process !== undefined ? process.env.NODE_ENV : undefined?.DEV ? 'development' : 'production';
150
+ const mode = typeof process !== 'undefined' ? process.env.NODE_ENV : undefined?.DEV ? 'development' : 'production';
150
151
  if (mode === 'development' && !url.includes('/_public/')) {
151
152
  const proxyUrl = new URL(window.location.origin);
152
153
  proxyUrl.pathname = `${apiPath}/proxy-file`;
@@ -228,6 +229,7 @@ async function multipartUpload(params) {
228
229
  // Complete multipart upload
229
230
  const res = await fetch(`${apiPath}/complete-multipart-upload`, {
230
231
  method: 'POST',
232
+ credentials: 'include',
231
233
  body: JSON.stringify({
232
234
  bucketName,
233
235
  uploadId,
@@ -245,6 +247,7 @@ async function multipartUpload(params) {
245
247
  async function confirmUpload({ url }, { apiPath, bucketName }) {
246
248
  const res = await fetch(`${apiPath}/confirm-upload`, {
247
249
  method: 'POST',
250
+ credentials: 'include',
248
251
  body: JSON.stringify({
249
252
  url,
250
253
  bucketName
@@ -261,6 +264,7 @@ async function confirmUpload({ url }, { apiPath, bucketName }) {
261
264
  async function deleteFile({ url }, { apiPath, bucketName }) {
262
265
  const res = await fetch(`${apiPath}/delete-file`, {
263
266
  method: 'POST',
267
+ credentials: 'include',
264
268
  body: JSON.stringify({
265
269
  url,
266
270
  bucketName
@@ -312,7 +316,7 @@ async function queuedPromises({ items, fn, maxParallel, maxRetries = 0 }) {
312
316
  return results;
313
317
  }
314
318
 
315
- const DEFAULT_BASE_URL = (process !== undefined ? process.env.NEXT_PUBLIC_EDGE_STORE_BASE_URL : undefined?.EDGE_STORE_BASE_URL) ?? 'https://files.edgestore.dev';
319
+ const DEFAULT_BASE_URL = (typeof process !== 'undefined' ? process.env.NEXT_PUBLIC_EDGE_STORE_BASE_URL : undefined?.EDGE_STORE_BASE_URL) ?? 'https://files.edgestore.dev';
316
320
  function createEdgeStoreProvider(opts) {
317
321
  const EdgeStoreContext = /*#__PURE__*/ React__namespace.createContext(undefined);
318
322
  const EdgeStoreProvider = ({ children, basePath })=>{
@@ -365,7 +369,8 @@ function EdgeStoreProviderInner({ children, context, basePath, maxConcurrentUplo
365
369
  error: false
366
370
  });
367
371
  const res = await fetch(`${apiPath}/init`, {
368
- method: 'POST'
372
+ method: 'POST',
373
+ credentials: 'include'
369
374
  });
370
375
  if (res.ok) {
371
376
  const json = await res.json();
package/dist/index.mjs CHANGED
@@ -68,6 +68,7 @@ async function uploadFile({ file, input, onProgressChange, options }, { apiPath,
68
68
  onProgressChange?.(0);
69
69
  const res = await fetch(`${apiPath}/request-upload`, {
70
70
  method: 'POST',
71
+ credentials: 'include',
71
72
  body: JSON.stringify({
72
73
  bucketName,
73
74
  input,
@@ -122,7 +123,7 @@ async function uploadFile({ file, input, onProgressChange, options }, { apiPath,
122
123
  * Since third party cookies doesn't work on localhost,
123
124
  * we need to proxy the file through the server.
124
125
  */ function getUrl(url, apiPath) {
125
- const mode = process !== undefined ? process.env.NODE_ENV : import.meta.env?.DEV ? 'development' : 'production';
126
+ const mode = typeof process !== 'undefined' ? process.env.NODE_ENV : import.meta.env?.DEV ? 'development' : 'production';
126
127
  if (mode === 'development' && !url.includes('/_public/')) {
127
128
  const proxyUrl = new URL(window.location.origin);
128
129
  proxyUrl.pathname = `${apiPath}/proxy-file`;
@@ -204,6 +205,7 @@ async function multipartUpload(params) {
204
205
  // Complete multipart upload
205
206
  const res = await fetch(`${apiPath}/complete-multipart-upload`, {
206
207
  method: 'POST',
208
+ credentials: 'include',
207
209
  body: JSON.stringify({
208
210
  bucketName,
209
211
  uploadId,
@@ -221,6 +223,7 @@ async function multipartUpload(params) {
221
223
  async function confirmUpload({ url }, { apiPath, bucketName }) {
222
224
  const res = await fetch(`${apiPath}/confirm-upload`, {
223
225
  method: 'POST',
226
+ credentials: 'include',
224
227
  body: JSON.stringify({
225
228
  url,
226
229
  bucketName
@@ -237,6 +240,7 @@ async function confirmUpload({ url }, { apiPath, bucketName }) {
237
240
  async function deleteFile({ url }, { apiPath, bucketName }) {
238
241
  const res = await fetch(`${apiPath}/delete-file`, {
239
242
  method: 'POST',
243
+ credentials: 'include',
240
244
  body: JSON.stringify({
241
245
  url,
242
246
  bucketName
@@ -288,7 +292,7 @@ async function queuedPromises({ items, fn, maxParallel, maxRetries = 0 }) {
288
292
  return results;
289
293
  }
290
294
 
291
- 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';
295
+ const DEFAULT_BASE_URL = (typeof process !== 'undefined' ? process.env.NEXT_PUBLIC_EDGE_STORE_BASE_URL : import.meta.env?.EDGE_STORE_BASE_URL) ?? 'https://files.edgestore.dev';
292
296
  function createEdgeStoreProvider(opts) {
293
297
  const EdgeStoreContext = /*#__PURE__*/ React.createContext(undefined);
294
298
  const EdgeStoreProvider = ({ children, basePath })=>{
@@ -341,7 +345,8 @@ function EdgeStoreProviderInner({ children, context, basePath, maxConcurrentUplo
341
345
  error: false
342
346
  });
343
347
  const res = await fetch(`${apiPath}/init`, {
344
- method: 'POST'
348
+ method: 'POST',
349
+ credentials: 'include'
345
350
  });
346
351
  if (res.ok) {
347
352
  const json = await res.json();
@@ -0,0 +1,2 @@
1
+ export { EdgeStoreApiClientError } from '@edgestore/shared';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/shared/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var shared = require('@edgestore/shared');
6
+
7
+
8
+
9
+ Object.defineProperty(exports, 'EdgeStoreApiClientError', {
10
+ enumerable: true,
11
+ get: function () { return shared.EdgeStoreApiClientError; }
12
+ });
@@ -0,0 +1 @@
1
+ export { EdgeStoreApiClientError } from '@edgestore/shared';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edgestore/react",
3
- "version": "0.1.5-alpha.16",
3
+ "version": "0.1.5-alpha.18",
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",
@@ -36,6 +36,11 @@
36
36
  "import": "./dist/utils/index.mjs",
37
37
  "require": "./dist/utils/index.js",
38
38
  "default": "./dist/utils/index.js"
39
+ },
40
+ "./shared": {
41
+ "import": "./dist/shared/index.mjs",
42
+ "require": "./dist/shared/index.js",
43
+ "default": "./dist/shared/index.js"
39
44
  }
40
45
  },
41
46
  "files": [
@@ -44,6 +49,7 @@
44
49
  "README.md",
45
50
  "package.json",
46
51
  "utils",
52
+ "shared",
47
53
  "!**/*.test.*"
48
54
  ],
49
55
  "private": false,
@@ -60,14 +66,15 @@
60
66
  "uuid": "^9.0.0"
61
67
  },
62
68
  "peerDependencies": {
63
- "@edgestore/shared": "0.1.5-alpha.16",
69
+ "@edgestore/shared": "0.1.5-alpha.18",
64
70
  "next": "*",
65
71
  "react": ">=16.8.0",
66
72
  "react-dom": ">=16.8.0",
67
73
  "zod": ">=3.0.0"
68
74
  },
69
75
  "devDependencies": {
70
- "@edgestore/shared": "0.1.5-alpha.16",
76
+ "@edgestore/shared": "0.1.5-alpha.18",
77
+ "@swc/helpers": "0.5.3",
71
78
  "@types/cookie": "^0.5.1",
72
79
  "@types/node": "^18.11.18",
73
80
  "@types/uuid": "^9.0.1",
@@ -77,5 +84,5 @@
77
84
  "typescript": "^5.1.6",
78
85
  "zod": "3.21.4"
79
86
  },
80
- "gitHead": "2f11a326b8412df19c375a75f1f8a329b6b9287b"
87
+ "gitHead": "10109dd7d4eadae627e0ebb2078be0c910a2dfae"
81
88
  }
@@ -0,0 +1 @@
1
+ export * from '../dist/shared';
@@ -0,0 +1 @@
1
+ module.exports = require('../dist/shared');
@@ -5,7 +5,7 @@ import EdgeStoreClientError from './libs/errors/EdgeStoreClientError';
5
5
  import { handleError } from './libs/errors/handleError';
6
6
 
7
7
  const DEFAULT_BASE_URL =
8
- (process !== undefined
8
+ (typeof process !== 'undefined'
9
9
  ? process.env.NEXT_PUBLIC_EDGE_STORE_BASE_URL
10
10
  : // @ts-expect-error - In Vite, the env variables are available on `import.meta`.
11
11
  import.meta.env?.EDGE_STORE_BASE_URL) ?? 'https://files.edgestore.dev';
@@ -143,6 +143,7 @@ function EdgeStoreProviderInner<TRouter extends AnyRouter>({
143
143
  });
144
144
  const res = await fetch(`${apiPath}/init`, {
145
145
  method: 'POST',
146
+ credentials: 'include',
146
147
  });
147
148
  if (res.ok) {
148
149
  const json = await res.json();
@@ -144,6 +144,7 @@ async function uploadFile(
144
144
  onProgressChange?.(0);
145
145
  const res = await fetch(`${apiPath}/request-upload`, {
146
146
  method: 'POST',
147
+ credentials: 'include',
147
148
  body: JSON.stringify({
148
149
  bucketName,
149
150
  input,
@@ -203,7 +204,7 @@ async function uploadFile(
203
204
  */
204
205
  function getUrl(url: string, apiPath: string) {
205
206
  const mode =
206
- process !== undefined
207
+ typeof process !== 'undefined'
207
208
  ? process.env.NODE_ENV
208
209
  : // @ts-expect-error - DEV is injected by Vite
209
210
  import.meta.env?.DEV
@@ -325,6 +326,7 @@ async function multipartUpload(params: {
325
326
  // Complete multipart upload
326
327
  const res = await fetch(`${apiPath}/complete-multipart-upload`, {
327
328
  method: 'POST',
329
+ credentials: 'include',
328
330
  body: JSON.stringify({
329
331
  bucketName,
330
332
  uploadId,
@@ -356,6 +358,7 @@ async function confirmUpload(
356
358
  ) {
357
359
  const res = await fetch(`${apiPath}/confirm-upload`, {
358
360
  method: 'POST',
361
+ credentials: 'include',
359
362
  body: JSON.stringify({
360
363
  url,
361
364
  bucketName,
@@ -386,6 +389,7 @@ async function deleteFile(
386
389
  ) {
387
390
  const res = await fetch(`${apiPath}/delete-file`, {
388
391
  method: 'POST',
392
+ credentials: 'include',
389
393
  body: JSON.stringify({
390
394
  url,
391
395
  bucketName,
@@ -0,0 +1 @@
1
+ export { EdgeStoreApiClientError } from '@edgestore/shared';