touchstudy-core 0.1.2 → 0.1.3

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,4 +1,3 @@
1
- import { createBrowserHistory } from 'history';
2
1
  import { createAction, createReducer, configureStore } from '@reduxjs/toolkit';
3
2
  import moment from 'moment';
4
3
  import React, { useCallback, useState, useEffect, Fragment, useRef, useMemo } from 'react';
@@ -15,6 +14,597 @@ import { initReactI18next, useTranslation } from 'react-i18next';
15
14
  export { I18nextProvider, useTranslation } from 'react-i18next';
16
15
  import { IoChevronDown } from 'react-icons/io5';
17
16
 
17
+ function _extends() {
18
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
19
+ for (var i = 1; i < arguments.length; i++) {
20
+ var source = arguments[i];
21
+ for (var key in source) {
22
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
23
+ target[key] = source[key];
24
+ }
25
+ }
26
+ }
27
+ return target;
28
+ };
29
+ return _extends.apply(this, arguments);
30
+ }
31
+
32
+ function isAbsolute(pathname) {
33
+ return pathname.charAt(0) === '/';
34
+ }
35
+
36
+ // About 1.5x faster than the two-arg version of Array#splice()
37
+ function spliceOne(list, index) {
38
+ for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1) {
39
+ list[i] = list[k];
40
+ }
41
+
42
+ list.pop();
43
+ }
44
+
45
+ // This implementation is based heavily on node's url.parse
46
+ function resolvePathname(to, from) {
47
+ if (from === undefined) from = '';
48
+
49
+ var toParts = (to && to.split('/')) || [];
50
+ var fromParts = (from && from.split('/')) || [];
51
+
52
+ var isToAbs = to && isAbsolute(to);
53
+ var isFromAbs = from && isAbsolute(from);
54
+ var mustEndAbs = isToAbs || isFromAbs;
55
+
56
+ if (to && isAbsolute(to)) {
57
+ // to is absolute
58
+ fromParts = toParts;
59
+ } else if (toParts.length) {
60
+ // to is relative, drop the filename
61
+ fromParts.pop();
62
+ fromParts = fromParts.concat(toParts);
63
+ }
64
+
65
+ if (!fromParts.length) return '/';
66
+
67
+ var hasTrailingSlash;
68
+ if (fromParts.length) {
69
+ var last = fromParts[fromParts.length - 1];
70
+ hasTrailingSlash = last === '.' || last === '..' || last === '';
71
+ } else {
72
+ hasTrailingSlash = false;
73
+ }
74
+
75
+ var up = 0;
76
+ for (var i = fromParts.length; i >= 0; i--) {
77
+ var part = fromParts[i];
78
+
79
+ if (part === '.') {
80
+ spliceOne(fromParts, i);
81
+ } else if (part === '..') {
82
+ spliceOne(fromParts, i);
83
+ up++;
84
+ } else if (up) {
85
+ spliceOne(fromParts, i);
86
+ up--;
87
+ }
88
+ }
89
+
90
+ if (!mustEndAbs) for (; up--; up) fromParts.unshift('..');
91
+
92
+ if (
93
+ mustEndAbs &&
94
+ fromParts[0] !== '' &&
95
+ (!fromParts[0] || !isAbsolute(fromParts[0]))
96
+ )
97
+ fromParts.unshift('');
98
+
99
+ var result = fromParts.join('/');
100
+
101
+ if (hasTrailingSlash && result.substr(-1) !== '/') result += '/';
102
+
103
+ return result;
104
+ }
105
+
106
+ var isProduction = process.env.NODE_ENV === 'production';
107
+ function warning(condition, message) {
108
+ if (!isProduction) {
109
+ if (condition) {
110
+ return;
111
+ }
112
+
113
+ var text = "Warning: " + message;
114
+
115
+ if (typeof console !== 'undefined') {
116
+ console.warn(text);
117
+ }
118
+
119
+ try {
120
+ throw Error(text);
121
+ } catch (x) {}
122
+ }
123
+ }
124
+
125
+ var isProduction$1 = process.env.NODE_ENV === 'production';
126
+ var prefix = 'Invariant failed';
127
+ function invariant(condition, message) {
128
+ if (condition) {
129
+ return;
130
+ }
131
+ if (isProduction$1) {
132
+ throw new Error(prefix);
133
+ }
134
+ var provided = typeof message === 'function' ? message() : message;
135
+ var value = provided ? "".concat(prefix, ": ").concat(provided) : prefix;
136
+ throw new Error(value);
137
+ }
138
+
139
+ function addLeadingSlash(path) {
140
+ return path.charAt(0) === '/' ? path : '/' + path;
141
+ }
142
+ function hasBasename(path, prefix) {
143
+ return path.toLowerCase().indexOf(prefix.toLowerCase()) === 0 && '/?#'.indexOf(path.charAt(prefix.length)) !== -1;
144
+ }
145
+ function stripBasename(path, prefix) {
146
+ return hasBasename(path, prefix) ? path.substr(prefix.length) : path;
147
+ }
148
+ function stripTrailingSlash(path) {
149
+ return path.charAt(path.length - 1) === '/' ? path.slice(0, -1) : path;
150
+ }
151
+ function parsePath(path) {
152
+ var pathname = path || '/';
153
+ var search = '';
154
+ var hash = '';
155
+ var hashIndex = pathname.indexOf('#');
156
+
157
+ if (hashIndex !== -1) {
158
+ hash = pathname.substr(hashIndex);
159
+ pathname = pathname.substr(0, hashIndex);
160
+ }
161
+
162
+ var searchIndex = pathname.indexOf('?');
163
+
164
+ if (searchIndex !== -1) {
165
+ search = pathname.substr(searchIndex);
166
+ pathname = pathname.substr(0, searchIndex);
167
+ }
168
+
169
+ return {
170
+ pathname: pathname,
171
+ search: search === '?' ? '' : search,
172
+ hash: hash === '#' ? '' : hash
173
+ };
174
+ }
175
+ function createPath(location) {
176
+ var pathname = location.pathname,
177
+ search = location.search,
178
+ hash = location.hash;
179
+ var path = pathname || '/';
180
+ if (search && search !== '?') path += search.charAt(0) === '?' ? search : "?" + search;
181
+ if (hash && hash !== '#') path += hash.charAt(0) === '#' ? hash : "#" + hash;
182
+ return path;
183
+ }
184
+
185
+ function createLocation(path, state, key, currentLocation) {
186
+ var location;
187
+
188
+ if (typeof path === 'string') {
189
+ // Two-arg form: push(path, state)
190
+ location = parsePath(path);
191
+ location.state = state;
192
+ } else {
193
+ // One-arg form: push(location)
194
+ location = _extends({}, path);
195
+ if (location.pathname === undefined) location.pathname = '';
196
+
197
+ if (location.search) {
198
+ if (location.search.charAt(0) !== '?') location.search = '?' + location.search;
199
+ } else {
200
+ location.search = '';
201
+ }
202
+
203
+ if (location.hash) {
204
+ if (location.hash.charAt(0) !== '#') location.hash = '#' + location.hash;
205
+ } else {
206
+ location.hash = '';
207
+ }
208
+
209
+ if (state !== undefined && location.state === undefined) location.state = state;
210
+ }
211
+
212
+ try {
213
+ location.pathname = decodeURI(location.pathname);
214
+ } catch (e) {
215
+ if (e instanceof URIError) {
216
+ throw new URIError('Pathname "' + location.pathname + '" could not be decoded. ' + 'This is likely caused by an invalid percent-encoding.');
217
+ } else {
218
+ throw e;
219
+ }
220
+ }
221
+
222
+ if (key) location.key = key;
223
+
224
+ if (currentLocation) {
225
+ // Resolve incomplete/relative pathname relative to current location.
226
+ if (!location.pathname) {
227
+ location.pathname = currentLocation.pathname;
228
+ } else if (location.pathname.charAt(0) !== '/') {
229
+ location.pathname = resolvePathname(location.pathname, currentLocation.pathname);
230
+ }
231
+ } else {
232
+ // When there is no prior location and pathname is empty, set it to /
233
+ if (!location.pathname) {
234
+ location.pathname = '/';
235
+ }
236
+ }
237
+
238
+ return location;
239
+ }
240
+
241
+ function createTransitionManager() {
242
+ var prompt = null;
243
+
244
+ function setPrompt(nextPrompt) {
245
+ process.env.NODE_ENV !== "production" ? warning(prompt == null, 'A history supports only one prompt at a time') : void 0;
246
+ prompt = nextPrompt;
247
+ return function () {
248
+ if (prompt === nextPrompt) prompt = null;
249
+ };
250
+ }
251
+
252
+ function confirmTransitionTo(location, action, getUserConfirmation, callback) {
253
+ // TODO: If another transition starts while we're still confirming
254
+ // the previous one, we may end up in a weird state. Figure out the
255
+ // best way to handle this.
256
+ if (prompt != null) {
257
+ var result = typeof prompt === 'function' ? prompt(location, action) : prompt;
258
+
259
+ if (typeof result === 'string') {
260
+ if (typeof getUserConfirmation === 'function') {
261
+ getUserConfirmation(result, callback);
262
+ } else {
263
+ process.env.NODE_ENV !== "production" ? warning(false, 'A history needs a getUserConfirmation function in order to use a prompt message') : void 0;
264
+ callback(true);
265
+ }
266
+ } else {
267
+ // Return false from a transition hook to cancel the transition.
268
+ callback(result !== false);
269
+ }
270
+ } else {
271
+ callback(true);
272
+ }
273
+ }
274
+
275
+ var listeners = [];
276
+
277
+ function appendListener(fn) {
278
+ var isActive = true;
279
+
280
+ function listener() {
281
+ if (isActive) fn.apply(void 0, arguments);
282
+ }
283
+
284
+ listeners.push(listener);
285
+ return function () {
286
+ isActive = false;
287
+ listeners = listeners.filter(function (item) {
288
+ return item !== listener;
289
+ });
290
+ };
291
+ }
292
+
293
+ function notifyListeners() {
294
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
295
+ args[_key] = arguments[_key];
296
+ }
297
+
298
+ listeners.forEach(function (listener) {
299
+ return listener.apply(void 0, args);
300
+ });
301
+ }
302
+
303
+ return {
304
+ setPrompt: setPrompt,
305
+ confirmTransitionTo: confirmTransitionTo,
306
+ appendListener: appendListener,
307
+ notifyListeners: notifyListeners
308
+ };
309
+ }
310
+
311
+ var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
312
+ function getConfirmation(message, callback) {
313
+ callback(window.confirm(message)); // eslint-disable-line no-alert
314
+ }
315
+ /**
316
+ * Returns true if the HTML5 history API is supported. Taken from Modernizr.
317
+ *
318
+ * https://github.com/Modernizr/Modernizr/blob/master/LICENSE
319
+ * https://github.com/Modernizr/Modernizr/blob/master/feature-detects/history.js
320
+ * changed to avoid false negatives for Windows Phones: https://github.com/reactjs/react-router/issues/586
321
+ */
322
+
323
+ function supportsHistory() {
324
+ var ua = window.navigator.userAgent;
325
+ if ((ua.indexOf('Android 2.') !== -1 || ua.indexOf('Android 4.0') !== -1) && ua.indexOf('Mobile Safari') !== -1 && ua.indexOf('Chrome') === -1 && ua.indexOf('Windows Phone') === -1) return false;
326
+ return window.history && 'pushState' in window.history;
327
+ }
328
+ /**
329
+ * Returns true if browser fires popstate on hash change.
330
+ * IE10 and IE11 do not.
331
+ */
332
+
333
+ function supportsPopStateOnHashChange() {
334
+ return window.navigator.userAgent.indexOf('Trident') === -1;
335
+ }
336
+ /**
337
+ * Returns true if a given popstate event is an extraneous WebKit event.
338
+ * Accounts for the fact that Chrome on iOS fires real popstate events
339
+ * containing undefined state when pressing the back button.
340
+ */
341
+
342
+ function isExtraneousPopstateEvent(event) {
343
+ return event.state === undefined && navigator.userAgent.indexOf('CriOS') === -1;
344
+ }
345
+
346
+ var PopStateEvent = 'popstate';
347
+ var HashChangeEvent = 'hashchange';
348
+
349
+ function getHistoryState() {
350
+ try {
351
+ return window.history.state || {};
352
+ } catch (e) {
353
+ // IE 11 sometimes throws when accessing window.history.state
354
+ // See https://github.com/ReactTraining/history/pull/289
355
+ return {};
356
+ }
357
+ }
358
+ /**
359
+ * Creates a history object that uses the HTML5 history API including
360
+ * pushState, replaceState, and the popstate event.
361
+ */
362
+
363
+
364
+ function createBrowserHistory(props) {
365
+ if (props === void 0) {
366
+ props = {};
367
+ }
368
+
369
+ !canUseDOM ? process.env.NODE_ENV !== "production" ? invariant(false, 'Browser history needs a DOM') : invariant(false) : void 0;
370
+ var globalHistory = window.history;
371
+ var canUseHistory = supportsHistory();
372
+ var needsHashChangeListener = !supportsPopStateOnHashChange();
373
+ var _props = props,
374
+ _props$forceRefresh = _props.forceRefresh,
375
+ forceRefresh = _props$forceRefresh === void 0 ? false : _props$forceRefresh,
376
+ _props$getUserConfirm = _props.getUserConfirmation,
377
+ getUserConfirmation = _props$getUserConfirm === void 0 ? getConfirmation : _props$getUserConfirm,
378
+ _props$keyLength = _props.keyLength,
379
+ keyLength = _props$keyLength === void 0 ? 6 : _props$keyLength;
380
+ var basename = props.basename ? stripTrailingSlash(addLeadingSlash(props.basename)) : '';
381
+
382
+ function getDOMLocation(historyState) {
383
+ var _ref = historyState || {},
384
+ key = _ref.key,
385
+ state = _ref.state;
386
+
387
+ var _window$location = window.location,
388
+ pathname = _window$location.pathname,
389
+ search = _window$location.search,
390
+ hash = _window$location.hash;
391
+ var path = pathname + search + hash;
392
+ process.env.NODE_ENV !== "production" ? warning(!basename || hasBasename(path, basename), 'You are attempting to use a basename on a page whose URL path does not begin ' + 'with the basename. Expected path "' + path + '" to begin with "' + basename + '".') : void 0;
393
+ if (basename) path = stripBasename(path, basename);
394
+ return createLocation(path, state, key);
395
+ }
396
+
397
+ function createKey() {
398
+ return Math.random().toString(36).substr(2, keyLength);
399
+ }
400
+
401
+ var transitionManager = createTransitionManager();
402
+
403
+ function setState(nextState) {
404
+ _extends(history, nextState);
405
+
406
+ history.length = globalHistory.length;
407
+ transitionManager.notifyListeners(history.location, history.action);
408
+ }
409
+
410
+ function handlePopState(event) {
411
+ // Ignore extraneous popstate events in WebKit.
412
+ if (isExtraneousPopstateEvent(event)) return;
413
+ handlePop(getDOMLocation(event.state));
414
+ }
415
+
416
+ function handleHashChange() {
417
+ handlePop(getDOMLocation(getHistoryState()));
418
+ }
419
+
420
+ var forceNextPop = false;
421
+
422
+ function handlePop(location) {
423
+ if (forceNextPop) {
424
+ forceNextPop = false;
425
+ setState();
426
+ } else {
427
+ var action = 'POP';
428
+ transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
429
+ if (ok) {
430
+ setState({
431
+ action: action,
432
+ location: location
433
+ });
434
+ } else {
435
+ revertPop(location);
436
+ }
437
+ });
438
+ }
439
+ }
440
+
441
+ function revertPop(fromLocation) {
442
+ var toLocation = history.location; // TODO: We could probably make this more reliable by
443
+ // keeping a list of keys we've seen in sessionStorage.
444
+ // Instead, we just default to 0 for keys we don't know.
445
+
446
+ var toIndex = allKeys.indexOf(toLocation.key);
447
+ if (toIndex === -1) toIndex = 0;
448
+ var fromIndex = allKeys.indexOf(fromLocation.key);
449
+ if (fromIndex === -1) fromIndex = 0;
450
+ var delta = toIndex - fromIndex;
451
+
452
+ if (delta) {
453
+ forceNextPop = true;
454
+ go(delta);
455
+ }
456
+ }
457
+
458
+ var initialLocation = getDOMLocation(getHistoryState());
459
+ var allKeys = [initialLocation.key]; // Public interface
460
+
461
+ function createHref(location) {
462
+ return basename + createPath(location);
463
+ }
464
+
465
+ function push(path, state) {
466
+ process.env.NODE_ENV !== "production" ? warning(!(typeof path === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to push when the 1st ' + 'argument is a location-like object that already has state; it is ignored') : void 0;
467
+ var action = 'PUSH';
468
+ var location = createLocation(path, state, createKey(), history.location);
469
+ transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
470
+ if (!ok) return;
471
+ var href = createHref(location);
472
+ var key = location.key,
473
+ state = location.state;
474
+
475
+ if (canUseHistory) {
476
+ globalHistory.pushState({
477
+ key: key,
478
+ state: state
479
+ }, null, href);
480
+
481
+ if (forceRefresh) {
482
+ window.location.href = href;
483
+ } else {
484
+ var prevIndex = allKeys.indexOf(history.location.key);
485
+ var nextKeys = allKeys.slice(0, prevIndex + 1);
486
+ nextKeys.push(location.key);
487
+ allKeys = nextKeys;
488
+ setState({
489
+ action: action,
490
+ location: location
491
+ });
492
+ }
493
+ } else {
494
+ process.env.NODE_ENV !== "production" ? warning(state === undefined, 'Browser history cannot push state in browsers that do not support HTML5 history') : void 0;
495
+ window.location.href = href;
496
+ }
497
+ });
498
+ }
499
+
500
+ function replace(path, state) {
501
+ process.env.NODE_ENV !== "production" ? warning(!(typeof path === 'object' && path.state !== undefined && state !== undefined), 'You should avoid providing a 2nd state argument to replace when the 1st ' + 'argument is a location-like object that already has state; it is ignored') : void 0;
502
+ var action = 'REPLACE';
503
+ var location = createLocation(path, state, createKey(), history.location);
504
+ transitionManager.confirmTransitionTo(location, action, getUserConfirmation, function (ok) {
505
+ if (!ok) return;
506
+ var href = createHref(location);
507
+ var key = location.key,
508
+ state = location.state;
509
+
510
+ if (canUseHistory) {
511
+ globalHistory.replaceState({
512
+ key: key,
513
+ state: state
514
+ }, null, href);
515
+
516
+ if (forceRefresh) {
517
+ window.location.replace(href);
518
+ } else {
519
+ var prevIndex = allKeys.indexOf(history.location.key);
520
+ if (prevIndex !== -1) allKeys[prevIndex] = location.key;
521
+ setState({
522
+ action: action,
523
+ location: location
524
+ });
525
+ }
526
+ } else {
527
+ process.env.NODE_ENV !== "production" ? warning(state === undefined, 'Browser history cannot replace state in browsers that do not support HTML5 history') : void 0;
528
+ window.location.replace(href);
529
+ }
530
+ });
531
+ }
532
+
533
+ function go(n) {
534
+ globalHistory.go(n);
535
+ }
536
+
537
+ function goBack() {
538
+ go(-1);
539
+ }
540
+
541
+ function goForward() {
542
+ go(1);
543
+ }
544
+
545
+ var listenerCount = 0;
546
+
547
+ function checkDOMListeners(delta) {
548
+ listenerCount += delta;
549
+
550
+ if (listenerCount === 1 && delta === 1) {
551
+ window.addEventListener(PopStateEvent, handlePopState);
552
+ if (needsHashChangeListener) window.addEventListener(HashChangeEvent, handleHashChange);
553
+ } else if (listenerCount === 0) {
554
+ window.removeEventListener(PopStateEvent, handlePopState);
555
+ if (needsHashChangeListener) window.removeEventListener(HashChangeEvent, handleHashChange);
556
+ }
557
+ }
558
+
559
+ var isBlocked = false;
560
+
561
+ function block(prompt) {
562
+ if (prompt === void 0) {
563
+ prompt = false;
564
+ }
565
+
566
+ var unblock = transitionManager.setPrompt(prompt);
567
+
568
+ if (!isBlocked) {
569
+ checkDOMListeners(1);
570
+ isBlocked = true;
571
+ }
572
+
573
+ return function () {
574
+ if (isBlocked) {
575
+ isBlocked = false;
576
+ checkDOMListeners(-1);
577
+ }
578
+
579
+ return unblock();
580
+ };
581
+ }
582
+
583
+ function listen(listener) {
584
+ var unlisten = transitionManager.appendListener(listener);
585
+ checkDOMListeners(1);
586
+ return function () {
587
+ checkDOMListeners(-1);
588
+ unlisten();
589
+ };
590
+ }
591
+
592
+ var history = {
593
+ length: globalHistory.length,
594
+ action: 'POP',
595
+ location: initialLocation,
596
+ createHref: createHref,
597
+ push: push,
598
+ replace: replace,
599
+ go: go,
600
+ goBack: goBack,
601
+ goForward: goForward,
602
+ block: block,
603
+ listen: listen
604
+ };
605
+ return history;
606
+ }
607
+
18
608
  var setLoading = createAction("common/setLoading");
