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