@bigbinary/neeto-image-uploader-frontend 2.3.3 → 2.3.5
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/AssetLibrary.js +237 -8520
- package/dist/AssetLibrary.js.map +1 -1
- package/dist/BasicImageUploader.js +12 -9
- package/dist/BasicImageUploader.js.map +1 -1
- package/dist/ImageUploader.js +17 -57
- package/dist/ImageUploader.js.map +1 -1
- package/dist/{ImageWithFallback-1d3c6c16.js → ImageWithFallback-8d240931.js} +5 -3
- package/dist/{ImageWithFallback-1d3c6c16.js.map → ImageWithFallback-8d240931.js.map} +1 -1
- package/dist/{ImageWithFallback-da061171.js → ImageWithFallback-edf8eba8.js} +15 -10
- package/dist/{ImageWithFallback-da061171.js.map → ImageWithFallback-edf8eba8.js.map} +1 -1
- package/dist/cjs/AssetLibrary.js +277 -8608
- package/dist/cjs/AssetLibrary.js.map +1 -1
- package/dist/cjs/BasicImageUploader.js +17 -12
- package/dist/cjs/BasicImageUploader.js.map +1 -1
- package/dist/cjs/ImageUploader.js +24 -61
- package/dist/cjs/ImageUploader.js.map +1 -1
- package/dist/cjs/hooks.js +7 -3
- package/dist/cjs/hooks.js.map +1 -1
- package/dist/cjs/index.js +18 -57
- package/dist/cjs/index.js.map +1 -1
- package/dist/hooks.js +7 -3
- package/dist/hooks.js.map +1 -1
- package/dist/{index-c128d963.js → index-8605e11c.js} +2 -98
- package/dist/index-8605e11c.js.map +1 -0
- package/dist/{index-69559a7a.js → index-cf7e4b89.js} +1 -99
- package/dist/index-cf7e4b89.js.map +1 -0
- package/dist/index.js +18 -57
- package/dist/index.js.map +1 -1
- package/dist/useImageUploader-608bca32.js +251 -0
- package/dist/useImageUploader-608bca32.js.map +1 -0
- package/dist/useImageUploader-8b4e333c.js +264 -0
- package/dist/useImageUploader-8b4e333c.js.map +1 -0
- package/dist/{useProfileImageUpload-0fd0e56b.js → useProfileImageUpload-08752a73.js} +10 -7
- package/dist/useProfileImageUpload-08752a73.js.map +1 -0
- package/dist/{useProfileImageUpload-0861cfca.js → useProfileImageUpload-29d226a6.js} +21 -15
- package/dist/useProfileImageUpload-29d226a6.js.map +1 -0
- package/dist/{utils-2fc0a9dc.js → utils-ede1695e.js} +43 -35
- package/dist/utils-ede1695e.js.map +1 -0
- package/dist/{utils-46caa3d3.js → utils-fa0fa918.js} +40 -33
- package/dist/utils-fa0fa918.js.map +1 -0
- package/package.json +101 -82
- package/dist/index-69559a7a.js.map +0 -1
- package/dist/index-c128d963.js.map +0 -1
- package/dist/useImageUploader-9faaa8e5.js +0 -643
- package/dist/useImageUploader-9faaa8e5.js.map +0 -1
- package/dist/useImageUploader-a53cf673.js +0 -658
- package/dist/useImageUploader-a53cf673.js.map +0 -1
- package/dist/useProfileImageUpload-0861cfca.js.map +0 -1
- package/dist/useProfileImageUpload-0fd0e56b.js.map +0 -1
- package/dist/utils-2fc0a9dc.js.map +0 -1
- package/dist/utils-46caa3d3.js.map +0 -1
|
@@ -1,658 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var index = require('./index-69559a7a.js');
|
|
4
|
-
var reactQuery = require('@tanstack/react-query');
|
|
5
|
-
var reactUtils = require('@bigbinary/neeto-commons-frontend/react-utils');
|
|
6
|
-
var query = require('./query-3c31bf92.js');
|
|
7
|
-
var activestorage = require('@rails/activestorage');
|
|
8
|
-
var neetoCist = require('@bigbinary/neeto-cist');
|
|
9
|
-
var initializers = require('@bigbinary/neeto-commons-frontend/initializers');
|
|
10
|
-
var Toastr = require('@bigbinary/neetoui/Toastr');
|
|
11
|
-
var ramda = require('ramda');
|
|
12
|
-
var axios = require('axios');
|
|
13
|
-
|
|
14
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
15
|
-
|
|
16
|
-
var Toastr__default = /*#__PURE__*/_interopDefaultLegacy(Toastr);
|
|
17
|
-
var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
|
|
18
|
-
|
|
19
|
-
var create = function create(payload) {
|
|
20
|
-
return axios__default["default"].post("/api/direct_uploads", {
|
|
21
|
-
blob: payload
|
|
22
|
-
}, {
|
|
23
|
-
transformRequestCase: false
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
var update = function update(_ref) {
|
|
27
|
-
var id = _ref.id,
|
|
28
|
-
payload = _ref.payload;
|
|
29
|
-
return axios__default["default"].put("neeto_image_uploader_engine/api/direct_uploads/".concat(id), {
|
|
30
|
-
blob: payload
|
|
31
|
-
}, {
|
|
32
|
-
transformRequestCase: false
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
var directUploadsApi = {
|
|
36
|
-
create: create,
|
|
37
|
-
update: update
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
41
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { index._defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
42
|
-
var useCreateBlob = function useCreateBlob(options) {
|
|
43
|
-
return reactUtils.useMutationWithInvalidation(directUploadsApi.create, _objectSpread({
|
|
44
|
-
keysToInvalidate: [query.QUERY_KEYS.ASSETS_LIST]
|
|
45
|
-
}, options));
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
49
|
-
try {
|
|
50
|
-
var info = gen[key](arg);
|
|
51
|
-
var value = info.value;
|
|
52
|
-
} catch (error) {
|
|
53
|
-
reject(error);
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
if (info.done) {
|
|
57
|
-
resolve(value);
|
|
58
|
-
} else {
|
|
59
|
-
Promise.resolve(value).then(_next, _throw);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
function _asyncToGenerator(fn) {
|
|
63
|
-
return function () {
|
|
64
|
-
var self = this,
|
|
65
|
-
args = arguments;
|
|
66
|
-
return new Promise(function (resolve, reject) {
|
|
67
|
-
var gen = fn.apply(self, args);
|
|
68
|
-
function _next(value) {
|
|
69
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
70
|
-
}
|
|
71
|
-
function _throw(err) {
|
|
72
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
73
|
-
}
|
|
74
|
-
_next(undefined);
|
|
75
|
-
});
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
80
|
-
|
|
81
|
-
function getDefaultExportFromCjs (x) {
|
|
82
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function getAugmentedNamespace(n) {
|
|
86
|
-
if (n.__esModule) return n;
|
|
87
|
-
var f = n.default;
|
|
88
|
-
if (typeof f == "function") {
|
|
89
|
-
var a = function a () {
|
|
90
|
-
if (this instanceof a) {
|
|
91
|
-
return Reflect.construct(f, arguments, this.constructor);
|
|
92
|
-
}
|
|
93
|
-
return f.apply(this, arguments);
|
|
94
|
-
};
|
|
95
|
-
a.prototype = f.prototype;
|
|
96
|
-
} else a = {};
|
|
97
|
-
Object.defineProperty(a, '__esModule', {value: true});
|
|
98
|
-
Object.keys(n).forEach(function (k) {
|
|
99
|
-
var d = Object.getOwnPropertyDescriptor(n, k);
|
|
100
|
-
Object.defineProperty(a, k, d.get ? d : {
|
|
101
|
-
enumerable: true,
|
|
102
|
-
get: function () {
|
|
103
|
-
return n[k];
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
return a;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
var regeneratorRuntime$1 = {exports: {}};
|
|
111
|
-
|
|
112
|
-
var _typeof = {exports: {}};
|
|
113
|
-
|
|
114
|
-
_typeof.exports;
|
|
115
|
-
|
|
116
|
-
(function (module) {
|
|
117
|
-
function _typeof(o) {
|
|
118
|
-
"@babel/helpers - typeof";
|
|
119
|
-
|
|
120
|
-
return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
121
|
-
return typeof o;
|
|
122
|
-
} : function (o) {
|
|
123
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
124
|
-
}, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(o);
|
|
125
|
-
}
|
|
126
|
-
module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
127
|
-
} (_typeof));
|
|
128
|
-
|
|
129
|
-
var _typeofExports = _typeof.exports;
|
|
130
|
-
|
|
131
|
-
regeneratorRuntime$1.exports;
|
|
132
|
-
|
|
133
|
-
(function (module) {
|
|
134
|
-
var _typeof = _typeofExports["default"];
|
|
135
|
-
function _regeneratorRuntime() {
|
|
136
|
-
module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
|
|
137
|
-
return e;
|
|
138
|
-
}, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
139
|
-
var t,
|
|
140
|
-
e = {},
|
|
141
|
-
r = Object.prototype,
|
|
142
|
-
n = r.hasOwnProperty,
|
|
143
|
-
o = Object.defineProperty || function (t, e, r) {
|
|
144
|
-
t[e] = r.value;
|
|
145
|
-
},
|
|
146
|
-
i = "function" == typeof Symbol ? Symbol : {},
|
|
147
|
-
a = i.iterator || "@@iterator",
|
|
148
|
-
c = i.asyncIterator || "@@asyncIterator",
|
|
149
|
-
u = i.toStringTag || "@@toStringTag";
|
|
150
|
-
function define(t, e, r) {
|
|
151
|
-
return Object.defineProperty(t, e, {
|
|
152
|
-
value: r,
|
|
153
|
-
enumerable: !0,
|
|
154
|
-
configurable: !0,
|
|
155
|
-
writable: !0
|
|
156
|
-
}), t[e];
|
|
157
|
-
}
|
|
158
|
-
try {
|
|
159
|
-
define({}, "");
|
|
160
|
-
} catch (t) {
|
|
161
|
-
define = function define(t, e, r) {
|
|
162
|
-
return t[e] = r;
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
function wrap(t, e, r, n) {
|
|
166
|
-
var i = e && e.prototype instanceof Generator ? e : Generator,
|
|
167
|
-
a = Object.create(i.prototype),
|
|
168
|
-
c = new Context(n || []);
|
|
169
|
-
return o(a, "_invoke", {
|
|
170
|
-
value: makeInvokeMethod(t, r, c)
|
|
171
|
-
}), a;
|
|
172
|
-
}
|
|
173
|
-
function tryCatch(t, e, r) {
|
|
174
|
-
try {
|
|
175
|
-
return {
|
|
176
|
-
type: "normal",
|
|
177
|
-
arg: t.call(e, r)
|
|
178
|
-
};
|
|
179
|
-
} catch (t) {
|
|
180
|
-
return {
|
|
181
|
-
type: "throw",
|
|
182
|
-
arg: t
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
e.wrap = wrap;
|
|
187
|
-
var h = "suspendedStart",
|
|
188
|
-
l = "suspendedYield",
|
|
189
|
-
f = "executing",
|
|
190
|
-
s = "completed",
|
|
191
|
-
y = {};
|
|
192
|
-
function Generator() {}
|
|
193
|
-
function GeneratorFunction() {}
|
|
194
|
-
function GeneratorFunctionPrototype() {}
|
|
195
|
-
var p = {};
|
|
196
|
-
define(p, a, function () {
|
|
197
|
-
return this;
|
|
198
|
-
});
|
|
199
|
-
var d = Object.getPrototypeOf,
|
|
200
|
-
v = d && d(d(values([])));
|
|
201
|
-
v && v !== r && n.call(v, a) && (p = v);
|
|
202
|
-
var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
|
|
203
|
-
function defineIteratorMethods(t) {
|
|
204
|
-
["next", "throw", "return"].forEach(function (e) {
|
|
205
|
-
define(t, e, function (t) {
|
|
206
|
-
return this._invoke(e, t);
|
|
207
|
-
});
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
function AsyncIterator(t, e) {
|
|
211
|
-
function invoke(r, o, i, a) {
|
|
212
|
-
var c = tryCatch(t[r], t, o);
|
|
213
|
-
if ("throw" !== c.type) {
|
|
214
|
-
var u = c.arg,
|
|
215
|
-
h = u.value;
|
|
216
|
-
return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
|
|
217
|
-
invoke("next", t, i, a);
|
|
218
|
-
}, function (t) {
|
|
219
|
-
invoke("throw", t, i, a);
|
|
220
|
-
}) : e.resolve(h).then(function (t) {
|
|
221
|
-
u.value = t, i(u);
|
|
222
|
-
}, function (t) {
|
|
223
|
-
return invoke("throw", t, i, a);
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
a(c.arg);
|
|
227
|
-
}
|
|
228
|
-
var r;
|
|
229
|
-
o(this, "_invoke", {
|
|
230
|
-
value: function value(t, n) {
|
|
231
|
-
function callInvokeWithMethodAndArg() {
|
|
232
|
-
return new e(function (e, r) {
|
|
233
|
-
invoke(t, n, e, r);
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
|
-
return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
237
|
-
}
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
function makeInvokeMethod(e, r, n) {
|
|
241
|
-
var o = h;
|
|
242
|
-
return function (i, a) {
|
|
243
|
-
if (o === f) throw new Error("Generator is already running");
|
|
244
|
-
if (o === s) {
|
|
245
|
-
if ("throw" === i) throw a;
|
|
246
|
-
return {
|
|
247
|
-
value: t,
|
|
248
|
-
done: !0
|
|
249
|
-
};
|
|
250
|
-
}
|
|
251
|
-
for (n.method = i, n.arg = a;;) {
|
|
252
|
-
var c = n.delegate;
|
|
253
|
-
if (c) {
|
|
254
|
-
var u = maybeInvokeDelegate(c, n);
|
|
255
|
-
if (u) {
|
|
256
|
-
if (u === y) continue;
|
|
257
|
-
return u;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
|
|
261
|
-
if (o === h) throw o = s, n.arg;
|
|
262
|
-
n.dispatchException(n.arg);
|
|
263
|
-
} else "return" === n.method && n.abrupt("return", n.arg);
|
|
264
|
-
o = f;
|
|
265
|
-
var p = tryCatch(e, r, n);
|
|
266
|
-
if ("normal" === p.type) {
|
|
267
|
-
if (o = n.done ? s : l, p.arg === y) continue;
|
|
268
|
-
return {
|
|
269
|
-
value: p.arg,
|
|
270
|
-
done: n.done
|
|
271
|
-
};
|
|
272
|
-
}
|
|
273
|
-
"throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
|
|
274
|
-
}
|
|
275
|
-
};
|
|
276
|
-
}
|
|
277
|
-
function maybeInvokeDelegate(e, r) {
|
|
278
|
-
var n = r.method,
|
|
279
|
-
o = e.iterator[n];
|
|
280
|
-
if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
|
|
281
|
-
var i = tryCatch(o, e.iterator, r.arg);
|
|
282
|
-
if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
|
|
283
|
-
var a = i.arg;
|
|
284
|
-
return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
|
|
285
|
-
}
|
|
286
|
-
function pushTryEntry(t) {
|
|
287
|
-
var e = {
|
|
288
|
-
tryLoc: t[0]
|
|
289
|
-
};
|
|
290
|
-
1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
|
|
291
|
-
}
|
|
292
|
-
function resetTryEntry(t) {
|
|
293
|
-
var e = t.completion || {};
|
|
294
|
-
e.type = "normal", delete e.arg, t.completion = e;
|
|
295
|
-
}
|
|
296
|
-
function Context(t) {
|
|
297
|
-
this.tryEntries = [{
|
|
298
|
-
tryLoc: "root"
|
|
299
|
-
}], t.forEach(pushTryEntry, this), this.reset(!0);
|
|
300
|
-
}
|
|
301
|
-
function values(e) {
|
|
302
|
-
if (e || "" === e) {
|
|
303
|
-
var r = e[a];
|
|
304
|
-
if (r) return r.call(e);
|
|
305
|
-
if ("function" == typeof e.next) return e;
|
|
306
|
-
if (!isNaN(e.length)) {
|
|
307
|
-
var o = -1,
|
|
308
|
-
i = function next() {
|
|
309
|
-
for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
|
|
310
|
-
return next.value = t, next.done = !0, next;
|
|
311
|
-
};
|
|
312
|
-
return i.next = i;
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
throw new TypeError(_typeof(e) + " is not iterable");
|
|
316
|
-
}
|
|
317
|
-
return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
|
|
318
|
-
value: GeneratorFunctionPrototype,
|
|
319
|
-
configurable: !0
|
|
320
|
-
}), o(GeneratorFunctionPrototype, "constructor", {
|
|
321
|
-
value: GeneratorFunction,
|
|
322
|
-
configurable: !0
|
|
323
|
-
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
|
|
324
|
-
var e = "function" == typeof t && t.constructor;
|
|
325
|
-
return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
|
|
326
|
-
}, e.mark = function (t) {
|
|
327
|
-
return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
|
|
328
|
-
}, e.awrap = function (t) {
|
|
329
|
-
return {
|
|
330
|
-
__await: t
|
|
331
|
-
};
|
|
332
|
-
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
|
|
333
|
-
return this;
|
|
334
|
-
}), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
|
|
335
|
-
void 0 === i && (i = Promise);
|
|
336
|
-
var a = new AsyncIterator(wrap(t, r, n, o), i);
|
|
337
|
-
return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
|
|
338
|
-
return t.done ? t.value : a.next();
|
|
339
|
-
});
|
|
340
|
-
}, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
|
|
341
|
-
return this;
|
|
342
|
-
}), define(g, "toString", function () {
|
|
343
|
-
return "[object Generator]";
|
|
344
|
-
}), e.keys = function (t) {
|
|
345
|
-
var e = Object(t),
|
|
346
|
-
r = [];
|
|
347
|
-
for (var n in e) r.push(n);
|
|
348
|
-
return r.reverse(), function next() {
|
|
349
|
-
for (; r.length;) {
|
|
350
|
-
var t = r.pop();
|
|
351
|
-
if (t in e) return next.value = t, next.done = !1, next;
|
|
352
|
-
}
|
|
353
|
-
return next.done = !0, next;
|
|
354
|
-
};
|
|
355
|
-
}, e.values = values, Context.prototype = {
|
|
356
|
-
constructor: Context,
|
|
357
|
-
reset: function reset(e) {
|
|
358
|
-
if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
|
|
359
|
-
},
|
|
360
|
-
stop: function stop() {
|
|
361
|
-
this.done = !0;
|
|
362
|
-
var t = this.tryEntries[0].completion;
|
|
363
|
-
if ("throw" === t.type) throw t.arg;
|
|
364
|
-
return this.rval;
|
|
365
|
-
},
|
|
366
|
-
dispatchException: function dispatchException(e) {
|
|
367
|
-
if (this.done) throw e;
|
|
368
|
-
var r = this;
|
|
369
|
-
function handle(n, o) {
|
|
370
|
-
return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
|
|
371
|
-
}
|
|
372
|
-
for (var o = this.tryEntries.length - 1; o >= 0; --o) {
|
|
373
|
-
var i = this.tryEntries[o],
|
|
374
|
-
a = i.completion;
|
|
375
|
-
if ("root" === i.tryLoc) return handle("end");
|
|
376
|
-
if (i.tryLoc <= this.prev) {
|
|
377
|
-
var c = n.call(i, "catchLoc"),
|
|
378
|
-
u = n.call(i, "finallyLoc");
|
|
379
|
-
if (c && u) {
|
|
380
|
-
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
381
|
-
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
382
|
-
} else if (c) {
|
|
383
|
-
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
384
|
-
} else {
|
|
385
|
-
if (!u) throw new Error("try statement without catch or finally");
|
|
386
|
-
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
},
|
|
391
|
-
abrupt: function abrupt(t, e) {
|
|
392
|
-
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
|
|
393
|
-
var o = this.tryEntries[r];
|
|
394
|
-
if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
|
|
395
|
-
var i = o;
|
|
396
|
-
break;
|
|
397
|
-
}
|
|
398
|
-
}
|
|
399
|
-
i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
|
|
400
|
-
var a = i ? i.completion : {};
|
|
401
|
-
return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
|
|
402
|
-
},
|
|
403
|
-
complete: function complete(t, e) {
|
|
404
|
-
if ("throw" === t.type) throw t.arg;
|
|
405
|
-
return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
|
|
406
|
-
},
|
|
407
|
-
finish: function finish(t) {
|
|
408
|
-
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
409
|
-
var r = this.tryEntries[e];
|
|
410
|
-
if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
|
|
411
|
-
}
|
|
412
|
-
},
|
|
413
|
-
"catch": function _catch(t) {
|
|
414
|
-
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
415
|
-
var r = this.tryEntries[e];
|
|
416
|
-
if (r.tryLoc === t) {
|
|
417
|
-
var n = r.completion;
|
|
418
|
-
if ("throw" === n.type) {
|
|
419
|
-
var o = n.arg;
|
|
420
|
-
resetTryEntry(r);
|
|
421
|
-
}
|
|
422
|
-
return o;
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
throw new Error("illegal catch attempt");
|
|
426
|
-
},
|
|
427
|
-
delegateYield: function delegateYield(e, r, n) {
|
|
428
|
-
return this.delegate = {
|
|
429
|
-
iterator: values(e),
|
|
430
|
-
resultName: r,
|
|
431
|
-
nextLoc: n
|
|
432
|
-
}, "next" === this.method && (this.arg = t), y;
|
|
433
|
-
}
|
|
434
|
-
}, e;
|
|
435
|
-
}
|
|
436
|
-
module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
437
|
-
} (regeneratorRuntime$1));
|
|
438
|
-
|
|
439
|
-
var regeneratorRuntimeExports = regeneratorRuntime$1.exports;
|
|
440
|
-
|
|
441
|
-
// TODO(Babel 8): Remove this file.
|
|
442
|
-
|
|
443
|
-
var runtime = regeneratorRuntimeExports();
|
|
444
|
-
var regenerator = runtime;
|
|
445
|
-
|
|
446
|
-
// Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
|
|
447
|
-
try {
|
|
448
|
-
regeneratorRuntime = runtime;
|
|
449
|
-
} catch (accidentalStrictMode) {
|
|
450
|
-
if (typeof globalThis === "object") {
|
|
451
|
-
globalThis.regeneratorRuntime = runtime;
|
|
452
|
-
} else {
|
|
453
|
-
Function("r", "regeneratorRuntime = r")(runtime);
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
var _regeneratorRuntime = /*@__PURE__*/getDefaultExportFromCjs(regenerator);
|
|
458
|
-
|
|
459
|
-
var generate = function generate() {
|
|
460
|
-
return axios__default["default"].post("neeto_image_uploader_engine/cloudflare_images");
|
|
461
|
-
};
|
|
462
|
-
var upload = function upload(_ref) {
|
|
463
|
-
var url = _ref.url,
|
|
464
|
-
formData = _ref.formData,
|
|
465
|
-
setUploadProgress = _ref.setUploadProgress;
|
|
466
|
-
return axios__default["default"].post(url, formData, {
|
|
467
|
-
headers: {
|
|
468
|
-
"Content-Type": "multipart/form-data"
|
|
469
|
-
},
|
|
470
|
-
onUploadProgress: function onUploadProgress(event) {
|
|
471
|
-
var percentComplete = Math.round(event.loaded / event.total * 100);
|
|
472
|
-
setUploadProgress(percentComplete);
|
|
473
|
-
},
|
|
474
|
-
transformRequestCase: false
|
|
475
|
-
});
|
|
476
|
-
};
|
|
477
|
-
var cloudflareImageApi = {
|
|
478
|
-
generate: generate,
|
|
479
|
-
upload: upload
|
|
480
|
-
};
|
|
481
|
-
|
|
482
|
-
var useCloudFlareImageUpload = function useCloudFlareImageUpload() {
|
|
483
|
-
return reactQuery.useMutation({
|
|
484
|
-
mutationFn: cloudflareImageApi.upload
|
|
485
|
-
});
|
|
486
|
-
};
|
|
487
|
-
|
|
488
|
-
var generateASCIIFileName = function generateASCIIFileName(originalFileName) {
|
|
489
|
-
if (/^[A-Za-z0-9-_.~]*$/.test(originalFileName)) {
|
|
490
|
-
return originalFileName;
|
|
491
|
-
}
|
|
492
|
-
var extension = originalFileName.split(".").pop();
|
|
493
|
-
return "image.".concat(extension);
|
|
494
|
-
};
|
|
495
|
-
|
|
496
|
-
var useImageUploader = function useImageUploader(_ref) {
|
|
497
|
-
var _ref$onUploadComplete = _ref.onUploadComplete,
|
|
498
|
-
onUploadComplete = _ref$onUploadComplete === void 0 ? neetoCist.noop : _ref$onUploadComplete,
|
|
499
|
-
_ref$setIsUploading = _ref.setIsUploading,
|
|
500
|
-
setIsUploading = _ref$setIsUploading === void 0 ? neetoCist.noop : _ref$setIsUploading;
|
|
501
|
-
var authenticationEndpoint = "".concat(window.location.origin, "/neeto_image_uploader_engine/imagekit/auth");
|
|
502
|
-
var _useCloudFlareImageUp = useCloudFlareImageUpload(),
|
|
503
|
-
cloudFlareImage = _useCloudFlareImageUp.mutate;
|
|
504
|
-
var handleUploadProgress = function handleUploadProgress(e, fileSize, setUploadProgress) {
|
|
505
|
-
if (e.loaded <= fileSize) {
|
|
506
|
-
var percent = Math.round(e.loaded / fileSize * 100);
|
|
507
|
-
setUploadProgress(percent);
|
|
508
|
-
}
|
|
509
|
-
ramda.equals(e.loaded, e.total) && setUploadProgress(100);
|
|
510
|
-
};
|
|
511
|
-
var developmentUpload = function developmentUpload(file, setUploadProgress) {
|
|
512
|
-
try {
|
|
513
|
-
setIsUploading(true);
|
|
514
|
-
var upload = new activestorage.DirectUpload(file, "/api/direct_uploads", {
|
|
515
|
-
directUploadWillStoreFileWithXHR: function directUploadWillStoreFileWithXHR(xhr) {
|
|
516
|
-
xhr.upload.addEventListener("progress", function (event) {
|
|
517
|
-
var percentComplete = Math.round(event.loaded / event.total * 100);
|
|
518
|
-
setUploadProgress(percentComplete);
|
|
519
|
-
});
|
|
520
|
-
}
|
|
521
|
-
});
|
|
522
|
-
upload.create(function (_, blob) {
|
|
523
|
-
var payload = {
|
|
524
|
-
id: blob.signed_id,
|
|
525
|
-
payload: {
|
|
526
|
-
metadata: {
|
|
527
|
-
organizationKey: initializers.globalProps.organization.publicApiKey,
|
|
528
|
-
url: blob.blob_url,
|
|
529
|
-
height: 200,
|
|
530
|
-
width: 200
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
};
|
|
534
|
-
directUploadsApi.update(payload);
|
|
535
|
-
var result = ramda.mergeRight(neetoCist.keysToCamelCase(blob), {
|
|
536
|
-
url: blob.blob_url
|
|
537
|
-
});
|
|
538
|
-
onUploadComplete(result);
|
|
539
|
-
setIsUploading(false);
|
|
540
|
-
});
|
|
541
|
-
} catch (error) {
|
|
542
|
-
Toastr__default["default"].error(error);
|
|
543
|
-
}
|
|
544
|
-
};
|
|
545
|
-
var imageKitUpload = /*#__PURE__*/function () {
|
|
546
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(file, XHRProgress) {
|
|
547
|
-
var imagekit, result;
|
|
548
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
549
|
-
while (1) switch (_context.prev = _context.next) {
|
|
550
|
-
case 0:
|
|
551
|
-
_context.prev = 0;
|
|
552
|
-
imagekit = new index.ImageKit(ramda.mergeRight(initializers.globalProps.imagekit, {
|
|
553
|
-
authenticationEndpoint: authenticationEndpoint
|
|
554
|
-
}));
|
|
555
|
-
setIsUploading(true);
|
|
556
|
-
_context.next = 5;
|
|
557
|
-
return imagekit.upload({
|
|
558
|
-
xhr: XHRProgress,
|
|
559
|
-
file: file,
|
|
560
|
-
fileName: generateASCIIFileName(file.name),
|
|
561
|
-
folder: initializers.globalProps.imagekit.folder,
|
|
562
|
-
customMetadata: {
|
|
563
|
-
organizationKey: initializers.globalProps.organization.publicApiKey,
|
|
564
|
-
appName: initializers.globalProps.appName
|
|
565
|
-
}
|
|
566
|
-
});
|
|
567
|
-
case 5:
|
|
568
|
-
result = _context.sent;
|
|
569
|
-
onUploadComplete(result);
|
|
570
|
-
setIsUploading(false);
|
|
571
|
-
_context.next = 13;
|
|
572
|
-
break;
|
|
573
|
-
case 10:
|
|
574
|
-
_context.prev = 10;
|
|
575
|
-
_context.t0 = _context["catch"](0);
|
|
576
|
-
Toastr__default["default"].error(_context.t0);
|
|
577
|
-
case 13:
|
|
578
|
-
case "end":
|
|
579
|
-
return _context.stop();
|
|
580
|
-
}
|
|
581
|
-
}, _callee, null, [[0, 10]]);
|
|
582
|
-
}));
|
|
583
|
-
return function imageKitUpload(_x, _x2) {
|
|
584
|
-
return _ref2.apply(this, arguments);
|
|
585
|
-
};
|
|
586
|
-
}();
|
|
587
|
-
var cloudFlareImageUpload = /*#__PURE__*/function () {
|
|
588
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(file, setUploadProgress) {
|
|
589
|
-
var formData, _yield$cloudflareImag, result;
|
|
590
|
-
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
591
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
592
|
-
case 0:
|
|
593
|
-
formData = new FormData();
|
|
594
|
-
formData.append("file", file);
|
|
595
|
-
setIsUploading(true);
|
|
596
|
-
_context2.prev = 3;
|
|
597
|
-
_context2.next = 6;
|
|
598
|
-
return cloudflareImageApi.generate();
|
|
599
|
-
case 6:
|
|
600
|
-
_yield$cloudflareImag = _context2.sent;
|
|
601
|
-
result = _yield$cloudflareImag.result;
|
|
602
|
-
cloudFlareImage({
|
|
603
|
-
url: result.uploadURL,
|
|
604
|
-
formData: formData,
|
|
605
|
-
setUploadProgress: setUploadProgress
|
|
606
|
-
}, {
|
|
607
|
-
onSuccess: function onSuccess(_ref4) {
|
|
608
|
-
var result = _ref4.result;
|
|
609
|
-
return onUploadComplete(result, file);
|
|
610
|
-
}
|
|
611
|
-
});
|
|
612
|
-
_context2.next = 14;
|
|
613
|
-
break;
|
|
614
|
-
case 11:
|
|
615
|
-
_context2.prev = 11;
|
|
616
|
-
_context2.t0 = _context2["catch"](3);
|
|
617
|
-
Toastr__default["default"].error(_context2.t0);
|
|
618
|
-
case 14:
|
|
619
|
-
_context2.prev = 14;
|
|
620
|
-
setIsUploading(false);
|
|
621
|
-
return _context2.finish(14);
|
|
622
|
-
case 17:
|
|
623
|
-
case "end":
|
|
624
|
-
return _context2.stop();
|
|
625
|
-
}
|
|
626
|
-
}, _callee2, null, [[3, 11, 14, 17]]);
|
|
627
|
-
}));
|
|
628
|
-
return function cloudFlareImageUpload(_x3, _x4) {
|
|
629
|
-
return _ref3.apply(this, arguments);
|
|
630
|
-
};
|
|
631
|
-
}();
|
|
632
|
-
var uploadFile = function uploadFile(file, setUploadProgress) {
|
|
633
|
-
if (ramda.isNil(file)) return;
|
|
634
|
-
var fileSize = file.size;
|
|
635
|
-
var XHRProgress = new XMLHttpRequest();
|
|
636
|
-
XHRProgress.upload.addEventListener("progress", function (e) {
|
|
637
|
-
handleUploadProgress(e, fileSize, setUploadProgress);
|
|
638
|
-
});
|
|
639
|
-
var productionUpload = function productionUpload() {
|
|
640
|
-
return initializers.globalProps.assetsUploaderService === index.CLOUD_FLARE ? cloudFlareImageUpload(file, setUploadProgress) : imageKitUpload(file, XHRProgress);
|
|
641
|
-
};
|
|
642
|
-
index.IS_DEVELOPMENT_OR_HEROKU_ENV ? developmentUpload(file, setUploadProgress) : productionUpload();
|
|
643
|
-
};
|
|
644
|
-
return {
|
|
645
|
-
uploadFile: uploadFile
|
|
646
|
-
};
|
|
647
|
-
};
|
|
648
|
-
|
|
649
|
-
exports._asyncToGenerator = _asyncToGenerator;
|
|
650
|
-
exports._regeneratorRuntime = _regeneratorRuntime;
|
|
651
|
-
exports.commonjsGlobal = commonjsGlobal;
|
|
652
|
-
exports.directUploadsApi = directUploadsApi;
|
|
653
|
-
exports.generateASCIIFileName = generateASCIIFileName;
|
|
654
|
-
exports.getAugmentedNamespace = getAugmentedNamespace;
|
|
655
|
-
exports.getDefaultExportFromCjs = getDefaultExportFromCjs;
|
|
656
|
-
exports.useCreateBlob = useCreateBlob;
|
|
657
|
-
exports.useImageUploader = useImageUploader;
|
|
658
|
-
//# sourceMappingURL=useImageUploader-a53cf673.js.map
|