@apps-in-toss/web-bridge 1.9.3 → 1.10.0
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.cjs +177 -87
- package/dist/index.d.cts +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +165 -79
- package/package.json +4 -7
package/dist/index.cjs
CHANGED
|
@@ -28,6 +28,9 @@ __export(index_exports, {
|
|
|
28
28
|
Storage: () => Storage,
|
|
29
29
|
TossAds: () => TossAds,
|
|
30
30
|
appsInTossEvent: () => appsInTossEvent,
|
|
31
|
+
createAsyncBridge: () => createAsyncBridge,
|
|
32
|
+
createConstantBridge: () => createConstantBridge,
|
|
33
|
+
createEventBridge: () => createEventBridge,
|
|
31
34
|
env: () => env,
|
|
32
35
|
fetchAlbumPhotos: () => fetchAlbumPhotos,
|
|
33
36
|
fetchContacts: () => fetchContacts,
|
|
@@ -47,10 +50,124 @@ __export(index_exports, {
|
|
|
47
50
|
tdsEvent: () => tdsEvent
|
|
48
51
|
});
|
|
49
52
|
module.exports = __toCommonJS(index_exports);
|
|
50
|
-
|
|
53
|
+
|
|
54
|
+
// ../bridge-core/dist/index.js
|
|
55
|
+
var NativeWindow = class {
|
|
56
|
+
get _window() {
|
|
57
|
+
if (typeof window !== "undefined") {
|
|
58
|
+
return window;
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
ReactNativeWebView: {
|
|
62
|
+
postMessage: () => {
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
__GRANITE_NATIVE_EMITTER: {
|
|
66
|
+
on: () => () => {
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
__CONSTANT_HANDLER_MAP: {}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
postMessage(message) {
|
|
73
|
+
const webView = this._window.ReactNativeWebView;
|
|
74
|
+
if (!webView) {
|
|
75
|
+
throw new Error("ReactNativeWebView is not available in browser environment");
|
|
76
|
+
}
|
|
77
|
+
webView.postMessage(JSON.stringify(message));
|
|
78
|
+
}
|
|
79
|
+
on(event, callback) {
|
|
80
|
+
const emitter = this._window.__GRANITE_NATIVE_EMITTER;
|
|
81
|
+
if (!emitter) {
|
|
82
|
+
throw new Error("__GRANITE_NATIVE_EMITTER is not available");
|
|
83
|
+
}
|
|
84
|
+
return emitter.on(event, callback);
|
|
85
|
+
}
|
|
86
|
+
getConstant(method) {
|
|
87
|
+
const constantHandlerMap = this._window.__CONSTANT_HANDLER_MAP;
|
|
88
|
+
if (constantHandlerMap && method in constantHandlerMap) {
|
|
89
|
+
return constantHandlerMap[method];
|
|
90
|
+
}
|
|
91
|
+
throw new Error(`${method} is not a constant handler`);
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
var nativeWindow = new NativeWindow();
|
|
95
|
+
var createEventId = () => Math.random().toString(36).substring(2, 15);
|
|
96
|
+
var deserializeError = (value) => {
|
|
97
|
+
if (value && value.__isError) {
|
|
98
|
+
const err = new Error(value.message);
|
|
99
|
+
for (const [key, val] of Object.entries(value)) {
|
|
100
|
+
err[key] = val;
|
|
101
|
+
}
|
|
102
|
+
return err;
|
|
103
|
+
}
|
|
104
|
+
return value;
|
|
105
|
+
};
|
|
106
|
+
function createAsyncBridge(method) {
|
|
107
|
+
return (...args) => {
|
|
108
|
+
const eventId = createEventId();
|
|
109
|
+
const emitters = [];
|
|
110
|
+
const unsubscribe = () => {
|
|
111
|
+
for (const remove of emitters) {
|
|
112
|
+
remove();
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
return new Promise((resolve, reject) => {
|
|
116
|
+
emitters.push(
|
|
117
|
+
nativeWindow.on(`${method}/resolve/${eventId}`, (data) => {
|
|
118
|
+
unsubscribe();
|
|
119
|
+
resolve(data);
|
|
120
|
+
})
|
|
121
|
+
);
|
|
122
|
+
emitters.push(
|
|
123
|
+
nativeWindow.on(`${method}/reject/${eventId}`, (error) => {
|
|
124
|
+
unsubscribe();
|
|
125
|
+
reject(deserializeError(error));
|
|
126
|
+
})
|
|
127
|
+
);
|
|
128
|
+
nativeWindow.postMessage({
|
|
129
|
+
type: "method",
|
|
130
|
+
functionName: method,
|
|
131
|
+
eventId,
|
|
132
|
+
args
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
function createEventBridge(method) {
|
|
138
|
+
return (args) => {
|
|
139
|
+
const eventId = createEventId();
|
|
140
|
+
const removes = [
|
|
141
|
+
nativeWindow.on(`${method}/onEvent/${eventId}`, (data) => {
|
|
142
|
+
args.onEvent(data);
|
|
143
|
+
}),
|
|
144
|
+
nativeWindow.on(`${method}/onError/${eventId}`, (error) => {
|
|
145
|
+
args.onError(deserializeError(error));
|
|
146
|
+
})
|
|
147
|
+
];
|
|
148
|
+
nativeWindow.postMessage({
|
|
149
|
+
type: "addEventListener",
|
|
150
|
+
functionName: method,
|
|
151
|
+
eventId,
|
|
152
|
+
args: args.options
|
|
153
|
+
});
|
|
154
|
+
return () => {
|
|
155
|
+
nativeWindow.postMessage({
|
|
156
|
+
type: "removeEventListener",
|
|
157
|
+
functionName: method,
|
|
158
|
+
eventId
|
|
159
|
+
});
|
|
160
|
+
removes.forEach((remove) => remove());
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
function createConstantBridge(method) {
|
|
165
|
+
return () => {
|
|
166
|
+
return nativeWindow.getConstant(method);
|
|
167
|
+
};
|
|
168
|
+
}
|
|
51
169
|
|
|
52
170
|
// src/storage.ts
|
|
53
|
-
var import_bridge_core = require("@apps-in-toss/bridge-core");
|
|
54
171
|
var Storage = {
|
|
55
172
|
/**
|
|
56
173
|
* @public
|
|
@@ -67,7 +184,7 @@ var Storage = {
|
|
|
67
184
|
* console.log(value); // 'value'
|
|
68
185
|
* ```
|
|
69
186
|
*/
|
|
70
|
-
getItem:
|
|
187
|
+
getItem: createAsyncBridge("getStorageItem"),
|
|
71
188
|
/**
|
|
72
189
|
* @public
|
|
73
190
|
* @category 저장소
|
|
@@ -85,7 +202,7 @@ var Storage = {
|
|
|
85
202
|
* await Storage.setItem('my-key', 'value');
|
|
86
203
|
* ```
|
|
87
204
|
*/
|
|
88
|
-
setItem:
|
|
205
|
+
setItem: createAsyncBridge("setStorageItem"),
|
|
89
206
|
/**
|
|
90
207
|
* @public
|
|
91
208
|
* @category 저장소
|
|
@@ -102,7 +219,7 @@ var Storage = {
|
|
|
102
219
|
* await Storage.removeItem('my-key');
|
|
103
220
|
* ```
|
|
104
221
|
*/
|
|
105
|
-
removeItem:
|
|
222
|
+
removeItem: createAsyncBridge("removeStorageItem"),
|
|
106
223
|
/**
|
|
107
224
|
* @public
|
|
108
225
|
* @category 저장소
|
|
@@ -118,15 +235,9 @@ var Storage = {
|
|
|
118
235
|
* await Storage.clearItems();
|
|
119
236
|
* ```
|
|
120
237
|
*/
|
|
121
|
-
clearItems:
|
|
238
|
+
clearItems: createAsyncBridge("clearItems")
|
|
122
239
|
};
|
|
123
240
|
|
|
124
|
-
// src/iap.ts
|
|
125
|
-
var import_bridge_core3 = require("@apps-in-toss/bridge-core");
|
|
126
|
-
|
|
127
|
-
// src/isMinVersionSupported.ts
|
|
128
|
-
var import_bridge_core2 = require("@apps-in-toss/bridge-core");
|
|
129
|
-
|
|
130
241
|
// src/utils/compareVersion.ts
|
|
131
242
|
var SEMVER_REGEX = /^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\\-]+(?:\.[\da-z\\-]+)*))?(?:\+[\da-z\\-]+(?:\.[\da-z\\-]+)*)?)?)?$/i;
|
|
132
243
|
var isWildcard = (val) => ["*", "x", "X"].includes(val);
|
|
@@ -196,12 +307,12 @@ var compareVersions = (v1, v2) => {
|
|
|
196
307
|
|
|
197
308
|
// src/isMinVersionSupported.ts
|
|
198
309
|
function isMinVersionSupported(minVersions) {
|
|
199
|
-
const operationalEnvironment =
|
|
310
|
+
const operationalEnvironment = createConstantBridge("getOperationalEnvironment")();
|
|
200
311
|
if (operationalEnvironment === "sandbox") {
|
|
201
312
|
return true;
|
|
202
313
|
}
|
|
203
|
-
const currentVersion =
|
|
204
|
-
const isIOS =
|
|
314
|
+
const currentVersion = createConstantBridge("getTossAppVersion")();
|
|
315
|
+
const isIOS = createConstantBridge("getPlatformOS")() === "ios";
|
|
205
316
|
const minVersion = isIOS ? minVersions.ios : minVersions.android;
|
|
206
317
|
if (minVersion === void 0) {
|
|
207
318
|
return false;
|
|
@@ -217,7 +328,7 @@ function isMinVersionSupported(minVersions) {
|
|
|
217
328
|
|
|
218
329
|
// src/iap.ts
|
|
219
330
|
function processProductGrant(params) {
|
|
220
|
-
return
|
|
331
|
+
return createAsyncBridge("processProductGrant")(params);
|
|
221
332
|
}
|
|
222
333
|
var IAP = {
|
|
223
334
|
/**
|
|
@@ -259,7 +370,7 @@ var IAP = {
|
|
|
259
370
|
const sku = options.sku ?? options.productId;
|
|
260
371
|
if (!isProcessProductGrantSupported) {
|
|
261
372
|
const v1 = () => {
|
|
262
|
-
|
|
373
|
+
createAsyncBridge(
|
|
263
374
|
"iapCreateOneTimePurchaseOrder"
|
|
264
375
|
)({
|
|
265
376
|
productId: sku
|
|
@@ -276,7 +387,7 @@ var IAP = {
|
|
|
276
387
|
};
|
|
277
388
|
return v1();
|
|
278
389
|
}
|
|
279
|
-
const unregisterCallbacks =
|
|
390
|
+
const unregisterCallbacks = createEventBridge("requestOneTimePurchase")({
|
|
280
391
|
options: { sku },
|
|
281
392
|
onEvent: async (event) => {
|
|
282
393
|
if (event.type === "purchased") {
|
|
@@ -302,7 +413,7 @@ var IAP = {
|
|
|
302
413
|
* @description 인앱결제로 구매할 수 있는 상품 목록을 가져와요. 상품 목록 화면에 진입할 때 호출해요.
|
|
303
414
|
* @returns {Promise<{ products: IapProductListItem[] } | undefined>} 상품 목록을 포함한 객체를 반환해요. 앱 버전이 최소 지원 버전(안드로이드 5.219.0, iOS 5.219.0)보다 낮으면 `undefined`를 반환해요.
|
|
304
415
|
*/
|
|
305
|
-
getProductItemList:
|
|
416
|
+
getProductItemList: createAsyncBridge("iapGetProductItemList"),
|
|
306
417
|
/**
|
|
307
418
|
* @public
|
|
308
419
|
* @category 인앱결제
|
|
@@ -325,7 +436,7 @@ var IAP = {
|
|
|
325
436
|
* }
|
|
326
437
|
* ```
|
|
327
438
|
*/
|
|
328
|
-
getPendingOrders:
|
|
439
|
+
getPendingOrders: createAsyncBridge(
|
|
329
440
|
"getPendingOrders"
|
|
330
441
|
),
|
|
331
442
|
/**
|
|
@@ -349,7 +460,7 @@ var IAP = {
|
|
|
349
460
|
* }
|
|
350
461
|
* ```
|
|
351
462
|
*/
|
|
352
|
-
getCompletedOrRefundedOrders:
|
|
463
|
+
getCompletedOrRefundedOrders: createAsyncBridge("getCompletedOrRefundedOrders"),
|
|
353
464
|
/**
|
|
354
465
|
* @public
|
|
355
466
|
* @category 인앱결제
|
|
@@ -373,33 +484,30 @@ var IAP = {
|
|
|
373
484
|
* }
|
|
374
485
|
* ```
|
|
375
486
|
*/
|
|
376
|
-
completeProductGrant:
|
|
487
|
+
completeProductGrant: createAsyncBridge("completeProductGrant")
|
|
377
488
|
};
|
|
378
489
|
|
|
379
490
|
// src/getSafeAreaInsets.ts
|
|
380
|
-
var
|
|
381
|
-
var _getSafeAreaInsets = (0, import_bridge_core4.createConstantBridge)("getSafeAreaInsets");
|
|
491
|
+
var _getSafeAreaInsets = createConstantBridge("getSafeAreaInsets");
|
|
382
492
|
function getSafeAreaInsets() {
|
|
383
493
|
return _getSafeAreaInsets();
|
|
384
494
|
}
|
|
385
495
|
|
|
386
496
|
// src/safeAreaInsets.ts
|
|
387
|
-
var import_bridge_core5 = require("@apps-in-toss/bridge-core");
|
|
388
497
|
function subscribeSafeAreaInsets({ onEvent }) {
|
|
389
|
-
return
|
|
498
|
+
return createEventBridge("safeAreaInsetsChange")({
|
|
390
499
|
onEvent,
|
|
391
500
|
onError: () => {
|
|
392
501
|
}
|
|
393
502
|
});
|
|
394
503
|
}
|
|
395
|
-
var _getSafeAreaInsets2 =
|
|
504
|
+
var _getSafeAreaInsets2 = createConstantBridge("getSafeAreaInsets");
|
|
396
505
|
var SafeAreaInsets = {
|
|
397
506
|
get: _getSafeAreaInsets2,
|
|
398
507
|
subscribe: subscribeSafeAreaInsets
|
|
399
508
|
};
|
|
400
509
|
|
|
401
510
|
// src/googleAdMob.ts
|
|
402
|
-
var import_bridge_core6 = require("@apps-in-toss/bridge-core");
|
|
403
511
|
var GoogleAdMob = {
|
|
404
512
|
/**
|
|
405
513
|
* @public
|
|
@@ -455,8 +563,8 @@ var GoogleAdMob = {
|
|
|
455
563
|
* }
|
|
456
564
|
* ```
|
|
457
565
|
*/
|
|
458
|
-
loadAppsInTossAdMob: Object.assign(
|
|
459
|
-
isSupported:
|
|
566
|
+
loadAppsInTossAdMob: Object.assign(createEventBridge("loadAppsInTossAdMob"), {
|
|
567
|
+
isSupported: createConstantBridge("loadAppsInTossAdMob_isSupported")
|
|
460
568
|
}),
|
|
461
569
|
/**
|
|
462
570
|
* @public
|
|
@@ -533,8 +641,8 @@ var GoogleAdMob = {
|
|
|
533
641
|
* }
|
|
534
642
|
* ```
|
|
535
643
|
*/
|
|
536
|
-
showAppsInTossAdMob: Object.assign(
|
|
537
|
-
isSupported:
|
|
644
|
+
showAppsInTossAdMob: Object.assign(createEventBridge("showAppsInTossAdMob"), {
|
|
645
|
+
isSupported: createConstantBridge("showAppsInTossAdMob_isSupported")
|
|
538
646
|
}),
|
|
539
647
|
/**
|
|
540
648
|
* @public
|
|
@@ -545,21 +653,20 @@ var GoogleAdMob = {
|
|
|
545
653
|
* @property {() => boolean} [isSupported] 현재 실행 중인 앱(예: 토스 앱, 개발용 샌드박스 앱 등)에서 `isAppsInTossAdMobLoaded` 를 지원하는지 확인하는 함수예요. 기능을 사용하기 전에 지원 여부를 확인해야 해요.
|
|
546
654
|
*/
|
|
547
655
|
isAppsInTossAdMobLoaded: Object.assign(
|
|
548
|
-
|
|
656
|
+
createAsyncBridge("isAppsInTossAdMobLoaded"),
|
|
549
657
|
{
|
|
550
|
-
isSupported:
|
|
658
|
+
isSupported: createConstantBridge("isAppsInTossAdMobLoaded_isSupported")
|
|
551
659
|
}
|
|
552
660
|
)
|
|
553
661
|
};
|
|
554
662
|
|
|
555
663
|
// src/graniteEvent.ts
|
|
556
|
-
var import_bridge_core7 = require("@apps-in-toss/bridge-core");
|
|
557
664
|
var graniteEvent = {
|
|
558
665
|
addEventListener: (event, {
|
|
559
666
|
onEvent,
|
|
560
667
|
onError,
|
|
561
668
|
options
|
|
562
|
-
}) =>
|
|
669
|
+
}) => createEventBridge(event)({
|
|
563
670
|
onEvent,
|
|
564
671
|
onError: onError ?? (() => {
|
|
565
672
|
}),
|
|
@@ -568,13 +675,12 @@ var graniteEvent = {
|
|
|
568
675
|
};
|
|
569
676
|
|
|
570
677
|
// src/appsInTossEvent.ts
|
|
571
|
-
var import_bridge_core8 = require("@apps-in-toss/bridge-core");
|
|
572
678
|
var appsInTossEvent = {
|
|
573
679
|
addEventListener: (event, {
|
|
574
680
|
onEvent,
|
|
575
681
|
onError,
|
|
576
682
|
options
|
|
577
|
-
}) =>
|
|
683
|
+
}) => createEventBridge(event)({
|
|
578
684
|
onEvent,
|
|
579
685
|
onError: onError ?? (() => {
|
|
580
686
|
}),
|
|
@@ -583,17 +689,15 @@ var appsInTossEvent = {
|
|
|
583
689
|
};
|
|
584
690
|
|
|
585
691
|
// src/env.ts
|
|
586
|
-
var import_bridge_core9 = require("@apps-in-toss/bridge-core");
|
|
587
692
|
var env = {
|
|
588
|
-
getDeploymentId:
|
|
693
|
+
getDeploymentId: createConstantBridge("getDeploymentId")
|
|
589
694
|
};
|
|
590
695
|
|
|
591
696
|
// src/global.ts
|
|
592
|
-
var
|
|
593
|
-
var
|
|
594
|
-
var
|
|
595
|
-
var
|
|
596
|
-
var brandPrimaryColor = (0, import_bridge_core10.createConstantBridge)("brandPrimaryColor");
|
|
697
|
+
var deploymentId = createConstantBridge("deploymentId");
|
|
698
|
+
var brandDisplayName = createConstantBridge("brandDisplayName");
|
|
699
|
+
var brandIcon = createConstantBridge("brandIcon");
|
|
700
|
+
var brandPrimaryColor = createConstantBridge("brandPrimaryColor");
|
|
597
701
|
var getAppsInTossGlobals = () => {
|
|
598
702
|
return {
|
|
599
703
|
deploymentId: deploymentId(),
|
|
@@ -604,7 +708,6 @@ var getAppsInTossGlobals = () => {
|
|
|
604
708
|
};
|
|
605
709
|
|
|
606
710
|
// src/tdsEvent.ts
|
|
607
|
-
var import_bridge_core11 = require("@apps-in-toss/bridge-core");
|
|
608
711
|
var tdsEvent = {
|
|
609
712
|
/**
|
|
610
713
|
* @public
|
|
@@ -634,7 +737,7 @@ var tdsEvent = {
|
|
|
634
737
|
onEvent,
|
|
635
738
|
onError,
|
|
636
739
|
options
|
|
637
|
-
}) =>
|
|
740
|
+
}) => createEventBridge(event)({
|
|
638
741
|
onEvent,
|
|
639
742
|
onError: onError ?? (() => {
|
|
640
743
|
}),
|
|
@@ -643,7 +746,6 @@ var tdsEvent = {
|
|
|
643
746
|
};
|
|
644
747
|
|
|
645
748
|
// src/partner.ts
|
|
646
|
-
var import_bridge_core12 = require("@apps-in-toss/bridge-core");
|
|
647
749
|
var partner = {
|
|
648
750
|
/**
|
|
649
751
|
* @public
|
|
@@ -665,7 +767,7 @@ var partner = {
|
|
|
665
767
|
});
|
|
666
768
|
* ```
|
|
667
769
|
*/
|
|
668
|
-
addAccessoryButton:
|
|
770
|
+
addAccessoryButton: createAsyncBridge("addAccessoryButton"),
|
|
669
771
|
/**
|
|
670
772
|
* @public
|
|
671
773
|
* @category 파트너
|
|
@@ -679,18 +781,16 @@ var partner = {
|
|
|
679
781
|
* partner.removeAccessoryButton();
|
|
680
782
|
* ```
|
|
681
783
|
*/
|
|
682
|
-
removeAccessoryButton:
|
|
784
|
+
removeAccessoryButton: createAsyncBridge("removeAccessoryButton")
|
|
683
785
|
};
|
|
684
786
|
|
|
685
787
|
// src/permissions/fetchAlbumPhotos.ts
|
|
686
|
-
var import_bridge_core14 = require("@apps-in-toss/bridge-core");
|
|
687
788
|
var import_types = require("@apps-in-toss/types");
|
|
688
789
|
|
|
689
790
|
// src/permissions/createPermissionFunction.ts
|
|
690
|
-
var
|
|
691
|
-
var
|
|
692
|
-
var
|
|
693
|
-
var openPermissionDialog = (0, import_bridge_core13.createAsyncBridge)("openPermissionDialog");
|
|
791
|
+
var requestPermission = createAsyncBridge("requestPermission");
|
|
792
|
+
var getPermission = createAsyncBridge("getPermission");
|
|
793
|
+
var openPermissionDialog = createAsyncBridge("openPermissionDialog");
|
|
694
794
|
function createPermissionFunction({
|
|
695
795
|
permission,
|
|
696
796
|
handler,
|
|
@@ -711,7 +811,7 @@ function createPermissionFunction({
|
|
|
711
811
|
// src/permissions/fetchAlbumPhotos.ts
|
|
712
812
|
var fetchAlbumPhotos = createPermissionFunction({
|
|
713
813
|
handler: (options) => {
|
|
714
|
-
return
|
|
814
|
+
return createAsyncBridge("fetchAlbumPhotos")(
|
|
715
815
|
options
|
|
716
816
|
);
|
|
717
817
|
},
|
|
@@ -723,11 +823,10 @@ var fetchAlbumPhotos = createPermissionFunction({
|
|
|
723
823
|
});
|
|
724
824
|
|
|
725
825
|
// src/permissions/fetchContacts.ts
|
|
726
|
-
var import_bridge_core15 = require("@apps-in-toss/bridge-core");
|
|
727
826
|
var import_types2 = require("@apps-in-toss/types");
|
|
728
827
|
var fetchContacts = createPermissionFunction({
|
|
729
828
|
handler: (options) => {
|
|
730
|
-
return
|
|
829
|
+
return createAsyncBridge("fetchContacts")(options);
|
|
731
830
|
},
|
|
732
831
|
permission: {
|
|
733
832
|
name: "contacts",
|
|
@@ -737,11 +836,10 @@ var fetchContacts = createPermissionFunction({
|
|
|
737
836
|
});
|
|
738
837
|
|
|
739
838
|
// src/permissions/getCurrentLocation.ts
|
|
740
|
-
var import_bridge_core16 = require("@apps-in-toss/bridge-core");
|
|
741
839
|
var import_types3 = require("@apps-in-toss/types");
|
|
742
840
|
var getCurrentLocation = createPermissionFunction({
|
|
743
841
|
handler: (options) => {
|
|
744
|
-
return
|
|
842
|
+
return createAsyncBridge(
|
|
745
843
|
"getCurrentLocation"
|
|
746
844
|
)(options);
|
|
747
845
|
},
|
|
@@ -753,11 +851,10 @@ var getCurrentLocation = createPermissionFunction({
|
|
|
753
851
|
});
|
|
754
852
|
|
|
755
853
|
// src/permissions/openCamera.ts
|
|
756
|
-
var import_bridge_core17 = require("@apps-in-toss/bridge-core");
|
|
757
854
|
var import_types4 = require("@apps-in-toss/types");
|
|
758
855
|
var openCamera = createPermissionFunction({
|
|
759
856
|
handler: (options) => {
|
|
760
|
-
return
|
|
857
|
+
return createAsyncBridge("openCamera")(options);
|
|
761
858
|
},
|
|
762
859
|
permission: {
|
|
763
860
|
name: "camera",
|
|
@@ -767,11 +864,10 @@ var openCamera = createPermissionFunction({
|
|
|
767
864
|
});
|
|
768
865
|
|
|
769
866
|
// src/permissions/setClipboardText.ts
|
|
770
|
-
var import_bridge_core18 = require("@apps-in-toss/bridge-core");
|
|
771
867
|
var import_types5 = require("@apps-in-toss/types");
|
|
772
868
|
var setClipboardText = createPermissionFunction({
|
|
773
869
|
handler: (options) => {
|
|
774
|
-
return
|
|
870
|
+
return createAsyncBridge("setClipboardText")(
|
|
775
871
|
options
|
|
776
872
|
);
|
|
777
873
|
},
|
|
@@ -783,11 +879,10 @@ var setClipboardText = createPermissionFunction({
|
|
|
783
879
|
});
|
|
784
880
|
|
|
785
881
|
// src/permissions/getClipboardText.ts
|
|
786
|
-
var import_bridge_core19 = require("@apps-in-toss/bridge-core");
|
|
787
882
|
var import_types6 = require("@apps-in-toss/types");
|
|
788
883
|
var getClipboardText = createPermissionFunction({
|
|
789
884
|
handler: () => {
|
|
790
|
-
return
|
|
885
|
+
return createAsyncBridge("getClipboardText")();
|
|
791
886
|
},
|
|
792
887
|
permission: {
|
|
793
888
|
name: "clipboard",
|
|
@@ -797,12 +892,11 @@ var getClipboardText = createPermissionFunction({
|
|
|
797
892
|
});
|
|
798
893
|
|
|
799
894
|
// src/permissions/startUpdateLocation.ts
|
|
800
|
-
var import_bridge_core20 = require("@apps-in-toss/bridge-core");
|
|
801
895
|
var import_types7 = require("@apps-in-toss/types");
|
|
802
|
-
var getPermission2 =
|
|
803
|
-
var openPermissionDialog2 =
|
|
896
|
+
var getPermission2 = createAsyncBridge("getPermission");
|
|
897
|
+
var openPermissionDialog2 = createAsyncBridge("openPermissionDialog");
|
|
804
898
|
var startUpdateLocation = (params) => {
|
|
805
|
-
return
|
|
899
|
+
return createEventBridge("updateLocationEvent")({
|
|
806
900
|
...params,
|
|
807
901
|
onError: (error) => {
|
|
808
902
|
const locationError = new import_types7.StartUpdateLocationPermissionError();
|
|
@@ -817,26 +911,21 @@ startUpdateLocation.getPermission = () => getPermission2({ name: "geolocation",
|
|
|
817
911
|
startUpdateLocation.openPermissionDialog = () => openPermissionDialog2({ name: "geolocation", access: "access" });
|
|
818
912
|
|
|
819
913
|
// src/integratedAd.ts
|
|
820
|
-
var import_bridge_core21 = require("@apps-in-toss/bridge-core");
|
|
821
914
|
var loadFullScreenAd = Object.assign(
|
|
822
|
-
|
|
915
|
+
createEventBridge("loadFullScreenAd"),
|
|
823
916
|
{
|
|
824
|
-
isSupported:
|
|
917
|
+
isSupported: createConstantBridge("loadFullScreenAd_isSupported")
|
|
825
918
|
}
|
|
826
919
|
);
|
|
827
920
|
var showFullScreenAd = Object.assign(
|
|
828
|
-
|
|
921
|
+
createEventBridge("showFullScreenAd"),
|
|
829
922
|
{
|
|
830
|
-
isSupported:
|
|
923
|
+
isSupported: createConstantBridge("showFullScreenAd_isSupported")
|
|
831
924
|
}
|
|
832
925
|
);
|
|
833
926
|
|
|
834
|
-
// src/toss-ad/index.ts
|
|
835
|
-
var import_bridge_core23 = require("@apps-in-toss/bridge-core");
|
|
836
|
-
|
|
837
927
|
// src/toss-ad/opener.ts
|
|
838
|
-
var
|
|
839
|
-
var openURL = (0, import_bridge_core22.createAsyncBridge)("openURL");
|
|
928
|
+
var openURL = createAsyncBridge("openURL");
|
|
840
929
|
function openUrlOpener(url) {
|
|
841
930
|
const transformed = getWebSchemeOrUri(url);
|
|
842
931
|
return openURL(transformed);
|
|
@@ -907,10 +996,10 @@ function loadAdsSdk() {
|
|
|
907
996
|
}
|
|
908
997
|
|
|
909
998
|
// src/toss-ad/index.ts
|
|
910
|
-
var fetchTossAd = Object.assign(
|
|
911
|
-
isSupported:
|
|
999
|
+
var fetchTossAd = Object.assign(createEventBridge("fetchTossAd"), {
|
|
1000
|
+
isSupported: createConstantBridge("fetchTossAd_isSupported")
|
|
912
1001
|
});
|
|
913
|
-
var tossAdEventLog =
|
|
1002
|
+
var tossAdEventLog = createAsyncBridge("tossAdEventLog");
|
|
914
1003
|
var SUPPORTED_STYLE_IDS = /* @__PURE__ */ new Set(["1", "2"]);
|
|
915
1004
|
function fetchTossAdPromise(options) {
|
|
916
1005
|
return new Promise((resolve, reject) => {
|
|
@@ -1104,9 +1193,8 @@ var TossAds = {
|
|
|
1104
1193
|
};
|
|
1105
1194
|
|
|
1106
1195
|
// src/getServerTime.ts
|
|
1107
|
-
var
|
|
1108
|
-
|
|
1109
|
-
isSupported: (0, import_bridge_core24.createConstantBridge)("getServerTime_isSupported")
|
|
1196
|
+
var getServerTime = Object.assign(createAsyncBridge("getServerTime"), {
|
|
1197
|
+
isSupported: createConstantBridge("getServerTime_isSupported")
|
|
1110
1198
|
});
|
|
1111
1199
|
|
|
1112
1200
|
// src/index.ts
|
|
@@ -1119,6 +1207,9 @@ __reExport(index_exports, require("@apps-in-toss/types"), module.exports);
|
|
|
1119
1207
|
Storage,
|
|
1120
1208
|
TossAds,
|
|
1121
1209
|
appsInTossEvent,
|
|
1210
|
+
createAsyncBridge,
|
|
1211
|
+
createConstantBridge,
|
|
1212
|
+
createEventBridge,
|
|
1122
1213
|
env,
|
|
1123
1214
|
fetchAlbumPhotos,
|
|
1124
1215
|
fetchContacts,
|
|
@@ -1136,6 +1227,5 @@ __reExport(index_exports, require("@apps-in-toss/types"), module.exports);
|
|
|
1136
1227
|
showFullScreenAd,
|
|
1137
1228
|
startUpdateLocation,
|
|
1138
1229
|
tdsEvent,
|
|
1139
|
-
...require("@apps-in-toss/bridge-core"),
|
|
1140
1230
|
...require("@apps-in-toss/types")
|
|
1141
1231
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
export * from './bridge';
|
|
2
2
|
export * from '@apps-in-toss/bridge-core';
|
|
3
|
-
import { LoadAdMobEvent, LoadAdMobOptions, ShowAdMobEvent, ShowAdMobOptions, IsAdMobLoadedOptions, LoadFullScreenAdEvent, LoadFullScreenAdOptions, ShowFullScreenAdEvent, ShowFullScreenAdOptions } from '@apps-in-toss/framework';
|
|
4
3
|
import * as _apps_in_toss_types from '@apps-in-toss/types';
|
|
5
|
-
import { FetchAlbumPhotos, FetchContacts, GetCurrentLocation, OpenCamera, SetClipboardText, GetClipboardText, StartUpdateLocationEventParams } from '@apps-in-toss/types';
|
|
4
|
+
import { LoadAdMobEvent, LoadAdMobOptions, ShowAdMobEvent, ShowAdMobOptions, IsAdMobLoadedOptions, FetchAlbumPhotos, FetchContacts, GetCurrentLocation, OpenCamera, SetClipboardText, GetClipboardText, StartUpdateLocationEventParams, LoadFullScreenAdEvent, LoadFullScreenAdOptions, ShowFullScreenAdEvent, ShowFullScreenAdOptions } from '@apps-in-toss/types';
|
|
6
5
|
export * from '@apps-in-toss/types';
|
|
7
6
|
|
|
8
7
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
export * from './bridge';
|
|
2
2
|
export * from '@apps-in-toss/bridge-core';
|
|
3
|
-
import { LoadAdMobEvent, LoadAdMobOptions, ShowAdMobEvent, ShowAdMobOptions, IsAdMobLoadedOptions, LoadFullScreenAdEvent, LoadFullScreenAdOptions, ShowFullScreenAdEvent, ShowFullScreenAdOptions } from '@apps-in-toss/framework';
|
|
4
3
|
import * as _apps_in_toss_types from '@apps-in-toss/types';
|
|
5
|
-
import { FetchAlbumPhotos, FetchContacts, GetCurrentLocation, OpenCamera, SetClipboardText, GetClipboardText, StartUpdateLocationEventParams } from '@apps-in-toss/types';
|
|
4
|
+
import { LoadAdMobEvent, LoadAdMobOptions, ShowAdMobEvent, ShowAdMobOptions, IsAdMobLoadedOptions, FetchAlbumPhotos, FetchContacts, GetCurrentLocation, OpenCamera, SetClipboardText, GetClipboardText, StartUpdateLocationEventParams, LoadFullScreenAdEvent, LoadFullScreenAdOptions, ShowFullScreenAdEvent, ShowFullScreenAdOptions } from '@apps-in-toss/types';
|
|
6
5
|
export * from '@apps-in-toss/types';
|
|
7
6
|
|
|
8
7
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,122 @@
|
|
|
1
1
|
export * from './bridge.js';
|
|
2
2
|
|
|
3
|
-
//
|
|
4
|
-
|
|
3
|
+
// ../bridge-core/dist/index.js
|
|
4
|
+
var NativeWindow = class {
|
|
5
|
+
get _window() {
|
|
6
|
+
if (typeof window !== "undefined") {
|
|
7
|
+
return window;
|
|
8
|
+
}
|
|
9
|
+
return {
|
|
10
|
+
ReactNativeWebView: {
|
|
11
|
+
postMessage: () => {
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
__GRANITE_NATIVE_EMITTER: {
|
|
15
|
+
on: () => () => {
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
__CONSTANT_HANDLER_MAP: {}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
postMessage(message) {
|
|
22
|
+
const webView = this._window.ReactNativeWebView;
|
|
23
|
+
if (!webView) {
|
|
24
|
+
throw new Error("ReactNativeWebView is not available in browser environment");
|
|
25
|
+
}
|
|
26
|
+
webView.postMessage(JSON.stringify(message));
|
|
27
|
+
}
|
|
28
|
+
on(event, callback) {
|
|
29
|
+
const emitter = this._window.__GRANITE_NATIVE_EMITTER;
|
|
30
|
+
if (!emitter) {
|
|
31
|
+
throw new Error("__GRANITE_NATIVE_EMITTER is not available");
|
|
32
|
+
}
|
|
33
|
+
return emitter.on(event, callback);
|
|
34
|
+
}
|
|
35
|
+
getConstant(method) {
|
|
36
|
+
const constantHandlerMap = this._window.__CONSTANT_HANDLER_MAP;
|
|
37
|
+
if (constantHandlerMap && method in constantHandlerMap) {
|
|
38
|
+
return constantHandlerMap[method];
|
|
39
|
+
}
|
|
40
|
+
throw new Error(`${method} is not a constant handler`);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
var nativeWindow = new NativeWindow();
|
|
44
|
+
var createEventId = () => Math.random().toString(36).substring(2, 15);
|
|
45
|
+
var deserializeError = (value) => {
|
|
46
|
+
if (value && value.__isError) {
|
|
47
|
+
const err = new Error(value.message);
|
|
48
|
+
for (const [key, val] of Object.entries(value)) {
|
|
49
|
+
err[key] = val;
|
|
50
|
+
}
|
|
51
|
+
return err;
|
|
52
|
+
}
|
|
53
|
+
return value;
|
|
54
|
+
};
|
|
55
|
+
function createAsyncBridge(method) {
|
|
56
|
+
return (...args) => {
|
|
57
|
+
const eventId = createEventId();
|
|
58
|
+
const emitters = [];
|
|
59
|
+
const unsubscribe = () => {
|
|
60
|
+
for (const remove of emitters) {
|
|
61
|
+
remove();
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
return new Promise((resolve, reject) => {
|
|
65
|
+
emitters.push(
|
|
66
|
+
nativeWindow.on(`${method}/resolve/${eventId}`, (data) => {
|
|
67
|
+
unsubscribe();
|
|
68
|
+
resolve(data);
|
|
69
|
+
})
|
|
70
|
+
);
|
|
71
|
+
emitters.push(
|
|
72
|
+
nativeWindow.on(`${method}/reject/${eventId}`, (error) => {
|
|
73
|
+
unsubscribe();
|
|
74
|
+
reject(deserializeError(error));
|
|
75
|
+
})
|
|
76
|
+
);
|
|
77
|
+
nativeWindow.postMessage({
|
|
78
|
+
type: "method",
|
|
79
|
+
functionName: method,
|
|
80
|
+
eventId,
|
|
81
|
+
args
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function createEventBridge(method) {
|
|
87
|
+
return (args) => {
|
|
88
|
+
const eventId = createEventId();
|
|
89
|
+
const removes = [
|
|
90
|
+
nativeWindow.on(`${method}/onEvent/${eventId}`, (data) => {
|
|
91
|
+
args.onEvent(data);
|
|
92
|
+
}),
|
|
93
|
+
nativeWindow.on(`${method}/onError/${eventId}`, (error) => {
|
|
94
|
+
args.onError(deserializeError(error));
|
|
95
|
+
})
|
|
96
|
+
];
|
|
97
|
+
nativeWindow.postMessage({
|
|
98
|
+
type: "addEventListener",
|
|
99
|
+
functionName: method,
|
|
100
|
+
eventId,
|
|
101
|
+
args: args.options
|
|
102
|
+
});
|
|
103
|
+
return () => {
|
|
104
|
+
nativeWindow.postMessage({
|
|
105
|
+
type: "removeEventListener",
|
|
106
|
+
functionName: method,
|
|
107
|
+
eventId
|
|
108
|
+
});
|
|
109
|
+
removes.forEach((remove) => remove());
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function createConstantBridge(method) {
|
|
114
|
+
return () => {
|
|
115
|
+
return nativeWindow.getConstant(method);
|
|
116
|
+
};
|
|
117
|
+
}
|
|
5
118
|
|
|
6
119
|
// src/storage.ts
|
|
7
|
-
import { createAsyncBridge } from "@apps-in-toss/bridge-core";
|
|
8
120
|
var Storage = {
|
|
9
121
|
/**
|
|
10
122
|
* @public
|
|
@@ -75,12 +187,6 @@ var Storage = {
|
|
|
75
187
|
clearItems: createAsyncBridge("clearItems")
|
|
76
188
|
};
|
|
77
189
|
|
|
78
|
-
// src/iap.ts
|
|
79
|
-
import { createAsyncBridge as createAsyncBridge2, createEventBridge } from "@apps-in-toss/bridge-core";
|
|
80
|
-
|
|
81
|
-
// src/isMinVersionSupported.ts
|
|
82
|
-
import { createConstantBridge } from "@apps-in-toss/bridge-core";
|
|
83
|
-
|
|
84
190
|
// src/utils/compareVersion.ts
|
|
85
191
|
var SEMVER_REGEX = /^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\\-]+(?:\.[\da-z\\-]+)*))?(?:\+[\da-z\\-]+(?:\.[\da-z\\-]+)*)?)?)?$/i;
|
|
86
192
|
var isWildcard = (val) => ["*", "x", "X"].includes(val);
|
|
@@ -171,7 +277,7 @@ function isMinVersionSupported(minVersions) {
|
|
|
171
277
|
|
|
172
278
|
// src/iap.ts
|
|
173
279
|
function processProductGrant(params) {
|
|
174
|
-
return
|
|
280
|
+
return createAsyncBridge("processProductGrant")(params);
|
|
175
281
|
}
|
|
176
282
|
var IAP = {
|
|
177
283
|
/**
|
|
@@ -213,7 +319,7 @@ var IAP = {
|
|
|
213
319
|
const sku = options.sku ?? options.productId;
|
|
214
320
|
if (!isProcessProductGrantSupported) {
|
|
215
321
|
const v1 = () => {
|
|
216
|
-
|
|
322
|
+
createAsyncBridge(
|
|
217
323
|
"iapCreateOneTimePurchaseOrder"
|
|
218
324
|
)({
|
|
219
325
|
productId: sku
|
|
@@ -256,7 +362,7 @@ var IAP = {
|
|
|
256
362
|
* @description 인앱결제로 구매할 수 있는 상품 목록을 가져와요. 상품 목록 화면에 진입할 때 호출해요.
|
|
257
363
|
* @returns {Promise<{ products: IapProductListItem[] } | undefined>} 상품 목록을 포함한 객체를 반환해요. 앱 버전이 최소 지원 버전(안드로이드 5.219.0, iOS 5.219.0)보다 낮으면 `undefined`를 반환해요.
|
|
258
364
|
*/
|
|
259
|
-
getProductItemList:
|
|
365
|
+
getProductItemList: createAsyncBridge("iapGetProductItemList"),
|
|
260
366
|
/**
|
|
261
367
|
* @public
|
|
262
368
|
* @category 인앱결제
|
|
@@ -279,7 +385,7 @@ var IAP = {
|
|
|
279
385
|
* }
|
|
280
386
|
* ```
|
|
281
387
|
*/
|
|
282
|
-
getPendingOrders:
|
|
388
|
+
getPendingOrders: createAsyncBridge(
|
|
283
389
|
"getPendingOrders"
|
|
284
390
|
),
|
|
285
391
|
/**
|
|
@@ -303,7 +409,7 @@ var IAP = {
|
|
|
303
409
|
* }
|
|
304
410
|
* ```
|
|
305
411
|
*/
|
|
306
|
-
getCompletedOrRefundedOrders:
|
|
412
|
+
getCompletedOrRefundedOrders: createAsyncBridge("getCompletedOrRefundedOrders"),
|
|
307
413
|
/**
|
|
308
414
|
* @public
|
|
309
415
|
* @category 인앱결제
|
|
@@ -327,33 +433,30 @@ var IAP = {
|
|
|
327
433
|
* }
|
|
328
434
|
* ```
|
|
329
435
|
*/
|
|
330
|
-
completeProductGrant:
|
|
436
|
+
completeProductGrant: createAsyncBridge("completeProductGrant")
|
|
331
437
|
};
|
|
332
438
|
|
|
333
439
|
// src/getSafeAreaInsets.ts
|
|
334
|
-
|
|
335
|
-
var _getSafeAreaInsets = createConstantBridge2("getSafeAreaInsets");
|
|
440
|
+
var _getSafeAreaInsets = createConstantBridge("getSafeAreaInsets");
|
|
336
441
|
function getSafeAreaInsets() {
|
|
337
442
|
return _getSafeAreaInsets();
|
|
338
443
|
}
|
|
339
444
|
|
|
340
445
|
// src/safeAreaInsets.ts
|
|
341
|
-
import { createEventBridge as createEventBridge2, createConstantBridge as createConstantBridge3 } from "@apps-in-toss/bridge-core";
|
|
342
446
|
function subscribeSafeAreaInsets({ onEvent }) {
|
|
343
|
-
return
|
|
447
|
+
return createEventBridge("safeAreaInsetsChange")({
|
|
344
448
|
onEvent,
|
|
345
449
|
onError: () => {
|
|
346
450
|
}
|
|
347
451
|
});
|
|
348
452
|
}
|
|
349
|
-
var _getSafeAreaInsets2 =
|
|
453
|
+
var _getSafeAreaInsets2 = createConstantBridge("getSafeAreaInsets");
|
|
350
454
|
var SafeAreaInsets = {
|
|
351
455
|
get: _getSafeAreaInsets2,
|
|
352
456
|
subscribe: subscribeSafeAreaInsets
|
|
353
457
|
};
|
|
354
458
|
|
|
355
459
|
// src/googleAdMob.ts
|
|
356
|
-
import { createAsyncBridge as createAsyncBridge3, createConstantBridge as createConstantBridge4, createEventBridge as createEventBridge3 } from "@apps-in-toss/bridge-core";
|
|
357
460
|
var GoogleAdMob = {
|
|
358
461
|
/**
|
|
359
462
|
* @public
|
|
@@ -409,8 +512,8 @@ var GoogleAdMob = {
|
|
|
409
512
|
* }
|
|
410
513
|
* ```
|
|
411
514
|
*/
|
|
412
|
-
loadAppsInTossAdMob: Object.assign(
|
|
413
|
-
isSupported:
|
|
515
|
+
loadAppsInTossAdMob: Object.assign(createEventBridge("loadAppsInTossAdMob"), {
|
|
516
|
+
isSupported: createConstantBridge("loadAppsInTossAdMob_isSupported")
|
|
414
517
|
}),
|
|
415
518
|
/**
|
|
416
519
|
* @public
|
|
@@ -487,8 +590,8 @@ var GoogleAdMob = {
|
|
|
487
590
|
* }
|
|
488
591
|
* ```
|
|
489
592
|
*/
|
|
490
|
-
showAppsInTossAdMob: Object.assign(
|
|
491
|
-
isSupported:
|
|
593
|
+
showAppsInTossAdMob: Object.assign(createEventBridge("showAppsInTossAdMob"), {
|
|
594
|
+
isSupported: createConstantBridge("showAppsInTossAdMob_isSupported")
|
|
492
595
|
}),
|
|
493
596
|
/**
|
|
494
597
|
* @public
|
|
@@ -499,21 +602,20 @@ var GoogleAdMob = {
|
|
|
499
602
|
* @property {() => boolean} [isSupported] 현재 실행 중인 앱(예: 토스 앱, 개발용 샌드박스 앱 등)에서 `isAppsInTossAdMobLoaded` 를 지원하는지 확인하는 함수예요. 기능을 사용하기 전에 지원 여부를 확인해야 해요.
|
|
500
603
|
*/
|
|
501
604
|
isAppsInTossAdMobLoaded: Object.assign(
|
|
502
|
-
|
|
605
|
+
createAsyncBridge("isAppsInTossAdMobLoaded"),
|
|
503
606
|
{
|
|
504
|
-
isSupported:
|
|
607
|
+
isSupported: createConstantBridge("isAppsInTossAdMobLoaded_isSupported")
|
|
505
608
|
}
|
|
506
609
|
)
|
|
507
610
|
};
|
|
508
611
|
|
|
509
612
|
// src/graniteEvent.ts
|
|
510
|
-
import { createEventBridge as createEventBridge4 } from "@apps-in-toss/bridge-core";
|
|
511
613
|
var graniteEvent = {
|
|
512
614
|
addEventListener: (event, {
|
|
513
615
|
onEvent,
|
|
514
616
|
onError,
|
|
515
617
|
options
|
|
516
|
-
}) =>
|
|
618
|
+
}) => createEventBridge(event)({
|
|
517
619
|
onEvent,
|
|
518
620
|
onError: onError ?? (() => {
|
|
519
621
|
}),
|
|
@@ -522,13 +624,12 @@ var graniteEvent = {
|
|
|
522
624
|
};
|
|
523
625
|
|
|
524
626
|
// src/appsInTossEvent.ts
|
|
525
|
-
import { createEventBridge as createEventBridge5 } from "@apps-in-toss/bridge-core";
|
|
526
627
|
var appsInTossEvent = {
|
|
527
628
|
addEventListener: (event, {
|
|
528
629
|
onEvent,
|
|
529
630
|
onError,
|
|
530
631
|
options
|
|
531
|
-
}) =>
|
|
632
|
+
}) => createEventBridge(event)({
|
|
532
633
|
onEvent,
|
|
533
634
|
onError: onError ?? (() => {
|
|
534
635
|
}),
|
|
@@ -537,17 +638,15 @@ var appsInTossEvent = {
|
|
|
537
638
|
};
|
|
538
639
|
|
|
539
640
|
// src/env.ts
|
|
540
|
-
import { createConstantBridge as createConstantBridge5 } from "@apps-in-toss/bridge-core";
|
|
541
641
|
var env = {
|
|
542
|
-
getDeploymentId:
|
|
642
|
+
getDeploymentId: createConstantBridge("getDeploymentId")
|
|
543
643
|
};
|
|
544
644
|
|
|
545
645
|
// src/global.ts
|
|
546
|
-
|
|
547
|
-
var
|
|
548
|
-
var
|
|
549
|
-
var
|
|
550
|
-
var brandPrimaryColor = createConstantBridge6("brandPrimaryColor");
|
|
646
|
+
var deploymentId = createConstantBridge("deploymentId");
|
|
647
|
+
var brandDisplayName = createConstantBridge("brandDisplayName");
|
|
648
|
+
var brandIcon = createConstantBridge("brandIcon");
|
|
649
|
+
var brandPrimaryColor = createConstantBridge("brandPrimaryColor");
|
|
551
650
|
var getAppsInTossGlobals = () => {
|
|
552
651
|
return {
|
|
553
652
|
deploymentId: deploymentId(),
|
|
@@ -558,7 +657,6 @@ var getAppsInTossGlobals = () => {
|
|
|
558
657
|
};
|
|
559
658
|
|
|
560
659
|
// src/tdsEvent.ts
|
|
561
|
-
import { createEventBridge as createEventBridge6 } from "@apps-in-toss/bridge-core";
|
|
562
660
|
var tdsEvent = {
|
|
563
661
|
/**
|
|
564
662
|
* @public
|
|
@@ -588,7 +686,7 @@ var tdsEvent = {
|
|
|
588
686
|
onEvent,
|
|
589
687
|
onError,
|
|
590
688
|
options
|
|
591
|
-
}) =>
|
|
689
|
+
}) => createEventBridge(event)({
|
|
592
690
|
onEvent,
|
|
593
691
|
onError: onError ?? (() => {
|
|
594
692
|
}),
|
|
@@ -597,7 +695,6 @@ var tdsEvent = {
|
|
|
597
695
|
};
|
|
598
696
|
|
|
599
697
|
// src/partner.ts
|
|
600
|
-
import { createAsyncBridge as createAsyncBridge4 } from "@apps-in-toss/bridge-core";
|
|
601
698
|
var partner = {
|
|
602
699
|
/**
|
|
603
700
|
* @public
|
|
@@ -619,7 +716,7 @@ var partner = {
|
|
|
619
716
|
});
|
|
620
717
|
* ```
|
|
621
718
|
*/
|
|
622
|
-
addAccessoryButton:
|
|
719
|
+
addAccessoryButton: createAsyncBridge("addAccessoryButton"),
|
|
623
720
|
/**
|
|
624
721
|
* @public
|
|
625
722
|
* @category 파트너
|
|
@@ -633,18 +730,16 @@ var partner = {
|
|
|
633
730
|
* partner.removeAccessoryButton();
|
|
634
731
|
* ```
|
|
635
732
|
*/
|
|
636
|
-
removeAccessoryButton:
|
|
733
|
+
removeAccessoryButton: createAsyncBridge("removeAccessoryButton")
|
|
637
734
|
};
|
|
638
735
|
|
|
639
736
|
// src/permissions/fetchAlbumPhotos.ts
|
|
640
|
-
import { createAsyncBridge as createAsyncBridge6 } from "@apps-in-toss/bridge-core";
|
|
641
737
|
import { FetchAlbumPhotosPermissionError } from "@apps-in-toss/types";
|
|
642
738
|
|
|
643
739
|
// src/permissions/createPermissionFunction.ts
|
|
644
|
-
|
|
645
|
-
var
|
|
646
|
-
var
|
|
647
|
-
var openPermissionDialog = createAsyncBridge5("openPermissionDialog");
|
|
740
|
+
var requestPermission = createAsyncBridge("requestPermission");
|
|
741
|
+
var getPermission = createAsyncBridge("getPermission");
|
|
742
|
+
var openPermissionDialog = createAsyncBridge("openPermissionDialog");
|
|
648
743
|
function createPermissionFunction({
|
|
649
744
|
permission,
|
|
650
745
|
handler,
|
|
@@ -665,7 +760,7 @@ function createPermissionFunction({
|
|
|
665
760
|
// src/permissions/fetchAlbumPhotos.ts
|
|
666
761
|
var fetchAlbumPhotos = createPermissionFunction({
|
|
667
762
|
handler: (options) => {
|
|
668
|
-
return
|
|
763
|
+
return createAsyncBridge("fetchAlbumPhotos")(
|
|
669
764
|
options
|
|
670
765
|
);
|
|
671
766
|
},
|
|
@@ -677,11 +772,10 @@ var fetchAlbumPhotos = createPermissionFunction({
|
|
|
677
772
|
});
|
|
678
773
|
|
|
679
774
|
// src/permissions/fetchContacts.ts
|
|
680
|
-
import { createAsyncBridge as createAsyncBridge7 } from "@apps-in-toss/bridge-core";
|
|
681
775
|
import { FetchContactsPermissionError } from "@apps-in-toss/types";
|
|
682
776
|
var fetchContacts = createPermissionFunction({
|
|
683
777
|
handler: (options) => {
|
|
684
|
-
return
|
|
778
|
+
return createAsyncBridge("fetchContacts")(options);
|
|
685
779
|
},
|
|
686
780
|
permission: {
|
|
687
781
|
name: "contacts",
|
|
@@ -691,13 +785,12 @@ var fetchContacts = createPermissionFunction({
|
|
|
691
785
|
});
|
|
692
786
|
|
|
693
787
|
// src/permissions/getCurrentLocation.ts
|
|
694
|
-
import { createAsyncBridge as createAsyncBridge8 } from "@apps-in-toss/bridge-core";
|
|
695
788
|
import {
|
|
696
789
|
GetCurrentLocationPermissionError
|
|
697
790
|
} from "@apps-in-toss/types";
|
|
698
791
|
var getCurrentLocation = createPermissionFunction({
|
|
699
792
|
handler: (options) => {
|
|
700
|
-
return
|
|
793
|
+
return createAsyncBridge(
|
|
701
794
|
"getCurrentLocation"
|
|
702
795
|
)(options);
|
|
703
796
|
},
|
|
@@ -709,11 +802,10 @@ var getCurrentLocation = createPermissionFunction({
|
|
|
709
802
|
});
|
|
710
803
|
|
|
711
804
|
// src/permissions/openCamera.ts
|
|
712
|
-
import { createAsyncBridge as createAsyncBridge9 } from "@apps-in-toss/bridge-core";
|
|
713
805
|
import { OpenCameraPermissionError } from "@apps-in-toss/types";
|
|
714
806
|
var openCamera = createPermissionFunction({
|
|
715
807
|
handler: (options) => {
|
|
716
|
-
return
|
|
808
|
+
return createAsyncBridge("openCamera")(options);
|
|
717
809
|
},
|
|
718
810
|
permission: {
|
|
719
811
|
name: "camera",
|
|
@@ -723,11 +815,10 @@ var openCamera = createPermissionFunction({
|
|
|
723
815
|
});
|
|
724
816
|
|
|
725
817
|
// src/permissions/setClipboardText.ts
|
|
726
|
-
import { createAsyncBridge as createAsyncBridge10 } from "@apps-in-toss/bridge-core";
|
|
727
818
|
import { SetClipboardTextPermissionError } from "@apps-in-toss/types";
|
|
728
819
|
var setClipboardText = createPermissionFunction({
|
|
729
820
|
handler: (options) => {
|
|
730
|
-
return
|
|
821
|
+
return createAsyncBridge("setClipboardText")(
|
|
731
822
|
options
|
|
732
823
|
);
|
|
733
824
|
},
|
|
@@ -739,11 +830,10 @@ var setClipboardText = createPermissionFunction({
|
|
|
739
830
|
});
|
|
740
831
|
|
|
741
832
|
// src/permissions/getClipboardText.ts
|
|
742
|
-
import { createAsyncBridge as createAsyncBridge11 } from "@apps-in-toss/bridge-core";
|
|
743
833
|
import { GetClipboardTextPermissionError } from "@apps-in-toss/types";
|
|
744
834
|
var getClipboardText = createPermissionFunction({
|
|
745
835
|
handler: () => {
|
|
746
|
-
return
|
|
836
|
+
return createAsyncBridge("getClipboardText")();
|
|
747
837
|
},
|
|
748
838
|
permission: {
|
|
749
839
|
name: "clipboard",
|
|
@@ -753,14 +843,13 @@ var getClipboardText = createPermissionFunction({
|
|
|
753
843
|
});
|
|
754
844
|
|
|
755
845
|
// src/permissions/startUpdateLocation.ts
|
|
756
|
-
import { createAsyncBridge as createAsyncBridge12, createEventBridge as createEventBridge7 } from "@apps-in-toss/bridge-core";
|
|
757
846
|
import {
|
|
758
847
|
StartUpdateLocationPermissionError
|
|
759
848
|
} from "@apps-in-toss/types";
|
|
760
|
-
var getPermission2 =
|
|
761
|
-
var openPermissionDialog2 =
|
|
849
|
+
var getPermission2 = createAsyncBridge("getPermission");
|
|
850
|
+
var openPermissionDialog2 = createAsyncBridge("openPermissionDialog");
|
|
762
851
|
var startUpdateLocation = (params) => {
|
|
763
|
-
return
|
|
852
|
+
return createEventBridge("updateLocationEvent")({
|
|
764
853
|
...params,
|
|
765
854
|
onError: (error) => {
|
|
766
855
|
const locationError = new StartUpdateLocationPermissionError();
|
|
@@ -775,26 +864,21 @@ startUpdateLocation.getPermission = () => getPermission2({ name: "geolocation",
|
|
|
775
864
|
startUpdateLocation.openPermissionDialog = () => openPermissionDialog2({ name: "geolocation", access: "access" });
|
|
776
865
|
|
|
777
866
|
// src/integratedAd.ts
|
|
778
|
-
import { createConstantBridge as createConstantBridge7, createEventBridge as createEventBridge8 } from "@apps-in-toss/bridge-core";
|
|
779
867
|
var loadFullScreenAd = Object.assign(
|
|
780
|
-
|
|
868
|
+
createEventBridge("loadFullScreenAd"),
|
|
781
869
|
{
|
|
782
|
-
isSupported:
|
|
870
|
+
isSupported: createConstantBridge("loadFullScreenAd_isSupported")
|
|
783
871
|
}
|
|
784
872
|
);
|
|
785
873
|
var showFullScreenAd = Object.assign(
|
|
786
|
-
|
|
874
|
+
createEventBridge("showFullScreenAd"),
|
|
787
875
|
{
|
|
788
|
-
isSupported:
|
|
876
|
+
isSupported: createConstantBridge("showFullScreenAd_isSupported")
|
|
789
877
|
}
|
|
790
878
|
);
|
|
791
879
|
|
|
792
|
-
// src/toss-ad/index.ts
|
|
793
|
-
import { createAsyncBridge as createAsyncBridge14, createConstantBridge as createConstantBridge8, createEventBridge as createEventBridge9 } from "@apps-in-toss/bridge-core";
|
|
794
|
-
|
|
795
880
|
// src/toss-ad/opener.ts
|
|
796
|
-
|
|
797
|
-
var openURL = createAsyncBridge13("openURL");
|
|
881
|
+
var openURL = createAsyncBridge("openURL");
|
|
798
882
|
function openUrlOpener(url) {
|
|
799
883
|
const transformed = getWebSchemeOrUri(url);
|
|
800
884
|
return openURL(transformed);
|
|
@@ -865,10 +949,10 @@ function loadAdsSdk() {
|
|
|
865
949
|
}
|
|
866
950
|
|
|
867
951
|
// src/toss-ad/index.ts
|
|
868
|
-
var fetchTossAd = Object.assign(
|
|
869
|
-
isSupported:
|
|
952
|
+
var fetchTossAd = Object.assign(createEventBridge("fetchTossAd"), {
|
|
953
|
+
isSupported: createConstantBridge("fetchTossAd_isSupported")
|
|
870
954
|
});
|
|
871
|
-
var tossAdEventLog =
|
|
955
|
+
var tossAdEventLog = createAsyncBridge("tossAdEventLog");
|
|
872
956
|
var SUPPORTED_STYLE_IDS = /* @__PURE__ */ new Set(["1", "2"]);
|
|
873
957
|
function fetchTossAdPromise(options) {
|
|
874
958
|
return new Promise((resolve, reject) => {
|
|
@@ -1062,9 +1146,8 @@ var TossAds = {
|
|
|
1062
1146
|
};
|
|
1063
1147
|
|
|
1064
1148
|
// src/getServerTime.ts
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
isSupported: createConstantBridge9("getServerTime_isSupported")
|
|
1149
|
+
var getServerTime = Object.assign(createAsyncBridge("getServerTime"), {
|
|
1150
|
+
isSupported: createConstantBridge("getServerTime_isSupported")
|
|
1068
1151
|
});
|
|
1069
1152
|
|
|
1070
1153
|
// src/index.ts
|
|
@@ -1076,6 +1159,9 @@ export {
|
|
|
1076
1159
|
Storage,
|
|
1077
1160
|
TossAds,
|
|
1078
1161
|
appsInTossEvent,
|
|
1162
|
+
createAsyncBridge,
|
|
1163
|
+
createConstantBridge,
|
|
1164
|
+
createEventBridge,
|
|
1079
1165
|
env,
|
|
1080
1166
|
fetchAlbumPhotos,
|
|
1081
1167
|
fetchContacts,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apps-in-toss/web-bridge",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.10.0",
|
|
5
5
|
"description": "Web Bridge for Apps In Toss",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"typecheck": "tsc --noEmit",
|
|
@@ -27,19 +27,16 @@
|
|
|
27
27
|
"dist"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@apps-in-toss/types": "1.
|
|
30
|
+
"@apps-in-toss/types": "1.10.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@apps-in-toss/bridge-core": "1.
|
|
34
|
-
"@apps-in-toss/
|
|
33
|
+
"@apps-in-toss/bridge-core": "1.10.0",
|
|
34
|
+
"@apps-in-toss/native-modules": "^1.10.0",
|
|
35
35
|
"@swc/core": "^1.12.7",
|
|
36
36
|
"picocolors": "^1.1.1",
|
|
37
37
|
"ts-morph": "^26.0.0",
|
|
38
38
|
"tsup": "^8.5.0",
|
|
39
39
|
"typescript": "4.9.5",
|
|
40
40
|
"vitest": "^3.1.2"
|
|
41
|
-
},
|
|
42
|
-
"peerDependencies": {
|
|
43
|
-
"@apps-in-toss/bridge-core": "*"
|
|
44
41
|
}
|
|
45
42
|
}
|