19
609
  var setAlert = createAction("common/setAlert");
20
610
  var setUser = createAction("common/setUser");
@@ -24,7 +614,7 @@ var GOOGLE_CLIENT_ID = "64118819726-0qlur4qjrs9jbuu6rnoa0u91g680lmpg.apps.google
24
614
  var GOOGLE_RECAPTCHA_ID = "6LfNtLUaAAAAAL24lbBV11jS-gBtt1mhtxb4NXs0";
25
615
  var ACCESS_TOKEN = "ACCESS_TOKEN";
26
616
  var DATE_MIN_VALUE = "0001-01-01T00:00:00+00:00";
27
- var BASE_URL = "https://localhost:7045";
617
+ var BASE_URL = "http://api.touchstudy.kr";
28
618
  var PUSHER_CONFIG = {
29
619
  cluster: "ap1",
30
620
  key: "9018c77328885a14150b"
@@ -464,7 +1054,7 @@ function kindOf(val) {
464
1054
  }
465
1055
 
466
1056
  // src/utils/warning.ts
467
- function warning(message) {
1057
+ function warning$1(message) {
468
1058
  if (typeof console !== "undefined" && typeof console.error === "function") {
469
1059
  console.error(message);
470
1060
  }
@@ -517,7 +1107,7 @@ function combineReducers(reducers) {
517
1107
  const key = reducerKeys[i];
518
1108
  if (process.env.NODE_ENV !== "production") {
519
1109
  if (typeof reducers[key] === "undefined") {
520
- warning(`No reducer provided for key "${key}"`);
1110
+ warning$1(`No reducer provided for key "${key}"`);
521
1111
  }
522
1112
  }
523
1113
  if (typeof reducers[key] === "function") {
@@ -542,7 +1132,7 @@ function combineReducers(reducers) {
542
1132
  if (process.env.NODE_ENV !== "production") {
543
1133
  const warningMessage = getUnexpectedStateShapeWarningMessage(state, finalReducers, action, unexpectedKeyCache);
544
1134
  if (warningMessage) {
545
- warning(warningMessage);
1135
+ warning$1(warningMessage);
546
1136
  }
547
1137
  }
548
1138
  let hasChanged = false;