@intoss/shared 0.0.14 → 0.0.16

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.
Files changed (2) hide show
  1. package/dist/index.js +867 -424
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,327 +1,677 @@
1
1
  "use strict";
2
+ function _array_like_to_array(arr, len) {
3
+ if (len == null || len > arr.length) len = arr.length;
4
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
5
+ return arr2;
6
+ }
7
+ function _array_with_holes(arr) {
8
+ if (Array.isArray(arr)) return arr;
9
+ }
10
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
11
+ try {
12
+ var info = gen[key](arg);
13
+ var value = info.value;
14
+ } catch (error) {
15
+ reject(error);
16
+ return;
17
+ }
18
+ if (info.done) {
19
+ resolve(value);
20
+ } else {
21
+ Promise.resolve(value).then(_next, _throw);
22
+ }
23
+ }
24
+ function _async_to_generator(fn) {
25
+ return function() {
26
+ var self = this, args = arguments;
27
+ return new Promise(function(resolve, reject) {
28
+ var gen = fn.apply(self, args);
29
+ function _next(value) {
30
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
31
+ }
32
+ function _throw(err) {
33
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
34
+ }
35
+ _next(undefined);
36
+ });
37
+ };
38
+ }
39
+ function _define_property(obj, key, value) {
40
+ if (key in obj) {
41
+ Object.defineProperty(obj, key, {
42
+ value: value,
43
+ enumerable: true,
44
+ configurable: true,
45
+ writable: true
46
+ });
47
+ } else {
48
+ obj[key] = value;
49
+ }
50
+ return obj;
51
+ }
52
+ function _iterable_to_array_limit(arr, i) {
53
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
54
+ if (_i == null) return;
55
+ var _arr = [];
56
+ var _n = true;
57
+ var _d = false;
58
+ var _s, _e;
59
+ try {
60
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
61
+ _arr.push(_s.value);
62
+ if (i && _arr.length === i) break;
63
+ }
64
+ } catch (err) {
65
+ _d = true;
66
+ _e = err;
67
+ } finally{
68
+ try {
69
+ if (!_n && _i["return"] != null) _i["return"]();
70
+ } finally{
71
+ if (_d) throw _e;
72
+ }
73
+ }
74
+ return _arr;
75
+ }
76
+ function _non_iterable_rest() {
77
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
78
+ }
79
+ function _object_spread(target) {
80
+ for(var i = 1; i < arguments.length; i++){
81
+ var source = arguments[i] != null ? arguments[i] : {};
82
+ var ownKeys = Object.keys(source);
83
+ if (typeof Object.getOwnPropertySymbols === "function") {
84
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
85
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
86
+ }));
87
+ }
88
+ ownKeys.forEach(function(key) {
89
+ _define_property(target, key, source[key]);
90
+ });
91
+ }
92
+ return target;
93
+ }
94
+ function ownKeys(object, enumerableOnly) {
95
+ var keys = Object.keys(object);
96
+ if (Object.getOwnPropertySymbols) {
97
+ var symbols = Object.getOwnPropertySymbols(object);
98
+ if (enumerableOnly) {
99
+ symbols = symbols.filter(function(sym) {
100
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
101
+ });
102
+ }
103
+ keys.push.apply(keys, symbols);
104
+ }
105
+ return keys;
106
+ }
107
+ function _object_spread_props(target, source) {
108
+ source = source != null ? source : {};
109
+ if (Object.getOwnPropertyDescriptors) {
110
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
111
+ } else {
112
+ ownKeys(Object(source)).forEach(function(key) {
113
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
114
+ });
115
+ }
116
+ return target;
117
+ }
118
+ function _sliced_to_array(arr, i) {
119
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
120
+ }
121
+ function _type_of(obj) {
122
+ "@swc/helpers - typeof";
123
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
124
+ }
125
+ function _unsupported_iterable_to_array(o, minLen) {
126
+ if (!o) return;
127
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
128
+ var n = Object.prototype.toString.call(o).slice(8, -1);
129
+ if (n === "Object" && o.constructor) n = o.constructor.name;
130
+ if (n === "Map" || n === "Set") return Array.from(n);
131
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
132
+ }
133
+ function _ts_generator(thisArg, body) {
134
+ var f, y, t, g, _ = {
135
+ label: 0,
136
+ sent: function() {
137
+ if (t[0] & 1) throw t[1];
138
+ return t[1];
139
+ },
140
+ trys: [],
141
+ ops: []
142
+ };
143
+ return g = {
144
+ next: verb(0),
145
+ "throw": verb(1),
146
+ "return": verb(2)
147
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
148
+ return this;
149
+ }), g;
150
+ function verb(n) {
151
+ return function(v) {
152
+ return step([
153
+ n,
154
+ v
155
+ ]);
156
+ };
157
+ }
158
+ function step(op) {
159
+ if (f) throw new TypeError("Generator is already executing.");
160
+ while(_)try {
161
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
162
+ if (y = 0, t) op = [
163
+ op[0] & 2,
164
+ t.value
165
+ ];
166
+ switch(op[0]){
167
+ case 0:
168
+ case 1:
169
+ t = op;
170
+ break;
171
+ case 4:
172
+ _.label++;
173
+ return {
174
+ value: op[1],
175
+ done: false
176
+ };
177
+ case 5:
178
+ _.label++;
179
+ y = op[1];
180
+ op = [
181
+ 0
182
+ ];
183
+ continue;
184
+ case 7:
185
+ op = _.ops.pop();
186
+ _.trys.pop();
187
+ continue;
188
+ default:
189
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
190
+ _ = 0;
191
+ continue;
192
+ }
193
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
194
+ _.label = op[1];
195
+ break;
196
+ }
197
+ if (op[0] === 6 && _.label < t[1]) {
198
+ _.label = t[1];
199
+ t = op;
200
+ break;
201
+ }
202
+ if (t && _.label < t[2]) {
203
+ _.label = t[2];
204
+ _.ops.push(op);
205
+ break;
206
+ }
207
+ if (t[2]) _.ops.pop();
208
+ _.trys.pop();
209
+ continue;
210
+ }
211
+ op = body.call(thisArg, _);
212
+ } catch (e) {
213
+ op = [
214
+ 6,
215
+ e
216
+ ];
217
+ y = 0;
218
+ } finally{
219
+ f = t = 0;
220
+ }
221
+ if (op[0] & 5) throw op[1];
222
+ return {
223
+ value: op[0] ? op[1] : void 0,
224
+ done: true
225
+ };
226
+ }
227
+ }
2
228
  var __defProp = Object.defineProperty;
3
- var __defProps = Object.defineProperties;
4
229
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
6
230
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
231
  var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
