@knovator/pagecreator 0.0.2 → 0.0.4

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/README.md CHANGED
@@ -112,7 +112,7 @@ We can use `@knovator/pagecreator` in React/Next application, we can create one
112
112
  import { Widget } from '@knovator/pagecreator';
113
113
 
114
114
  <Widget
115
- apiBaseUrl=''
115
+ imageBaseUrl=''
116
116
  widgetData={}
117
117
  onClick={...}
118
118
  >
@@ -120,8 +120,8 @@ import { Widget } from '@knovator/pagecreator';
120
120
  **Props**
121
121
  - `widgetData`
122
122
  - [widgetData](data-formats.md#widgetdata)
123
- - `apiBaseUrl`
124
- - baseUrl to start prefix image urls
123
+ - `imageBaseUrl`
124
+ - baseUrl to append before image urls
125
125
  - `formatItem` (optional): `(item: TileData) => JSX.Element`
126
126
  - Customize look of Items
127
127
  - `onClick` (optional): `(item: TileData) => void;`
@@ -132,7 +132,7 @@ import { Widget } from '@knovator/pagecreator';
132
132
  import { Page } from '@knovator/pagecreator';
133
133
 
134
134
  <Page
135
- apiBaseUrl=''
135
+ imageBaseUrl=''
136
136
  pageData={...}
137
137
  onClick={...}
138
138
  >
@@ -140,7 +140,7 @@ import { Page } from '@knovator/pagecreator';
140
140
  **Props**
141
141
  - `title` (optional)
142
142
  - Title to show on page
143
- - `apiBaseUrl`
143
+ - `imageBaseUrl`
144
144
  - baseUrl to start prefix image urls
145
145
  - `pageData`
146
146
  - [PageData](data-formats.md#pagedata)
@@ -1,3 +1,3 @@
1
1
  import { PageProps } from '../../types';
2
- export declare function Page({ title, apiBaseUrl, pageData, formatItem, onClick, }: PageProps): JSX.Element | null;
2
+ export declare function Page({ title, imageBaseUrl, pageData, formatItem, onClick, }: PageProps): JSX.Element | null;
3
3
  export default Page;
@@ -1,3 +1,3 @@
1
1
  import { WidgetProps } from '../../types';
2
- export declare function Widget({ widgetData, apiBaseUrl, formatItem, onClick, settings, }: WidgetProps): JSX.Element | null;
2
+ export declare function Widget({ widgetData, imageBaseUrl, formatItem, onClick, settings, }: WidgetProps): JSX.Element | null;
3
3
  export default Widget;
@@ -32,7 +32,7 @@ export interface ReviewCardProps extends UserCardProps {
32
32
  }
33
33
  export interface WidgetProps {
34
34
  widgetData: WidgetData;
35
- apiBaseUrl: string;
35
+ imageBaseUrl: string;
36
36
  formatItem?: (item: TileData | CollectionItemType) => JSX.Element;
37
37
  onClick?: (item: TileData | CollectionItemType) => void;
38
38
  settings?: Settings;
@@ -42,7 +42,7 @@ export interface WidgetTypeProps extends WidgetProps {
42
42
  }
43
43
  export interface PageProps {
44
44
  title?: string;
45
- apiBaseUrl: string;
45
+ imageBaseUrl: string;
46
46
  pageData: PageData;
47
47
  formatItem?: (CODE: string, item: TileData | CollectionItemType) => JSX.Element;
48
48
  onClick?: (CODE: string, item: TileData | CollectionItemType) => JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knovator/pagecreator",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:knovator/pagecreator.git"
@@ -23,8 +23,7 @@
23
23
  "index.d.ts",
24
24
  "index.js"
25
25
  ],
26
- "module": "./index.js",
27
- "main": "./index.js",
28
- "type": "module",
26
+ "main": "./index.cjs",
27
+ "type": "commonjs",
29
28
  "types": "./index.d.ts"
30
29
  }
package/index.js DELETED
@@ -1,709 +0,0 @@
1
- import { jsx, jsxs } from 'react/jsx-runtime';
2
- import Slider from 'react-slick';
3
-
4
- function FixedWidget(_ref) {
5
- var widgetData = _ref.widgetData,
6
- formatItem = _ref.formatItem;
7
- return jsx("div", Object.assign({
8
- className: "grid grid-cols-".concat(widgetData.mobilePerRow, " md:grid-cols-").concat(widgetData.tabletPerRow, " lg:grid-cols-").concat(widgetData.webPerRow)
9
- }, {
10
- children: widgetData.widgetType === 'Image' ? widgetData.tiles.map(function (tile) {
11
- return formatItem(tile);
12
- }) : widgetData.collectionItems.map(function (item) {
13
- return formatItem(item);
14
- })
15
- }));
16
- }
17
-
18
- /******************************************************************************
19
- Copyright (c) Microsoft Corporation.
20
-
21
- Permission to use, copy, modify, and/or distribute this software for any
22
- purpose with or without fee is hereby granted.
23
-
24
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
25
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
26
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
27
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
28
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
29
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
30
- PERFORMANCE OF THIS SOFTWARE.
31
- ***************************************************************************** */
32
-
33
- function __rest(s, e) {
34
- var t = {};
35
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
36
- t[p] = s[p];
37
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
38
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
39
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
40
- t[p[i]] = s[p[i]];
41
- }
42
- return t;
43
- }
44
-
45
- function __awaiter(thisArg, _arguments, P, generator) {
46
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
47
- return new (P || (P = Promise))(function (resolve, reject) {
48
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
49
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
50
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
51
- step((generator = generator.apply(thisArg, _arguments || [])).next());
52
- });
53
- }
54
-
55
- var Next = function Next() {
56
- return jsx("svg", Object.assign({
57
- width: "12",
58
- height: "12",
59
- viewBox: "0 0 12 12",
60
- fill: "none",
61
- xmlns: "http://www.w3.org/2000/svg"
62
- }, {
63
- children: jsx("path", {
64
- d: "M9.129 5.25L5.106 1.227L6.1665 0.166504L12 6L6.1665 11.8335L5.106 10.773L9.129 6.75H0V5.25H9.129Z",
65
- fill: "#40B5E8"
66
- })
67
- }));
68
- };
69
-
70
- var Previous = function Previous() {
71
- return jsx("svg", Object.assign({
72
- width: "12",
73
- height: "12",
74
- viewBox: "0 0 12 12",
75
- fill: "none",
76
- xmlns: "http://www.w3.org/2000/svg"
77
- }, {
78
- children: jsx("path", {
79
- d: "M2.871 5.25L6.894 1.227L5.8335 0.166504L0 6L5.8335 11.8335L6.894 10.773L2.871 6.75H12V5.25H2.871Z",
80
- fill: "#40B5E8"
81
- })
82
- }));
83
- };
84
-
85
- var SlickArrowLeft = function SlickArrowLeft(_a) {
86
- var currentSlide = _a.currentSlide;
87
- _a.slideCount;
88
- var props = __rest(_a, ["currentSlide", "slideCount"]);
89
-
90
- return jsx("button", Object.assign({}, props, {
91
- className: 'slick-prev slick-arrow' + (currentSlide === 0 ? ' slick-disabled' : ''),
92
- "aria-hidden": "true",
93
- "aria-disabled": currentSlide === 0 ? true : false,
94
- type: "button"
95
- }, {
96
- children: jsx(Previous, {})
97
- }));
98
- };
99
-
100
- var SlickArrowRight = function SlickArrowRight(_a) {
101
- var currentSlide = _a.currentSlide,
102
- slideCount = _a.slideCount,
103
- props = __rest(_a, ["currentSlide", "slideCount"]);
104
-
105
- return jsx("button", Object.assign({}, props, {
106
- className: 'slick-next slick-arrow' + (slideCount && currentSlide === slideCount - 1 ? ' slick-disabled' : ''),
107
- "aria-hidden": "true",
108
- "aria-disabled": slideCount && currentSlide === slideCount - 1 ? true : false,
109
- type: "button"
110
- }, {
111
- children: jsx(Next, {})
112
- }));
113
- };
114
-
115
- function CarouselWidget(_ref) {
116
- var widgetData = _ref.widgetData,
117
- formatItem = _ref.formatItem,
118
- settings = _ref.settings;
119
- var defaultSettings = {
120
- dots: false,
121
- infinite: true,
122
- slidesToShow: widgetData.mobilePerRow,
123
- slidesToScroll: 1,
124
- autoplay: widgetData.autoPlay,
125
- autoplaySpeed: 1500,
126
- pauseOnHover: true,
127
- nextArrow: jsx(SlickArrowRight, {}),
128
- prevArrow: jsx(SlickArrowLeft, {}),
129
- responsive: [{
130
- breakpoint: 768,
131
- settings: {
132
- slidesToShow: widgetData.tabletPerRow
133
- }
134
- }, {
135
- breakpoint: 1024,
136
- settings: {
137
- arrows: false,
138
- slidesToShow: widgetData.webPerRow
139
- }
140
- }]
141
- };
142
- if (!widgetData) return null;
143
- return jsx(Slider, Object.assign({}, settings ? settings : defaultSettings, {
144
- children: widgetData.widgetType === 'Image' ? widgetData.tiles.map(function (tile) {
145
- return formatItem(tile);
146
- }) : widgetData.collectionItems.map(function (item) {
147
- return formatItem(item);
148
- })
149
- }));
150
- }
151
-
152
- function Banner(_ref) {
153
- var imageAltText = _ref.imageAltText,
154
- imageUrl = _ref.imageUrl,
155
- _onClick = _ref.onClick;
156
- return jsx("div", Object.assign({
157
- className: "kpc_banner"
158
- }, {
159
- children: jsx("img", {
160
- src: imageUrl,
161
- alt: imageAltText,
162
- className: "kpc_banner-image",
163
- onClick: function onClick() {
164
- return _onClick && _onClick();
165
- }
166
- })
167
- }));
168
- }
169
-
170
- function CollectionItem(_ref) {
171
- var name = _ref.name,
172
- _onClick = _ref.onClick;
173
- return jsx("div", Object.assign({
174
- className: "kpc_item",
175
- onClick: function onClick() {
176
- return _onClick && _onClick();
177
- }
178
- }, {
179
- children: jsx("p", Object.assign({
180
- className: "kpc_item-text"
181
- }, {
182
- children: name
183
- }))
184
- }));
185
- }
186
-
187
- function Widget(_ref) {
188
- var widgetData = _ref.widgetData,
189
- apiBaseUrl = _ref.apiBaseUrl,
190
- formatItem = _ref.formatItem,
191
- _onClick = _ref.onClick,
192
- settings = _ref.settings;
193
-
194
- var formatTile = function formatTile(tile) {
195
- var _a;
196
-
197
- if (typeof formatItem === 'function' && formatItem) return formatItem(tile);else if (widgetData.widgetType === 'Image') return jsx(Banner, {
198
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
199
- // @ts-ignore
200
- imageUrl: "".concat(apiBaseUrl).concat((_a = tile.img) === null || _a === void 0 ? void 0 : _a.uri),
201
- imageAltText: tile._id,
202
- onClick: function onClick() {
203
- return _onClick && _onClick(tile);
204
- }
205
- }, tile._id);else return jsx(CollectionItem, Object.assign({
206
- onClick: function onClick() {
207
- return _onClick && _onClick(tile);
208
- }
209
- }, tile), tile._id);
210
- };
211
-
212
- if (!widgetData) return null;
213
- return jsxs("div", Object.assign({
214
- className: "kpc_widget"
215
- }, {
216
- children: [jsx("h2", Object.assign({
217
- className: "kpc_widget-title"
218
- }, {
219
- children: widgetData.selectionTitle
220
- })), jsx("div", Object.assign({
221
- className: "kpc_widget-body"
222
- }, {
223
- children: widgetData.selectionType === 'Carousel' ? jsx(CarouselWidget, {
224
- settings: settings,
225
- apiBaseUrl: apiBaseUrl,
226
- widgetData: widgetData,
227
- formatItem: formatTile
228
- }) : jsx(FixedWidget, {
229
- apiBaseUrl: apiBaseUrl,
230
- widgetData: widgetData,
231
- formatItem: formatTile
232
- })
233
- }))]
234
- }));
235
- }
236
-
237
- function Page(_ref) {
238
- var title = _ref.title,
239
- apiBaseUrl = _ref.apiBaseUrl,
240
- pageData = _ref.pageData,
241
- formatItem = _ref.formatItem,
242
- onClick = _ref.onClick;
243
- if (!pageData) return null;
244
- return jsxs("div", Object.assign({
245
- className: "kpc_page"
246
- }, {
247
- children: [jsx("h1", Object.assign({
248
- className: "kpc_page-title"
249
- }, {
250
- children: title
251
- })), jsx("div", Object.assign({
252
- className: "kpc_page-widgets"
253
- }, {
254
- children: pageData.widgets.map(function (widgetData, index) {
255
- return jsx(Widget, {
256
- widgetData: widgetData,
257
- apiBaseUrl: apiBaseUrl,
258
- formatItem: formatItem && function (tileData) {
259
- return formatItem(widgetData.code, tileData);
260
- },
261
- onClick: onClick && function (tileData) {
262
- return onClick(widgetData.code, tileData);
263
- }
264
- }, index);
265
- })
266
- }))]
267
- }));
268
- }
269
-
270
- var regeneratorRuntime$1 = {exports: {}};
271
-
272
- var _typeof = {exports: {}};
273
-
274
- (function (module) {
275
- function _typeof(obj) {
276
- "@babel/helpers - typeof";
277
-
278
- return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
279
- return typeof obj;
280
- } : function (obj) {
281
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
282
- }, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(obj);
283
- }
284
-
285
- module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
286
- }(_typeof));
287
-
288
- (function (module) {
289
- var _typeof$1 = _typeof.exports["default"];
290
-
291
- function _regeneratorRuntime() {
292
- /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
293
-
294
- module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
295
- return exports;
296
- }, module.exports.__esModule = true, module.exports["default"] = module.exports;
297
- var exports = {},
298
- Op = Object.prototype,
299
- hasOwn = Op.hasOwnProperty,
300
- $Symbol = "function" == typeof Symbol ? Symbol : {},
301
- iteratorSymbol = $Symbol.iterator || "@@iterator",
302
- asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
303
- toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
304
-
305
- function define(obj, key, value) {
306
- return Object.defineProperty(obj, key, {
307
- value: value,
308
- enumerable: !0,
309
- configurable: !0,
310
- writable: !0
311
- }), obj[key];
312
- }
313
-
314
- try {
315
- define({}, "");
316
- } catch (err) {
317
- define = function define(obj, key, value) {
318
- return obj[key] = value;
319
- };
320
- }
321
-
322
- function wrap(innerFn, outerFn, self, tryLocsList) {
323
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
324
- generator = Object.create(protoGenerator.prototype),
325
- context = new Context(tryLocsList || []);
326
- return generator._invoke = function (innerFn, self, context) {
327
- var state = "suspendedStart";
328
- return function (method, arg) {
329
- if ("executing" === state) throw new Error("Generator is already running");
330
-
331
- if ("completed" === state) {
332
- if ("throw" === method) throw arg;
333
- return doneResult();
334
- }
335
-
336
- for (context.method = method, context.arg = arg;;) {
337
- var delegate = context.delegate;
338
-
339
- if (delegate) {
340
- var delegateResult = maybeInvokeDelegate(delegate, context);
341
-
342
- if (delegateResult) {
343
- if (delegateResult === ContinueSentinel) continue;
344
- return delegateResult;
345
- }
346
- }
347
-
348
- if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
349
- if ("suspendedStart" === state) throw state = "completed", context.arg;
350
- context.dispatchException(context.arg);
351
- } else "return" === context.method && context.abrupt("return", context.arg);
352
- state = "executing";
353
- var record = tryCatch(innerFn, self, context);
354
-
355
- if ("normal" === record.type) {
356
- if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
357
- return {
358
- value: record.arg,
359
- done: context.done
360
- };
361
- }
362
-
363
- "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
364
- }
365
- };
366
- }(innerFn, self, context), generator;
367
- }
368
-
369
- function tryCatch(fn, obj, arg) {
370
- try {
371
- return {
372
- type: "normal",
373
- arg: fn.call(obj, arg)
374
- };
375
- } catch (err) {
376
- return {
377
- type: "throw",
378
- arg: err
379
- };
380
- }
381
- }
382
-
383
- exports.wrap = wrap;
384
- var ContinueSentinel = {};
385
-
386
- function Generator() {}
387
-
388
- function GeneratorFunction() {}
389
-
390
- function GeneratorFunctionPrototype() {}
391
-
392
- var IteratorPrototype = {};
393
- define(IteratorPrototype, iteratorSymbol, function () {
394
- return this;
395
- });
396
- var getProto = Object.getPrototypeOf,
397
- NativeIteratorPrototype = getProto && getProto(getProto(values([])));
398
- NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
399
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
400
-
401
- function defineIteratorMethods(prototype) {
402
- ["next", "throw", "return"].forEach(function (method) {
403
- define(prototype, method, function (arg) {
404
- return this._invoke(method, arg);
405
- });
406
- });
407
- }
408
-
409
- function AsyncIterator(generator, PromiseImpl) {
410
- function invoke(method, arg, resolve, reject) {
411
- var record = tryCatch(generator[method], generator, arg);
412
-
413
- if ("throw" !== record.type) {
414
- var result = record.arg,
415
- value = result.value;
416
- return value && "object" == _typeof$1(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
417
- invoke("next", value, resolve, reject);
418
- }, function (err) {
419
- invoke("throw", err, resolve, reject);
420
- }) : PromiseImpl.resolve(value).then(function (unwrapped) {
421
- result.value = unwrapped, resolve(result);
422
- }, function (error) {
423
- return invoke("throw", error, resolve, reject);
424
- });
425
- }
426
-
427
- reject(record.arg);
428
- }
429
-
430
- var previousPromise;
431
-
432
- this._invoke = function (method, arg) {
433
- function callInvokeWithMethodAndArg() {
434
- return new PromiseImpl(function (resolve, reject) {
435
- invoke(method, arg, resolve, reject);
436
- });
437
- }
438
-
439
- return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
440
- };
441
- }
442
-
443
- function maybeInvokeDelegate(delegate, context) {
444
- var method = delegate.iterator[context.method];
445
-
446
- if (undefined === method) {
447
- if (context.delegate = null, "throw" === context.method) {
448
- if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
449
- context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
450
- }
451
-
452
- return ContinueSentinel;
453
- }
454
-
455
- var record = tryCatch(method, delegate.iterator, context.arg);
456
- if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
457
- var info = record.arg;
458
- return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
459
- }
460
-
461
- function pushTryEntry(locs) {
462
- var entry = {
463
- tryLoc: locs[0]
464
- };
465
- 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
466
- }
467
-
468
- function resetTryEntry(entry) {
469
- var record = entry.completion || {};
470
- record.type = "normal", delete record.arg, entry.completion = record;
471
- }
472
-
473
- function Context(tryLocsList) {
474
- this.tryEntries = [{
475
- tryLoc: "root"
476
- }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
477
- }
478
-
479
- function values(iterable) {
480
- if (iterable) {
481
- var iteratorMethod = iterable[iteratorSymbol];
482
- if (iteratorMethod) return iteratorMethod.call(iterable);
483
- if ("function" == typeof iterable.next) return iterable;
484
-
485
- if (!isNaN(iterable.length)) {
486
- var i = -1,
487
- next = function next() {
488
- for (; ++i < iterable.length;) {
489
- if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
490
- }
491
-
492
- return next.value = undefined, next.done = !0, next;
493
- };
494
-
495
- return next.next = next;
496
- }
497
- }
498
-
499
- return {
500
- next: doneResult
501
- };
502
- }
503
-
504
- function doneResult() {
505
- return {
506
- value: undefined,
507
- done: !0
508
- };
509
- }
510
-
511
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
512
- var ctor = "function" == typeof genFun && genFun.constructor;
513
- return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
514
- }, exports.mark = function (genFun) {
515
- return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
516
- }, exports.awrap = function (arg) {
517
- return {
518
- __await: arg
519
- };
520
- }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
521
- return this;
522
- }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
523
- void 0 === PromiseImpl && (PromiseImpl = Promise);
524
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
525
- return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
526
- return result.done ? result.value : iter.next();
527
- });
528
- }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
529
- return this;
530
- }), define(Gp, "toString", function () {
531
- return "[object Generator]";
532
- }), exports.keys = function (object) {
533
- var keys = [];
534
-
535
- for (var key in object) {
536
- keys.push(key);
537
- }
538
-
539
- return keys.reverse(), function next() {
540
- for (; keys.length;) {
541
- var key = keys.pop();
542
- if (key in object) return next.value = key, next.done = !1, next;
543
- }
544
-
545
- return next.done = !0, next;
546
- };
547
- }, exports.values = values, Context.prototype = {
548
- constructor: Context,
549
- reset: function reset(skipTempReset) {
550
- if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) {
551
- "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
552
- }
553
- },
554
- stop: function stop() {
555
- this.done = !0;
556
- var rootRecord = this.tryEntries[0].completion;
557
- if ("throw" === rootRecord.type) throw rootRecord.arg;
558
- return this.rval;
559
- },
560
- dispatchException: function dispatchException(exception) {
561
- if (this.done) throw exception;
562
- var context = this;
563
-
564
- function handle(loc, caught) {
565
- return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
566
- }
567
-
568
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
569
- var entry = this.tryEntries[i],
570
- record = entry.completion;
571
- if ("root" === entry.tryLoc) return handle("end");
572
-
573
- if (entry.tryLoc <= this.prev) {
574
- var hasCatch = hasOwn.call(entry, "catchLoc"),
575
- hasFinally = hasOwn.call(entry, "finallyLoc");
576
-
577
- if (hasCatch && hasFinally) {
578
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
579
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
580
- } else if (hasCatch) {
581
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
582
- } else {
583
- if (!hasFinally) throw new Error("try statement without catch or finally");
584
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
585
- }
586
- }
587
- }
588
- },
589
- abrupt: function abrupt(type, arg) {
590
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
591
- var entry = this.tryEntries[i];
592
-
593
- if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
594
- var finallyEntry = entry;
595
- break;
596
- }
597
- }
598
-
599
- finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
600
- var record = finallyEntry ? finallyEntry.completion : {};
601
- return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
602
- },
603
- complete: function complete(record, afterLoc) {
604
- if ("throw" === record.type) throw record.arg;
605
- return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
606
- },
607
- finish: function finish(finallyLoc) {
608
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
609
- var entry = this.tryEntries[i];
610
- if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
611
- }
612
- },
613
- "catch": function _catch(tryLoc) {
614
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
615
- var entry = this.tryEntries[i];
616
-
617
- if (entry.tryLoc === tryLoc) {
618
- var record = entry.completion;
619
-
620
- if ("throw" === record.type) {
621
- var thrown = record.arg;
622
- resetTryEntry(entry);
623
- }
624
-
625
- return thrown;
626
- }
627
- }
628
-
629
- throw new Error("illegal catch attempt");
630
- },
631
- delegateYield: function delegateYield(iterable, resultName, nextLoc) {
632
- return this.delegate = {
633
- iterator: values(iterable),
634
- resultName: resultName,
635
- nextLoc: nextLoc
636
- }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
637
- }
638
- }, exports;
639
- }
640
-
641
- module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
642
- }(regeneratorRuntime$1));
643
-
644
- // TODO(Babel 8): Remove this file.
645
-
646
- var runtime = regeneratorRuntime$1.exports();
647
- var regenerator = runtime;
648
-
649
- // Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
650
- try {
651
- regeneratorRuntime = runtime;
652
- } catch (accidentalStrictMode) {
653
- if (typeof globalThis === "object") {
654
- globalThis.regeneratorRuntime = runtime;
655
- } else {
656
- Function("r", "regeneratorRuntime = r")(runtime);
657
- }
658
- }
659
-
660
- function getData(_ref) {
661
- var url = _ref.url,
662
- code = _ref.code,
663
- token = _ref.token;
664
- return __awaiter(this, void 0, void 0, /*#__PURE__*/regenerator.mark(function _callee() {
665
- var response, data;
666
- return regenerator.wrap(function _callee$(_context) {
667
- while (1) {
668
- switch (_context.prev = _context.next) {
669
- case 0:
670
- _context.next = 2;
671
- return fetch(url, {
672
- method: 'POST',
673
- headers: {
674
- 'Content-Type': 'application/json',
675
- Authorization: token ? "Bearer ".concat(token) : ''
676
- },
677
- body: JSON.stringify({
678
- code: code
679
- })
680
- });
681
-
682
- case 2:
683
- response = _context.sent;
684
-
685
- if (response.ok) {
686
- _context.next = 5;
687
- break;
688
- }
689
-
690
- throw new Error(response.statusText);
691
-
692
- case 5:
693
- _context.next = 7;
694
- return response.json();
695
-
696
- case 7:
697
- data = _context.sent;
698
- return _context.abrupt("return", data['data']);
699
-
700
- case 9:
701
- case "end":
702
- return _context.stop();
703
- }
704
- }
705
- }, _callee);
706
- }));
707
- }
708
-
709
- export { Page, Widget, getData };