10
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
11
- var __spreadValues = (a, b) => {
12
- for (var prop in b || (b = {}))
13
- if (__hasOwnProp.call(b, prop))
14
- __defNormalProp(a, prop, b[prop]);
15
- if (__getOwnPropSymbols)
16
- for (var prop of __getOwnPropSymbols(b)) {
17
- if (__propIsEnum.call(b, prop))
18
- __defNormalProp(a, prop, b[prop]);
19
- }
20
- return a;
21
- };
22
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
23
- var __export = (target, all) => {
24
- for (var name in all)
25
- __defProp(target, name, { get: all[name], enumerable: true });
232
+ var __export = function(target, all) {
233
+ for(var name in all)__defProp(target, name, {
234
+ get: all[name],
235
+ enumerable: true
236
+ });
26
237
  };
27
- var __copyProps = (to, from, except, desc) => {
28
- if (from && typeof from === "object" || typeof from === "function") {
29
- for (let key of __getOwnPropNames(from))
30
- if (!__hasOwnProp.call(to, key) && key !== except)
31
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
32
- }
33
- return to;
238
+ var __copyProps = function(to, from, except, desc) {
239
+ if (from && (typeof from === "undefined" ? "undefined" : _type_of(from)) === "object" || typeof from === "function") {
240
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
241
+ try {
242
+ var _loop = function() {
243
+ var key = _step.value;
244
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
245
+ get: function() {
246
+ return from[key];
247
+ },
248
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
249
+ });
250
+ };
251
+ for(var _iterator = __getOwnPropNames(from)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
252
+ } catch (err) {
253
+ _didIteratorError = true;
254
+ _iteratorError = err;
255
+ } finally{
256
+ try {
257
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
258
+ _iterator.return();
259
+ }
260
+ } finally{
261
+ if (_didIteratorError) {
262
+ throw _iteratorError;
263
+ }
264
+ }
265
+ }
266
+ }
267
+ return to;
34
268
  };
35
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
36
- var __async = (__this, __arguments, generator) => {
37
- return new Promise((resolve, reject) => {
38
- var fulfilled = (value) => {
39
- try {
40
- step(generator.next(value));
41
- } catch (e) {
42
- reject(e);
43
- }
44
- };
45
- var rejected = (value) => {
46
- try {
47
- step(generator.throw(value));
48
- } catch (e) {
49
- reject(e);
50
- }
51
- };
52
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
53
- step((generator = generator.apply(__this, __arguments)).next());
54
- });
269
+ var __toCommonJS = function(mod) {
270
+ return __copyProps(__defProp({}, "__esModule", {
271
+ value: true
272
+ }), mod);
55
273
  };
56
-
57
274
  // src/index.ts
58
275
  var index_exports = {};
59
276
  __export(index_exports, {
60
- AdGroupProvider: () => AdGroupProvider,
61
- AuthStateProvider: () => AuthStateProvider,
62
- ConfigProvider: () => ConfigProvider,
63
- FetcherProvider: () => FetcherProvider,
64
- QueryProvider: () => QueryProvider,
65
- bind: () => bind,
66
- calculateDay: () => calculateDay,
67
- calculateDayOfWeek: () => calculateDayOfWeek,
68
- calculateHour: () => calculateHour,
69
- calculateMinute: () => calculateMinute,
70
- calculateWeek: () => calculateWeek,
71
- useAdGroup: () => useAdGroup,
72
- useAdvertisement: () => useAdvertisement,
73
- useAuthState: () => useAuthState,
74
- useConfig: () => useConfig,
75
- useFetcher: () => useFetcher,
76
- useSignInWithToss: () => useSignInWithToss,
77
- useStorage: () => useStorage
277
+ AdGroupProvider: function() {
278
+ return AdGroupProvider;
279
+ },
280
+ AuthStateProvider: function() {
281
+ return AuthStateProvider;
282
+ },
283
+ ConfigProvider: function() {
284
+ return ConfigProvider;
285
+ },
286
+ FetcherProvider: function() {
287
+ return FetcherProvider;
288
+ },
289
+ QueryProvider: function() {
290
+ return QueryProvider;
291
+ },
292
+ bind: function() {
293
+ return bind;
294
+ },
295
+ calculateDay: function() {
296
+ return calculateDay;
297
+ },
298
+ calculateDayOfWeek: function() {
299
+ return calculateDayOfWeek;
300
+ },
301
+ calculateHour: function() {
302
+ return calculateHour;
303
+ },
304
+ calculateMinute: function() {
305
+ return calculateMinute;
306
+ },
307
+ calculateWeek: function() {
308
+ return calculateWeek;
309
+ },
310
+ useAdGroup: function() {
311
+ return useAdGroup;
312
+ },
313
+ useAdvertisement: function() {
314
+ return useAdvertisement;
315
+ },
316
+ useAuthState: function() {
317
+ return useAuthState;
318
+ },
319
+ useConfig: function() {
320
+ return useConfig;
321
+ },
322
+ useFetcher: function() {
323
+ return useFetcher;
324
+ },
325
+ useSignInWithToss: function() {
326
+ return useSignInWithToss;
327
+ },
328
+ useStorage: function() {
329
+ return useStorage;
330
+ }
78
331
  });
79
332
  module.exports = __toCommonJS(index_exports);
80
-
81
333
  // src/config/ConfigContext/ConfigContext.tsx
82
334
  var import_react = require("react");
83
-
84
335
  // src/config/ConfigContext/constant.ts
85
336
  var import_framework = require("@apps-in-toss/framework");
86
337
  var RUNNING_ENVIRONMENT = (0, import_framework.getOperationalEnvironment)() === "sandbox" ? "local" : (0, import_framework.getSchemeUri)().startsWith("intoss-private") ? "preview" : "production";
87
338
  var API_ENDPOINT = {
88
- local: "http://localhost:3000",
89
- preview: "https://preview-api.intoss.app",
90
- production: "https://api.intoss.app"
339
+ local: "http://localhost:3000",
340
+ preview: "https://preview-api.intoss.app",
341
+ production: "https://api.intoss.app"
91
342
  }[RUNNING_ENVIRONMENT];
92
-
93
343
  // src/config/ConfigContext/ConfigContext.tsx
94
344
  var import_jsx_runtime = require("react/jsx-runtime");
95
345
  var ConfigContext = (0, import_react.createContext)({
96
- appName: "",
97
- apiEndpoint: "http://localhost:3000",
98
- runningEnvironment: "local"
346
+ appName: "",
347
+ apiEndpoint: "http://localhost:3000",
348
+ runningEnvironment: "local"
99
349
  });
100
- var ConfigProvider = ({ appName, children }) => {
101
- const contextValue = (0, import_react.useMemo)(
102
- () => ({
103
- appName,
104
- apiEndpoint: API_ENDPOINT,
105
- runningEnvironment: RUNNING_ENVIRONMENT
106
- }),
107
- [appName]
108
- );
109
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ConfigContext.Provider, { value: contextValue, children });
350
+ var ConfigProvider = function(param) {
351
+ var appName = param.appName, children = param.children;
352
+ var contextValue = (0, import_react.useMemo)(function() {
353
+ return {
354
+ appName: appName,
355
+ apiEndpoint: API_ENDPOINT,
356
+ runningEnvironment: RUNNING_ENVIRONMENT
357
+ };
358
+ }, [
359
+ appName
360
+ ]);
361
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ConfigContext.Provider, {
362
+ value: contextValue,
363
+ children: children
364
+ });
365
+ };
366
+ var useConfig = function() {
367
+ return (0, import_react.useContext)(ConfigContext);
110
368
  };
111
- var useConfig = () => (0, import_react.useContext)(ConfigContext);
112
-
113
369
  // src/advertisement/AdGroupContext/AdGroupContext.tsx
114
370
  var import_react2 = require("react");
115
371
  var import_jsx_runtime2 = require("react/jsx-runtime");
116
372
  var AdGroupContext = (0, import_react2.createContext)({
117
- getInterstitialAdGroup: () => ({ id: "ait-ad-test-interstitial-id", type: "interstitial" }),
118
- getRewardedAdGroup: () => ({ id: "ait-ad-test-rewarded-id", type: "rewarded" })
119
- });
120
- var AdGroupProvider = ({ initial, children }) => {
121
- const { appName, runningEnvironment } = useConfig();
122
- const [initialized, setInitialized] = (0, import_react2.useState)(runningEnvironment !== "production");
123
- const [adGroupList, setAdGroupList] = (0, import_react2.useState)(initial);
124
- const getInterstitialAdGroup = (0, import_react2.useCallback)(
125
- (key) => {
126
- var _a;
127
- return {
128
- id: (_a = adGroupList[key]) != null ? _a : "ait-ad-test-interstitial-id",
129
- type: "interstitial"
130
- };
131
- },
132
- [adGroupList]
133
- );
134
- const getRewardedAdGroup = (0, import_react2.useCallback)(
135
- (key) => {
136
- var _a;
137
- return {
138
- id: (_a = adGroupList[key]) != null ? _a : "ait-ad-test-rewarded-id",
139
- type: "rewarded"
140
- };
373
+ getInterstitialAdGroup: function() {
374
+ return {
375
+ id: "ait-ad-test-interstitial-id",
376
+ type: "interstitial"
377
+ };
141
378
  },
142
- [adGroupList]
143
- );
144
- const contextValue = (0, import_react2.useMemo)(
145
- () => ({
146
- getInterstitialAdGroup,
147
- getRewardedAdGroup
148
- }),
149
- [getInterstitialAdGroup, getRewardedAdGroup]
150
- );
151
- (0, import_react2.useEffect)(() => {
152
- if (initialized) {
153
- return;
379
+ getRewardedAdGroup: function() {
380
+ return {
381
+ id: "ait-ad-test-rewarded-id",
382
+ type: "rewarded"
383
+ };
384
+ }
385
+ });
386
+ var AdGroupProvider = function(param) {
387
+ var initial = param.initial, children = param.children;
388
+ var _useConfig = useConfig(), appName = _useConfig.appName, runningEnvironment = _useConfig.runningEnvironment;
389
+ var _ref = _sliced_to_array((0, import_react2.useState)(runningEnvironment !== "production"), 2), initialized = _ref[0], setInitialized = _ref[1];
390
+ var _ref1 = _sliced_to_array((0, import_react2.useState)(initial), 2), adGroupList = _ref1[0], setAdGroupList = _ref1[1];
391
+ var getInterstitialAdGroup = (0, import_react2.useCallback)(function(key) {
392
+ var _adGroupList_key;
393
+ return {
394
+ id: (_adGroupList_key = adGroupList[key]) !== null && _adGroupList_key !== void 0 ? _adGroupList_key : "ait-ad-test-interstitial-id",
395
+ type: "interstitial"
396
+ };
397
+ }, [
398
+ adGroupList
399
+ ]);
400
+ var getRewardedAdGroup = (0, import_react2.useCallback)(function(key) {
401
+ var _adGroupList_key;
402
+ return {
403
+ id: (_adGroupList_key = adGroupList[key]) !== null && _adGroupList_key !== void 0 ? _adGroupList_key : "ait-ad-test-rewarded-id",
404
+ type: "rewarded"
405
+ };
406
+ }, [
407
+ adGroupList
408
+ ]);
409
+ var contextValue = (0, import_react2.useMemo)(function() {
410
+ return {
411
+ getInterstitialAdGroup: getInterstitialAdGroup,
412
+ getRewardedAdGroup: getRewardedAdGroup
413
+ };
414
+ }, [
415
+ getInterstitialAdGroup,
416
+ getRewardedAdGroup
417
+ ]);
418
+ (0, import_react2.useEffect)(function() {
419
+ if (initialized) {
420
+ return;
421
+ }
422
+ var controller = new AbortController();
423
+ var timeoutId = setTimeout(function() {
424
+ return controller.abort();
425
+ }, 3e3);
426
+ fetch("https://static.intoss.app/".concat(appName, "/assets/adGroupList.json"), {
427
+ signal: controller.signal
428
+ }).then(function(res) {
429
+ return res.json();
430
+ }).then(setAdGroupList).finally(function() {
431
+ clearTimeout(timeoutId);
432
+ setInitialized(true);
433
+ });
434
+ }, [
435
+ appName,
436
+ initialized
437
+ ]);
438
+ if (!initialized) {
439
+ return null;
154
440
  }
155
- const controller = new AbortController();
156
- const timeoutId = setTimeout(() => controller.abort(), 3e3);
157
- fetch(`https://static.intoss.app/${appName}/assets/adGroupList.json`, {
158
- signal: controller.signal
159
- }).then((res) => res.json()).then(setAdGroupList).finally(() => {
160
- clearTimeout(timeoutId);
161
- setInitialized(true);
441
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AdGroupContext.Provider, {
442
+ value: contextValue,
443
+ children: children
162
444
  });
163
- }, [appName, initialized]);
164
- if (!initialized) {
165
- return null;
166
- }
167
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AdGroupContext.Provider, { value: contextValue, children });
168
445
  };
169
- var useAdGroup = () => (0, import_react2.useContext)(AdGroupContext);
170
-
446
+ var useAdGroup = function() {
447
+ return (0, import_react2.useContext)(AdGroupContext);
448
+ };
171
449
  // src/advertisement/useAdvertisement/useAdvertisement.ts
172
450
  var import_framework2 = require("@apps-in-toss/framework");
173
451
  var import_react3 = require("react");
174
- var useAdvertisement = ({
175
- primaryAdGroup,
176
- secondaryAdGroup,
177
- onShowAd,
178
- onDissmissAd
179
- }) => {
180
- const [initialized, setInitialized] = (0, import_react3.useState)(false);
181
- const [adLoaded, setAdLoaded] = (0, import_react3.useState)(false);
182
- const [adGroupId, setAdGroupId] = (0, import_react3.useState)();
183
- const [adCleanup, setAdCleanup] = (0, import_react3.useState)(null);
184
- const loadAd = (0, import_react3.useCallback)(
185
- (adGroupId2) => new Promise((resolve) => {
186
- const cleanup = import_framework2.GoogleAdMob.loadAppsInTossAdMob({
187
- options: {
188
- adGroupId: adGroupId2
189
- },
190
- onEvent: (event) => {
191
- switch (event.type) {
192
- case "loaded":
193
- resolve([true, cleanup]);
194
- break;
195
- }
196
- },
197
- onError: () => resolve([false, cleanup])
198
- });
199
- }),
200
- []
201
- );
202
- const loadWaterfall = (0, import_react3.useCallback)(() => __async(null, null, function* () {
203
- if (import_framework2.GoogleAdMob.loadAppsInTossAdMob.isSupported() !== true) {
204
- setInitialized(true);
205
- return;
206
- }
207
- if (adLoaded) {
208
- return;
209
- }
210
- const [primaryAdLoaded, primaryAdCleanup] = yield loadAd(primaryAdGroup.id);
211
- if (primaryAdLoaded) {
212
- setInitialized(true);
213
- setAdLoaded(true);
214
- setAdGroupId(primaryAdGroup.id);
215
- setAdCleanup(() => primaryAdCleanup);
216
- return;
217
- }
218
- primaryAdCleanup();
219
- if (!secondaryAdGroup) {
220
- setInitialized(true);
221
- return;
222
- }
223
- const [secondaryAdLoaded, secondaryAdCleanup] = yield loadAd(secondaryAdGroup.id);
224
- if (secondaryAdLoaded) {
225
- setInitialized(true);
226
- setAdLoaded(true);
227
- setAdGroupId(secondaryAdGroup.id);
228
- setAdCleanup(() => secondaryAdCleanup);
229
- return;
230
- }
231
- secondaryAdCleanup();
232
- setInitialized(true);
233
- }), [primaryAdGroup, secondaryAdGroup, adLoaded, loadAd]);
234
- const cleanupAd = (0, import_react3.useCallback)(() => {
235
- adCleanup == null ? void 0 : adCleanup();
236
- setAdLoaded(false);
237
- setAdGroupId(void 0);
238
- setAdCleanup(null);
239
- }, [adCleanup]);
240
- const showAd = (0, import_react3.useCallback)(() => {
241
- if (import_framework2.GoogleAdMob.loadAppsInTossAdMob.isSupported() !== true) {
242
- onShowAd == null ? void 0 : onShowAd();
243
- onDissmissAd == null ? void 0 : onDissmissAd();
244
- return;
245
- }
246
- if (!adLoaded || !adGroupId) {
247
- onShowAd == null ? void 0 : onShowAd();
248
- onDissmissAd == null ? void 0 : onDissmissAd();
249
- return;
250
- }
251
- import_framework2.GoogleAdMob.showAppsInTossAdMob({
252
- options: {
253
- adGroupId
254
- },
255
- onEvent: (event) => {
256
- switch (event.type) {
257
- case "show":
258
- if (adGroupId === primaryAdGroup.id && primaryAdGroup.type === "interstitial" || adGroupId === (secondaryAdGroup == null ? void 0 : secondaryAdGroup.id) && secondaryAdGroup.type === "interstitial") {
259
- onShowAd == null ? void 0 : onShowAd();
452
+ var useAdvertisement = function(param) {
453
+ var primaryAdGroup = param.primaryAdGroup, secondaryAdGroup = param.secondaryAdGroup, onShowAd = param.onShowAd, onDissmissAd = param.onDissmissAd;
454
+ var _ref = _sliced_to_array((0, import_react3.useState)(false), 2), initialized = _ref[0], setInitialized = _ref[1];
455
+ var _ref1 = _sliced_to_array((0, import_react3.useState)(false), 2), adLoaded = _ref1[0], setAdLoaded = _ref1[1];
456
+ var _ref2 = _sliced_to_array((0, import_react3.useState)(), 2), adGroupId = _ref2[0], setAdGroupId = _ref2[1];
457
+ var _ref3 = _sliced_to_array((0, import_react3.useState)(null), 2), adCleanup = _ref3[0], setAdCleanup = _ref3[1];
458
+ var loadAd = (0, import_react3.useCallback)(function(adGroupId2) {
459
+ return new Promise(function(resolve) {
460
+ var cleanup = import_framework2.GoogleAdMob.loadAppsInTossAdMob({
461
+ options: {
462
+ adGroupId: adGroupId2
463
+ },
464
+ onEvent: function(event) {
465
+ switch(event.type){
466
+ case "loaded":
467
+ resolve([
468
+ true,
469
+ cleanup
470
+ ]);
471
+ break;
472
+ }
473
+ },
474
+ onError: function() {
475
+ return resolve([
476
+ false,
477
+ cleanup
478
+ ]);
479
+ }
480
+ });
481
+ });
482
+ }, []);
483
+ var loadWaterfall = (0, import_react3.useCallback)(/*#__PURE__*/ _async_to_generator(function() {
484
+ var _ref, primaryAdLoaded, primaryAdCleanup, _ref1, secondaryAdLoaded, secondaryAdCleanup;
485
+ return _ts_generator(this, function(_state) {
486
+ switch(_state.label){
487
+ case 0:
488
+ if (import_framework2.GoogleAdMob.loadAppsInTossAdMob.isSupported() !== true) {
489
+ setInitialized(true);
490
+ return [
491
+ 2
492
+ ];
493
+ }
494
+ if (adLoaded) {
495
+ return [
496
+ 2
497
+ ];
498
+ }
499
+ return [
500
+ 4,
501
+ loadAd(primaryAdGroup.id)
502
+ ];
503
+ case 1:
504
+ _ref = _sliced_to_array.apply(void 0, [
505
+ _state.sent(),
506
+ 2
507
+ ]), primaryAdLoaded = _ref[0], primaryAdCleanup = _ref[1];
508
+ if (primaryAdLoaded) {
509
+ setInitialized(true);
510
+ setAdLoaded(true);
511
+ setAdGroupId(primaryAdGroup.id);
512
+ setAdCleanup(function() {
513
+ return primaryAdCleanup;
514
+ });
515
+ return [
516
+ 2
517
+ ];
518
+ }
519
+ primaryAdCleanup();
520
+ if (!secondaryAdGroup) {
521
+ setInitialized(true);
522
+ return [
523
+ 2
524
+ ];
525
+ }
526
+ return [
527
+ 4,
528
+ loadAd(secondaryAdGroup.id)
529
+ ];
530
+ case 2:
531
+ _ref1 = _sliced_to_array.apply(void 0, [
532
+ _state.sent(),
533
+ 2
534
+ ]), secondaryAdLoaded = _ref1[0], secondaryAdCleanup = _ref1[1];
535
+ if (secondaryAdLoaded) {
536
+ setInitialized(true);
537
+ setAdLoaded(true);
538
+ setAdGroupId(secondaryAdGroup.id);
539
+ setAdCleanup(function() {
540
+ return secondaryAdCleanup;
541
+ });
542
+ return [
543
+ 2
544
+ ];
545
+ }
546
+ secondaryAdCleanup();
547
+ setInitialized(true);
548
+ return [
549
+ 2
550
+ ];
260
551
  }
261
- break;
262
- case "failedToShow":
263
- onShowAd == null ? void 0 : onShowAd();
264
- cleanupAd();
265
- break;
266
- case "dismissed":
267
- onDissmissAd == null ? void 0 : onDissmissAd();
268
- cleanupAd();
269
- break;
270
- case "userEarnedReward":
271
- onShowAd == null ? void 0 : onShowAd();
272
- break;
552
+ });
553
+ }), [
554
+ primaryAdGroup,
555
+ secondaryAdGroup,
556
+ adLoaded,
557
+ loadAd
558
+ ]);
559
+ var cleanupAd = (0, import_react3.useCallback)(function() {
560
+ adCleanup === null || adCleanup === void 0 ? void 0 : adCleanup();
561
+ setAdLoaded(false);
562
+ setAdGroupId(void 0);
563
+ setAdCleanup(null);
564
+ }, [
565
+ adCleanup
566
+ ]);
567
+ var showAd = (0, import_react3.useCallback)(function() {
568
+ if (import_framework2.GoogleAdMob.loadAppsInTossAdMob.isSupported() !== true) {
569
+ onShowAd === null || onShowAd === void 0 ? void 0 : onShowAd();
570
+ onDissmissAd === null || onDissmissAd === void 0 ? void 0 : onDissmissAd();
571
+ return;
273
572
  }
274
- },
275
- onError: () => {
276
- onShowAd == null ? void 0 : onShowAd();
277
- cleanupAd();
278
- }
279
- });
280
- }, [adLoaded, adGroupId, primaryAdGroup, secondaryAdGroup, onShowAd, onDissmissAd, cleanupAd]);
281
- (0, import_react3.useEffect)(() => {
282
- if (!adGroupId) {
283
- loadWaterfall();
284
- }
285
- }, [adGroupId, loadWaterfall]);
286
- (0, import_react3.useEffect)(() => () => cleanupAd(), []);
287
- return {
288
- initialized,
289
- adLoaded,
290
- showAd
291
- };
573
+ if (!adLoaded || !adGroupId) {
574
+ onShowAd === null || onShowAd === void 0 ? void 0 : onShowAd();
575
+ onDissmissAd === null || onDissmissAd === void 0 ? void 0 : onDissmissAd();
576
+ return;
577
+ }
578
+ import_framework2.GoogleAdMob.showAppsInTossAdMob({
579
+ options: {
580
+ adGroupId: adGroupId
581
+ },
582
+ onEvent: function(event) {
583
+ switch(event.type){
584
+ case "show":
585
+ if (adGroupId === primaryAdGroup.id && primaryAdGroup.type === "interstitial" || adGroupId === (secondaryAdGroup === null || secondaryAdGroup === void 0 ? void 0 : secondaryAdGroup.id) && secondaryAdGroup.type === "interstitial") {
586
+ onShowAd === null || onShowAd === void 0 ? void 0 : onShowAd();
587
+ }
588
+ break;
589
+ case "failedToShow":
590
+ onShowAd === null || onShowAd === void 0 ? void 0 : onShowAd();
591
+ cleanupAd();
592
+ break;
593
+ case "dismissed":
594
+ onDissmissAd === null || onDissmissAd === void 0 ? void 0 : onDissmissAd();
595
+ cleanupAd();
596
+ break;
597
+ case "userEarnedReward":
598
+ onShowAd === null || onShowAd === void 0 ? void 0 : onShowAd();
599
+ break;
600
+ }
601
+ },
602
+ onError: function() {
603
+ onShowAd === null || onShowAd === void 0 ? void 0 : onShowAd();
604
+ cleanupAd();
605
+ }
606
+ });
607
+ }, [
608
+ adLoaded,
609
+ adGroupId,
610
+ primaryAdGroup,
611
+ secondaryAdGroup,
612
+ onShowAd,
613
+ onDissmissAd,
614
+ cleanupAd
615
+ ]);
616
+ (0, import_react3.useEffect)(function() {
617
+ if (!adGroupId) {
618
+ loadWaterfall();
619
+ }
620
+ }, [
621
+ adGroupId,
622
+ loadWaterfall
623
+ ]);
624
+ (0, import_react3.useEffect)(function() {
625
+ return function() {
626
+ return cleanupAd();
627
+ };
628
+ }, []);
629
+ return {
630
+ initialized: initialized,
631
+ adLoaded: adLoaded,
632
+ showAd: showAd
633
+ };
292
634
  };
293
-
294
635
  // src/auth-state/AuthStateContext/AuthStateContext.tsx
295
636
  var import_react_query = require("@tanstack/react-query");
296
637
  var import_react4 = require("react");
297
638
  var import_jsx_runtime3 = require("react/jsx-runtime");
298
639
  var AuthStateContext = (0, import_react4.createContext)({
299
- isPreparing: true,
300
- isLoggedIn: false,
301
- retry: () => Promise.resolve()
640
+ isPreparing: true,
641
+ isLoggedIn: false,
642
+ retry: function() {
643
+ return Promise.resolve();
644
+ }
302
645
  });
303
- var AuthStateProvider = ({ children }) => {
304
- const { data, isFetching, refetch } = (0, import_react_query.useQuery)({
305
- queryKey: ["/my/user"]
306
- });
307
- const contextValue = (0, import_react4.useMemo)(
308
- () => {
309
- var _a;
310
- return {
311
- isPreparing: isFetching,
312
- isLoggedIn: Boolean((_a = data == null ? void 0 : data.user) == null ? void 0 : _a.id),
313
- retry: refetch
314
- };
315
- },
316
- [data, isFetching, refetch]
317
- );
318
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(AuthStateContext.Provider, { value: contextValue, children });
646
+ var AuthStateProvider = function(param) {
647
+ var children = param.children;
648
+ var _ref = (0, import_react_query.useQuery)({
649
+ queryKey: [
650
+ "/my/user"
651
+ ]
652
+ }), data = _ref.data, isFetching = _ref.isFetching, refetch = _ref.refetch;
653
+ var contextValue = (0, import_react4.useMemo)(function() {
654
+ var _data_user;
655
+ return {
656
+ isPreparing: isFetching,
657
+ isLoggedIn: Boolean(data === null || data === void 0 ? void 0 : (_data_user = data.user) === null || _data_user === void 0 ? void 0 : _data_user.id),
658
+ retry: refetch
659
+ };
660
+ }, [
661
+ data,
662
+ isFetching,
663
+ refetch
664
+ ]);
665
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(AuthStateContext.Provider, {
666
+ value: contextValue,
667
+ children: children
668
+ });
669
+ };
670
+ var useAuthState = function() {
671
+ return (0, import_react4.useContext)(AuthStateContext);
319
672
  };
320
- var useAuthState = () => (0, import_react4.useContext)(AuthStateContext);
321
-
322
673
  // src/auth-state/useSignInWithToss/useSignInWithToss.ts
323
674
  var import_framework4 = require("@apps-in-toss/framework");
324
-
325
675
  // src/query/FetcherContext/FetcherContext.tsx
326
676
  var import_framework3 = require("@apps-in-toss/framework");
327
677
  var import_string = require("es-toolkit/string");
@@ -329,194 +679,287 @@ var import_react5 = require("react");
329
679
  var import_jsx_runtime4 = require("react/jsx-runtime");
330
680
  var KEY_TOKEN = "@auth/token";
331
681
  var FetcherContext = (0, import_react5.createContext)({
332
- fetcher: fetch,
333
- setToken: () => null
682
+ fetcher: fetch,
683
+ setToken: function() {
684
+ return null;
685
+ }
334
686
  });
335
- var camelizeKeys = (input) => {
336
- if (Array.isArray(input)) {
337
- return input.map(camelizeKeys);
338
- }
339
- if (input !== null && typeof input === "object") {
340
- return Object.fromEntries(
341
- Object.entries(input).map(([key, value]) => [(0, import_string.camelCase)(key), camelizeKeys(value)])
342
- );
343
- }
344
- return input;
687
+ var camelizeKeys = function(input) {
688
+ if (Array.isArray(input)) {
689
+ return input.map(camelizeKeys);
690
+ }
691
+ if (input !== null && (typeof input === "undefined" ? "undefined" : _type_of(input)) === "object") {
692
+ return Object.fromEntries(Object.entries(input).map(function(param) {
693
+ var _param = _sliced_to_array(param, 2), key = _param[0], value = _param[1];
694
+ return [
695
+ (0, import_string.camelCase)(key),
696
+ camelizeKeys(value)
697
+ ];
698
+ }));
699
+ }
700
+ return input;
701
+ };
702
+ var FetcherProvider = function(param) {
703
+ var baseUrl = param.baseUrl, children = param.children;
704
+ var _useConfig = useConfig(), appName = _useConfig.appName, apiEndpoint = _useConfig.apiEndpoint;
705
+ var _ref = _sliced_to_array((0, import_react5.useState)(null), 2), token = _ref[0], setToken = _ref[1];
706
+ var _ref1 = _sliced_to_array((0, import_react5.useState)(false), 2), initialized = _ref1[0], setInitialized = _ref1[1];
707
+ var fetcher = (0, import_react5.useCallback)(function(input, init) {
708
+ return fetch("".concat(baseUrl !== null && baseUrl !== void 0 ? baseUrl : apiEndpoint, "/").concat(appName).concat(input), _object_spread_props(_object_spread({}, init), {
709
+ headers: _object_spread({
710
+ "Content-Type": "application/json"
711
+ }, init === null || init === void 0 ? void 0 : init.headers, token ? {
712
+ Authorization: "Bearer ".concat(token)
713
+ } : {})
714
+ })).then(function(res) {
715
+ return res.json();
716
+ }).then(function(data) {
717
+ return camelizeKeys(data);
718
+ });
719
+ }, [
720
+ appName,
721
+ apiEndpoint,
722
+ token,
723
+ baseUrl
724
+ ]);
725
+ (0, import_react5.useEffect)(function() {
726
+ import_framework3.Storage.getItem(KEY_TOKEN).then(setToken).finally(function() {
727
+ return setInitialized(true);
728
+ });
729
+ }, []);
730
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FetcherContext.Provider, {
731
+ value: {
732
+ fetcher: fetcher,
733
+ setToken: setToken
734
+ },
735
+ children: initialized ? children : null
736
+ });
345
737
  };
346
- var FetcherProvider = ({ baseUrl, children }) => {
347
- const { appName, apiEndpoint } = useConfig();
348
- const [token, setToken] = (0, import_react5.useState)(null);
349
- const [initialized, setInitialized] = (0, import_react5.useState)(false);
350
- const fetcher = (0, import_react5.useCallback)(
351
- (input, init) => fetch(`${baseUrl != null ? baseUrl : apiEndpoint}/${appName}${input}`, __spreadProps(__spreadValues({}, init), {
352
- headers: __spreadValues(__spreadValues({
353
- "Content-Type": "application/json"
354
- }, init == null ? void 0 : init.headers), token ? { Authorization: `Bearer ${token}` } : {})
355
- })).then((res) => res.json()).then((data) => camelizeKeys(data)),
356
- [appName, apiEndpoint, token, baseUrl]
357
- );
358
- (0, import_react5.useEffect)(() => {
359
- import_framework3.Storage.getItem(KEY_TOKEN).then(setToken).finally(() => setInitialized(true));
360
- }, []);
361
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FetcherContext.Provider, { value: { fetcher, setToken }, children: initialized ? children : null });
738
+ var useFetcher = function() {
739
+ return (0, import_react5.useContext)(FetcherContext);
362
740
  };
363
- var useFetcher = () => (0, import_react5.useContext)(FetcherContext);
364
-
365
741
  // src/view-model/bind/bind.ts
366
742
  var import_react6 = require("react");
367
- var bind = (useViewModel, ViewComponent, options) => {
368
- const { displayName } = options != null ? options : {};
369
- const MemoizedViewComponent = (0, import_react6.memo)(ViewComponent);
370
- const Component = (0, import_react6.memo)(
371
- (props) => (0, import_react6.createElement)(
372
- MemoizedViewComponent,
373
- useViewModel(props)
374
- )
375
- );
376
- Component.ViewComponent = MemoizedViewComponent;
377
- if (displayName) {
378
- Component.displayName = displayName;
379
- Component.ViewComponent.displayName = `${displayName}View`;
380
- }
381
- return Component;
743
+ var bind = function(useViewModel, ViewComponent, options) {
744
+ var displayName = (options !== null && options !== void 0 ? options : {}).displayName;
745
+ var MemoizedViewComponent = (0, import_react6.memo)(ViewComponent);
746
+ var Component = (0, import_react6.memo)(function(props) {
747
+ return (0, import_react6.createElement)(MemoizedViewComponent, useViewModel(props));
748
+ });
749
+ Component.ViewComponent = MemoizedViewComponent;
750
+ if (displayName) {
751
+ Component.displayName = displayName;
752
+ Component.ViewComponent.displayName = "".concat(displayName, "View");
753
+ }
754
+ return Component;
382
755
  };
383
-
384
756
  // src/query/QueryProvider/QueryProvider.tsx
385
757
  var import_react_query3 = require("@tanstack/react-query");
386
-
387
758
  // src/query/QueryProvider/useQueryProvider.ts
388
759
  var import_react_query2 = require("@tanstack/react-query");
389
760
  var import_react7 = require("react");
390
- var useQueryProvider = ({ children }) => {
391
- const { fetcher } = useFetcher();
392
- const queryClient = (0, import_react7.useMemo)(
393
- () => new import_react_query2.QueryClient({
394
- defaultOptions: {
395
- queries: {
396
- queryFn: ({ queryKey }) => fetcher(queryKey[0])
397
- }
398
- }
399
- }),
400
- [fetcher]
401
- );
402
- return {
403
- queryClient,
404
- children
405
- };
761
+ var useQueryProvider = function(param) {
762
+ var children = param.children;
763
+ var fetcher = useFetcher().fetcher;
764
+ var queryClient = (0, import_react7.useMemo)(function() {
765
+ return new import_react_query2.QueryClient({
766
+ defaultOptions: {
767
+ queries: {
768
+ queryFn: function(param) {
769
+ var queryKey = param.queryKey;
770
+ return fetcher(queryKey[0]);
771
+ }
772
+ }
773
+ }
774
+ });
775
+ }, [
776
+ fetcher
777
+ ]);
778
+ return {
779
+ queryClient: queryClient,
780
+ children: children
781
+ };
406
782
  };
407
-
408
783
  // src/query/QueryProvider/QueryProvider.tsx
409
784
  var import_jsx_runtime5 = require("react/jsx-runtime");
410
- var QueryProvider = bind(useQueryProvider, ({ queryClient, children }) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_query3.QueryClientProvider, { client: queryClient, children }));
411
-
785
+ var QueryProvider = bind(useQueryProvider, function(param) {
786
+ var queryClient = param.queryClient, children = param.children;
787
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_query3.QueryClientProvider, {
788
+ client: queryClient,
789
+ children: children
790
+ });
791
+ });
412
792
  // src/auth-state/useSignInWithToss/useSignInWithToss.ts
413
793
  var import_react_query4 = require("@tanstack/react-query");
414
794
  var import_react8 = require("react");
415
795
  var KEY_TOKEN2 = "@auth/token";
416
- var useSignInWithToss = ({ onSuccess }) => {
417
- const { retry } = useAuthState();
418
- const { fetcher, setToken } = useFetcher();
419
- const signInWithTossMutation = (0, import_react_query4.useMutation)({
420
- mutationFn: (body) => __async(null, null, function* () {
421
- return fetcher("/my/sessions", {
422
- method: "POST",
423
- body: JSON.stringify(body)
424
- });
425
- }),
426
- onSuccess: (data) => __async(null, null, function* () {
427
- setToken(data.token);
428
- yield import_framework4.Storage.setItem(KEY_TOKEN2, data.token);
429
- yield retry();
430
- onSuccess == null ? void 0 : onSuccess();
431
- })
432
- });
433
- const signInWithToss = (0, import_react8.useCallback)(() => __async(null, null, function* () {
434
- const { authorizationCode, referrer } = yield (0, import_framework4.appLogin)();
435
- signInWithTossMutation.mutate({
436
- authorizationCode,
437
- referrer
796
+ var useSignInWithToss = function(param) {
797
+ var onSuccess = param.onSuccess;
798
+ var retry = useAuthState().retry;
799
+ var _useFetcher = useFetcher(), fetcher = _useFetcher.fetcher, setToken = _useFetcher.setToken;
800
+ var signInWithTossMutation = (0, import_react_query4.useMutation)({
801
+ mutationFn: function() {
802
+ var _ref = _async_to_generator(function(body) {
803
+ return _ts_generator(this, function(_state) {
804
+ return [
805
+ 2,
806
+ fetcher("/my/sessions", {
807
+ method: "POST",
808
+ body: JSON.stringify(body)
809
+ })
810
+ ];
811
+ });
812
+ });
813
+ return function(body) {
814
+ return _ref.apply(this, arguments);
815
+ };
816
+ }(),
817
+ onSuccess: function() {
818
+ var _ref = _async_to_generator(function(data) {
819
+ return _ts_generator(this, function(_state) {
820
+ switch(_state.label){
821
+ case 0:
822
+ setToken(data.token);
823
+ return [
824
+ 4,
825
+ import_framework4.Storage.setItem(KEY_TOKEN2, data.token)
826
+ ];
827
+ case 1:
828
+ _state.sent();
829
+ return [
830
+ 4,
831
+ retry()
832
+ ];
833
+ case 2:
834
+ _state.sent();
835
+ onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess();
836
+ return [
837
+ 2
838
+ ];
839
+ }
840
+ });
841
+ });
842
+ return function(data) {
843
+ return _ref.apply(this, arguments);
844
+ };
845
+ }()
438
846
  });
439
- }), [signInWithTossMutation]);
440
- return {
441
- signInWithToss,
442
- isLoading: signInWithTossMutation.isPending
443
- };
847
+ var signInWithToss = (0, import_react8.useCallback)(/*#__PURE__*/ _async_to_generator(function() {
848
+ var _ref, authorizationCode, referrer;
849
+ return _ts_generator(this, function(_state) {
850
+ switch(_state.label){
851
+ case 0:
852
+ return [
853
+ 4,
854
+ (0, import_framework4.appLogin)()
855
+ ];
856
+ case 1:
857
+ _ref = _state.sent(), authorizationCode = _ref.authorizationCode, referrer = _ref.referrer;
858
+ signInWithTossMutation.mutate({
859
+ authorizationCode: authorizationCode,
860
+ referrer: referrer
861
+ });
862
+ return [
863
+ 2
864
+ ];
865
+ }
866
+ });
867
+ }), [
868
+ signInWithTossMutation
869
+ ]);
870
+ return {
871
+ signInWithToss: signInWithToss,
872
+ isLoading: signInWithTossMutation.isPending
873
+ };
444
874
  };
445
-
446
875
  // src/calendar/calculateDay/calculateDay.ts
447
876
  var MS_PER_DAY = 864e5;
448
877
  var KST_OFFSET_MS = 324e5;
449
- var calculateDay = (timestamp) => Math.floor((timestamp + KST_OFFSET_MS) / MS_PER_DAY);
450
-
878
+ var calculateDay = function(timestamp) {
879
+ return Math.floor((timestamp + KST_OFFSET_MS) / MS_PER_DAY);
880
+ };
451
881
  // src/calendar/calculateDayOfWeek/calculateDayOfWeek.ts
452
882
  var KST_OFFSET_WEEKDAY = 3;
453
- var calculateDayOfWeek = (day) => (day + KST_OFFSET_WEEKDAY) % 7;
454
-
883
+ var calculateDayOfWeek = function(day) {
884
+ return (day + KST_OFFSET_WEEKDAY) % 7;
885
+ };
455
886
  // src/calendar/calculateHour/calculateHour.ts
456
887
  var MS_PER_DAY2 = 864e5;
457
888
  var MS_PER_HOUR = 36e5;
458
889
  var KST_OFFSET_MS2 = 324e5;
459
- var calculateHour = (timestamp) => Math.floor((timestamp + KST_OFFSET_MS2) % MS_PER_DAY2 / MS_PER_HOUR);
460
-
890
+ var calculateHour = function(timestamp) {
891
+ return Math.floor((timestamp + KST_OFFSET_MS2) % MS_PER_DAY2 / MS_PER_HOUR);
892
+ };
461
893
  // src/calendar/calculateMinute/calculateMinute.ts
462
894
  var MS_PER_HOUR2 = 36e5;
463
895
  var MS_PER_MINUTE = 6e4;
464
896
  var KST_OFFSET_MS3 = 324e5;
465
- var calculateMinute = (timestamp) => Math.floor((timestamp + KST_OFFSET_MS3) % MS_PER_HOUR2 / MS_PER_MINUTE);
466
-
897
+ var calculateMinute = function(timestamp) {
898
+ return Math.floor((timestamp + KST_OFFSET_MS3) % MS_PER_HOUR2 / MS_PER_MINUTE);
899
+ };
467
900
  // src/calendar/calculateWeek/calculateWeek.ts
468
901
  var KST_OFFSET_WEEKDAY2 = 3;
469
- var calculateWeek = (day) => Math.floor((day + KST_OFFSET_WEEKDAY2) / 7);
470
-
902
+ var calculateWeek = function(day) {
903
+ return Math.floor((day + KST_OFFSET_WEEKDAY2) / 7);
904
+ };
471
905
  // src/storage/useStorage/useStorage.ts
472
906
  var import_framework5 = require("@apps-in-toss/framework");
473
907
  var import_react9 = require("react");
474
908
  var import_react_native = require("react-native");
475
- var useStorage = (key) => {
476
- const [stateValue, setStateValue] = (0, import_react9.useState)();
477
- const [isLoading, setIsLoading] = (0, import_react9.useState)(true);
478
- const updateValue = (0, import_react9.useCallback)(
479
- (value) => {
480
- setStateValue(value);
481
- import_react_native.DeviceEventEmitter.emit(key, value);
482
- return import_framework5.Storage.setItem(key, JSON.stringify({ value }));
483
- },
484
- [key]
485
- );
486
- (0, import_react9.useEffect)(() => {
487
- setIsLoading(true);
488
- import_framework5.Storage.getItem(key).then((item) => {
489
- try {
490
- setStateValue(item === null ? void 0 : JSON.parse(item).value);
491
- } catch (e) {
492
- setStateValue(void 0);
493
- } finally {
494
- setIsLoading(false);
495
- }
496
- });
497
- const updateValueListener = import_react_native.DeviceEventEmitter.addListener(key, setStateValue);
498
- return () => updateValueListener.remove();
499
- }, [key]);
500
- return [stateValue, updateValue, isLoading];
909
+ var useStorage = function(key) {
910
+ var _ref = _sliced_to_array((0, import_react9.useState)(), 2), stateValue = _ref[0], setStateValue = _ref[1];
911
+ var _ref1 = _sliced_to_array((0, import_react9.useState)(true), 2), isLoading = _ref1[0], setIsLoading = _ref1[1];
912
+ var updateValue = (0, import_react9.useCallback)(function(value) {
913
+ setStateValue(value);
914
+ import_react_native.DeviceEventEmitter.emit(key, value);
915
+ return import_framework5.Storage.setItem(key, JSON.stringify({
916
+ value: value
917
+ }));
918
+ }, [
919
+ key
920
+ ]);
921
+ (0, import_react9.useEffect)(function() {
922
+ setIsLoading(true);
923
+ import_framework5.Storage.getItem(key).then(function(item) {
924
+ try {
925
+ setStateValue(item === null ? void 0 : JSON.parse(item).value);
926
+ } catch (e) {
927
+ setStateValue(void 0);
928
+ } finally{
929
+ setIsLoading(false);
930
+ }
931
+ });
932
+ var updateValueListener = import_react_native.DeviceEventEmitter.addListener(key, setStateValue);
933
+ return function() {
934
+ return updateValueListener.remove();
935
+ };
936
+ }, [
937
+ key
938
+ ]);
939
+ return [
940
+ stateValue,
941
+ updateValue,
942
+ isLoading
943
+ ];
501
944
  };
502
945
  // Annotate the CommonJS export names for ESM import in node:
503
946
  0 && (module.exports = {
504
- AdGroupProvider,
505
- AuthStateProvider,
506
- ConfigProvider,
507
- FetcherProvider,
508
- QueryProvider,
509
- bind,
510
- calculateDay,
511
- calculateDayOfWeek,
512
- calculateHour,
513
- calculateMinute,
514
- calculateWeek,
515
- useAdGroup,
516
- useAdvertisement,
517
- useAuthState,
518
- useConfig,
519
- useFetcher,
520
- useSignInWithToss,
521
- useStorage
947
+ AdGroupProvider: AdGroupProvider,
948
+ AuthStateProvider: AuthStateProvider,
949
+ ConfigProvider: ConfigProvider,
950
+ FetcherProvider: FetcherProvider,
951
+ QueryProvider: QueryProvider,
952
+ bind: bind,
953
+ calculateDay: calculateDay,
954
+ calculateDayOfWeek: calculateDayOfWeek,
955
+ calculateHour: calculateHour,
956
+ calculateMinute: calculateMinute,
957
+ calculateWeek: calculateWeek,
958
+ useAdGroup: useAdGroup,
959
+ useAdvertisement: useAdvertisement,
960
+ useAuthState: useAuthState,
961
+ useConfig: useConfig,
962
+ useFetcher: useFetcher,
963
+ useSignInWithToss: useSignInWithToss,
964
+ useStorage: useStorage
522
965
  });